aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2008-11-03 09:53:31 -0600
committermegamage <none@none>2008-11-03 09:53:31 -0600
commitb9af250881457ba6f7c4ac54ff5f981476c2dec6 (patch)
treec20504d42998c9461b8f853cba0b040a1e041016 /src
parentb3bdc26a110bca8672cfa2a13cd1415199811ad8 (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')
-rw-r--r--src/bindings/scripts/ScriptMgr.cpp4
-rw-r--r--src/game/Opcodes.cpp7
-rw-r--r--src/game/Pet.cpp37
-rw-r--r--src/game/Pet.h17
-rw-r--r--src/game/PetHandler.cpp53
-rw-r--r--src/game/WorldSession.h7
6 files changed, 85 insertions, 40 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp
index 1d2a882b30a..76f637527ae 100644
--- a/src/bindings/scripts/ScriptMgr.cpp
+++ b/src/bindings/scripts/ScriptMgr.cpp
@@ -1838,8 +1838,8 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target)
//*********************************
//*** Functions used internally ***
-Trinity_DLL_EXPORT
-const char* ScriptsVersion()
+TRINITY_DLL_EXPORT
+char const* ScriptsVersion()
{
return "Default Trinity scripting library";
}
diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp
index 1220ce7fc7e..98ce54ce111 100644
--- a/src/game/Opcodes.cpp
+++ b/src/game/Opcodes.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
*/
/** \file
@@ -313,7 +313,6 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x11A*/ { "CMSG_ACCEPT_TRADE", STATUS_LOGGEDIN, &WorldSession::HandleAcceptTradeOpcode },
/*0x11B*/ { "CMSG_UNACCEPT_TRADE", STATUS_LOGGEDIN, &WorldSession::HandleUnacceptTradeOpcode },
/*0x11C*/ { "CMSG_CANCEL_TRADE", STATUS_AUTHED, &WorldSession::HandleCancelTradeOpcode },
- // also send after logout complete
/*0x11D*/ { "CMSG_SET_TRADE_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleSetTradeItemOpcode },
/*0x11E*/ { "CMSG_CLEAR_TRADE_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleClearTradeItemOpcode },
/*0x11F*/ { "CMSG_SET_TRADE_GOLD", STATUS_LOGGEDIN, &WorldSession::HandleSetTradeGoldOpcode },
@@ -525,7 +524,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x1ED*/ { "CMSG_AUTH_SESSION", STATUS_NEVER, &WorldSession::Handle_EarlyProccess },
/*0x1EE*/ { "SMSG_AUTH_RESPONSE", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x1EF*/ { "MSG_GM_SHOWLABEL", STATUS_NEVER, &WorldSession::Handle_NULL },
- /*0x1F0*/ { "CMSG_PET_CAST_SPELL", STATUS_LOGGEDIN, &WorldSession::HandleAddDynamicTargetObsoleteOpcode},
+ /*0x1F0*/ { "CMSG_PET_CAST_SPELL", STATUS_LOGGEDIN, &WorldSession::HandlePetCastSpellOpcode },
/*0x1F1*/ { "MSG_SAVE_GUILD_EMBLEM", STATUS_LOGGEDIN, &WorldSession::HandleGuildSaveEmblemOpcode },
/*0x1F2*/ { "MSG_TABARDVENDOR_ACTIVATE", STATUS_LOGGEDIN, &WorldSession::HandleTabardVendorActivateOpcode},
/*0x1F3*/ { "SMSG_PLAY_SPELL_VISUAL", STATUS_NEVER, &WorldSession::Handle_ServerSide },
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 71f34697c7c..d8186da36de 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.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"
@@ -188,7 +188,8 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu
if(!IsPositionValid())
{
- sLog.outError("ERROR: Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %d Y: ^%d)", GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY());
+ sLog.outError("ERROR: Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",
+ GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY());
delete result;
return false;
}
@@ -205,7 +206,7 @@ bool Pet::LoadPetFromDB( Unit* owner, uint32 petentry, uint32 petnumber, bool cu
delete result;
return true;
}
- if(getPetType()==HUNTER_PET || getPetType()==SUMMON_PET && cinfo->type == CREATURE_TYPE_DEMON && owner->getClass() == CLASS_WARLOCK)
+ if(getPetType()==HUNTER_PET || (getPetType()==SUMMON_PET && cinfo->type == CREATURE_TYPE_DEMON && owner->getClass() == CLASS_WARLOCK))
m_charmInfo->SetPetNumber(pet_number, true);
else
m_charmInfo->SetPetNumber(pet_number, false);
@@ -1218,7 +1219,7 @@ void Pet::_LoadSpellCooldowns()
WorldPacket data(SMSG_SPELL_COOLDOWN, (8+1+result->GetRowCount()*8));
data << GetGUID();
- data << uint8(0x0);
+ data << uint8(0x0); // flags (0x1, 0x2)
do
{
@@ -1366,9 +1367,9 @@ void Pet::_LoadAuras(uint32 timediff)
else
remaincharges = -1;
- /// do not load single target auras (unless they were cast by the player)
- if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
- continue;
+ /// do not load single target auras (unless they were cast by the player)
+ if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
+ continue;
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
@@ -1400,18 +1401,18 @@ void Pet::_SaveAuras()
break;
if (i != 3)
- continue;
-
- if(itr->second->IsPassive())
- continue;
+ continue;
+
+ if(itr->second->IsPassive())
+ continue;
- /// do not save single target auras (unless they were cast by the player)
- if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
- continue;
+ /// do not save single target auras (unless they were cast by the player)
+ if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
+ continue;
- CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
- "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')",
- 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));
+ CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
+ "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')",
+ 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));
}
}
diff --git a/src/game/Pet.h b/src/game/Pet.h
index c34f06f2ccc..32a8b9db6ae 100644
--- a/src/game/Pet.h
+++ b/src/game/Pet.h
@@ -98,6 +98,23 @@ enum PetTalk
PET_TALK_ATTACK = 1
};
+enum PetNameInvalidReason
+{
+ PET_NAME_INVALID = 1,
+ PET_NAME_NO_NAME = 2,
+ PET_NAME_TOO_SHORT = 3,
+ PET_NAME_TOO_LONG = 4,
+ PET_NAME_MIXED_LANGUAGES = 6,
+ PET_NAME_PROFANE = 7,
+ PET_NAME_RESERVED = 8,
+ PET_NAME_THREE_CONSECUTIVE = 11,
+ PET_NAME_INVALID_SPACE = 12,
+ PET_NAME_CONSECUTIVE_SPACES = 13,
+ PET_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 14,
+ PET_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 15,
+ PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 16
+};
+
typedef HM_NAMESPACE::hash_map<uint16, PetSpell*> PetSpellMap;
typedef std::map<uint32,uint32> TeachSpellMap;
typedef std::vector<uint32> AutoSpellList;
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);
+}
diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h
index fc3866868cd..4526d4d7b39 100644
--- a/src/game/WorldSession.h
+++ b/src/game/WorldSession.h
@@ -30,6 +30,7 @@
class MailItemsInfo;
struct ItemPrototype;
struct AuctionEntry;
+struct DeclinedName;
class Creature;
class Item;
@@ -82,13 +83,13 @@ class TRINITY_DLL_SPEC WorldSession
void SendPacket(WorldPacket const* packet);
void SendNotification(const char *format,...) ATTR_PRINTF(2,3);
void SendNotification(int32 string_id,...);
+ void SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName);
void SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type);
void SendPartyResult(PartyOperation operation, std::string member, PartyResult res);
void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2,3);
uint32 GetSecurity() const { return _security; }
uint32 GetAccountId() const { return _accountId; }
- //std::string const& GetRemoteAddress() const { return m_remoteaddress; }
Player* GetPlayer() const { return _player; }
char const* GetPlayerName() const;
void SetSecurity(uint32 security) { _security = security; }
@@ -116,7 +117,7 @@ class TRINITY_DLL_SPEC WorldSession
void QueuePacket(WorldPacket* new_packet);
bool Update(uint32 diff);
-
+
/// Handle the authentication waiting queue (to be completed)
void SendAuthWaitQue(uint32 position);
@@ -533,7 +534,7 @@ class TRINITY_DLL_SPEC WorldSession
void HandlePetCancelAuraOpcode( WorldPacket& recvPacket );
void HandlePetUnlearnOpcode( WorldPacket& recvPacket );
void HandlePetSpellAutocastOpcode( WorldPacket& recvPacket );
- void HandleAddDynamicTargetObsoleteOpcode( WorldPacket& recvPacket );
+ void HandlePetCastSpellOpcode( WorldPacket& recvPacket );
void HandleSetActionBar(WorldPacket& recv_data);