- Blood: Eliminate gView extern'd pointer.

This commit is contained in:
Mitchell Richters 2022-09-10 23:57:16 +10:00 committed by Christoph Oelckers
parent 560bf3e8df
commit 59bee2f9f6
11 changed files with 119 additions and 122 deletions

View file

@ -4927,11 +4927,11 @@ void MoveDude(DBloodActor* actor)
switch (nLink) switch (nLink)
{ {
case kMarkerLowStack: case kMarkerLowStack:
if (pPlayer == gView) if (pPlayer->nPlayer == myconnectindex)
gotpic.Set(actor->sector()->floorpicnum); gotpic.Set(actor->sector()->floorpicnum);
break; break;
case kMarkerUpStack: case kMarkerUpStack:
if (pPlayer == gView) if (pPlayer->nPlayer == myconnectindex)
gotpic.Set(actor->sector()->ceilingpicnum); gotpic.Set(actor->sector()->ceilingpicnum);
break; break;
case kMarkerLowWater: case kMarkerLowWater:

View file

@ -477,13 +477,13 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
auto& nVoxel = voxelIndex[nTile]; auto& nVoxel = voxelIndex[nTile];
if (cl_showweapon == 2 && r_voxels && nVoxel != -1) if (cl_showweapon == 2 && r_voxels && nVoxel != -1)
{ {
pNSprite->set_int_ang((gView->actor->int_ang() + 512) & 2047); // always face viewer pNSprite->angle = (pPlayer->actor->spr.angle + DAngle90).Normalized360(); // always face viewer
pNSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB; pNSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
pNSprite->cstat &= ~CSTAT_SPRITE_YFLIP; pNSprite->cstat &= ~CSTAT_SPRITE_YFLIP;
pNSprite->picnum = nVoxel; pNSprite->picnum = nVoxel;
if (pPlayer->curWeapon == kWeapLifeLeech) // position lifeleech behind player if (pPlayer->curWeapon == kWeapLifeLeech) // position lifeleech behind player
{ {
pNSprite->pos.XY() += gView->actor->spr.angle.ToVector() * 8; pNSprite->pos.XY() += pPlayer->actor->spr.angle.ToVector() * 8;
} }
if ((pPlayer->curWeapon == kWeapLifeLeech) || (pPlayer->curWeapon == kWeapVoodooDoll)) // make lifeleech/voodoo doll always face viewer like sprite if ((pPlayer->curWeapon == kWeapLifeLeech) || (pPlayer->curWeapon == kWeapVoodooDoll)) // make lifeleech/voodoo doll always face viewer like sprite
pNSprite->set_int_ang((pNSprite->int_ang() + 512) & 2047); // offset angle 90 degrees pNSprite->set_int_ang((pNSprite->int_ang() + 512) & 2047); // offset angle 90 degrees
@ -524,6 +524,7 @@ static int GetOctant(int x, int y)
void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, DAngle cA, double interpfrac) void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, DAngle cA, double interpfrac)
{ {
PLAYER* pPlayer = &gPlayer[myconnectindex];
int nViewSprites = tsprites.Size(); int nViewSprites = tsprites.Size();
// shift before interpolating to increase precision. // shift before interpolating to increase precision.
DAngle myclock = DAngle::fromDeg(((PlayClock << 3) + (4 << 3) * interpfrac) * BAngToDegree); DAngle myclock = DAngle::fromDeg(((PlayClock << 3) + (4 << 3) * interpfrac) * BAngToDegree);
@ -813,7 +814,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
case kMissileFlareRegular: case kMissileFlareRegular:
case kMissileFlareAlt: case kMissileFlareAlt:
if (pTSprite->statnum == kStatFlare) { if (pTSprite->statnum == kStatFlare) {
if (owneractor->GetTarget() == gView->actor) if (owneractor->GetTarget() == pPlayer->actor)
{ {
pTSprite->xrepeat = 0; pTSprite->xrepeat = 0;
break; break;
@ -852,41 +853,41 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
} }
if (pXSector && pXSector->color) copyfloorpal(pTSprite, pSector); if (pXSector && pXSector->color) copyfloorpal(pTSprite, pSector);
if (powerupCheck(gView, kPwUpBeastVision) > 0) pTSprite->shade = -128; if (powerupCheck(pPlayer, kPwUpBeastVision) > 0) pTSprite->shade = -128;
if (IsPlayerSprite(pTSprite)) { if (IsPlayerSprite(pTSprite)) {
PLAYER* pPlayer = &gPlayer[pTSprite->type - kDudePlayer1]; PLAYER* thisPlayer = &gPlayer[pTSprite->type - kDudePlayer1];
if (powerupCheck(pPlayer, kPwUpShadowCloak) && !powerupCheck(gView, kPwUpBeastVision)) { if (powerupCheck(thisPlayer, kPwUpShadowCloak) && !powerupCheck(pPlayer, kPwUpBeastVision)) {
pTSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT; pTSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
pTSprite->pal = 5; pTSprite->pal = 5;
} }
else if (powerupCheck(pPlayer, kPwUpDeathMask)) { else if (powerupCheck(thisPlayer, kPwUpDeathMask)) {
pTSprite->shade = -128; pTSprite->shade = -128;
pTSprite->pal = 5; pTSprite->pal = 5;
} }
else if (powerupCheck(pPlayer, kPwUpDoppleganger)) { else if (powerupCheck(thisPlayer, kPwUpDoppleganger)) {
pTSprite->pal = 11 + (gView->teamId & 3); pTSprite->pal = 11 + (pPlayer->teamId & 3);
} }
if (powerupCheck(pPlayer, kPwUpReflectShots)) { if (powerupCheck(thisPlayer, kPwUpReflectShots)) {
viewAddEffect(tsprites, nTSprite, kViewEffectReflectiveBall); viewAddEffect(tsprites, nTSprite, kViewEffectReflectiveBall);
} }
if (cl_showweapon && gGameOptions.nGameType > 0 && gView) { if (cl_showweapon && gGameOptions.nGameType > 0 && pPlayer) {
viewAddEffect(tsprites, nTSprite, kViewEffectShowWeapon); viewAddEffect(tsprites, nTSprite, kViewEffectShowWeapon);
} }
if (pPlayer->flashEffect && (gView != pPlayer || gViewPos != VIEWPOS_0)) { if (thisPlayer->flashEffect && (pPlayer != thisPlayer || gViewPos != VIEWPOS_0)) {
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectShoot); auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectShoot);
if (pNTSprite) { if (pNTSprite) {
POSTURE* pPosture = &pPlayer->pPosture[pPlayer->lifeMode][pPlayer->posture]; POSTURE* pPosture = &thisPlayer->pPosture[thisPlayer->lifeMode][thisPlayer->posture];
pNTSprite->pos.XY() += pTSprite->angle.ToVector() * pPosture->zOffset * 0.25; pNTSprite->pos.XY() += pTSprite->angle.ToVector() * pPosture->zOffset * 0.25;
pNTSprite->set_int_z(pPlayer->actor->int_pos().Z - pPosture->xOffset); pNTSprite->set_int_z(thisPlayer->actor->int_pos().Z - pPosture->xOffset);
} }
} }
if (pPlayer->hasFlag > 0 && gGameOptions.nGameType == 3) { if (thisPlayer->hasFlag > 0 && gGameOptions.nGameType == 3) {
if (pPlayer->hasFlag & 1) { if (thisPlayer->hasFlag & 1) {
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectFlag); auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectFlag);
if (pNTSprite) if (pNTSprite)
{ {
@ -894,7 +895,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
pNTSprite->cstat |= CSTAT_SPRITE_XFLIP; pNTSprite->cstat |= CSTAT_SPRITE_XFLIP;
} }
} }
if (pPlayer->hasFlag & 2) { if (thisPlayer->hasFlag & 2) {
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectFlag); auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectFlag);
if (pNTSprite) if (pNTSprite)
{ {
@ -905,7 +906,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
} }
} }
if (pTSprite->ownerActor != gView->actor || gViewPos != VIEWPOS_0) { if (pTSprite->ownerActor != pPlayer->actor || gViewPos != VIEWPOS_0) {
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->int_pos().X, pTSprite->int_pos().Y) >= cZ) if (getflorzofslopeptr(pTSprite->sectp, pTSprite->int_pos().X, pTSprite->int_pos().Y) >= cZ)
{ {
viewAddEffect(tsprites, nTSprite, kViewEffectShadow); viewAddEffect(tsprites, nTSprite, kViewEffectShadow);

View file

@ -441,7 +441,7 @@ void GameInterface::Ticker()
viewCorrectPrediction(); viewCorrectPrediction();
ambProcess(pPlayer); ambProcess(pPlayer);
viewUpdateDelirium(); viewUpdateDelirium(pPlayer);
gi->UpdateSounds(); gi->UpdateSounds();
if (pPlayer->hand == 1) if (pPlayer->hand == 1)
{ {
@ -627,7 +627,6 @@ void GameInterface::app_init()
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925; enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;
gViewIndex = myconnectindex; gViewIndex = myconnectindex;
gView = &gPlayer[myconnectindex];
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -639,7 +638,6 @@ void GameInterface::app_init()
static void gameInit() static void gameInit()
{ {
gViewIndex = myconnectindex; gViewIndex = myconnectindex;
gView = &gPlayer[myconnectindex];
UpdateNetworkMenus(); UpdateNetworkMenus();
if (gGameOptions.nGameType > 0) if (gGameOptions.nGameType > 0)
@ -775,7 +773,7 @@ DEFINE_ACTION_FUNCTION(_Blood, PowerupIcon)
DEFINE_ACTION_FUNCTION(_Blood, GetViewPlayer) DEFINE_ACTION_FUNCTION(_Blood, GetViewPlayer)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
ACTION_RETURN_POINTER(gView); ACTION_RETURN_POINTER(&gPlayer[myconnectindex]);
} }
DEFINE_ACTION_FUNCTION(_BloodPlayer, GetHealth) DEFINE_ACTION_FUNCTION(_BloodPlayer, GetHealth)

View file

@ -60,7 +60,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (!SyncInput() && gamestate == GS_LEVEL) if (!SyncInput() && gamestate == GS_LEVEL)
{ {
// Perform unsynchronised angle/horizon if not dead. // Perform unsynchronised angle/horizon if not dead.
if (gView->actor->xspr.health != 0) if (pPlayer->actor->xspr.health != 0)
{ {
pPlayer->angle.applyinput(input.avel, &pPlayer->input.actions, scaleAdjust); pPlayer->angle.applyinput(input.avel, &pPlayer->input.actions, scaleAdjust);
pPlayer->horizon.applyinput(input.horz, &pPlayer->input.actions, scaleAdjust); pPlayer->horizon.applyinput(input.horz, &pPlayer->input.actions, scaleAdjust);

View file

@ -104,13 +104,13 @@ static void viewBurnTime(int gScale)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double interpfrac) void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double interpfrac)
{ {
double look_anghalf = gView->angle.look_anghalf(interpfrac); double look_anghalf = pPlayer->angle.look_anghalf(interpfrac);
if (gViewPos == 0) if (gViewPos == 0)
{ {
double looking_arc = gView->angle.looking_arc(interpfrac); double looking_arc = pPlayer->angle.looking_arc(interpfrac);
double cX = 160 - look_anghalf; double cX = 160 - look_anghalf;
double cY = 220 + looking_arc; double cY = 220 + looking_arc;
@ -133,29 +133,29 @@ void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, doubl
} }
int nShade = pSector? pSector->floorshade : 0; int nShade = pSector? pSector->floorshade : 0;
int nPalette = 0; int nPalette = 0;
if (gView->actor->sector()->hasX()) { if (pPlayer->actor->sector()->hasX()) {
sectortype* pViewSect = gView->actor->sector(); sectortype* pViewSect = pPlayer->actor->sector();
XSECTOR* pXSector = &pViewSect->xs(); XSECTOR* pXSector = &pViewSect->xs();
if (pXSector->color) if (pXSector->color)
nPalette = pViewSect->floorpal; nPalette = pViewSect->floorpal;
} }
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (gView->sceneQav < 0) WeaponDraw(gView, nShade, cX, cY, nPalette); if (pPlayer->sceneQav < 0) WeaponDraw(pPlayer, nShade, cX, cY, nPalette);
else if (gView->actor->xspr.health > 0) playerQavSceneDraw(gView, nShade, cX, cY, nPalette); else if (pPlayer->actor->xspr.health > 0) playerQavSceneDraw(pPlayer, nShade, cX, cY, nPalette);
else { else {
gView->sceneQav = gView->weaponQav = kQAVNone; pPlayer->sceneQav = pPlayer->weaponQav = kQAVNone;
gView->qavTimer = gView->weaponTimer = gView->curWeapon = 0; pPlayer->qavTimer = pPlayer->weaponTimer = pPlayer->curWeapon = 0;
} }
#else #else
WeaponDraw(gView, nShade, cX, cY, nPalette); WeaponDraw(pPlayer, nShade, cX, cY, nPalette);
#endif #endif
} }
if (gViewPos == 0 && gView->actor->xspr.burnTime > 60) if (gViewPos == 0 && pPlayer->actor->xspr.burnTime > 60)
{ {
viewBurnTime(gView->actor->xspr.burnTime); viewBurnTime(pPlayer->actor->xspr.burnTime);
} }
if (packItemActive(gView, 1)) if (packItemActive(pPlayer, 1))
{ {
drawElement(0, 0, 2344, 1, 0, 0, -1); drawElement(0, 0, 2344, 1, 0, 0, -1);
drawElement(320, 0, 2344, 1, 1, 0, 1); drawElement(320, 0, 2344, 1, 1, 0, 1);
@ -167,15 +167,15 @@ void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, doubl
drawElement(212, 77, 2347, 1, 0, 0, 1, 0, 0.2); drawElement(212, 77, 2347, 1, 0, 0, 1, 0, 0.2);
} }
} }
if (powerupCheck(gView, kPwUpAsbestArmor) > 0) if (powerupCheck(pPlayer, kPwUpAsbestArmor) > 0)
{ {
drawElement(0, 237, 2358, 1, 0, 1, -1); drawElement(0, 237, 2358, 1, 0, 1, -1);
drawElement(320, 237, 2358, 1, 1, 1, 1); drawElement(320, 237, 2358, 1, 1, 1, 1);
} }
int zn = ((gView->zWeapon - gView->zView - (12 << 8)) >> 7) + 220; int zn = ((pPlayer->zWeapon - pPlayer->zView - (12 << 8)) >> 7) + 220;
PLAYER* pPSprite = &gPlayer[gView->actor->spr.type - kDudePlayer1]; PLAYER* pPSprite = &gPlayer[pPlayer->actor->spr.type - kDudePlayer1];
if (gView->actor->IsPlayerActor() && pPSprite->hand == 1) if (pPlayer->actor->IsPlayerActor() && pPSprite->hand == 1)
{ {
gChoke.animateChoke(160, zn, interpfrac); gChoke.animateChoke(160, zn, interpfrac);
} }

View file

@ -72,7 +72,6 @@ void GameInterface::SwitchCoopView()
gViewIndex = connectpoint2[gViewIndex]; gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1) if (gViewIndex == -1)
gViewIndex = connecthead; gViewIndex = connecthead;
gView = &gPlayer[gViewIndex];
} }
else if (gGameOptions.nGameType == 3) else if (gGameOptions.nGameType == 3)
{ {
@ -85,7 +84,6 @@ void GameInterface::SwitchCoopView()
if (oldViewIndex == gViewIndex || gPlayer[myconnectindex].teamId == gPlayer[gViewIndex].teamId) if (oldViewIndex == gViewIndex || gPlayer[myconnectindex].teamId == gPlayer[gViewIndex].teamId)
break; break;
} while (oldViewIndex != gViewIndex); } while (oldViewIndex != gViewIndex);
gView = &gPlayer[gViewIndex];
} }
} }

View file

@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
PLAYER gPlayer[kMaxPlayers]; PLAYER gPlayer[kMaxPlayers];
PLAYER* gView;
bool gBlueFlagDropped = false; bool gBlueFlagDropped = false;
bool gRedFlagDropped = false; bool gRedFlagDropped = false;

View file

@ -201,7 +201,6 @@ struct POWERUPINFO
void playerResetPosture(PLAYER* pPlayer); void playerResetPosture(PLAYER* pPlayer);
extern PLAYER gPlayer[kMaxPlayers]; extern PLAYER gPlayer[kMaxPlayers];
extern PLAYER* gView;
extern bool gBlueFlagDropped; extern bool gBlueFlagDropped;
extern bool gRedFlagDropped; extern bool gRedFlagDropped;

View file

@ -72,7 +72,7 @@ static void UpdateFrame(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void UpdateStatusBar() void UpdateStatusBar(PLAYER* pPlayer)
{ {
if (automapMode == am_off && hud_size <= Hud_Stbar) if (automapMode == am_off && hud_size <= Hud_Stbar)
{ {
@ -81,7 +81,7 @@ void UpdateStatusBar()
SummaryInfo sum; SummaryInfo sum;
if (gGameOptions.nGameType == 3) if (gGameOptions.nGameType == 3)
{ {
sum.kills = gView ? gView->fragCount : 0; sum.kills = pPlayer ? pPlayer->fragCount : 0;
sum.maxkills = -3; sum.maxkills = -3;
} }
else else

View file

@ -111,12 +111,12 @@ GameStats GameInterface::getStats()
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void viewDrawAimedPlayerName(void) void viewDrawAimedPlayerName(PLAYER* pPlayer)
{ {
if (!cl_idplayers || (gView->aim.dx == 0 && gView->aim.dy == 0)) if (!cl_idplayers || (pPlayer->aim.dx == 0 && pPlayer->aim.dy == 0))
return; return;
int hit = HitScan(gView->actor, gView->zView, gView->aim.dx, gView->aim.dy, gView->aim.dz, CLIPMASK0, 512); int hit = HitScan(pPlayer->actor, pPlayer->zView, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, CLIPMASK0, 512);
if (hit == 3) if (hit == 3)
{ {
auto actor = gHitInfo.actor(); auto actor = gHitInfo.actor();
@ -314,27 +314,27 @@ void UpdateDacs(int nPalette, bool bNoTint)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void UpdateBlend() void UpdateBlend(PLAYER* pPlayer)
{ {
int nRed = 0; int nRed = 0;
int nGreen = 0; int nGreen = 0;
int nBlue = 0; int nBlue = 0;
nRed += gView->pickupEffect; nRed += pPlayer->pickupEffect;
nGreen += gView->pickupEffect; nGreen += pPlayer->pickupEffect;
nBlue -= gView->pickupEffect; nBlue -= pPlayer->pickupEffect;
nRed += ClipHigh(gView->painEffect, 85) * 2; nRed += ClipHigh(pPlayer->painEffect, 85) * 2;
nGreen -= ClipHigh(gView->painEffect, 85) * 3; nGreen -= ClipHigh(pPlayer->painEffect, 85) * 3;
nBlue -= ClipHigh(gView->painEffect, 85) * 3; nBlue -= ClipHigh(pPlayer->painEffect, 85) * 3;
nRed -= gView->blindEffect; nRed -= pPlayer->blindEffect;
nGreen -= gView->blindEffect; nGreen -= pPlayer->blindEffect;
nBlue -= gView->blindEffect; nBlue -= pPlayer->blindEffect;
nRed -= gView->chokeEffect >> 6; nRed -= pPlayer->chokeEffect >> 6;
nGreen -= gView->chokeEffect >> 5; nGreen -= pPlayer->chokeEffect >> 5;
nBlue -= gView->chokeEffect >> 6; nBlue -= pPlayer->chokeEffect >> 6;
nRed = ClipRange(nRed, -255, 255); nRed = ClipRange(nRed, -255, 255);
nGreen = ClipRange(nGreen, -255, 255); nGreen = ClipRange(nGreen, -255, 255);
@ -358,13 +358,13 @@ int gShowFrameRate = 1;
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void viewUpdateDelirium(void) void viewUpdateDelirium(PLAYER* pPlayer)
{ {
gScreenTiltO = gScreenTilt; gScreenTiltO = gScreenTilt;
deliriumTurnO = deliriumTurn; deliriumTurnO = deliriumTurn;
deliriumPitchO = deliriumPitch; deliriumPitchO = deliriumPitch;
int powerCount; int powerCount;
if ((powerCount = powerupCheck(gView, kPwUpDeliriumShroom)) != 0) if ((powerCount = powerupCheck(pPlayer, kPwUpDeliriumShroom)) != 0)
{ {
int tilt1 = 170, tilt2 = 170, pitch = 20; int tilt1 = 170, tilt2 = 170, pitch = 20;
int timer = PlayClock * 2; int timer = PlayClock * 2;
@ -405,7 +405,7 @@ void viewUpdateDelirium(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void viewUpdateShake(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, double& pshakeX, double& pshakeY) void viewUpdateShake(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, double& pshakeX, double& pshakeY)
{ {
auto doEffect = [&](const int& effectType) auto doEffect = [&](const int& effectType)
{ {
@ -421,8 +421,8 @@ void viewUpdateShake(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, doub
pshakeY += QRandom2(nValue); pshakeY += QRandom2(nValue);
} }
}; };
doEffect(gView->flickerEffect); doEffect(pPlayer->flickerEffect);
doEffect(gView->quakeEffect); doEffect(pPlayer->quakeEffect);
} }
@ -436,7 +436,7 @@ int32_t g_frameRate;
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void DrawMap(DBloodActor* view, const double smoothratio) static void DrawMap(PLAYER* pPlayer, const double smoothratio)
{ {
int tm = 0; int tm = 0;
if (viewport3d.Left() > 0) if (viewport3d.Left() > 0)
@ -444,8 +444,8 @@ static void DrawMap(DBloodActor* view, const double smoothratio)
setViewport(Hud_Stbar); setViewport(Hud_Stbar);
tm = 1; tm = 1;
} }
auto ang = !SyncInput() ? gView->angle.sum() : gView->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio)); auto ang = !SyncInput() ? pPlayer->angle.sum() : pPlayer->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
DrawOverheadMap(view->interpolatedpos(smoothratio * (1. / MaxSmoothRatio)).XY(), ang, smoothratio * (1. / MaxSmoothRatio)); DrawOverheadMap(pPlayer->actor->interpolatedpos(smoothratio * (1. / MaxSmoothRatio)).XY(), ang, smoothratio * (1. / MaxSmoothRatio));
if (tm) if (tm)
setViewport(hud_size); setViewport(hud_size);
} }
@ -456,13 +456,13 @@ static void DrawMap(DBloodActor* view, const double smoothratio)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double smoothratio) static void SetupView(PLAYER* pPlayer, int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sectortype*& pSector, double& zDelta, double& shakeX, double& shakeY, DAngle& rotscrnang, const double smoothratio)
{ {
int bobWidth, bobHeight; int bobWidth, bobHeight;
pSector = gView->actor->sector(); pSector = pPlayer->actor->sector();
#if 0 #if 0
if (numplayers > 1 && gView == gMe && gPrediction && gMe->actor->xspr.health > 0) if (numplayers > 1 && pPlayer == gMe && gPrediction && gMe->actor->xspr.health > 0)
{ {
nSectnum = predict.sectnum; nSectnum = predict.sectnum;
cX = interpolatedvalue(predictOld.x, predict.x, smoothratio * (1. / MaxSmoothRatio)); cX = interpolatedvalue(predictOld.x, predict.x, smoothratio * (1. / MaxSmoothRatio));
@ -490,31 +490,31 @@ static void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sec
else else
#endif #endif
{ {
cX = interpolatedvalue(gView->actor->opos.X, gView->actor->spr.pos.X, smoothratio * (1. / MaxSmoothRatio)) * worldtoint; cX = interpolatedvalue(pPlayer->actor->opos.X, pPlayer->actor->spr.pos.X, smoothratio * (1. / MaxSmoothRatio)) * worldtoint;
cY = interpolatedvalue(gView->actor->opos.Y, gView->actor->spr.pos.Y, smoothratio * (1. / MaxSmoothRatio)) * worldtoint; cY = interpolatedvalue(pPlayer->actor->opos.Y, pPlayer->actor->spr.pos.Y, smoothratio * (1. / MaxSmoothRatio)) * worldtoint;
cZ = interpolatedvalue(gView->ozView, gView->zView, smoothratio * (1. / MaxSmoothRatio)); cZ = interpolatedvalue(pPlayer->ozView, pPlayer->zView, smoothratio * (1. / MaxSmoothRatio));
zDelta = interpolatedvalue<double>(gView->ozWeapon, gView->zWeapon - gView->zView - (12 << 8), smoothratio * (1. / MaxSmoothRatio)); zDelta = interpolatedvalue<double>(pPlayer->ozWeapon, pPlayer->zWeapon - pPlayer->zView - (12 << 8), smoothratio * (1. / MaxSmoothRatio));
bobWidth = interpolatedvalue(gView->obobWidth, gView->bobWidth, smoothratio * (1. / MaxSmoothRatio)); bobWidth = interpolatedvalue(pPlayer->obobWidth, pPlayer->bobWidth, smoothratio * (1. / MaxSmoothRatio));
bobHeight = interpolatedvalue(gView->obobHeight, gView->bobHeight, smoothratio * (1. / MaxSmoothRatio)); bobHeight = interpolatedvalue(pPlayer->obobHeight, pPlayer->bobHeight, smoothratio * (1. / MaxSmoothRatio));
shakeX = interpolatedvalue<double>(gView->oswayWidth, gView->swayWidth, smoothratio * (1. / MaxSmoothRatio)); shakeX = interpolatedvalue<double>(pPlayer->oswayWidth, pPlayer->swayWidth, smoothratio * (1. / MaxSmoothRatio));
shakeY = interpolatedvalue<double>(gView->oswayHeight, gView->swayHeight, smoothratio * (1. / MaxSmoothRatio)); shakeY = interpolatedvalue<double>(pPlayer->oswayHeight, pPlayer->swayHeight, smoothratio * (1. / MaxSmoothRatio));
if (!SyncInput()) if (!SyncInput())
{ {
cA = gView->angle.sum(); cA = pPlayer->angle.sum();
cH = gView->horizon.sum(); cH = pPlayer->horizon.sum();
rotscrnang = gView->angle.rotscrnang; rotscrnang = pPlayer->angle.rotscrnang;
} }
else else
{ {
cA = gView->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio)); cA = pPlayer->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
cH = gView->horizon.interpolatedsum(smoothratio * (1. / MaxSmoothRatio)); cH = pPlayer->horizon.interpolatedsum(smoothratio * (1. / MaxSmoothRatio));
rotscrnang = gView->angle.interpolatedrotscrn(smoothratio * (1. / MaxSmoothRatio)); rotscrnang = pPlayer->angle.interpolatedrotscrn(smoothratio * (1. / MaxSmoothRatio));
} }
} }
viewUpdateShake(cX, cY, cZ, cA, cH, shakeX, shakeY); viewUpdateShake(pPlayer, cX, cY, cZ, cA, cH, shakeX, shakeY);
cH += buildhoriz(MulScale(0x40000000 - Cos(gView->tiltEffect << 2), 30, 30)); cH += buildhoriz(MulScale(0x40000000 - Cos(pPlayer->tiltEffect << 2), 30, 30));
if (gViewPos == 0) if (gViewPos == 0)
{ {
if (cl_viewhbob) if (cl_viewhbob)
@ -530,7 +530,7 @@ static void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sec
} }
else else
{ {
calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, gView->actor, &pSector, cA, cH, smoothratio); calcChaseCamPos((int*)&cX, (int*)&cY, (int*)&cZ, pPlayer->actor, &pSector, cA, cH, smoothratio);
} }
if (pSector != nullptr) if (pSector != nullptr)
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &pSector); CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &pSector);
@ -610,6 +610,8 @@ void renderCrystalBall()
void viewDrawScreen(bool sceneonly) void viewDrawScreen(bool sceneonly)
{ {
PLAYER* pPlayer = &gPlayer[myconnectindex];
if (testgotpic(2342, true)) if (testgotpic(2342, true))
{ {
FireProcess(); FireProcess();
@ -635,18 +637,18 @@ void viewDrawScreen(bool sceneonly)
if (automapMode == am_off) if (automapMode == am_off)
{ {
int basepal = 0; int basepal = 0;
if (powerupCheck(gView, kPwUpDeathMask) > 0) basepal = 4; if (powerupCheck(pPlayer, kPwUpDeathMask) > 0) basepal = 4;
else if (powerupCheck(gView, kPwUpReflectShots) > 0) basepal = 1; else if (powerupCheck(pPlayer, kPwUpReflectShots) > 0) basepal = 1;
else if (gView->isUnderwater) { else if (pPlayer->isUnderwater) {
if (gView->nWaterPal) basepal = gView->nWaterPal; if (pPlayer->nWaterPal) basepal = pPlayer->nWaterPal;
else { else {
if (gView->actor->xspr.medium == kMediumWater) basepal = 1; if (pPlayer->actor->xspr.medium == kMediumWater) basepal = 1;
else if (gView->actor->xspr.medium == kMediumGoo) basepal = 3; else if (pPlayer->actor->xspr.medium == kMediumGoo) basepal = 3;
else basepal = 2; else basepal = 2;
} }
} }
UpdateDacs(basepal); UpdateDacs(basepal);
UpdateBlend(); UpdateBlend(pPlayer);
int cX, cY, cZ; int cX, cY, cZ;
DAngle cA, rotscrnang; DAngle cA, rotscrnang;
@ -654,13 +656,13 @@ void viewDrawScreen(bool sceneonly)
sectortype* pSector; sectortype* pSector;
double zDelta; double zDelta;
double shakeX, shakeY; double shakeX, shakeY;
SetupView(cX, cY, cZ, cA, cH, pSector, zDelta, shakeX, shakeY, rotscrnang, gInterpolate); SetupView(pPlayer, cX, cY, cZ, cA, cH, pSector, zDelta, shakeX, shakeY, rotscrnang, gInterpolate);
DAngle tilt = interpolatedvalue(gScreenTiltO, gScreenTilt, gInterpolate * (1. / MaxSmoothRatio)); DAngle tilt = interpolatedvalue(gScreenTiltO, gScreenTilt, gInterpolate * (1. / MaxSmoothRatio));
bool bDelirium = powerupCheck(gView, kPwUpDeliriumShroom) > 0; bool bDelirium = powerupCheck(pPlayer, kPwUpDeliriumShroom) > 0;
static bool bDeliriumOld = false; static bool bDeliriumOld = false;
//int tiltcs, tiltdim; //int tiltcs, tiltdim;
uint8_t otherview = powerupCheck(gView, kPwUpCrystalBall) > 0; uint8_t otherview = powerupCheck(pPlayer, kPwUpCrystalBall) > 0;
if (tilt.Degrees() || bDelirium) if (tilt.Degrees() || bDelirium)
{ {
rotscrnang = tilt; rotscrnang = tilt;
@ -704,7 +706,7 @@ void viewDrawScreen(bool sceneonly)
break; break;
} }
} }
g_relvisibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - brightness, 0)) - g_visibility; g_relvisibility = (int32_t)(ClipLow(gVisibility - 32 * pPlayer->visibility - brightness, 0)) - g_visibility;
cA += interpolatedvalue(deliriumTurnO, deliriumTurn, gInterpolate * (1. / MaxSmoothRatio)); cA += interpolatedvalue(deliriumTurnO, deliriumTurn, gInterpolate * (1. / MaxSmoothRatio));
if (pSector != nullptr) if (pSector != nullptr)
@ -735,21 +737,21 @@ void viewDrawScreen(bool sceneonly)
} }
} }
if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate * (1. / MaxSmoothRatio)); if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate * (1. / MaxSmoothRatio));
fixedhoriz deliriumPitchI = interpolatedvalue(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), gInterpolate * (1. / MaxSmoothRatio)); fixedhoriz deliriumPitchI = interpolatedvalue(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), gInterpolate * (1. / MaxSmoothRatio));
auto bakCstat = gView->actor->spr.cstat; auto bakCstat = pPlayer->actor->spr.cstat;
gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
render_drawrooms(gView->actor, vec3_t( cX, cY, cZ ), sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate); render_drawrooms(pPlayer->actor, vec3_t( cX, cY, cZ ), sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
gView->actor->spr.cstat = bakCstat; pPlayer->actor->spr.cstat = bakCstat;
bDeliriumOld = bDelirium && gDeliriumBlur; bDeliriumOld = bDelirium && gDeliriumBlur;
int nClipDist = gView->actor->int_clipdist(); int nClipDist = pPlayer->actor->int_clipdist();
int vec, vf4; int vec, vf4;
Collision c1, c2; Collision c1, c2;
GetZRange(gView->actor, &vf4, &c1, &vec, &c2, nClipDist, 0); GetZRange(pPlayer->actor, &vf4, &c1, &vec, &c2, nClipDist, 0);
if (sceneonly) return; if (sceneonly) return;
double look_anghalf = gView->angle.look_anghalf(gInterpolate * (1. / MaxSmoothRatio)); double look_anghalf = pPlayer->angle.look_anghalf(gInterpolate * (1. / MaxSmoothRatio));
DrawCrosshair(kCrosshairTile, gView->actor->xspr.health >> 4, -look_anghalf, 0, 2); DrawCrosshair(kCrosshairTile, pPlayer->actor->xspr.health >> 4, -look_anghalf, 0, 2);
#if 0 // This currently does not work. May have to be redone as a hardware effect. #if 0 // This currently does not work. May have to be redone as a hardware effect.
if (v4 && gNetPlayers > 1) if (v4 && gNetPlayers > 1)
{ {
@ -782,23 +784,23 @@ void viewDrawScreen(bool sceneonly)
} }
UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays. UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays.
MarkSectorSeen(gView->actor->sector()); MarkSectorSeen(pPlayer->actor->sector());
if (automapMode != am_off) if (automapMode != am_off)
{ {
DrawMap(gView->actor, gInterpolate); DrawMap(pPlayer, gInterpolate);
} }
UpdateStatusBar(); UpdateStatusBar(pPlayer);
viewDrawAimedPlayerName(); viewDrawAimedPlayerName(pPlayer);
if (paused) if (paused)
{ {
auto text = GStrings("TXTB_PAUSED"); auto text = GStrings("TXTB_PAUSED");
viewDrawText(PickBigFont(text), text, 160, 10, 0, 0, 1, 0); viewDrawText(PickBigFont(text), text, 160, 10, 0, 0, 1, 0);
} }
else if (gView->nPlayer != myconnectindex) else if (pPlayer->nPlayer != myconnectindex)
{ {
FStringf gTempStr("] %s [", PlayerName(gView->nPlayer)); FStringf gTempStr("] %s [", PlayerName(pPlayer->nPlayer));
viewDrawText(OriginalSmallFont, gTempStr, 160, 10, 0, 0, 1, 0); viewDrawText(OriginalSmallFont, gTempStr, 160, 10, 0, 0, 1, 0);
} }
if (cl_interpolate) if (cl_interpolate)
@ -839,7 +841,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos,
for (int i = connecthead; i >= 0; i = connectpoint2[i]) for (int i = connecthead; i >= 0; i = connectpoint2[i])
{ {
if (i == gView->nPlayer || gGameOptions.nGameType == 1) if (i == myconnectindex || gGameOptions.nGameType == 1)
{ {
auto actor = gPlayer[i].actor; auto actor = gPlayer[i].actor;
auto vect = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim); auto vect = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim);

View file

@ -92,13 +92,13 @@ extern DAngle gScreenTiltO, gScreenTilt;
extern int gShowFrameRate; extern int gShowFrameRate;
extern int gLastPal; extern int gLastPal;
void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double interpfrac); void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double interpfrac);
void viewInitializePrediction(void); void viewInitializePrediction(void);
void viewUpdatePrediction(InputPacket* pInput); void viewUpdatePrediction(InputPacket* pInput);
void viewCorrectPrediction(void); void viewCorrectPrediction(void);
void viewBackupView(int nPlayer); void viewBackupView(int nPlayer);
void InitStatusBar(void); void InitStatusBar(void);
void UpdateStatusBar(); void UpdateStatusBar(PLAYER* pPlayer);
void viewInit(void); void viewInit(void);
void viewprocessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth); void viewprocessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void viewSetMessage(const char* pMessage, const char* color = nullptr, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL); void viewSetMessage(const char* pMessage, const char* color = nullptr, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);
@ -108,7 +108,7 @@ void viewSetErrorMessage(const char* pMessage);
void DoLensEffect(void); void DoLensEffect(void);
void UpdateDacs(int nPalette, bool bNoTint = false); void UpdateDacs(int nPalette, bool bNoTint = false);
void viewDrawScreen(bool sceneonly = false); void viewDrawScreen(bool sceneonly = false);
void viewUpdateDelirium(void); void viewUpdateDelirium(PLAYER* pPlayer);
void viewSetSystemMessage(const char* pMessage, ...); void viewSetSystemMessage(const char* pMessage, ...);
inline void viewInterpolateSector(sectortype* pSector) inline void viewInterpolateSector(sectortype* pSector)