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;
} }
@ -1003,7 +1008,7 @@ void from_bytes(struct ServerToClient* msg, char* bytes, size_t max_len, bool wr
#endif #endif
ser_server_to_client(&ser, msg); ser_server_to_client(&ser, msg);
} }
// has to be global var because can only get this information // has to be global var because can only get this information
static cpShape* closest_to_point_in_radius_result = NULL; static cpShape* closest_to_point_in_radius_result = NULL;

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