diff options
| author | megamage <none@none> | 2008-11-03 09:53:31 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2008-11-03 09:53:31 -0600 |
| commit | b9af250881457ba6f7c4ac54ff5f981476c2dec6 (patch) | |
| tree | c20504d42998c9461b8f853cba0b040a1e041016 /src/game/PetHandler.cpp | |
| parent | b3bdc26a110bca8672cfa2a13cd1415199811ad8 (diff) | |
[svn] Fix the compile error. Patch provided by Tidus.
Merge part of mangos svn rev 6748: Use SMSG_PET_NAME_INVALID opcode instead of db string. Source: Mangos.
--HG--
branch : trunk
Diffstat (limited to 'src/game/PetHandler.cpp')
| -rw-r--r-- | src/game/PetHandler.cpp | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index e9f860c7207..c162f22c64b 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Common.h" @@ -378,7 +378,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) void WorldSession::HandlePetRename( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8+1+1+1+1+1+1+1); + CHECK_PACKET_SIZE(recv_data, 8+1); sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME\n" ); @@ -390,6 +390,7 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) recv_data >> petguid; recv_data >> name; + CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> isdeclined; Pet* pet = ObjectAccessor::GetPet(petguid); @@ -399,11 +400,18 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() ) return; - if((!ObjectMgr::IsValidPetName(name)) || (objmgr.IsReservedName(name))) + if(!ObjectMgr::IsValidPetName(name)) { - SendNotification(LANG_PET_INVALID_NAME); + SendPetNameInvalid(PET_NAME_INVALID, name, NULL); return; } + + if(objmgr.IsReservedName(name)) + { + SendPetNameInvalid(PET_NAME_RESERVED, name, NULL); + return; + } + pet->SetName(name); Unit *owner = pet->GetOwner(); @@ -415,13 +423,16 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) if(isdeclined) { for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + { + CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); recv_data >> declinedname.name[i]; + } std::wstring wname; - Utf8toWStr(name,wname); + Utf8toWStr(name, wname); if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname)) { - SendNotification(LANG_PET_INVALID_NAME); + SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname); return; } } @@ -433,11 +444,11 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) CharacterDatabase.escape_string(declinedname.name[i]); CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')", - pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(),declinedname.name[1].c_str(),declinedname.name[2].c_str(),declinedname.name[3].c_str(),declinedname.name[4].c_str()); + pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str()); } CharacterDatabase.escape_string(name); - CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(),_player->GetGUIDLow(),pet->GetCharmInfo()->GetPetNumber() ); + CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); CharacterDatabase.CommitTransaction(); pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); @@ -445,14 +456,14 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); + CHECK_PACKET_SIZE(recv_data, 8); uint64 guid; recv_data >> guid; //pet guid sLog.outDetail( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) ); // pet/charmed - Creature* pet=ObjectAccessor::GetCreatureOrPet(*_player, guid); + Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player, guid); if(pet) { if(pet->isPet()) @@ -580,7 +591,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) } } -void WorldSession::HandleAddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket ) +void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) { sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL"); @@ -600,7 +611,7 @@ void WorldSession::HandleAddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm())) { - sLog.outError( "HandleAddDynamicTargetObsoleteOpcode.Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); + sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); return; } @@ -655,3 +666,19 @@ void WorldSession::HandleAddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket delete spell; } } + +void WorldSession::SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName) +{ + WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1); + data << uint32(error); + data << name; + if(declinedName) + { + data << uint8(1); + for(uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + data << declinedName->name[i]; + } + else + data << uint8(0); + SendPacket(&data); +} |
