mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
*Cleanup, add two new functions, attempt to fix arena point flushing for offline players.
--HG-- branch : trunk
This commit is contained in:
@@ -1816,22 +1816,25 @@ void BattleGroundMgr::DistributeArenaPoints()
|
||||
|
||||
//at first update all points for all team members
|
||||
for(ObjectMgr::ArenaTeamMap::iterator team_itr = objmgr.GetArenaTeamMapBegin(); team_itr != objmgr.GetArenaTeamMapEnd(); ++team_itr)
|
||||
{
|
||||
if (ArenaTeam * at = team_itr->second)
|
||||
{
|
||||
at->UpdateArenaPointsHelper(PlayerPoints);
|
||||
}
|
||||
}
|
||||
|
||||
//cycle that gives points to all players
|
||||
for (std::map<uint32, uint32>::iterator plr_itr = PlayerPoints.begin(); plr_itr != PlayerPoints.end(); ++plr_itr)
|
||||
{
|
||||
//update to database
|
||||
CharacterDatabase.PExecute("UPDATE characters SET arena_pending_points = '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first);
|
||||
//add points if player is online
|
||||
//add points to player
|
||||
Player* pl = objmgr.GetPlayer(plr_itr->first);
|
||||
if (pl)
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE characters SET arena_pending_points = '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first);
|
||||
pl->ModifyArenaPoints(plr_itr->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE characters SET arena_pending_points = 0 WHERE guid = '%u'", plr_itr->first);
|
||||
CharacterDatabase._UpdateDataBlobValue(plr_itr->first, PLAYER_FIELD_ARENA_CURRENCY,
|
||||
std::max(std::min(int32(plr_itr->second),int32(sWorld.getConfig(CONFIG_MAX_ARENA_POINTS))),0));
|
||||
}
|
||||
}
|
||||
|
||||
PlayerPoints.clear();
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
# pragma warning(disable:4311) // 'variable' : pointer truncation from 'type' to 'type'
|
||||
# pragma warning(disable:4355) // 'this' : used in base member initializer list
|
||||
# pragma warning(disable:4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning)
|
||||
# pragma warning(disable:4522) //warning when class has 2 constructosr
|
||||
# pragma warning(disable:4522) //warning when class has 2 constructors
|
||||
#endif // __SHOW_STUPID_WARNINGS__
|
||||
#endif // __GNUC__
|
||||
|
||||
@@ -199,7 +199,7 @@ extern char const* localeNames[MAX_LOCALE];
|
||||
|
||||
LocaleConstant GetLocaleByName(const std::string& name);
|
||||
|
||||
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some pother platforms)
|
||||
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Config/ConfigEnv.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "../../game/UpdateFields.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -172,6 +175,26 @@ bool Database::PExecute(const char * format,...)
|
||||
return Execute(szQuery);
|
||||
}
|
||||
|
||||
bool Database::_UpdateDataBlobValue(const uint32 guid, const uint32 field, const uint32 value)
|
||||
{
|
||||
return PExecute(
|
||||
"UPDATE characters SET data="
|
||||
"CONCAT(SUBSTRING_INDEX(`data`,' ',%u),' ',"
|
||||
"SUBSTRING_INDEX(SUBSTRING_INDEX(`data`,' ',%u),' ',-1)+%u,"
|
||||
"' ',SUBSTRING_INDEX(`data`,' ',%u)) WHERE guid=%u",
|
||||
field, field+1, value, -int32(PLAYER_END-field)-1, guid);
|
||||
}
|
||||
|
||||
bool Database::_SetDataBlobValue(const uint32 guid, const uint32 field, const uint32 value)
|
||||
{
|
||||
return PExecute(
|
||||
"UPDATE characters SET data="
|
||||
"CONCAT(SUBSTRING_INDEX(`data`,' ',%u),' ',"
|
||||
"%u,' ',SUBSTRING_INDEX(`data`,' ',%u)),"
|
||||
"WHERE guid=%u",
|
||||
field, field+1, value, -int32(PLAYER_END-field)-1, guid);
|
||||
}
|
||||
|
||||
bool Database::DirectPExecute(const char * format,...)
|
||||
{
|
||||
if (!format)
|
||||
|
||||
@@ -102,6 +102,9 @@ class TRINITY_DLL_SPEC Database
|
||||
virtual bool DirectExecute(const char* sql) = 0;
|
||||
bool DirectPExecute(const char *format,...) ATTR_PRINTF(2,3);
|
||||
|
||||
bool Database::_UpdateDataBlobValue(const uint32 guid, const uint32 field, const uint32 value);
|
||||
bool Database::_SetDataBlobValue(const uint32 guid, const uint32 field, const uint32 value);
|
||||
|
||||
// Writes SQL commands to a LOG file (see Trinityd.conf "LogSQL")
|
||||
bool PExecuteLog(const char *format,...) ATTR_PRINTF(2,3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user