Compare commits

...

18 Commits

Author SHA1 Message Date
Akkadius 63c2f20cb0 Update content_filter_criteria.h 2024-02-17 14:49:33 -06:00
Akkadius fa46cbb539 [Expansions] Fix content filter criteria for max_expansions 2024-02-17 14:19:58 -06:00
Mitch Freeman e6df5be1ed [Bug Fix] Update database_schema to add guild_permissions (#4085)
* Update database_schema to add guild_permissions

* Reordered
2024-02-16 18:09:18 -05:00
hg 6bb2f97b74 [Code] Update fmt to 10.2.1 (#4071)
This fixes MSVC compile warnings for stdext::checked_array_iterator
which were deprecated in STL for VS 2022 17.8:

https://github.com/microsoft/STL/wiki/Changelog#vs-2022-178
2024-02-16 00:29:04 -06:00
hg 86f39743fc [Quest API] Add tracebacks to Lua error messages (#4079)
This adds an error msg handler for lua calls to add a stack trace to
error messages. Lua 5.1 does not have luaL_traceback like luajit and lua
5.2+ so debug.traceback() is used directly as the msg handler.

The traceback will add more detail to errors than just logging package
and event names. Exceptions in C++ binds and luabind errors will now
show script context instead of just the error message.

e.g., for a luabind overload error:

  No matching overload found, candidates:
  void signal(int,int,int)
  void signal(int,int)
  stack traceback:
    [C]: in function 'signal'
    quests/arena/player.lua:10: in function 'somefn'
    quests/arena/player.lua:27: in function <quests/arena/player.lua:17>
2024-02-16 00:27:37 -06:00
Alex King 447fc026a8 [Repositories] Convert Zone Flags to Repositories (#4077)
# Notes
- Converts `ClearZoneFlag()`, `LoadZoneFlags()`, and `SetZoneFlag()` to repositories.
2024-02-16 00:27:08 -06:00
Chris Miles 7408df933c [Database] Remove "item_tick" from database schema per https://github.com/EQEmu/Server/pull/3985 (#4083) 2024-02-16 00:23:23 -06:00
JJ 2f59e70c6b [Bug Fix] Fix manifest check on base_data change (#4082) 2024-02-15 19:04:26 -05:00
Alex King eb8514eea8 [Bug Fix] Fix fix_z Query (#4080)
# Notes
- This query was not working properly due to using backticks instead of single quotes.
2024-02-15 11:51:07 -05:00
Alex King f498bac574 [Bug Fix] Fix ObjectContentsRepository using content_db (#4076)
# Notes
- `*this` was using content database, causing this not to work on servers using sharded databases.
2024-02-14 18:34:43 -05:00
Alex King 9a0b3a4c36 [Bug Fix] Fix #wpadd Query (#4078)
# Notes
- `GetNextWaypoint()` was getting a null value and crashing in `Strings::ToInt()`.
2024-02-14 18:28:31 -05:00
Chris Miles 34ea870717 [Opcodes] Fix opcode reloading (#4075) 2024-02-13 19:40:23 -05:00
Alex King d68c1a7a6c [Quest API] Add IsInAGuild() to Perl/Lua (#4066)
# Perl
- Add `$client->IsInAGuild()`.

# Lua
- Add `client:IsInAGuild()`.

# Notes
- Allows operators to more accurately tell if a player is in a group.
- `GuildID()` returns `uint32` max value if the player isn't in a guild so conditions using it must check for a value over a certain point, this is just a bool that simplifies that logic.
2024-02-13 19:27:43 -05:00
Akkadius c50100fcdb [Hotfix] Fix issues where we're using the wrong database pointers 2024-02-12 21:41:52 -06:00
JJ 20cdc1e63d [Release] 22.44.4 (#4074)
### Fixes

* Fix ClearSpawnTimers() ([#4073](https://github.com/EQEmu/Server/pull/4073)) @Kinglykrab 2024-02-13
2024-02-12 20:34:40 -06:00
Alex King 43c7523ee1 [Hotfix] Fix ClearSpawnTimers() (#4073)
# Notes
- This wasn't a part of my other pull request.
- We were clearing `spawn2_list` before using it in `ClearSpawnTimers()`.
2024-02-12 21:12:30 -05:00
JJ e060d97798 [Release] 22.44.3 (#4072)
### Fixes

* Fix Issue with ClearSpawnTimers() ([#4070](https://github.com/EQEmu/Server/pull/4070)) @Kinglykrab 2024-02-13
2024-02-12 19:20:04 -06:00
Alex King 435b6142b8 [Bug Fix] Fix Issue with ClearSpawnTimers() (#4070)
# Notes
- We were using the improper ID for this and not checking if the vector was empty before using.
2024-02-12 20:00:45 -05:00
23 changed files with 595 additions and 92 deletions
+18
View File
@@ -1,3 +1,21 @@
## [22.44.5] - 2/12/2024
### Fixes
* [Hotfix] Fix issues where we're using the wrong database pointers @Akkadius
## [22.44.4] - 2/12/2024
### Fixes
* Fix ClearSpawnTimers() ([#4073](https://github.com/EQEmu/Server/pull/4073)) @Kinglykrab 2024-02-13
## [22.44.3] - 2/12/2024
### Fixes
* Fix Issue with ClearSpawnTimers() ([#4070](https://github.com/EQEmu/Server/pull/4070)) @Kinglykrab 2024-02-13
## [22.44.2] - 2/12/2024
### Bots
+2 -2
View File
@@ -5247,7 +5247,7 @@ MODIFY COLUMN `name` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci
ManifestEntry{
.version = 9257,
.description = "2024_01_16_ground_spawns_fix_z.sql",
.check = "SHOW COLUMNS FROM `ground_spawns` LIKE `fix_z`",
.check = "SHOW COLUMNS FROM `ground_spawns` LIKE 'fix_z'",
.condition = "empty",
.match = "",
.sql = R"(
@@ -5259,7 +5259,7 @@ ADD COLUMN `fix_z` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 AFTER `respawn_timer`;
ManifestEntry{
.version = 9258,
.description = "2024_02_04_base_data.sql",
.check = "SHOW COLUMNS FROM `base_data` LIKE `hp_regen`",
.check = "SHOW COLUMNS FROM `base_data` LIKE 'hp_regen'",
.condition = "empty",
.match = "",
.sql = R"(
+1 -1
View File
@@ -146,6 +146,7 @@ namespace DatabaseSchema {
"friends",
"guild_bank",
"guild_members",
"guild_permissions",
"guild_ranks",
"guild_relations",
"guild_tributes",
@@ -333,7 +334,6 @@ namespace DatabaseSchema {
"group_leaders",
"instance_list",
"ip_exemptions",
"item_tick",
"lfguild",
"merc_buffs",
"merchantlist_temp",
+12 -2
View File
@@ -75,9 +75,18 @@ class BaseGuildManager
virtual ~BaseGuildManager();
//this must be called before doing anything else with this object
void SetDatabase(Database *db)
BaseGuildManager * SetDatabase(Database *db)
{
m_db = db;
return this;
}
BaseGuildManager * SetContentDatabase(Database *db)
{
m_content_db = db;
return this;
}
bool LoadGuilds();
@@ -194,7 +203,8 @@ class BaseGuildManager
std::map<uint32, GuildInfo *> m_guilds; //we own the pointers in this map
void ClearGuilds(); //clears internal structure
Database *m_db; //we do not own this
Database *m_db;
Database *m_content_db;
bool _StoreGuildDB(uint32 guild_id);
GuildInfo* _CreateGuild(uint32 guild_id, std::string guild_name, uint32 leader_char_id, uint8 minstatus, std::string guild_motd, std::string motd_setter, std::string Channel, std::string URL, uint32 favour);
@@ -0,0 +1,392 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://docs.eqemu.io/developer/repositories
*/
#ifndef EQEMU_BASE_ZONE_FLAGS_REPOSITORY_H
#define EQEMU_BASE_ZONE_FLAGS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseZoneFlagsRepository {
public:
struct ZoneFlags {
int32_t charID;
int32_t zoneID;
};
static std::string PrimaryKey()
{
return std::string("charID");
}
static std::vector<std::string> Columns()
{
return {
"charID",
"zoneID",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"charID",
"zoneID",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("zone_flags");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static ZoneFlags NewEntity()
{
ZoneFlags e{};
e.charID = 0;
e.zoneID = 0;
return e;
}
static ZoneFlags GetZoneFlags(
const std::vector<ZoneFlags> &zone_flagss,
int zone_flags_id
)
{
for (auto &zone_flags : zone_flagss) {
if (zone_flags.charID == zone_flags_id) {
return zone_flags;
}
}
return NewEntity();
}
static ZoneFlags FindOne(
Database& db,
int zone_flags_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
zone_flags_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
ZoneFlags e{};
e.charID = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.zoneID = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int zone_flags_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
zone_flags_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const ZoneFlags &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[0] + " = " + std::to_string(e.charID));
v.push_back(columns[1] + " = " + std::to_string(e.zoneID));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.charID
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static ZoneFlags InsertOne(
Database& db,
ZoneFlags e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.charID));
v.push_back(std::to_string(e.zoneID));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.charID = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<ZoneFlags> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.charID));
v.push_back(std::to_string(e.zoneID));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<ZoneFlags> All(Database& db)
{
std::vector<ZoneFlags> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ZoneFlags e{};
e.charID = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.zoneID = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<ZoneFlags> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<ZoneFlags> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ZoneFlags e{};
e.charID = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.zoneID = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const ZoneFlags &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.charID));
v.push_back(std::to_string(e.zoneID));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<ZoneFlags> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.charID));
v.push_back(std::to_string(e.zoneID));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_BASE_ZONE_FLAGS_REPOSITORY_H
@@ -103,7 +103,7 @@ public:
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT MAX(`number`) FROM `{}` WHERE `zoneid` = {} AND `gridid` = {}",
"SELECT COALESCE(MAX(`number`), 0) FROM `{}` WHERE `zoneid` = {} AND `gridid` = {}",
TableName(),
zone_id,
grid_id
@@ -0,0 +1,50 @@
#ifndef EQEMU_ZONE_FLAGS_REPOSITORY_H
#define EQEMU_ZONE_FLAGS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_zone_flags_repository.h"
class ZoneFlagsRepository: public BaseZoneFlagsRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* ZoneFlagsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* ZoneFlagsRepository::GetWhereNeverExpires()
* ZoneFlagsRepository::GetWhereXAndY()
* ZoneFlagsRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_ZONE_FLAGS_REPOSITORY_H
+1 -1
View File
@@ -25,7 +25,7 @@
// Build variables
// these get injected during the build pipeline
#define CURRENT_VERSION "22.44.2-dev" // always append -dev to the current version for custom-builds
#define CURRENT_VERSION "22.44.5-dev" // always append -dev to the current version for custom-builds
#define LOGIN_VERSION "0.8.0"
#define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "eqemu-server",
"version": "22.44.2",
"version": "22.44.5",
"repository": {
"type": "git",
"url": "https://github.com/EQEmu/Server.git"
+2 -2
View File
@@ -325,7 +325,7 @@ bool WorldGuildManager::LoadTributes()
tribute_list.clear();
auto tributes = TributesRepository::All(*m_db);
auto tributes = TributesRepository::All(*m_content_db);
for (auto const& t : tributes) {
td.name = t.name;
td.description = t.descr;
@@ -336,7 +336,7 @@ bool WorldGuildManager::LoadTributes()
LogInfo("Loaded [{}] tributes", Strings::Commify(tributes.size()));
auto tribute_levels = TributeLevelsRepository::GetWhere(*m_db, "TRUE ORDER BY tribute_id, level");
auto tribute_levels = TributeLevelsRepository::GetWhere(*m_content_db, "TRUE ORDER BY tribute_id, level");
for (auto const& t : tribute_levels) {
uint32 id = t.tribute_id;
+1 -1
View File
@@ -264,7 +264,7 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
}
}
guild_mgr.SetDatabase(&database);
guild_mgr.SetDatabase(&database)->SetContentDatabase(&content_db);
LogInfo("Purging expired data buckets");
database.PurgeAllDeletedDataBuckets();
+1
View File
@@ -1367,6 +1367,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
}
case ServerOP_ReloadOpcodes: {
ReloadAllPatches();
zoneserver_list.SendPacket(pack);
break;
}
case ServerOP_CZDialogueWindow:
+7
View File
@@ -3290,6 +3290,12 @@ int Lua_Client::GetEXPPercentage()
return self->GetEXPPercentage();
}
bool Lua_Client::IsInAGuild()
{
Lua_Safe_Call_Bool();
return self->IsInAGuild();
}
luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>())
@@ -3578,6 +3584,7 @@ luabind::scope lua_register_client() {
.def("IsDueling", (bool(Lua_Client::*)(void))&Lua_Client::IsDueling)
.def("IsEXPEnabled", (bool(Lua_Client::*)(void))&Lua_Client::IsEXPEnabled)
.def("IsGrouped", (bool(Lua_Client::*)(void))&Lua_Client::IsGrouped)
.def("IsInAGuild", (bool(Lua_Client::*)(void))&Lua_Client::IsInAGuild)
.def("IsLD", (bool(Lua_Client::*)(void))&Lua_Client::IsLD)
.def("IsMedding", (bool(Lua_Client::*)(void))&Lua_Client::IsMedding)
.def("IsRaidGrouped", (bool(Lua_Client::*)(void))&Lua_Client::IsRaidGrouped)
+1
View File
@@ -495,6 +495,7 @@ public:
void ClearXTargets();
int GetAAEXPPercentage();
int GetEXPPercentage();
bool IsInAGuild();
void ApplySpell(int spell_id);
void ApplySpell(int spell_id, int duration);
+37 -22
View File
@@ -190,6 +190,14 @@ std::map<std::string, std::list<lua_registered_event>> lua_encounter_events_regi
std::map<std::string, bool> lua_encounters_loaded;
std::map<std::string, Encounter *> lua_encounters;
// use debug.traceback() for errors (luaL_traceback is only in luajit and lua 5.2+)
static void PushErrorHandler(lua_State* L)
{
lua_getglobal(L, "debug");
lua_getfield(L, -1, "traceback");
lua_remove(L, -2);
}
LuaParser::LuaParser() {
for (int i = 0; i < _LargestEventID; ++i) {
NPCArgumentDispatch[i] = handle_npc_null;
@@ -416,13 +424,14 @@ int LuaParser::_EventNPC(std::string package_name, QuestEventID evt, NPC* npc, M
int start = lua_gettop(L);
try {
int npop = 1;
int npop = 2;
PushErrorHandler(L);
if(l_func != nullptr) {
l_func->push(L);
} else {
lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
lua_getfield(L, -1, sub_name);
npop = 2;
npop = 3;
}
lua_createtable(L, 0, 0);
@@ -437,7 +446,7 @@ int LuaParser::_EventNPC(std::string package_name, QuestEventID evt, NPC* npc, M
Client *c = (init && init->IsClient()) ? init->CastToClient() : nullptr;
quest_manager.StartQuest(npc, c);
if(lua_pcall(L, 1, 1, 0)) {
if(lua_pcall(L, 1, 1, start + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
quest_manager.EndQuest();
@@ -509,13 +518,14 @@ int LuaParser::_EventPlayer(std::string package_name, QuestEventID evt, Client *
int start = lua_gettop(L);
try {
int npop = 1;
int npop = 2;
PushErrorHandler(L);
if(l_func != nullptr) {
l_func->push(L);
} else {
lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
lua_getfield(L, -1, sub_name);
npop = 2;
npop = 3;
}
lua_createtable(L, 0, 0);
@@ -529,7 +539,7 @@ int LuaParser::_EventPlayer(std::string package_name, QuestEventID evt, Client *
arg_function(this, L, client, data, extra_data, extra_pointers);
quest_manager.StartQuest(client, client);
if(lua_pcall(L, 1, 1, 0)) {
if(lua_pcall(L, 1, 1, start + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
quest_manager.EndQuest();
@@ -586,13 +596,14 @@ int LuaParser::_EventItem(std::string package_name, QuestEventID evt, Client *cl
int start = lua_gettop(L);
try {
int npop = 1;
int npop = 2;
PushErrorHandler(L);
if(l_func != nullptr) {
l_func->push(L);
} else {
lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
lua_getfield(L, -1, sub_name);
npop = 2;
npop = 3;
}
lua_createtable(L, 0, 0);
@@ -612,7 +623,7 @@ int LuaParser::_EventItem(std::string package_name, QuestEventID evt, Client *cl
arg_function(this, L, client, item, mob, data, extra_data, extra_pointers);
quest_manager.StartQuest(client, client, item);
if(lua_pcall(L, 1, 1, 0)) {
if(lua_pcall(L, 1, 1, start + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
quest_manager.EndQuest();
@@ -666,13 +677,14 @@ int LuaParser::_EventSpell(std::string package_name, QuestEventID evt, Mob* mob,
int start = lua_gettop(L);
try {
int npop = 1;
int npop = 2;
PushErrorHandler(L);
if(l_func != nullptr) {
l_func->push(L);
} else {
lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
lua_getfield(L, -1, sub_name);
npop = 2;
npop = 3;
}
lua_createtable(L, 0, 0);
@@ -693,7 +705,7 @@ int LuaParser::_EventSpell(std::string package_name, QuestEventID evt, Mob* mob,
arg_function(this, L, mob, client, spell_id, data, extra_data, extra_pointers);
quest_manager.StartQuest(mob, client, nullptr, const_cast<SPDat_Spell_Struct*>(&spells[spell_id]));
if(lua_pcall(L, 1, 1, 0)) {
if(lua_pcall(L, 1, 1, start + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
quest_manager.EndQuest();
@@ -745,6 +757,7 @@ int LuaParser::_EventEncounter(std::string package_name, QuestEventID evt, std::
int start = lua_gettop(L);
try {
PushErrorHandler(L);
lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
lua_getfield(L, -1, sub_name);
@@ -758,22 +771,22 @@ int LuaParser::_EventEncounter(std::string package_name, QuestEventID evt, std::
arg_function(this, L, enc, data, extra_data, extra_pointers);
quest_manager.StartQuest(enc, nullptr, nullptr, nullptr, encounter_name);
if(lua_pcall(L, 1, 1, 0)) {
if(lua_pcall(L, 1, 1, start + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
quest_manager.EndQuest();
lua_pop(L, 2);
lua_pop(L, 3);
return 0;
}
quest_manager.EndQuest();
if(lua_isnumber(L, -1)) {
int ret = static_cast<int>(lua_tointeger(L, -1));
lua_pop(L, 2);
lua_pop(L, 3);
return ret;
}
lua_pop(L, 2);
lua_pop(L, 3);
} catch(std::exception &ex) {
AddError(fmt::format("Lua Exception | [{}] for Encounter [{}]: {}", sub_name, encounter_name, ex.what()));
@@ -1124,10 +1137,11 @@ void LuaParser::LoadScript(std::string filename, std::string package_name) {
}
auto top = lua_gettop(L);
PushErrorHandler(L);
if(luaL_loadfile(L, filename.c_str())) {
std::string error = lua_tostring(L, -1);
AddError(error);
lua_pop(L, 1);
lua_pop(L, 2);
return;
}
@@ -1147,10 +1161,10 @@ void LuaParser::LoadScript(std::string filename, std::string package_name) {
lua_setfenv(L, -2); //set the env to the table we made
if(lua_pcall(L, 0, 0, 0)) {
if(lua_pcall(L, 0, 0, top + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
lua_pop(L, 1);
lua_pop(L, 2);
}
else {
loaded_[package_name] = true;
@@ -1599,13 +1613,14 @@ int LuaParser::_EventBot(
int start = lua_gettop(L);
try {
int npop = 1;
int npop = 2;
PushErrorHandler(L);
if(l_func != nullptr) {
l_func->push(L);
} else {
lua_getfield(L, LUA_REGISTRYINDEX, package_name.c_str());
lua_getfield(L, -1, sub_name);
npop = 2;
npop = 3;
}
lua_createtable(L, 0, 0);
@@ -1620,7 +1635,7 @@ int LuaParser::_EventBot(
auto* c = (init && init->IsClient()) ? init->CastToClient() : nullptr;
quest_manager.StartQuest(bot, c);
if(lua_pcall(L, 1, 1, 0)) {
if(lua_pcall(L, 1, 1, start + 1)) {
std::string error = lua_tostring(L, -1);
AddError(error);
quest_manager.EndQuest();
+1 -1
View File
@@ -318,7 +318,7 @@ int main(int argc, char **argv)
}
/* Guilds */
guild_mgr.SetDatabase(&database);
guild_mgr.SetDatabase(&database)->SetContentDatabase(&content_db);
GuildBanks = nullptr;
#ifdef _EQDEBUG
+6
View File
@@ -3098,6 +3098,11 @@ int Perl_Client_GetEXPPercentage(Client* self)
return self->GetEXPPercentage();
}
bool Perl_Client_IsInAGuild(Client* self)
{
return self->IsInAGuild();
}
void perl_register_client()
{
perl::interpreter perl(PERL_GET_THX);
@@ -3386,6 +3391,7 @@ void perl_register_client()
package.add("IsDueling", &Perl_Client_IsDueling);
package.add("IsEXPEnabled", &Perl_Client_IsEXPEnabled);
package.add("IsGrouped", &Perl_Client_IsGrouped);
package.add("IsInAGuild", &Perl_Client_IsInAGuild);
package.add("IsLD", &Perl_Client_IsLD);
package.add("IsMedding", &Perl_Client_IsMedding);
package.add("IsRaidGrouped", &Perl_Client_IsRaidGrouped);
+2 -2
View File
@@ -440,14 +440,14 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
std::unordered_map<uint32, uint32> spawn_times;
timeval tv;
timeval tv{};
gettimeofday(&tv, nullptr);
/* Bulk Load NPC Types Data into the cache */
content_db.LoadNPCTypesData(0, true);
const auto& l = RespawnTimesRepository::GetWhere(
*this,
database,
fmt::format(
"`instance_id` = {}",
zone->GetInstanceID()
+7
View File
@@ -58,6 +58,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "bot_command.h"
#include "../common/events/player_event_logs.h"
#include "../common/repositories/guild_tributes_repository.h"
#include "../common/patches/patches.h"
extern EntityList entity_list;
extern Zone* zone;
@@ -1978,6 +1979,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
break;
}
case ServerOP_ReloadOpcodes:
{
zone->SendReloadMessage("Opcodes");
ReloadAllPatches();
break;
}
case ServerOP_ReloadAlternateCurrencies:
{
if (zone && zone->IsLoaded()) {
+16 -14
View File
@@ -1898,6 +1898,10 @@ void Zone::Repop(bool is_forced)
return;
}
if (is_forced) {
ClearSpawnTimers();
}
LinkedListIterator<Spawn2 *> iterator(spawn2_list);
iterator.Reset();
@@ -1905,10 +1909,6 @@ void Zone::Repop(bool is_forced)
iterator.RemoveCurrent();
}
if (is_forced) {
ClearSpawnTimers();
}
npc_scale_manager->LoadScaleData();
entity_list.ClearTrapPointers();
@@ -2649,22 +2649,24 @@ void Zone::ClearSpawnTimers()
iterator.Reset();
std::vector<std::string> respawn_ids;
std::vector<uint32> respawn_ids;
while (iterator.MoreElements()) {
respawn_ids.emplace_back(std::to_string(iterator.GetData()->GetID()));
respawn_ids.emplace_back(iterator.GetData()->spawn2_id);
iterator.Advance();
}
RespawnTimesRepository::DeleteWhere(
database,
fmt::format(
"`instance_id` = {} AND `id` IN ({})",
GetInstanceID(),
Strings::Implode(", ", respawn_ids)
)
);
if (!respawn_ids.empty()) {
RespawnTimesRepository::DeleteWhere(
database,
fmt::format(
"`instance_id` = {} AND `id` IN ({})",
GetInstanceID(),
Strings::Join(respawn_ids, ", ")
)
);
}
}
uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) {
+3 -3
View File
@@ -214,7 +214,7 @@ void ZoneDatabase::LoadWorldContainer(uint32 parent_id, EQ::ItemInstance* contai
}
const auto& l = ObjectContentsRepository::GetWhere(
*this,
database,
fmt::format(
"`parentid` = {}",
parent_id
@@ -271,7 +271,7 @@ void ZoneDatabase::SaveWorldContainer(uint32 zone_id, uint32 parent_id, const EQ
}
ObjectContentsRepository::ReplaceOne(
*this,
database,
ObjectContentsRepository::ObjectContents{
.zoneid = zone_id,
.parentid = parent_id,
@@ -293,7 +293,7 @@ void ZoneDatabase::SaveWorldContainer(uint32 zone_id, uint32 parent_id, const EQ
void ZoneDatabase::DeleteWorldContainer(uint32 parent_id, uint32 zone_id)
{
ObjectContentsRepository::DeleteWhere(
*this,
database,
fmt::format(
"`parentid` = {} AND `zoneid` = {}",
parent_id,
+32 -38
View File
@@ -35,6 +35,7 @@ extern WorldServer worldserver;
extern Zone* zone;
#include "../common/repositories/character_peqzone_flags_repository.h"
#include "../common/repositories/zone_flags_repository.h"
#include "../common/events/player_event_logs.h"
@@ -1067,53 +1068,48 @@ void Client::GoToDeath() {
MovePC(m_pp.binds[0].zone_id, m_pp.binds[0].instance_id, 0.0f, 0.0f, 0.0f, 0.0f, 1, ZoneToBindPoint);
}
void Client::ClearZoneFlag(uint32 zone_id) {
void Client::ClearZoneFlag(uint32 zone_id)
{
if (!HasZoneFlag(zone_id)) {
return;
}
zone_flags.erase(zone_id);
std::string query = fmt::format(
"DELETE FROM zone_flags WHERE charID = {} AND zoneID = {}",
CharacterID(),
zone_id
ZoneFlagsRepository::DeleteWhere(
database,
fmt::format(
"`charID` = {} AND `zoneID` = {}",
CharacterID(),
zone_id
)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogError("MySQL Error while trying to clear zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
}
}
bool Client::HasZoneFlag(uint32 zone_id) const {
bool Client::HasZoneFlag(uint32 zone_id) const
{
return zone_flags.find(zone_id) != zone_flags.end();
}
void Client::LoadZoneFlags() {
const auto query = fmt::format(
"SELECT zoneID from zone_flags WHERE charID = {}",
CharacterID()
void Client::LoadZoneFlags()
{
const auto& l = ZoneFlagsRepository::GetWhere(
database,
fmt::format(
"`charID` = {}",
CharacterID()
)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogError("MySQL Error while trying to load zone flags for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
return;
}
if (!results.RowCount()) {
return;
}
zone_flags.clear();
for (auto row : results) {
zone_flags.insert(Strings::ToUnsignedInt(row[0]));
for (const auto& e : l) {
zone_flags.insert(e.zoneID);
}
}
void Client::SendZoneFlagInfo(Client *to) const {
void Client::SendZoneFlagInfo(Client* to) const
{
if (zone_flags.empty()) {
to->Message(
Chat::White,
@@ -1178,23 +1174,21 @@ void Client::SendZoneFlagInfo(Client *to) const {
);
}
void Client::SetZoneFlag(uint32 zone_id) {
void Client::SetZoneFlag(uint32 zone_id)
{
if (HasZoneFlag(zone_id)) {
return;
}
zone_flags.insert(zone_id);
const auto query = fmt::format(
"INSERT INTO zone_flags (charID, zoneID) VALUES ({}, {})",
CharacterID(),
zone_id
ZoneFlagsRepository::InsertOne(
database,
ZoneFlagsRepository::ZoneFlags{
.charID = static_cast<int32_t>(CharacterID()),
.zoneID = static_cast<int32_t>(zone_id)
}
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogError("MySQL Error while trying to set zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
}
}
void Client::ClearPEQZoneFlag(uint32 zone_id) {