Changeset 152 for trunk

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

Location:
trunk/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/bindings/scripts/ScriptMgr.cpp

    r150 r152  
    18391839//*** Functions used internally *** 
    18401840 
    1841 Trinity_DLL_EXPORT 
    1842 const char* ScriptsVersion() 
     1841TRINITY_DLL_EXPORT 
     1842char const* ScriptsVersion() 
    18431843{ 
    18441844        return "Default Trinity scripting library"; 
  • trunk/src/game/Opcodes.cpp

    r102 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 
     
    314314    /*0x11B*/ { "CMSG_UNACCEPT_TRADE",              STATUS_LOGGEDIN, &WorldSession::HandleUnacceptTradeOpcode       }, 
    315315    /*0x11C*/ { "CMSG_CANCEL_TRADE",                STATUS_AUTHED,   &WorldSession::HandleCancelTradeOpcode         }, 
    316                                                             // also send after logout complete 
    317316    /*0x11D*/ { "CMSG_SET_TRADE_ITEM",              STATUS_LOGGEDIN, &WorldSession::HandleSetTradeItemOpcode        }, 
    318317    /*0x11E*/ { "CMSG_CLEAR_TRADE_ITEM",            STATUS_LOGGEDIN, &WorldSession::HandleClearTradeItemOpcode      }, 
     
    526525    /*0x1EE*/ { "SMSG_AUTH_RESPONSE",               STATUS_NEVER,    &WorldSession::Handle_ServerSide               }, 
    527526    /*0x1EF*/ { "MSG_GM_SHOWLABEL",                 STATUS_NEVER,    &WorldSession::Handle_NULL                     }, 
    528     /*0x1F0*/ { "CMSG_PET_CAST_SPELL",              STATUS_LOGGEDIN, &WorldSession::HandleAddDynamicTargetObsoleteOpcode}, 
     527    /*0x1F0*/ { "CMSG_PET_CAST_SPELL",              STATUS_LOGGEDIN, &WorldSession::HandlePetCastSpellOpcode        }, 
    529528    /*0x1F1*/ { "MSG_SAVE_GUILD_EMBLEM",            STATUS_LOGGEDIN, &WorldSession::HandleGuildSaveEmblemOpcode     }, 
    530529    /*0x1F2*/ { "MSG_TABARDVENDOR_ACTIVATE",        STATUS_LOGGEDIN, &WorldSession::HandleTabardVendorActivateOpcode}, 
  • trunk/src/game/Pet.cpp

    r149 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 
     
    189189    if(!IsPositionValid()) 
    190190    { 
    191         sLog.outError("ERROR: Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %d Y: ^%d)", GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY()); 
     191        sLog.outError("ERROR: Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", 
     192            GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY()); 
    192193        delete result; 
    193194        return false; 
     
    206207        return true; 
    207208    } 
    208     if(getPetType()==HUNTER_PET || getPetType()==SUMMON_PET && cinfo->type == CREATURE_TYPE_DEMON && owner->getClass() == CLASS_WARLOCK) 
     209    if(getPetType()==HUNTER_PET || (getPetType()==SUMMON_PET && cinfo->type == CREATURE_TYPE_DEMON && owner->getClass() == CLASS_WARLOCK)) 
    209210        m_charmInfo->SetPetNumber(pet_number, true); 
    210211    else 
     
    12191220        WorldPacket data(SMSG_SPELL_COOLDOWN, (8+1+result->GetRowCount()*8)); 
    12201221        data << GetGUID(); 
    1221         data << uint8(0x0); 
     1222        data << uint8(0x0);                                 // flags (0x1, 0x2) 
    12221223 
    12231224        do 
     
    13671368                remaincharges = -1; 
    13681369 
    1369                         /// do not load single target auras (unless they were cast by the player) 
    1370                         if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) 
    1371                                 continue; 
     1370            /// do not load single target auras (unless they were cast by the player) 
     1371            if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) 
     1372                continue; 
    13721373 
    13731374            Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
     
    14011402 
    14021403        if (i != 3) 
    1403                         continue; 
    1404  
    1405                 if(itr->second->IsPassive()) 
    1406                         continue; 
    1407  
    1408                 /// do not save single target auras (unless they were cast by the player) 
    1409                 if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 
    1410                         continue; 
    1411  
    1412                 CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 
    1413                         "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')", 
    1414                         m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(),(*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); 
     1404            continue; 
     1405         
     1406        if(itr->second->IsPassive()) 
     1407            continue; 
     1408 
     1409        /// do not save single target auras (unless they were cast by the player) 
     1410        if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 
     1411            continue; 
     1412 
     1413        CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 
     1414            "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')", 
     1415            m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(),(*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); 
    14151416    } 
    14161417} 
  • trunk/src/game/Pet.h

    r126 r152  
    9797    PET_TALK_SPECIAL_SPELL  = 0, 
    9898    PET_TALK_ATTACK         = 1 
     99}; 
     100 
     101enum PetNameInvalidReason 
     102{ 
     103    PET_NAME_INVALID                                        = 1, 
     104    PET_NAME_NO_NAME                                        = 2, 
     105    PET_NAME_TOO_SHORT                                      = 3, 
     106    PET_NAME_TOO_LONG                                       = 4, 
     107    PET_NAME_MIXED_LANGUAGES                                = 6, 
     108    PET_NAME_PROFANE                                        = 7, 
     109    PET_NAME_RESERVED                                       = 8, 
     110    PET_NAME_THREE_CONSECUTIVE                              = 11, 
     111    PET_NAME_INVALID_SPACE                                  = 12, 
     112    PET_NAME_CONSECUTIVE_SPACES                             = 13, 
     113    PET_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS          = 14, 
     114    PET_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END   = 15, 
     115    PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME              = 16 
    99116}; 
    100117 
  • 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} 
  • trunk/src/game/WorldSession.h

    r112 r152  
    3131struct ItemPrototype; 
    3232struct AuctionEntry; 
     33struct DeclinedName; 
    3334 
    3435class Creature; 
     
    8384        void SendNotification(const char *format,...) ATTR_PRINTF(2,3); 
    8485        void SendNotification(int32 string_id,...); 
     86        void SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName); 
    8587        void SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type); 
    8688        void SendPartyResult(PartyOperation operation, std::string member, PartyResult res); 
     
    8991        uint32 GetSecurity() const { return _security; } 
    9092        uint32 GetAccountId() const { return _accountId; } 
    91         //std::string const& GetRemoteAddress() const { return m_remoteaddress; } 
    9293        Player* GetPlayer() const { return _player; } 
    9394        char const* GetPlayerName() const; 
     
    117118        void QueuePacket(WorldPacket* new_packet); 
    118119        bool Update(uint32 diff); 
    119          
     120 
    120121        /// Handle the authentication waiting queue (to be completed) 
    121122        void SendAuthWaitQue(uint32 position); 
     
    534535        void HandlePetUnlearnOpcode( WorldPacket& recvPacket ); 
    535536        void HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ); 
    536         void HandleAddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket ); 
     537        void HandlePetCastSpellOpcode( WorldPacket& recvPacket ); 
    537538 
    538539        void HandleSetActionBar(WorldPacket& recv_data);