From 3a757a7a85b6ab051517b1cdcda510a465a0c317 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Thu, 13 Dec 2018 21:44:52 -0500 Subject: [PATCH] Resolved a possible scaling issue with the way CharMaxLevel works with quest globals and data buckets. --- changelog.txt | 15 +++++++++++++++ common/eq_packet_structs.h | 1 - zone/client.cpp | 11 ++++++++++- zone/client.h | 6 +++++- zone/client_packet.cpp | 9 +++++++++ zone/exp.cpp | 32 +++++++++----------------------- 6 files changed, 48 insertions(+), 26 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4b717ed5b..af3d6e7a8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,20 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 12/15/2018 == +Kinglykrab: Added multiple new instance related quest functions. + 1. quest::GetInstanceIDByCharID(const char *zone, int16 version, uint32 char_id) + - Allows you to pull the instance ID of a client by character ID. + 2. quest::AssignToInstanceByCharID(uint16 instance_id, uint32 char_id) + - Allows you to assign an instance to a client by character ID. + 3. quest::RemoveFromInstanceByCharID(uint16 instance_id, uint32 char_id) + - Allows you to remove a client from an instance by character ID. + + Added spell buckets, similar to spell globals. + - Uses a new spell_buckets table and the Spells:EnableSpellBuckets rule. + + Added max level by data bucket. + - Uses data bucket char_id-CharMaxLevel and Character:PerCharacterBucketMaxLevel rule. + == 10/09/2018 == Uleat: Added bot owner options - usage: ^owneroption [option] (or aliased as: ^oo [option]) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index bde77822b..db97818a5 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -306,7 +306,6 @@ union uint32 DestructibleUnk9; bool targetable_with_hotkey; bool show_name; - }; struct PlayerState_Struct { diff --git a/zone/client.cpp b/zone/client.cpp index 18940d58a..0d5ee036d 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -263,6 +263,16 @@ Client::Client(EQStreamInterface* ieqs) PendingSacrifice = false; controlling_boat_id = 0; + if (!RuleB(Character, PerCharacterQglobalMaxLevel) && !RuleB(Character, PerCharacterBucketMaxLevel)) { + SetClientMaxLevel(0); + } else if (RuleB(Character, PerCharacterQglobalMaxLevel)) { + int client_max_level = GetCharMaxLevelFromQGlobal(); + SetClientMaxLevel(client_max_level); + } else if (RuleB(Character, PerCharacterBucketMaxLevel)) { + int client_max_level = GetCharMaxLevelFromBucket(); + SetClientMaxLevel(client_max_level); + } + KarmaUpdateTimer = new Timer(RuleI(Chat, KarmaUpdateIntervalMS)); GlobalChatLimiterTimer = new Timer(RuleI(Chat, IntervalDurationMS)); AttemptedMessages = 0; @@ -1966,7 +1976,6 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) // ns->spawn.pvp = GetPVP(false) ? 1 : 0; ns->spawn.show_name = true; - strcpy(ns->spawn.title, m_pp.title); strcpy(ns->spawn.suffix, m_pp.suffix); diff --git a/zone/client.h b/zone/client.h index f7848202d..8bdb33477 100644 --- a/zone/client.h +++ b/zone/client.h @@ -697,7 +697,9 @@ public: void SendGuildJoin(GuildJoin_Struct* gj); void RefreshGuildInfo(); - + int GetClientMaxLevel() const { return client_max_level; } + void SetClientMaxLevel(int max_level) { client_max_level = max_level; } + void CheckManaEndUpdate(); void SendManaUpdate(); void SendEnduranceUpdate(); @@ -1644,6 +1646,8 @@ private: void InterrogateInventory_(bool errorcheck, Client* requester, int16 head, int16 index, const EQEmu::ItemInstance* inst, const EQEmu::ItemInstance* parent, bool log, bool silent, bool &error, int depth); bool InterrogateInventory_error(int16 head, int16 index, const EQEmu::ItemInstance* inst, const EQEmu::ItemInstance* parent, int depth); + int client_max_level; + #ifdef BOTS struct BotOwnerOptions { bool death_marquee; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ceb242890..18862ee1f 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1419,6 +1419,15 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) drakkin_tattoo = m_pp.drakkin_tattoo; drakkin_details = m_pp.drakkin_details; + // Max Level for Character:PerCharacterQglobalMaxLevel and Character:PerCharacterBucketMaxLevel + int client_max_level = 0; + if (RuleB(Character, PerCharacterQglobalMaxLevel)) { + client_max_level = GetCharMaxLevelFromQGlobal(); + } else if (RuleB(Character, PerCharacterBucketMaxLevel)) { + client_max_level = GetCharMaxLevelFromBucket(); + } + SetClientMaxLevel(client_max_level); + // we know our class now, so we might have to fix our consume timer! if (class_ == MONK) consume_food_timer.SetTimer(CONSUMPTION_MNK_TIMER); diff --git a/zone/exp.cpp b/zone/exp.cpp index 302e29279..5ffdd5690 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -684,26 +684,12 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { } } - if(RuleB(Character, PerCharacterQglobalMaxLevel)){ - uint32 MaxLevel = GetCharMaxLevelFromQGlobal(); - if(MaxLevel){ - if(GetLevel() >= MaxLevel){ - uint32 expneeded = GetEXPForLevel(MaxLevel); - if(set_exp > expneeded) { - set_exp = expneeded; - } - } - } - } - - if(RuleB(Character, PerCharacterBucketMaxLevel)){ - uint32 MaxLevel = GetCharMaxLevelFromBucket(); - if(MaxLevel){ - if(GetLevel() >= MaxLevel){ - uint32 expneeded = GetEXPForLevel(MaxLevel); - if(set_exp > expneeded) { - set_exp = expneeded; - } + if (GetClientMaxLevel() > 0) { + int client_max_level = GetClientMaxLevel(); + if (GetLevel() >= client_max_level) { + uint32 expneeded = GetEXPForLevel(client_max_level); + if(set_exp > expneeded) { + set_exp = expneeded; } } } @@ -1142,7 +1128,7 @@ uint32 Client::GetCharMaxLevelFromQGlobal() { ++gcount; } - return false; + return 0; } uint32 Client::GetCharMaxLevelFromBucket() { @@ -1151,14 +1137,14 @@ uint32 Client::GetCharMaxLevelFromBucket() { auto results = database.QueryDatabase(query); if (!results.Success()) { Log(Logs::General, Logs::Error, "Data bucket for CharMaxLevel for char ID %i failed.", char_id); - return false; + return 0; } if (results.RowCount() > 0) { auto row = results.begin(); return atoi(row[0]); } - return false; + return 0; } uint32 Client::GetRequiredAAExperience() {