Browse Source

Merge branch 'master' of github.com:diasurgical/devilution

pull/417/head
Anders Jenbo 7 years ago
parent
commit
b6695fe26b
  1. 2
      Source/diablo.cpp
  2. 12
      Source/lighting.cpp
  3. 2
      Source/lighting.h
  4. 110
      Source/pack.cpp
  5. 2
      Source/pack.h
  6. 92
      Source/spells.cpp
  7. 1
      Source/spells.h

2
Source/diablo.cpp

@ -192,7 +192,7 @@ void run_game_loop(unsigned int uMsg)
pfile_flush_W();
PaletteFadeOut(8);
SetCursor_(0);
SetCursor_(CURSOR_NONE);
ClearScreenBuffer();
force_redraw = 255;
scrollrt_draw_game_screen(TRUE);

12
Source/lighting.cpp

@ -11,7 +11,7 @@ BOOL dovision;
int numvision;
char lightmax;
BOOL dolighting;
BYTE lightblock[8][8][16][16];
BYTE lightblock[64][16][16];
int visionid;
BYTE *pLightTbl;
BOOL lightflag;
@ -558,7 +558,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)
mult = xoff + 8 * yoff;
for (y = 0; y < min_y; y++) {
for (x = 1; x < max_x; x++) {
radius_block = lightblock[0][mult][y][x];
radius_block = lightblock[mult][y][x];
if (radius_block < 128) {
temp_x = nXPos + x;
temp_y = nYPos + y;
@ -575,7 +575,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)
mult = xoff + 8 * yoff;
for (y = 0; y < max_y; y++) {
for (x = 1; x < max_x; x++) {
radius_block = lightblock[0][mult][y + block_y][x + block_x];
radius_block = lightblock[mult][y + block_y][x + block_x];
if (radius_block < 128) {
temp_x = nXPos + y;
temp_y = nYPos - x;
@ -592,7 +592,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)
mult = xoff + 8 * yoff;
for (y = 0; y < max_y; y++) {
for (x = 1; x < min_x; x++) {
radius_block = lightblock[0][mult][y + block_y][x + block_x];
radius_block = lightblock[mult][y + block_y][x + block_x];
if (radius_block < 128) {
temp_x = nXPos - x;
temp_y = nYPos - y;
@ -609,7 +609,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)
mult = xoff + 8 * yoff;
for (y = 0; y < min_y; y++) {
for (x = 1; x < min_x; x++) {
radius_block = lightblock[0][mult][y + block_y][x + block_x];
radius_block = lightblock[mult][y + block_y][x + block_x];
if (radius_block < 128) {
temp_x = nXPos - y;
temp_y = nYPos + x;
@ -960,7 +960,7 @@ void MakeLightTable()
} else {
fa = 0.5;
}
lightblock[i][j][k][l] = fs + fa;
lightblock[i * 8 + j][k][l] = fs + fa;
}
}
}

2
Source/lighting.h

@ -11,7 +11,7 @@ extern BOOL dovision;
extern int numvision;
extern char lightmax;
extern BOOL dolighting;
extern BYTE lightblock[8][8][16][16];
extern BYTE lightblock[64][16][16];
extern int visionid;
extern BYTE *pLightTbl;
extern BOOL lightflag;

110
Source/pack.cpp

@ -2,6 +2,36 @@
DEVILUTION_BEGIN_NAMESPACE
static void PackItem(PkItemStruct *id, ItemStruct *is)
{
if (is->_itype == -1) {
id->idx = 0xFFFF;
} else {
id->idx = is->IDidx;
if (is->IDidx == IDI_EAR) {
id->iCreateInfo = is->_iName[8] | (is->_iName[7] << 8);
id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8);
id->bId = is->_iName[13];
id->bDur = is->_iName[14];
id->bMDur = is->_iName[15];
id->bCh = is->_iName[16];
id->bMCh = is->_iName[17];
id->wValue = is->_ivalue | (is->_iName[18] << 8) | ((is->_iCurs - 19) << 6);
id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8);
} else {
id->iSeed = is->_iSeed;
id->iCreateInfo = is->_iCreateInfo;
id->bId = is->_iIdentified + 2 * is->_iMagical;
id->bDur = is->_iDurability;
id->bMDur = is->_iMaxDur;
id->bCh = is->_iCharges;
id->bMCh = is->_iMaxCharges;
if (!is->IDidx)
id->wValue = is->_ivalue;
}
}
}
void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield)
{
PlayerStruct *pPlayer;
@ -77,33 +107,35 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield)
pPack->pManaShield = FALSE;
}
void PackItem(PkItemStruct *id, ItemStruct *is)
// Note: last slot of item[MAXITEMS+1] used as temporary buffer
// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)]
static void UnPackItem(PkItemStruct *is, ItemStruct *id)
{
if (is->_itype == -1) {
id->idx = 0xFFFF;
if (is->idx == 0xFFFF) {
id->_itype = -1;
} else {
id->idx = is->IDidx;
if (is->IDidx == IDI_EAR) {
id->iCreateInfo = is->_iName[8] | (is->_iName[7] << 8);
id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8);
id->bId = is->_iName[13];
id->bDur = is->_iName[14];
id->bMDur = is->_iName[15];
id->bCh = is->_iName[16];
id->bMCh = is->_iName[17];
id->wValue = is->_ivalue | (is->_iName[18] << 8) | ((is->_iCurs - 19) << 6);
id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8);
if (is->idx == IDI_EAR) {
RecreateEar(
MAXITEMS,
is->iCreateInfo,
is->iSeed,
is->bId,
is->bDur,
is->bMDur,
is->bCh,
is->bMCh,
is->wValue,
is->dwBuff);
} else {
id->iSeed = is->_iSeed;
id->iCreateInfo = is->_iCreateInfo;
id->bId = is->_iIdentified + 2 * is->_iMagical;
id->bDur = is->_iDurability;
id->bMDur = is->_iMaxDur;
id->bCh = is->_iCharges;
id->bMCh = is->_iMaxCharges;
if (!is->IDidx)
id->wValue = is->_ivalue;
RecreateItem(MAXITEMS, is->idx, is->iCreateInfo, is->iSeed, is->wValue);
item[MAXITEMS]._iMagical = is->bId >> 1;
item[MAXITEMS]._iIdentified = is->bId & 1;
item[MAXITEMS]._iDurability = is->bDur;
item[MAXITEMS]._iMaxDur = is->bMDur;
item[MAXITEMS]._iCharges = is->bCh;
item[MAXITEMS]._iMaxCharges = is->bMCh;
}
*id = item[MAXITEMS];
}
}
@ -218,36 +250,4 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok)
pPlayer->pManaShield = pPack->pManaShield;
}
// Note: last slot of item[MAXITEMS+1] used as temporary buffer
// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)]
void UnPackItem(PkItemStruct *is, ItemStruct *id)
{
if (is->idx == 0xFFFF) {
id->_itype = -1;
} else {
if (is->idx == IDI_EAR) {
RecreateEar(
MAXITEMS,
is->iCreateInfo,
is->iSeed,
is->bId,
is->bDur,
is->bMDur,
is->bCh,
is->bMCh,
is->wValue,
is->dwBuff);
} else {
RecreateItem(MAXITEMS, is->idx, is->iCreateInfo, is->iSeed, is->wValue);
item[MAXITEMS]._iMagical = is->bId >> 1;
item[MAXITEMS]._iIdentified = is->bId & 1;
item[MAXITEMS]._iDurability = is->bDur;
item[MAXITEMS]._iMaxDur = is->bMDur;
item[MAXITEMS]._iCharges = is->bCh;
item[MAXITEMS]._iMaxCharges = is->bMCh;
}
*id = item[MAXITEMS];
}
}
DEVILUTION_END_NAMESPACE

