diff options
Diffstat (limited to 'src')
38 files changed, 919 insertions, 576 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index f542ff1f145..78d0024c73a 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -1056,7 +1056,7 @@ void BattleGround::Reset() m_Events = 0; if (m_InvitedAlliance > 0 || m_InvitedHorde > 0) - sLog.outError("BattleGround system ERROR: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde); + sLog.outError("BattleGround system: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde); m_InvitedAlliance = 0; m_InvitedHorde = 0; @@ -1484,7 +1484,7 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f if(!pCreature->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not added to battleground. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not added to battleground. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); return NULL; } diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 4e3dd92e3d4..26223b2b0af 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -647,6 +647,11 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) DEBUG_LOG( "WORLD: Sent server info" ); } + data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4); + data << uint32(0); + data << uint32(0); + SendPacket(&data); + //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD); @@ -770,7 +775,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) if(uint32 sourceNode = pCurrChar->m_taxi.GetTaxiSource()) { - sLog.outDebug( "WORLD: Restart character %u taxi flight", pCurrChar->GetGUIDLow() ); uint32 MountId = objmgr.GetTaxiMount(sourceNode, pCurrChar->GetTeam()); @@ -1222,7 +1226,7 @@ void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data ) uint32 slot; recv_data >> slot; - if(slot > MAX_GLYPH_SLOT_INDEX) + if(slot >= MAX_GLYPH_SLOT_INDEX) { sLog.outDebug("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot); return; diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 390cab6150a..026111cbcb0 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -137,6 +137,7 @@ ChatCommand * ChatHandler::getCommandTable() { "arena", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugArenaCommand, "", NULL }, { "bg", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugBattlegroundCommand, "", NULL }, { "sendlargepacket",SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendLargePacketCommand, "", NULL }, + { "setitemflag", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -163,10 +164,10 @@ ChatCommand * ChatHandler::getCommandTable() static ChatCommand goCommandTable[] = { { "grid", SEC_MODERATOR, false, &ChatHandler::HandleGoGridCommand, "", NULL }, - { "creature", SEC_GAMEMASTER, false, &ChatHandler::HandleGoCreatureCommand, "", NULL }, - { "object", SEC_GAMEMASTER, false, &ChatHandler::HandleGoObjectCommand, "", NULL }, - { "trigger", SEC_GAMEMASTER, false, &ChatHandler::HandleGoTriggerCommand, "", NULL }, - { "graveyard", SEC_GAMEMASTER, false, &ChatHandler::HandleGoGraveyardCommand, "", NULL }, + { "creature", SEC_MODERATOR, false, &ChatHandler::HandleGoCreatureCommand, "", NULL }, + { "object", SEC_MODERATOR, false, &ChatHandler::HandleGoObjectCommand, "", NULL }, + { "trigger", SEC_MODERATOR, false, &ChatHandler::HandleGoTriggerCommand, "", NULL }, + { "graveyard", SEC_MODERATOR, false, &ChatHandler::HandleGoGraveyardCommand, "", NULL }, { "zonexy", SEC_MODERATOR, false, &ChatHandler::HandleGoZoneXYCommand, "", NULL }, { "xy", SEC_MODERATOR, false, &ChatHandler::HandleGoXYCommand, "", NULL }, { "xyz", SEC_MODERATOR, false, &ChatHandler::HandleGoXYZCommand, "", NULL }, @@ -214,10 +215,10 @@ ChatCommand * ChatHandler::getCommandTable() static ChatCommand instanceCommandTable[] = { - { "listbinds", SEC_MODERATOR, false, &ChatHandler::HandleInstanceListBindsCommand, "", NULL }, - { "unbind", SEC_MODERATOR, false, &ChatHandler::HandleInstanceUnbindCommand, "", NULL }, - { "stats", SEC_MODERATOR, true, &ChatHandler::HandleInstanceStatsCommand, "", NULL }, - { "savedata", SEC_MODERATOR, false, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL }, + { "listbinds", SEC_ADMINISTRATOR, false, &ChatHandler::HandleInstanceListBindsCommand, "", NULL }, + { "unbind", SEC_ADMINISTRATOR, false, &ChatHandler::HandleInstanceUnbindCommand, "", NULL }, + { "stats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleInstanceStatsCommand, "", NULL }, + { "savedata", SEC_ADMINISTRATOR, false, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -291,13 +292,13 @@ ChatCommand * ChatHandler::getCommandTable() { "titles", SEC_MODERATOR, false, &ChatHandler::HandleModifyKnownTitlesCommand, "", NULL }, { "mount", SEC_MODERATOR, false, &ChatHandler::HandleModifyMountCommand, "", NULL }, { "honor", SEC_MODERATOR, false, &ChatHandler::HandleModifyHonorCommand, "", NULL }, - { "rep", SEC_MODERATOR, false, &ChatHandler::HandleModifyRepCommand, "", NULL }, + { "rep", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyRepCommand, "", NULL }, { "arena", SEC_MODERATOR, false, &ChatHandler::HandleModifyArenaCommand, "", NULL }, { "drunk", SEC_MODERATOR, false, &ChatHandler::HandleModifyDrunkCommand, "", NULL }, { "standstate", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyStandStateCommand, "", NULL }, { "morph", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyMorphCommand, "", NULL }, - { "phase", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyPhaseCommand, "", NULL }, - { "gender", SEC_ADMINISTRATOR, false, &ChatHandler::HandleModifyGenderCommand, "", NULL }, + { "phase", SEC_ADMINISTRATOR, false, &ChatHandler::HandleModifyPhaseCommand, "", NULL }, + { "gender", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyGenderCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -306,9 +307,11 @@ ChatCommand * ChatHandler::getCommandTable() { "add", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddCommand, "", NULL }, { "additem", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddVendorItemCommand, "", NULL }, { "addmove", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddMoveCommand, "", NULL }, + { "allowmove", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcAllowMovementCommand, "", NULL }, { "changeentry", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcChangeEntryCommand, "", NULL }, { "changelevel", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcChangeLevelCommand, "", NULL }, { "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcDeleteCommand, "", NULL }, + { "delitem", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcDelVendorItemCommand, "", NULL }, { "factionid", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFactionIdCommand, "", NULL }, { "flag", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFlagCommand, "", NULL }, { "follow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFollowCommand, "", NULL }, @@ -364,6 +367,7 @@ ChatCommand * ChatHandler::getCommandTable() static ChatCommand reloadCommandTable[] = { { "all", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllCommand, "", NULL }, + { "all_area", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllAreaCommand, "", NULL }, { "all_loot", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllLootCommand, "", NULL }, { "all_npc", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllNpcCommand, "", NULL }, { "all_quest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllQuestCommand, "", NULL }, @@ -615,7 +619,6 @@ ChatCommand * ChatHandler::getCommandTable() { "plimit", SEC_ADMINISTRATOR, true, &ChatHandler::HandlePLimitCommand, "", NULL }, { "start", SEC_PLAYER, false, &ChatHandler::HandleStartCommand, "", NULL }, { "taxicheat", SEC_MODERATOR, false, &ChatHandler::HandleTaxiCheatCommand, "", NULL }, - { "allowmove", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAllowMovementCommand, "", NULL }, { "linkgrave", SEC_ADMINISTRATOR, false, &ChatHandler::HandleLinkGraveCommand, "", NULL }, { "neargrave", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNearGraveCommand, "", NULL }, { "explorecheat", SEC_ADMINISTRATOR, false, &ChatHandler::HandleExploreCheatCommand, "", NULL }, @@ -641,8 +644,8 @@ ChatCommand * ChatHandler::getCommandTable() { "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleRenameCommand, "", NULL }, { "customize", SEC_GAMEMASTER, true, &ChatHandler::HandleCustomizeCommand, "", NULL }, { "loadscripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLoadScriptsCommand, "", NULL }, - { "mute", SEC_GAMEMASTER, true, &ChatHandler::HandleMuteCommand, "", NULL }, - { "unmute", SEC_GAMEMASTER, true, &ChatHandler::HandleUnmuteCommand, "", NULL }, + { "mute", SEC_MODERATOR, true, &ChatHandler::HandleMuteCommand, "", NULL }, + { "unmute", SEC_MODERATOR, true, &ChatHandler::HandleUnmuteCommand, "", NULL }, { "movegens", SEC_ADMINISTRATOR, false, &ChatHandler::HandleMovegensCommand, "", NULL }, { "cometome", SEC_ADMINISTRATOR, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, { "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL }, @@ -675,28 +678,9 @@ ChatCommand * ChatHandler::getCommandTable() { Field *fields = result->Fetch(); std::string name = fields[0].GetCppString(); - for(uint32 i = 0; commandTable[i].Name != NULL; i++) - { - if (name == commandTable[i].Name) - { - commandTable[i].SecurityLevel = (uint16)fields[1].GetUInt16(); - commandTable[i].Help = fields[2].GetCppString(); - } - if(commandTable[i].ChildCommands != NULL) - { - ChatCommand *ptable = commandTable[i].ChildCommands; - for(uint32 j = 0; ptable[j].Name != NULL; j++) - { - // first case for "" named subcommand - if (ptable[j].Name[0]=='\0' && name == commandTable[i].Name || - name == fmtstring("%s %s", commandTable[i].Name, ptable[j].Name) ) - { - ptable[j].SecurityLevel = (uint16)fields[1].GetUInt16(); - ptable[j].Help = fields[2].GetCppString(); - } - } - } - } + + SetDataForCommandInTable(commandTable, name.c_str(), fields[1].GetUInt16(), fields[2].GetCppString(), name); + } while(result->NextRow()); delete result; } @@ -937,6 +921,61 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co return false; } +bool ChatHandler::SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand ) +{ + std::string cmd = ""; + + while (*text != ' ' && *text != '\0') + { + cmd += *text; + ++text; + } + + while (*text == ' ') ++text; + + for(uint32 i = 0; table[i].Name != NULL; i++) + { + // for data fill use full explicit command names + if( table[i].Name != cmd ) + continue; + + // select subcommand from child commands list (including "") + if(table[i].ChildCommands != NULL) + { + if(SetDataForCommandInTable(table[i].ChildCommands, text, security, help, fullcommand)) + return true; + else if(*text) + return false; + + // fail with "" subcommands, then use normal level up command instead + } + // expected subcommand by full name DB content + else if(*text) + { + sLog.outErrorDb("Table `command` have unexpected subcommand '%s' in command '%s', skip.",text,fullcommand.c_str()); + return false; + } + + if(table[i].SecurityLevel != security) + sLog.outDetail("Table `command` overwrite for command '%s' default security (%u) by %u",fullcommand.c_str(),table[i].SecurityLevel,security); + + table[i].SecurityLevel = security; + table[i].Help = help; + return true; + } + + // in case "" command let process by caller + if(!cmd.empty()) + { + if(table==getCommandTable()) + sLog.outErrorDb("Table `command` have not existed command '%s', skip.",cmd.c_str()); + else + sLog.outErrorDb("Table `command` have not existed subcommand '%s' in command '%s', skip.",cmd.c_str(),fullcommand.c_str()); + } + + return false; +} + int ChatHandler::ParseCommands(const char* text) { ASSERT(text); @@ -1392,7 +1431,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text) return 0; int32 rank = param1_str ? (uint32)atol(param1_str) : 0; - if(rank >= 5) + if(rank >= MAX_TALENT_RANK) return 0; if(rank < 0) diff --git a/src/game/Chat.h b/src/game/Chat.h index 7d799849b8e..ee95f78a396 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -85,6 +85,7 @@ class ChatHandler void SendGlobalSysMessage(const char *str); void SendGlobalGMSysMessage(const char *str); + bool SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand ); bool ExecuteCommandInTable(ChatCommand *table, const char* text, const std::string& fullcommand); bool ShowHelpForCommand(ChatCommand *table, const char* cmd); bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd); @@ -368,7 +369,7 @@ class ChatHandler bool HandleGoXYZCommand(const char* args); bool HandleGoZoneXYCommand(const char* args); bool HandleGoGridCommand(const char* args); - bool HandleAllowMovementCommand(const char* args); + bool HandleNpcAllowMovementCommand(const char* args); bool HandleGoCommand(const char* args); bool HandleCooldownCommand(const char* args); @@ -511,6 +512,7 @@ class ChatHandler bool HandleDebugSpawnVehicle(const char * args); bool HandleDebugSendLargePacketCommand(const char * args); bool HandleDebugSendSetPhaseShiftCommand(const char * args); + bool HandleDebugSetItemFlagCommand(const char * args); Player* getSelectedPlayer(); Creature* getSelectedCreature(); diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 43025958224..d427d1e5943 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -78,7 +78,7 @@ bool Corpse::Create( uint32 guidlow, Player *owner) if(!IsPositionValid()) { - sLog.outError("ERROR: Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", + sLog.outError("Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow,owner->GetName(),owner->GetPositionX(), owner->GetPositionY()); return false; } @@ -155,7 +155,7 @@ bool Corpse::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId) if( ! result ) { - sLog.outError("ERROR: Corpse (GUID: %u) not found in table `corpse`, can't load. ",guid); + sLog.outError("Corpse (GUID: %u) not found in table `corpse`, can't load. ",guid); return false; } @@ -183,7 +183,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) if(!LoadValues( fields[5].GetString() )) { - sLog.outError("ERROR: Corpse #%d have broken data in `data` field. Can't be loaded.",guid); + sLog.outError("Corpse #%d have broken data in `data` field. Can't be loaded.",guid); return false; } @@ -191,7 +191,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) m_type = CorpseType(fields[7].GetUInt32()); if(m_type >= MAX_CORPSE_TYPE) { - sLog.outError("ERROR: Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID())); + sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID())); return false; } uint32 instanceid = fields[8].GetUInt32(); @@ -208,7 +208,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) if(!IsPositionValid()) { - sLog.outError("ERROR: Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", + sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUIDLow(),GUID_LOPART(GetOwnerGUID()),GetPositionX(),GetPositionY()); return false; } diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 34ca8bb31e0..db502d2cc25 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1352,7 +1352,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry); if(!cinfo) { - sLog.outErrorDb("Error: creature entry %u does not exist.", Entry); + sLog.outErrorDb("Creature entry %u does not exist.", Entry); return false; } m_originalEntry = Entry; @@ -1395,7 +1395,7 @@ bool Creature::LoadFromDB(uint32 guid, Map *map) if(!IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",GetGUIDLow(),GetEntry(),GetPositionX(),GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",GetGUIDLow(),GetEntry(),GetPositionX(),GetPositionY()); return false; } //We should set first home position, because then AI calls home movement diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp index 4df0767e20e..73aff0dbb09 100644 --- a/src/game/Debugcmds.cpp +++ b/src/game/Debugcmds.cpp @@ -637,7 +637,7 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args) if(!v->IsPositionValid()) { - sLog.outError("ERROR: Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", + sLog.outError("Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", v->GetGUIDLow(), v->GetEntry(), v->GetPositionX(), v->GetPositionY()); delete v; return false; @@ -667,3 +667,27 @@ bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args) m_session->SendSetPhaseShift(PhaseShift); return true; } + +bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args) +{ + if(!args) + return false; + + char* e = strtok((char*)args, " "); + char* f = strtok(NULL, " "); + + if (!e || !f) + return false; + + uint32 guid = (uint32)atoi(e); + uint32 flag = (uint32)atoi(f); + + Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + + if(!i) + return false; + + i->SetUInt32Value(ITEM_FIELD_FLAGS, flag); + + return true; +} diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 4667b7c91a5..9a7a9aa9832 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -61,7 +61,7 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 if(!IsPositionValid()) { - sLog.outError("ERROR: DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY()); + sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY()); return false; } diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index f17533f04cb..bfd3b3ae1db 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -101,7 +101,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa if(!IsPositionValid()) { - sLog.outError("ERROR: Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y); + sLog.outError("Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y); return false; } @@ -568,7 +568,7 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map) if( !data ) { - sLog.outErrorDb("ERROR: Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid); + sLog.outErrorDb("Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid); return false; } diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 8454604a786..26f49097b65 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -350,7 +350,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result) if (!result) { - sLog.outError("ERROR: Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid)); + sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ",guid,GUID_LOPART(owner_guid)); return false; } @@ -358,7 +358,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result) if(!LoadValues(fields[0].GetString())) { - sLog.outError("ERROR: Item #%d have broken data in `data` field. Can't be loaded.",guid); + sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid); if (delete_result) delete result; return false; } diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index b8150b48c52..caf878da7e1 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -107,6 +107,7 @@ enum ITEM_FLAGS ITEM_FLAGS_CONJURED = 0x00000002, ITEM_FLAGS_OPENABLE = 0x00000004, ITEM_FLAGS_WRAPPED = 0x00000008, + ITEM_FLAGS_BROKEN = 0x00000010, // appears red icon (like when item durability==0) ITEM_FLAGS_WRAPPER = 0x00000200, // used or not used wrapper ITEM_FLAGS_PARTY_LOOT = 0x00000800, // determines if item is party loot or not ITEM_FLAGS_CHARTER = 0x00002000, // arena/guild charter diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index ba7092ec72f..a9c27a719e3 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1104,7 +1104,7 @@ bool ChatHandler::HandleNpcAddCommand(const char* args) if(!pCreature->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); delete pCreature; return false; } @@ -3146,7 +3146,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args) if(!wpCreature2->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature2->GetGUIDLow(),wpCreature2->GetEntry(),wpCreature2->GetPositionX(),wpCreature2->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature2->GetGUIDLow(),wpCreature2->GetEntry(),wpCreature2->GetPositionX(),wpCreature2->GetPositionY()); delete wpCreature2; return false; } @@ -3378,7 +3378,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) if(!wpCreature->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY()); delete wpCreature; delete result; return false; @@ -3442,7 +3442,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) if(!pCreature->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); delete pCreature; delete result; return false; @@ -3507,7 +3507,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) if(!pCreature->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); delete pCreature; delete result; return false; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index bd2fadcb0ee..13ea1a33ff3 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1415,21 +1415,6 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args) return true; } -bool ChatHandler::HandleAllowMovementCommand(const char* /*args*/) -{ - if(sWorld.getAllowMovement()) - { - sWorld.SetAllowMovement(false); - SendSysMessage(LANG_CREATURE_MOVE_DISABLED); - } - else - { - sWorld.SetAllowMovement(true); - SendSysMessage(LANG_CREATURE_MOVE_ENABLED); - } - return true; -} - bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) { Player* SelectedPlayer = getSelectedPlayer(); @@ -2314,8 +2299,8 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) // search highest talent rank uint32 spellid = 0; - int rank = 4; - for(; rank >= 0; --rank) + + for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) { if(talentInfo->RankID[rank]!=0) { @@ -4124,6 +4109,21 @@ bool ChatHandler::HandleNearGraveCommand(const char* args) } //-----------------------Npc Commands----------------------- +bool ChatHandler::HandleNpcAllowMovementCommand(const char* /*args*/) +{ + if(sWorld.getAllowMovement()) + { + sWorld.SetAllowMovement(false); + SendSysMessage(LANG_CREATURE_MOVE_DISABLED); + } + else + { + sWorld.SetAllowMovement(true); + SendSysMessage(LANG_CREATURE_MOVE_ENABLED); + } + return true; +} + bool ChatHandler::HandleNpcChangeEntryCommand(const char *args) { if(!args) diff --git a/src/game/Makefile.am b/src/game/Makefile.am index 8482a8874ce..a760cdd1eeb 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -30,6 +30,7 @@ noinst_LIBRARIES = libmangosgame.a # libmangossgame library will later be reused by ... libmangosgame_a_SOURCES = \ +<<<<<<< HEAD:src/game/Makefile.am AccountMgr.cpp \ AccountMgr.h \ AchievementMgr.h \ @@ -309,6 +310,261 @@ libmangosgame_a_SOURCES = \ GroupReference.cpp \ GroupReference.h \ GroupRefManager.h +======= + AccountMgr.cpp \ + AccountMgr.h \ + AchievementMgr.h \ + AchievementMgr.cpp \ + AggressorAI.cpp \ + AggressorAI.h \ + AnimalRandomMovementGenerator.h \ + ArenaTeam.cpp \ + ArenaTeam.h \ + ArenaTeamHandler.cpp \ + AuctionHouseHandler.cpp \ + AuctionHouseMgr.cpp \ + AuctionHouseMgr.h \ + Bag.cpp \ + Bag.h \ + BattleGround.cpp \ + BattleGroundAA.cpp \ + BattleGroundAB.cpp \ + BattleGroundAV.cpp \ + BattleGroundBE.cpp \ + BattleGroundDS.cpp \ + BattleGroundEY.cpp \ + BattleGroundNA.cpp \ + BattleGroundRL.cpp \ + BattleGroundRV.cpp \ + BattleGroundSA.cpp \ + BattleGroundWS.cpp \ + BattleGround.h \ + BattleGroundAA.h \ + BattleGroundAB.h \ + BattleGroundAV.h \ + BattleGroundBE.h \ + BattleGroundDS.h \ + BattleGroundEY.h \ + BattleGroundNA.h \ + BattleGroundRL.h \ + BattleGroundRV.h \ + BattleGroundSA.h \ + BattleGroundWS.h \ + BattleGroundHandler.cpp \ + BattleGroundMgr.cpp \ + BattleGroundMgr.h \ + Calendar.cpp \ + Calendar.h \ + CalendarHandler.cpp \ + Cell.h \ + CellImpl.h \ + Channel.cpp \ + Channel.h \ + ChannelHandler.cpp \ + ChannelMgr.h \ + CharacterHandler.cpp \ + Chat.cpp \ + Chat.h \ + ChatHandler.cpp \ + CombatHandler.cpp \ + ConfusedMovementGenerator.cpp \ + ConfusedMovementGenerator.h \ + Corpse.cpp \ + Corpse.h \ + CreatureAI.cpp \ + CreatureAI.h \ + CreatureAIImpl.h \ + CreatureAIRegistry.cpp \ + CreatureAIRegistry.h \ + CreatureAISelector.cpp \ + CreatureAISelector.h \ + Creature.cpp \ + Creature.h \ + debugcmds.cpp \ + DestinationHolder.cpp \ + DestinationHolder.h \ + DestinationHolderImp.h \ + DuelHandler.cpp \ + DynamicObject.cpp \ + DynamicObject.h \ + FleeingMovementGenerator.cpp \ + FleeingMovementGenerator.h \ + Formulas.h \ + GameEventMgr.cpp \ + GameEventMgr.h \ + GameObject.cpp \ + GameObject.h \ + GlobalEvents.cpp \ + GlobalEvents.h \ + GMTicketHandler.cpp \ + GMTicketMgr.cpp \ + GMTicketMgr.h \ + GossipDef.cpp \ + GossipDef.h \ + GridDefines.h \ + GridNotifiers.cpp \ + GridNotifiers.h \ + GridNotifiersImpl.h \ + GridStates.cpp \ + GridStates.h \ + Group.cpp \ + Group.h \ + GroupHandler.cpp \ + GuardAI.cpp \ + GuardAI.h \ + Guild.cpp \ + Guild.h \ + GuildHandler.cpp \ + HomeMovementGenerator.cpp \ + HomeMovementGenerator.h \ + HostilRefManager.cpp \ + HostilRefManager.h \ + IdleMovementGenerator.cpp \ + IdleMovementGenerator.h \ + InstanceData.cpp \ + InstanceData.h \ + InstanceSaveMgr.cpp \ + InstanceSaveMgr.h \ + Item.cpp \ + Item.h \ + ItemEnchantmentMgr.cpp \ + ItemEnchantmentMgr.h \ + ItemHandler.cpp \ + ItemPrototype.h \ + Language.h \ + Level0.cpp \ + Level1.cpp \ + Level2.cpp \ + Level3.cpp \ + LFGHandler.cpp \ + LootHandler.cpp \ + LootMgr.cpp \ + LootMgr.h \ + Mail.cpp \ + Mail.h \ + Map.cpp \ + Map.h \ + MapInstanced.cpp \ + MapInstanced.h \ + MapManager.cpp \ + MapManager.h \ + MapReference.h \ + MapRefManager.h \ + MiscHandler.cpp \ + MotionMaster.cpp \ + MotionMaster.h \ + MovementGenerator.cpp \ + MovementGenerator.h \ + MovementGeneratorImpl.h \ + MovementHandler.cpp \ + NPCHandler.cpp \ + NPCHandler.h \ + NullCreatureAI.cpp \ + NullCreatureAI.h \ + ObjectAccessor.cpp \ + ObjectAccessor.h \ + Object.cpp \ + ObjectDefines.h \ + ObjectGridLoader.cpp \ + ObjectGridLoader.h \ + Object.h \ + ObjectMgr.cpp \ + ObjectMgr.h \ + ObjectPosSelector.cpp \ + ObjectPosSelector.h \ + Opcodes.cpp \ + Opcodes.h \ + Path.h \ + PetAI.cpp \ + PetAI.h \ + Pet.cpp \ + Pet.h \ + PetHandler.cpp \ + PetitionsHandler.cpp \ + Player.cpp \ + Player.h \ + PlayerDump.cpp \ + PlayerDump.h \ + PointMovementGenerator.cpp \ + PointMovementGenerator.h \ + PoolHandler.cpp \ + PoolHandler.h \ + QueryHandler.cpp \ + QuestDef.cpp \ + QuestDef.h \ + QuestHandler.cpp \ + RandomMovementGenerator.cpp \ + RandomMovementGenerator.h \ + ReactorAI.cpp \ + ReactorAI.h \ + ScriptCalls.cpp \ + ScriptCalls.h \ + SharedDefines.h \ + SkillHandler.cpp \ + SpellAuraDefines.h \ + SpellAuras.cpp \ + SpellAuras.h \ + Spell.cpp \ + SpellEffects.cpp \ + Spell.h \ + SkillDiscovery.cpp \ + SkillDiscovery.h \ + SkillExtraItems.cpp \ + SkillExtraItems.h \ + SpellHandler.cpp \ + SocialMgr.cpp \ + SocialMgr.h \ + SpellMgr.cpp \ + SpellMgr.h \ + StatSystem.cpp \ + TargetedMovementGenerator.cpp \ + TargetedMovementGenerator.h \ + TaxiHandler.cpp \ + TemporarySummon.cpp \ + TemporarySummon.h \ + TotemAI.cpp \ + TotemAI.h \ + Totem.cpp \ + Totem.h \ + TradeHandler.cpp \ + Transports.cpp \ + Transports.h \ + ThreatManager.cpp \ + ThreatManager.h \ + Traveller.h \ + Unit.cpp \ + Unit.h \ + UnitEvents.h \ + UpdateData.cpp \ + UpdateData.h \ + UpdateFields.h \ + UpdateMask.h \ + Vehicle.cpp \ + Vehicle.h \ + VoiceChatHandler.cpp \ + WaypointManager.cpp \ + WaypointManager.h \ + WaypointMovementGenerator.cpp \ + WaypointMovementGenerator.h \ + Weather.cpp \ + Weather.h \ + World.cpp \ + World.h \ + WorldLog.cpp \ + WorldLog.h \ + WorldSession.cpp \ + WorldSession.h \ + WorldSocket.cpp \ + WorldSocket.h \ + WorldSocketMgr.cpp \ + WorldSocketMgr.h \ + FollowerReference.cpp \ + FollowerReference.h \ + FollowerRefManager.h \ + GroupReference.cpp \ + GroupReference.h \ + GroupRefManager.h +>>>>>>> 2429aaf2276d689e101ed88285f18449dbe4280d:src/game/Makefile.am ## Link against shared library libmangosgame_a_LIBADD = ../shared/libmangosshared.a ../shared/Auth/libmangosauth.a ../shared/Config/libmangosconfig.a ../shared/Database/libmangosdatabase.a ../shared/vmap/libmangosvmaps.a diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 81a2422d85f..d53fc81cffc 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1850,7 +1850,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const Cell xy_cell(xy_val); if(xy_cell != cur_cell) { - sLog.outDebug("ERROR: %s (GUID: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]", + sLog.outDebug("%s (GUID: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]", (c->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature"),c->GetGUIDLow(), c->GetPositionX(),c->GetPositionY(),(moved ? "final" : "original"), cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(), @@ -2031,7 +2031,7 @@ void Map::RemoveAllObjectsInRemoveList() { Corpse* corpse = ObjectAccessor::Instance().GetCorpse(*obj, obj->GetGUID()); if (!corpse) - sLog.outError("ERROR: Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); + sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); else Remove(corpse,true); break; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 446a7331615..7dc3154bec7 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -878,7 +878,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) if(decompressedSize == 0) // erase { - SetAccountData(type, timestamp, ""); + SetAccountData(type, 0, ""); WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); data << uint32(type); @@ -978,7 +978,7 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) } else if(type==ACTION_BUTTON_SPELL) { - sLog.outDetail( "MISC: Added Action %u into button %u", action, button ); + sLog.outDetail( "MISC: Added Spell %u into button %u", action, button ); GetPlayer()->addActionButton(button,action,type,misc); } else if(type==ACTION_BUTTON_ITEM) @@ -1198,7 +1198,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) // find talent rank uint32 curtalent_maxrank = 0; - for(uint32 k = 5; k > 0; --k) + for(uint32 k = MAX_TALENT_RANK; k > 0; --k) { if(talentInfo->RankID[k-1] && plr->HasSpell(talentInfo->RankID[k-1])) { diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 63ad7de7c75..b6069fe1ae1 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1077,7 +1077,7 @@ void Object::RemoveByteFlag( uint16 index, uint8 offset, uint8 oldFlag ) bool Object::PrintIndexError(uint32 index, bool set) const { - sLog.outError("ERROR: Attempt %s non-existed value field: %u (count: %u) for object typeid: %u type mask: %u",(set ? "set value to" : "get value from"),index,m_valuesCount,GetTypeId(),m_objectType); + sLog.outError("Attempt %s non-existed value field: %u (count: %u) for object typeid: %u type mask: %u",(set ? "set value to" : "get value from"),index,m_valuesCount,GetTypeId(),m_objectType); // assert must fail after function call return false; @@ -1620,7 +1620,7 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a summon->Relocate(x, y, z, angle); if(!summon->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",summon->GetGUIDLow(),summon->GetEntry(),summon->GetPositionX(),summon->GetPositionY()); + sLog.outError("Creature (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",summon->GetGUIDLow(),summon->GetEntry(),summon->GetPositionX(),summon->GetPositionY()); delete summon; return NULL; } diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index cc4231fa14a..c245b09f410 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -406,7 +406,7 @@ ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia) { //in fact this function is called from several places //even when player doesn't have a corpse, not an error - //sLog.outError("ERROR: Try remove corpse that not in map for GUID %ul", player_guid); + //sLog.outError("Try remove corpse that not in map for GUID %ul", player_guid); return NULL; } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index c21a0e0eb35..02f09991650 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -146,7 +146,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool if(!IsPositionValid()) { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", + sLog.outError("Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY()); delete result; return false; @@ -709,7 +709,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) { if(!creature) { - sLog.outError("CRITICAL ERROR: NULL pointer parsed into CreateBaseAtCreature()"); + sLog.outError("CRITICAL: NULL pointer parsed into CreateBaseAtCreature()"); return false; } uint32 guid=objmgr.GenerateLowGuid(HIGHGUID_PET); @@ -726,7 +726,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if(!IsPositionValid()) { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", + sLog.outError("Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY()); return false; } @@ -734,7 +734,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) CreatureInfo const *cinfo = GetCreatureInfo(); if(!cinfo) { - sLog.outError("ERROR: CreateBaseAtCreature() failed, creatureInfo is missing!"); + sLog.outError("CreateBaseAtCreature() failed, creatureInfo is missing!"); return false; } @@ -771,7 +771,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel) Unit* owner = GetOwner(); if(!owner) { - sLog.outError("ERROR: attempt to summon pet (Entry %u) without owner! Attempt terminated.", cinfo->Entry); + sLog.outError("attempt to summon pet (Entry %u) without owner! Attempt terminated.", cinfo->Entry); return false; } @@ -1267,7 +1267,7 @@ bool Pet::addSpell(uint32 spell_id, uint16 active, PetSpellState state, PetSpell { if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) { - for(int i=0; i <5; ++i) + for(int i=0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; @@ -1544,7 +1544,7 @@ bool Pet::resetTalents(bool no_cost) if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) continue; - for (int j = 0; j < 5; j++) + for (int j = 0; j < MAX_TALENT_RANK; j++) { for(PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end();) { diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index ed07f169e69..088f0ff2c58 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -693,7 +693,6 @@ void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, Dec void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data ) { sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT"); - recv_data.hexlike(); CHECK_PACKET_SIZE(recv_data, 8+4+4); @@ -701,117 +700,5 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data ) uint32 talent_id, requested_rank; recv_data >> guid >> talent_id >> requested_rank; - Pet *pet = _player->GetPet(); - - if(!pet) - return; - - if(guid != pet->GetGUID()) - return; - - uint32 CurTalentPoints = pet->GetFreeTalentPoints(); - - if(CurTalentPoints == 0) - return; - - if (requested_rank > 4) - return; - - TalentEntry const *talentInfo = sTalentStore.LookupEntry(talent_id); - - if(!talentInfo) - return; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - - if(!talentTabInfo) - return; - - CreatureInfo const *ci = pet->GetCreatureInfo(); - - if(!ci) - return; - - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - - if(!pet_family) - return; - - if(pet_family->petTalentType < 0) // not hunter pet - return; - - // prevent learn talent for different family (cheating) - if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) - return; - - // prevent skip talent ranks (cheating) - if(requested_rank > 0 && !pet->HasSpell(talentInfo->RankID[requested_rank-1])) - return; - - // Check if it requires another talent - if (talentInfo->DependsOn > 0) - { - if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) - { - bool hasEnoughRank = false; - for (int i = talentInfo->DependsOnRank; i <= 4; i++) - { - if (depTalentInfo->RankID[i] != 0) - if (pet->HasSpell(depTalentInfo->RankID[i])) - hasEnoughRank = true; - } - if (!hasEnoughRank) - return; - } - } - - // Find out how many points we have in this field - uint32 spentPoints = 0; - - uint32 tTab = talentInfo->TalentTab; - if (talentInfo->Row > 0) - { - unsigned int numRows = sTalentStore.GetNumRows(); - for (unsigned int i = 0; i < numRows; i++) // Loop through all talents. - { - // Someday, someone needs to revamp - const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i); - if (tmpTalent) // the way talents are tracked - { - if (tmpTalent->TalentTab == tTab) - { - for (int j = 0; j <= 4; j++) - { - if (tmpTalent->RankID[j] != 0) - { - if (pet->HasSpell(tmpTalent->RankID[j])) - { - spentPoints += j + 1; - } - } - } - } - } - } - } - - // not have required min points spent in talent tree - if(spentPoints < (talentInfo->Row * 3)) - return; - - // spell not set in talent.dbc - uint32 spellid = talentInfo->RankID[requested_rank]; - if( spellid == 0 ) - { - sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talent_id, requested_rank); - return; - } - - // already known - if(pet->HasSpell(spellid)) - return; - - // learn! (other talent ranks will unlearned at learning) - pet->learnSpell(spellid); - sLog.outDetail("TalentID: %u Rank: %u Spell: %u", talent_id, requested_rank, spellid); + _player->LearnPetTalent(guid, talent_id, requested_rank); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2d41400c80f..35317d9ded8 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2818,7 +2818,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen { if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) { - for(int i=0; i <5; ++i) + for(int i=0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; @@ -3277,7 +3277,7 @@ void Player::RemoveArenaSpellCooldowns() // notify player WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); data << uint32(itr->first); - data << GetGUID(); + data << uint64(GetGUID()); GetSession()->SendPacket(&data); // remove cooldown m_spellCooldowns.erase(itr); @@ -3440,7 +3440,7 @@ bool Player::resetTalents(bool no_cost) if( (getClassMask() & talentTabInfo->ClassMask) == 0 ) continue; - for (int j = 0; j < 5; j++) + for (int j = 0; j < MAX_TALENT_RANK; j++) { for(PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();) { @@ -4316,7 +4316,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); if(!dcost) { - sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", ditemProto->ItemLevel); + sLog.outError("RepairDurability: Wrong item lvl %u", ditemProto->ItemLevel); return TotalCost; } @@ -4324,7 +4324,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); if(!dQualitymodEntry) { - sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntryId); + sLog.outError("RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntryId); return TotalCost; } @@ -4567,7 +4567,7 @@ float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const { if(modGroup >= BASEMOD_END || modType > MOD_END) { - sLog.outError("ERROR: trial to access non existed BaseModGroup or wrong BaseModType!"); + sLog.outError("trial to access non existed BaseModGroup or wrong BaseModType!"); return 0.0f; } @@ -4581,7 +4581,7 @@ float Player::GetTotalBaseModValue(BaseModGroup modGroup) const { if(modGroup >= BASEMOD_END) { - sLog.outError("ERROR: wrong BaseModGroup in GetTotalBaseModValue()!"); + sLog.outError("wrong BaseModGroup in GetTotalBaseModValue()!"); return 0.0f; } @@ -5592,7 +5592,7 @@ void Player::CheckExploreSystem() if(offset >= 128) { - sLog.outError("ERROR: Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < 128 ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset); + sLog.outError("Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < 128 ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset); return; } @@ -6111,12 +6111,9 @@ bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 sta //Calculate total reputation percent player gain with quest/creature level int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest) { - // always 100% (3.0.8) - int32 percent = 100; - int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN); - percent += rep > 0 ? repMod : -repMod; + int32 percent = rep > 0 ? repMod : -repMod; if(percent <=0) return 0; @@ -8628,10 +8625,10 @@ uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap slots[0] = EQUIPMENT_SLOT_RANGED; break; case INVTYPE_BAG: - slots[0] = INVENTORY_SLOT_BAG_1; - slots[1] = INVENTORY_SLOT_BAG_2; - slots[2] = INVENTORY_SLOT_BAG_3; - slots[3] = INVENTORY_SLOT_BAG_4; + slots[0] = INVENTORY_SLOT_BAG_START + 0; + slots[1] = INVENTORY_SLOT_BAG_START + 1; + slots[2] = INVENTORY_SLOT_BAG_START + 2; + slots[3] = INVENTORY_SLOT_BAG_START + 3; break; case INVTYPE_RELIC: { @@ -9295,8 +9292,8 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(false /*pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS*/)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - // guestbag case (disabled until proper implement) - if(slot >= QUESTBAG_SLOT_START && slot < QUESTBAG_SLOT_END && !(false /*pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS*/)) + // guestbag case (not use) + if(slot >= QUESTBAG_SLOT_START && slot < QUESTBAG_SLOT_END) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; // prevent cheating @@ -9632,8 +9629,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3 } } - // Vanity pet case skipped as not used - /* until proper implementation else if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { @@ -9656,28 +9651,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3 } } */ - /* until proper implementation - else if(pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS) - { - res = _CanStoreItem_InInventorySlots(QUESTBAG_SLOT_START,QUESTBAG_SLOT_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - */ res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); if(res!=EQUIP_ERR_OK) @@ -9826,8 +9799,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3 } } - // Vanity pet case skipped as not used - /* until proper implementation else if(false pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { @@ -9850,28 +9821,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3 } } */ - /* until proper implementation - else if(false pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS) - { - res = _CanStoreItem_InInventorySlots(QUESTBAG_SLOT_START,QUESTBAG_SLOT_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - */ for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { @@ -9943,13 +9892,11 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const int inv_bags[INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START][MAX_BAG_SIZE]; int inv_keys[KEYRING_SLOT_END-KEYRING_SLOT_START]; int inv_tokens[CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START]; - int inv_quests[QUESTBAG_SLOT_END-QUESTBAG_SLOT_START]; memset(inv_slot_items,0,sizeof(int)*(INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START)); memset(inv_bags,0,sizeof(int)*(INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START)*MAX_BAG_SIZE); memset(inv_keys,0,sizeof(int)*(KEYRING_SLOT_END-KEYRING_SLOT_START)); memset(inv_tokens,0,sizeof(int)*(CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START)); - memset(inv_quests,0,sizeof(int)*(QUESTBAG_SLOT_END-QUESTBAG_SLOT_START)); for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) { @@ -9971,8 +9918,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } } - // Vanity pet case skipped as not used - for(int i = CURRENCYTOKEN_SLOT_START; i < CURRENCYTOKEN_SLOT_END; i++) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); @@ -9983,16 +9928,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } } - for(int i = QUESTBAG_SLOT_START; i < QUESTBAG_SLOT_END; i++) - { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - - if (pItem2 && !pItem2->IsInTrade()) - { - inv_quests[i-QUESTBAG_SLOT_START] = pItem2->GetCount(); - } - } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) @@ -10052,8 +9987,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - // Vanity pet case skipped as not used - for(int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; t++) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); @@ -10066,18 +9999,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } if (b_found) continue; - for(int t = QUESTBAG_SLOT_START; t < QUESTBAG_SLOT_END; t++) - { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); - if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_quests[t-QUESTBAG_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) - { - inv_quests[t-QUESTBAG_SLOT_START] += pItem->GetCount(); - b_found = true; - break; - } - } - if (b_found) continue; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) { pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); @@ -10130,8 +10051,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; - // Vanity pet case skipped as not used - /* until proper implementation if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { @@ -10148,22 +10067,6 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const if (b_found) continue; */ - /* until proper implementation - if(pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS) - { - for(uint32 t = QUESTBAG_SLOT_START; t < QUESTBAG_SLOT_END; ++t) - { - if( inv_quests[t-QUESTBAG_SLOT_START] == 0 ) - { - inv_quests[t-QUESTBAG_SLOT_START] = 1; - b_found = true; - break; - } - } - } - - if (b_found) continue; - */ for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) { @@ -11279,6 +11182,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq } } } + for(int i = KEYRING_SLOT_START; i < QUESTBAG_SLOT_END; i++) { if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) @@ -14324,7 +14228,7 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid ) if(!LoadValues( fields[1].GetString())) { - sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded for character list.",GUID_LOPART(guid)); + sLog.outError("Player #%d have broken data in `data` field. Can't be loaded for character list.",GUID_LOPART(guid)); if(delete_result) delete result; return false; } @@ -14518,7 +14422,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(!result) { - sLog.outError("ERROR: Player (GUID: %u) not found in table `characters`, can't load. ",guid); + sLog.outError("Player (GUID: %u) not found in table `characters`, can't load. ",guid); return false; } @@ -14530,7 +14434,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // player should be able to load/delete character only with correct account! if( dbAccountId != GetSession()->GetAccountId() ) { - sLog.outError("ERROR: Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId); + sLog.outError("Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId); delete result; return false; } @@ -14549,7 +14453,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(!LoadValues( fields[2].GetString())) { - sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); + sLog.outError("Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); delete result; return false; } @@ -14627,7 +14531,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(!IsPositionValid()) { - sLog.outError("ERROR: Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); + sLog.outError("Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); RelocateToHomebind(); transGUID = 0; @@ -14703,7 +14607,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // transport size limited m_movementInfo.t_x > 50 || m_movementInfo.t_y > 50 || m_movementInfo.t_z > 50 ) { - sLog.outError("ERROR: Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", + sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", guid,GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o); @@ -14741,7 +14645,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(!m_transport) { - sLog.outError("ERROR: Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.", + sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.", guid,transGUID); RelocateToHomebind(); @@ -15225,7 +15129,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) void Player::_LoadGlyphAuras() { - for (uint8 i = 0; i <= MAX_GLYPH_SLOT_INDEX; ++i) + for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) { if (uint32 glyph = GetGlyph(i)) { @@ -17076,7 +16980,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) if(pet->isControlled()) { - WorldPacket data(SMSG_PET_SPELLS, 8); + WorldPacket data(SMSG_PET_SPELLS, 8+4); data << uint64(0); data << uint32(0); GetSession()->SendPacket(&data); @@ -17283,9 +17187,9 @@ void Player::PossessSpellInitialize() //basic info 20 data << uint64(charm->GetGUID()); - data << uint32(0); //family - data << uint32(0); //0 - data << uint8(0) << uint8(0) << uint16(0); //reactstate, commandstate, 0 + data << uint32(0x00000000); + data << uint32(0); + data << uint32(0); //action bar 40 for(uint32 i = 0; i < 10; i++) @@ -18933,10 +18837,6 @@ void Player::SendInitialPacketsBeforeAddToMap() data << (float)0.01666667f; // game speed GetSession()->SendPacket( &data ); - data.Initialize(SMSG_TIME_SYNC_REQ, 4); // new 2.0.x, enable movement - data << uint32(0x00000000); // on blizz it increments periodically - GetSession()->SendPacket(&data); - // set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || isInFlight()) AddUnitMovementFlag(MOVEMENTFLAG_FLYING2); @@ -20719,3 +20619,252 @@ void Player::UpdateAchievementCriteria( AchievementCriteriaTypes type, uint32 mi { GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1,miscvalue2,unit,time); } + +void Player::LearnTalent(uint32 talentId, uint32 talentRank) +{ + uint32 CurTalentPoints = GetFreeTalentPoints(); + + if(CurTalentPoints == 0) + return; + + if (talentRank >= MAX_TALENT_RANK) + return; + + TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentId ); + + if(!talentInfo) + return; + + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); + + if(!talentTabInfo) + return; + + // prevent learn talent for different class (cheating) + if( (getClassMask() & talentTabInfo->ClassMask) == 0 ) + return; + + // find current max talent rank + int32 curtalent_maxrank = 0; + for(int32 k = MAX_TALENT_RANK-1; k > -1; --k) + { + if(talentInfo->RankID[k] && HasSpell(talentInfo->RankID[k])) + { + curtalent_maxrank = k + 1; + break; + } + } + + // we already have same or higher talent rank learned + if(curtalent_maxrank >= (talentRank + 1)) + return; + + // check if we have enough talent points + if(CurTalentPoints < (talentRank - curtalent_maxrank + 1)) + return; + + // Check if it requires another talent + if (talentInfo->DependsOn > 0) + { + if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) + { + bool hasEnoughRank = false; + for (int i = talentInfo->DependsOnRank; i < MAX_TALENT_RANK; i++) + { + if (depTalentInfo->RankID[i] != 0) + if (HasSpell(depTalentInfo->RankID[i])) + hasEnoughRank = true; + } + if (!hasEnoughRank) + return; + } + } + + // Find out how many points we have in this field + uint32 spentPoints = 0; + + uint32 tTab = talentInfo->TalentTab; + if (talentInfo->Row > 0) + { + unsigned int numRows = sTalentStore.GetNumRows(); + for (unsigned int i = 0; i < numRows; i++) // Loop through all talents. + { + // Someday, someone needs to revamp + const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i); + if (tmpTalent) // the way talents are tracked + { + if (tmpTalent->TalentTab == tTab) + { + for (int j = 0; j < MAX_TALENT_RANK; j++) + { + if (tmpTalent->RankID[j] != 0) + { + if (HasSpell(tmpTalent->RankID[j])) + { + spentPoints += j + 1; + } + } + } + } + } + } + } + + // not have required min points spent in talent tree + if(spentPoints < (talentInfo->Row * MAX_TALENT_RANK)) + return; + + // spell not set in talent.dbc + uint32 spellid = talentInfo->RankID[talentRank]; + if( spellid == 0 ) + { + sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank); + return; + } + + // already known + if(HasSpell(spellid)) + return; + + // learn! (other talent ranks will unlearned at learning) + learnSpell(spellid, false); + sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid); + + // update free talent points + SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1)); +} + +void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank) +{ + Pet *pet = GetPet(); + + if(!pet) + return; + + if(petGuid != pet->GetGUID()) + return; + + uint32 CurTalentPoints = pet->GetFreeTalentPoints(); + + if(CurTalentPoints == 0) + return; + + if (talentRank >= MAX_PET_TALENT_RANK) + return; + + TalentEntry const *talentInfo = sTalentStore.LookupEntry(talentId); + + if(!talentInfo) + return; + + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + + if(!talentTabInfo) + return; + + CreatureInfo const *ci = pet->GetCreatureInfo(); + + if(!ci) + return; + + CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + + if(!pet_family) + return; + + if(pet_family->petTalentType < 0) // not hunter pet + return; + + // prevent learn talent for different family (cheating) + if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + return; + + // find current max talent rank + int32 curtalent_maxrank = 0; + for(int32 k = MAX_TALENT_RANK-1; k > -1; --k) + { + if(talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k])) + { + curtalent_maxrank = k + 1; + break; + } + } + + // we already have same or higher talent rank learned + if(curtalent_maxrank >= (talentRank + 1)) + return; + + // check if we have enough talent points + if(CurTalentPoints < (talentRank - curtalent_maxrank + 1)) + return; + + // Check if it requires another talent + if (talentInfo->DependsOn > 0) + { + if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) + { + bool hasEnoughRank = false; + for (int i = talentInfo->DependsOnRank; i < MAX_TALENT_RANK; i++) + { + if (depTalentInfo->RankID[i] != 0) + if (pet->HasSpell(depTalentInfo->RankID[i])) + hasEnoughRank = true; + } + if (!hasEnoughRank) + return; + } + } + + // Find out how many points we have in this field + uint32 spentPoints = 0; + + uint32 tTab = talentInfo->TalentTab; + if (talentInfo->Row > 0) + { + unsigned int numRows = sTalentStore.GetNumRows(); + for (unsigned int i = 0; i < numRows; ++i) // Loop through all talents. + { + // Someday, someone needs to revamp + const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i); + if (tmpTalent) // the way talents are tracked + { + if (tmpTalent->TalentTab == tTab) + { + for (int j = 0; j < MAX_TALENT_RANK; j++) + { + if (tmpTalent->RankID[j] != 0) + { + if (pet->HasSpell(tmpTalent->RankID[j])) + { + spentPoints += j + 1; + } + } + } + } + } + } + } + + // not have required min points spent in talent tree + if(spentPoints < (talentInfo->Row * MAX_PET_TALENT_RANK)) + return; + + // spell not set in talent.dbc + uint32 spellid = talentInfo->RankID[talentRank]; + if( spellid == 0 ) + { + sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talentId, talentRank); + return; + } + + // already known + if(pet->HasSpell(spellid)) + return; + + // learn! (other talent ranks will unlearned at learning) + pet->learnSpell(spellid); + sLog.outDetail("PetTalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid); + + // update free talent points + pet->SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1)); +} diff --git a/src/game/Player.h b/src/game/Player.h index 3649b04d4ca..acaa1af8c89 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -560,7 +560,9 @@ enum PlayerSlots PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START) }; -enum EquipmentSlots +#define INVENTORY_SLOT_BAG_0 255 + +enum EquipmentSlots // 19 slots { EQUIPMENT_SLOT_START = 0, EQUIPMENT_SLOT_HEAD = 0, @@ -585,121 +587,59 @@ enum EquipmentSlots EQUIPMENT_SLOT_END = 19 }; -enum InventorySlots +enum InventorySlots // 4 slots { - INVENTORY_SLOT_BAG_0 = 255, INVENTORY_SLOT_BAG_START = 19, - INVENTORY_SLOT_BAG_1 = 19, - INVENTORY_SLOT_BAG_2 = 20, - INVENTORY_SLOT_BAG_3 = 21, - INVENTORY_SLOT_BAG_4 = 22, - INVENTORY_SLOT_BAG_END = 23, + INVENTORY_SLOT_BAG_END = 23 +}; +enum InventoryPackSlots // 16 slots +{ INVENTORY_SLOT_ITEM_START = 23, - INVENTORY_SLOT_ITEM_1 = 23, - INVENTORY_SLOT_ITEM_2 = 24, - INVENTORY_SLOT_ITEM_3 = 25, - INVENTORY_SLOT_ITEM_4 = 26, - INVENTORY_SLOT_ITEM_5 = 27, - INVENTORY_SLOT_ITEM_6 = 28, - INVENTORY_SLOT_ITEM_7 = 29, - INVENTORY_SLOT_ITEM_8 = 30, - INVENTORY_SLOT_ITEM_9 = 31, - INVENTORY_SLOT_ITEM_10 = 32, - INVENTORY_SLOT_ITEM_11 = 33, - INVENTORY_SLOT_ITEM_12 = 34, - INVENTORY_SLOT_ITEM_13 = 35, - INVENTORY_SLOT_ITEM_14 = 36, - INVENTORY_SLOT_ITEM_15 = 37, - INVENTORY_SLOT_ITEM_16 = 38, INVENTORY_SLOT_ITEM_END = 39 }; -enum BankSlots +enum BankItemSlots // 28 slots { BANK_SLOT_ITEM_START = 39, - BANK_SLOT_ITEM_1 = 39, - BANK_SLOT_ITEM_2 = 40, - BANK_SLOT_ITEM_3 = 41, - BANK_SLOT_ITEM_4 = 42, - BANK_SLOT_ITEM_5 = 43, - BANK_SLOT_ITEM_6 = 44, - BANK_SLOT_ITEM_7 = 45, - BANK_SLOT_ITEM_8 = 46, - BANK_SLOT_ITEM_9 = 47, - BANK_SLOT_ITEM_10 = 48, - BANK_SLOT_ITEM_11 = 49, - BANK_SLOT_ITEM_12 = 50, - BANK_SLOT_ITEM_13 = 51, - BANK_SLOT_ITEM_14 = 52, - BANK_SLOT_ITEM_15 = 53, - BANK_SLOT_ITEM_16 = 54, - BANK_SLOT_ITEM_17 = 55, - BANK_SLOT_ITEM_18 = 56, - BANK_SLOT_ITEM_19 = 57, - BANK_SLOT_ITEM_20 = 58, - BANK_SLOT_ITEM_21 = 59, - BANK_SLOT_ITEM_22 = 60, - BANK_SLOT_ITEM_23 = 61, - BANK_SLOT_ITEM_24 = 62, - BANK_SLOT_ITEM_25 = 63, - BANK_SLOT_ITEM_26 = 64, - BANK_SLOT_ITEM_27 = 65, - BANK_SLOT_ITEM_28 = 66, - BANK_SLOT_ITEM_END = 67, + BANK_SLOT_ITEM_END = 67 +}; +enum BankBagSlots // 7 slots +{ BANK_SLOT_BAG_START = 67, - BANK_SLOT_BAG_1 = 67, - BANK_SLOT_BAG_2 = 68, - BANK_SLOT_BAG_3 = 69, - BANK_SLOT_BAG_4 = 70, - BANK_SLOT_BAG_5 = 71, - BANK_SLOT_BAG_6 = 72, - BANK_SLOT_BAG_7 = 73, BANK_SLOT_BAG_END = 74 }; -enum BuyBackSlots +enum BuyBackSlots // 12 slots { // stored in m_buybackitems BUYBACK_SLOT_START = 74, - BUYBACK_SLOT_1 = 74, - BUYBACK_SLOT_2 = 75, - BUYBACK_SLOT_3 = 76, - BUYBACK_SLOT_4 = 77, - BUYBACK_SLOT_5 = 78, - BUYBACK_SLOT_6 = 79, - BUYBACK_SLOT_7 = 80, - BUYBACK_SLOT_8 = 81, - BUYBACK_SLOT_9 = 82, - BUYBACK_SLOT_10 = 83, - BUYBACK_SLOT_11 = 84, - BUYBACK_SLOT_12 = 85, BUYBACK_SLOT_END = 86 }; -enum KeyRingSlots +enum KeyRingSlots // 32 slots { KEYRING_SLOT_START = 86, KEYRING_SLOT_END = 118 }; -enum VanityPetSlots +enum VanityPetSlots // 18 slots { VANITYPET_SLOT_START = 118, // not use, vanity pets stored as spells - VANITYPET_SLOT_END = 136 // not alloed any content in. + VANITYPET_SLOT_END = 136 // not allowed any content in. }; -enum CurrencyTokenSlots +enum CurrencyTokenSlots // 32 slots { CURRENCYTOKEN_SLOT_START = 136, CURRENCYTOKEN_SLOT_END = 168 }; -enum QuestBagSlots +enum QuestBagSlots // 32 slots { - QUESTBAG_SLOT_START = 168, - QUESTBAG_SLOT_END = 200 + QUESTBAG_SLOT_START = 168, // not use + QUESTBAG_SLOT_END = 200 // not allowed any content in. }; struct ItemPosCount @@ -768,11 +708,6 @@ struct MovementInfo x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f; t_guid = 0; } - - void SetMovementFlags(uint32 _flags) - { - flags = _flags; - } }; // flags that use in movement check for example at spell casting @@ -850,7 +785,6 @@ enum PlayerLoginQueryIndex MAX_PLAYER_LOGIN_QUERY = 21 }; - // Player summoning auto-decline time (in secs) #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE) #define MAX_MONEY_AMOUNT (0x7FFFFFFF-1) @@ -1472,6 +1406,9 @@ class TRINITY_DLL_SPEC Player : public Unit uint32 resetTalentsCost() const; void InitTalentForLevel(); + void LearnTalent(uint32 talentId, uint32 talentRank); + void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank); + uint32 CalculateTalentsPoints() const; void InitGlyphsForLevel(); diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 1c23e8dc3a0..09d8f2f838d 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -102,20 +102,20 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+4+4+4+10) ); data << MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER); data << name; - data << (uint8)0; - data << (uint32)(field & 0xFF); - data << (uint32)((field >> 16) & 0xFF); - data << (uint32)((field >> 8) & 0xFF); + data << uint8(0); + data << uint32(field & 0xFF); + data << uint32((field >> 16) & 0xFF); + data << uint32((field >> 8) & 0xFF); // if the first declined name field (3) is empty, the rest must be too if(sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) && fields[3].GetCppString() != "") { - data << (uint8)1; // is declined + data << uint8(1); // is declined for(int i = 3; i < MAX_DECLINED_NAME_CASES+3; ++i) data << fields[i].GetCppString(); } else - data << (uint8)0; // is declined + data << uint8(0); // is declined session->SendPacket( &data ); delete result; @@ -123,7 +123,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data ) { - CHECK_PACKET_SIZE(recv_data,8); + CHECK_PACKET_SIZE(recv_data, 8); uint64 guid; @@ -176,23 +176,23 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) sLog.outDetail("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry); // guess size WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 100 ); - data << (uint32)entry; // creature entry + data << uint32(entry); // creature entry data << Name; data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty data << SubName; data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0 - data << (uint32)ci->type_flags; // flags wdbFeild7=wad flags1 - data << (uint32)ci->type; - data << (uint32)ci->family; // family wdbFeild9 - data << (uint32)ci->rank; // rank wdbFeild10 - data << (uint32)ci->PetSpellDataId; // Id from CreatureSpellData.dbc wdbField12 - data << (uint32)ci->Modelid1; // Modelid1 - data << (uint32)ci->Modelid2; // Modelid2 - data << (uint32)ci->Modelid3; // Modelid3 - data << (uint32)ci->Modelid4; // Modelid4 - data << (float)ci->unk16; // unk - data << (float)ci->unk17; // unk - data << (uint8)ci->RacialLeader; + data << uint32(ci->type_flags); // flags wdbFeild7=wad flags1 + data << uint32(ci->type); + data << uint32(ci->family); // family wdbFeild9 + data << uint32(ci->rank); // rank wdbFeild10 + data << uint32(ci->PetSpellDataId); // Id from CreatureSpellData.dbc wdbField12 + data << uint32(ci->Modelid1); // modelid_male1 + data << uint32(ci->Modelid2); // modelid_female1 ? + data << uint32(ci->Modelid3); // modelid_male2 ? + data << uint32(ci->Modelid4); // modelid_femmale2 ? + data << float(ci->unk16); // unk + data << float(ci->unk17); // unk + data << uint8(ci->RacialLeader); SendPacket( &data ); sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); } @@ -206,7 +206,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) WorldPacket data( SMSG_CREATURE_QUERY_RESPONSE, 4 ); data << uint32(entry | 0x80000000); SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); + sLog.outDebug( "WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE " ); } } @@ -242,15 +242,16 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) } sLog.outDetail("WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name, entryID); WorldPacket data ( SMSG_GAMEOBJECT_QUERY_RESPONSE, 150 ); - data << entryID; - data << (uint32)info->type; - data << (uint32)info->displayId; + data << uint32(entryID); + data << uint32(info->type); + data << uint32(info->displayId); data << Name; data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4 data << uint8(0); // 2.0.3, string data << CastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting") - data << uint8(0); // 2.0.3, probably string - data.append(info->raw.data,24); + data << uint8(0); // 2.0.3, string + data.append(info->raw.data, 24); + data << float(info->size); // go size SendPacket( &data ); sLog.outDebug( "WORLD: Sent CMSG_GAMEOBJECT_QUERY " ); } diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index 3afeaa0aa54..242c10bf48f 100644 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -125,7 +125,7 @@ enum __QuestFlags //QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently QUEST_FLAGS_EPIC = 0x00000020, // Not used currently: Unsure of content QUEST_FLAGS_RAID = 0x00000040, // Not used currently - QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expension enabled only + QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expansion enabled only QUEST_FLAGS_UNK2 = 0x00000100, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs QUEST_FLAGS_HIDDEN_REWARDS = 0x00000200, // Items and money rewarded only sent in SMSG_QUESTGIVER_OFFER_REWARD (not in SMSG_QUESTGIVER_QUEST_DETAILS or in client quest log(SMSG_QUEST_QUERY_RESPONSE)) QUEST_FLAGS_AUTO_REWARDED = 0x00000400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side. diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 86920b1bb27..be289df52ba 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -451,7 +451,7 @@ enum SpellCategory #define SPELL_ATTR_EX6_UNK30 0x40000000 // 30 not set in 3.0.3 #define SPELL_ATTR_EX6_UNK31 0x80000000 // 31 not set in 3.0.3 -#define MAX_GLYPH_SLOT_INDEX 5 +#define MAX_GLYPH_SLOT_INDEX 6 enum SheathTypes { diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index a6d854d25ce..ccc2eea8297 100644 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -35,103 +35,7 @@ void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data ) uint32 talent_id, requested_rank; recv_data >> talent_id >> requested_rank; - uint32 CurTalentPoints = GetPlayer()->GetFreeTalentPoints(); - - if(CurTalentPoints == 0) - return; - - if (requested_rank > 4) - return; - - TalentEntry const *talentInfo = sTalentStore.LookupEntry( talent_id ); - - if(!talentInfo) - return; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - - if(!talentTabInfo) - return; - - Player * player = GetPlayer(); - - // prevent learn talent for different class (cheating) - if( (player->getClassMask() & talentTabInfo->ClassMask) == 0 ) - return; - - // prevent skip talent ranks (cheating) - if(requested_rank > 0 && !player->HasSpell(talentInfo->RankID[requested_rank-1])) - return; - - // Check if it requires another talent - if (talentInfo->DependsOn > 0) - { - if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn)) - { - bool hasEnoughRank = false; - for (int i = talentInfo->DependsOnRank; i <= 4; i++) - { - if (depTalentInfo->RankID[i] != 0) - if (player->HasSpell(depTalentInfo->RankID[i])) - hasEnoughRank = true; - } - if (!hasEnoughRank) - return; - } - } - - // Find out how many points we have in this field - uint32 spentPoints = 0; - - uint32 tTab = talentInfo->TalentTab; - if (talentInfo->Row > 0) - { - unsigned int numRows = sTalentStore.GetNumRows(); - for (unsigned int i = 0; i < numRows; i++) // Loop through all talents. - { - // Someday, someone needs to revamp - const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i); - if (tmpTalent) // the way talents are tracked - { - if (tmpTalent->TalentTab == tTab) - { - for (int j = 0; j <= 4; j++) - { - if (tmpTalent->RankID[j] != 0) - { - if (player->HasSpell(tmpTalent->RankID[j])) - { - spentPoints += j + 1; - } - } - } - } - } - } - } - - // not have required min points spent in talent tree - if(spentPoints < (talentInfo->Row * 5)) - return; - - // spell not set in talent.dbc - uint32 spellid = talentInfo->RankID[requested_rank]; - if( spellid == 0 ) - { - sLog.outError("Talent.dbc have for talent: %u Rank: %u spell id = 0", talent_id, requested_rank); - return; - } - - // already known - if(GetPlayer( )->HasSpell(spellid)) - return; - - // learn! (other talent ranks will unlearned at learning) - GetPlayer( )->learnSpell(spellid,false); - sLog.outDetail("TalentID: %u Rank: %u Spell: %u", talent_id, requested_rank, spellid); - - // update free talent points - GetPlayer()->SetFreeTalentPoints(CurTalentPoints - 1); + _player->LearnTalent(talent_id, requested_rank); } void WorldSession::HandleTalentWipeOpcode( WorldPacket & recv_data ) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 0a2dbe53485..1788240fddf 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4867,7 +4867,7 @@ SpellCastResult Spell::CheckItems() ItemPrototype const *proto = m_CastItem->GetProto(); if(!proto) return SPELL_FAILED_ITEM_NOT_READY; - for(int s=0;s < MAX_ITEM_PROTO_SPELLS; ++s) + for(int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s) { // CastItem will be used up and does not count as reagent int32 charges = m_CastItem->GetSpellCharges(s); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 9e56b7e2bdb..f01195b2b23 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3057,7 +3057,7 @@ void Aura::HandleAuraModScale(bool apply, bool Real) if(caster->GetTypeId() == TYPEID_PLAYER) { - WorldPacket data(SMSG_PET_SPELLS, 8); + WorldPacket data(SMSG_PET_SPELLS, 8+4); data << uint64(0); data << uint32(0); ((Player*)caster)->GetSession()->SendPacket(&data); @@ -3213,7 +3213,7 @@ void Aura::HandleAuraModPetTalentsPoints(bool Apply, bool Real) if(caster->GetTypeId() == TYPEID_PLAYER) { - WorldPacket data(SMSG_PET_SPELLS, 8); + WorldPacket data(SMSG_PET_SPELLS, 8+4); data << uint64(0); data << uint32(0); ((Player*)caster)->GetSession()->SendPacket(&data); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 48555e6a0a4..742fc30fd69 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4115,7 +4115,6 @@ void Spell::EffectSummonPet(uint32 i) owner->GetClosePoint(x, y, z, owner->GetObjectSize()); Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0); if(!pet) - return; if(m_caster->GetTypeId() == TYPEID_UNIT) @@ -5410,16 +5409,6 @@ void Spell::EffectApplyGlyph(uint32 i) Player *player = (Player*)m_caster; - // remove old glyph - if(uint32 oldglyph = player->GetGlyph(m_glyphIndex)) - { - if(GlyphPropertiesEntry const *old_gp = sGlyphPropertiesStore.LookupEntry(oldglyph)) - { - player->RemoveAurasDueToSpell(old_gp->SpellId); - player->SetGlyph(m_glyphIndex, 0); - } - } - // apply new one if(uint32 glyph = m_spellInfo->EffectMiscValue[i]) { @@ -5430,7 +5419,17 @@ void Spell::EffectApplyGlyph(uint32 i) if(gp->TypeFlags != gs->TypeFlags) { SendCastResult(SPELL_FAILED_INVALID_GLYPH); - return; // glyph slot missmatch + return; // glyph slot mismatch + } + } + + // remove old glyph + if(uint32 oldglyph = player->GetGlyph(m_glyphIndex)) + { + if(GlyphPropertiesEntry const *old_gp = sGlyphPropertiesStore.LookupEntry(oldglyph)) + { + player->RemoveAurasDueToSpell(old_gp->SpellId); + player->SetGlyph(m_glyphIndex, 0); } } diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index feafa0076dd..23b53ee1ccf 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -151,7 +151,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, if(!IsPositionValid()) { - sLog.outError("ERROR: Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", + sLog.outError("Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow,x,y); return false; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0ccabfb2054..af26cdbfa2f 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10876,7 +10876,7 @@ float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) co { if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { - sLog.outError("ERROR: trial to access non existed modifier value from UnitMods!"); + sLog.outError("trial to access non existed modifier value from UnitMods!"); return 0.0f; } @@ -10906,7 +10906,7 @@ float Unit::GetTotalAuraModValue(UnitMods unitMod) const { if(unitMod >= UNIT_MOD_END) { - sLog.outError("ERROR: trial to access non existed UnitMods in GetTotalAuraModValue()!"); + sLog.outError("trial to access non existed UnitMods in GetTotalAuraModValue()!"); return 0.0f; } @@ -12418,7 +12418,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) if(!pet->InitStatsForLevel(level)) { - sLog.outError("ERROR: Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry()); + sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry()); delete pet; return NULL; } diff --git a/src/game/World.cpp b/src/game/World.cpp index 947500c09dc..12d8d2ed64b 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -265,6 +265,7 @@ World::AddSession_ (WorldSession* s) packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account s->SendPacket (&packet); + s->SendAddonsInfo(); UpdateMaxSessionCounters (); // Updates the population diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 01459930788..5bf573ed7df 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -39,6 +39,7 @@ #include "OutdoorPvPMgr.h" //#include "Language.h" // for CMSG_CANCEL_MOUNT_AURA handler #include "SocialMgr.h" +#include "zlib/zlib.h" /// WorldSession constructor WorldSession::WorldSession(uint32 id, WorldSocket *sock, uint32 sec, uint8 expansion, time_t mute_time, LocaleConstant locale) : @@ -615,3 +616,123 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi) data >> mi->u_unk1; } } + +void WorldSession::ReadAddonsInfo(WorldPacket &data) +{ + if (data.rpos() + 4 > data.size()) + return; + uint32 size; + data >> size; + + if(!size) + return; + + uLongf uSize = size; + + uint32 pos = data.rpos(); + + ByteBuffer addonInfo; + addonInfo.resize(size); + + if (uncompress(const_cast<uint8*>(addonInfo.contents()), &uSize, const_cast<uint8*>(data.contents() + pos), data.size() - pos) == Z_OK) + { + uint32 addonsCount; + addonInfo >> addonsCount; // addons count + + for(uint32 i = 0; i < addonsCount; ++i) + { + std::string addonName; + uint8 enabled; + uint32 crc, unk1; + + // check next addon data format correctness + if(addonInfo.rpos()+1 > addonInfo.size()) + return; + + addonInfo >> addonName; + + // recheck next addon data format correctness + if(addonInfo.rpos()+1+4+4 > addonInfo.size()) + return; + + addonInfo >> enabled >> crc >> unk1; + + sLog.outDebug("ADDON: Name: %s, Enabled: 0x%x, CRC: 0x%x, Unknown2: 0x%x", addonName.c_str(), enabled, crc, unk1); + + m_addonsList.push_back(AddonInfo(addonName, enabled, crc)); + } + + uint32 unk2; + addonInfo >> unk2; + + if(addonInfo.rpos() != addonInfo.size()) + sLog.outDebug("packet under read!"); + } + else + sLog.outError("Addon packet uncompress error!"); +} + +void WorldSession::SendAddonsInfo() +{ + unsigned char tdata[256] = + { + 0xC3, 0x5B, 0x50, 0x84, 0xB9, 0x3E, 0x32, 0x42, 0x8C, 0xD0, 0xC7, 0x48, 0xFA, 0x0E, 0x5D, 0x54, + 0x5A, 0xA3, 0x0E, 0x14, 0xBA, 0x9E, 0x0D, 0xB9, 0x5D, 0x8B, 0xEE, 0xB6, 0x84, 0x93, 0x45, 0x75, + 0xFF, 0x31, 0xFE, 0x2F, 0x64, 0x3F, 0x3D, 0x6D, 0x07, 0xD9, 0x44, 0x9B, 0x40, 0x85, 0x59, 0x34, + 0x4E, 0x10, 0xE1, 0xE7, 0x43, 0x69, 0xEF, 0x7C, 0x16, 0xFC, 0xB4, 0xED, 0x1B, 0x95, 0x28, 0xA8, + 0x23, 0x76, 0x51, 0x31, 0x57, 0x30, 0x2B, 0x79, 0x08, 0x50, 0x10, 0x1C, 0x4A, 0x1A, 0x2C, 0xC8, + 0x8B, 0x8F, 0x05, 0x2D, 0x22, 0x3D, 0xDB, 0x5A, 0x24, 0x7A, 0x0F, 0x13, 0x50, 0x37, 0x8F, 0x5A, + 0xCC, 0x9E, 0x04, 0x44, 0x0E, 0x87, 0x01, 0xD4, 0xA3, 0x15, 0x94, 0x16, 0x34, 0xC6, 0xC2, 0xC3, + 0xFB, 0x49, 0xFE, 0xE1, 0xF9, 0xDA, 0x8C, 0x50, 0x3C, 0xBE, 0x2C, 0xBB, 0x57, 0xED, 0x46, 0xB9, + 0xAD, 0x8B, 0xC6, 0xDF, 0x0E, 0xD6, 0x0F, 0xBE, 0x80, 0xB3, 0x8B, 0x1E, 0x77, 0xCF, 0xAD, 0x22, + 0xCF, 0xB7, 0x4B, 0xCF, 0xFB, 0xF0, 0x6B, 0x11, 0x45, 0x2D, 0x7A, 0x81, 0x18, 0xF2, 0x92, 0x7E, + 0x98, 0x56, 0x5D, 0x5E, 0x69, 0x72, 0x0A, 0x0D, 0x03, 0x0A, 0x85, 0xA2, 0x85, 0x9C, 0xCB, 0xFB, + 0x56, 0x6E, 0x8F, 0x44, 0xBB, 0x8F, 0x02, 0x22, 0x68, 0x63, 0x97, 0xBC, 0x85, 0xBA, 0xA8, 0xF7, + 0xB5, 0x40, 0x68, 0x3C, 0x77, 0x86, 0x6F, 0x4B, 0xD7, 0x88, 0xCA, 0x8A, 0xD7, 0xCE, 0x36, 0xF0, + 0x45, 0x6E, 0xD5, 0x64, 0x79, 0x0F, 0x17, 0xFC, 0x64, 0xDD, 0x10, 0x6F, 0xF3, 0xF5, 0xE0, 0xA6, + 0xC3, 0xFB, 0x1B, 0x8C, 0x29, 0xEF, 0x8E, 0xE5, 0x34, 0xCB, 0xD1, 0x2A, 0xCE, 0x79, 0xC3, 0x9A, + 0x0D, 0x36, 0xEA, 0x01, 0xE0, 0xAA, 0x91, 0x20, 0x54, 0xF0, 0x72, 0xD8, 0x1E, 0xC7, 0x89, 0xD2 + }; + + WorldPacket data(SMSG_ADDON_INFO, 4); + + for(AddonsList::iterator itr = m_addonsList.begin(); itr != m_addonsList.end(); ++itr) + { + uint8 state = (itr->Enabled ? 2 : 1); + data << uint8(state); + + uint8 unk1 = (itr->Enabled ? 1 : 0); + data << uint8(unk1); + if (unk1) + { + uint8 unk2 = (itr->CRC != 0x4c1c776d); // If addon is Standard addon CRC + data << uint8(unk2); + if (unk2) + data.append(tdata, sizeof(tdata)); + + data << uint32(0); + } + + uint8 unk3 = (itr->Enabled ? 0 : 1); + data << uint8(unk3); + if (unk3) + { + // String, 256 (null terminated?) + data << uint8(0); + } + } + + m_addonsList.clear(); + + uint32 count = 0; + data << uint32(count); + /*for(uint32 i = 0; i < count; ++i) + { + uint32 + string (16 bytes) + string (16 bytes) + uint32 + }*/ + + SendPacket(&data); +} diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 7649c69f486..0848ef63ecb 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -58,6 +58,22 @@ struct AccountData std::string Data; }; +struct AddonInfo +{ + AddonInfo(std::string name, uint8 enabled, uint32 crc) + { + Name = name; + Enabled = enabled; + CRC = crc; + } + + std::string Name; + uint8 Enabled; + uint32 CRC; +}; + +typedef std::list<AddonInfo> AddonsList; + enum PartyOperation { PARTY_OP_INVITE = 0, @@ -92,6 +108,9 @@ class TRINITY_DLL_SPEC WorldSession void SizeError(WorldPacket const& packet, uint32 size) const; + void ReadAddonsInfo(WorldPacket &data); + void SendAddonsInfo(); + void ReadMovementInfo(WorldPacket &data, MovementInfo *mi); void SendPacket(WorldPacket const* packet); @@ -698,6 +717,7 @@ class TRINITY_DLL_SPEC WorldSession int m_sessionDbLocaleIndex; uint32 m_latency; AccountData m_accountData[NUM_ACCOUNT_DATA_TYPES]; + AddonsList m_addonsList; ZThread::LockedQueue<WorldPacket*,ZThread::FastMutex> _recvQueue; }; diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index c8ed6db0592..ca5a233bc64 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -37,7 +37,6 @@ #include "WorldPacket.h" #include "SharedDefines.h" #include "ByteBuffer.h" -#include "AddonHandler.h" #include "Opcodes.h" #include "Database/DatabaseEnv.h" #include "Auth/Sha1.h" @@ -187,7 +186,7 @@ int WorldSocket::SendPacket (const WorldPacket& pct) } ServerPktHeader header(pct.size()+2, pct.GetOpcode()); - m_Crypt.EncryptSend ( header.header, header.getHeaderLength()); + m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength()); if (m_OutBuffer->space () >= pct.size () + header.getHeaderLength() && msg_queue()->is_empty()) { @@ -480,7 +479,7 @@ int WorldSocket::handle_input_header (void) ACE_ASSERT (m_Header.length () == sizeof (ClientPktHeader)); - m_Crypt.DecryptRecv ((ACE_UINT8*) m_Header.rd_ptr (), sizeof (ClientPktHeader)); + m_Crypt.DecryptRecv ((uint8*) m_Header.rd_ptr (), sizeof (ClientPktHeader)); ClientPktHeader& header = *((ClientPktHeader*) m_Header.rd_ptr ()); @@ -1000,16 +999,13 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) m_Crypt.Init (); m_Session->LoadAccountData(); + m_Session->ReadAddonsInfo(recvPacket); // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec ACE_OS::sleep (ACE_Time_Value (0, 10000)); sWorld.AddSession (m_Session); - // Create and send the Addon packet - if (sAddOnHandler.BuildAddonPacket (&recvPacket, &SendAddonPacked)) - SendPacket (SendAddonPacked); - return 0; } diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index b15bb456945..9589865b9ac 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -345,7 +345,7 @@ void LoadDBCStores(const std::string& dataPath) { TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); if (!talentInfo) continue; - for (int j = 0; j < 5; j++) + for (int j = 0; j < MAX_TALENT_RANK; j++) if(talentInfo->RankID[j]) sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j); } @@ -369,7 +369,7 @@ void LoadDBCStores(const std::string& dataPath) // find talent rank uint32 curtalent_maxrank = 0; - for(uint32 k = 5; k > 0; --k) + for(uint32 k = MAX_TALENT_RANK; k > 0; --k) { if(talentInfo->RankID[k-1]) { diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index 6fb43567a3a..ec60105a230 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -1408,13 +1408,16 @@ struct SummonPropertiesEntry uint32 Flags; // 5 }; +#define MAX_TALENT_RANK 5 +#define MAX_PET_TALENT_RANK 3 // use in calculations, expected <= MAX_TALENT_RANK + struct TalentEntry { uint32 TalentID; // 0 uint32 TalentTab; // 1 index in TalentTab.dbc (TalentTabEntry) uint32 Row; // 2 uint32 Col; // 3 - uint32 RankID[5]; // 4-8 + uint32 RankID[MAX_TALENT_RANK]; // 4-8 // 9-12 not used, always 0, maybe not used high ranks uint32 DependsOn; // 13 index in Talent.dbc (TalentEntry) // 14-15 not used diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp index dc6fec3b7b3..b958742ffc7 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/shared/Database/DBCfmt.cpp @@ -97,4 +97,3 @@ const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiii const char WorldMapAreaEntryfmt[]="xinxffffix"; const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx"; const char WorldMapOverlayEntryfmt[]="nxixxxxxxxxxxxxxx"; - |