Core: Brought back named loads which are a bit counter intuitive
This commit is contained in:
@@ -19,10 +19,6 @@ thing := 1
|
|||||||
|
|
||||||
:goto_block: for
|
:goto_block: for
|
||||||
|
|
||||||
@language_todo: Bring back named loads
|
|
||||||
A :: #load "array.core"
|
|
||||||
|
|
||||||
|
|
||||||
@reproduction:
|
@reproduction:
|
||||||
This kills the compiler due to referencing slice data
|
This kills the compiler due to referencing slice data
|
||||||
|
|
||||||
@@ -68,7 +64,7 @@ Add(&guys, {100, 100})
|
|||||||
// Error! Couldn't infer type of compound expression
|
// Error! Couldn't infer type of compound expression
|
||||||
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = {x,y}
|
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = {x,y}
|
||||||
// Error! Couldn't infer type of compound expression
|
// Error! Couldn't infer type of compound expression
|
||||||
// if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ;; MAP_CurrentMap.actors.data[0].p = {x,y}
|
// if Mode == 1 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ;; MAP.CurrentMAP.actors.data[0].p = {x,y}
|
||||||
|
|
||||||
// @compiler_todo: It's possible to have 2 definitions with same name. 1 global, 1 local
|
// @compiler_todo: It's possible to have 2 definitions with same name. 1 global, 1 local
|
||||||
// Mode := 0
|
// Mode := 0
|
||||||
@@ -77,7 +73,7 @@ Add(&guys, {100, 100})
|
|||||||
|
|
||||||
#import "raylib.core"
|
#import "raylib.core"
|
||||||
#load "array.core"
|
#load "array.core"
|
||||||
#load "map.core"
|
MAP :: #load "map.core"
|
||||||
|
|
||||||
sqrtf :: #foreign (value: F32): F32
|
sqrtf :: #foreign (value: F32): F32
|
||||||
|
|
||||||
@@ -104,10 +100,10 @@ ANI_SetTiles: Array(ANI_SetTile)
|
|||||||
MouseSelecting := false
|
MouseSelecting := false
|
||||||
MouseSelectionPivot: Vector2
|
MouseSelectionPivot: Vector2
|
||||||
MouseSelectionBox: Rectangle
|
MouseSelectionBox: Rectangle
|
||||||
MouseSelectedActors: Array(*MAP_Actor) // @todo: ids
|
MouseSelectedActors: Array(*MAP.Actor) // @todo: ids
|
||||||
|
|
||||||
main :: (): int
|
main :: (): int
|
||||||
MAP_Init()
|
MAP.Init()
|
||||||
|
|
||||||
// InitAudioDevice()
|
// InitAudioDevice()
|
||||||
// sound := LoadSound("catune - Pass the town, and to the C.mp3")
|
// sound := LoadSound("catune - Pass the town, and to the C.mp3")
|
||||||
@@ -140,7 +136,7 @@ main :: (): int
|
|||||||
MouseY = GetMouseY()
|
MouseY = GetMouseY()
|
||||||
MouseP = GetMousePosition()
|
MouseP = GetMousePosition()
|
||||||
Dt = GetFrameTime()
|
Dt = GetFrameTime()
|
||||||
map := &MAP_CurrentMap
|
map := &MAP.CurrentMap
|
||||||
|
|
||||||
MouseSelecting = false
|
MouseSelecting = false
|
||||||
if IsMouseButtonDown(MOUSE_BUTTON_LEFT)
|
if IsMouseButtonDown(MOUSE_BUTTON_LEFT)
|
||||||
@@ -170,11 +166,11 @@ main :: (): int
|
|||||||
if IsKeyPressed(KEY_F3)
|
if IsKeyPressed(KEY_F3)
|
||||||
for i := 0, i < map.actors.len, i += 1
|
for i := 0, i < map.actors.len, i += 1
|
||||||
it := map.actors.data + i
|
it := map.actors.data + i
|
||||||
MAP_MoveTowardsTarget(it)
|
MAP.MoveTowardsTarget(it)
|
||||||
MAP_PathFindUpdate(map)
|
MAP.PathFindUpdate(map)
|
||||||
|
|
||||||
if IsKeyPressed(KEY_F4)
|
if IsKeyPressed(KEY_F4)
|
||||||
MAP_RandomizeActors()
|
MAP.RandomizeActors()
|
||||||
|
|
||||||
|
|
||||||
BeginDrawing()
|
BeginDrawing()
|
||||||
@@ -227,8 +223,8 @@ main :: (): int
|
|||||||
|
|
||||||
if tile_it.t > 1
|
if tile_it.t > 1
|
||||||
map_tile := map.data + (tile_it.p.x + tile_it.p.y*map.x)
|
map_tile := map.data + (tile_it.p.x + tile_it.p.y*map.x)
|
||||||
if tile_it.set ;; *map_tile |= MAP_TILE_BLOCKER
|
if tile_it.set ;; *map_tile |= MAP.TILE_BLOCKER
|
||||||
else ;; *map_tile &= ~MAP_TILE_BLOCKER
|
else ;; *map_tile &= ~MAP.TILE_BLOCKER
|
||||||
remove = true
|
remove = true
|
||||||
|
|
||||||
tile_it.t += Dt*8
|
tile_it.t += Dt*8
|
||||||
@@ -238,36 +234,36 @@ main :: (): int
|
|||||||
|
|
||||||
for i := 0, i < map.actors.len, i += 1
|
for i := 0, i < map.actors.len, i += 1
|
||||||
actor_it := map.actors.data + i
|
actor_it := map.actors.data + i
|
||||||
target_r := MAP_Rectangle(actor_it.target_p)
|
target_r := MAP.Rect(actor_it.target_p)
|
||||||
|
|
||||||
main_p := MAP_Circle(actor_it.p)
|
main_p := MAP.Circle(actor_it.p)
|
||||||
DrawCircleV(main_p, RectX/2, actor_color)
|
DrawCircleV(main_p, RectX/2, actor_color)
|
||||||
DrawRectangleRec(target_r, target_color)
|
DrawRectangleRec(target_r, target_color)
|
||||||
|
|
||||||
smaller_the_further: F32 = 0
|
smaller_the_further: F32 = 0
|
||||||
for tile_i := actor_it.tiles_visited.len - 1, tile_i >= 0, tile_i -= 1
|
for tile_i := actor_it.tiles_visited.len - 1, tile_i >= 0, tile_i -= 1
|
||||||
tile_it := actor_it.tiles_visited.data + tile_i
|
tile_it := actor_it.tiles_visited.data + tile_i
|
||||||
p := MAP_Circle({tile_it.x, tile_it.y})
|
p := MAP.Circle({tile_it.x, tile_it.y})
|
||||||
DrawCircleV(p, RectX/2 - smaller_the_further, past_actor_color)
|
DrawCircleV(p, RectX/2 - smaller_the_further, past_actor_color)
|
||||||
smaller_the_further += 0.5
|
smaller_the_further += 0.5
|
||||||
|
|
||||||
for path_i := 0, path_i < actor_it.open_paths.len, path_i += 1
|
for path_i := 0, path_i < actor_it.open_paths.len, path_i += 1
|
||||||
path_it := actor_it.open_paths.data + path_i
|
path_it := actor_it.open_paths.data + path_i
|
||||||
path_r := MAP_Rectangle(path_it.p)
|
path_r := MAP.Rect(path_it.p)
|
||||||
DrawRectangleRec(path_r, orange)
|
DrawRectangleRec(path_r, orange)
|
||||||
s := TextFormat("%d", sqrtf(path_it.value_to_sort_by->F32)->int)
|
s := TextFormat("%d", sqrtf(path_it.value_to_sort_by->F32)->int)
|
||||||
DrawText(s, path_r.x->int, path_r.y->int, 1, RAYWHITE)
|
DrawText(s, path_r.x->int, path_r.y->int, 1, RAYWHITE)
|
||||||
|
|
||||||
for path_i := 0, path_i < actor_it.close_paths.len, path_i += 1
|
for path_i := 0, path_i < actor_it.close_paths.len, path_i += 1
|
||||||
path_it := actor_it.close_paths.data + path_i
|
path_it := actor_it.close_paths.data + path_i
|
||||||
path_r := MAP_Rectangle(path_it.p)
|
path_r := MAP.Rect(path_it.p)
|
||||||
DrawRectangleRec(path_r, brown)
|
DrawRectangleRec(path_r, brown)
|
||||||
|
|
||||||
for path_i := 0, path_i < actor_it.history.len, path_i += 1
|
for path_i := 0, path_i < actor_it.history.len, path_i += 1
|
||||||
path_it := actor_it.history.data + path_i
|
path_it := actor_it.history.data + path_i
|
||||||
|
|
||||||
p0 := MAP_Circle(path_it.came_from)
|
p0 := MAP.Circle(path_it.came_from)
|
||||||
p1 := MAP_Circle(path_it.p)
|
p1 := MAP.Circle(path_it.p)
|
||||||
|
|
||||||
DrawLineEx(p0, p1, 5, LIGHTGRAY)
|
DrawLineEx(p0, p1, 5, LIGHTGRAY)
|
||||||
DrawCircleV(p0, 4, LIGHTGRAY)
|
DrawCircleV(p0, 4, LIGHTGRAY)
|
||||||
@@ -276,12 +272,12 @@ main :: (): int
|
|||||||
if Mode == 1
|
if Mode == 1
|
||||||
for actor_i := 0, actor_i < MouseSelectedActors.len, actor_i += 1
|
for actor_i := 0, actor_i < MouseSelectedActors.len, actor_i += 1
|
||||||
actor_it := MouseSelectedActors.data[actor_i]
|
actor_it := MouseSelectedActors.data[actor_i]
|
||||||
actor_box := MAP_Rectangle(actor_it.p)
|
actor_box := MAP.Rect(actor_it.p)
|
||||||
DrawRectangleRec(actor_box, GREEN)
|
DrawRectangleRec(actor_box, GREEN)
|
||||||
|
|
||||||
if IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)
|
if IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)
|
||||||
p := MAP_ScreenToMap(MouseP)
|
p := MAP.ScreenToMap(MouseP)
|
||||||
MAP_SetTargetP(actor_it, p)
|
MAP.SetTargetP(actor_it, p)
|
||||||
|
|
||||||
if MouseSelecting
|
if MouseSelecting
|
||||||
Reset(&MouseSelectedActors)
|
Reset(&MouseSelectedActors)
|
||||||
@@ -290,7 +286,7 @@ main :: (): int
|
|||||||
|
|
||||||
for actor_i := 0, actor_i < map.actors.len, actor_i += 1
|
for actor_i := 0, actor_i < map.actors.len, actor_i += 1
|
||||||
actor_it := map.actors.data + actor_i
|
actor_it := map.actors.data + actor_i
|
||||||
actor_box := MAP_Rectangle(actor_it.p)
|
actor_box := MAP.Rect(actor_it.p)
|
||||||
|
|
||||||
if CheckCollisionRecs(actor_box, MouseSelectionBox)
|
if CheckCollisionRecs(actor_box, MouseSelectionBox)
|
||||||
Add(&MouseSelectedActors, actor_it)
|
Add(&MouseSelectedActors, actor_it)
|
||||||
|
|||||||
@@ -1,65 +1,65 @@
|
|||||||
MAP_CurrentMap: MAP_Map
|
CurrentMap: Map
|
||||||
|
|
||||||
MAP_PATH_SEARCHING :: 0
|
PATH_SEARCHING :: 0
|
||||||
MAP_PATH_REACHED :: 1
|
PATH_REACHED :: 1
|
||||||
MAP_PATH_UNREACHABLE :: 2
|
PATH_UNREACHABLE :: 2
|
||||||
|
|
||||||
MAP_TILE_BLOCKER :: 1
|
TILE_BLOCKER :: 1
|
||||||
MAP_TILE_ACTOR_IS_STANDING :: 2
|
TILE_ACTOR_IS_STANDING :: 2
|
||||||
|
|
||||||
MAP_Tile :: int
|
Tile :: int
|
||||||
MAP_Map :: struct
|
Map :: struct
|
||||||
data: *MAP_Tile
|
data: *Tile
|
||||||
x: int
|
x: int
|
||||||
y: int
|
y: int
|
||||||
actors: Array(MAP_Actor)
|
actors: Array(Actor)
|
||||||
|
|
||||||
MAP_Actor :: struct
|
Actor :: struct
|
||||||
p: V2I
|
p: V2I
|
||||||
target_p: V2I
|
target_p: V2I
|
||||||
map: *MAP_Map
|
map: *Map
|
||||||
|
|
||||||
open_paths: Array(MAP_Path)
|
open_paths: Array(Path)
|
||||||
close_paths: Array(MAP_Path)
|
close_paths: Array(Path)
|
||||||
tiles_visited: Array(V2I)
|
tiles_visited: Array(V2I)
|
||||||
history: Array(MAP_Path)
|
history: Array(Path)
|
||||||
|
|
||||||
MAP_Path :: struct
|
Path :: struct
|
||||||
value_to_sort_by: int // distance from target
|
value_to_sort_by: int // distance from target
|
||||||
p: V2I
|
p: V2I
|
||||||
came_from: V2I
|
came_from: V2I
|
||||||
|
|
||||||
MAP_Rectangle :: (p: V2I): Rectangle
|
Rect :: (p: V2I): Rectangle
|
||||||
result := Rectangle{p.x->F32 * RectX, p.y->F32 * RectY, RectX, RectY}
|
result := Rectangle{p.x->F32 * RectX, p.y->F32 * RectY, RectX, RectY}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
MAP_Circle :: (p: V2I): Vector2
|
Circle :: (p: V2I): Vector2
|
||||||
result := Vector2{p.x->F32 * RectX + RectX/2, p.y->F32 * RectY + RectY/2}
|
result := Vector2{p.x->F32 * RectX + RectX/2, p.y->F32 * RectY + RectY/2}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
MAP_ScreenToMap :: (p: Vector2): V2I
|
ScreenToMap :: (p: Vector2): V2I
|
||||||
p0 := p.x / RectX
|
p0 := p.x / RectX
|
||||||
p1 := p.y / RectY
|
p1 := p.y / RectY
|
||||||
result := V2I{p0->int, p1->int}
|
result := V2I{p0->int, p1->int}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
MAP_AddActor :: (map: *MAP_Map, p: V2I): *MAP_Actor
|
AddActor :: (map: *Map, p: V2I): *Actor
|
||||||
Add(&map.actors, {p, p, map})
|
Add(&map.actors, {p, p, map})
|
||||||
Assert(map.data[p.x + p.y * map.x] == 0)
|
Assert(map.data[p.x + p.y * map.x] == 0)
|
||||||
map.data[p.x + p.y * map.x] |= MAP_TILE_ACTOR_IS_STANDING
|
map.data[p.x + p.y * map.x] |= TILE_ACTOR_IS_STANDING
|
||||||
actor := GetLast(&MAP_CurrentMap.actors)
|
actor := GetLast(&CurrentMap.actors)
|
||||||
return actor
|
return actor
|
||||||
|
|
||||||
MAP_ActorSetP :: (actor: *MAP_Actor, p: V2I)
|
ActorSetP :: (actor: *Actor, p: V2I)
|
||||||
map := actor.map
|
map := actor.map
|
||||||
new_tile := map.data + p.x + p.y * map.x
|
new_tile := map.data + p.x + p.y * map.x
|
||||||
if *new_tile != 0 ;; return
|
if *new_tile != 0 ;; return
|
||||||
|
|
||||||
tile := map.data + actor.p.x + actor.p.y * map.x
|
tile := map.data + actor.p.x + actor.p.y * map.x
|
||||||
Assert((*tile & MAP_TILE_ACTOR_IS_STANDING) != 0)
|
Assert((*tile & TILE_ACTOR_IS_STANDING) != 0)
|
||||||
*tile &= ~MAP_TILE_ACTOR_IS_STANDING
|
*tile &= ~TILE_ACTOR_IS_STANDING
|
||||||
|
|
||||||
*new_tile |= MAP_TILE_ACTOR_IS_STANDING
|
*new_tile |= TILE_ACTOR_IS_STANDING
|
||||||
actor.p = p
|
actor.p = p
|
||||||
|
|
||||||
Reset(&actor.tiles_visited)
|
Reset(&actor.tiles_visited)
|
||||||
@@ -67,48 +67,48 @@ MAP_ActorSetP :: (actor: *MAP_Actor, p: V2I)
|
|||||||
Reset(&actor.open_paths)
|
Reset(&actor.open_paths)
|
||||||
Reset(&actor.close_paths)
|
Reset(&actor.close_paths)
|
||||||
|
|
||||||
MAP_SetTargetP :: (s: *MAP_Actor, p: V2I)
|
SetTargetP :: (s: *Actor, p: V2I)
|
||||||
s.target_p = p
|
s.target_p = p
|
||||||
Reset(&s.tiles_visited)
|
Reset(&s.tiles_visited)
|
||||||
Reset(&s.history)
|
Reset(&s.history)
|
||||||
Reset(&s.open_paths)
|
Reset(&s.open_paths)
|
||||||
Reset(&s.close_paths)
|
Reset(&s.close_paths)
|
||||||
|
|
||||||
MAP_GetRandomP :: (m: *MAP_Map): V2I
|
GetRandomP :: (m: *Map): V2I
|
||||||
result := V2I{GetRandomValue(0, MAP_CurrentMap.x - 1), GetRandomValue(0, MAP_CurrentMap.y - 1)}
|
result := V2I{GetRandomValue(0, CurrentMap.x - 1), GetRandomValue(0, CurrentMap.y - 1)}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
MAP_GetRandomUnblockedP :: (m: *MAP_Map): V2I
|
GetRandomUnblockedP :: (m: *Map): V2I
|
||||||
for i := 0, i < 128, i += 1
|
for i := 0, i < 128, i += 1
|
||||||
p := MAP_GetRandomP(m)
|
p := GetRandomP(m)
|
||||||
if m.data[p.x + p.y * m.x] == 0
|
if m.data[p.x + p.y * m.x] == 0
|
||||||
return p
|
return p
|
||||||
|
|
||||||
Assert(false, "Invalid codepath")
|
Assert(false, "Invalid codepath")
|
||||||
r: V2I; return r
|
r: V2I; return r
|
||||||
|
|
||||||
MAP_Init :: ()
|
Init :: ()
|
||||||
MAP_CurrentMap.x = WinX / RectX
|
CurrentMap.x = WinX / RectX
|
||||||
MAP_CurrentMap.y = WinY / RectY
|
CurrentMap.y = WinY / RectY
|
||||||
bytes := sizeof(MAP_Tile) * MAP_CurrentMap.x->U64 * MAP_CurrentMap.y->U64
|
bytes := sizeof(Tile) * CurrentMap.x->U64 * CurrentMap.y->U64
|
||||||
MAP_CurrentMap.data = malloc(bytes)
|
CurrentMap.data = malloc(bytes)
|
||||||
memset(MAP_CurrentMap.data, 0, bytes)
|
memset(CurrentMap.data, 0, bytes)
|
||||||
|
|
||||||
actor := MAP_AddActor(&MAP_CurrentMap, MAP_GetRandomUnblockedP(&MAP_CurrentMap))
|
actor := AddActor(&CurrentMap, GetRandomUnblockedP(&CurrentMap))
|
||||||
actor.target_p = MAP_GetRandomUnblockedP(&MAP_CurrentMap)
|
actor.target_p = GetRandomUnblockedP(&CurrentMap)
|
||||||
|
|
||||||
actor2 := MAP_AddActor(&MAP_CurrentMap, MAP_GetRandomUnblockedP(&MAP_CurrentMap))
|
actor2 := AddActor(&CurrentMap, GetRandomUnblockedP(&CurrentMap))
|
||||||
actor2.target_p = MAP_GetRandomUnblockedP(&MAP_CurrentMap)
|
actor2.target_p = GetRandomUnblockedP(&CurrentMap)
|
||||||
|
|
||||||
MAP_RandomizeActors :: ()
|
RandomizeActors :: ()
|
||||||
map := &MAP_CurrentMap
|
map := &CurrentMap
|
||||||
for i := 0, i < map.actors.len, i += 1
|
for i := 0, i < map.actors.len, i += 1
|
||||||
it := map.actors.data + i
|
it := map.actors.data + i
|
||||||
p := MAP_GetRandomUnblockedP(&MAP_CurrentMap)
|
p := GetRandomUnblockedP(&CurrentMap)
|
||||||
MAP_ActorSetP(it, p)
|
ActorSetP(it, p)
|
||||||
it.target_p = MAP_GetRandomUnblockedP(&MAP_CurrentMap)
|
it.target_p = GetRandomUnblockedP(&CurrentMap)
|
||||||
|
|
||||||
MAP_InsertOpenPath :: (s: *MAP_Actor, p: V2I, came_from: V2I, ignore_blocks: bool = false)
|
InsertOpenPath :: (s: *Actor, p: V2I, came_from: V2I, ignore_blocks: bool = false)
|
||||||
if p.x < 0 || p.x >= s.map.x ;; return
|
if p.x < 0 || p.x >= s.map.x ;; return
|
||||||
if p.y < 0 || p.y >= s.map.y ;; return
|
if p.y < 0 || p.y >= s.map.y ;; return
|
||||||
if ignore_blocks == false && s.map.data[p.x + p.y * s.map.x] != 0 ;; return
|
if ignore_blocks == false && s.map.data[p.x + p.y * s.map.x] != 0 ;; return
|
||||||
@@ -126,7 +126,7 @@ MAP_InsertOpenPath :: (s: *MAP_Actor, p: V2I, came_from: V2I, ignore_blocks: boo
|
|||||||
d := dx*dx + dy*dy
|
d := dx*dx + dy*dy
|
||||||
InsertSortedDecreasing(&s.open_paths, {d, p, came_from})
|
InsertSortedDecreasing(&s.open_paths, {d, p, came_from})
|
||||||
|
|
||||||
MAP_GetCloseP :: (s: *MAP_Actor, p: V2I): *MAP_Path
|
GetCloseP :: (s: *Actor, p: V2I): *Path
|
||||||
for i := 0, i < s.close_paths.len, i += 1
|
for i := 0, i < s.close_paths.len, i += 1
|
||||||
it := s.close_paths.data + i
|
it := s.close_paths.data + i
|
||||||
if it.p.x == p.x && it.p.y == p.y ;; return it
|
if it.p.x == p.x && it.p.y == p.y ;; return it
|
||||||
@@ -134,7 +134,7 @@ MAP_GetCloseP :: (s: *MAP_Actor, p: V2I): *MAP_Path
|
|||||||
Assert(false, "Invalid codepath")
|
Assert(false, "Invalid codepath")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
MAP_RecomputeHistory :: (s: *MAP_Actor)
|
RecomputeHistory :: (s: *Actor)
|
||||||
if s.close_paths.len > 1
|
if s.close_paths.len > 1
|
||||||
Reset(&s.history)
|
Reset(&s.history)
|
||||||
it := GetLast(&s.close_paths)
|
it := GetLast(&s.close_paths)
|
||||||
@@ -144,11 +144,11 @@ MAP_RecomputeHistory :: (s: *MAP_Actor)
|
|||||||
if i > 512
|
if i > 512
|
||||||
Reset(&s.history)
|
Reset(&s.history)
|
||||||
break
|
break
|
||||||
it = MAP_GetCloseP(s, it.came_from)
|
it = GetCloseP(s, it.came_from)
|
||||||
Add(&s.history, *it)
|
Add(&s.history, *it)
|
||||||
Pop(&s.history)
|
Pop(&s.history)
|
||||||
|
|
||||||
MAP_MoveTowardsTarget :: (s: *MAP_Actor)
|
MoveTowardsTarget :: (s: *Actor)
|
||||||
tile := s.map.data + s.p.x + s.p.y * s.map.x
|
tile := s.map.data + s.p.x + s.p.y * s.map.x
|
||||||
if s.history.len > 0
|
if s.history.len > 0
|
||||||
step := Pop(&s.history)
|
step := Pop(&s.history)
|
||||||
@@ -156,10 +156,10 @@ MAP_MoveTowardsTarget :: (s: *MAP_Actor)
|
|||||||
if *new_tile == 0
|
if *new_tile == 0
|
||||||
Add(&s.tiles_visited, s.p)
|
Add(&s.tiles_visited, s.p)
|
||||||
s.p = step.p
|
s.p = step.p
|
||||||
*tile &= ~MAP_TILE_ACTOR_IS_STANDING
|
*tile &= ~TILE_ACTOR_IS_STANDING
|
||||||
*new_tile |= MAP_TILE_ACTOR_IS_STANDING
|
*new_tile |= TILE_ACTOR_IS_STANDING
|
||||||
|
|
||||||
MAP_PathFindUpdate :: (map: *MAP_Map)
|
PathFindUpdate :: (map: *Map)
|
||||||
for actor_i := 0, actor_i < map.actors.len, actor_i += 1
|
for actor_i := 0, actor_i < map.actors.len, actor_i += 1
|
||||||
s := map.actors.data + actor_i
|
s := map.actors.data + actor_i
|
||||||
for i := 0, i < s.history.len, i += 1
|
for i := 0, i < s.history.len, i += 1
|
||||||
@@ -172,9 +172,9 @@ MAP_PathFindUpdate :: (map: *MAP_Map)
|
|||||||
Reset(&s.history)
|
Reset(&s.history)
|
||||||
break
|
break
|
||||||
|
|
||||||
MAP_PathFind(s)
|
PathFind(s)
|
||||||
|
|
||||||
MAP_PathFindStep :: (s: *MAP_Actor, compute_history: bool = true): bool
|
PathFindStep :: (s: *Actor, compute_history: bool = true): bool
|
||||||
if s.open_paths.len == 0
|
if s.open_paths.len == 0
|
||||||
// Reset if we didnt find solution
|
// Reset if we didnt find solution
|
||||||
if s.close_paths.len != 0
|
if s.close_paths.len != 0
|
||||||
@@ -185,7 +185,7 @@ MAP_PathFindStep :: (s: *MAP_Actor, compute_history: bool = true): bool
|
|||||||
Reset(&s.close_paths)
|
Reset(&s.close_paths)
|
||||||
Reset(&s.history)
|
Reset(&s.history)
|
||||||
|
|
||||||
MAP_InsertOpenPath(s, s.p, s.p, ignore_blocks = true)
|
InsertOpenPath(s, s.p, s.p, ignore_blocks = true)
|
||||||
|
|
||||||
if s.close_paths.len != 0
|
if s.close_paths.len != 0
|
||||||
last := GetLast(&s.close_paths)
|
last := GetLast(&s.close_paths)
|
||||||
@@ -201,13 +201,13 @@ MAP_PathFindStep :: (s: *MAP_Actor, compute_history: bool = true): bool
|
|||||||
for x := -1, x <= 1, x += 1
|
for x := -1, x <= 1, x += 1
|
||||||
if x == 0 && y == 0 ;; continue
|
if x == 0 && y == 0 ;; continue
|
||||||
p := V2I{it.p.x + x, it.p.y + y}
|
p := V2I{it.p.x + x, it.p.y + y}
|
||||||
MAP_InsertOpenPath(s, p, it.p)
|
InsertOpenPath(s, p, it.p)
|
||||||
|
|
||||||
if compute_history ;; MAP_RecomputeHistory(s)
|
if compute_history ;; RecomputeHistory(s)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
MAP_PathFind :: (s: *MAP_Actor)
|
PathFind :: (s: *Actor)
|
||||||
for i := 0, i < 32, i += 1
|
for i := 0, i < 32, i += 1
|
||||||
done := MAP_PathFindStep(s, false)
|
done := PathFindStep(s, false)
|
||||||
if done ;; break
|
if done ;; break
|
||||||
MAP_RecomputeHistory(s)
|
RecomputeHistory(s)
|
||||||
|
|||||||
@@ -920,7 +920,12 @@ parse_decl(B32 is_global) {
|
|||||||
result = parse_enum(tname);
|
result = parse_enum(tname);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (token_match_pound(pctx->intern("import"_s))) {
|
else if (token_match_pound(pctx->intern_load)) {
|
||||||
|
Ast_File *file = parse_load(false);
|
||||||
|
result = ast_namespace(tname, file, tname->intern_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (token_match_pound(pctx->intern_import)) {
|
||||||
Ast_Module *module = parse_import(false);
|
Ast_Module *module = parse_import(false);
|
||||||
result = ast_namespace(tname, module, tname->intern_val);
|
result = ast_namespace(tname, module, tname->intern_val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1155,23 +1155,19 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
|
|||||||
Ast_Scope *scope = field_access_scope ? field_access_scope : node->parent_scope;
|
Ast_Scope *scope = field_access_scope ? field_access_scope : node->parent_scope;
|
||||||
Search_Flag flag = field_access_scope ? SEARCH_ONLY_CURRENT_SCOPE : 0;
|
Search_Flag flag = field_access_scope ? SEARCH_ONLY_CURRENT_SCOPE : 0;
|
||||||
|
|
||||||
if (!string_compare(ast->pos->file.s, "Language.core"_s)) { // @debug
|
|
||||||
int a = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @consider: Maybe instead of using AST_IDENT another case should be
|
// @consider: Maybe instead of using AST_IDENT another case should be
|
||||||
// added like AST_RESOLVED or something because currently the identifier
|
// added like AST_RESOLVED or something because currently the identifier
|
||||||
// is a bit bogus.
|
// is a bit bogus.
|
||||||
|
|
||||||
|
// if (node->intern_val == pctx->intern("MAP"_s)) {
|
||||||
|
// __debugbreak();
|
||||||
|
// }
|
||||||
|
|
||||||
// When copying polymorphs we fill out resolved_decl in
|
// When copying polymorphs we fill out resolved_decl in
|
||||||
// identifiers, so it can happen that we have already resolved the name
|
// identifiers, so it can happen that we have already resolved the name
|
||||||
Ast_Decl *decl = node->resolved_decl;
|
Ast_Decl *decl = node->resolved_decl;
|
||||||
if (!decl) decl = resolve_name(scope, node->pos, node->intern_val, flag | RESOLVE_NAME_MAKE_SURE_OPERATOR_OVERLOAD_IS_NOT_EVER_CALLED);
|
if (!decl) decl = resolve_name(scope, node->pos, node->intern_val, flag | RESOLVE_NAME_MAKE_SURE_OPERATOR_OVERLOAD_IS_NOT_EVER_CALLED);
|
||||||
|
|
||||||
// if (decl->type_val && decl->type_val->kind == TYPE_POLYMORPH) {
|
|
||||||
// compiler_error(ast->pos, "Trying to use a polymorphic in an invalid way");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Substitute lambda alias
|
// Substitute lambda alias
|
||||||
if (decl->kind == AST_CONST && decl->resolved_decl && decl->resolved_decl->kind == AST_LAMBDA) {
|
if (decl->kind == AST_CONST && decl->resolved_decl && decl->resolved_decl->kind == AST_LAMBDA) {
|
||||||
decl = decl->resolved_decl;
|
decl = decl->resolved_decl;
|
||||||
@@ -1181,7 +1177,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
|
|||||||
node->resolved_type = node->resolved_decl->type;
|
node->resolved_type = node->resolved_decl->type;
|
||||||
|
|
||||||
Operand result = operand(node->resolved_decl);
|
Operand result = operand(node->resolved_decl);
|
||||||
if (result.is_const) {
|
if (result.is_const && decl->kind != AST_NAMESPACE) {
|
||||||
rewrite_into_const(node, Ast_Atom, node->resolved_decl->value);
|
rewrite_into_const(node, Ast_Atom, node->resolved_decl->value);
|
||||||
node->resolved_decl = decl;
|
node->resolved_decl = decl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user