Initial commit: base-road-network copy
This commit is contained in:
25
src/infrastructure/road.odin
Normal file
25
src/infrastructure/road.odin
Normal file
@@ -0,0 +1,25 @@
|
||||
package infrastructure
|
||||
|
||||
Road :: struct {
|
||||
// Index to nodes that limit the road
|
||||
nodes: [2]u32,
|
||||
}
|
||||
|
||||
// Road Initialisation
|
||||
road_init :: proc(start: u32, end: u32) -> Road {
|
||||
return {
|
||||
nodes = {start, end}
|
||||
}
|
||||
}
|
||||
|
||||
// Updates existing node reference to a new one; returns false if old ref was not found
|
||||
road_update_node_reference :: proc(self: ^Road, old_ref: u32, new_ref: u32) -> bool {
|
||||
for &node in self.nodes {
|
||||
if node != old_ref do continue
|
||||
|
||||
node = new_ref
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user