fix and cleanup P_SpawnMapThings
-split emeraldhunt handling into its own function -merge hoop spawn loop into the main mapthing spawnloop -continue early for things like rings and coins - reduce the amount of R_PointInSubsector on maps with nights hoops hopefully reduces levelload time slightly
This commit is contained in:
1 parent
abf9885564
commit
6643dc7ad0
2 files changed
+74
-71
No files matched your search
+1
-1
@@ -842,7 +842,7 @@ void P_SetThingPosition(mobj_t *thing)
|
||||
// at sector_t->touching_thinglist) are broken. When a node is
|
||||
// added, new sector links are created.
|
||||
|
||||
P_CreateSecNodeList(thing,thing->x,thing->y);
|
||||
P_CreateSecNodeList(thing, thing->x, thing->y);
|
||||
thing->touching_sectorlist = sector_list; // Attach to Thing's mobj_t
|
||||
sector_list = NULL; // clear for next time
|
||||
}
|
||||
|
||||
+73
-70
@@ -924,6 +924,47 @@ static void P_LoadThings(UINT8 *data)
|
||||
}
|
||||
}
|
||||
|
||||
static void P_SpawnEmeraldHunt(void)
|
||||
{
|
||||
INT32 i;
|
||||
INT32 emer[3] = {0, 0, 0};
|
||||
INT32 timeout = 0; // keeps from getting stuck
|
||||
fixed_t x, y, z;
|
||||
|
||||
// increment spawn numbers because zero is valid.
|
||||
emer[0] = (P_RandomKey(numhuntemeralds)) + 1;
|
||||
while (timeout++ < 100)
|
||||
{
|
||||
emer[1] = (P_RandomKey(numhuntemeralds)) + 1;
|
||||
|
||||
if (emer[1] != emer[0])
|
||||
break;
|
||||
}
|
||||
|
||||
timeout = 0;
|
||||
while (timeout++ < 100)
|
||||
{
|
||||
emer[2] = (P_RandomKey(numhuntemeralds)) + 1;
|
||||
|
||||
if (emer[2] != emer[1] && emer[2] != emer[0])
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (!emer[i])
|
||||
continue;
|
||||
|
||||
// decrement spawn values to the actual number because zero is valid.
|
||||
x = huntemeralds[emer[i] - 1]->x<<FRACBITS;
|
||||
y = huntemeralds[emer[i] - 1]->y<<FRACBITS;
|
||||
z = huntemeralds[emer[i] - 1]->z<<FRACBITS;
|
||||
|
||||
// spawn emerald
|
||||
P_SpawnMobj(x, y, z, MT_EMERHUNT);
|
||||
}
|
||||
}
|
||||
|
||||
static void P_SpawnMapThings(void)
|
||||
{
|
||||
size_t i;
|
||||
@@ -934,16 +975,12 @@ static void P_SpawnMapThings(void)
|
||||
// Spawn axis points first so they are at the front of the list for fast searching.
|
||||
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
|
||||
{
|
||||
switch (mt->type)
|
||||
if (mt->type == 1700 || // MT_AXIS
|
||||
mt->type == 1701 || // MT_AXISTRANSFER
|
||||
mt->type == 1702) // MT_AXISTRANSFERLINE
|
||||
{
|
||||
case 1700: // MT_AXIS
|
||||
case 1701: // MT_AXISTRANSFER
|
||||
case 1702: // MT_AXISTRANSFERLINE
|
||||
mt->mobj = NULL;
|
||||
P_SpawnMapThing(mt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
mt->mobj = NULL;
|
||||
P_SpawnMapThing(mt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,77 +991,43 @@ static void P_SpawnMapThings(void)
|
||||
// Z for objects
|
||||
mt->z = (INT16)(P_GetSectorFloorZAt(mtsector, (mt->x << FRACBITS), (mt->y << FRACBITS))) >> FRACBITS;
|
||||
|
||||
if (mt->type == 1700 // MT_AXIS
|
||||
|| mt->type == 1701 // MT_AXISTRANSFER
|
||||
|| mt->type == 1702) // MT_AXISTRANSFERLINE
|
||||
if (mt->type == 1700 || // MT_AXIS
|
||||
mt->type == 1701 || // MT_AXISTRANSFER
|
||||
mt->type == 1702) // MT_AXISTRANSFERLINE
|
||||
{
|
||||
continue; // These were already spawned
|
||||
}
|
||||
|
||||
mt->mobj = NULL;
|
||||
|
||||
// srb2kart - ignore rings, coins and item patterns!
|
||||
if (mt->type == 300 || mt->type == 308 || mt->type == 309 ||
|
||||
(mt->type >= 600 && mt->type <= 609) ||
|
||||
mt->type == 1706 || mt->type == 1800)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// spawn hoops
|
||||
if (mt->type == 1705 || mt->type == 1713)
|
||||
{
|
||||
// Z for objects Tails 05-26-2002
|
||||
mt->z = (INT16)(mtsector->floorheight >> FRACBITS);
|
||||
|
||||
P_SpawnHoops(mt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mt->type == mobjinfo[MT_RANDOMITEM].doomednum)
|
||||
nummapboxes++;
|
||||
|
||||
mt->mobj = NULL;
|
||||
// Everything else
|
||||
P_SpawnMapThing(mt);
|
||||
}
|
||||
|
||||
// random emeralds for hunt
|
||||
if (numhuntemeralds)
|
||||
{
|
||||
INT32 emer1, emer2, emer3;
|
||||
INT32 timeout = 0; // keeps from getting stuck
|
||||
|
||||
emer1 = emer2 = emer3 = 0;
|
||||
|
||||
//increment spawn numbers because zero is valid.
|
||||
emer1 = (P_RandomKey(numhuntemeralds)) + 1;
|
||||
while (timeout++ < 100)
|
||||
{
|
||||
emer2 = (P_RandomKey(numhuntemeralds)) + 1;
|
||||
|
||||
if (emer2 != emer1)
|
||||
break;
|
||||
}
|
||||
|
||||
timeout = 0;
|
||||
while (timeout++ < 100)
|
||||
{
|
||||
emer3 = (P_RandomKey(numhuntemeralds)) + 1;
|
||||
|
||||
if (emer3 != emer2 && emer3 != emer1)
|
||||
break;
|
||||
}
|
||||
|
||||
//decrement spawn values to the actual number because zero is valid.
|
||||
if (emer1)
|
||||
P_SpawnMobj(huntemeralds[emer1 - 1]->x<<FRACBITS,
|
||||
huntemeralds[emer1 - 1]->y<<FRACBITS,
|
||||
huntemeralds[emer1 - 1]->z<<FRACBITS, MT_EMERHUNT);
|
||||
|
||||
if (emer2)
|
||||
P_SpawnMobj(huntemeralds[emer2 - 1]->x<<FRACBITS,
|
||||
huntemeralds[emer2 - 1]->y<<FRACBITS,
|
||||
huntemeralds[emer2 - 1]->z<<FRACBITS, MT_EMERHUNT);
|
||||
|
||||
if (emer3)
|
||||
P_SpawnMobj(huntemeralds[emer3 - 1]->x<<FRACBITS,
|
||||
huntemeralds[emer3 - 1]->y<<FRACBITS,
|
||||
huntemeralds[emer3 - 1]->z<<FRACBITS, MT_EMERHUNT);
|
||||
}
|
||||
|
||||
// Run through the list of mapthings again to spawn hoops and rings
|
||||
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
|
||||
{
|
||||
if (mt->type == 300 || mt->type == 308 || mt->type == 309
|
||||
|| mt->type == 1706 || (mt->type >= 600 && mt->type <= 609)
|
||||
|| mt->type == 1705 || mt->type == 1713 || mt->type == 1800)
|
||||
{
|
||||
mt->mobj = NULL;
|
||||
|
||||
// Z for objects Tails 05-26-2002
|
||||
mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector->floorheight>>FRACBITS);
|
||||
|
||||
P_SpawnHoops(mt);
|
||||
}
|
||||
}
|
||||
P_SpawnEmeraldHunt();
|
||||
}
|
||||
|
||||
static void P_SpawnEmblems(boolean loademblems)
|
||||
|
||||
Reference in new issue
Block a user