Misc fixes.

This commit is contained in:
tomrus88 2009-09-14 18:11:15 +04:00
parent 6f2b9a7e80
commit 2d86aa4535
15 changed files with 53 additions and 76 deletions

View file

@ -99,7 +99,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
return false;
}
plClass = (uint8)pl->getClass();
plClass = pl->getClass();
plName = pl->GetName();
}
else
@ -150,7 +150,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
if(pl)
{
pl->SetInArenaTeam(m_TeamId, GetSlot());
pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType());
pl->SetArenaTeamIdInvited(0);
pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING, newmember.personal_rating );
@ -277,18 +277,13 @@ void ArenaTeam::DelMember(uint64 guid)
}
}
Player *player = objmgr.GetPlayer(guid);
if(player)
if(Player *player = objmgr.GetPlayer(guid))
{
player->SetInArenaTeam(0, GetSlot());
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0);
// delete all info regarding this team
for(int i = 0; i < ARENA_TEAM_END; ++i)
{
player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + i, 0);
}
}
CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u' AND guid = '%u'", GetId(), GUID_LOPART(guid));
}
@ -537,14 +532,12 @@ void ArenaTeam::FinishGame(int32 mod)
if (i->second->GetType() == this->m_Type && i->second->GetStats().rating > m_stats.rating)
++m_stats.rank;
}
}
int32 ArenaTeam::WonAgainst(uint32 againstRating)
{
// called when the team has won
//'chance' calculation - to beat the opponent
// 'chance' calculation - to beat the opponent
float chance = GetChanceAgainst(m_stats.rating, againstRating);
// calculate the rating modification (ELO system with k=32)
int32 mod = (int32)floor(32.0f * (1.0f - chance));
@ -704,25 +697,3 @@ bool ArenaTeam::IsFighting() const
}
return false;
}
/*
arenateam fields (id from 2.3.3 client):
1414 - arena team id 2v2
1415 - 0=captain, 1=member
1416 - played this week
1417 - played this season
1418 - unk - rank?
1419 - personal arena rating
1420 - arena team id 3v3
1421 - 0=captain, 1=member
1422 - played this week
1423 - played this season
1424 - unk - rank?
1425 - personal arena rating
1426 - arena team id 5v5
1427 - 0=captain, 1=member
1428 - played this week
1429 - played this season
1430 - unk - rank?
1431 - personal arena rating
*/

View file

@ -1590,12 +1590,9 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
pCreature->setDeathState(DEAD);
pCreature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pCreature->GetGUID());
pCreature->SetChannelObjectGUID(pCreature->GetGUID());
// aura
pCreature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
//pCreature->SetUInt32Value(UNIT_FIELD_AURAFLAGS, 0x00000009);
//pCreature->SetUInt32Value(UNIT_FIELD_AURALEVELS, 0x0000003C);
//pCreature->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS, 0x000000FF);
// casting visual effect
pCreature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL);
// correct cast speed

View file

@ -1511,7 +1511,7 @@ void Creature::setDeathState(DeathState s)
if(s == JUST_DIED)
{
SetUInt64Value(UNIT_FIELD_TARGET,0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetTargetGUID(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
if(!isPet() && GetCreatureInfo()->SkinLootId)

View file

@ -314,7 +314,7 @@ FleeingMovementGenerator<Creature>::_Init(Creature &owner)
return;
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
owner.SetTargetGUID(0);
is_water_ok = owner.canSwim();
is_land_ok = owner.canWalk();
}

View file

@ -1340,7 +1340,6 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data)
sLog.outDebug("WORLD: CMSG_ITEM_REFUND_INFO_REQUEST");
uint64 guid;
recv_data >> guid; // item guid
Item *item = _player->GetItemByGuid(guid);
@ -1357,5 +1356,5 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data)
return;
}
// refund system not implemented yet
// item refund system not implemented yet
}

View file

@ -383,7 +383,7 @@ void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data )
uint64 guid ;
recv_data >> guid;
_player->SetUInt32Value(UNIT_FIELD_TARGET, guid);
_player->SetTargetGUID(guid);
// update reputation list if need
Unit* unit = ObjectAccessor::GetUnit(*_player, guid );

View file

@ -177,7 +177,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c
if(isType(TYPEMASK_UNIT))
{
if(((Unit*)this)->getVictim())
if(((Unit*)this)->GetTargetGUID())
flags |= UPDATEFLAG_HAS_TARGET;
}
}
@ -554,10 +554,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags, uint32 flags2
// 0x4
if(flags & UPDATEFLAG_HAS_TARGET) // packed guid (current target guid)
{
if(Unit *victim = ((Unit*)this)->getVictim())
data->append(victim->GetPackGUID());
else
*data << uint8(0);
data->appendPackGUID(((Unit*)this)->GetTargetGUID());
}
// 0x2