2
Source/pack.h

@ -3,10 +3,8 @@
#define __PACK_H__
void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield);
void PackItem(PkItemStruct *id, ItemStruct *is);
void VerifyGoldSeeds(PlayerStruct *pPlayer);
void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok);
void UnPackItem(PkItemStruct *is, ItemStruct *id);
/* rdata */

92
Source/spells.cpp

@ -145,6 +145,52 @@ void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int
}
}
static void PlacePlayer(int pnum)
{
int nx, ny, max, min, x, y;
DWORD i;
BOOL done;
if (plr[pnum].plrlevel == currlevel) {
for (i = 0; i < 8; i++) {
nx = plr[pnum].WorldX + plrxoff2[i];
ny = plr[pnum].WorldY + plryoff2[i];
if (PosOkPlayer(pnum, nx, ny)) {
break;
}
}
if (!PosOkPlayer(pnum, nx, ny)) {
done = FALSE;
for (max = 1, min = -1; min > -50 && !done; max++, min--) {
for (y = min; y <= max && !done; y++) {
ny = plr[pnum].WorldY + y;
for (x = min; x <= max && !done; x++) {
nx = plr[pnum].WorldX + x;
if (PosOkPlayer(pnum, nx, ny)) {
done = TRUE;
}
}
}
}
}
plr[pnum].WorldX = nx;
plr[pnum].WorldY = ny;
dPlayer[nx][ny] = pnum + 1;
if (pnum == myplr) {
ViewX = nx;
ViewY = ny;
}
}
}
/**
* @param pnum player index
* @param rid target player index
@ -194,52 +240,6 @@ void DoResurrect(int pnum, int rid)
}
}
void PlacePlayer(int pnum)
{
int nx, ny, max, min, x, y;
DWORD i;
BOOL done;
if (plr[pnum].plrlevel == currlevel) {
for (i = 0; i < 8; i++) {
nx = plr[pnum].WorldX + plrxoff2[i];
ny = plr[pnum].WorldY + plryoff2[i];
if (PosOkPlayer(pnum, nx, ny)) {
break;
}
}
if (!PosOkPlayer(pnum, nx, ny)) {
done = FALSE;
for (max = 1, min = -1; min > -50 && !done; max++, min--) {
for (y = min; y <= max && !done; y++) {
ny = plr[pnum].WorldY + y;
for (x = min; x <= max && !done; x++) {
nx = plr[pnum].WorldX + x;
if (PosOkPlayer(pnum, nx, ny)) {
done = TRUE;
}
}
}
}
}
plr[pnum].WorldX = nx;
plr[pnum].WorldY = ny;
dPlayer[nx][ny] = pnum + 1;
if (pnum == myplr) {
ViewX = nx;
ViewY = ny;
}
}
}
void DoHealOther(int pnum, int rid)
{
int i, j, hp;

1
Source/spells.h

@ -7,7 +7,6 @@ void UseMana(int id, int sn);
BOOL CheckSpell(int id, int sn, char st, BOOL manaonly);
void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int spllvl);
void DoResurrect(int pnum, int rid);
void PlacePlayer(int pnum);
void DoHealOther(int pnum, int rid);
#endif /* __SPELLS_H__ */

Loading…
Cancel
Save