From f450d6a125966ef12ecc0aa8bcb23627768a74ba Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 14 Apr 2021 21:39:21 +0200 Subject: [PATCH] :truck: Move defines to there proper files --- Source/appfat.h | 16 ++- Source/automap.cpp | 8 +- Source/automap.h | 1 + Source/control.cpp | 6 +- Source/control.h | 12 ++ Source/dead.h | 2 + Source/diablo.cpp | 8 ++ Source/diablo.h | 12 +- Source/effects.cpp | 1 + Source/encrypt.cpp | 4 +- Source/engine.h | 12 +- Source/error.cpp | 2 + Source/gamemenu.cpp | 1 + Source/gendung.h | 9 ++ Source/gmenu.h | 3 + Source/interfac.h | 2 + Source/inv.h | 5 +- Source/items.cpp | 2 + Source/items.h | 13 +- Source/lighting.h | 7 +- Source/loadsave.cpp | 4 + Source/missiles.h | 2 + Source/monster.cpp | 9 +- Source/monster.h | 5 + Source/mpqapi.cpp | 4 +- Source/msg.cpp | 7 +- Source/msg.h | 6 + Source/multi.cpp | 1 + Source/multi.h | 3 + Source/objects.cpp | 3 + Source/objects.h | 5 +- Source/pack.cpp | 66 +++++----- Source/pack.h | 1 + Source/palette.h | 20 +++ Source/path.cpp | 3 + Source/path.h | 2 + Source/pfile.h | 2 + Source/player.cpp | 2 + Source/player.h | 17 ++- Source/plrmsg.cpp | 2 + Source/portal.h | 2 + Source/quests.cpp | 1 + Source/quests.h | 2 + Source/render.cpp | 4 +- Source/render.h | 8 ++ Source/scrollrt.h | 2 + Source/sha.cpp | 4 +- Source/sound.h | 3 + Source/spelldat.h | 2 + Source/stores.h | 5 + Source/towners.h | 4 + Source/trigs.h | 2 + SourceS/console.h | 2 +- SourceS/miniwin/misc.h | 20 +++ SourceS/sdl2_to_1_2_backports.h | 1 - SourceX/controls/touch.cpp | 1 - defs.h | 212 -------------------------------- types.h | 1 - 58 files changed, 282 insertions(+), 284 deletions(-) delete mode 100644 defs.h diff --git a/Source/appfat.h b/Source/appfat.h index 72a721f9f..513fc67e5 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -7,10 +7,22 @@ #include -#include "../defs.h" - namespace devilution { +#define ErrSdl() ErrDlg("SDL Error", SDL_GetError(), __FILE__, __LINE__) + +#undef assert + +#ifndef _DEBUG +#define assert(exp) +#define assurance(exp, value) if (!(exp)) return +#define commitment(exp, value) if (!(exp)) return false +#else +#define assert(exp) (void)((exp) || (assert_fail(__LINE__, __FILE__, #exp), 0)) +#define assurance(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0)) +#define commitment(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0)) +#endif + [[noreturn]] void app_fatal(const char *pszFmt, ...) DVL_PRINTF_ATTRIBUTE(1, 2); void DrawDlg(const char *pszFmt, ...) DVL_PRINTF_ATTRIBUTE(1, 2); #ifdef _DEBUG diff --git a/Source/automap.cpp b/Source/automap.cpp index 0b5afb34e..d11b5991e 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -3,7 +3,13 @@ * * Implementation of the in-game map overlay. */ -#include "all.h" +#include "automap.h" +#include "control.h" +#include "player.h" +#include "palette.h" +#include "inv.h" +#include "monster.h" +#include "setmaps.h" namespace devilution { diff --git a/Source/automap.h b/Source/automap.h index 3d0425fa2..c46cbd12f 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -6,6 +6,7 @@ #pragma once #include "engine.h" +#include "gendung.h" namespace devilution { diff --git a/Source/control.cpp b/Source/control.cpp index 613781100..ac9b50791 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1681,9 +1681,9 @@ void ReleaseChrBtns(bool addAllStatPoints) chrbtn[static_cast(i)] = false; if (MouseX >= ChrBtnsRect[static_cast(i)].x - && MouseX <= ChrBtnsRect[static_cast(i)].x + ChrBtnsRect[static_cast(i)].w - && MouseY >= ChrBtnsRect[static_cast(i)].y - && MouseY <= ChrBtnsRect[static_cast(i)].y + ChrBtnsRect[static_cast(i)].h) { + && MouseX <= ChrBtnsRect[static_cast(i)].x + ChrBtnsRect[static_cast(i)].w + && MouseY >= ChrBtnsRect[static_cast(i)].y + && MouseY <= ChrBtnsRect[static_cast(i)].y + ChrBtnsRect[static_cast(i)].h) { PlayerStruct &player = plr[myplr]; int statPointsToAdd = 1; if (addAllStatPoints) diff --git a/Source/control.h b/Source/control.h index 299104d32..8cc4828cb 100644 --- a/Source/control.h +++ b/Source/control.h @@ -13,6 +13,18 @@ namespace devilution { +#define PANEL_WIDTH 640 +#define PANEL_HEIGHT 128 +#define PANEL_TOP (gnScreenHeight - PANEL_HEIGHT) +#define PANEL_LEFT (gnScreenWidth - PANEL_WIDTH) / 2 +#define PANEL_X PANEL_LEFT +#define PANEL_Y PANEL_TOP + +#define SPANEL_WIDTH 320 +#define SPANEL_HEIGHT 352 +#define RIGHT_PANEL (gnScreenWidth - SPANEL_WIDTH) +#define RIGHT_PANEL_X RIGHT_PANEL + enum text_color : uint8_t { COL_WHITE, COL_BLUE, diff --git a/Source/dead.h b/Source/dead.h index 231337923..13fcf7e2f 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -7,6 +7,8 @@ namespace devilution { +#define MAXDEAD 31 + struct DeadStruct { Uint8 *_deadData[8]; int _deadFrame; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index a44324cc8..e12805b96 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -8,12 +8,20 @@ #include "console.h" #include "options.h" #include "multi.h" +#include "sound.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" #include namespace devilution { +#ifndef DEFAULT_WIDTH +#define DEFAULT_WIDTH 640 +#endif +#ifndef DEFAULT_HEIGHT +#define DEFAULT_HEIGHT 480 +#endif + SDL_Window *ghMainWnd; DWORD glSeedTbl[NUMLEVELS]; dungeon_type gnLevelTypeTbl[NUMLEVELS]; diff --git a/Source/diablo.h b/Source/diablo.h index 9d4b40fc2..b87850685 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -7,7 +7,6 @@ #include -#include "pack.h" #include "gendung.h" #ifdef _DEBUG #include "monstdat.h" @@ -15,19 +14,16 @@ namespace devilution { +#define GAME_ID (gbIsHellfire ? (gbIsSpawn ? LOAD_BE32("HSHR") : LOAD_BE32("HRTL")) : (gbIsSpawn ? LOAD_BE32("DSHR") : LOAD_BE32("DRTL"))) + +#define NUMLEVELS 25 + enum clicktype : int8_t { CLICK_NONE, CLICK_LEFT, CLICK_RIGHT, }; -#ifndef DEFAULT_WIDTH -#define DEFAULT_WIDTH 640 -#endif -#ifndef DEFAULT_HEIGHT -#define DEFAULT_HEIGHT 480 -#endif - extern SDL_Window *ghMainWnd; extern DWORD glSeedTbl[NUMLEVELS]; extern dungeon_type gnLevelTypeTbl[NUMLEVELS]; diff --git a/Source/effects.cpp b/Source/effects.cpp index 332a68dde..fa0e070f2 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -4,6 +4,7 @@ * Implementation of functions for loading and playing sounds. */ #include "all.h" +#include "sound.h" #include namespace devilution { diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index c9dea99b6..9352baecf 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -16,7 +16,7 @@ void Decrypt(DWORD *castBlock, DWORD size, DWORD key) seed = 0xEEEEEEEE; for (i = 0; i < (size >> 2); i++) { - DWORD t = SwapLE32(*castBlock); + DWORD t = SDL_SwapLE32(*castBlock); seed += hashtable[4][(key & 0xFF)]; t ^= seed + key; *castBlock = t; @@ -35,7 +35,7 @@ void Encrypt(DWORD *castBlock, DWORD size, DWORD key) DWORD t = ch = *castBlock; seed += hashtable[4][(key & 0xFF)]; t ^= seed + key; - *castBlock = SwapLE32(t); + *castBlock = SDL_SwapLE32(t); castBlock++; seed += ch + (seed << 5) + 3; key = ((key << 0x15) ^ 0xFFE00000) + 0x11111111 | (key >> 0x0B); diff --git a/Source/engine.h b/Source/engine.h index eace519f3..baacd817f 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -27,6 +27,14 @@ namespace devilution { +#define MemFreeDbg(p) \ + { \ + void *p__p; \ + p__p = p; \ + p = NULL; \ + mem_free_dbg(p__p); \ + } + enum direction : uint8_t { DIR_S, DIR_SW, @@ -63,7 +71,7 @@ inline BYTE *CelGetFrameStart(BYTE *pCelBuff, int nCel) pFrameTable = (DWORD *)pCelBuff; - return pCelBuff + SwapLE32(pFrameTable[nCel]); + return pCelBuff + SDL_SwapLE32(pFrameTable[nCel]); } #define LOAD_LE32(b) (((DWORD)(b)[3] << 24) | ((DWORD)(b)[2] << 16) | ((DWORD)(b)[1] << 8) | (DWORD)(b)[0]) @@ -452,4 +460,4 @@ DWORD LoadFileWithMem(const char *pszName, BYTE *p); void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel); void PlayInGameMovie(const char *pszMovie); -} +} // namespace devilution diff --git a/Source/error.cpp b/Source/error.cpp index 252bda029..3394d6a01 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -101,6 +101,8 @@ void ClrDiabloMsg() msgcnt = 0; } +#define DIALOG_Y ((gnScreenHeight - PANEL_HEIGHT) / 2 - 18) + void DrawDiabloMsg(CelOutputBuffer out) { int i, len, width, sx, sy; diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 66ae9a8b5..1e7310126 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -6,6 +6,7 @@ */ #include "all.h" #include "options.h" +#include "sound.h" namespace devilution { diff --git a/Source/gendung.h b/Source/gendung.h index efd94260d..cc82f2aed 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -11,6 +11,15 @@ namespace devilution { +#define DMAXX 40 +#define DMAXY 40 + +#define MAXDUNX (16 + DMAXX * 2 + 16) +#define MAXDUNY (16 + DMAXY * 2 + 16) + +#define MAXTHEMES 50 +#define MAXTILES 2048 + enum _setlevels : int8_t { SL_NONE, SL_SKELKING, diff --git a/Source/gmenu.h b/Source/gmenu.h index 1e2bd7f0b..734030828 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -9,6 +9,9 @@ namespace devilution { +#define GMENU_SLIDER 0x40000000 +#define GMENU_ENABLED 0x80000000 + struct TMenuItem { Uint32 dwFlags; const char *pszStr; diff --git a/Source/interfac.h b/Source/interfac.h index 7e9ee0b7d..018c68cfb 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -9,6 +9,8 @@ namespace devilution { +#define UI_OFFSET_Y ((Sint16)((gnScreenHeight - 480) / 2)) + enum interface_mode : uint16_t { // clang-format off WM_DIABNEXTLVL = 0x402, // WM_USER+2 diff --git a/Source/inv.h b/Source/inv.h index 640ba804e..b71465936 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -8,10 +8,13 @@ #include #include "items.h" +#include "palette.h" #include "player.h" namespace devilution { +#define INV_SLOT_SIZE_PX 28 + enum inv_item : int8_t { // clang-format off INVITEM_HEAD = 0, @@ -127,4 +130,4 @@ bool DropItemBeforeTrig(); extern int AP2x2Tbl[10]; -} +} // namespace devilution diff --git a/Source/items.cpp b/Source/items.cpp index cc46a7822..be51b5b2a 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -11,6 +11,8 @@ namespace devilution { +#define ITEMTYPES 43 + enum anim_armor_id : uint8_t { // clang-format off ANIM_ID_LIGHT_ARMOR = 0, diff --git a/Source/items.h b/Source/items.h index d97c68632..9a61840c4 100644 --- a/Source/items.h +++ b/Source/items.h @@ -11,6 +11,15 @@ namespace devilution { +#define MAXITEMS 127 + +#define GOLD_SMALL_LIMIT 1000 +#define GOLD_MEDIUM_LIMIT 2500 +#define GOLD_MAX_LIMIT 5000 + +// Item indestructible durability +#define DUR_INDESTRUCTIBLE 255 + enum item_quality : uint8_t { ITEM_QUALITY_NORMAL, ITEM_QUALITY_MAGIC, @@ -159,7 +168,7 @@ struct ItemStruct { Sint16 _ix; Sint16 _iy; bool _iAnimFlag; - Uint8 *_iAnimData; // PSX name -> ItemFrame + Uint8 *_iAnimData; // PSX name -> ItemFrame Uint8 _iAnimLen; // Number of frames in current animation Uint8 _iAnimFrame; // Current frame of animation. Sint32 _iAnimWidth; @@ -439,4 +448,4 @@ extern int MaxGold; extern BYTE ItemCAnimTbl[]; extern _sfx_id ItemInvSnds[]; -} +} // namespace devilution diff --git a/Source/lighting.h b/Source/lighting.h index b6079d979..c050d6667 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -7,6 +7,11 @@ namespace devilution { +#define MAXLIGHTS 32 +#define MAXVISION 32 +#define LIGHTSIZE (27 * 256) +#define NO_LIGHT -1 + struct LightListStruct { int _lx; int _ly; @@ -64,4 +69,4 @@ void lighting_color_cycling(); extern const char CrawlTable[2749]; extern const BYTE vCrawlTable[23][30]; -} +} // namespace devilution diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index bbfbe1bc2..e16ef2f6b 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1749,6 +1749,10 @@ void SaveHeroItems(PlayerStruct *pPlayer) SaveItems(&file, pPlayer->SpdList, MAXBELTITEMS); } +// 256 kilobytes + 3 bytes (demo leftover) for file magic (262147) +// final game uses 4-byte magic instead of 3 +#define FILEBUFF ((256 * 1024) + 3) + void SaveGameData() { SaveHelper file("game", FILEBUFF); diff --git a/Source/missiles.h b/Source/missiles.h index 8cda678d7..d6e10b22b 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -11,6 +11,8 @@ namespace devilution { +#define MAXMISSILES 125 + struct ChainStruct { Sint32 idx; Sint32 _mitype; diff --git a/Source/monster.cpp b/Source/monster.cpp index d8c467950..a38b416a2 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -11,6 +11,12 @@ namespace devilution { +#define NIGHTMARE_TO_HIT_BONUS 85 +#define HELL_TO_HIT_BONUS 120 + +#define NIGHTMARE_AC_BONUS 50 +#define HELL_AC_BONUS 80 + /** Tracks which missile files are already loaded */ int MissileFileFlag; @@ -2895,8 +2901,7 @@ bool M_CallWalk(int i, int md) bool M_PathWalk(int i) { Sint8 path[MAX_PATH_LENGTH]; - bool(*Check) - (int, int, int); + bool (*Check)(int, int, int); /** Maps from walking path step to facing direction. */ const Sint8 plr2monst[9] = { 0, 5, 3, 7, 1, 4, 6, 0, 2 }; diff --git a/Source/monster.h b/Source/monster.h index 39eb10c53..cdf1fefba 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -7,8 +7,13 @@ #include +#include "monstdat.h" + namespace devilution { +#define MAXMONSTERS 200 +#define MAX_LVLMTYPES 24 + enum monster_flag : uint16_t { // clang-format off MFLAG_HIDDEN = 1 << 0, diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 8e882bd21..d57c4b6e5 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -584,7 +584,7 @@ static bool mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, len = PkwareCompress(mpq_buf, len); if (!cur_archive.stream.write((char *)mpq_buf, len)) return false; - sectoroffsettable[cur_sector++] = SwapLE32(destsize); + sectoroffsettable[cur_sector++] = SDL_SwapLE32(destsize); destsize += len; // compressed length if (dwLen > kSectorSize) dwLen -= kSectorSize; @@ -592,7 +592,7 @@ static bool mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, break; } - sectoroffsettable[num_sectors] = SwapLE32(destsize); + sectoroffsettable[num_sectors] = SDL_SwapLE32(destsize); if (!cur_archive.stream.seekp(pBlk->offset, std::ios::beg)) return false; if (!cur_archive.stream.write(reinterpret_cast(sectoroffsettable.get()), offset_table_bytesize)) diff --git a/Source/msg.cpp b/Source/msg.cpp index 919bdad8b..5e1d78d99 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -6,10 +6,13 @@ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" +#include "objects.h" #include "options.h" namespace devilution { +#define MAX_CHUNKS (NUMLEVELS + 4) + static DWORD sgdwOwnerWait; static DWORD sgdwRecvOffset; static int sgnCurrMegaPlayer; @@ -859,7 +862,7 @@ void NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, BYTE cl) void NetSendCmdLoc(int playerId, bool bHiPri, _cmd_id bCmd, BYTE x, BYTE y) { - ALIGN_BY_1 TCmdLoc cmd; + TCmdLoc cmd; cmd.bCmd = bCmd; cmd.x = x; @@ -917,7 +920,7 @@ void NetSendCmdLocParam3(bool bHiPri, _cmd_id bCmd, BYTE x, BYTE y, WORD wParam1 void NetSendCmdParam1(bool bHiPri, _cmd_id bCmd, WORD wParam1) { - ALIGN_BY_1 TCmdParam1 cmd; + TCmdParam1 cmd; cmd.bCmd = bCmd; cmd.wParam1 = wParam1; diff --git a/Source/msg.h b/Source/msg.h index 0af67b958..55447a862 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -8,9 +8,15 @@ #include #include "quests.h" +#include "objects.h" +#include "monster.h" +#include "portal.h" namespace devilution { +#define MAX_SEND_STR_LEN 80 +#define MAXMULTIQUESTS 10 + enum _cmd_id : uint8_t { CMD_STAND, CMD_WALKXY, diff --git a/Source/multi.cpp b/Source/multi.cpp index d90bfa0e3..26e0eba17 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -4,6 +4,7 @@ * Implementation of functions for keeping multiplaye games in sync. */ #include "all.h" +#include "diablo.h" #include "options.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/multi.h b/Source/multi.h index b92987265..8b37fceb7 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -11,6 +11,9 @@ namespace devilution { +// must be unsigned to generate unsigned comparisons with pnum +#define MAX_PLRS 4 + enum event_type : uint8_t { EVENT_TYPE_PLAYER_CREATE_GAME, EVENT_TYPE_PLAYER_LEAVE_GAME, diff --git a/Source/objects.cpp b/Source/objects.cpp index 573e9c96d..0e6a5d8ef 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -141,6 +141,9 @@ char shrinemin[] = { 1, // Solar, 1, // Murphy's }; + +#define MAX_LVLS 24 + /** Specifies the maximum dungeon level on which each shrine will appear. */ char shrinemax[] = { MAX_LVLS, // Mysterious diff --git a/Source/objects.h b/Source/objects.h index b0fedab97..c5848fa2f 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -5,10 +5,13 @@ */ #pragma once +#include "objdat.h" #include "textdat.h" namespace devilution { +#define MAXOBJECTS 127 + struct ObjectStruct { _object_id _otype; Sint32 _ox; @@ -84,4 +87,4 @@ void objects_454BA8(); void objects_rnd_454BEA(); bool objects_lv_24_454B04(int s); -} +} // namespace devilution diff --git a/Source/pack.cpp b/Source/pack.cpp index ed65ef1c7..6e377c133 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -17,7 +17,7 @@ void PackItem(PkItemStruct *id, const ItemStruct *is) if (!gbIsHellfire) { idx = RemapItemIdxToDiablo(idx); } - id->idx = SwapLE16(idx); + id->idx = SDL_SwapLE16(idx); if (is->IDidx == IDI_EAR) { id->iCreateInfo = is->_iName[8] | (is->_iName[7] << 8); id->iSeed = LOAD_BE32(&is->_iName[9]); @@ -26,18 +26,18 @@ void PackItem(PkItemStruct *id, const ItemStruct *is) id->bMDur = is->_iName[15]; id->bCh = is->_iName[16]; id->bMCh = is->_iName[17]; - id->wValue = SwapLE16(is->_ivalue | (is->_iName[18] << 8) | ((is->_iCurs - ICURS_EAR_SORCERER) << 6)); + id->wValue = SDL_SwapLE16(is->_ivalue | (is->_iName[18] << 8) | ((is->_iCurs - ICURS_EAR_SORCERER) << 6)); id->dwBuff = LOAD_BE32(&is->_iName[19]); } else { - id->iSeed = SwapLE32(is->_iSeed); - id->iCreateInfo = SwapLE16(is->_iCreateInfo); + id->iSeed = SDL_SwapLE32(is->_iSeed); + id->iCreateInfo = SDL_SwapLE16(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 == IDI_GOLD) - id->wValue = SwapLE16(is->_ivalue); + id->wValue = SDL_SwapLE16(is->_ivalue); id->dwBuff = is->dwBuff; } } @@ -68,12 +68,12 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield) pPack->pBaseVit = pPlayer->_pBaseVit; pPack->pLevel = pPlayer->_pLevel; pPack->pStatPts = pPlayer->_pStatPts; - pPack->pExperience = SwapLE32(pPlayer->_pExperience); - pPack->pGold = SwapLE32(pPlayer->_pGold); - pPack->pHPBase = SwapLE32(pPlayer->_pHPBase); - pPack->pMaxHPBase = SwapLE32(pPlayer->_pMaxHPBase); - pPack->pManaBase = SwapLE32(pPlayer->_pManaBase); - pPack->pMaxManaBase = SwapLE32(pPlayer->_pMaxManaBase); + pPack->pExperience = SDL_SwapLE32(pPlayer->_pExperience); + pPack->pGold = SDL_SwapLE32(pPlayer->_pGold); + pPack->pHPBase = SDL_SwapLE32(pPlayer->_pHPBase); + pPack->pMaxHPBase = SDL_SwapLE32(pPlayer->_pMaxHPBase); + pPack->pManaBase = SDL_SwapLE32(pPlayer->_pManaBase); + pPack->pMaxManaBase = SDL_SwapLE32(pPlayer->_pMaxManaBase); pPack->pMemSpells = SDL_SwapLE64(pPlayer->_pMemSpells); for (i = 0; i < 37; i++) // Should be MAX_SPELLS but set to 37 to make save games compatible @@ -112,14 +112,14 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield) pi++; } - pPack->wReflections = SwapLE16(pPlayer->wReflections); - pPack->pDifficulty = SwapLE32(pPlayer->pDifficulty); - pPack->pDamAcFlags = SwapLE32(pPlayer->pDamAcFlags); - pPack->pDiabloKillLevel = SwapLE32(pPlayer->pDiabloKillLevel); + pPack->wReflections = SDL_SwapLE16(pPlayer->wReflections); + pPack->pDifficulty = SDL_SwapLE32(pPlayer->pDifficulty); + pPack->pDamAcFlags = SDL_SwapLE32(pPlayer->pDamAcFlags); + pPack->pDiabloKillLevel = SDL_SwapLE32(pPlayer->pDiabloKillLevel); pPack->bIsHellfire = gbIsHellfire; if (!gbIsMultiplayer || manashield) - pPack->pManaShield = SwapLE32(pPlayer->pManaShield); + pPack->pManaShield = SDL_SwapLE32(pPlayer->pManaShield); else pPack->pManaShield = false; } @@ -134,7 +134,7 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield) */ void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire) { - WORD idx = SwapLE16(is->idx); + WORD idx = SDL_SwapLE16(is->idx); if (idx == 0xFFFF) { id->_itype = ITYPE_NONE; return; @@ -152,18 +152,18 @@ void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire) if (idx == IDI_EAR) { RecreateEar( MAXITEMS, - SwapLE16(is->iCreateInfo), - SwapLE32(is->iSeed), + SDL_SwapLE16(is->iCreateInfo), + SDL_SwapLE32(is->iSeed), is->bId, is->bDur, is->bMDur, is->bCh, is->bMCh, - SwapLE16(is->wValue), - SwapLE32(is->dwBuff)); + SDL_SwapLE16(is->wValue), + SDL_SwapLE32(is->dwBuff)); } else { memset(&items[MAXITEMS], 0, sizeof(*items)); - RecreateItem(MAXITEMS, idx, SwapLE16(is->iCreateInfo), SwapLE32(is->iSeed), SwapLE16(is->wValue), isHellfire); + RecreateItem(MAXITEMS, idx, SDL_SwapLE16(is->iCreateInfo), SDL_SwapLE32(is->iSeed), SDL_SwapLE16(is->wValue), isHellfire); items[MAXITEMS]._iMagical = is->bId >> 1; items[MAXITEMS]._iIdentified = is->bId & 1; items[MAXITEMS]._iDurability = is->bDur; @@ -229,17 +229,17 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync) pPlayer->_pVitality = pPack->pBaseVit; pPlayer->_pLevel = pPack->pLevel; pPlayer->_pStatPts = pPack->pStatPts; - pPlayer->_pExperience = SwapLE32(pPack->pExperience); - pPlayer->_pGold = SwapLE32(pPack->pGold); - pPlayer->_pMaxHPBase = SwapLE32(pPack->pMaxHPBase); - pPlayer->_pHPBase = SwapLE32(pPack->pHPBase); + pPlayer->_pExperience = SDL_SwapLE32(pPack->pExperience); + pPlayer->_pGold = SDL_SwapLE32(pPack->pGold); + pPlayer->_pMaxHPBase = SDL_SwapLE32(pPack->pMaxHPBase); + pPlayer->_pHPBase = SDL_SwapLE32(pPack->pHPBase); pPlayer->_pBaseToBlk = ToBlkTbl[static_cast(pPlayer->_pClass)]; if (!netSync) if ((int)(pPlayer->_pHPBase & 0xFFFFFFC0) < 64) pPlayer->_pHPBase = 64; - pPlayer->_pMaxManaBase = SwapLE32(pPack->pMaxManaBase); - pPlayer->_pManaBase = SwapLE32(pPack->pManaBase); + pPlayer->_pMaxManaBase = SDL_SwapLE32(pPack->pMaxManaBase); + pPlayer->_pManaBase = SDL_SwapLE32(pPack->pManaBase); pPlayer->_pMemSpells = SDL_SwapLE64(pPack->pMemSpells); for (i = 0; i < 37; i++) // Should be MAX_SPELLS but set to 36 to make save games compatible @@ -289,16 +289,16 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync) } CalcPlrInv(pnum, false); - pPlayer->wReflections = SwapLE16(pPack->wReflections); + pPlayer->wReflections = SDL_SwapLE16(pPack->wReflections); pPlayer->pTownWarps = 0; pPlayer->pDungMsgs = 0; pPlayer->pDungMsgs2 = 0; pPlayer->pLvlLoad = 0; - pPlayer->pDiabloKillLevel = SwapLE32(pPack->pDiabloKillLevel); + pPlayer->pDiabloKillLevel = SDL_SwapLE32(pPack->pDiabloKillLevel); pPlayer->pBattleNet = pPack->pBattleNet; - pPlayer->pManaShield = SwapLE32(pPack->pManaShield); - pPlayer->pDifficulty = (_difficulty)SwapLE32(pPack->pDifficulty); - pPlayer->pDamAcFlags = SwapLE32(pPack->pDamAcFlags); + pPlayer->pManaShield = SDL_SwapLE32(pPack->pManaShield); + pPlayer->pDifficulty = (_difficulty)SDL_SwapLE32(pPack->pDifficulty); + pPlayer->pDamAcFlags = SDL_SwapLE32(pPack->pDamAcFlags); } } // namespace devilution diff --git a/Source/pack.h b/Source/pack.h index bc3b37ecb..de1bc3f23 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -5,6 +5,7 @@ */ #pragma once +#include "player.h" #include "inv.h" #include "items.h" diff --git a/Source/palette.h b/Source/palette.h index 55571ac19..33af2c22e 100644 --- a/Source/palette.h +++ b/Source/palette.h @@ -7,6 +7,26 @@ namespace devilution { +// Diablo uses a 256 color palette +// Entry 0-127 (0x00-0x7F) are level specific +// Entry 128-255 (0x80-0xFF) are global + +// standard palette for all levels +// 8 or 16 shades per color +// example (dark blue): PAL16_BLUE+14, PAL8_BLUE+7 +// example (light red): PAL16_RED+2, PAL8_RED +// example (orange): PAL16_ORANGE+8, PAL8_ORANGE+4 +#define PAL8_BLUE 128 +#define PAL8_RED 136 +#define PAL8_YELLOW 144 +#define PAL8_ORANGE 152 +#define PAL16_BEIGE 160 +#define PAL16_BLUE 176 +#define PAL16_YELLOW 192 +#define PAL16_ORANGE 208 +#define PAL16_RED 224 +#define PAL16_GRAY 240 + extern SDL_Color logical_palette[256]; extern SDL_Color system_palette[256]; extern SDL_Color orig_palette[256]; diff --git a/Source/path.cpp b/Source/path.cpp index 289a2ee49..1478c64fe 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -6,6 +6,9 @@ #include "all.h" namespace devilution { + +#define MAXPATHNODES 300 + /** Notes visisted by the path finding algorithm. */ PATHNODE path_nodes[MAXPATHNODES]; /** size of the pnode_tblptr stack */ diff --git a/Source/path.h b/Source/path.h index 045b22381..6936aaad6 100644 --- a/Source/path.h +++ b/Source/path.h @@ -7,6 +7,8 @@ namespace devilution { +#define MAX_PATH_LENGTH 25 + struct PATHNODE { Uint8 f; Uint8 h; diff --git a/Source/pfile.h b/Source/pfile.h index 23fe61dfb..78af9f12b 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -10,6 +10,8 @@ namespace devilution { +#define MAX_CHARACTERS 99 + extern bool gbValidSaveFile; class PFileScopedArchiveWriter { diff --git a/Source/player.cpp b/Source/player.cpp index 399a72627..71916f460 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -874,6 +874,8 @@ void NextPlrLevel(int pnum) CalcPlrInv(pnum, true); } +#define MAXEXP 2000000000 + void AddPlrExperience(int pnum, int lvl, int exp) { int powerLvlCap, expCap, newLvl, i; diff --git a/Source/player.h b/Source/player.h index 30e8f01d9..6985e037c 100644 --- a/Source/player.h +++ b/Source/player.h @@ -7,14 +7,25 @@ #include +#include "diablo.h" #include "enum_traits.h" #include "gendung.h" #include "items.h" +#include "multi.h" #include "spelldat.h" +#include "path.h" #include "interfac.h" namespace devilution { +// number of inventory grid cells +#define NUM_INV_GRID_ELEM 40 +#define MAXBELTITEMS 8 +#define MAXRESIST 75 +#define MAXCHARLEVEL 51 +#define MAX_SPELL_LEVEL 15 +#define PLR_NAME_LEN 32 + /** Walking directions */ enum { // clang-format off @@ -168,9 +179,9 @@ struct PlayerStruct { Sint32 _pAnimFrame; // Current frame of animation. Sint32 _pAnimWidth; Sint32 _pAnimWidth2; - Sint32 _pAnimNumSkippedFrames; // Number of Frames that will be skipped (for example with modifier "faster attack") + Sint32 _pAnimNumSkippedFrames; // Number of Frames that will be skipped (for example with modifier "faster attack") Sint32 _pAnimGameTicksSinceSequenceStarted; // Number of GameTicks after the current animation sequence started - Sint32 _pAnimStopDistributingAfterFrame; // Distribute the NumSkippedFrames only before this frame + Sint32 _pAnimStopDistributingAfterFrame; // Distribute the NumSkippedFrames only before this frame Sint32 _plid; Sint32 _pvid; spell_id _pSpell; @@ -419,4 +430,4 @@ extern int DexterityTbl[enum_size::value]; extern int VitalityTbl[enum_size::value]; extern int ExpLvlsTbl[MAXCHARLEVEL]; -} +} // namespace devilution diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 2adc394d9..2112c3458 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -7,6 +7,8 @@ namespace devilution { +#define PMSG_COUNT 8 + static BYTE plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; diff --git a/Source/portal.h b/Source/portal.h index 3a90910fb..b8a330940 100644 --- a/Source/portal.h +++ b/Source/portal.h @@ -7,6 +7,8 @@ namespace devilution { +#define MAXPORTAL 4 + struct PortalStruct { bool open; Sint32 x; diff --git a/Source/quests.cpp b/Source/quests.cpp index 2a08a3486..88fc03a62 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -4,6 +4,7 @@ * Implementation of functionality for handling quests. */ #include "all.h" +#include "gendung.h" #include "options.h" namespace devilution { diff --git a/Source/quests.h b/Source/quests.h index c6845a224..be81a1620 100644 --- a/Source/quests.h +++ b/Source/quests.h @@ -12,6 +12,8 @@ namespace devilution { +#define MAXQUESTS 24 + /** States of the mushroom quest */ enum { QS_INIT, diff --git a/Source/render.cpp b/Source/render.cpp index 4cc49dd6f..ab1c8a87a 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -430,7 +430,9 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask) } } -DVL_ATTRIBUTE_ALWAYS_INLINE +#if DVL_HAVE_ATTRIBUTE(always_inline) || (defined(__GNUC__) && !defined(__clang__)) +__attribute__((always_inline)) +#endif inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask) { #ifdef NO_OVERDRAW diff --git a/Source/render.h b/Source/render.h index 70473cc26..ed3f55f60 100644 --- a/Source/render.h +++ b/Source/render.h @@ -9,6 +9,14 @@ namespace devilution { +#define BUFFER_BORDER_LEFT 64 +#define BUFFER_BORDER_TOP 160 +#define BUFFER_BORDER_RIGHT devilution::borderRight +#define BUFFER_BORDER_BOTTOM 16 + +#define TILE_WIDTH 64 +#define TILE_HEIGHT 32 + /** * @brief Blit current world CEL to the given buffer * @param out Target buffer diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 8bc9dd8f2..d6fbf7e96 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -9,6 +9,8 @@ namespace devilution { +#define PANELS_COVER (gnScreenWidth <= PANEL_WIDTH && gnScreenHeight <= SPANEL_HEIGHT + PANEL_HEIGHT) + enum _scroll_direction : uint8_t { SDIR_NONE, SDIR_N, diff --git a/Source/sha.cpp b/Source/sha.cpp index ab9c05d02..011ddf740 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -54,7 +54,7 @@ static void SHA1ProcessMessageBlock(SHA1Context *context) DWORD *buf = (DWORD *)context->buffer; for (i = 0; i < 16; i++) - W[i] = SwapLE32(buf[i]); + W[i] = SDL_SwapLE32(buf[i]); for (i = 16; i < 80; i++) { W[i] = W[i - 16] ^ W[i - 14] ^ W[i - 8] ^ W[i - 3]; @@ -140,7 +140,7 @@ void SHA1Result(int n, char Message_Digest[SHA1HashSize]) Message_Digest_Block = (DWORD *)Message_Digest; if (Message_Digest) { for (i = 0; i < 5; i++) { - *Message_Digest_Block = SwapLE32(sgSHA1[n].state[i]); + *Message_Digest_Block = SDL_SwapLE32(sgSHA1[n].state[i]); Message_Digest_Block++; } } diff --git a/Source/sound.h b/Source/sound.h index 33b2c2343..121730313 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -9,6 +9,9 @@ namespace devilution { +#define VOLUME_MIN -1600 +#define VOLUME_MAX 0 + enum _music_id : uint8_t { TMUSIC_TOWN, TMUSIC_L1, diff --git a/Source/spelldat.h b/Source/spelldat.h index 725536f01..b472cb33d 100644 --- a/Source/spelldat.h +++ b/Source/spelldat.h @@ -11,6 +11,8 @@ namespace devilution { +#define MAX_SPELLS 52 + enum spell_type : uint8_t { RSPLTYPE_SKILL, RSPLTYPE_SPELL, diff --git a/Source/stores.h b/Source/stores.h index 326bee374..9b1be027c 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -9,6 +9,11 @@ namespace devilution { +#define WITCH_ITEMS 25 +#define SMITH_ITEMS 25 +#define SMITH_PREMIUM_ITEMS 15 +#define STORE_LINES 104 + enum talk_id : uint8_t { STORE_NONE, STORE_SMITH, diff --git a/Source/towners.h b/Source/towners.h index 09d4b9387..1cfb68221 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -7,8 +7,12 @@ #include +#include "quests.h" + namespace devilution { +#define NUM_TOWNERS 16 + enum _talker_id : uint8_t { TOWN_SMITH, TOWN_HEALER, diff --git a/Source/trigs.h b/Source/trigs.h index 90bf3227a..a5be4d222 100644 --- a/Source/trigs.h +++ b/Source/trigs.h @@ -7,6 +7,8 @@ namespace devilution { +#define MAXTRIGGERS 7 + struct TriggerStruct { int _tx; int _ty; diff --git a/SourceS/console.h b/SourceS/console.h index aaad797a8..196d37c6a 100644 --- a/SourceS/console.h +++ b/SourceS/console.h @@ -3,7 +3,7 @@ #include #include -#include "../defs.h" +#include "miniwin/misc.h" namespace devilution { diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 4d01e9a88..9a2abcff3 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -1,7 +1,22 @@ #pragma once +#include + namespace devilution { +#ifdef __has_attribute +#define DVL_HAVE_ATTRIBUTE(x) __has_attribute(x) +#else +#define DVL_HAVE_ATTRIBUTE(x) 0 +#endif + +#if DVL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__)) +#define DVL_PRINTF_ATTRIBUTE(fmtargnum, firstarg) \ + __attribute__((__format__(__printf__, fmtargnum, firstarg))) +#else +#define DVL_PRINTF_ATTRIBUTE(fmtargnum) +#endif + typedef uint16_t SHORT; typedef int32_t LONG; @@ -49,6 +64,11 @@ bool TranslateMessage(const MSG *lpMsg); void PushMessage(const MSG *lpMsg); bool PostMessage(UINT Msg, WPARAM wParam, LPARAM lParam); +#ifdef _MSC_VER +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#endif + // // MSCVRT emulation // diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index 16dc95172..b2a5949ac 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -10,7 +10,6 @@ #include #include "console.h" -#include "../defs.h" #include "../SourceX/stubs.h" #define WINDOW_ICON_NAME 0 diff --git a/SourceX/controls/touch.cpp b/SourceX/controls/touch.cpp index 6c544603d..c7ae5a822 100644 --- a/SourceX/controls/touch.cpp +++ b/SourceX/controls/touch.cpp @@ -2,7 +2,6 @@ #include "display.h" #include "options.h" #include "touch.h" -#include "../../defs.h" #include static int visible_width; diff --git a/defs.h b/defs.h deleted file mode 100644 index 1223e46d8..000000000 --- a/defs.h +++ /dev/null @@ -1,212 +0,0 @@ -/** - * @file defs.h - * - * Global definitions and Macros. - */ - -#define DMAXX 40 -#define DMAXY 40 - -#define LIGHTSIZE 6912 // 27 * 256 -#define NO_LIGHT -1 - -#define GMENU_SLIDER 0x40000000 -#define GMENU_ENABLED 0x80000000 - -// must be unsigned to generate unsigned comparisons with pnum -#define MAX_PLRS 4 - -#define MAX_CHARACTERS 99 -#define MAX_LVLS 24 -#define MAX_LVLMTYPES 24 -#define MAX_SPELLS 52 -#define MAX_SPELL_LEVEL 15 - -#define MAX_CHUNKS (MAX_LVLS + 5) - -// #define MAX_PATH 260 -#define MAX_SEND_STR_LEN 80 - -#define MAXDEAD 31 -#define MAXDUNX 112 -#define MAXDUNY 112 -#define MAXITEMS 127 -#define MAXBELTITEMS 8 -#define MAXLIGHTS 32 -#define MAXMISSILES 125 -#define MAXMONSTERS 200 -#define MAXOBJECTS 127 -#define MAXPORTAL 4 - -#define MAXQUESTS 24 -#define MAXMULTIQUESTS 10 - -#define MAXTHEMES 50 -#define MAXTILES 2048 - -#define MAXTRIGGERS 7 - -#define MAXVISION 32 -#define MDMAXX 40 -#define MDMAXY 40 -#define MAXCHARLEVEL 51 -#define ITEMTYPES 43 - -// number of inventory grid cells -#define NUM_INV_GRID_ELEM 40 -#define INV_SLOT_SIZE_PX 28 - -// Item indestructible durability -#define DUR_INDESTRUCTIBLE 255 - -#define VOLUME_MIN -1600 -#define VOLUME_MAX 0 - -#define NUM_TOWNERS 16 - -// todo: enums -#define NUMLEVELS 25 -#define WITCH_ITEMS 25 -#define SMITH_ITEMS 25 -#define SMITH_PREMIUM_ITEMS 15 -#define STORE_LINES 104 - -// from diablo 2 beta -#define MAXEXP 2000000000 -#define MAXRESIST 75 - -#define GOLD_SMALL_LIMIT 1000 -#define GOLD_MEDIUM_LIMIT 2500 -#define GOLD_MAX_LIMIT 5000 - -#define PLR_NAME_LEN 32 - -#define MAXPATHNODES 300 - -#define MAX_PATH_LENGTH 25 - -// 256 kilobytes + 3 bytes (demo leftover) for file magic (262147) -// final game uses 4-byte magic instead of 3 -#define FILEBUFF ((256 * 1024) + 3) - -#define PMSG_COUNT 8 - -#define GAME_ID (gbIsHellfire ? (gbIsSpawn ? LOAD_BE32("HSHR") : LOAD_BE32("HRTL")) : (gbIsSpawn ? LOAD_BE32("DSHR") : LOAD_BE32("DRTL"))) - -// Diablo uses a 256 color palette -// Entry 0-127 (0x00-0x7F) are level specific -// Entry 128-255 (0x80-0xFF) are global - -// standard palette for all levels -// 8 or 16 shades per color -// example (dark blue): PAL16_BLUE+14, PAL8_BLUE+7 -// example (light red): PAL16_RED+2, PAL8_RED -// example (orange): PAL16_ORANGE+8, PAL8_ORANGE+4 -#define PAL8_BLUE 128 -#define PAL8_RED 136 -#define PAL8_YELLOW 144 -#define PAL8_ORANGE 152 -#define PAL16_BEIGE 160 -#define PAL16_BLUE 176 -#define PAL16_YELLOW 192 -#define PAL16_ORANGE 208 -#define PAL16_RED 224 -#define PAL16_GRAY 240 - -// If defined, use 32-bit colors instead of 8-bit [Default -> Undefined] -//#define RGBMODE - -#ifndef RGBMODE -#define SCREEN_BPP 8 -#else -#define SCREEN_BPP 32 -#endif - -#define BUFFER_BORDER_LEFT 64 -#define BUFFER_BORDER_TOP 160 -#define BUFFER_BORDER_RIGHT devilution::borderRight -#define BUFFER_BORDER_BOTTOM 16 - -#define UI_OFFSET_Y ((Sint16)((gnScreenHeight - 480) / 2)) - -#define TILE_WIDTH 64 -#define TILE_HEIGHT 32 - -#define PANEL_WIDTH 640 -#define PANEL_HEIGHT 128 -#define PANEL_TOP (gnScreenHeight - PANEL_HEIGHT) -#define PANEL_LEFT (gnScreenWidth - PANEL_WIDTH) / 2 -#define PANEL_X PANEL_LEFT -#define PANEL_Y PANEL_TOP - -#define SPANEL_WIDTH 320 -#define SPANEL_HEIGHT 352 -#define PANELS_COVER (gnScreenWidth <= PANEL_WIDTH && gnScreenHeight <= SPANEL_HEIGHT + PANEL_HEIGHT) - -#define RIGHT_PANEL (gnScreenWidth - SPANEL_WIDTH) -#define RIGHT_PANEL_X RIGHT_PANEL - -#define DIALOG_TOP ((gnScreenHeight - PANEL_HEIGHT) / 2 - 18) -#define DIALOG_Y DIALOG_TOP - -#define NIGHTMARE_TO_HIT_BONUS 85 -#define HELL_TO_HIT_BONUS 120 - -#define NIGHTMARE_AC_BONUS 50 -#define HELL_AC_BONUS 80 - -#define MemFreeDbg(p) \ - { \ - void *p__p; \ - p__p = p; \ - p = NULL; \ - mem_free_dbg(p__p); \ - } - -#undef assert - -#ifndef _DEBUG -#define assert(exp) -#define assurance(exp, value) if (!(exp)) return -#define commitment(exp, value) if (!(exp)) return false -#else -#define assert(exp) (void)((exp) || (assert_fail(__LINE__, __FILE__, #exp), 0)) -#define assurance(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0)) -#define commitment(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0)) -#endif - -// To apply to certain functions which have local variables aligned by 1 for unknown yet reason -#if (_MSC_VER == 1200) -#define ALIGN_BY_1 __declspec(align(1)) -#else -#define ALIGN_BY_1 -#endif - -#define SwapLE32 SDL_SwapLE32 -#define SwapLE16 SDL_SwapLE16 - -#define ErrSdl() ErrDlg("SDL Error", SDL_GetError(), __FILE__, __LINE__) - -#ifdef _MSC_VER -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#endif - -#ifdef __has_attribute -#define DVL_HAVE_ATTRIBUTE(x) __has_attribute(x) -#else -#define DVL_HAVE_ATTRIBUTE(x) 0 -#endif - -#if DVL_HAVE_ATTRIBUTE(always_inline) || (defined(__GNUC__) && !defined(__clang__)) -#define DVL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) -#else -#define DVL_ATTRIBUTE_ALWAYS_INLINE -#endif - -#if DVL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__)) -#define DVL_PRINTF_ATTRIBUTE(fmtargnum, firstarg) \ - __attribute__((__format__(__printf__, fmtargnum, firstarg))) -#else -#define DVL_PRINTF_ATTRIBUTE(fmtargnum) -#endif diff --git a/types.h b/types.h index 0cc3c56a3..e88bc6d7c 100644 --- a/types.h +++ b/types.h @@ -12,6 +12,5 @@ #include "ui_fwd.h" #include -#include "defs.h" #endif