sector.c: factor out goto soup in P_CheckSectors() into function.

git-svn-id: https://svn.eduke32.com/eduke32@4283 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-01-31 21:12:59 +00:00
parent 6de687ba86
commit aa547e8c16

View file

@ -2907,11 +2907,18 @@ static int32_t our_neartag_blacklist(int32_t i)
return sprite[i].picnum >= SECTOREFFECTOR__STATIC && sprite[i].picnum <= GPSPEED__STATIC; return sprite[i].picnum >= SECTOREFFECTOR__STATIC && sprite[i].picnum <= GPSPEED__STATIC;
} }
static void G_ClearCameras(DukePlayer_t *p)
{
G_ClearCameraView(p);
if (I_EscapeTrigger())
I_EscapeTriggerClear();
}
void P_CheckSectors(int32_t snum) void P_CheckSectors(int32_t snum)
{ {
int32_t i = -1; int32_t i = -1;
DukePlayer_t *const p = g_player[snum].ps; DukePlayer_t *const p = g_player[snum].ps;
int16_t hitscanwall = -1; // CAUTION with goto's!!!
if (p->cursectnum > -1) if (p->cursectnum > -1)
switch (sector[p->cursectnum].lotag) switch (sector[p->cursectnum].lotag)
@ -2975,8 +2982,8 @@ void P_CheckSectors(int32_t snum)
{ {
if (klabs(g_player[snum].sync->svel) > 768 || klabs(g_player[snum].sync->fvel) > 768) if (klabs(g_player[snum].sync->svel) > 768 || klabs(g_player[snum].sync->fvel) > 768)
{ {
i = -1; G_ClearCameras(p);
goto CLEARCAMERAS; return;
} }
} }
@ -2984,13 +2991,12 @@ void P_CheckSectors(int32_t snum)
p->toggle_key_flag = 0; p->toggle_key_flag = 0;
else if (!p->toggle_key_flag) else if (!p->toggle_key_flag)
{ {
int16_t hitscanwall;
if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_ESCAPE)) if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_ESCAPE))
{ {
if (p->newowner >= 0) if (p->newowner >= 0)
{ G_ClearCameras(p);
i = -1;
goto CLEARCAMERAS;
}
return; return;
} }
@ -3152,7 +3158,6 @@ void P_CheckSectors(int32_t snum)
case VIEWSCREEN__STATIC: case VIEWSCREEN__STATIC:
case VIEWSCREEN2__STATIC: case VIEWSCREEN2__STATIC:
{
// Try to find a camera sprite for the viewscreen. // Try to find a camera sprite for the viewscreen.
for (SPRITES_OF(STAT_ACTOR, i)) for (SPRITES_OF(STAT_ACTOR, i))
{ {
@ -3179,17 +3184,8 @@ void P_CheckSectors(int32_t snum)
return; return;
} }
} }
}
CLEARCAMERAS:
if (i < 0)
G_ClearCameraView(p);
else if (p->newowner >= 0)
p->newowner = -1;
if (I_EscapeTrigger())
I_EscapeTriggerClear();
G_ClearCameras(p);
return; return;
} // switch } // switch
} }
@ -3199,8 +3195,8 @@ CLEARCAMERAS:
if (p->newowner >= 0) if (p->newowner >= 0)
{ {
i = -1; G_ClearCameras(p);
goto CLEARCAMERAS; return;
} }
if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1)
@ -3222,8 +3218,8 @@ CLEARCAMERAS:
} }
else if (p->newowner >= 0) else if (p->newowner >= 0)
{ {
i = -1; G_ClearCameras(p);
goto CLEARCAMERAS; return;
} }
} }