test: try prevent synch issues when p_setscale gets called on mobj spawn

This commit is contained in:
Alug committed 2025-05-05 20:30:34 +02:00
1 parent 94a5c1fe31
commit 2adffd32ea
3 files changed
+32 -18

No files matched your search

+23 -18
View File
@@ -740,23 +740,7 @@ void P_UnsetThingPosition(mobj_t *thing)
thing->touching_sectorlist = NULL; //to be restored by P_SetThingPosition
}
if (!(thing->flags & MF_NOBLOCKMAP))
{
/* inert things don't need to be in blockmap
*
* killough 8/11/98: simpler scheme using pointers-to-pointers for prev
* pointers, allows head node pointers to be treated like everything else
*
* Also more robust, since it doesn't depend on current position for
* unlinking. Old method required computing head node based on position
* at time of unlinking, assuming it was the same position as during
* linking.
*/
mobj_t *bnext, **bprev = thing->bprev;
if (bprev && (*bprev = bnext = thing->bnext) != NULL) // unlink from block map
bnext->bprev = bprev;
}
P_UnlinkfromBlockMap(thing);
}
void P_UnsetPrecipThingPosition(precipmobj_t *thing)
@@ -768,7 +752,7 @@ void P_UnsetPrecipThingPosition(precipmobj_t *thing)
bnext->bprev = bprev;
}
static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap)
void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap)
{
const INT32 blockx = (unsigned)(thing->x - bmaporgx) >> MAPBLOCKSHIFT;
const INT32 blocky = (unsigned)(thing->y - bmaporgy) >> MAPBLOCKSHIFT;
@@ -797,6 +781,27 @@ static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap)
}
}
void P_UnlinkfromBlockMap(mobj_t *thing)
{
if (!(thing->flags & MF_NOBLOCKMAP))
{
/* inert things don't need to be in blockmap
*
* killough 8/11/98: simpler scheme using pointers-to-pointers for prev
* pointers, allows head node pointers to be treated like everything else
*
* Also more robust, since it doesn't depend on current position for
* unlinking. Old method required computing head node based on position
* at time of unlinking, assuming it was the same position as during
* linking.
*/
mobj_t *bnext, **bprev = thing->bprev;
if (bprev && (*bprev = bnext = thing->bnext) != NULL) // unlink from block map
bnext->bprev = bprev;
}
}
//
// P_SetThingPosition
// Links a thing into both a block and a subsector
+2
View File
@@ -51,6 +51,8 @@ fixed_t P_InterceptVector(divline_t *v2, divline_t *v1);
INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld);
void P_UnsetPrecipThingPosition(precipmobj_t *thing);
void P_SetPrecipitationThingPosition(precipmobj_t *thing);
void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap);
void P_UnlinkfromBlockMap(mobj_t *thing);
void P_CreatePrecipSecNodeList(precipmobj_t *thing, fixed_t x,fixed_t y);
boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y);
+7
View File
@@ -5665,6 +5665,8 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale)
oldscale = mobj->scale; //keep for adjusting stuff below
P_UnlinkfromBlockMap(mobj);
mobj->scale = newscale;
mobj->radius = FixedMul(mobj->info->radius, newscale);
@@ -5678,6 +5680,11 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale)
player->viewheight = FixedMul(FixedDiv(player->viewheight, oldscale), newscale); // Nonono don't calculate viewheight elsewhere, this is the best place for it!
player->dashspeed = FixedMul(FixedDiv(player->dashspeed, oldscale), newscale); // Prevents the player from having to re-charge up spindash if the player grew in size
}
if (!(mobj->flags & MF_NOBLOCKMAP))
{
P_LinkToBlockMap(mobj, blocklinks);
}
}
void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target