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
+1
View File
@@ -1167,6 +1167,7 @@ CREATE TABLE `characters` (
`ammoId` int(10) unsigned NOT NULL DEFAULT '0',
`knownTitles` longtext,
`actionBars` tinyint(3) unsigned NOT NULL DEFAULT '0',
`grantableLevels` tinyint(3) unsigned NOT NULL DEFAULT '0',
`deleteInfos_Account` int(10) unsigned DEFAULT NULL,
`deleteInfos_Name` varchar(12) DEFAULT NULL,
`deleteDate` int(10) unsigned DEFAULT NULL,
@@ -0,0 +1 @@
ALTER TABLE `characters` ADD COLUMN `grantableLevels` tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER `actionBars`;
+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:
@@ -807,7 +807,7 @@ enum SpellEffects
SPELL_EFFECT_CHARGE_DEST = 149,
SPELL_EFFECT_QUEST_START = 150,
SPELL_EFFECT_TRIGGER_SPELL_2 = 151,
SPELL_EFFECT_152 = 152,
SPELL_EFFECT_SUMMON_RAF_FRIEND = 152,
SPELL_EFFECT_CREATE_TAMED_PET = 153,
SPELL_EFFECT_DISCOVER_TAXI = 154,
SPELL_EFFECT_TITAN_GRIP = 155,
+3 -2
View File
@@ -86,14 +86,15 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
}
/// WorldSession constructor
WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter):
WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
m_muteTime(mute_time), m_timeOutTime(0), _player(NULL), m_Socket(sock),
_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0),
m_inQueue(false), m_playerLoading(false), m_playerLogout(false),
m_playerRecentlyLogout(false), m_playerSave(false),
m_sessionDbcLocale(sWorld->GetAvailableDbcLocale(locale)),
m_sessionDbLocaleIndex(locale),
m_latency(0), m_TutorialsChanged(false), recruiterId(recruiter)
m_latency(0), m_TutorialsChanged(false), recruiterId(recruiter),
isRecruiter(isARecruiter)
{
if (sock)
{
+3 -1
View File
@@ -214,7 +214,7 @@ class CharacterCreateInfo
class WorldSession
{
public:
WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter);
WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter);
~WorldSession();
bool PlayerLoading() const { return m_playerLoading; }
@@ -390,6 +390,7 @@ class WorldSession
// Recruit-A-Friend Handling
uint32 GetRecruiterId() { return recruiterId; }
bool IsARecruiter() { return isRecruiter; }
public: // opcodes handlers
@@ -953,6 +954,7 @@ class WorldSession
bool m_TutorialsChanged;
AddonsList m_addonsList;
uint32 recruiterId;
bool isRecruiter;
ACE_Based::LockedQueue<WorldPacket*, ACE_Thread_Mutex> _recvQueue;
};
#endif
+8 -7
View File
@@ -849,7 +849,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION);
if (expansion > world_expansion)
expansion = world_expansion;
//expansion = ((sWorld->getIntConfig(CONFIG_EXPANSION) > fields[6].GetUInt8()) ? fields[6].GetUInt8() : sWorld->getIntConfig(CONFIG_EXPANSION));
N.SetHexStr ("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");
g.SetDword (7);
@@ -882,11 +881,6 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
}
id = fields[0].GetUInt32();
/*
if (security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB
security = SEC_ADMINISTRATOR;
*/
K.SetHexStr (fields[1].GetCString());
int64 mutetime = fields[7].GetInt64();
@@ -982,6 +976,13 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
account.c_str(),
address.c_str());
// Check if this user is by any chance a recruiter
result = LoginDatabase.PQuery ("SELECT 1 FROM account WHERE recruiter = %u", id);
bool isRecruiter = false;
if (result)
isRecruiter = true;
// Update the last_ip in the database
// No SQL injection, username escaped.
LoginDatabase.EscapeString (address);
@@ -993,7 +994,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
safe_account.c_str());
// NOTE ATM the socket is single-threaded, have this in mind ...
ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale, recruiter), -1);
ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale, recruiter, isRecruiter), -1);
m_Crypt.Init(&K);
+22 -1
View File
@@ -711,6 +711,7 @@ void Spell::SelectSpellTargets()
else if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_TRIGGER_SPELL)
AddUnitTarget(m_caster, i);
break;
case SPELL_EFFECT_SUMMON_RAF_FRIEND:
case SPELL_EFFECT_SUMMON_PLAYER:
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->ToPlayer()->GetSelection())
{
@@ -5276,7 +5277,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_BAD_TARGETS;
Player* target = ObjectAccessor::FindPlayer(m_caster->ToPlayer()->GetSelection());
if (!target || m_caster->ToPlayer() == target || !target->IsInSameRaidWith(m_caster->ToPlayer()))
if (!target || m_caster->ToPlayer() == target || (!target->IsInSameRaidWith(m_caster->ToPlayer()) && m_spellInfo->Id != 48955)) // refer-a-friend spell
return SPELL_FAILED_BAD_TARGETS;
// check if our map is dungeon
@@ -5298,6 +5299,25 @@ SpellCastResult Spell::CheckCast(bool strict)
}
break;
}
// RETURN HERE
case SPELL_EFFECT_SUMMON_RAF_FRIEND:
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_BAD_TARGETS;
Player* playerCaster = m_caster->ToPlayer();
//
if(!(playerCaster->GetSelection()))
return SPELL_FAILED_BAD_TARGETS;
Player* target = ObjectAccessor::FindPlayer(playerCaster->GetSelection());
if (!target ||
!(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId()))
return SPELL_FAILED_BAD_TARGETS;
break;
}
case SPELL_EFFECT_LEAP:
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
{
@@ -6558,6 +6578,7 @@ bool Spell::CheckTarget(Unit* target, uint32 eff)
//Check targets for LOS visibility (except spells without range limitations)
switch(m_spellInfo->Effects[eff].Effect)
{
case SPELL_EFFECT_SUMMON_RAF_FRIEND:
case SPELL_EFFECT_SUMMON_PLAYER: // from anywhere
break;
case SPELL_EFFECT_DUMMY:
+1
View File
@@ -356,6 +356,7 @@ class Spell
void EffectEnergizePct(SpellEffIndex effIndex);
void EffectTriggerSpellWithValue(SpellEffIndex effIndex);
void EffectTriggerRitualOfSummoning(SpellEffIndex effIndex);
void EffectSummonRaFFriend(SpellEffIndex effIndex);
void EffectKillCreditPersonal(SpellEffIndex effIndex);
void EffectKillCredit(SpellEffIndex effIndex);
void EffectQuestFail(SpellEffIndex effIndex);
+13 -1
View File
@@ -216,7 +216,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
&Spell::EffectChargeDest, //149 SPELL_EFFECT_CHARGE_DEST
&Spell::EffectQuestStart, //150 SPELL_EFFECT_QUEST_START
&Spell::EffectTriggerRitualOfSummoning, //151 SPELL_EFFECT_TRIGGER_SPELL_2
&Spell::EffectNULL, //152 SPELL_EFFECT_152 summon Refer-a-Friend
&Spell::EffectSummonRaFFriend, //152 SPELL_EFFECT_SUMMON_RAF_FRIEND summon Refer-a-Friend
&Spell::EffectCreateTamedPet, //153 SPELL_EFFECT_CREATE_TAMED_PET misc value is creature entry
&Spell::EffectDiscoverTaxi, //154 SPELL_EFFECT_DISCOVER_TAXI
&Spell::EffectTitanGrip, //155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal.
@@ -7074,3 +7074,15 @@ void Spell::EffectBind(SpellEffIndex effIndex)
data << uint32(area_id);
player->SendDirectMessage(&data);
}
void Spell::EffectSummonRaFFriend(SpellEffIndex effIndex) {
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
Player *player = m_caster->ToPlayer();
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
m_caster->CastSpell(m_caster, m_spellInfo->Effects[effIndex].TriggerSpell, true);
}
@@ -42,7 +42,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
"position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, "
"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, "
"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, "
"health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars FROM characters WHERE guid = ?", CONNECTION_ASYNC)
"health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels FROM characters WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_GROUP, "SELECT guid FROM group_member WHERE memberGuid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_BOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_AURAS, "SELECT caster_guid, spell, effect_mask, recalculate_mask, stackcount, amount0, amount1, amount2, "