Browse Source

♻️ Pass 'PlayerStruct' pointer to 'ClrPlrPath'

pull/1867/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
39736e2538
  1. 4
      Source/items.cpp
  2. 2
      Source/missiles.cpp
  3. 26
      Source/msg.cpp
  4. 2
      Source/objects.cpp
  5. 2
      Source/pack.cpp
  6. 12
      Source/player.cpp
  7. 2
      Source/player.h
  8. 2
      Source/spells.cpp

4
Source/items.cpp

@ -4078,7 +4078,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl)
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
} else {
ClrPlrPath(p);
ClrPlrPath(&plr[p]);
plr[p]._pSpell = spl;
plr[p]._pSplType = RSPLTYPE_INVALID;
plr[p]._pSplFrom = 3;
@ -4096,7 +4096,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl)
if (p == myplr)
NewCursor(CURSOR_TELEPORT);
} else {
ClrPlrPath(p);
ClrPlrPath(&plr[p]);
plr[p]._pSpell = spl;
plr[p]._pSplType = RSPLTYPE_INVALID;
plr[p]._pSplFrom = 3;

2
Source/missiles.cpp

@ -4220,7 +4220,7 @@ void MI_Town(int i)
for (p = 0; p < MAX_PLRS; p++) {
if (plr[p].plractive && currlevel == plr[p].plrlevel && !plr[p]._pLvlChanging && plr[p]._pmode == PM_STAND && plr[p].position.tile == missile[i].position.tile) {
ClrPlrPath(p);
ClrPlrPath(&plr[p]);
if (p == myplr) {
NetSendCmdParam1(true, CMD_WARP, missile[i]._misource);
plr[p]._pmode = PM_NEWLVL;

26
Source/msg.cpp

@ -1317,7 +1317,7 @@ static DWORD On_WALKXY(TCmd *pCmd, int pnum)
auto *p = (TCmdLoc *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
MakePlrPath(pnum, p->x, p->y, true);
plr[pnum].destAction = ACTION_NONE;
}
@ -1616,7 +1616,7 @@ static DWORD On_SATTACKXY(TCmd *pCmd, int pnum)
auto *p = (TCmdLoc *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_ATTACK;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
@ -1630,7 +1630,7 @@ static DWORD On_RATTACKXY(TCmd *pCmd, int pnum)
auto *p = (TCmdLoc *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_RATTACK;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
@ -1646,7 +1646,7 @@ static DWORD On_SPELLXYD(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam1);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELLWALL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
@ -1669,7 +1669,7 @@ static DWORD On_SPELLXY(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam1);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
@ -1691,7 +1691,7 @@ static DWORD On_TSPELLXY(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam1);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
@ -1784,7 +1784,7 @@ static DWORD On_RATTACKID(TCmd *pCmd, int pnum)
auto *p = (TCmdParam1 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_RATTACKMON;
plr[pnum].destParam1 = p->wParam1;
}
@ -1797,7 +1797,7 @@ static DWORD On_RATTACKPID(TCmd *pCmd, int pnum)
auto *p = (TCmdParam1 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_RATTACKPLR;
plr[pnum].destParam1 = p->wParam1;
}
@ -1812,7 +1812,7 @@ static DWORD On_SPELLID(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam2);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELLMON;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
@ -1833,7 +1833,7 @@ static DWORD On_SPELLPID(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam2);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELLPLR;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
@ -1854,7 +1854,7 @@ static DWORD On_TSPELLID(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam2);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELLMON;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
@ -1875,7 +1875,7 @@ static DWORD On_TSPELLPID(TCmd *pCmd, int pnum)
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
auto spell = static_cast<spell_id>(p->wParam2);
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_SPELLPLR;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
@ -2430,7 +2430,7 @@ static DWORD On_NOVA(TCmd *pCmd, int pnum)
auto *p = (TCmdLoc *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pnum != myplr) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum]._pSpell = SPL_NOVA;
plr[pnum]._pSplType = RSPLTYPE_INVALID;
plr[pnum]._pSplFrom = 3;

2
Source/objects.cpp

@ -1956,7 +1956,7 @@ void Obj_Circle(int i)
AddMissile(plr[myplr].position.tile.x, plr[myplr].position.tile.y, 35, 46, plr[myplr]._pdir, MIS_RNDTELEPORT, TARGET_MONSTERS, myplr, 0, 0);
track_repeat_walk(false);
sgbMouseDown = CLICK_NONE;
ClrPlrPath(myplr);
ClrPlrPath(&plr[myplr]);
StartStand(myplr, DIR_S);
}
} else {

2
Source/pack.cpp

@ -216,7 +216,7 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync)
pPlayer->position.tile = { pPack->px, pPack->py };
pPlayer->position.future = { pPack->px, pPack->py };
pPlayer->plrlevel = pPack->plrlevel;
ClrPlrPath(pnum);
ClrPlrPath(pPlayer);
pPlayer->destAction = ACTION_NONE;
strcpy(pPlayer->_pName, pPack->pName);
pPlayer->_pClass = (HeroClass)pPack->pClass;

12
Source/player.cpp

@ -2106,7 +2106,7 @@ void InitLevelChange(int pnum)
plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = true;
}
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
plr[pnum].destAction = ACTION_NONE;
plr[pnum]._pLvlChanging = true;
@ -3167,7 +3167,7 @@ void CheckNewPath(int pnum)
}
if (x < 2 && y < 2) {
ClrPlrPath(pnum);
ClrPlrPath(&plr[pnum]);
if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) {
TalktoMonster(i);
} else {
@ -3651,13 +3651,9 @@ void ProcessPlayers()
}
}
void ClrPlrPath(int pnum)
void ClrPlrPath(PlayerStruct *player)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("ClrPlrPath: illegal player %d", pnum);
}
memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath));
memset(player->walkpath, WALK_NONE, sizeof(player->walkpath));
}
bool PosOkPlayer(int pnum, int x, int y)

2
Source/player.h

@ -428,7 +428,7 @@ void StartNewLvl(int pnum, interface_mode fom, int lvl);
void RestartTownLvl(int pnum);
void StartWarpLvl(int pnum, int pidx);
void ProcessPlayers();
void ClrPlrPath(int pnum);
void ClrPlrPath(PlayerStruct *player);
bool PosOkPlayer(int pnum, int x, int y);
void MakePlrPath(int pnum, int xx, int yy, bool endspace);
void CheckPlrSpell();

2
Source/spells.cpp

@ -279,7 +279,7 @@ void DoResurrect(int pnum, int rid)
drawmanaflag = true;
}
ClrPlrPath(rid);
ClrPlrPath(&plr[rid]);
plr[rid].destAction = ACTION_NONE;
plr[rid]._pInvincible = false;
PlacePlayer(rid);

Loading…
Cancel
Save