Skip to content

Commit 6c2000c

Browse files
authored
Fix save/load bug preventing player movement with sv_savefmt 1/2 (#378)
After commit dc010d6, loading non-legacy saves (sv_savefmt 1 or 2) would result in players being unable to move. This seems to have been caused by localstack pointer corruption during the save/load process. The issue seems to have occurred because: 1. Commit dc010d6 changed localstack from a static array to dynamically allocated memory in the addressable memory region 2. When loading saves, SV_SpawnServer -> Q_InitProgs -> PR_Configure -> PRAddressableFlush would reinitialize all addressable memory 3. The localstack pointer wasn't properly cleared, causing corruption of the stringtable and breaking OP_PUSH pointers stored in saved games The fix ensures that when addressable memory is flushed, the localstack state is properly cleared. The localstack will be correctly reallocated when progs are reloaded.
1 parent f129cce commit 6c2000c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

engine/qclib/initlib.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ void PRAddressableFlush(progfuncs_t *progfuncs, size_t totalammount)
499499
{
500500
prinst.addressableused = 0;
501501
prinst.mfreelist = 0;
502+
// Clear localstack state when flushing memory
503+
prinst.localstack = NULL;
504+
prinst.localstack_used = 0;
505+
prinst.spushed = 0;
502506

503507
if (totalammount <= 0) //flush
504508
{

0 commit comments

Comments
 (0)