fp: Use the chunk pool from the platform

This commit is contained in:
doyle 2023-09-17 20:53:13 +10:00
parent 6d33b18364
commit bda508d291
5 changed files with 15 additions and 20 deletions

2
External/tely vendored

@ -1 +1 @@
Subproject commit 502c8dca126566cd603b83f047851787144b0b8f
Subproject commit 5bba4cddbc9352be4083fb1ec02dfbab2de0c115

View File

@ -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<Dqn_V2I> 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);

View File

@ -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;

View File

@ -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

View File

@ -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"