Don't Starve Revision History Viewer

Comparing Six Feet Under (Rev 86935) to All's Well That Maxwell (Rev 88237)

map/network.lua

320321322323324325326327
--print(self.id.."::AddEdgeByNode: Edge ",id,"added") table.insert(self.nodes[node1.id].edges, edge) table.insert(self.nodes[node2.id].edges, edge) --self.nodes[node2.id].edges[id] = self.edges[id] assert(self.nodes[node1.id])
320321322323324325326327328
--print(self.id.."::AddEdgeByNode: Edge ",id,"added") -- The Edge constructor adds itself to its nodes, this isn't necessary (I hope) --table.insert(self.nodes[node1.id].edges, edge) --table.insert(self.nodes[node2.id].edges, edge) --self.nodes[node2.id].edges[id] = self.edges[id] assert(self.nodes[node1.id])
552553554555556557
end end function Graph:RemoveNode(id) assert(id) assert(self.nodes[id])
553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
end end function Graph:MakeLoop() -- This assumes the graph is linear, and connects one end with the other local first = nil local last = nil for nodeid,node in pairs(self.nodes) do --print(self.id, nodeid, #node.edges) if #node.edges == 1 then if not first then first = node else last = node break end end end if not first or not last then print("Warning: Tried to make "..self.id.." into a loop but couldn't find end nodes.") return end if first.data.entrance then if first.edges[1].node1 == first then first = first.edges[1].node2 else first = first.edges[1].node1 end end if last.data.entrance then if last.edges[1].node1 == last then last = last.edges[1].node2 else last = last.edges[1].node1 end end self:AddEdge({node1id=first.id, node2id=last.id}) end function Graph:RemoveNode(id) assert(id) assert(self.nodes[id])
693694695696697698699700701702703
local nextNode = nil for edgeId,edge in pairs(task:GetEdges(false)) do --print("internal edge",edge.node1.id, edge.node2.id) if edge.node1.id == node.id then --print("\tlink!!") assert(nextNode == nil, "We already have a node from this task!") nextNode = edge.node2 elseif edge.node2.id == node.id then --print("\tlink!!") assert(nextNode == nil, "We already have a node from this task!") nextNode = edge.node1
733734735736737738739740741742743
local nextNode = nil for edgeId,edge in pairs(task:GetEdges(false)) do --print("internal edge",edge.node1.id, edge.node2.id) if edge.node1.id == node.id and not edge.node2.data.blocker_blank then --print("\tlink!!") assert(nextNode == nil, "We already have a node from this task!") nextNode = edge.node2 elseif edge.node2.id == node.id and not edge.node1.data.blocker_blank then --print("\tlink!!") assert(nextNode == nil, "We already have a node from this task!") nextNode = edge.node1