Skip to content

Commit 94d1550

Browse files
committed
Revert "SV_Physics(): fix entity cap check in the for loop, plus vkQuake specific improvements for sv_fastpushmove"
This creates infinite spawning edicts, crashing game, as seen in Arcane Dimensions This reverts commit c4b6120.
1 parent d5ec19e commit 94d1550

3 files changed

Lines changed: 6 additions & 53 deletions

File tree

Quake/pr_edict.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ cvar_t saved2 = {"saved2", "0", CVAR_ARCHIVE};
4848
cvar_t saved3 = {"saved3", "0", CVAR_ARCHIVE};
4949
cvar_t saved4 = {"saved4", "0", CVAR_ARCHIVE};
5050

51-
//
52-
static ED_AllocHook_func GLOBAL_ALLOC_HOOK = NULL;
53-
54-
ED_AllocHook_func ED_AllocSetHook (ED_AllocHook_func alloc_hook)
55-
{
56-
ED_AllocHook_func previous = GLOBAL_ALLOC_HOOK;
57-
GLOBAL_ALLOC_HOOK = alloc_hook;
58-
59-
return previous;
60-
}
61-
6251
/*
6352
=================
6453
ED_Alloc
@@ -85,8 +74,9 @@ edict_t *ED_Alloc (void)
8574
qcvm->free_list.head_index = (qcvm->free_list.head_index + 1) % MAX_EDICTS;
8675
qcvm->free_list.size -= 1;
8776

88-
if (GLOBAL_ALLOC_HOOK)
89-
GLOBAL_ALLOC_HOOK (e);
77+
// no real need, but easier for debugging...
78+
if (qcvm->free_list.size == 0)
79+
qcvm->free_list.head_index = 0;
9080

9181
return e;
9282
}
@@ -106,9 +96,6 @@ edict_t *ED_Alloc (void)
10696

10797
assert (!e->free);
10898

109-
if (GLOBAL_ALLOC_HOOK)
110-
GLOBAL_ALLOC_HOOK (e);
111-
11299
return e;
113100
}
114101

Quake/progs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ void ED_Free (edict_t *ed);
112112
void ED_RemoveFromFreeList (edict_t *ed);
113113
void ED_RebuildFreeList (bool force_free_reuse);
114114

115-
typedef void (*ED_AllocHook_func) (edict_t *allocated_ed);
116-
117-
// register a ED_AllocHook_func that will be called at each ED_Alloc,
118-
// passing the newly allocated allocated_ed. Returns the previously registered ED_AllocHook.
119-
ED_AllocHook_func ED_AllocSetHook (ED_AllocHook_func alloc_hook);
120-
121115
void ED_Print (edict_t *ed);
122116
void ED_Write (FILE *f, edict_t *ed);
123117
const char *ED_ParseEdict (const char *data, edict_t *ent);

Quake/sv_phys.c

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static void SV_PushMove (edict_t *pusher, float movetime)
499499
check = NEXT_EDICT (qcvm->edicts);
500500

501501
while (true)
502-
{
502+
{
503503
if (e >= (fast_pushers ? num_pushable_ent_cache - 1 : qcvm->num_edicts - 1 - 1))
504504
break;
505505

@@ -1242,19 +1242,6 @@ static void SV_Physics_Step (edict_t *ent)
12421242

12431243
//============================================================================
12441244

1245-
// track ED_Alloc during SV_Physics execution
1246-
static void SV_Physics_Alloc_Hook (edict_t *e)
1247-
{
1248-
assert (!e->free);
1249-
1250-
// track the newly allocated edicts in order to add them into the pushable_ent_cache.
1251-
// this is OK because by construction free edicts cannot be reused immediatly,
1252-
// so e is garanteed not to be in pushable_ent_cache already.
1253-
// since they are just allocated, they have a blank state so we add all of them
1254-
// to pushable_ent_cache regardless, and the pushable test will be made later on in SV_PushMove in any case.
1255-
pushable_ent_cache[num_pushable_ent_cache++] = e;
1256-
}
1257-
12581245
/*
12591246
================
12601247
SV_Physics
@@ -1265,11 +1252,8 @@ void SV_Physics (void)
12651252
{
12661253
int i;
12671254
int entity_cap; // For sv_freezenonclients
1268-
int *pentitycap = NULL;
12691255
edict_t *ent;
12701256

1271-
ED_AllocHook_func previous_alloc_hook = NULL;
1272-
12731257
int physics_mode;
12741258
if (qcvm->extglobals.physics_mode)
12751259
physics_mode = *qcvm->extglobals.physics_mode;
@@ -1311,16 +1295,9 @@ void SV_Physics (void)
13111295
ent = qcvm->edicts;
13121296

13131297
if (sv_freezenonclients.value && qcvm == &sv.qcvm)
1314-
{
13151298
entity_cap = svs.maxclients + 1; // Only run physics on clients and the world
1316-
// a const during edicts iteration = entity_cap;
1317-
pentitycap = &entity_cap;
1318-
}
13191299
else
1320-
{
1321-
// adapts to the actual qcvm->num_edicts possibly raising during edicts iteration itself
1322-
pentitycap = &qcvm->num_edicts;
1323-
}
1300+
entity_cap = qcvm->num_edicts;
13241301

13251302
// fill the pushable entities cache
13261303
if (sv_fastpushmove.value > 0.f)
@@ -1337,12 +1314,10 @@ void SV_Physics (void)
13371314

13381315
pushable_ent_cache[num_pushable_ent_cache++] = check;
13391316
}
1340-
1341-
previous_alloc_hook = ED_AllocSetHook (SV_Physics_Alloc_Hook);
13421317
}
13431318

13441319
// for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
1345-
for (i = 0; i < *pentitycap; i++, ent = NEXT_EDICT (ent))
1320+
for (i = 0; i < entity_cap; i++, ent = NEXT_EDICT (ent))
13461321
{
13471322
if (ent->free)
13481323
continue;
@@ -1388,7 +1363,4 @@ void SV_Physics (void)
13881363

13891364
if (!(sv_freezenonclients.value && qcvm == &sv.qcvm))
13901365
qcvm->time += host_frametime;
1391-
1392-
if (sv_fastpushmove.value > 0.f)
1393-
ED_AllocSetHook (previous_alloc_hook);
13941366
}

0 commit comments

Comments
 (0)