|
|
|
|
@ -243,16 +243,12 @@ void DrawMissilePrivate(MissileStruct *m, int sx, int sy, BOOL pre)
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
pCelBuff = m->_miAnimData; |
|
|
|
|
if (!pCelBuff) { |
|
|
|
|
// app_fatal("Draw Missile 2 type %d: NULL Cel Buffer", m->_mitype);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(pCelBuff != NULL, m->_mitype); |
|
|
|
|
|
|
|
|
|
nCel = m->_miAnimFrame; |
|
|
|
|
frames = SDL_SwapLE32(*(DWORD *)pCelBuff); |
|
|
|
|
if (nCel < 1 || frames > 50 || nCel > frames) { |
|
|
|
|
// app_fatal("Draw Missile 2: frame %d of %d, missile type==%d", nCel, frames, m->_mitype);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(nCel >= 1 && frames <= 50 && nCel <= frames, nCel); |
|
|
|
|
|
|
|
|
|
mx = sx + m->_mixoff - m->_miAnimWidth2; |
|
|
|
|
my = sy + m->_miyoff; |
|
|
|
|
if (m->_miUniqTrans) |
|
|
|
|
@ -308,34 +304,14 @@ static void DrawMonster(int x, int y, int mx, int my, int m)
|
|
|
|
|
char trans; |
|
|
|
|
BYTE *pCelBuff; |
|
|
|
|
|
|
|
|
|
if ((DWORD)m >= MAXMONSTERS) { |
|
|
|
|
// app_fatal("Draw Monster: tried to draw illegal monster %d", m);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(m >= 0 && m < MAXMONSTERS, m); |
|
|
|
|
|
|
|
|
|
pCelBuff = monster[m]._mAnimData; |
|
|
|
|
if (!pCelBuff) { |
|
|
|
|
// app_fatal("Draw Monster \"%s\": NULL Cel Buffer", monster[m].mName);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(pCelBuff != NULL, m); |
|
|
|
|
|
|
|
|
|
nCel = monster[m]._mAnimFrame; |
|
|
|
|
frames = SDL_SwapLE32(*(DWORD *)pCelBuff); |
|
|
|
|
if (nCel < 1 || frames > 50 || nCel > frames) { |
|
|
|
|
/*
|
|
|
|
|
const char *szMode = "unknown action"; |
|
|
|
|
if(monster[m]._mmode <= 17) |
|
|
|
|
szMode = szMonModeAssert[monster[m]._mmode]; |
|
|
|
|
app_fatal( |
|
|
|
|
"Draw Monster \"%s\" %s: facing %d, frame %d of %d", |
|
|
|
|
monster[m].mName, |
|
|
|
|
szMode, |
|
|
|
|
monster[m]._mdir, |
|
|
|
|
nCel, |
|
|
|
|
frames); |
|
|
|
|
*/ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(nCel >= 1 && frames <= 50 && nCel <= frames, nCel); |
|
|
|
|
|
|
|
|
|
if (!(dFlags[x][y] & BFLAG_LIT)) { |
|
|
|
|
Cl2DrawLightTbl(mx, my, monster[m]._mAnimData, monster[m]._mAnimFrame, monster[m].MType->width, 1); |
|
|
|
|
@ -354,6 +330,36 @@ static void DrawMonster(int x, int y, int mx, int my, int m)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Helper for rendering player a Mana Shild |
|
|
|
|
* @param pnum Player id |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param lighting Should lighting be applied |
|
|
|
|
*/ |
|
|
|
|
static void DrawManaShild(int pnum, int x, int y, bool lighting) |
|
|
|
|
{ |
|
|
|
|
if (!plr[pnum].pManaShield) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
x += plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0]; |
|
|
|
|
|
|
|
|
|
int width = misfiledata[MFILE_MANASHLD].mAnimWidth[0]; |
|
|
|
|
BYTE *pCelBuff = misfiledata[MFILE_MANASHLD].mAnimData[0]; |
|
|
|
|
|
|
|
|
|
if (pnum == myplr) { |
|
|
|
|
Cl2Draw(x, y, pCelBuff, 1, width); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (lighting) { |
|
|
|
|
Cl2DrawLightTbl(x, y, pCelBuff, 1, width, 1); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Cl2DrawLight(x, y, pCelBuff, 1, width); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Render a player sprite |
|
|
|
|
* @param pnum Player id |
|
|
|
|
@ -369,66 +375,40 @@ static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i
|
|
|
|
|
{ |
|
|
|
|
int l, frames; |
|
|
|
|
|
|
|
|
|
if (dFlags[x][y] & BFLAG_LIT || plr[myplr]._pInfraFlag || !setlevel && currlevel == 0) { |
|
|
|
|
if (!pCelBuff) { |
|
|
|
|
// app_fatal("Drawing player %d \"%s\": NULL Cel Buffer", pnum, plr[pnum]._pName);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
frames = SDL_SwapLE32(*(DWORD *)pCelBuff); |
|
|
|
|
if (nCel < 1 || frames > 50 || nCel > frames) { |
|
|
|
|
/*
|
|
|
|
|
const char *szMode = "unknown action"; |
|
|
|
|
if(plr[pnum]._pmode <= PM_QUIT) |
|
|
|
|
szMode = szPlrModeAssert[plr[pnum]._pmode]; |
|
|
|
|
app_fatal( |
|
|
|
|
"Drawing player %d \"%s\" %s: facing %d, frame %d of %d", |
|
|
|
|
pnum, |
|
|
|
|
plr[pnum]._pName, |
|
|
|
|
szMode, |
|
|
|
|
plr[pnum]._pdir, |
|
|
|
|
nCel, |
|
|
|
|
frames); |
|
|
|
|
*/ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (pnum == pcursplr) |
|
|
|
|
Cl2DrawOutline(165, px, py, pCelBuff, nCel, nWidth); |
|
|
|
|
if (pnum == myplr) { |
|
|
|
|
Cl2Draw(px, py, pCelBuff, nCel, nWidth); |
|
|
|
|
if (plr[pnum].pManaShield) |
|
|
|
|
Cl2Draw( |
|
|
|
|
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0], |
|
|
|
|
py, |
|
|
|
|
misfiledata[MFILE_MANASHLD].mAnimData[0], |
|
|
|
|
1, |
|
|
|
|
misfiledata[MFILE_MANASHLD].mAnimWidth[0]); |
|
|
|
|
} else if (!(dFlags[x][y] & BFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) { |
|
|
|
|
Cl2DrawLightTbl(px, py, pCelBuff, nCel, nWidth, 1); |
|
|
|
|
if (plr[pnum].pManaShield) |
|
|
|
|
Cl2DrawLightTbl( |
|
|
|
|
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0], |
|
|
|
|
py, |
|
|
|
|
misfiledata[MFILE_MANASHLD].mAnimData[0], |
|
|
|
|
1, |
|
|
|
|
misfiledata[MFILE_MANASHLD].mAnimWidth[0], |
|
|
|
|
1); |
|
|
|
|
} else { |
|
|
|
|
l = light_table_index; |
|
|
|
|
if (light_table_index < 5) |
|
|
|
|
light_table_index = 0; |
|
|
|
|
else |
|
|
|
|
light_table_index -= 5; |
|
|
|
|
Cl2DrawLight(px, py, pCelBuff, nCel, nWidth); |
|
|
|
|
if (plr[pnum].pManaShield) |
|
|
|
|
Cl2DrawLight( |
|
|
|
|
px + plr[pnum]._pAnimWidth2 - misfiledata[MFILE_MANASHLD].mAnimWidth2[0], |
|
|
|
|
py, |
|
|
|
|
misfiledata[MFILE_MANASHLD].mAnimData[0], |
|
|
|
|
1, |
|
|
|
|
misfiledata[MFILE_MANASHLD].mAnimWidth[0]); |
|
|
|
|
light_table_index = l; |
|
|
|
|
} |
|
|
|
|
if ((dFlags[x][y] & BFLAG_LIT) == 0 && !plr[myplr]._pInfraFlag && leveltype != DTYPE_TOWN) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assurance(pCelBuff != NULL, pnum); |
|
|
|
|
|
|
|
|
|
frames = SDL_SwapLE32(*(DWORD *)pCelBuff); |
|
|
|
|
assurance(nCel >= 1 && frames <= 50 && nCel <= frames, nCel); |
|
|
|
|
|
|
|
|
|
if (pnum == pcursplr) |
|
|
|
|
Cl2DrawOutline(165, px, py, pCelBuff, nCel, nWidth); |
|
|
|
|
|
|
|
|
|
if (pnum == myplr) { |
|
|
|
|
Cl2Draw(px, py, pCelBuff, nCel, nWidth); |
|
|
|
|
DrawManaShild(pnum, px, py, true); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(dFlags[x][y] & BFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) { |
|
|
|
|
Cl2DrawLightTbl(px, py, pCelBuff, nCel, nWidth, 1); |
|
|
|
|
DrawManaShild(pnum, px, py, true); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
l = light_table_index; |
|
|
|
|
if (light_table_index < 5) |
|
|
|
|
light_table_index = 0; |
|
|
|
|
else |
|
|
|
|
light_table_index -= 5; |
|
|
|
|
|
|
|
|
|
Cl2DrawLight(px, py, pCelBuff, nCel, nWidth); |
|
|
|
|
DrawManaShild(pnum, px, py, false); |
|
|
|
|
|
|
|
|
|
light_table_index = l; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -492,17 +472,11 @@ static void DrawObject(int x, int y, int ox, int oy, BOOL pre)
|
|
|
|
|
assert((unsigned char)bv < MAXOBJECTS); |
|
|
|
|
|
|
|
|
|
pCelBuff = object[bv]._oAnimData; |
|
|
|
|
if (!pCelBuff) { |
|
|
|
|
// app_fatal("Draw Object type %d: NULL Cel Buffer", object[bv]._otype);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(pCelBuff != NULL, object[bv]._otype); |
|
|
|
|
|
|
|
|
|
nCel = object[bv]._oAnimFrame; |
|
|
|
|
frames = SDL_SwapLE32(*(DWORD *)pCelBuff); |
|
|
|
|
if (nCel < 1 || frames > 50 || nCel > (int)frames) { |
|
|
|
|
// app_fatal("Draw Object: frame %d of %d, object type==%d", nCel, frames, object[bv]._otype);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(nCel >= 1 && frames <= 50 && nCel <= frames, nCel); |
|
|
|
|
|
|
|
|
|
if (bv == pcursobj) |
|
|
|
|
CelBlitOutline(194, sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth); |
|
|
|
|
@ -599,16 +573,12 @@ static void DrawItem(int x, int y, int sx, int sy, BOOL pre)
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
pCelBuff = pItem->_iAnimData; |
|
|
|
|
if (pCelBuff == NULL) { |
|
|
|
|
// app_fatal("Draw Item \"%s\" 1: NULL Cel Buffer", pItem->_iIName);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
pFrameTable = (DWORD *)pCelBuff; |
|
|
|
|
assurance(pCelBuff != NULL, bItem); |
|
|
|
|
|
|
|
|
|
nCel = pItem->_iAnimFrame; |
|
|
|
|
if (nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { |
|
|
|
|
// app_fatal("Draw \"%s\" Item 1: frame %d of %d, item type==%d", pItem->_iIName, nCel, pFrameTable[0], pItem->_itype);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
pFrameTable = (DWORD *)pCelBuff; |
|
|
|
|
assurance(nCel >= 1 && pFrameTable[0] <= 50 && nCel <= pFrameTable[0], nCel); |
|
|
|
|
|
|
|
|
|
int px = sx - pItem->_iAnimWidth2; |
|
|
|
|
if (bItem - 1 == pcursitem || AutoMapShowItems) { |
|
|
|
|
CelBlitOutline(181, px, sy, pCelBuff, nCel, pItem->_iAnimWidth); |
|
|
|
|
@ -645,20 +615,14 @@ static void DrawMonsterHelper(int x, int y, int oy, int sx, int sy)
|
|
|
|
|
if (!(dFlags[x][y] & BFLAG_LIT) && !plr[myplr]._pInfraFlag) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if ((DWORD)mi >= MAXMONSTERS) { |
|
|
|
|
// app_fatal("Draw Monster: tried to draw illegal monster %d", mi);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(mi >= 0 && mi < MAXMONSTERS, mi); |
|
|
|
|
|
|
|
|
|
pMonster = &monster[mi]; |
|
|
|
|
if (pMonster->_mFlags & MFLAG_HIDDEN) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pMonster->MType == NULL) { |
|
|
|
|
// app_fatal("Draw Monster \"%s\": uninitialized monster", pMonster->mName);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(pMonster->MType != NULL, mi); |
|
|
|
|
|
|
|
|
|
px = sx + pMonster->_mxoff - pMonster->MType->width2; |
|
|
|
|
py = sy + pMonster->_myoff; |
|
|
|
|
@ -672,25 +636,21 @@ static void DrawMonsterHelper(int x, int y, int oy, int sx, int sy)
|
|
|
|
|
* @brief Check if and how a player should be rendered |
|
|
|
|
* @param y dPiece coordinate |
|
|
|
|
* @param x dPiece coordinate |
|
|
|
|
* @param oy dPiece Y offset |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
*/ |
|
|
|
|
static void DrawPlayerHelper(int x, int y, int oy, int sx, int sy) |
|
|
|
|
static void DrawPlayerHelper(int x, int y, int sx, int sy) |
|
|
|
|
{ |
|
|
|
|
int p = dPlayer[x][y + oy]; |
|
|
|
|
int p = dPlayer[x][y]; |
|
|
|
|
p = p > 0 ? p - 1 : -(p + 1); |
|
|
|
|
|
|
|
|
|
if ((DWORD)p >= MAX_PLRS) { |
|
|
|
|
// app_fatal("draw player: tried to draw illegal player %d", p);
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
assurance(p >= 0 && p < MAX_PLRS, p); |
|
|
|
|
|
|
|
|
|
PlayerStruct *pPlayer = &plr[p]; |
|
|
|
|
int px = sx + pPlayer->_pxoff - pPlayer->_pAnimWidth2; |
|
|
|
|
int py = sy + pPlayer->_pyoff; |
|
|
|
|
|
|
|
|
|
DrawPlayer(p, x, y + oy, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); |
|
|
|
|
DrawPlayer(p, x, y, px, py, pPlayer->_pAnimData, pPlayer->_pAnimFrame, pPlayer->_pAnimWidth); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -747,8 +707,7 @@ static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy)
|
|
|
|
|
pFrameTable = (DWORD *)pCelBuff; |
|
|
|
|
nCel = pDeadGuy->_deadFrame; |
|
|
|
|
if (nCel < 1 || pFrameTable[0] > 50 || nCel > (int)pFrameTable[0]) { |
|
|
|
|
// app_fatal("Unclipped dead: frame %d of %d, deadnum==%d", nCel, pFrameTable[0], (bDead & 0x1F) - 1);
|
|
|
|
|
break; |
|
|
|
|
app_fatal("Unclipped dead: frame %d of %d, deadnum==%d", nCel, pFrameTable[0], (bDead & 0x1F) - 1); |
|
|
|
|
} |
|
|
|
|
if (pDeadGuy->_deadtrans != 0) { |
|
|
|
|
Cl2DrawLightTbl(px, dy, pCelBuff, nCel, pDeadGuy->_deadWidth, pDeadGuy->_deadtrans); |
|
|
|
|
@ -761,7 +720,7 @@ static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy)
|
|
|
|
|
DrawItem(sx, sy, dx, dy, 1); |
|
|
|
|
if (bFlag & BFLAG_PLAYERLR) { |
|
|
|
|
assert((DWORD)(sy - 1) < MAXDUNY); |
|
|
|
|
DrawPlayerHelper(sx, sy, -1, dx, dy); |
|
|
|
|
DrawPlayerHelper(sx, sy - 1, dx, dy); |
|
|
|
|
} |
|
|
|
|
if (bFlag & BFLAG_MONSTLR && negMon < 0) { |
|
|
|
|
DrawMonsterHelper(sx, sy, -1, dx, dy); |
|
|
|
|
@ -770,7 +729,7 @@ static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy)
|
|
|
|
|
DrawDeadPlayer(sx, sy, dx, dy); |
|
|
|
|
} |
|
|
|
|
if (dPlayer[sx][sy] > 0) { |
|
|
|
|
DrawPlayerHelper(sx, sy, 0, dx, dy); |
|
|
|
|
DrawPlayerHelper(sx, sy, dx, dy); |
|
|
|
|
} |
|
|
|
|
if (dMonster[sx][sy] > 0) { |
|
|
|
|
DrawMonsterHelper(sx, sy, 0, dx, dy); |
|
|
|
|
|