Core/Refer-a-Friend: Finish base work for Refer-a-Friend.

Any testing would be very much appreciated.
This commit is contained in:
Silinoron
2011-08-03 09:28:12 -07:00
parent 98bdbdd76f
commit 76fe596160
12 changed files with 87 additions and 33 deletions
+26 -19
View File
@@ -964,7 +964,10 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
SetUInt32Value(PLAYER_BYTES, (createInfo->Skin | (createInfo->Face << 8) | (createInfo->HairStyle << 16) | (createInfo->HairColor << 24)));
SetUInt32Value(PLAYER_BYTES_2, (createInfo->FacialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24)));
SetUInt32Value(PLAYER_BYTES_2, (createInfo->FacialHair |
(0x00 << 8) |
(0x00 << 16) |
(((GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED) << 24)));
SetByteValue(PLAYER_BYTES_3, 0, createInfo->Gender);
SetByteValue(PLAYER_BYTES_3, 3, 0); // BattlefieldArenaFaction (0 or 1)
@@ -5064,6 +5067,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
RemoveAurasDueToSpell(20584); // speed bonuses
RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND);
setDeathState(ALIVE);
SetMovement(MOVE_LAND_WALK);
@@ -5072,7 +5078,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
m_deathTimer = 0;
// set health/powers (0- will be set in caller)
if (restore_percent>0.0f)
if (restore_percent > 0.0f)
{
SetHealth(uint32(GetMaxHealth()*restore_percent));
SetPower(POWER_MANA, uint32(GetMaxPower(POWER_MANA)*restore_percent));
@@ -16394,8 +16400,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
//"resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, instance_mode_mask, "
// 39 40 41 42 43 44 45 46 47 48 49
//"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, "
// 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
//"health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = '%u'", guid);
// 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
//"health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels FROM characters WHERE guid = '%u'", guid);
PreparedQueryResult result = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADFROM);
if (!result)
@@ -16980,17 +16986,6 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
break;
}
/*switch(sWorld->getIntConfig(CONFIG_GM_ACCEPT_TICKETS))
{
default:
case 0: break; // disable
case 1: SetAcceptTicket(true); break; // enable
case 2: // save state
if (extraflags & PLAYER_EXTRA_GM_ACCEPT_TICKETS)
SetAcceptTicket(true);
break;
}*/
switch (sWorld->getIntConfig(CONFIG_GM_CHAT))
{
default:
@@ -17014,6 +17009,14 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
}
}
// RaF stuff.
m_grantableLevels = fields[66].GetUInt32();
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND);
if (m_grantableLevels > 0)
SetByteValue(PLAYER_FIELD_BYTES, 1, 0x01);
_LoadDeclinedNames(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES));
m_achievementMgr.CheckAllAchievementCriteria();
@@ -18196,7 +18199,7 @@ void Player::SaveToDB()
"trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, "
"death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, "
"todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, "
"power4, power5, power6, power7, latency, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars) VALUES ("
"power4, power5, power6, power7, latency, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels) VALUES ("
<< GetGUIDLow() << ','
<< GetSession()->GetAccountId() << ", '"
<< sql_name << "', "
@@ -18328,6 +18331,8 @@ void Player::SaveToDB()
ss << "',";
ss << uint32(GetByteValue(PLAYER_FIELD_BYTES, 2));
ss << ",";
ss << uint32(m_grantableLevels);
ss << ')';
SQLTransaction trans = CharacterDatabase.BeginTransaction();
@@ -19831,10 +19836,12 @@ void Player::SetRestBonus (float rest_bonus_new)
m_rest_bonus = rest_bonus_new;
// update data for client
if (m_rest_bonus>10)
SetByteValue(PLAYER_BYTES_2, 3, 0x01); // Set Reststate = Rested
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_RAF_LINKED);
else if (m_rest_bonus > 10)
SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_RESTED); // Set Reststate = Rested
else if (m_rest_bonus <= 1)
SetByteValue(PLAYER_BYTES_2, 3, 0x02); // Set Reststate = Normal
SetByteValue(PLAYER_BYTES_2, 3, REST_STATE_NOT_RAF_LINKED); // Set Reststate = Normal
//RestTickUpdate
SetUInt32Value(PLAYER_REST_STATE_EXPERIENCE, uint32(m_rest_bonus));
+7
View File
@@ -884,6 +884,13 @@ enum ReferAFriendError
ERR_REFER_A_FRIEND_SUMMON_OFFLINE_S = 0x0D
};
enum PlayerRestState
{
REST_STATE_RESTED = 0x01,
REST_STATE_NOT_RAF_LINKED = 0x02,
REST_STATE_RAF_LINKED = 0x06
};
class PlayerTaxi
{
public: