diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/Chat.cpp | 6 | ||||
| -rw-r--r-- | src/game/Level2.cpp | 128 | ||||
| -rw-r--r-- | src/game/Level3.cpp | 109 | ||||
| -rw-r--r-- | src/game/Pet.h | 1 | ||||
| -rw-r--r-- | src/game/Player.h | 1 | ||||
| -rw-r--r-- | src/game/Spell.cpp | 16 | ||||
| -rw-r--r-- | src/game/SpellAuras.cpp | 4 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 16 | ||||
| -rw-r--r-- | src/game/Unit.h | 2 | ||||
| -rw-r--r-- | src/game/WaypointMovementGenerator.cpp | 14 |
10 files changed, 158 insertions, 139 deletions
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 2cee426fded..c05fd2b35c6 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -859,6 +859,8 @@ int ChatHandler::ParseCommands(const char* text) if(strlen(text) < 2) return 0; + std::string fullcmd = text; // original `text` can't be used. It content destroyed in command code processing. + /// ignore messages staring from many dots. if(text[0] == '.' && text[1] == '.' || text[0] == '!' && text[1] == '!') return 0; @@ -867,9 +869,7 @@ int ChatHandler::ParseCommands(const char* text) if(text[0] == '!' || text[0] == '.') ++text; - std::string fullcmd = text; // original `text` can't be used. It content destroyed in command code processing. - - if(!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) + if(!ExecuteCommandInTable(getCommandTable(), text, fullcmd) && m_session->GetSecurity() > SEC_PLAYER) SendSysMessage(LANG_NO_CMD); return 1; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 5f3b12b0eb8..97a094585d1 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1679,80 +1679,72 @@ bool ChatHandler::HandleNpcFactionIdCommand(const char* args) //kick player bool ChatHandler::HandleKickPlayerCommand(const char *args) { - char* kickName = strtok((char*)args, " "); - char* kickReason = strtok(NULL, "\n"); + if(!*args) + return false; + + const char* kickName = strtok((char*)args, " "); + if(!kickName) + { - if (!kickName) - { - Player* player = getSelectedPlayer(); + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + std::string name = kickName; - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(m_session && name==m_session->GetPlayer()->GetName()) + { + SendSysMessage(LANG_COMMAND_KICKSELF); + SetSentErrorMessage(true); + return false; + } - if(player==m_session->GetPlayer()) - { - SendSysMessage(LANG_COMMAND_KICKSELF); - SetSentErrorMessage(true); - return false; - } - - if(player->GetSession()->GetSecurity() > m_session->GetSecurity()) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); //maybe replacement string for this later on - SetSentErrorMessage(true); - return false; - } + Player* player = objmgr.GetPlayer(kickName); + if(!player) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(player->GetSession()->GetSecurity() > m_session->GetSecurity()) + { + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); //maybe replacement string for this later on + SetSentErrorMessage(true); + return false; + } + + char* kickReason = strtok(NULL, "\n"); + std::string reason = "No Reason"; + if(kickReason) + {reason = kickReason;} - player->GetSession()->KickPlayer(); - } - else + if(sWorld.KickPlayer(name.c_str())) { - std::string name = kickName; - std::string reason = "No Reason"; - if(kickReason) - reason = kickReason; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(m_session && name==m_session->GetPlayer()->GetName()) - { - SendSysMessage(LANG_COMMAND_KICKSELF); - SetSentErrorMessage(true); - return false; - } - - if(objmgr.GetPlayer(kickName)->GetSession()->GetSecurity() > m_session->GetSecurity()) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); //maybe replacement string for this later on - SetSentErrorMessage(true); - return false; - } - - if(sWorld.KickPlayer(name)) - { - if(sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD) == 1) - { - sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, name.c_str(), m_session->GetPlayer()->GetName(), reason.c_str()); - } - else - { - PSendSysMessage(LANG_COMMAND_KICKMESSAGE, name.c_str(), m_session->GetPlayer()->GetName(), reason.c_str()); - } - } - else - PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER, name.c_str()); - } + if(sWorld.getConfig(CONFIG_SHOW_KICK_IN_WORLD) == 1) + { + sWorld.SendWorldText(LANG_COMMAND_KICKMESSAGE, name.c_str(), m_session->GetPlayer()->GetName(), reason.c_str()); + } + else + { + PSendSysMessage(LANG_COMMAND_KICKMESSAGE, name.c_str(), m_session->GetPlayer()->GetName(), reason.c_str()); + } + } + else + { + PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER, name.c_str()); + return false; + } - return true; + return true; } //show info of player diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 6bdffe0b187..ae0ea508308 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -731,43 +731,57 @@ bool ChatHandler::HandleLoadScriptsCommand(const char* args) bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) { - char* arg1 = strtok((char*)args, " "); - if( !arg1 ) + if(!*args) return false; - /// must be NULL if targeted syntax and must be not nULL if not targeted - char* arg2 = strtok(NULL, " "); - std::string targetAccountName; uint32 targetAccountId = 0; uint32 targetSecurity = 0; + uint32 gm = 0; + char* arg1 = strtok((char*)args, " "); + char* arg2 = strtok(NULL, " "); - /// only target player different from self allowed (if targetPlayer!=NULL then not console) - Player* targetPlayer = getSelectedPlayer(); - if(targetPlayer && m_session->GetPlayer()!=targetPlayer) + if(getSelectedPlayer() && arg1 && !arg2) { - /// wrong command syntax or unexpected targeting - if(arg2) - return false; + targetAccountId = getSelectedPlayer()->GetSession()->GetAccountId(); + accmgr.GetName(targetAccountId, targetAccountName); + Player* targetPlayer = getSelectedPlayer(); + gm = atoi(arg1); - /// security level expected in arg2 after this if. - arg2 = arg1; + // Check for invalid specified GM level. + if ( (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) ) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } - targetAccountId = targetPlayer->GetSession()->GetAccountId(); + // Check if targets GM level and specified GM level is not higher than current gm level targetSecurity = targetPlayer->GetSession()->GetSecurity(); - if(!accmgr.GetName(targetAccountId,targetAccountName)) + if(targetSecurity >= m_session->GetSecurity() || gm >= m_session->GetSecurity() ) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); SetSentErrorMessage(true); return false; } - } - else + + // Decide which string to show + if(m_session->GetPlayer()!=targetPlayer) + { + PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); + }else{ + PSendSysMessage(LANG_YOURS_SECURITY_CHANGED, m_session->GetPlayer()->GetName(), gm); + } + + loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + return true; + }else { - /// wrong command syntax (second arg expected) + // Check for second parameter if(!arg2) return false; - + + // Check for account targetAccountName = arg1; if(!AccountMgr::normilizeString(targetAccountName)) { @@ -775,41 +789,34 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) SetSentErrorMessage(true); return false; } + + // Check for invalid specified GM level. + gm = atoi(arg2); + if ( (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) ) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + targetAccountId = accmgr.GetId(arg1); + /// m_session==NULL only for console + uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; - targetAccountId = accmgr.GetId(targetAccountName); + /// can set security level only for target with less security and to less security that we have + /// This is also reject self apply in fact targetSecurity = accmgr.GetSecurity(targetAccountId); - } - - int32 gm = (int32)atoi(arg2); - if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - /// m_session==NULL only for console - uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; - - /// can set security level only for target with less security and to less security that we have - /// This is also reject self apply in fact - if(targetSecurity >= plSecurity || uint32(gm) >= plSecurity ) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage(true); - return false; - } + if(targetSecurity >= plSecurity || gm >= plSecurity ) + { + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); + SetSentErrorMessage(true); + return false; + } - if(targetPlayer) - { - ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,GetName(), gm); - targetPlayer->GetSession()->SetSecurity(gm); + PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); + loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + return true; } - - PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); - loginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId); - - return true; } /// Set password for account diff --git a/src/game/Pet.h b/src/game/Pet.h index 670d4101911..178ebfb131e 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -214,6 +214,7 @@ class Pet : public Creature uint64 GetAuraUpdateMask() { return m_auraUpdateMask; } void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); } + void UnsetAuraUpdateMask(uint8 slot) { m_auraUpdateMask &= ~(uint64(1) << slot); } void ResetAuraUpdateMask() { m_auraUpdateMask = 0; } DeclinedName const* GetDeclinedNames() const { return m_declinedname; } diff --git a/src/game/Player.h b/src/game/Player.h index d46d6b69aaa..ef111762efa 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2156,6 +2156,7 @@ class TRINITY_DLL_SPEC Player : public Unit void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; } uint64 GetAuraUpdateMask() { return m_auraUpdateMask; } void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); } + void UnsetAuraUpdateMask(uint8 slot) { m_auraUpdateMask &= ~(uint64(1) << slot); } Player* GetNextRandomRaidMember(float radius); PartyResult CanUninviteFromGroup() const; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8d5757595cb..e515c592c50 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1127,6 +1127,14 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if( m_caster != unit ) { + if (unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) + { + if (unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + { + m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); + return; + } + } if( !m_caster->IsFriendlyTo(unit) ) { // for delayed spells ignore not visible explicit target @@ -1536,10 +1544,10 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) case TARGET_UNIT_TARGET_ANY: // SelectMagnetTarget()? case TARGET_UNIT_TARGET_PARTY: case TARGET_UNIT_SINGLE_UNKNOWN: - TagUnitMap.push_back(m_targets.getUnitTarget()); + TagUnitMap.push_back(target); break; case TARGET_UNIT_PARTY_TARGET: - m_caster->GetPartyMember(TagUnitMap, radius); + target->GetPartyMember(TagUnitMap, radius); break; case TARGET_UNIT_TARGET_ENEMY: if(Unit* pUnitTarget = SelectMagnetTarget()) @@ -2148,11 +2156,11 @@ void Spell::cancel() { Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if( unit && unit->isAlive() ) - unit->RemoveAurasDueToSpell(m_spellInfo->Id); + unit->RemoveAurasDueToCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); } } - m_caster->RemoveAurasDueToSpell(m_spellInfo->Id); + m_caster->RemoveAurasDueToCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); SendChannelUpdate(0); SendInterrupted(0); SendCastResult(SPELL_FAILED_INTERRUPTED); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 67791f825d4..38ca4e91d4c 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -882,7 +882,7 @@ void Aura::_AddAura() SendAuraUpdate(false); // update for out of range group members - m_target->UpdateAuraForGroup(slot); + m_target->UpdateAuraForGroup(slot, true); } } else // use found slot @@ -970,7 +970,7 @@ void Aura::_RemoveAura() SendAuraUpdate(true); // update for out of range group members - m_target->UpdateAuraForGroup(slot); + m_target->UpdateAuraForGroup(slot, false); if( IsSealSpell(GetSpellProto()) ) m_target->ModifyAuraState(AURA_STATE_JUDGEMENT,false); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 56a63cc5220..5a2503f99fe 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11199,6 +11199,8 @@ void Unit::CleanupsBeforeDelete() { if(m_uint32Values) // only for fully created object { + UnpossessSelf(false); + RemoveAllFromVision(); InterruptNonMeleeSpells(true); m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList CombatStop(); @@ -11208,8 +11210,6 @@ void Unit::CleanupsBeforeDelete() RemoveAllAuras(); RemoveAllGameObjects(); RemoveAllDynObjects(); - UnpossessSelf(false); - RemoveAllFromVision(); GetMotionMaster()->Clear(false); // remove different non-standard movement generators. } RemoveFromWorld(); @@ -12400,7 +12400,7 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT return CastingTime; } -void Unit::UpdateAuraForGroup(uint8 slot) +void Unit::UpdateAuraForGroup(uint8 slot, bool apply) { if(GetTypeId() == TYPEID_PLAYER) { @@ -12408,7 +12408,10 @@ void Unit::UpdateAuraForGroup(uint8 slot) if(player->GetGroup()) { player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS); - player->SetAuraUpdateMask(slot); + if(apply) + player->SetAuraUpdateMask(slot); + else + player->UnsetAuraUpdateMask(slot); } } else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) @@ -12420,7 +12423,10 @@ void Unit::UpdateAuraForGroup(uint8 slot) if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) { ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS); - pet->SetAuraUpdateMask(slot); + if(apply) + pet->SetAuraUpdateMask(slot); + else + pet->UnsetAuraUpdateMask(slot); } } } diff --git a/src/game/Unit.h b/src/game/Unit.h index e2d1a25e7a2..31787663968 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1449,7 +1449,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void UpdateReactives(uint32 p_time); // group updates - void UpdateAuraForGroup(uint8 slot); + void UpdateAuraForGroup(uint8 slot, bool apply); // pet auras typedef std::set<PetAura const*> PetAuraSet; diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 8786d25549e..589afa088c3 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -94,10 +94,14 @@ template<> void WaypointMovementGenerator<Creature>::Initialize(Creature &u) { - u.StopMoving(); - if(!path_id) - path_id = u.GetWaypointPath(); - waypoints = WaypointMgr.GetPath(path_id); + u.StopMoving(); + i_currentNode = -1; // uint32, become 0 in the first update + i_nextMoveTime.Reset(0); + StopedByPlayer = false; + if(!path_id) + path_id = u.GetWaypointPath(); + /*i_currentNode = 0; + waypoints = WaypointMgr.GetPath(path_id); if(waypoints && waypoints->size()) { Traveller<Creature> traveller(u); @@ -105,7 +109,7 @@ WaypointMovementGenerator<Creature>::Initialize(Creature &u) InitTraveller(u,node); i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - } + }*/ } template<> |
