Changeset 272 for trunk/src/game
- Timestamp:
- 11/22/08 00:35:41 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 64 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) (14 diffs)
-
Creature.h (modified) (9 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)
-
GridStates.cpp (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) (25 diffs)
-
Map.h (modified) (13 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)
-
Object.cpp (modified) (3 diffs)
-
Object.h (modified) (1 diff)
-
ObjectAccessor.cpp (modified) (8 diffs)
-
ObjectAccessor.h (modified) (5 diffs)
-
ObjectMgr.cpp (modified) (44 diffs)
-
ObjectMgr.h (modified) (20 diffs)
-
Pet.cpp (modified) (8 diffs)
-
Player.cpp (modified) (24 diffs)
-
Player.h (modified) (16 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
r260 r272 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 << (uint32)auction->Id;93 data << (uint32) pItem->GetEntry();92 data << auction->Id; 93 data << pItem->GetUInt32Value(OBJECT_FIELD_ENTRY); 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 ed empty bag to auction)248 // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction) 249 249 if(!it) 250 250 { … … 717 717 if (il) 718 718 { 719 if (il->Name.size() > size_t(loc_idx)&& !il->Name[loc_idx].empty())719 if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) 720 720 name = il->Name[loc_idx]; 721 721 } -
trunk/src/game/Bag.cpp
r260 r272 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 Entry(itemid);74 SetUInt32Value(OBJECT_FIELD_ENTRY, 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 ing 20 slots88 // Cleanning 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 217 216 return NULL_SLOT; 218 217 } … … 222 221 if( slot < GetBagSize() ) 223 222 return m_bagslot[slot]; 224 223 225 224 return NULL; 226 225 } -
trunk/src/game/BattleGround.h
r257 r272 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 99 BG_HONOR_SCORE_TICKS = 330 // points 98 BUFF_RESPAWN_TIME = 180 // secs 100 99 }; 101 100 … … 435 434 436 435 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
r262 r272 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, stackcount,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,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 184 183 recv_data >> name; 185 184 … … 216 215 ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_); 217 216 ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_); 218 219 217 if( !classEntry || !raceEntry ) 220 218 { … … 610 608 } 611 609 612 if (! pCurrChar->GetMap()->Add(pCurrChar))610 if (!MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar)) 613 611 { 614 612 AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId()); … … 1002 1000 uint64 guid; 1003 1001 1004 CHECK_PACKET_SIZE(recv_data, 8 );1002 CHECK_PACKET_SIZE(recv_data, 8+6); 1005 1003 recv_data >> guid; 1006 1004 1007 1005 // not accept declined names for unsupported languages 1008 1006 std::string name; 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);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; 1014 1012 SendPacket(&data); 1015 1013 return; … … 1017 1015 1018 1016 std::wstring wname; 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);1017 if(!Utf8toWStr(name,wname)) 1018 { 1019 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); 1020 data << (uint32)1; 1021 data << guid; 1024 1022 SendPacket(&data); 1025 1023 return; … … 1028 1026 if(!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using 1029 1027 { 1030 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1031 data << uint32(1);1032 data << uint64(guid);1028 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); 1029 data << (uint32)1; 1030 data << guid; 1033 1031 SendPacket(&data); 1034 1032 return; … … 1038 1036 DeclinedName declinedname; 1039 1037 1040 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);1041 1038 recv_data >> name2; 1042 1039 1043 if(name2 != name)// character have different name1044 { 1045 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1046 data << uint32(1);1047 data << uint64(guid);1040 if(name2!=name) // character have different name 1041 { 1042 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); 1043 data << (uint32)1; 1044 data << guid; 1048 1045 SendPacket(&data); 1049 1046 return; … … 1052 1049 for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) 1053 1050 { 1054 CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);1055 1051 recv_data >> declinedname.name[i]; 1056 1052 if(!normalizePlayerName(declinedname.name[i])) 1057 1053 { 1058 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1059 data << uint32(1);1060 data << uint64(guid);1054 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); 1055 data << (uint32)1; 1056 data << guid; 1061 1057 SendPacket(&data); 1062 1058 return; … … 1064 1060 } 1065 1061 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);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; 1071 1067 SendPacket(&data); 1072 1068 return; … … 1079 1075 CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid)); 1080 1076 CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')", 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());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()); 1082 1078 CharacterDatabase.CommitTransaction(); 1083 1079 1084 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);1085 data << uint32(0); // OK1086 data << uint64(guid);1080 WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8); 1081 data << (uint32)0; // OK 1082 data << guid; 1087 1083 SendPacket(&data); 1088 1084 } -
trunk/src/game/Chat.cpp
r260 r272 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 94 66 static ChatCommand serverCommandTable[] = 95 67 { 96 68 { "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, 97 69 { "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, 98 { "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable},99 { "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable},70 { "idlerestart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleRestartCommand, "", NULL }, 71 { "idleshutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleShutDownCommand, "", NULL }, 100 72 { "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, 101 73 { "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, 102 { "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable},103 { "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable},74 { "restart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleRestartCommand, "", NULL }, 75 { "shutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleShutDownCommand, "", NULL }, 104 76 { "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable }, 105 77 { NULL, 0, false, NULL, "", NULL } -
trunk/src/game/Chat.h
r260 r272 176 176 bool HandleModifyRepCommand(const char* args); 177 177 bool HandleModifyArenaCommand(const char* args); 178 bool HandleModifyGenderCommand(const char* args);179 178 180 179 bool HandleNpcAddCommand(const char* args); … … 193 192 bool HandleNpcSpawnDistCommand(const char* args); 194 193 bool HandleNpcSpawnTimeCommand(const char* args); 195 bool HandleNpcTameCommand(const char* args);196 194 bool HandleNpcTextEmoteCommand(const char* args); 197 195 bool HandleNpcUnFollowCommand(const char* args); … … 218 216 bool HandleReloadCreatureQuestRelationsCommand(const char* args); 219 217 bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); 220 bool HandleReloadDbScriptStringCommand(const char* args);221 218 bool HandleReloadGameGraveyardZoneCommand(const char* args); 222 219 bool HandleReloadGameObjectScriptsCommand(const char* args); … … 274 271 bool HandleServerCorpsesCommand(const char* args); 275 272 bool HandleServerExitCommand(const char* args); 276 bool HandleServerIdleRestartCommand(const char* args);277 bool HandleServerIdleShutDownCommand(const char* args);278 273 bool HandleServerInfoCommand(const char* args); 279 274 bool HandleServerMotdCommand(const char* args); 280 bool HandleServerRestartCommand(const char* args);281 275 bool HandleServerSetMotdCommand(const char* args); 282 276 bool HandleServerSetLogLevelCommand(const char* args); 283 bool HandleServerShutDownCommand(const char* args);284 bool HandleServerShutDownCancelCommand(const char* args);285 277 286 278 bool HandleAddHonorCommand(const char* args); … … 336 328 bool HandleBanListCharacterCommand(const char* args); 337 329 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); 338 335 bool HandleGoXYCommand(const char* args); 339 336 bool HandleGoXYZCommand(const char* args); … … 369 366 bool HandleAddItemCommand(const char* args); 370 367 bool HandleAddItemSetCommand(const char* args); 368 bool HandleModifyGenderCommand(const char* args); 371 369 bool HandlePetTpCommand(const char* args); 372 370 bool HandlePetUnlearnCommand(const char* args); -
trunk/src/game/Creature.cpp
r267 r272 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), m_isAggressive(true),125 m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), 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), … … 148 148 i_AI = NULL; 149 149 150 DeletePossessedAI(); 150 if (i_AI_possessed) 151 { 152 delete i_AI_possessed; 153 i_AI_possessed = NULL; 154 } 151 155 } 152 156 … … 178 182 float x,y,z,o; 179 183 GetRespawnCoord(x, y, z, &o); 180 GetMap()->CreatureRelocation(this,x,y,z,o);184 MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o); 181 185 } 182 186 … … 210 214 } 211 215 212 Set Entry(Entry);// normal entry always216 SetUInt32Value(OBJECT_FIELD_ENTRY, Entry); // normal entry always 213 217 m_creatureInfo = cinfo; // map mode related always 214 218 … … 294 298 SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); 295 299 296 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));297 300 SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); 298 301 SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); … … 325 328 SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); 326 329 327 if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER328 || GetCreatureType() == CREATURE_TYPE_CRITTER)329 m_isAggressive = false;330 else331 m_isAggressive = true;332 333 330 return true; 334 331 } … … 360 357 lootForBody = false; 361 358 362 if(m_originalEntry != Get Entry())359 if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY)) 363 360 UpdateEntry(m_originalEntry); 364 361 … … 379 376 380 377 //Call AI respawn virtual function 381 i_AI->JustRespawned();382 383 GetMap()->Add(this);378 AI()->JustRespawned(); 379 380 MapManager::Instance().GetMap(GetMapId(), this)->Add(this); 384 381 } 385 382 break; … … 443 440 // do not allow the AI to be changed during update 444 441 m_AI_locked = true; 445 i_AI->UpdateAI(diff);442 AI()->UpdateAI(diff); 446 443 m_AI_locked = false; 447 444 } … … 563 560 } 564 561 565 void Creature::D eletePossessedAI()562 void Creature::DisablePossessedAI() 566 563 { 567 564 if (!i_AI_possessed) return; 568 569 delete i_AI_possessed;570 i_AI_possessed = NULL;571 565 572 566 // Signal the old AI that it's been re-enabled … … 1418 1412 SetPower(POWER_MANA,data->curmana); 1419 1413 1414 SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); 1415 1420 1416 // checked at creature_template loading 1421 1417 m_defaultMovementType = MovementGeneratorType(data->movementType); … … 1542 1538 { 1543 1539 return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER)); 1544 }1545 1546 bool Creature::canStartAttack(Unit const* who) const1547 {1548 if(!who->isInAccessiblePlaceFor(this)1549 || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE1550 || !IsWithinDistInMap(who, GetAttackDistance(who)))1551 return false;1552 1553 if(!canAttack(who))1554 return false;1555 1556 return IsWithinLOSInMap(who);1557 1540 } 1558 1541 … … 1836 1819 } 1837 1820 1838 Unit* Creature::SelectNearestTarget(float dist) const1839 {1840 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));1841 Cell cell(p);1842 cell.data.Part.reserved = ALL_DISTRICT;1843 cell.SetNoCreate();1844 1845 Unit *target = NULL;1846 1847 {1848 Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);1849 Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check);1850 1851 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);1852 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);1853 1854 CellLock<GridReadGuard> cell_lock(cell, p);1855 cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap());1856 cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap());1857 }1858 1859 return target;1860 }1861 1862 1821 void Creature::CallAssistence() 1863 1822 { … … 2139 2098 } 2140 2099 2141 std::string Creature::GetScriptName() 2142 { 2143 return objmgr.GetScriptName(GetScriptId()); 2144 } 2145 2146 uint32 Creature::GetScriptId() 2147 { 2148 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; 2100 char const* Creature::GetScriptName() const 2101 { 2102 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; 2149 2103 } 2150 2104 -
trunk/src/game/Creature.h
r267 r272 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 uint32 ScriptID;208 char const* ScriptName; 209 209 uint32 GetRandomValidModelId() const; 210 210 uint32 GetFirstValidModelId() const; 211 212 // helpers 211 213 212 SkillType GetRequiredLootSkill() const 214 213 { … … 220 219 return SKILL_SKINNING; // normal case 221 220 } 222 221 223 222 bool isTameable() const 224 223 { … … 427 426 bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } 428 427 bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } 429 bool isAggressive() const { return m_isAggressive; }430 void SetAggressive(bool agg) { m_isAggressive = agg; }431 428 ///// TODO RENAME THIS!!!!! 432 429 bool isCanTrainingOf(Player* player, bool msg) const; … … 461 458 bool AIM_Initialize(); 462 459 void InitPossessedAI(); 463 void D eletePossessedAI();460 void DisablePossessedAI(); 464 461 465 462 void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); … … 502 499 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } 503 500 CreatureDataAddon const* GetCreatureAddon() const; 504 505 std::string GetScriptName(); 506 uint32 GetScriptId(); 501 char const* GetScriptName() const; 507 502 508 503 void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 ); … … 530 525 // overwrite WorldObject function for proper name localization 531 526 const char* GetNameForLocaleIdx(int32 locale_idx) const; 532 527 533 528 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState 534 529 … … 558 553 bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const; 559 554 bool IsWithinSightDist(Unit const* u) const; 560 bool canStartAttack(Unit const* u) const;561 555 float GetAttackDistance(Unit const* pl) const; 562 556 563 Unit* SelectNearestTarget(float dist = 0) const;564 557 void CallAssistence(); 565 558 void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } … … 641 634 bool m_isPet; // set only in Pet::Pet 642 635 bool m_isTotem; // set only in Totem::Totem 643 bool m_isAggressive;644 636 void RegenerateMana(); 645 637 void RegenerateHealth(); -
trunk/src/game/CreatureAI.cpp
r260 r272 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
r260 r272 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
r260 r272 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
r260 r272 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
r263 r272 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?84 83 const uint32 nBaseExp = content == CONTENT_1_60 ? 45 : 235; 85 84 if( mob_level >= pl_level ) -
trunk/src/game/GMTicketHandler.cpp
r263 r272 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 69 71 if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 70 72 ticket->SetText(ticketText.c_str()); … … 104 106 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); 105 107 106 if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 108 CharacterDatabase.escape_string(ticketText); 109 110 if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 107 111 { 108 112 WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); -
trunk/src/game/GMTicketMgr.h
r263 r272 51 51 m_text = text ? text : ""; 52 52 m_lastUpdate = time(NULL); 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); 53 CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid); 57 54 } 58 55 … … 66 63 CharacterDatabase.BeginTransaction(); 67 64 DeleteFromDB(); 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()); 65 CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText()); 73 66 CharacterDatabase.CommitTransaction(); 74 67 } -
trunk/src/game/GameEvent.cpp
r259 r272 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, (uint64)(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); 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
r246 r272 1281 1281 { 1282 1282 trigger->setFaction(14); 1283 trigger->CastSpell(target, spell, true , 0, 0, target->GetGUID());1283 trigger->CastSpell(target, spell, true); 1284 1284 } 1285 1285 //trigger->setDeathState(JUST_DIED); -
trunk/src/game/GameObject.h
r260 r272 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 uint32 ScriptId;360 char *ScriptName; 361 361 }; 362 362 -
trunk/src/game/GridNotifiers.h
r267 r272 699 699 // Creature checks 700 700 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&); 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; 735 714 }; 736 715 -
trunk/src/game/GridNotifiersImpl.h
r265 r272 73 73 74 74 // Creature AI reaction 75 if( c->isAggressive() &&!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))75 if(!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->isAggressive() &&!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))84 if(!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->isAggressive() &&!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))90 if(!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/GridStates.cpp
r268 r272 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 … … 37 37 if( info.getTimeTracker().Passed() ) 38 38 { 39 if( grid.ActiveObjectsInGrid() == 0 && ! m.ActiveObjectsNearGrid(x, y) )39 if( grid.ActiveObjectsInGrid() == 0 && !ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, m.GetId(), m.GetInstanceId()) ) 40 40 { 41 41 ObjectGridStoper stoper(grid); … … 51 51 52 52 void 53 IdleState::Update(Map &m, NGridType &grid, GridInfo & , const uint32 &x, const uint32 &y, const uint32 &) const53 IdleState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &) const 54 54 { 55 55 m.ResetGridExpiry(grid); -
trunk/src/game/Item.cpp
r260 r272 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 OUL_SHARDS))182 if(!(pProto->BagFamily & BAG_FAMILY_MASK_SHARDS)) 183 183 return false; 184 184 return true; … … 248 248 Object::_Create( guidlow, 0, HIGHGUID_ITEM ); 249 249 250 Set Entry(itemid);250 SetUInt32Value(OBJECT_FIELD_ENTRY, 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 Entry());432 return objmgr.GetItemPrototype(GetUInt32Value(OBJECT_FIELD_ENTRY)); 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((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) 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 ) 766 768 return; 767 769 … … 774 776 void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) 775 777 { 776 if(Get EnchantmentDuration(slot) ==duration)778 if(GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration) 777 779 return; 778 780 … … 783 785 void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges) 784 786 { 785 if(GetEnchantmentCharges(slot) == charges)786 return;787 788 787 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges); 789 788 SetState(ITEM_CHANGED); … … 792 791 void Item::ClearEnchantment(EnchantmentSlot slot) 793 792 { 794 if(!Get EnchantmentId(slot))795 return; 796 797 for( uint8 x = 0; x < 3; ++x)798 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0);793 if(!GetUInt32Value(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); 799 798 SetState(ITEM_CHANGED); 800 799 } -
trunk/src/game/Item.h
r260 r272 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); } 231 232 uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); } 232 233 void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); } -
trunk/src/game/ItemEnchantmentMgr.cpp
r260 r272 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
r260 r272 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
r260 r272 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() > size_t(loc_idx)&& !il->Name[loc_idx].empty())316 if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) 317 317 Name = il->Name[loc_idx]; 318 if (il->Description.size() > size_t(loc_idx)&& !il->Description[loc_idx].empty())318 if (il->Description.size() > 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)365 363 data << pProto->Armor; 366 364 data << pProto->HolyRes; … … 370 368 data << pProto->ShadowRes; 371 369 data << pProto->ArcaneRes; 372 373 370 data << pProto->Delay; 374 371 data << pProto->Ammo_type; 375 data << pProto->RangedModRange; 376 372 373 data << (float)pProto->RangedModRange; 377 374 for(int s = 0; s < 5; s++) 378 375 { … … 980 977 if (il) 981 978 { 982 if (il->Name.size() > size_t(loc_idx)&& !il->Name[loc_idx].empty())979 if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) 983 980 Name = il->Name[loc_idx]; 984 981 } … … 1031 1028 } 1032 1029 1033 if(item==gift) // not poss able with pacjket from real client1030 if(item==gift) // not possible with pacjket from real client 1034 1031 { 1035 1032 _player->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, NULL ); … … 1076 1073 CharacterDatabase.BeginTransaction(); 1077 1074 CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS)); 1078 item->Set Entry(gift->GetEntry());1075 item->SetUInt32Value(OBJECT_FIELD_ENTRY, gift->GetUInt32Value(OBJECT_FIELD_ENTRY)); 1079 1076 1080 1077 switch (item->GetEntry()) 1081 1078 { 1082 case 5042: item->Set Entry(5043); break;1083 case 5048: item->Set Entry(5044); break;1084 case 17303: item->Set Entry(17302); break;1085 case 17304: item->Set Entry(17305); break;1086 case 17307: item->Set Entry(17308); break;1087 case 21830: item->Set Entry(21831); break;1079 case 5042: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 5043); break; 1080 case 5048: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 5044); break; 1081 case 17303: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17302); break; 1082 case 17304: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17305); break; 1083 case 17307: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17308); break; 1084 case 21830: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 21831); break; 1088 1085 } 1089 1086 item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); -
trunk/src/game/ItemPrototype.h
r260 r272 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 ED = 2,81 BIND_WHEN_EQUIPPED = 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 103 ITEM_FLAGS_BOA = 0x08000000, // bind on account 104 ITEM_FLAGS_MILLABLE = 0x20000000 102 ITEM_FLAGS_SPECIALUSE = 0x00800000 // last used flag in 2.3.0 105 103 }; 106 104 … … 109 107 BAG_FAMILY_MASK_ARROWS = 0x00000001, 110 108 BAG_FAMILY_MASK_BULLETS = 0x00000002, 111 BAG_FAMILY_MASK_S OUL_SHARDS= 0x00000004,109 BAG_FAMILY_MASK_SHARDS = 0x00000004, 112 110 BAG_FAMILY_MASK_LEATHERWORKING_SUPP = 0x00000008, 113 BAG_FAMILY_MASK_ INSCRIPTION_SUPP = 0x00000010,111 BAG_FAMILY_MASK_UNUSED = 0x00000010, // not used currently 114 112 BAG_FAMILY_MASK_HERBS = 0x00000020, 115 113 BAG_FAMILY_MASK_ENCHANTING_SUPP = 0x00000040, … … 119 117 BAG_FAMILY_MASK_MINING_SUPP = 0x00000400, 120 118 BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT = 0x00000800, 121 BAG_FAMILY_MASK_VANITY_PETS = 0x00001000, 122 BAG_FAMILY_MASK_CURRENCY_TOKENS = 0x00002000, 123 BAG_FAMILY_MASK_QUEST_ITEMS = 0x00004000 124 }; 119 BAG_FAMILY_MASK_VANITY_PETS = 0x00001000 120 }; 121 122 /* TODO: Not entirely positive on need for this?? 123 enum SOCKET_CONTENT (); 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 ItemSubclassGlyph394 {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 = 11405 };406 407 #define MAX_ITEM_SUBCLASS_GLYPH 12408 392 409 393 const uint32 MaxItemSubclassValues[MAX_ITEM_CLASS] = … … 541 525 uint32 RequiredDisenchantSkill; 542 526 float ArmorDamageModifier; 543 uint32 ScriptId;527 char* ScriptName; 544 528 uint32 DisenchantID; 545 529 uint32 FoodType; -
trunk/src/game/Level2.cpp
r263 r272 2362 2362 // Check 2363 2363 // Remember: "show" must also be the name of a column! 2364 if( (show != "emote") && (show != "spell") && (show != "text id1") && (show != "textid2")2365 && (show != "text id3") && (show != "textid4") && (show != "textid5")2364 if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2") 2365 && (show != "text3") && (show != "text4") && (show != "text5") 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 supported2709 if( show == "textid1" || show == "textid2" || show == "textid3" ||2710 show == "textid4" || show == "textid5" )2711 {2712 2705 return false; 2713 2706 } … … 2850 2843 2851 2844 QueryResult *result = 2852 WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text id1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u",2845 WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u", 2853 2846 target->GetGUIDLow() ); 2854 2847 if(!result) … … 2862 2855 PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); 2863 2856 2864 result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text id1, 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 )",2857 result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, 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 )", 2865 2858 target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); 2866 2859 if(!result) … … 2879 2872 uint32 emote = fields[3].GetUInt32(); 2880 2873 uint32 spell = fields[4].GetUInt32(); 2881 uint32 textid[MAX_WAYPOINT_TEXT]; 2882 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 2883 textid[i] = fields[5+i].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(); 2884 2879 uint32 model1 = fields[10].GetUInt32(); 2885 2880 uint32 model2 = fields[11].GetUInt32(); … … 2894 2889 PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); 2895 2890 PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); 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]) : "")); 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); 2898 2896 2899 2897 }while( result->NextRow() ); … … 3216 3214 3217 3215 QueryResult *result = WorldDatabase.PQuery( 3218 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14153219 "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text id1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );3216 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3217 "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); 3220 3218 3221 3219 if (!result) … … 3234 3232 3235 3233 outfile << "INSERT INTO creature_movement "; 3236 outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text id1, textid2, textid3, textid4, textid5 ) VALUES ";3234 outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES "; 3237 3235 3238 3236 outfile << "( "; … … 3259 3257 outfile << fields[9].GetUInt32(); // spell 3260 3258 outfile << ", "; 3261 outfile << fields[10].GetUInt32(); // textid1 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 } 3262 3270 outfile << ", "; 3263 outfile << fields[11].GetUInt32(); // textid2 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 } 3264 3282 outfile << ", "; 3265 outfile << fields[12].GetUInt32(); // textid3 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 } 3266 3294 outfile << ", "; 3267 outfile << fields[13].GetUInt32(); // textid4 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 } 3268 3306 outfile << ", "; 3269 outfile << fields[14].GetUInt32(); // textid5 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 } 3270 3318 outfile << ");\n "; 3271 3319 -
trunk/src/game/Level3.cpp
r260 r272 136 136 HandleReloadSpellScriptsCommand("a"); 137 137 SendGlobalSysMessage("DB tables `*_scripts` reloaded."); 138 HandleReloadDbScriptStringCommand("a");139 138 return true; 140 139 } … … 600 599 SendGlobalSysMessage("DB table `spell_scripts` reloaded."); 601 600 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.");610 601 return true; 611 602 } … … 1777 1768 // search highest talent rank 1778 1769 uint32 spellid = 0; 1779 int rank = 4; 1780 for(; rank >= 0; --rank) 1770 for(int rank = 4; rank >= 0; --rank) 1781 1771 { 1782 1772 if(talentInfo->RankID[rank]!=0) … … 4656 4646 } 4657 4647 4658 bool ChatHandler::HandleServerShutDownCancelCommand(const char* args) 4659 { 4660 sWorld.ShutdownCancel(); 4661 return true; 4662 } 4663 4664 bool ChatHandler::HandleServerShutDownCommand(const char* args) 4648 bool ChatHandler::HandleShutDownCommand(const char* args) 4665 4649 { 4666 4650 if(!*args) 4667 4651 return false; 4668 4652 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')) 4653 if(std::string(args)=="cancel") 4654 { 4655 sWorld.ShutdownCancel(); 4656 } 4657 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) 4684 4663 return false; 4685 4664 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) 4665 sWorld.ShutdownServ(time); 4666 } 4667 return true; 4668 } 4669 4670 bool ChatHandler::HandleRestartCommand(const char* args) 4671 { 4672 if(!*args) 4673 return false; 4674 4675 if(std::string(args)=="cancel") 4676 { 4677 sWorld.ShutdownCancel(); 4678 } 4679 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) 4690 4685 return false; 4691 4686 4692 sWorld.ShutdownServ (time, 0, exitcode); 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(); 4693 4700 } 4694 4701 else 4695 sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE); 4696 return true; 4697 } 4698 4699 bool ChatHandler::HandleServerRestartCommand(const char* args) 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) 4700 4715 { 4701 4716 if(!*args) 4702 4717 return false; 4703 4718 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')) 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) 4719 4729 return false; 4720 4730 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) 4735 { 4736 if(!*args) 4737 return false; 4738 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); 4763 } 4764 else 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')) 4789 return false; 4790 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); 4798 } 4799 else 4800 sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE); 4731 sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); 4732 } 4801 4733 return true; 4802 4734 } -
trunk/src/game/Mail.cpp
r260 r272 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 190 191 if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION)) 191 192 { … … 194 195 } 195 196 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 }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 } 201 202 } 202 203 } -
trunk/src/game/Map.cpp
r268 r272 36 36 #include "ScriptCalls.h" 37 37 #include "Group.h" 38 #include "MapRefManager.h"39 38 40 39 #include "MapInstanced.h" … … 451 450 bool Map::Add(Player *player) 452 451 { 453 player->GetMapRef().link(this, player);454 455 452 player->SetInstanceId(GetInstanceId()); 456 453 … … 595 592 } 596 593 597 void Map::UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff)598 {599 CellPair standing_cell(Trinity::ComputeCellPair(x, y));600 601 // Check for correctness of standing_cell, it also avoids problems with update_cell602 if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)603 return;604 605 // will this reduce the speed?606 Trinity::ObjectUpdater updater(t_diff);607 // for creature608 TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater);609 // for pets610 TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);611 612 // the overloaded operators handle range checking613 // so ther's no need for range checking inside the loop614 CellPair begin_cell(standing_cell), end_cell(standing_cell);615 begin_cell << 1; begin_cell -= 1; // upper left616 end_cell >> 1; end_cell += 1; // lower right617 618 for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)619 {620 for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)621 {622 // marked cells are those that have been visited623 // don't visit the same cell twice624 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;625 if(!isCellMarked(cell_id))626 {627 markCell(cell_id);628 CellPair pair(x,y);629 Cell cell(pair);630 cell.data.Part.reserved = CENTER_DISTRICT;631 cell.SetNoCreate();632 CellLock<NullGuard> cell_lock(cell, pair);633 cell_lock->Visit(cell_lock, grid_object_update, *this);634 cell_lock->Visit(cell_lock, world_object_update, *this);635 }636 }637 }638 }639 640 594 void Map::Update(const uint32 &t_diff) 641 595 { 642 resetMarkedCells();643 644 // update cells around players645 for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)646 {647 Player* plr = iter->getSource();648 if(plr->IsInWorld())649 UpdateActiveCells(plr->GetPositionX(), plr->GetPositionY(), t_diff);650 }651 652 // update cells around active objects653 // clone the active object list, because update might remove from it654 std::set<WorldObject *> activeObjects(i_activeObjects);655 for(std::set<WorldObject *>::iterator iter = activeObjects.begin(); iter != activeObjects.end(); ++iter)656 {657 if((*iter)->IsInWorld())658 UpdateActiveCells((*iter)->GetPositionX(), (*iter)->GetPositionY(), t_diff);659 }660 661 596 // 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 ! 662 597 // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended … … 676 611 void Map::Remove(Player *player, bool remove) 677 612 { 678 player->GetMapRef().unlink();679 613 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 680 614 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) … … 826 760 AddCreatureToMoveList(creature,x,y,z,ang); 827 761 // in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList 828 if(creature->isActive()) 829 { 830 if(creature->isPossessedByPlayer()) 831 EnsureGridLoadedForPlayer(new_cell, (Player*)creature->GetCharmer(), false); 832 else 833 EnsureGridLoadedForPlayer(new_cell, NULL, false); 834 } 762 if(creature->isPossessedByPlayer()) 763 EnsureGridLoadedForPlayer(new_cell, (Player*)creature->GetCharmer(), false); 835 764 } 836 765 else … … 981 910 982 911 { 983 if(!pForce && PlayersNearGrid(x, y) )912 if(!pForce && ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, i_id, i_InstanceId) ) 984 913 return false; 985 914 … … 1490 1419 } 1491 1420 1492 uint32 Map::GetPlayersCountExceptGMs() const1493 {1494 uint32 count = 0;1495 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)1496 if(!itr->getSource()->isGameMaster())1497 ++count;1498 return count;1499 }1500 1501 void Map::SendToPlayers(WorldPacket const* data) const1502 {1503 for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)1504 itr->getSource()->GetSession()->SendPacket(data);1505 }1506 1507 bool Map::PlayersNearGrid(uint32 x, uint32 y) const1508 {1509 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);1510 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);1511 cell_min << 2;1512 cell_min -= 2;1513 cell_max >> 2;1514 cell_max += 2;1515 1516 for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)1517 {1518 Player* plr = iter->getSource();1519 1520 CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY());1521 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&1522 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )1523 return true;1524 }1525 1526 return false;1527 }1528 1529 bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const1530 {1531 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);1532 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);1533 cell_min << 2;1534 cell_min -= 2;1535 cell_max >> 2;1536 cell_max += 2;1537 1538 for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)1539 {1540 Player* plr = iter->getSource();1541 1542 CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY());1543 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&1544 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )1545 return true;1546 }1547 1548 for(std::set<WorldObject*>::const_iterator itr = i_activeObjects.begin(); itr != i_activeObjects.end(); ++itr)1549 {1550 CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY());1551 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&1552 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )1553 return true;1554 }1555 1556 return false;1557 }1558 1559 1421 template void Map::Add(Corpse *); 1560 1422 template void Map::Add(Creature *); … … 1592 1454 bool InstanceMap::CanEnter(Player *player) 1593 1455 { 1594 if( player->GetMapRef().getTarget() == this)1456 if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) 1595 1457 { 1596 1458 sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); … … 1709 1571 SetResetSchedule(false); 1710 1572 1573 i_Players.push_back(player); 1711 1574 player->SendInitWorldStates(); 1712 1575 sLog.outDetail("MAP: Player '%s' entered the instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); … … 1733 1596 { 1734 1597 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); 1735 1599 SetResetSchedule(true); 1736 //if last player set unload timer 1737 if(!m_unloadTimer && m_mapRefManager.getSize() == 1) 1600 if(!m_unloadTimer && i_Players.empty()) 1738 1601 m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); 1739 1602 Map::Remove(player, remove); … … 1762 1625 if (mInstance) 1763 1626 { 1764 i_script _id = mInstance->script_id;1627 i_script = mInstance->script; 1765 1628 i_data = Script->CreateInstanceData(this); 1766 1629 } … … 1779 1642 if(data) 1780 1643 { 1781 sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId);1644 sLog.outDebug("Loading instance data for `%s` with id %u", i_script.c_str(), i_InstanceId); 1782 1645 i_data->Load(data); 1783 1646 } … … 1787 1650 else 1788 1651 { 1789 sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id));1652 sLog.outDebug("New instance data, \"%s\" ,initialized!",i_script.c_str()); 1790 1653 i_data->Initialize(); 1791 1654 } … … 1800 1663 // the instance must be deleted from the DB by InstanceSaveManager 1801 1664 1802 if( HavePlayers())1665 if(!i_Players.empty()) 1803 1666 { 1804 1667 if(method == INSTANCE_RESET_ALL) 1805 1668 { 1806 1669 // notify the players to leave the instance so it can be reset 1807 for( MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)1808 itr->getSource()->SendResetFailedNotify(GetId());1670 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1671 (*itr)->SendResetFailedNotify(GetId()); 1809 1672 } 1810 1673 else … … 1813 1676 { 1814 1677 // set the homebind timer for players inside (1 minute) 1815 for( MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)1816 itr->getSource()->m_InstanceValid = false;1678 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1679 (*itr)->m_InstanceValid = false; 1817 1680 } 1818 1681 … … 1830 1693 } 1831 1694 1832 return m_mapRefManager.isEmpty(); 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; 1833 1705 } 1834 1706 … … 1844 1716 Group *group = player->GetGroup(); 1845 1717 // group members outside the instance group don't get bound 1846 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1847 { 1848 Player* plr = itr->getSource(); 1849 // players inside an instance cannot be bound to other instances 1850 // some players may already be permanently bound, in this case nothing happens 1851 InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 1852 if(!bind || !bind->perm) 1853 { 1854 plr->BindToInstance(save, true); 1855 WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 1856 data << uint32(0); 1857 plr->GetSession()->SendPacket(&data); 1858 } 1859 1860 // if the leader is not in the instance the group will not get a perm bind 1861 if(group && group->GetLeaderGUID() == plr->GetGUID()) 1862 group->BindToInstance(save, true); 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 } 1863 1737 } 1864 1738 } … … 1872 1746 void InstanceMap::UnloadAll(bool pForce) 1873 1747 { 1874 if( HavePlayers())1748 if(!i_Players.empty()) 1875 1749 { 1876 1750 sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!"); 1877 for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 1878 { 1879 Player* plr = itr->getSource(); 1880 plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 1881 } 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()); 1882 1753 } 1883 1754 … … 1888 1759 } 1889 1760 1890 void InstanceMap::SendResetWarnings(uint32 timeLeft) const1891 { 1892 for( MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)1893 itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft);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); 1894 1765 } 1895 1766 … … 1899 1770 // the reset time is only scheduled when there are no payers inside 1900 1771 // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled 1901 if( !HavePlayers() && !IsRaid() && !IsHeroic())1772 if(i_Players.empty() && !IsRaid() && !IsHeroic()) 1902 1773 { 1903 1774 InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); … … 1907 1778 } 1908 1779 1780 void InstanceMap::SendToPlayers(WorldPacket const* data) const 1781 { 1782 for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 1783 (*itr)->GetSession()->SendPacket(data); 1784 } 1785 1909 1786 /* ******* Battleground Instance Maps ******* */ 1910 1787 … … 1920 1797 bool BattleGroundMap::CanEnter(Player * player) 1921 1798 { 1922 if( player->GetMapRef().getTarget() == this)1799 if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) 1923 1800 { 1924 1801 sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow()); … … 1941 1818 if(!CanEnter(player)) 1942 1819 return false; 1820 i_Players.push_back(player); 1943 1821 // reset instance validity, battleground maps do not homebind 1944 1822 player->m_InstanceValid = true; … … 1950 1828 { 1951 1829 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); 1952 1831 Map::Remove(player, remove); 1953 1832 } … … 1960 1839 void BattleGroundMap::UnloadAll(bool pForce) 1961 1840 { 1962 while(HavePlayers()) 1963 { 1964 Player * plr = m_mapRefManager.getFirst()->getSource(); 1965 if(plr) (plr)->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 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()); 1966 1846 // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator. 1967 1847 // just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop 1968 1848 // note that this remove is not needed if the code works well in other places 1969 plr->GetMapRef().unlink();1849 i_Players.remove(plr); 1970 1850 } 1971 1851 -
trunk/src/game/Map.h
r268 r272 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"37 36 38 37 #include <bitset> … … 106 105 float startLocZ; 107 106 float startLocO; 108 uint32 script_id;107 char const* script; 109 108 }; 110 109 … … 128 127 class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ZThread::Mutex> 129 128 { 130 friend class MapReference;131 129 public: 132 130 Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); … … 240 238 GameObject* GetGameObjectInMap(uint64 guid); 241 239 242 bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }243 uint32 GetPlayersCountExceptGMs() const;244 bool PlayersNearGrid(uint32 x,uint32 y) const;245 bool ActiveObjectsNearGrid(uint32 x, uint32 y) const;246 247 void AddActiveObject(WorldObject* obj) { i_activeObjects.insert(obj); }248 void RemoveActiveObject(WorldObject* obj) { i_activeObjects.erase(obj); }249 250 void SendToPlayers(WorldPacket const* data) const;251 252 typedef MapRefManager PlayerList;253 PlayerList const& GetPlayers() const { return m_mapRefManager; }254 240 template<class T> void SwitchGridContainers(T* obj, bool active); 255 241 private: … … 292 278 inline void setNGrid(NGridType* grid, uint32 x, uint32 y); 293 279 294 void UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff);295 280 protected: 296 281 typedef Trinity::ObjectLevelLockable<Map, ZThread::Mutex>::Lock Guard; … … 302 287 uint32 m_unloadTimer; 303 288 304 MapRefManager m_mapRefManager;305 289 private: 306 290 typedef GridReadGuard ReadGuard; … … 313 297 time_t i_gridExpiry; 314 298 315 std::set<WorldObject *> i_activeObjects;316 299 std::set<WorldObject *> i_objectsToRemove; 317 300 … … 343 326 { 344 327 public: 328 typedef std::list<Player *> PlayerList; // online players only 329 345 330 InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); 346 331 ~InstanceMap(); … … 350 335 void CreateInstanceData(bool load); 351 336 bool Reset(uint8 method); 352 uint32 GetScriptId() { return i_script_id; }337 std::string GetScript() { return i_script; } 353 338 InstanceData* GetInstanceData() { return i_data; } 354 339 void PermBindAllPlayers(Player *player); 340 PlayerList const& GetPlayers() const { return i_Players;} 341 void SendToPlayers(WorldPacket const* data) const; 355 342 time_t GetResetTime(); 356 343 void UnloadAll(bool pForce); 357 344 bool CanEnter(Player* player); 358 void SendResetWarnings(uint32 timeLeft) const; 345 uint32 GetPlayersCountExceptGMs() const; 346 uint32 HavePlayers() const { return !i_Players.empty(); } 347 void SendResetWarnings(uint32 timeLeft); 359 348 void SetResetSchedule(bool on); 360 349 private: … … 362 351 bool m_unloadWhenEmpty; 363 352 InstanceData* i_data; 364 uint32 i_script_id; 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; 365 357 }; 366 358 … … 368 360 { 369 361 public: 362 typedef std::list<Player *> PlayerList; // online players only 363 370 364 BattleGroundMap(uint32 id, time_t, uint32 InstanceId); 371 365 ~BattleGroundMap(); … … 376 370 void SetUnload(); 377 371 void UnloadAll(bool pForce); 372 private: 373 PlayerList i_Players; 378 374 }; 379 375 -
trunk/src/game/MapInstanced.cpp
r257 r272 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 ) : Map(id, expiry, 0, 0)29 MapInstanced::MapInstanced(uint32 id, time_t expiry, uint32 aInstanceId) : 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
r257 r272 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 expiry);33 MapInstanced(uint32 id, time_t, uint32 aInstanceId); 34 34 ~MapInstanced() {} 35 35 -
trunk/src/game/MapManager.cpp
r260 r272 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 );114 m = new MapInstanced(id, i_gridCleanUpDelay, 0); 115 115 } 116 116 else … … 223 223 } 224 224 225 void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId )225 void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode) 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());250 248 251 249 for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) … … 339 337 for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr) 340 338 if(mitr->second->IsDungeon()) 341 ret += ((InstanceMap*)mitr->second)->GetPlayers(). getSize();339 ret += ((InstanceMap*)mitr->second)->GetPlayers().size(); 342 340 } 343 341 return ret; -
trunk/src/game/MapManager.h
r260 r272 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 31 30 class Transport; 32 31 … … 46 45 // only const version for outer users 47 46 Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); } 48 void DeleteInstance(uint32 mapid, uint32 instanceId );47 void DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode); 49 48 50 49 inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const -
trunk/src/game/NPCHandler.cpp
r257 r272 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 342 343 if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str())) 343 344 unit->OnGossipSelect (_player, option); 344 345 } 345 346 else 347 346 348 { 347 349 if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option))) 348 unit->OnGossipSelect (_player, option);350 unit->OnGossipSelect (_player, option); 349 351 } 350 352 } … … 376 378 void WorldSession::SendSpiritResurrect() 377 379 { 378 _player->ResurrectPlayer(0.5f, true);380 _player->ResurrectPlayer(0.5f,false, true); 379 381 380 382 _player->DurabilityLossAll(0.25f,true); -
trunk/src/game/Object.cpp
r268 r272 991 991 WorldObject::~WorldObject() 992 992 { 993 if(m_isActive && !isType(TYPEMASK_PLAYER) &&IsInWorld())994 GetMap()->RemoveActiveObject(this);993 if(m_isActive && IsInWorld()) 994 ObjectAccessor::Instance().RemoveActiveObject(this); 995 995 } 996 996 … … 998 998 { 999 999 // if already in the same activity state as we try to set, do nothing 1000 if(isActive == m_isActive || isType(TYPEMASK_PLAYER))1000 if(isActive == m_isActive) 1001 1001 return; 1002 1003 1002 m_isActive = isActive; 1004 1003 if(IsInWorld()) 1005 1004 { 1006 1005 if(isActive) 1007 GetMap()->AddActiveObject(this);1006 ObjectAccessor::Instance().AddActiveObject(this); 1008 1007 else 1009 GetMap()->RemoveActiveObject(this);1008 ObjectAccessor::Instance().RemoveActiveObject(this); 1010 1009 } 1011 1010 } … … 1014 1013 { 1015 1014 Object::AddToWorld(); 1016 if(m_isActive && !isType(TYPEMASK_PLAYER))1017 GetMap()->AddActiveObject(this);1015 if(m_isActive) 1016 ObjectAccessor::Instance().AddActiveObject(this); 1018 1017 } 1019 1018 1020 1019 void WorldObject::RemoveFromWorld() 1021 1020 { 1022 if(m_isActive && !isType(TYPEMASK_PLAYER))1023 GetMap()->RemoveActiveObject(this);1021 if(m_isActive) 1022 ObjectAccessor::Instance().RemoveActiveObject(this); 1024 1023 Object::RemoveFromWorld(); 1025 1024 } -
trunk/src/game/Object.h
r268 r272 456 456 GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); 457 457 bool isActive() const { return m_isActive; } 458 v oid setActive(bool isActive);458 virtual void setActive(bool isActive); 459 459 protected: 460 460 explicit WorldObject(); -
trunk/src/game/ObjectAccessor.cpp
r268 r272 143 143 { 144 144 Creature * ret = GetObjectInWorld(guid, (Creature*)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 145 if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL; 154 146 return ret; 155 147 } … … 257 249 258 250 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 0x10000 268 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 string 273 } 274 } 275 276 void 259 277 ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) 260 278 { … … 344 362 TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); 345 363 CellLock<GridReadGuard> cell_lock(cell, p); 346 cell_lock->Visit(cell_lock, player_notifier, * obj->GetMap());364 cell_lock->Visit(cell_lock, player_notifier, *MapManager::Instance().GetMap(obj->GetMapId(), obj)); 347 365 } 348 366 … … 488 506 489 507 void 508 ObjectAccessor::AddActiveObject( WorldObject * obj ) 509 { 510 i_activeobjects.insert(obj); 511 } 512 513 void 514 ObjectAccessor::RemoveActiveObject( WorldObject * obj ) 515 { 516 i_activeobjects.erase(obj); 517 } 518 519 void 490 520 ObjectAccessor::Update(uint32 diff) 491 521 { 492 /* { 493 //Player update now in MapManager -> UpdatePlayers 522 { 494 523 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 495 524 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); … … 502 531 } 503 532 504 // TODO: move this to Map::Update505 533 // clone the active object list, because update might remove from it 506 534 std::set<WorldObject *> activeobjects(i_activeobjects); … … 561 589 } 562 590 } 563 }*/ 564 565 UpdateDataMapType update_players; 566 { 567 Guard guard(i_updateGuard); 568 while(!i_objects.empty()) 569 { 570 Object* obj = *i_objects.begin(); 571 i_objects.erase(i_objects.begin()); 572 if (!obj) 573 continue; 574 _buildUpdateObject(obj, update_players); 575 obj->ClearUpdateMask(false); 576 } 577 } 578 579 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 580 for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) 581 { 582 iter->second.BuildPacket(&packet); 583 iter->first->GetSession()->SendPacket(&packet); 584 packet.clear(); // clean the string 585 } 586 } 587 588 void 589 ObjectAccessor::UpdatePlayers(uint32 diff) 590 { 591 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 592 for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) 593 if(iter->second->IsInWorld()) 594 iter->second->Update(diff); 591 } 592 593 _update(); 594 } 595 596 bool 597 ObjectAccessor::ActiveObjectsNearGrid(uint32 x, uint32 y, uint32 m_id, uint32 i_id) const 598 { 599 CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); 600 CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); 601 cell_min << 2; 602 cell_min -= 2; 603 cell_max >> 2; 604 cell_max += 2; 605 606 for(std::set<WorldObject*>::const_iterator itr = i_activeobjects.begin(); itr != i_activeobjects.end(); ++itr) 607 { 608 if( m_id != (*itr)->GetMapId() || i_id != (*itr)->GetInstanceId() ) 609 continue; 610 611 CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY()); 612 if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 613 (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) 614 return true; 615 } 616 617 return false; 595 618 } 596 619 … … 655 678 Cell cell(p); 656 679 657 obj->GetMap()->UpdateObjectVisibility(obj,cell,p);680 MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p); 658 681 } 659 682 … … 662 685 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 663 686 Cell cell(p); 664 Map* m = player->GetMap();687 Map* m = MapManager::Instance().GetMap(player->GetMapId(),player); 665 688 666 689 m->UpdatePlayerVisibility(player,cell,p); -
trunk/src/game/ObjectAccessor.h
r268 r272 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);190 189 191 190 Corpse* GetCorpseForPlayerGUID(uint64 guid); … … 195 194 Corpse* ConvertCorpseForPlayer(uint64 player_guid); 196 195 196 bool ActiveObjectsNearGrid(uint32 x,uint32 y,uint32 m_id,uint32 i_id) const; 197 197 198 static void UpdateObject(Object* obj, Player* exceptPlayer); 198 199 static void _buildUpdateObject(Object* obj, UpdateDataMapType &); … … 200 201 static void UpdateObjectVisibility(WorldObject* obj); 201 202 static void UpdateVisibilityForPlayer(Player* player); 203 204 void AddActiveObject(WorldObject*); 205 void RemoveActiveObject(WorldObject*); 202 206 private: 203 207 struct WorldObjectChangeAccumulator … … 224 228 void _update(void); 225 229 std::set<Object *> i_objects; 230 std::set<WorldObject *> i_activeobjects; 226 231 LockType i_playerGuard; 227 232 LockType i_updateGuard; -
trunk/src/game/ObjectMgr.cpp
r263 r272 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"25 24 26 25 #include "Log.h" … … 118 117 m_hiDoGuid = 1; 119 118 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;126 121 127 122 mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); … … 421 416 422 417 //prepare mail data... : 423 uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() );418 uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() ); 424 419 425 420 // set owner to bidder (to prevent delete item with sender char deleting) … … 472 467 sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); 473 468 474 uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() );469 uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() ); 475 470 476 471 WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); … … 504 499 sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); 505 500 506 uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() );501 uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() ); 507 502 508 503 uint32 profit = auction->bid + auction->deposit - auctionCut; … … 551 546 // will delete item or place to receiver mail list 552 547 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 553 549 } 554 550 // owner not found … … 568 564 void ObjectMgr::LoadCreatureLocales() 569 565 { 570 mCreatureLocaleMap.clear(); // need for reload case571 566 mCreatureLocaleMap.clear(); 567 572 568 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"); 573 569 … … 628 624 sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); 629 625 } 630 626 631 627 void ObjectMgr::LoadNpcOptionLocales() 632 628 { … … 697 693 } 698 694 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 708 695 void ObjectMgr::LoadCreatureTemplates() 709 696 { 710 SQLCreatureLoader loader; 711 loader.Load(sCreatureStorage); 697 sCreatureStorage.Load(); 712 698 713 699 sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); … … 1527 1513 aItem->location = fields[11].GetUInt8(); 1528 1514 //check if sold item exists 1529 if ( GetAItem( aItem->item_guidlow ) )1515 if ( this->GetAItem( aItem->item_guidlow ) ) 1530 1516 { 1531 1517 GetAuctionsMap( aItem->location )->AddAuction(aItem); … … 1547 1533 void ObjectMgr::LoadItemLocales() 1548 1534 { 1549 mItemLocaleMap.clear(); // need for reload case1550 1535 mItemLocaleMap.clear(); 1536 1551 1537 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"); 1552 1538 … … 1609 1595 } 1610 1596 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 1620 1597 void ObjectMgr::LoadItemPrototypes() 1621 1598 { 1622 SQLItemLoader loader; 1623 loader.Load(sItemStorage); 1599 sItemStorage.Load (); 1624 1600 sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); 1625 1601 sLog.outString(); … … 2531 2507 if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) 2532 2508 continue; 2533 2509 2534 2510 // skip expansion classes if not playing with expansion 2535 2511 if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT) … … 3580 3556 void ObjectMgr::LoadQuestLocales() 3581 3557 { 3582 mQuestLocaleMap.clear(); // need for reload case3558 mQuestLocaleMap.clear(); 3583 3559 3584 3560 QueryResult *result = WorldDatabase.Query("SELECT entry," … … 3774 3750 scripts.clear(); // need for reload support 3775 3751 3776 QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,data int, x, y, z, o FROM %s", tablename );3752 QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename ); 3777 3753 3778 3754 uint32 count = 0; … … 3796 3772 Field *fields = result->Fetch(); 3797 3773 ScriptInfo tmp; 3798 tmp.id = fields[0].GetUInt32();3799 tmp.delay = fields[1].GetUInt32();3800 tmp.command = fields[2].GetUInt32();3801 tmp.datalong = fields[3].GetUInt32();3774 tmp.id = fields[0].GetUInt32(); 3775 tmp.delay = fields[1].GetUInt32(); 3776 tmp.command = fields[2].GetUInt32(); 3777 tmp.datalong = fields[3].GetUInt32(); 3802 3778 tmp.datalong2 = fields[4].GetUInt32(); 3803 tmp.data int = 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();3779 tmp.datatext = 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(); 3808 3784 3809 3785 // generic command args check … … 3817 3793 continue; 3818 3794 } 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 loading3831 3795 break; 3832 3796 } … … 4193 4157 void ObjectMgr::LoadPageTextLocales() 4194 4158 { 4195 mPageTextLocaleMap.clear(); // need for reload case4196 4159 mPageTextLocaleMap.clear(); 4160 4197 4161 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"); 4198 4162 … … 4243 4207 } 4244 4208 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 4254 4209 void ObjectMgr::LoadInstanceTemplate() 4255 4210 { 4256 SQLInstanceLoader loader; 4257 loader.Load(sInstanceTemplate); 4211 sInstanceTemplate.Load(); 4258 4212 4259 4213 for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) … … 4371 4325 void ObjectMgr::LoadNpcTextLocales() 4372 4326 { 4373 mNpcTextLocaleMap.clear(); // need for reload case4374 4327 mNpcTextLocaleMap.clear(); 4328 4375 4329 QueryResult *result = WorldDatabase.Query("SELECT entry," 4376 4330 "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," … … 4669 4623 4670 4624 uint32 Trigger_ID = fields[0].GetUInt32(); 4671 const char *scriptName = fields[1].GetString();4625 std::string scriptName = fields[1].GetCppString(); 4672 4626 4673 4627 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); … … 4677 4631 continue; 4678 4632 } 4679 mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName);4633 mAreaTriggerScripts[Trigger_ID] = scriptName; 4680 4634 } while( result->NextRow() ); 4681 4635 … … 4685 4639 sLog.outString( ">> Loaded %u areatrigger scripts", count ); 4686 4640 } 4687 4688 4641 uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) 4689 4642 { … … 4744 4697 uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) 4745 4698 { 4746 uint 16mount_entry = 0;4747 uint 16mount_id = 0;4699 uint32 mount_entry = 0; 4700 uint32 mount_id = 0; 4748 4701 4749 4702 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); 4750 if (node)4703 if (node) 4751 4704 { 4752 4705 if (team == ALLIANCE) mount_entry = node->alliance_mount_type; … … 4987 4940 } 4988 4941 4942 // find now nearest graveyard at same map 4989 4943 if(entryNear) 4990 4944 return entryNear; … … 5227 5181 { 5228 5182 m_hiCharGuid = (*result)[0].GetUInt32()+1; 5183 5229 5184 delete result; 5230 5185 } … … 5234 5189 { 5235 5190 m_hiCreatureGuid = (*result)[0].GetUInt32()+1; 5191 5236 5192 delete result; 5237 5193 } 5238 5194 5239 // pet guids are not saved to DB, set to 0 (pet guid != pet id) 5240 m_hiPetGuid = 0; 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 } 5241 5202 5242 5203 result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); … … 5244 5205 { 5245 5206 m_hiItemGuid = (*result)[0].GetUInt32()+1; 5207 5246 5208 delete result; 5247 5209 } … … 5257 5219 { 5258 5220 m_hiGoGuid = (*result)[0].GetUInt32()+1; 5221 5259 5222 delete result; 5260 5223 } … … 5264 5227 { 5265 5228 m_auctionid = (*result)[0].GetUInt32()+1; 5229 5266 5230 delete result; 5267 5231 } 5268 5232 else 5233 { 5234 m_auctionid = 0; 5235 } 5269 5236 result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); 5270 5237 if( result ) 5271 5238 { 5272 5239 m_mailid = (*result)[0].GetUInt32()+1; 5240 5273 5241 delete result; 5274 5242 } 5275 5243 else 5244 { 5245 m_mailid = 0; 5246 } 5276 5247 result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); 5277 5248 if( result ) 5278 5249 { 5279 m_ItemTextId = (*result)[0].GetUInt32()+1; 5250 m_ItemTextId = (*result)[0].GetUInt32(); 5251 5280 5252 delete result; 5281 5253 } 5254 else 5255 m_ItemTextId = 0; 5282 5256 5283 5257 result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); … … 5285 5259 { 5286 5260 m_hiCorpseGuid = (*result)[0].GetUInt32()+1; 5261 5287 5262 delete result; 5288 5263 } 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++;5323 5264 } 5324 5265 5325 5266 uint32 ObjectMgr::GenerateAuctionID() 5326 5267 { 5327 if(m_auctionid>=0xFFFFFFFE) 5268 ++m_auctionid; 5269 if(m_auctionid>=0xFFFFFFFF) 5328 5270 { 5329 5271 sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. "); 5330 World::StopNow(ERROR_EXIT_CODE);5331 } 5332 return m_auctionid ++;5272 sWorld.m_stopEvent = true; 5273 } 5274 return m_auctionid; 5333 5275 } 5334 5276 5335 5277 uint32 ObjectMgr::GenerateMailID() 5336 5278 { 5337 if(m_mailid>=0xFFFFFFFE) 5279 ++m_mailid; 5280 if(m_mailid>=0xFFFFFFFF) 5338 5281 { 5339 5282 sLog.outError("Mail ids overflow!! Can't continue, shutting down server. "); 5340 World::StopNow(ERROR_EXIT_CODE);5341 } 5342 return m_mailid ++;5283 sWorld.m_stopEvent = true; 5284 } 5285 return m_mailid; 5343 5286 } 5344 5287 5345 5288 uint32 ObjectMgr::GenerateItemTextID() 5346 5289 { 5347 if(m_ItemTextId>=0xFFFFFFFE) 5290 ++m_ItemTextId; 5291 if(m_ItemTextId>=0xFFFFFFFF) 5348 5292 { 5349 5293 sLog.outError("Item text ids overflow!! Can't continue, shutting down server. "); 5350 World::StopNow(ERROR_EXIT_CODE);5351 } 5352 return m_ItemTextId ++;5294 sWorld.m_stopEvent = true; 5295 } 5296 return m_ItemTextId; 5353 5297 } 5354 5298 … … 5372 5316 { 5373 5317 case HIGHGUID_ITEM: 5374 if(m_hiItemGuid>=0xFFFFFFFE) 5318 ++m_hiItemGuid; 5319 if(m_hiItemGuid>=0xFFFFFFFF) 5375 5320 { 5376 5321 sLog.outError("Item guid overflow!! Can't continue, shutting down server. "); 5377 World::StopNow(ERROR_EXIT_CODE);5378 } 5379 return m_hiItemGuid ++;5322 sWorld.m_stopEvent = true; 5323 } 5324 return m_hiItemGuid; 5380 5325 case HIGHGUID_UNIT: 5381 if(m_hiCreatureGuid>=0x00FFFFFE) 5326 ++m_hiCreatureGuid; 5327 if(m_hiCreatureGuid>=0x00FFFFFF) 5382 5328 { 5383 5329 sLog.outError("Creature guid overflow!! Can't continue, shutting down server. "); 5384 World::StopNow(ERROR_EXIT_CODE);5385 } 5386 return m_hiCreatureGuid ++;5330 sWorld.m_stopEvent = true; 5331 } 5332 return m_hiCreatureGuid; 5387 5333 case HIGHGUID_PET: 5388 if(m_hiPetGuid>=0x00FFFFFE) 5334 ++m_hiPetGuid; 5335 if(m_hiPetGuid>=0x00FFFFFF) 5389 5336 { 5390 5337 sLog.outError("Pet guid overflow!! Can't continue, shutting down server. "); 5391 World::StopNow(ERROR_EXIT_CODE);5392 } 5393 return m_hiPetGuid ++;5338 sWorld.m_stopEvent = true; 5339 } 5340 return m_hiPetGuid; 5394 5341 case HIGHGUID_PLAYER: 5395 if(m_hiCharGuid>=0xFFFFFFFE) 5342 ++m_hiCharGuid; 5343 if(m_hiCharGuid>=0xFFFFFFFF) 5396 5344 { 5397 5345 sLog.outError("Players guid overflow!! Can't continue, shutting down server. "); 5398 World::StopNow(ERROR_EXIT_CODE);5399 } 5400 return m_hiCharGuid ++;5346 sWorld.m_stopEvent = true; 5347 } 5348 return m_hiCharGuid; 5401 5349 case HIGHGUID_GAMEOBJECT: 5402 if(m_hiGoGuid>=0x00FFFFFE) 5350 ++m_hiGoGuid; 5351 if(m_hiGoGuid>=0x00FFFFFF) 5403 5352 { 5404 5353 sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. "); 5405 World::StopNow(ERROR_EXIT_CODE);5406 } 5407 return m_hiGoGuid ++;5354 sWorld.m_stopEvent = true; 5355 } 5356 return m_hiGoGuid; 5408 5357 case HIGHGUID_CORPSE: 5409 if(m_hiCorpseGuid>=0xFFFFFFFE) 5358 ++m_hiCorpseGuid; 5359 if(m_hiCorpseGuid>=0xFFFFFFFF) 5410 5360 { 5411 5361 sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. "); 5412 World::StopNow(ERROR_EXIT_CODE);5413 } 5414 return m_hiCorpseGuid ++;5362 sWorld.m_stopEvent = true; 5363 } 5364 return m_hiCorpseGuid; 5415 5365 case HIGHGUID_DYNAMICOBJECT: 5416 if(m_hiDoGuid>=0xFFFFFFFE) 5366 ++m_hiDoGuid; 5367 if(m_hiDoGuid>=0xFFFFFFFF) 5417 5368 { 5418 5369 sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); 5419 World::StopNow(ERROR_EXIT_CODE);5420 } 5421 return m_hiDoGuid ++;5370 sWorld.m_stopEvent = true; 5371 } 5372 return m_hiDoGuid; 5422 5373 default: 5423 5374 ASSERT(0); … … 5430 5381 void ObjectMgr::LoadGameObjectLocales() 5431 5382 { 5432 mGameObjectLocaleMap.clear(); // need for reload case5433 5383 mGameObjectLocaleMap.clear(); 5384 5434 5385 QueryResult *result = WorldDatabase.Query("SELECT entry," 5435 5386 "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," … … 5499 5450 } 5500 5451 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 5510 5452 void ObjectMgr::LoadGameobjectInfo() 5511 5453 { 5512 SQLGameObjectLoader loader; 5513 loader.Load(sGOStorage); 5454 sGOStorage.Load(); 5514 5455 5515 5456 // some checks … … 6684 6625 } 6685 6626 6686 uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id)6687 { 6688 AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find( trigger_id);6627 const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id) 6628 { 6629 AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id); 6689 6630 if(i!= mAreaTriggerScripts.end()) 6690 return i->second ;6691 return 0;6631 return i->second.c_str(); 6632 return ""; 6692 6633 } 6693 6634 … … 6734 6675 return false; 6735 6676 } 6736 case CONDITION_NO_AURA:6737 return !player->HasAura(value1, value2);6738 case CONDITION_ACTIVE_EVENT:6739 return gameeventmgr.IsActiveEvent(value1);6677 case CONDITION_NO_AURA: 6678 return !player->HasAura(value1, value2); 6679 case CONDITION_ACTIVE_EVENT: 6680 return gameeventmgr.IsActiveEvent(value1); 6740 6681 default: 6741 6682 return false; … … 6858 6799 break; 6859 6800 } 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 }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 } 6884 6825 } 6885 6826 return true; … … 7011 6952 if(itr->first > new_id) 7012 6953 new_id = itr->first; 7013 6954 7014 6955 // use next 7015 6956 ++new_id; … … 7051 6992 void ObjectMgr::LoadTrainerSpell() 7052 6993 { 7053 // For reload case 6994 // For reload case 7054 6995 for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) 7055 6996 itr->second.Clear(); … … 7142 7083 void ObjectMgr::LoadVendors() 7143 7084 { 7144 // For reload case 7085 // For reload case 7145 7086 for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 7146 7087 itr->second.Clear(); … … 7249 7190 "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text " 7250 7191 "FROM npc_option"); 7251 7252 7192 if( !result ) 7253 7193 { … … 7402 7342 } 7403 7343 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 do7420 {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 vector7432 // assume "" is the first element7433 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 7478 7344 // Functions for scripting access 7479 uint32 GetAreaTriggerScriptId(uint32 trigger_id)7480 { 7481 return objmgr.GetAreaTriggerScript Id(trigger_id);7345 const char* GetAreaTriggerScriptNameById(uint32 id) 7346 { 7347 return objmgr.GetAreaTriggerScriptName(id); 7482 7348 } 7483 7349 … … 7494 7360 return objmgr.LoadTrinityStrings(db,table,end_value,start_value); 7495 7361 } 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
r263 r272 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 int32 dataint;87 std::string datatext; 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 ranges133 #define MIN_TRINITY_STRING_ID 1134 #define MAX_TRINITY_STRING_ID 2000000000135 #define MIN_DB_SCRIPT_STRING_ID MAX_TRINITY_STRING_ID136 #define MAX_DB_SCRIPT_STRING_ID 2000010000137 130 138 131 struct TrinityStringLocale … … 215 208 CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active. 216 209 CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD ñommission aura active 217 CONDITION_NO_AURA = 11, // spell_id effindex218 CONDITION_ACTIVE_EVENT = 12, // event_id210 CONDITION_NO_AURA = 11, // spell_id effindex 211 CONDITION_ACTIVE_EVENT = 12, // event_id 219 212 }; 220 213 … … 258 251 // NPC gossip text id 259 252 typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap; 260 typedef std::list<GossipOption> CacheNpcOptionList; 253 261 254 262 255 typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap; … … 307 300 typedef UNORDERED_MAP<uint32, Quest*> QuestMap; 308 301 309 310 302 typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap; 311 303 312 typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;304 typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap; 313 305 314 306 typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap; … … 317 309 318 310 typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap; 319 320 typedef std::vector<std::string> ScriptNameMap;321 311 322 312 Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} … … 487 477 AreaTrigger const* GetGoBackTrigger(uint32 Map) const; 488 478 489 uint32 GetAreaTriggerScriptId(uint32 trigger_id);479 const char* GetAreaTriggerScriptName(uint32 id); 490 480 491 481 ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const … … 533 523 534 524 bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); 535 bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); } 536 void LoadDbScriptStrings(); 525 bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",1,std::numeric_limits<int32>::max()); } 537 526 void LoadPetCreateSpells(); 538 527 void LoadCreatureLocales(); … … 604 593 uint32 GenerateItemTextID(); 605 594 uint32 GeneratePetNumber(); 606 uint32 GenerateArenaTeamId();607 uint32 GenerateGuildId();608 595 609 596 void LoadPlayerInfoInCache(); … … 682 669 return &itr->second; 683 670 } 671 684 672 NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const 685 673 { … … 706 694 const char *GetTrinityString(int32 entry, int locale_idx) const; 707 695 const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); } 708 int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }696 int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } 709 697 void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } 710 698 … … 745 733 LocaleConstant GetLocaleForIndex(int i); 746 734 // guild bank tabs 747 uint32 GetGuildBankTabPrice(uint8 Index) const{ return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }735 const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } 748 736 749 737 uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); … … 766 754 bool AddGameTele(GameTele& data); 767 755 bool DeleteGameTele(std::string name); 768 756 769 757 CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; } 770 758 … … 774 762 if(iter == m_mCacheNpcTextIdMap.end()) 775 763 return 0; 776 764 777 765 return iter->second; 778 766 } … … 795 783 return &iter->second; 796 784 } 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); 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 805 789 protected: 806 807 // first free id for selected id type808 790 uint32 m_auctionid; 809 791 uint32 m_mailid; 810 792 uint32 m_ItemTextId; 811 uint32 m_arenaTeamId; 812 uint32 m_guildId; 813 uint32 m_hiPetNumber; 814 815 // first free low guid for seelcted guid type 793 816 794 uint32 m_hiCharGuid; 817 795 uint32 m_hiCreatureGuid; … … 822 800 uint32 m_hiCorpseGuid; 823 801 824 QuestMap mQuestTemplates; 802 uint32 m_hiPetNumber; 803 804 QuestMap mQuestTemplates; 825 805 826 806 typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap; … … 869 849 GameTeleMap m_GameTeleMap; 870 850 871 ScriptNameMap m_scriptNames;872 873 851 typedef std::vector<LocaleConstant> LocalForIndex; 874 852 LocalForIndex m_LocalForIndex; … … 878 856 private: 879 857 void LoadScripts(ScriptMapMap& scripts, char const* tablename); 880 void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids);881 858 void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); 882 859 void LoadQuestRelationsHelper(QuestRelations& map,char const* table); … … 931 908 932 909 // scripting access functions 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(); 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); 937 912 938 913 #endif -
trunk/src/game/Pet.cpp
r265 r272 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_CAST291 // so overwrite old state292 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;294 289 } 295 290 … … 1328 1323 SetUInt32Value(i, 0); 1329 1324 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());1325 QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); 1331 1326 1332 1327 if(result) … … 1338 1333 uint32 spellid = fields[1].GetUInt32(); 1339 1334 uint32 effindex = fields[2].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(); 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(); 1345 1339 1346 1340 SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); … … 1379 1373 continue; 1380 1374 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 } 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); 1390 1381 } 1391 1382 while( result->NextRow() ); … … 1400 1391 1401 1392 AuraMap const& auras = GetAuras(); 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()) 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 ) 1438 1402 break; 1439 } 1440 1441 if (lastEffectPair == itr->first) 1442 stackCounter++; 1443 else 1444 { 1445 lastEffectPair = itr->first; 1446 stackCounter = 1; 1447 } 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)); 1448 1417 } 1449 1418 } … … 1465 1434 return false; 1466 1435 } 1467 1468 // same spells don't have autocast option1469 if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET)1470 active = ACT_CAST;1471 1436 1472 1437 PetSpellMap::iterator itr = m_spells.find(spell_id); … … 1544 1509 CastSpell(this, spell_id, true); 1545 1510 else if(state == PETSPELL_NEW) 1546 m_charmInfo->AddSpellToAB(oldspell_id, spell_id , (ActiveStates)active);1511 m_charmInfo->AddSpellToAB(oldspell_id, spell_id); 1547 1512 1548 1513 if(newspell->active == ACT_ENABLED) … … 1694 1659 return; 1695 1660 1696 //if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid))1697 //if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER1698 //&& tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE)1699 //return;1661 if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) 1662 if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER 1663 && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) 1664 return; 1700 1665 1701 1666 PetSpellMap::const_iterator itr = m_spells.find((uint16)spellid); -
trunk/src/game/Player.cpp
r257 r272 800 800 } 801 801 802 void Player::EnvironmentalDamage(uint64 guid, Enviro mentalDamage type, uint32 damage)802 void Player::EnvironmentalDamage(uint64 guid, EnvironmentalDamageType 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() ? GetMap() : NULL;1644 Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : 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 applySickness)3753 void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, 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 )4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) 4285 4285 { 4286 4286 if(modGroup >= BASEMOD_END || modType >= MOD_END) … … 5244 5244 } 5245 5245 5246 Map *m = GetMap();5246 Map *m = MapManager::Instance().GetMap(GetMapId(), this); 5247 5247 5248 5248 const float old_x = GetPositionX(); … … 5262 5262 5263 5263 // reread after Map::Relocation 5264 m = GetMap();5264 m = MapManager::Instance().GetMap(GetMapId(), this); 5265 5265 x = GetPositionX(); 5266 5266 y = GetPositionY(); … … 6177 6177 return 0; 6178 6178 6179 uint32 id = (*result)[0].GetUInt32(); 6180 delete result; 6181 return id; 6179 return (*result)[0].GetUInt32(); 6182 6180 } 6183 6181 … … 6710 6708 } 6711 6709 6712 if(!IsUseEquip edWeapon(slot==EQUIPMENT_SLOT_MAINHAND))6710 if(!IsUseEquippedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 6713 6711 return; 6714 6712 … … 8488 8486 return item; 8489 8487 8490 if( item->IsBroken() || !IsUseEquip edWeapon(attackType==BASE_ATTACK) )8488 if( item->IsBroken() || !IsUseEquippedWeapon(attackType==BASE_ATTACK) ) 8491 8489 return NULL; 8492 8490 … … 8642 8640 return false; 8643 8641 } 8644 8645 8642 8646 8643 bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const … … 10159 10156 if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10160 10157 pItem->GetProto()->Bonding == BIND_QUEST_ITEM || 10161 pItem->GetProto()->Bonding == BIND_WHEN_EQUIP ED && IsBagPos(pos) )10158 pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 10162 10159 pItem->SetBinding( true ); 10163 10160 … … 10205 10202 if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 10206 10203 pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || 10207 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIP ED && IsBagPos(pos) )10204 pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 10208 10205 pItem2->SetBinding( true ); 10209 10206 … … 10407 10404 10408 10405 // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) 10409 if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIP ED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM )10406 if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 10410 10407 pItem->SetBinding( true ); 10411 10408 … … 10551 10548 if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 10552 10549 CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); 10550 10551 ItemPrototype const *pProto = pItem->GetProto(); 10553 10552 10554 10553 RemoveEnchantmentDurations(pItem); … … 14209 14208 SetUInt32Value(i, 0); 14210 14209 14211 //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index, stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());14210 //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 14212 14211 14213 14212 if(result) … … 14219 14218 uint32 spellid = fields[1].GetUInt32(); 14220 14219 uint32 effindex = fields[2].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(); 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(); 14226 14224 14227 14225 SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); … … 14260 14258 continue; 14261 14259 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 } 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); 14271 14265 } 14272 14266 while( result->NextRow() ); … … 15327 15321 15328 15322 AuraMap const& auras = GetAuras(); 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()) 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) 15368 15340 break; 15369 } 15370 15371 if (lastEffectPair == itr->first) 15372 stackCounter++; 15373 else 15374 { 15375 lastEffectPair = itr->first; 15376 stackCounter = 1; 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)); 15377 15348 } 15378 15349 } … … 17940 17911 continue; 17941 17912 17942 if ( sSpellStore.LookupEntry(pAbility->spellId))17913 if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) 17943 17914 { 17944 17915 // Ok need learn spell … … 18353 18324 Player* not_gray_member_with_max_level = NULL; 18354 18325 18326 // gets the max member level of the group, and the max member level that still gets XP 18355 18327 pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); 18356 18328 … … 18361 18333 xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); 18362 18334 18363 // /skip in check PvP case (for speed, not used)18335 // skip in check PvP case (for speed, not used) 18364 18336 bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); 18365 18337 bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); … … 18688 18660 UpdateBlockPercentage(); 18689 18661 } 18690 18691 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const18692 {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 //***********************************18702 18662 18703 18663 void Player::HandleFallDamage(MovementInfo& movementInfo) … … 18937 18897 target->AddThreat(this, 1000000.0f); 18938 18898 } 18939 // D elete the assigned possessed AI18940 ((Creature*)target)->D eletePossessedAI();18899 // Disable the assigned possessed AI 18900 ((Creature*)target)->DisablePossessedAI(); 18941 18901 } 18942 18902 } … … 19002 18962 } 19003 18963 18964 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const 18965 { 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 19004 18973 bool Player::isTotalImmunity() 19005 18974 { -
trunk/src/game/Player.h
r268 r272 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"37 36 #include "Util.h" // for Tokens typedef 38 37 … … 781 780 782 781 /// Type of environmental damages 783 enum Enviro mentalDamage782 enum EnvironmentalDamageType 784 783 { 785 784 DAMAGE_EXHAUSTED = 0, … … 898 897 void AddToWorld(); 899 898 void RemoveFromWorld(); 899 // always active 900 void setActive(bool) {} 900 901 901 902 void SetViewport(uint64 guid, bool movable); … … 1124 1125 uint32 GetArmorProficiency() const { return m_ArmorProficiency; } 1125 1126 bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } 1126 bool IsUseEquip edWeapon( bool mainhand ) const1127 bool IsUseEquippedWeapon( bool mainhand ) const 1127 1128 { 1128 1129 // disarm applied only to mainhand weapon … … 1306 1307 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); 1307 1308 else 1308 SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d)? GetMoney() + d : MAX_MONEY_AMOUNT);1309 SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); 1309 1310 1310 1311 // "At Gold Limit" … … 1428 1429 PlayerSpellMap const& GetSpellMap() const { return m_spells; } 1429 1430 PlayerSpellMap & GetSpellMap() { return m_spells; } 1431 ActionButtonList const& GetActionButtonList() const { return m_actionButtons; } 1430 1432 1431 1433 void AddSpellMod(SpellModifier* mod, bool apply); … … 1517 1519 void SendUpdateToOutOfRangeGroupMembers(); 1518 1520 1519 void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); }1520 void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); }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 1523 void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } 1522 1524 uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } … … 1531 1533 { 1532 1534 SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); 1533 SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID());1535 SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID()); 1534 1536 } 1535 1537 uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } … … 1607 1609 void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); 1608 1610 1609 //Low Level Packets1611 //Low Level Packets 1610 1612 void PlaySound(uint32 Sound, bool OnlySelf); 1611 1613 //notifiers … … 1639 1641 void KillPlayer(); 1640 1642 uint32 GetResurrectionSpellId(); 1641 void ResurrectPlayer(float restore_percent, bool applySickness = false);1643 void ResurrectPlayer(float restore_percent, bool updateToWorld = true, bool applySickness = false); 1642 1644 void BuildPlayerRepop(); 1643 1645 void RepopAtGraveyard(); … … 1761 1763 void SetRegularAttackTime(); 1762 1764 void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } 1763 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply );1765 void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats = true); 1764 1766 float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; 1765 1767 float GetTotalBaseModValue(BaseModGroup modGroup) const; … … 1768 1770 void _RemoveAllStatBonuses(); 1769 1771 1770 void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType,bool apply);1772 void _ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply); 1771 1773 void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); 1772 1774 void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); … … 1933 1935 1934 1936 /*********************************************************/ 1935 /*** ENVIRO MENTAL SYSTEM ***/1936 /*********************************************************/ 1937 1938 void EnvironmentalDamage(uint64 guid, Enviro mentalDamage type, uint32 damage);1937 /*** ENVIRONMENTAL SYSTEM ***/ 1938 /*********************************************************/ 1939 1940 void EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage); 1939 1941 1940 1942 /*********************************************************/ … … 2061 2063 2062 2064 GridReference<Player> &GetGridRef() { return m_gridRef; } 2063 MapReference &GetMapRef() { return m_mapRef; }2064 2065 2065 bool isAllowedToLoot(Creature* creature); 2066 2066 … … 2308 2308 2309 2309 GridReference<Player> m_gridRef; 2310 MapReference m_mapRef;2311 2310 }; 2312 2311 -
trunk/src/game/PlayerDump.cpp
r263 r272 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 375 374 FILE *fin = fopen(file.c_str(), "r"); 376 375 if(!fin) 377 return DUMP_FILE_OPEN_ERROR;376 return DUMP_FILE_OPEN_ERROR; 378 377 379 378 QueryResult * result = NULL; … … 392 391 else incHighest = false; 393 392 } 394 else 395 guid = objmgr.m_hiCharGuid; 393 else guid = objmgr.m_hiCharGuid; 396 394 397 395 // normalize the name if specified and check if it exists … … 471 469 case DTT_CHAR_TABLE: 472 470 if(!changenth(line, 1, newguid)) 473 ROLLBACK(DUMP_FILE_BROKEN);471 ROLLBACK(DUMP_FILE_BROKEN); 474 472 break; 475 473 … … 477 475 { 478 476 if(!changenth(line, 1, newguid)) 479 ROLLBACK(DUMP_FILE_BROKEN);477 ROLLBACK(DUMP_FILE_BROKEN); 480 478 481 479 // guid, data field:guid, items 482 480 if(!changenth(line, 2, chraccount)) 483 ROLLBACK(DUMP_FILE_BROKEN); 481 ROLLBACK(DUMP_FILE_BROKEN); 482 484 483 std::string vals = getnth(line, 3); 485 484 if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid)) 486 ROLLBACK(DUMP_FILE_BROKEN); 485 ROLLBACK(DUMP_FILE_BROKEN); 486 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); 489 ROLLBACK(DUMP_FILE_BROKEN); 490 490 491 if(!changenth(line, 3, vals.c_str())) 491 ROLLBACK(DUMP_FILE_BROKEN); 492 ROLLBACK(DUMP_FILE_BROKEN); 493 492 494 if (name == "") 493 495 { … … 502 504 // rename on login: `at_login` field 30 in raw field list 503 505 if(!changenth(line, 30, "1")) 504 ROLLBACK(DUMP_FILE_BROKEN);506 ROLLBACK(DUMP_FILE_BROKEN); 505 507 } 506 508 } 507 509 else if(!changenth(line, 4, name.c_str())) 508 ROLLBACK(DUMP_FILE_BROKEN);510 ROLLBACK(DUMP_FILE_BROKEN); 509 511 510 512 break; … … 513 515 { 514 516 if(!changenth(line, 1, newguid)) 515 ROLLBACK(DUMP_FILE_BROKEN);517 ROLLBACK(DUMP_FILE_BROKEN); 516 518 517 519 // bag, item 518 520 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true)) 519 ROLLBACK(DUMP_FILE_BROKEN);520 if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid))521 ROLLBACK(DUMP_FILE_BROKEN);521 ROLLBACK(DUMP_FILE_BROKEN); 522 if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid)) 523 ROLLBACK(DUMP_FILE_BROKEN); 522 524 break; 523 525 } … … 526 528 // item, owner, data field:item, owner guid 527 529 if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid)) 528 ROLLBACK(DUMP_FILE_BROKEN); 529 if(!changenth(line, 2, newguid)) 530 ROLLBACK(DUMP_FILE_BROKEN); 530 ROLLBACK(DUMP_FILE_BROKEN); 531 if(!changenth(line, 2, newguid)) 532 ROLLBACK(DUMP_FILE_BROKEN); 533 531 534 std::string vals = getnth(line,3); 532 535 if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid)) 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);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); 538 541 break; 539 542 } … … 542 545 // guid,item_guid, 543 546 if(!changenth(line, 1, newguid)) 544 ROLLBACK(DUMP_FILE_BROKEN);545 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))546 ROLLBACK(DUMP_FILE_BROKEN);547 ROLLBACK(DUMP_FILE_BROKEN); 548 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) 549 ROLLBACK(DUMP_FILE_BROKEN); 547 550 break; 548 551 } … … 567 570 // item, entry, owner, ... 568 571 if(!changenth(line, 1, newpetid)) 569 ROLLBACK(DUMP_FILE_BROKEN);570 if(!changenth(line, 3, newguid))571 ROLLBACK(DUMP_FILE_BROKEN);572 ROLLBACK(DUMP_FILE_BROKEN); 573 if(!changenth(line, 3, newguid)) 574 ROLLBACK(DUMP_FILE_BROKEN); 572 575 573 576 break; … … 580 583 std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); 581 584 if(petids_iter == petids.end()) // couldn't find new inserted id 582 ROLLBACK(DUMP_FILE_BROKEN);585 ROLLBACK(DUMP_FILE_BROKEN); 583 586 584 587 snprintf(newpetid, 20, "%d", petids_iter->second); 585 588 586 589 if(!changenth(line, 1, newpetid)) 587 ROLLBACK(DUMP_FILE_BROKEN);590 ROLLBACK(DUMP_FILE_BROKEN); 588 591 589 592 break; … … 593 596 // id,messageType,stationery,sender,receiver 594 597 if(!changeGuid(line, 1, mails, objmgr.m_mailid)) 595 ROLLBACK(DUMP_FILE_BROKEN);596 if(!changenth(line, 5, newguid))597 ROLLBACK(DUMP_FILE_BROKEN);598 ROLLBACK(DUMP_FILE_BROKEN); 599 if(!changenth(line, 5, newguid)) 600 ROLLBACK(DUMP_FILE_BROKEN); 598 601 break; 599 602 } … … 602 605 // mail_id,item_guid,item_template,receiver 603 606 if(!changeGuid(line, 1, mails, objmgr.m_mailid)) 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);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); 609 612 break; 610 613 } … … 615 618 616 619 if(!CharacterDatabase.Execute(line.c_str())) 617 ROLLBACK(DUMP_FILE_BROKEN);620 ROLLBACK(DUMP_FILE_BROKEN); 618 621 } 619 622 -
trunk/src/game/SharedDefines.h
r262 r272 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 AUTOCASTABLE_BY_PET0x00020000 // 17251 #define SPELL_ATTR_EX_UNK17 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
r248 r272 997 997 998 998 unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); 999 //TODO: find a better way to judge CC auras1000 if(m_spellInfo->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE)1001 unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC);1002 999 } 1003 1000 else -
trunk/src/game/SpellAuras.cpp
r257 r272 171 171 &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus 172 172 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus 173 &Aura::Handle NoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim173 &Aura::HandleAuraHealing, //115 SPELL_AURA_MOD_HEALING 174 174 &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT 175 175 &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult 176 &Aura::Handle NoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus176 &Aura::HandleAuraHealingPct, //118 SPELL_AURA_MOD_HEALING_PCT 177 177 &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless 178 178 &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE … … 192 192 &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT 193 193 &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE 194 &Aura::Handle NoImmediateEffect,//136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus194 &Aura::HandleAuraHealingPct, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus 195 195 &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE 196 196 &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE … … 221 221 &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE 222 222 &Aura::HandleUnused, //164 useless, only one test spell 223 &Aura::Handle NoImmediateEffect,//165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus223 &Aura::HandleAuraAttackPowerAttacker, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus 224 224 &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT 225 225 &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT … … 2000 2000 } 2001 2001 2002 // Waiting to Resurrect2003 if(GetId()==2584)2004 {2005 // Waiting to resurrect spell cancel, we must remove player from resurrect queue2006 if(m_target->GetTypeId() == TYPEID_PLAYER)2007 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())2008 bg->RemovePlayerFromResurrectQueue(m_target->GetGUID());2009 return;2010 }2011 2012 2002 // Dark Fiend 2013 2003 if(GetId()==45934) … … 2305 2295 void Aura::HandleAuraMounted(bool apply, bool Real) 2306 2296 { 2307 // only at real add/remove aura2308 if(!Real)2309 return;2310 2311 2297 if(apply) 2312 2298 { … … 2708 2694 else 2709 2695 { 2710 // Will use the default model here 2711 if (uint32 modelid = ci->GetRandomValidModelId()) 2712 m_target->SetDisplayId(modelid); 2696 if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); 2713 2697 2714 2698 // Dragonmaw Illusion (set mount model also) … … 3606 3590 /*** MODIFY SPEED ***/ 3607 3591 /*********************************************************/ 3608 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)3592 void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) 3609 3593 { 3610 3594 // all applied/removed only at real aura add/remove … … 3615 3599 } 3616 3600 3617 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real)3601 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real) 3618 3602 { 3619 3603 // all applied/removed only at real aura add/remove … … 3654 3638 } 3655 3639 3656 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)3640 void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real) 3657 3641 { 3658 3642 // all applied/removed only at real aura add/remove … … 3663 3647 } 3664 3648 3665 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real)3649 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) 3666 3650 { 3667 3651 // all applied/removed only at real aura add/remove … … 3674 3658 } 3675 3659 3676 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)3660 void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real) 3677 3661 { 3678 3662 // all applied/removed only at real aura add/remove … … 4359 4343 } 4360 4344 4361 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real)4345 void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real) 4362 4346 { 4363 4347 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4370 4354 } 4371 4355 4372 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real)4356 void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real) 4373 4357 { 4374 4358 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4388 4372 } 4389 4373 4390 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real)4374 void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real) 4391 4375 { 4392 4376 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4399 4383 } 4400 4384 4401 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real)4385 void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real) 4402 4386 { 4403 4387 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4408 4392 } 4409 4393 4410 void Aura::HandleModHealingDone(bool /*apply*/, bool Real)4394 void Aura::HandleModHealingDone(bool apply, bool Real) 4411 4395 { 4412 4396 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4448 4432 } 4449 4433 4450 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real)4434 void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real) 4451 4435 { 4452 4436 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 4583 4567 } 4584 4568 4585 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)4569 void Aura::HandleModPowerRegenPCT(bool apply, bool Real) 4586 4570 { 4587 4571 // spells required only Real aura add/remove … … 4597 4581 } 4598 4582 4599 void Aura::HandleModManaRegen(bool /*apply*/, bool Real)4583 void Aura::HandleModManaRegen(bool apply, bool Real) 4600 4584 { 4601 4585 // spells required only Real aura add/remove … … 4684 4668 /********************************/ 4685 4669 4686 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real)4670 void Aura::HandleAuraModParryPercent(bool apply, bool Real) 4687 4671 { 4688 4672 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4692 4676 } 4693 4677 4694 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real)4678 void Aura::HandleAuraModDodgePercent(bool apply, bool Real) 4695 4679 { 4696 4680 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4701 4685 } 4702 4686 4703 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real)4687 void Aura::HandleAuraModBlockPercent(bool apply, bool Real) 4704 4688 { 4705 4689 if(m_target->GetTypeId()!=TYPEID_PLAYER) … … 4710 4694 } 4711 4695 4712 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)4696 void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real) 4713 4697 { 4714 4698 // spells required only Real aura add/remove … … 4778 4762 } 4779 4763 4780 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)4764 void Aura::HandleModSpellCritChanceShool(bool apply, bool Real) 4781 4765 { 4782 4766 // spells required only Real aura add/remove … … 4858 4842 4859 4843 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); 4844 } 4845 4846 void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real) 4847 { 4848 // spells required only Real aura add/remove 4849 if(!Real) 4850 return; 4851 Unit *caster = GetCaster(); 4852 4853 if (!caster) 4854 return; 4855 4856 // Hunter's Mark 4857 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL) 4858 { 4859 // Check Improved Hunter's Mark bonus on caster 4860 Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); 4861 for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) 4862 { 4863 Modifier* mod = (*i)->GetModifier(); 4864 // mproved Hunter's Mark script from 5236 to 5240 4865 if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240) 4866 { 4867 // Get amount of ranged bonus for this spell.. 4868 int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target); 4869 // Set melee attack power bonus % from ranged depends from Improved mask aura 4870 m_modifier.m_amount = mod->m_amount * ranged_bonus / 100; 4871 m_currentBasePoints = m_modifier.m_amount; 4872 break; 4873 } 4874 } 4875 return; 4876 } 4860 4877 } 4861 4878 … … 5307 5324 } 5308 5325 5309 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real)5326 void Aura::HandleAuraModExpertise(bool apply, bool Real) 5310 5327 { 5311 5328 if(m_target->GetTypeId() != TYPEID_PLAYER) … … 5330 5347 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) 5331 5348 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); 5349 } 5350 5351 //HandleNoImmediateEffect auras implementation to support new stat system 5352 void Aura::HandleAuraHealing(bool apply, bool Real) 5353 { 5354 //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply); 5355 } 5356 5357 void Aura::HandleAuraHealingPct(bool apply, bool Real) 5358 { 5359 //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply); 5332 5360 } 5333 5361 -
trunk/src/game/SpellAuras.h
r257 r272 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); 188 189 void HandleAuraModAttackPowerPercent(bool apply, bool Real); 189 190 void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real); 190 191 void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real); 191 192 void HandleSpiritOfRedemption(bool apply, bool Real); 193 void HandleAuraHealingPct(bool apply, bool Real); 192 194 void HandleModManaRegen(bool apply, bool Real); 193 195 void HandleComprehendLanguage(bool apply, bool Real); 196 void HandleAuraHealing(bool apply, bool Real); 194 197 void HandleShieldBlockValue(bool apply, bool Real); 195 198 void HandleModSpellCritChanceShool(bool apply, bool Real); … … 251 254 uint8 slot = GetAuraSlot(); 252 255 253 // only aura in slot with charges and without stack limitation256 // only aura inslot with charges and without stack limitation 254 257 if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0) 255 258 SetAuraApplication(slot, m_procCharges - 1); -
trunk/src/game/SpellEffects.cpp
r257 r272 334 334 break; 335 335 } 336 // must only affect demons (also undead?)336 // must only affect demons 337 337 case 45072: 338 338 { 339 if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON 340 || unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) 339 if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON) 341 340 return; 342 341 break; 343 342 } 344 // gruul's shatter345 case 33671:346 {347 // don't damage self and only players348 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;356 343 } 357 344 break; … … 1172 1159 m_caster->CastSpell(m_caster, 45009, true); 1173 1160 return; 1174 } 1161 } 1175 1162 case 45030: // Impale Emissary 1176 1163 { … … 1275 1262 //Polymorph Cast Visual Rank 1 1276 1263 const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820}; 1277 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1264 unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 1278 1265 } 1279 1266 return; … … 2251 2238 m_caster->ModifyPower(POWER_MANA,gain); 2252 2239 //send log 2253 m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA );2240 m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA,false); 2254 2241 } 2255 2242 } … … 2267 2254 /*do not uncomment . 2268 2255 if(bg->GetTypeID()==BATTLEGROUND_WS) 2269 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);2256 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 2270 2257 sLog.outDebug("Send Event Horde Flag Picked Up"); 2271 2258 break; … … 2280 2267 /*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 2281 2268 if(bg->GetTypeID()==BATTLEGROUND_WS) 2282 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);2269 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 2283 2270 sLog.outDebug("Send Event Alliance Flag Picked Up"); 2284 2271 break; … … 2291 2278 case 23385: // Alliance Flag Returns 2292 2279 if(bg->GetTypeID()==BATTLEGROUND_WS) 2293 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);2280 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 2294 2281 sLog.outDebug("Alliance Flag Returned"); 2295 2282 break; 2296 2283 case 23386: // Horde Flag Returns 2297 2284 if(bg->GetTypeID()==BATTLEGROUND_WS) 2298 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);2285 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 2299 2286 sLog.outDebug("Horde Flag Returned"); 2300 2287 break;*/ … … 2302 2289 /* 2303 2290 if(bg->GetTypeID()==BATTLEGROUND_EY) 2304 bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);2291 bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 2305 2292 */ 2306 2293 break; … … 2651 2638 float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); 2652 2639 Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; 2653 if(!caster) return;2654 2640 2655 2641 if(Player* modOwner = caster->GetSpellModOwner()) … … 2681 2667 2682 2668 // Some level depends spells 2683 int multiplier = 0;2669 int multiplier = 0; 2684 2670 int level_diff = 0; 2685 2671 switch (m_spellInfo->Id) … … 2688 2674 case 9512: 2689 2675 level_diff = m_caster->getLevel() - 40; 2690 multiplier = 2;2676 multiplier = 2; 2691 2677 break; 2692 2678 // Blood Fury 2693 2679 case 24571: 2694 2680 level_diff = m_caster->getLevel() - 60; 2695 multiplier = 10;2681 multiplier = 10; 2696 2682 break; 2697 2683 // Burst of Energy 2698 2684 case 24532: 2699 2685 level_diff = m_caster->getLevel() - 60; 2700 multiplier = 4;2686 multiplier = 4; 2701 2687 break; 2702 2688 default: … … 3760 3746 ((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)); 3761 3747 else 3762 m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation());3748 MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); 3763 3749 } 3764 3750 … … 3781 3767 return; 3782 3768 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());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()); 3784 3770 3785 3771 // TODO: find formula for honor reward based on player's level! … … 3787 3773 // now fixed only for level 70 players: 3788 3774 if (((Player*)unitTarget)->getLevel() == 70) 3789 ((Player*)unitTarget)->RewardHonor(NULL, 1, damage);3775 ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage); 3790 3776 } 3791 3777 … … 4002 3988 4003 3989 // add to world 4004 pet->GetMap()->Add((Creature*)pet);3990 MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); 4005 3991 4006 3992 // visual effect for levelup … … 4032 4018 return; 4033 4019 4034 OldSummon->GetMap()->Remove((Creature*)OldSummon,false);4020 MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false); 4035 4021 OldSummon->SetMapId(m_caster->GetMapId()); 4036 4022 … … 4039 4025 4040 4026 OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); 4041 m_caster->GetMap()->Add((Creature*)OldSummon);4027 MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon); 4042 4028 4043 4029 if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) … … 4122 4108 if(m_caster->GetTypeId() == TYPEID_UNIT) 4123 4109 { 4124 if ( ((Creature*)m_caster)->isTotem() )4125 NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);4126 else4127 NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);4110 if ( ((Creature*)m_caster)->isTotem() ) 4111 NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); 4112 else 4113 NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); 4128 4114 } 4129 4115 … … 4447 4433 ((Player*)m_caster)->AddComboPoints(unitTarget, 1); 4448 4434 } 4449 4450 4435 // Mangle (Cat): CP 4451 4436 if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) … … 4454 4439 ((Player*)m_caster)->AddComboPoints(unitTarget,1); 4455 4440 } 4441 4456 4442 4457 4443 // take ammo … … 5449 5435 } 5450 5436 5451 void Spell::EffectResurrect(uint32 /*effIndex*/)5437 void Spell::EffectResurrect(uint32 i) 5452 5438 { 5453 5439 if(!unitTarget) … … 5670 5656 int32 targetLevel = creature->getLevel(); 5671 5657 5672 uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 5658 uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 5673 5659 5674 5660 ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); … … 5697 5683 5698 5684 if(m_caster->GetTypeId() != TYPEID_PLAYER) 5699 m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation());5685 MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); 5700 5686 5701 5687 // not all charge effects used in negative spells … … 6133 6119 linkedGO->SetOwnerGUID(m_caster->GetGUID() ); 6134 6120 6135 linkedGO->GetMap()->Add(linkedGO);6121 MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO); 6136 6122 } 6137 6123 else -
trunk/src/game/SpellHandler.cpp
r267 r272 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 … … 55 55 } 56 56 57 if(pItem->GetGUID() != item_guid)58 {59 pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );60 return;61 }62 63 57 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()); 64 58 … … 244 238 245 239 pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); 246 pItem->Set Entry(entry);240 pItem->SetUInt32Value(OBJECT_FIELD_ENTRY, entry); 247 241 pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags); 248 242 pItem->SetState(ITEM_CHANGED, pUser); … … 266 260 267 261 uint64 guid; 262 uint32 spellId = OPEN_CHEST; 268 263 269 264 recv_data >> guid; … … 328 323 329 324 Spell *spell = new Spell(_player, spellInfo, false); 330 spell->m_cast_count = cast_count; // set count of casts325 spell->m_cast_count = cast_count; //set count of casts 331 326 spell->prepare(&targets); 332 327 } … … 369 364 spellInfo->EffectApplyAuraName[i] == SPELL_AURA_BIND_SIGHT) 370 365 { 371 // Fix me: creature may be killed during player aura cancel372 366 _player->RemoveAurasDueToSpellByCancel(spellId); 373 367 if (_player->GetCharm()) 374 368 _player->GetCharm()->RemoveAurasDueToSpellByCancel(spellId); 375 else if (_player->GetFarsightTarget() && _player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT)369 else if (_player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT) 376 370 ((Unit*)_player->GetFarsightTarget())->RemoveAurasDueToSpellByCancel(spellId); 377 371 return; -
trunk/src/game/SpellMgr.cpp
r265 r272 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 {260 247 case SPELL_TRACKER: 261 248 case SPELL_WARLOCK_ARMOR: … … 263 250 case SPELL_ELEMENTAL_SHIELD: 264 251 case SPELL_MAGE_POLYMORPH: 252 case SPELL_POSITIVE_SHOUT: 253 case SPELL_JUDGEMENT: 254 case SPELL_WARLOCK_CORRUPTION: 265 255 return spellSpec1==spellSpec2; 266 256 case SPELL_BATTLE_ELIXIR: … … 1041 1031 } 1042 1032 1043 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2 , bool sameCaster) const1044 { 1045 //if(spellId_1 == spellId_2) // auras due to the same spell1046 //return false;1033 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const 1034 { 1035 if(spellId_1 == spellId_2) // auras due to the same spell 1036 return false; 1047 1037 1048 1038 SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); … … 1052 1042 return false; 1053 1043 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 1061 1044 if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) 1062 1045 return false; 1063 1046 1064 // generic spells 1065 if(!spellInfo_1->SpellFamilyName) 1047 if(!spellInfo_1->SpellFamilyName) // generic spells 1066 1048 { 1067 1049 if(!spellInfo_1->SpellIconID … … 1069 1051 return false; 1070 1052 } 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) 1053 else if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) 1054 return false; 1055 1056 for(uint32 i = 0; i < 3; ++i) 1057 if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i] 1058 || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) 1076 1059 return false; 1077 }1078 1079 // check for class spells1080 else1081 {1082 if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags)1083 return false;1084 }1085 1086 for(uint32 i = 0; i < 3; ++i)1087 {1088 if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i]1089 || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]1090 || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i]) // paladin resist aura1091 return false; // need itemtype check? need an example to add that check1092 1093 if(spellInfo_1->EffectApplyAuraName[i] // both spell has the same auras1094 && !sameCaster1095 && 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_AURA1097 {1098 switch(spellInfo_1->EffectApplyAuraName[i])1099 {1100 // DOT or HOT from different casters will stack1101 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 }1113 1060 1114 1061 return true; -
trunk/src/game/SpellMgr.h
r264 r272 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); 304 bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1, uint32 spellSpec2); 303 bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2); 305 304 bool IsPassiveSpell(uint32 spellId); 306 305 … … 770 769 bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const; 771 770 static bool canStackSpellRanks(SpellEntry const *spellInfo); 772 bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2 , bool sameCaster) const;771 bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const; 773 772 774 773 SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const; -
trunk/src/game/StatSystem.cpp
r257 r272 385 385 weapon_maxdamage = lvl*1.25*att_speed; 386 386 } 387 else if(!IsUseEquip edWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc)387 else if(!IsUseEquippedWeapon(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
r265 r272 98 98 default: break; 99 99 } 100 101 if(GetEntry() == SENTRY_TOTEM_ENTRY)102 SetAggressive(true);103 100 } 104 101 -
trunk/src/game/Unit.cpp
r267 r272 1149 1149 if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) 1150 1150 { 1151 uint32 modDamage=*damage; 1152 1151 1153 // apply spellmod to Done damage 1152 1154 if(Player* modOwner = GetSpellModOwner()) … … 1433 1435 if(!this || !pVictim) 1434 1436 return 0; 1435 if(! isAlive() || !pVictim->isAlive())1437 if(!this->isAlive() || !pVictim->isAlive()) 1436 1438 return 0; 1437 1439 … … 3781 3783 { 3782 3784 m_ccAuras.push_back(Aur); 3785 RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); 3783 3786 } 3784 3787 } … … 3896 3899 if(!is_triggered_by_spell) 3897 3900 { 3898 bool sameCaster = Aur->GetCasterGUID() == (*i).second->GetCasterGUID(); 3899 if( spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId, sameCaster) ) 3900 { 3901 //some spells should be not removed by lower rank of them 3902 // what is this spell? 3903 if (!sameCaster 3904 &&(spellProto->Effect[effIndex]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY) 3905 &&(spellProto->DurationIndex==21) 3906 &&(spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 3907 &&(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)) 3908 return false; 3901 SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); 3902 3903 bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); 3904 3905 if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) 3906 { 3907 // cannot remove higher rank 3908 if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 3909 if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 3910 return false; 3909 3911 3910 3912 // Its a parent aura (create this aura in ApplyModifier) … … 3920 3922 else 3921 3923 next = m_Auras.begin(); 3924 } 3925 else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) 3926 { 3927 // Its a parent aura (create this aura in ApplyModifier) 3928 if ((*i).second->IsInUse()) 3929 { 3930 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()); 3931 continue; 3932 } 3933 RemoveAurasDueToSpell(i_spellId); 3934 3935 if( m_Auras.empty() ) 3936 break; 3937 else 3938 next = m_Auras.begin(); 3939 } 3940 // Potions stack aura by aura (elixirs/flask already checked) 3941 else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) 3942 { 3943 if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex)) 3944 { 3945 if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 3946 return false; // cannot remove higher rank 3947 3948 // Its a parent aura (create this aura in ApplyModifier) 3949 if ((*i).second->IsInUse()) 3950 { 3951 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()); 3952 continue; 3953 } 3954 RemoveAura(i); 3955 next = i; 3956 } 3922 3957 } 3923 3958 } … … 4094 4129 void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) 4095 4130 { 4096 Aura* Aur = i->second; 4097 SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); 4098 4099 Unit* caster = NULL; 4100 if (IsSingleTargetSpell(AurSpellInfo)) 4101 { 4102 caster = Aur->GetCaster(); 4103 if(caster) 4131 if (IsSingleTargetSpell((*i).second->GetSpellProto())) 4132 { 4133 if(Unit* caster = (*i).second->GetCaster()) 4104 4134 { 4105 4135 AuraList& scAuras = caster->GetSingleCastAuras(); 4106 scAuras.remove( Aur);4136 scAuras.remove((*i).second); 4107 4137 } 4108 4138 else … … 4113 4143 } 4114 4144 4115 // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) 4116 if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) 4145 if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) 4117 4146 { 4118 4147 m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); … … 4126 4155 } 4127 4156 4157 // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) 4158 Aura* Aur = i->second; 4128 4159 // Set remove mode 4129 4160 Aur->SetRemoveMode(mode); … … 4133 4164 ++m_removedAuras; // internal count used by unit update 4134 4165 4135 // Statu eunsummoned at aura remove4166 // Status unsummoned at aura remove 4136 4167 Totem* statue = NULL; 4137 bool caster_channeled = false; 4138 if(IsChanneledSpell(AurSpellInfo)) 4139 { 4140 if(!caster) // can be already located for IsSingleTargetSpell case 4141 caster = Aur->GetCaster(); 4142 4143 if(caster) 4144 { 4168 if(IsChanneledSpell(Aur->GetSpellProto())) 4169 if(Unit* caster = Aur->GetCaster()) 4145 4170 if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) 4146 4171 statue = ((Totem*)caster); 4147 else 4148 caster_channeled = caster==this; 4149 } 4150 } 4172 4151 4173 4152 4174 if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id)) … … 4165 4187 Aur->_RemoveAura(); 4166 4188 delete Aur; 4167 4168 if(caster_channeled)4169 RemoveAurasAtChanneledTarget (AurSpellInfo);4170 4189 4171 4190 if(statue) … … 4594 4613 } 4595 4614 4596 bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 cooldown) 4597 { 4598 SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto(); 4599 4615 bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) 4616 { 4600 4617 Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 4601 4618 ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; … … 4657 4674 } 4658 4675 4659 bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 4660 { 4661 SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); 4662 uint32 effIndex = triggeredByAura->GetEffIndex (); 4663 4676 bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 4677 { 4664 4678 Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 4665 4679 ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; … … 6249 6263 return false; 6250 6264 6265 uint32 spell = 0; 6251 6266 switch(triggeredByAura->GetSpellProto()->Id) 6252 6267 { … … 6278 6293 6279 6294 // overwrite non existing triggered spell call in spell.dbc 6295 uint32 spell = 0; 6280 6296 switch(triggeredByAura->GetSpellProto()->Id) 6281 6297 { … … 6477 6493 } 6478 6494 6479 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 6480 { 6481 int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; 6482 6495 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 6496 { 6483 6497 if(!pVictim || !pVictim->isAlive()) 6484 6498 return false; … … 7246 7260 } 7247 7261 7248 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype )7262 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype, bool critical) 7249 7263 { 7250 7264 WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); … … 7346 7360 AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); 7347 7361 for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) 7348 if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto))7362 if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) 7349 7363 TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; 7350 7364 … … 8194 8208 8195 8209 // ..done (for creature type by mask) in taken 8196 AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);8210 AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); 8197 8211 for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) 8198 8212 if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) … … 8262 8276 // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage 8263 8277 8264 AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);8278 AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); 8265 8279 for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) 8266 8280 if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) … … 8492 8506 target->SetStandState(PLAYER_STATE_NONE); 8493 8507 8494 if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER 8495 && ((Creature*)target)->isAggressive() && ((Creature*)target)->AI()) 8508 if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI()) 8496 8509 ((Creature*)target)->AI()->AttackStart(this); 8497 8510 … … 8542 8555 { 8543 8556 assert(target); 8544 8545 if(!IsHostileTo(target))8546 return false;8547 8557 8548 8558 if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) … … 8721 8731 if(IsInWorld()) 8722 8732 { 8723 Map *m = GetMap();8733 Map *m = MapManager::Instance().GetMap(GetMapId(), this); 8724 8734 8725 8735 if(GetTypeId()==TYPEID_PLAYER) … … 9130 9140 } 9131 9141 9132 // search nearby enemy before enter evade mode9133 if(Unit *target = ((Creature*)this)->SelectNearestTarget())9134 {9135 ((Creature*)this)->AI()->AttackStart(target);9136 return true;9137 }9138 9139 9142 // enter in evade mode in other case 9140 9143 ((Creature*)this)->AI()->EnterEvadeMode(); … … 9790 9793 } 9791 9794 9795 9796 9792 9797 CharmInfo* Unit::InitCharmInfo(Unit *charm) 9793 9798 { … … 9953 9958 struct ProcTriggeredData 9954 9959 { 9955 ProcTriggeredData( Aura* _triggeredByAura, uint32 _cooldown)9956 : triggeredByAura(_triggeredByAura),9960 ProcTriggeredData(SpellEntry const * _spellInfo, uint32 _spellParam, Aura* _triggeredByAura, uint32 _cooldown) 9961 : spellInfo(_spellInfo), spellParam(_spellParam), triggeredByAura(_triggeredByAura), 9957 9962 triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), 9958 9963 cooldown(_cooldown) 9959 {} 9960 9961 Aura* triggeredByAura; // triggred aura, can be invalidate at triggered aura proccessing 9962 Unit::spellEffectPair triggeredByAura_SpellPair; // spell pair, used for re-find aura (by pointer comparison in range) 9963 uint32 cooldown; // possible hidden cooldown 9964 {} 9965 9966 SpellEntry const * spellInfo; 9967 uint32 spellParam; 9968 Aura* triggeredByAura; 9969 Unit::spellEffectPair triggeredByAura_SpellPair; 9970 uint32 cooldown; 9964 9971 }; 9965 9972 … … 9978 9985 next = i; ++next; 9979 9986 9980 Aura* i_aura = *i; 9981 9982 uint32 cooldown; // returned at next line 9983 if(!IsTriggeredAtSpellProcEvent(i_aura->GetSpellProto(), procSpell, procFlag,attType,isVictim,cooldown)) 9987 SpellEntry const *spellProto = (*i)->GetSpellProto(); 9988 if(!spellProto) 9984 9989 continue; 9985 9990 9986 procTriggered.push_back( ProcTriggeredData(i_aura, cooldown) ); 9991 SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 9992 if(!spellProcEvent) 9993 { 9994 // used to prevent spam in log about same non-handled spells 9995 static std::set<uint32> nonHandledSpellProcSet; 9996 9997 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 9998 { 9999 sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 10000 nonHandledSpellProcSet.insert(spellProto->Id); 10001 } 10002 10003 // spell.dbc use totally different flags, that only can create problems if used. 10004 continue; 10005 } 10006 10007 // Check spellProcEvent data requirements 10008 if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 10009 continue; 10010 10011 // Check if current equipment allows aura to proc 10012 if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 10013 { 10014 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 10015 { 10016 Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 10017 10018 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10019 continue; 10020 } 10021 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 10022 { 10023 // Check if player is wearing shield 10024 Item *item = ((Player*)this)->GetShield(true); 10025 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 10026 continue; 10027 } 10028 } 10029 10030 float chance = (float)spellProto->procChance; 10031 10032 if(Player* modOwner = GetSpellModOwner()) 10033 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 10034 10035 if(!isVictim && spellProcEvent->ppmRate != 0) 10036 { 10037 uint32 WeaponSpeed = GetAttackTime(attType); 10038 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 10039 } 10040 10041 if(roll_chance_f(chance)) 10042 { 10043 uint32 cooldown = spellProcEvent->cooldown; 10044 10045 uint32 i_spell_eff = (*i)->GetEffIndex(); 10046 10047 int32 i_spell_param; 10048 switch(*aur) 10049 { 10050 case SPELL_AURA_PROC_TRIGGER_SPELL: 10051 i_spell_param = procFlag; 10052 break; 10053 case SPELL_AURA_DUMMY: 10054 case SPELL_AURA_PRAYER_OF_MENDING: 10055 case SPELL_AURA_MOD_HASTE: 10056 i_spell_param = i_spell_eff; 10057 break; 10058 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 10059 i_spell_param = (*i)->GetModifier()->m_miscvalue; 10060 break; 10061 default: 10062 i_spell_param = (*i)->GetModifier()->m_amount; 10063 break; 10064 } 10065 10066 procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); 10067 } 9987 10068 } 9988 10069 … … 10017 10098 } 10018 10099 10019 /// this is aura triggering code call 10020 Aura* triggeredByAura = i->triggeredByAura; 10021 10022 /// save charges existence before processing to prevent crash at access to deleted triggered aura after 10023 /// used in speedup code check before check aura existance. 10024 bool triggeredByAuraWithCharges = triggeredByAura->m_procCharges > 0; 10025 10026 /// success in event proccesing 10027 /// used in speedup code check before check aura existance. 10100 // save charges existence before processing to prevent crash at access to deleted triggered aura after 10101 bool triggeredByAuraWithCharges = i->triggeredByAura->m_procCharges > 0; 10102 10028 10103 bool casted = false; 10029 10030 /// process triggered code10031 10104 switch(*aur) 10032 10105 { 10033 10106 case SPELL_AURA_PROC_TRIGGER_SPELL: 10034 10107 { 10035 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s proc aura of spell %u)", 10036 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10037 casted = HandleProcTriggerSpell(pTarget, damage, triggeredByAura, procSpell, procFlag, attType, i->cooldown); 10108 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()); 10109 casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); 10038 10110 break; 10039 10111 } 10040 10112 case SPELL_AURA_PROC_TRIGGER_DAMAGE: 10041 10113 { 10042 uint32 triggered_damage = triggeredByAura->GetModifier()->m_amount; 10043 sLog.outDebug("ProcDamageAndSpell: doing %u damage (triggered by %s aura of spell %u)", 10044 triggered_damage, (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10045 SpellNonMeleeDamageLog(pTarget, triggeredByAura->GetId(), triggered_damage, true, true); 10114 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()); 10115 uint32 damage = i->spellParam; 10116 SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); 10046 10117 casted = true; 10047 10118 break; … … 10049 10120 case SPELL_AURA_DUMMY: 10050 10121 { 10051 uint32 effect = triggeredByAura->GetEffIndex(); 10052 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s dummy aura of spell %u)", 10053 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10054 casted = HandleDummyAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 10122 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()); 10123 casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 10055 10124 break; 10056 10125 } 10057 10126 case SPELL_AURA_PRAYER_OF_MENDING: 10058 10127 { 10059 sLog.outDebug("ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)", 10060 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10061 10062 casted = HandleMeandingAuraProc(triggeredByAura); 10128 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()); 10129 10130 // aura can be deleted at casts 10131 int32 heal = i->triggeredByAura->GetModifier()->m_amount; 10132 uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); 10133 10134 // jumps 10135 int32 jumps = i->triggeredByAura->m_procCharges-1; 10136 10137 // current aura expire 10138 i->triggeredByAura->m_procCharges = 1; // will removed at next charges decrease 10139 10140 // next target selection 10141 if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 10142 { 10143 Aura* aura = i->triggeredByAura; 10144 10145 SpellEntry const* spellProto = aura->GetSpellProto(); 10146 uint32 effIdx = aura->GetEffIndex(); 10147 10148 float radius; 10149 if (spellProto->EffectRadiusIndex[effIdx]) 10150 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 10151 else 10152 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 10153 10154 if(Player* caster = ((Player*)aura->GetCaster())) 10155 { 10156 caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 10157 10158 if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 10159 { 10160 // aura will applied from caster, but spell casted from current aura holder 10161 SpellModifier *mod = new SpellModifier; 10162 mod->op = SPELLMOD_CHARGES; 10163 mod->value = jumps-5; // negative 10164 mod->type = SPELLMOD_FLAT; 10165 mod->spellId = spellProto->Id; 10166 mod->effectId = effIdx; 10167 mod->lastAffected = NULL; 10168 mod->mask = spellProto->SpellFamilyFlags; 10169 mod->charges = 0; 10170 10171 caster->AddSpellMod(mod, true); 10172 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); 10173 caster->AddSpellMod(mod, false); 10174 } 10175 } 10176 } 10177 10178 // heal 10179 CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 10180 casted = true; 10063 10181 break; 10064 10182 } 10065 10183 case SPELL_AURA_MOD_HASTE: 10066 10184 { 10067 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s haste aura of spell %u)", 10068 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10069 casted = HandleHasteAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 10185 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()); 10186 casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 10070 10187 break; 10071 10188 } … … 10074 10191 // nothing do, just charges counter 10075 10192 // but count only in case appropriate school damage 10076 casted = triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask;10193 casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; 10077 10194 break; 10078 10195 } 10079 10196 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 10080 10197 { 10081 sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)", 10082 (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 10083 casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown); 10198 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()); 10199 casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); 10084 10200 break; 10085 10201 } … … 10092 10208 } 10093 10209 10094 // /Update charge (aura can be removed by triggers)10210 // Update charge (aura can be removed by triggers) 10095 10211 if(casted && triggeredByAuraWithCharges) 10096 10212 { 10097 // / need re-found aura (can be dropped by triggers)10213 // need found aura (can be dropped by triggers) 10098 10214 AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); 10099 10215 AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); 10100 10216 for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) 10101 10217 { 10102 if(itr->second == triggeredByAura) // pointer still valid10218 if(itr->second == i->triggeredByAura) 10103 10219 { 10104 if( triggeredByAura->m_procCharges > 0)10105 triggeredByAura->m_procCharges -= 1;10106 10107 triggeredByAura->UpdateAuraCharges();10220 if(i->triggeredByAura->m_procCharges > 0) 10221 i->triggeredByAura->m_procCharges -= 1; 10222 10223 i->triggeredByAura->UpdateAuraCharges(); 10108 10224 break; 10109 10225 } … … 10112 10228 } 10113 10229 10114 // /Safely remove auras with zero charges10230 // Safely remove auras with zero charges 10115 10231 for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) 10116 10232 { … … 10225 10341 // send explicit stop packet 10226 10342 // rely on vmaps here because for example stormwind is in air 10227 //float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);10343 float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); 10228 10344 //if (fabs(GetPositionZ() - z) < 2.0f) 10229 10345 // Relocate(GetPositionX(), GetPositionY(), z); … … 10435 10551 } 10436 10552 10437 Unit* Unit::SelectNearbyTarget( float dist) const10553 Unit* Unit::SelectNearbyTarget() const 10438 10554 { 10439 10555 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); … … 10445 10561 10446 10562 { 10447 Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist);10563 Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); 10448 10564 Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(targets, u_check); 10449 10565 … … 10709 10825 } 10710 10826 10711 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID());10712 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID());10713 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());10827 pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID()); 10828 pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID()); 10829 pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction()); 10714 10830 pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); 10715 10831 … … 10729 10845 return pet; 10730 10846 } 10731 10732 bool Unit::IsTriggeredAtSpellProcEvent(SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown )10733 {10734 SpellProcEventEntry const * spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id);10735 10736 if(!spellProcEvent)10737 {10738 // used to prevent spam in log about same non-handled spells10739 static std::set<uint32> nonHandledSpellProcSet;10740 10741 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end())10742 {10743 sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's"));10744 nonHandledSpellProcSet.insert(spellProto->Id);10745 }10746 10747 // spell.dbc use totally different flags, that only can create problems if used.10748 return false;10749 }10750 10751 // Check spellProcEvent data requirements10752 if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag))10753 return false;10754 10755 // Check if current equipment allows aura to proc10756 if(!isVictim && GetTypeId() == TYPEID_PLAYER )10757 {10758 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON)10759 {10760 Item *item = ((Player*)this)->GetWeaponForAttack(attType,true);10761 10762 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))10763 return false;10764 }10765 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR)10766 {10767 // Check if player is wearing shield10768 Item *item = ((Player*)this)->GetShield(true);10769 if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))10770 return false;10771 }10772 }10773 10774 float chance = (float)spellProto->procChance;10775 10776 if(Player* modOwner = GetSpellModOwner())10777 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance);10778 10779 if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0)10780 {10781 uint32 WeaponSpeed = GetAttackTime(attType);10782 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate);10783 }10784 10785 cooldown = spellProcEvent ? spellProcEvent->cooldown : 0;10786 return roll_chance_f(chance);10787 }10788 10789 bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura )10790 {10791 // aura can be deleted at casts10792 SpellEntry const* spellProto = triggeredByAura->GetSpellProto();10793 uint32 effIdx = triggeredByAura->GetEffIndex();10794 int32 heal = triggeredByAura->GetModifier()->m_amount;10795 uint64 caster_guid = triggeredByAura->GetCasterGUID();10796 10797 // jumps10798 int32 jumps = triggeredByAura->m_procCharges-1;10799 10800 // current aura expire10801 triggeredByAura->m_procCharges = 1; // will removed at next charges decrease10802 10803 // next target selection10804 if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid))10805 {10806 float radius;10807 if (spellProto->EffectRadiusIndex[effIdx])10808 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx]));10809 else10810 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex));10811 10812 if(Player* caster = ((Player*)triggeredByAura->GetCaster()))10813 {10814 caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL);10815 10816 if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius))10817 {10818 // aura will applied from caster, but spell casted from current aura holder10819 SpellModifier *mod = new SpellModifier;10820 mod->op = SPELLMOD_CHARGES;10821 mod->value = jumps-5; // negative10822 mod->type = SPELLMOD_FLAT;10823 mod->spellId = spellProto->Id;10824 mod->effectId = effIdx;10825 mod->lastAffected = NULL;10826 mod->mask = spellProto->SpellFamilyFlags;10827 mod->charges = 0;10828 10829 caster->AddSpellMod(mod, true);10830 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID());10831 caster->AddSpellMod(mod, false);10832 }10833 }10834 }10835 10836 // heal10837 CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid);10838 return true;10839 }10840 10841 void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo)10842 {10843 uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT);10844 10845 if(!IS_UNIT_GUID(target_guid))10846 return;10847 10848 Unit* target = ObjectAccessor::GetUnit(*this, target_guid);10849 if(!target)10850 return;10851 10852 for (AuraMap::iterator iter = target->GetAuras().begin(); iter != target->GetAuras().end(); )10853 {10854 if (iter->second->GetId() == spellInfo->Id && iter->second->GetCasterGUID()==GetGUID())10855 target->RemoveAura(iter);10856 else10857 ++iter;10858 }10859 } -
trunk/src/game/Unit.h
r266 r272 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 … … 763 763 void CombatStop(bool cast = false); 764 764 void CombatStopWithPets(bool cast = false); 765 Unit* SelectNearbyTarget( float dist = ATTACK_DISTANCE) const;765 Unit* SelectNearbyTarget() const; 766 766 767 767 void addUnitState(uint32 f) { m_state |= f; } … … 934 934 935 935 void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); 936 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype );936 void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false); 937 937 uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); 938 938 void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); … … 1040 1040 void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); 1041 1041 void RemoveAurasDueToSpellByCancel(uint32 spellId); 1042 void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo);1043 1042 void RemoveNotOwnSingleTargetAuras(); 1044 1043 … … 1372 1371 1373 1372 void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); 1374 bool IsTriggeredAtSpellProcEvent( SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ); 1375 bool HandleDummyAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 1376 bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, uint32 cooldown); 1377 bool HandleHasteAuraProc( Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 1378 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 cooldown); 1379 bool HandleMeandingAuraProc(Aura* triggeredByAura); 1373 bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 1374 bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); 1375 bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 1376 bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell,uint32 cooldown); 1380 1377 1381 1378 uint32 m_state; // Even derived shouldn't modify -
trunk/src/game/WaypointManager.cpp
r263 r272 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"28 27 29 28 INSTANTIATE_SINGLETON_1(WaypointManager); … … 31 30 bool WaypointBehavior::isEmpty() 32 31 { 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; 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(); 41 34 } 42 35 43 36 WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) 44 37 { 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]; 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]; 51 41 } 52 42 … … 77 67 } 78 68 79 result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text id1, textid2, textid3, textid4, textid5, id, point FROM creature_movement");69 result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id, point FROM creature_movement"); 80 70 if(result) 81 71 { … … 124 114 be.emote = fields[7].GetUInt32(); 125 115 be.spell = fields[8].GetUInt32(); 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; 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(); 153 121 154 122 // save memory by not storing empty behaviors … … 298 266 if(!node.behavior) node.behavior = new WaypointBehavior(); 299 267 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 : "";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 : ""; 305 273 if(field == "emote") node.behavior->emote = text ? atoi(text) : 0; 306 274 if(field == "spell") node.behavior->spell = text ? atoi(text) : 0; -
trunk/src/game/WaypointManager.h
r263 r272 26 26 #include "Utilities/UnorderedMap.h" 27 27 28 #define MAX_WAYPOINT_TEXT 529 28 struct WaypointBehavior 30 29 { 31 30 uint32 emote; 32 31 uint32 spell; 33 int32 textid[MAX_WAYPOINT_TEXT];32 std::string text[5]; 34 33 uint32 model1; 35 34 uint32 model2; -
trunk/src/game/WaypointMovementGenerator.cpp
r263 r272 22 22 creature_movement Table 23 23 24 alter table creature_movement add `text id1` int(11) NOT NULL default '0';25 alter table creature_movement add `text id2` int(11) NOT NULL default '0';26 alter table creature_movement add `text id3` int(11) NOT NULL default '0';27 alter table creature_movement add `text id4` int(11) NOT NULL default '0';28 alter table creature_movement add `text id5` int(11) NOT NULL default '0';24 alter table creature_movement add `text1` varchar(255) default NULL; 25 alter table creature_movement add `text2` varchar(255) default NULL; 26 alter table creature_movement add `text3` varchar(255) default NULL; 27 alter table creature_movement add `text4` varchar(255) default NULL; 28 alter table creature_movement add `text5` varchar(255) default NULL; 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->textid[0])151 if(!behavior->text[0].empty()) 152 152 { 153 // Not only one text is set154 if( behavior->textid[1])153 // Only one text is set 154 if( !behavior->text[1].empty() ) 155 155 { 156 156 // Select one from max 5 texts (0 and 1 already checked) 157 157 int i = 2; 158 for( ; i < MAX_WAYPOINT_TEXT; ++i )159 if( !behavior->textid[i])158 for( ; i < 5; ++i ) 159 if( behavior->text[i].empty() ) 160 160 break; 161 161 162 creature.Say(behavior->textid[rand() % i], 0, 0); 162 creature.Say(behavior->text[rand() % i].c_str(), 0, 0); 163 163 164 } 164 165 else 165 creature.Say(behavior->text id[0], 0, 0);166 creature.Say(behavior->text[0].c_str(), 0, 0); 166 167 } 167 168 } // wpBehaviour found -
trunk/src/game/World.cpp
r260 r272 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;70 69 volatile uint32 World::m_worldLoopCounter = 0; 71 70 … … 544 543 m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 545 544 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 608 609 if(reload) 609 610 { … … 769 770 m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 770 771 771 // always use declined names in the russian client772 m_configs[CONFIG_DECLINED_NAMES_USED] = 772 // always use declined names in the Russian client 773 m_configs[CONFIG_DECLINED_NAMES_USED] = 773 774 (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 774 775 … … 965 966 DetectDBCLang(); 966 967 967 sLog.outString( "Loading Script Names...");968 objmgr.LoadScriptNames();969 970 968 sLog.outString( "Loading InstanceTemplate" ); 971 969 objmgr.LoadInstanceTemplate(); … … 1083 1081 sLog.outString( "Loading Tavern Area Triggers..." ); 1084 1082 objmgr.LoadTavernAreaTriggers(); 1085 1083 1086 1084 sLog.outString( "Loading AreaTrigger script names..." ); 1087 1085 objmgr.LoadAreaTriggerScripts(); 1086 1088 1087 1089 1088 sLog.outString( "Loading Graveyard-zone links..."); … … 1166 1165 sLog.outString( "Loading Npc Text Id..." ); 1167 1166 objmgr.LoadNpcTextId(); // must be after load Creature and NpcText 1168 1167 1169 1168 sLog.outString( "Loading Npc Options..." ); 1170 1169 objmgr.LoadNpcOptions(); … … 1194 1193 objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) 1195 1194 1196 sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls1197 objmgr.LoadDbScriptStrings();1198 1199 1195 sLog.outString( "Initializing Scripts..." ); 1200 1196 if(!LoadScriptingModule()) … … 1267 1263 sLog.outString( "WORLD: World initialized" ); 1268 1264 } 1269 1270 1265 void World::DetectDBCLang() 1271 1266 { … … 1468 1463 } 1469 1464 1470 /// </ul> 1471 ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1472 MapManager::Instance().DoDelayedMovesAndRemoves(); 1465 MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1473 1466 1474 1467 // update the instance reset times … … 1590 1583 } 1591 1584 1592 //if(source && !source->IsInWorld()) source = NULL;1593 1594 1585 Object* target = NULL; 1595 1586 … … 1619 1610 } 1620 1611 1621 //if(target && !target->IsInWorld()) target = NULL;1622 1623 1612 switch (step.script->command) 1624 1613 { … … 1648 1637 { 1649 1638 case 0: // Say 1650 ((Creature *)source)->Say(step.script->data int, LANG_UNIVERSAL, unit_target);1639 ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 1651 1640 break; 1652 1641 case 1: // Whisper … … 1656 1645 break; 1657 1646 } 1658 ((Creature *)source)->Whisper(step.script->data int,unit_target);1647 ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); 1659 1648 break; 1660 1649 case 2: // Yell 1661 ((Creature *)source)->Yell(step.script->data int, LANG_UNIVERSAL, unit_target);1650 ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 1662 1651 break; 1663 1652 case 3: // Emote text 1664 ((Creature *)source)->TextEmote(step.script->data int, unit_target);1653 ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); 1665 1654 break; 1666 1655 default: … … 1713 1702 } 1714 1703 ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); 1715 ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);1704 MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 1716 1705 break; 1717 1706 case SCRIPT_COMMAND_FLAG_SET: … … 1863 1852 go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds 1864 1853 1865 go->GetMap()->Add(go);1854 MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); 1866 1855 break; 1867 1856 } … … 2385 2374 2386 2375 ///- if there is a shutdown timer 2387 if( !m_stopEvent &&m_ShutdownTimer > 0 && elapsed > 0)2376 if(m_ShutdownTimer > 0 && elapsed > 0) 2388 2377 { 2389 2378 ///- ... and it is overdue, stop the world (set m_stopEvent) … … 2391 2380 { 2392 2381 if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2393 m_stopEvent = true; // exist code already set2382 m_stopEvent = true; 2394 2383 else 2395 2384 m_ShutdownTimer = 1; // minimum timer value to wait idle state … … 2406 2395 2407 2396 /// Shutdown the server 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 2397 void World::ShutdownServ(uint32 time, uint32 options) 2398 { 2414 2399 m_ShutdownMask = options; 2415 m_ExitCode = exitcode;2416 2400 2417 2401 ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) … … 2419 2403 { 2420 2404 if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2421 m_stopEvent = true; // exist code already set2405 m_stopEvent = true; 2422 2406 else 2423 2407 m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick … … 2464 2448 void World::ShutdownCancel() 2465 2449 { 2466 // nothing cancel or too later 2467 if(!m_ShutdownTimer || m_stopEvent) 2450 if(!m_ShutdownTimer) 2468 2451 return; 2469 2452 … … 2472 2455 m_ShutdownMask = 0; 2473 2456 m_ShutdownTimer = 0; 2474 m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value2475 2457 SendServerMessage(msgid); 2476 2458 2477 DEBUG_LOG("Server %s cancel led.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));2459 DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 2478 2460 } 2479 2461 … … 2520 2502 if(!itr->second->Update(diff)) // As interval = 0 2521 2503 { 2522 RemoveQueuedPlayer (itr->second);2523 2504 delete itr->second; 2524 2505 m_sessions.erase(itr); -
trunk/src/game/World.h
r260 r272 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 ShutdownExitCode55 {56 SHUTDOWN_EXIT_CODE = 0,57 ERROR_EXIT_CODE = 1,58 RESTART_EXIT_CODE = 2,59 };60 61 54 /// Timers for different object refresh rates 62 55 enum WorldTimers … … 69 62 WUPDATE_CORPSES = 5, 70 63 WUPDATE_EVENTS = 6, 71 WUPDATE_COUNT = 7 64 WUPDATE_COUNT = 7, 65 72 66 }; 73 67 … … 112 106 CONFIG_INSTANCE_IGNORE_RAID, 113 107 CONFIG_BATTLEGROUND_CAST_DESERTER, 114 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE,115 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY,116 108 CONFIG_INSTANCE_RESET_TIME_HOUR, 117 109 CONFIG_INSTANCE_UNLOAD_DELAY, … … 152 144 CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, 153 145 CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, 154 CONFIG_DETECT_POS_COLLISION,155 146 CONFIG_RESTRICTED_LFG_CHANNEL, 156 147 CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, … … 326 317 struct CliCommandHolder 327 318 { 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; }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; } 342 333 }; 343 334 … … 346 337 { 347 338 public: 339 static volatile bool m_stopEvent; 348 340 static volatile uint32 m_worldLoopCounter; 349 341 … … 353 345 WorldSession* FindSession(uint32 id) const; 354 346 void AddSession(WorldSession *s); 347 355 348 bool RemoveSession(uint32 id); 356 349 /// Get the number of current active sessions … … 415 408 void LoadConfigSettings(bool reload = false); 416 409 417 void SendWorldText(int32 string_id, ...); 410 void SendWorldText(int32 string_id, ...); 418 411 void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); 419 412 void SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); … … 422 415 423 416 /// Are we in the middle of a shutdown? 417 uint32 GetShutdownMask() const { return m_ShutdownMask; } 424 418 bool IsShutdowning() const { return m_ShutdownTimer > 0; } 425 void ShutdownServ(uint32 time, uint32 options , uint8 exitcode);419 void ShutdownServ(uint32 time, uint32 options = 0); 426 420 void ShutdownCancel(); 427 421 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; }431 422 432 423 void Update(time_t diff); … … 463 454 void KickAllQueued(); 464 455 BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); 465 bool RemoveBanAccount(BanMode mode, std::string nameOrIP);456 bool RemoveBanAccount(BanMode mode, std::string nameOrIP); 466 457 467 458 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target); … … 491 482 LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } 492 483 493 //used World DB version494 void LoadDBVersion();495 char const* GetDBVersion() { return m_DBVersion.c_str(); }496 497 //used Script version498 void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; }499 char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); }484 //used World DB version 485 void LoadDBVersion(); 486 char const* GetDBVersion() { return m_DBVersion.c_str(); } 487 488 //used Script version 489 void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; } 490 char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); } 500 491 501 492 protected: … … 508 499 void ResetDailyQuests(); 509 500 private: 510 static volatile bool m_stopEvent;511 static uint8 m_ExitCode;512 uint32 m_ShutdownTimer;513 uint32 m_ShutdownMask;514 515 501 time_t m_startTime; 516 502 time_t m_gameTime; … … 540 526 std::set<uint32> m_forbiddenMapIds; 541 527 528 uint32 m_ShutdownTimer; 529 uint32 m_ShutdownMask; 530 542 531 // for max speed access 543 532 static float m_MaxVisibleDistanceForCreature; … … 557 546 //Player Queue 558 547 Queue m_QueuedPlayer; 559 548 560 549 //sessions that are added async 561 550 void AddSession_(WorldSession* s); 562 551 ZThread::LockedQueue<WorldSession*, ZThread::FastMutex> addSessQueue; 563 552 564 //used versions565 std::string m_DBVersion;566 std::string m_ScriptsVersion;553 //used versions 554 std::string m_DBVersion; 555 std::string m_ScriptsVersion; 567 556 }; 568 557
![(please configure the [header_logo] section in trac.ini)](/TrinityCore/trac.cgi/chrome/site/your_project_logo.png)