diff options
Diffstat (limited to 'src/game/Level1.cpp')
| -rw-r--r-- | src/game/Level1.cpp | 458 | 
1 files changed, 325 insertions, 133 deletions
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 489cc656243..90b167b06f0 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1,7 +1,7 @@  /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>   * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ bool ChatHandler::HandleNpcSayCommand(const char* args)          return false;      } -    pCreature->Say(args, LANG_UNIVERSAL, 0); +    pCreature->MonsterSay(args, LANG_UNIVERSAL, 0);      return true;  } @@ -71,7 +71,7 @@ bool ChatHandler::HandleNpcYellCommand(const char* args)          return false;      } -    pCreature->Yell(args, LANG_UNIVERSAL, 0); +    pCreature->MonsterYell(args, LANG_UNIVERSAL, 0);      return true;  } @@ -91,7 +91,7 @@ bool ChatHandler::HandleNpcTextEmoteCommand(const char* args)          return false;      } -    pCreature->TextEmote(args, 0); +    pCreature->MonsterTextEmote(args, 0);      return true;  } @@ -115,7 +115,11 @@ bool ChatHandler::HandleNpcWhisperCommand(const char* args)      uint64 receiver_guid= atol(receiver_str); -    pCreature->Whisper(text,receiver_guid); +    // check online security +    if (HasLowerSecurity(objmgr.GetPlayer(receiver_guid), 0)) +        return false; + +    pCreature->MonsterWhisper(text,receiver_guid);      return true;  } @@ -125,8 +129,7 @@ bool ChatHandler::HandleNameAnnounceCommand(const char* args)      WorldPacket data;      if(!*args)          return false; -    //char str[1024]; -    //sprintf(str, GetTrinityString(LANG_ANNOUNCE_COLOR), m_session->GetPlayer()->GetName(), args); +      sWorld.SendWorldText(LANG_ANNOUNCE_COLOR, m_session->GetPlayer()->GetName(), args);      return true;  } @@ -650,14 +653,16 @@ bool ChatHandler::HandleVisibleCommand(const char* args)      return false;  } + +  bool ChatHandler::HandleGPSCommand(const char* args)  {      WorldObject *obj = NULL;      if (*args)      { -        std::string name = args; -        if(normalizePlayerName(name)) -            obj = objmgr.GetPlayer(name.c_str()); +        uint64 guid = extractGuidFromLink((char*)args); +        if(guid) +            obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*m_session->GetPlayer(),guid,TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);          if(!obj)          { @@ -708,18 +713,20 @@ bool ChatHandler::HandleGPSCommand(const char* args)          obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ),          zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),          area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ), +        obj->GetPhaseMask(),          obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),          cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),          zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );      sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):", -        GetName(), +        m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND),          (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(),          (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) );      sLog.outDebug(GetTrinityString(LANG_MAP_POSITION),          obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),          zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),          area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), +        obj->GetPhaseMask(),          obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),          cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),          zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); @@ -733,9 +740,8 @@ bool ChatHandler::HandleNamegoCommand(const char* args)      if(!*args)          return false; -    std::string name = args; - -    if(!normalizePlayerName(name)) +    std::string name = extractPlayerNameFromLink((char*)args); +    if(name.empty())      {          SendSysMessage(LANG_PLAYER_NOT_FOUND);          SetSentErrorMessage(true); @@ -745,9 +751,14 @@ bool ChatHandler::HandleNamegoCommand(const char* args)      Player *chr = objmgr.GetPlayer(name.c_str());      if (chr)      { +        std::string nameLink = playerLink(name); +        // check online security +        if (HasLowerSecurity(chr, 0)) +            return false; +          if(chr->IsBeingTeleported()==true)          { -            PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); +            PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());              SetSentErrorMessage(true);              return false;          } @@ -756,10 +767,25 @@ bool ChatHandler::HandleNamegoCommand(const char* args)          if(pMap->IsBattleGroundOrArena())          { -            // cannot summon to bg -            PSendSysMessage(LANG_CANNOT_SUMMON_TO_BG,chr->GetName()); -            SetSentErrorMessage(true); -            return false; +            // only allow if gm mode is on +            if (!chr->isGameMaster()) +            { +                PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chr->GetName()); +                SetSentErrorMessage(true); +                return false; +            } +            // if both players are in different bgs +            else if (chr->GetBattleGroundId() && m_session->GetPlayer()->GetBattleGroundId() != chr->GetBattleGroundId()) +            { +                PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chr->GetName()); +                SetSentErrorMessage(true); +                return false; +            } +            // all's well, set bg id +            // when porting out from the bg, it will be reset to 0 +            chr->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId()); +            // remember current position as entry point for return at bg end teleportation +            chr->SetBattleGroundEntryPoint(chr->GetMapId(),chr->GetPositionX(),chr->GetPositionY(),chr->GetPositionZ(),chr->GetOrientation());          }          else if(pMap->IsDungeon())          { @@ -767,7 +793,7 @@ bool ChatHandler::HandleNamegoCommand(const char* args)              if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )              {                  // cannot summon from instance to instance -                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); +                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());                  SetSentErrorMessage(true);                  return false;              } @@ -778,15 +804,15 @@ bool ChatHandler::HandleNamegoCommand(const char* args)                  (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )                  // the last check is a bit excessive, but let it be, just in case              { -                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); +                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());                  SetSentErrorMessage(true);                  return false;              }          } -        PSendSysMessage(LANG_SUMMONING, chr->GetName(),""); +        PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),"");          if (needReportToTarget(chr)) -            ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, GetName()); +            ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str());          // stop flight if need          if(chr->isInFlight()) @@ -805,7 +831,13 @@ bool ChatHandler::HandleNamegoCommand(const char* args)      }      else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))      { -        PSendSysMessage(LANG_SUMMONING, name.c_str(),GetTrinityString(LANG_OFFLINE)); +        // check offline security +        if (HasLowerSecurity(NULL, guid)) +            return false; + +        std::string nameLink = playerLink(name); + +        PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),GetMangosString(LANG_OFFLINE));          // in point where GM stay          Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(), @@ -833,9 +865,8 @@ bool ChatHandler::HandleGonameCommand(const char* args)      Player* _player = m_session->GetPlayer(); -    std::string name = args; - -    if(!normalizePlayerName(name)) +    std::string name = extractPlayerNameFromLink((char*)args); +    if(name.empty())      {          SendSysMessage(LANG_PLAYER_NOT_FOUND);          SetSentErrorMessage(true); @@ -845,28 +876,36 @@ bool ChatHandler::HandleGonameCommand(const char* args)      Player *chr = objmgr.GetPlayer(name.c_str());      if (chr)      { +        // check online security +        if (HasLowerSecurity(chr, 0)) +            return false; + +        std::string chrNameLink = playerLink(name); +          Map* cMap = chr->GetMap();          if(cMap->IsBattleGroundOrArena())          {              // only allow if gm mode is on              if (!_player->isGameMaster())              { -                PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chr->GetName()); +                PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chrNameLink.c_str());                  SetSentErrorMessage(true);                  return false;              } -            // if already in a bg, don't let port to other -            else if (_player->GetBattleGroundId()) +            // if both players are in different bgs +            else if (_player->GetBattleGroundId() && _player->GetBattleGroundId() != chr->GetBattleGroundId())              { -                PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chr->GetName()); +                PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chrNameLink.c_str());                  SetSentErrorMessage(true);                  return false;              }              // all's well, set bg id              // when porting out from the bg, it will be reset to 0 -            _player->SetBattleGroundId(chr->GetBattleGroundId()); +            _player->SetBattleGroundId(chr->GetBattleGroundId(), chr->GetBattleGroundTypeId()); +            // remember current position as entry point for return at bg end teleportation +            _player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());          } -        else if(cMap->IsDungeon()) +        else if(cMap->IsDungeon() && cMap->Instanceable())          {              Map* pMap = MapManager::Instance().GetMap(_player->GetMapId(),_player); @@ -878,7 +917,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)                  // we are in group, we can go only if we are in the player group                  if (_player->GetGroup() != chr->GetGroup())                  { -                    PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName()); +                    PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chrNameLink.c_str());                      SetSentErrorMessage(true);                      return false;                  } @@ -888,7 +927,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)                  // we are not in group, let's verify our GM mode                  if (!_player->isGameMaster())                  { -                    PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName()); +                    PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chrNameLink.c_str());                      SetSentErrorMessage(true);                      return false;                  } @@ -912,10 +951,9 @@ bool ChatHandler::HandleGonameCommand(const char* args)              _player->SetDifficulty(chr->GetDifficulty());          } -        PSendSysMessage(LANG_APPEARING_AT, chr->GetName()); - +        PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str());          if (_player->IsVisibleGloballyFor(chr)) -            ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName()); +            ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, GetNameLink().c_str());          // stop flight if need          if(_player->isInFlight()) @@ -938,7 +976,13 @@ bool ChatHandler::HandleGonameCommand(const char* args)      if (uint64 guid = objmgr.GetPlayerGUIDByName(name))      { -        PSendSysMessage(LANG_APPEARING_AT, name.c_str()); +        // check offline security +        if (HasLowerSecurity(NULL, guid)) +            return false; + +        std::string nameLink = playerLink(name); + +        PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());          // to point where player stay (if loaded)          float x,y,z,o; @@ -977,12 +1021,15 @@ bool ChatHandler::HandleRecallCommand(const char* args)          chr = getSelectedPlayer();          if(!chr)              chr = m_session->GetPlayer(); + +        // check online security +        else if (HasLowerSecurity(chr, 0)) +            return false;      }      else      { -        std::string name = args; - -        if(!normalizePlayerName(name)) +        std::string name = extractPlayerNameFromLink((char*)args); +        if(name.empty())          {              SendSysMessage(LANG_PLAYER_NOT_FOUND);              SetSentErrorMessage(true); @@ -997,11 +1044,15 @@ bool ChatHandler::HandleRecallCommand(const char* args)              SetSentErrorMessage(true);              return false;          } + +        // check online security +        if (HasLowerSecurity(chr, 0)) +            return false;      }      if(chr->IsBeingTeleported())      { -        PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); +        PSendSysMessage(LANG_IS_TELEPORTED, GetNameLink(chr).c_str());          SetSentErrorMessage(true);          return false;      } @@ -1035,6 +1086,10 @@ bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; +      uint64 titles2 = titles;      for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i) @@ -1084,9 +1139,13 @@ bool ChatHandler::HandleModifyHPCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr).c_str(), hp, hpm);      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetName(), hp, hpm); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm);      chr->SetMaxHealth( hpm );      chr->SetHealth( hp ); @@ -1128,9 +1187,13 @@ bool ChatHandler::HandleModifyManaCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_MANA, GetNameLink(chr).c_str(), mana, manam);      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetName(), mana, manam); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam);      chr->SetMaxPower(POWER_MANA,manam );      chr->SetPower(POWER_MANA, mana ); @@ -1173,9 +1236,13 @@ bool ChatHandler::HandleModifyEnergyCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_ENERGY, GetNameLink(chr).c_str(), energy/10, energym/10);      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetName(), energy/10, energym/10); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy/10, energym/10);      chr->SetMaxPower(POWER_ENERGY,energym );      chr->SetPower(POWER_ENERGY, energy ); @@ -1220,9 +1287,13 @@ bool ChatHandler::HandleModifyRageCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_RAGE, GetNameLink(chr).c_str(), rage/10, ragem/10);      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetName(), rage/10, ragem/10); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage/10, ragem/10);      chr->SetMaxPower(POWER_RAGE,ragem );      chr->SetPower(POWER_RAGE, rage ); @@ -1230,6 +1301,40 @@ bool ChatHandler::HandleModifyRageCommand(const char* args)      return true;  } +// Edit Player Runic Power +bool ChatHandler::HandleModifyRunicPowerCommand(const char* args) +{ +    if(!*args) +        return false; + +    int32 rune = atoi((char*)args)*10; +    int32 runem = atoi((char*)args)*10; + +    if (rune <= 0 || runem <= 0 || runem < rune) +    { +        SendSysMessage(LANG_BAD_VALUE); +        SetSentErrorMessage(true); +        return false; +    } + +    Player *chr = getSelectedPlayer(); +    if (chr == NULL) +    { +        SendSysMessage(LANG_NO_CHAR_SELECTED); +        SetSentErrorMessage(true); +        return false; +    } + +    PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, GetNameLink(chr).c_str(), rune/10, runem/10); +    if (needReportToTarget(chr)) +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10); + +    chr->SetMaxPower(POWER_RUNIC_POWER,runem ); +    chr->SetPower(POWER_RUNIC_POWER, rune ); + +    return true; +} +  //Edit Player Faction  bool ChatHandler::HandleModifyFactionCommand(const char* args)  { @@ -1344,9 +1449,13 @@ bool ChatHandler::HandleModifySpellCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName()); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, GetNameLink(chr).c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, GetName(), spellflatid, val, mark); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, GetNameLink().c_str(), spellflatid, val, mark);      WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2));      data << uint8(spellflatid); @@ -1374,6 +1483,11 @@ bool ChatHandler::HandleModifyTalentCommand (const char* args)              SetSentErrorMessage(true);              return false;          } + +        // check online security +        if (HasLowerSecurity(player, 0)) +            return false; +          player->SetFreeTalentPoints(tp);          return true;      } @@ -1398,21 +1512,25 @@ bool ChatHandler::HandleTaxiCheatCommand(const char* args)          chr=m_session->GetPlayer();      } +    // check online security +    else if (HasLowerSecurity(chr, 0)) +        return false; +      if (argstr == "on")      {          chr->SetTaxiCheater(true); -        PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName()); +        PSendSysMessage(LANG_YOU_GIVE_TAXIS, GetNameLink(chr).c_str());          if (needReportToTarget(chr)) -            ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetName()); +            ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetNameLink().c_str());          return true;      }      if (argstr == "off")      {          chr->SetTaxiCheater(false); -        PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName()); +        PSendSysMessage(LANG_YOU_REMOVE_TAXIS, GetNameLink(chr).c_str());          if (needReportToTarget(chr)) -            ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetName()); +            ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetNameLink().c_str());          return true;      } @@ -1445,16 +1563,22 @@ bool ChatHandler::HandleModifyASpeedCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    std::string chrNameLink = GetNameLink(chr); +      if(chr->isInFlight())      { -        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); +        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());          SetSentErrorMessage(true);          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName()); +    PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chrNameLink.c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetName(), ASpeed); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetNameLink().c_str(), ASpeed);      chr->SetSpeed(MOVE_WALK,    ASpeed,true);      chr->SetSpeed(MOVE_RUN,     ASpeed,true); @@ -1487,16 +1611,22 @@ bool ChatHandler::HandleModifySpeedCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    std::string chrNameLink = GetNameLink(chr); +      if(chr->isInFlight())      { -        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); +        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());          SetSentErrorMessage(true);          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName()); +    PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chrNameLink.c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetName(), Speed); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetNameLink().c_str(), Speed);      chr->SetSpeed(MOVE_RUN,Speed,true); @@ -1526,16 +1656,22 @@ bool ChatHandler::HandleModifySwimCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    std::string chrNameLink = GetNameLink(chr); +      if(chr->isInFlight())      { -        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); +        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());          SetSentErrorMessage(true);          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName()); +    PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chrNameLink.c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetName(), Swim); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetNameLink().c_str(), Swim);      chr->SetSpeed(MOVE_SWIM,Swim,true); @@ -1565,16 +1701,22 @@ bool ChatHandler::HandleModifyBWalkCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    std::string chrNameLink = GetNameLink(chr); +      if(chr->isInFlight())      { -        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); +        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());          SetSentErrorMessage(true);          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName()); +    PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chrNameLink.c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetName(), BSpeed); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetNameLink().c_str(), BSpeed);      chr->SetSpeed(MOVE_RUN_BACK,BSpeed,true); @@ -1604,9 +1746,13 @@ bool ChatHandler::HandleModifyFlyCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName()); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, GetNameLink(chr).c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetName(), FSpeed); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetNameLink().c_str(), FSpeed);      chr->SetSpeed(MOVE_FLIGHT,FSpeed,true); @@ -1635,9 +1781,13 @@ bool ChatHandler::HandleModifyScaleCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName()); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, GetNameLink(chr).c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetName(), Scale); +        ChatHandler(chr).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetNameLink().c_str(), Scale);      chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); @@ -1878,9 +2028,13 @@ bool ChatHandler::HandleModifyMountCommand(const char* args)          return false;      } -    PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName()); +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; + +    PSendSysMessage(LANG_YOU_GIVE_MOUNT, GetNameLink(chr).c_str());      if (needReportToTarget(chr)) -        ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetName()); +        ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetNameLink().c_str());      chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 );      chr->Mount(mId); @@ -1915,6 +2069,10 @@ bool ChatHandler::HandleModifyMoneyCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(chr, 0)) +        return false; +      int32 addmoney = atoi((char*)args);      uint32 moneyuser = chr->GetMoney(); @@ -1926,25 +2084,25 @@ bool ChatHandler::HandleModifyMoneyCommand(const char* args)          sLog.outDetail(GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney);          if(newmoney <= 0 )          { -            PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName()); +            PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str());              if (needReportToTarget(chr)) -                ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetName()); +                ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetNameLink().c_str());              chr->SetMoney(0);          }          else          { -            PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName()); +            PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), GetNameLink(chr).c_str());              if (needReportToTarget(chr)) -                ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetName(), abs(addmoney)); +                ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetNameLink().c_str(), abs(addmoney));              chr->SetMoney( newmoney );          }      }      else      { -        PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName()); +        PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, GetNameLink(chr).c_str());          if (needReportToTarget(chr)) -            ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetName(), addmoney); +            ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetNameLink().c_str(), addmoney);          chr->ModifyMoney( addmoney );      } @@ -1953,20 +2111,24 @@ bool ChatHandler::HandleModifyMoneyCommand(const char* args)      return true;  } -//Edit Player field +//Edit Unit field  bool ChatHandler::HandleModifyBitCommand(const char* args)  {      if( !*args )          return false; -    Player *chr = getSelectedPlayer(); -    if (chr == NULL) +    Unit *unit = getSelectedUnit(); +    if (!unit)      {          SendSysMessage(LANG_NO_CHAR_SELECTED);          SetSentErrorMessage(true);          return false;      } +    // check online security +    if (unit->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player *)unit, 0)) +        return false; +      char* pField = strtok((char*)args, " ");      if (!pField)          return false; @@ -1978,13 +2140,12 @@ bool ChatHandler::HandleModifyBitCommand(const char* args)      uint16 field = atoi(pField);      uint32 bit   = atoi(pBit); -    if (field < 1 || field >= PLAYER_END) +    if (field < OBJECT_END || field >= unit->GetValuesCount())      {          SendSysMessage(LANG_BAD_VALUE);          SetSentErrorMessage(true);          return false;      } -      if (bit < 1 || bit > 32)      {          SendSysMessage(LANG_BAD_VALUE); @@ -1992,17 +2153,16 @@ bool ChatHandler::HandleModifyBitCommand(const char* args)          return false;      } -    if ( chr->HasFlag( field, (1<<(bit-1)) ) ) +    if ( unit->HasFlag( field, (1<<(bit-1)) ) )      { -        chr->RemoveFlag( field, (1<<(bit-1)) ); +        unit->RemoveFlag( field, (1<<(bit-1)) );          PSendSysMessage(LANG_REMOVE_BIT, bit, field);      }      else      { -        chr->SetFlag( field, (1<<(bit-1)) ); +        unit->SetFlag( field, (1<<(bit-1)) );          PSendSysMessage(LANG_SET_BIT, bit, field);      } -      return true;  } @@ -2019,11 +2179,15 @@ bool ChatHandler::HandleModifyHonorCommand (const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(target, 0)) +        return false; +      int32 amount = (uint32)atoi(args);      target->ModifyHonorPoints(amount); -    PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints()); +    PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, GetNameLink(target).c_str(), target->GetHonorPoints());      return true;  } @@ -2126,8 +2290,10 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args)              }          }      } +      if (counter == 0)                                      // if counter == 0 then we found nth          SendSysMessage (LANG_COMMAND_NOAREAFOUND); +      return true;  } @@ -2254,9 +2420,13 @@ bool ChatHandler::HandleSendMailCommand(const char* args)      // format: name "subject text" "mail text" -    char* pName = strtok((char*)args, " "); -    if(!pName) +    std::string name = extractPlayerNameFromLink((char*)args); +    if(name.empty()) +    { +        SendSysMessage(LANG_PLAYER_NOT_FOUND); +        SetSentErrorMessage(true);          return false; +    }      char* tail1 = strtok(NULL, "");      if(!tail1) @@ -2294,18 +2464,10 @@ bool ChatHandler::HandleSendMailCommand(const char* args)      if (!msgText)          return false; -    // pName, msgSubject, msgText isn't NUL after prev. check -    std::string name    = pName; +    // msgSubject, msgText isn't NUL after prev. check      std::string subject = msgSubject;      std::string text    = msgText; -    if(!normalizePlayerName(name)) -    { -        SendSysMessage(LANG_PLAYER_NOT_FOUND); -        SetSentErrorMessage(true); -        return false; -    } -      uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);      if(!receiver_guid)      { @@ -2314,7 +2476,6 @@ bool ChatHandler::HandleSendMailCommand(const char* args)          return false;      } -    uint32 mailId = objmgr.GenerateMailID();      // from console show not existed sender      uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0; @@ -2326,7 +2487,8 @@ bool ChatHandler::HandleSendMailCommand(const char* args)      WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE); -    PSendSysMessage(LANG_MAIL_SENT, name.c_str()); +    std::string nameLink = playerLink(name); +    PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());      return true;  } @@ -2336,14 +2498,8 @@ bool ChatHandler::HandleNameTeleCommand(const char * args)      if(!*args)          return false; -    char* pName = strtok((char*)args, " "); - -    if(!pName) -        return false; - -    std::string name = pName; - -    if(!normalizePlayerName(name)) +    std::string name = extractPlayerNameFromLink((char*)args); +    if(name.empty())      {          SendSysMessage(LANG_PLAYER_NOT_FOUND);          SetSentErrorMessage(true); @@ -2374,17 +2530,22 @@ bool ChatHandler::HandleNameTeleCommand(const char * args)      Player *chr = objmgr.GetPlayer(name.c_str());      if (chr)      { +        // check online security +        if (HasLowerSecurity(chr, 0)) +            return false; + +        std::string chrNameLink = playerLink(name);          if(chr->IsBeingTeleported()==true)          { -            PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); +            PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());              SetSentErrorMessage(true);              return false;          } -        PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str()); +        PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str());          if (needReportToTarget(chr)) -            ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetName()); +            ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str());          // stop flight if need          if(chr->isInFlight()) @@ -2398,10 +2559,17 @@ bool ChatHandler::HandleNameTeleCommand(const char * args)          chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);      } -    else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str())) +    else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))      { -        PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetTrinityString(LANG_OFFLINE), tele->name.c_str()); -        Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y),guid); +        // check offline security +        if (HasLowerSecurity(NULL, guid)) +            return false; + +        std::string nameLink = playerLink(name); + +        PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); +        Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation, +            MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),guid);      }      else          PSendSysMessage(LANG_NO_PLAYER, name.c_str()); @@ -2423,6 +2591,10 @@ bool ChatHandler::HandleGroupTeleCommand(const char * args)          return false;      } +    // check online security +    if (HasLowerSecurity(player, 0)) +        return false; +      // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r      GameTele const* tele = extractGameTeleFromLink((char*)args);      if(!tele) @@ -2439,10 +2611,13 @@ bool ChatHandler::HandleGroupTeleCommand(const char * args)          SetSentErrorMessage(true);          return false;      } + +    std::string nameLink = GetNameLink(player); +      Group *grp = player->GetGroup();      if(!grp)      { -        PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); +        PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());          SetSentErrorMessage(true);          return false;      } @@ -2454,15 +2629,21 @@ bool ChatHandler::HandleGroupTeleCommand(const char * args)          if(!pl || !pl->GetSession() )              continue; +        // check online security +        if (HasLowerSecurity(pl, 0)) +            return false; + +        std::string plNameLink = GetNameLink(pl); +          if(pl->IsBeingTeleported())          { -            PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); +            PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());              continue;          } -        PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", tele->name.c_str()); +        PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str());          if (needReportToTarget(pl)) -            ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetName()); +            ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());          // stop flight if need          if(pl->isInFlight()) @@ -2486,9 +2667,8 @@ bool ChatHandler::HandleGroupgoCommand(const char* args)      if(!*args)          return false; -    std::string name = args; - -    if(!normalizePlayerName(name)) +    std::string name = extractPlayerNameFromLink((char*)args); +    if(name.empty())      {          SendSysMessage(LANG_PLAYER_NOT_FOUND);          SetSentErrorMessage(true); @@ -2503,16 +2683,22 @@ bool ChatHandler::HandleGroupgoCommand(const char* args)          return false;      } +    // check online security +    if (HasLowerSecurity(player, 0)) +        return false; +      Group *grp = player->GetGroup(); +    std::string nameLink = playerLink(name); +      if(!grp)      { -        PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); +        PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());          SetSentErrorMessage(true);          return false;      } -    Map* gmMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); +    Map* gmMap = m_session->GetPlayer()->GetMap();      bool to_instance =  gmMap->Instanceable();      // we are in instance, and can summon only player in our group with us as lead @@ -2533,29 +2719,35 @@ bool ChatHandler::HandleGroupgoCommand(const char* args)          if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() )              continue; +        // check online security +        if (HasLowerSecurity(pl, 0)) +            return false; + +        std::string plNameLink = playerLink(name); +          if(pl->IsBeingTeleported()==true)          { -            PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); +            PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());              SetSentErrorMessage(true);              return false;          }          if (to_instance)          { -            Map* plMap = MapManager::Instance().GetMap(pl->GetMapId(),pl); +            Map* plMap = pl->GetMap();              if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() )              {                  // cannot summon from instance to instance -                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName()); +                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,plNameLink.c_str());                  SetSentErrorMessage(true);                  return false;              }          } -        PSendSysMessage(LANG_SUMMONING, pl->GetName(),""); +        PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(),"");          if (needReportToTarget(pl)) -            ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, GetName()); +            ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str());          // stop flight if need          if(pl->isInFlight())  | 
