Browse Source

🚚 Move local symbols in to anon namespace

pull/2328/head
Anders Jenbo 5 years ago
parent
commit
20262e4569
  1. 2
      Source/capture.cpp
  2. 2
      Source/codec.cpp
  3. 570
      Source/control.cpp
  4. 84
      Source/debug.cpp
  5. 1907
      Source/diablo.cpp
  6. 676
      Source/drlg_l1.cpp
  7. 9
      Source/drlg_l1.h

2
Source/capture.cpp

@ -16,6 +16,7 @@
#include "utils/ui_fwd.h"
namespace devilution {
namespace {
/**
* @brief Write the PCX-file header
@ -156,6 +157,7 @@ static void RedPalette()
BltFast(nullptr, nullptr);
RenderPresent();
}
}
/**
* @brief Save the current screen to a screen??.PCX (00-99) in file if available, then make the screen red for 200ms.

2
Source/codec.cpp

@ -12,6 +12,7 @@
#include "utils/stdcompat/cstddef.hpp"
namespace devilution {
namespace {
struct CodecSignature {
uint32_t checksum;
@ -53,6 +54,7 @@ static void CodecInitKey(const char *pszPassword)
}
memset(key, 0, sizeof(key));
}
}
std::size_t codec_decode(byte *pbSrcDst, std::size_t size, const char *pszPassword)
{

570
Source/control.cpp

@ -32,50 +32,24 @@
#include "utils/sdl_geometry.h"
namespace devilution {
namespace {
Surface pBtmBuff;
Surface pLifeBuff;
Surface pManaBuff;
std::optional<CelSprite> talkButtons;
std::optional<CelSprite> pDurIcons;
std::optional<CelSprite> pChrButtons;
std::optional<CelSprite> multiButtons;
std::optional<CelSprite> pPanelButtons;
std::optional<CelSprite> pChrPanel;
std::optional<CelSprite> pGBoxBuff;
std::optional<CelSprite> pSBkBtnCel;
std::optional<CelSprite> pSBkIconCels;
std::optional<CelSprite> pSpellBkCel;
std::optional<CelSprite> pSpellCels;
} // namespace
BYTE sgbNextTalkSave;
BYTE sgbTalkSavePos;
/**
* @brief Set if the life flask needs to be redrawn during next frame
*/
*/
bool drawhpflag;
bool dropGoldFlag;
bool panbtns[8];
bool chrbtn[4];
bool lvlbtndown;
char sgszTalkSave[8][80];
int dropGoldValue;
/**
* @brief Set if the mana flask needs to be redrawn during the next frame
*/
*/
bool drawmanaflag;
bool chrbtnactive;
char sgszTalkMsg[MAX_SEND_STR_LEN];
int pnumlines;
bool pinfoflag;
bool talkButtonsDown[3];
spell_id pSpell;
uint16_t infoclr;
int sgbPlrTalkTbl;
char tempstr[256];
bool whisperList[MAX_PLRS];
int sbooktab;
spell_type pSplType;
int initialDropGoldIndex;
@ -84,16 +58,51 @@ bool sbookflag;
bool chrflag;
bool drawbtnflag;
char infostr[64];
int numpanbtns;
char panelstr[4][64];
bool panelflag;
uint8_t SplTransTbl[256];
int initialDropGoldValue;
bool panbtndown;
bool spselflag;
extern std::array<Keymapper::ActionIndex, 4> quickSpellActionIndexes;
/** Maps from attribute_id to the rectangle on screen used for attribute increment buttons. */
Rectangle ChrBtnsRect[4] = {
{ { 137, 138 }, { 41, 22 } },
{ { 137, 166 }, { 41, 22 } },
{ { 137, 195 }, { 41, 22 } },
{ { 137, 223 }, { 41, 22 } }
};
namespace {
Surface pBtmBuff;
Surface pLifeBuff;
Surface pManaBuff;
std::optional<CelSprite> talkButtons;
std::optional<CelSprite> pDurIcons;
std::optional<CelSprite> pChrButtons;
std::optional<CelSprite> multiButtons;
std::optional<CelSprite> pPanelButtons;
std::optional<CelSprite> pChrPanel;
std::optional<CelSprite> pGBoxBuff;
std::optional<CelSprite> pSBkBtnCel;
std::optional<CelSprite> pSBkIconCels;
std::optional<CelSprite> pSpellBkCel;
std::optional<CelSprite> pSpellCels;
BYTE sgbNextTalkSave;
BYTE sgbTalkSavePos;
bool panbtns[8];
char sgszTalkSave[8][80];
char sgszTalkMsg[MAX_SEND_STR_LEN];
bool talkButtonsDown[3];
int sgbPlrTalkTbl;
bool whisperList[MAX_PLRS];
int numpanbtns;
char panelstr[4][64];
uint8_t SplTransTbl[256];
/** Map of hero class names */
const char *const ClassStrTbl[] = {
N_("Warrior"),
@ -210,13 +219,6 @@ const char *const PanBtnStr[8] = {
N_("Send Message"),
"" // Player attack
};
/** Maps from attribute_id to the rectangle on screen used for attribute increment buttons. */
Rectangle ChrBtnsRect[4] = {
{ { 137, 138 }, { 41, 22 } },
{ { 137, 166 }, { 41, 22 } },
{ { 137, 195 }, { 41, 22 } },
{ { 137, 223 }, { 41, 22 } }
};
/** Maps from spellbook page number and position to spell_id. */
spell_id SpellPages[6][7] = {
@ -292,15 +294,256 @@ void SetSpellTrans(spell_type t)
SplTransTbl[PAL16_YELLOW - PAL16_GRAY + i] = i;
SplTransTbl[PAL16_ORANGE - PAL16_GRAY + i] = i;
}
SplTransTbl[PAL16_BEIGE + 15] = 0;
SplTransTbl[PAL16_YELLOW + 15] = 0;
SplTransTbl[PAL16_ORANGE + 15] = 0;
break;
case RSPLTYPE_SKILL:
break;
SplTransTbl[PAL16_BEIGE + 15] = 0;
SplTransTbl[PAL16_YELLOW + 15] = 0;
SplTransTbl[PAL16_ORANGE + 15] = 0;
break;
case RSPLTYPE_SKILL:
break;
}
}
static void PrintSBookHotkey(const Surface &out, Point position, const std::string &text)
{
// Align the hot key text with the top-right corner of the spell icon
position += Displacement { SPLICONLENGTH - (GetLineWidth(text.c_str()) + 5), 17 - SPLICONLENGTH };
// Draw a drop shadow below and to the left of the text
DrawString(out, text.c_str(), position + Displacement { -1, 1 }, UIS_BLACK);
// Then draw the text over the top
DrawString(out, text.c_str(), position, UIS_SILVER);
}
/**
* Draws a section of the empty flask cel on top of the panel to create the illusion
* of the flask getting empty. This function takes a cel and draws a
* horizontal stripe of height (max-min) onto the given buffer.
* @param out Target buffer.
* @param position Buffer coordinate.
* @param celBuf Buffer of the empty flask cel.
* @param y0 Top of the flask cel section to draw.
* @param y1 Bottom of the flask cel section to draw.
*/
static void DrawFlaskTop(const Surface &out, Point position, const Surface &celBuf, int y0, int y1)
{
out.BlitFrom(celBuf, SDL_Rect { 0, static_cast<decltype(SDL_Rect {}.y)>(y0), celBuf.w(), y1 - y0 }, position);
}
/**
* Draws the dome of the flask that protrudes above the panel top line.
* It draws a rectangle of fixed width 59 and height 'h' from the source buffer
* into the target buffer.
* @param out The target buffer.
* @param celBuf Buffer of the empty flask cel.
* @param sourcePosition Source buffer start coordinate.
* @param targetPosition Target buffer coordinate.
* @param h How many lines of the source buffer that will be copied.
*/
static void DrawFlask(const Surface &out, const Surface &celBuf, Point sourcePosition, Point targetPosition, int h)
{
constexpr int FlaskWidth = 59;
out.BlitFromSkipColorIndexZero(celBuf, MakeSdlRect(sourcePosition.x, sourcePosition.y, FlaskWidth, h), targetPosition);
}
/**
* @brief Draws the part of the life/mana flasks protruding above the bottom panel
* @see DrawFlaskLower()
* @param out The display region to draw to
* @param sourceBuffer A sprite representing the appropriate background/empty flask style
* @param offset X coordinate offset for where the flask should be drawn
* @param fillPer How full the flask is (a value from 0 to 80)
*/
void DrawFlaskUpper(const Surface &out, const Surface &sourceBuffer, int offset, int fillPer)
{
// clamping because this function only draws the top 12% of the flask display
int emptyPortion = clamp(80 - fillPer, 0, 11) + 2; // +2 to account for the frame being included in the sprite
// Draw the empty part of the flask
DrawFlask(out, sourceBuffer, { 13, 3 }, { PANEL_LEFT + offset, PANEL_TOP - 13 }, emptyPortion);
if (emptyPortion < 13)
// Draw the filled part of the flask
DrawFlask(out, pBtmBuff, { offset, emptyPortion + 3 }, { PANEL_LEFT + offset, PANEL_TOP - 13 + emptyPortion }, 13 - emptyPortion);
}
/**
* @brief Draws the part of the life/mana flasks inside the bottom panel
* @see DrawFlaskUpper()
* @param out The display region to draw to
* @param sourceBuffer A sprite representing the appropriate background/empty flask style
* @param offset X coordinate offset for where the flask should be drawn
* @param fillPer How full the flask is (a value from 0 to 80)
*/
void DrawFlaskLower(const Surface &out, const Surface &sourceBuffer, int offset, int fillPer)
{
int filled = clamp(fillPer, 0, 69);
if (filled < 69)
DrawFlaskTop(out, { PANEL_X + offset, PANEL_Y }, sourceBuffer, 16, 85 - filled);
// It appears that the panel defaults to having a filled flask and DrawFlaskTop only overlays the appropriate amount of empty space.
// This draw might not be necessary?
if (filled > 0)
DrawPanelBox(out, { offset, 85 - filled, 88, filled }, { PANEL_X + offset, PANEL_Y + 69 - filled });
}
void control_set_button_down(int btnId)
{
panbtns[btnId] = true;
drawbtnflag = true;
panbtndown = true;
}
static void PrintInfo(const Surface &out)
{
if (talkflag)
return;
Rectangle line { { PANEL_X + 177, PANEL_Y + LineOffsets[pnumlines][0] }, { 288, 0 } };
int yo = 0;
int lo = 1;
if (infostr[0] != '\0') {
DrawString(out, infostr, line, infoclr | UIS_CENTER | UIS_FIT_SPACING, 2);
yo = 1;
lo = 0;
}
for (int i = 0; i < pnumlines; i++) {
line.position.y = PANEL_Y + LineOffsets[pnumlines - lo][i + yo];
DrawString(out, panelstr[i], line, infoclr | UIS_CENTER | UIS_FIT_SPACING, 2);
}
}
int CapStatPointsToAdd(int remainingStatPoints, const PlayerStruct &player, CharacterAttribute attribute)
{
int pointsToReachCap = player.GetMaximumAttributeValue(attribute) - player.GetBaseAttributeValue(attribute);
return std::min(remainingStatPoints, pointsToReachCap);
}
static int DrawDurIcon4Item(const Surface &out, ItemStruct *pItem, int x, int c)
{
if (pItem->isEmpty())
return x;
if (pItem->_iDurability > 5)
return x;
if (c == 0) {
switch (pItem->_itype) {
case ITYPE_SWORD:
c = 2;
break;
case ITYPE_AXE:
c = 6;
break;
case ITYPE_BOW:
c = 7;
break;
case ITYPE_MACE:
c = 5;
break;
case ITYPE_STAFF:
c = 8;
break;
default:
c = 1;
break;
}
}
if (pItem->_iDurability > 2)
c += 8;
CelDrawTo(out, { x, -17 + PANEL_Y }, *pDurIcons, c);
return x - 32 - 8;
}
static void PrintSBookStr(const Surface &out, Point position, const char *text)
{
DrawString(out, text, { { RIGHT_PANEL_X + SPLICONLENGTH + position.x, position.y }, { 222, 0 } }, UIS_SILVER);
}
spell_type GetSBookTrans(spell_id ii, bool townok)
{
auto &myPlayer = Players[MyPlayerId];
if ((myPlayer._pClass == HeroClass::Monk) && (ii == SPL_SEARCH))
return RSPLTYPE_SKILL;
spell_type st = RSPLTYPE_SPELL;
if ((myPlayer._pISpells & GetSpellBitmask(ii)) != 0) {
st = RSPLTYPE_CHARGES;
}
if ((myPlayer._pAblSpells & GetSpellBitmask(ii)) != 0) {
st = RSPLTYPE_SKILL;
}
if (st == RSPLTYPE_SPELL) {
if (!CheckSpell(MyPlayerId, ii, st, true)) {
st = RSPLTYPE_INVALID;
}
if ((char)(myPlayer._pSplLvl[ii] + myPlayer._pISplLvlAdd) <= 0) {
st = RSPLTYPE_INVALID;
}
}
if (townok && currlevel == 0 && st != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell) {
st = RSPLTYPE_INVALID;
}
return st;
}
static void ControlSetGoldCurs(PlayerStruct &player)
{
SetPlrHandGoldCurs(&player.HoldItem);
NewCursor(player.HoldItem._iCurs + CURSOR_FIRSTITEM);
}
void control_reset_talk_msg()
{
uint32_t pmask = 0;
for (int i = 0; i < MAX_PLRS; i++) {
if (whisperList[i])
pmask |= 1 << i;
}
NetSendCmdString(pmask, sgszTalkMsg);
}
static void ControlPressEnter()
{
if (sgszTalkMsg[0] != 0) {
control_reset_talk_msg();
int i = 0;
for (; i < 8; i++) {
if (strcmp(sgszTalkSave[i], sgszTalkMsg) == 0)
break;
}
if (i >= 8) {
strcpy(sgszTalkSave[sgbNextTalkSave], sgszTalkMsg);
sgbNextTalkSave++;
sgbNextTalkSave &= 7;
} else {
BYTE talkSave = sgbNextTalkSave - 1;
talkSave &= 7;
if (i != talkSave) {
strcpy(sgszTalkSave[i], sgszTalkSave[talkSave]);
strcpy(sgszTalkSave[talkSave], sgszTalkMsg);
}
}
sgszTalkMsg[0] = '\0';
sgbTalkSavePos = sgbNextTalkSave;
}
control_reset_talk();
}
static void ControlUpDown(int v)
{
for (int i = 0; i < 8; i++) {
sgbTalkSavePos = (v + sgbTalkSavePos) & 7;
if (sgszTalkSave[sgbTalkSavePos][0] != 0) {
strcpy(sgszTalkMsg, sgszTalkSave[sgbTalkSavePos]);
return;
}
}
}
} // namespace
void DrawSpell(const Surface &out)
{
auto &myPlayer = Players[MyPlayerId];
@ -323,17 +566,6 @@ void DrawSpell(const Surface &out)
DrawSpellCel(out, position, *pSpellCels, nCel);
}
static void PrintSBookHotkey(const Surface &out, Point position, const std::string &text)
{
// Align the hot key text with the top-right corner of the spell icon
position += Displacement { SPLICONLENGTH - (GetLineWidth(text.c_str()) + 5), 17 - SPLICONLENGTH };
// Draw a drop shadow below and to the left of the text
DrawString(out, text.c_str(), position + Displacement { -1, 1 }, UIS_BLACK);
// Then draw the text over the top
DrawString(out, text.c_str(), position, UIS_SILVER);
}
void DrawSpellList(const Surface &out)
{
int c;
@ -550,78 +782,6 @@ void DrawPanelBox(const Surface &out, SDL_Rect srcRect, Point targetPosition)
out.BlitFrom(pBtmBuff, srcRect, targetPosition);
}
/**
* Draws a section of the empty flask cel on top of the panel to create the illusion
* of the flask getting empty. This function takes a cel and draws a
* horizontal stripe of height (max-min) onto the given buffer.
* @param out Target buffer.
* @param position Buffer coordinate.
* @param celBuf Buffer of the empty flask cel.
* @param y0 Top of the flask cel section to draw.
* @param y1 Bottom of the flask cel section to draw.
*/
static void DrawFlaskTop(const Surface &out, Point position, const Surface &celBuf, int y0, int y1)
{
out.BlitFrom(celBuf, SDL_Rect { 0, static_cast<decltype(SDL_Rect {}.y)>(y0), celBuf.w(), y1 - y0 }, position);
}
/**
* Draws the dome of the flask that protrudes above the panel top line.
* It draws a rectangle of fixed width 59 and height 'h' from the source buffer
* into the target buffer.
* @param out The target buffer.
* @param celBuf Buffer of the empty flask cel.
* @param sourcePosition Source buffer start coordinate.
* @param targetPosition Target buffer coordinate.
* @param h How many lines of the source buffer that will be copied.
*/
static void DrawFlask(const Surface &out, const Surface &celBuf, Point sourcePosition, Point targetPosition, int h)
{
constexpr int FlaskWidth = 59;
out.BlitFromSkipColorIndexZero(celBuf, MakeSdlRect(sourcePosition.x, sourcePosition.y, FlaskWidth, h), targetPosition);
}
/**
* @brief Draws the part of the life/mana flasks protruding above the bottom panel
* @see DrawFlaskLower()
* @param out The display region to draw to
* @param sourceBuffer A sprite representing the appropriate background/empty flask style
* @param offset X coordinate offset for where the flask should be drawn
* @param fillPer How full the flask is (a value from 0 to 80)
*/
void DrawFlaskUpper(const Surface &out, const Surface &sourceBuffer, int offset, int fillPer)
{
// clamping because this function only draws the top 12% of the flask display
int emptyPortion = clamp(80 - fillPer, 0, 11) + 2; // +2 to account for the frame being included in the sprite
// Draw the empty part of the flask
DrawFlask(out, sourceBuffer, { 13, 3 }, { PANEL_LEFT + offset, PANEL_TOP - 13 }, emptyPortion);
if (emptyPortion < 13)
// Draw the filled part of the flask
DrawFlask(out, pBtmBuff, { offset, emptyPortion + 3 }, { PANEL_LEFT + offset, PANEL_TOP - 13 + emptyPortion }, 13 - emptyPortion);
}
/**
* @brief Draws the part of the life/mana flasks inside the bottom panel
* @see DrawFlaskUpper()
* @param out The display region to draw to
* @param sourceBuffer A sprite representing the appropriate background/empty flask style
* @param offset X coordinate offset for where the flask should be drawn
* @param fillPer How full the flask is (a value from 0 to 80)
*/
void DrawFlaskLower(const Surface &out, const Surface &sourceBuffer, int offset, int fillPer)
{
int filled = clamp(fillPer, 0, 69);
if (filled < 69)
DrawFlaskTop(out, { PANEL_X + offset, PANEL_Y }, sourceBuffer, 16, 85 - filled);
// It appears that the panel defaults to having a filled flask and DrawFlaskTop only overlays the appropriate amount of empty space.
// This draw might not be necessary?
if (filled > 0)
DrawPanelBox(out, { offset, 85 - filled, 88, filled }, { PANEL_X + offset, PANEL_Y + 69 - filled });
}
void DrawLifeFlaskUpper(const Surface &out)
{
constexpr int LifeFlaskUpperOffset = 109;
@ -849,13 +1009,6 @@ void DoPanBtn()
}
}
void control_set_button_down(int btnId)
{
panbtns[btnId] = true;
drawbtnflag = true;
panbtndown = true;
}
void control_check_btn_press()
{
int x = PanBtnPos[3].x + PANEL_LEFT + PanBtnPos[3].w;
@ -1080,27 +1233,6 @@ void FreeControlPan()
pGBoxBuff = std::nullopt;
}
static void PrintInfo(const Surface &out)
{
if (talkflag)
return;
Rectangle line { { PANEL_X + 177, PANEL_Y + LineOffsets[pnumlines][0] }, { 288, 0 } };
int yo = 0;
int lo = 1;
if (infostr[0] != '\0') {
DrawString(out, infostr, line, infoclr | UIS_CENTER | UIS_FIT_SPACING, 2);
yo = 1;
lo = 0;
}
for (int i = 0; i < pnumlines; i++) {
line.position.y = PANEL_Y + LineOffsets[pnumlines - lo][i + yo];
DrawString(out, panelstr[i], line, infoclr | UIS_CENTER | UIS_FIT_SPACING, 2);
}
}
void DrawInfoBox(const Surface &out)
{
DrawPanelBox(out, { 177, 62, 288, 60 }, { PANEL_X + 177, PANEL_Y + 46 });
@ -1430,13 +1562,6 @@ void CheckChrBtns()
}
}
int CapStatPointsToAdd(int remainingStatPoints, const PlayerStruct &player, CharacterAttribute attribute)
{
int pointsToReachCap = player.GetMaximumAttributeValue(attribute) - player.GetBaseAttributeValue(attribute);
return std::min(remainingStatPoints, pointsToReachCap);
}
void ReleaseChrBtns(bool addAllStatPoints)
{
chrbtnactive = false;
@ -1473,40 +1598,6 @@ void ReleaseChrBtns(bool addAllStatPoints)
}
}
static int DrawDurIcon4Item(const Surface &out, ItemStruct *pItem, int x, int c)
{
if (pItem->isEmpty())
return x;
if (pItem->_iDurability > 5)
return x;
if (c == 0) {
switch (pItem->_itype) {
case ITYPE_SWORD:
c = 2;
break;
case ITYPE_AXE:
c = 6;
break;
case ITYPE_BOW:
c = 7;
break;
case ITYPE_MACE:
c = 5;
break;
case ITYPE_STAFF:
c = 8;
break;
default:
c = 1;
break;
}
}
if (pItem->_iDurability > 2)
c += 8;
CelDrawTo(out, { x, -17 + PANEL_Y }, *pDurIcons, c);
return x - 32 - 8;
}
void DrawDurIcon(const Surface &out)
{
bool hasRoomBetweenPanels = gnScreenWidth >= PANEL_WIDTH + 16 + (32 + 8 + 32 + 8 + 32 + 8 + 32) + 16;
@ -1543,38 +1634,6 @@ void RedBack(const Surface &out)
}
}
static void PrintSBookStr(const Surface &out, Point position, const char *text)
{
DrawString(out, text, { { RIGHT_PANEL_X + SPLICONLENGTH + position.x, position.y }, { 222, 0 } }, UIS_SILVER);
}
spell_type GetSBookTrans(spell_id ii, bool townok)
{
auto &myPlayer = Players[MyPlayerId];
if ((myPlayer._pClass == HeroClass::Monk) && (ii == SPL_SEARCH))
return RSPLTYPE_SKILL;
spell_type st = RSPLTYPE_SPELL;
if ((myPlayer._pISpells & GetSpellBitmask(ii)) != 0) {
st = RSPLTYPE_CHARGES;
}
if ((myPlayer._pAblSpells & GetSpellBitmask(ii)) != 0) {
st = RSPLTYPE_SKILL;
}
if (st == RSPLTYPE_SPELL) {
if (!CheckSpell(MyPlayerId, ii, st, true)) {
st = RSPLTYPE_INVALID;
}
if ((char)(myPlayer._pSplLvl[ii] + myPlayer._pISplLvlAdd) <= 0) {
st = RSPLTYPE_INVALID;
}
}
if (townok && currlevel == 0 && st != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell) {
st = RSPLTYPE_INVALID;
}
return st;
}
void DrawSpellBook(const Surface &out)
{
CelDrawTo(out, { RIGHT_PANEL_X, 351 }, *pSpellBkCel, 1);
@ -1743,12 +1802,6 @@ void control_drop_gold(char vkey)
}
}
static void ControlSetGoldCurs(PlayerStruct &player)
{
SetPlrHandGoldCurs(&player.HoldItem);
NewCursor(player.HoldItem._iCurs + CURSOR_FIRSTITEM);
}
void control_remove_gold(int pnum, int goldIndex)
{
auto &player = Players[pnum];
@ -1866,17 +1919,6 @@ void control_release_talk_btn()
whisperList[p - 1] = !whisperList[p - 1];
}
void control_reset_talk_msg()
{
uint32_t pmask = 0;
for (int i = 0; i < MAX_PLRS; i++) {
if (whisperList[i])
pmask |= 1 << i;
}
NetSendCmdString(pmask, sgszTalkMsg);
}
void control_type_message()
{
if (!gbIsMultiplayer)
@ -1899,33 +1941,6 @@ void control_reset_talk()
force_redraw = 255;
}
static void ControlPressEnter()
{
if (sgszTalkMsg[0] != 0) {
control_reset_talk_msg();
int i = 0;
for (; i < 8; i++) {
if (strcmp(sgszTalkSave[i], sgszTalkMsg) == 0)
break;
}
if (i >= 8) {
strcpy(sgszTalkSave[sgbNextTalkSave], sgszTalkMsg);
sgbNextTalkSave++;
sgbNextTalkSave &= 7;
} else {
BYTE talkSave = sgbNextTalkSave - 1;
talkSave &= 7;
if (i != talkSave) {
strcpy(sgszTalkSave[i], sgszTalkSave[talkSave]);
strcpy(sgszTalkSave[talkSave], sgszTalkMsg);
}
}
sgszTalkMsg[0] = '\0';
sgbTalkSavePos = sgbNextTalkSave;
}
control_reset_talk();
}
bool control_talk_last_key(int vkey)
{
if (!gbIsMultiplayer)
@ -1945,17 +1960,6 @@ bool control_talk_last_key(int vkey)
return true;
}
static void ControlUpDown(int v)
{
for (int i = 0; i < 8; i++) {
sgbTalkSavePos = (v + sgbTalkSavePos) & 7;
if (sgszTalkSave[sgbTalkSavePos][0] != 0) {
strcpy(sgszTalkMsg, sgszTalkSave[sgbTalkSavePos]);
return;
}
}
}
bool control_presskeys(int vkey)
{
if (!gbIsMultiplayer)

84
Source/debug.cpp

@ -14,17 +14,53 @@
namespace devilution {
std::optional<CelSprite> pSquareCel;
#ifdef _DEBUG
#define DebugSeeds 4096
int seed_index;
int level_seeds[NUMLEVELS + 1];
int seed_table[DebugSeeds];
namespace {
std::optional<CelSprite> pSquareCel;
char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY];
char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY];
int DebugPlayerId;
int DebugQuestId;
int DebugMonsterId;
void SetSpellLevelCheat(spell_id spl, int spllvl)
{
auto &myPlayer = Players[MyPlayerId];
myPlayer._pMemSpells |= GetSpellBitmask(spl);
myPlayer._pSplLvl[spl] = spllvl;
}
void PrintDebugMonster(int m)
{
char dstr[128];
sprintf(dstr, "Monster %i = %s", m, _(Monsters[m].mName));
NetSendCmdString(1 << MyPlayerId, dstr);
sprintf(dstr, "X = %i, Y = %i", Monsters[m].position.tile.x, Monsters[m].position.tile.y);
NetSendCmdString(1 << MyPlayerId, dstr);
sprintf(dstr, "Enemy = %i, HP = %i", Monsters[m]._menemy, Monsters[m]._mhitpoints);
NetSendCmdString(1 << MyPlayerId, dstr);
sprintf(dstr, "Mode = %i, Var1 = %i", Monsters[m]._mmode, Monsters[m]._mVar1);
NetSendCmdString(1 << MyPlayerId, dstr);
bool bActive = false;
for (int i = 0; i < ActiveMonsterCount; i++) {
if (ActiveMonsters[i] == m)
bActive = true;
}
sprintf(dstr, "Active List = %i, Squelch = %i", bActive ? 1 : 0, Monsters[m]._msquelch);
NetSendCmdString(1 << MyPlayerId, dstr);
}
}
void LoadDebugGFX()
{
if (visiondebug)
@ -99,14 +135,6 @@ void MaxSpellsCheat()
}
}
void SetSpellLevelCheat(spell_id spl, int spllvl)
{
auto &myPlayer = Players[MyPlayerId];
myPlayer._pMemSpells |= GetSpellBitmask(spl);
myPlayer._pSplLvl[spl] = spllvl;
}
void SetAllSpellsCheat()
{
SetSpellLevelCheat(SPL_FIREBOLT, 8);
@ -133,8 +161,6 @@ void SetAllSpellsCheat()
SetSpellLevelCheat(SPL_BONESPIRIT, 1);
}
int DebugPlayerId;
void PrintDebugPlayer(bool bNextPlayer)
{
char dstr[128];
@ -162,8 +188,6 @@ void PrintDebugPlayer(bool bNextPlayer)
}
}
int DebugQuestId;
void PrintDebugQuest()
{
char dstr[128];
@ -176,32 +200,6 @@ void PrintDebugQuest()
DebugQuestId = 0;
}
void PrintDebugMonster(int m)
{
char dstr[128];
sprintf(dstr, "Monster %i = %s", m, _(Monsters[m].mName));
NetSendCmdString(1 << MyPlayerId, dstr);
sprintf(dstr, "X = %i, Y = %i", Monsters[m].position.tile.x, Monsters[m].position.tile.y);
NetSendCmdString(1 << MyPlayerId, dstr);
sprintf(dstr, "Enemy = %i, HP = %i", Monsters[m]._menemy, Monsters[m]._mhitpoints);
NetSendCmdString(1 << MyPlayerId, dstr);
sprintf(dstr, "Mode = %i, Var1 = %i", Monsters[m]._mmode, Monsters[m]._mVar1);
NetSendCmdString(1 << MyPlayerId, dstr);
bool bActive = false;
for (int i = 0; i < ActiveMonsterCount; i++) {
if (ActiveMonsters[i] == m)
bActive = true;
}
sprintf(dstr, "Active List = %i, Squelch = %i", bActive ? 1 : 0, Monsters[m]._msquelch);
NetSendCmdString(1 << MyPlayerId, dstr);
}
int DebugMonsterId;
void GetDebugMonster()
{
int mi1 = pcursmonst;

1907
Source/diablo.cpp

File diff suppressed because it is too large Load Diff

676
Source/drlg_l1.cpp

@ -503,8 +503,6 @@ BYTE CornerstoneRoomPattern[27] = {
*/
BYTE L5ConvTbl[16] = { 22, 13, 1, 13, 2, 13, 13, 13, 4, 13, 1, 13, 2, 13, 16, 13 };
} // namespace
void DRLG_InitL5Vals()
{
for (int j = 0; j < MAXDUNY; j++) {
@ -881,52 +879,6 @@ static void DrlgL1Floor()
}
}
void DRLG_LPass3(int lv)
{
{
MegaTile mega = pMegaTiles[lv];
int v1 = SDL_SwapLE16(mega.micro1) + 1;
int v2 = SDL_SwapLE16(mega.micro2) + 1;
int v3 = SDL_SwapLE16(mega.micro3) + 1;
int v4 = SDL_SwapLE16(mega.micro4) + 1;
for (int j = 0; j < MAXDUNY; j += 2) {
for (int i = 0; i < MAXDUNX; i += 2) {
dPiece[i + 0][j + 0] = v1;
dPiece[i + 1][j + 0] = v2;
dPiece[i + 0][j + 1] = v3;
dPiece[i + 1][j + 1] = v4;
}
}
}
int yy = 16;
for (int j = 0; j < DMAXY; j++) {
int xx = 16;
for (int i = 0; i < DMAXX; i++) { // NOLINT(modernize-loop-convert)
int v1 = 0;
int v2 = 0;
int v3 = 0;
int v4 = 0;
int tileId = dungeon[i][j] - 1;
if (tileId >= 0) {
MegaTile mega = pMegaTiles[tileId];
v1 = SDL_SwapLE16(mega.micro1) + 1;
v2 = SDL_SwapLE16(mega.micro2) + 1;
v3 = SDL_SwapLE16(mega.micro3) + 1;
v4 = SDL_SwapLE16(mega.micro4) + 1;
}
dPiece[xx + 0][yy + 0] = v1;
dPiece[xx + 1][yy + 0] = v2;
dPiece[xx + 0][yy + 1] = v3;
dPiece[xx + 1][yy + 1] = v4;
xx += 2;
}
yy += 2;
}
}
static void DrlgL1Pass3()
{
DRLG_LPass3(22 - 1);
@ -954,20 +906,6 @@ static void DrlgFreeL1Sp()
L5pSetPiece = nullptr;
}
void DRLG_Init_Globals()
{
memset(dFlags, 0, sizeof(dFlags));
memset(dPlayer, 0, sizeof(dPlayer));
memset(dMonster, 0, sizeof(dMonster));
memset(dDead, 0, sizeof(dDead));
memset(dObject, 0, sizeof(dObject));
memset(dItem, 0, sizeof(dItem));
memset(dMissile, 0, sizeof(dMissile));
memset(dSpecial, 0, sizeof(dSpecial));
int8_t c = DisableLighting ? 0 : 15;
memset(dLight, c, sizeof(dLight));
}
static void DrlgInitL1Vals()
{
int8_t pc;
@ -994,100 +932,6 @@ static void DrlgInitL1Vals()
}
}
void LoadL1Dungeon(const char *path, int vx, int vy)
{
dminx = 16;
dminy = 16;
dmaxx = 96;
dmaxy = 96;
DRLG_InitTrans();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 22;
L5dflags[i][j] = 0;
}
}
auto dunData = LoadFileInMem<uint16_t>(path);
int width = SDL_SwapLE16(dunData[0]);
int height = SDL_SwapLE16(dunData[1]);
const uint16_t *tileLayer = &dunData[2];
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
uint8_t tileId = SDL_SwapLE16(*tileLayer);
tileLayer++;
if (tileId != 0) {
dungeon[i][j] = tileId;
L5dflags[i][j] |= DLRG_PROTECTED;
} else {
dungeon[i][j] = 13;
}
}
}
DrlgL1Floor();
ViewX = vx;
ViewY = vy;
DrlgL1Pass3();
DRLG_Init_Globals();
if (currlevel < 17)
DrlgInitL1Vals();
SetMapMonsters(dunData.get(), { 0, 0 });
SetMapObjects(dunData.get(), 0, 0);
}
void LoadPreL1Dungeon(const char *path)
{
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 22;
L5dflags[i][j] = 0;
}
}
dminx = 16;
dminy = 16;
dmaxx = 96;
dmaxy = 96;
auto dunData = LoadFileInMem<uint16_t>(path);
int width = SDL_SwapLE16(dunData[0]);
int height = SDL_SwapLE16(dunData[1]);
const uint16_t *tileLayer = &dunData[2];
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
uint8_t tileId = SDL_SwapLE16(*tileLayer);
tileLayer++;
if (tileId != 0) {
dungeon[i][j] = tileId;
L5dflags[i][j] |= DLRG_PROTECTED;
} else {
dungeon[i][j] = 13;
}
}
}
DrlgL1Floor();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
}
static void InitL5Dungeon()
{
for (int j = 0; j < DMAXY; j++) {
@ -1706,6 +1550,31 @@ static void L5tileFix()
}
}
void drlg_l1_set_corner_room(int rx1, int ry1)
{
int rw = CornerstoneRoomPattern[0];
int rh = CornerstoneRoomPattern[1];
setpc_x = rx1;
setpc_y = ry1;
setpc_w = rw;
setpc_h = rh;
int sp = 2;
for (int j = 0; j < rh; j++) {
for (int i = 0; i < rw; i++) {
if (CornerstoneRoomPattern[sp] != 0) {
dungeon[rx1 + i][ry1 + j] = CornerstoneRoomPattern[sp];
L5dflags[rx1 + i][ry1 + j] |= DLRG_PROTECTED;
} else {
dungeon[rx1 + i][ry1 + j] = 13;
}
sp++;
}
}
}
void drlg_l1_crypt_rndset(const BYTE *miniset, int rndper)
{
int sw = miniset[0];
@ -1825,6 +1694,35 @@ static void DrlgL5SetRoom(int rx1, int ry1)
}
}
void drlg_l1_set_crypt_room(int rx1, int ry1)
{
int rw = UberRoomPattern[0];
int rh = UberRoomPattern[1];
UberRow = 2 * rx1 + 6;
UberCol = 2 * ry1 + 8;
setpc_x = rx1;
setpc_y = ry1;
setpc_w = rw;
setpc_h = rh;
IsUberRoomOpened = false;
IsUberLeverActivated = false;
int sp = 2;
for (int j = 0; j < rh; j++) {
for (int i = 0; i < rw; i++) {
if (UberRoomPattern[sp] != 0) {
dungeon[rx1 + i][ry1 + j] = UberRoomPattern[sp];
L5dflags[rx1 + i][ry1 + j] |= DLRG_PROTECTED;
} else {
dungeon[rx1 + i][ry1 + j] = 13;
}
sp++;
}
}
}
static void L5FillChambers()
{
if (HR1)
@ -2045,66 +1943,12 @@ static void L5FillChambers()
}
}
void drlg_l1_set_crypt_room(int rx1, int ry1)
static void DrlgL5FTransparencyValueR(int i, int j, int x, int y, int d)
{
int rw = UberRoomPattern[0];
int rh = UberRoomPattern[1];
UberRow = 2 * rx1 + 6;
UberCol = 2 * ry1 + 8;
setpc_x = rx1;
setpc_y = ry1;
setpc_w = rw;
setpc_h = rh;
IsUberRoomOpened = false;
IsUberLeverActivated = false;
int sp = 2;
for (int j = 0; j < rh; j++) {
for (int i = 0; i < rw; i++) {
if (UberRoomPattern[sp] != 0) {
dungeon[rx1 + i][ry1 + j] = UberRoomPattern[sp];
L5dflags[rx1 + i][ry1 + j] |= DLRG_PROTECTED;
} else {
dungeon[rx1 + i][ry1 + j] = 13;
}
sp++;
}
}
}
void drlg_l1_set_corner_room(int rx1, int ry1)
{
int rw = CornerstoneRoomPattern[0];
int rh = CornerstoneRoomPattern[1];
setpc_x = rx1;
setpc_y = ry1;
setpc_w = rw;
setpc_h = rh;
int sp = 2;
for (int j = 0; j < rh; j++) {
for (int i = 0; i < rw; i++) {
if (CornerstoneRoomPattern[sp] != 0) {
dungeon[rx1 + i][ry1 + j] = CornerstoneRoomPattern[sp];
L5dflags[rx1 + i][ry1 + j] |= DLRG_PROTECTED;
} else {
dungeon[rx1 + i][ry1 + j] = 13;
}
sp++;
}
}
}
static void DrlgL5FTransparencyValueR(int i, int j, int x, int y, int d)
{
if (dTransVal[x][y] != 0 || dungeon[i][j] != 13) {
if (d == 1) {
dTransVal[x][y] = TransVal;
dTransVal[x][y + 1] = TransVal;
if (dTransVal[x][y] != 0 || dungeon[i][j] != 13) {
if (d == 1) {
dTransVal[x][y] = TransVal;
dTransVal[x][y + 1] = TransVal;
}
if (d == 2) {
dTransVal[x + 1][y] = TransVal;
@ -2251,6 +2095,129 @@ static void DrlgL5CornerFix()
}
}
void drlg_l1_crypt_pattern1(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern97, rndper);
drlg_l1_crypt_rndset(CryptPattern98, rndper);
drlg_l1_crypt_rndset(CryptPattern99, rndper);
drlg_l1_crypt_rndset(CryptPattern100, rndper);
}
void drlg_l1_crypt_pattern2(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern46, rndper);
drlg_l1_crypt_rndset(CryptPattern47, rndper);
drlg_l1_crypt_rndset(CryptPattern48, rndper);
drlg_l1_crypt_rndset(CryptPattern49, rndper);
drlg_l1_crypt_rndset(CryptPattern50, rndper);
drlg_l1_crypt_rndset(CryptPattern51, rndper);
drlg_l1_crypt_rndset(CryptPattern52, rndper);
drlg_l1_crypt_rndset(CryptPattern53, rndper);
drlg_l1_crypt_rndset(CryptPattern54, rndper);
drlg_l1_crypt_rndset(CryptPattern55, rndper);
drlg_l1_crypt_rndset(CryptPattern56, rndper);
drlg_l1_crypt_rndset(CryptPattern57, rndper);
drlg_l1_crypt_rndset(CryptPattern58, rndper);
drlg_l1_crypt_rndset(CryptPattern59, rndper);
drlg_l1_crypt_rndset(CryptPattern60, rndper);
drlg_l1_crypt_rndset(CryptPattern61, rndper);
drlg_l1_crypt_rndset(CryptPattern62, rndper);
}
void drlg_l1_crypt_pattern3(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern63, rndper);
drlg_l1_crypt_rndset(CryptPattern64, rndper);
drlg_l1_crypt_rndset(CryptPattern65, rndper);
drlg_l1_crypt_rndset(CryptPattern66, rndper);
drlg_l1_crypt_rndset(CryptPattern67, rndper);
drlg_l1_crypt_rndset(CryptPattern68, rndper);
drlg_l1_crypt_rndset(CryptPattern69, rndper);
drlg_l1_crypt_rndset(CryptPattern70, rndper);
drlg_l1_crypt_rndset(CryptPattern71, rndper);
drlg_l1_crypt_rndset(CryptPattern72, rndper);
drlg_l1_crypt_rndset(CryptPattern73, rndper);
drlg_l1_crypt_rndset(CryptPattern74, rndper);
drlg_l1_crypt_rndset(CryptPattern75, rndper);
drlg_l1_crypt_rndset(CryptPattern76, rndper);
drlg_l1_crypt_rndset(CryptPattern77, rndper);
drlg_l1_crypt_rndset(CryptPattern78, rndper);
drlg_l1_crypt_rndset(CryptPattern79, rndper);
}
void drlg_l1_crypt_pattern4(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern80, rndper);
drlg_l1_crypt_rndset(CryptPattern81, rndper);
drlg_l1_crypt_rndset(CryptPattern82, rndper);
drlg_l1_crypt_rndset(CryptPattern83, rndper);
drlg_l1_crypt_rndset(CryptPattern84, rndper);
drlg_l1_crypt_rndset(CryptPattern85, rndper);
drlg_l1_crypt_rndset(CryptPattern86, rndper);
drlg_l1_crypt_rndset(CryptPattern87, rndper);
drlg_l1_crypt_rndset(CryptPattern88, rndper);
drlg_l1_crypt_rndset(CryptPattern89, rndper);
drlg_l1_crypt_rndset(CryptPattern90, rndper);
drlg_l1_crypt_rndset(CryptPattern91, rndper);
drlg_l1_crypt_rndset(CryptPattern92, rndper);
drlg_l1_crypt_rndset(CryptPattern93, rndper);
drlg_l1_crypt_rndset(CryptPattern94, rndper);
drlg_l1_crypt_rndset(CryptPattern95, rndper);
drlg_l1_crypt_rndset(CryptPattern96, rndper);
}
void drlg_l1_crypt_pattern5(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern36, rndper);
drlg_l1_crypt_rndset(CryptPattern37, rndper);
drlg_l1_crypt_rndset(CryptPattern38, rndper);
drlg_l1_crypt_rndset(CryptPattern39, rndper);
drlg_l1_crypt_rndset(CryptPattern40, rndper);
drlg_l1_crypt_rndset(CryptPattern41, rndper);
drlg_l1_crypt_rndset(CryptPattern42, rndper);
drlg_l1_crypt_rndset(CryptPattern43, rndper);
drlg_l1_crypt_rndset(CryptPattern44, rndper);
drlg_l1_crypt_rndset(CryptPattern45, rndper);
}
void drlg_l1_crypt_pattern6(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern10, rndper);
drlg_l1_crypt_rndset(CryptPattern12, rndper);
drlg_l1_crypt_rndset(CryptPattern11, rndper);
drlg_l1_crypt_rndset(CryptPattern13, rndper);
drlg_l1_crypt_rndset(CryptPattern14, rndper);
drlg_l1_crypt_rndset(CryptPattern15, rndper);
drlg_l1_crypt_rndset(CryptPattern16, rndper);
drlg_l1_crypt_rndset(CryptPattern17, rndper);
drlg_l1_crypt_rndset(CryptPattern18, rndper);
drlg_l1_crypt_rndset(CryptPattern19, rndper);
drlg_l1_crypt_rndset(CryptPattern20, rndper);
drlg_l1_crypt_rndset(CryptPattern21, rndper);
drlg_l1_crypt_rndset(CryptPattern22, rndper);
drlg_l1_crypt_rndset(CryptPattern23, rndper);
drlg_l1_crypt_rndset(CryptPattern24, rndper);
drlg_l1_crypt_rndset(CryptPattern25, rndper);
drlg_l1_crypt_rndset(CryptPattern26, rndper);
drlg_l1_crypt_rndset(CryptPattern27, rndper);
drlg_l1_crypt_rndset(CryptPattern28, rndper);
drlg_l1_crypt_rndset(CryptPattern29, rndper);
drlg_l1_crypt_rndset(CryptPattern30, rndper);
drlg_l1_crypt_rndset(CryptPattern31, rndper);
drlg_l1_crypt_rndset(CryptPattern32, rndper);
drlg_l1_crypt_rndset(CryptPattern33, rndper);
drlg_l1_crypt_rndset(CryptPattern34, rndper);
drlg_l1_crypt_rndset(CryptPattern35, rndper);
}
void drlg_l1_crypt_pattern7(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern5, rndper);
drlg_l1_crypt_rndset(CryptPattern6, rndper);
drlg_l1_crypt_rndset(CryptPattern7, rndper);
drlg_l1_crypt_rndset(CryptPattern8, rndper);
}
static void DrlgL5(lvl_entry entry)
{
int minarea = 761;
@ -2476,6 +2443,162 @@ static void DrlgL5(lvl_entry entry)
DRLG_CheckQuests(setpc_x, setpc_y);
}
} // namespace
void DRLG_LPass3(int lv)
{
{
MegaTile mega = pMegaTiles[lv];
int v1 = SDL_SwapLE16(mega.micro1) + 1;
int v2 = SDL_SwapLE16(mega.micro2) + 1;
int v3 = SDL_SwapLE16(mega.micro3) + 1;
int v4 = SDL_SwapLE16(mega.micro4) + 1;
for (int j = 0; j < MAXDUNY; j += 2) {
for (int i = 0; i < MAXDUNX; i += 2) {
dPiece[i + 0][j + 0] = v1;
dPiece[i + 1][j + 0] = v2;
dPiece[i + 0][j + 1] = v3;
dPiece[i + 1][j + 1] = v4;
}
}
}
int yy = 16;
for (int j = 0; j < DMAXY; j++) {
int xx = 16;
for (int i = 0; i < DMAXX; i++) { // NOLINT(modernize-loop-convert)
int v1 = 0;
int v2 = 0;
int v3 = 0;
int v4 = 0;
int tileId = dungeon[i][j] - 1;
if (tileId >= 0) {
MegaTile mega = pMegaTiles[tileId];
v1 = SDL_SwapLE16(mega.micro1) + 1;
v2 = SDL_SwapLE16(mega.micro2) + 1;
v3 = SDL_SwapLE16(mega.micro3) + 1;
v4 = SDL_SwapLE16(mega.micro4) + 1;
}
dPiece[xx + 0][yy + 0] = v1;
dPiece[xx + 1][yy + 0] = v2;
dPiece[xx + 0][yy + 1] = v3;
dPiece[xx + 1][yy + 1] = v4;
xx += 2;
}
yy += 2;
}
}
void DRLG_Init_Globals()
{
memset(dFlags, 0, sizeof(dFlags));
memset(dPlayer, 0, sizeof(dPlayer));
memset(dMonster, 0, sizeof(dMonster));
memset(dDead, 0, sizeof(dDead));
memset(dObject, 0, sizeof(dObject));
memset(dItem, 0, sizeof(dItem));
memset(dMissile, 0, sizeof(dMissile));
memset(dSpecial, 0, sizeof(dSpecial));
int8_t c = DisableLighting ? 0 : 15;
memset(dLight, c, sizeof(dLight));
}
void LoadL1Dungeon(const char *path, int vx, int vy)
{
dminx = 16;
dminy = 16;
dmaxx = 96;
dmaxy = 96;
DRLG_InitTrans();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 22;
L5dflags[i][j] = 0;
}
}
auto dunData = LoadFileInMem<uint16_t>(path);
int width = SDL_SwapLE16(dunData[0]);
int height = SDL_SwapLE16(dunData[1]);
const uint16_t *tileLayer = &dunData[2];
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
uint8_t tileId = SDL_SwapLE16(*tileLayer);
tileLayer++;
if (tileId != 0) {
dungeon[i][j] = tileId;
L5dflags[i][j] |= DLRG_PROTECTED;
} else {
dungeon[i][j] = 13;
}
}
}
DrlgL1Floor();
ViewX = vx;
ViewY = vy;
DrlgL1Pass3();
DRLG_Init_Globals();
if (currlevel < 17)
DrlgInitL1Vals();
SetMapMonsters(dunData.get(), { 0, 0 });
SetMapObjects(dunData.get(), 0, 0);
}
void LoadPreL1Dungeon(const char *path)
{
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
dungeon[i][j] = 22;
L5dflags[i][j] = 0;
}
}
dminx = 16;
dminy = 16;
dmaxx = 96;
dmaxy = 96;
auto dunData = LoadFileInMem<uint16_t>(path);
int width = SDL_SwapLE16(dunData[0]);
int height = SDL_SwapLE16(dunData[1]);
const uint16_t *tileLayer = &dunData[2];
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
uint8_t tileId = SDL_SwapLE16(*tileLayer);
tileLayer++;
if (tileId != 0) {
dungeon[i][j] = tileId;
L5dflags[i][j] |= DLRG_PROTECTED;
} else {
dungeon[i][j] = 13;
}
}
}
DrlgL1Floor();
for (int j = 0; j < DMAXY; j++) {
for (int i = 0; i < DMAXX; i++) {
pdungeon[i][j] = dungeon[i][j];
}
}
}
void CreateL5Dungeon(uint32_t rseed, lvl_entry entry)
{
SetRndSeed(rseed);
@ -2518,127 +2641,4 @@ void CreateL5Dungeon(uint32_t rseed, lvl_entry entry)
}
}
void drlg_l1_crypt_pattern1(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern97, rndper);
drlg_l1_crypt_rndset(CryptPattern98, rndper);
drlg_l1_crypt_rndset(CryptPattern99, rndper);
drlg_l1_crypt_rndset(CryptPattern100, rndper);
}
void drlg_l1_crypt_pattern2(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern46, rndper);
drlg_l1_crypt_rndset(CryptPattern47, rndper);
drlg_l1_crypt_rndset(CryptPattern48, rndper);
drlg_l1_crypt_rndset(CryptPattern49, rndper);
drlg_l1_crypt_rndset(CryptPattern50, rndper);
drlg_l1_crypt_rndset(CryptPattern51, rndper);
drlg_l1_crypt_rndset(CryptPattern52, rndper);
drlg_l1_crypt_rndset(CryptPattern53, rndper);
drlg_l1_crypt_rndset(CryptPattern54, rndper);
drlg_l1_crypt_rndset(CryptPattern55, rndper);
drlg_l1_crypt_rndset(CryptPattern56, rndper);
drlg_l1_crypt_rndset(CryptPattern57, rndper);
drlg_l1_crypt_rndset(CryptPattern58, rndper);
drlg_l1_crypt_rndset(CryptPattern59, rndper);
drlg_l1_crypt_rndset(CryptPattern60, rndper);
drlg_l1_crypt_rndset(CryptPattern61, rndper);
drlg_l1_crypt_rndset(CryptPattern62, rndper);
}
void drlg_l1_crypt_pattern3(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern63, rndper);
drlg_l1_crypt_rndset(CryptPattern64, rndper);
drlg_l1_crypt_rndset(CryptPattern65, rndper);
drlg_l1_crypt_rndset(CryptPattern66, rndper);
drlg_l1_crypt_rndset(CryptPattern67, rndper);
drlg_l1_crypt_rndset(CryptPattern68, rndper);
drlg_l1_crypt_rndset(CryptPattern69, rndper);
drlg_l1_crypt_rndset(CryptPattern70, rndper);
drlg_l1_crypt_rndset(CryptPattern71, rndper);
drlg_l1_crypt_rndset(CryptPattern72, rndper);
drlg_l1_crypt_rndset(CryptPattern73, rndper);
drlg_l1_crypt_rndset(CryptPattern74, rndper);
drlg_l1_crypt_rndset(CryptPattern75, rndper);
drlg_l1_crypt_rndset(CryptPattern76, rndper);
drlg_l1_crypt_rndset(CryptPattern77, rndper);
drlg_l1_crypt_rndset(CryptPattern78, rndper);
drlg_l1_crypt_rndset(CryptPattern79, rndper);
}
void drlg_l1_crypt_pattern4(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern80, rndper);
drlg_l1_crypt_rndset(CryptPattern81, rndper);
drlg_l1_crypt_rndset(CryptPattern82, rndper);
drlg_l1_crypt_rndset(CryptPattern83, rndper);
drlg_l1_crypt_rndset(CryptPattern84, rndper);
drlg_l1_crypt_rndset(CryptPattern85, rndper);
drlg_l1_crypt_rndset(CryptPattern86, rndper);
drlg_l1_crypt_rndset(CryptPattern87, rndper);
drlg_l1_crypt_rndset(CryptPattern88, rndper);
drlg_l1_crypt_rndset(CryptPattern89, rndper);
drlg_l1_crypt_rndset(CryptPattern90, rndper);
drlg_l1_crypt_rndset(CryptPattern91, rndper);
drlg_l1_crypt_rndset(CryptPattern92, rndper);
drlg_l1_crypt_rndset(CryptPattern93, rndper);
drlg_l1_crypt_rndset(CryptPattern94, rndper);
drlg_l1_crypt_rndset(CryptPattern95, rndper);
drlg_l1_crypt_rndset(CryptPattern96, rndper);
}
void drlg_l1_crypt_pattern5(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern36, rndper);
drlg_l1_crypt_rndset(CryptPattern37, rndper);
drlg_l1_crypt_rndset(CryptPattern38, rndper);
drlg_l1_crypt_rndset(CryptPattern39, rndper);
drlg_l1_crypt_rndset(CryptPattern40, rndper);
drlg_l1_crypt_rndset(CryptPattern41, rndper);
drlg_l1_crypt_rndset(CryptPattern42, rndper);
drlg_l1_crypt_rndset(CryptPattern43, rndper);
drlg_l1_crypt_rndset(CryptPattern44, rndper);
drlg_l1_crypt_rndset(CryptPattern45, rndper);
}
void drlg_l1_crypt_pattern6(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern10, rndper);
drlg_l1_crypt_rndset(CryptPattern12, rndper);
drlg_l1_crypt_rndset(CryptPattern11, rndper);
drlg_l1_crypt_rndset(CryptPattern13, rndper);
drlg_l1_crypt_rndset(CryptPattern14, rndper);
drlg_l1_crypt_rndset(CryptPattern15, rndper);
drlg_l1_crypt_rndset(CryptPattern16, rndper);
drlg_l1_crypt_rndset(CryptPattern17, rndper);
drlg_l1_crypt_rndset(CryptPattern18, rndper);
drlg_l1_crypt_rndset(CryptPattern19, rndper);
drlg_l1_crypt_rndset(CryptPattern20, rndper);
drlg_l1_crypt_rndset(CryptPattern21, rndper);
drlg_l1_crypt_rndset(CryptPattern22, rndper);
drlg_l1_crypt_rndset(CryptPattern23, rndper);
drlg_l1_crypt_rndset(CryptPattern24, rndper);
drlg_l1_crypt_rndset(CryptPattern25, rndper);
drlg_l1_crypt_rndset(CryptPattern26, rndper);
drlg_l1_crypt_rndset(CryptPattern27, rndper);
drlg_l1_crypt_rndset(CryptPattern28, rndper);
drlg_l1_crypt_rndset(CryptPattern29, rndper);
drlg_l1_crypt_rndset(CryptPattern30, rndper);
drlg_l1_crypt_rndset(CryptPattern31, rndper);
drlg_l1_crypt_rndset(CryptPattern32, rndper);
drlg_l1_crypt_rndset(CryptPattern33, rndper);
drlg_l1_crypt_rndset(CryptPattern34, rndper);
drlg_l1_crypt_rndset(CryptPattern35, rndper);
}
void drlg_l1_crypt_pattern7(int rndper)
{
drlg_l1_crypt_rndset(CryptPattern5, rndper);
drlg_l1_crypt_rndset(CryptPattern6, rndper);
drlg_l1_crypt_rndset(CryptPattern7, rndper);
drlg_l1_crypt_rndset(CryptPattern8, rndper);
}
} // namespace devilution

9
Source/drlg_l1.h

@ -22,14 +22,5 @@ void DRLG_Init_Globals();
void LoadL1Dungeon(const char *path, int vx, int vy);
void LoadPreL1Dungeon(const char *path);
void CreateL5Dungeon(uint32_t rseed, lvl_entry entry);
void drlg_l1_set_crypt_room(int rx1, int ry1);
void drlg_l1_set_corner_room(int rx1, int ry1);
void drlg_l1_crypt_pattern1(int rndper);
void drlg_l1_crypt_pattern2(int rndper);
void drlg_l1_crypt_pattern3(int rndper);
void drlg_l1_crypt_pattern4(int rndper);
void drlg_l1_crypt_pattern5(int rndper);
void drlg_l1_crypt_pattern6(int rndper);
void drlg_l1_crypt_pattern7(int rndper);
} // namespace devilution

Loading…
Cancel
Save