View file

@ -1609,6 +1609,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
m_movementInfo.t_seat = -1;
m_movementInfo.t_time = 0;
}
@ -13910,18 +13911,18 @@ void Player::_LoadArenaTeamInfo(QueryResult *result)
ArenaTeam* aTeam = objmgr.GetArenaTeamById(arenateamid);
if(!aTeam)
{
sLog.outError("Player::_LoadArenaTeamInfo: couldn't load arenateam %u, week %u, season %u, rating %u", arenateamid, played_week, played_season, personal_rating);
sLog.outError("Player::_LoadArenaTeamInfo: couldn't load arenateam %u", arenateamid);
continue;
}
uint8 arenaSlot = aTeam->GetSlot();
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_ID] = arenateamid; // TeamID
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_TYPE] = aTeam->GetType(); // team type
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_MEMBER] = ((aTeam->GetCaptain() == GetGUID()) ? (uint32)0 : (uint32)1); // Captain 0, member 1
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK] = played_week; // Played Week
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON] = played_season; // Played Season
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_WINS_SEASON] = wons_season; // wins season
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING] = personal_rating; // Personal Rating
m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arenaSlot * ARENA_TEAM_END) + ARENA_TEAM_UNK2] = 0; // unk 3.2
} while (result->NextRow());
delete result;
@ -14194,6 +14195,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
m_movementInfo.t_time = 0;
m_movementInfo.t_seat = -1;
}
_LoadBGData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
@ -14261,6 +14264,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
m_movementInfo.t_time = 0;
m_movementInfo.t_seat = -1;
transGUID = 0;
}
@ -14298,6 +14303,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
m_movementInfo.t_y = 0.0f;
m_movementInfo.t_z = 0.0f;
m_movementInfo.t_o = 0.0f;
m_movementInfo.t_time = 0;
m_movementInfo.t_seat = -1;
transGUID = 0;
}
@ -14400,7 +14407,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
delete result;
// clear channel spell data (if saved at channel spell casting)
SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0);
SetChannelObjectGUID(0);
SetUInt32Value(UNIT_CHANNEL_SPELL,0);
// clear charm/summon related fields

View file

@ -719,7 +719,7 @@ enum InstanceResetWarningType
enum ArenaTeamInfoType
{
ARENA_TEAM_ID = 0,
ARENA_TEAM_UNK2 = 1, // new in 3.2 - team type?
ARENA_TEAM_TYPE = 1, // new in 3.2 - team type?
ARENA_TEAM_MEMBER = 2, // 0 - captain, 1 - member
ARENA_TEAM_GAMES_WEEK = 3,
ARENA_TEAM_GAMES_SEASON = 4,
@ -1443,7 +1443,7 @@ class MANGOS_DLL_SPEC Player : public Unit
QuestStatusMap& getQuestStatusMap() { return mQuestStatus; };
const uint64& GetSelection( ) const { return m_curSelection; }
void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); }
void SetSelection(const uint64 &guid) { m_curSelection = guid; SetTargetGUID(guid); }
uint8 GetComboPoints() { return m_comboPoints; }
const uint64& GetComboTarget() const { return m_comboTarget; }
@ -1659,9 +1659,10 @@ class MANGOS_DLL_SPEC Player : public Unit
static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
// Arena Team
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot)
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
{
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END), ArenaTeamId);
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID, ArenaTeamId);
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_TYPE, type);
}
uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END)); }
static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);

View file

@ -336,7 +336,7 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data )
sLog.outDetail("WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID);
recv_data >> guid;
GetPlayer()->SetUInt64Value(UNIT_FIELD_TARGET, guid);
_player->SetTargetGUID(guid);
GossipText const* pGossip = objmgr.GetGossipText(textID);

View file

@ -3347,7 +3347,7 @@ void Spell::SendChannelUpdate(uint32 time)
{
if(time == 0)
{
m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0);
m_caster->SetChannelObjectGUID(0);
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
}
@ -3401,7 +3401,7 @@ void Spell::SendChannelStart(uint32 duration)
m_timer = duration;
if(target)
m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID());
m_caster->SetChannelObjectGUID(target->GetGUID());
m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);
}

View file

