Fix null character access in server bonus status query

This commit is contained in:
shen
2026-09-30 23:10:22 -07:00
parent eb5833747a
commit f2848af3ac
4 changed files with 56 additions and 3 deletions
+15 -2
View File
@@ -142,16 +142,18 @@
+int AutoHuntPullLeash(LPCHARACTER mob, LPCHARACTER victim);
--- /dev/null
+++ b/server/game/src/server_bonuses.h
@@ -0,0 +1,12 @@
@@ -0,0 +1,14 @@
+// PORT: report actual global rates and the character's effective event privileges.
+#ifndef MT_AUTOHUNT_SERVER_TEST
+#include "priv_manager.h"
+#endif
+ACMD(do_server_bonuses) {
+ if (!ch->IsPC() || get_global_time() < ch->GetQuestFlag("server_bonuses.next_query")) return;
+ ch->SetQuestFlag("server_bonuses.next_query", get_global_time() + 2);
+ CHARACTER_MANAGER& cm = CHARACTER_MANAGER::instance();
+ CPrivManager& pm = CPrivManager::instance();
+ ch->ChatPacket(CHAT_TYPE_COMMAND, "ServerBonuses %d %d %d %d %d %d %d %d",
+ cm.GetMobExpRate(NULL), cm.GetMobGoldAmountRate(NULL), cm.GetMobGoldDropRate(NULL), cm.GetMobItemRate(NULL),
+ cm.GetMobExpRate(NULL), cm.GetMobGoldAmountRate(NULL), cm.GetMobGoldDropRate(NULL), cm.GetGlobalMobItemRate(),
+ pm.GetPriv(ch, PRIV_EXP_PCT), pm.GetPriv(ch, PRIV_ITEM_DROP),
+ pm.GetPriv(ch, PRIV_GOLD_DROP), pm.GetPriv(ch, PRIV_GOLD10_DROP));
+}
@@ -174,3 +176,14 @@
if (Return())
return true;
}
--- a/server/game/src/char_manager.h
+++ b/server/game/src/char_manager.h
@@ -92,6 +92,8 @@
void SetUserDamageRatePremium(int value) { m_iUserDamageRatePremium = value; }
void SetUserDamageRate(int value ) { m_iUserDamageRate = value; }
int GetMobItemRate(LPCHARACTER ch);
+ // PORT: query the global rate without dereferencing a character in locale-specific rules.
+ int GetGlobalMobItemRate() const { return m_iMobItemRate; }
int GetMobDamageRate(LPCHARACTER ch);
int GetMobGoldAmountRate(LPCHARACTER ch);
int GetMobGoldDropRate(LPCHARACTER ch);