diff --git a/conf/Individual-XP.conf.dist b/conf/Individual-XP.conf.dist index c9b97d4..fef4ebc 100644 --- a/conf/Individual-XP.conf.dist +++ b/conf/Individual-XP.conf.dist @@ -1,8 +1,8 @@ [worldserver] # -# PlayerAnnounce -# Description: This will show the console on what players are logged in -# Default: Enabled = 1 -# Disabled = 0 -PlayerAnnounce = 1 \ No newline at end of file +# MaxXPRate +# Description: This is the max amount a player can set their xp to. +# Default: Default = 1 +# +MaxXPRate = 10 \ No newline at end of file diff --git a/src/Individual_XP.cpp b/src/Individual_XP.cpp index e64046a..1a5b96a 100644 --- a/src/Individual_XP.cpp +++ b/src/Individual_XP.cpp @@ -17,9 +17,11 @@ class PlayerXpRate : public DataMap::Base public: PlayerXpRate() {} PlayerXpRate(uint32 XPRate) : XPRate(XPRate) {} - uint32 XPRate = 0; + uint32 XPRate = 1; }; +uint32 MaxRate; + class Individual_XP : public PlayerScript { public: @@ -45,13 +47,13 @@ public: CharacterDatabase.PQuery("REPLACE INTO `individualxp` (`CharacterGUID`, `XPRate`) VALUES (%u, %u);", p->GetGUIDLow(), data->XPRate); } - void OnGiveXP(Player* p, uint32& amount, Unit* victim) override + void OnGiveXP(Player* p, uint32& amount, Unit* victim) { + uint32 bonus_xp = amount * p->CustomData.Get("Individual_XP")->XPRate ; uint32 curXP = p->GetUInt32Value(PLAYER_XP); uint32 nextLvlXP = p->GetUInt32Value(PLAYER_NEXT_LEVEL_XP); - uint32 bonus_xp = p->CustomData.Get("Individual_XP")->XPRate * amount; - uint32 newXP = curXP + amount + bonus_xp; uint8 level = p->getLevel(); + uint32 newXP = curXP + bonus_xp - amount; while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { @@ -64,8 +66,8 @@ public: nextLvlXP = p->GetUInt32Value(PLAYER_NEXT_LEVEL_XP); } - p->SendLogXPGain(amount, victim, bonus_xp, false, 1.0f); - p->SetUInt32Value(PLAYER_XP, newXP); + p->SetUInt32Value(PLAYER_XP, (newXP)); + p->SendLogXPGain(bonus_xp, victim, NULL, false, 1.0f); } }; @@ -85,21 +87,20 @@ public: static bool HandleIndividualXPCommand(ChatHandler* handler, char const* args) { + Player* me = handler->GetSession()->GetPlayer(); if (!*args) return false; - - Player* me = handler->GetSession()->GetPlayer(); - - // Crash before Set - me->CustomData.Get("Individual_XP")->XPRate = (uint32)atoi(args); //Return int from command if (!me) return false; - me->GetSession()->SendAreaTriggerMessage("You have Updated your XP rate to %u", me->CustomData.Get("Individual_XP")->XPRate); + if (atoi(args) > MaxRate || (atoi(args) == 0)) + return false; + + me->CustomData.Get("Individual_XP")->XPRate = (uint32)atoi(args); //Return int from command + + me->GetSession()->SendAreaTriggerMessage("You have updated your XP rate to %u", me->CustomData.Get("Individual_XP")->XPRate); return true; - - } }; @@ -117,6 +118,7 @@ public: sConfigMgr->LoadMore(cfg_def_file.c_str()); sConfigMgr->LoadMore(cfg_file.c_str()); + MaxRate = sConfigMgr->GetIntDefault("MaxXPRate", 10); } } }; diff --git a/src/Individual_XP.h b/src/Individual_XP.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/cmake/after_ws_install.cmake b/src/cmake/after_ws_install.cmake index 0045f5c..af022d1 100644 --- a/src/cmake/after_ws_install.cmake +++ b/src/cmake/after_ws_install.cmake @@ -1,13 +1,13 @@ if ( MSVC ) add_custom_command(TARGET worldserver POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual_XP.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual-XP.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ ) elseif ( MINGW ) add_custom_command(TARGET worldserver POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual_XP.conf.dist ${CMAKE_BINARY_DIR}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual-XP.conf.dist ${CMAKE_BINARY_DIR}/bin/ ) endif() -install(FILES "${CMAKE_Individual_XP_DIR}/conf/Individual_XP.conf.dist" DESTINATION ${CONF_DIR}) +install(FILES "${CMAKE_Individual_XP_DIR}/conf/Individual-XP.conf.dist" DESTINATION ${CONF_DIR})