Browse Source

Rename object globals

pull/2319/head
Anders Jenbo 5 years ago
parent
commit
467b74dc06
  1. 4
      Source/controls/plrctrls.cpp
  2. 8
      Source/cursor.cpp
  3. 2
      Source/diablo.cpp
  4. 8
      Source/inv.cpp
  5. 20
      Source/items.cpp
  6. 4
      Source/lighting.cpp
  7. 52
      Source/loadsave.cpp
  8. 8
      Source/missiles.cpp
  9. 8
      Source/monster.cpp
  10. 10
      Source/msg.cpp
  11. 1356
      Source/objects.cpp
  12. 12
      Source/objects.h
  13. 42
      Source/player.cpp
  14. 12
      Source/quests.cpp
  15. 32
      Source/scrollrt.cpp
  16. 6
      Source/setmaps.cpp
  17. 8
      Source/themes.cpp

4
Source/controls/plrctrls.cpp

@ -147,9 +147,9 @@ void FindItemOrObject()
if (dObject[mx + xx][my + yy] == 0)
continue;
int o = dObject[mx + xx][my + yy] > 0 ? dObject[mx + xx][my + yy] - 1 : -(dObject[mx + xx][my + yy] + 1);
if (object[o]._oSelFlag == 0)
if (Objects[o]._oSelFlag == 0)
continue;
if (xx == 0 && yy == 0 && object[o]._oDoorFlag)
if (xx == 0 && yy == 0 && Objects[o]._oDoorFlag)
continue; // Ignore doorway so we don't get stuck behind barrels
int newRotations = GetRotaryDistance({ mx + xx, my + yy });
if (rotations < newRotations)

8
Source/cursor.cpp

