[Items] Overhaul Item Hand-in System (#4593)

* [Items] Overhaul Item Hand-in System

* Edge case lua fix

* Merge fix

* I'm going to be amazed if this works first try

* Update linux-build.sh

* Update linux-build.sh

* Update linux-build.sh

* Update linux-build.sh

* Update linux-build.sh

* Update linux-build.sh

* Update linux-build.sh

* Update linux-build.sh

* Add protections against scripts that hand back items themselves

* Remove EVENT_ITEM_ScriptStopReturn

* test

* Update npc_handins.cpp

* Add Items:AlwaysReturnHandins

* Update spdat.cpp

* Bypass update prompt on CI
This commit is contained in:
Chris Miles
2025-02-03 16:51:09 -06:00
committed by GitHub
parent d1d6db3a09
commit 6fb919a16f
40 changed files with 2254 additions and 473 deletions
+49 -2
View File
@@ -124,6 +124,7 @@ void CatchSignal(int sig_num);
extern void MapOpcodes();
bool CheckForCompatibleQuestPlugins();
int main(int argc, char **argv)
{
RegisterExecutablePlatform(ExePlatformZone);
@@ -298,7 +299,7 @@ int main(int argc, char **argv)
}
// command handler
if (ZoneCLI::RanConsoleCommand(argc, argv) && !ZoneCLI::RanSidecarCommand(argc, argv)) {
if (ZoneCLI::RanConsoleCommand(argc, argv) && !(ZoneCLI::RanSidecarCommand(argc, argv) || ZoneCLI::RanTestCommand(argc, argv))) {
LogSys.EnableConsoleLogging();
ZoneCLI::CommandHandler(argc, argv);
}
@@ -369,6 +370,11 @@ int main(int argc, char **argv)
return 1;
}
if (!CheckForCompatibleQuestPlugins()) {
LogError("Incompatible quest plugins detected, please update your plugins to the latest version");
return 1;
}
// load these here for now until spells and items can be truly repointed to "content_db"
database.SetSharedItemsCount(content_db.GetItemsCount());
database.SetSharedSpellsCount(content_db.GetSpellsCount());
@@ -481,7 +487,8 @@ int main(int argc, char **argv)
worldserver.SetScheduler(&event_scheduler);
// sidecar command handler
if (ZoneCLI::RanConsoleCommand(argc, argv) && ZoneCLI::RanSidecarCommand(argc, argv)) {
if (ZoneCLI::RanConsoleCommand(argc, argv)
&& (ZoneCLI::RanSidecarCommand(argc, argv) || ZoneCLI::RanTestCommand(argc, argv))) {
ZoneCLI::CommandHandler(argc, argv);
}
@@ -712,3 +719,43 @@ void UpdateWindowTitle(char *iNewTitle)
SetConsoleTitle(tmp);
#endif
}
bool CheckForCompatibleQuestPlugins()
{
const std::vector<std::string>& directories = { "lua_modules", "plugins" };
bool lua_found = false;
bool perl_found = false;
for (const auto& directory : directories) {
for (const auto& file : fs::directory_iterator(path.GetServerPath() + "/" + directory)) {
if (file.is_regular_file()) {
auto f = file.path().string();
if (File::Exists(f)) {
auto r = File::GetContents(std::filesystem::path{ f }.string());
if (Strings::Contains(r.contents, "CheckHandin")) {
if (Strings::EqualFold(directory, "lua_modules")) {
lua_found = true;
} else if (Strings::EqualFold(directory, "plugins")) {
perl_found = true;
}
if (lua_found && perl_found) {
return true;
}
}
}
}
}
}
if (!lua_found) {
LogError("Failed to find CheckHandin in lua_modules");
}
if (!perl_found) {
LogError("Failed to find CheckHandin in plugins");
}
return lua_found && perl_found;
}