Browse Source

[hellfire] Correct player structure and related functions

pull/876/head
Anders Jenbo 7 years ago
parent
commit
d26fe48942
  1. 2
      Source/mainmenu.cpp
  2. 12
      Source/missiles.cpp
  3. 4
      Source/msg.cpp
  4. 4
      Source/multi.cpp
  5. 14
      Source/pack.cpp
  6. 22
      Source/player.cpp
  7. 12
      Source/scrollrt.cpp
  8. 17
      structs.h

2
Source/mainmenu.cpp

@ -71,10 +71,12 @@ int __stdcall mainmenu_select_hero_dialog(
pfile_create_player_description(cdesc, cdlen);
if (multi) {
#ifndef HELLFIRE
if (mode == 'BNET')
*multi = hero_is_created || !plr[myplr].pBattleNet;
else
*multi = hero_is_created;
#endif
}
if (cname && clen)
SStrCopy(cname, gszHero, clen);

12
Source/missiles.cpp

@ -2432,9 +2432,14 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas
{
int i, mi;
#ifdef HELLFIRE
if (nummissiles >= MAXMISSILES - 1)
#else
if (nummissiles >= MAXMISSILES)
#endif
return -1;
#ifndef HELLFIRE
if (mitype == MIS_MANASHIELD && plr[id].pManaShield == TRUE) {
if (currlevel != plr[id].plrlevel)
return -1;
@ -2445,6 +2450,7 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas
return -1;
}
}
#endif
mi = missileavail[0];
@ -2452,6 +2458,10 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas
missileactive[nummissiles] = mi;
nummissiles++;
#ifdef HELLFIRE
memset(&missile[mi], 0, sizeof(*missile));
#endif
missile[mi]._mitype = mitype;
missile[mi]._micaster = micaster;
missile[mi]._misource = id;
@ -2485,7 +2495,7 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas
missile[mi]._mirnd = 0;
if (missiledata[mitype].mlSFX != -1) {
PlaySfxLoc(missiledata[mitype].mlSFX, sx, sy);
PlaySfxLoc(missiledata[mitype].mlSFX, missile[mi]._misx, missile[mi]._misy);
}
missiledata[mitype].mAddProc(mi, sx, sy, dx, dy, midir, micaster, id, midam);

4
Source/msg.cpp

@ -1125,10 +1125,12 @@ DWORD ParseCmd(int pnum, TCmd *pCmd)
return On_CHEAT_SPELL_LEVEL(pCmd, pnum);
case CMD_NOVA:
return On_NOVA(pCmd, pnum);
#ifndef HELLFIRE
case CMD_SETSHIELD:
return On_SETSHIELD(pCmd, pnum);
case CMD_REMSHIELD:
return On_REMSHIELD(pCmd, pnum);
#endif
}
if (pCmd->bCmd < CMD_DLEVEL_0 || pCmd->bCmd > CMD_DLEVEL_END) {
@ -2605,6 +2607,7 @@ DWORD On_NOVA(TCmd *pCmd, int pnum)
return sizeof(*p);
}
#ifndef HELLFIRE
DWORD On_SETSHIELD(TCmd *pCmd, int pnum)
{
if (gbBufferMsgs != 1)
@ -2620,3 +2623,4 @@ DWORD On_REMSHIELD(TCmd *pCmd, int pnum)
return sizeof(*pCmd);
}
#endif

4
Source/multi.cpp

@ -876,8 +876,10 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info,
&& (!first || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) {
return FALSE;
}
#ifndef HELLFIRE
if (type == 'BNET')
plr[0].pBattleNet = 1;
#endif
}
multi_event_handler(TRUE);
@ -895,8 +897,10 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info,
pfile_read_player_from_save();
#ifndef HELLFIRE
if (type == 'BNET')
plr[myplr].pBattleNet = 1;
#endif
return TRUE;
}

14
Source/pack.cpp

@ -68,12 +68,19 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield)
pi++;
}
#ifdef HELLFIRE
pPack->wReflection = pPlayer->wReflection;
pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel;
pPack->pDifficulty = pPlayer->pDifficulty;
pPack->pDamAcFlags = pPlayer->pDamAcFlags;
#else
pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel;
if (gbMaxPlayers == 1 || manashield)
pPack->pManaShield = pPlayer->pManaShield;
else
pPack->pManaShield = FALSE;
#endif
}
void PackItem(PkItemStruct *id, ItemStruct *is)
@ -212,9 +219,16 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok)
pPlayer->pTownWarps = 0;
pPlayer->pDungMsgs = 0;
pPlayer->pLvlLoad = 0;
#ifdef HELLFIRE
pPlayer->wReflection = pPack->wReflection;
pPlayer->pDiabloKillLevel = pPack->pDiabloKillLevel;
pPlayer->pDifficulty = pPack->pDifficulty;
pPlayer->pDamAcFlags = pPack->pDamAcFlags;
#else
pPlayer->pDiabloKillLevel = pPack->pDiabloKillLevel;
pPlayer->pBattleNet = pPack->pBattleNet;
pPlayer->pManaShield = pPack->pManaShield;
#endif
}
// Note: last slot of item[MAXITEMS+1] used as temporary buffer

22
Source/player.cpp

