diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 041bad1db..7d5c95feb 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -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 } diff --git a/src/p_setup.c b/src/p_setup.c index 886d1d0ee..ddbcab495 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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<y<z<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<y<z<x<y<z<x<y<z<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)