diff --git a/src/g_game.c b/src/g_game.c index bc881c5d5..c1629af5a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5658,6 +5658,7 @@ void G_ConsGhostTic(INT32 playernum) mobj = (mobj_t *)th; if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) break; + mobj = NULL; // wasn't this one, keep searching. } if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { diff --git a/src/lua_script.c b/src/lua_script.c index 5a2f6448c..85aefbfbd 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1597,14 +1597,12 @@ void LUA_Archive(void) if (gamestate == GS_LEVEL) { for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); - } + if (th->function.acp1 == (actionf_p1)P_MobjThinker) + { + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(th, "mobj"); + } } WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. @@ -1634,13 +1632,9 @@ void LUA_UnArchive(void) do { mobjnum = READUINT32(save_p); // read a mobjnum for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj - continue; - UnArchiveExtVars(th); // apply variables - } + if (th->function.acp1 == (actionf_p1)P_MobjThinker + && ((mobj_t *)th)->mobjnum == mobjnum) // find matching mobj + UnArchiveExtVars(th); // apply variables } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode diff --git a/src/m_cheat.c b/src/m_cheat.c index abada4be5..91ca536c8 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -909,9 +909,8 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location - if (!mo->spawnpoint) - continue; - mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; + if (mo->spawnpoint) + mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; } } diff --git a/src/p_enemy.c b/src/p_enemy.c index 3a032fbf0..caa85e331 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2418,11 +2418,9 @@ void A_1upThinker(mobj_t *actor) if (closestplayer == -1 || skins[players[closestplayer].skin].spritedef.numframes <= states[S_PLAY_BOX1].frame) { // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite. actor->frame = 0; - if (actor->tracer) - { - mobj_t *tracer = actor->tracer; - P_SetTarget(&actor->tracer, NULL); - P_RemoveMobj(tracer); + if (actor->tracer) { + P_RemoveMobj(actor->tracer); + P_SetTarget(&actor->target, NULL); } return; } diff --git a/src/p_floor.c b/src/p_floor.c index bebc9a272..27460eda6 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1968,8 +1968,32 @@ void T_ThwompSector(levelspecthink_t *thwomp) } else // Not going anywhere, so look for players. { + //thinker_t *th; + //mobj_t *mo; + thwomp->direction = -1; + /* // SRB2kart 170217 - Thwomps are automatic. + // scan the thinkers to find players! + if (!rover || (rover->flags & FF_EXISTS)) + { + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator + && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } + } + }*/ + thwomp->sector->ceilspeed = 0; thwomp->sector->floorspeed = 0; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 78fcb8f63..37af3777c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4124,21 +4124,11 @@ static void P_Boss3Thinker(mobj_t *mobj) continue; mo2 = (mobj_t *)th; - - if (!mo2) - continue; - - if (mo2->type != MT_BOSS3WAYPOINT) - continue; - - if (!mo2->spawnpoint) - continue; - - if (mo2->spawnpoint->angle != mobj->threshold) - continue; - - P_SetTarget(&mobj->target, mo2); - break; + if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == mobj->threshold) + { + P_SetTarget(&mobj->target, mo2); + break; + } } if (!mobj->target) // Should NEVER happen @@ -10052,19 +10042,28 @@ void P_RemoveMobj(mobj_t *mobj) // killough 11/98: // // Remove any references to other mobjs. - P_SetTarget(&mobj->target, NULL); - P_SetTarget(&mobj->tracer, NULL); + P_SetTarget(&mobj->target, P_SetTarget(&mobj->tracer, NULL)); - if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); - if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - P_SetTarget(&mobj->hprev->hnext, mobj->hnext); + // repair hnext chain + { + mobj_t *cachenext = mobj->hnext; - P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + P_SetTarget(&mobj->hnext, NULL); + } + + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + P_SetTarget(&mobj->hprev, NULL); + } + } // clear the reference from the mapthing if (mobj->spawnpoint) - P_SetTarget(&mobj->spawnpoint->mobj, NULL); + mobj->spawnpoint->mobj = NULL; R_RemoveMobjInterpolator(mobj); @@ -11815,12 +11814,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; } else - { - P_SetTarget(&mobj->hprev, NULL); - P_SetTarget(&mobj->hnext, NULL); - } + mobj->hprev = mobj->hnext = NULL; nextmobj = mobj; } @@ -11846,9 +11844,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - P_SetTarget(&mobj->hnext, NULL); + mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11873,9 +11873,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - P_SetTarget(&mobj->hnext, NULL); + mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11958,12 +11960,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; } else - { - P_SetTarget(&mobj->hprev, NULL); - P_SetTarget(&mobj->hnext, NULL); - } + mobj->hprev = mobj->hnext = NULL; nextmobj = mobj; } @@ -12000,9 +12001,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - P_SetTarget(&mobj->hnext, NULL); + mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; nextmobj = mobj; } diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bbf934231..9a3376595 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1826,14 +1826,11 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (mo2->health != th->pointnum) - continue; - - target = mo2; - break; + if (mo2->threshold == th->sequence && mo2->health == th->pointnum) + { + target = mo2; + break; + } } if (!target) @@ -1910,23 +1907,23 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) + if (mo2->threshold == th->sequence) { - if (mo2->health == target->health - 1) + if (th->direction == -1) { - waypoint = mo2; - break; + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } } - } - else - { - if (mo2->health == target->health + 1) + else { - waypoint = mo2; - break; + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } } } } @@ -1949,22 +1946,22 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) + if (mo2->threshold == th->sequence) { - if (waypoint == NULL) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } - else - { - if (mo2->health == 0) + if (th->direction == -1) { - waypoint = mo2; - break; + if (waypoint == NULL) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } + else + { + if (mo2->health == 0) + { + waypoint = mo2; + break; + } } } } @@ -1986,23 +1983,23 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) + if (mo2->threshold == th->sequence) { - if (mo2->health == target->health - 1) + if (th->direction == -1) { - waypoint = mo2; - break; + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } } - } - else - { - if (mo2->health == target->health + 1) + else { - waypoint = mo2; - break; + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } } } } @@ -2506,31 +2503,31 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) // highest waypoint # + if (mo2->threshold == th->sequence) { - if (mo2->health == 0) - last = mo2; - else + if (th->direction == -1) // highest waypoint # { - if (first == NULL) - first = mo2; - else if (mo2->health > first->health) - first = mo2; + if (mo2->health == 0) + last = mo2; + else + { + if (first == NULL) + first = mo2; + else if (mo2->health > first->health) + first = mo2; + } } - } - else // waypoint 0 - { - if (mo2->health == 0) - first = mo2; - else + else // waypoint 0 { - if (last == NULL) - last = mo2; - else if (mo2->health > last->health) - last = mo2; + if (mo2->health == 0) + first = mo2; + else + { + if (last == NULL) + last = mo2; + else if (mo2->health > last->health) + last = mo2; + } } } } @@ -2567,6 +2564,36 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // Find the actual target movement waypoint target = first; + /*for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + { + if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold == th->sequence) + { + if (th->direction == -1) // highest waypoint # + { + if (mo2->health == first->health - 1) + { + target = mo2; + break; + } + } + else // waypoint 0 + { + if (mo2->health == first->health + 1) + { + target = mo2; + break; + } + } + } + }*/ if (!target) { diff --git a/src/p_saveg.c b/src/p_saveg.c index be393c51b..e260321be 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1881,10 +1881,8 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) continue; mobj = (mobj_t *)th; - if (mobj->mobjnum != oldposition) - continue; - - return mobj; + if (mobj->mobjnum == oldposition) + return mobj; } CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); return NULL; @@ -2883,14 +2881,12 @@ static void P_NetUnArchiveThinkers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 != (actionf_p1)T_ExecutorDelay) - continue; - - delay = (void *)currentthinker; - if (!(mobjnum = (UINT32)(size_t)delay->caller)) - continue; - - delay->caller = P_FindNewPosition(mobjnum); + if (currentthinker->function.acp1 == (actionf_p1)T_ExecutorDelay) + { + delay = (void *)currentthinker; + if ((mobjnum = (UINT32)(size_t)delay->caller)) + delay->caller = P_FindNewPosition(mobjnum); + } } } } diff --git a/src/p_spec.c b/src/p_spec.c index 2e8b09a12..370afc056 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3032,7 +3032,7 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { thinker_t *think; mobj_t *mo; - INT32 specialnum = (flag == MT_REDFLAG) ? 3 : 4; + INT32 specialnum = 0; for (think = thinkercap.next; think != &thinkercap; think = think->next) { @@ -3044,6 +3044,11 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (mo->type != flag) continue; + if (mo->type == MT_REDFLAG) + specialnum = 3; + else if (mo->type == MT_BLUEFLAG) + specialnum = 4; + if (GETSECSPECIAL(mo->subsector->sector->special, 4) == specialnum) return true; else if (mo->subsector->sector->ffloors) // Check the 3D floors @@ -3058,11 +3063,9 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) continue; - if (!(mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) - && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))) - continue; - - return true; + if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) + && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) + return true; } } } @@ -3474,11 +3477,8 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers continue; mo2 = (mobj_t *)th; - - if (mo2->type != MT_EGGTRAP) - continue; - - P_KillMobj(mo2, NULL, player->mo); + if (mo2->type == MT_EGGTRAP) + P_KillMobj(mo2, NULL, player->mo); } // clear the special so you can't push the button twice. @@ -3817,15 +3817,12 @@ DoneSection2: mo2 = (mobj_t *)th; - if (mo2->type != MT_TUBEWAYPOINT) - continue; - if (mo2->threshold != sequence) - continue; - if (mo2->health != 0) - continue; - - waypoint = mo2; - break; + if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence + && mo2->health == 0) + { + waypoint = mo2; + break; + } } if (!waypoint) @@ -3896,15 +3893,13 @@ DoneSection2: mo2 = (mobj_t *)th; - if (mo2->type != MT_TUBEWAYPOINT) - continue; - if (mo2->threshold != sequence) - continue; - - if (!waypoint) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; + if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence) + { + if (!waypoint) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } } if (!waypoint) diff --git a/src/p_user.c b/src/p_user.c index 4a74657fd..60661e4c2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2628,17 +2628,15 @@ static void P_DoZoomTube(player_t *player) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != sequence) - continue; - - if (reverse && mo2->health != player->mo->tracer->health - 1) - continue; - - if (!reverse && mo2->health != player->mo->tracer->health + 1) - continue; - - waypoint = mo2; - break; + if (mo2->threshold == sequence) + { + if ((reverse && mo2->health == player->mo->tracer->health - 1) + || (!reverse && mo2->health == player->mo->tracer->health + 1)) + { + waypoint = mo2; + break; + } + } } if (waypoint)