diff options
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_account.cpp | 43 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_achievement.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_event.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gm.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_go.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gps.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_honor.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_learn.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_modify.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_npc.cpp | 102 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_quest.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_reload.cpp | 20 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_tele.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_titles.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_wp.cpp | 200 |
18 files changed, 295 insertions, 98 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index bcef7ac9ba9..bd415c0f79f 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -81,7 +81,7 @@ public: return false; } - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_EXPANSION); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION); stmt->setUInt8(0, uint8(expansion)); stmt->setUInt32(1, accountId); @@ -109,6 +109,7 @@ public: { case AOR_OK: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); + sLog->outChar("Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password.", handler->GetSession()->GetAccountId(),handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName(), handler->GetSession()->GetPlayer()->GetGUIDLow()); break; case AOR_NAME_TOO_LONG: handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); @@ -250,7 +251,7 @@ public: if (!param.empty()) { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_ACCOUNT_LOCK); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK); if (param == "on") { @@ -388,8 +389,13 @@ public: if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION)) return false; - // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION); + + stmt->setUInt8(0, expansion); + stmt->setUInt32(1, accountId); + + LoginDatabase.Execute(stmt); + handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion); return true; } @@ -480,13 +486,34 @@ public: } // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID + PreparedStatement* stmt; + if (gmRealmID == -1) - LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId); + { + stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS); + + stmt->setUInt32(0, targetAccountId); + } else - LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID); + { + stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM); + + stmt->setUInt32(0, targetAccountId); + stmt->setUInt32(1, realmID); + } + LoginDatabase.Execute(stmt); if (gm != 0) - LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, gmRealmID); + { + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS); + + stmt->setUInt32(0, targetAccountId); + stmt->setUInt8(1, uint8(gm)); + stmt->setUInt32(2, gmRealmID); + + LoginDatabase.Execute(stmt); + } + handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); return true; diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 61ce13f0ecb..f136cba46ab 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index d47b04f3bcb..06885e899e4 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index 3bd745df4f4..4f6acd7b629 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 6135e231c24..926e2fe2bf2 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 5ed2d6a3dd8..3de0d89bac5 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index eb1ccc543f3..2fb6c3f0d10 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_gps.cpp b/src/server/scripts/Commands/cs_gps.cpp index 6e67eebc5bc..0d249326837 100644 --- a/src/server/scripts/Commands/cs_gps.cpp +++ b/src/server/scripts/Commands/cs_gps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index f6c6d89c0b7..4edc5f6fea0 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index d03291d6d5d..fcabaaa7e5b 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 7c08fe4d297..5f0434e5c55 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1,5 +1,5 @@ /*
- * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 065f1b1fee1..99283623207 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index a5aa2a516f3..54dac404f03 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -219,10 +219,10 @@ public: if (!*args) return false; - char* guid_str = strtok((char*)args, " "); - char* wait_str = strtok((char*)NULL, " "); + char* guidStr = strtok((char*)args, " "); + char* waitStr = strtok((char*)NULL, " "); - uint32 lowguid = atoi((char*)guid_str); + uint32 lowGuid = atoi((char*)guidStr); Creature* creature = NULL; @@ -234,10 +234,10 @@ public: // attempt check creature existence by DB data if (!creature) { - CreatureData const* data = sObjectMgr->GetCreatureData(lowguid); + CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid); if (!data) { - handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid); handler->SetSentErrorMessage(true); return false; } @@ -245,20 +245,22 @@ public: else { // obtain real GUID for DB operations - lowguid = creature->GetDBTableGUIDLow(); + lowGuid = creature->GetDBTableGUIDLow(); } - int wait = wait_str ? atoi(wait_str) : 0; + int wait = waitStr ? atoi(waitStr) : 0; if (wait < 0) wait = 0; - //Player* player = handler->GetSession()->GetPlayer(); + // Update movement type + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); - //WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); + stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE)); + stmt->setUInt32(1, lowGuid); + + WorldDatabase.Execute(stmt); - // update movement type - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, lowguid); if (creature && creature->GetWaypointPath()) { creature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); @@ -457,17 +459,23 @@ public: creature->setFaction(factionId); - // faction is set in creature_template - not inside creature + // Faction is set in creature_template - not inside creature - // update in memory + // Update in memory.. if (CreatureTemplate const* cinfo = creature->GetCreatureInfo()) { const_cast<CreatureTemplate*>(cinfo)->faction_A = factionId; const_cast<CreatureTemplate*>(cinfo)->faction_H = factionId; } - // and DB - WorldDatabase.PExecute("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, creature->GetEntry()); + // ..and DB + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_FACTION); + + stmt->setUInt16(0, uint16(factionId)); + stmt->setUInt16(1, uint16(factionId)); + stmt->setUInt32(2, creature->GetEntry()); + + WorldDatabase.Execute(stmt); return true; } @@ -491,7 +499,12 @@ public: creature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags); - WorldDatabase.PExecute("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, creature->GetEntry()); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_NPCFLAG); + + stmt->setUInt32(0, npcFlags); + stmt->setUInt32(1, creature->GetEntry()); + + WorldDatabase.Execute(stmt); handler->SendSysMessage(LANG_VALUE_SAVED_REJOIN); @@ -637,7 +650,16 @@ public: } } - WorldDatabase.PExecute("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_POSITION); + + stmt->setFloat(0, x); + stmt->setFloat(1, y); + stmt->setFloat(2, z); + stmt->setFloat(3, o); + stmt->setUInt32(4, lowguid); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage(LANG_COMMAND_CREATUREMOVED); return true; } @@ -884,10 +906,10 @@ public: mtype = RANDOM_MOTION_TYPE; Creature* creature = handler->getSelectedCreature(); - uint32 u_guidlow = 0; + uint32 guidLow = 0; if (creature) - u_guidlow = creature->GetDBTableGUIDLow(); + guidLow = creature->GetDBTableGUIDLow(); else return false; @@ -900,7 +922,14 @@ public: creature->Respawn(); } - WorldDatabase.PExecute("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u", option, mtype, u_guidlow); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_DISTANCE); + + stmt->setFloat(0, option); + stmt->setUInt8(1, uint8(mtype)); + stmt->setUInt32(2, guidLow); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST, option); return true; } @@ -916,9 +945,9 @@ public: if (!stime) return false; - int i_stime = atoi((char*)stime); + int spawnTime = atoi((char*)stime); - if (i_stime < 0) + if (spawnTime < 0) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); @@ -926,16 +955,22 @@ public: } Creature* creature = handler->getSelectedCreature(); - uint32 u_guidlow = 0; + uint32 guidLow = 0; if (creature) - u_guidlow = creature->GetDBTableGUIDLow(); + guidLow = creature->GetDBTableGUIDLow(); else return false; - WorldDatabase.PExecute("UPDATE creature SET spawntimesecs=%i WHERE guid=%u", i_stime, u_guidlow); - creature->SetRespawnDelay((uint32)i_stime); - handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, i_stime); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS); + + stmt->setUInt32(0, uint32(spawnTime)); + stmt->setUInt32(1, guidLow); + + WorldDatabase.Execute(stmt); + + creature->SetRespawnDelay((uint32)spawnTime); + handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, spawnTime); return true; } @@ -1198,8 +1233,15 @@ public: CreatureGroupMap[lowguid] = group_member; creature->SearchFormation(); - WorldDatabase.PExecute("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u', '%u', '%f', '%f', '%u')", - leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION); + + stmt->setUInt32(0, leaderGUID); + stmt->setUInt32(1, lowguid); + stmt->setFloat(2, group_member->follow_dist); + stmt->setFloat(3, group_member->follow_angle); + stmt->setUInt32(4, uint32(group_member->groupAI)); + + WorldDatabase.Execute(stmt); handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID); diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 3d437e473f7..2472a29e595 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 7784d495f80..4d8ce4ef4ed 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -36,6 +36,7 @@ EndScriptData */ #include "SkillDiscovery.h" #include "SkillExtraItems.h" #include "Chat.h" +#include "WaypointManager.h" class reload_commandscript : public CommandScript { @@ -144,13 +145,14 @@ public: { "spell_linked_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLinkedSpellCommand, "", NULL }, { "spell_pet_auras", SEC_ADMINISTRATOR, true, &HandleReloadSpellPetAurasCommand, "", NULL }, { "spell_proc_event", SEC_ADMINISTRATOR, true, &HandleReloadSpellProcEventCommand, "", NULL }, - { "spell_proc", SEC_ADMINISTRATOR, true, &HandleReloadSpellProcsCommand, "", NULL }, + { "spell_proc", SEC_ADMINISTRATOR, true, &HandleReloadSpellProcsCommand, "", NULL }, { "spell_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSpellScriptsCommand, "", NULL }, { "spell_target_position", SEC_ADMINISTRATOR, true, &HandleReloadSpellTargetPositionCommand, "", NULL }, { "spell_threats", SEC_ADMINISTRATOR, true, &HandleReloadSpellThreatsCommand, "", NULL }, { "spell_group_stack_rules", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL }, { "trinity_string", SEC_ADMINISTRATOR, true, &HandleReloadTrinityStringCommand, "", NULL }, { "waypoint_scripts", SEC_ADMINISTRATOR, true, &HandleReloadWpScriptsCommand, "", NULL }, + { "waypoint_data", SEC_ADMINISTRATOR, true, &HandleReloadWpCommand, "", NULL }, { "vehicle_accessory", SEC_ADMINISTRATOR, true, &HandleReloadVehicleAccessoryCommand, "", NULL }, { "vehicle_template_accessory", SEC_ADMINISTRATOR, true, &HandleReloadVehicleTemplateAccessoryCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } @@ -264,6 +266,7 @@ public: handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); HandleReloadDbScriptStringCommand(handler, "a"); HandleReloadWpScriptsCommand(handler, "a"); + HandleReloadWpCommand(handler, "a"); return true; } @@ -986,6 +989,19 @@ public: return true; } + static bool HandleReloadWpCommand(ChatHandler* handler, const char* args) + { + if (*args != 'a') + sLog->outString("Re-Loading Waypoints data from 'waypoints_data'"); + + sWaypointMgr->Load(); + + if (*args != 'a') + sLog->outString("DB Table 'waypoint_data' reloaded."); + + return true; + } + static bool HandleReloadEventAITextsCommand(ChatHandler* handler, const char* /*args*/) { diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index ef4ddf17476..5054bd83f32 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index 2ffeea78575..0a3b430ab2c 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index d34ee801e50..8f5e862555c 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -117,8 +117,15 @@ public: Player* player = handler->GetSession()->GetPlayer(); //Map* map = player->GetMap(); - WorldDatabase.PExecute("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u', '%u', '%f', '%f', '%f')", - pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA); + + stmt->setUInt32(0, pathid); + stmt->setUInt32(1, point + 1); + stmt->setFloat(2, player->GetPositionX()); + stmt->setFloat(3, player->GetPositionY()); + stmt->setFloat(4, player->GetPositionZ()); + + WorldDatabase.Execute(stmt); handler->PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1, "|r|cff00ff00 created. "); return true; @@ -136,7 +143,7 @@ public: path_number = strtok((char*)args, " "); uint32 pathid = 0; - uint32 guidlow = 0; + uint32 guidLow = 0; Creature* target = handler->getSelectedCreature(); // Did player provide a path_id? @@ -165,15 +172,34 @@ public: return true; } - guidlow = target->GetDBTableGUIDLow(); - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'", guidlow); + guidLow = target->GetDBTableGUIDLow(); + QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'", guidLow); + + PreparedStatement* stmt; if (result) - WorldDatabase.PExecute("UPDATE creature_addon SET path_id = '%u' WHERE guid = '%u'", pathid, guidlow); + { + stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ADDON_PATH); + + stmt->setUInt32(0, pathid); + stmt->setUInt32(1, guidLow); + } else - WorldDatabase.PExecute("INSERT INTO creature_addon(guid, path_id) VALUES ('%u', '%u')", guidlow, pathid); + { + stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_ADDON); + + stmt->setUInt32(0, guidLow); + stmt->setUInt32(1, pathid); + } + + WorldDatabase.Execute(stmt); + + stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); + + stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE)); + stmt->setUInt32(1, guidLow); - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow); + WorldDatabase.Execute(stmt); target->LoadPath(pathid); target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); @@ -208,15 +234,27 @@ public: return true; } - uint32 guidlow = target->GetDBTableGUIDLow(); + uint32 guildLow = target->GetDBTableGUIDLow(); if (target->GetCreatureAddon()) { if (target->GetCreatureAddon()->path_id != 0) { - WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", guidlow); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON); + + stmt->setUInt32(0, guildLow); + + WorldDatabase.Execute(stmt); + target->UpdateWaypointID(0); - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow); + + stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); + + stmt->setUInt8(0, uint8(IDLE_MOTION_TYPE)); + stmt->setUInt32(1, guildLow); + + WorldDatabase.Execute(stmt); + target->LoadPath(0); target->SetDefaultMovementType(IDLE_MOTION_TYPE); target->GetMotionMaster()->MoveTargetedHome(); @@ -254,7 +292,12 @@ public: if (!result) { - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT); + + stmt->setUInt32(0, id); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); } else @@ -264,7 +307,13 @@ public: { QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts"); id = result->Fetch()->GetUInt32(); - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id+1); + + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT); + + stmt->setUInt32(0, id + 1); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: |r|cff00ffff", id+1); } @@ -322,7 +371,12 @@ public: if (result) { - WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_SCRIPT); + + stmt->setUInt32(0, id); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: Waypoint script removed: ", id); } else @@ -379,8 +433,15 @@ public: { uint32 newid = atoi(arg_3); handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r", "|cff00ff00", "Wp Event: Wypoint scipt guid: ", newid, " id changed: ", id); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'", - newid, id); return true; + + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_ID); + + stmt->setUInt32(0, newid); + stmt->setUInt32(1, id); + + WorldDatabase.Execute(stmt); + + return true; } else { @@ -394,36 +455,56 @@ public: if (arg_str_2 == "posx") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'", - (float)(atof(arg_3)), id); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_X); + + stmt->setFloat(0, float(atof(arg_3))); + stmt->setUInt32(1, id); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); return true; } else if (arg_str_2 == "posy") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'", - (float)(atof(arg_3)), id); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Y); + + stmt->setFloat(0, float(atof(arg_3))); + stmt->setUInt32(1, id); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); return true; } else if (arg_str_2 == "posz") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'", - (float)(atof(arg_3)), id); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Z); + + stmt->setFloat(0, float(atof(arg_3))); + stmt->setUInt32(1, id); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); return true; } else if (arg_str_2 == "orientation") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'", - (float)(atof(arg_3)), id); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_O); + + stmt->setFloat(0, float(atof(arg_3))); + stmt->setUInt32(1, id); + + WorldDatabase.Execute(stmt); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); return true; } else if (arg_str_2 == "dataint") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", - arg_2, atoi(arg_3), id); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); return true; } @@ -431,8 +512,7 @@ public: { std::string arg_str_3 = arg_3; WorldDatabase.EscapeString(arg_str_3); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", - arg_2, arg_str_3.c_str(), id); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", arg_2, arg_str_3.c_str(), id); // Query can't be a prepared statement } } handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated."); @@ -540,10 +620,19 @@ public: wpCreature->AddObjectToRemoveList(); } - WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'", - pathid, point); - WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'", - pathid, point); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA); + + stmt->setUInt32(0, pathid); + stmt->setUInt32(1, point); + + WorldDatabase.Execute(stmt); + + stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT); + + stmt->setUInt32(0, pathid); + stmt->setUInt32(1, point); + + WorldDatabase.Execute(stmt); handler->PSendSysMessage(LANG_WAYPOINT_REMOVED); return true; @@ -588,8 +677,15 @@ public: //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2); } - WorldDatabase.PExecute("UPDATE waypoint_data SET position_x = '%f', position_y = '%f', position_z = '%f' where id = '%u' AND point='%u'", - chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), pathid, point); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION); + + stmt->setFloat(0, chr->GetPositionX()); + stmt->setFloat(1, chr->GetPositionY()); + stmt->setFloat(2, chr->GetPositionZ()); + stmt->setUInt32(3, pathid); + stmt->setUInt32(4, point); + + WorldDatabase.Execute(stmt); handler->PSendSysMessage(LANG_WAYPOINT_CHANGED); } @@ -601,16 +697,14 @@ public: if (text == 0) { // show_str check for present in list of correct values, no sql injection possible - WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", - show_str, pathid, point); + WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", show_str, pathid, point); // Query can't be a prepared statement } else { // show_str check for present in list of correct values, no sql injection possible std::string text2 = text; WorldDatabase.EscapeString(text2); - WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", - show_str, text2.c_str(), pathid, point); + WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", show_str, text2.c_str(), pathid, point); // Query can't be a prepared statement } handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); @@ -735,7 +829,12 @@ public: { handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid); + + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); + + stmt->setUInt32(0, wpguid); + + WorldDatabase.Execute(stmt); } else { @@ -777,8 +876,14 @@ public: return false; } - // set "wpguid" column to the visual waypoint - WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); + // Set "wpguid" column to the visual waypoint + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID); + + stmt->setInt32(0, int32(wpCreature->GetGUIDLow())); + stmt->setUInt32(1, pathid); + stmt->setUInt32(2, point); + + WorldDatabase.Execute(stmt); wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); @@ -920,7 +1025,12 @@ public: { handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid); + + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); + + stmt->setUInt32(0, guid); + + WorldDatabase.Execute(stmt); } else { @@ -931,7 +1041,9 @@ public: } while (result->NextRow()); // set "wpguid" column to "empty" - no visual waypoint spawned - WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'"); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_ALL_WAYPOINT_DATA_WPGUID); + + WorldDatabase.Execute(stmt); //WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'"); if (hasError) |
