Changeset 152 for trunk/src/game/PetHandler.cpp
- Timestamp:
- 11/19/08 13:41:09 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/PetHandler.cpp
r135 r152 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 379 379 void WorldSession::HandlePetRename( WorldPacket & recv_data ) 380 380 { 381 CHECK_PACKET_SIZE(recv_data, 8+1+1+1+1+1+1+1);381 CHECK_PACKET_SIZE(recv_data, 8+1); 382 382 383 383 sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME\n" ); … … 391 391 recv_data >> petguid; 392 392 recv_data >> name; 393 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); 393 394 recv_data >> isdeclined; 394 395 … … 400 401 return; 401 402 402 if((!ObjectMgr::IsValidPetName(name)) || (objmgr.IsReservedName(name))) 403 { 404 SendNotification(LANG_PET_INVALID_NAME); 405 return; 406 } 403 if(!ObjectMgr::IsValidPetName(name)) 404 { 405 SendPetNameInvalid(PET_NAME_INVALID, name, NULL); 406 return; 407 } 408 409 if(objmgr.IsReservedName(name)) 410 { 411 SendPetNameInvalid(PET_NAME_RESERVED, name, NULL); 412 return; 413 } 414 407 415 pet->SetName(name); 408 416 … … 416 424 { 417 425 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) 426 { 427 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); 418 428 recv_data >> declinedname.name[i]; 429 } 419 430 420 431 std::wstring wname; 421 Utf8toWStr(name, wname);432 Utf8toWStr(name, wname); 422 433 if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname)) 423 434 { 424 Send Notification(LANG_PET_INVALID_NAME);435 SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname); 425 436 return; 426 437 } … … 434 445 CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); 435 446 CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')", 436 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());447 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()); 437 448 } 438 449 439 450 CharacterDatabase.escape_string(name); 440 CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(),pet->GetCharmInfo()->GetPetNumber());451 CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); 441 452 CharacterDatabase.CommitTransaction(); 442 453 … … 446 457 void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) 447 458 { 448 CHECK_PACKET_SIZE(recv_data, 8);459 CHECK_PACKET_SIZE(recv_data, 8); 449 460 450 461 uint64 guid; … … 453 464 454 465 // pet/charmed 455 Creature* pet =ObjectAccessor::GetCreatureOrPet(*_player, guid);466 Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player, guid); 456 467 if(pet) 457 468 { … … 581 592 } 582 593 583 void WorldSession::Handle AddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket )594 void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) 584 595 { 585 596 sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL"); … … 601 612 if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm())) 602 613 { 603 sLog.outError( "Handle AddDynamicTargetObsoleteOpcode.Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );614 sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); 604 615 return; 605 616 } … … 656 667 } 657 668 } 669 670 void WorldSession::SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName) 671 { 672 WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1); 673 data << uint32(error); 674 data << name; 675 if(declinedName) 676 { 677 data << uint8(1); 678 for(uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) 679 data << declinedName->name[i]; 680 } 681 else 682 data << uint8(0); 683 SendPacket(&data); 684 }