Show
Ignore:
Timestamp:
11/19/08 13:41:09 (17 years ago)
Author:
yumileroy
Message:

[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.

Original author: megamage
Date: 2008-11-03 09:53:31-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/PetHandler.cpp

    r135 r152  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    379379void WorldSession::HandlePetRename( WorldPacket & recv_data ) 
    380380{ 
    381     CHECK_PACKET_SIZE(recv_data,8+1+1+1+1+1+1+1); 
     381    CHECK_PACKET_SIZE(recv_data, 8+1); 
    382382 
    383383    sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME\n" ); 
     
    391391    recv_data >> petguid; 
    392392    recv_data >> name; 
     393    CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); 
    393394    recv_data >> isdeclined; 
    394395 
     
    400401        return; 
    401402 
    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 
    407415    pet->SetName(name); 
    408416 
     
    416424    { 
    417425        for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) 
     426        { 
     427            CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); 
    418428            recv_data >> declinedname.name[i]; 
     429        } 
    419430 
    420431        std::wstring wname; 
    421         Utf8toWStr(name,wname); 
     432        Utf8toWStr(name, wname); 
    422433        if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname)) 
    423434        { 
    424             SendNotification(LANG_PET_INVALID_NAME); 
     435            SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname); 
    425436            return; 
    426437        } 
     
    434445        CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); 
    435446        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()); 
    437448    } 
    438449 
    439450    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()); 
    441452    CharacterDatabase.CommitTransaction(); 
    442453 
     
    446457void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) 
    447458{ 
    448     CHECK_PACKET_SIZE(recv_data,8); 
     459    CHECK_PACKET_SIZE(recv_data, 8); 
    449460 
    450461    uint64 guid; 
     
    453464 
    454465    // pet/charmed 
    455     Creature* pet=ObjectAccessor::GetCreatureOrPet(*_player, guid); 
     466    Creature* pet = ObjectAccessor::GetCreatureOrPet(*_player, guid); 
    456467    if(pet) 
    457468    { 
     
    581592} 
    582593 
    583 void WorldSession::HandleAddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket ) 
     594void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) 
    584595{ 
    585596    sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL"); 
     
    601612    if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm())) 
    602613    { 
    603         sLog.outError( "HandleAddDynamicTargetObsoleteOpcode.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() ); 
    604615        return; 
    605616    } 
     
    656667    } 
    657668} 
     669 
     670void 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}