- Blood: Eliminate gMe extern'd pointer.

This commit is contained in:
Mitchell Richters 2022-09-10 23:15:58 +10:00 committed by Christoph Oelckers
parent 3c39174a22
commit 6356aeafc2
14 changed files with 164 additions and 160 deletions

View file

@ -47,7 +47,7 @@ int nAmbChannels = 0;
//
//---------------------------------------------------------------------------
void ambProcess(void)
void ambProcess(PLAYER* pPlayer)
{
if (!SoundEnabled())
return;
@ -60,7 +60,7 @@ void ambProcess(void)
{
if (actor->xspr.state)
{
int nDist = (int)(actor->spr.pos - gMe->actor->spr.pos).Length();
int nDist = (int)(actor->spr.pos - pPlayer->actor->spr.pos).Length();
int vs = MulScale(actor->xspr.data4, actor->xspr.busy, 16);
ambChannels[actor->spr.intowner].distance += ClipRange(scale(nDist, actor->xspr.data1, actor->xspr.data2, vs, 0), 0, vs);
}

View file

@ -343,7 +343,7 @@ void StartLevel(MapRecord* level, bool newgame)
PreloadCache();
InitMirrors();
trInit(actorlist);
if (!gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
if (!gPlayer[myconnectindex].packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
sfxSetReverb(0);
ambInit();
Net_ClearFifo();
@ -426,6 +426,8 @@ void GameInterface::Ticker()
playerProcess(&gPlayer[i]);
}
PLAYER* pPlayer = &gPlayer[myconnectindex];
trProcessBusy();
evProcess(PlayClock);
seqProcess(4);
@ -438,17 +440,17 @@ void GameInterface::Ticker()
actortime.Unclock();
viewCorrectPrediction();
ambProcess();
ambProcess(pPlayer);
viewUpdateDelirium();
gi->UpdateSounds();
if (gMe->hand == 1)
if (pPlayer->hand == 1)
{
const int CHOKERATE = 8;
const int COUNTRATE = 30;
gChokeCounter += CHOKERATE;
while (gChokeCounter >= COUNTRATE)
{
gChoke.callback(gMe);
gChoke.callback(pPlayer);
gChokeCounter -= COUNTRATE;
}
}
@ -625,7 +627,7 @@ void GameInterface::app_init()
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;
gViewIndex = myconnectindex;
gMe = gView = &gPlayer[myconnectindex];
gView = &gPlayer[myconnectindex];
}
//---------------------------------------------------------------------------
@ -637,7 +639,7 @@ void GameInterface::app_init()
static void gameInit()
{
gViewIndex = myconnectindex;
gMe = gView = &gPlayer[myconnectindex];
gView = &gPlayer[myconnectindex];
UpdateNetworkMenus();
if (gGameOptions.nGameType > 0)

View file

@ -445,7 +445,7 @@ void CounterCheck(DBloodActor*, sectortype* pSector) // 12
void FinishHim(DBloodActor* actor, sectortype*) // 13
{
if (!actor) return;
if (actor->IsPlayerActor() && playerSeqPlaying(&gPlayer[actor->spr.type - kDudePlayer1], 16) && actor == gMe->actor)
if (actor->IsPlayerActor() && playerSeqPlaying(&gPlayer[actor->spr.type - kDudePlayer1], 16) && actor == gPlayer[myconnectindex].actor)
sndStartSample(3313, -1, 1, 0);
}

View file

@ -174,8 +174,8 @@ void hudDraw(PLAYER* gView, sectortype* pSector, double bobx, double boby, doubl
}
int zn = ((gView->zWeapon - gView->zView - (12 << 8)) >> 7) + 220;
PLAYER* pPSprite = &gPlayer[gMe->actor->spr.type - kDudePlayer1];
if (gMe->actor->IsPlayerActor() && pPSprite->hand == 1)
PLAYER* pPSprite = &gPlayer[gView->actor->spr.type - kDudePlayer1];
if (gView->actor->IsPlayerActor() && pPSprite->hand == 1)
{
gChoke.animateChoke(160, zn, interpfrac);
}

View file

@ -760,7 +760,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
InitSectorFX();
viewInitializePrediction();
PreloadCache();
if (!gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
if (!gPlayer[myconnectindex].packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
sfxSetReverb(0);
ambInit();
for (int i = 0; i < gNetPlayers; i++)

View file

@ -46,11 +46,11 @@ void sub_5A928(void)
buttonMap.ClearButton(i);
}
const char* SetGodMode(bool god)
const char* SetGodMode(PLAYER* pPlayer, bool god)
{
playerSetGodMode(gMe, god);
playerSetGodMode(pPlayer, god);
bPlayerCheated = true;
return gMe->godMode ? GStrings("TXTB_GODMODE") : GStrings("TXTB_NOTGODMODE");
return pPlayer->godMode ? GStrings("TXTB_GODMODE") : GStrings("TXTB_NOTGODMODE");
}
const char* SetClipMode(bool noclip)
@ -76,29 +76,29 @@ void packClear(PLAYER* pPlayer)
}
}
void SetAmmo(bool stat)
void SetAmmo(PLAYER* pPlayer, bool stat)
{
if (stat)
{
for (int i = 0; i < 12; i++)
gMe->ammoCount[i] = gAmmoInfo[i].max;
pPlayer->ammoCount[i] = gAmmoInfo[i].max;
viewSetMessage(GStrings("TXTB_FULLAMMO"));
}
else
{
for (int i = 0; i < 12; i++)
gMe->ammoCount[i] = 0;
pPlayer->ammoCount[i] = 0;
viewSetMessage(GStrings("TXTB_NOAMMO"));
}
}
void SetWeapons(bool stat)
void SetWeapons(PLAYER* pPlayer, bool stat)
{
for (int i = 0; i < 14; i++)
{
gMe->hasWeapon[i] = stat;
pPlayer->hasWeapon[i] = stat;
}
SetAmmo(stat);
SetAmmo(pPlayer, stat);
if (stat)
viewSetMessage(GStrings("TXTB_ALLWEAP"));
else
@ -106,29 +106,29 @@ void SetWeapons(bool stat)
if (!VanillaMode())
{
// Keep the pitchfork to avoid freeze
gMe->hasWeapon[kWeapPitchFork] = 1;
gMe->curWeapon = kWeapNone;
gMe->nextWeapon = kWeapPitchFork;
pPlayer->hasWeapon[kWeapPitchFork] = 1;
pPlayer->curWeapon = kWeapNone;
pPlayer->nextWeapon = kWeapPitchFork;
}
viewSetMessage(GStrings("TXTB_NOWEAP"));
}
}
void SetToys(bool stat)
void SetToys(PLAYER* pPlayer, bool stat)
{
if (stat)
{
packStuff(gMe);
packStuff(pPlayer);
viewSetMessage(GStrings("TXTB_FULLINV"));
}
else
{
packClear(gMe);
packClear(pPlayer);
viewSetMessage(GStrings("TXTB_NOINV"));
}
}
void SetArmor(bool stat)
void SetArmor(PLAYER* pPlayer, bool stat)
{
int nAmount;
if (stat)
@ -142,13 +142,13 @@ void SetArmor(bool stat)
nAmount = 0;
}
for (int i = 0; i < 3; i++)
gMe->armor[i] = nAmount;
pPlayer->armor[i] = nAmount;
}
void SetKeys(bool stat)
void SetKeys(PLAYER* pPlayer, bool stat)
{
for (int i = 1; i <= 6; i++)
gMe->hasKey[i] = stat;
pPlayer->hasKey[i] = stat;
if (stat)
viewSetMessage(GStrings("TXTB_ALLKEYS"));
else
@ -173,95 +173,95 @@ void SetMap(bool stat)
viewSetMessage(GStrings("TXTB_NOALLMAP"));
}
void SetWooMode(bool stat)
void SetWooMode(PLAYER* pPlayer, bool stat)
{
if (stat)
{
if (!powerupCheck(gMe, kPwUpTwoGuns))
powerupActivate(gMe, kPwUpTwoGuns);
if (!powerupCheck(pPlayer, kPwUpTwoGuns))
powerupActivate(pPlayer, kPwUpTwoGuns);
}
else
{
if (powerupCheck(gMe, kPwUpTwoGuns))
if (powerupCheck(pPlayer, kPwUpTwoGuns))
{
if (!VanillaMode())
gMe->pwUpTime[kPwUpTwoGuns] = 0;
powerupDeactivate(gMe, kPwUpTwoGuns);
pPlayer->pwUpTime[kPwUpTwoGuns] = 0;
powerupDeactivate(pPlayer, kPwUpTwoGuns);
}
}
}
void ToggleWooMode(void)
void ToggleWooMode(PLAYER* pPlayer)
{
SetWooMode(!(powerupCheck(gMe, kPwUpTwoGuns) != 0));
SetWooMode(pPlayer, !(powerupCheck(pPlayer, kPwUpTwoGuns) != 0));
}
void ToggleBoots(void)
void ToggleBoots(PLAYER* pPlayer)
{
if (powerupCheck(gMe, kPwUpJumpBoots))
if (powerupCheck(pPlayer, kPwUpJumpBoots))
{
viewSetMessage(GStrings("TXTB_NOJBOOTS"));
if (!VanillaMode())
{
gMe->pwUpTime[kPwUpJumpBoots] = 0;
gMe->packSlots[4].curAmount = 0;
pPlayer->pwUpTime[kPwUpJumpBoots] = 0;
pPlayer->packSlots[4].curAmount = 0;
}
powerupDeactivate(gMe, kPwUpJumpBoots);
powerupDeactivate(pPlayer, kPwUpJumpBoots);
}
else
{
viewSetMessage(GStrings("TXTB_JBOOTS"));
if (!VanillaMode())
gMe->pwUpTime[kPwUpJumpBoots] = gPowerUpInfo[kPwUpJumpBoots].bonusTime;
powerupActivate(gMe, kPwUpJumpBoots);
pPlayer->pwUpTime[kPwUpJumpBoots] = gPowerUpInfo[kPwUpJumpBoots].bonusTime;
powerupActivate(pPlayer, kPwUpJumpBoots);
}
}
void ToggleInvisibility(void)
void ToggleInvisibility(PLAYER* pPlayer)
{
if (powerupCheck(gMe, kPwUpShadowCloak))
if (powerupCheck(pPlayer, kPwUpShadowCloak))
{
viewSetMessage(GStrings("TXTB_VISIBLE"));
if (!VanillaMode())
gMe->pwUpTime[kPwUpShadowCloak] = 0;
powerupDeactivate(gMe, kPwUpShadowCloak);
pPlayer->pwUpTime[kPwUpShadowCloak] = 0;
powerupDeactivate(pPlayer, kPwUpShadowCloak);
}
else
{
viewSetMessage(GStrings("TXTB_INVISIBLE"));
powerupActivate(gMe, kPwUpShadowCloak);
powerupActivate(pPlayer, kPwUpShadowCloak);
}
}
void ToggleInvulnerability(void)
void ToggleInvulnerability(PLAYER* pPlayer)
{
if (powerupCheck(gMe, kPwUpDeathMask))
if (powerupCheck(pPlayer, kPwUpDeathMask))
{
viewSetMessage(GStrings("TXTB_VULN"));
if (!VanillaMode())
gMe->pwUpTime[kPwUpDeathMask] = 0;
powerupDeactivate(gMe, kPwUpDeathMask);
pPlayer->pwUpTime[kPwUpDeathMask] = 0;
powerupDeactivate(pPlayer, kPwUpDeathMask);
}
else
{
viewSetMessage(GStrings("TXTB_INVULN"));
powerupActivate(gMe, kPwUpDeathMask);
powerupActivate(pPlayer, kPwUpDeathMask);
}
}
void ToggleDelirium(void)
void ToggleDelirium(PLAYER* pPlayer)
{
if (powerupCheck(gMe, kPwUpDeliriumShroom))
if (powerupCheck(pPlayer, kPwUpDeliriumShroom))
{
viewSetMessage(GStrings("TXTB_NODELIR"));
if (!VanillaMode())
gMe->pwUpTime[kPwUpDeliriumShroom] = 0;
powerupDeactivate(gMe, kPwUpDeliriumShroom);
pPlayer->pwUpTime[kPwUpDeliriumShroom] = 0;
powerupDeactivate(pPlayer, kPwUpDeliriumShroom);
}
else
{
viewSetMessage(GStrings("TXTB_DELIR"));
powerupActivate(gMe, kPwUpDeliriumShroom);
powerupActivate(pPlayer, kPwUpDeliriumShroom);
}
}
@ -292,24 +292,25 @@ static int parseArgs(char* pzArgs, int* nArg1, int* nArg2)
const char* GameInterface::GenericCheat(int player, int cheat)
{
// message processing is not perfect because many cheats output multiple messages.
PLAYER* pPlayer = &gPlayer[player];
if (gGameOptions.nGameType != 0 || numplayers > 1) // sp only for now.
return nullptr;
if (gamestate != GS_LEVEL || gMe->actor->xspr.health == 0) // must be alive and in a level to cheat.
if (gamestate != GS_LEVEL || pPlayer->actor->xspr.health == 0) // must be alive and in a level to cheat.
return nullptr;
bPlayerCheated = true;
switch (cheat)
{
case CHT_GOD:
return SetGodMode(!gMe->godMode);
return SetGodMode(pPlayer, !pPlayer->godMode);
case CHT_GODOFF:
return SetGodMode(false);
return SetGodMode(pPlayer, false);
case CHT_GODON:
return SetGodMode(true);
return SetGodMode(pPlayer, true);
case CHT_NOCLIP:
return SetClipMode(!gNoClip);
@ -318,107 +319,107 @@ const char* GameInterface::GenericCheat(int player, int cheat)
// demo record
break;
case kCheatSatchel:
SetToys(true);
SetToys(pPlayer, true);
break;
case kCheatKevorkian:
actDamageSprite(gMe->actor, gMe->actor, kDamageBullet, 8000);
actDamageSprite(pPlayer->actor, pPlayer->actor, kDamageBullet, 8000);
return GStrings("TXTB_KEVORKIAN");
case kCheatMcGee:
{
if (!gMe->actor->xspr.burnTime)
evPostActor(gMe->actor, 0, kCallbackFXFlameLick);
actBurnSprite(gMe->actor, gMe->actor, 2400);
if (!pPlayer->actor->xspr.burnTime)
evPostActor(pPlayer->actor, 0, kCallbackFXFlameLick);
actBurnSprite(pPlayer->actor, pPlayer->actor, 2400);
return GStrings("TXTB_FIRED");
}
case kCheatEdmark:
actDamageSprite(gMe->actor, gMe->actor, kDamageExplode, 8000);
actDamageSprite(pPlayer->actor, pPlayer->actor, kDamageExplode, 8000);
return GStrings("TXTB_THEDAYS");
case kCheatKrueger:
{
actHealDude(gMe->actor, 200, 200);
gMe->armor[1] = VanillaMode() ? 200 : 3200;
if (!gMe->actor->xspr.burnTime)
evPostActor(gMe->actor, 0, kCallbackFXFlameLick);
actBurnSprite(gMe->actor, gMe->actor, 2400);
actHealDude(pPlayer->actor, 200, 200);
pPlayer->armor[1] = VanillaMode() ? 200 : 3200;
if (!pPlayer->actor->xspr.burnTime)
evPostActor(pPlayer->actor, 0, kCallbackFXFlameLick);
actBurnSprite(pPlayer->actor, pPlayer->actor, 2400);
return GStrings("TXTB_RETARD");
}
case kCheatSterno:
gMe->blindEffect = 250;
pPlayer->blindEffect = 250;
break;
case kCheat14: // quakeEffect (causing a little flickerEffect), not used by any cheat code (dead code)
gMe->flickerEffect = 360;
pPlayer->flickerEffect = 360;
break;
case kCheatSpork:
actHealDude(gMe->actor, 200, 200);
actHealDude(pPlayer->actor, 200, 200);
break;
case kCheatClarice:
for (int i = 0; i < 3; i++)
gMe->armor[i] = 1600;
pPlayer->armor[i] = 1600;
return GStrings("TXTB_HALFARMOR");
case kCheatFrankenstein:
gMe->packSlots[0].curAmount = 100;
pPlayer->packSlots[0].curAmount = 100;
break;
case kCheatCheeseHead:
gMe->packSlots[1].curAmount = 100;
pPlayer->packSlots[1].curAmount = 100;
if (!VanillaMode())
gMe->pwUpTime[kPwUpDivingSuit] = gPowerUpInfo[kPwUpDivingSuit].bonusTime;
pPlayer->pwUpTime[kPwUpDivingSuit] = gPowerUpInfo[kPwUpDivingSuit].bonusTime;
break;
case kCheatTequila:
ToggleWooMode();
ToggleWooMode(pPlayer);
break;
case kCheatFunkyShoes:
ToggleBoots();
ToggleBoots(pPlayer);
break;
case kCheatKeyMaster:
SetKeys(true);
SetKeys(pPlayer, true);
break;
case kCheatOneRing:
ToggleInvisibility();
ToggleInvisibility(pPlayer);
break;
case kCheatVoorhees:
ToggleInvulnerability();
ToggleInvulnerability(pPlayer);
break;
case kCheatJoJo:
ToggleDelirium();
ToggleDelirium(pPlayer);
break;
case kCheatLaraCroft:
SetInfiniteAmmo(!gInfiniteAmmo);
SetWeapons(gInfiniteAmmo);
SetWeapons(pPlayer, gInfiniteAmmo);
break;
case kCheatHongKong:
SetWeapons(true);
SetWeapons(pPlayer, true);
SetInfiniteAmmo(true);
break;
case kCheatMontana:
SetWeapons(true);
SetToys(true);
SetWeapons(pPlayer, true);
SetToys(pPlayer, true);
break;
case kCheatBunz:
SetWeapons(true);
SetWooMode(true);
SetWeapons(pPlayer, true);
SetWooMode(pPlayer, true);
break;
case kCheatCousteau:
actHealDude(gMe->actor, 200, 200);
gMe->packSlots[1].curAmount = 100;
actHealDude(pPlayer->actor, 200, 200);
pPlayer->packSlots[1].curAmount = 100;
if (!VanillaMode())
gMe->pwUpTime[kPwUpDivingSuit] = gPowerUpInfo[kPwUpDivingSuit].bonusTime;
pPlayer->pwUpTime[kPwUpDivingSuit] = gPowerUpInfo[kPwUpDivingSuit].bonusTime;
break;
case kCheatForkYou:
SetInfiniteAmmo(false);
SetMap(false);
SetWeapons(false);
SetAmmo(false);
SetArmor(false);
SetToys(false);
SetKeys(false);
SetWooMode(true);
powerupActivate(gMe, kPwUpDeliriumShroom);
gMe->actor->xspr.health = 16;
gMe->hasWeapon[kWeapPitchFork] = 1;
gMe->curWeapon = kWeapNone;
gMe->nextWeapon = kWeapPitchFork;
SetWeapons(pPlayer, false);
SetAmmo(pPlayer, false);
SetArmor(pPlayer, false);
SetToys(pPlayer, false);
SetKeys(pPlayer, false);
SetWooMode(pPlayer, true);
powerupActivate(pPlayer, kPwUpDeliriumShroom);
pPlayer->actor->xspr.health = 16;
pPlayer->hasWeapon[kWeapPitchFork] = 1;
pPlayer->curWeapon = kWeapNone;
pPlayer->nextWeapon = kWeapPitchFork;
break;
default:
@ -511,10 +512,11 @@ static cheatseq_t s_CheatInfo[] = {
void cheatReset(void)
{
PLAYER* pPlayer = &gPlayer[myconnectindex];
bPlayerCheated = 0;
playerSetGodMode(gMe, 0);
playerSetGodMode(pPlayer, 0);
gNoClip = 0;
packClear(gMe);
packClear(pPlayer);
gInfiniteAmmo = 0;
gFullMap = 0;
}
@ -528,10 +530,11 @@ void cheatReset(void)
static void cmd_Give(int player, uint8_t** stream, bool skip)
{
PLAYER* pPlayer = &gPlayer[player];
int type = ReadByte(stream);
if (skip) return;
if (numplayers != 1 || gamestate != GS_LEVEL || gMe->actor->xspr.health == 0)
if (numplayers != 1 || gamestate != GS_LEVEL || pPlayer->actor->xspr.health == 0)
{
Printf("give: Cannot give while dead or not in a single-player game.\n");
return;
@ -540,41 +543,41 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
switch (type)
{
case GIVE_ALL:
SetWeapons(true);
SetAmmo(true);
SetToys(true);
SetArmor(true);
SetKeys(true);
SetWeapons(pPlayer, true);
SetAmmo(pPlayer, true);
SetToys(pPlayer, true);
SetArmor(pPlayer, true);
SetKeys(pPlayer, true);
bPlayerCheated = true;
break;
case GIVE_HEALTH:
actHealDude(gMe->actor, 200, 200);
actHealDude(pPlayer->actor, 200, 200);
bPlayerCheated = true;
break;
case GIVE_WEAPONS:
SetWeapons(true);
SetWeapons(pPlayer, true);
bPlayerCheated = true;
break;
case GIVE_AMMO:
SetAmmo(true);
SetAmmo(pPlayer, true);
bPlayerCheated = true;
break;
case GIVE_ARMOR:
SetArmor(true);
SetArmor(pPlayer, true);
bPlayerCheated = true;
break;
case GIVE_KEYS:
SetKeys(true);
SetKeys(pPlayer, true);
bPlayerCheated = true;
break;
case GIVE_INVENTORY:
SetToys(true);
SetToys(pPlayer, true);
bPlayerCheated = true;
break;

View file

@ -38,10 +38,4 @@ enum MESSAGE_PRIORITY {
extern bool bPlayerCheated;
void cheatReset(void);
void SetAmmo(bool stat);
void SetWeapons(bool stat);
void SetToys(bool stat);
void SetArmor(bool stat);
void SetKeys(bool stat);
END_BLD_NS

View file

@ -82,7 +82,7 @@ void GameInterface::SwitchCoopView()
gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1)
gViewIndex = connecthead;
if (oldViewIndex == gViewIndex || gMe->teamId == gPlayer[gViewIndex].teamId)
if (oldViewIndex == gViewIndex || gPlayer[myconnectindex].teamId == gPlayer[gViewIndex].teamId)
break;
} while (oldViewIndex != gViewIndex);
gView = &gPlayer[gViewIndex];

View file

@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
PLAYER gPlayer[kMaxPlayers];
PLAYER* gMe, * gView;
PLAYER* gView;
bool gBlueFlagDropped = false;
bool gRedFlagDropped = false;
@ -316,7 +316,7 @@ bool powerupActivate(PLAYER* pPlayer, int nPowerUp)
pPlayer->damageControl[0]++;
break;
case kItemReflectShots: // reflective shots
if (pPlayer == gMe && gGameOptions.nGameType == 0)
if (pPlayer->nPlayer == myconnectindex && gGameOptions.nGameType == 0)
sfxSetReverb2(1);
break;
case kItemDeathMask:
@ -325,7 +325,7 @@ bool powerupActivate(PLAYER* pPlayer, int nPowerUp)
break;
case kItemDivingSuit: // diving suit
pPlayer->damageControl[4]++;
if (pPlayer == gMe && gGameOptions.nGameType == 0)
if (pPlayer->nPlayer == myconnectindex && gGameOptions.nGameType == 0)
sfxSetReverb(1);
break;
case kItemGasMask:
@ -378,11 +378,11 @@ void powerupDeactivate(PLAYER* pPlayer, int nPowerUp)
break;
case kItemDivingSuit:
pPlayer->damageControl[4]--;
if (pPlayer == gMe && VanillaMode() ? true : pPlayer->pwUpTime[24] == 0)
if (pPlayer->nPlayer == myconnectindex && VanillaMode() ? true : pPlayer->pwUpTime[24] == 0)
sfxSetReverb(0);
break;
case kItemReflectShots:
if (pPlayer == gMe && VanillaMode() ? true : pPlayer->packSlots[1].isActive == 0)
if (pPlayer->nPlayer == myconnectindex && VanillaMode() ? true : pPlayer->packSlots[1].isActive == 0)
sfxSetReverb(0);
break;
case kItemGasMask:
@ -805,7 +805,7 @@ void playerStart(int nPlayer, int bNewLevel)
playerSetRace(pPlayer, kModeHuman);
playerResetPosture(pPlayer);
seqSpawn(pDudeInfo->seqStartID, actor, -1);
if (pPlayer == gMe)
if (nPlayer == myconnectindex)
actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
@ -901,7 +901,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->nWaterPal = 0;
playerResetPowerUps(pPlayer);
if (pPlayer == gMe)
if (nPlayer == myconnectindex)
{
viewInitializePrediction();
}
@ -1364,7 +1364,7 @@ void PickUp(PLAYER* pPlayer, DBloodActor* actor)
actPostSprite(actor, kStatFree);
pPlayer->pickupEffect = 30;
if (pPlayer == gMe) {
if (pPlayer->nPlayer == myconnectindex) {
if (customMsg > 0) trTextOver(customMsg - 1);
else if (msg) viewSetMessage(msg, nullptr, MESSAGE_PRIORITY_PICKUP);
}
@ -1694,7 +1694,7 @@ void ProcessInput(PLAYER* pPlayer)
auto pSector = result.hitSector;
auto pXSector = &pSector->xs();
int key = pXSector->Key;
if (pXSector->locked && pPlayer == gMe)
if (pXSector->locked && pPlayer->nPlayer == myconnectindex)
{
viewSetMessage(GStrings("TXTB_LOCKED"));
auto snd = 3062;
@ -1704,7 +1704,7 @@ void ProcessInput(PLAYER* pPlayer)
}
if (!key || pPlayer->hasKey[key])
trTriggerSector(pSector, kCmdSpritePush);
else if (pPlayer == gMe)
else if (pPlayer->nPlayer == myconnectindex)
{
viewSetMessage(GStrings("TXTB_KEY"));
auto snd = 3063;
@ -1719,7 +1719,7 @@ void ProcessInput(PLAYER* pPlayer)
auto pWall = result.hitWall;
auto pXWall = &pWall->xw();
int key = pXWall->key;
if (pXWall->locked && pPlayer == gMe)
if (pXWall->locked && pPlayer->nPlayer == myconnectindex)
{
viewSetMessage(GStrings("TXTB_LOCKED"));
auto snd = 3062;
@ -1729,7 +1729,7 @@ void ProcessInput(PLAYER* pPlayer)
}
if (!key || pPlayer->hasKey[key])
trTriggerWall(pWall, kCmdWallPush);
else if (pPlayer == gMe)
else if (pPlayer->nPlayer == myconnectindex)
{
viewSetMessage(GStrings("TXTB_KEY"));
auto snd = 3063;
@ -1743,11 +1743,11 @@ void ProcessInput(PLAYER* pPlayer)
{
auto act = result.actor();
int key = act->xspr.key;
if (actor->xspr.locked && pPlayer == gMe && act->xspr.lockMsg)
if (actor->xspr.locked && pPlayer->nPlayer == myconnectindex && act->xspr.lockMsg)
trTextOver(act->xspr.lockMsg);
if (!key || pPlayer->hasKey[key])
trTriggerSprite(act, kCmdSpritePush);
else if (pPlayer == gMe)
else if (pPlayer->nPlayer == myconnectindex)
{
viewSetMessage(GStrings("TXTB_KEY"));
sndStartSample(3063, 255, 2, 0);
@ -1920,7 +1920,7 @@ void playerProcess(PLAYER* pPlayer)
pPlayer->painEffect = ClipLow(pPlayer->painEffect - 4, 0);
pPlayer->blindEffect = ClipLow(pPlayer->blindEffect - 4, 0);
pPlayer->pickupEffect = ClipLow(pPlayer->pickupEffect - 4, 0);
if (pPlayer == gMe && gMe->actor->xspr.health == 0)
if (pPlayer->nPlayer == myconnectindex && pPlayer->actor->xspr.health == 0)
pPlayer->hand = 0;
if (!actor->xspr.health)
return;
@ -2005,7 +2005,7 @@ void playerFrag(PLAYER* pKiller, PLAYER* pVictim)
team_score[pVictim->teamId]--;
int nMessage = Random(5);
int nSound = gSuicide[nMessage].Kills;
if (pVictim == gMe && gMe->handTime <= 0)
if (pVictim->nPlayer == myconnectindex && pVictim->handTime <= 0)
{
strcpy(buffer, GStrings("TXTB_KILLSELF"));
if (gGameOptions.nGameType > 0 && nSound >= 0)
@ -2037,7 +2037,7 @@ void playerFrag(PLAYER* pKiller, PLAYER* pVictim)
int nSound = gVictory[nMessage].Kills;
const char* pzMessage = gVictory[nMessage].message;
sprintf(buffer, pzMessage, PlayerName(nKiller), PlayerName(nVictim));
if (gGameOptions.nGameType > 0 && nSound >= 0 && pKiller == gMe)
if (gGameOptions.nGameType > 0 && nSound >= 0 && pKiller->nPlayer == myconnectindex)
sndStartSample(nSound, 255, 2, 0);
}
viewSetMessage(buffer);
@ -2397,7 +2397,7 @@ void PlayerSurvive(int, DBloodActor* actor)
if (actor->IsPlayerActor())
{
PLAYER* pPlayer = &gPlayer[actor->spr.type - kDudePlayer1];
if (pPlayer == gMe)
if (pPlayer->nPlayer == myconnectindex)
viewSetMessage(GStrings("TXT_LIVEAGAIM"));
else
{

View file

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

View file

@ -73,9 +73,10 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
{
if (pos != nullptr && type != SOURCE_None)
{
PLAYER* pPlayer = &gPlayer[myconnectindex];
FVector3 camera;
if (gMe && gMe->actor) camera = GetSoundPos(gMe->actor->int_pos());
if (pPlayer && pPlayer->actor) camera = GetSoundPos(pPlayer->actor->int_pos());
else camera = { 0, 0, 0 }; // don't crash if there is no player.
if (vel) vel->Zero();
@ -114,13 +115,14 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3
void GameInterface::UpdateSounds()
{
PLAYER* pPlayer = &gPlayer[myconnectindex];
SoundListener listener;
if (gMe->actor)
if (pPlayer->actor)
{
listener.angle = -gMe->actor->spr.int_ang() * float(BAngRadian); // Build uses a period of 2048.
listener.angle = -pPlayer->actor->spr.int_ang() * float(BAngRadian); // Build uses a period of 2048.
listener.velocity.Zero();
listener.position = GetSoundPos(gMe->actor->int_pos());
listener.position = GetSoundPos(pPlayer->actor->int_pos());
listener.valid = true;
}
else
@ -134,7 +136,7 @@ void GameInterface::UpdateSounds()
//assert(primaryLevel->Zones.Size() > listenactor->Sector->ZoneNumber);
listener.Environment = 0;// primaryLevel->Zones[listenactor->Sector->ZoneNumber].Environment;
listener.ListenerObject = gMe;
listener.ListenerObject = pPlayer;
soundEngine->SetListener(listener);
soundEngine->UpdateSounds(I_GetTime());
}

View file

@ -63,7 +63,7 @@ void sfxKillAllSounds(void);
void sfxSetReverb(bool toggle);
void sfxSetReverb2(bool toggle);
void ambProcess(void);
void ambProcess(PLAYER* pPlayer);
void ambKillAll(void);
void ambInit(void);

View file

@ -613,9 +613,11 @@ void OperateSprite(DBloodActor* actor, EVENT event)
case kSoundPlayer:
if (gGameOptions.nGameType == 0)
{
if (gMe->actor->xspr.health <= 0)
PLAYER* pPlayer = &gPlayer[myconnectindex];
if (pPlayer->actor->xspr.health <= 0)
break;
gMe->restTime = 0;
pPlayer->restTime = 0;
}
sndStartSample(actor->xspr.data1, -1, 1, 0, CHANF_FORCE);
break;

View file

@ -796,7 +796,7 @@ void viewDrawScreen(bool sceneonly)
auto text = GStrings("TXTB_PAUSED");
viewDrawText(PickBigFont(text), text, 160, 10, 0, 0, 1, 0);
}
else if (gView != gMe)
else if (gView->nPlayer != myconnectindex)
{
FStringf gTempStr("] %s [", PlayerName(gView->nPlayer));
viewDrawText(OriginalSmallFont, gTempStr, 160, 10, 0, 0, 1, 0);
@ -821,8 +821,9 @@ bool GameInterface::GenerateSavePic()
std::pair<DVector3, DAngle> GameInterface::GetCoordinates()
{
if (!gMe || !gMe->actor) return std::make_pair(DVector3(DBL_MAX, 0, 0), nullAngle);
return std::make_pair(gMe->actor->spr.pos, gMe->actor->spr.angle);
PLAYER* pPlayer = &gPlayer[myconnectindex];
if (!pPlayer->actor) return std::make_pair(DVector3(DBL_MAX, 0, 0), nullAngle);
return std::make_pair(pPlayer->actor->spr.pos, pPlayer->actor->spr.angle);
}