@ -632,7 +632,7 @@ void CheckCursMove()
if (pcursmonst == -1 && pcursplr == -1) {
if (!flipflag && mx + 1 < MAXDUNX && dObject[mx + 1][my] != 0) {
int8_t bv = dObject[mx + 1][my] > 0 ? dObject[mx + 1][my] - 1 : -(dObject[mx + 1][my] + 1);
if (object[bv]._oSelFlag >= 2) {
if (Objects[bv]._oSelFlag >= 2) {
cursmx = mx + 1;
cursmy = my;
pcursobj = bv;
@ -640,7 +640,7 @@ void CheckCursMove()
}
if (flipflag && my + 1 < MAXDUNY && dObject[mx][my + 1] != 0) {
int8_t bv = dObject[mx][my + 1] > 0 ? dObject[mx][my + 1] - 1 : -(dObject[mx][my + 1] + 1);
if (object[bv]._oSelFlag >= 2) {
if (Objects[bv]._oSelFlag >= 2) {
cursmx = mx;
cursmy = my + 1;
pcursobj = bv;
@ -648,7 +648,7 @@ void CheckCursMove()
}
if (dObject[mx][my] != 0) {
int8_t bv = dObject[mx][my] > 0 ? dObject[mx][my] - 1 : -(dObject[mx][my] + 1);
if (object[bv]._oSelFlag == 1 || object[bv]._oSelFlag == 3) {
if (Objects[bv]._oSelFlag == 1 || Objects[bv]._oSelFlag == 3) {
cursmx = mx;
cursmy = my;
pcursobj = bv;
@ -656,7 +656,7 @@ void CheckCursMove()
}
if (mx + 1 < MAXDUNX && my + 1 < MAXDUNY && dObject[mx + 1][my + 1] != 0) {
int8_t bv = dObject[mx + 1][my + 1] > 0 ? dObject[mx + 1][my + 1] - 1 : -(dObject[mx + 1][my + 1] + 1);
if (object[bv]._oSelFlag >= 2) {
if (Objects[bv]._oSelFlag >= 2) {
cursmx = mx + 1;
cursmy = my + 1;
pcursobj = bv;

2
Source/diablo.cpp

@ -625,7 +625,7 @@ static bool LeftMouseCmd(bool bShift)
bNear = myPlayer.position.tile.WalkingDistance({ cursmx, cursmy }) < 2;
if (pcursitem != -1 && pcurs == CURSOR_HAND && !bShift) {
NetSendCmdLocParam1(true, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, { cursmx, cursmy }, pcursitem);
} else if (pcursobj != -1 && (!objectIsDisabled(pcursobj)) && (!bShift || (bNear && object[pcursobj]._oBreak == 1))) {
} else if (pcursobj != -1 && (!objectIsDisabled(pcursobj)) && (!bShift || (bNear && Objects[pcursobj]._oBreak == 1))) {
NetSendCmdLocParam1(true, pcurs == CURSOR_DISARM ? CMD_DISARMXY : CMD_OPOBJXY, { cursmx, cursmy }, pcursobj);
} else if (myPlayer._pwtype == WT_RANGED) {
if (bShift) {

8
Source/inv.cpp

@ -1674,22 +1674,22 @@ bool CanPut(Point position)
return false;
if (dObject[position.x][position.y] != 0) {
if (object[dObject[position.x][position.y] > 0 ? dObject[position.x][position.y] - 1 : -(dObject[position.x][position.y] + 1)]._oSolidFlag)
if (Objects[dObject[position.x][position.y] > 0 ? dObject[position.x][position.y] - 1 : -(dObject[position.x][position.y] + 1)]._oSolidFlag)
return false;
}
int8_t oi = dObject[position.x + 1][position.y + 1];
if (oi > 0 && object[oi - 1]._oSelFlag != 0) {
if (oi > 0 && Objects[oi - 1]._oSelFlag != 0) {
return false;
}
if (oi < 0 && object[-(oi + 1)]._oSelFlag != 0) {
if (oi < 0 && Objects[-(oi + 1)]._oSelFlag != 0) {
return false;
}
oi = dObject[position.x + 1][position.y];
if (oi > 0) {
int8_t oi2 = dObject[position.x][position.y + 1];
if (oi2 > 0 && object[oi - 1]._oSelFlag != 0 && object[oi2 - 1]._oSelFlag != 0)
if (oi2 > 0 && Objects[oi - 1]._oSelFlag != 0 && Objects[oi2 - 1]._oSelFlag != 0)
return false;
}

20
Source/items.cpp

@ -1278,20 +1278,20 @@ bool ItemSpaceOk(Point position)
if (dObject[position.x][position.y] != 0) {
oi = dObject[position.x][position.y] > 0 ? dObject[position.x][position.y] - 1 : -(dObject[position.x][position.y] + 1);
if (object[oi]._oSolidFlag)
if (Objects[oi]._oSolidFlag)
return false;
}
if (dObject[position.x + 1][position.y + 1] > 0 && object[dObject[position.x + 1][position.y + 1] - 1]._oSelFlag != 0)
if (dObject[position.x + 1][position.y + 1] > 0 && Objects[dObject[position.x + 1][position.y + 1] - 1]._oSelFlag != 0)
return false;
if (dObject[position.x + 1][position.y + 1] < 0 && object[-(dObject[position.x + 1][position.y + 1] + 1)]._oSelFlag != 0)
if (dObject[position.x + 1][position.y + 1] < 0 && Objects[-(dObject[position.x + 1][position.y + 1] + 1)]._oSelFlag != 0)
return false;
if (dObject[position.x + 1][position.y] > 0
&& dObject[position.x][position.y + 1] > 0
&& object[dObject[position.x + 1][position.y] - 1]._oSelFlag != 0
&& object[dObject[position.x][position.y + 1] - 1]._oSelFlag != 0) {
&& Objects[dObject[position.x + 1][position.y] - 1]._oSelFlag != 0
&& Objects[dObject[position.x][position.y + 1] - 1]._oSelFlag != 0) {
return false;
}
@ -2831,9 +2831,9 @@ void SpawnRock()
int oi;
bool ostand = false;
for (int i = 0; i < nobjects && !ostand; i++) {
oi = objectactive[i];
ostand = object[oi]._otype == OBJ_STAND;
for (int i = 0; i < ActiveObjectCount && !ostand; i++) {
oi = ActiveObjects[i];
ostand = Objects[oi]._otype == OBJ_STAND;
}
if (!ostand)
@ -2841,8 +2841,8 @@ void SpawnRock()
int ii = AllocateItem();
Items[ii].position = object[oi].position;
dItem[object[oi].position.x][object[oi].position.y] = ii + 1;
Items[ii].position = Objects[oi].position;
dItem[Objects[oi].position.x][Objects[oi].position.y] = ii + 1;
int curlv = items_get_currlevel();
GetItemAttrs(ii, IDI_ROCK, curlv);
SetupItem(ii);

4
Source/lighting.cpp

@ -477,7 +477,7 @@ void RotateRadius(int *x, int *y, int *dx, int *dy, int *lx, int *ly, int *bx, i
void SetLight(int x, int y, char v)
{
if (LoadMapObjsFlag)
if (LoadingMapObjects)
dPreLight[x][y] = v;
else
dLight[x][y] = v;
@ -485,7 +485,7 @@ void SetLight(int x, int y, char v)
char GetLight(int x, int y)
{
if (LoadMapObjsFlag)
if (LoadingMapObjects)
return dPreLight[x][y];
return dLight[x][y];

52
Source/loadsave.cpp

@ -708,7 +708,7 @@ static void LoadMissile(LoadHelper *file, int i)
static void LoadObject(LoadHelper *file, int i)
{
ObjectStruct *pObject = &object[i];
ObjectStruct *pObject = &Objects[i];
pObject->_otype = static_cast<_object_id>(file->NextLE<int32_t>());
pObject->position.x = file->NextLE<int32_t>();
@ -1156,7 +1156,7 @@ void LoadGame(bool firstflag)
ActiveMonsterCount = tmpNummonsters;
ActiveItemCount = tmpNumitems;
ActiveMissileCount = tmpNummissiles;
nobjects = tmpNobjects;
ActiveObjectCount = tmpNobjects;
for (int &monstkill : MonsterKillCounts)
monstkill = file.NextBE<int32_t>();
@ -1172,14 +1172,14 @@ void LoadGame(bool firstflag)
missileId = file.NextLE<int8_t>();
for (int i = 0; i < ActiveMissileCount; i++)
LoadMissile(&file, ActiveMissiles[i]);
for (int &objectId : objectactive)
for (int &objectId : ActiveObjects)
objectId = file.NextLE<int8_t>();
for (int &objectId : objectavail)
for (int &objectId : AvailableObjects)
objectId = file.NextLE<int8_t>();
for (int i = 0; i < nobjects; i++)
LoadObject(&file, objectactive[i]);
for (int i = 0; i < nobjects; i++)
SyncObjectAnim(objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
LoadObject(&file, ActiveObjects[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SyncObjectAnim(ActiveObjects[i]);
ActiveLightCount = file.NextBE<int32_t>();
@ -1750,7 +1750,7 @@ static void SaveMissile(SaveHelper *file, int i)
static void SaveObject(SaveHelper *file, int i)
{
ObjectStruct *pObject = &object[i];
ObjectStruct *pObject = &Objects[i];
file->WriteLE<int32_t>(pObject->_otype);
file->WriteLE<int32_t>(pObject->position.x);
@ -1908,7 +1908,7 @@ void SaveGameData()
file.WriteBE<int32_t>(ActiveMonsterCount);
file.WriteBE<int32_t>(ActiveItemCount);
file.WriteBE<int32_t>(ActiveMissileCount);
file.WriteBE<int32_t>(nobjects);
file.WriteBE<int32_t>(ActiveObjectCount);
for (uint8_t i = 0; i < giNumberOfLevels; i++) {
file.WriteBE<uint32_t>(glSeedTbl[i]);
@ -1936,12 +1936,12 @@ void SaveGameData()
file.WriteLE<int8_t>(missileId);
for (int i = 0; i < ActiveMissileCount; i++)
SaveMissile(&file, ActiveMissiles[i]);
for (int objectId : objectactive)
for (int objectId : ActiveObjects)
file.WriteLE<int8_t>(objectId);
for (int objectId : objectavail)
for (int objectId : AvailableObjects)
file.WriteLE<int8_t>(objectId);
for (int i = 0; i < nobjects; i++)
SaveObject(&file, objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SaveObject(&file, ActiveObjects[i]);
file.WriteBE<int32_t>(ActiveLightCount);
@ -2052,19 +2052,19 @@ void SaveLevel()
file.WriteBE<int32_t>(ActiveMonsterCount);
file.WriteBE<int32_t>(ActiveItemCount);
file.WriteBE<int32_t>(nobjects);
file.WriteBE<int32_t>(ActiveObjectCount);
if (leveltype != DTYPE_TOWN) {
for (int monsterId : ActiveMonsters)
file.WriteBE<int32_t>(monsterId);
for (int i = 0; i < ActiveMonsterCount; i++)
SaveMonster(&file, ActiveMonsters[i]);
for (int objectId : objectactive)
for (int objectId : ActiveObjects)
file.WriteLE<int8_t>(objectId);
for (int objectId : objectavail)
for (int objectId : AvailableObjects)
file.WriteLE<int8_t>(objectId);
for (int i = 0; i < nobjects; i++)
SaveObject(&file, objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SaveObject(&file, ActiveObjects[i]);
}
for (int itemId : ActiveItems)
@ -2135,22 +2135,22 @@ void LoadLevel()
ActiveMonsterCount = file.NextBE<int32_t>();
ActiveItemCount = file.NextBE<int32_t>();
nobjects = file.NextBE<int32_t>();
ActiveObjectCount = file.NextBE<int32_t>();
if (leveltype != DTYPE_TOWN) {
for (int &monsterId : ActiveMonsters)
monsterId = file.NextBE<int32_t>();
for (int i = 0; i < ActiveMonsterCount; i++)
LoadMonster(&file, ActiveMonsters[i]);
for (int &objectId : objectactive)
for (int &objectId : ActiveObjects)
objectId = file.NextLE<int8_t>();
for (int &objectId : objectavail)
for (int &objectId : AvailableObjects)
objectId = file.NextLE<int8_t>();
for (int i = 0; i < nobjects; i++)
LoadObject(&file, objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
LoadObject(&file, ActiveObjects[i]);
if (!gbSkipSync) {
for (int i = 0; i < nobjects; i++)
SyncObjectAnim(objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SyncObjectAnim(ActiveObjects[i]);
}
}

8
Source/missiles.cpp

@ -1014,8 +1014,8 @@ void CheckMissileCol(int i, int mindam, int maxdam, bool shift, Point position,
}
if (dObject[mx][my] != 0) {
int oi = dObject[mx][my] > 0 ? dObject[mx][my] - 1 : -(dObject[mx][my] + 1);
if (!object[oi]._oMissFlag) {
if (object[oi]._oBreak == 1)
if (!Objects[oi]._oMissFlag) {
if (Objects[oi]._oBreak == 1)
BreakObject(-1, oi);
if (!nodel)
Missiles[i]._mirange = 0;
@ -1899,7 +1899,7 @@ void AddRndTeleport(int mi, Point src, Point dst, int /*midir*/, int8_t mienemy,
} else {
int oi = dObject[dst.x][dst.y] - 1;
// BUGFIX: should only run magic circle check if dObject[dx][dy] is non-zero.
if (object[oi]._otype == OBJ_MCIRCLE1 || object[oi]._otype == OBJ_MCIRCLE2) {
if (Objects[oi]._otype == OBJ_MCIRCLE1 || Objects[oi]._otype == OBJ_MCIRCLE2) {
Missiles[mi].position.tile = dst;
if (!PosOkPlayer(MyPlayerId, dst))
UpdateVileMissPos(mi, dst);
@ -3263,7 +3263,7 @@ void MI_Lightball(int i)
int8_t obj = dObject[tx][ty];
if (obj != 0 && tx == Missiles[i].position.tile.x && ty == Missiles[i].position.tile.y) {
int oi = (obj > 0) ? (obj - 1) : -(obj + 1);
if (object[oi]._otype == OBJ_SHRINEL || object[oi]._otype == OBJ_SHRINER)
if (Objects[oi]._otype == OBJ_SHRINEL || Objects[oi]._otype == OBJ_SHRINER)
Missiles[i]._mirange = j;
}
if (Missiles[i]._mirange == 0)

8
Source/monster.cpp

@ -1262,7 +1262,7 @@ void AddDoppelganger(MonsterStruct &monster)
break;
}
int oi = dObject[position.x][position.y] > 0 ? dObject[position.x][position.y] - 1 : -(dObject[position.x][position.y] + 1);
if (!object[oi]._oSolidFlag) {
if (!Objects[oi]._oSolidFlag) {
target = position;
break;
}
@ -4958,7 +4958,7 @@ bool PosOkMonst2(int i, Point position)
if (dObject[position.x][position.y] != 0) {
int oi = dObject[position.x][position.y] > 0 ? dObject[position.x][position.y] - 1 : -(dObject[position.x][position.y] + 1);
if (object[oi]._oSolidFlag)
if (Objects[oi]._oSolidFlag)
return false;
}
@ -4970,8 +4970,8 @@ bool PosOkMonst3(int i, Point position)
bool isdoor = false;
if (dObject[position.x][position.y] != 0) {
int oi = dObject[position.x][position.y] > 0 ? dObject[position.x][position.y] - 1 : -(dObject[position.x][position.y] + 1);
isdoor = IsAnyOf(object[oi]._otype, OBJ_L1LDOOR, OBJ_L1RDOOR, OBJ_L2LDOOR, OBJ_L2RDOOR, OBJ_L3LDOOR, OBJ_L3RDOOR);
if (object[oi]._oSolidFlag && !isdoor)
isdoor = IsAnyOf(Objects[oi]._otype, OBJ_L1LDOOR, OBJ_L1RDOOR, OBJ_L2LDOOR, OBJ_L2RDOOR, OBJ_L3LDOOR, OBJ_L3RDOOR);
if (Objects[oi]._oSolidFlag && !isdoor)
return false;
}

10
Source/msg.cpp

@ -1007,7 +1007,7 @@ DWORD OnOperateObjectTile(TCmd *pCmd, int pnum)
auto *p = (TCmdLocParam1 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == Players[pnum].plrlevel) {
if (object[p->wParam1]._oSolidFlag || object[p->wParam1]._oDoorFlag)
if (Objects[p->wParam1]._oSolidFlag || Objects[p->wParam1]._oDoorFlag)
MakePlrPath(pnum, { p->x, p->y }, false);
else
MakePlrPath(pnum, { p->x, p->y }, true);
@ -1023,7 +1023,7 @@ DWORD OnDisarm(TCmd *pCmd, int pnum)
auto *p = (TCmdLocParam1 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == Players[pnum].plrlevel) {
if (object[p->wParam1]._oSolidFlag || object[p->wParam1]._oDoorFlag)
if (Objects[p->wParam1]._oSolidFlag || Objects[p->wParam1]._oDoorFlag)
MakePlrPath(pnum, { p->x, p->y }, false);
else
MakePlrPath(pnum, { p->x, p->y }, true);
@ -2142,10 +2142,10 @@ void DeltaLoadLevel()
}
}
for (int i = 0; i < nobjects; i++) {
int ot = object[objectactive[i]]._otype;
for (int i = 0; i < ActiveObjectCount; i++) {
int ot = Objects[ActiveObjects[i]]._otype;
if (ot == OBJ_TRAPL || ot == OBJ_TRAPR)
Obj_Trap(objectactive[i]);
Obj_Trap(ActiveObjects[i]);
}
}
deltaload = false;

1356
Source/objects.cpp

File diff suppressed because it is too large Load Diff

12
Source/objects.h

@ -51,12 +51,12 @@ struct ObjectStruct {
int _oVar8;
};
extern int objectactive[MAXOBJECTS];
extern int nobjects;
extern int objectavail[MAXOBJECTS];
extern ObjectStruct object[MAXOBJECTS];
extern bool InitObjFlag;
extern bool LoadMapObjsFlag;
extern ObjectStruct Objects[MAXOBJECTS];
extern int AvailableObjects[MAXOBJECTS];
extern int ActiveObjects[MAXOBJECTS];
extern int ActiveObjectCount;
extern bool ApplyObjectLighting;
extern bool LoadingMapObjects;
void InitObjectGFX();
void FreeObjectGFX();

42
Source/player.cpp

@ -2585,7 +2585,7 @@ bool PlrHitObj(int pnum, int mx, int my)
oi = -dObject[mx][my] - 1;
}
if (object[oi]._oBreak == 1) {
if (Objects[oi]._oBreak == 1) {
BreakObject(pnum, oi);
return true;
}
@ -3128,14 +3128,14 @@ void CheckNewPath(int pnum, bool pmWillBeCalled)
} break;
case ACTION_OPERATE:
i = player.destParam1;
x = abs(player.position.tile.x - object[i].position.x);
y = abs(player.position.tile.y - object[i].position.y);
if (y > 1 && dObject[object[i].position.x][object[i].position.y - 1] == -(i + 1)) {
y = abs(player.position.tile.y - object[i].position.y + 1);
x = abs(player.position.tile.x - Objects[i].position.x);
y = abs(player.position.tile.y - Objects[i].position.y);
if (y > 1 && dObject[Objects[i].position.x][Objects[i].position.y - 1] == -(i + 1)) {
y = abs(player.position.tile.y - Objects[i].position.y + 1);
}
if (x <= 1 && y <= 1) {
if (object[i]._oBreak == 1) {
d = GetDirection(player.position.tile, object[i].position);
if (Objects[i]._oBreak == 1) {
d = GetDirection(player.position.tile, Objects[i].position);
StartAttack(pnum, d);
} else {
OperateObject(pnum, i, false);
@ -3144,14 +3144,14 @@ void CheckNewPath(int pnum, bool pmWillBeCalled)
break;
case ACTION_DISARM:
i = player.destParam1;
x = abs(player.position.tile.x - object[i].position.x);
y = abs(player.position.tile.y - object[i].position.y);
if (y > 1 && dObject[object[i].position.x][object[i].position.y - 1] == -(i + 1)) {
y = abs(player.position.tile.y - object[i].position.y + 1);
x = abs(player.position.tile.x - Objects[i].position.x);
y = abs(player.position.tile.y - Objects[i].position.y);
if (y > 1 && dObject[Objects[i].position.x][Objects[i].position.y - 1] == -(i + 1)) {
y = abs(player.position.tile.y - Objects[i].position.y + 1);
}
if (x <= 1 && y <= 1) {
if (object[i]._oBreak == 1) {
d = GetDirection(player.position.tile, object[i].position);
if (Objects[i]._oBreak == 1) {
d = GetDirection(player.position.tile, Objects[i].position);
StartAttack(pnum, d);
} else {
TryDisarm(pnum, i);
@ -3161,7 +3161,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled)
break;
case ACTION_OPERATETK:
i = player.destParam1;
if (object[i]._oBreak != 1) {
if (Objects[i]._oBreak != 1) {
OperateObject(pnum, i, true);
}
break;
@ -3226,14 +3226,14 @@ void CheckNewPath(int pnum, bool pmWillBeCalled)
player.destAction = ACTION_NONE;
} else if (player.destAction == ACTION_OPERATE) {
i = player.destParam1;
x = abs(player.position.tile.x - object[i].position.x);
y = abs(player.position.tile.y - object[i].position.y);
if (y > 1 && dObject[object[i].position.x][object[i].position.y - 1] == -(i + 1)) {
y = abs(player.position.tile.y - object[i].position.y + 1);
x = abs(player.position.tile.x - Objects[i].position.x);
y = abs(player.position.tile.y - Objects[i].position.y);
if (y > 1 && dObject[Objects[i].position.x][Objects[i].position.y - 1] == -(i + 1)) {
y = abs(player.position.tile.y - Objects[i].position.y + 1);
}
if (x <= 1 && y <= 1) {
if (object[i]._oBreak == 1) {
d = GetDirection(player.position.tile, object[i].position);
if (Objects[i]._oBreak == 1) {
d = GetDirection(player.position.tile, Objects[i].position);
StartAttack(pnum, d);
}
}
@ -3528,7 +3528,7 @@ bool PosOkPlayer(int pnum, Point position)
} else {
bv = -(dObject[position.x][position.y] + 1);
}
if (object[bv]._oSolidFlag) {
if (Objects[bv]._oSolidFlag) {
return false;
}
}

12
Source/quests.cpp

@ -645,8 +645,8 @@ void ResyncQuests()
setpc_w + setpc_x + 1,
setpc_h + setpc_y + 1);
ObjChangeMapResync(setpc_x, setpc_y, (setpc_w / 2) + setpc_x + 2, (setpc_h / 2) + setpc_y - 2);
for (int i = 0; i < nobjects; i++)
SyncObjectAnim(objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SyncObjectAnim(ActiveObjects[i]);
auto tren = TransVal;
TransVal = 9;
DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w / 2) + setpc_x + 4, setpc_y + (setpc_h / 2));
@ -656,8 +656,8 @@ void ResyncQuests()
int x = setpc_x;
int y = setpc_y;
ObjChangeMapResync(x, y, x + setpc_w + 1, y + setpc_h + 1);
for (int i = 0; i < nobjects; i++)
SyncObjectAnim(objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SyncObjectAnim(ActiveObjects[i]);
auto tren = TransVal;
TransVal = 9;
DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w / 2) + setpc_x + 4, setpc_y + (setpc_h / 2));
@ -690,8 +690,8 @@ void ResyncQuests()
ObjChangeMapResync(1, 18, 20, 24);
if (Quests[Q_BETRAYER]._qvar1 >= 7)
InitVPTriggers();
for (int i = 0; i < nobjects; i++)
SyncObjectAnim(objectactive[i]);
for (int i = 0; i < ActiveObjectCount; i++)
SyncObjectAnim(ActiveObjects[i]);
}
if (currlevel == Quests[Q_BETRAYER]._qlevel
&& !setlevel

32
Source/scrollrt.cpp

@ -72,7 +72,7 @@ bool CouldMissileCollide(Point tile, bool checkPlayerAndMonster)
int oid = dObject[tile.x][tile.y];
if (oid != 0) {
oid = oid > 0 ? oid - 1 : -(oid + 1);
if (!object[oid]._oMissFlag)
if (!Objects[oid]._oMissFlag)
return true;
}
if (nMissileTable[dPiece[tile.x][tile.y]])
@ -620,42 +620,42 @@ static void DrawObject(const Surface &out, int x, int y, int ox, int oy, bool pr
int8_t bv = -1;
if (dObject[x][y] > 0) {
bv = dObject[x][y] - 1;
if (object[bv]._oPreFlag != pre)
if (Objects[bv]._oPreFlag != pre)
return;
objectPosition.x = ox - CalculateWidth2(object[bv]._oAnimWidth);
objectPosition.x = ox - CalculateWidth2(Objects[bv]._oAnimWidth);
objectPosition.y = oy;
} else {
bv = -(dObject[x][y] + 1);
if (object[bv]._oPreFlag != pre)
if (Objects[bv]._oPreFlag != pre)
return;
int xx = object[bv].position.x - x;
int yy = object[bv].position.y - y;
objectPosition.x = (xx * TILE_WIDTH / 2) + ox - CalculateWidth2(object[bv]._oAnimWidth) - (yy * TILE_WIDTH / 2);
int xx = Objects[bv].position.x - x;
int yy = Objects[bv].position.y - y;
objectPosition.x = (xx * TILE_WIDTH / 2) + ox - CalculateWidth2(Objects[bv]._oAnimWidth) - (yy * TILE_WIDTH / 2);
objectPosition.y = oy + (yy * TILE_HEIGHT / 2) + (xx * TILE_HEIGHT / 2);
}
assert(bv >= 0 && bv < MAXOBJECTS);
byte *pCelBuff = object[bv]._oAnimData;
byte *pCelBuff = Objects[bv]._oAnimData;
if (pCelBuff == nullptr) {
Log("Draw Object type {}: NULL Cel Buffer", object[bv]._otype);
Log("Draw Object type {}: NULL Cel Buffer", Objects[bv]._otype);
return;
}
uint32_t nCel = object[bv]._oAnimFrame;
uint32_t nCel = Objects[bv]._oAnimFrame;
uint32_t frames = LoadLE32(pCelBuff);
if (nCel < 1 || frames > 50 || nCel > frames) {
Log("Draw Object: frame {} of {}, object type=={}", nCel, frames, object[bv]._otype);
Log("Draw Object: frame {} of {}, object type=={}", nCel, frames, Objects[bv]._otype);
return;
}
CelSprite cel { object[bv]._oAnimData, object[bv]._oAnimWidth };
CelSprite cel { Objects[bv]._oAnimData, Objects[bv]._oAnimWidth };
if (bv == pcursobj)
CelBlitOutlineTo(out, 194, objectPosition, cel, object[bv]._oAnimFrame);
if (object[bv]._oLight) {
CelClippedDrawLightTo(out, objectPosition, cel, object[bv]._oAnimFrame);
CelBlitOutlineTo(out, 194, objectPosition, cel, Objects[bv]._oAnimFrame);
if (Objects[bv]._oLight) {
CelClippedDrawLightTo(out, objectPosition, cel, Objects[bv]._oAnimFrame);
} else {
CelClippedDrawTo(out, objectPosition, cel, object[bv]._oAnimFrame);
CelClippedDrawTo(out, objectPosition, cel, Objects[bv]._oAnimFrame);
}
}

6
Source/setmaps.cpp

@ -87,9 +87,9 @@ int ObjIndex(int x, int y)
int i;
int oi;
for (i = 0; i < nobjects; i++) {
oi = objectactive[i];
if (object[oi].position.x == x && object[oi].position.y == y)
for (i = 0; i < ActiveObjectCount; i++) {
oi = ActiveObjects[i];
if (Objects[oi].position.x == x && Objects[oi].position.y == y)
return oi;
}
app_fatal("ObjIndex: Active object not found at (%i,%i)", x, y);

8
Source/themes.cpp

@ -721,8 +721,8 @@ void Theme_Library(int t)
AddObject(OBJ_BOOKSTAND, xp, yp);
if (GenerateRnd(2 * librnd[leveltype - 1]) != 0 && dObject[xp][yp] != 0) { /// BUGFIX: check dObject[xp][yp] was populated by AddObject (fixed)
int oi = dObject[xp][yp] - 1;
object[oi]._oSelFlag = 0;
object[oi]._oAnimFrame += 2;
Objects[oi]._oSelFlag = 0;
Objects[oi]._oAnimFrame += 2;
}
}
}
@ -977,7 +977,7 @@ void CreateThemeRooms()
if (currlevel == 16) {
return;
}
InitObjFlag = true;
ApplyObjectLighting = true;
for (int i = 0; i < numthemes; i++) {
themex = 0;
themey = 0;
@ -1037,7 +1037,7 @@ void CreateThemeRooms()
app_fatal("Unknown theme type: %i", themes[i].ttype);
}
}
InitObjFlag = false;
ApplyObjectLighting = false;
if (leveltype == DTYPE_HELL && themeCount > 0) {
UpdateL4Trans();
}

Loading…
Cancel
Save