* HIGHLY EXPERIMENTAL - USE AT OWN RISK *
Database Layer: - Implement connection pooling: Instead of 1 delay thread per database, you can configure between 1 and 32 worker threads that have a seperate thread in the core and have a seperate connection to the MySQL server (based on raczman/Albator´s database layer for Trinitycore3) - Implement a configurable thread bundle for synchroneous requests from seperate core threads (see worldserver.conf.dist for more info) - Every mapupdate thread now has its seperate MySQL connection to the world and characters database - Drop inconsistent PExecuteLog function - query logging will be implemented CONSISTENTLY later - Drop current prepared statement interface - this will be done *properly* later - You´ll need to update your worldserver.conf and authserver.conf - You´re recommended to make a backup of your databases before using this. * HIGHLY EXPERIMENTAL - USE AT OWN RISK * * HIGHLY EXPERIMENTAL - USE AT OWN RISK * etc. --HG-- branch : trunk
This commit is contained in:
@@ -84,12 +84,10 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
|
||||
else // save
|
||||
{
|
||||
// _name is already escaped at this point.
|
||||
if (CharacterDatabase.PExecute("INSERT INTO channels (m_name, m_team, m_announce, m_moderate, m_public, m_password) "
|
||||
"VALUES ('%s', '%u', '1', '0', '1', '')", _name.c_str(), m_Team))
|
||||
{
|
||||
sLog.outDebug("New Channel(%s) saved", name.c_str());
|
||||
m_IsSaved = true;
|
||||
}
|
||||
CharacterDatabase.PExecute("INSERT INTO channels (m_name, m_team, m_announce, m_moderate, m_public, m_password) "
|
||||
"VALUES ('%s', '%u', '1', '0', '1', '')", _name.c_str(), m_Team);
|
||||
sLog.outDebug("New Channel(%s) saved", name.c_str());
|
||||
m_IsSaved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,8 +99,9 @@ bool Channel::_UpdateStringInDB(const std::string& colName, const std::string& c
|
||||
std::string _colValue(colValue);
|
||||
CharacterDatabase.escape_string(_colValue);
|
||||
CharacterDatabase.escape_string(_name);
|
||||
return CharacterDatabase.PExecute("UPDATE channels SET %s = '%s' WHERE m_name = '%s' AND m_team = '%u'",
|
||||
CharacterDatabase.PExecute("UPDATE channels SET %s = '%s' WHERE m_name = '%s' AND m_team = '%u'",
|
||||
colName.c_str(), _colValue.c_str(), _name.c_str(), m_Team);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Channel::_UpdateIntInDB(const std::string& colName, int colValue) const
|
||||
@@ -110,8 +109,9 @@ bool Channel::_UpdateIntInDB(const std::string& colName, int colValue) const
|
||||
// Prevent SQL-injection
|
||||
std::string _name(m_name);
|
||||
CharacterDatabase.escape_string(_name);
|
||||
return CharacterDatabase.PExecute("UPDATE channels SET %s = '%u' WHERE m_name = '%s' AND m_team = '%u'",
|
||||
CharacterDatabase.PExecute("UPDATE channels SET %s = '%u' WHERE m_name = '%s' AND m_team = '%u'",
|
||||
colName.c_str(), colValue, _name.c_str(), m_Team);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Channel::_UpdateBanListInDB() const
|
||||
|
||||
@@ -1174,7 +1174,7 @@ bool ChatHandler::HandleNpcAddMoveCommand(const char* args)
|
||||
//WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0);
|
||||
|
||||
// update movement type
|
||||
WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
|
||||
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid);
|
||||
if (pCreature && pCreature->GetWaypointPath())
|
||||
{
|
||||
pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
|
||||
@@ -1253,7 +1253,7 @@ bool ChatHandler::HandleNpcFlagCommand(const char* args)
|
||||
|
||||
pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags);
|
||||
|
||||
WorldDatabase.PExecuteLog("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry());
|
||||
WorldDatabase.PExecute("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry());
|
||||
|
||||
SendSysMessage(LANG_VALUE_SAVED_REJOIN);
|
||||
|
||||
@@ -1372,7 +1372,7 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args)
|
||||
}
|
||||
}
|
||||
|
||||
WorldDatabase.PExecuteLog("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid);
|
||||
WorldDatabase.PExecute("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid);
|
||||
PSendSysMessage(LANG_COMMAND_CREATUREMOVED);
|
||||
return true;
|
||||
}
|
||||
@@ -1583,7 +1583,7 @@ bool ChatHandler::HandleNpcFactionIdCommand(const char* args)
|
||||
}
|
||||
|
||||
// and DB
|
||||
WorldDatabase.PExecuteLog("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry());
|
||||
WorldDatabase.PExecute("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1621,7 +1621,7 @@ bool ChatHandler::HandleNpcSpawnDistCommand(const char* args)
|
||||
pCreature->Respawn();
|
||||
}
|
||||
|
||||
WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow);
|
||||
WorldDatabase.PExecute("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow);
|
||||
PSendSysMessage(LANG_COMMAND_SPAWNDIST,option);
|
||||
return true;
|
||||
}
|
||||
@@ -1653,7 +1653,7 @@ bool ChatHandler::HandleNpcSpawnTimeCommand(const char* args)
|
||||
else
|
||||
return false;
|
||||
|
||||
WorldDatabase.PExecuteLog("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow);
|
||||
WorldDatabase.PExecute("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow);
|
||||
pCreature->SetRespawnDelay((uint32)i_stime);
|
||||
PSendSysMessage(LANG_COMMAND_SPAWNTIME,i_stime);
|
||||
|
||||
@@ -2384,7 +2384,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args)
|
||||
Player* player = m_session->GetPlayer();
|
||||
//Map *map = player->GetMap();
|
||||
|
||||
WorldDatabase.PExecuteLog("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u','%u','%f', '%f', '%f')",
|
||||
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());
|
||||
|
||||
PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1,"|r|cff00ff00 created. ");
|
||||
@@ -2588,7 +2588,7 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
|
||||
if (result)
|
||||
{
|
||||
WorldDatabase.PExecuteLog("DELETE FROM waypoint_scripts WHERE guid = %u", id);
|
||||
WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id);
|
||||
PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id);
|
||||
}
|
||||
else
|
||||
@@ -2647,7 +2647,7 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
{
|
||||
uint32 newid = atoi(arg_3);
|
||||
PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r","|cff00ff00","Wp Event: Wypoint scipt guid: ", newid," id changed: ", id);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'",
|
||||
newid, id); return true;
|
||||
}
|
||||
else
|
||||
@@ -2663,7 +2663,7 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
if (arg_str_2 == "posx")
|
||||
{
|
||||
coord = atof(arg_3);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id);
|
||||
return true;
|
||||
@@ -2671,7 +2671,7 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
else if (arg_str_2 == "posy")
|
||||
{
|
||||
coord = atof(arg_3);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id);
|
||||
return true;
|
||||
@@ -2679,7 +2679,7 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
else if (arg_str_2 == "posz")
|
||||
{
|
||||
coord = atof(arg_3);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id);
|
||||
return true;
|
||||
@@ -2687,14 +2687,14 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
else if (arg_str_2 == "orientation")
|
||||
{
|
||||
coord = atof(arg_3);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "dataint")
|
||||
{
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'",
|
||||
arg_2, atoi(arg_3), id);
|
||||
PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id);
|
||||
return true;
|
||||
@@ -2703,7 +2703,7 @@ bool ChatHandler::HandleWpEventCommand(const char* args)
|
||||
{
|
||||
std::string arg_str_3 = arg_3;
|
||||
WorldDatabase.escape_string(arg_str_3);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'",
|
||||
arg_2, arg_str_3.c_str(), id);
|
||||
}
|
||||
}
|
||||
@@ -2832,9 +2832,9 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
|
||||
wpCreature->AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
WorldDatabase.PExecuteLog("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'",
|
||||
WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'",
|
||||
pathid, point);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'",
|
||||
pathid, point);
|
||||
|
||||
PSendSysMessage(LANG_WAYPOINT_REMOVED);
|
||||
@@ -2875,7 +2875,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
|
||||
//sMapMgr.GetMap(npcCreature->GetMapId())->Add(wpCreature2);
|
||||
}
|
||||
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'",
|
||||
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);
|
||||
|
||||
PSendSysMessage(LANG_WAYPOINT_CHANGED);
|
||||
@@ -2888,7 +2888,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
|
||||
if (text == 0)
|
||||
{
|
||||
// show_str check for present in list of correct values, no sql injection possible
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'",
|
||||
show_str, pathid, point);
|
||||
}
|
||||
else
|
||||
@@ -2896,7 +2896,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
|
||||
// show_str check for present in list of correct values, no sql injection possible
|
||||
std::string text2 = text;
|
||||
WorldDatabase.escape_string(text2);
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'",
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'",
|
||||
show_str, text2.c_str(), pathid, point);
|
||||
}
|
||||
|
||||
@@ -3031,7 +3031,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);
|
||||
hasError = true;
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpguid);
|
||||
WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3075,7 +3075,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
|
||||
|
||||
sLog.outDebug("DEBUG: UPDATE waypoint_data SET wpguid = '%u");
|
||||
// set "wpguid" column to the visual waypoint
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
|
||||
|
||||
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
@@ -3205,7 +3205,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
|
||||
hasError = true;
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", guid);
|
||||
WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3216,8 +3216,8 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
|
||||
}
|
||||
while (result->NextRow());
|
||||
// set "wpguid" column to "empty" - no visual waypoint spawned
|
||||
WorldDatabase.PExecuteLog("UPDATE waypoint_data SET wpguid = '0'");
|
||||
//WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'");
|
||||
//WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");
|
||||
|
||||
if (hasError)
|
||||
{
|
||||
@@ -4210,7 +4210,7 @@ bool ChatHandler::HandleNpcAddFormationCommand(const char* args)
|
||||
CreatureGroupMap[lowguid] = group_member;
|
||||
pCreature->SearchFormation();
|
||||
|
||||
WorldDatabase.PExecuteLog("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u','%u','%f', '%f', '%u')",
|
||||
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);
|
||||
|
||||
PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID);
|
||||
|
||||
Reference in New Issue
Block a user