Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMake/Assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ set(devilutionx_assets
txtdata/sound/effects.tsv
txtdata/spells/spelldat.tsv
txtdata/text/textdat.tsv
txtdata/towners/quest_dialog.tsv
txtdata/towners/towners.tsv
ui_art/diablo.pal
ui_art/creditsw.clx
ui_art/dvl_but_sml.clx
Expand Down
2 changes: 2 additions & 0 deletions CMake/Mods.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(hellfire_mod
txtdata/monsters/monstdat.tsv
txtdata/sound/effects.tsv
txtdata/spells/spelldat.tsv
txtdata/towners/quest_dialog.tsv
txtdata/towners/towners.tsv
ui_art/diablo.pal
ui_art/hf_titlew.clx
ui_art/supportw.clx
Expand Down
1 change: 1 addition & 0 deletions CMake/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set(tests
stores_test
tile_properties_test
timedemo_test
townerdat_test
writehero_test
vendor_test
)
Expand Down
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(libdevilutionx_SRCS
sync.cpp
textdat.cpp
tmsg.cpp
townerdat.cpp
towners.cpp
track.cpp

Expand Down
41 changes: 24 additions & 17 deletions Source/lua/modules/towners.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
#include "lua/modules/towners.hpp"

#include <optional>
#include <unordered_map>
#include <utility>

#include <sol/sol.hpp>

Check warning on line 7 in Source/lua/modules/towners.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/lua/modules/towners.cpp:7:1 [misc-include-cleaner]

included header sol.hpp is not used directly

#include "engine/point.hpp"
#include "lua/metadoc.hpp"
#include "player.h"

Check warning on line 11 in Source/lua/modules/towners.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/lua/modules/towners.cpp:11:1 [misc-include-cleaner]

included header player.h is not used directly
#include "towners.h"

namespace devilution {
namespace {

const char *const TownerTableNames[NUM_TOWNER_TYPES] {
"griswold",
"pepin",
"deadguy",
"ogden",
"cain",
"farnham",
"adria",
"gillian",
"wirt",
"cow",
"lester",
"celia",
"nut",
// Map from towner type enum to Lua table name
const std::unordered_map<_talker_id, const char *> TownerTableNames = {
{ TOWN_SMITH, "griswold" },
{ TOWN_HEALER, "pepin" },
{ TOWN_DEADGUY, "deadguy" },
{ TOWN_TAVERN, "ogden" },
{ TOWN_STORY, "cain" },
{ TOWN_DRUNK, "farnham" },
{ TOWN_WITCH, "adria" },
{ TOWN_BMAID, "gillian" },
{ TOWN_PEGBOY, "wirt" },
{ TOWN_COW, "cow" },
{ TOWN_FARMER, "lester" },
{ TOWN_GIRL, "celia" },
{ TOWN_COWFARM, "nut" },
};

void PopulateTownerTable(_talker_id townerId, sol::table &out)

Check warning on line 34 in Source/lua/modules/towners.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/lua/modules/towners.cpp:34:52 [misc-include-cleaner]

no header providing "sol::table" is directly included
{
LuaSetDocFn(out, "position", "()",
"Returns towner coordinates",
Expand All @@ -41,13 +43,18 @@
}
} // namespace

sol::table LuaTownersModule(sol::state_view &lua)

Check warning on line 46 in Source/lua/modules/towners.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/lua/modules/towners.cpp:46:34 [misc-include-cleaner]

no header providing "sol::state_view" is directly included
{
sol::table table = lua.create_table();
for (uint8_t townerId = TOWN_SMITH; townerId < NUM_TOWNER_TYPES; ++townerId) {
// Iterate over all towner types found in TSV data
for (const auto &[townerId, name] : TownerLongNames) {
auto tableNameIt = TownerTableNames.find(townerId);
if (tableNameIt == TownerTableNames.end())
continue; // Skip if no table name mapping

sol::table townerTable = lua.create_table();
PopulateTownerTable(static_cast<_talker_id>(townerId), townerTable);
LuaSetDoc(table, TownerTableNames[townerId], /*signature=*/"", TownerLongNames[townerId], std::move(townerTable));
PopulateTownerTable(townerId, townerTable);
LuaSetDoc(table, tableNameIt->second, /*signature=*/"", name.c_str(), std::move(townerTable));
}
return table;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#ifdef USE_SDL3
#include <SDL3/SDL_timer.h>
#else
#include <SDL.h>

Check warning on line 17 in Source/msg.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/msg.cpp:17:1 [misc-include-cleaner]

included header SDL.h is not used directly
#endif

#include <ankerl/unordered_dense.h>
#include <fmt/format.h>

Check warning on line 21 in Source/msg.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/msg.cpp:21:1 [misc-include-cleaner]

included header format.h is not used directly

#if !defined(UNPACKED_MPQS) || !defined(UNPACKED_SAVES) || !defined(NONET)
#define USE_PKWARE
Expand All @@ -28,7 +28,7 @@
#include "DiabloUI/diabloui.h"
#include "automap.h"
#include "config.h"
#include "control.h"

Check warning on line 31 in Source/msg.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/msg.cpp:31:1 [misc-include-cleaner]

included header control.h is not used directly
#include "dead.h"
#include "engine/backbuffer_state.hpp"
#include "engine/random.hpp"
Expand All @@ -44,7 +44,7 @@
#include "monsters/validation.hpp"
#include "nthread.h"
#include "objects.h"
#include "options.h"

Check warning on line 47 in Source/msg.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/msg.cpp:47:1 [misc-include-cleaner]

included header options.h is not used directly
#include "pack.h"
#include "pfile.h"
#include "player.h"
Expand All @@ -59,7 +59,7 @@
#include "utils/endian_swap.hpp"
#include "utils/is_of.hpp"
#include "utils/language.h"
#include "utils/str_cat.hpp"

Check warning on line 62 in Source/msg.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/msg.cpp:62:1 [misc-include-cleaner]

included header str_cat.hpp is not used directly
#include "utils/str_split.hpp"
#include "utils/utf8.hpp"

Expand All @@ -85,7 +85,7 @@

void EventFailedPacket(const char *playerName)
{
const std::string message = fmt::format("Player '{}' sent an invalid packet.", playerName);

Check warning on line 88 in Source/msg.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/msg.cpp:88:13 [misc-include-cleaner]

no header providing "std::string" is directly included
EventPlrMsg(message);
}

Expand Down Expand Up @@ -1953,7 +1953,7 @@
const Point position { message.x, message.y };
const uint16_t townerIdx = Swap16LE(message.wParam1);

if (gbBufferMsgs != 1 && player.isOnActiveLevel() && InDungeonBounds(position) && townerIdx < NUM_TOWNERS) {
if (gbBufferMsgs != 1 && player.isOnActiveLevel() && InDungeonBounds(position) && townerIdx < GetNumTowners()) {
MakePlrPath(player, position, false);
player.destAction = ACTION_TALK;
player.destParam1 = townerIdx;
Expand Down
11 changes: 6 additions & 5 deletions Source/quests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "options.h"
#include "panels/ui_panels.hpp"
#include "stores.h"
#include "townerdat.hpp"
#include "towners.h"
#include "utils/endian_swap.hpp"
#include "utils/is_of.hpp"
Expand Down Expand Up @@ -197,8 +198,8 @@ void StartPWaterPurify()

void InitQuests()
{
QuestDialogTable[TOWN_HEALER][Q_MUSHROOM] = TEXT_NONE;
QuestDialogTable[TOWN_WITCH][Q_MUSHROOM] = TEXT_MUSH9;
SetTownerQuestDialog(TOWN_HEALER, Q_MUSHROOM, TEXT_NONE);
SetTownerQuestDialog(TOWN_WITCH, Q_MUSHROOM, TEXT_MUSH9);

QuestLogIsOpen = false;
WaterDone = 0;
Expand Down Expand Up @@ -626,10 +627,10 @@ void ResyncQuests()
} else {
if (Quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) {
if (Quests[Q_MUSHROOM]._qvar1 >= QS_MUSHGIVEN) {
QuestDialogTable[TOWN_WITCH][Q_MUSHROOM] = TEXT_NONE;
QuestDialogTable[TOWN_HEALER][Q_MUSHROOM] = TEXT_MUSH3;
SetTownerQuestDialog(TOWN_WITCH, Q_MUSHROOM, TEXT_NONE);
SetTownerQuestDialog(TOWN_HEALER, Q_MUSHROOM, TEXT_MUSH3);
} else if (Quests[Q_MUSHROOM]._qvar1 >= QS_BRAINGIVEN) {
QuestDialogTable[TOWN_HEALER][Q_MUSHROOM] = TEXT_NONE;
SetTownerQuestDialog(TOWN_HEALER, Q_MUSHROOM, TEXT_NONE);
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "options.h"
#include "panels/info_box.hpp"
#include "qol/stash.h"
#include "townerdat.hpp"
#include "towners.h"
#include "utils/format_int.hpp"
#include "utils/language.h"
Expand Down Expand Up @@ -1207,7 +1208,7 @@ void StartTalk()

int sn = 0;
for (auto &quest : Quests) {
if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog)
if (quest._qactive == QUEST_ACTIVE && GetTownerQuestDialog(TownerId, quest._qidx) != TEXT_NONE && quest._qlog)
sn++;
}

Expand All @@ -1222,7 +1223,7 @@ void StartTalk()
const int sn2 = sn - 2;

for (auto &quest : Quests) {
if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog) {
if (quest._qactive == QUEST_ACTIVE && GetTownerQuestDialog(TownerId, quest._qidx) != TEXT_NONE && quest._qlog) {
AddSText(0, sn, _(QuestsData[quest._qidx]._qlstr), UiFlags::ColorWhite | UiFlags::AlignCenter, true);
sn += la;
}
Expand Down Expand Up @@ -1911,7 +1912,7 @@ void TalkEnter()

int sn = 0;
for (auto &quest : Quests) {
if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog)
if (quest._qactive == QUEST_ACTIVE && GetTownerQuestDialog(TownerId, quest._qidx) != TEXT_NONE && quest._qlog)
sn++;
}
int la = 2;
Expand All @@ -1930,9 +1931,9 @@ void TalkEnter()
}

for (auto &quest : Quests) {
if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog) {
if (quest._qactive == QUEST_ACTIVE && GetTownerQuestDialog(TownerId, quest._qidx) != TEXT_NONE && quest._qlog) {
if (sn == CurrentTextLine) {
InitQTextMsg(QuestDialogTable[TownerId][quest._qidx]);
InitQTextMsg(GetTownerQuestDialog(TownerId, quest._qidx));
}
sn += la;
}
Expand Down
Loading
Loading