20% of sector.cpp

# Conflicts:
#	source/games/duke/src/zz_sector.cpp
This commit is contained in:
Christoph Oelckers 2020-05-10 16:53:09 +02:00
parent c8cb0e4efd
commit 536e3c886c
13 changed files with 1136 additions and 932 deletions

View file

@ -374,6 +374,10 @@ inline int badguy(void const* const pSprite)
return A_CheckEnemySprite(pSprite);
}
inline int badguypic(int tile)
{
return A_CheckEnemyTile(tile);
}
int G_WakeUp(spritetype* const pSprite, int const playerNum);
inline int wakeup(int sn, int pn)
{

View file

@ -105,6 +105,7 @@ G_EXTERN int32_t myminlag[MAXPLAYERS], mymaxlag, otherminlag, bufferjitter;
G_EXTERN int32_t g_networkBroadcastMode, g_movesPerPacket;
G_EXTERN int32_t g_animWallCnt;
#define numanimwalls g_animWallCnt
G_EXTERN int32_t g_animateCnt;
#define animatecnt g_animateCnt
G_EXTERN int32_t g_cloudCnt;
@ -141,8 +142,11 @@ G_EXTERN int32_t screenpeek;
G_EXTERN int16_t g_animateSect[MAXANIMATES];
#define animatesect g_animateSect
G_EXTERN int32_t *g_animatePtr[MAXANIMATES];
#define animateptr g_animatePtr
G_EXTERN int32_t g_animateGoal[MAXANIMATES];
#define animategoal g_animateGoal
G_EXTERN int32_t g_animateVel[MAXANIMATES];
#define animatevel g_animateVel
G_EXTERN int16_t g_cloudSect[256];
G_EXTERN int16_t g_cloudX;
@ -315,13 +319,13 @@ inline void restoreinterpolations()
}
inline int setinterpolation(int32_t* posptr)
{
G_SetInterpolation(posptr);
return G_SetInterpolation(posptr);
}
inline int stopinterpolation(int32_t* posptr)
inline void stopinterpolation(int32_t* posptr)
{
G_SetInterpolation(posptr);
}
inline int dointerpolations(int smoothratio)
inline void dointerpolations(int smoothratio)
{
G_DoInterpolations(smoothratio);
}

View file

