Skip to content

Commit

Permalink
Rename glSeedTbl
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills authored and AJenbo committed Mar 6, 2024
1 parent 9879be0 commit 9e682af
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ std::string TextCmdLevelSeed(const std::string_view parameter)

return StrCat(
"Seedinfo for ", levelType, " ", currlevel, "\n",
"seed: ", glSeedTbl[currlevel], "\n",
"seed: ", DungeonSeeds[currlevel], "\n",
#ifdef _DEBUG
"Mid1: ", glMid1Seed[currlevel], "\n",
"Mid2: ", glMid2Seed[currlevel], "\n",
Expand All @@ -546,7 +546,7 @@ std::string TextCmdLevelSeed(const std::string_view parameter)
"\n",
gameId, " ", mode, "\n",
questPool, " quests: ", questFlags, "\n",
"Storybook: ", glSeedTbl[16]);
"Storybook: ", DungeonSeeds[16]);
}

std::vector<TextCmdItem> TextCmdList = {
Expand Down
14 changes: 7 additions & 7 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

namespace devilution {

uint32_t glSeedTbl[NUMLEVELS];
uint32_t DungeonSeeds[NUMLEVELS];
Point MousePosition;
bool gbRunGame;
bool gbRunGameResult;
Expand Down Expand Up @@ -1339,7 +1339,7 @@ void LoadAllGFX()
*/
void CreateLevel(lvl_entry entry)
{
CreateDungeon(glSeedTbl[currlevel], entry);
CreateDungeon(DungeonSeeds[currlevel], entry);

switch (leveltype) {
case DTYPE_TOWN:
Expand Down Expand Up @@ -2837,7 +2837,7 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) {
NewCursor(CURSOR_HAND);
}
SetRndSeed(glSeedTbl[currlevel]);
SetRndSeed(DungeonSeeds[currlevel]);
IncProgress();
MakeLightTable();
SetDungeonMicros();
Expand All @@ -2857,12 +2857,12 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
InitAutomapOnce();
}
if (!setlevel) {
SetRndSeed(glSeedTbl[currlevel]);
SetRndSeed(DungeonSeeds[currlevel]);
} else {
// Maps are not randomly generated, but the monsters max hitpoints are.
// So we need to ensure that we have a stable seed when generating quest/set-maps.
// For this purpose we reuse the normal dungeon seeds.
SetRndSeed(glSeedTbl[static_cast<size_t>(setlvlnum)]);
SetRndSeed(DungeonSeeds[static_cast<size_t>(setlvlnum)]);
}

if (leveltype == DTYPE_TOWN) {
Expand Down Expand Up @@ -2894,7 +2894,7 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
CreateLevel(lvldir);
IncProgress();
LoadLevelSOLData();
SetRndSeed(glSeedTbl[currlevel]);
SetRndSeed(DungeonSeeds[currlevel]);

if (leveltype != DTYPE_TOWN) {
GetLevelMTypes();
Expand Down Expand Up @@ -2942,7 +2942,7 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
visited = visited || player._pLvlVisited[currlevel];
}

SetRndSeed(glSeedTbl[currlevel]);
SetRndSeed(DungeonSeeds[currlevel]);

if (leveltype != DTYPE_TOWN) {
if (firstflag || lvldir == ENTRY_LOAD || !myPlayer._pLvlVisited[currlevel] || gbIsMultiplayer) {
Expand Down
2 changes: 1 addition & 1 deletion Source/diablo.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum class MouseActionType : uint8_t {
OperateObject,
};

extern uint32_t glSeedTbl[NUMLEVELS];
extern uint32_t DungeonSeeds[NUMLEVELS];
extern Point MousePosition;
extern DVL_API_FOR_TEST bool gbRunGame;
extern bool gbRunGameResult;
Expand Down
6 changes: 3 additions & 3 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,7 @@ void LoadGame(bool firstflag)
app_fatal(_("Player is on a Hellfire only level"));

for (uint8_t i = 0; i < giNumberOfLevels; i++) {
glSeedTbl[i] = file.NextBE<uint32_t>();
DungeonSeeds[i] = file.NextBE<uint32_t>();
file.Skip(4); // Skip loading gnLevelTypeTbl
}

Expand Down Expand Up @@ -2418,7 +2418,7 @@ void SaveGameData(SaveWriter &saveWriter)
file.WriteBE<int32_t>(ActiveObjectCount);

for (uint8_t i = 0; i < giNumberOfLevels; i++) {
file.WriteBE<uint32_t>(glSeedTbl[i]);
file.WriteBE<uint32_t>(DungeonSeeds[i]);
file.WriteBE<int32_t>(getHellfireLevelType(GetLevelType(i)));
}

Expand Down Expand Up @@ -2554,7 +2554,7 @@ void SaveLevel(SaveWriter &saveWriter)
DoUnVision(myPlayer.position.tile, myPlayer._pLightRad); // fix for vision staying on the level

if (leveltype == DTYPE_TOWN)
glSeedTbl[0] = AdvanceRndSeed();
DungeonSeeds[0] = AdvanceRndSeed();

char szName[MaxMpqPathSize];
GetTempLevelNames(szName);
Expand Down
8 changes: 4 additions & 4 deletions Source/lua/modules/dev/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace {

std::string ExportDun()
{
const std::string levelName = StrCat(currlevel, "-", glSeedTbl[currlevel], ".dun");
const std::string levelName = StrCat(currlevel, "-", DungeonSeeds[currlevel], ".dun");
FILE *dunFile = OpenFile(levelName.c_str(), "ab");

WriteLE16(dunFile, DMAXX);
Expand Down Expand Up @@ -101,19 +101,19 @@ std::string DebugCmdResetLevel(uint8_t level, std::optional<int> seed)
DeltaClearLevel(level);

if (seed.has_value()) {
glSeedTbl[level] = *seed;
DungeonSeeds[level] = *seed;
return StrCat("Successfully reset level ", level, " with seed ", *seed, ".");
}
return StrCat("Successfully reset level ", level, ".");
}

std::string DebugCmdLevelSeed(std::optional<uint8_t> level)
{
constexpr size_t NumLevels = sizeof(glSeedTbl) / sizeof(glSeedTbl[0]);
constexpr size_t NumLevels = sizeof(DungeonSeeds) / sizeof(DungeonSeeds[0]);
if (level.has_value() && *level >= NumLevels) {
return StrCat("level out of range, max: ", NumLevels - 1);
}
return StrCat(glSeedTbl[level.value_or(currlevel)]);
return StrCat(DungeonSeeds[level.value_or(currlevel)]);
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ void DeltaLeaveSync(uint8_t bLevel)
if (!gbIsMultiplayer)
return;
if (leveltype == DTYPE_TOWN) {
glSeedTbl[0] = AdvanceRndSeed();
DungeonSeeds[0] = AdvanceRndSeed();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ bool NetInit(bool bSinglePlayer)
gnTickDelay = 1000 / sgGameInitInfo.nTickRate;

for (int i = 0; i < NUMLEVELS; i++) {
glSeedTbl[i] = AdvanceRndSeed();
DungeonSeeds[i] = AdvanceRndSeed();
}
PublicGame = DvlNet_IsPublicGame();

Expand Down
2 changes: 1 addition & 1 deletion Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ void AddPedestalOfBlood(Object &pedestalOfBlood)

void AddStoryBook(Object &storyBook)
{
storyBook._oVar1 = (glSeedTbl[16] >> 16) % 3;
storyBook._oVar1 = (DungeonSeeds[16] >> 16) % 3;
if (currlevel == 4)
storyBook._oVar2 = StoryText[storyBook._oVar1][0];
else if (currlevel == 8)
Expand Down
2 changes: 1 addition & 1 deletion Source/quests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void InitQuests()

if (!UseMultiplayerQuests() && *sgOptions.Gameplay.randomizeQuests) {
// Quests are set from the seed used to generate level 16.
InitialiseQuestPools(glSeedTbl[15], Quests);
InitialiseQuestPools(DungeonSeeds[15], Quests);
}

if (gbIsSpawn) {
Expand Down
2 changes: 1 addition & 1 deletion Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ void SetupTownStores()
l = i;
}
} else {
SetRndSeed(glSeedTbl[currlevel] * SDL_GetTicks());
SetRndSeed(DungeonSeeds[currlevel] * SDL_GetTicks());
}

l = std::clamp(l + 2, 6, 16);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/memory_map/levelSeed.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
R 32 glSeedTbl
R 32 DungeonSeeds
R 32 gnLevelTypeTbl

0 comments on commit 9e682af

Please sign in to comment.