From 3e31d0ef6925c3e729defe197f7a1cd4c8063a79 Mon Sep 17 00:00:00 2001 From: doyle Date: Mon, 18 Sep 2023 21:46:42 +1000 Subject: [PATCH] fp: Use new insert API for containers --- External/tely | 2 +- feely_pona.cpp | 11 ++--------- feely_pona_game.cpp | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/External/tely b/External/tely index b45db1a..0b5b08b 160000 --- a/External/tely +++ b/External/tely @@ -1 +1 @@ -Subproject commit b45db1a82cf5fb7f32d298c71b7dc0ac806a6f5f +Subproject commit 0b5b08bb635d1aad6832a69d30e2c45f7a59af8b diff --git a/feely_pona.cpp b/feely_pona.cpp index c3e4550..483cbfe 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -87,7 +87,7 @@ void TELY_DLL_Init(void *user_data) } game->entities = Dqn_VArray_Init(&platform->arena, 1024 * 8); - game->root_entity = Dqn_VArray_Make(&game->entities, 1, Dqn_ZeroMem_No); + game->root_entity = Dqn_VArray_Make(&game->entities, Dqn_ZeroMem_No); Dqn_FArray_Add(&game->parent_entity_stack, game->root_entity->handle); // NOTE: Unit test DFS pre-order and post-order walk @@ -284,14 +284,7 @@ Dqn_Slice AStarPathFind(Dqn_Arena *arena, TELY_Platform *platform, Dqn_ if (next_cost_result.value->heuristic >= frontier_heuristic) continue; - char const *src = DQN_CAST(char *)(frontier.data + index); - char const *dest = DQN_CAST(char *)(frontier.data + (index + 1)); - char const *end = DQN_CAST(char *)(frontier.data + frontier.size); - Dqn_usize bytes_to_move = end - src; - DQN_MEMMOVE(DQN_CAST(void *)dest, src, bytes_to_move); - - frontier.data[index] = next_tile; - frontier.size++; + Dqn_FArray_Insert(&frontier, index, next_tile); inserted = true; break; } diff --git a/feely_pona_game.cpp b/feely_pona_game.cpp index 6ea1402..13af4a6 100644 --- a/feely_pona_game.cpp +++ b/feely_pona_game.cpp @@ -197,7 +197,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_ if (game->entities.size >= (FP_GAME_ENTITY_HANDLE_INDEX_MAX + 1)) return result; - result = Dqn_VArray_Make(&game->entities, 1, Dqn_ZeroMem_Yes); + result = Dqn_VArray_Make(&game->entities, Dqn_ZeroMem_Yes); if (!result) return result; result->handle.id = (game->entities.size - 1) & FP_GAME_ENTITY_HANDLE_INDEX_MASK;