Changeset 260 for trunk/src/game
- Timestamp:
- 11/21/08 08:47:55 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 36 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/AuctionHouse.cpp
r229 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 90 90 return false; 91 91 } 92 data << auction->Id;93 data << pItem->GetUInt32Value(OBJECT_FIELD_ENTRY);92 data << (uint32) auction->Id; 93 data << (uint32) pItem->GetEntry(); 94 94 95 95 for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++) … … 246 246 return; 247 247 } 248 // prevent sending bag with items (cheat: can be placed in bag after adding equip ped empty bag to auction)248 // prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction) 249 249 if(!it) 250 250 { … … 717 717 if (il) 718 718 { 719 if (il->Name.size() > loc_idx&& !il->Name[loc_idx].empty())719 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) 720 720 name = il->Name[loc_idx]; 721 721 } -
trunk/src/game/Bag.cpp
r177 r260 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 44 delete m_bagslot[i]; 45 45 } 46 46 … … 72 72 Object::_Create( guidlow, 0, HIGHGUID_CONTAINER ); 73 73 74 Set UInt32Value(OBJECT_FIELD_ENTRY,itemid);74 SetEntry(itemid); 75 75 SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); 76 76 … … 86 86 SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots); 87 87 88 // Clean ning 20 slots88 // Cleaning 20 slots 89 89 for (uint8 i = 0; i < MAX_BAG_SIZE; i++) 90 90 { … … 214 214 if(m_bagslot[i]->GetGUID() == guid) 215 215 return i; 216 216 217 return NULL_SLOT; 217 218 } … … 221 222 if( slot < GetBagSize() ) 222 223 return m_bagslot[slot]; 223 224 224 225 return NULL; 225 226 } -
trunk/src/game/Chat.cpp
r233 r260 64 64 }; 65 65 66 static ChatCommand serverIdleRestartCommandTable[] = 67 { 68 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 69 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL }, 70 { NULL, 0, false, NULL, "", NULL } 71 }; 72 73 static ChatCommand serverIdleShutdownCommandTable[] = 74 { 75 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 76 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL }, 77 { NULL, 0, false, NULL, "", NULL } 78 }; 79 80 static ChatCommand serverRestartCommandTable[] = 81 { 82 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 83 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerRestartCommand, "", NULL }, 84 { NULL, 0, false, NULL, "", NULL } 85 }; 86 87 static ChatCommand serverShutdownCommandTable[] = 88 { 89 { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, 90 { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCommand, "", NULL }, 91 { NULL, 0, false, NULL, "", NULL } 92 }; 93 66 94 static ChatCommand serverCommandTable[] = 67 95 { 68 96 { "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL }, 69 97 { "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL }, 70 { "idlerestart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleRestartCommand, "", NULL},71 { "idleshutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleIdleShutDownCommand, "", NULL},98 { "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable }, 99 { "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, 72 100 { "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL }, 73 101 { "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL }, 74 { "restart", SEC_ADMINISTRATOR, true, &ChatHandler::HandleRestartCommand, "", NULL},75 { "shutdown", SEC_ADMINISTRATOR, true, &ChatHandler::HandleShutDownCommand, "", NULL},102 { "restart", SEC_ADMINISTRATOR, true, NULL, "", serverRestartCommandTable }, 103 { "shutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable }, 76 104 { "set", SEC_ADMINISTRATOR, true, NULL, "", serverSetCommandTable }, 77 105 { NULL, 0, false, NULL, "", NULL } -
trunk/src/game/Chat.h
r233 r260 176 176 bool HandleModifyRepCommand(const char* args); 177 177 bool HandleModifyArenaCommand(const char* args); 178 bool HandleModifyGenderCommand(const char* args); 178 179 179 180 bool HandleNpcAddCommand(const char* args); … … 192 193 bool HandleNpcSpawnDistCommand(const char* args); 193 194 bool HandleNpcSpawnTimeCommand(const char* args); 195 bool HandleNpcTameCommand(const char* args); 194 196 bool HandleNpcTextEmoteCommand(const char* args); 195 197 bool HandleNpcUnFollowCommand(const char* args); … … 216 218 bool HandleReloadCreatureQuestRelationsCommand(const char* args); 217 219 bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); 220 bool HandleReloadDbScriptStringCommand(const char* args); 218 221 bool HandleReloadGameGraveyardZoneCommand(const char* args); 219 222 bool HandleReloadGameObjectScriptsCommand(const char* args); … … 271 274 bool HandleServerCorpsesCommand(const char* args); 272 275 bool HandleServerExitCommand(const char* args); 276 bool HandleServerIdleRestartCommand(const char* args); 277 bool HandleServerIdleShutDownCommand(const char* args); 273 278 bool HandleServerInfoCommand(const char* args); 274 279 bool HandleServerMotdCommand(const char* args); 280 bool HandleServerRestartCommand(const char* args); 275 281 bool HandleServerSetMotdCommand(const char* args); 276 282 bool HandleServerSetLogLevelCommand(const char* args); 283 bool HandleServerShutDownCommand(const char* args); 284 bool HandleServerShutDownCancelCommand(const char* args); 277 285 278 286 bool HandleAddHonorCommand(const char* args); … … 328 336 bool HandleBanListCharacterCommand(const char* args); 329 337 bool HandleBanListIPCommand(const char* args); 330 bool HandleIdleRestartCommand(const char* args);331 bool HandleIdleShutDownCommand(const char* args);332 bool HandleShutDownCommand(const char* args);333 bool HandleRestartCommand(const char* args);334 bool HandleSecurityCommand(const char* args);335 338 bool HandleGoXYCommand(const char* args); 336 339 bool HandleGoXYZCommand(const char* args); … … 366 369 bool HandleAddItemCommand(const char* args); 367 370 bool HandleAddItemSetCommand(const char* args); 368 bool HandleModifyGenderCommand(const char* args);369 371 bool HandlePetTpCommand(const char* args); 370 372 bool HandlePetUnlearnCommand(const char* args); -
trunk/src/game/Creature.cpp
r230 r260 178 178 float x,y,z,o; 179 179 GetRespawnCoord(x, y, z, &o); 180 MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o);180 GetMap()->CreatureRelocation(this,x,y,z,o); 181 181 } 182 182 … … 210 210 } 211 211 212 Set UInt32Value(OBJECT_FIELD_ENTRY, Entry);// normal entry always212 SetEntry(Entry); // normal entry always 213 213 m_creatureInfo = cinfo; // map mode related always 214 214 … … 353 353 lootForBody = false; 354 354 355 if(m_originalEntry != Get UInt32Value(OBJECT_FIELD_ENTRY))355 if(m_originalEntry != GetEntry()) 356 356 UpdateEntry(m_originalEntry); 357 357 … … 372 372 373 373 //Call AI respawn virtual function 374 AI()->JustRespawned();375 376 MapManager::Instance().GetMap(GetMapId(), this)->Add(this);374 i_AI->JustRespawned(); 375 376 GetMap()->Add(this); 377 377 } 378 378 break; … … 436 436 // do not allow the AI to be changed during update 437 437 m_AI_locked = true; 438 AI()->UpdateAI(diff);438 i_AI->UpdateAI(diff); 439 439 m_AI_locked = false; 440 440 } … … 2097 2097 } 2098 2098 2099 char const* Creature::GetScriptName() const 2100 { 2101 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; 2099 std::string Creature::GetScriptName() 2100 { 2101 return objmgr.GetScriptName(GetScriptId()); 2102 } 2103 2104 uint32 Creature::GetScriptId() 2105 { 2106 return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; 2102 2107 } 2103 2108 -
trunk/src/game/Creature.h
r230 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 206 206 uint32 MechanicImmuneMask; 207 207 uint32 flags_extra; 208 char const* ScriptName;208 uint32 ScriptID; 209 209 uint32 GetRandomValidModelId() const; 210 210 uint32 GetFirstValidModelId() const; 211 211 212 // helpers 212 213 SkillType GetRequiredLootSkill() const 213 214 { … … 219 220 return SKILL_SKINNING; // normal case 220 221 } 221 222 222 223 bool isTameable() const 223 224 { … … 499 500 CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } 500 501 CreatureDataAddon const* GetCreatureAddon() const; 501 char const* GetScriptName() const; 502 503 std::string GetScriptName(); 504 uint32 GetScriptId(); 502 505 503 506 void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 ); … … 525 528 // overwrite WorldObject function for proper name localization 526 529 const char* GetNameForLocaleIdx(int32 locale_idx) const; 527 530 528 531 void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState 529 532 -
trunk/src/game/CreatureAI.cpp
r207 r260 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
r102 r260 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
r174 r260 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
r174 r260 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
r111 r260 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) 32 return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); 33 33 } 34 34 } … … 81 81 inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content) 82 82 { 83 //TODO: need modifier for CONTENT_71_80 different from CONTENT_61_70? 83 84 const uint32 nBaseExp = content == CONTENT_1_60 ? 45 : 235; 84 85 if( mob_level >= pl_level ) -
trunk/src/game/GMTicketHandler.cpp
r229 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 67 67 recv_data >> ticketText; 68 68 69 CharacterDatabase.escape_string(ticketText);70 71 69 if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 72 70 ticket->SetText(ticketText.c_str()); … … 106 104 sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2); 107 105 108 CharacterDatabase.escape_string(ticketText); 109 110 if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 106 if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) 111 107 { 112 108 WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); -
trunk/src/game/GMTicketMgr.h
r229 r260 51 51 m_text = text ? text : ""; 52 52 m_lastUpdate = time(NULL); 53 CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid); 53 54 std::string escapedString = m_text; 55 CharacterDatabase.escape_string(escapedString); 56 CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", escapedString.c_str(), m_guid); 54 57 } 55 58 … … 63 66 CharacterDatabase.BeginTransaction(); 64 67 DeleteFromDB(); 65 CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText()); 68 69 std::string escapedString = m_text; 70 CharacterDatabase.escape_string(escapedString); 71 72 CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, escapedString.c_str()); 66 73 CharacterDatabase.CommitTransaction(); 67 74 } -
trunk/src/game/GameObject.h
r230 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 358 358 } raw; 359 359 }; 360 char *ScriptName;360 uint32 ScriptId; 361 361 }; 362 362 -
trunk/src/game/Item.cpp
r102 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 180 180 return true; 181 181 case ITEM_SUBCLASS_SOUL_CONTAINER: 182 if(!(pProto->BagFamily & BAG_FAMILY_MASK_S HARDS))182 if(!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS)) 183 183 return false; 184 184 return true; … … 248 248 Object::_Create( guidlow, 0, HIGHGUID_ITEM ); 249 249 250 Set UInt32Value(OBJECT_FIELD_ENTRY,itemid);250 SetEntry(itemid); 251 251 SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); 252 252 … … 430 430 ItemPrototype const *Item::GetProto() const 431 431 { 432 return objmgr.GetItemPrototype(Get UInt32Value(OBJECT_FIELD_ENTRY));432 return objmgr.GetItemPrototype(GetEntry()); 433 433 } 434 434 … … 763 763 { 764 764 // Better lost small time at check in comparison lost time at item save to DB. 765 if( GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET)==id && 766 GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration && 767 GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET)==charges ) 765 if((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) 768 766 return; 769 767 … … 776 774 void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) 777 775 { 778 if(Get UInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration)776 if(GetEnchantmentDuration(slot) == duration) 779 777 return; 780 778 … … 785 783 void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges) 786 784 { 785 if(GetEnchantmentCharges(slot) == charges) 786 return; 787 787 788 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges); 788 789 SetState(ITEM_CHANGED); … … 791 792 void Item::ClearEnchantment(EnchantmentSlot slot) 792 793 { 793 if(!Get UInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET))794 return; 795 796 for( int x=0;x<3;x++)797 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0);794 if(!GetEnchantmentId(slot)) 795 return; 796 797 for(uint8 x = 0; x < 3; ++x) 798 SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0); 798 799 SetState(ITEM_CHANGED); 799 800 } -
trunk/src/game/Item.h
r102 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 229 229 bool GemsFitSockets() const; 230 230 231 uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }232 231 uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); } 233 232 void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); } -
trunk/src/game/ItemEnchantmentMgr.cpp
r206 r260 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
r102 r260 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
r229 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 314 314 if (il) 315 315 { 316 if (il->Name.size() > loc_idx&& !il->Name[loc_idx].empty())316 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) 317 317 Name = il->Name[loc_idx]; 318 if (il->Description.size() > loc_idx&& !il->Description[loc_idx].empty())318 if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty()) 319 319 Description = il->Description[loc_idx]; 320 320 } … … 361 361 data << pProto->Damage[i].DamageType; 362 362 } 363 364 // resistances (7) 363 365 data << pProto->Armor; 364 366 data << pProto->HolyRes; … … 368 370 data << pProto->ShadowRes; 369 371 data << pProto->ArcaneRes; 372 370 373 data << pProto->Delay; 371 374 data << pProto->Ammo_type; 372 373 data << (float)pProto->RangedModRange; 375 data << pProto->RangedModRange; 376 374 377 for(int s = 0; s < 5; s++) 375 378 { … … 977 980 if (il) 978 981 { 979 if (il->Name.size() > loc_idx&& !il->Name[loc_idx].empty())982 if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) 980 983 Name = il->Name[loc_idx]; 981 984 } … … 1028 1031 } 1029 1032 1030 if(item==gift) // not poss ible with pacjket from real client1033 if(item==gift) // not possable with pacjket from real client 1031 1034 { 1032 1035 _player->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, NULL ); … … 1073 1076 CharacterDatabase.BeginTransaction(); 1074 1077 CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS)); 1075 item->Set UInt32Value(OBJECT_FIELD_ENTRY, gift->GetUInt32Value(OBJECT_FIELD_ENTRY));1078 item->SetEntry(gift->GetEntry()); 1076 1079 1077 1080 switch (item->GetEntry()) 1078 1081 { 1079 case 5042: item->Set UInt32Value(OBJECT_FIELD_ENTRY,5043); break;1080 case 5048: item->Set UInt32Value(OBJECT_FIELD_ENTRY,5044); break;1081 case 17303: item->Set UInt32Value(OBJECT_FIELD_ENTRY,17302); break;1082 case 17304: item->Set UInt32Value(OBJECT_FIELD_ENTRY,17305); break;1083 case 17307: item->Set UInt32Value(OBJECT_FIELD_ENTRY,17308); break;1084 case 21830: item->Set UInt32Value(OBJECT_FIELD_ENTRY,21831); break;1082 case 5042: item->SetEntry( 5043); break; 1083 case 5048: item->SetEntry( 5044); break; 1084 case 17303: item->SetEntry(17302); break; 1085 case 17304: item->SetEntry(17305); break; 1086 case 17307: item->SetEntry(17308); break; 1087 case 21830: item->SetEntry(21831); break; 1085 1088 } 1086 1089 item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID()); -
trunk/src/game/ItemPrototype.h
r257 r260 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 … … 100 100 ITEM_FLAGS_USEABLE_IN_ARENA = 0x00200000, 101 101 ITEM_FLAGS_THROWABLE = 0x00400000, // not used in game for check trow possibility, only for item in game tooltip 102 ITEM_FLAGS_SPECIALUSE = 0x00800000 // last used flag in 2.3.0 102 ITEM_FLAGS_SPECIALUSE = 0x00800000, // last used flag in 2.3.0 103 ITEM_FLAGS_BOA = 0x08000000, // bind on account 104 ITEM_FLAGS_MILLABLE = 0x20000000 103 105 }; 104 106 … … 107 109 BAG_FAMILY_MASK_ARROWS = 0x00000001, 108 110 BAG_FAMILY_MASK_BULLETS = 0x00000002, 109 BAG_FAMILY_MASK_S HARDS= 0x00000004,111 BAG_FAMILY_MASK_SOUL_SHARDS = 0x00000004, 110 112 BAG_FAMILY_MASK_LEATHERWORKING_SUPP = 0x00000008, 111 BAG_FAMILY_MASK_ UNUSED = 0x00000010, // not used currently113 BAG_FAMILY_MASK_INSCRIPTION_SUPP = 0x00000010, 112 114 BAG_FAMILY_MASK_HERBS = 0x00000020, 113 115 BAG_FAMILY_MASK_ENCHANTING_SUPP = 0x00000040, … … 117 119 BAG_FAMILY_MASK_MINING_SUPP = 0x00000400, 118 120 BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT = 0x00000800, 119 BAG_FAMILY_MASK_VANITY_PETS = 0x00001000 120 }; 121 122 /* TODO: Not entirely positive on need for this?? 123 enum SOCKET_CONTENT (); 124 */ 121 BAG_FAMILY_MASK_VANITY_PETS = 0x00001000, 122 BAG_FAMILY_MASK_CURRENCY_TOKENS = 0x00002000, 123 BAG_FAMILY_MASK_QUEST_ITEMS = 0x00004000 124 }; 125 125 126 126 enum SocketColor … … 276 276 }; 277 277 278 #define MAX_ITEM_SUBCLASS_ARMOR 10278 #define MAX_ITEM_SUBCLASS_ARMOR 10 279 279 280 280 enum ItemSubclassReagent … … 390 390 391 391 #define MAX_ITEM_SUBCLASS_JUNK 6 392 393 enum ItemSubclassGlyph 394 { 395 ITEM_SUBCLASS_GLYPH_WARRIOR = 1, 396 ITEM_SUBCLASS_GLYPH_PALADIN = 2, 397 ITEM_SUBCLASS_GLYPH_HUNTER = 3, 398 ITEM_SUBCLASS_GLYPH_ROGUE = 4, 399 ITEM_SUBCLASS_GLYPH_PRIEST = 5, 400 ITEM_SUBCLASS_GLYPH_DEATH_KNIGHT = 6, 401 ITEM_SUBCLASS_GLYPH_SHAMAN = 7, 402 ITEM_SUBCLASS_GLYPH_MAGE = 8, 403 ITEM_SUBCLASS_GLYPH_WARLOCK = 9, 404 ITEM_SUBCLASS_GLYPH_DRUID = 11 405 }; 406 407 #define MAX_ITEM_SUBCLASS_GLYPH 12 392 408 393 409 const uint32 MaxItemSubclassValues[MAX_ITEM_CLASS] = … … 525 541 uint32 RequiredDisenchantSkill; 526 542 float ArmorDamageModifier; 527 char* ScriptName;543 uint32 ScriptId; 528 544 uint32 DisenchantID; 529 545 uint32 FoodType; -
trunk/src/game/Level2.cpp
r230 r260 2362 2362 // Check 2363 2363 // Remember: "show" must also be the name of a column! 2364 if( (show != "emote") && (show != "spell") && (show != "text 1") && (show != "text2")2365 && (show != "text 3") && (show != "text4") && (show != "text5")2364 if( (show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2") 2365 && (show != "textid3") && (show != "textid4") && (show != "textid5") 2366 2366 && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") 2367 2367 && (show != "model1") && (show != "model2") && (show != "orientation")) … … 2703 2703 PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); 2704 2704 SetSentErrorMessage(true); 2705 return false; 2706 } 2707 2708 // set in game textids not supported 2709 if( show == "textid1" || show == "textid2" || show == "textid3" || 2710 show == "textid4" || show == "textid5" ) 2711 { 2705 2712 return false; 2706 2713 } … … 2843 2850 2844 2851 QueryResult *result = 2845 WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text 1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u",2852 WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u", 2846 2853 target->GetGUIDLow() ); 2847 2854 if(!result) … … 2855 2862 PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); 2856 2863 2857 result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text 1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )",2864 result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", 2858 2865 target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); 2859 2866 if(!result) … … 2872 2879 uint32 emote = fields[3].GetUInt32(); 2873 2880 uint32 spell = fields[4].GetUInt32(); 2874 const char * text1 = fields[5].GetString(); 2875 const char * text2 = fields[6].GetString(); 2876 const char * text3 = fields[7].GetString(); 2877 const char * text4 = fields[8].GetString(); 2878 const char * text5 = fields[9].GetString(); 2881 uint32 textid[MAX_WAYPOINT_TEXT]; 2882 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 2883 textid[i] = fields[5+i].GetUInt32(); 2879 2884 uint32 model1 = fields[10].GetUInt32(); 2880 2885 uint32 model2 = fields[11].GetUInt32(); … … 2889 2894 PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); 2890 2895 PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); 2891 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1); 2892 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2); 2893 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3); 2894 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4); 2895 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5); 2896 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 2897 PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetTrinityString(textid[i]) : "")); 2896 2898 2897 2899 }while( result->NextRow() ); … … 3214 3216 3215 3217 QueryResult *result = WorldDatabase.PQuery( 3216 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14153217 "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text 1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );3218 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3219 "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); 3218 3220 3219 3221 if (!result) … … 3232 3234 3233 3235 outfile << "INSERT INTO creature_movement "; 3234 outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text 1, text2, text3, text4, text5 ) VALUES ";3236 outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5 ) VALUES "; 3235 3237 3236 3238 outfile << "( "; … … 3257 3259 outfile << fields[9].GetUInt32(); // spell 3258 3260 outfile << ", "; 3259 const char *tmpChar = fields[10].GetString(); 3260 if( !tmpChar ) 3261 { 3262 outfile << "NULL"; // text1 3263 } 3264 else 3265 { 3266 outfile << "'"; 3267 outfile << tmpChar; // text1 3268 outfile << "'"; 3269 } 3261 outfile << fields[10].GetUInt32(); // textid1 3270 3262 outfile << ", "; 3271 tmpChar = fields[11].GetString(); 3272 if( !tmpChar ) 3273 { 3274 outfile << "NULL"; // text2 3275 } 3276 else 3277 { 3278 outfile << "'"; 3279 outfile << tmpChar; // text2 3280 outfile << "'"; 3281 } 3263 outfile << fields[11].GetUInt32(); // textid2 3282 3264 outfile << ", "; 3283 tmpChar = fields[12].GetString(); 3284 if( !tmpChar ) 3285 { 3286 outfile << "NULL"; // text3 3287 } 3288 else 3289 { 3290 outfile << "'"; 3291 outfile << tmpChar; // text3 3292 outfile << "'"; 3293 } 3265 outfile << fields[12].GetUInt32(); // textid3 3294 3266 outfile << ", "; 3295 tmpChar = fields[13].GetString(); 3296 if( !tmpChar ) 3297 { 3298 outfile << "NULL"; // text4 3299 } 3300 else 3301 { 3302 outfile << "'"; 3303 outfile << tmpChar; // text4 3304 outfile << "'"; 3305 } 3267 outfile << fields[13].GetUInt32(); // textid4 3306 3268 outfile << ", "; 3307 tmpChar = fields[14].GetString(); 3308 if( !tmpChar ) 3309 { 3310 outfile << "NULL"; // text5 3311 } 3312 else 3313 { 3314 outfile << "'"; 3315 outfile << tmpChar; // text5 3316 outfile << "'"; 3317 } 3269 outfile << fields[14].GetUInt32(); // textid5 3318 3270 outfile << ");\n "; 3319 3271 -
trunk/src/game/Level3.cpp
r235 r260 136 136 HandleReloadSpellScriptsCommand("a"); 137 137 SendGlobalSysMessage("DB tables `*_scripts` reloaded."); 138 HandleReloadDbScriptStringCommand("a"); 138 139 return true; 139 140 } … … 599 600 SendGlobalSysMessage("DB table `spell_scripts` reloaded."); 600 601 602 return true; 603 } 604 605 bool ChatHandler::HandleReloadDbScriptStringCommand(const char* arg) 606 { 607 sLog.outString( "Re-Loading Script strings from `db_script_string`..."); 608 objmgr.LoadDbScriptStrings(); 609 SendGlobalSysMessage("DB table `db_script_string` reloaded."); 601 610 return true; 602 611 } … … 1768 1777 // search highest talent rank 1769 1778 uint32 spellid = 0; 1770 for(int rank = 4; rank >= 0; --rank) 1779 int rank = 4; 1780 for(; rank >= 0; --rank) 1771 1781 { 1772 1782 if(talentInfo->RankID[rank]!=0) … … 4646 4656 } 4647 4657 4648 bool ChatHandler::HandleShutDownCommand(const char* args) 4658 bool ChatHandler::HandleServerShutDownCancelCommand(const char* args) 4659 { 4660 sWorld.ShutdownCancel(); 4661 return true; 4662 } 4663 4664 bool ChatHandler::HandleServerShutDownCommand(const char* args) 4649 4665 { 4650 4666 if(!*args) 4651 4667 return false; 4652 4668 4653 if(std::string(args)=="cancel") 4654 { 4655 sWorld.ShutdownCancel(); 4669 char* time_str = strtok ((char*) args, " "); 4670 char* exitcode_str = strtok (NULL, ""); 4671 4672 int32 time = atoi (time_str); 4673 4674 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4675 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4676 return false; 4677 4678 if (exitcode_str) 4679 { 4680 int32 exitcode = atoi (exitcode_str); 4681 4682 // Handle atoi() errors 4683 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4684 return false; 4685 4686 // Exit code should be in range of 0-125, 126-255 is used 4687 // in many shells for their own return codes and code > 255 4688 // is not supported in many others 4689 if (exitcode < 0 || exitcode > 125) 4690 return false; 4691 4692 sWorld.ShutdownServ (time, 0, exitcode); 4656 4693 } 4657 4694 else 4658 { 4659 int32 time = atoi(args); 4660 4661 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4662 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4695 sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE); 4696 return true; 4697 } 4698 4699 bool ChatHandler::HandleServerRestartCommand(const char* args) 4700 { 4701 if(!*args) 4702 return false; 4703 4704 char* time_str = strtok ((char*) args, " "); 4705 char* exitcode_str = strtok (NULL, ""); 4706 4707 int32 time = atoi (time_str); 4708 4709 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4710 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4711 return false; 4712 4713 if (exitcode_str) 4714 { 4715 int32 exitcode = atoi (exitcode_str); 4716 4717 // Handle atoi() errors 4718 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4663 4719 return false; 4664 4720 4665 sWorld.ShutdownServ(time); 4666 } 4667 return true; 4668 } 4669 4670 bool ChatHandler::HandleRestartCommand(const char* args) 4721 // Exit code should be in range of 0-125, 126-255 is used 4722 // in many shells for their own return codes and code > 255 4723 // is not supported in many others 4724 if (exitcode < 0 || exitcode > 125) 4725 return false; 4726 4727 sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode); 4728 } 4729 else 4730 sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE); 4731 return true; 4732 } 4733 4734 bool ChatHandler::HandleServerIdleRestartCommand(const char* args) 4671 4735 { 4672 4736 if(!*args) 4673 4737 return false; 4674 4738 4675 if(std::string(args)=="cancel") 4676 { 4677 sWorld.ShutdownCancel(); 4739 char* time_str = strtok ((char*) args, " "); 4740 char* exitcode_str = strtok (NULL, ""); 4741 4742 int32 time = atoi (time_str); 4743 4744 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4745 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4746 return false; 4747 4748 if (exitcode_str) 4749 { 4750 int32 exitcode = atoi (exitcode_str); 4751 4752 // Handle atoi() errors 4753 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4754 return false; 4755 4756 // Exit code should be in range of 0-125, 126-255 is used 4757 // in many shells for their own return codes and code > 255 4758 // is not supported in many others 4759 if (exitcode < 0 || exitcode > 125) 4760 return false; 4761 4762 sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode); 4678 4763 } 4679 4764 else 4680 { 4681 int32 time = atoi(args); 4682 4683 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4684 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4765 sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE); 4766 return true; 4767 } 4768 4769 bool ChatHandler::HandleServerIdleShutDownCommand(const char* args) 4770 { 4771 if(!*args) 4772 return false; 4773 4774 char* time_str = strtok ((char*) args, " "); 4775 char* exitcode_str = strtok (NULL, ""); 4776 4777 int32 time = atoi (time_str); 4778 4779 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4780 if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0) 4781 return false; 4782 4783 if (exitcode_str) 4784 { 4785 int32 exitcode = atoi (exitcode_str); 4786 4787 // Handle atoi() errors 4788 if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0')) 4685 4789 return false; 4686 4790 4687 sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); 4688 } 4689 return true; 4690 } 4691 4692 bool ChatHandler::HandleIdleRestartCommand(const char* args) 4693 { 4694 if(!*args) 4695 return false; 4696 4697 if(std::string(args)=="cancel") 4698 { 4699 sWorld.ShutdownCancel(); 4791 // Exit code should be in range of 0-125, 126-255 is used 4792 // in many shells for their own return codes and code > 255 4793 // is not supported in many others 4794 if (exitcode < 0 || exitcode > 125) 4795 return false; 4796 4797 sWorld.ShutdownServ (time, SHUTDOWN_MASK_IDLE, exitcode); 4700 4798 } 4701 4799 else 4702 { 4703 int32 time = atoi(args); 4704 4705 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4706 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4707 return false; 4708 4709 sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); 4710 } 4711 return true; 4712 } 4713 4714 bool ChatHandler::HandleIdleShutDownCommand(const char* args) 4715 { 4716 if(!*args) 4717 return false; 4718 4719 if(std::string(args)=="cancel") 4720 { 4721 sWorld.ShutdownCancel(); 4722 } 4723 else 4724 { 4725 int32 time = atoi(args); 4726 4727 ///- Prevent interpret wrong arg value as 0 secs shutdown time 4728 if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) 4729 return false; 4730 4731 sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); 4732 } 4800 sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE); 4733 4801 return true; 4734 4802 } -
trunk/src/game/Mail.cpp
r229 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 188 188 return; 189 189 } 190 191 190 if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION)) 192 191 { … … 195 194 } 196 195 197 198 199 200 201 196 if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 197 { 198 pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD); 199 return; 200 } 202 201 } 203 202 } -
trunk/src/game/Map.cpp
r257 r260 1714 1714 if (mInstance) 1715 1715 { 1716 i_script = mInstance->script;1716 i_script_id = mInstance->script_id; 1717 1717 i_data = Script->CreateInstanceData(this); 1718 1718 } … … 1731 1731 if(data) 1732 1732 { 1733 sLog.outDebug("Loading instance data for `%s` with id %u", i_script.c_str(), i_InstanceId);1733 sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId); 1734 1734 i_data->Load(data); 1735 1735 } … … 1739 1739 else 1740 1740 { 1741 sLog.outDebug("New instance data, \"%s\" ,initialized!", i_script.c_str());1741 sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id)); 1742 1742 i_data->Initialize(); 1743 1743 } -
trunk/src/game/Map.h
r257 r260 106 106 float startLocZ; 107 107 float startLocO; 108 char const* script;108 uint32 script_id; 109 109 }; 110 110 … … 344 344 void CreateInstanceData(bool load); 345 345 bool Reset(uint8 method); 346 std::string GetScript() { return i_script; }346 uint32 GetScriptId() { return i_script_id; } 347 347 InstanceData* GetInstanceData() { return i_data; } 348 348 void PermBindAllPlayers(Player *player); … … 356 356 bool m_unloadWhenEmpty; 357 357 InstanceData* i_data; 358 std::string i_script; 359 // only online players that are inside the instance currently 360 // TODO ? - use the grid instead to access the players 361 PlayerList i_Players; 358 uint32 i_script_id; 362 359 }; 363 360 -
trunk/src/game/MapManager.cpp
r257 r260 223 223 } 224 224 225 void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId , uint8 mode)225 void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) 226 226 { 227 227 Map *m = _GetBaseMap(mapid); -
trunk/src/game/MapManager.h
r206 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 28 28 #include "Map.h" 29 29 #include "GridStates.h" 30 30 31 class Transport; 31 32 … … 45 46 // only const version for outer users 46 47 Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); } 47 void DeleteInstance(uint32 mapid, uint32 instanceId , uint8 mode);48 void DeleteInstance(uint32 mapid, uint32 instanceId); 48 49 49 50 inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const -
trunk/src/game/ObjectMgr.cpp
r230 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 22 22 #include "Database/DatabaseEnv.h" 23 23 #include "Database/SQLStorage.h" 24 #include "Database/SQLStorageImpl.h" 24 25 25 26 #include "Log.h" … … 117 118 m_hiDoGuid = 1; 118 119 m_hiCorpseGuid = 1; 119 120 120 m_hiPetNumber = 1; 121 m_ItemTextId = 1; 122 m_mailid = 1; 123 m_auctionid = 1; 124 m_guildId = 1; 125 m_arenaTeamId = 1; 121 126 122 127 mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); … … 416 421 417 422 //prepare mail data... : 418 uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() );423 uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() ); 419 424 420 425 // set owner to bidder (to prevent delete item with sender char deleting) … … 467 472 sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); 468 473 469 uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() );474 uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() ); 470 475 471 476 WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); … … 499 504 sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); 500 505 501 uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() );506 uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() ); 502 507 503 508 uint32 profit = auction->bid + auction->deposit - auctionCut; … … 546 551 // will delete item or place to receiver mail list 547 552 WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); 548 549 553 } 550 554 // owner not found … … 564 568 void ObjectMgr::LoadCreatureLocales() 565 569 { 566 mCreatureLocaleMap.clear(); 567 570 mCreatureLocaleMap.clear(); // need for reload case 571 568 572 QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); 569 573 … … 624 628 sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); 625 629 } 626 630 627 631 void ObjectMgr::LoadNpcOptionLocales() 628 632 { … … 693 697 } 694 698 699 struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader> 700 { 701 template<class D> 702 void convert_from_str(uint32 field_pos, char *src, D &dst) 703 { 704 dst = D(objmgr.GetScriptId(src)); 705 } 706 }; 707 695 708 void ObjectMgr::LoadCreatureTemplates() 696 709 { 697 sCreatureStorage.Load(); 710 SQLCreatureLoader loader; 711 loader.Load(sCreatureStorage); 698 712 699 713 sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); … … 1513 1527 aItem->location = fields[11].GetUInt8(); 1514 1528 //check if sold item exists 1515 if ( this->GetAItem( aItem->item_guidlow ) )1529 if ( GetAItem( aItem->item_guidlow ) ) 1516 1530 { 1517 1531 GetAuctionsMap( aItem->location )->AddAuction(aItem); … … 1533 1547 void ObjectMgr::LoadItemLocales() 1534 1548 { 1535 mItemLocaleMap.clear(); 1536 1549 mItemLocaleMap.clear(); // need for reload case 1550 1537 1551 QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); 1538 1552 … … 1595 1609 } 1596 1610 1611 struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader> 1612 { 1613 template<class D> 1614 void convert_from_str(uint32 field_pos, char *src, D &dst) 1615 { 1616 dst = D(objmgr.GetScriptId(src)); 1617 } 1618 }; 1619 1597 1620 void ObjectMgr::LoadItemPrototypes() 1598 1621 { 1599 sItemStorage.Load (); 1622 SQLItemLoader loader; 1623 loader.Load(sItemStorage); 1600 1624 sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); 1601 1625 sLog.outString(); … … 2507 2531 if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) 2508 2532 continue; 2509 2533 2510 2534 // skip expansion classes if not playing with expansion 2511 2535 if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT) … … 3556 3580 void ObjectMgr::LoadQuestLocales() 3557 3581 { 3558 mQuestLocaleMap.clear(); 3582 mQuestLocaleMap.clear(); // need for reload case 3559 3583 3560 3584 QueryResult *result = WorldDatabase.Query("SELECT entry," … … 3750 3774 scripts.clear(); // need for reload support 3751 3775 3752 QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,data text, x, y, z, o FROM %s", tablename );3776 QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename ); 3753 3777 3754 3778 uint32 count = 0; … … 3772 3796 Field *fields = result->Fetch(); 3773 3797 ScriptInfo tmp; 3774 tmp.id = fields[0].GetUInt32();3775 tmp.delay = fields[1].GetUInt32();3776 tmp.command = fields[2].GetUInt32();3777 tmp.datalong = fields[3].GetUInt32();3798 tmp.id = fields[0].GetUInt32(); 3799 tmp.delay = fields[1].GetUInt32(); 3800 tmp.command = fields[2].GetUInt32(); 3801 tmp.datalong = fields[3].GetUInt32(); 3778 3802 tmp.datalong2 = fields[4].GetUInt32(); 3779 tmp.data text = fields[5].GetCppString();3780 tmp.x = fields[6].GetFloat();3781 tmp.y = fields[7].GetFloat();3782 tmp.z = fields[8].GetFloat();3783 tmp.o = fields[9].GetFloat();3803 tmp.dataint = fields[5].GetInt32(); 3804 tmp.x = fields[6].GetFloat(); 3805 tmp.y = fields[7].GetFloat(); 3806 tmp.z = fields[8].GetFloat(); 3807 tmp.o = fields[9].GetFloat(); 3784 3808 3785 3809 // generic command args check … … 3793 3817 continue; 3794 3818 } 3819 if(tmp.dataint==0) 3820 { 3821 sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,tmp.id); 3822 continue; 3823 } 3824 if(tmp.dataint < MIN_DB_SCRIPT_STRING_ID || tmp.dataint >= MAX_DB_SCRIPT_STRING_ID) 3825 { 3826 sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID,tmp.id); 3827 continue; 3828 } 3829 3830 // if(!objmgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading 3795 3831 break; 3796 3832 } … … 4157 4193 void ObjectMgr::LoadPageTextLocales() 4158 4194 { 4159 mPageTextLocaleMap.clear(); 4160 4195 mPageTextLocaleMap.clear(); // need for reload case 4196 4161 4197 QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); 4162 4198 … … 4207 4243 } 4208 4244 4245 struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader> 4246 { 4247 template<class D> 4248 void convert_from_str(uint32 field_pos, char *src, D &dst) 4249 { 4250 dst = D(objmgr.GetScriptId(src)); 4251 } 4252 }; 4253 4209 4254 void ObjectMgr::LoadInstanceTemplate() 4210 4255 { 4211 sInstanceTemplate.Load(); 4256 SQLInstanceLoader loader; 4257 loader.Load(sInstanceTemplate); 4212 4258 4213 4259 for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) … … 4325 4371 void ObjectMgr::LoadNpcTextLocales() 4326 4372 { 4327 mNpcTextLocaleMap.clear(); 4328 4373 mNpcTextLocaleMap.clear(); // need for reload case 4374 4329 4375 QueryResult *result = WorldDatabase.Query("SELECT entry," 4330 4376 "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," … … 4623 4669 4624 4670 uint32 Trigger_ID = fields[0].GetUInt32(); 4625 std::string scriptName = fields[1].GetCppString();4671 const char *scriptName = fields[1].GetString(); 4626 4672 4627 4673 AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); … … 4631 4677 continue; 4632 4678 } 4633 mAreaTriggerScripts[Trigger_ID] = scriptName;4679 mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName); 4634 4680 } while( result->NextRow() ); 4635 4681 … … 4639 4685 sLog.outString( ">> Loaded %u areatrigger scripts", count ); 4640 4686 } 4687 4641 4688 uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) 4642 4689 { … … 4697 4744 uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) 4698 4745 { 4699 uint 32mount_entry = 0;4700 uint 32mount_id = 0;4746 uint16 mount_entry = 0; 4747 uint16 mount_id = 0; 4701 4748 4702 4749 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); 4703 if 4750 if(node) 4704 4751 { 4705 4752 if (team == ALLIANCE) mount_entry = node->alliance_mount_type; … … 4940 4987 } 4941 4988 4942 // find now nearest graveyard at same map4943 4989 if(entryNear) 4944 4990 return entryNear; … … 5181 5227 { 5182 5228 m_hiCharGuid = (*result)[0].GetUInt32()+1; 5183 5184 5229 delete result; 5185 5230 } … … 5189 5234 { 5190 5235 m_hiCreatureGuid = (*result)[0].GetUInt32()+1; 5191 5192 5236 delete result; 5193 5237 } 5194 5238 5195 result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); 5196 if( result ) 5197 { 5198 m_hiPetGuid = (*result)[0].GetUInt32()+1; 5199 5200 delete result; 5201 } 5239 // pet guids are not saved to DB, set to 0 (pet guid != pet id) 5240 m_hiPetGuid = 0; 5202 5241 5203 5242 result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); … … 5205 5244 { 5206 5245 m_hiItemGuid = (*result)[0].GetUInt32()+1; 5207 5208 5246 delete result; 5209 5247 } … … 5219 5257 { 5220 5258 m_hiGoGuid = (*result)[0].GetUInt32()+1; 5221 5222 5259 delete result; 5223 5260 } … … 5227 5264 { 5228 5265 m_auctionid = (*result)[0].GetUInt32()+1; 5229 5230 5266 delete result; 5231 5267 } 5232 else 5233 { 5234 m_auctionid = 0; 5235 } 5268 5236 5269 result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); 5237 5270 if( result ) 5238 5271 { 5239 5272 m_mailid = (*result)[0].GetUInt32()+1; 5240 5241 5273 delete result; 5242 5274 } 5243 else 5244 { 5245 m_mailid = 0; 5246 } 5275 5247 5276 result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); 5248 5277 if( result ) 5249 5278 { 5250 m_ItemTextId = (*result)[0].GetUInt32(); 5251 5279 m_ItemTextId = (*result)[0].GetUInt32()+1; 5252 5280 delete result; 5253 5281 } 5254 else5255 m_ItemTextId = 0;5256 5282 5257 5283 result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); … … 5259 5285 { 5260 5286 m_hiCorpseGuid = (*result)[0].GetUInt32()+1; 5261 5262 5287 delete result; 5263 5288 } 5289 5290 result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); 5291 if (result) 5292 { 5293 m_arenaTeamId = (*result)[0].GetUInt32()+1; 5294 delete result; 5295 } 5296 5297 result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); 5298 if (result) 5299 { 5300 m_guildId = (*result)[0].GetUInt32()+1; 5301 delete result; 5302 } 5303 } 5304 5305 uint32 ObjectMgr::GenerateArenaTeamId() 5306 { 5307 if(m_arenaTeamId>=0xFFFFFFFE) 5308 { 5309 sLog.outError("Arena team ids overflow!! Can't continue, shutting down server. "); 5310 World::StopNow(ERROR_EXIT_CODE); 5311 } 5312 return m_arenaTeamId++; 5313 } 5314 5315 uint32 ObjectMgr::GenerateGuildId() 5316 { 5317 if(m_guildId>=0xFFFFFFFE) 5318 { 5319 sLog.outError("Guild ids overflow!! Can't continue, shutting down server. "); 5320 World::StopNow(ERROR_EXIT_CODE); 5321 } 5322 return m_guildId++; 5264 5323 } 5265 5324 5266 5325 uint32 ObjectMgr::GenerateAuctionID() 5267 5326 { 5268 ++m_auctionid; 5269 if(m_auctionid>=0xFFFFFFFF) 5327 if(m_auctionid>=0xFFFFFFFE) 5270 5328 { 5271 5329 sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. "); 5272 sWorld.m_stopEvent = true;5273 } 5274 return m_auctionid ;5330 World::StopNow(ERROR_EXIT_CODE); 5331 } 5332 return m_auctionid++; 5275 5333 } 5276 5334 5277 5335 uint32 ObjectMgr::GenerateMailID() 5278 5336 { 5279 ++m_mailid; 5280 if(m_mailid>=0xFFFFFFFF) 5337 if(m_mailid>=0xFFFFFFFE) 5281 5338 { 5282 5339 sLog.outError("Mail ids overflow!! Can't continue, shutting down server. "); 5283 sWorld.m_stopEvent = true;5284 } 5285 return m_mailid ;5340 World::StopNow(ERROR_EXIT_CODE); 5341 } 5342 return m_mailid++; 5286 5343 } 5287 5344 5288 5345 uint32 ObjectMgr::GenerateItemTextID() 5289 5346 { 5290 ++m_ItemTextId; 5291 if(m_ItemTextId>=0xFFFFFFFF) 5347 if(m_ItemTextId>=0xFFFFFFFE) 5292 5348 { 5293 5349 sLog.outError("Item text ids overflow!! Can't continue, shutting down server. "); 5294 sWorld.m_stopEvent = true;5295 } 5296 return m_ItemTextId ;5350 World::StopNow(ERROR_EXIT_CODE); 5351 } 5352 return m_ItemTextId++; 5297 5353 } 5298 5354 … … 5316 5372 { 5317 5373 case HIGHGUID_ITEM: 5318 ++m_hiItemGuid; 5319 if(m_hiItemGuid>=0xFFFFFFFF) 5374 if(m_hiItemGuid>=0xFFFFFFFE) 5320 5375 { 5321 5376 sLog.outError("Item guid overflow!! Can't continue, shutting down server. "); 5322 sWorld.m_stopEvent = true;5323 } 5324 return m_hiItemGuid ;5377 World::StopNow(ERROR_EXIT_CODE); 5378 } 5379 return m_hiItemGuid++; 5325 5380 case HIGHGUID_UNIT: 5326 ++m_hiCreatureGuid; 5327 if(m_hiCreatureGuid>=0x00FFFFFF) 5381 if(m_hiCreatureGuid>=0x00FFFFFE) 5328 5382 { 5329 5383 sLog.outError("Creature guid overflow!! Can't continue, shutting down server. "); 5330 sWorld.m_stopEvent = true;5331 } 5332 return m_hiCreatureGuid ;5384 World::StopNow(ERROR_EXIT_CODE); 5385 } 5386 return m_hiCreatureGuid++; 5333 5387 case HIGHGUID_PET: 5334 ++m_hiPetGuid; 5335 if(m_hiPetGuid>=0x00FFFFFF) 5388 if(m_hiPetGuid>=0x00FFFFFE) 5336 5389 { 5337 5390 sLog.outError("Pet guid overflow!! Can't continue, shutting down server. "); 5338 sWorld.m_stopEvent = true;5339 } 5340 return m_hiPetGuid ;5391 World::StopNow(ERROR_EXIT_CODE); 5392 } 5393 return m_hiPetGuid++; 5341 5394 case HIGHGUID_PLAYER: 5342 ++m_hiCharGuid; 5343 if(m_hiCharGuid>=0xFFFFFFFF) 5395 if(m_hiCharGuid>=0xFFFFFFFE) 5344 5396 { 5345 5397 sLog.outError("Players guid overflow!! Can't continue, shutting down server. "); 5346 sWorld.m_stopEvent = true;5347 } 5348 return m_hiCharGuid ;5398 World::StopNow(ERROR_EXIT_CODE); 5399 } 5400 return m_hiCharGuid++; 5349 5401 case HIGHGUID_GAMEOBJECT: 5350 ++m_hiGoGuid; 5351 if(m_hiGoGuid>=0x00FFFFFF) 5402 if(m_hiGoGuid>=0x00FFFFFE) 5352 5403 { 5353 5404 sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. "); 5354 sWorld.m_stopEvent = true;5355 } 5356 return m_hiGoGuid ;5405 World::StopNow(ERROR_EXIT_CODE); 5406 } 5407 return m_hiGoGuid++; 5357 5408 case HIGHGUID_CORPSE: 5358 ++m_hiCorpseGuid; 5359 if(m_hiCorpseGuid>=0xFFFFFFFF) 5409 if(m_hiCorpseGuid>=0xFFFFFFFE) 5360 5410 { 5361 5411 sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. "); 5362 sWorld.m_stopEvent = true;5363 } 5364 return m_hiCorpseGuid ;5412 World::StopNow(ERROR_EXIT_CODE); 5413 } 5414 return m_hiCorpseGuid++; 5365 5415 case HIGHGUID_DYNAMICOBJECT: 5366 ++m_hiDoGuid; 5367 if(m_hiDoGuid>=0xFFFFFFFF) 5416 if(m_hiDoGuid>=0xFFFFFFFE) 5368 5417 { 5369 5418 sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); 5370 sWorld.m_stopEvent = true;5371 } 5372 return m_hiDoGuid ;5419 World::StopNow(ERROR_EXIT_CODE); 5420 } 5421 return m_hiDoGuid++; 5373 5422 default: 5374 5423 ASSERT(0); … … 5381 5430 void ObjectMgr::LoadGameObjectLocales() 5382 5431 { 5383 mGameObjectLocaleMap.clear(); 5384 5432 mGameObjectLocaleMap.clear(); // need for reload case 5433 5385 5434 QueryResult *result = WorldDatabase.Query("SELECT entry," 5386 5435 "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," … … 5450 5499 } 5451 5500 5501 struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader> 5502 { 5503 template<class D> 5504 void convert_from_str(uint32 field_pos, char *src, D &dst) 5505 { 5506 dst = D(objmgr.GetScriptId(src)); 5507 } 5508 }; 5509 5452 5510 void ObjectMgr::LoadGameobjectInfo() 5453 5511 { 5454 sGOStorage.Load(); 5512 SQLGameObjectLoader loader; 5513 loader.Load(sGOStorage); 5455 5514 5456 5515 // some checks … … 6625 6684 } 6626 6685 6627 const char* ObjectMgr::GetAreaTriggerScriptName(uint32id)6628 { 6629 AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find( id);6686 uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id) 6687 { 6688 AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id); 6630 6689 if(i!= mAreaTriggerScripts.end()) 6631 return i->second .c_str();6632 return "";6690 return i->second; 6691 return 0; 6633 6692 } 6634 6693 … … 6675 6734 return false; 6676 6735 } 6677 6678 6679 6680 6736 case CONDITION_NO_AURA: 6737 return !player->HasAura(value1, value2); 6738 case CONDITION_ACTIVE_EVENT: 6739 return gameeventmgr.IsActiveEvent(value1); 6681 6740 default: 6682 6741 return false; … … 6799 6858 break; 6800 6859 } 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6860 case CONDITION_NO_AURA: 6861 { 6862 if(!sSpellStore.LookupEntry(value1)) 6863 { 6864 sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); 6865 return false; 6866 } 6867 if(value2 > 2) 6868 { 6869 sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); 6870 return false; 6871 } 6872 break; 6873 } 6874 case CONDITION_ACTIVE_EVENT: 6875 { 6876 GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); 6877 if(value1 >=events.size() || !events[value1].isValid()) 6878 { 6879 sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1); 6880 return false; 6881 } 6882 break; 6883 } 6825 6884 } 6826 6885 return true; … … 6952 7011 if(itr->first > new_id) 6953 7012 new_id = itr->first; 6954 7013 6955 7014 // use next 6956 7015 ++new_id; … … 6992 7051 void ObjectMgr::LoadTrainerSpell() 6993 7052 { 6994 // For reload case 7053 // For reload case 6995 7054 for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) 6996 7055 itr->second.Clear(); … … 7083 7142 void ObjectMgr::LoadVendors() 7084 7143 { 7085 // For reload case 7144 // For reload case 7086 7145 for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) 7087 7146 itr->second.Clear(); … … 7190 7249 "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text " 7191 7250 "FROM npc_option"); 7251 7192 7252 if( !result ) 7193 7253 { … … 7342 7402 } 7343 7403 7404 void ObjectMgr::LoadScriptNames() 7405 { 7406 m_scriptNames.push_back(""); 7407 QueryResult *result = WorldDatabase.Query( 7408 "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' " 7409 "UNION " 7410 "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' " 7411 "UNION " 7412 "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' " 7413 "UNION " 7414 "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' " 7415 "UNION " 7416 "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''"); 7417 if(result) 7418 { 7419 do 7420 { 7421 m_scriptNames.push_back((*result)[0].GetString()); 7422 } while (result->NextRow()); 7423 delete result; 7424 } 7425 7426 std::sort(m_scriptNames.begin(), m_scriptNames.end()); 7427 } 7428 7429 uint32 ObjectMgr::GetScriptId(const char *name) 7430 { 7431 // use binary search to find the script name in the sorted vector 7432 // assume "" is the first element 7433 if(!name) return 0; 7434 ScriptNameMap::const_iterator itr = 7435 std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name); 7436 if(itr == m_scriptNames.end()) return 0; 7437 return itr - m_scriptNames.begin(); 7438 } 7439 7440 void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids) 7441 { 7442 for(ScriptMapMap::const_iterator itrMM = scripts.begin(); itrMM != scripts.end(); ++itrMM) 7443 { 7444 for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM) 7445 { 7446 if(itrM->second.dataint) 7447 { 7448 if(!GetTrinityStringLocale (itrM->second.dataint)) 7449 sLog.outErrorDb( "Table `db_script_string` has not existed string id %u", *itrM); 7450 7451 if(ids.count(itrM->second.dataint)) 7452 ids.erase(itrM->second.dataint); 7453 } 7454 } 7455 } 7456 } 7457 7458 void ObjectMgr::LoadDbScriptStrings() 7459 { 7460 LoadTrinityStrings(WorldDatabase,"db_script_string",MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID); 7461 7462 std::set<int32> ids; 7463 7464 for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) 7465 if(GetTrinityStringLocale(i)) 7466 ids.insert(i); 7467 7468 CheckScripts(sQuestEndScripts,ids); 7469 CheckScripts(sQuestStartScripts,ids); 7470 CheckScripts(sSpellScripts,ids); 7471 CheckScripts(sGameObjectScripts,ids); 7472 CheckScripts(sEventScripts,ids); 7473 7474 for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) 7475 sLog.outErrorDb( "Table `db_script_string` has unused string id %u", *itr); 7476 } 7477 7344 7478 // Functions for scripting access 7345 const char* GetAreaTriggerScriptNameById(uint32id)7346 { 7347 return objmgr.GetAreaTriggerScript Name(id);7479 uint32 GetAreaTriggerScriptId(uint32 trigger_id) 7480 { 7481 return objmgr.GetAreaTriggerScriptId(trigger_id); 7348 7482 } 7349 7483 … … 7360 7494 return objmgr.LoadTrinityStrings(db,table,end_value,start_value); 7361 7495 } 7496 7497 uint32 TRINITY_DLL_SPEC GetScriptId(const char *name) 7498 { 7499 return objmgr.GetScriptId(name); 7500 } 7501 7502 ObjectMgr::ScriptNameMap & GetScriptNames() 7503 { 7504 return objmgr.GetScriptNames(); 7505 } -
trunk/src/game/ObjectMgr.h
r206 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 85 85 uint32 datalong; 86 86 uint32 datalong2; 87 std::string datatext;87 int32 dataint; 88 88 float x; 89 89 float y; … … 128 128 129 129 typedef UNORDERED_MAP<uint64/*(instance,guid) pair*/,time_t> RespawnTimes; 130 131 132 // mangos string ranges 133 #define MIN_TRINITY_STRING_ID 1 134 #define MAX_TRINITY_STRING_ID 2000000000 135 #define MIN_DB_SCRIPT_STRING_ID MAX_TRINITY_STRING_ID 136 #define MAX_DB_SCRIPT_STRING_ID 2000010000 130 137 131 138 struct TrinityStringLocale … … 208 215 CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active. 209 216 CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD ñommission aura active 210 211 217 CONDITION_NO_AURA = 11, // spell_id effindex 218 CONDITION_ACTIVE_EVENT = 12, // event_id 212 219 }; 213 220 … … 251 258 // NPC gossip text id 252 259 typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap; 253 260 typedef std::list<GossipOption> CacheNpcOptionList; 254 261 255 262 typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap; … … 300 307 typedef UNORDERED_MAP<uint32, Quest*> QuestMap; 301 308 309 302 310 typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap; 303 311 304 typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap;312 typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap; 305 313 306 314 typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap; … … 309 317 310 318 typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap; 319 320 typedef std::vector<std::string> ScriptNameMap; 311 321 312 322 Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} … … 477 487 AreaTrigger const* GetGoBackTrigger(uint32 Map) const; 478 488 479 const char* GetAreaTriggerScriptName(uint32id);489 uint32 GetAreaTriggerScriptId(uint32 trigger_id); 480 490 481 491 ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const … … 523 533 524 534 bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); 525 bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",1,std::numeric_limits<int32>::max()); } 535 bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); } 536 void LoadDbScriptStrings(); 526 537 void LoadPetCreateSpells(); 527 538 void LoadCreatureLocales(); … … 593 604 uint32 GenerateItemTextID(); 594 605 uint32 GeneratePetNumber(); 606 uint32 GenerateArenaTeamId(); 607 uint32 GenerateGuildId(); 595 608 596 609 void LoadPlayerInfoInCache(); … … 669 682 return &itr->second; 670 683 } 671 672 684 NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const 673 685 { … … 694 706 const char *GetTrinityString(int32 entry, int locale_idx) const; 695 707 const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); } 696 708 int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } 697 709 void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } 698 710 … … 733 745 LocaleConstant GetLocaleForIndex(int i); 734 746 // guild bank tabs 735 const uint32 GetGuildBankTabPrice(uint8 Index){ return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }747 uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } 736 748 737 749 uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); … … 754 766 bool AddGameTele(GameTele& data); 755 767 bool DeleteGameTele(std::string name); 756 768 757 769 CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; } 758 770 … … 762 774 if(iter == m_mCacheNpcTextIdMap.end()) 763 775 return 0; 764 776 765 777 return iter->second; 766 778 } … … 783 795 return &iter->second; 784 796 } 785 void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); 786 bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); 787 bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const; 788 797 void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event 798 bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); // for event 799 bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0 ) const; 800 801 void LoadScriptNames(); 802 ScriptNameMap &GetScriptNames() { return m_scriptNames; } 803 const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; } 804 uint32 GetScriptId(const char *name); 789 805 protected: 806 807 // first free id for selected id type 790 808 uint32 m_auctionid; 791 809 uint32 m_mailid; 792 810 uint32 m_ItemTextId; 793 811 uint32 m_arenaTeamId; 812 uint32 m_guildId; 813 uint32 m_hiPetNumber; 814 815 // first free low guid for seelcted guid type 794 816 uint32 m_hiCharGuid; 795 817 uint32 m_hiCreatureGuid; … … 800 822 uint32 m_hiCorpseGuid; 801 823 802 uint32 m_hiPetNumber; 803 804 QuestMap mQuestTemplates; 824 QuestMap mQuestTemplates; 805 825 806 826 typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap; … … 849 869 GameTeleMap m_GameTeleMap; 850 870 871 ScriptNameMap m_scriptNames; 872 851 873 typedef std::vector<LocaleConstant> LocalForIndex; 852 874 LocalForIndex m_LocalForIndex; … … 856 878 private: 857 879 void LoadScripts(ScriptMapMap& scripts, char const* tablename); 880 void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids); 858 881 void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); 859 882 void LoadQuestRelationsHelper(QuestRelations& map,char const* table); … … 908 931 909 932 // scripting access functions 910 bool TRINITY_DLL_SPEC LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min()); 911 TRINITY_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id); 933 TRINITY_DLL_SPEC bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min()); 934 TRINITY_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 trigger_id); 935 TRINITY_DLL_SPEC uint32 GetScriptId(const char *name); 936 TRINITY_DLL_SPEC ObjectMgr::ScriptNameMap& GetScriptNames(); 912 937 913 938 #endif -
trunk/src/game/PlayerDump.cpp
r112 r260 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 346 return DUMP_FILE_OPEN_ERROR; 347 347 348 348 std::string dump = GetDump(guid); … … 372 372 } 373 373 } 374 374 375 FILE *fin = fopen(file.c_str(), "r"); 375 376 if(!fin) 376 377 return DUMP_FILE_OPEN_ERROR; 377 378 378 379 QueryResult * result = NULL; … … 391 392 else incHighest = false; 392 393 } 393 else guid = objmgr.m_hiCharGuid; 394 else 395 guid = objmgr.m_hiCharGuid; 394 396 395 397 // normalize the name if specified and check if it exists … … 469 471 case DTT_CHAR_TABLE: 470 472 if(!changenth(line, 1, newguid)) 471 473 ROLLBACK(DUMP_FILE_BROKEN); 472 474 break; 473 475 … … 475 477 { 476 478 if(!changenth(line, 1, newguid)) 477 479 ROLLBACK(DUMP_FILE_BROKEN); 478 480 479 481 // guid, data field:guid, items 480 482 if(!changenth(line, 2, chraccount)) 481 ROLLBACK(DUMP_FILE_BROKEN); 482 483 ROLLBACK(DUMP_FILE_BROKEN); 483 484 std::string vals = getnth(line, 3); 484 485 if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid)) 485 ROLLBACK(DUMP_FILE_BROKEN); 486 486 ROLLBACK(DUMP_FILE_BROKEN); 487 487 for(uint16 field = PLAYER_FIELD_INV_SLOT_HEAD; field < PLAYER_FARSIGHT; field++) 488 488 if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true)) 489 ROLLBACK(DUMP_FILE_BROKEN); 490 489 ROLLBACK(DUMP_FILE_BROKEN); 491 490 if(!changenth(line, 3, vals.c_str())) 492 ROLLBACK(DUMP_FILE_BROKEN); 493 491 ROLLBACK(DUMP_FILE_BROKEN); 494 492 if (name == "") 495 493 { … … 504 502 // rename on login: `at_login` field 30 in raw field list 505 503 if(!changenth(line, 30, "1")) 506 504 ROLLBACK(DUMP_FILE_BROKEN); 507 505 } 508 506 } 509 507 else if(!changenth(line, 4, name.c_str())) 510 508 ROLLBACK(DUMP_FILE_BROKEN); 511 509 512 510 break; … … 515 513 { 516 514 if(!changenth(line, 1, newguid)) 517 515 ROLLBACK(DUMP_FILE_BROKEN); 518 516 519 517 // bag, item 520 518 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true)) 521 522 523 519 ROLLBACK(DUMP_FILE_BROKEN); 520 if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid)) 521 ROLLBACK(DUMP_FILE_BROKEN); 524 522 break; 525 523 } … … 528 526 // item, owner, data field:item, owner guid 529 527 if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid)) 530 ROLLBACK(DUMP_FILE_BROKEN); 531 if(!changenth(line, 2, newguid)) 532 ROLLBACK(DUMP_FILE_BROKEN); 533 528 ROLLBACK(DUMP_FILE_BROKEN); 529 if(!changenth(line, 2, newguid)) 530 ROLLBACK(DUMP_FILE_BROKEN); 534 531 std::string vals = getnth(line,3); 535 532 if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid)) 536 537 538 539 540 533 ROLLBACK(DUMP_FILE_BROKEN); 534 if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid)) 535 ROLLBACK(DUMP_FILE_BROKEN); 536 if(!changenth(line, 3, vals.c_str())) 537 ROLLBACK(DUMP_FILE_BROKEN); 541 538 break; 542 539 } … … 545 542 // guid,item_guid, 546 543 if(!changenth(line, 1, newguid)) 547 548 549 544 ROLLBACK(DUMP_FILE_BROKEN); 545 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) 546 ROLLBACK(DUMP_FILE_BROKEN); 550 547 break; 551 548 } … … 570 567 // item, entry, owner, ... 571 568 if(!changenth(line, 1, newpetid)) 572 573 574 569 ROLLBACK(DUMP_FILE_BROKEN); 570 if(!changenth(line, 3, newguid)) 571 ROLLBACK(DUMP_FILE_BROKEN); 575 572 576 573 break; … … 583 580 std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); 584 581 if(petids_iter == petids.end()) // couldn't find new inserted id 585 582 ROLLBACK(DUMP_FILE_BROKEN); 586 583 587 584 snprintf(newpetid, 20, "%d", petids_iter->second); 588 585 589 586 if(!changenth(line, 1, newpetid)) 590 587 ROLLBACK(DUMP_FILE_BROKEN); 591 588 592 589 break; … … 596 593 // id,messageType,stationery,sender,receiver 597 594 if(!changeGuid(line, 1, mails, objmgr.m_mailid)) 598 599 600 595 ROLLBACK(DUMP_FILE_BROKEN); 596 if(!changenth(line, 5, newguid)) 597 ROLLBACK(DUMP_FILE_BROKEN); 601 598 break; 602 599 } … … 605 602 // mail_id,item_guid,item_template,receiver 606 603 if(!changeGuid(line, 1, mails, objmgr.m_mailid)) 607 608 609 610 611 604 ROLLBACK(DUMP_FILE_BROKEN); 605 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) 606 ROLLBACK(DUMP_FILE_BROKEN); 607 if(!changenth(line, 4, newguid)) 608 ROLLBACK(DUMP_FILE_BROKEN); 612 609 break; 613 610 } … … 618 615 619 616 if(!CharacterDatabase.Execute(line.c_str())) 620 617 ROLLBACK(DUMP_FILE_BROKEN); 621 618 } 622 619 -
trunk/src/game/SpellHandler.cpp
r252 r260 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 57 63 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()); 58 64 … … 238 244 239 245 pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); 240 pItem->Set UInt32Value(OBJECT_FIELD_ENTRY,entry);246 pItem->SetEntry(entry); 241 247 pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags); 242 248 pItem->SetState(ITEM_CHANGED, pUser); … … 260 266 261 267 uint64 guid; 262 uint32 spellId = OPEN_CHEST;263 268 264 269 recv_data >> guid; … … 323 328 324 329 Spell *spell = new Spell(_player, spellInfo, false); 325 spell->m_cast_count = cast_count; // set count of casts330 spell->m_cast_count = cast_count; // set count of casts 326 331 spell->prepare(&targets); 327 332 } -
trunk/src/game/WaypointManager.cpp
r207 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 25 25 #include "ProgressBar.h" 26 26 #include "MapManager.h" 27 #include "ObjectMgr.h" 27 28 28 29 INSTANTIATE_SINGLETON_1(WaypointManager); … … 30 31 bool WaypointBehavior::isEmpty() 31 32 { 32 return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() && 33 text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty(); 33 if (emote || spell || model1 || model2) 34 return false; 35 36 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 37 if(textid[i]) 38 return false; 39 40 return true; 34 41 } 35 42 36 43 WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) 37 44 { 38 emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2; 39 text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2]; 40 text[3] = b.text[3]; text[4] = b.text[4]; 45 emote = b.emote; 46 spell = b.spell; 47 model1 = b.model1; 48 model2 = b.model2; 49 for(int i=0; i < MAX_WAYPOINT_TEXT; ++i) 50 textid[i] = b.textid[i]; 41 51 } 42 52 … … 67 77 } 68 78 69 result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text 1, text2, text3, text4, text5, id, point FROM creature_movement");79 result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement"); 70 80 if(result) 71 81 { … … 114 124 be.emote = fields[7].GetUInt32(); 115 125 be.spell = fields[8].GetUInt32(); 116 be.text[0] = fields[9].GetCppString(); 117 be.text[1] = fields[10].GetCppString(); 118 be.text[2] = fields[11].GetCppString(); 119 be.text[3] = fields[12].GetCppString(); 120 be.text[4] = fields[13].GetCppString(); 126 127 // load and store without holes in array 128 int j = 0; 129 for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 130 { 131 be.textid[j] = fields[9+i].GetUInt32(); 132 if(be.textid[j]) 133 { 134 if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) 135 { 136 sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]); 137 continue; 138 } 139 140 if (!objmgr.GetTrinityStringLocale (be.textid[j])) 141 { 142 sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.", 143 id, point, be.textid[j], i+1); 144 continue; 145 } 146 147 ++j; // to next internal field 148 } 149 } 150 // fill array tail 151 for(; j < MAX_WAYPOINT_TEXT; ++j) 152 be.textid[j] = 0; 121 153 122 154 // save memory by not storing empty behaviors … … 266 298 if(!node.behavior) node.behavior = new WaypointBehavior(); 267 299 268 if(field == "text1") node.behavior->text[0] = text ? text : "";269 if(field == "text2") node.behavior->text[1] = text ? text : "";270 if(field == "text3") node.behavior->text[2] = text ? text : "";271 if(field == "text4") node.behavior->text[3] = text ? text : "";272 if(field == "text5") node.behavior->text[4] = text ? text : "";300 // if(field == "text1") node.behavior->text[0] = text ? text : ""; 301 // if(field == "text2") node.behavior->text[1] = text ? text : ""; 302 // if(field == "text3") node.behavior->text[2] = text ? text : ""; 303 // if(field == "text4") node.behavior->text[3] = text ? text : ""; 304 // if(field == "text5") node.behavior->text[4] = text ? text : ""; 273 305 if(field == "emote") node.behavior->emote = text ? atoi(text) : 0; 274 306 if(field == "spell") node.behavior->spell = text ? atoi(text) : 0; -
trunk/src/game/WaypointManager.h
r206 r260 26 26 #include "Utilities/UnorderedMap.h" 27 27 28 #define MAX_WAYPOINT_TEXT 5 28 29 struct WaypointBehavior 29 30 { 30 31 uint32 emote; 31 32 uint32 spell; 32 std::string text[5];33 int32 textid[MAX_WAYPOINT_TEXT]; 33 34 uint32 model1; 34 35 uint32 model2; -
trunk/src/game/WaypointMovementGenerator.cpp
r229 r260 22 22 creature_movement Table 23 23 24 alter table creature_movement add `text 1` varchar(255) default NULL;25 alter table creature_movement add `text 2` varchar(255) default NULL;26 alter table creature_movement add `text 3` varchar(255) default NULL;27 alter table creature_movement add `text 4` varchar(255) default NULL;28 alter table creature_movement add `text 5` varchar(255) default NULL;24 alter table creature_movement add `textid1` int(11) NOT NULL default '0'; 25 alter table creature_movement add `textid2` int(11) NOT NULL default '0'; 26 alter table creature_movement add `textid3` int(11) NOT NULL default '0'; 27 alter table creature_movement add `textid4` int(11) NOT NULL default '0'; 28 alter table creature_movement add `textid5` int(11) NOT NULL default '0'; 29 29 alter table creature_movement add `emote` int(10) unsigned default '0'; 30 30 alter table creature_movement add `spell` int(5) unsigned default '0'; … … 149 149 if(behavior->model1 != 0) 150 150 creature.SetDisplayId(behavior->model1); 151 if( !behavior->text[0].empty())151 if(behavior->textid[0]) 152 152 { 153 // Only one text is set154 if( !behavior->text[1].empty())153 // Not only one text is set 154 if( behavior->textid[1] ) 155 155 { 156 156 // Select one from max 5 texts (0 and 1 already checked) 157 157 int i = 2; 158 for( ; i < 5; ++i )159 if( behavior->text[i].empty())158 for( ; i < MAX_WAYPOINT_TEXT; ++i ) 159 if( !behavior->textid[i] ) 160 160 break; 161 161 162 creature.Say(behavior->text[rand() % i].c_str(), 0, 0); 163 162 creature.Say(behavior->textid[rand() % i], 0, 0); 164 163 } 165 164 else 166 creature.Say(behavior->text [0].c_str(), 0, 0);165 creature.Say(behavior->textid[0], 0, 0); 167 166 } 168 167 } // wpBehaviour found -
trunk/src/game/World.cpp
r230 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 67 67 68 68 volatile bool World::m_stopEvent = false; 69 uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; 69 70 volatile uint32 World::m_worldLoopCounter = 0; 70 71 … … 543 544 m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 544 545 545 546 546 m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); 547 547 /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define … … 606 606 } 607 607 608 609 608 if(reload) 610 609 { … … 770 769 m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 771 770 772 // always use declined names in the Russian client773 m_configs[CONFIG_DECLINED_NAMES_USED] = 771 // always use declined names in the russian client 772 m_configs[CONFIG_DECLINED_NAMES_USED] = 774 773 (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 775 774 … … 966 965 DetectDBCLang(); 967 966 967 sLog.outString( "Loading Script Names..."); 968 objmgr.LoadScriptNames(); 969 968 970 sLog.outString( "Loading InstanceTemplate" ); 969 971 objmgr.LoadInstanceTemplate(); … … 1081 1083 sLog.outString( "Loading Tavern Area Triggers..." ); 1082 1084 objmgr.LoadTavernAreaTriggers(); 1083 1085 1084 1086 sLog.outString( "Loading AreaTrigger script names..." ); 1085 1087 objmgr.LoadAreaTriggerScripts(); 1086 1087 1088 1088 1089 sLog.outString( "Loading Graveyard-zone links..."); … … 1165 1166 sLog.outString( "Loading Npc Text Id..." ); 1166 1167 objmgr.LoadNpcTextId(); // must be after load Creature and NpcText 1167 1168 1168 1169 sLog.outString( "Loading Npc Options..." ); 1169 1170 objmgr.LoadNpcOptions(); … … 1193 1194 objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) 1194 1195 1196 sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls 1197 objmgr.LoadDbScriptStrings(); 1198 1195 1199 sLog.outString( "Initializing Scripts..." ); 1196 1200 if(!LoadScriptingModule()) … … 1263 1267 sLog.outString( "WORLD: World initialized" ); 1264 1268 } 1269 1265 1270 void World::DetectDBCLang() 1266 1271 { … … 1463 1468 } 1464 1469 1465 MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1470 /// </ul> 1471 ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1472 MapManager::Instance().DoDelayedMovesAndRemoves(); 1466 1473 1467 1474 // update the instance reset times … … 1583 1590 } 1584 1591 1592 //if(source && !source->IsInWorld()) source = NULL; 1593 1585 1594 Object* target = NULL; 1586 1595 … … 1610 1619 } 1611 1620 1621 //if(target && !target->IsInWorld()) target = NULL; 1622 1612 1623 switch (step.script->command) 1613 1624 { … … 1637 1648 { 1638 1649 case 0: // Say 1639 ((Creature *)source)->Say(step.script->data text.c_str(), LANG_UNIVERSAL, unit_target);1650 ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); 1640 1651 break; 1641 1652 case 1: // Whisper … … 1645 1656 break; 1646 1657 } 1647 ((Creature *)source)->Whisper(step.script->data text.c_str(),unit_target);1658 ((Creature *)source)->Whisper(step.script->dataint,unit_target); 1648 1659 break; 1649 1660 case 2: // Yell 1650 ((Creature *)source)->Yell(step.script->data text.c_str(), LANG_UNIVERSAL, unit_target);1661 ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); 1651 1662 break; 1652 1663 case 3: // Emote text 1653 ((Creature *)source)->TextEmote(step.script->data text.c_str(), unit_target);1664 ((Creature *)source)->TextEmote(step.script->dataint, unit_target); 1654 1665 break; 1655 1666 default: … … 1702 1713 } 1703 1714 ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); 1704 MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);1715 ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 1705 1716 break; 1706 1717 case SCRIPT_COMMAND_FLAG_SET: … … 1852 1863 go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds 1853 1864 1854 MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go);1865 go->GetMap()->Add(go); 1855 1866 break; 1856 1867 } … … 2374 2385 2375 2386 ///- if there is a shutdown timer 2376 if( m_ShutdownTimer > 0 && elapsed > 0)2387 if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) 2377 2388 { 2378 2389 ///- ... and it is overdue, stop the world (set m_stopEvent) … … 2380 2391 { 2381 2392 if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2382 m_stopEvent = true; 2393 m_stopEvent = true; // exist code already set 2383 2394 else 2384 2395 m_ShutdownTimer = 1; // minimum timer value to wait idle state … … 2395 2406 2396 2407 /// Shutdown the server 2397 void World::ShutdownServ(uint32 time, uint32 options) 2398 { 2408 void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) 2409 { 2410 // ignore if server shutdown at next tick 2411 if(m_stopEvent) 2412 return; 2413 2399 2414 m_ShutdownMask = options; 2415 m_ExitCode = exitcode; 2400 2416 2401 2417 ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) … … 2403 2419 { 2404 2420 if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2405 m_stopEvent = true; 2421 m_stopEvent = true; // exist code already set 2406 2422 else 2407 2423 m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick … … 2448 2464 void World::ShutdownCancel() 2449 2465 { 2450 if(!m_ShutdownTimer) 2466 // nothing cancel or too later 2467 if(!m_ShutdownTimer || m_stopEvent) 2451 2468 return; 2452 2469 … … 2455 2472 m_ShutdownMask = 0; 2456 2473 m_ShutdownTimer = 0; 2474 m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value 2457 2475 SendServerMessage(msgid); 2458 2476 2459 DEBUG_LOG("Server %s cancel ed.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));2477 DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 2460 2478 } 2461 2479 … … 2502 2520 if(!itr->second->Update(diff)) // As interval = 0 2503 2521 { 2522 RemoveQueuedPlayer (itr->second); 2504 2523 delete itr->second; 2505 2524 m_sessions.erase(itr); -
trunk/src/game/World.h
r229 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 52 52 }; 53 53 54 enum ShutdownExitCode 55 { 56 SHUTDOWN_EXIT_CODE = 0, 57 ERROR_EXIT_CODE = 1, 58 RESTART_EXIT_CODE = 2, 59 }; 60 54 61 /// Timers for different object refresh rates 55 62 enum WorldTimers … … 62 69 WUPDATE_CORPSES = 5, 63 70 WUPDATE_EVENTS = 6, 64 WUPDATE_COUNT = 7, 65 71 WUPDATE_COUNT = 7 66 72 }; 67 73 … … 106 112 CONFIG_INSTANCE_IGNORE_RAID, 107 113 CONFIG_BATTLEGROUND_CAST_DESERTER, 114 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, 115 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY, 108 116 CONFIG_INSTANCE_RESET_TIME_HOUR, 109 117 CONFIG_INSTANCE_UNLOAD_DELAY, … … 144 152 CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, 145 153 CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, 154 CONFIG_DETECT_POS_COLLISION, 146 155 CONFIG_RESTRICTED_LFG_CHANNEL, 147 156 CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, … … 317 326 struct CliCommandHolder 318 327 { 319 320 321 322 323 324 325 326 327 328 329 330 331 332 328 typedef void Print(const char*); 329 330 char *m_command; 331 Print* m_print; 332 333 CliCommandHolder(const char *command, Print* zprint) 334 : m_print(zprint) 335 { 336 size_t len = strlen(command)+1; 337 m_command = new char[len]; 338 memcpy(m_command, command, len); 339 } 340 341 ~CliCommandHolder() { delete[] m_command; } 333 342 }; 334 343 … … 337 346 { 338 347 public: 339 static volatile bool m_stopEvent;340 348 static volatile uint32 m_worldLoopCounter; 341 349 … … 345 353 WorldSession* FindSession(uint32 id) const; 346 354 void AddSession(WorldSession *s); 347 348 355 bool RemoveSession(uint32 id); 349 356 /// Get the number of current active sessions … … 408 415 void LoadConfigSettings(bool reload = false); 409 416 410 void SendWorldText(int32 string_id, ...); 417 void SendWorldText(int32 string_id, ...); 411 418 void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); 412 419 void SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self = 0, uint32 team = 0); … … 415 422 416 423 /// Are we in the middle of a shutdown? 417 uint32 GetShutdownMask() const { return m_ShutdownMask; }418 424 bool IsShutdowning() const { return m_ShutdownTimer > 0; } 419 void ShutdownServ(uint32 time, uint32 options = 0);425 void ShutdownServ(uint32 time, uint32 options, uint8 exitcode); 420 426 void ShutdownCancel(); 421 427 void ShutdownMsg(bool show = false, Player* player = NULL); 428 static uint8 GetExitCode() { return m_ExitCode; } 429 static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; } 430 static bool IsStopped() { return m_stopEvent; } 422 431 423 432 void Update(time_t diff); … … 454 463 void KickAllQueued(); 455 464 BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); 456 465 bool RemoveBanAccount(BanMode mode, std::string nameOrIP); 457 466 458 467 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target); … … 482 491 LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } 483 492 484 485 486 487 488 489 490 493 //used World DB version 494 void LoadDBVersion(); 495 char const* GetDBVersion() { return m_DBVersion.c_str(); } 496 497 //used Script version 498 void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; } 499 char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); } 491 500 492 501 protected: … … 499 508 void ResetDailyQuests(); 500 509 private: 510 static volatile bool m_stopEvent; 511 static uint8 m_ExitCode; 512 uint32 m_ShutdownTimer; 513 uint32 m_ShutdownMask; 514 501 515 time_t m_startTime; 502 516 time_t m_gameTime; … … 526 540 std::set<uint32> m_forbiddenMapIds; 527 541 528 uint32 m_ShutdownTimer;529 uint32 m_ShutdownMask;530 531 542 // for max speed access 532 543 static float m_MaxVisibleDistanceForCreature; … … 546 557 //Player Queue 547 558 Queue m_QueuedPlayer; 548 559 549 560 //sessions that are added async 550 561 void AddSession_(WorldSession* s); 551 562 ZThread::LockedQueue<WorldSession*, ZThread::FastMutex> addSessQueue; 552 563 553 554 555 564 //used versions 565 std::string m_DBVersion; 566 std::string m_ScriptsVersion; 556 567 }; 557 568