@ -277,6 +277,7 @@ typedef struct player_struct {
#define scuba_amount inv_amount[GET_SCUBA]
#define boot_amount inv_amount[GET_BOOTS]
#define raat609 level_end_timer // name in RRGDX is 'MamaEnd'
#define raat5dd sea_sick_stat
// KEEPINSYNC lunatic/_defs_game.lua
@ -408,11 +409,7 @@ void P_CheckWeapon(DukePlayer_t *pPlayer);
void P_DisplayScuba(void);
void P_DisplayWeapon(void);
void P_DropWeapon(int playerNum);
int P_FindOtherPlayer(int playerNum, int32_t *pDist);
inline int findotherplayer(int p, int* d)
{
return P_FindOtherPlayer(p, d);
}
int findotherplayer(int p, int* d);
void P_FragPlayer(int playerNum);
#ifdef YAX_ENABLE
void getzsofslope_player(int sectNum, int playerX, int playerY, int32_t *pCeilZ, int32_t *pFloorZ);

View file

@ -128,28 +128,16 @@ inline void checkhitwall(int spr, int wal, int x, int y, int z, int w)
vec3_t vec{ x, y, z };
A_DamageWall(spr, wal, &vec, w);
}
int __fastcall A_FindPlayer(const spritetype *pSprite,int32_t *dist);
inline int findplayer(const spritetype* pSprite, int32_t* dist)
{
return A_FindPlayer(pSprite, dist);
}
int findplayer(const spritetype* pSprite, int32_t* dist);
void operatejaildoors(int hitag);
void G_AlignWarpElevators(void);
bool isadoorwall(int tileNum);
bool isablockdoor(int tileNum);
void G_AnimateCamSprite(int smoothRatio);
void G_AnimateWalls(void);
int G_ActivateWarpElevators(int s,int warpDir);
inline int activatewarpelevators(int s, int w)
{
return G_ActivateWarpElevators(s, w);
}
void animatewalls(void);
bool activatewarpelevators(int s, int w);
int check_activator_motion(int lotag);
void G_DoSectorAnimations(void);
void G_OperateActivators(int lotag, int playerNum);
inline void operateactivators(int l, int w)
{
G_OperateActivators(l, w);
}
void operateactivators(int l, int w);
void G_OperateForceFields(int spriteNum,int wallTag);
inline void operateforcefields(int s, int w)
{
@ -160,29 +148,17 @@ inline void operatemasterswitches(int l)
{
return G_OperateMasterSwitches(l);
}
void G_OperateRespawns(int lotag);
void G_OperateSectors(int sectNum,int spriteNum);
inline void operatesectors(int s, int i)
{
G_OperateSectors(s, i);
}
void operaterespawns(int lotag);
void operatesectors(int s, int i);
void P_HandleSharedKeys(int playerNum);
int GetAnimationGoal(const int32_t *animPtr);
inline int getanimationgoal(const int32_t* animPtr)
{
return GetAnimationGoal(animPtr);
}
int getanimationgoal(const int32_t* animPtr);
bool isanearoperator(int lotag);
bool isanunderoperator(int lotag);
int P_ActivateSwitch(int playerNum, int wallOrSprite, int nSwitchType);
void P_CheckSectors(int playerNum);
void Sect_DamageCeiling(int sectNum);
inline void checkhitceiling(int sec) { Sect_DamageCeiling(sec); }
int SetAnimation(int sectNum,int32_t *animPtr,int goalVal,int animVel);
inline int setanimation(int sectNum, int32_t* animPtr, int goalVal, int animVel)
{
return SetAnimation(sectNum, animPtr, goalVal, animVel);
}
int setanimation(short animsect, int* animptr, int thegoal, int thevel);
void G_DoFurniture(int wallNum, int sectNum, int playerNum);
void dotorch();

View file

@ -31,10 +31,13 @@ source as it is released.
*/
//-------------------------------------------------------------------------
#include <utility>
#include "ns.h"
#include "global.h"
#include "sounds_common.h"
using std::min;
using std::max;
// PRIMITIVE
BEGIN_DUKE_NS
@ -46,12 +49,25 @@ BEGIN_DUKE_NS
bool isadoorwall_d(int dapic);
bool isadoorwall_r(int dapic);
void animatewalls_d(void);
void animatewalls_r(void);
void operaterespawns_d(int low);
void operaterespawns_r(int low);
bool isadoorwall(int dapic)
{
return isRR() ? isadoorwall_r(dapic) : isadoorwall_d(dapic);
}
void animatewalls()
{
if (isRR()) animatewalls_r(); else animatewalls_d();
}
void operaterespawns(int low)
{
if (isRR()) operaterespawns_r(low); else operaterespawns_d(low);
}
//---------------------------------------------------------------------------
//
@ -213,5 +229,805 @@ bool isanearoperator(int lotag)
return false;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int findplayer(const spritetype* s, int* d)
{
short j, closest_player;
int x, closest;
if (ud.multimode < 2)
{
*d = abs(ps[myconnectindex].oposx - s->x) + abs(ps[myconnectindex].oposy - s->y) + ((abs(ps[myconnectindex].oposz - s->z + (28 << 8))) >> 4);
return myconnectindex;
}
closest = 0x7fffffff;
closest_player = 0;
for (j = connecthead; j >= 0; j = connectpoint2[j])
{
x = abs(ps[j].oposx - s->x) + abs(ps[j].oposy - s->y) + ((abs(ps[j].oposz - s->z + (28 << 8))) >> 4);
if (x < closest && sprite[ps[j].i].extra > 0)
{
closest_player = j;
closest = x;
}
}
*d = closest;
return closest_player;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int findotherplayer(int p, int* d)
{
short j, closest_player;
int x, closest;
closest = 0x7fffffff;
closest_player = p;
for (j = connecthead; j >= 0; j = connectpoint2[j])
if (p != j && sprite[ps[j].i].extra > 0)
{
x = abs(ps[j].oposx - ps[p].posx) + abs(ps[j].oposy - ps[p].posy) + (abs(ps[j].oposz - ps[p].posz) >> 4);
if (x < closest)
{
closest_player = j;
closest = x;
}
}
*d = closest;
return closest_player;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void doanimations(void)
{
int i, j, a, p, v, dasect;
for (i = animatecnt - 1; i >= 0; i--)
{
a = *animateptr[i];
v = animatevel[i] * TICSPERFRAME;
dasect = animatesect[i];
if (a == animategoal[i])
{
stopinterpolation(animateptr[i]);
animatecnt--;
animateptr[i] = animateptr[animatecnt];
animategoal[i] = animategoal[animatecnt];
animatevel[i] = animatevel[animatecnt];
animatesect[i] = animatesect[animatecnt];
if (sector[animatesect[i]].lotag == ST_18_ELEVATOR_DOWN || sector[animatesect[i]].lotag == ST_19_ELEVATOR_UP)
if (animateptr[i] == &sector[animatesect[i]].ceilingz)
continue;
if ((sector[dasect].lotag & 0xff) != ST_22_SPLITTING_DOOR)
callsound(dasect, -1);
continue;
}
if (v > 0) { a = min(a + v, animategoal[i]); }
else { a = max(a + v, animategoal[i]); }
if (animateptr[i] == &sector[animatesect[i]].floorz)
{
for (p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].cursectnum == dasect)
if ((sector[dasect].floorz - ps[p].posz) < (64 << 8))
if (sprite[ps[p].i].owner >= 0)
{
ps[p].posz += v;
ps[p].poszv = 0;
#if 0
if (p == myconnectindex)
{
myz += v;
myzvel = 0;
myzbak[((movefifoplc - 1) & (MOVEFIFOSIZ - 1))] = ps[p].posz;
}
#endif
}
for (j = headspritesect[dasect]; j >= 0; j = nextspritesect[j])
if (sprite[j].statnum != STAT_EFFECTOR)
{
hittype[j].bposz = sprite[j].z;
sprite[j].z += v;
hittype[j].floorz = sector[dasect].floorz + v;
}
}
*animateptr[i] = a;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int getanimationgoal(const int* animptr)
{
int i, j;
j = -1;
for (i = animatecnt - 1; i >= 0; i--)
if (animptr == (int*)animateptr[i])
{
j = i;
break;
}
return(j);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int setanimation(short animsect, int* animptr, int thegoal, int thevel)
{
int i, j;
if (animatecnt >= MAXANIMATES - 1)
return(-1);
j = animatecnt;
for (i = 0; i < animatecnt; i++)
if (animptr == animateptr[i])
{
j = i;
break;
}
animatesect[j] = animsect;
animateptr[j] = animptr;
animategoal[j] = thegoal;
if (thegoal >= *animptr)
animatevel[j] = thevel;
else
animatevel[j] = -thevel;
if (j == animatecnt) animatecnt++;
setinterpolation(animptr);
return(j);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool activatewarpelevators(int s, int d) //Parm = sectoreffectornum
{
short i, sn;
sn = sprite[s].sectnum;
// See if the sector exists
i = headspritestat[3];
while (i >= 0)
{
if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
if (sprite[i].hitag == sprite[s].hitag)
if ((abs(sector[sn].floorz - hittype[s].temp_data[2]) > sprite[i].yvel) ||
(sector[sprite[i].sectnum].hitag == (sector[sn].hitag - d)))
break;
i = nextspritestat[i];
}
if (i == -1)
{
d = 0;
return 1; // No find
}
else
{
if (d == 0)
spritesound(ELEVATOR_OFF, s);
else spritesound(ELEVATOR_ON, s);
}
i = headspritestat[3];
while (i >= 0)
{
if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
if (sprite[i].hitag == sprite[s].hitag)
{
hittype[i].temp_data[0] = d;
hittype[i].temp_data[1] = d; //Make all check warp
}
i = nextspritestat[i];
}
return 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operatesectors(int sn, int ii)
{
int j=0, l, q, startwall, endwall;
int i;
char sect_error;
sectortype* sptr;
sect_error = 0;
sptr = &sector[sn];
switch (sptr->lotag & (0xffff - 49152))
{
case 41:
if (isRR()) operatejaildoors(sptr->hitag);
break;
case 7:
if (!isRR()) break;
startwall = sptr->wallptr;
endwall = startwall + sptr->wallnum;
for (j = startwall; j < endwall; j++)
{
setanimation(sn, &wall[j].x, wall[j].x + 1024, 4);
setanimation(sn, &wall[wall[j].nextwall].x, wall[wall[j].nextwall].x + 1024, 4);
}
break;
case ST_30_ROTATE_RISE_BRIDGE:
j = sector[sn].hitag;
if (hittype[j].tempang == 0 ||
hittype[j].tempang == 256)
callsound(sn, ii);
if (sprite[j].extra == 1)
sprite[j].extra = 3;
else sprite[j].extra = 1;
break;
case ST_31_TWO_WAY_TRAIN:
j = sector[sn].hitag;
if (hittype[j].temp_data[4] == 0)
hittype[j].temp_data[4] = 1;
callsound(sn, ii);
break;
case ST_26_SPLITTING_ST_DOOR: //The split doors
i = getanimationgoal(&sptr->ceilingz);
if (i == -1) //if the door has stopped
{
haltsoundhack = 1;
sptr->lotag &= 0xff00;
sptr->lotag |= ST_22_SPLITTING_DOOR;
operatesectors(sn, ii);
sptr->lotag &= 0xff00;
sptr->lotag |= ST_9_SLIDING_ST_DOOR;
operatesectors(sn, ii);
sptr->lotag &= 0xff00;
sptr->lotag |= ST_26_SPLITTING_ST_DOOR;
}
return;
case ST_9_SLIDING_ST_DOOR:
{
int dax, day, dax2, day2, sp;
int wallfind[2];
startwall = sptr->wallptr;
endwall = startwall + sptr->wallnum - 1;
sp = sptr->extra >> 4;
//first find center point by averaging all points
dax = 0L, day = 0L;
for (i = startwall; i <= endwall; i++)
{
dax += wall[i].x;
day += wall[i].y;
}
dax /= (endwall - startwall + 1);
day /= (endwall - startwall + 1);
//find any points with either same x or same y coordinate
// as center (dax, day) - should be 2 points found.
wallfind[0] = -1;
wallfind[1] = -1;
for (i = startwall; i <= endwall; i++)
if ((wall[i].x == dax) || (wall[i].y == day))
{
if (wallfind[0] == -1)
wallfind[0] = i;
else wallfind[1] = i;
}
for (j = 0; j < 2; j++)
{
if ((wall[wallfind[j]].x == dax) && (wall[wallfind[j]].y == day))
{
//find what direction door should open by averaging the
// 2 neighboring points of wallfind[0] & wallfind[1].
i = wallfind[j] - 1; if (i < startwall) i = endwall;
dax2 = ((wall[i].x + wall[wall[wallfind[j]].point2].x) >> 1) - wall[wallfind[j]].x;
day2 = ((wall[i].y + wall[wall[wallfind[j]].point2].y) >> 1) - wall[wallfind[j]].y;
if (dax2 != 0)
{
dax2 = wall[wall[wall[wallfind[j]].point2].point2].x;
dax2 -= wall[wall[wallfind[j]].point2].x;
setanimation(sn, &wall[wallfind[j]].x, wall[wallfind[j]].x + dax2, sp);
setanimation(sn, &wall[i].x, wall[i].x + dax2, sp);
setanimation(sn, &wall[wall[wallfind[j]].point2].x, wall[wall[wallfind[j]].point2].x + dax2, sp);
callsound(sn, ii);
}
else if (day2 != 0)
{
day2 = wall[wall[wall[wallfind[j]].point2].point2].y;
day2 -= wall[wall[wallfind[j]].point2].y;
setanimation(sn, &wall[wallfind[j]].y, wall[wallfind[j]].y + day2, sp);
setanimation(sn, &wall[i].y, wall[i].y + day2, sp);
setanimation(sn, &wall[wall[wallfind[j]].point2].y, wall[wall[wallfind[j]].point2].y + day2, sp);
callsound(sn, ii);
}
}
else
{
i = wallfind[j] - 1; if (i < startwall) i = endwall;
dax2 = ((wall[i].x + wall[wall[wallfind[j]].point2].x) >> 1) - wall[wallfind[j]].x;
day2 = ((wall[i].y + wall[wall[wallfind[j]].point2].y) >> 1) - wall[wallfind[j]].y;
if (dax2 != 0)
{
setanimation(sn, &wall[wallfind[j]].x, dax, sp);
setanimation(sn, &wall[i].x, dax + dax2, sp);
setanimation(sn, &wall[wall[wallfind[j]].point2].x, dax + dax2, sp);
callsound(sn, ii);
}
else if (day2 != 0)
{
setanimation(sn, &wall[wallfind[j]].y, day, sp);
setanimation(sn, &wall[i].y, day + day2, sp);
setanimation(sn, &wall[wall[wallfind[j]].point2].y, day + day2, sp);
callsound(sn, ii);
}
}
}
}
return;
case ST_15_WARP_ELEVATOR://Warping elevators
if (sprite[ii].picnum != APLAYER) return;
// if(ps[sprite[ii].yvel].select_dir == 1) return;
i = headspritesect[sn];
while (i >= 0)
{
if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 17) break;
i = nextspritesect[i];
}
if (sprite[ii].sectnum == sn)
{
if (activatewarpelevators(i, -1))
activatewarpelevators(i, 1);
else if (activatewarpelevators(i, 1))
activatewarpelevators(i, -1);
return;
}
else
{
if (sptr->floorz > sprite[i].z)
activatewarpelevators(i, -1);
else
activatewarpelevators(i, 1);
}
return;
case ST_16_PLATFORM_DOWN:
case ST_17_PLATFORM_UP:
i = getanimationgoal(&sptr->floorz);
if (i == -1)
{
i = nextsectorneighborz(sn, sptr->floorz, 1, 1);
if (i == -1)
{
i = nextsectorneighborz(sn, sptr->floorz, 1, -1);
if (i == -1) return;
j = sector[i].floorz;
setanimation(sn, &sptr->floorz, j, sptr->extra);
}
else
{
j = sector[i].floorz;
setanimation(sn, &sptr->floorz, j, sptr->extra);
}
callsound(sn, ii);
}
return;
case ST_18_ELEVATOR_DOWN:
case ST_19_ELEVATOR_UP:
i = getanimationgoal(&sptr->floorz);
if (i == -1)
{
i = nextsectorneighborz(sn, sptr->floorz, 1, -1);
if (i == -1) i = nextsectorneighborz(sn, sptr->floorz, 1, 1);
if (i == -1) return;
j = sector[i].floorz;
q = sptr->extra;
l = sptr->ceilingz - sptr->floorz;
setanimation(sn, &sptr->floorz, j, q);
setanimation(sn, &sptr->ceilingz, j + l, q);
callsound(sn, ii);
}
return;
case ST_29_TEETH_DOOR:
if (sptr->lotag & 0x8000)
j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz;
else
j = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz;
i = headspritestat[3]; //Effectors
while (i >= 0)
{
if ((sprite[i].lotag == 22) &&
(sprite[i].hitag == sptr->hitag))
{
sector[sprite[i].sectnum].extra = -sector[sprite[i].sectnum].extra;
hittype[i].temp_data[0] = sn;
hittype[i].temp_data[1] = 1;
}
i = nextspritestat[i];
}
sptr->lotag ^= 0x8000;
setanimation(sn, &sptr->ceilingz, j, sptr->extra);
callsound(sn, ii);
return;
case ST_20_CEILING_DOOR:
REDODOOR:
if (sptr->lotag & 0x8000)
{
i = headspritesect[sn];
while (i >= 0)
{
if (sprite[i].statnum == 3 && sprite[i].lotag == 9)
{
j = sprite[i].z;
break;
}
i = nextspritesect[i];
}
if (i == -1)
j = sptr->floorz;
}
else
{
j = nextsectorneighborz(sn, sptr->ceilingz, -1, -1);
if (j >= 0) j = sector[j].ceilingz;
else
{
sptr->lotag |= 32768;
goto REDODOOR;
}
}
sptr->lotag ^= 0x8000;
setanimation(sn, &sptr->ceilingz, j, sptr->extra);
callsound(sn, ii);
return;
case ST_21_FLOOR_DOOR:
i = getanimationgoal(&sptr->floorz);
if (i >= 0)
{
if (animategoal[sn] == sptr->ceilingz)
animategoal[i] = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz;
else animategoal[i] = sptr->ceilingz;
j = animategoal[i];
}
else
{
if (sptr->ceilingz == sptr->floorz)
j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz;
else j = sptr->ceilingz;
sptr->lotag ^= 0x8000;
if (setanimation(sn, &sptr->floorz, j, sptr->extra) >= 0)
callsound(sn, ii);
}
return;
case ST_22_SPLITTING_DOOR:
if ((sptr->lotag & 0x8000))
{
q = (sptr->ceilingz + sptr->floorz) >> 1;
j = setanimation(sn, &sptr->floorz, q, sptr->extra);
j = setanimation(sn, &sptr->ceilingz, q, sptr->extra);
}
else
{
q = sector[nextsectorneighborz(sn, sptr->floorz, 1, 1)].floorz;
j = setanimation(sn, &sptr->floorz, q, sptr->extra);
q = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz;
j = setanimation(sn, &sptr->ceilingz, q, sptr->extra);
}
sptr->lotag ^= 0x8000;
callsound(sn, ii);
return;
case ST_23_SWINGING_DOOR: //Swingdoor
j = -1;
q = 0;
i = headspritestat[3];
while (i >= 0)
{
if (sprite[i].lotag == 11 && sprite[i].sectnum == sn && !hittype[i].temp_data[4])
{
j = i;
break;
}
i = nextspritestat[i];
}
l = sector[sprite[i].sectnum].lotag & 0x8000;
if (j >= 0)
{
i = headspritestat[3];
while (i >= 0)
{
if (l == (sector[sprite[i].sectnum].lotag & 0x8000) && sprite[i].lotag == 11 && sprite[j].hitag == sprite[i].hitag && !hittype[i].temp_data[4])
{
if (sector[sprite[i].sectnum].lotag & 0x8000) sector[sprite[i].sectnum].lotag &= 0x7fff;
else sector[sprite[i].sectnum].lotag |= 0x8000;
hittype[i].temp_data[4] = 1;
hittype[i].temp_data[3] = -hittype[i].temp_data[3];
if (q == 0)
{
callsound(sn, i);
q = 1;
}
}
i = nextspritestat[i];
}
}
return;
case ST_25_SLIDING_DOOR: //Subway type sliding doors
j = headspritestat[3];
while (j >= 0)//Find the sprite
{
if ((sprite[j].lotag) == 15 && sprite[j].sectnum == sn)
break; //Found the sectoreffector.
j = nextspritestat[j];
}
if (j < 0)
return;
i = headspritestat[3];
while (i >= 0)
{
if (sprite[i].hitag == sprite[j].hitag)
{
if (sprite[i].lotag == 15)
{
sector[sprite[i].sectnum].lotag ^= 0x8000; // Toggle the open or close
sprite[i].ang += 1024;
if (hittype[i].temp_data[4]) callsound(sprite[i].sectnum, i);
callsound(sprite[i].sectnum, i);
if (sector[sprite[i].sectnum].lotag & 0x8000) hittype[i].temp_data[4] = 1;
else hittype[i].temp_data[4] = 2;
}
}
i = nextspritestat[i];
}
return;
case ST_27_STRETCH_BRIDGE: //Extended bridge
j = headspritestat[3];
while (j >= 0)
{
if ((sprite[j].lotag & 0xff) == 20 && sprite[j].sectnum == sn) //Bridge
{
sector[sn].lotag ^= 0x8000;
if (sector[sn].lotag & 0x8000) //OPENING
hittype[j].temp_data[0] = 1;
else hittype[j].temp_data[0] = 2;
callsound(sn, ii);
break;
}
j = nextspritestat[j];
}
return;
case ST_28_DROP_FLOOR:
//activate the rest of them
j = headspritesect[sn];
while (j >= 0)
{
if (sprite[j].statnum == 3 && (sprite[j].lotag & 0xff) == 21)
break; //Found it
j = nextspritesect[j];
}
j = sprite[j].hitag;
l = headspritestat[3];
while (l >= 0)
{
if ((sprite[l].lotag & 0xff) == 21 && !hittype[l].temp_data[0] &&
(sprite[l].hitag) == j)
hittype[l].temp_data[0] = 1;
l = nextspritestat[l];
}
callsound(sn, ii);
return;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operateactivators(short low, short snum)
{
int i, j, k;
short * p;
walltype* wal;
for (i = numcyclers - 1; i >= 0; i--)
{
p = &cyclers[i][0];
if (p[4] == low)
{
p[5] = !p[5];
sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3];
wal = &wall[sector[p[0]].wallptr];
for (j = sector[p[0]].wallnum; j > 0; j--, wal++)
wal->shade = p[3];
}
}
i = headspritestat[8];
k = -1;
while (i >= 0)
{
if (sprite[i].lotag == low)
{
if (sprite[i].picnum == ACTIVATORLOCKED)
{
sector[sprite[i].sectnum].lotag ^= 16384;
if (snum >= 0)
{
if (sector[sprite[i].sectnum].lotag & 16384)
FTA(4, &ps[snum]);
else FTA(8, &ps[snum]);
}
}
else
{
switch (sprite[i].hitag)
{
case 0:
break;
case 1:
if (sector[sprite[i].sectnum].floorz != sector[sprite[i].sectnum].ceilingz)
{
i = nextspritestat[i];
continue;
}
break;
case 2:
if (sector[sprite[i].sectnum].floorz == sector[sprite[i].sectnum].ceilingz)
{
i = nextspritestat[i];
continue;
}
break;
}
if (sector[sprite[i].sectnum].lotag < 3)
{
j = headspritesect[sprite[i].sectnum];
while (j >= 0)
{
if (sprite[j].statnum == 3) switch (sprite[j].lotag)
{
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
if (isRRRA()) break;
case SE_36_PROJ_SHOOTER:
case SE_31_FLOOR_RISE_FALL:
case SE_32_CEILING_RISE_FALL:
hittype[j].temp_data[0] = 1 - hittype[j].temp_data[0];
callsound(sprite[i].sectnum, j);
break;
}
j = nextspritesect[j];
}
}
if (k == -1 && (sector[sprite[i].sectnum].lotag & 0xff) == 22)
k = callsound(sprite[i].sectnum, i);
operatesectors(sprite[i].sectnum, i);
}
}
i = nextspritestat[i];
}
operaterespawns(low);
}
END_DUKE_NS

View file

@ -38,11 +38,6 @@ source as it is released.
// PRIMITIVE
BEGIN_DUKE_NS
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//
@ -81,5 +76,134 @@ bool isadoorwall_d(int dapic)
return 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void animatewalls_d(void)
{
int i, j, p, t;
for (p = 0; p < numanimwalls; p++)
{
i = animwall[p].wallnum;
j = wall[i].picnum;
switch (j)
{
case SCREENBREAK1:
case SCREENBREAK2:
case SCREENBREAK3:
case SCREENBREAK4:
case SCREENBREAK5:
case SCREENBREAK9:
case SCREENBREAK10:
case SCREENBREAK11:
case SCREENBREAK12:
case SCREENBREAK13:
case SCREENBREAK14:
case SCREENBREAK15:
case SCREENBREAK16:
case SCREENBREAK17:
case SCREENBREAK18:
case SCREENBREAK19:
if ((krand() & 255) < 16)
{
animwall[p].tag = wall[i].picnum;
wall[i].picnum = SCREENBREAK6;
}
continue;
case SCREENBREAK6:
case SCREENBREAK7:
case SCREENBREAK8:
if (animwall[p].tag >= 0 && wall[i].extra != FEMPIC2 && wall[i].extra != FEMPIC3)
wall[i].picnum = animwall[p].tag;
else
{
wall[i].picnum++;
if (wall[i].picnum == (SCREENBREAK6 + 3))
wall[i].picnum = SCREENBREAK6;
}
continue;
}
if (wall[i].cstat & 16)
switch (wall[i].overpicnum)
{
case W_FORCEFIELD:
case W_FORCEFIELD + 1:
case W_FORCEFIELD + 2:
t = animwall[p].tag;
if (wall[i].cstat & 254)
{
wall[i].xpanning -= t >> 10; // sintable[(t+512)&2047]>>12;
wall[i].ypanning -= t >> 10; // sintable[t&2047]>>12;
if (wall[i].extra == 1)
{
wall[i].extra = 0;
animwall[p].tag = 0;
}
else
animwall[p].tag += 128;
if (animwall[p].tag < (128 << 4))
{
if (animwall[p].tag & 128)
wall[i].overpicnum = W_FORCEFIELD;
else wall[i].overpicnum = W_FORCEFIELD + 1;
}
else
{
if ((krand() & 255) < 32)
animwall[p].tag = 128 << (krand() & 3);
else wall[i].overpicnum = W_FORCEFIELD + 1;
}
}
break;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operaterespawns_d(int low)
{
short i, j, nexti;
i = headspritestat[11];
while (i >= 0)
{
nexti = nextspritestat[i];
if (sprite[i].lotag == low) switch (sprite[i].picnum)
{
case RESPAWN:
if (badguypic(sprite[i].hitag) && ud.monsters_off) break;
j = spawn(i, TRANSPORTERSTAR);
sprite[j].z -= (32 << 8);
sprite[i].extra = 66 - 12; // Just a way to killit
break;
}
i = nexti;
}
}
END_DUKE_NS

View file

@ -186,7 +186,144 @@ bool isablockdoor(int dapic)
return false;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void animatewalls_r(void)
{
int i, j, p, t;
if (isRRRA() &&ps[screenpeek].sea_sick_stat == 1)
{
for (i = 0; i < MAXWALLS; i++)
{
if (wall[i].picnum == RRTILE7873)
wall[i].xpanning += 6;
else if (wall[i].picnum == RRTILE7870)
wall[i].xpanning += 6;
}
}
for (p = 0; p < numanimwalls; p++)
{
i = animwall[p].wallnum;
j = wall[i].picnum;
switch (j)
{
case SCREENBREAK1:
case SCREENBREAK2:
case SCREENBREAK3:
case SCREENBREAK4:
case SCREENBREAK5:
case SCREENBREAK9:
case SCREENBREAK10:
case SCREENBREAK11:
case SCREENBREAK12:
case SCREENBREAK13:
if ((krand() & 255) < 16)
{
animwall[p].tag = wall[i].picnum;
wall[i].picnum = SCREENBREAK6;
}
continue;
case SCREENBREAK6:
case SCREENBREAK7:
case SCREENBREAK8:
if (animwall[p].tag >= 0)
wall[i].picnum = animwall[p].tag;
else
{
wall[i].picnum++;
if (wall[i].picnum == (SCREENBREAK6 + 3))
wall[i].picnum = SCREENBREAK6;
}
continue;
}
if (wall[i].cstat & 16)
switch (wall[i].overpicnum)
{
case W_FORCEFIELD:
case W_FORCEFIELD + 1:
case W_FORCEFIELD + 2:
t = animwall[p].tag;
if (wall[i].cstat & 254)
{
wall[i].xpanning -= t >> 10; // sintable[(t+512)&2047]>>12;
wall[i].ypanning -= t >> 10; // sintable[t&2047]>>12;
if (wall[i].extra == 1)
{
wall[i].extra = 0;
animwall[p].tag = 0;
}
else
animwall[p].tag += 128;
if (animwall[p].tag < (128 << 4))
{
if (animwall[p].tag & 128)
wall[i].overpicnum = W_FORCEFIELD;
else wall[i].overpicnum = W_FORCEFIELD + 1;
}
else
{
if ((krand() & 255) < 32)
animwall[p].tag = 128 << (krand() & 3);
else wall[i].overpicnum = W_FORCEFIELD + 1;
}
}
break;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operaterespawns_r(int low)
{
short i, j, nexti;
i = headspritestat[11];
while (i >= 0)
{
nexti = nextspritestat[i];
if (sprite[i].lotag == low) switch (sprite[i].picnum)
{
case RESPAWN:
if (badguypic(sprite[i].hitag) && ud.monsters_off) break;
j = spawn(i, TRANSPORTERSTAR);
sprite[j].z -= (32 << 8);
sprite[i].extra = 66 - 12; // Just a way to killit
break;
case RRTILE7424:
if (isRRRA() && !ud.monsters_off)
changespritestat(i, 119);
break;
}
i = nexti;
}
}
END_DUKE_NS

View file

@ -864,6 +864,8 @@ void thunder();
void moveexplosions_r();
void moveeffectors_r();
void doanimations(void);
void G_MoveWorld_d(void)
{
extern double g_moveActorsTime, g_moveWorldTime;
@ -890,7 +892,7 @@ void G_MoveWorld_d(void)
movestandables_d(); //ST 6
G_RefreshLights();
G_DoSectorAnimations();
doanimations();
movefx(); //ST 11
g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime);
@ -939,7 +941,7 @@ void G_MoveWorld_r(void)
}
G_RefreshLights();
G_DoSectorAnimations();
doanimations();
if (!DEER)
movefx(); //ST 11

View file

@ -661,7 +661,7 @@ void G_DoCheats(void)
{
if (lotag & (uint16_t)~16384u)
sector[i].lotag &= (uint16_t)~16384u;
G_OperateSectors(i, pPlayer->i);
operatesectors(i, pPlayer->i);
}
}
G_OperateForceFields(pPlayer->i, -1);

View file

@ -7559,8 +7559,8 @@ int G_DoMoveThings(void)
}
else
{
G_AnimateWalls();
movecyclers();
animatewalls();
movecyclers();
}
//if (g_netServer && (everyothertime % 10) == 0)

View file

@ -1502,7 +1502,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
break;
case 4:
A_Spawn(vm.spriteNum, TILE_VIXEN);
G_OperateActivators(666, vm.playerNum);
operateactivators(666, vm.playerNum);
break;
}
continue;
@ -1515,7 +1515,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case CON_MAMATRIGGER:
insptr++;
G_OperateActivators(667, vm.playerNum);
operateactivators(667, vm.playerNum);
continue;
case CON_MAMASPAWN:
@ -2468,7 +2468,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
break;
if (j == -1)
G_OperateSectors(foundSect, vm.spriteNum);
operatesectors(foundSect, vm.spriteNum);
}
}
continue;
@ -2657,11 +2657,11 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case NAKED1__STATIC:
case STATUE__STATIC:
if (vm.pSprite->yvel)
G_OperateRespawns(vm.pSprite->yvel);
operaterespawns(vm.pSprite->yvel);
break;
default:
if (vm.pSprite->hitag >= 0)
G_OperateRespawns(vm.pSprite->hitag);
operaterespawns(vm.pSprite->hitag);
break;
}
continue;

View file

@ -420,7 +420,7 @@ notarget:
// Hitscan weapon fired from actor (sprite s);
static void A_PreFireHitscan(const spritetype *pSprite, vec3_t * const srcVect, int32_t * const zvel, int * const shootAng, int const doSpread)
{
int const playerNum = A_FindPlayer(pSprite, NULL);
int const playerNum = findplayer(pSprite, NULL);
const DukePlayer_t *pPlayer = g_player[playerNum].ps;
int const playerDist = safeldist(pPlayer->i, pSprite);
@ -605,7 +605,7 @@ growspark_rr:
else
{
int32_t playerDist;
int const playerSprite = g_player[A_FindPlayer(pSprite, &playerDist)].ps->i;
int const playerSprite = g_player[findplayer(pSprite, &playerDist)].ps->i;
Zvel = tabledivide32_noinline((sprite[playerSprite].z - startPos.z) << 8, playerDist + 1);
shootAng = getangle(sprite[playerSprite].x - startPos.x, sprite[playerSprite].y - startPos.y);
}
@ -894,7 +894,7 @@ growspark_rr:
}
else
{
int const otherPlayer = A_FindPlayer(pSprite, NULL);
int const otherPlayer = findplayer(pSprite, NULL);
if (pSprite->picnum == TILE_VIXEN)
shootAng -= krand2()&16;
else
@ -1004,7 +1004,7 @@ growspark_rr:
}
else
{
int const otherPlayer = A_FindPlayer(pSprite, NULL);
int const otherPlayer = findplayer(pSprite, NULL);
if (RR)
{
if (pSprite->picnum == TILE_HULK)
@ -1123,7 +1123,7 @@ growspark_rr:
else
{
// NOTE: otherSprite is a player index
otherSprite = A_FindPlayer(pSprite, NULL);
otherSprite = findplayer(pSprite, NULL);
shootAng = getangle(g_player[otherSprite].ps->opos.x - startPos.x, g_player[otherSprite].ps->opos.y - startPos.y);
if (PN(spriteNum) == TILE_BOSS3)
startPos.z -= ZOFFSET5;
@ -1319,7 +1319,7 @@ growspark_rr:
if (pSprite->extra >= 0)
pSprite->shade = -96;
int const playerSprite = g_player[A_FindPlayer(pSprite, NULL)].ps->i;
int const playerSprite = g_player[findplayer(pSprite, NULL)].ps->i;
int const playerDist = ldist(&sprite[playerSprite], pSprite);
Zvel = -playerDist >> 1;
@ -1350,7 +1350,7 @@ growspark_rr:
}
else if (pSprite->statnum != STAT_EFFECTOR)
{
int const otherPlayer = A_FindPlayer(pSprite, NULL);
int const otherPlayer = findplayer(pSprite, NULL);
Zvel = tabledivide32_noinline((g_player[otherPlayer].ps->opos.z - startPos.z) * 512,
safeldist(g_player[otherPlayer].ps->i, pSprite));
}
@ -4862,31 +4862,6 @@ static int P_CheckFloorDamage(DukePlayer_t *pPlayer, int floorTexture)
}
int P_FindOtherPlayer(int playerNum, int32_t *pDist)
{
int closestPlayer = playerNum;
int closestPlayerDist = INT32_MAX;
for (bssize_t TRAVERSE_CONNECT(otherPlayer))
{
if (playerNum != otherPlayer && sprite[g_player[otherPlayer].ps->i].extra > 0)
{
int otherPlayerDist = klabs(g_player[otherPlayer].ps->opos.x - g_player[playerNum].ps->pos.x) +
klabs(g_player[otherPlayer].ps->opos.y - g_player[playerNum].ps->pos.y) +
(klabs(g_player[otherPlayer].ps->opos.z - g_player[playerNum].ps->pos.z) >> 4);
if (otherPlayerDist < closestPlayerDist)
{
closestPlayer = otherPlayer;
closestPlayerDist = otherPlayerDist;
}
}
}
*pDist = closestPlayerDist;
return closestPlayer;
}
void P_FragPlayer(int playerNum)
{
@ -7717,7 +7692,7 @@ check_enemy_sprite:
{
if (sectorLotag == 17 || (RRRA && sectorLotag == 18))
{
if (GetAnimationGoal(&sector[pPlayer->cursectnum].floorz) >= 0)
if (getanimationgoal(&sector[pPlayer->cursectnum].floorz) >= 0)
{
if (!S_CheckSoundPlaying(pPlayer->i, 432))
A_PlaySound(432, pPlayer->i);
@ -8676,7 +8651,7 @@ HORIZONLY:;
case NAKED1__STATIC:
case STATUE__STATIC:
if (sprite[pPlayer->actorsqu].yvel)
G_OperateRespawns(sprite[pPlayer->actorsqu].yvel);
operaterespawns(sprite[pPlayer->actorsqu].yvel);
A_DeleteSprite(pPlayer->actorsqu);
break;
case APLAYER__STATIC:

View file

@ -57,156 +57,15 @@ int S_FindMusicSFX(int sectNum, int* sndptr)
}
static inline int32_t A_FP_ManhattanDist(const DukePlayer_t *pPlayer, const spritetype *pSprite)
static void G_SetupCamTile(int spriteNum, int smoothRatio)
{
return klabs(pPlayer->opos.x - pSprite->x)
+ klabs(pPlayer->opos.y - pSprite->y)
+ ((klabs(pPlayer->opos.z - pSprite->z + (28 << 8))) >> 4);
}
int const viewscrTile = TILE_VIEWSCR;
TileFiles.MakeCanvas(viewscrTile, tilesiz[PN(spriteNum)].x, tilesiz[PN(spriteNum)].y);
int __fastcall A_FindPlayer(const spritetype *pSprite, int32_t *dist)
{
if (!g_netServer && ud.multimode < 2)
{
DukePlayer_t *const pPlayer = g_player[myconnectindex].ps;
if (dist)
*dist = A_FP_ManhattanDist(pPlayer, pSprite);
return myconnectindex;
}
int closestPlayer = 0;
int32_t closestPlayerDist = INT32_MAX;
for (bssize_t TRAVERSE_CONNECT(j))
{
DukePlayer_t *const pPlayer = g_player[j].ps;
int32_t playerDist = A_FP_ManhattanDist(pPlayer, pSprite);
if (playerDist < closestPlayerDist && sprite[pPlayer->i].extra > 0)
{
closestPlayer = j;
closestPlayerDist = playerDist;
}
}
if (dist)
*dist = closestPlayerDist;
return closestPlayer;
}
void G_DoSectorAnimations(void)
{
for (bssize_t animNum=g_animateCnt-1; animNum>=0; animNum--)
{
int animPos = *g_animatePtr[animNum];
int const animVel = g_animateVel[animNum] * TICSPERFRAME;
int const animSect = g_animateSect[animNum];
if (animPos == g_animateGoal[animNum])
{
G_StopInterpolation(g_animatePtr[animNum]);
g_animateCnt--;
g_animatePtr[animNum] = g_animatePtr[g_animateCnt];
g_animateGoal[animNum] = g_animateGoal[g_animateCnt];
g_animateVel[animNum] = g_animateVel[g_animateCnt];
g_animateSect[animNum] = g_animateSect[g_animateCnt];
if ((sector[g_animateSect[animNum]].lotag == ST_18_ELEVATOR_DOWN || sector[g_animateSect[animNum]].lotag == ST_19_ELEVATOR_UP)
&& (g_animatePtr[animNum] == &sector[g_animateSect[animNum]].ceilingz))
continue;
if ((sector[animSect].lotag&0xff) != ST_22_SPLITTING_DOOR)
callsound(animSect,-1);
continue;
}
animPos = (animVel > 0) ? min(animPos + animVel, g_animateGoal[animNum])
: max(animPos + animVel, g_animateGoal[animNum]);
if (g_animatePtr[animNum] == &sector[g_animateSect[animNum]].floorz)
{
for (bssize_t TRAVERSE_CONNECT(playerNum))
{
if ((g_player[playerNum].ps->cursectnum == animSect)
&& ((sector[animSect].floorz - g_player[playerNum].ps->pos.z) < (64 << 8))
&& (sprite[g_player[playerNum].ps->i].owner >= 0))
{
g_player[playerNum].ps->pos.z += animVel;
g_player[playerNum].ps->vel.z = 0;
/*
if (p == myconnectindex)
{
my.z += v;
myvel.z = 0;
}
*/
}
}
for (bssize_t j=headspritesect[animSect]; j>=0; j=nextspritesect[j])
{
if (sprite[j].statnum != STAT_EFFECTOR)
{
actor[j].bpos.z = sprite[j].z;
sprite[j].z += animVel;
actor[j].floorz = sector[animSect].floorz+animVel;
}
}
}
*g_animatePtr[animNum] = animPos;
}
}
int GetAnimationGoal(const int32_t *animPtr)
{
for (bssize_t i = 0; i < g_animateCnt; i++)
if (animPtr == g_animatePtr[i])
return i;
return -1;
}
int SetAnimation(int sectNum, int32_t *animPtr, int goalVal, int animVel)
{
if (g_animateCnt >= MAXANIMATES)
return -1;
int animNum = g_animateCnt;
for (bssize_t i = 0; i < g_animateCnt; i++)
{
if (animPtr == g_animatePtr[i])
{
animNum = i;
break;
}
}
g_animateSect[animNum] = sectNum;
g_animatePtr[animNum] = animPtr;
g_animateGoal[animNum] = goalVal;
g_animateVel[animNum] = (goalVal >= *animPtr) ? animVel : -animVel;
if (animNum == g_animateCnt)
g_animateCnt++;
G_SetInterpolation(animPtr);
return animNum;
}
static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio)
{
vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio);
int const saveMirror = display_mirror;
auto canvas = renderSetTarget(tileNum);
auto canvas = renderSetTarget(viewscrTile);
if (!canvas) return;
screen->RenderTextureView(canvas, [=](IntRect& rect)
@ -245,10 +104,8 @@ void G_AnimateCamSprite(int smoothRatio)
if (OW(spriteNum) >= 0 && dist(&sprite[pPlayer->i], &sprite[spriteNum]) < VIEWSCREEN_ACTIVE_DISTANCE)
{
int const viewscrTile = TILE_VIEWSCR;
TileFiles.MakeCanvas(viewscrTile, tilesiz[PN(spriteNum)].x, tilesiz[PN(spriteNum)].y);
G_SetupCamTile(OW(spriteNum), viewscrTile, smoothRatio);
G_SetupCamTile(OW(spriteNum), smoothRatio);
#ifdef POLYMER
// Force texture update on viewscreen sprite in Polymer!
if (videoGetRenderMode() == REND_POLYMER)
@ -260,694 +117,6 @@ void G_AnimateCamSprite(int smoothRatio)
}
}
void G_AnimateWalls(void)
{
if (RRRA && g_player[screenpeek].ps->sea_sick_stat == 1)
{
for (bssize_t i = 0; i < MAXWALLS; i++)
{
if (wall[i].picnum == TILE_RRTILE7873 || wall[i].picnum == TILE_RRTILE7870)
wall[i].xpanning += 6;
}
}
for (bssize_t animwallNum = 0; animwallNum < g_animWallCnt; animwallNum++)
{
int const wallNum = animwall[animwallNum].wallnum;
switch (DYNAMICTILEMAP(wall[wallNum].picnum))
{
case SCREENBREAK14__STATIC:
case SCREENBREAK15__STATIC:
case SCREENBREAK16__STATIC:
case SCREENBREAK17__STATIC:
case SCREENBREAK18__STATIC:
case SCREENBREAK19__STATIC:
if (RR) continue;
fallthrough__;
case SCREENBREAK1__STATIC:
case SCREENBREAK2__STATIC:
case SCREENBREAK3__STATIC:
case SCREENBREAK4__STATIC:
case SCREENBREAK5__STATIC:
case SCREENBREAK9__STATIC:
case SCREENBREAK10__STATIC:
case SCREENBREAK11__STATIC:
case SCREENBREAK12__STATIC:
case SCREENBREAK13__STATIC:
if ((krand2()&255) < 16)
{
animwall[animwallNum].tag = wall[wallNum].picnum;
wall[wallNum].picnum = TILE_SCREENBREAK6;
}
continue;
case SCREENBREAK6__STATIC:
case SCREENBREAK7__STATIC:
case SCREENBREAK8__STATIC:
if (animwall[animwallNum].tag >= 0 && (RR || (wall[wallNum].extra != TILE_FEMPIC2 && wall[wallNum].extra != TILE_FEMPIC3)))
wall[wallNum].picnum = animwall[animwallNum].tag;
else
{
wall[wallNum].picnum++;
if (wall[wallNum].picnum == (TILE_SCREENBREAK6+3))
wall[wallNum].picnum = TILE_SCREENBREAK6;
}
continue;
}
if ((wall[wallNum].cstat&16) && G_GetForcefieldPicnum(wallNum)==TILE_W_FORCEFIELD)
{
int const wallTag = animwall[animwallNum].tag;
if (wall[wallNum].cstat&254)
{
wall[wallNum].xpanning -= wallTag>>10; // sintable[(t+512)&2047]>>12;
wall[wallNum].ypanning -= wallTag>>10; // sintable[t&2047]>>12;
if (wall[wallNum].extra == 1)
{
wall[wallNum].extra = 0;
animwall[animwallNum].tag = 0;
}
else animwall[animwallNum].tag += 128;
if (animwall[animwallNum].tag < (128 << 4))
{
wall[wallNum].overpicnum = (animwall[animwallNum].tag & 128) ? TILE_W_FORCEFIELD : TILE_W_FORCEFIELD + 1;
}
else
{
if ((krand2()&255) < 32)
animwall[animwallNum].tag = 128<<(krand2()&3);
else wall[wallNum].overpicnum = TILE_W_FORCEFIELD+1;
}
}
}
}
}
int G_ActivateWarpElevators(int spriteNum, int warpDir)
{
bssize_t i;
int const sectNum = sprite[spriteNum].sectnum;
for (SPRITES_OF(STAT_EFFECTOR, i))
if ((SLT(i) == SE_17_WARP_ELEVATOR || (RRRA && SLT(i) == 18)) && SHT(i) == sprite[spriteNum].hitag)
{
if (klabs(sector[sectNum].floorz - actor[spriteNum].t_data[2]) > SP(i) ||
sector[SECT(i)].hitag == sector[sectNum].hitag - warpDir)
break;
}
if (i == -1)
return 1; // No find
A_PlaySound(warpDir ? ELEVATOR_ON : ELEVATOR_OFF, spriteNum);
for (SPRITES_OF(STAT_EFFECTOR, i))
if ((SLT(i) == SE_17_WARP_ELEVATOR || (RRRA && SLT(i) == 18)) && SHT(i) == sprite[spriteNum].hitag)
T1(i) = T2(i) = warpDir; //Make all check warp
return 0;
}
void G_OperateSectors(int sectNum, int spriteNum)
{
int32_t j=0;
int32_t i;
sectortype *const pSector = &sector[sectNum];
switch (pSector->lotag & (uint16_t)~49152u)
{
case 41:
if (!RR) break;
operatejaildoors(pSector->hitag);
break;
case 7:
{
if (!RR) break;
int const startwall = pSector->wallptr;
int const endwall = startwall + pSector->wallnum;
for (bssize_t j = startwall; j < endwall; j++)
{
SetAnimation(sectNum, &wall[j].x, wall[j].x + 1024, 4);
SetAnimation(sectNum, &wall[wall[j].nextwall].x, wall[wall[j].nextwall].x + 1024, 4);
}
break;
}
case ST_30_ROTATE_RISE_BRIDGE:
j = sector[sectNum].hitag;
if (E_SpriteIsValid(j))
{
if (actor[j].tempang == 0 || actor[j].tempang == 256)
callsound(sectNum,spriteNum);
sprite[j].extra = (sprite[j].extra == 1) ? 3 : 1;
}
break;
case ST_31_TWO_WAY_TRAIN:
j = sector[sectNum].hitag;
if (E_SpriteIsValid(j))
{
if (actor[j].t_data[4] == 0)
actor[j].t_data[4] = 1;
callsound(sectNum,spriteNum);
}
break;
case ST_26_SPLITTING_ST_DOOR: //The split doors
if (GetAnimationGoal(&pSector->ceilingz) == -1) //if the door has stopped
{
g_haltSoundHack = 1;
pSector->lotag &= 0xFF00u;
pSector->lotag |= ST_22_SPLITTING_DOOR;
G_OperateSectors(sectNum,spriteNum);
pSector->lotag &= 0xFF00u;
pSector->lotag |= ST_9_SLIDING_ST_DOOR;
G_OperateSectors(sectNum,spriteNum);
pSector->lotag &= 0xFF00u;
pSector->lotag |= ST_26_SPLITTING_ST_DOOR;
}
return;
case ST_9_SLIDING_ST_DOOR:
{
int const startWall = pSector->wallptr;
int const endWall = startWall + pSector->wallnum - 1;
int const doorSpeed = pSector->extra >> 4;
//first find center point by averaging all points
vec2_t vect = { 0, 0 };
for (i = startWall; i <= endWall; i++)
{
vect.x += wall[i].x;
vect.y += wall[i].y;
}
vect.x = tabledivide32_noinline(vect.x, (endWall-startWall+1));
vect.y = tabledivide32_noinline(vect.y, (endWall-startWall+1));
//find any points with either same x or same y coordinate
// as center (dax, day) - should be 2 points found.
int wallfind[2] = { -1, -1 };
for (i = startWall; i <= endWall; i++)
{
if (wall[i].x == vect.x || wall[i].y == vect.y)
{
if (wallfind[0] == -1)
wallfind[0] = i;
else
wallfind[1] = i;
}
}
if (wallfind[1] == -1)
return;
for (j=0; j<2; j++)
{
int const foundWall = wallfind[j];
i = foundWall - 1;
if (i < startWall)
i = endWall;
vec2_t vect2 = { ((wall[i].x + wall[wall[foundWall].point2].x) >> 1) - wall[foundWall].x,
((wall[i].y + wall[wall[foundWall].point2].y) >> 1) - wall[foundWall].y };
if (wall[foundWall].x == vect.x && wall[foundWall].y == vect.y)
{
//find what direction door should open by averaging the
// 2 neighboring points of wallfind[0] & wallfind[1].
if (vect2.x != 0)
{
vect2.x = wall[wall[wall[foundWall].point2].point2].x;
vect2.x -= wall[wall[foundWall].point2].x;
SetAnimation(sectNum, &wall[foundWall].x, wall[foundWall].x + vect2.x, doorSpeed);
SetAnimation(sectNum, &wall[i].x, wall[i].x + vect2.x, doorSpeed);
SetAnimation(sectNum, &wall[wall[foundWall].point2].x, wall[wall[foundWall].point2].x + vect2.x, doorSpeed);
callsound(sectNum, spriteNum);
}
else if (vect2.y != 0)
{
vect2.y = wall[wall[wall[foundWall].point2].point2].y;
vect2.y -= wall[wall[foundWall].point2].y;
SetAnimation(sectNum, &wall[foundWall].y, wall[foundWall].y + vect2.y, doorSpeed);
SetAnimation(sectNum, &wall[i].y, wall[i].y + vect2.y, doorSpeed);
SetAnimation(sectNum, &wall[wall[foundWall].point2].y, wall[wall[foundWall].point2].y + vect2.y, doorSpeed);
callsound(sectNum, spriteNum);
}
}
else
{
if (vect2.x != 0)
{
SetAnimation(sectNum, &wall[foundWall].x, vect.x, doorSpeed);
SetAnimation(sectNum, &wall[i].x, vect.x + vect2.x, doorSpeed);
SetAnimation(sectNum, &wall[wall[foundWall].point2].x, vect.x + vect2.x, doorSpeed);
callsound(sectNum, spriteNum);
}
else if (vect2.y != 0)
{
SetAnimation(sectNum, &wall[foundWall].y, vect.y, doorSpeed);
SetAnimation(sectNum, &wall[i].y, vect.y + vect2.y, doorSpeed);
SetAnimation(sectNum, &wall[wall[foundWall].point2].y, vect.y + vect2.y, doorSpeed);
callsound(sectNum, spriteNum);
}
}
}
}
return;
case ST_15_WARP_ELEVATOR://Warping elevators
if (sprite[spriteNum].picnum != TILE_APLAYER)
return;
for (SPRITES_OF_SECT(sectNum, i))
if (PN(i)==TILE_SECTOREFFECTOR && SLT(i) == SE_17_WARP_ELEVATOR)
break;
if (i < 0)
return;
if (sprite[spriteNum].sectnum == sectNum)
{
if (G_ActivateWarpElevators(i,-1))
G_ActivateWarpElevators(i,1);
else if (G_ActivateWarpElevators(i,1))
G_ActivateWarpElevators(i,-1);
}
else
{
if (pSector->floorz > SZ(i))
G_ActivateWarpElevators(i,-1);
else
G_ActivateWarpElevators(i,1);
}
return;
case ST_16_PLATFORM_DOWN:
case ST_17_PLATFORM_UP:
i = GetAnimationGoal(&pSector->floorz);
if (i == -1)
{
i = nextsectorneighborz(sectNum,pSector->floorz,1,1);
if (i == -1)
{
i = nextsectorneighborz(sectNum,pSector->floorz,1,-1);
if (i == -1) return;
j = sector[i].floorz;
SetAnimation(sectNum,&pSector->floorz,j,pSector->extra);
}
else
{
j = sector[i].floorz;
SetAnimation(sectNum,&pSector->floorz,j,pSector->extra);
}
callsound(sectNum,spriteNum);
}
return;
case ST_18_ELEVATOR_DOWN:
case ST_19_ELEVATOR_UP:
i = GetAnimationGoal(&pSector->floorz);
if (i==-1)
{
i = nextsectorneighborz(sectNum, pSector->floorz, 1, -1);
if (i == -1)
i = nextsectorneighborz(sectNum, pSector->floorz, 1, 1);
if (i == -1)
return;
j = sector[i].floorz;
int const sectorExtra = pSector->extra;
int const zDiff = pSector->ceilingz - pSector->floorz;
SetAnimation(sectNum, &pSector->floorz, j, sectorExtra);
SetAnimation(sectNum, &pSector->ceilingz, j + zDiff, sectorExtra);
callsound(sectNum, spriteNum);
}
return;
case ST_29_TEETH_DOOR:
for (SPRITES_OF(STAT_EFFECTOR, i))
if (SLT(i) == SE_22_TEETH_DOOR && SHT(i) == pSector->hitag)
{
sector[SECT(i)].extra = -sector[SECT(i)].extra;
T1(i) = sectNum;
T2(i) = 1;
}
callsound(sectNum, spriteNum);
pSector->lotag ^= 0x8000u;
if (pSector->lotag & 0x8000u)
{
j = nextsectorneighborz(sectNum,pSector->ceilingz,-1,-1);
//if (j == -1) j = nextsectorneighborz(sectNum,pSector->ceilingz,1,1);
if (j == -1)
{
Printf("WARNING: ST29: null sector!\n");
return;
}
j = sector[j].ceilingz;
}
else
{
j = nextsectorneighborz(sectNum,pSector->ceilingz,1,1);
//if (j == -1) j = nextsectorneighborz(sectNum,pSector->ceilingz,-1,-1);
if (j == -1)
{
Printf("WARNING: ST29: null sector!\n");
return;
}
j = sector[j].floorz;
}
SetAnimation(sectNum,&pSector->ceilingz,j,pSector->extra);
return;
case ST_20_CEILING_DOOR:
REDODOOR:
if (pSector->lotag & 0x8000u)
{
for (SPRITES_OF_SECT(sectNum, i))
if (sprite[i].statnum == STAT_EFFECTOR && SLT(i)==SE_9_DOWN_OPEN_DOOR_LIGHTS)
{
j = SZ(i);
break;
}
if (i==-1)
j = pSector->floorz;
}
else
{
j = nextsectorneighborz(sectNum,pSector->ceilingz,-1,-1);
if (j >= 0) j = sector[j].ceilingz;
else
{
pSector->lotag |= 32768u;
goto REDODOOR;
}
}
pSector->lotag ^= 0x8000u;
SetAnimation(sectNum,&pSector->ceilingz,j,pSector->extra);
callsound(sectNum,spriteNum);
return;
case ST_21_FLOOR_DOOR:
i = GetAnimationGoal(&pSector->floorz);
if (i >= 0)
{
if (g_animateGoal[sectNum] == pSector->ceilingz)
g_animateGoal[i] = sector[nextsectorneighborz(sectNum,pSector->ceilingz,1,1)].floorz;
else g_animateGoal[i] = pSector->ceilingz;
}
else
{
if (pSector->ceilingz == pSector->floorz)
j = sector[nextsectorneighborz(sectNum,pSector->ceilingz,1,1)].floorz;
else j = pSector->ceilingz;
pSector->lotag ^= 0x8000u;
if (SetAnimation(sectNum,&pSector->floorz,j,pSector->extra) >= 0)
callsound(sectNum,spriteNum);
}
return;
case ST_22_SPLITTING_DOOR:
if (pSector->lotag & 0x8000u)
{
int const q = (pSector->ceilingz + pSector->floorz) >> 1;
SetAnimation(sectNum, &pSector->floorz, q, pSector->extra);
SetAnimation(sectNum, &pSector->ceilingz, q, pSector->extra);
}
else
{
int const floorNeighbor = nextsectorneighborz(sectNum, pSector->floorz, 1, 1);
int const ceilingNeighbor = nextsectorneighborz(sectNum, pSector->ceilingz, -1, -1);
if (floorNeighbor>=0 && ceilingNeighbor>=0)
{
SetAnimation(sectNum, &pSector->floorz, sector[floorNeighbor].floorz, pSector->extra);
SetAnimation(sectNum, &pSector->ceilingz, sector[ceilingNeighbor].ceilingz, pSector->extra);
}
else
{
Printf("WARNING: ST_22_SPLITTING_DOOR: null sector: floor neighbor=%d, ceiling neighbor=%d!\n",
floorNeighbor, ceilingNeighbor);
pSector->lotag ^= 0x8000u;
}
}
pSector->lotag ^= 0x8000u;
callsound(sectNum,spriteNum);
return;
case ST_23_SWINGING_DOOR: //Swingdoor
{
j = -1;
for (SPRITES_OF(STAT_EFFECTOR, i))
if (SLT(i) == SE_11_SWINGING_DOOR && SECT(i) == sectNum && !T5(i))
{
j = i;
break;
}
if (i < 0)
return;
uint16_t const tag = sector[SECT(i)].lotag & 0x8000u;
if (j >= 0)
{
int soundPlayed = 0;
for (SPRITES_OF(STAT_EFFECTOR, i))
{
if (tag == (sector[SECT(i)].lotag & 0x8000u) && SLT(i) == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT(i) && !T5(i))
{
if (sector[SECT(i)].lotag & 0x8000u) sector[SECT(i)].lotag &= 0x7fff;
else sector[SECT(i)].lotag |= 0x8000u;
T5(i) = 1;
T4(i) = -T4(i);
if (!soundPlayed)
{
callsound(sectNum, i);
soundPlayed = 1;
}
}
}
}
}
return;
case ST_25_SLIDING_DOOR: //Subway type sliding doors
for (SPRITES_OF(STAT_EFFECTOR, j))
if (sprite[j].lotag == SE_15_SLIDING_DOOR && sprite[j].sectnum == sectNum)
break; //Found the sectoreffector.
if (j < 0)
return;
for (SPRITES_OF(STAT_EFFECTOR, i))
if (SHT(i)==sprite[j].hitag)
{
if (SLT(i) == SE_15_SLIDING_DOOR)
{
sector[SECT(i)].lotag ^= 0x8000u; // Toggle the open or close
SA(i) += 1024;
if (T5(i))
callsound(SECT(i),i);
callsound(SECT(i),i);
T5(i) = (sector[SECT(i)].lotag & 0x8000u) ? 1 : 2;
}
}
return;
case ST_27_STRETCH_BRIDGE: //Extended bridge
for (SPRITES_OF(STAT_EFFECTOR, j))
if ((sprite[j].lotag&0xff)==SE_20_STRETCH_BRIDGE && sprite[j].sectnum == sectNum) //Bridge
{
sector[sectNum].lotag ^= 0x8000u;
// Highest bit now set means we're opening.
actor[j].t_data[0] = (sector[sectNum].lotag & 0x8000u) ? 1 : 2;
callsound(sectNum,spriteNum);
break;
}
return;
case ST_28_DROP_FLOOR:
//activate the rest of them
for (SPRITES_OF_SECT(sectNum, j))
if (sprite[j].statnum==STAT_EFFECTOR && (sprite[j].lotag&0xff)==SE_21_DROP_FLOOR)
break;
if (j >= 0) // PK: The matching SE21 might have gone, see SE_21_KILLIT in actors.c
{
j = sprite[j].hitag;
for (bssize_t SPRITES_OF(STAT_EFFECTOR, l))
{
if ((sprite[l].lotag&0xff)==SE_21_DROP_FLOOR && !actor[l].t_data[0] &&
sprite[l].hitag == j)
actor[l].t_data[0] = 1;
}
callsound(sectNum,spriteNum);
}
return;
}
}
void G_OperateRespawns(int lotag)
{
for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_FX, spriteNum, nextSprite))
{
spritetype * const pSprite = &sprite[spriteNum];
if (pSprite->lotag == lotag && pSprite->picnum == TILE_RESPAWN)
{
if (!ud.monsters_off || !A_CheckEnemyTile(pSprite->hitag))
{
int const j = A_Spawn(spriteNum, TILE_TRANSPORTERSTAR);
sprite[j].z -= ZOFFSET5;
// Just a way to killit (see G_MoveFX(): RESPAWN__STATIC)
pSprite->extra = 66-12;
}
}
if (RRRA && pSprite->lotag == lotag && pSprite->picnum == TILE_RRTILE7424)
{
if (!ud.monsters_off)
changespritestat(spriteNum, 119);
}
}
}
void G_OperateActivators(int lotag, int playerNum)
{
for (bssize_t spriteNum=g_cyclerCnt-1; spriteNum>=0; spriteNum--)
{
int16_t *const pCycler = &g_cyclers[spriteNum][0];
if (pCycler[4] == lotag)
{
pCycler[5] = !pCycler[5];
sector[pCycler[0]].floorshade = pCycler[3];
sector[pCycler[0]].ceilingshade = pCycler[3];
walltype *pWall = &wall[sector[pCycler[0]].wallptr];
for (bsize_t j = sector[pCycler[0]].wallnum; j > 0; j--, pWall++)
pWall->shade = pCycler[3];
}
}
int soundPlayed = -1;
for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_ACTIVATOR, spriteNum, nextSprite))
{
if (sprite[spriteNum].lotag == lotag)
{
if (sprite[spriteNum].picnum == TILE_ACTIVATORLOCKED)
{
sector[SECT(spriteNum)].lotag ^= 16384;
if (playerNum >= 0 && playerNum < ud.multimode)
P_DoQuote((sector[SECT(spriteNum)].lotag & 16384) ? QUOTE_LOCKED : QUOTE_UNLOCKED, g_player[playerNum].ps);
}
else
{
switch (SHT(spriteNum))
{
case 1:
if (sector[SECT(spriteNum)].floorz != sector[SECT(spriteNum)].ceilingz)
continue;
break;
case 2:
if (sector[SECT(spriteNum)].floorz == sector[SECT(spriteNum)].ceilingz)
continue;
break;
}
// ST_2_UNDERWATER
if (sector[sprite[spriteNum].sectnum].lotag < 3)
{
for (bssize_t SPRITES_OF_SECT(sprite[spriteNum].sectnum, foundSprite))
{
if (sprite[foundSprite].statnum == STAT_EFFECTOR)
{
switch (sprite[foundSprite].lotag)
{
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
if (RRRA) break;
fallthrough__;
case SE_36_PROJ_SHOOTER:
case SE_31_FLOOR_RISE_FALL:
case SE_32_CEILING_RISE_FALL:
actor[foundSprite].t_data[0] = 1 - actor[foundSprite].t_data[0];
callsound(SECT(spriteNum), foundSprite);
break;
}
}
}
}
if (soundPlayed == -1 && (sector[SECT(spriteNum)].lotag&0xff) == ST_22_SPLITTING_DOOR)
soundPlayed = callsound(SECT(spriteNum),spriteNum);
G_OperateSectors(SECT(spriteNum),spriteNum);
}
}
}
G_OperateRespawns(lotag);
}
void G_OperateMasterSwitches(int lotag)
{
@ -1371,7 +540,7 @@ default_case:
{
if (g_player[playerNum].ps->sea_sick == 0)
g_player[playerNum].ps->sea_sick = 350;
G_OperateActivators(668, playerNum);
operateactivators(668, playerNum);
G_OperateMasterSwitches(668);
A_PlaySound(328,g_player[playerNum].ps->i);
return 1;
@ -1456,7 +625,7 @@ default_case:
}
}
G_OperateActivators(lotag, playerNum);
operateactivators(lotag, playerNum);
G_OperateForceFields(g_player[playerNum].ps->i, lotag);
G_OperateMasterSwitches(lotag);
@ -1489,12 +658,12 @@ void G_ActivateBySector(int sectNum, int spriteNum)
for (bssize_t SPRITES_OF_SECT(sectNum, i))
if (PN(i) == TILE_ACTIVATOR)
{
G_OperateActivators(SLT(i),-1);
operateactivators(SLT(i),-1);
++activatedSectors;
}
if ((!RR && !activatedSectors) || (RR && sector[sectNum].lotag != SE_22_TEETH_DOOR))
G_OperateSectors(sectNum, spriteNum);
operatesectors(sectNum, spriteNum);
}
static void G_BreakWall(int tileNum, int spriteNum, int wallNum)
@ -4463,7 +3632,7 @@ void P_CheckSectors(int playerNum)
{
if (RR && !RRRA)
g_canSeePlayer = -1;
G_OperateSectors(nearSector,pPlayer->i);
operatesectors(nearSector,pPlayer->i);
}
else if (RR)
{
@ -4490,7 +3659,7 @@ void P_CheckSectors(int playerNum)
{
if (RR && !RRRA)
g_canSeePlayer = -1;
G_OperateSectors(sprite[pPlayer->i].sectnum,pPlayer->i);
operatesectors(sprite[pPlayer->i].sectnum,pPlayer->i);
}
else if (RR)
{