@ -534,31 +534,31 @@ void SetPlrAnims(int pnum)
void ClearPlrRVars(PlayerStruct *p)
{
// TODO: Missing debug assert p != NULL
#ifdef HELLFIRE
p->pManaShield = 0;
#endif
p->bReserved[0] = 0;
p->bReserved[1] = 0;
p->bReserved[2] = 0;
#ifndef HELLFIRE
p->wReserved[0] = 0;
#ifdef HELLFIRE
p->bReserved[3] = 0;
#endif
p->wReserved[0] = 0;
p->wReserved[1] = 0;
p->wReserved[2] = 0;
p->wReserved[3] = 0;
p->wReserved[4] = 0;
p->wReserved[5] = 0;
p->wReserved[6] = 0;
p->wReserved[7] = 0;
#ifndef HELLFIRE
p->wReserved[7] = 0;
#endif
p->dwReserved[0] = 0;
p->dwReserved[1] = 0;
#endif
p->dwReserved[2] = 0;
p->dwReserved[3] = 0;
p->dwReserved[4] = 0;
#ifndef HELLFIRE
p->dwReserved[5] = 0;
p->dwReserved[6] = 0;
#endif
}
/**
@ -711,8 +711,10 @@ void CreatePlayer(int pnum, char c)
plr[pnum]._pLvlChanging = FALSE;
plr[pnum].pTownWarps = 0;
plr[pnum].pLvlLoad = 0;
plr[pnum].pBattleNet = 0;
#ifndef HELLFIRE
plr[pnum].pBattleNet = FALSE;
plr[pnum].pManaShield = FALSE;
#endif
InitDungMsgs(pnum);
CreatePlrItems(pnum);
@ -888,7 +890,9 @@ void InitPlayer(int pnum, BOOL FirstTime)
} else {
plr[pnum]._pwtype = WT_MELEE;
}
#ifndef HELLFIRE
plr[pnum].pManaShield = FALSE;
#endif
}
if (plr[pnum].plrlevel == currlevel || leveldebug) {
@ -4180,7 +4184,7 @@ void InitDungMsgs(int pnum)
plr[pnum].pDungMsgs = 0;
#ifdef HELLFIRE
plr[pnum].pBattleNet = 0;
plr[pnum].pDungMsgs2 = 0;
#endif
}

12
Source/scrollrt.cpp

@ -255,6 +255,7 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel
Cl2DecodeFrm2(165, px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap);
if (pnum == myplr) {
Cl2DecodeFrm1(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap);
#ifndef HELLFIRE
if (plr[pnum].pManaShield)
Cl2DecodeFrm1(
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0],
@ -264,8 +265,10 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel
misfiledata[MFILE_MANASHLD].mAnimWidth[0],
CelSkip,
CelCap);
#endif
} else if (!(dFlags[x][y] & BFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) {
Cl2DecodeFrm3(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap, 1);
#ifndef HELLFIRE
if (plr[pnum].pManaShield)
Cl2DecodeFrm3(
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0],
@ -276,6 +279,7 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel
CelSkip,
CelCap,
1);
#endif
} else {
l = light_table_index;
if (light_table_index < 5)
@ -283,6 +287,7 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel
else
light_table_index -= 5;
Cl2DecodeLightTbl(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap);
#ifndef HELLFIRE
if (plr[pnum].pManaShield)
Cl2DecodeLightTbl(
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0],
@ -292,6 +297,7 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel
misfiledata[MFILE_MANASHLD].mAnimWidth[0],
CelSkip,
CelCap);
#endif
light_table_index = l;
}
}
@ -328,6 +334,7 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
Cl2DecodeClrHL(165, px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap);
if (pnum == myplr) {
Cl2DecodeFrm4(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap);
#ifndef HELLFIRE
if (plr[pnum].pManaShield)
Cl2DecodeFrm4(
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0],
@ -337,8 +344,10 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
misfiledata[MFILE_MANASHLD].mAnimWidth[0],
CelSkip,
CelCap);
#endif
} else if (!(dFlags[x][y] & BFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) {
Cl2DecodeFrm5(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap, 1);
#ifndef HELLFIRE
if (plr[pnum].pManaShield)
Cl2DecodeFrm5(
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0],
@ -349,6 +358,7 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
CelSkip,
CelCap,
1);
#endif
} else {
l = light_table_index;
if (light_table_index < 5)
@ -356,6 +366,7 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
else
light_table_index -= 5;
Cl2DecodeFrm6(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap);
#ifndef HELLFIRE
if (plr[pnum].pManaShield)
Cl2DecodeFrm6(
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0],
@ -365,6 +376,7 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
misfiledata[MFILE_MANASHLD].mAnimWidth[0],
CelSkip,
CelCap);
#endif
light_table_index = l;
}
}

17
structs.h

@ -335,27 +335,23 @@ typedef struct PlayerStruct {
unsigned char pTownWarps;
unsigned char pDungMsgs;
unsigned char pLvlLoad;
/*
#ifdef HELLFIRE
unsigned char pDungMsgs2;
char bReserved[4];
short wReflection;
short wReserved[7];
int pDiabloKillLevel;
DWORD pDiabloKillLevel;
int pDifficulty;
int pDamAcFlags;
int dwReserved[5];
#else
*/
unsigned char pBattleNet;
BOOLEAN pManaShield;
char bReserved[3];
short wReserved[8];
DWORD pDiabloKillLevel;
int dwReserved[7];
/*
#endif
*/
unsigned char *_pNData;
unsigned char *_pWData;
unsigned char *_pAData;
@ -1432,12 +1428,23 @@ typedef struct PkPlayerStruct {
char pTownWarps;
char pDungMsgs;
char pLvlLoad;
#ifdef HELLFIRE
unsigned char pDungMsgs2;
char bReserved[4];
short wReflection;
short wReserved[7];
DWORD pDiabloKillLevel;
int pDifficulty;
int pDamAcFlags;
int dwReserved[5];
#else
char pBattleNet;
BOOLEAN pManaShield;
char bReserved[3];
short wReserved[8];
int pDiabloKillLevel;
int dwReserved[7];
#endif
} PkPlayerStruct;
#pragma pack(pop)

Loading…
Cancel
Save