From bda508d2918cbe99e9b39504cb956480084671ae Mon Sep 17 00:00:00 2001 From: doyle Date: Sun, 17 Sep 2023 20:53:13 +1000 Subject: [PATCH] fp: Use the chunk pool from the platform --- External/tely | 2 +- feely_pona.cpp | 23 +++++++++-------------- feely_pona.h | 2 +- feely_pona_game.cpp | 6 +++--- feely_pona_unity.h | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/External/tely b/External/tely index 502c8dc..5bba4cd 160000 --- a/External/tely +++ b/External/tely @@ -1 +1 @@ -Subproject commit 502c8dca126566cd603b83f047851787144b0b8f +Subproject commit 5bba4cddbc9352be4083fb1ec02dfbab2de0c115 diff --git a/feely_pona.cpp b/feely_pona.cpp index 09ba010..36a6449 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -48,7 +48,7 @@ void TELY_DLL_Init(void *user_data) TELY_Assets *assets = &platform->assets; FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes); - game->chunk_pool.arena = &platform->arena; + game->chunk_pool = &platform->chunk_pool; platform->user_data = game; { TELY_AssetSpriteSheet *sheet = &game->hero_sprite_sheet; @@ -212,11 +212,6 @@ void TELY_DLL_Init(void *user_data) game->inter_italic_font = platform->func_load_font(assets, DQN_STRING8("Inter (Italic)"), DQN_STRING8("Data/Inter-Italic.otf"), font_size); game->jetbrains_mono_font = platform->func_load_font(assets, DQN_STRING8("JetBrains Mono NL (Regular)"), DQN_STRING8("Data/JetBrainsMonoNL-Regular.ttf"), font_size); game->test_audio = platform->func_load_audio(assets, DQN_STRING8("Test Audio"), DQN_STRING8("Data/Audio/Purrple Cat - Moonwinds.qoa")); - - // NOTE: TELY audio ============================================================================ - - TELY_Audio *audio = &platform->audio; - audio->chunk_pool = &game->chunk_pool; } void FP_Game_EntityChangeState(FP_GameEntity *entity, FP_GameEntityState state) @@ -427,7 +422,7 @@ void FP_GameUpdate(TELY_Platform *platform, FP_Game *game, TELY_Renderer *render // NOTE: Dealloc all waypoints for (FP_GameWaypoint *waypoint = entity->waypoints->next; waypoint != entity->waypoints; ) { FP_GameWaypoint *next = waypoint->next; - TELY_ChunkPool_Dealloc(&game->chunk_pool, waypoint); + TELY_ChunkPool_Dealloc(game->chunk_pool, waypoint); waypoint = next; } entity->waypoints->next = entity->waypoints; @@ -437,12 +432,12 @@ void FP_GameUpdate(TELY_Platform *platform, FP_Game *game, TELY_Renderer *render Dqn_Slice path_find = AStarPathFind(&platform->arena, platform, entity_tile, stalk_tile); for (Dqn_usize index = path_find.size - 1; index < path_find.size; index--) { - FP_GameWaypoint *waypoint = TELY_ChunkPool_New(&game->chunk_pool, FP_GameWaypoint); - waypoint->pos = path_find.data[index]; - waypoint->next = entity->waypoints; - waypoint->prev = entity->waypoints->prev; - waypoint->next->prev = waypoint; - waypoint->prev->next = waypoint; + FP_GameWaypoint *waypoint = TELY_ChunkPool_New(game->chunk_pool, FP_GameWaypoint); + waypoint->pos = path_find.data[index]; + waypoint->next = entity->waypoints; + waypoint->prev = entity->waypoints->prev; + waypoint->next->prev = waypoint; + waypoint->prev->next = waypoint; } } } @@ -462,7 +457,7 @@ void FP_GameUpdate(TELY_Platform *platform, FP_Game *game, TELY_Renderer *render if (Dqn_V2_LengthSq(entity_to_target_pos) < DQN_SQUARED(entity->local_hit_box_size.x * .5f)) { waypoint->next->prev = waypoint->prev; waypoint->prev->next = waypoint->next; - TELY_ChunkPool_Dealloc(&game->chunk_pool, waypoint); + TELY_ChunkPool_Dealloc(game->chunk_pool, waypoint); } else { Dqn_V2 entity_to_target_pos_norm = Dqn_V2_Normalise(entity_to_target_pos); entity->local_pos += entity_to_target_pos_norm * (entity->local_hit_box_size.x * .05f); diff --git a/feely_pona.h b/feely_pona.h index e5b7253..da1377a 100644 --- a/feely_pona.h +++ b/feely_pona.h @@ -121,7 +121,7 @@ struct FP_GameCamera struct FP_Game { - TELY_ChunkPool chunk_pool; + TELY_ChunkPool *chunk_pool; TELY_AssetFontHandle inter_regular_font; TELY_AssetFontHandle inter_italic_font; TELY_AssetFontHandle jetbrains_mono_font; diff --git a/feely_pona_game.cpp b/feely_pona_game.cpp index 8da3b3a..291f3ca 100644 --- a/feely_pona_game.cpp +++ b/feely_pona_game.cpp @@ -205,8 +205,8 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_ result->size_scale = Dqn_V2_InitNx1(1); result->parent = FP_Game_ActiveParentEntityPointer(game); - result->name = TELY_ChunkPool_AllocFmtFV(&game->chunk_pool, fmt, args); - result->waypoints = TELY_ChunkPool_New(&game->chunk_pool, FP_GameWaypoint); + result->name = TELY_ChunkPool_AllocFmtFV(game->chunk_pool, fmt, args); + result->waypoints = TELY_ChunkPool_New(game->chunk_pool, FP_GameWaypoint); result->waypoints->next = result->waypoints; result->waypoints->prev = result->waypoints; @@ -290,7 +290,7 @@ static void FP_Game_DetachEntityIntoFreeList(FP_Game *game, FP_GameEntityHandle parent->last_child = entity->prev; if (entity->name.size) - TELY_ChunkPool_Dealloc(&game->chunk_pool, entity->name.data); + TELY_ChunkPool_Dealloc(game->chunk_pool, entity->name.data); if (new_entity_generation > entity_generation) { // NOTE: Update the incremented handle disassociating all prior handles diff --git a/feely_pona_unity.h b/feely_pona_unity.h index ddbc367..7a3b9a0 100644 --- a/feely_pona_unity.h +++ b/feely_pona_unity.h @@ -43,10 +43,10 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed #include "External/tely/tely_profile.h" #include "External/tely/tely_platform_input.h" +#include "External/tely/tely_tools.h" #include "External/tely/tely_asset.h" #include "External/tely/tely_colour.h" #include "External/tely/tely_render.h" -#include "External/tely/tely_tools.h" #include "External/tely/tely_audio.h" #include "External/tely/tely_platform.h" #include "External/tely/tely_ui.h"