Browse Source

Reorder player.cpp

pull/914/head
Anders Jenbo 5 years ago
parent
commit
f7290182fd
  1. 324
      Source/player.cpp
  2. 62
      Source/player.h

324
Source/player.cpp

@ -383,6 +383,54 @@ void InitPlayerGFX(int pnum)
}
}
static DWORD GetPlrGFXSize(const char *szCel)
{
DWORD c;
const char *a, *w;
DWORD dwSize, dwMaxSize;
HANDLE hsFile;
char pszName[256];
char Type[16];
dwMaxSize = 0;
for (c = 0; c < NUM_CLASSES; c++) {
#ifdef SPAWN
if (c != 0)
continue;
#endif
for (a = &ArmourChar[0]; *a; a++) {
#ifdef SPAWN
if (a != &ArmourChar[0])
break;
#endif
for (w = &WepChar[0]; *w; w++) { // BUGFIX loads non-existing animagions; DT is only for N, BT is only for U, D & H
#ifdef HELLFIRE
if ((c == PC_BARD && hfbard_mpq == NULL) || (c == PC_BARBARIAN && hfbarb_mpq == NULL)) {
#endif
sprintf(Type, "%c%c%c", CharChar[c], *a, *w);
sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], Type, Type, szCel);
#ifdef HELLFIRE
} else {
sprintf(Type, "%c%c%c", CharCharHF[c], *a, *w);
sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTblOld[c], Type, Type, szCel);
}
#endif
if (WOpenFile(pszName, &hsFile, TRUE)) {
/// ASSERT: assert(hsFile);
dwSize = WGetFileSize(hsFile, NULL);
WCloseFile(hsFile);
if (dwMaxSize <= dwSize) {
dwMaxSize = dwSize;
}
}
}
}
}
return dwMaxSize;
}
void InitPlrGFXMem(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
@ -454,54 +502,6 @@ void InitPlrGFXMem(int pnum)
plr[pnum]._pGFXLoad = 0;
}
DWORD GetPlrGFXSize(const char *szCel)
{
DWORD c;
const char *a, *w;
DWORD dwSize, dwMaxSize;
HANDLE hsFile;
char pszName[256];
char Type[16];
dwMaxSize = 0;
for (c = 0; c < NUM_CLASSES; c++) {
#ifdef SPAWN
if (c != 0)
continue;
#endif
for (a = &ArmourChar[0]; *a; a++) {
#ifdef SPAWN
if (a != &ArmourChar[0])
break;
#endif
for (w = &WepChar[0]; *w; w++) { // BUGFIX loads non-existing animagions; DT is only for N, BT is only for U, D & H
#ifdef HELLFIRE
if ((c == PC_BARD && hfbard_mpq == NULL) || (c == PC_BARBARIAN && hfbarb_mpq == NULL)) {
#endif
sprintf(Type, "%c%c%c", CharChar[c], *a, *w);
sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], Type, Type, szCel);
#ifdef HELLFIRE
} else {
sprintf(Type, "%c%c%c", CharCharHF[c], *a, *w);
sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTblOld[c], Type, Type, szCel);
}
#endif
if (WOpenFile(pszName, &hsFile, TRUE)) {
/// ASSERT: assert(hsFile);
dwSize = WGetFileSize(hsFile, NULL);
WCloseFile(hsFile);
if (dwMaxSize <= dwSize) {
dwMaxSize = dwSize;
}
}
}
}
}
return dwMaxSize;
}
void FreePlayerGFX(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
@ -1907,6 +1907,43 @@ void RespawnDeadItem(ItemStruct *itm, int x, int y)
itm->_itype = ITYPE_NONE;
}
static void PlrDeadItem(int pnum, ItemStruct *itm, int xx, int yy)
{
int x, y;
int i, j, k;
if (itm->_itype == ITYPE_NONE)
return;
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("PlrDeadItem: illegal player %d", pnum);
}
x = xx + plr[pnum]._px;
y = yy + plr[pnum]._py;
if ((xx || yy) && ItemSpaceOk(x, y)) {
RespawnDeadItem(itm, x, y);
plr[pnum].HoldItem = *itm;
NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y);
return;
}
for (k = 1; k < 50; k++) {
for (j = -k; j <= k; j++) {
y = j + plr[pnum]._py;
for (i = -k; i <= k; i++) {
x = i + plr[pnum]._px;
if (ItemSpaceOk(x, y)) {
RespawnDeadItem(itm, x, y);
plr[pnum].HoldItem = *itm;
NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y);
return;
}
}
}
}
}
void StartPlayerKill(int pnum, int earflag)
{
BOOL diablolevel;
@ -2033,43 +2070,6 @@ void StartPlayerKill(int pnum, int earflag)
#endif
}
void PlrDeadItem(int pnum, ItemStruct *itm, int xx, int yy)
{
int x, y;
int i, j, k;
if (itm->_itype == ITYPE_NONE)
return;
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("PlrDeadItem: illegal player %d", pnum);
}
x = xx + plr[pnum]._px;
y = yy + plr[pnum]._py;
if ((xx || yy) && ItemSpaceOk(x, y)) {
RespawnDeadItem(itm, x, y);
plr[pnum].HoldItem = *itm;
NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y);
return;
}
for (k = 1; k < 50; k++) {
for (j = -k; j <= k; j++) {
y = j + plr[pnum]._py;
for (i = -k; i <= k; i++) {
x = i + plr[pnum]._px;
if (ItemSpaceOk(x, y)) {
RespawnDeadItem(itm, x, y);
plr[pnum].HoldItem = *itm;
NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y);
return;
}
}
}
}
}
void DropHalfPlayersGold(int pnum)
{
int i, hGold;
@ -3199,6 +3199,56 @@ BOOL PM_DoBlock(int pnum)
return FALSE;
}
static void ArmorDur(int pnum)
{
int a;
ItemStruct *pi;
PlayerStruct *p;
if (pnum != myplr) {
return;
}
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("ArmorDur: illegal player %d", pnum);
}
p = &plr[pnum];
if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
return;
}
a = random_(8, 3);
if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
a = 1;
}
if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) {
a = 0;
}
if (a != 0) {
pi = &p->InvBody[INVLOC_CHEST];
} else {
pi = &p->InvBody[INVLOC_HEAD];
}
if (pi->_iDurability == DUR_INDESTRUCTIBLE) {
return;
}
pi->_iDurability--;
if (pi->_iDurability != 0) {
return;
}
if (a != 0) {
NetSendCmdDelItem(TRUE, INVLOC_CHEST);
} else {
NetSendCmdDelItem(TRUE, INVLOC_HEAD);
}
pi->_itype = ITYPE_NONE;
CalcPlrInv(pnum, TRUE);
}
BOOL PM_DoSpell(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
@ -3306,56 +3356,6 @@ BOOL PM_DoGotHit(int pnum)
return FALSE;
}
void ArmorDur(int pnum)
{
int a;
ItemStruct *pi;
PlayerStruct *p;
if (pnum != myplr) {
return;
}
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("ArmorDur: illegal player %d", pnum);
}
p = &plr[pnum];
if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
return;
}
a = random_(8, 3);
if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
a = 1;
}
if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) {
a = 0;
}
if (a != 0) {
pi = &p->InvBody[INVLOC_CHEST];
} else {
pi = &p->InvBody[INVLOC_HEAD];
}
if (pi->_iDurability == DUR_INDESTRUCTIBLE) {
return;
}
pi->_iDurability--;
if (pi->_iDurability != 0) {
return;
}
if (a != 0) {
NetSendCmdDelItem(TRUE, INVLOC_CHEST);
} else {
NetSendCmdDelItem(TRUE, INVLOC_HEAD);
}
pi->_itype = ITYPE_NONE;
CalcPlrInv(pnum, TRUE);
}
BOOL PM_DoDeath(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
@ -3789,6 +3789,33 @@ void ValidatePlayer()
plr[myplr]._pMemSpells &= msk;
}
static void CheckCheatStats(int pnum)
{
if (plr[pnum]._pStrength > 750) {
plr[pnum]._pStrength = 750;
}
if (plr[pnum]._pDexterity > 750) {
plr[pnum]._pDexterity = 750;
}
if (plr[pnum]._pMagic > 750) {
plr[pnum]._pMagic = 750;
}
if (plr[pnum]._pVitality > 750) {
plr[pnum]._pVitality = 750;
}
if (plr[pnum]._pHitPoints > 128000) {
plr[pnum]._pHitPoints = 128000;
}
if (plr[pnum]._pMana > 128000) {
plr[pnum]._pMana = 128000;
}
}
void ProcessPlayers()
{
int pnum;
@ -3906,33 +3933,6 @@ void ProcessPlayers()
}
}
void CheckCheatStats(int pnum)
{
if (plr[pnum]._pStrength > 750) {
plr[pnum]._pStrength = 750;
}
if (plr[pnum]._pDexterity > 750) {
plr[pnum]._pDexterity = 750;
}
if (plr[pnum]._pMagic > 750) {
plr[pnum]._pMagic = 750;
}
if (plr[pnum]._pVitality > 750) {
plr[pnum]._pVitality = 750;
}
if (plr[pnum]._pHitPoints > 128000) {
plr[pnum]._pHitPoints = 128000;
}
if (plr[pnum]._pMana > 128000) {
plr[pnum]._pMana = 128000;
}
}
void ClrPlrPath(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {

62
Source/player.h

@ -6,34 +6,19 @@
#ifndef __PLAYER_H__
#define __PLAYER_H__
extern int plr_lframe_size;
extern int plr_wframe_size;
extern BYTE plr_gfx_flag;
extern int plr_aframe_size;
extern int myplr;
#ifdef HELLFIRE
extern PlayerStruct *plr;
#else
extern PlayerStruct plr[MAX_PLRS];
#endif
extern int plr_fframe_size;
extern int plr_qframe_size;
extern BOOL deathflag;
extern int plr_hframe_size;
extern int plr_bframe_size;
extern BYTE plr_gfx_bflag;
extern int plr_sframe_size;
extern int deathdelay;
extern int plr_dframe_size;
void SetPlayerGPtrs(BYTE *pData, BYTE **pAnim);
void LoadPlrGFX(int pnum, player_graphic gfxflag);
void InitPlayerGFX(int pnum);
void InitPlrGFXMem(int pnum);
DWORD GetPlrGFXSize(const char *szCel);
void FreePlayerGFX(int pnum);
void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width);
void ClearPlrPVars(int pnum);
void SetPlrAnims(int pnum);
void ClearPlrRVars(PlayerStruct *p);
void CreatePlayer(int pnum, char c);
@ -45,61 +30,27 @@ void InitPlayer(int pnum, BOOL FirstTime);
void InitMultiView();
void CheckEFlag(int pnum, BOOL flag);
BOOL SolidLoc(int x, int y);
BOOL PlrDirOK(int pnum, int dir);
void PlrClrTrans(int x, int y);
void PlrDoTrans(int x, int y);
void SetPlayerOld(int pnum);
void FixPlayerLocation(int pnum, int bDir);
void StartStand(int pnum, int dir);
void StartWalkStand(int pnum);
void PM_ChangeLightOff(int pnum);
void PM_ChangeOffset(int pnum);
void StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int EndDir, int sdir);
void StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir, int sdir);
void StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir, int sdir);
void StartAttack(int pnum, int d);
void StartRangeAttack(int pnum, int d, int cx, int cy);
void StartPlrBlock(int pnum, int dir);
void StartSpell(int pnum, int d, int cx, int cy);
void FixPlrWalkTags(int pnum);
void RemovePlrFromMap(int pnum);
void StartPlrHit(int pnum, int dam, BOOL forcehit);
void RespawnDeadItem(ItemStruct *itm, int x, int y);
void StartPlayerKill(int pnum, int earflag);
void PlrDeadItem(int pnum, ItemStruct *itm, int xx, int yy);
void DropHalfPlayersGold(int pnum);
#ifdef HELLFIRE
void StripTopGold(int pnum);
#endif
void SyncPlrKill(int pnum, int earflag);
void j_StartPlayerKill(int pnum, int earflag);
void RemovePlrMissiles(int pnum);
void InitLevelChange(int pnum);
void StartNewLvl(int pnum, int fom, int lvl);
void RestartTownLvl(int pnum);
void StartWarpLvl(int pnum, int pidx);
BOOL PM_DoStand(int pnum);
BOOL PM_DoNewLvl(int pnum);
BOOL PM_DoWalk(int pnum);
BOOL PM_DoWalk2(int pnum);
BOOL PM_DoWalk3(int pnum);
BOOL WeaponDur(int pnum, int durrnd);
BOOL PlrHitMonst(int pnum, int m);
BOOL PlrHitPlr(int pnum, char p);
BOOL PlrHitObj(int pnum, int mx, int my);
BOOL PM_DoAttack(int pnum);
BOOL PM_DoRangeAttack(int pnum);
void ShieldDur(int pnum);
BOOL PM_DoBlock(int pnum);
BOOL PM_DoSpell(int pnum);
BOOL PM_DoGotHit(int pnum);
void ArmorDur(int pnum);
BOOL PM_DoDeath(int pnum);
void CheckNewPath(int pnum);
BOOL PlrDeathModeOK(int p);
void ValidatePlayer();
void ProcessPlayers();
void CheckCheatStats(int pnum);
void ClrPlrPath(int pnum);
BOOL PosOkPlayer(int pnum, int x, int y);
void MakePlrPath(int pnum, int xx, int yy, BOOL endspace);
@ -125,30 +76,17 @@ int player_45EFAB(int i);
int player_45EFB5(int i);
#endif
/* rdata */
extern const char ArmourChar[4];
extern const char WepChar[10];
extern const char CharChar[];
/* data */
extern int plrxoff[9];
extern int plryoff[9];
extern int plrxoff2[9];
extern int plryoff2[9];
extern char PlrGFXAnimLens[NUM_CLASSES][11];
extern int PWVel[NUM_CLASSES][3];
extern int AnimLenFromClass[NUM_CLASSES];
extern int StrengthTbl[NUM_CLASSES];
extern int MagicTbl[NUM_CLASSES];
extern int DexterityTbl[NUM_CLASSES];
extern int VitalityTbl[NUM_CLASSES];
extern int ToBlkTbl[NUM_CLASSES];
extern const char *const ClassStrTblOld[];
extern int MaxStats[NUM_CLASSES][4];
extern int ExpLvlsTbl[MAXCHARLEVEL];
extern const char *const ClassStrTbl[NUM_CLASSES];
extern BYTE fix[9];
#endif /* __PLAYER_H__ */

Loading…
Cancel
Save