Browse Source

Replace ReturnLevel/LevelTyp/LvlPosition

pull/5879/merge
obligaron 3 years ago committed by Anders Jenbo
parent
commit
4cdd7ff2d9
  1. 14
      Source/debug.cpp
  2. 7
      Source/diablo.cpp
  3. 8
      Source/interfac.cpp
  4. 2
      Source/levels/trigs.cpp
  5. 52
      Source/quests.cpp
  6. 4
      Source/quests.h
  7. 6
      test/drlg_l4_test.cpp

14
Source/debug.cpp

@ -242,16 +242,6 @@ std::string DebugCmdLoadQuestMap(const string_view parameter)
if (level != quest._qslvl)
continue;
if (!MyPlayer->isOnLevel(quest._qlevel)) {
StartNewLvl(*MyPlayer, (quest._qlevel != 21) ? interface_mode::WM_DIABNEXTLVL : interface_mode::WM_DIABTOWNWARP, quest._qlevel);
ProcessMessages();
// Workaround for SDL_PollEvent:
// StartNewLvl pushes a new event with SDL_PushEvent.
// ProcessMessages calls SDL_PollEvent but SDL ignores the new pushed event.
// Calling SDL_PollEvent again fixes this.
ProcessMessages();
}
setlvltype = quest._qlvltype;
StartNewLvl(*MyPlayer, WM_DIABSETLVL, level);
@ -289,10 +279,6 @@ std::string DebugCmdLoadMap(const string_view parameter)
if (TestMapPath.empty() || mapType < DTYPE_CATHEDRAL || mapType > DTYPE_LAST || !InDungeonBounds(spawn))
return "Directions not understood";
ReturnLvlPosition = ViewPosition;
ReturnLevel = currlevel;
ReturnLevelType = leveltype;
setlvltype = static_cast<dungeon_type>(mapType);
ViewPosition = spawn;

7
Source/diablo.cpp

@ -2759,8 +2759,11 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
IncProgress();
if (lvldir == ENTRY_RTNLVL)
GetReturnLvlPos();
if (lvldir == ENTRY_RTNLVL) {
ViewPosition = GetMapReturnPosition();
if (Quests[Q_BETRAYER]._qactive == QUEST_DONE)
Quests[Q_BETRAYER]._qvar2 = 2;
}
if (lvldir == ENTRY_WARPLVL)
GetPortalLvlPos();

8
Source/interfac.cpp

