Browse Source

Clean up use of miniwin

pull/4952/head
Anders Jenbo 4 years ago
parent
commit
3d08f951d6
  1. 2
      Source/engine/render/scrollrt.cpp
  2. 5
      Source/levels/drlg_l2.cpp
  3. 17
      Source/levels/drlg_l3.cpp
  4. 5
      Source/levels/drlg_l4.cpp
  5. 5
      Source/miniwin/miniwin.h
  6. 8
      Source/miniwin/misc_msg.h
  7. 1
      Source/monster.cpp
  8. 65
      Source/player.cpp
  9. 3
      Source/spells.cpp

2
Source/engine/render/scrollrt.cpp

@ -868,7 +868,7 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit
}
int8_t playerId = dPlayer[tilePosition.x][tilePosition.y];
if (playerId > 0 && playerId <= MAX_PLRS) {
DrawPlayerHelper(out, Players[abs(playerId) - 1], tilePosition, targetBufferPosition);
DrawPlayerHelper(out, Players[playerId - 1], tilePosition, targetBufferPosition);
}
if (dMonster[tilePosition.x][tilePosition.y] > 0) {
DrawMonsterHelper(out, tilePosition, targetBufferPosition);

5
Source/levels/drlg_l2.cpp

@ -13,7 +13,6 @@
#include "engine/size.hpp"
#include "levels/gendung.h"
#include "levels/setmaps.h"
#include "miniwin/miniwin.h"
#include "player.h"
#include "quests.h"
#include "utils/stdcompat/algorithm.hpp"
@ -33,8 +32,8 @@ const int DirYadd[5] = { 0, -1, 0, 1, 0 };
const ShadowStruct SPATSL2[2] = { { 6, 3, 0, 3, 48, 0, 50 }, { 9, 3, 0, 3, 48, 0, 50 } };
// short word_48489A = 0;
const BYTE BTYPESL2[161] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 17, 18, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0,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 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
const uint8_t BSTYPESL2[161] = { 0, 1, 2, 3, 0, 0, 6, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 6, 6, 6, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 6, 2, 2, 2, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 3, 3, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
/** Miniset: Arch vertical. */
const Miniset VARCH1 {

17
Source/levels/drlg_l3.cpp

@ -6,7 +6,6 @@
#include "levels/gendung.h"
#include "levels/setmaps.h"
#include "lighting.h"
#include "miniwin/miniwin.h"
#include "monster.h"
#include "objdat.h"
#include "objects.h"
@ -22,7 +21,7 @@ int lockoutcnt;
* A lookup table for the 16 possible patterns of a 2x2 area,
* where each cell either contains a SW wall or it doesn't.
*/
const BYTE L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 };
const uint8_t L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 };
/** Miniset: Stairs up. */
const Miniset L3UP {
{ 3, 3 },
@ -1100,10 +1099,10 @@ void River()
if (dungeon[rx][ry] == 7) {
dircheck = 0;
if (dir < 2) {
river[2][riveramt] = (BYTE)GenerateRnd(2) + 17;
river[2][riveramt] = GenerateRnd(2) + 17;
}
if (dir > 1) {
river[2][riveramt] = (BYTE)GenerateRnd(2) + 15;
river[2][riveramt] = GenerateRnd(2) + 15;
}
river[0][riveramt] = rx;
river[1][riveramt] = ry;
@ -1261,8 +1260,7 @@ bool Spawn(int x, int y, int *totarea);
bool SpawnEdge(int x, int y, int *totarea)
{
BYTE i;
static BYTE spawntable[15] = { 0x00, 0x0A, 0x43, 0x05, 0x2c, 0x06, 0x09, 0x00, 0x00, 0x1c, 0x83, 0x06, 0x09, 0x0A, 0x05 };
constexpr uint8_t spawntable[15] = { 0x00, 0x0A, 0x43, 0x05, 0x2c, 0x06, 0x09, 0x00, 0x00, 0x1c, 0x83, 0x06, 0x09, 0x0A, 0x05 };
if (*totarea > 40) {
return true;
@ -1277,7 +1275,7 @@ bool SpawnEdge(int x, int y, int *totarea)
return true;
}
i = dungeon[x][y];
uint8_t i = dungeon[x][y];
dungeon[x][y] |= 0x80;
*totarea += 1;
@ -1311,8 +1309,7 @@ bool SpawnEdge(int x, int y, int *totarea)
bool Spawn(int x, int y, int *totarea)
{
BYTE i;
static BYTE spawntable[15] = { 0x00, 0x0A, 0x03, 0x05, 0x0C, 0x06, 0x09, 0x00, 0x00, 0x0C, 0x03, 0x06, 0x09, 0x0A, 0x05 };
constexpr uint8_t spawntable[15] = { 0x00, 0x0A, 0x03, 0x05, 0x0C, 0x06, 0x09, 0x00, 0x00, 0x0C, 0x03, 0x06, 0x09, 0x0A, 0x05 };
if (*totarea > 40) {
return true;
@ -1327,7 +1324,7 @@ bool Spawn(int x, int y, int *totarea)
return true;
}
i = dungeon[x][y];
uint8_t i = dungeon[x][y];
dungeon[x][y] |= 0x80;
*totarea += 1;

5
Source/levels/drlg_l4.cpp

@ -8,7 +8,6 @@
#include "engine/load_file.hpp"
#include "engine/random.hpp"
#include "levels/gendung.h"
#include "miniwin/miniwin.h"
#include "monster.h"
#include "multi.h"
#include "objdat.h"
@ -29,7 +28,7 @@ Point L4Hold;
* A lookup table for the 16 possible patterns of a 2x2 area,
* where each cell either contains a SW wall or it doesn't.
*/
const BYTE L4ConvTbl[16] = { 30, 6, 1, 6, 2, 6, 6, 6, 9, 6, 1, 6, 2, 6, 3, 6 };
const uint8_t L4ConvTbl[16] = { 30, 6, 1, 6, 2, 6, 6, 6, 9, 6, 1, 6, 2, 6, 3, 6 };
/** Miniset: Stairs up. */
const Miniset L4USTAIRS {
@ -123,7 +122,7 @@ const Miniset L4PENTA2 {
};
/** Maps tile IDs to their corresponding undecorated tile ID. */
const BYTE L4BTYPES[140] = {
const uint8_t L4BTYPES[140] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

5
Source/miniwin/miniwin.h

@ -7,11 +7,6 @@ namespace devilution {
#endif
typedef uint32_t DWORD;
typedef unsigned char BYTE;
//
// Everything else
//
#ifdef _MSC_VER
#define strcasecmp _stricmp

8
Source/miniwin/misc_msg.h

@ -38,14 +38,6 @@ void PushMessage(const tagMSG *lpMsg);
bool PostMessage(uint32_t type, int32_t wParam, int32_t lParam);
void ClearMessageQueue();
//
// MSCVRT emulation
//
#define DVL_FILE_BEGIN 0
#define DVL_FILE_CURRENT 1
#define DVL_FILE_END 2
#define DVL_WM_QUIT 0x0012
//

1
Source/monster.cpp

@ -28,6 +28,7 @@
#include "levels/trigs.h"
#include "lighting.h"
#include "minitext.h"
#include "miniwin/miniwin.h"
#include "missiles.h"
#include "movie.h"
#include "options.h"

65
Source/player.cpp

@ -12,7 +12,6 @@
#include "controls/plrctrls.h"
#include "cursor.h"
#include "dead.h"
#include "miniwin/miniwin.h"
#include "miniwin/misc_msg.h"
#ifdef _DEBUG
#include "debug.h"
@ -637,7 +636,7 @@ void InitLevelChange(int pnum)
*/
bool DoWalk(int pnum, int variant)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PM_DoWalk: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -790,12 +789,12 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false)
{
int hper = 0;
if ((DWORD)monsterId >= MaxMonsters) {
if (monsterId < 0 || monsterId >= MaxMonsters) {
app_fatal(StrCat("PlrHitMonst: illegal monster ", monsterId));
}
auto &monster = Monsters[monsterId];
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PlrHitMonst: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -972,7 +971,7 @@ bool PlrHitMonst(int pnum, int monsterId, bool adjacentDamage = false)
bool PlrHitPlr(Player &attacker, int8_t p)
{
if ((DWORD)p >= MAX_PLRS) {
if (p < 0 || p >= MAX_PLRS) {
app_fatal(StrCat("PlrHitPlr: illegal target player ", p));
}
Player &target = Players[p];
@ -1052,7 +1051,7 @@ bool PlrHitObj(int pnum, Object &targetObject)
bool DoAttack(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PM_DoAttack: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -1069,13 +1068,7 @@ bool DoAttack(int pnum)
int dy = position.y;
if (dMonster[dx][dy] != 0) {
int m = -1;
if (dMonster[dx][dy] > 0) {
m = dMonster[dx][dy] - 1;
} else {
m = -(dMonster[dx][dy] + 1);
}
if (CanTalkToMonst(Monsters[m])) {
if (CanTalkToMonst(Monsters[abs(dMonster[dx][dy]) - 1])) {
player.position.temp.x = 0; /** @todo Looks to be irrelevant, probably just remove it */
return false;
}
@ -1091,21 +1084,9 @@ bool DoAttack(int pnum)
}
if (dMonster[dx][dy] != 0) {
int m = dMonster[dx][dy];
if (dMonster[dx][dy] > 0) {
m = dMonster[dx][dy] - 1;
} else {
m = -(dMonster[dx][dy] + 1);
}
didhit = PlrHitMonst(pnum, m);
didhit = PlrHitMonst(pnum, abs(dMonster[dx][dy]) - 1);
} else if (dPlayer[dx][dy] != 0 && !player.friendlyMode) {
BYTE p = dPlayer[dx][dy];
if (dPlayer[dx][dy] > 0) {
p = dPlayer[dx][dy] - 1;
} else {
p = -(dPlayer[dx][dy] + 1);
}
didhit = PlrHitPlr(player, p);
didhit = PlrHitPlr(player, abs(dPlayer[dx][dy]) - 1);
} else {
Object *object = ObjectAtPosition(position, false);
if (object != nullptr) {
@ -1162,7 +1143,7 @@ bool DoAttack(int pnum)
bool DoRangeAttack(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PM_DoRangeAttack: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -1262,7 +1243,7 @@ void DamageParryItem(Player &player)
bool DoBlock(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PM_DoBlock: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -1323,7 +1304,7 @@ void DamageArmor(Player &player)
bool DoSpell(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PM_DoSpell: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -1354,7 +1335,7 @@ bool DoSpell(int pnum)
bool DoGotHit(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("PM_DoGotHit: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -1425,7 +1406,7 @@ void TryDisarm(const Player &player, Object &object)
void CheckNewPath(int pnum, bool pmWillBeCalled)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("CheckNewPath: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -1763,7 +1744,7 @@ bool PlrDeathModeOK(Player &player)
void ValidatePlayer()
{
if ((DWORD)MyPlayerId >= MAX_PLRS) {
if (MyPlayerId < 0 || MyPlayerId >= MAX_PLRS) {
app_fatal(StrCat("ValidatePlayer: illegal player ", MyPlayerId));
}
Player &myPlayer = *MyPlayer;
@ -2833,7 +2814,7 @@ void InitPlayer(Player &player, bool firstTime)
void InitMultiView()
{
if ((DWORD)MyPlayerId >= MAX_PLRS) {
if (MyPlayerId < 0 || MyPlayerId >= MAX_PLRS) {
app_fatal(StrCat("InitPlayer: illegal player ", MyPlayerId));
}
Player &myPlayer = *MyPlayer;
@ -2887,7 +2868,7 @@ void FixPlayerLocation(Player &player, Direction bDir)
void StartStand(int pnum, Direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("StartStand: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -2937,7 +2918,7 @@ void FixPlrWalkTags(const Player &player)
void StartPlrHit(int pnum, int dam, bool forcehit)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("StartPlrHit: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -3188,7 +3169,7 @@ StartNewLvl(int pnum, interface_mode fom, int lvl)
{
InitLevelChange(pnum);
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("StartNewLvl: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -3228,7 +3209,7 @@ StartNewLvl(int pnum, interface_mode fom, int lvl)
void RestartTownLvl(int pnum)
{
InitLevelChange(pnum);
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("RestartTownLvl: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -3277,7 +3258,7 @@ void StartWarpLvl(int pnum, int pidx)
void ProcessPlayers()
{
if ((DWORD)MyPlayerId >= MAX_PLRS) {
if (MyPlayerId < 0 || MyPlayerId >= MAX_PLRS) {
app_fatal(StrCat("ProcessPlayers: illegal player ", MyPlayerId));
}
Player &myPlayer = *MyPlayer;
@ -3446,7 +3427,7 @@ void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType)
{
bool addflag = false;
if ((DWORD)MyPlayerId >= MAX_PLRS) {
if (MyPlayerId < 0 || MyPlayerId >= MAX_PLRS) {
app_fatal(StrCat("CheckPlrSpell: illegal player ", MyPlayerId));
}
Player &myPlayer = *MyPlayer;
@ -3622,7 +3603,7 @@ void SyncInitPlrPos(int pnum)
void SyncInitPlr(int pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
if (pnum < 0 || pnum >= MAX_PLRS) {
app_fatal(StrCat("SyncInitPlr: illegal player ", pnum));
}
Player &player = Players[pnum];
@ -3803,7 +3784,7 @@ enum {
void PlayDungMsgs()
{
if ((DWORD)MyPlayerId >= MAX_PLRS) {
if (MyPlayerId < 0 || MyPlayerId >= MAX_PLRS) {
app_fatal(StrCat("PlayDungMsgs: illegal player ", MyPlayerId));
}
Player &myPlayer = *MyPlayer;

3
Source/spells.cpp

@ -7,7 +7,6 @@
#include "control.h"
#include "cursor.h"
#include "miniwin/miniwin.h"
#ifdef _DEBUG
#include "debug.h"
#endif
@ -260,7 +259,7 @@ void CastSpell(int id, spell_id spl, int sx, int sy, int dx, int dy, int spllvl)
void DoResurrect(int pnum, uint16_t rid)
{
if ((DWORD)pnum >= MAX_PLRS || rid >= MAX_PLRS) {
if ((pnum < 0 && pnum >= MAX_PLRS) || rid >= MAX_PLRS) {
return;
}

Loading…
Cancel
Save