Skip to content

Commit

Permalink
Trim edict on load : add old savegame compatibility workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
vsonnier committed Jul 21, 2024
1 parent 58f5bbe commit d5cb8de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Host_Status_f
*/
static void Host_Status_f (void)
{
void (*print_fn) (const char *fmt, ...) FUNCP_PRINTF (1, 2);
void (*print_fn) (const char *fmt, ...) FUNCP_PRINTF (1, 2);
client_t *client;
int seconds;
int minutes;
Expand Down Expand Up @@ -1156,9 +1156,12 @@ static void Host_Savegame_f (void)
for (i = 0; i < qcvm->num_edicts; i++)
{
ED_Write (f, EDICT_NUM (i));
fflush (f);
}

// padding to min with 'free' edicts for savegame compatibility
for (; i < qcvm->min_edicts; i++)
fprintf (f, "{\n}\n");

// add extra info (lightstyles, precaches, etc) in a way that's supposed to be compatible with DP.
// sidenote - this provides extended lightstyles and support for late precaches
// it does NOT protect against spawnfunc precache changes - we would need to include makestatics here too (and optionally baselines, or just recalculate
Expand Down
1 change: 1 addition & 0 deletions Quake/progs.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ struct qcvm_s
int num_edicts;
int reserved_edicts;
int max_edicts;
int min_edicts; // for savegame compatibility
edict_t *edicts; // can NOT be array indexed, because edict_t is variable sized, but can be used to reference the world ent
edict_t *free_edicts_head;
edict_t *free_edicts_tail;
Expand Down
1 change: 1 addition & 0 deletions Quake/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3251,6 +3251,7 @@ void SV_SpawnServer (const char *server)

// create a baseline for more efficient communications
SV_CreateBaseline ();
qcvm->min_edicts = qcvm->num_edicts;

// johnfitz -- warn if signon buffer larger than standard server can handle
if (sv.signon.cursize > 8000 - 2) // max size that will fit into 8000-sized client->message buffer with 2 extra bytes on the end
Expand Down

0 comments on commit d5cb8de

Please sign in to comment.