From 6e096143f00ecc804eb5fba293eef027f771cb58 Mon Sep 17 00:00:00 2001 From: qndel Date: Fri, 13 Nov 2020 04:16:26 +0100 Subject: [PATCH] Add no-light define and fix usage --- Source/lighting.cpp | 14 +++++++------- Source/missiles.cpp | 4 ++-- Source/monster.cpp | 4 ++-- defs.h | 1 + structs.h | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/lighting.cpp b/Source/lighting.cpp index ebdcaa054..79d71016f 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1043,10 +1043,10 @@ int AddLight(int x, int y, int r) int lid; if (lightflag) { - return -1; + return NO_LIGHT; } - lid = -1; + lid = NO_LIGHT; if (numlights < MAXLIGHTS) { lid = lightactive[numlights++]; @@ -1065,7 +1065,7 @@ int AddLight(int x, int y, int r) void AddUnLight(int i) { - if (lightflag || i == -1) { + if (lightflag || i == NO_LIGHT) { return; } @@ -1075,7 +1075,7 @@ void AddUnLight(int i) void ChangeLightRadius(int i, int r) { - if (lightflag || i == -1) { + if (lightflag || i == NO_LIGHT) { return; } @@ -1089,7 +1089,7 @@ void ChangeLightRadius(int i, int r) void ChangeLightXY(int i, int x, int y) { - if (lightflag || i == -1) { + if (lightflag || i == NO_LIGHT) { return; } @@ -1104,7 +1104,7 @@ void ChangeLightXY(int i, int x, int y) void ChangeLightOff(int i, int x, int y) { - if (lightflag || i == -1) { + if (lightflag || i == NO_LIGHT) { return; } @@ -1119,7 +1119,7 @@ void ChangeLightOff(int i, int x, int y) void ChangeLight(int i, int x, int y, int r) { - if (lightflag || i == -1) { + if (lightflag || i == NO_LIGHT) { return; } diff --git a/Source/missiles.cpp b/Source/missiles.cpp index e7272b42a..135edb043 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2727,7 +2727,7 @@ void AddAcid(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in missile[mi]._mirange = 5 * (monster[id]._mint + 4); else missile[mi]._mirange = 1; - missile[mi]._mlid = -1; + missile[mi]._mlid = NO_LIGHT; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; PutMissile(mi); @@ -3384,7 +3384,7 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas missile[mi]._midam = midam; missile[mi]._miHitFlag = FALSE; missile[mi]._midist = 0; - missile[mi]._mlid = -1; + missile[mi]._mlid = NO_LIGHT; missile[mi]._mirnd = 0; if (missiledata[mitype].mlSFX != -1) { diff --git a/Source/monster.cpp b/Source/monster.cpp index c76b75b81..0deeb0c85 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -501,7 +501,7 @@ void InitMonster(int i, int rd, int mtype, int x, int y) monster[i]._mDelFlag = FALSE; monster[i]._uniqtype = 0; monster[i]._msquelch = 0; - monster[i].mlid = 0; + monster[i].mlid = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) monster[i]._mRndSeed = GetRndSeed(); monster[i]._mAISeed = GetRndSeed(); monster[i].mWhoHit = 0; @@ -804,7 +804,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int bosspacksize) Monst->mMagicRes = Uniq->mMagicRes; Monst->mtalkmsg = Uniq->mtalkmsg; if (uniqindex == UMT_HORKDMN) - Monst->mlid = 0; + Monst->mlid = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) else Monst->mlid = AddLight(Monst->_mx, Monst->_my, 3); diff --git a/defs.h b/defs.h index acd3dc77d..84a7c3cf7 100644 --- a/defs.h +++ b/defs.h @@ -8,6 +8,7 @@ #define DMAXY 40 #define LIGHTSIZE 6912 // 27 * 256 +#define NO_LIGHT -1 #define GMENU_SLIDER 0x40000000 #define GMENU_ENABLED 0x80000000 diff --git a/structs.h b/structs.h index e3d861ec5..1ec9f1cc6 100644 --- a/structs.h +++ b/structs.h @@ -602,7 +602,7 @@ typedef struct MonsterStruct { // note: missing field _mAFNum unsigned char leader; unsigned char leaderflag; unsigned char packsize; - unsigned char mlid; + Sint8 mlid; // BUGFIX -1 is used when not emitting light this should be signed (fixed) const char *mName; CMonster *MType; MonsterData *MData;