Fix the item box related crashes

Removed Magnet item box pulling code. It's a mess, hacky, doesn't really help in races, and breaks things. We will implement something new for it soon.
This commit is contained in:
Sryder 2018-03-13 05:20:47 +00:00
parent 71c1a5b7e2
commit 07c7bc05c5
10 changed files with 62 additions and 88 deletions

View file

@ -7115,7 +7115,6 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
"MT_INVISSPRING",
"MT_BLUEDIAG",
"MT_RANDOMITEM",
"MT_FLINGRANDOMITEM",
"MT_RANDOMITEMPOP",
"MT_MUSHROOMTRAIL",

View file

@ -2564,7 +2564,7 @@ state_t states[NUMSTATES] =
{SPR_RNDM, 21, 3, {NULL}, 0, 0, S_RANDOMITEM23}, // S_RANDOMITEM22
{SPR_RNDM, 22, 3, {NULL}, 0, 0, S_RANDOMITEM24}, // S_RANDOMITEM23
{SPR_RNDM, 23, 3, {NULL}, 0, 0, S_RANDOMITEM1}, // S_RANDOMITEM24
{SPR_RNDM, 0, 1, {A_ItemPop}, 0, 0, S_NULL}, // S_DEADRANDOMITEM
{SPR_RNDM, 0, 1, {A_ItemPop}, 0, 0, S_NULL}, // S_DEADRANDOMITEM
{SPR_RPOP, FF_FULLBRIGHT, 5, {NULL}, 0, 0, S_RANDOMITEMPOP2}, // S_RANDOMITEMPOP1
{SPR_RPOP, FF_FULLBRIGHT|1, 5, {NULL}, 0, 0, S_RANDOMITEMPOP3}, // S_RANDOMITEMPOP2
@ -14252,7 +14252,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
MT_FLINGRANDOMITEM, // reactiontime
0, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
@ -14267,48 +14267,21 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
36*FRACUNIT, // height
0, // display offset
100, // mass
0, // damage
MT_RANDOMITEMPOP, // damage
sfx_None, // activesound
MF_SLIDEME|MF_SPECIAL|MF_NOGRAVITY|MF_NOCLIPHEIGHT, // flags
S_NULL // raisestate
},
{ // MT_FLINGRANDOMITEM
-1, // doomednum
S_RANDOMITEM1, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
MT_FLINGRANDOMITEM, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
MT_RANDOMITEM, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_DEADRANDOMITEM, // deathstate
S_NULL, // xdeathstate
sfx_pop, // deathsound
60*FRACUNIT, // speed
31*FRACUNIT, // radius
16*FRACUNIT, // height
0, // display offset
100, // mass
0, // damage
sfx_None, // activesound
MF_SLIDEME|MF_SPECIAL, // flags
S_NULL // raisestate
},
{ // MT_RANDOMITEMPOP
-1, // doomednum
S_SPRK1, // spawnstate
S_INVISIBLE, // spawnstate
1, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
0, // reactiontime
sfx_None, // attacksound
S_SPRK1, // painstate
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
@ -14320,7 +14293,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
16*FRACUNIT, // radius
32*FRACUNIT, // height
0, // display offset
100, // mass
MT_SPARK, // mass
0, // damage
sfx_None, // activesound
MF_NOCLIP, // flags

View file

@ -3964,7 +3964,6 @@ typedef enum mobj_type
MT_INVISSPRING,
MT_BLUEDIAG,
MT_RANDOMITEM,
MT_FLINGRANDOMITEM,
MT_RANDOMITEMPOP,
MT_MUSHROOMTRAIL,

View file

@ -587,7 +587,7 @@ static void K_KartItemRouletteByDistance(player_t *player, ticcmd_t *cmd)
&& players[i].kartstuff[k_position] < player->kartstuff[k_position])
pdis += P_AproxDistance(P_AproxDistance(players[i].mo->x - player->mo->x,
players[i].mo->y - player->mo->y),
players[i].mo->z - player->mo->z) / mapheaderinfo[gamemap-1]->mobj_scale
players[i].mo->z - player->mo->z) / mapheaderinfo[gamemap-1]->mobj_scale
* (pingame - players[i].kartstuff[k_position])
/ ((pingame - 1) * (pingame + 1) / 3);
}
@ -654,7 +654,7 @@ static void K_KartItemRouletteByDistance(player_t *player, ticcmd_t *cmd)
//}
/*else if (gametype == GT_NEO)
{
}
else
CONS_Printf("ERROR: P_KartItemRoulette - There's no applicable game type!\n");
@ -840,7 +840,7 @@ static void K_UpdateOffroad(player_t *player)
offroadstrength = 3;
// If you are offroad, a timer starts. Depending on your weight value, the timer increments differently.
//if ((nextsector->special & 256) && nextsector->special != 768
//if ((nextsector->special & 256) && nextsector->special != 768
// && nextsector->special != 1024 && nextsector->special != 4864)
if (offroadstrength)
{
@ -4227,7 +4227,7 @@ static void K_DrawKartPositionNum(INT32 num)
// Alternate frame every three frames
switch (leveltime % 21)
{
case 1: case 2: case 3:
case 1: case 2: case 3:
localpatch = kp_winnernum[0];
break;
case 4: case 5: case 6:
@ -4998,7 +4998,7 @@ void K_drawKartHUD(void)
{
if (leveltime < 178)
K_drawStartLakitu();
if (stplyr->kartstuff[k_lapanimation])
K_drawLapLakitu();

View file

@ -740,8 +740,7 @@ static boolean P_LookForShield(mobj_t *actor)
(actor->type == MT_BLUETEAMRING && player->ctfteam != 2))
continue;
// SRB2kart - magnet item
if (player->kartstuff[k_magnettimer] //(player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT
if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT
&& (P_AproxDistance(P_AproxDistance(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST/4, player->mo->scale)))
{
P_SetTarget(&actor->tracer, player->mo);
@ -3613,7 +3612,7 @@ void A_AttractChase(mobj_t *actor)
// Turn flingrings back into regular rings if attracted.
if (actor->tracer && actor->tracer->player
&& actor->tracer->player->kartstuff[k_magnettimer] //&& (actor->tracer->player->powers[pw_shield] & SH_NOSTACK) != SH_ATTRACT
&& (actor->tracer->player->powers[pw_shield] & SH_NOSTACK) != SH_ATTRACT
&& actor->info->reactiontime && actor->type != (mobjtype_t)actor->info->reactiontime)
{
mobj_t *newring;
@ -3627,9 +3626,7 @@ void A_AttractChase(mobj_t *actor)
P_LookForShield(actor); // Go find 'em, boy!
if (actor->tracer && actor->tracer->player && actor->tracer->player->kartstuff[k_comebackmode] == 1)
;
else if (!actor->tracer
if (!actor->tracer
|| !actor->tracer->player
|| !actor->tracer->health
|| !P_CheckSight(actor, actor->tracer)) // You have to be able to SEE it...sorta
@ -8094,6 +8091,7 @@ void A_ToggleFlameJet(mobj_t* actor)
void A_ItemPop(mobj_t *actor)
{
mobj_t *remains;
mobjtype_t explode;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_ItemPop", actor))
return;
@ -8107,12 +8105,24 @@ void A_ItemPop(mobj_t *actor)
}
// de-solidify
//P_UnsetThingPosition(actor);
//actor->flags &= ~MF_SOLID;
//actor->flags |= MF_NOCLIP;
//P_SetThingPosition(actor);
P_UnsetThingPosition(actor);
actor->flags &= ~MF_SOLID;
actor->flags |= MF_NOCLIP;
P_SetThingPosition(actor);
remains = P_SpawnMobj(actor->x, actor->y, actor->z, MT_RANDOMITEMPOP);
// item explosion
explode = mobjinfo[actor->info->damage].mass;
remains = P_SpawnMobj(actor->x, actor->y,
((actor->eflags & MFE_VERTICALFLIP) ? (actor->z + 3*(actor->height/4) - FixedMul(mobjinfo[explode].height, actor->scale)) : (actor->z + actor->height/4)), explode);
if (actor->eflags & MFE_VERTICALFLIP)
{
remains->eflags |= MFE_VERTICALFLIP;
remains->flags2 |= MF2_OBJECTFLIP;
}
remains->destscale = actor->destscale;
P_SetScale(remains, actor->scale);
remains = P_SpawnMobj(actor->x, actor->y, actor->z, actor->info->damage);
remains->type = actor->type; // Transfer type information
P_UnsetThingPosition(remains);
if (sector_list)
@ -8120,25 +8130,21 @@ void A_ItemPop(mobj_t *actor)
P_DelSeclist(sector_list);
sector_list = NULL;
}
remains->flags = actor->flags; // Transfer flags
P_SetThingPosition(remains);
remains->destscale = actor->destscale;
P_SetScale(remains, actor->scale);
remains->flags = actor->flags; // Transfer flags
remains->flags2 = actor->flags2; // Transfer flags2
remains->fuse = actor->fuse; // Transfer respawn timer
remains->threshold = 68;
remains->skin = NULL;
remains->spawnpoint = actor->spawnpoint;
actor->flags2 |= MF2_BOSSNOTRAP; // Dummy flag to mark this as an exploded TV until it respawns
tmthing = remains;
P_SetTarget(&tmthing, remains);
if (actor->info->deathsound)
S_StartSound(remains, actor->info->deathsound);
if (actor->type != MT_RANDOMITEM)
{
P_RemoveMobj(actor);
return;
}
actor->target->player->kartstuff[k_itemroulette] = 1;
remains->flags2 &= ~MF2_AMBUSH;

View file

@ -1787,7 +1787,7 @@ static mobj_t *SearchMarioNode(msecnode_t *node)
break;
}
// Ignore popped monitors, too.
if (node->m_thing->flags & MF_MONITOR
if (node->m_thing->flags & MF_MONITOR || node->m_thing->type == MT_RANDOMITEM
&& node->m_thing->threshold == 68)
continue;
// Okay, we found something valid.

View file

@ -161,9 +161,6 @@ boolean P_CanPickupItem(player_t *player, boolean weapon)
if (G_BattleGametype() && player->kartstuff[k_balloon] <= 0) // No balloons in Match
return false;
if (player->kartstuff[k_magnettimer]) // You should probably collect stuff when you're attracting it :V
return true;
if (player->kartstuff[k_bootaketimer] || player->kartstuff[k_boostolentimer]
|| player->kartstuff[k_growshrinktimer] > 1 || player->kartstuff[k_goldshroomtimer]) // Item-specific timer going off
return false;
@ -417,7 +414,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
switch (special->type)
{
case MT_RANDOMITEM: // SRB2kart
case MT_FLINGRANDOMITEM:
if (G_BattleGametype() && player->kartstuff[k_balloon] <= 0)
{
if (player->kartstuff[k_comebackmode] == 0 && !player->kartstuff[k_comebacktimer])
@ -450,7 +446,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
special->momx = special->momy = special->momz = 0;
P_SetTarget(&special->target, toucher);
P_SetMobjState(special, special->info->deathstate);
P_KillMobj(special, toucher, toucher);
break;
// ***************************************** //
// Rings, coins, spheres, weapon panels, etc //
@ -2128,7 +2124,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
// if killed by a player
if (source && source->player)
{
if (target->flags & MF_MONITOR)
if (target->flags & MF_MONITOR || target->type == MT_RANDOMITEM)
{
P_SetTarget(&target->target, source);
source->player->numboxes++;

View file

@ -1371,7 +1371,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
{
case MT_FLINGRING:
case MT_FLINGCOIN:
case MT_FLINGRANDOMITEM: // SRB2kart
case MT_FLINGEMERALD:
case MT_BOUNCERING:
case MT_RAILRING:
@ -2357,7 +2356,6 @@ static boolean P_ZMovement(mobj_t *mo)
case MT_BLUETEAMRING:
case MT_FLINGRING:
case MT_FLINGCOIN:
case MT_FLINGRANDOMITEM:
case MT_FLINGEMERALD:
// Remove flinged stuff from death pits.
if (P_CheckDeathPitCollide(mo))
@ -2550,7 +2548,6 @@ static boolean P_ZMovement(mobj_t *mo)
// Flingrings bounce
if (mo->type == MT_FLINGRING
|| mo->type == MT_FLINGCOIN
|| mo->type == MT_FLINGRANDOMITEM
|| P_WeaponOrPanel(mo->type)
|| mo->type == MT_FLINGEMERALD
|| mo->type == MT_BIGTUMBLEWEED
@ -5968,9 +5965,6 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
fixed_t ty = dest->y;
fixed_t tz = dest->z + (dest->height/2); // Aim for center
if (source->type == MT_RANDOMITEM || source->type == MT_FLINGRANDOMITEM) // SRB2kart - item boxes are sorta tall
tz = dest->z;
if (!dest || dest->health <= 0 || !dest->player || !source->tracer)
return;
@ -7696,7 +7690,6 @@ void P_MobjThinker(mobj_t *mobj)
case MT_BLUEBALL:
case MT_REDTEAMRING:
case MT_BLUETEAMRING:
case MT_RANDOMITEM:
// No need to check water. Who cares?
P_RingThinker(mobj);
if (mobj->flags2 & MF2_NIGHTSPULL)
@ -7707,7 +7700,6 @@ void P_MobjThinker(mobj_t *mobj)
// Flung items
case MT_FLINGRING:
case MT_FLINGCOIN:
case MT_FLINGRANDOMITEM:
if (mobj->flags2 & MF2_NIGHTSPULL)
P_NightsItemChase(mobj);
else
@ -8239,6 +8231,20 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
}
P_RemoveMobj(mobj); // make sure they disappear
return;
case MT_RANDOMITEM:
// Respawn from mapthing if you have one!
if (mobj->spawnpoint)
{
P_SpawnMapThing(mobj->spawnpoint);
newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing
}
else
newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type);
// Transfer flags2 (strongbox, objectflip)
newmobj->flags2 = mobj->flags2;
P_RemoveMobj(mobj); // make sure they disappear
return;
case MT_METALSONIC_BATTLE:
break; // don't remove
case MT_SPIKE:
@ -8293,7 +8299,6 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
#ifdef ESLOPE // Sliding physics for slidey mobjs!
if (mobj->type == MT_FLINGRING
|| mobj->type == MT_FLINGCOIN
|| mobj->type == MT_FLINGRANDOMITEM
|| P_WeaponOrPanel(mobj->type)
|| mobj->type == MT_FLINGEMERALD
|| mobj->type == MT_BIGTUMBLEWEED
@ -8737,12 +8742,12 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
case MT_BANANAITEM: case MT_BANANASHIELD:
case MT_TRIPLEBANANASHIELD1: case MT_TRIPLEBANANASHIELD2: case MT_TRIPLEBANANASHIELD3:
case MT_GREENITEM: case MT_GREENSHIELD:
case MT_TRIPLEGREENSHIELD1: case MT_TRIPLEGREENSHIELD2: case MT_TRIPLEGREENSHIELD3:
case MT_REDITEM: case MT_REDSHIELD: case MT_REDITEMDUD:
case MT_TRIPLEGREENSHIELD1: case MT_TRIPLEGREENSHIELD2: case MT_TRIPLEGREENSHIELD3:
case MT_REDITEM: case MT_REDSHIELD: case MT_REDITEMDUD:
case MT_TRIPLEREDSHIELD1: case MT_TRIPLEREDSHIELD2: case MT_TRIPLEREDSHIELD3:
case MT_BATTLEBALLOON: case MT_FIREBALL:
case MT_FAKEITEM: case MT_FAKESHIELD:
case MT_BOMBITEM: case MT_BOMBSHIELD:
case MT_FAKEITEM: case MT_FAKESHIELD:
case MT_BOMBITEM: case MT_BOMBSHIELD:
P_SpawnShadowMobj(mobj);
default:
break;
@ -8985,7 +8990,6 @@ void P_RemoveMobj(mobj_t *mobj)
if (mobj->spawnpoint &&
(mobj->type == MT_RING
|| mobj->type == MT_COIN
|| mobj->type == MT_RANDOMITEM
|| mobj->type == MT_BLUEBALL
|| mobj->type == MT_REDTEAMRING
|| mobj->type == MT_BLUETEAMRING
@ -9499,7 +9503,7 @@ void P_RespawnBattleSpecials(void)
// pull it from the que
iquetail = (iquetail+1)&(ITEMQUESIZE-1);
}
numgotboxes = 0;
}
@ -10963,7 +10967,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
mthing->mobj = mobj;
}
// All manners of rings and coins
else if (mthing->type == mobjinfo[MT_RING].doomednum || mthing->type == mobjinfo[MT_COIN].doomednum || mthing->type == mobjinfo[MT_RANDOMITEM].doomednum ||
else if (mthing->type == mobjinfo[MT_RING].doomednum || mthing->type == mobjinfo[MT_COIN].doomednum ||
mthing->type == mobjinfo[MT_REDTEAMRING].doomednum || mthing->type == mobjinfo[MT_BLUETEAMRING].doomednum)
{
mobjtype_t ringthing = MT_RING;
@ -10984,9 +10988,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
case 309: // No team rings in non-CTF
ringthing = (gametype == GT_CTF) ? MT_BLUETEAMRING : MT_RING;
break;
case 2000: // SRB2kart
ringthing = MT_RANDOMITEM;
break;
default:
// Spawn rings as blue spheres in special stages, ala S3+K.
if (G_IsSpecialStage(gamemap) && useNightsSS)

View file

@ -827,7 +827,7 @@ void P_ReloadRings(void)
continue;
}
if (!(mo->type == MT_RING || mo->type == MT_NIGHTSWING || mo->type == MT_COIN
|| mo->type == MT_BLUEBALL || mo->type == MT_RANDOMITEM))
|| mo->type == MT_BLUEBALL))
continue;
// Don't auto-disintegrate things being pulled to us

View file

@ -9444,7 +9444,7 @@ void P_PlayerThink(player_t *player)
mo2 = (mobj_t *)th;
if (!(mo2->type == MT_NIGHTSWING || mo2->type == MT_RING || mo2->type == MT_COIN
|| mo2->type == MT_BLUEBALL || mo2->type == MT_RANDOMITEM))
|| mo2->type == MT_BLUEBALL))
continue;
if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale))