Fixed honor points and arena points displaying in currency tab

Currencies lost (spent all in vendor) are not removed from known currencies tab, they now display 0 count

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-08-10 13:26:07 +02:00
parent 719f770a56
commit 88965d9419
4 changed files with 37 additions and 28 deletions
+1 -1
View File
@@ -4853,7 +4853,7 @@ bool ChatHandler::HandleResetHonorCommand (const char * args)
target->SetUInt32Value(PLAYER_FIELD_KILLS, 0);
target->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0);
target->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0);
target->SetHonorPoints(0);
target->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0);
target->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0);
target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL);
+14 -25
View File
@@ -748,9 +748,9 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
InitRunes();
SetUInt32Value (PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_START_PLAYER_MONEY));
SetUInt32Value (PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_START_HONOR_POINTS));
SetUInt32Value (PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_START_ARENA_POINTS));
SetUInt32Value(PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_START_PLAYER_MONEY));
SetHonorPoints(sWorld.getConfig(CONFIG_START_HONOR_POINTS));
SetArenaPoints(sWorld.getConfig(CONFIG_START_ARENA_POINTS));
// start with every map explored
if (sWorld.getConfig(CONFIG_START_ALL_EXPLORED))
@@ -6837,12 +6837,12 @@ void Player::ModifyHonorPoints(int32 value)
if (value < 0)
{
if (GetHonorPoints() > sWorld.getConfig(CONFIG_MAX_HONOR_POINTS))
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) + value);
SetHonorPoints(sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) + value);
else
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() > uint32(-value) ? GetHonorPoints() + value : 0);
SetHonorPoints(GetHonorPoints() > uint32(-value) ? GetHonorPoints() + value : 0);
}
else
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() < sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) - value ? GetHonorPoints() + value : sWorld.getConfig(CONFIG_MAX_HONOR_POINTS));
SetHonorPoints(GetHonorPoints() < sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) - value ? GetHonorPoints() + value : sWorld.getConfig(CONFIG_MAX_HONOR_POINTS));
}
void Player::ModifyArenaPoints(int32 value)
@@ -6850,12 +6850,12 @@ void Player::ModifyArenaPoints(int32 value)
if (value < 0)
{
if (GetArenaPoints() > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS))
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) + value);
SetArenaPoints(sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) + value);
else
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() > uint32(-value) ? GetArenaPoints() + value : 0);
SetArenaPoints(GetArenaPoints() > uint32(-value) ? GetArenaPoints() + value : 0);
}
else
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() < sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_MAX_ARENA_POINTS));
SetArenaPoints(GetArenaPoints() < sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_MAX_ARENA_POINTS));
}
uint32 Player::GetGuildIdFromDB(uint64 guid)
@@ -11458,7 +11458,7 @@ Item* Player::_StoreItem(uint16 pos, Item *pItem, uint32 count, bool clone, bool
// need update known currency
if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(), true);
AddKnownCurrency(pItem->GetEntry());
if (IsInWorld() && update)
{
@@ -11765,9 +11765,6 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update)
}
}
}
// need update known currency
else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(), false);
m_items[slot] = NULL;
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
@@ -11892,9 +11889,6 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
// equipment visual show
SetVisibleItemSlot(slot, NULL);
}
// need update known currency
else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(), false);
m_items[slot] = NULL;
}
@@ -15937,7 +15931,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
if (arena_currency > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS))
arena_currency = sWorld.getConfig(CONFIG_MAX_ARENA_POINTS);
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, arena_currency);
SetArenaPoints(arena_currency);
// check arena teams integrity
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
@@ -15955,7 +15949,7 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
SetArenaTeamInfoField(arena_slot, ArenaTeamInfoType(j), 0);
}
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, fields[40].GetUInt32());
SetHonorPoints(fields[40].GetUInt32());
SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, fields[41].GetUInt32());
SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, fields[42].GetUInt32());
SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, fields[43].GetUInt32());
@@ -23115,15 +23109,10 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
pet->SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1));
}
void Player::UpdateKnownCurrencies(uint32 itemId, bool apply)
void Player::AddKnownCurrency(uint32 itemId)
{
if (CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId))
{
if (apply)
SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES,(1LL << (ctEntry->BitIndex-1)));
else
RemoveFlag64(PLAYER_FIELD_KNOWN_CURRENCIES,(1LL << (ctEntry->BitIndex-1)));
}
SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (1LL << (ctEntry->BitIndex-1)));
}
void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode)
+21 -1
View File
@@ -844,6 +844,12 @@ enum CharDeleteMethod
// the name gets freed up and appears as deleted ingame
};
enum CurrencyItems
{
ITEM_HONOR_POINTS_ID = 43308,
ITEM_ARENA_POINTS_ID = 43307
};
class PlayerTaxi
{
public:
@@ -1938,6 +1944,18 @@ class Player : public Unit, public GridObject<Player>
void ModifyHonorPoints(int32 value);
void ModifyArenaPoints(int32 value);
uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot);
void SetHonorPoints(uint32 value)
{
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, value);
if (value)
AddKnownCurrency(ITEM_HONOR_POINTS_ID); // Arena Points
}
void SetArenaPoints(uint32 value)
{
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, value);
if (value)
AddKnownCurrency(ITEM_ARENA_POINTS_ID); // Arena Points
}
//End of PvP System
@@ -2596,7 +2614,9 @@ class Player : public Unit, public GridObject<Player>
void SendRefundInfo(Item* item);
void RefundItem(Item* item);
void UpdateKnownCurrencies(uint32 itemId, bool apply);
// know currencies are not removed at any point (0 displayed)
void AddKnownCurrency(uint32 itemId);
int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest, bool noQuestBonus = false);
void AdjustQuestReqItemCount(Quest const* pQuest, QuestStatusData& questStatusData);
@@ -1250,7 +1250,7 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data)
WorldPacket data(MSG_INSPECT_HONOR_STATS, 8+1+4*4);
data << uint64(player->GetGUID());
data << uint8(player->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY));
data << uint8(player->GetHonorPoints());
data << uint32(player->GetUInt32Value(PLAYER_FIELD_KILLS));
data << uint32(player->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION));
data << uint32(player->GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION));