mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11187] Minimize direct access to honor and arena points fields
This commit is contained in:
parent
49ef8edb6a
commit
972c08a878
4 changed files with 43 additions and 37 deletions
|
|
@ -4724,9 +4724,9 @@ bool ChatHandler::HandleResetHonorCommand(char* args)
|
||||||
if (!ExtractPlayerTarget(&args, &target))
|
if (!ExtractPlayerTarget(&args, &target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
target->SetHonorPoints(0);
|
||||||
target->SetUInt32Value(PLAYER_FIELD_KILLS, 0);
|
target->SetUInt32Value(PLAYER_FIELD_KILLS, 0);
|
||||||
target->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0);
|
target->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0);
|
||||||
target->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0);
|
|
||||||
target->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0);
|
target->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0);
|
||||||
target->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0);
|
target->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0);
|
||||||
target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL);
|
target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL);
|
||||||
|
|
|
||||||
|
|
@ -737,8 +737,8 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
||||||
InitRunes();
|
InitRunes();
|
||||||
|
|
||||||
SetUInt32Value (PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY));
|
SetUInt32Value (PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY));
|
||||||
SetUInt32Value (PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_UINT32_START_HONOR_POINTS));
|
SetHonorPoints(sWorld.getConfig(CONFIG_UINT32_START_HONOR_POINTS));
|
||||||
SetUInt32Value (PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_UINT32_START_ARENA_POINTS));
|
SetArenaPoints(sWorld.getConfig(CONFIG_UINT32_START_ARENA_POINTS));
|
||||||
|
|
||||||
// Played time
|
// Played time
|
||||||
m_Last_tick = time(NULL);
|
m_Last_tick = time(NULL);
|
||||||
|
|
@ -6646,30 +6646,40 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ModifyHonorPoints( int32 value )
|
void Player::SetHonorPoints(uint32 value)
|
||||||
{
|
{
|
||||||
if(value < 0)
|
if (value > sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS))
|
||||||
{
|
value = sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS);
|
||||||
if (GetHonorPoints() > sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS))
|
|
||||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS) + value);
|
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, value);
|
||||||
else
|
|
||||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() > uint32(-value) ? GetHonorPoints() + value : 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() < sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS) - value ? GetHonorPoints() + value : sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ModifyArenaPoints( int32 value )
|
void Player::SetArenaPoints(uint32 value)
|
||||||
{
|
{
|
||||||
if(value < 0)
|
if (value > sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS))
|
||||||
{
|
value = sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS);
|
||||||
if (GetArenaPoints() > sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS))
|
|
||||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS) + value);
|
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, value);
|
||||||
else
|
}
|
||||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() > uint32(-value) ? GetArenaPoints() + value : 0);
|
|
||||||
}
|
void Player::ModifyHonorPoints(int32 value)
|
||||||
else
|
{
|
||||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() < sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS));
|
int32 newValue = (int32)GetHonorPoints() + value;
|
||||||
|
|
||||||
|
if (newValue < 0)
|
||||||
|
newValue = 0;
|
||||||
|
|
||||||
|
SetHonorPoints(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::ModifyArenaPoints(int32 value)
|
||||||
|
{
|
||||||
|
int32 newValue = (int32)GetArenaPoints() + value;
|
||||||
|
|
||||||
|
if (newValue < 0)
|
||||||
|
newValue = 0;
|
||||||
|
|
||||||
|
SetArenaPoints(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Player::GetGuildIdFromDB(ObjectGuid guid)
|
uint32 Player::GetGuildIdFromDB(ObjectGuid guid)
|
||||||
|
|
@ -15313,11 +15323,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
||||||
|
|
||||||
_LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO));
|
_LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO));
|
||||||
|
|
||||||
uint32 arena_currency = fields[39].GetUInt32();
|
SetArenaPoints(fields[39].GetUInt32());
|
||||||
if (arena_currency > sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS))
|
|
||||||
arena_currency = sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS);
|
|
||||||
|
|
||||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, arena_currency);
|
|
||||||
|
|
||||||
// check arena teams integrity
|
// check arena teams integrity
|
||||||
for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||||
|
|
@ -15335,10 +15341,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
||||||
SetArenaTeamInfoField(arena_slot, ArenaTeamInfoType(j), 0);
|
SetArenaTeamInfoField(arena_slot, ArenaTeamInfoType(j), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 honor_currency = fields[40].GetUInt32();
|
SetHonorPoints(fields[40].GetUInt32());
|
||||||
if (honor_currency > sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS))
|
|
||||||
honor_currency = sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS);
|
|
||||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, honor_currency);
|
|
||||||
|
|
||||||
SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, fields[41].GetUInt32());
|
SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, fields[41].GetUInt32());
|
||||||
SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, fields[42].GetUInt32());
|
SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, fields[42].GetUInt32());
|
||||||
|
|
|
||||||
|
|
@ -2010,10 +2010,13 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
void UpdateArenaFields();
|
void UpdateArenaFields();
|
||||||
void UpdateHonorFields();
|
void UpdateHonorFields();
|
||||||
bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
|
bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1);
|
||||||
uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
|
uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
|
||||||
uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
|
uint32 GetArenaPoints() const { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); }
|
||||||
void ModifyHonorPoints( int32 value );
|
void SetHonorPoints(uint32 value);
|
||||||
void ModifyArenaPoints( int32 value );
|
void SetArenaPoints(uint32 value);
|
||||||
|
void ModifyHonorPoints(int32 value);
|
||||||
|
void ModifyArenaPoints(int32 value);
|
||||||
|
|
||||||
uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot);
|
uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot);
|
||||||
|
|
||||||
//End of PvP System
|
//End of PvP System
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11186"
|
#define REVISION_NR "11187"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue