Bump max entities and remove bad perf memset

main
Cameron Murphy Reikes 2 years ago
parent 8a91469cf8
commit 5b5036ff5b

@ -515,6 +515,11 @@ void destroy(GameState* gs)
} }
cpSpaceFree(gs->space); cpSpaceFree(gs->space);
gs->space = NULL; gs->space = NULL;
for (size_t i = 0; i < gs->cur_next_entity; i++)
{
if (gs->entities[i].exists) gs->entities[i] = (Entity){ 0 };
}
gs->cur_next_entity = 0; gs->cur_next_entity = 0;
} }
// center of mass, not the literal position // center of mass, not the literal position
@ -857,8 +862,8 @@ void ser_server_to_client(SerState* ser, ServerToClient* s)
if (!ser->serializing) if (!ser->serializing)
{ {
// avoid a memset here very expensive
destroy(gs); destroy(gs);
memset((void*)gs->entities, 0, sizeof(*gs->entities) * gs->max_entities);
initialize(gs, gs->entities, gs->max_entities * sizeof(*gs->entities)); initialize(gs, gs->entities, gs->max_entities * sizeof(*gs->entities));
gs->cur_next_entity = cur_next_entity; gs->cur_next_entity = cur_next_entity;
} }

@ -1,7 +1,7 @@
#pragma once #pragma once
#define MAX_PLAYERS 8 #define MAX_PLAYERS 8
#define MAX_ENTITIES 1024*2 #define MAX_ENTITIES 1024*25
#define BOX_SIZE 0.25f #define BOX_SIZE 0.25f
#define PLAYER_SIZE ((V2){.x = BOX_SIZE, .y = BOX_SIZE}) #define PLAYER_SIZE ((V2){.x = BOX_SIZE, .y = BOX_SIZE})
#define PLAYER_MASS 0.5f #define PLAYER_MASS 0.5f

Loading…
Cancel
Save