Changeset 279 for trunk/src/game
- Timestamp:
- 11/22/08 00:36:22 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 61 modified
-
AuctionHouse.cpp (modified) (4 diffs)
-
Bag.cpp (modified) (6 diffs)
-
BattleGround.h (modified) (3 diffs)
-
CharacterHandler.cpp (modified) (12 diffs)
-
Chat.cpp (modified) (1 diff)
-
Chat.h (modified) (6 diffs)
-
Creature.cpp (modified) (12 diffs)
-
Creature.h (modified) (8 diffs)
-
CreatureAI.cpp (modified) (1 diff)
-
CreatureAIImpl.h (modified) (1 diff)
-
CreatureAIRegistry.cpp (modified) (1 diff)
-
CreatureAISelector.cpp (modified) (1 diff)
-
Formulas.h (modified) (3 diffs)
-
GMTicketHandler.cpp (modified) (3 diffs)
-
GMTicketMgr.h (modified) (2 diffs)
-
GameEvent.cpp (modified) (1 diff)
-
GameObject.cpp (modified) (1 diff)
-
GameObject.h (modified) (2 diffs)
-
GridNotifiers.h (modified) (1 diff)
-
GridNotifiersImpl.h (modified) (3 diffs)
-
Item.cpp (modified) (8 diffs)
-
Item.h (modified) (2 diffs)
-
ItemEnchantmentMgr.cpp (modified) (1 diff)
-
ItemEnchantmentMgr.h (modified) (1 diff)
-
ItemHandler.cpp (modified) (7 diffs)
-
ItemPrototype.h (modified) (8 diffs)
-
Level2.cpp (modified) (9 diffs)
-
Level3.cpp (modified) (4 diffs)
-
Mail.cpp (modified) (3 diffs)
-
Map.cpp (modified) (24 diffs)
-
Map.h (modified) (11 diffs)
-
MapInstanced.cpp (modified) (3 diffs)
-
MapInstanced.h (modified) (2 diffs)
-
MapManager.cpp (modified) (5 diffs)
-
MapManager.h (modified) (3 diffs)
-
NPCHandler.cpp (modified) (4 diffs)
-
ObjectAccessor.cpp (modified) (8 diffs)
-
ObjectAccessor.h (modified) (2 diffs)
-
ObjectMgr.cpp (modified) (44 diffs)
-
ObjectMgr.h (modified) (20 diffs)
-
Pet.cpp (modified) (8 diffs)
-
Player.cpp (modified) (23 diffs)
-
Player.h (modified) (15 diffs)
-
PlayerDump.cpp (modified) (16 diffs)
-
SharedDefines.h (modified) (1 diff)
-
Spell.cpp (modified) (1 diff)
-
SpellAuras.cpp (modified) (27 diffs)
-
SpellAuras.h (modified) (3 diffs)
-
SpellEffects.cpp (modified) (24 diffs)
-
SpellHandler.cpp (modified) (6 diffs)
-
SpellMgr.cpp (modified) (7 diffs)
-
SpellMgr.h (modified) (3 diffs)
-
StatSystem.cpp (modified) (1 diff)
-
Totem.cpp (modified) (1 diff)
-
Unit.cpp (modified) (36 diffs)
-
Unit.h (modified) (5 diffs)
-
WaypointManager.cpp (modified) (6 diffs)
-
WaypointManager.h (modified) (1 diff)
-
WaypointMovementGenerator.cpp (modified) (2 diffs)
-
World.cpp (modified) (24 diffs)
-
World.h (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/AuctionHouse.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 90 90 return false; 91 91 } 92 data << auction->Id;93 data << pItem->GetUInt32Value(OBJECT_FIELD_ENTRY);92 data << (uint32) auction->Id; 93 data << (uint32) pItem->GetEntry(); 94 94 95 95 for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++) … … 246 246 return; 247 247 } 248 // prevent sending bag with items (cheat: can be placed in bag after adding equip ped empty bag to auction)248 // prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction) 249 249 if(!it) 250 250 { … … 717 717 if (il) 718 718 { 719 if (il->Name.size() > loc_idx&& !il->Name[loc_idx].empty())719 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) 720 720 name = il->Name[loc_idx]; 721 721 } -
trunk/src/game/Bag.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 42 42 for(int i = 0; i < MAX_BAG_SIZE; ++i) 43 43 if (m_bagslot[i]) 44 delete m_bagslot[i];44 delete m_bagslot[i]; 45 45 } 46 46 … … 72 72 Object::_Create( guidlow, 0, HIGHGUID_CONTAINER ); 73 73 74 Set UInt32Value(OBJECT_FIELD_ENTRY,itemid);74 SetEntry(itemid); 75 75 SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); 76 76 … … 86 86 SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots); 87 87 88 // Clean ning 20 slots88 // Cleaning 20 slots 89 89 for (uint8 i = 0; i < MAX_BAG_SIZE; i++) 90 90 { … … 214 214 if(m_bagslot[i]->GetGUID() == guid) 215 215 return i; 216 216 217 return NULL_SLOT; 217 218 } … … 221 222 if( slot < GetBagSize() ) 222 223 return m_bagslot[slot]; 223 224 224 225 return NULL; 225 226 } -
trunk/src/game/BattleGround.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 96 96 RESPAWN_ONE_DAY = 86400, // secs 97 97 RESPAWN_IMMEDIATELY = 0, // secs 98 BUFF_RESPAWN_TIME = 180 // secs 98 BUFF_RESPAWN_TIME = 180, // secs 99 BG_HONOR_SCORE_TICKS = 330 // points 99 100 }; 100 101 … … 434 435 435 436 virtual void AddPlayer(Player *plr); // must be implemented in BG subclass 436 437 437 virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); 438 438 // can be extended in in BG subclass -
trunk/src/game/CharacterHandler.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 65 65 res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid)); 66 66 res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); 67 res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index, amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));67 res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); 68 68 res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,slot,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid)); 69 69 res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid)); … … 181 181 std::string name; 182 182 uint8 race_,class_; 183 183 184 recv_data >> name; 184 185 … … 215 216 ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_); 216 217 ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_); 218 217 219 if( !classEntry || !raceEntry ) 218 220 { … … 608 610 } 609 611 610 if (! MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar))612 if (!pCurrChar->GetMap()->Add(pCurrChar)) 611 613 { 612 614 AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId()); … … 1000 1002 uint64 guid; 1001 1003 1002 CHECK_PACKET_SIZE(recv_data, 8 +6);1004 CHECK_PACKET_SIZE(recv_data, 8); 1003 1005 recv_data >> guid; 1004 1006 1005 1007 // not accept declined names for unsupported languages 1006 1008 std::string name; 1007 if(!objmgr.GetPlayerNameByGUID(guid, name))1008 { 1009 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1010 data << (uint32)1;1011 data << guid;1009 if(!objmgr.GetPlayerNameByGUID(guid, name)) 1010 { 1011 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1012 data << uint32(1); 1013 data << uint64(guid); 1012 1014 SendPacket(&data); 1013 1015 return; … … 1015 1017 1016 1018 std::wstring wname; 1017 if(!Utf8toWStr(name, wname))1018 { 1019 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1020 data << (uint32)1;1021 data << guid;1019 if(!Utf8toWStr(name, wname)) 1020 { 1021 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1022 data << uint32(1); 1023 data << uint64(guid); 1022 1024 SendPacket(&data); 1023 1025 return; … … 1026 1028 if(!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using 1027 1029 { 1028 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1029 data << (uint32)1;1030 data << guid;1030 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1031 data << uint32(1); 1032 data << uint64(guid); 1031 1033 SendPacket(&data); 1032 1034 return; … … 1036 1038 DeclinedName declinedname; 1037 1039 1040 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); 1038 1041 recv_data >> name2; 1039 1042 1040 if(name2 !=name)// character have different name1041 { 1042 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1043 data << (uint32)1;1044 data << guid;1043 if(name2 != name) // character have different name 1044 { 1045 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1046 data << uint32(1); 1047 data << uint64(guid); 1045 1048 SendPacket(&data); 1046 1049 return; … … 1049 1052 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) 1050 1053 { 1054 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1); 1051 1055 recv_data >> declinedname.name[i]; 1052 1056 if(!normalizePlayerName(declinedname.name[i])) 1053 1057 { 1054 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1055 data << (uint32)1;1056 data << guid;1058 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1059 data << uint32(1); 1060 data << uint64(guid); 1057 1061 SendPacket(&data); 1058 1062 return; … … 1060 1064 } 1061 1065 1062 if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0),declinedname))1063 { 1064 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1065 data << (uint32)1;1066 data << guid;1066 if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname)) 1067 { 1068 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1069 data << uint32(1); 1070 data << uint64(guid); 1067 1071 SendPacket(&data); 1068 1072 return; … … 1075 1079 CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid)); 1076 1080 CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')", 1077 GUID_LOPART(guid), 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());1081 GUID_LOPART(guid), 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()); 1078 1082 CharacterDatabase.CommitTransaction(); 1079 1083 1080 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1081 data << (uint32)0; // OK1082 data << guid;1084 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); 1085 data << uint32(0); // OK 1086 data << uint64(guid); 1083 1087 SendPacket(&data); 1084 1088 } -
trunk/src/game/Chat.cpp
r272 r279 64 64 }; 65 65 66 static ChatCommand serverIdleRestartCommandTable[] = 67 { 68 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 69 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL }, 70 { NULL, 0, false, NULL, "", NULL } 71 }; 72 73 static ChatCommand serverIdleShutdownCommandTable[] = 74 { 75 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 76 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL }, 77 { NULL, 0, false, NULL, "", NULL } 78 }; 79 80 static ChatCommand serverRestartCommandTable[] = 81 { 82 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 83 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerRestartCommand, "", NULL }, 84 { NULL, 0, false, NULL, "", NULL } 85 }; 86 87 static ChatCommand serverShutdownCommandTable[] = 88 { 89 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 90 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCommand, "", NULL }, 91 { NULL, 0, false, NULL, "", NULL } 92 }; 93 66 94 static ChatCommand serverCommandTable[] = 67 95 { 68 96 { "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, 69 97 { "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, 70 { "idlerestart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleRestartCommand, "", NULL},71 { "idleshutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleShutDownCommand, "", NULL},98 { "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable }, 99 { "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, 72 100 { "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, 73 101 { "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, 74 { "restart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleRestartCommand, "", NULL},75 { "shutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleShutDownCommand, "", NULL},102 { "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable }, 103 { "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, 76 104 { "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable }, 77 105 { NULL, 0, false, NULL, "", NULL } -
trunk/src/game/Chat.h
r272 r279 176 176 bool HandleModifyRepCommand(const char* args); 177 177 bool HandleModifyArenaCommand(const char* args); 178 bool HandleModifyGenderCommand(const char* args); 178 179 179 180 bool HandleNpcAddCommand(const char* args); … … 192 193 bool HandleNpcSpawnDistCommand(const char* args); 193 194 bool HandleNpcSpawnTimeCommand(const char* args); 195 bool HandleNpcTameCommand(const char* args); 194 196 bool HandleNpcTextEmoteCommand(const char* args); 195 197 bool HandleNpcUnFollowCommand(const char* args); … … 216 218 bool HandleReloadCreatureQuestRelationsCommand(const char* args); 217 219 bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); 220 bool HandleReloadDbScriptStringCommand(const char* args); 218 221 bool HandleReloadGameGraveyardZoneCommand(const char* args); 219 222 bool HandleReloadGameObjectScriptsCommand(const char* args); … … 271 274 bool HandleServerCorpsesCommand(const char* args); 272 275 bool HandleServerExitCommand(const char* args); 276 bool HandleServerIdleRestartCommand(const char* args); 277 bool HandleServerIdleShutDownCommand(const char* args); 273 278 bool HandleServerInfoCommand(const char* args); 274 279 bool HandleServerMotdCommand(const char* args); 280 bool HandleServerRestartCommand(const char* args); 275 281 bool HandleServerSetMotdCommand(const char* args); 276 282 bool HandleServerSetLogLevelCommand(const char* args); 283 bool HandleServerShutDownCommand(const char* args); 284 bool HandleServerShutDownCancelCommand(const char* args); 277 285 278 286 bool HandleAddHonorCommand(const char* args); … … 328 336 bool HandleBanListCharacterCommand(const char* args); 329 337 bool HandleBanListIPCommand(const char* args); 330 bool HandleIdleRestartCommand(const char* args);331 bool HandleIdleShutDownCommand(const char* args);332 bool HandleShutDownCommand(const char* args);333 bool HandleRestartCommand(const char* args);334 bool HandleSecurityCommand(const char* args);335 338 bool HandleGoXYCommand(const char* args); 336 339 bool HandleGoXYZCommand(const char* args); … … 366 369 bool HandleAddItemCommand(const char* args); 367 370 bool HandleAddItemSetCommand(const char* args); 368 bool HandleModifyGenderCommand(const char* args);369 371 bool HandlePetTpCommand(const char* args); 370 372 bool HandlePetUnlearnCommand(const char* args); -
trunk/src/game/Creature.cpp
r272 r279 123 123 m_lootMoney(0), m_lootRecipient(0), 124 124 m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), 125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), 125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true), 126 126 m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), 127 127 m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), … … 182 182 float x,y,z,o; 183 183 GetRespawnCoord(x, y, z, &o); 184 MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o);184 GetMap()->CreatureRelocation(this,x,y,z,o); 185 185 } 186 186 … … 214 214 } 215 215 216 Set UInt32Value(OBJECT_FIELD_ENTRY, Entry);// normal entry always216 SetEntry(Entry); // normal entry always 217 217 m_creatureInfo = cinfo; // map mode related always 218 218 … … 298 298 SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); 299 299 300 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 300 301 SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); 301 302 SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); … … 328 329 SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 329 330 331 if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER 332 || GetCreatureType() == CREATURE_TYPE_CRITTER) 333 m_isAggressive = false; 334 else 335 m_isAggressive = true; 336 330 337 return true; 331 338 } … … 357 364 lootForBody = false; 358 365 359 if(m_originalEntry != Get UInt32Value(OBJECT_FIELD_ENTRY))366 if(m_originalEntry != GetEntry()) 360 367 UpdateEntry(m_originalEntry); 361 368 … … 376 383 377 384 //Call AI respawn virtual function 378 AI()->JustRespawned();379 380 MapManager::Instance().GetMap(GetMapId(), this)->Add(this);385 i_AI->JustRespawned(); 386 387 GetMap()->Add(this); 381 388 } 382 389 break; … … 440 447 // do not allow the AI to be changed during update 441 448 m_AI_locked = true; 442 AI()->UpdateAI(diff);449 i_AI->UpdateAI(diff); 443 450 m_AI_locked = false; 444 451 } … … 1412 1419 SetPower(POWER_MANA,data->curmana); 1413 1420 1414 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));1415 1416 1421 // checked at creature_template loading 1417 1422 m_defaultMovementType = MovementGeneratorType(data->movementType); … … 1538 1543 { 1539 1544 return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); 1545 } 1546 1547 bool Creature::canStartAttack(Unit const* who) const 1548 { 1549 if(!who->isInAccessiblePlaceFor(this) 1550 || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE 1551 || !IsWithinDistInMap(who, GetAttackDistance(who))) 1552 return false; 1553 1554 if(!canAttack(who)) 1555 return false; 1556 1557 return IsWithinLOSInMap(who); 1540 1558 } 1541 1559 … … 1819 1837 } 1820 1838 1839 Unit* Creature::SelectNearestTarget(float dist) const 1840 { 1841 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); 1842 Cell cell(p); 1843 cell.data.Part.reserved = ALL_DISTRICT; 1844 cell.SetNoCreate(); 1845 1846 Unit *target = NULL; 1847 1848 { 1849 Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); 1850 Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check); 1851 1852 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); 1853 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); 1854 1855 CellLock<GridReadGuard> cell_lock(cell, p); 1856 cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap()); 1857 cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap()); 1858 } 1859 1860 return target; 1861 } 1862 1821 1863 void Creature::CallAssistence() 1822 1864 { … … 2098 2140 } 2099 2141 2100 char const* Creature::GetScriptName() const 2101 { 2102 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; 2142 std::string Creature::GetScriptName() 2143 { 2144 return objmgr.GetScriptName(GetScriptId()); 2145 } 2146 2147 uint32 Creature::GetScriptId() 2148 { 2149 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; 2103 2150 } 2104 2151 -
trunk/src/game/Creature.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 206 206 uint32 MechanicImmuneMask; 207 207 uint32 flags_extra; 208 char const* ScriptName;208 uint32 ScriptID; 209 209 uint32 GetRandomValidModelId() const; 210 210 uint32 GetFirstValidModelId() const; 211 211 212 // helpers 212 213 SkillType GetRequiredLootSkill() const 213 214 { … … 219 220 return SKILL_SKINNING; // normal case 220 221 } 221 222 222 223 bool isTameable() const 223 224 { … … 426 427 bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } 427 428 bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } 429 bool isAggressive() const { return m_isAggressive; } 430 void SetAggressive(bool agg) { m_isAggressive = agg; } 428 431 ///// TODO RENAME THIS!!!!! 429 432 bool isCanTrainingOf(Player* player, bool msg) const; … … 499 502 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } 500 503 CreatureDataAddon const* GetCreatureAddon() const; 501 char const* GetScriptName() const; 504 505 std::string GetScriptName(); 506 uint32 GetScriptId(); 502 507 503 508 void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 ); … … 525 530 // overwrite WorldObject function for proper name localization 526 531 const char* GetNameForLocaleIdx(int32 locale_idx) const; 527 532 528 533 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState 529 534 … … 553 558 bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const; 554 559 bool IsWithinSightDist(Unit const* u) const; 560 bool canStartAttack(Unit const* u) const; 555 561 float GetAttackDistance(Unit const* pl) const; 556 562 563 Unit* SelectNearestTarget(float dist = 0) const; 557 564 void CallAssistence(); 558 565 void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } … … 634 641 bool m_isPet; // set only in Pet::Pet 635 642 bool m_isTotem; // set only in Totem::Totem 643 bool m_isAggressive; 636 644 void RegenerateMana(); 637 645 void RegenerateHealth(); -
trunk/src/game/CreatureAI.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/game/CreatureAIImpl.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 #ifndef CREATUREAIIMPL_H -
trunk/src/game/CreatureAIRegistry.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/game/CreatureAISelector.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/game/Formulas.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 30 30 inline uint32 hk_honor_at_level(uint32 level, uint32 count=1) 31 31 { 32 return (uint32) ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));32 return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); 33 33 } 34 34 } … … 81 81 inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content) 82 82 { 83 //TODO: need modifier for CONTENT_71_80 different from CONTENT_61_70? 83 84 const uint32 nBaseExp = content == CONTENT_1_60 ? 45 : 235; 84 85 if( mob_level >= pl_level ) -
trunk/src/game/GMTicketHandler.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 67 67 recv_data >> ticketText; 68 68 69 CharacterDatabase.escape_string(ticketText);70 71 69 if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 72 70 ticket->SetText(ticketText.c_str()); … … 106 104 sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2); 107 105 108 CharacterDatabase.escape_string(ticketText); 109 110 if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 106 if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 111 107 { 112 108 WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); -
trunk/src/game/GMTicketMgr.h
r272 r279 51 51 m_text = text ? text : ""; 52 52 m_lastUpdate = time(NULL); 53 CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid); 53 54 std::string escapedString = m_text; 55 CharacterDatabase.escape_string(escapedString); 56 CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", escapedString.c_str(), m_guid); 54 57 } 55 58 … … 63 66 CharacterDatabase.BeginTransaction(); 64 67 DeleteFromDB(); 65 CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText()); 68 69 std::string escapedString = m_text; 70 CharacterDatabase.escape_string(escapedString); 71 72 CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, escapedString.c_str()); 66 73 CharacterDatabase.CommitTransaction(); 67 74 } -
trunk/src/game/GameEvent.cpp
r272 r279 1504 1504 CharacterDatabase.PExecute("DELETE FROM game_event_save WHERE event_id = '%u'",event_id); 1505 1505 if(mGameEvent[event_id].nextstart) 1506 CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state, mGameEvent[event_id].nextstart);1506 CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart)); 1507 1507 else 1508 1508 CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u','0000-00-00 00:00:00')",event_id,mGameEvent[event_id].state); -
trunk/src/game/GameObject.cpp
r272 r279 1281 1281 { 1282 1282 trigger->setFaction(14); 1283 trigger->CastSpell(target, spell, true );1283 trigger->CastSpell(target, spell, true, 0, 0, target->GetGUID()); 1284 1284 } 1285 1285 //trigger->setDeathState(JUST_DIED); -
trunk/src/game/GameObject.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 358 358 } raw; 359 359 }; 360 char *ScriptName;360 uint32 ScriptId; 361 361 }; 362 362 -
trunk/src/game/GridNotifiers.h
r272 r279 699 699 // Creature checks 700 700 701 class InAttackDistanceFromAnyHostileCreatureCheck 702 { 703 public: 704 explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {} 705 bool operator()(Creature* u) 706 { 707 if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) 708 return true; 709 710 return false; 711 } 712 private: 713 Unit* const i_funit; 701 class NearestHostileUnitInAttackDistanceCheck 702 { 703 public: 704 explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : m_creature(creature) 705 { 706 m_range = (dist == 0 ? 9999 : dist); 707 m_force = (dist == 0 ? false : true); 708 } 709 bool operator()(Unit* u) 710 { 711 // TODO: addthreat for every enemy in range? 712 if(!m_creature->IsWithinDistInMap(u, m_range)) 713 return false; 714 715 if(m_force) 716 { 717 if(!m_creature->canAttack(u)) 718 return false; 719 } 720 else 721 { 722 if(!m_creature->canStartAttack(u)) 723 return false; 724 } 725 726 m_range = m_creature->GetDistance(u); 727 return true; 728 } 729 float GetLastRange() const { return m_range; } 730 private: 731 Creature const *m_creature; 732 float m_range; 733 bool m_force; 734 NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&); 714 735 }; 715 736 -
trunk/src/game/GridNotifiersImpl.h
r272 r279 73 73 74 74 // Creature AI reaction 75 if( !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))75 if(c->isAggressive() && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 76 76 { 77 77 if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() ) … … 82 82 inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) 83 83 { 84 if( !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))84 if(c1->isAggressive() && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 85 85 { 86 86 if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() ) … … 88 88 } 89 89 90 if( !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))90 if(c2->isAggressive() && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) 91 91 { 92 92 if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() ) -
trunk/src/game/Item.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 180 180 return true; 181 181 case ITEM_SUBCLASS_SOUL_CONTAINER: 182 if(!(pProto->BagFamily & BAG_FAMILY_MASK_S HARDS))182 if(!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS)) 183 183 return false; 184 184 return true; … … 248 248 Object::_Create( guidlow, 0, HIGHGUID_ITEM ); 249 249 250 Set UInt32Value(OBJECT_FIELD_ENTRY,itemid);250 SetEntry(itemid); 251 251 SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); 252 252 … … 430 430 ItemPrototype const *Item::GetProto() const 431 431 { 432 return objmgr.GetItemPrototype(Get UInt32Value(OBJECT_FIELD_ENTRY));432 return objmgr.GetItemPrototype(GetEntry()); 433 433 } 434 434 … … 763 763 { 764 764 // Better lost small time at check in comparison lost time at item save to DB. 765 if( GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET)==id && 766 GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration && 767 GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET)==charges ) 765 if((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) 768 766 return; 769 767 … … 776 774 void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) 777 775 { 778 if(Get UInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration)776 if(GetEnchantmentDuration(slot) == duration) 779 777 return; 780 778 … … 785 783 void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges) 786 784 { 785 if(GetEnchantmentCharges(slot) == charges) 786 return; 787 787 788 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges); 788 789 SetState(ITEM_CHANGED); … … 791 792 void Item::ClearEnchantment(EnchantmentSlot slot) 792 793 { 793 if(!Get UInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET))794 return; 795 796 for( int x=0;x<3;x++)797 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0);794 if(!GetEnchantmentId(slot)) 795 return; 796 797 for(uint8 x = 0; x < 3; ++x) 798 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0); 798 799 SetState(ITEM_CHANGED); 799 800 } -
trunk/src/game/Item.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 229 229 bool GemsFitSockets() const; 230 230 231 uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }232 231 uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); } 233 232 void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); } -
trunk/src/game/ItemEnchantmentMgr.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/game/ItemEnchantmentMgr.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/game/ItemHandler.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 314 314 if (il) 315 315 { 316 if (il->Name.size() > loc_idx&& !il->Name[loc_idx].empty())316 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) 317 317 Name = il->Name[loc_idx]; 318 if (il->Description.size() > loc_idx&& !il->Description[loc_idx].empty())318 if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty()) 319 319 Description = il->Description[loc_idx]; 320 320 } … … 361 361 data << pProto->Damage[i].DamageType; 362 362 } 363 364 // resistances (7) 363 365 data << pProto->Armor; 364 366 data << pProto->HolyRes; … … 368 370 data << pProto->ShadowRes; 369 371 data << pProto->ArcaneRes; 372 370 373 data << pProto->Delay; 371 374 data << pProto->Ammo_type; 372 373 data << (float)pProto->RangedModRange; 375 data << pProto->RangedModRange; 376 374 377 for(int s = 0; s < 5; s++) 375 378 { … … 977 980 if (il) 978 981 { 979 if (il->Name.size() > loc_idx&& !il->Name[loc_idx].empty())982 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) 980 983 Name = il->Name[loc_idx]; 981 984 } … … 1028 1031 } 1029 1032 1030 if(item==gift) // not poss ible with pacjket from real client1033 if(item==gift) // not possable with pacjket from real client 1031 1034 { 1032 1035 _player->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, NULL ); … … 1073 1076 CharacterDatabase.BeginTransaction(); 1074 1077 CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS)); 1075 item->Set UInt32Value(OBJECT_FIELD_ENTRY, gift->GetUInt32Value(OBJECT_FIELD_ENTRY));1078 item->SetEntry(gift->GetEntry()); 1076 1079 1077 1080 switch (item->GetEntry()) 1078 1081 { 1079 case 5042: item->Set UInt32Value(OBJECT_FIELD_ENTRY,5043); break;1080 case 5048: item->Set UInt32Value(OBJECT_FIELD_ENTRY,5044); break;1081 case 17303: item->Set UInt32Value(OBJECT_FIELD_ENTRY,17302); break;1082 case 17304: item->Set UInt32Value(OBJECT_FIELD_ENTRY,17305); break;1083 case 17307: item->Set UInt32Value(OBJECT_FIELD_ENTRY,17308); break;1084 case 21830: item->Set UInt32Value(OBJECT_FIELD_ENTRY,21831); break;1082 case 5042: item->SetEntry( 5043); break; 1083 case 5048: item->SetEntry( 5044); break; 1084 case 17303: item->SetEntry(17302); break; 1085 case 17304: item->SetEntry(17305); break; 1086 case 17307: item->SetEntry(17308); break; 1087 case 21830: item->SetEntry(21831); break; 1085 1088 } 1086 1089 item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); -
trunk/src/game/ItemPrototype.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 79 79 NO_BIND = 0, 80 80 BIND_WHEN_PICKED_UP = 1, 81 BIND_WHEN_EQUIP PED = 2,81 BIND_WHEN_EQUIPED = 2, 82 82 BIND_WHEN_USE = 3, 83 83 BIND_QUEST_ITEM = 4, … … 100 100 ITEM_FLAGS_USEABLE_IN_ARENA = 0x00200000, 101 101 ITEM_FLAGS_THROWABLE = 0x00400000, // not used in game for check trow possibility, only for item in game tooltip 102 ITEM_FLAGS_SPECIALUSE = 0x00800000 // last used flag in 2.3.0 102 ITEM_FLAGS_SPECIALUSE = 0x00800000, // last used flag in 2.3.0 103 ITEM_FLAGS_BOA = 0x08000000, // bind on account 104 ITEM_FLAGS_MILLABLE = 0x20000000 103 105 }; 104 106 … … 107 109 BAG_FAMILY_MASK_ARROWS = 0x00000001, 108 110 BAG_FAMILY_MASK_BULLETS = 0x00000002, 109 BAG_FAMILY_MASK_S HARDS= 0x00000004,111 BAG_FAMILY_MASK_SOUL_SHARDS = 0x00000004, 110 112 BAG_FAMILY_MASK_LEATHERWORKING_SUPP = 0x00000008, 111 BAG_FAMILY_MASK_ UNUSED = 0x00000010, // not used currently113 BAG_FAMILY_MASK_INSCRIPTION_SUPP = 0x00000010, 112 114 BAG_FAMILY_MASK_HERBS = 0x00000020, 113 115 BAG_FAMILY_MASK_ENCHANTING_SUPP = 0x00000040, … … 117 119 BAG_FAMILY_MASK_MINING_SUPP = 0x00000400, 118 120 BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT = 0x00000800, 119 BAG_FAMILY_MASK_VANITY_PETS = 0x00001000 120 }; 121 122 /* TODO: Not entirely positive on need for this?? 123 enum SOCKET_CONTENT (); 124 */ 121 BAG_FAMILY_MASK_VANITY_PETS = 0x00001000, 122 BAG_FAMILY_MASK_CURRENCY_TOKENS = 0x00002000, 123 BAG_FAMILY_MASK_QUEST_ITEMS = 0x00004000 124 }; 125 125 126 126 enum SocketColor … … 276 276 }; 277 277 278 #define MAX_ITEM_SUBCLASS_ARMOR 10278 #define MAX_ITEM_SUBCLASS_ARMOR 10 279 279 280 280 enum ItemSubclassReagent … … 390 390 391 391 #define MAX_ITEM_SUBCLASS_JUNK 6 392 393 enum ItemSubclassGlyph 394 { 395 ITEM_SUBCLASS_GLYPH_WARRIOR = 1, 396 ITEM_SUBCLASS_GLYPH_PALADIN = 2, 397 ITEM_SUBCLASS_GLYPH_HUNTER = 3, 398 ITEM_SUBCLASS_GLYPH_ROGUE = 4, 399 ITEM_SUBCLASS_GLYPH_PRIEST = 5, 400 ITEM_SUBCLASS_GLYPH_DEATH_KNIGHT = 6, 401 ITEM_SUBCLASS_GLYPH_SHAMAN = 7, 402 ITEM_SUBCLASS_GLYPH_MAGE = 8, 403 ITEM_SUBCLASS_GLYPH_WARLOCK = 9, 404 ITEM_SUBCLASS_GLYPH_DRUID = 11 405 }; 406 407 #define MAX_ITEM_SUBCLASS_GLYPH 12 392 408 393 409 const uint32 MaxItemSubclassValues[MAX_ITEM_CLASS] = … … 525 541 uint32 RequiredDisenchantSkill; 526 542 float ArmorDamageModifier; 527 char* ScriptName;543 uint32 ScriptId; 528 544 uint32 DisenchantID; 529 545 uint32 FoodType; -
trunk/src/game/Level2.cpp
r272 r279 2362 2362 // Check 2363 2363 // Remember: "show" must also be the name of a column! 2364 if( (show != "emote") && (show != "spell") && (show != "text 1") && (show != "text2")2365 && (show != "text 3") && (show != "text4") && (show != "text5")2364 if( (show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2") 2365 && (show != "textid3") && (show != "textid4") && (show != "textid5") 2366 2366 && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") 2367 2367 && (show != "model1") && (show != "model2") && (show != "orientation")) … … 2703 2703 PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); 2704 2704 SetSentErrorMessage(true); 2705 return false; 2706 } 2707 2708 // set in game textids not supported 2709 if( show == "textid1" || show == "textid2" || show == "textid3" || 2710 show == "textid4" || show == "textid5" ) 2711 { 2705 2712 return false; 2706 2713 } … … 2843 2850 2844 2851 QueryResult *result = 2845 WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text 1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u",2852 WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u", 2846 2853 target->GetGUIDLow() ); 2847 2854 if(!result) … … 2855 2862 PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); 2856 2863 2857 result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text 1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )",2864 result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", 2858 2865 target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); 2859 2866 if(!result) … … 2872 2879 uint32 emote = fields[3].GetUInt32(); 2873 2880 uint32 spell = fields[4].GetUInt32(); 2874 const char * text1 = fields[5].GetString(); 2875 const char * text2 = fields[6].GetString(); 2876 const char * text3 = fields[7].GetString(); 2877 const char * text4 = fields[8].GetString(); 2878 const char * text5 = fields[9].GetString(); 2881 uint32 textid[MAX_WAYPOINT_TEXT]; 2882 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 2883 textid[i] = fields[5+i].GetUInt32(); 2879 2884 uint32 model1 = fields[10].GetUInt32(); 2880 2885 uint32 model2 = fields[11].GetUInt32(); … … 2889 2894 PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); 2890 2895 PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); 2891 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1); 2892 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2); 2893 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3); 2894 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4); 2895 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5); 2896 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 2897 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetTrinityString(textid[i]) : "")); 2896 2898 2897 2899 }while( result->NextRow() ); … … 3214 3216 3215 3217 QueryResult *result = WorldDatabase.PQuery( 3216 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14153217 "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text 1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );3218 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3219 "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); 3218 3220 3219 3221 if (!result) … … 3232 3234 3233 3235 outfile << "INSERT INTO creature_movement "; 3234 outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text 1, text2, text3, text4, text5 ) VALUES ";3236 outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5 ) VALUES "; 3235 3237 3236 3238 outfile << "( "; … … 3257 3259 outfile << fields[9].GetUInt32(); // spell 3258 3260 outfile << ", "; 3259 const char *tmpChar = fields[10].GetString(); 3260 if( !tmpChar ) 3261 { 3262 outfile << "NULL"; // text1 3263 } 3264 else 3265 { 3266 outfile << "'"; 3267 outfile << tmpChar; // text1 3268 outfile << "'"; 3269 } 3261 outfile << fields[10].GetUInt32(); // textid1 3270 3262 outfile << ", "; 3271 tmpChar = fields[11].GetString(); 3272 if( !tmpChar ) 3273 { 3274 outfile << "NULL"; // text2 3275 } 3276 else 3277 { 3278 outfile << "'"; 3279 outfile << tmpChar; // text2 3280 outfile << "'"; 3281 } 3263 outfile << fields[11].GetUInt32(); // textid2 3282 3264 outfile << ", "; 3283 tmpChar = fields[12].GetString(); 3284 if( !tmpChar ) 3285 { 3286 outfile << "NULL"; // text3 3287 } 3288 else 3289 { 3290 outfile << "'"; 3291 outfile << tmpChar; // text3 3292 outfile << "'"; 3293 } 3265 outfile << fields[12].GetUInt32(); // textid3 3294 3266 outfile << ", "; 3295 tmpChar = fields[13].GetString(); 3296 if( !tmpChar ) 3297 { 3298 outfile << "NULL"; // text4 3299 } 3300 else 3301 { 3302 outfile << "'"; 3303 outfile << tmpChar; // text4 3304 outfile << "'"; 3305 } 3267 outfile << fields[13].GetUInt32(); // textid4 3306 3268 outfile << ", "; 3307 tmpChar = fields[14].GetString(); 3308 if( !tmpChar ) 3309 { 3310 outfile << "NULL"; // text5 3311 } 3312 else 3313 { 3314 outfile << "'"; 3315 outfile << tmpChar; // text5 3316 outfile << "'"; 3317 } 3269 outfile << fields[14].GetUInt32(); // textid5 3318 3270 outfile << ");\n "; 3319 3271 -
trunk/src/game/Level3.cpp
r272 r279 136 136 HandleReloadSpellScriptsCommand("a"); 137 137 SendGlobalSysMessage("DB tables `*_scripts` reloaded."); 138 HandleReloadDbScriptStringCommand("a"); 138 139 return true; 139 140 } … … 599 600 SendGlobalSysMessage("DB table `spell_scripts` reloaded."); 600 601 602 return true; 603 } 604 605 bool ChatHandler::HandleReloadDbScriptStringCommand(const char* arg) 606 { 607 sLog.outString( "Re-Loading Script strings from `db_script_string`..."); 608 objmgr.LoadDbScriptStrings(); 609 SendGlobalSysMessage("DB table `db_script_string` reloaded."); 601 610 return true; 602 611 } … … 1768 1777 // search highest talent rank 1769 1778 uint32 spellid = 0; 1770 for(int rank = 4; rank >= 0; --rank) 1779 int rank = 4; 1780 for(; rank >= 0; --rank) 1771 1781 { 1772 1782 if(talentInfo->RankID[rank]!=0) … … 4646 4656 } 4647 4657 4648 bool ChatHandler::HandleShutDownCommand(const char* args) 4658 bool ChatHandler::HandleServerShutDownCancelCommand(const char* args) 4659 { 4660 sWorld.ShutdownCancel(); 4661 return true; 4662 } 4663 4664 bool ChatHandler::HandleServerShutDownCommand(const char* args) 4649 4665 { 4650 4666 if(!*args) 4651 4667 return false; 4652 4668 4653 if(std::string(args)=="cancel") 4654 { 4655 sWorld.ShutdownCancel(); 4669 char* time_str = strtok ((char*) args, " "); 4670 char* exitcode_str = strtok (NULL, ""); 4671 4672 int32 time = atoi (time_str); 4673 4674 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4675 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4676 return false; 4677 4678 if (exitcode_str) 4679 { 4680 int32 exitcode = atoi (exitcode_str); 4681 4682 // Handle atoi() errors 4683 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4684 return false; 4685 4686 // Exit code should be in range of 0-125, 126-255 is used 4687 // in many shells for their own return codes and code > 255 4688 // is not supported in many others 4689 if (exitcode < 0 || exitcode > 125) 4690 return false; 4691 4692 sWorld.ShutdownServ (time, 0, exitcode); 4656 4693 } 4657 4694 else 4658 { 4659 int32 time = atoi(args); 4660 4661 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4662 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4695 sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE); 4696 return true; 4697 } 4698 4699 bool ChatHandler::HandleServerRestartCommand(const char* args) 4700 { 4701 if(!*args) 4702 return false; 4703 4704 char* time_str = strtok ((char*) args, " "); 4705 char* exitcode_str = strtok (NULL, ""); 4706 4707 int32 time = atoi (time_str); 4708 4709 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4710 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4711 return false; 4712 4713 if (exitcode_str) 4714 { 4715 int32 exitcode = atoi (exitcode_str); 4716 4717 // Handle atoi() errors 4718 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4663 4719 return false; 4664 4720 4665 sWorld.ShutdownServ(time); 4666 } 4667 return true; 4668 } 4669 4670 bool ChatHandler::HandleRestartCommand(const char* args) 4721 // Exit code should be in range of 0-125, 126-255 is used 4722 // in many shells for their own return codes and code > 255 4723 // is not supported in many others 4724 if (exitcode < 0 || exitcode > 125) 4725 return false; 4726 4727 sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode); 4728 } 4729 else 4730 sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE); 4731 return true; 4732 } 4733 4734 bool ChatHandler::HandleServerIdleRestartCommand(const char* args) 4671 4735 { 4672 4736 if(!*args) 4673 4737 return false; 4674 4738 4675 if(std::string(args)=="cancel") 4676 { 4677 sWorld.ShutdownCancel(); 4739 char* time_str = strtok ((char*) args, " "); 4740 char* exitcode_str = strtok (NULL, ""); 4741 4742 int32 time = atoi (time_str); 4743 4744 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4745 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4746 return false; 4747 4748 if (exitcode_str) 4749 { 4750 int32 exitcode = atoi (exitcode_str); 4751 4752 // Handle atoi() errors 4753 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4754 return false; 4755 4756 // Exit code should be in range of 0-125, 126-255 is used 4757 // in many shells for their own return codes and code > 255 4758 // is not supported in many others 4759 if (exitcode < 0 || exitcode > 125) 4760 return false; 4761 4762 sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode); 4678 4763 } 4679 4764 else 4680 { 4681 int32 time = atoi(args); 4682 4683 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4684 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4765 sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE); 4766 return true; 4767 } 4768 4769 bool ChatHandler::HandleServerIdleShutDownCommand(const char* args) 4770 { 4771 if(!*args) 4772 return false; 4773 4774 char* time_str = strtok ((char*) args, " "); 4775 char* exitcode_str = strtok (NULL, ""); 4776 4777 int32 time = atoi (time_str); 4778 4779 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4780 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4781 return false; 4782 4783 if (exitcode_str) 4784 { 4785 int32 exitcode = atoi (exitcode_str); 4786 4787 // Handle atoi() errors 4788 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4685 4789 return false; 4686 4790 4687 sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); 4688 } 4689 return true; 4690 } 4691 4692 bool ChatHandler::HandleIdleRestartCommand(const char* args) 4693 { 4694 if(!*args) 4695 return false; 4696 4697 if(std::string(args)=="cancel") 4698 { 4699 sWorld.ShutdownCancel(); 4791 // Exit code should be in range of 0-125, 126-255 is used 4792 // in many shells for their own return codes and code > 255 4793 // is not supported in many others 4794 if (exitcode < 0 || exitcode > 125) 4795 return false; 4796 4797 sWorld.ShutdownServ (time, SHUTDOWN_MASK_IDLE, exitcode); 4700 4798 } 4701 4799 else 4702 { 4703 int32 time = atoi(args); 4704 4705 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4706 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4707 return false; 4708 4709 sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); 4710 } 4711 return true; 4712 } 4713 4714 bool ChatHandler::HandleIdleShutDownCommand(const char* args) 4715 { 4716 if(!*args) 4717 return false; 4718 4719 if(std::string(args)=="cancel") 4720 { 4721 sWorld.ShutdownCancel(); 4722 } 4723 else 4724 { 4725 int32 time = atoi(args); 4726 4727 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4728 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4729 return false; 4730 4731 sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); 4732 } 4800 sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE); 4733 4801 return true; 4734 4802 } -
trunk/src/game/Mail.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 188 188 return; 189 189 } 190 191 190 if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION)) 192 191 { … … 195 194 } 196 195 197 if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))198 {199 pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD);200 return;201 }196 if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 197 { 198 pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD); 199 return; 200 } 202 201 } 203 202 } -
trunk/src/game/Map.cpp
r272 r279 36 36 #include "ScriptCalls.h" 37 37 #include "Group.h" 38 #include "MapRefManager.h" 38 39 39 40 #include "MapInstanced.h" … … 450 451 bool Map::Add(Player *player) 451 452 { 453 player->GetMapRef().link(this, player); 454 452 455 player->SetInstanceId(GetInstanceId()); 453 456 … … 594 597 void Map::Update(const uint32 &t_diff) 595 598 { 599 // TODO: need have an active object list for every map 600 601 /*resetMarkedCells(); 602 603 Trinity::ObjectUpdater updater(t_diff); 604 // for creature 605 TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater); 606 // for pets 607 TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater); 608 609 for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 610 { 611 Player* plr = iter->getSource(); 612 if(!plr->IsInWorld()) 613 continue; 614 615 CellPair standing_cell(Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY())); 616 617 // Check for correctness of standing_cell, it also avoids problems with update_cell 618 if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 619 continue; 620 621 // the overloaded operators handle range checking 622 // so ther's no need for range checking inside the loop 623 CellPair begin_cell(standing_cell), end_cell(standing_cell); 624 begin_cell << 1; begin_cell -= 1; // upper left 625 end_cell >> 1; end_cell += 1; // lower right 626 627 for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) 628 { 629 for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) 630 { 631 // marked cells are those that have been visited 632 // don't visit the same cell twice 633 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; 634 if(!isCellMarked(cell_id)) 635 { 636 markCell(cell_id); 637 CellPair pair(x,y); 638 Cell cell(pair); 639 cell.data.Part.reserved = CENTER_DISTRICT; 640 cell.SetNoCreate(); 641 CellLock<NullGuard> cell_lock(cell, pair); 642 cell_lock->Visit(cell_lock, grid_object_update, *this); 643 cell_lock->Visit(cell_lock, world_object_update, *this); 644 } 645 } 646 } 647 }*/ 648 596 649 // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! 597 650 // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended … … 611 664 void Map::Remove(Player *player, bool remove) 612 665 { 666 player->GetMapRef().unlink(); 613 667 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 614 668 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) … … 910 964 911 965 { 912 if(!pForce && ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, i_id, i_InstanceId) )966 if(!pForce && PlayersNearGrid(x, y) ) 913 967 return false; 914 968 … … 1419 1473 } 1420 1474 1475 uint32 Map::GetPlayersCountExceptGMs() const 1476 { 1477 uint32 count = 0; 1478 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1479 if(!itr->getSource()->isGameMaster()) 1480 ++count; 1481 return count; 1482 } 1483 1484 void Map::SendToPlayers(WorldPacket const* data) const 1485 { 1486 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1487 itr->getSource()->GetSession()->SendPacket(data); 1488 } 1489 1490 bool Map::PlayersNearGrid(uint32 x, uint32 y) const 1491 { 1492 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); 1493 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); 1494 cell_min << 2; 1495 cell_min -= 2; 1496 cell_max >> 2; 1497 cell_max += 2; 1498 1499 for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 1500 { 1501 Player* plr = iter->getSource(); 1502 1503 CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); 1504 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 1505 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) 1506 return true; 1507 } 1508 1509 return false; 1510 } 1511 1421 1512 template void Map::Add(Corpse *); 1422 1513 template void Map::Add(Creature *); … … 1454 1545 bool InstanceMap::CanEnter(Player *player) 1455 1546 { 1456 if( std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end())1547 if(player->GetMapRef().getTarget() == this) 1457 1548 { 1458 1549 sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); … … 1571 1662 SetResetSchedule(false); 1572 1663 1573 i_Players.push_back(player);1574 1664 player->SendInitWorldStates(); 1575 1665 sLog.outDetail("MAP: Player '%s' entered the instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); … … 1596 1686 { 1597 1687 sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); 1598 i_Players.remove(player);1599 1688 SetResetSchedule(true); 1600 if(!m_unloadTimer && i_Players.empty()) 1689 //if last player set unload timer 1690 if(!m_unloadTimer && m_mapRefManager.getSize() == 1) 1601 1691 m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); 1602 1692 Map::Remove(player, remove); … … 1625 1715 if (mInstance) 1626 1716 { 1627 i_script = mInstance->script;1717 i_script_id = mInstance->script_id; 1628 1718 i_data = Script->CreateInstanceData(this); 1629 1719 } … … 1642 1732 if(data) 1643 1733 { 1644 sLog.outDebug("Loading instance data for `%s` with id %u", i_script.c_str(), i_InstanceId);1734 sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId); 1645 1735 i_data->Load(data); 1646 1736 } … … 1650 1740 else 1651 1741 { 1652 sLog.outDebug("New instance data, \"%s\" ,initialized!", i_script.c_str());1742 sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id)); 1653 1743 i_data->Initialize(); 1654 1744 } … … 1663 1753 // the instance must be deleted from the DB by InstanceSaveManager 1664 1754 1665 if( !i_Players.empty())1755 if(HavePlayers()) 1666 1756 { 1667 1757 if(method == INSTANCE_RESET_ALL) 1668 1758 { 1669 1759 // notify the players to leave the instance so it can be reset 1670 for( PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1671 (*itr)->SendResetFailedNotify(GetId());1760 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1761 itr->getSource()->SendResetFailedNotify(GetId()); 1672 1762 } 1673 1763 else … … 1676 1766 { 1677 1767 // set the homebind timer for players inside (1 minute) 1678 for( PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1679 (*itr)->m_InstanceValid = false;1768 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1769 itr->getSource()->m_InstanceValid = false; 1680 1770 } 1681 1771 … … 1693 1783 } 1694 1784 1695 return i_Players.empty(); 1696 } 1697 1698 uint32 InstanceMap::GetPlayersCountExceptGMs() const 1699 { 1700 uint32 count = 0; 1701 for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1702 if(!(*itr)->isGameMaster()) 1703 ++count; 1704 return count; 1785 return m_mapRefManager.isEmpty(); 1705 1786 } 1706 1787 … … 1716 1797 Group *group = player->GetGroup(); 1717 1798 // group members outside the instance group don't get bound 1718 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1719 { 1720 if(*itr) 1721 { 1722 // players inside an instance cannot be bound to other instances 1723 // some players may already be permanently bound, in this case nothing happens 1724 InstancePlayerBind *bind = (*itr)->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 1725 if(!bind || !bind->perm) 1726 { 1727 (*itr)->BindToInstance(save, true); 1728 WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 1729 data << uint32(0); 1730 (*itr)->GetSession()->SendPacket(&data); 1731 } 1732 1733 // if the leader is not in the instance the group will not get a perm bind 1734 if(group && group->GetLeaderGUID() == (*itr)->GetGUID()) 1735 group->BindToInstance(save, true); 1736 } 1799 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1800 { 1801 Player* plr = itr->getSource(); 1802 // players inside an instance cannot be bound to other instances 1803 // some players may already be permanently bound, in this case nothing happens 1804 InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 1805 if(!bind || !bind->perm) 1806 { 1807 plr->BindToInstance(save, true); 1808 WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 1809 data << uint32(0); 1810 plr->GetSession()->SendPacket(&data); 1811 } 1812 1813 // if the leader is not in the instance the group will not get a perm bind 1814 if(group && group->GetLeaderGUID() == plr->GetGUID()) 1815 group->BindToInstance(save, true); 1737 1816 } 1738 1817 } … … 1746 1825 void InstanceMap::UnloadAll(bool pForce) 1747 1826 { 1748 if( !i_Players.empty())1827 if(HavePlayers()) 1749 1828 { 1750 1829 sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!"); 1751 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1752 if(*itr) (*itr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); 1830 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1831 { 1832 Player* plr = itr->getSource(); 1833 plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 1834 } 1753 1835 } 1754 1836 … … 1759 1841 } 1760 1842 1761 void InstanceMap::SendResetWarnings(uint32 timeLeft) 1762 { 1763 for( PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1764 (*itr)->SendInstanceResetWarning(GetId(), timeLeft);1843 void InstanceMap::SendResetWarnings(uint32 timeLeft) const 1844 { 1845 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1846 itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft); 1765 1847 } 1766 1848 … … 1770 1852 // the reset time is only scheduled when there are no payers inside 1771 1853 // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled 1772 if( i_Players.empty() && !IsRaid() && !IsHeroic())1854 if(!HavePlayers() && !IsRaid() && !IsHeroic()) 1773 1855 { 1774 1856 InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); … … 1778 1860 } 1779 1861 1780 void InstanceMap::SendToPlayers(WorldPacket const* data) const1781 {1782 for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)1783 (*itr)->GetSession()->SendPacket(data);1784 }1785 1786 1862 /* ******* Battleground Instance Maps ******* */ 1787 1863 … … 1797 1873 bool BattleGroundMap::CanEnter(Player * player) 1798 1874 { 1799 if( std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end())1875 if(player->GetMapRef().getTarget() == this) 1800 1876 { 1801 1877 sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow()); … … 1818 1894 if(!CanEnter(player)) 1819 1895 return false; 1820 i_Players.push_back(player);1821 1896 // reset instance validity, battleground maps do not homebind 1822 1897 player->m_InstanceValid = true; … … 1828 1903 { 1829 1904 sLog.outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); 1830 i_Players.remove(player);1831 1905 Map::Remove(player, remove); 1832 1906 } … … 1839 1913 void BattleGroundMap::UnloadAll(bool pForce) 1840 1914 { 1841 while(!i_Players.empty()) 1842 { 1843 PlayerList::iterator itr = i_Players.begin(); 1844 Player * plr = *itr; 1845 if(plr) (plr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); 1915 while(HavePlayers()) 1916 { 1917 Player * plr = m_mapRefManager.getFirst()->getSource(); 1918 if(plr) (plr)->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 1846 1919 // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator. 1847 1920 // just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop 1848 1921 // note that this remove is not needed if the code works well in other places 1849 i_Players.remove(plr);1922 plr->GetMapRef().unlink(); 1850 1923 } 1851 1924 -
trunk/src/game/Map.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 34 34 #include "SharedDefines.h" 35 35 #include "GameSystem/GridRefManager.h" 36 #include "MapRefManager.h" 36 37 37 38 #include <bitset> … … 105 106 float startLocZ; 106 107 float startLocO; 107 char const* script;108 uint32 script_id; 108 109 }; 109 110 … … 127 128 class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ZThread::Mutex> 128 129 { 130 friend class MapReference; 129 131 public: 130 132 Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); … … 238 240 GameObject* GetGameObjectInMap(uint64 guid); 239 241 242 bool HavePlayers() const { return !m_mapRefManager.isEmpty(); } 243 uint32 GetPlayersCountExceptGMs() const; 244 bool PlayersNearGrid(uint32 x,uint32 y) const; 245 246 void SendToPlayers(WorldPacket const* data) const; 247 248 typedef MapRefManager PlayerList; 249 PlayerList const& GetPlayers() const { return m_mapRefManager; } 240 250 template<class T> void SwitchGridContainers(T* obj, bool active); 241 251 private: … … 287 297 uint32 m_unloadTimer; 288 298 299 MapRefManager m_mapRefManager; 289 300 private: 290 301 typedef GridReadGuard ReadGuard; … … 326 337 { 327 338 public: 328 typedef std::list<Player *> PlayerList; // online players only329 330 339 InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); 331 340 ~InstanceMap(); … … 335 344 void CreateInstanceData(bool load); 336 345 bool Reset(uint8 method); 337 std::string GetScript() { return i_script; }346 uint32 GetScriptId() { return i_script_id; } 338 347 InstanceData* GetInstanceData() { return i_data; } 339 348 void PermBindAllPlayers(Player *player); 340 PlayerList const& GetPlayers() const { return i_Players;}341 void SendToPlayers(WorldPacket const* data) const;342 349 time_t GetResetTime(); 343 350 void UnloadAll(bool pForce); 344 351 bool CanEnter(Player* player); 345 uint32 GetPlayersCountExceptGMs() const; 346 uint32 HavePlayers() const { return !i_Players.empty(); } 347 void SendResetWarnings(uint32 timeLeft); 352 void SendResetWarnings(uint32 timeLeft) const; 348 353 void SetResetSchedule(bool on); 349 354 private: … … 351 356 bool m_unloadWhenEmpty; 352 357 InstanceData* i_data; 353 std::string i_script; 354 // only online players that are inside the instance currently 355 // TODO ? - use the grid instead to access the players 356 PlayerList i_Players; 358 uint32 i_script_id; 357 359 }; 358 360 … … 360 362 { 361 363 public: 362 typedef std::list<Player *> PlayerList; // online players only363 364 364 BattleGroundMap(uint32 id, time_t, uint32 InstanceId); 365 365 ~BattleGroundMap(); … … 370 370 void SetUnload(); 371 371 void UnloadAll(bool pForce); 372 private:373 PlayerList i_Players;374 372 }; 375 373 -
trunk/src/game/MapInstanced.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 27 27 #include "World.h" 28 28 29 MapInstanced::MapInstanced(uint32 id, time_t expiry , uint32 aInstanceId) : Map(id, expiry, 0, 0)29 MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0) 30 30 { 31 31 // initialize instanced maps list … … 262 262 m_InstancedMaps.erase(itr++); 263 263 } 264 -
trunk/src/game/MapInstanced.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 31 31 typedef UNORDERED_MAP< uint32, Map* > InstancedMaps; 32 32 33 MapInstanced(uint32 id, time_t , uint32 aInstanceId);33 MapInstanced(uint32 id, time_t expiry); 34 34 ~MapInstanced() {} 35 35 -
trunk/src/game/MapManager.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 112 112 if (entry && entry->Instanceable()) 113 113 { 114 m = new MapInstanced(id, i_gridCleanUpDelay , 0);114 m = new MapInstanced(id, i_gridCleanUpDelay); 115 115 } 116 116 else … … 223 223 } 224 224 225 void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId , uint8 mode)225 void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) 226 226 { 227 227 Map *m = _GetBaseMap(mapid); … … 246 246 if( !i_timer.Passed() ) 247 247 return; 248 249 ObjectAccessor::Instance().UpdatePlayers(i_timer.GetCurrent()); 248 250 249 251 for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) … … 337 339 for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr) 338 340 if(mitr->second->IsDungeon()) 339 ret += ((InstanceMap*)mitr->second)->GetPlayers(). size();341 ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize(); 340 342 } 341 343 return ret; -
trunk/src/game/MapManager.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 28 28 #include "Map.h" 29 29 #include "GridStates.h" 30 30 31 class Transport; 31 32 … … 45 46 // only const version for outer users 46 47 Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); } 47 void DeleteInstance(uint32 mapid, uint32 instanceId , uint8 mode);48 void DeleteInstance(uint32 mapid, uint32 instanceId); 48 49 49 50 inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const -
trunk/src/game/NPCHandler.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 223 223 TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); 224 224 if(!trainer_spells) 225 return; 225 return; 226 226 227 227 // not found, cheat? … … 340 340 if(!code.empty()) 341 341 { 342 343 342 if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str())) 344 343 unit->OnGossipSelect (_player, option); 345 344 } 346 345 else 347 348 346 { 349 347 if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option))) 350 unit->OnGossipSelect (_player, option);348 unit->OnGossipSelect (_player, option); 351 349 } 352 350 } … … 378 376 void WorldSession::SendSpiritResurrect() 379 377 { 380 _player->ResurrectPlayer(0.5f, false,true);378 _player->ResurrectPlayer(0.5f, true); 381 379 382 380 _player->DurabilityLossAll(0.25f,true); -
trunk/src/game/ObjectAccessor.cpp
r272 r279 143 143 { 144 144 Creature * ret = GetObjectInWorld(guid, (Creature*)NULL); 145 if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL; 145 if(!ret) 146 return NULL; 147 148 if(ret->GetMapId() != u.GetMapId()) 149 return NULL; 150 151 if(ret->GetInstanceId() != u.GetInstanceId()) 152 return NULL; 153 146 154 return ret; 147 155 } … … 249 257 250 258 void 251 ObjectAccessor::_update()252 {253 UpdateDataMapType update_players;254 {255 Guard guard(i_updateGuard);256 while(!i_objects.empty())257 {258 Object* obj = *i_objects.begin();259 i_objects.erase(i_objects.begin());260 if (!obj)261 continue;262 _buildUpdateObject(obj, update_players);263 obj->ClearUpdateMask(false);264 }265 }266 267 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000268 for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)269 {270 iter->second.BuildPacket(&packet);271 iter->first->GetSession()->SendPacket(&packet);272 packet.clear(); // clean the string273 }274 }275 276 void277 259 ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) 278 260 { … … 362 344 TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); 363 345 CellLock<GridReadGuard> cell_lock(cell, p); 364 cell_lock->Visit(cell_lock, player_notifier, * MapManager::Instance().GetMap(obj->GetMapId(), obj));346 cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap()); 365 347 } 366 348 … … 520 502 ObjectAccessor::Update(uint32 diff) 521 503 { 522 { 504 505 { 506 //Player update now in MapManager -> UpdatePlayers 507 /* 523 508 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 524 509 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); … … 529 514 iter->second->Update(diff); 530 515 } 531 } 532 516 }*/ 517 518 // TODO: move this to Map::Update 533 519 // clone the active object list, because update might remove from it 534 520 std::set<WorldObject *> activeobjects(i_activeobjects); … … 591 577 } 592 578 593 _update(); 579 UpdateDataMapType update_players; 580 { 581 Guard guard(i_updateGuard); 582 while(!i_objects.empty()) 583 { 584 Object* obj = *i_objects.begin(); 585 i_objects.erase(i_objects.begin()); 586 if (!obj) 587 continue; 588 _buildUpdateObject(obj, update_players); 589 obj->ClearUpdateMask(false); 590 } 591 } 592 593 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 594 for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) 595 { 596 iter->second.BuildPacket(&packet); 597 iter->first->GetSession()->SendPacket(&packet); 598 packet.clear(); // clean the string 599 } 600 } 601 602 void 603 ObjectAccessor::UpdatePlayers(uint32 diff) 604 { 605 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 606 for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) 607 if(iter->second->IsInWorld()) 608 iter->second->Update(diff); 594 609 } 595 610 … … 678 693 Cell cell(p); 679 694 680 MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p);695 obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 681 696 } 682 697 … … 685 700 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 686 701 Cell cell(p); 687 Map* m = MapManager::Instance().GetMap(player->GetMapId(),player);702 Map* m = player->GetMap(); 688 703 689 704 m->UpdatePlayerVisibility(player,cell,p); -
trunk/src/game/ObjectAccessor.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 187 187 188 188 void Update(uint32 diff); 189 void UpdatePlayers(uint32 diff); 189 190 190 191 Corpse* GetCorpseForPlayerGUID(uint64 guid); -
trunk/src/game/ObjectMgr.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 22 22 #include "Database/DatabaseEnv.h" 23 23 #include "Database/SQLStorage.h" 24 #include "Database/SQLStorageImpl.h" 24 25 25 26 #include "Log.h" … … 117 118 m_hiDoGuid = 1; 118 119 m_hiCorpseGuid = 1; 119 120 120 m_hiPetNumber = 1; 121 m_ItemTextId = 1; 122 m_mailid = 1; 123 m_auctionid = 1; 124 m_guildId = 1; 125 m_arenaTeamId = 1; 121 126 122 127 mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); … … 416 421 417 422 //prepare mail data... : 418 uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() );423 uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() ); 419 424 420 425 // set owner to bidder (to prevent delete item with sender char deleting) … … 467 472 sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); 468 473 469 uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() );474 uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() ); 470 475 471 476 WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); … … 499 504 sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); 500 505 501 uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() );506 uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() ); 502 507 503 508 uint32 profit = auction->bid + auction->deposit - auctionCut; … … 546 551 // will delete item or place to receiver mail list 547 552 WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); 548 549 553 } 550 554 // owner not found … … 564 568 void ObjectMgr::LoadCreatureLocales() 565 569 { 566 mCreatureLocaleMap.clear(); 567 570 mCreatureLocaleMap.clear(); // need for reload case 571 568 572 QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); 569 573 … … 624 628 sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); 625 629 } 626 630 627 631 void ObjectMgr::LoadNpcOptionLocales() 628 632 { … … 693 697 } 694 698 699 struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader> 700 { 701 template<class D> 702 void convert_from_str(uint32 field_pos, char *src, D &dst) 703 { 704 dst = D(objmgr.GetScriptId(src)); 705 } 706 }; 707 695 708 void ObjectMgr::LoadCreatureTemplates() 696 709 { 697 sCreatureStorage.Load(); 710 SQLCreatureLoader loader; 711 loader.Load(sCreatureStorage); 698 712 699 713 sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); … … 1513 1527 aItem->location = fields[11].GetUInt8(); 1514 1528 //check if sold item exists 1515 if ( this->GetAItem( aItem->item_guidlow ) )1529 if ( GetAItem( aItem->item_guidlow ) ) 1516 1530 { 1517 1531 GetAuctionsMap( aItem->location )->AddAuction(aItem); … … 1533 1547 void ObjectMgr::LoadItemLocales() 1534 1548 { 1535 mItemLocaleMap.clear(); 1536 1549 mItemLocaleMap.clear(); // need for reload case 1550 1537 1551 QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); 1538 1552 … … 1595 1609 } 1596 1610 1611 struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader> 1612 { 1613 template<class D> 1614 void convert_from_str(uint32 field_pos, char *src, D &dst) 1615 { 1616 dst = D(objmgr.GetScriptId(src)); 1617 } 1618 }; 1619 1597 1620 void ObjectMgr::LoadItemPrototypes() 1598 1621 { 1599 sItemStorage.Load (); 1622 SQLItemLoader loader; 1623 loader.Load(sItemStorage); 1600 1624 sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); 1601 1625 sLog.outString(); … … 2507 2531 if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) 2508 2532 continue; 2509 2533 2510 2534 // skip expansion classes if not playing with expansion 2511 2535 if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT) … … 3556 3580 void ObjectMgr::LoadQuestLocales() 3557 3581 { 3558 mQuestLocaleMap.clear(); 3582 mQuestLocaleMap.clear(); // need for reload case 3559 3583 3560 3584 QueryResult *result = WorldDatabase.Query("SELECT entry," … … 3750 3774 scripts.clear(); // need for reload support 3751 3775 3752 QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,data text, x, y, z, o FROM %s", tablename );3776 QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename ); 3753 3777 3754 3778 uint32 count = 0; … … 3772 3796 Field *fields = result->Fetch(); 3773 3797 ScriptInfo tmp; 3774 tmp.id = fields[0].GetUInt32();3775 tmp.delay = fields[1].GetUInt32();3776 tmp.command = fields[2].GetUInt32();3777 tmp.datalong = fields[3].GetUInt32();3798 tmp.id = fields[0].GetUInt32(); 3799 tmp.delay = fields[1].GetUInt32(); 3800 tmp.command = fields[2].GetUInt32(); 3801 tmp.datalong = fields[3].GetUInt32(); 3778 3802 tmp.datalong2 = fields[4].GetUInt32(); 3779 tmp.data text = fields[5].GetCppString();3780 tmp.x = fields[6].GetFloat();3781 tmp.y = fields[7].GetFloat();3782 tmp.z = fields[8].GetFloat();3783 tmp.o = fields[9].GetFloat();3803 tmp.dataint = fields[5].GetInt32(); 3804 tmp.x = fields[6].GetFloat(); 3805 tmp.y = fields[7].GetFloat(); 3806 tmp.z = fields[8].GetFloat(); 3807 tmp.o = fields[9].GetFloat(); 3784 3808 3785 3809 // generic command args check … … 3793 3817 continue; 3794 3818 } 3819 if(tmp.dataint==0) 3820 { 3821 sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,tmp.id); 3822 continue; 3823 } 3824 if(tmp.dataint < MIN_DB_SCRIPT_STRING_ID || tmp.dataint >= MAX_DB_SCRIPT_STRING_ID) 3825 { 3826 sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID,tmp.id); 3827 continue; 3828 } 3829 3830 // if(!objmgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading 3795 3831 break; 3796 3832 } … … 4157 4193 void ObjectMgr::LoadPageTextLocales() 4158 4194 { 4159 mPageTextLocaleMap.clear(); 4160 4195 mPageTextLocaleMap.clear(); // need for reload case 4196 4161 4197 QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); 4162 4198 … … 4207 4243 } 4208 4244 4245 struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader> 4246 { 4247 template<class D> 4248 void convert_from_str(uint32 field_pos, char *src, D &dst) 4249 { 4250 dst = D(objmgr.GetScriptId(src)); 4251 } 4252 }; 4253 4209 4254 void ObjectMgr::LoadInstanceTemplate() 4210 4255 { 4211 sInstanceTemplate.Load(); 4256 SQLInstanceLoader loader; 4257 loader.Load(sInstanceTemplate); 4212 4258 4213 4259 for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) … … 4325 4371 void ObjectMgr::LoadNpcTextLocales() 4326 4372 { 4327 mNpcTextLocaleMap.clear(); 4328 4373 mNpcTextLocaleMap.clear(); // need for reload case 4374 4329 4375 QueryResult *result = WorldDatabase.Query("SELECT entry," 4330 4376 "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," … … 4623 4669 4624 4670 uint32 Trigger_ID = fields[0].GetUInt32(); 4625 std::string scriptName = fields[1].GetCppString();4671 const char *scriptName = fields[1].GetString(); 4626 4672 4627 4673 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); … … 4631 4677 continue; 4632 4678 } 4633 mAreaTriggerScripts[Trigger_ID] = scriptName;4679 mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName); 4634 4680 } while( result->NextRow() ); 4635 4681 … … 4639 4685 sLog.outString( ">> Loaded %u areatrigger scripts", count ); 4640 4686 } 4687 4641 4688 uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) 4642 4689 { … … 4697 4744 uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) 4698 4745 { 4699 uint 32mount_entry = 0;4700 uint 32mount_id = 0;4746 uint16 mount_entry = 0; 4747 uint16 mount_id = 0; 4701 4748 4702 4749 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); 4703 if (node)4750 if(node) 4704 4751 { 4705 4752 if (team == ALLIANCE) mount_entry = node->alliance_mount_type; … … 4940 4987 } 4941 4988 4942 // find now nearest graveyard at same map4943 4989 if(entryNear) 4944 4990 return entryNear; … … 5181 5227 { 5182 5228 m_hiCharGuid = (*result)[0].GetUInt32()+1; 5183 5184 5229 delete result; 5185 5230 } … … 5189 5234 { 5190 5235 m_hiCreatureGuid = (*result)[0].GetUInt32()+1; 5191 5192 5236 delete result; 5193 5237 } 5194 5238 5195 result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); 5196 if( result ) 5197 { 5198 m_hiPetGuid = (*result)[0].GetUInt32()+1; 5199 5200 delete result; 5201 } 5239 // pet guids are not saved to DB, set to 0 (pet guid != pet id) 5240 m_hiPetGuid = 0; 5202 5241 5203 5242 result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); … … 5205 5244 { 5206 5245 m_hiItemGuid = (*result)[0].GetUInt32()+1; 5207 5208 5246 delete result; 5209 5247 } … … 5219 5257 { 5220 5258 m_hiGoGuid = (*result)[0].GetUInt32()+1; 5221 5222 5259 delete result; 5223 5260 } … … 5227 5264 { 5228 5265 m_auctionid = (*result)[0].GetUInt32()+1; 5229 5230 5266 delete result; 5231 5267 } 5232 else 5233 { 5234 m_auctionid = 0; 5235 } 5268 5236 5269 result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); 5237 5270 if( result ) 5238 5271 { 5239 5272 m_mailid = (*result)[0].GetUInt32()+1; 5240 5241 5273 delete result; 5242 5274 } 5243 else 5244 { 5245 m_mailid = 0; 5246 } 5275 5247 5276 result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); 5248 5277 if( result ) 5249 5278 { 5250 m_ItemTextId = (*result)[0].GetUInt32(); 5251 5279 m_ItemTextId = (*result)[0].GetUInt32()+1; 5252 5280 delete result; 5253 5281 } 5254 else5255 m_ItemTextId = 0;5256 5282 5257 5283 result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); … … 5259 5285 { 5260 5286 m_hiCorpseGuid = (*result)[0].GetUInt32()+1; 5261 5262 5287 delete result; 5263 5288 } 5289 5290 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); 5291 if (result) 5292 { 5293 m_arenaTeamId = (*result)[0].GetUInt32()+1; 5294 delete result; 5295 } 5296 5297 result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); 5298 if (result) 5299 { 5300 m_guildId = (*result)[0].GetUInt32()+1; 5301 delete result; 5302 } 5303 } 5304 5305 uint32 ObjectMgr::GenerateArenaTeamId() 5306 { 5307 if(m_arenaTeamId>=0xFFFFFFFE) 5308 { 5309 sLog.outError("Arena team ids overflow!! Can't continue, shutting down server. "); 5310 World::StopNow(ERROR_EXIT_CODE); 5311 } 5312 return m_arenaTeamId++; 5313 } 5314 5315 uint32 ObjectMgr::GenerateGuildId() 5316 { 5317 if(m_guildId>=0xFFFFFFFE) 5318 { 5319 sLog.outError("Guild ids overflow!! Can't continue, shutting down server. "); 5320 World::StopNow(ERROR_EXIT_CODE); 5321 } 5322 return m_guildId++; 5264 5323 } 5265 5324 5266 5325 uint32 ObjectMgr::GenerateAuctionID() 5267 5326 { 5268 ++m_auctionid; 5269 if(m_auctionid>=0xFFFFFFFF) 5327 if(m_auctionid>=0xFFFFFFFE) 5270 5328 { 5271 5329 sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. "); 5272 sWorld.m_stopEvent = true;5273 } 5274 return m_auctionid ;5330 World::StopNow(ERROR_EXIT_CODE); 5331 } 5332 return m_auctionid++; 5275 5333 } 5276 5334 5277 5335 uint32 ObjectMgr::GenerateMailID() 5278 5336 { 5279 ++m_mailid; 5280 if(m_mailid>=0xFFFFFFFF) 5337 if(m_mailid>=0xFFFFFFFE) 5281 5338 { 5282 5339 sLog.outError("Mail ids overflow!! Can't continue, shutting down server. "); 5283 sWorld.m_stopEvent = true;5284 } 5285 return m_mailid ;5340 World::StopNow(ERROR_EXIT_CODE); 5341 } 5342 return m_mailid++; 5286 5343 } 5287 5344 5288 5345 uint32 ObjectMgr::GenerateItemTextID() 5289 5346 { 5290 ++m_ItemTextId; 5291 if(m_ItemTextId>=0xFFFFFFFF) 5347 if(m_ItemTextId>=0xFFFFFFFE) 5292 5348 { 5293 5349 sLog.outError("Item text ids overflow!! Can't continue, shutting down server. "); 5294 sWorld.m_stopEvent = true;5295 } 5296 return m_ItemTextId ;5350 World::StopNow(ERROR_EXIT_CODE); 5351 } 5352 return m_ItemTextId++; 5297 5353 } 5298 5354 … … 5316 5372 { 5317 5373 case HIGHGUID_ITEM: 5318 ++m_hiItemGuid; 5319 if(m_hiItemGuid>=0xFFFFFFFF) 5374 if(m_hiItemGuid>=0xFFFFFFFE) 5320 5375 { 5321 5376 sLog.outError("Item guid overflow!! Can't continue, shutting down server. "); 5322 sWorld.m_stopEvent = true;5323 } 5324 return m_hiItemGuid ;5377 World::StopNow(ERROR_EXIT_CODE); 5378 } 5379 return m_hiItemGuid++; 5325 5380 case HIGHGUID_UNIT: 5326 ++m_hiCreatureGuid; 5327 if(m_hiCreatureGuid>=0x00FFFFFF) 5381 if(m_hiCreatureGuid>=0x00FFFFFE) 5328 5382 { 5329 5383 sLog.outError("Creature guid overflow!! Can't continue, shutting down server. "); 5330 sWorld.m_stopEvent = true;5331 } 5332 return m_hiCreatureGuid ;5384 World::StopNow(ERROR_EXIT_CODE); 5385 } 5386 return m_hiCreatureGuid++; 5333 5387 case HIGHGUID_PET: 5334 ++m_hiPetGuid; 5335 if(m_hiPetGuid>=0x00FFFFFF) 5388 if(m_hiPetGuid>=0x00FFFFFE) 5336 5389 { 5337 5390 sLog.outError("Pet guid overflow!! Can't continue, shutting down server. "); 5338 sWorld.m_stopEvent = true;5339 } 5340 return m_hiPetGuid ;5391 World::StopNow(ERROR_EXIT_CODE); 5392 } 5393 return m_hiPetGuid++; 5341 5394 case HIGHGUID_PLAYER: 5342 ++m_hiCharGuid; 5343 if(m_hiCharGuid>=0xFFFFFFFF) 5395 if(m_hiCharGuid>=0xFFFFFFFE) 5344 5396 { 5345 5397 sLog.outError("Players guid overflow!! Can't continue, shutting down server. "); 5346 sWorld.m_stopEvent = true;5347 } 5348 return m_hiCharGuid ;5398 World::StopNow(ERROR_EXIT_CODE); 5399 } 5400 return m_hiCharGuid++; 5349 5401 case HIGHGUID_GAMEOBJECT: 5350 ++m_hiGoGuid; 5351 if(m_hiGoGuid>=0x00FFFFFF) 5402 if(m_hiGoGuid>=0x00FFFFFE) 5352 5403 { 5353 5404 sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. "); 5354 sWorld.m_stopEvent = true;5355 } 5356 return m_hiGoGuid ;5405 World::StopNow(ERROR_EXIT_CODE); 5406 } 5407 return m_hiGoGuid++; 5357 5408 case HIGHGUID_CORPSE: 5358 ++m_hiCorpseGuid; 5359 if(m_hiCorpseGuid>=0xFFFFFFFF) 5409 if(m_hiCorpseGuid>=0xFFFFFFFE) 5360 5410 { 5361 5411 sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. "); 5362 sWorld.m_stopEvent = true;5363 } 5364 return m_hiCorpseGuid ;5412 World::StopNow(ERROR_EXIT_CODE); 5413 } 5414 return m_hiCorpseGuid++; 5365 5415 case HIGHGUID_DYNAMICOBJECT: 5366 ++m_hiDoGuid; 5367 if(m_hiDoGuid>=0xFFFFFFFF) 5416 if(m_hiDoGuid>=0xFFFFFFFE) 5368 5417 { 5369 5418 sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); 5370 sWorld.m_stopEvent = true;5371 } 5372 return m_hiDoGuid ;5419 World::StopNow(ERROR_EXIT_CODE); 5420 } 5421 return m_hiDoGuid++; 5373 5422 default: 5374 5423 ASSERT(0); … … 5381 5430 void ObjectMgr::LoadGameObjectLocales() 5382 5431 { 5383 mGameObjectLocaleMap.clear(); 5384 5432 mGameObjectLocaleMap.clear(); // need for reload case 5433 5385 5434 QueryResult *result = WorldDatabase.Query("SELECT entry," 5386 5435 "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," … … 5450 5499 } 5451 5500 5501 struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader> 5502 { 5503 template<class D> 5504 void convert_from_str(uint32 field_pos, char *src, D &dst) 5505 { 5506 dst = D(objmgr.GetScriptId(src)); 5507 } 5508 }; 5509 5452 5510 void ObjectMgr::LoadGameobjectInfo() 5453 5511 { 5454 sGOStorage.Load(); 5512 SQLGameObjectLoader loader; 5513 loader.Load(sGOStorage); 5455 5514 5456 5515 // some checks … … 6625 6684 } 6626 6685 6627 const char* ObjectMgr::GetAreaTriggerScriptName(uint32id)6628 { 6629 AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find( id);6686 uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id) 6687 { 6688 AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id); 6630 6689 if(i!= mAreaTriggerScripts.end()) 6631 return i->second .c_str();6632 return "";6690 return i->second; 6691 return 0; 6633 6692 } 6634 6693 … … 6675 6734 return false; 6676 6735 } 6677 case CONDITION_NO_AURA:6678 return !player->HasAura(value1, value2);6679 case CONDITION_ACTIVE_EVENT:6680 return gameeventmgr.IsActiveEvent(value1);6736 case CONDITION_NO_AURA: 6737 return !player->HasAura(value1, value2); 6738 case CONDITION_ACTIVE_EVENT: 6739 return gameeventmgr.IsActiveEvent(value1); 6681 6740 default: 6682 6741 return false; … … 6799 6858 break; 6800 6859 } 6801 case CONDITION_NO_AURA:6802 {6803 if(!sSpellStore.LookupEntry(value1))6804 {6805 sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1);6806 return false;6807 }6808 if(value2 > 2)6809 {6810 sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);6811 return false;6812 }6813 break;6814 }6815 case CONDITION_ACTIVE_EVENT:6816 {6817 GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();6818 if(value1 >=events.size() || !events[value1].isValid())6819 {6820 sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1);6821 return false;6822 }6823 break;6824 }6860 case CONDITION_NO_AURA: 6861 { 6862 if(!sSpellStore.LookupEntry(value1)) 6863 { 6864 sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); 6865 return false; 6866 } 6867 if(value2 > 2) 6868 { 6869 sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); 6870 return false; 6871 } 6872 break; 6873 } 6874 case CONDITION_ACTIVE_EVENT: 6875 { 6876 GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); 6877 if(value1 >=events.size() || !events[value1].isValid()) 6878 { 6879 sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1); 6880 return false; 6881 } 6882 break; 6883 } 6825 6884 } 6826 6885 return true; … … 6952 7011 if(itr->first > new_id) 6953 7012 new_id = itr->first; 6954 7013 6955 7014 // use next 6956 7015 ++new_id; … … 6992 7051 void ObjectMgr::LoadTrainerSpell() 6993 7052 { 6994 // For reload case 7053 // For reload case 6995 7054 for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) 6996 7055 itr->second.Clear(); … … 7083 7142 void ObjectMgr::LoadVendors() 7084 7143 { 7085 // For reload case 7144 // For reload case 7086 7145 for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 7087 7146 itr->second.Clear(); … … 7190 7249 "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text " 7191 7250 "FROM npc_option"); 7251 7192 7252 if( !result ) 7193 7253 { … … 7342 7402 } 7343 7403 7404 void ObjectMgr::LoadScriptNames() 7405 { 7406 m_scriptNames.push_back(""); 7407 QueryResult *result = WorldDatabase.Query( 7408 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' " 7409 "UNION " 7410 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' " 7411 "UNION " 7412 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' " 7413 "UNION " 7414 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' " 7415 "UNION " 7416 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''"); 7417 if(result) 7418 { 7419 do 7420 { 7421 m_scriptNames.push_back((*result)[0].GetString()); 7422 } while (result->NextRow()); 7423 delete result; 7424 } 7425 7426 std::sort(m_scriptNames.begin(), m_scriptNames.end()); 7427 } 7428 7429 uint32 ObjectMgr::GetScriptId(const char *name) 7430 { 7431 // use binary search to find the script name in the sorted vector 7432 // assume "" is the first element 7433 if(!name) return 0; 7434 ScriptNameMap::const_iterator itr = 7435 std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name); 7436 if(itr == m_scriptNames.end()) return 0; 7437 return itr - m_scriptNames.begin(); 7438 } 7439 7440 void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids) 7441 { 7442 for(ScriptMapMap::const_iterator itrMM = scripts.begin(); itrMM != scripts.end(); ++itrMM) 7443 { 7444 for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM) 7445 { 7446 if(itrM->second.dataint) 7447 { 7448 if(!GetTrinityStringLocale (itrM->second.dataint)) 7449 sLog.outErrorDb( "Table `db_script_string` has not existed string id %u", *itrM); 7450 7451 if(ids.count(itrM->second.dataint)) 7452 ids.erase(itrM->second.dataint); 7453 } 7454 } 7455 } 7456 } 7457 7458 void ObjectMgr::LoadDbScriptStrings() 7459 { 7460 LoadTrinityStrings(WorldDatabase,"db_script_string",MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID); 7461 7462 std::set<int32> ids; 7463 7464 for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) 7465 if(GetTrinityStringLocale(i)) 7466 ids.insert(i); 7467 7468 CheckScripts(sQuestEndScripts,ids); 7469 CheckScripts(sQuestStartScripts,ids); 7470 CheckScripts(sSpellScripts,ids); 7471 CheckScripts(sGameObjectScripts,ids); 7472 CheckScripts(sEventScripts,ids); 7473 7474 for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) 7475 sLog.outErrorDb( "Table `db_script_string` has unused string id %u", *itr); 7476 } 7477 7344 7478 // Functions for scripting access 7345 const char* GetAreaTriggerScriptNameById(uint32id)7346 { 7347 return objmgr.GetAreaTriggerScript Name(id);7479 uint32 GetAreaTriggerScriptId(uint32 trigger_id) 7480 { 7481 return objmgr.GetAreaTriggerScriptId(trigger_id); 7348 7482 } 7349 7483 … … 7360 7494 return objmgr.LoadTrinityStrings(db,table,end_value,start_value); 7361 7495 } 7496 7497 uint32 TRINITY_DLL_SPEC GetScriptId(const char *name) 7498 { 7499 return objmgr.GetScriptId(name); 7500 } 7501 7502 ObjectMgr::ScriptNameMap & GetScriptNames() 7503 { 7504 return objmgr.GetScriptNames(); 7505 } -
trunk/src/game/ObjectMgr.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 85 85 uint32 datalong; 86 86 uint32 datalong2; 87 std::string datatext;87 int32 dataint; 88 88 float x; 89 89 float y; … … 128 128 129 129 typedef UNORDERED_MAP<uint64/*(instance,guid) pair*/,time_t> RespawnTimes; 130 131 132 // mangos string ranges 133 #define MIN_TRINITY_STRING_ID 1 134 #define MAX_TRINITY_STRING_ID 2000000000 135 #define MIN_DB_SCRIPT_STRING_ID MAX_TRINITY_STRING_ID 136 #define MAX_DB_SCRIPT_STRING_ID 2000010000 130 137 131 138 struct TrinityStringLocale … … 208 215 CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active. 209 216 CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD ñommission aura active 210 CONDITION_NO_AURA = 11, // spell_id effindex211 CONDITION_ACTIVE_EVENT = 12, // event_id217 CONDITION_NO_AURA = 11, // spell_id effindex 218 CONDITION_ACTIVE_EVENT = 12, // event_id 212 219 }; 213 220 … … 251 258 // NPC gossip text id 252 259 typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap; 253 260 typedef std::list<GossipOption> CacheNpcOptionList; 254 261 255 262 typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap; … … 300 307 typedef UNORDERED_MAP<uint32, Quest*> QuestMap; 301 308 309 302 310 typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap; 303 311 304 typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap;312 typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap; 305 313 306 314 typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap; … … 309 317 310 318 typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap; 319 320 typedef std::vector<std::string> ScriptNameMap; 311 321 312 322 Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} … … 477 487 AreaTrigger const* GetGoBackTrigger(uint32 Map) const; 478 488 479 const char* GetAreaTriggerScriptName(uint32id);489 uint32 GetAreaTriggerScriptId(uint32 trigger_id); 480 490 481 491 ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const … … 523 533 524 534 bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); 525 bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",1,std::numeric_limits<int32>::max()); } 535 bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); } 536 void LoadDbScriptStrings(); 526 537 void LoadPetCreateSpells(); 527 538 void LoadCreatureLocales(); … … 593 604 uint32 GenerateItemTextID(); 594 605 uint32 GeneratePetNumber(); 606 uint32 GenerateArenaTeamId(); 607 uint32 GenerateGuildId(); 595 608 596 609 void LoadPlayerInfoInCache(); … … 669 682 return &itr->second; 670 683 } 671 672 684 NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const 673 685 { … … 694 706 const char *GetTrinityString(int32 entry, int locale_idx) const; 695 707 const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); } 696 int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }708 int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } 697 709 void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } 698 710 … … 733 745 LocaleConstant GetLocaleForIndex(int i); 734 746 // guild bank tabs 735 const uint32 GetGuildBankTabPrice(uint8 Index){ return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }747 uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } 736 748 737 749 uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); … … 754 766 bool AddGameTele(GameTele& data); 755 767 bool DeleteGameTele(std::string name); 756 768 757 769 CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; } 758 770 … … 762 774 if(iter == m_mCacheNpcTextIdMap.end()) 763 775 return 0; 764 776 765 777 return iter->second; 766 778 } … … 783 795 return &iter->second; 784 796 } 785 void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); 786 bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); 787 bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const; 788 797 void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event 798 bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); // for event 799 bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0 ) const; 800 801 void LoadScriptNames(); 802 ScriptNameMap &GetScriptNames() { return m_scriptNames; } 803 const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; } 804 uint32 GetScriptId(const char *name); 789 805 protected: 806 807 // first free id for selected id type 790 808 uint32 m_auctionid; 791 809 uint32 m_mailid; 792 810 uint32 m_ItemTextId; 793 811 uint32 m_arenaTeamId; 812 uint32 m_guildId; 813 uint32 m_hiPetNumber; 814 815 // first free low guid for seelcted guid type 794 816 uint32 m_hiCharGuid; 795 817 uint32 m_hiCreatureGuid; … … 800 822 uint32 m_hiCorpseGuid; 801 823 802 uint32 m_hiPetNumber; 803 804 QuestMap mQuestTemplates; 824 QuestMap mQuestTemplates; 805 825 806 826 typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap; … … 849 869 GameTeleMap m_GameTeleMap; 850 870 871 ScriptNameMap m_scriptNames; 872 851 873 typedef std::vector<LocaleConstant> LocalForIndex; 852 874 LocalForIndex m_LocalForIndex; … … 856 878 private: 857 879 void LoadScripts(ScriptMapMap& scripts, char const* tablename); 880 void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids); 858 881 void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); 859 882 void LoadQuestRelationsHelper(QuestRelations& map,char const* table); … … 908 931 909 932 // scripting access functions 910 bool TRINITY_DLL_SPEC LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min()); 911 TRINITY_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id); 933 TRINITY_DLL_SPEC bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min()); 934 TRINITY_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 trigger_id); 935 TRINITY_DLL_SPEC uint32 GetScriptId(const char *name); 936 TRINITY_DLL_SPEC ObjectMgr::ScriptNameMap& GetScriptNames(); 912 937 913 938 #endif -
trunk/src/game/Pet.cpp
r272 r279 287 287 ++iter; 288 288 m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str()); 289 290 // patch for old data where some spells have ACT_DECIDE but should have ACT_CAST 291 // so overwrite old state 292 SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_charmInfo->GetActionBarEntry(index)->SpellOrAction); 293 if (spellInfo && spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) m_charmInfo->GetActionBarEntry(index)->Type = ACT_CAST; 289 294 } 290 295 … … 1323 1328 SetUInt32Value(i, 0); 1324 1329 1325 QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index, amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());1330 QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); 1326 1331 1327 1332 if(result) … … 1333 1338 uint32 spellid = fields[1].GetUInt32(); 1334 1339 uint32 effindex = fields[2].GetUInt32(); 1335 int32 damage = (int32)fields[3].GetUInt32(); 1336 int32 maxduration = (int32)fields[4].GetUInt32(); 1337 int32 remaintime = (int32)fields[5].GetUInt32(); 1338 int32 remaincharges = (int32)fields[6].GetUInt32(); 1340 uint32 stackcount= fields[3].GetUInt32(); 1341 int32 damage = (int32)fields[4].GetUInt32(); 1342 int32 maxduration = (int32)fields[5].GetUInt32(); 1343 int32 remaintime = (int32)fields[6].GetUInt32(); 1344 int32 remaincharges = (int32)fields[7].GetUInt32(); 1339 1345 1340 1346 SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); … … 1373 1379 continue; 1374 1380 1375 Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 1376 1377 if(!damage) 1378 damage = aura->GetModifier()->m_amount; 1379 aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 1380 AddAura(aura); 1381 for(uint32 i=0; i<stackcount; i++) 1382 { 1383 Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 1384 1385 if(!damage) 1386 damage = aura->GetModifier()->m_amount; 1387 aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 1388 AddAura(aura); 1389 } 1381 1390 } 1382 1391 while( result->NextRow() ); … … 1391 1400 1392 1401 AuraMap const& auras = GetAuras(); 1393 for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) 1394 { 1395 // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. 1396 SpellEntry const *spellInfo = itr->second->GetSpellProto(); 1397 uint8 i; 1398 for (i = 0; i < 3; i++) 1399 if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || 1400 spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || 1401 spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) 1402 if (auras.empty()) 1403 return; 1404 1405 spellEffectPair lastEffectPair = auras.begin()->first; 1406 uint32 stackCounter = 1; 1407 1408 for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) 1409 { 1410 if(itr == auras.end() || lastEffectPair != itr->first) 1411 { 1412 AuraMap::const_iterator itr2 = itr; 1413 // save previous spellEffectPair to db 1414 itr2--; 1415 SpellEntry const *spellInfo = itr2->second->GetSpellProto(); 1416 /// do not save single target auras (unless they were cast by the player) 1417 if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) 1418 { 1419 if(!itr2->second->IsPassive()) 1420 { 1421 // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras. 1422 uint8 i; 1423 for (i = 0; i < 3; i++) 1424 if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH || 1425 spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER || 1426 spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET ) 1427 break; 1428 1429 if (i == 3) 1430 { 1431 CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " 1432 "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')", 1433 m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(),(uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges)); 1434 } 1435 } 1436 } 1437 if(itr == auras.end()) 1402 1438 break; 1403 1404 if (i != 3) 1405 continue; 1406 1407 if(itr->second->IsPassive()) 1408 continue; 1409 1410 /// do not save single target auras (unless they were cast by the player) 1411 if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 1412 continue; 1413 1414 CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 1415 "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')", 1416 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)); 1439 } 1440 1441 if (lastEffectPair == itr->first) 1442 stackCounter++; 1443 else 1444 { 1445 lastEffectPair = itr->first; 1446 stackCounter = 1; 1447 } 1417 1448 } 1418 1449 } … … 1434 1465 return false; 1435 1466 } 1467 1468 // same spells don't have autocast option 1469 if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) 1470 active = ACT_CAST; 1436 1471 1437 1472 PetSpellMap::iterator itr = m_spells.find(spell_id); … … 1509 1544 CastSpell(this, spell_id, true); 1510 1545 else if(state == PETSPELL_NEW) 1511 m_charmInfo->AddSpellToAB(oldspell_id, spell_id );1546 m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active); 1512 1547 1513 1548 if(newspell->active == ACT_ENABLED) … … 1659 1694 return; 1660 1695 1661 if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid))1662 if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER1663 && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE)1664 return;1696 //if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) 1697 // if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER 1698 // && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) 1699 // return; 1665 1700 1666 1701 PetSpellMap::const_iterator itr = m_spells.find((uint16)spellid); -
trunk/src/game/Player.cpp
r272 r279 800 800 } 801 801 802 void Player::EnvironmentalDamage(uint64 guid, Enviro nmentalDamageType type, uint32 damage)802 void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage) 803 803 { 804 804 WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); … … 1642 1642 { 1643 1643 // far teleport to another map 1644 Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL;1644 Map* oldmap = IsInWorld() ? GetMap() : NULL; 1645 1645 // check if we can enter before stopping combat / removing pet / totems / interrupting spells 1646 1646 … … 3751 3751 } 3752 3752 3753 void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, boolapplySickness)3753 void Player::ResurrectPlayer(float restore_percent, bool applySickness) 3754 3754 { 3755 3755 WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // remove spirit healer position … … 4282 4282 } 4283 4283 4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply , bool affectStats)4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) 4285 4285 { 4286 4286 if(modGroup >= BASEMOD_END || modType >= MOD_END) … … 5244 5244 } 5245 5245 5246 Map *m = MapManager::Instance().GetMap(GetMapId(), this);5246 Map *m = GetMap(); 5247 5247 5248 5248 const float old_x = GetPositionX(); … … 5262 5262 5263 5263 // reread after Map::Relocation 5264 m = MapManager::Instance().GetMap(GetMapId(), this);5264 m = GetMap(); 5265 5265 x = GetPositionX(); 5266 5266 y = GetPositionY(); … … 6177 6177 return 0; 6178 6178 6179 return (*result)[0].GetUInt32(); 6179 uint32 id = (*result)[0].GetUInt32(); 6180 delete result; 6181 return id; 6180 6182 } 6181 6183 … … 6708 6710 } 6709 6711 6710 if(!IsUseEquip pedWeapon(slot==EQUIPMENT_SLOT_MAINHAND))6712 if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 6711 6713 return; 6712 6714 … … 8486 8488 return item; 8487 8489 8488 if( item->IsBroken() || !IsUseEquip pedWeapon(attackType==BASE_ATTACK) )8490 if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) 8489 8491 return NULL; 8490 8492 … … 8640 8642 return false; 8641 8643 } 8644 8642 8645 8643 8646 bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const … … 10156 10159 if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10157 10160 pItem->GetProto()->Bonding == BIND_QUEST_ITEM || 10158 pItem->GetProto()->Bonding == BIND_WHEN_EQUIP PED && IsBagPos(pos) )10161 pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 10159 10162 pItem->SetBinding( true ); 10160 10163 … … 10202 10205 if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10203 10206 pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || 10204 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIP PED && IsBagPos(pos) )10207 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 10205 10208 pItem2->SetBinding( true ); 10206 10209 … … 10404 10407 10405 10408 // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) 10406 if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIP PED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM )10409 if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 10407 10410 pItem->SetBinding( true ); 10408 10411 … … 10548 10551 if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 10549 10552 CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); 10550 10551 ItemPrototype const *pProto = pItem->GetProto();10552 10553 10553 10554 RemoveEnchantmentDurations(pItem); … … 14208 14209 SetUInt32Value(i, 0); 14209 14210 14210 //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index, amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());14211 //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 14211 14212 14212 14213 if(result) … … 14218 14219 uint32 spellid = fields[1].GetUInt32(); 14219 14220 uint32 effindex = fields[2].GetUInt32(); 14220 int32 damage = (int32)fields[3].GetUInt32(); 14221 int32 maxduration = (int32)fields[4].GetUInt32(); 14222 int32 remaintime = (int32)fields[5].GetUInt32(); 14223 int32 remaincharges = (int32)fields[6].GetUInt32(); 14221 uint32 stackcount = fields[3].GetUInt32(); 14222 int32 damage = (int32)fields[4].GetUInt32(); 14223 int32 maxduration = (int32)fields[5].GetUInt32(); 14224 int32 remaintime = (int32)fields[6].GetUInt32(); 14225 int32 remaincharges = (int32)fields[7].GetUInt32(); 14224 14226 14225 14227 SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); … … 14258 14260 continue; 14259 14261 14260 Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 14261 if(!damage) 14262 damage = aura->GetModifier()->m_amount; 14263 aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 14264 AddAura(aura); 14262 for(uint32 i=0; i<stackcount; i++) 14263 { 14264 Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 14265 if(!damage) 14266 damage = aura->GetModifier()->m_amount; 14267 aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 14268 AddAura(aura); 14269 sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex); 14270 } 14265 14271 } 14266 14272 while( result->NextRow() ); … … 15321 15327 15322 15328 AuraMap const& auras = GetAuras(); 15323 for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) 15324 { 15325 SpellEntry const *spellInfo = itr->second->GetSpellProto(); 15326 15327 //skip all auras from spells that are passive or need a shapeshift 15328 if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost()) 15329 continue; 15330 15331 //do not save single target auras (unless they were cast by the player) 15332 if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 15333 continue; 15334 15335 uint8 i; 15336 // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras 15337 for (i = 0; i < 3; i++) 15338 if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || 15339 spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) 15329 15330 if (auras.empty()) 15331 return; 15332 15333 spellEffectPair lastEffectPair = auras.begin()->first; 15334 uint32 stackCounter = 1; 15335 15336 for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) 15337 { 15338 if(itr == auras.end() || lastEffectPair != itr->first) 15339 { 15340 AuraMap::const_iterator itr2 = itr; 15341 // save previous spellEffectPair to db 15342 itr2--; 15343 SpellEntry const *spellInfo = itr2->second->GetSpellProto(); 15344 15345 //skip all auras from spells that are passive or need a shapeshift 15346 if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost())) 15347 { 15348 //do not save single target auras (unless they were cast by the player) 15349 if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) 15350 { 15351 uint8 i; 15352 // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras 15353 for (i = 0; i < 3; i++) 15354 if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || 15355 spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) 15356 break; 15357 15358 if (i == 3) 15359 { 15360 CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " 15361 "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')", 15362 GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges)); 15363 } 15364 } 15365 } 15366 15367 if(itr == auras.end()) 15340 15368 break; 15341 15342 if (i == 3) 15343 { 15344 CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex()); 15345 CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 15346 "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')", 15347 GetGUIDLow(), 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)); 15369 } 15370 15371 if (lastEffectPair == itr->first) 15372 stackCounter++; 15373 else 15374 { 15375 lastEffectPair = itr->first; 15376 stackCounter = 1; 15348 15377 } 15349 15378 } … … 17911 17940 continue; 17912 17941 17913 if ( SpellEntry const* spellentry =sSpellStore.LookupEntry(pAbility->spellId))17942 if (sSpellStore.LookupEntry(pAbility->spellId)) 17914 17943 { 17915 17944 // Ok need learn spell … … 18324 18353 Player* not_gray_member_with_max_level = NULL; 18325 18354 18326 // gets the max member level of the group, and the max member level that still gets XP18327 18355 pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); 18328 18356 … … 18333 18361 xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); 18334 18362 18335 // skip in check PvP case (for speed, not used)18363 /// skip in check PvP case (for speed, not used) 18336 18364 bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); 18337 18365 bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); … … 18660 18688 UpdateBlockPercentage(); 18661 18689 } 18690 18691 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const 18692 { 18693 for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) 18694 if(itr->pos == pos) 18695 return true; 18696 return false; 18697 } 18698 18699 //*********************************** 18700 //-------------TRINITY--------------- 18701 //*********************************** 18662 18702 18663 18703 void Player::HandleFallDamage(MovementInfo& movementInfo) … … 18962 19002 } 18963 19003 18964 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const18965 {18966 for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)18967 if(itr->pos == this->pos)18968 return true;18969 18970 return false;18971 }18972 18973 19004 bool Player::isTotalImmunity() 18974 19005 { -
trunk/src/game/Player.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 34 34 #include "WorldSession.h" 35 35 #include "Pet.h" 36 #include "MapReference.h" 36 37 #include "Util.h" // for Tokens typedef 37 38 … … 780 781 781 782 /// Type of environmental damages 782 enum Enviro nmentalDamageType783 enum EnviromentalDamage 783 784 { 784 785 DAMAGE_EXHAUSTED = 0, … … 1125 1126 uint32 GetArmorProficiency() const { return m_ArmorProficiency; } 1126 1127 bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } 1127 bool IsUseEquip pedWeapon( bool mainhand ) const1128 bool IsUseEquipedWeapon( bool mainhand ) const 1128 1129 { 1129 1130 // disarm applied only to mainhand weapon … … 1307 1308 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); 1308 1309 else 1309 SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d? GetMoney() + d : MAX_MONEY_AMOUNT);1310 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); 1310 1311 1311 1312 // "At Gold Limit" … … 1429 1430 PlayerSpellMap const& GetSpellMap() const { return m_spells; } 1430 1431 PlayerSpellMap & GetSpellMap() { return m_spells; } 1431 ActionButtonList const& GetActionButtonList() const { return m_actionButtons; }1432 1432 1433 1433 void AddSpellMod(SpellModifier* mod, bool apply); … … 1519 1519 void SendUpdateToOutOfRangeGroupMembers(); 1520 1520 1521 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); }1522 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); }1521 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); } 1522 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); } 1523 1523 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } 1524 1524 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } … … 1533 1533 { 1534 1534 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); 1535 SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID());1535 SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID()); 1536 1536 } 1537 1537 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } … … 1609 1609 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); 1610 1610 1611 //Low Level Packets1611 //Low Level Packets 1612 1612 void PlaySound(uint32 Sound, bool OnlySelf); 1613 1613 //notifiers … … 1641 1641 void KillPlayer(); 1642 1642 uint32 GetResurrectionSpellId(); 1643 void ResurrectPlayer(float restore_percent, bool updateToWorld = true, boolapplySickness = false);1643 void ResurrectPlayer(float restore_percent, bool applySickness = false); 1644 1644 void BuildPlayerRepop(); 1645 1645 void RepopAtGraveyard(); … … 1763 1763 void SetRegularAttackTime(); 1764 1764 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } 1765 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply , bool affectStats = true);1765 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply); 1766 1766 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; 1767 1767 float GetTotalBaseModValue(BaseModGroup modGroup) const; … … 1770 1770 void _RemoveAllStatBonuses(); 1771 1771 1772 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType,bool apply);1772 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply); 1773 1773 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); 1774 1774 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); … … 1935 1935 1936 1936 /*********************************************************/ 1937 /*** ENVIRO NMENTAL SYSTEM ***/1938 /*********************************************************/ 1939 1940 void EnvironmentalDamage(uint64 guid, Enviro nmentalDamageType type, uint32 damage);1937 /*** ENVIROMENTAL SYSTEM ***/ 1938 /*********************************************************/ 1939 1940 void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage); 1941 1941 1942 1942 /*********************************************************/ … … 2063 2063 2064 2064 GridReference<Player> &GetGridRef() { return m_gridRef; } 2065 MapReference &GetMapRef() { return m_mapRef; } 2066 2065 2067 bool isAllowedToLoot(Creature* creature); 2066 2068 … … 2308 2310 2309 2311 GridReference<Player> m_gridRef; 2312 MapReference m_mapRef; 2310 2313 }; 2311 2314 -
trunk/src/game/PlayerDump.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 278 278 // for guid set stop if set is empty 279 279 if(guids && guids->empty()) 280 return; // nothing to do280 return; // nothing to do 281 281 282 282 // setup for guids case start position … … 344 344 FILE *fout = fopen(file.c_str(), "w"); 345 345 if (!fout) 346 return DUMP_FILE_OPEN_ERROR;346 return DUMP_FILE_OPEN_ERROR; 347 347 348 348 std::string dump = GetDump(guid); … … 372 372 } 373 373 } 374 374 375 FILE *fin = fopen(file.c_str(), "r"); 375 376 if(!fin) 376 return DUMP_FILE_OPEN_ERROR;377 return DUMP_FILE_OPEN_ERROR; 377 378 378 379 QueryResult * result = NULL; … … 391 392 else incHighest = false; 392 393 } 393 else guid = objmgr.m_hiCharGuid; 394 else 395 guid = objmgr.m_hiCharGuid; 394 396 395 397 // normalize the name if specified and check if it exists … … 469 471 case DTT_CHAR_TABLE: 470 472 if(!changenth(line, 1, newguid)) 471 ROLLBACK(DUMP_FILE_BROKEN);473 ROLLBACK(DUMP_FILE_BROKEN); 472 474 break; 473 475 … … 475 477 { 476 478 if(!changenth(line, 1, newguid)) 477 ROLLBACK(DUMP_FILE_BROKEN);479 ROLLBACK(DUMP_FILE_BROKEN); 478 480 479 481 // guid, data field:guid, items 480 482 if(!changenth(line, 2, chraccount)) 481 ROLLBACK(DUMP_FILE_BROKEN); 482 483 ROLLBACK(DUMP_FILE_BROKEN); 483 484 std::string vals = getnth(line, 3); 484 485 if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid)) 485 ROLLBACK(DUMP_FILE_BROKEN); 486 486 ROLLBACK(DUMP_FILE_BROKEN); 487 487 for(uint16 field = PLAYER_FIELD_INV_SLOT_HEAD; field < PLAYER_FARSIGHT; field++) 488 488 if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true)) 489 ROLLBACK(DUMP_FILE_BROKEN); 490 489 ROLLBACK(DUMP_FILE_BROKEN); 491 490 if(!changenth(line, 3, vals.c_str())) 492 ROLLBACK(DUMP_FILE_BROKEN); 493 491 ROLLBACK(DUMP_FILE_BROKEN); 494 492 if (name == "") 495 493 { … … 504 502 // rename on login: `at_login` field 30 in raw field list 505 503 if(!changenth(line, 30, "1")) 506 ROLLBACK(DUMP_FILE_BROKEN);504 ROLLBACK(DUMP_FILE_BROKEN); 507 505 } 508 506 } 509 507 else if(!changenth(line, 4, name.c_str())) 510 ROLLBACK(DUMP_FILE_BROKEN);508 ROLLBACK(DUMP_FILE_BROKEN); 511 509 512 510 break; … … 515 513 { 516 514 if(!changenth(line, 1, newguid)) 517 ROLLBACK(DUMP_FILE_BROKEN);515 ROLLBACK(DUMP_FILE_BROKEN); 518 516 519 517 // bag, item 520 518 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true)) 521 ROLLBACK(DUMP_FILE_BROKEN);522 if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid))523 ROLLBACK(DUMP_FILE_BROKEN);519 ROLLBACK(DUMP_FILE_BROKEN); 520 if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid)) 521 ROLLBACK(DUMP_FILE_BROKEN); 524 522 break; 525 523 } … … 528 526 // item, owner, data field:item, owner guid 529 527 if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid)) 530 ROLLBACK(DUMP_FILE_BROKEN); 531 if(!changenth(line, 2, newguid)) 532 ROLLBACK(DUMP_FILE_BROKEN); 533 528 ROLLBACK(DUMP_FILE_BROKEN); 529 if(!changenth(line, 2, newguid)) 530 ROLLBACK(DUMP_FILE_BROKEN); 534 531 std::string vals = getnth(line,3); 535 532 if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid)) 536 ROLLBACK(DUMP_FILE_BROKEN);537 if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid))538 ROLLBACK(DUMP_FILE_BROKEN);539 if(!changenth(line, 3, vals.c_str()))540 ROLLBACK(DUMP_FILE_BROKEN);533 ROLLBACK(DUMP_FILE_BROKEN); 534 if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid)) 535 ROLLBACK(DUMP_FILE_BROKEN); 536 if(!changenth(line, 3, vals.c_str())) 537 ROLLBACK(DUMP_FILE_BROKEN); 541 538 break; 542 539 } … … 545 542 // guid,item_guid, 546 543 if(!changenth(line, 1, newguid)) 547 ROLLBACK(DUMP_FILE_BROKEN);548 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))549 ROLLBACK(DUMP_FILE_BROKEN);544 ROLLBACK(DUMP_FILE_BROKEN); 545 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) 546 ROLLBACK(DUMP_FILE_BROKEN); 550 547 break; 551 548 } … … 570 567 // item, entry, owner, ... 571 568 if(!changenth(line, 1, newpetid)) 572 ROLLBACK(DUMP_FILE_BROKEN);573 if(!changenth(line, 3, newguid))574 ROLLBACK(DUMP_FILE_BROKEN);569 ROLLBACK(DUMP_FILE_BROKEN); 570 if(!changenth(line, 3, newguid)) 571 ROLLBACK(DUMP_FILE_BROKEN); 575 572 576 573 break; … … 583 580 std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); 584 581 if(petids_iter == petids.end()) // couldn't find new inserted id 585 ROLLBACK(DUMP_FILE_BROKEN);582 ROLLBACK(DUMP_FILE_BROKEN); 586 583 587 584 snprintf(newpetid, 20, "%d", petids_iter->second); 588 585 589 586 if(!changenth(line, 1, newpetid)) 590 ROLLBACK(DUMP_FILE_BROKEN);587 ROLLBACK(DUMP_FILE_BROKEN); 591 588 592 589 break; … … 596 593 // id,messageType,stationery,sender,receiver 597 594 if(!changeGuid(line, 1, mails, objmgr.m_mailid)) 598 ROLLBACK(DUMP_FILE_BROKEN);599 if(!changenth(line, 5, newguid))600 ROLLBACK(DUMP_FILE_BROKEN);595 ROLLBACK(DUMP_FILE_BROKEN); 596 if(!changenth(line, 5, newguid)) 597 ROLLBACK(DUMP_FILE_BROKEN); 601 598 break; 602 599 } … … 605 602 // mail_id,item_guid,item_template,receiver 606 603 if(!changeGuid(line, 1, mails, objmgr.m_mailid)) 607 ROLLBACK(DUMP_FILE_BROKEN);608 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))609 ROLLBACK(DUMP_FILE_BROKEN);610 if(!changenth(line, 4, newguid))611 ROLLBACK(DUMP_FILE_BROKEN);604 ROLLBACK(DUMP_FILE_BROKEN); 605 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) 606 ROLLBACK(DUMP_FILE_BROKEN); 607 if(!changenth(line, 4, newguid)) 608 ROLLBACK(DUMP_FILE_BROKEN); 612 609 break; 613 610 } … … 618 615 619 616 if(!CharacterDatabase.Execute(line.c_str())) 620 ROLLBACK(DUMP_FILE_BROKEN);617 ROLLBACK(DUMP_FILE_BROKEN); 621 618 } 622 619 -
trunk/src/game/SharedDefines.h
r274 r279 249 249 #define SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY 0x00008000 // 15 remove auras on immunity 250 250 #define SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE 0x00010000 // 16 unaffected by school immunity 251 #define SPELL_ATTR_EX_UN K170x00020000 // 17251 #define SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET 0x00020000 // 17 252 252 #define SPELL_ATTR_EX_UNK18 0x00040000 // 18 253 253 #define SPELL_ATTR_EX_UNK19 0x00080000 // 19 -
trunk/src/game/Spell.cpp
r274 r279 997 997 998 998 unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); 999 //TODO: find a better way to judge CC auras 1000 if(m_spellInfo->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE) 1001 unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); 999 1002 } 1000 1003 else -
trunk/src/game/SpellAuras.cpp
r274 r279 170 170 &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus 171 171 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus 172 &Aura::Handle AuraHealing, //115 SPELL_AURA_MOD_HEALING172 &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim 173 173 &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT 174 174 &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult 175 &Aura::Handle AuraHealingPct, //118 SPELL_AURA_MOD_HEALING_PCT175 &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus 176 176 &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless 177 177 &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE … … 191 191 &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT 192 192 &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE 193 &Aura::Handle AuraHealingPct,//136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus193 &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus 194 194 &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE 195 195 &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE … … 220 220 &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE 221 221 &Aura::HandleUnused, //164 useless, only one test spell 222 &Aura::Handle AuraAttackPowerAttacker,//165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus222 &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus 223 223 &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT 224 224 &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT … … 1999 1999 } 2000 2000 2001 // Waiting to Resurrect 2002 if(GetId()==2584) 2003 { 2004 // Waiting to resurrect spell cancel, we must remove player from resurrect queue 2005 if(m_target->GetTypeId() == TYPEID_PLAYER) 2006 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) 2007 bg->RemovePlayerFromResurrectQueue(m_target->GetGUID()); 2008 return; 2009 } 2010 2001 2011 // Dark Fiend 2002 2012 if(GetId()==45934) … … 2287 2297 void Aura::HandleAuraMounted(bool apply, bool Real) 2288 2298 { 2299 // only at real add/remove aura 2300 if(!Real) 2301 return; 2302 2289 2303 if(apply) 2290 2304 { … … 2686 2700 else 2687 2701 { 2688 if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); 2702 // Will use the default model here 2703 if (uint32 modelid = ci->GetRandomValidModelId()) 2704 m_target->SetDisplayId(modelid); 2689 2705 2690 2706 // Dragonmaw Illusion (set mount model also) … … 3582 3598 /*** MODIFY SPEED ***/ 3583 3599 /*********************************************************/ 3584 void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real)3600 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real) 3585 3601 { 3586 3602 // all applied/removed only at real aura add/remove … … 3591 3607 } 3592 3608 3593 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real)3609 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) 3594 3610 { 3595 3611 // all applied/removed only at real aura add/remove … … 3630 3646 } 3631 3647 3632 void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real)3648 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) 3633 3649 { 3634 3650 // all applied/removed only at real aura add/remove … … 3639 3655 } 3640 3656 3641 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real)3657 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real) 3642 3658 { 3643 3659 // all applied/removed only at real aura add/remove … … 3650 3666 } 3651 3667 3652 void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real)3668 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) 3653 3669 { 3654 3670 // all applied/removed only at real aura add/remove … … 4335 4351 } 4336 4352 4337 void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real)4353 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real) 4338 4354 { 4339 4355 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4346 4362 } 4347 4363 4348 void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real)4364 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real) 4349 4365 { 4350 4366 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4364 4380 } 4365 4381 4366 void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real)4382 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real) 4367 4383 { 4368 4384 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4375 4391 } 4376 4392 4377 void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real)4393 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real) 4378 4394 { 4379 4395 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4384 4400 } 4385 4401 4386 void Aura::HandleModHealingDone(bool apply, bool Real)4402 void Aura::HandleModHealingDone(bool /*apply*/, bool Real) 4387 4403 { 4388 4404 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4424 4440 } 4425 4441 4426 void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real)4442 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real) 4427 4443 { 4428 4444 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4559 4575 } 4560 4576 4561 void Aura::HandleModPowerRegenPCT(bool apply, bool Real)4577 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real) 4562 4578 { 4563 4579 // spells required only Real aura add/remove … … 4573 4589 } 4574 4590 4575 void Aura::HandleModManaRegen(bool apply, bool Real)4591 void Aura::HandleModManaRegen(bool /*apply*/, bool Real) 4576 4592 { 4577 4593 // spells required only Real aura add/remove … … 4660 4676 /********************************/ 4661 4677 4662 void Aura::HandleAuraModParryPercent(bool apply, bool Real)4678 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real) 4663 4679 { 4664 4680 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4668 4684 } 4669 4685 4670 void Aura::HandleAuraModDodgePercent(bool apply, bool Real)4686 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real) 4671 4687 { 4672 4688 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4677 4693 } 4678 4694 4679 void Aura::HandleAuraModBlockPercent(bool apply, bool Real)4695 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real) 4680 4696 { 4681 4697 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4686 4702 } 4687 4703 4688 void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real)4704 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real) 4689 4705 { 4690 4706 // spells required only Real aura add/remove … … 4754 4770 } 4755 4771 4756 void Aura::HandleModSpellCritChanceShool(bool apply, bool Real)4772 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) 4757 4773 { 4758 4774 // spells required only Real aura add/remove … … 4834 4850 4835 4851 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); 4836 }4837 4838 void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real)4839 {4840 // spells required only Real aura add/remove4841 if(!Real)4842 return;4843 Unit *caster = GetCaster();4844 4845 if (!caster)4846 return;4847 4848 // Hunter's Mark4849 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)4850 {4851 // Check Improved Hunter's Mark bonus on caster4852 Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);4853 for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)4854 {4855 Modifier* mod = (*i)->GetModifier();4856 // mproved Hunter's Mark script from 5236 to 52404857 if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240)4858 {4859 // Get amount of ranged bonus for this spell..4860 int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target);4861 // Set melee attack power bonus % from ranged depends from Improved mask aura4862 m_modifier.m_amount = mod->m_amount * ranged_bonus / 100;4863 m_currentBasePoints = m_modifier.m_amount;4864 break;4865 }4866 }4867 return;4868 }4869 4852 } 4870 4853 … … 5316 5299 } 5317 5300 5318 void Aura::HandleAuraModExpertise(bool apply, bool Real)5301 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real) 5319 5302 { 5320 5303 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 5339 5322 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) 5340 5323 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); 5341 }5342 5343 //HandleNoImmediateEffect auras implementation to support new stat system5344 void Aura::HandleAuraHealing(bool apply, bool Real)5345 {5346 //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply);5347 }5348 5349 void Aura::HandleAuraHealingPct(bool apply, bool Real)5350 {5351 //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply);5352 5324 } 5353 5325 -
trunk/src/game/SpellAuras.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 #ifndef TRINITY_SPELLAURAS_H … … 186 186 void HandleModRating(bool apply, bool Real); 187 187 void HandleModTargetResistance(bool apply, bool Real); 188 void HandleAuraAttackPowerAttacker(bool apply, bool Real);189 188 void HandleAuraModAttackPowerPercent(bool apply, bool Real); 190 189 void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real); 191 190 void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real); 192 191 void HandleSpiritOfRedemption(bool apply, bool Real); 193 void HandleAuraHealingPct(bool apply, bool Real);194 192 void HandleModManaRegen(bool apply, bool Real); 195 193 void HandleComprehendLanguage(bool apply, bool Real); 196 void HandleAuraHealing(bool apply, bool Real);197 194 void HandleShieldBlockValue(bool apply, bool Real); 198 195 void HandleModSpellCritChanceShool(bool apply, bool Real); … … 254 251 uint8 slot = GetAuraSlot(); 255 252 256 // only aura in slot with charges and without stack limitation253 // only aura in slot with charges and without stack limitation 257 254 if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0) 258 255 SetAuraApplication(slot, m_procCharges - 1); -
trunk/src/game/SpellEffects.cpp
r274 r279 334 334 break; 335 335 } 336 // must only affect demons 336 // must only affect demons (also undead?) 337 337 case 45072: 338 338 { 339 if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON) 339 if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON 340 || unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) 340 341 return; 341 342 break; 342 343 } 344 // gruul's shatter 345 case 33671: 346 { 347 // don't damage self and only players 348 if(unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER) 349 return; 350 351 float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0])); 352 if(!radius) return; 353 float distance = m_caster->GetDistance2d(unitTarget); 354 damage = (distance > radius ) ? 0 : (int32)(m_spellInfo->EffectBasePoints[0]*((radius - distance)/radius)); 355 }break; 343 356 } 344 357 break; … … 1159 1172 m_caster->CastSpell(m_caster, 45009, true); 1160 1173 return; 1161 } 1174 } 1162 1175 case 45030: // Impale Emissary 1163 1176 { … … 1262 1275 //Polymorph Cast Visual Rank 1 1263 1276 const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820}; 1264 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1277 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1265 1278 } 1266 1279 return; … … 2238 2251 m_caster->ModifyPower(POWER_MANA,gain); 2239 2252 //send log 2240 m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA ,false);2253 m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA); 2241 2254 } 2242 2255 } … … 2254 2267 /*do not uncomment . 2255 2268 if(bg->GetTypeID()==BATTLEGROUND_WS) 2256 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2269 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2257 2270 sLog.outDebug("Send Event Horde Flag Picked Up"); 2258 2271 break; … … 2267 2280 /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion 2268 2281 if(bg->GetTypeID()==BATTLEGROUND_WS) 2269 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2282 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2270 2283 sLog.outDebug("Send Event Alliance Flag Picked Up"); 2271 2284 break; … … 2278 2291 case 23385: // Alliance Flag Returns 2279 2292 if(bg->GetTypeID()==BATTLEGROUND_WS) 2280 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2293 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2281 2294 sLog.outDebug("Alliance Flag Returned"); 2282 2295 break; 2283 2296 case 23386: // Horde Flag Returns 2284 2297 if(bg->GetTypeID()==BATTLEGROUND_WS) 2285 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2298 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2286 2299 sLog.outDebug("Horde Flag Returned"); 2287 2300 break;*/ … … 2289 2302 /* 2290 2303 if(bg->GetTypeID()==BATTLEGROUND_EY) 2291 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);2304 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 2292 2305 */ 2293 2306 break; … … 2638 2651 float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); 2639 2652 Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; 2653 if(!caster) return; 2640 2654 2641 2655 if(Player* modOwner = caster->GetSpellModOwner()) … … 2667 2681 2668 2682 // Some level depends spells 2669 int multiplier = 0;2683 int multiplier = 0; 2670 2684 int level_diff = 0; 2671 2685 switch (m_spellInfo->Id) … … 2674 2688 case 9512: 2675 2689 level_diff = m_caster->getLevel() - 40; 2676 multiplier = 2;2690 multiplier = 2; 2677 2691 break; 2678 2692 // Blood Fury 2679 2693 case 24571: 2680 2694 level_diff = m_caster->getLevel() - 60; 2681 multiplier = 10;2695 multiplier = 10; 2682 2696 break; 2683 2697 // Burst of Energy 2684 2698 case 24532: 2685 2699 level_diff = m_caster->getLevel() - 60; 2686 multiplier = 4;2700 multiplier = 4; 2687 2701 break; 2688 2702 default: … … 3746 3760 ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); 3747 3761 else 3748 MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation());3762 m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); 3749 3763 } 3750 3764 … … 3767 3781 return; 3768 3782 3769 sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow());3783 sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, damage, ((Player*)unitTarget)->GetGUIDLow()); 3770 3784 3771 3785 // TODO: find formula for honor reward based on player's level! … … 3773 3787 // now fixed only for level 70 players: 3774 3788 if (((Player*)unitTarget)->getLevel() == 70) 3775 ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage);3789 ((Player*)unitTarget)->RewardHonor(NULL, 1, damage); 3776 3790 } 3777 3791 … … 3988 4002 3989 4003 // add to world 3990 MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);4004 pet->GetMap()->Add((Creature*)pet); 3991 4005 3992 4006 // visual effect for levelup … … 4018 4032 return; 4019 4033 4020 MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false);4034 OldSummon->GetMap()->Remove((Creature*)OldSummon,false); 4021 4035 OldSummon->SetMapId(m_caster->GetMapId()); 4022 4036 … … 4025 4039 4026 4040 OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); 4027 MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon);4041 m_caster->GetMap()->Add((Creature*)OldSummon); 4028 4042 4029 4043 if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) … … 4108 4122 if(m_caster->GetTypeId() == TYPEID_UNIT) 4109 4123 { 4110 if ( ((Creature*)m_caster)->isTotem() )4111 NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);4112 else4113 NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);4124 if ( ((Creature*)m_caster)->isTotem() ) 4125 NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); 4126 else 4127 NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); 4114 4128 } 4115 4129 … … 4433 4447 ((Player*)m_caster)->AddComboPoints(unitTarget, 1); 4434 4448 } 4449 4435 4450 // Mangle (Cat): CP 4436 4451 if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) … … 4439 4454 ((Player*)m_caster)->AddComboPoints(unitTarget,1); 4440 4455 } 4441 4442 4456 4443 4457 // take ammo … … 5435 5449 } 5436 5450 5437 void Spell::EffectResurrect(uint32 i)5451 void Spell::EffectResurrect(uint32 /*effIndex*/) 5438 5452 { 5439 5453 if(!unitTarget) … … 5656 5670 int32 targetLevel = creature->getLevel(); 5657 5671 5658 uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 5672 uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 5659 5673 5660 5674 ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); … … 5683 5697 5684 5698 if(m_caster->GetTypeId() != TYPEID_PLAYER) 5685 MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation());5699 m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); 5686 5700 5687 5701 // not all charge effects used in negative spells … … 6119 6133 linkedGO->SetOwnerGUID(m_caster->GetGUID() ); 6120 6134 6121 MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO);6135 linkedGO->GetMap()->Add(linkedGO); 6122 6136 } 6123 6137 else -
trunk/src/game/SpellHandler.cpp
r275 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 56 56 } 57 57 58 if(pItem->GetGUID() != item_guid) 59 { 60 pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); 61 return; 62 } 63 58 64 sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, spell_count: %u , cast_count: %u, Item: %u, data length = %i", bagIndex, slot, spell_count, cast_count, pItem->GetEntry(), recvPacket.size()); 59 65 … … 239 245 240 246 pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); 241 pItem->Set UInt32Value(OBJECT_FIELD_ENTRY,entry);247 pItem->SetEntry(entry); 242 248 pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags); 243 249 pItem->SetState(ITEM_CHANGED, pUser); … … 261 267 262 268 uint64 guid; 263 uint32 spellId = OPEN_CHEST;264 269 265 270 recv_data >> guid; … … 324 329 325 330 Spell *spell = new Spell(_player, spellInfo, false); 326 spell->m_cast_count = cast_count; // set count of casts331 spell->m_cast_count = cast_count; // set count of casts 327 332 spell->prepare(&targets); 328 333 } … … 365 370 spellInfo->EffectApplyAuraName[i] == SPELL_AURA_BIND_SIGHT) 366 371 { 372 // Fix me: creature may be killed during player aura cancel 367 373 _player->RemoveAurasDueToSpellByCancel(spellId); 368 374 if (_player->GetCharm()) 369 375 _player->GetCharm()->RemoveAurasDueToSpellByCancel(spellId); 370 else if (_player->GetFarsightTarget() ->GetTypeId() != TYPEID_DYNAMICOBJECT)376 else if (_player->GetFarsightTarget() && _player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT) 371 377 ((Unit*)_player->GetFarsightTarget())->RemoveAurasDueToSpellByCancel(spellId); 372 378 return; -
trunk/src/game/SpellMgr.cpp
r272 r279 100 100 } 101 101 102 bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2)102 /*bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) 103 103 { 104 104 SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); … … 114 114 115 115 return true; 116 } 116 }*/ 117 117 118 118 int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) … … 245 245 case SPELL_CURSE: 246 246 case SPELL_ASPECT: 247 case SPELL_POSITIVE_SHOUT: 248 case SPELL_JUDGEMENT: 249 case SPELL_WARLOCK_CORRUPTION: 250 return spellSpec1==spellSpec2; 251 default: 252 return false; 253 } 254 } 255 256 bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2) 257 { 258 switch(spellSpec1) 259 { 247 260 case SPELL_TRACKER: 248 261 case SPELL_WARLOCK_ARMOR: … … 250 263 case SPELL_ELEMENTAL_SHIELD: 251 264 case SPELL_MAGE_POLYMORPH: 252 case SPELL_POSITIVE_SHOUT:253 case SPELL_JUDGEMENT:254 case SPELL_WARLOCK_CORRUPTION:255 265 return spellSpec1==spellSpec2; 256 266 case SPELL_BATTLE_ELIXIR: … … 1031 1041 } 1032 1042 1033 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2 ) const1034 { 1035 if(spellId_1 == spellId_2) // auras due to the same spell1036 return false;1043 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const 1044 { 1045 //if(spellId_1 == spellId_2) // auras due to the same spell 1046 // return false; 1037 1047 1038 1048 SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); … … 1042 1052 return false; 1043 1053 1054 SpellSpecific spellId_spec_1 = GetSpellSpecific(spellId_1); 1055 SpellSpecific spellId_spec_2 = GetSpellSpecific(spellId_2); 1056 if (spellId_spec_1 && spellId_spec_2) 1057 if (IsSingleFromSpellSpecificPerTarget(spellId_spec_1, spellId_spec_2) 1058 ||(IsSingleFromSpellSpecificPerCaster(spellId_spec_1, spellId_spec_2) && sameCaster)) 1059 return true; 1060 1044 1061 if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) 1045 1062 return false; 1046 1063 1047 if(!spellInfo_1->SpellFamilyName) // generic spells 1064 // generic spells 1065 if(!spellInfo_1->SpellFamilyName) 1048 1066 { 1049 1067 if(!spellInfo_1->SpellIconID … … 1051 1069 return false; 1052 1070 } 1053 else if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) 1054 return false; 1071 1072 // if both elixirs are not battle/guardian/potions/flasks then always stack 1073 else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION) 1074 { 1075 if(spellId_spec_1 || spellId_spec_2) 1076 return false; 1077 } 1078 1079 // check for class spells 1080 else 1081 { 1082 if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) 1083 return false; 1084 } 1055 1085 1056 1086 for(uint32 i = 0; i < 3; ++i) 1087 { 1057 1088 if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i] 1058 || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) 1059 return false; 1089 || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i] 1090 || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i]) // paladin resist aura 1091 return false; // need itemtype check? need an example to add that check 1092 1093 if(spellInfo_1->EffectApplyAuraName[i] // both spell has the same auras 1094 && !sameCaster 1095 && spellInfo_1->Effect[i] != SPELL_EFFECT_APPLY_AREA_AURA_PARTY) // not area auras (shaman totem) 1096 // a better check may be effect == SPELL_EFFECT_APPLY_AURA 1097 { 1098 switch(spellInfo_1->EffectApplyAuraName[i]) 1099 { 1100 // DOT or HOT from different casters will stack 1101 case SPELL_AURA_PERIODIC_DAMAGE: 1102 case SPELL_AURA_PERIODIC_HEAL: 1103 case SPELL_AURA_PERIODIC_TRIGGER_SPELL: 1104 case SPELL_AURA_PERIODIC_ENERGIZE: 1105 case SPELL_AURA_PERIODIC_MANA_LEECH: 1106 case SPELL_AURA_PERIODIC_LEECH: 1107 return false; 1108 default: 1109 break; 1110 } 1111 } 1112 } 1060 1113 1061 1114 return true; -
trunk/src/game/SpellMgr.h
r272 r279 285 285 } 286 286 287 bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2);287 //bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); 288 288 289 289 inline bool IsSealSpell(SpellEntry const *spellInfo) … … 301 301 302 302 int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); 303 bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2); 303 bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1, uint32 spellSpec2); 304 bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1, uint32 spellSpec2); 304 305 bool IsPassiveSpell(uint32 spellId); 305 306 … … 769 770 bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const; 770 771 static bool canStackSpellRanks(SpellEntry const *spellInfo); 771 bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2 ) const;772 bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const; 772 773 773 774 SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const; -
trunk/src/game/StatSystem.cpp
r272 r279 385 385 weapon_maxdamage = lvl*1.25*att_speed; 386 386 } 387 else if(!IsUseEquip pedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc)387 else if(!IsUseEquipedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) 388 388 { 389 389 weapon_mindamage = BASE_MINDAMAGE; -
trunk/src/game/Totem.cpp
r272 r279 98 98 default: break; 99 99 } 100 101 if(GetEntry() == SENTRY_TOTEM_ENTRY) 102 SetAggressive(true); 100 103 } 101 104 -
trunk/src/game/Unit.cpp
r277 r279 1150 1150 if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) 1151 1151 { 1152 uint32 modDamage=*damage;1153 1154 1152 // apply spellmod to Done damage 1155 1153 if(Player* modOwner = GetSpellModOwner()) … … 1436 1434 if(!this || !pVictim) 1437 1435 return 0; 1438 if(! this->isAlive() || !pVictim->isAlive())1436 if(!isAlive() || !pVictim->isAlive()) 1439 1437 return 0; 1440 1438 … … 3799 3797 { 3800 3798 m_ccAuras.push_back(Aur); 3801 RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC);3802 3799 } 3803 3800 } … … 3915 3912 if(!is_triggered_by_spell) 3916 3913 { 3917 SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); 3918 3919 bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); 3920 3921 if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) 3922 { 3923 // cannot remove higher rank 3924 if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 3925 if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 3926 return false; 3914 bool sameCaster = Aur->GetCasterGUID() == (*i).second->GetCasterGUID(); 3915 if( spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId, sameCaster) ) 3916 { 3917 //some spells should be not removed by lower rank of them 3918 // what is this spell? 3919 if (!sameCaster 3920 &&(spellProto->Effect[effIndex]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY) 3921 &&(spellProto->DurationIndex==21) 3922 &&(spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 3923 &&(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)) 3924 return false; 3927 3925 3928 3926 // Its a parent aura (create this aura in ApplyModifier) … … 3938 3936 else 3939 3937 next = m_Auras.begin(); 3940 }3941 else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) )3942 {3943 // Its a parent aura (create this aura in ApplyModifier)3944 if ((*i).second->IsInUse())3945 {3946 sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex());3947 continue;3948 }3949 RemoveAurasDueToSpell(i_spellId);3950 3951 if( m_Auras.empty() )3952 break;3953 else3954 next = m_Auras.begin();3955 }3956 // Potions stack aura by aura (elixirs/flask already checked)3957 else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION )3958 {3959 if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex))3960 {3961 if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)3962 return false; // cannot remove higher rank3963 3964 // Its a parent aura (create this aura in ApplyModifier)3965 if ((*i).second->IsInUse())3966 {3967 sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex());3968 continue;3969 }3970 RemoveAura(i);3971 next = i;3972 }3973 3938 } 3974 3939 } … … 4145 4110 void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) 4146 4111 { 4147 if (IsSingleTargetSpell((*i).second->GetSpellProto())) 4148 { 4149 if(Unit* caster = (*i).second->GetCaster()) 4112 Aura* Aur = i->second; 4113 SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); 4114 4115 Unit* caster = NULL; 4116 if (IsSingleTargetSpell(AurSpellInfo)) 4117 { 4118 caster = Aur->GetCaster(); 4119 if(caster) 4150 4120 { 4151 4121 AuraList& scAuras = caster->GetSingleCastAuras(); 4152 scAuras.remove( (*i).second);4122 scAuras.remove(Aur); 4153 4123 } 4154 4124 else … … 4159 4129 } 4160 4130 4161 if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) 4131 // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) 4132 if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) 4162 4133 { 4163 4134 m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); … … 4171 4142 } 4172 4143 4173 // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)4174 Aura* Aur = i->second;4175 4144 // Set remove mode 4176 4145 Aur->SetRemoveMode(mode); … … 4180 4149 ++m_removedAuras; // internal count used by unit update 4181 4150 4182 // Statu sunsummoned at aura remove4151 // Statue unsummoned at aura remove 4183 4152 Totem* statue = NULL; 4184 if(IsChanneledSpell(Aur->GetSpellProto())) 4185 if(Unit* caster = Aur->GetCaster()) 4153 bool caster_channeled = false; 4154 if(IsChanneledSpell(AurSpellInfo)) 4155 { 4156 if(!caster) // can be already located for IsSingleTargetSpell case 4157 caster = Aur->GetCaster(); 4158 4159 if(caster) 4160 { 4186 4161 if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) 4187 4162 statue = ((Totem*)caster); 4188 4163 else 4164 caster_channeled = caster==this; 4165 } 4166 } 4189 4167 4190 4168 if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id)) … … 4203 4181 Aur->_RemoveAura(); 4204 4182 delete Aur; 4183 4184 if(caster_channeled) 4185 RemoveAurasAtChanneledTarget (AurSpellInfo); 4205 4186 4206 4187 if(statue) … … 4629 4610 } 4630 4611 4631 bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) 4632 { 4612 bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 cooldown) 4613 { 4614 SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto(); 4615 4633 4616 Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 4634 4617 ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; … … 4690 4673 } 4691 4674 4692 bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 4693 { 4675 bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 4676 { 4677 SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); 4678 uint32 effIndex = triggeredByAura->GetEffIndex (); 4679 4694 4680 Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 4695 4681 ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; … … 6279 6265 return false; 6280 6266 6281 uint32 spell = 0;6282 6267 switch(triggeredByAura->GetSpellProto()->Id) 6283 6268 { … … 6309 6294 6310 6295 // overwrite non existing triggered spell call in spell.dbc 6311 uint32 spell = 0;6312 6296 switch(triggeredByAura->GetSpellProto()->Id) 6313 6297 { … … 6509 6493 } 6510 6494 6511 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 6512 { 6495 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 6496 { 6497 int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; 6498 6513 6499 if(!pVictim || !pVictim->isAlive()) 6514 6500 return false; … … 7276 7262 } 7277 7263 7278 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype , bool critical)7264 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype) 7279 7265 { 7280 7266 WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); … … 7376 7362 AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); 7377 7363 for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) 7378 if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto))7364 if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) ) 7379 7365 TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; 7380 7366 … … 8224 8210 8225 8211 // ..done (for creature type by mask) in taken 8226 AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);8212 AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); 8227 8213 for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) 8228 8214 if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) … … 8292 8278 // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage 8293 8279 8294 AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);8280 AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); 8295 8281 for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) 8296 8282 if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) … … 8522 8508 target->SetStandState(PLAYER_STATE_NONE); 8523 8509 8524 if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) 8510 if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER 8511 && ((Creature*)target)->isAggressive() && ((Creature*)target)->AI()) 8525 8512 ((Creature*)target)->AI()->AttackStart(this); 8526 8513 … … 8571 8558 { 8572 8559 assert(target); 8560 8561 if(!IsHostileTo(target)) 8562 return false; 8573 8563 8574 8564 if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) … … 8747 8737 if(IsInWorld()) 8748 8738 { 8749 Map *m = MapManager::Instance().GetMap(GetMapId(), this);8739 Map *m = GetMap(); 8750 8740 8751 8741 if(GetTypeId()==TYPEID_PLAYER) … … 9156 9146 } 9157 9147 9148 // search nearby enemy before enter evade mode 9149 if(Unit *target = ((Creature*)this)->SelectNearestTarget()) 9150 { 9151 ((Creature*)this)->AI()->AttackStart(target); 9152 return true; 9153 } 9154 9158 9155 // enter in evade mode in other case 9159 9156 ((Creature*)this)->AI()->EnterEvadeMode(); … … 9809 9806 } 9810 9807 9811 9812 9813 9808 CharmInfo* Unit::InitCharmInfo(Unit *charm) 9814 9809 { … … 9985 9980 struct ProcTriggeredData 9986 9981 { 9987 ProcTriggeredData( SpellEntry const * _spellInfo, uint32 _spellParam,Aura* _triggeredByAura, uint32 _cooldown)9988 : spellInfo(_spellInfo), spellParam(_spellParam),triggeredByAura(_triggeredByAura),9982 ProcTriggeredData(Aura* _triggeredByAura, uint32 _cooldown) 9983 : triggeredByAura(_triggeredByAura), 9989 9984 triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), 9990 9985 cooldown(_cooldown) 9991 {} 9992 9993 SpellEntry const * spellInfo; 9994 uint32 spellParam; 9995 Aura* triggeredByAura; 9996 Unit::spellEffectPair triggeredByAura_SpellPair; 9997 uint32 cooldown; 9986 {} 9987 9988 Aura* triggeredByAura; // triggred aura, can be invalidate at triggered aura proccessing 9989 Unit::spellEffectPair triggeredByAura_SpellPair; // spell pair, used for re-find aura (by pointer comparison in range) 9990 uint32 cooldown; // possible hidden cooldown 9998 9991 }; 9999 9992 … … 10012 10005 next = i; ++next; 10013 10006 10014 SpellEntry const *spellProto = (*i)->GetSpellProto(); 10015 if(!spellProto) 10007 Aura* i_aura = *i; 10008 10009 uint32 cooldown; // returned at next line 10010 if(!IsTriggeredAtSpellProcEvent(i_aura->GetSpellProto(), procSpell, procFlag,attType,isVictim,cooldown)) 10016 10011 continue; 10017 10012 10018 SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 10019 if(!spellProcEvent) 10020 { 10021 // used to prevent spam in log about same non-handled spells 10022 static std::set<uint32> nonHandledSpellProcSet; 10023 10024 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 10025 { 10026 sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 10027 nonHandledSpellProcSet.insert(spellProto->Id); 10028 } 10029 10030 // spell.dbc use totally different flags, that only can create problems if used. 10031 continue; 10032 } 10033 10034 // Check spellProcEvent data requirements 10035 if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 10036 continue; 10037 10038 // Check if current equipment allows aura to proc 10039 if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 10040 { 10041 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 10042 { 10043 Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 10044 10045 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10046 continue; 10047 } 10048 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 10049 { 10050 // Check if player is wearing shield 10051 Item *item = ((Player*)this)->GetShield(true); 10052 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10053 continue; 10054 } 10055 } 10056 10057 float chance = (float)spellProto->procChance; 10058 10059 if(Player* modOwner = GetSpellModOwner()) 10060 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 10061 10062 if(!isVictim && spellProcEvent->ppmRate != 0) 10063 { 10064 uint32 WeaponSpeed = GetAttackTime(attType); 10065 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 10066 } 10067 10068 if(roll_chance_f(chance)) 10069 { 10070 uint32 cooldown = spellProcEvent->cooldown; 10071 10072 uint32 i_spell_eff = (*i)->GetEffIndex(); 10073 10074 int32 i_spell_param; 10075 switch(*aur) 10076 { 10077 case SPELL_AURA_PROC_TRIGGER_SPELL: 10078 i_spell_param = procFlag; 10079 break; 10080 case SPELL_AURA_DUMMY: 10081 case SPELL_AURA_PRAYER_OF_MENDING: 10082 case SPELL_AURA_MOD_HASTE: 10083 i_spell_param = i_spell_eff; 10084 break; 10085 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 10086 i_spell_param = (*i)->GetModifier()->m_miscvalue; 10087 break; 10088 default: 10089 i_spell_param = (*i)->GetModifier()->m_amount; 10090 break; 10091 } 10092 10093 procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); 10094 } 10013 procTriggered.push_back( ProcTriggeredData(i_aura, cooldown) ); 10095 10014 } 10096 10015 … … 10125 10044 } 10126 10045 10127 // save charges existence before processing to prevent crash at access to deleted triggered aura after 10128 bool triggeredByAuraWithCharges = i->triggeredByAura->m_procCharges > 0; 10129 10046 /// this is aura triggering code call 10047 Aura* triggeredByAura = i->triggeredByAura; 10048 10049 /// save charges existence before processing to prevent crash at access to deleted triggered aura after 10050 /// used in speedup code check before check aura existance. 10051 bool triggeredByAuraWithCharges = triggeredByAura->m_procCharges > 0; 10052 10053 /// success in event proccesing 10054 /// used in speedup code check before check aura existance. 10130 10055 bool casted = false; 10056 10057 /// process triggered code 10131 10058 switch(*aur) 10132 10059 { 10133 10060 case SPELL_AURA_PROC_TRIGGER_SPELL: 10134 10061 { 10135 sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10136 casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); 10062 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s proc aura of spell %u)", 10063 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10064 casted = HandleProcTriggerSpell(pTarget, damage, triggeredByAura, procSpell, procFlag, attType, i->cooldown); 10137 10065 break; 10138 10066 } 10139 10067 case SPELL_AURA_PROC_TRIGGER_DAMAGE: 10140 10068 { 10141 sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10142 uint32 damage = i->spellParam; 10143 SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); 10069 uint32 triggered_damage = triggeredByAura->GetModifier()->m_amount; 10070 sLog.outDebug("ProcDamageAndSpell: doing %u damage (triggered by %s aura of spell %u)", 10071 triggered_damage, (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10072 SpellNonMeleeDamageLog(pTarget, triggeredByAura->GetId(), triggered_damage, true, true); 10144 10073 casted = true; 10145 10074 break; … … 10147 10076 case SPELL_AURA_DUMMY: 10148 10077 { 10149 sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10150 casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 10078 uint32 effect = triggeredByAura->GetEffIndex(); 10079 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s dummy aura of spell %u)", 10080 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10081 casted = HandleDummyAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 10151 10082 break; 10152 10083 } 10153 10084 case SPELL_AURA_PRAYER_OF_MENDING: 10154 10085 { 10155 sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10156 10157 // aura can be deleted at casts 10158 int32 heal = i->triggeredByAura->GetModifier()->m_amount; 10159 uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); 10160 10161 // jumps 10162 int32 jumps = i->triggeredByAura->m_procCharges-1; 10163 10164 // current aura expire 10165 i->triggeredByAura->m_procCharges = 1; // will removed at next charges decrease 10166 10167 // next target selection 10168 if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 10169 { 10170 Aura* aura = i->triggeredByAura; 10171 10172 SpellEntry const* spellProto = aura->GetSpellProto(); 10173 uint32 effIdx = aura->GetEffIndex(); 10174 10175 float radius; 10176 if (spellProto->EffectRadiusIndex[effIdx]) 10177 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 10178 else 10179 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 10180 10181 if(Player* caster = ((Player*)aura->GetCaster())) 10182 { 10183 caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 10184 10185 if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 10186 { 10187 // aura will applied from caster, but spell casted from current aura holder 10188 SpellModifier *mod = new SpellModifier; 10189 mod->op = SPELLMOD_CHARGES; 10190 mod->value = jumps-5; // negative 10191 mod->type = SPELLMOD_FLAT; 10192 mod->spellId = spellProto->Id; 10193 mod->effectId = effIdx; 10194 mod->lastAffected = NULL; 10195 mod->mask = spellProto->SpellFamilyFlags; 10196 mod->charges = 0; 10197 10198 caster->AddSpellMod(mod, true); 10199 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); 10200 caster->AddSpellMod(mod, false); 10201 } 10202 } 10203 } 10204 10205 // heal 10206 CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 10207 casted = true; 10086 sLog.outDebug("ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)", 10087 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10088 10089 casted = HandleMeandingAuraProc(triggeredByAura); 10208 10090 break; 10209 10091 } 10210 10092 case SPELL_AURA_MOD_HASTE: 10211 10093 { 10212 sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10213 casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 10094 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s haste aura of spell %u)", 10095 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10096 casted = HandleHasteAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 10214 10097 break; 10215 10098 } … … 10218 10101 // nothing do, just charges counter 10219 10102 // but count only in case appropriate school damage 10220 casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask;10103 casted = triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; 10221 10104 break; 10222 10105 } 10223 10106 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 10224 10107 { 10225 sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 10226 casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); 10108 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)", 10109 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10110 casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown); 10227 10111 break; 10228 10112 } … … 10235 10119 } 10236 10120 10237 // Update charge (aura can be removed by triggers)10121 /// Update charge (aura can be removed by triggers) 10238 10122 if(casted && triggeredByAuraWithCharges) 10239 10123 { 10240 // needfound aura (can be dropped by triggers)10124 /// need re-found aura (can be dropped by triggers) 10241 10125 AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); 10242 10126 AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); 10243 10127 for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) 10244 10128 { 10245 if(itr->second == i->triggeredByAura)10129 if(itr->second == triggeredByAura) // pointer still valid 10246 10130 { 10247 if( i->triggeredByAura->m_procCharges > 0)10248 i->triggeredByAura->m_procCharges -= 1;10249 10250 i->triggeredByAura->UpdateAuraCharges();10131 if(triggeredByAura->m_procCharges > 0) 10132 triggeredByAura->m_procCharges -= 1; 10133 10134 triggeredByAura->UpdateAuraCharges(); 10251 10135 break; 10252 10136 } … … 10255 10139 } 10256 10140 10257 // Safely remove auras with zero charges10141 /// Safely remove auras with zero charges 10258 10142 for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) 10259 10143 { … … 10368 10252 // send explicit stop packet 10369 10253 // rely on vmaps here because for example stormwind is in air 10370 float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);10254 //float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); 10371 10255 //if (fabs(GetPositionZ() - z) < 2.0f) 10372 10256 // Relocate(GetPositionX(), GetPositionY(), z); … … 10578 10462 } 10579 10463 10580 Unit* Unit::SelectNearbyTarget( ) const10464 Unit* Unit::SelectNearbyTarget(float dist) const 10581 10465 { 10582 10466 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); … … 10588 10472 10589 10473 { 10590 Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE);10474 Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist); 10591 10475 Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(targets, u_check); 10592 10476 … … 10852 10736 } 10853 10737 10854 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID());10855 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID());10856 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, this->getFaction());10738 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()); 10739 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID()); 10740 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction()); 10857 10741 pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); 10858 10742 … … 10872 10756 return pet; 10873 10757 } 10758 10759 bool Unit::IsTriggeredAtSpellProcEvent(SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ) 10760 { 10761 SpellProcEventEntry const * spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 10762 10763 if(!spellProcEvent) 10764 { 10765 // used to prevent spam in log about same non-handled spells 10766 static std::set<uint32> nonHandledSpellProcSet; 10767 10768 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 10769 { 10770 sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 10771 nonHandledSpellProcSet.insert(spellProto->Id); 10772 } 10773 10774 // spell.dbc use totally different flags, that only can create problems if used. 10775 return false; 10776 } 10777 10778 // Check spellProcEvent data requirements 10779 if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 10780 return false; 10781 10782 // Check if current equipment allows aura to proc 10783 if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 10784 { 10785 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 10786 { 10787 Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 10788 10789 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10790 return false; 10791 } 10792 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 10793 { 10794 // Check if player is wearing shield 10795 Item *item = ((Player*)this)->GetShield(true); 10796 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10797 return false; 10798 } 10799 } 10800 10801 float chance = (float)spellProto->procChance; 10802 10803 if(Player* modOwner = GetSpellModOwner()) 10804 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 10805 10806 if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0) 10807 { 10808 uint32 WeaponSpeed = GetAttackTime(attType); 10809 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 10810 } 10811 10812 cooldown = spellProcEvent ? spellProcEvent->cooldown : 0; 10813 return roll_chance_f(chance); 10814 } 10815 10816 bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura ) 10817 { 10818 // aura can be deleted at casts 10819 SpellEntry const* spellProto = triggeredByAura->GetSpellProto(); 10820 uint32 effIdx = triggeredByAura->GetEffIndex(); 10821 int32 heal = triggeredByAura->GetModifier()->m_amount; 10822 uint64 caster_guid = triggeredByAura->GetCasterGUID(); 10823 10824 // jumps 10825 int32 jumps = triggeredByAura->m_procCharges-1; 10826 10827 // current aura expire 10828 triggeredByAura->m_procCharges = 1; // will removed at next charges decrease 10829 10830 // next target selection 10831 if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 10832 { 10833 float radius; 10834 if (spellProto->EffectRadiusIndex[effIdx]) 10835 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 10836 else 10837 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 10838 10839 if(Player* caster = ((Player*)triggeredByAura->GetCaster())) 10840 { 10841 caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 10842 10843 if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 10844 { 10845 // aura will applied from caster, but spell casted from current aura holder 10846 SpellModifier *mod = new SpellModifier; 10847 mod->op = SPELLMOD_CHARGES; 10848 mod->value = jumps-5; // negative 10849 mod->type = SPELLMOD_FLAT; 10850 mod->spellId = spellProto->Id; 10851 mod->effectId = effIdx; 10852 mod->lastAffected = NULL; 10853 mod->mask = spellProto->SpellFamilyFlags; 10854 mod->charges = 0; 10855 10856 caster->AddSpellMod(mod, true); 10857 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID()); 10858 caster->AddSpellMod(mod, false); 10859 } 10860 } 10861 } 10862 10863 // heal 10864 CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 10865 return true; 10866 } 10867 10868 void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo) 10869 { 10870 uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT); 10871 10872 if(!IS_UNIT_GUID(target_guid)) 10873 return; 10874 10875 Unit* target = ObjectAccessor::GetUnit(*this, target_guid); 10876 if(!target) 10877 return; 10878 10879 for (AuraMap::iterator iter = target->GetAuras().begin(); iter != target->GetAuras().end(); ) 10880 { 10881 if (iter->second->GetId() == spellInfo->Id && iter->second->GetCasterGUID()==GetGUID()) 10882 target->RemoveAura(iter); 10883 else 10884 ++iter; 10885 } 10886 } -
trunk/src/game/Unit.h
r277 r279 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 764 764 void CombatStop(bool cast = false); 765 765 void CombatStopWithPets(bool cast = false); 766 Unit* SelectNearbyTarget( ) const;766 Unit* SelectNearbyTarget(float dist = ATTACK_DISTANCE) const; 767 767 768 768 void addUnitState(uint32 f) { m_state |= f; } … … 935 935 936 936 void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); 937 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype , bool critical = false);937 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); 938 938 uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); 939 939 void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); … … 1041 1041 void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); 1042 1042 void RemoveAurasDueToSpellByCancel(uint32 spellId); 1043 void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); 1043 1044 void RemoveNotOwnSingleTargetAuras(); 1044 1045 … … 1372 1373 1373 1374 void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); 1374 bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 1375 bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); 1376 bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 1377 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell,uint32 cooldown); 1375 bool IsTriggeredAtSpellProcEvent( SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ); 1376 bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 1377 bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, uint32 cooldown); 1378 bool HandleHasteAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 1379 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 cooldown); 1380 bool HandleMeandingAuraProc(Aura* triggeredByAura); 1378 1381 1379 1382 uint32 m_state; // Even derived shouldn't modify -
trunk/src/game/WaypointManager.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 25 25 #include "ProgressBar.h" 26 26 #include "MapManager.h" 27 #include "ObjectMgr.h" 27 28 28 29 INSTANTIATE_SINGLETON_1(WaypointManager); … … 30 31 bool WaypointBehavior::isEmpty() 31 32 { 32 return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() && 33 text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty(); 33 if (emote || spell || model1 || model2) 34 return false; 35 36 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 37 if(textid[i]) 38 return false; 39 40 return true; 34 41 } 35 42 36 43 WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) 37 44 { 38 emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2; 39 text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2]; 40 text[3] = b.text[3]; text[4] = b.text[4]; 45 emote = b.emote; 46 spell = b.spell; 47 model1 = b.model1; 48 model2 = b.model2; 49 for(int i=0; i < MAX_WAYPOINT_TEXT; ++i) 50 textid[i] = b.textid[i]; 41 51 } 42 52 … … 67 77 } 68 78 69 result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text 1, text2, text3, text4, text5, id, point FROM creature_movement");79 result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement"); 70 80 if(result) 71 81 { … … 114 124 be.emote = fields[7].GetUInt32(); 115 125 be.spell = fields[8].GetUInt32(); 116 be.text[0] = fields[9].GetCppString(); 117 be.text[1] = fields[10].GetCppString(); 118 be.text[2] = fields[11].GetCppString(); 119 be.text[3] = fields[12].GetCppString(); 120 be.text[4] = fields[13].GetCppString(); 126 127 // load and store without holes in array 128 int j = 0; 129 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 130 { 131 be.textid[j] = fields[9+i].GetUInt32(); 132 if(be.textid[j]) 133 { 134 if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) 135 { 136 sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]); 137 continue; 138 } 139 140 if (!objmgr.GetTrinityStringLocale (be.textid[j])) 141 { 142 sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.", 143 id, point, be.textid[j], i+1); 144 continue; 145 } 146 147 ++j; // to next internal field 148 } 149 } 150 // fill array tail 151 for(; j < MAX_WAYPOINT_TEXT; ++j) 152 be.textid[j] = 0; 121 153 122 154 // save memory by not storing empty behaviors … … 266 298 if(!node.behavior) node.behavior = new WaypointBehavior(); 267 299 268 if(field == "text1") node.behavior->text[0] = text ? text : "";269 if(field == "text2") node.behavior->text[1] = text ? text : "";270 if(field == "text3") node.behavior->text[2] = text ? text : "";271 if(field == "text4") node.behavior->text[3] = text ? text : "";272 if(field == "text5") node.behavior->text[4] = text ? text : "";300 // if(field == "text1") node.behavior->text[0] = text ? text : ""; 301 // if(field == "text2") node.behavior->text[1] = text ? text : ""; 302 // if(field == "text3") node.behavior->text[2] = text ? text : ""; 303 // if(field == "text4") node.behavior->text[3] = text ? text : ""; 304 // if(field == "text5") node.behavior->text[4] = text ? text : ""; 273 305 if(field == "emote") node.behavior->emote = text ? atoi(text) : 0; 274 306 if(field == "spell") node.behavior->spell = text ? atoi(text) : 0; -
trunk/src/game/WaypointManager.h
r272 r279 26 26 #include "Utilities/UnorderedMap.h" 27 27 28 #define MAX_WAYPOINT_TEXT 5 28 29 struct WaypointBehavior 29 30 { 30 31 uint32 emote; 31 32 uint32 spell; 32 std::string text[5];33 int32 textid[MAX_WAYPOINT_TEXT]; 33 34 uint32 model1; 34 35 uint32 model2; -
trunk/src/game/WaypointMovementGenerator.cpp
r272 r279 22 22 creature_movement Table 23 23 24 alter table creature_movement add `text 1` varchar(255) default NULL;25 alter table creature_movement add `text 2` varchar(255) default NULL;26 alter table creature_movement add `text 3` varchar(255) default NULL;27 alter table creature_movement add `text 4` varchar(255) default NULL;28 alter table creature_movement add `text 5` varchar(255) default NULL;24 alter table creature_movement add `textid1` int(11) NOT NULL default '0'; 25 alter table creature_movement add `textid2` int(11) NOT NULL default '0'; 26 alter table creature_movement add `textid3` int(11) NOT NULL default '0'; 27 alter table creature_movement add `textid4` int(11) NOT NULL default '0'; 28 alter table creature_movement add `textid5` int(11) NOT NULL default '0'; 29 29 alter table creature_movement add `emote` int(10) unsigned default '0'; 30 30 alter table creature_movement add `spell` int(5) unsigned default '0'; … … 149 149 if(behavior->model1 != 0) 150 150 creature.SetDisplayId(behavior->model1); 151 if( !behavior->text[0].empty())151 if(behavior->textid[0]) 152 152 { 153 // Only one text is set154 if( !behavior->text[1].empty())153 // Not only one text is set 154 if( behavior->textid[1] ) 155 155 { 156 156 // Select one from max 5 texts (0 and 1 already checked) 157 157 int i = 2; 158 for( ; i < 5; ++i )159 if( behavior->text[i].empty())158 for( ; i < MAX_WAYPOINT_TEXT; ++i ) 159 if( !behavior->textid[i] ) 160 160 break; 161 161 162 creature.Say(behavior->text[rand() % i].c_str(), 0, 0); 163 162 creature.Say(behavior->textid[rand() % i], 0, 0); 164 163 } 165 164 else 166 creature.Say(behavior->text [0].c_str(), 0, 0);165 creature.Say(behavior->textid[0], 0, 0); 167 166 } 168 167 } // wpBehaviour found -
trunk/src/game/World.cpp
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 67 67 68 68 volatile bool World::m_stopEvent = false; 69 uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; 69 70 volatile uint32 World::m_worldLoopCounter = 0; 70 71 … … 543 544 m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 544 545 545 546 546 m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); 547 547 /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define … … 606 606 } 607 607 608 609 608 if(reload) 610 609 { … … 770 769 m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 771 770 772 // always use declined names in the Russian client773 m_configs[CONFIG_DECLINED_NAMES_USED] = 771 // always use declined names in the russian client 772 m_configs[CONFIG_DECLINED_NAMES_USED] = 774 773 (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 775 774 … … 966 965 DetectDBCLang(); 967 966 967 sLog.outString( "Loading Script Names..."); 968 objmgr.LoadScriptNames(); 969 968 970 sLog.outString( "Loading InstanceTemplate" ); 969 971 objmgr.LoadInstanceTemplate(); … … 1081 1083 sLog.outString( "Loading Tavern Area Triggers..." ); 1082 1084 objmgr.LoadTavernAreaTriggers(); 1083 1085 1084 1086 sLog.outString( "Loading AreaTrigger script names..." ); 1085 1087 objmgr.LoadAreaTriggerScripts(); 1086 1087 1088 1088 1089 sLog.outString( "Loading Graveyard-zone links..."); … … 1165 1166 sLog.outString( "Loading Npc Text Id..." ); 1166 1167 objmgr.LoadNpcTextId(); // must be after load Creature and NpcText 1167 1168 1168 1169 sLog.outString( "Loading Npc Options..." ); 1169 1170 objmgr.LoadNpcOptions(); … … 1193 1194 objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) 1194 1195 1196 sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls 1197 objmgr.LoadDbScriptStrings(); 1198 1195 1199 sLog.outString( "Initializing Scripts..." ); 1196 1200 if(!LoadScriptingModule()) … … 1263 1267 sLog.outString( "WORLD: World initialized" ); 1264 1268 } 1269 1265 1270 void World::DetectDBCLang() 1266 1271 { … … 1463 1468 } 1464 1469 1465 MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1470 /// </ul> 1471 ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1472 MapManager::Instance().DoDelayedMovesAndRemoves(); 1466 1473 1467 1474 // update the instance reset times … … 1583 1590 } 1584 1591 1592 //if(source && !source->IsInWorld()) source = NULL; 1593 1585 1594 Object* target = NULL; 1586 1595 … … 1610 1619 } 1611 1620 1621 //if(target && !target->IsInWorld()) target = NULL; 1622 1612 1623 switch (step.script->command) 1613 1624 { … … 1637 1648 { 1638 1649 case 0: // Say 1639 ((Creature *)source)->Say(step.script->data text.c_str(), LANG_UNIVERSAL, unit_target);1650 ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); 1640 1651 break; 1641 1652 case 1: // Whisper … … 1645 1656 break; 1646 1657 } 1647 ((Creature *)source)->Whisper(step.script->data text.c_str(),unit_target);1658 ((Creature *)source)->Whisper(step.script->dataint,unit_target); 1648 1659 break; 1649 1660 case 2: // Yell 1650 ((Creature *)source)->Yell(step.script->data text.c_str(), LANG_UNIVERSAL, unit_target);1661 ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); 1651 1662 break; 1652 1663 case 3: // Emote text 1653 ((Creature *)source)->TextEmote(step.script->data text.c_str(), unit_target);1664 ((Creature *)source)->TextEmote(step.script->dataint, unit_target); 1654 1665 break; 1655 1666 default: … … 1702 1713 } 1703 1714 ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); 1704 MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);1715 ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 1705 1716 break; 1706 1717 case SCRIPT_COMMAND_FLAG_SET: … … 1852 1863 go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds 1853 1864 1854 MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go);1865 go->GetMap()->Add(go); 1855 1866 break; 1856 1867 } … … 2374 2385 2375 2386 ///- if there is a shutdown timer 2376 if( m_ShutdownTimer > 0 && elapsed > 0)2387 if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) 2377 2388 { 2378 2389 ///- ... and it is overdue, stop the world (set m_stopEvent) … … 2380 2391 { 2381 2392 if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2382 m_stopEvent = true; 2393 m_stopEvent = true; // exist code already set 2383 2394 else 2384 2395 m_ShutdownTimer = 1; // minimum timer value to wait idle state … … 2395 2406 2396 2407 /// Shutdown the server 2397 void World::ShutdownServ(uint32 time, uint32 options) 2398 { 2408 void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) 2409 { 2410 // ignore if server shutdown at next tick 2411 if(m_stopEvent) 2412 return; 2413 2399 2414 m_ShutdownMask = options; 2415 m_ExitCode = exitcode; 2400 2416 2401 2417 ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) … … 2403 2419 { 2404 2420 if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2405 m_stopEvent = true; 2421 m_stopEvent = true; // exist code already set 2406 2422 else 2407 2423 m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick … … 2448 2464 void World::ShutdownCancel() 2449 2465 { 2450 if(!m_ShutdownTimer) 2466 // nothing cancel or too later 2467 if(!m_ShutdownTimer || m_stopEvent) 2451 2468 return; 2452 2469 … … 2455 2472 m_ShutdownMask = 0; 2456 2473 m_ShutdownTimer = 0; 2474 m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value 2457 2475 SendServerMessage(msgid); 2458 2476 2459 DEBUG_LOG("Server %s cancel ed.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));2477 DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 2460 2478 } 2461 2479 … … 2502 2520 if(!itr->second->Update(diff)) // As interval = 0 2503 2521 { 2522 RemoveQueuedPlayer (itr->second); 2504 2523 delete itr->second; 2505 2524 m_sessions.erase(itr); -
trunk/src/game/World.h
r272 r279 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 52 52 }; 53 53 54 enum ShutdownExitCode 55 { 56 SHUTDOWN_EXIT_CODE = 0, 57 ERROR_EXIT_CODE = 1, 58 RESTART_EXIT_CODE = 2, 59 }; 60 54 61 /// Timers for different object refresh rates 55 62 enum WorldTimers … … 62 69 WUPDATE_CORPSES = 5, 63 70 WUPDATE_EVENTS = 6, 64 WUPDATE_COUNT = 7, 65 71 WUPDATE_COUNT = 7 66 72 }; 67 73 … … 106 112 CONFIG_INSTANCE_IGNORE_RAID, 107 113 CONFIG_BATTLEGROUND_CAST_DESERTER, 114 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, 115 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY, 108 116 CONFIG_INSTANCE_RESET_TIME_HOUR, 109 117 CONFIG_INSTANCE_UNLOAD_DELAY, … … 144 152 CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, 145 153 CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, 154 CONFIG_DETECT_POS_COLLISION, 146 155 CONFIG_RESTRICTED_LFG_CHANNEL, 147 156 CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, … … 317 326 struct CliCommandHolder 318 327 { 319 typedef void Print(const char*);320 321 char *m_command;322 Print* m_print;323 324 CliCommandHolder(const char *command, Print* zprint)325 : m_print(zprint)326 {327 size_t len = strlen(command)+1;328 m_command = new char[len];329 memcpy(m_command, command, len);330 }331 332 ~CliCommandHolder() { delete[] m_command; }328 typedef void Print(const char*); 329 330 char *m_command; 331 Print* m_print; 332 333 CliCommandHolder(const char *command, Print* zprint) 334 : m_print(zprint) 335 { 336 size_t len = strlen(command)+1; 337 m_command = new char[len]; 338 memcpy(m_command, command, len); 339 } 340 341 ~CliCommandHolder() { delete[] m_command; } 333 342 }; 334 343 … … 337 346 { 338 347 public: 339 static volatile bool m_stopEvent;340 348 static volatile uint32 m_worldLoopCounter; 341 349 … … 345 353 WorldSession* FindSession(uint32 id) const; 346 354 void AddSession(WorldSession *s); 347 348 355 bool RemoveSession(uint32 id); 349 356 /// Get the number of current active sessions … … 408 415 void LoadConfigSettings(bool reload = false); 409 416 410 void SendWorldText(int32 string_id, ...); 417 void SendWorldText(int32 string_id, ...); 411 418 void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); 412 419 void SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); … … 415 422 416 423 /// Are we in the middle of a shutdown? 417 uint32 GetShutdownMask() const { return m_ShutdownMask; }418 424 bool IsShutdowning() const { return m_ShutdownTimer > 0; } 419 void ShutdownServ(uint32 time, uint32 options = 0);425 void ShutdownServ(uint32 time, uint32 options, uint8 exitcode); 420 426 void ShutdownCancel(); 421 427 void ShutdownMsg(bool show = false, Player* player = NULL); 428 static uint8 GetExitCode() { return m_ExitCode; } 429 static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; } 430 static bool IsStopped() { return m_stopEvent; } 422 431 423 432 void Update(time_t diff); … … 454 463 void KickAllQueued(); 455 464 BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); 456 bool RemoveBanAccount(BanMode mode, std::string nameOrIP);465 bool RemoveBanAccount(BanMode mode, std::string nameOrIP); 457 466 458 467 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target); … … 482 491 LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } 483 492 484 //used World DB version485 void LoadDBVersion();486 char const* GetDBVersion() { return m_DBVersion.c_str(); }487 488 //used Script version489 void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; }490 char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); }493 //used World DB version 494 void LoadDBVersion(); 495 char const* GetDBVersion() { return m_DBVersion.c_str(); } 496 497 //used Script version 498 void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; } 499 char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); } 491 500 492 501 protected: … … 499 508 void ResetDailyQuests(); 500 509 private: 510 static volatile bool m_stopEvent; 511 static uint8 m_ExitCode; 512 uint32 m_ShutdownTimer; 513 uint32 m_ShutdownMask; 514 501 515 time_t m_startTime; 502 516 time_t m_gameTime; … … 526 540 std::set<uint32> m_forbiddenMapIds; 527 541 528 uint32 m_ShutdownTimer;529 uint32 m_ShutdownMask;530 531 542 // for max speed access 532 543 static float m_MaxVisibleDistanceForCreature; … … 546 557 //Player Queue 547 558 Queue m_QueuedPlayer; 548 559 549 560 //sessions that are added async 550 561 void AddSession_(WorldSession* s); 551 562 ZThread::LockedQueue<WorldSession*, ZThread::FastMutex> addSessQueue; 552 563 553 //used versions554 std::string m_DBVersion;555 std::string m_ScriptsVersion;564 //used versions 565 std::string m_DBVersion; 566 std::string m_ScriptsVersion; 556 567 }; 557 568
![(please configure the [header_logo] section in trac.ini)](/TrinityCore/trac.cgi/chrome/site/your_project_logo.png)