@ -371,7 +371,10 @@ void ShowProgress(interface_mode uMsg)
IncProgress();
break;
case WM_DIABSETLVL:
SetReturnLvlPos();
// Note: ReturnLevel, ReturnLevelType and ReturnLvlPosition is only set to ensure vanilla compatibility
ReturnLevel = GetMapReturnLevel();
ReturnLevelType = GetLevelType(ReturnLevel);
ReturnLvlPosition = GetMapReturnPosition();
IncProgress();
if (!gbIsMultiplayer) {
pfile_save_level();
@ -398,7 +401,8 @@ void ShowProgress(interface_mode uMsg)
setlevel = false;
FreeGameMem();
IncProgress();
GetReturnLvlPos();
currlevel = GetMapReturnLevel();
leveltype = GetLevelType(currlevel);
LoadGameLevel(false, ENTRY_RTNLVL);
IncProgress();
break;

2
Source/levels/trigs.cpp

@ -881,7 +881,7 @@ void CheckTriggers()
StartNewLvl(myPlayer, trigs[i]._tmsg, currlevel - 1);
break;
case WM_DIABRTNLVL:
StartNewLvl(myPlayer, trigs[i]._tmsg, ReturnLevel);
StartNewLvl(myPlayer, trigs[i]._tmsg, GetMapReturnLevel());
break;
case WM_DIABTOWNWARP:
if (gbIsMultiplayer) {

52
Source/quests.cpp

@ -498,50 +498,36 @@ void DRLG_CheckQuests(Point position)
}
}
void SetReturnLvlPos()
int GetMapReturnLevel()
{
switch (setlvlnum) {
case SL_SKELKING:
ReturnLvlPosition = Quests[Q_SKELKING].position + Direction::SouthEast;
ReturnLevel = Quests[Q_SKELKING]._qlevel;
ReturnLevelType = DTYPE_CATHEDRAL;
break;
return Quests[Q_SKELKING]._qlevel;
case SL_BONECHAMB:
ReturnLvlPosition = Quests[Q_SCHAMB].position + Direction::SouthEast;
ReturnLevel = Quests[Q_SCHAMB]._qlevel;
ReturnLevelType = DTYPE_CATACOMBS;
break;
case SL_MAZE:
break;
return Quests[Q_SCHAMB]._qlevel;
case SL_POISONWATER:
ReturnLvlPosition = Quests[Q_PWATER].position + Direction::SouthWest;
ReturnLevel = Quests[Q_PWATER]._qlevel;
ReturnLevelType = DTYPE_CATHEDRAL;
break;
return Quests[Q_PWATER]._qlevel;
case SL_VILEBETRAYER:
ReturnLvlPosition = Quests[Q_BETRAYER].position + Direction::South;
ReturnLevel = Quests[Q_BETRAYER]._qlevel;
ReturnLevelType = DTYPE_HELL;
break;
case SL_NONE:
break;
return Quests[Q_BETRAYER]._qlevel;
default:
if (IsArenaLevel(setlvlnum)) {
ReturnLvlPosition = Towners[TOWN_DRUNK].position + Displacement { 1, 0 };
ReturnLevel = 0;
ReturnLevelType = DTYPE_TOWN;
}
break;
return 0;
}
}
void GetReturnLvlPos()
Point GetMapReturnPosition()
{
if (Quests[Q_BETRAYER]._qactive == QUEST_DONE)
Quests[Q_BETRAYER]._qvar2 = 2;
ViewPosition = ReturnLvlPosition;
currlevel = ReturnLevel;
leveltype = ReturnLevelType;
switch (setlvlnum) {
case SL_SKELKING:
return Quests[Q_SKELKING].position + Direction::SouthEast;
case SL_BONECHAMB:
return Quests[Q_SCHAMB].position + Direction::SouthEast;
case SL_POISONWATER:
return Quests[Q_PWATER].position + Direction::SouthWest;
case SL_VILEBETRAYER:
return Quests[Q_BETRAYER].position + Direction::South;
default:
return Towners[TOWN_DRUNK].position + Displacement { 1, 0 };
}
}
void LoadPWaterPalette()

4
Source/quests.h

@ -125,8 +125,8 @@ void CheckQuests();
bool ForceQuests();
void CheckQuestKill(const Monster &monster, bool sendmsg);
void DRLG_CheckQuests(Point position);
void SetReturnLvlPos();
void GetReturnLvlPos();
int GetMapReturnLevel();
Point GetMapReturnPosition();
void LoadPWaterPalette();
void UpdatePWaterPalette();
void ResyncMPQuests();

6
test/drlg_l4_test.cpp

@ -65,7 +65,7 @@ TEST(Drlg_l4, CreateL4Dungeon_diablo_15_1583642716)
Quests[Q_BETRAYER]._qactive = QUEST_ACTIVE;
TestCreateDungeon(15, 1583642716, ENTRY_MAIN); // Betrayer quest does not change level gen
EXPECT_EQ(ViewPosition, Point(44, 26));
EXPECT_EQ(Quests[Q_BETRAYER].position, Point(34, 24)) << "Ensure the portal to lazarus has a spawn position if the player has activated the quest";
EXPECT_EQ(Quests[Q_BETRAYER].position, Point(84, 64)) << "Ensure the portal to lazarus has a spawn position if the player has activated the quest";
LoadExpectedLevelData("diablo/15-1583642716-changed.dun");
@ -74,10 +74,10 @@ TEST(Drlg_l4, CreateL4Dungeon_diablo_15_1583642716)
TestCreateDungeon(15, 1583642716, ENTRY_MAIN);
EXPECT_EQ(ViewPosition, Point(44, 26));
EXPECT_EQ(Quests[Q_BETRAYER].position, Point(34, 24)) << "Not really required? current bugfix sets this position anyway";
EXPECT_EQ(Quests[Q_BETRAYER].position, Point(84, 64)) << "Not really required? current bugfix sets this position anyway";
TestCreateDungeon(15, 1583642716, ENTRY_PREV);
EXPECT_EQ(ViewPosition, Point(88, 67));
EXPECT_EQ(Quests[Q_BETRAYER].position, Point(34, 24)) << "Not really required? current bugfix sets this position anyway";
EXPECT_EQ(Quests[Q_BETRAYER].position, Point(84, 64)) << "Not really required? current bugfix sets this position anyway";
}
TEST(Drlg_l4, CreateL4Dungeon_diablo_15_1256511996)

Loading…
Cancel
Save