@ -534,7 +534,7 @@ SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint3
Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
{
if (caster)
m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetUInt64Value(UNIT_FIELD_TARGET);
m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetTargetGUID();
else
m_casters_target_guid = 0;
}
@ -3665,7 +3665,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
m_target->addUnitState(UNIT_STAT_STUNNED);
m_target->SetUInt64Value(UNIT_FIELD_TARGET, 0);
m_target->SetTargetGUID(0);
m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0);
@ -3735,7 +3735,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
{
if(m_target->getVictim() && m_target->isAlive())
m_target->SetUInt64Value(UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() );
m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
data.append(m_target->GetPackGUID());
@ -3939,8 +3939,8 @@ void Aura::HandleAuraModRoot(bool apply, bool Real)
m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
m_target->addUnitState(UNIT_STAT_ROOT);
m_target->SetUInt64Value (UNIT_FIELD_TARGET, 0);
// probably wrong (this add skinable flag)
m_target->SetTargetGUID(0);
// probably wrong (this add skinnable flag)
// TODO: find correct flag
//m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
@ -3991,14 +3991,14 @@ void Aura::HandleAuraModRoot(bool apply, bool Real)
return;
m_target->clearUnitState(UNIT_STAT_ROOT);
// probably wrong (this add skinable flag)
// probably wrong (this add skinnable flag)
// TODO: find correct flag
//m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
{
if(m_target->getVictim() && m_target->isAlive())
m_target->SetUInt64Value (UNIT_FIELD_TARGET, m_target->getVictim()->GetGUID() );
m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
if(m_target->GetTypeId() == TYPEID_PLAYER)
{

View file

@ -6518,7 +6518,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
{
case GAMEOBJECT_TYPE_FISHINGNODE:
{
m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID());
m_caster->SetChannelObjectGUID(pGameObj->GetGUID());
m_caster->AddGameObject(pGameObj); // will removed at spell cancel
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))

View file

@ -7629,8 +7629,8 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
}
//Set our target
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
// Set our target
SetTargetGUID(victim->GetGUID());
if(meleeAttack)
addUnitState(UNIT_STAT_MELEE_ATTACKING);
@ -7668,8 +7668,8 @@ bool Unit::AttackStop(bool targetSwitch /*=false*/)
m_attacking->_removeAttacker(this);
m_attacking = NULL;
//Clear our target
SetUInt64Value(UNIT_FIELD_TARGET, 0);
// Clear our target
SetTargetGUID(0);
clearUnitState(UNIT_STAT_MELEE_ATTACKING);
@ -7831,6 +7831,7 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
}
}
}
Unit *Unit::GetOwner() const
{
if(uint64 ownerid = GetOwnerGUID())
@ -7894,7 +7895,7 @@ float Unit::GetCombatDistance( const Unit* target ) const
void Unit::SetPet(Pet* pet)
{
SetUInt64Value(UNIT_FIELD_SUMMON, pet ? pet->GetGUID() : 0);
SetPetGUID(pet ? pet->GetGUID() : 0);
// FIXME: hack, speed must be set only at follow
if(pet && GetTypeId()==TYPEID_PLAYER)
@ -7904,16 +7905,14 @@ void Unit::SetPet(Pet* pet)
void Unit::SetCharm(Unit* pet)
{
SetUInt64Value(UNIT_FIELD_CHARM, pet ? pet->GetGUID() : 0);
SetCharmGUID(pet ? pet->GetGUID() : 0);
}
void Unit::AddGuardian( Pet* pet )
{
m_guardianPets.insert(pet->GetGUID());
}
void Unit::RemoveGuardian( Pet* pet )
{
m_guardianPets.erase(pet->GetGUID());
@ -12136,7 +12135,7 @@ bool Unit::HandleMendingAuraProc( Aura* triggeredByAura )
void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo)
{
uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT);
uint64 target_guid = GetChannelObjectGUID();
if(!IS_UNIT_GUID(target_guid))
return;

View file

@ -1156,9 +1156,15 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); }
void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); }
uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); }
void SetPetGUID(uint64 pet) { SetUInt64Value(UNIT_FIELD_SUMMON, pet); }
uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); }
void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); }
uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); }
void SetCharmGUID(uint64 charm) { SetUInt64Value(UNIT_FIELD_CHARM, charm); }
uint64 GetTargetGUID() const { return GetUInt64Value(UNIT_FIELD_TARGET); }
void SetTargetGUID(uint64 targetGuid) { SetUInt64Value(UNIT_FIELD_TARGET, targetGuid); }
uint64 GetChannelObjectGUID() const { return GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT); }
void SetChannelObjectGUID(uint64 targetGuid) { SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, targetGuid); }
uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
uint64 GetCharmerOrOwnerOrOwnGUID() const