diff options
-rw-r--r-- | contrib/conf_merge/confdiffmerge.php | 169 | ||||
-rw-r--r-- | src/server/game/Calendar/CalendarMgr.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Calendar/CalendarMgr.h | 3 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Handlers/CalendarHandler.cpp | 21 | ||||
-rw-r--r-- | src/server/game/Tickets/TicketMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Warden/Warden.cpp | 2 | ||||
-rw-r--r-- | src/server/shared/Database/DatabaseWorkerPool.h | 6 | ||||
-rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 14 |
9 files changed, 225 insertions, 17 deletions
diff --git a/contrib/conf_merge/confdiffmerge.php b/contrib/conf_merge/confdiffmerge.php new file mode 100644 index 00000000000..7bcaef5042e --- /dev/null +++ b/contrib/conf_merge/confdiffmerge.php @@ -0,0 +1,169 @@ +<!-- + @title Configuration file merger/differ. + @about This script allows you to diff two config files and select which value to pick between the two. + It will then give you an updated configuration file with the settings you chose. + How-to: a) Paste both versions of your config file, submit the form. + b) Select values you want to keep in the next form, then submit said form. + c) Copy the output'd config file and profit! + Note: if either one of your config file has custom values, make sure that it is set to be the NEW + config file on the first step (right hand textarea). This will be adressed at a later date. + @author Warpten + @date 05/17/2014 + @license GNU GPL v2(GPL) + @version 0.0.1 +--> +<!DOCTYPE html> +<html> +<head> + <title><world/auth>server.conf diff</title> + <style type="text/css"> + form * { font-family: Verdana; font-size: 11px; } + form#step1 { position: relative; width: 800px; } + form#step2 { width: 500px; } + form > div { position: absolute; width: 50%; height: 500px; } + form > div:nth-child(1) { right: 0px; } + textarea { width: 90%; height: 500px; } + h3 { display: block; margin: 3px; padding: auto; text-align: center; } + input.valueName { border: 0px; background-color: white; } + form > p { margin: 0; padding: 3px; border-bottom: 1px solid black; } + textarea#result { width: 1000px; } + </style> +</head> + +<body> +<?php + +function printIndent($string, $indent = 1) +{ + echo str_pad("\r\n" . $string, $indent, " "); +} + +if (!isset($_POST['step'])) +{ +?> + <form action="" method="POST" id="step1"> + <div> + <h3>Paste the new configuration file</h3> + <textarea name="leftFile"></textarea> + </div><div> + <h3>Paste the old configuration file</h3> + <textarea name="rightFile"></textarea> + <input type="submit" value="Compare files" /> + </div> + <input type="hidden" name="step" value="0" /> + </form> +<?php +} +else if ($_POST['step'] == 0) +{ + if (@empty($_POST['leftFile']) || @empty($_POST['rightFile'])) + printf("You did not provide either the old or the new configuration file.<br />"); + + define('EOL', "\n\n"); + $settingsData = array(); + + // Process them + $newFile = explode(EOL, $_POST['leftFile']); + $oldFile = explode(EOL, $_POST['rightFile']); + + for ($i = 0, $o = count($oldFile); $i < $o; ++$i) + { + $oldFile[$i] = explode(PHP_EOL, $oldFile[$i]); + for ($j = 0, $p = count($oldFile[$i]); $j < $p; ++$j) + { + $currentLine = $oldFile[$i][$j]; + if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false) + if (strlen($data[1]) != 0) + $settingsData[$data[1]]["oldValue"] = str_replace('"', '', trim($data[2])); + } + } + + for ($i = 0, $o = count($newFile); $i < $o; ++$i) + { + $newFile[$i] = explode(PHP_EOL, $newFile[$i]); + for ($j = 0, $p = count($newFile[$i]); $j < $p; ++$j) + { + $currentLine = $newFile[$i][$j]; + if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false) + if (strlen($data[1]) != 0) + $settingsData[$data[1]]["newValue"] = str_replace('"', '', trim($data[2])); + } + } + + printIndent("<p>Please select values you want to keep. Note the script will default to new values, unless said <i>new</i> value does not exist.<br />You also can take advantage of this form and edit fields.</p>", 1); + printIndent('<form action="" method="POST" id="step2">', 1); + + foreach ($settingsData as $itemName => &$values) + { + $displayOld = isset($values['oldValue']) ? $values['oldValue'] : "Value missing"; + $displayNew = isset($values['newValue']) ? $values['newValue'] : "Value missing"; + + if ($displayOld == $displayNew) + continue; + + $line = '<p><input type="text" class="valueName" name="nameCross[]" value="' . $itemName . '" />'; + $line .= '<input type="radio" name="optionSelector[' . $itemName . ']" value="oldValue" ' . ($displayOld != "Value missing" ? "checked" : "") . '/>'; + $line .= '<input type="text" name="oldValue[]" value="' . $displayOld . '" /> '; + $line .= '<input type="radio" name="optionSelector[' . $itemName . ']" value="newValue" ' . ($displayNew != "Value missing" ? "checked" : "") . '/>'; + $line .= '<input type="text" name="newValue[]" value="' . $displayNew . '" /></p>'; + printIndent($line, 2); + } + printIndent('<input type="hidden" name="step" value="1" />', 2); + printIndent('<input type="submit" value="Gief resulting configuration file" />', 2); + printIndent('<input type="hidden" name="file" value="' . htmlspecialchars($_POST['rightFile']) . '" />', 2); + printIndent('</form>', 1); +} +else if ($_POST['step'] == 1) +{ + $errors = array(); + + $confFile = $_POST['file']; + + foreach ($_POST['optionSelector'] as $valueName => &$keyName) + { + $definiteValueIndex = -1; + foreach ($_POST['nameCross'] as $index => &$key) + { + if ($key == $valueName) + { + $definiteValueIndex = $index; + break; + } + } + + if ($definiteValueIndex == -1) + { + // TODO: Handle custom values that get lost + continue; + } + + $newStr = $_POST[$keyName][$definiteValueIndex]; + $oldStr = $_POST[$keyName == "oldValue" ? "newValue" : "oldValue"][$definiteValueIndex]; + if (!ctype_digit($newStr)) + $newStr = '"' . $newStr . '"'; + if (!ctype_digit($oldStr)) + $oldStr = '"' . $oldStr . '"'; + + $newValueString = $valueName . " = " . $newStr; + $oldValueString = $valueName . " = " . $oldStr; + $confFile = str_replace($oldValueString, $newValueString, $confFile); + } + echo "<p>Here is your new configuration file:</p>"; + echo '<form><textarea id="result">'; + printf('%s', $confFile); + echo '</textarea></form>'; + + if (!empty($errors)) + { + echo "<p>The following errors happened during processing:</p><ul><li>"; + echo implode("</li><li>", $errors); + echo "</li>"; + } +} +?> + +<script type="text/javascript"> + +</script> +</body> +</html> diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 52ed50f3948..a4cb972e625 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -17,7 +17,6 @@ #include "CalendarMgr.h" #include "QueryResult.h" -#include "DatabaseEnv.h" #include "Log.h" #include "Player.h" #include "GuildMgr.h" @@ -128,6 +127,12 @@ void CalendarMgr::AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType s void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite) { + SQLTransaction dummy; + AddInvite(calendarEvent, invite, dummy); +} + +void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans) +{ if (!calendarEvent->IsGuildAnnouncement()) SendCalendarEventInvite(*invite); @@ -137,7 +142,7 @@ void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite if (!calendarEvent->IsGuildAnnouncement()) { _invites[invite->GetEventId()].push_back(invite); - UpdateInvite(invite); + UpdateInvite(invite, trans); } } @@ -221,7 +226,6 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 /*remover void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) { - SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT); stmt->setUInt64(0, calendarEvent->GetEventId()); stmt->setUInt32(1, GUID_LOPART(calendarEvent->GetCreatorGUID())); @@ -232,13 +236,17 @@ void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) stmt->setUInt32(6, uint32(calendarEvent->GetEventTime())); stmt->setUInt32(7, calendarEvent->GetFlags()); stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct? - trans->Append(stmt); - CharacterDatabase.CommitTransaction(trans); + CharacterDatabase.Execute(stmt); } void CalendarMgr::UpdateInvite(CalendarInvite* invite) { - SQLTransaction trans = CharacterDatabase.BeginTransaction(); + SQLTransaction dummy; + UpdateInvite(invite, dummy); +} + +void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans) +{ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); stmt->setUInt64(1, invite->GetEventId()); @@ -248,8 +256,7 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite) stmt->setUInt32(5, uint32(invite->GetStatusTime())); stmt->setUInt8(6, invite->GetRank()); stmt->setString(7, invite->GetText()); - trans->Append(stmt); - CharacterDatabase.CommitTransaction(trans); + CharacterDatabase.ExecuteOrAppend(trans, stmt); } void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index da185d519d5..8f44b013e5c 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -20,6 +20,7 @@ #include <ace/Singleton.h> #include "Common.h" +#include "DatabaseEnv.h" #include "WorldPacket.h" enum CalendarMailAnswers @@ -305,8 +306,10 @@ class CalendarMgr void UpdateEvent(CalendarEvent* calendarEvent); void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite); + void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans); void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover); void UpdateInvite(CalendarInvite* invite); + void UpdateInvite(CalendarInvite* invite, SQLTransaction& trans); void RemoveAllPlayerEventsAndInvites(uint64 guid); void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 40488df9ef3..306e4209e4d 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1100,7 +1100,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f SwitchDoorOrButton(true, alternative); SetLootState(GO_ACTIVATED, user); - m_cooldownTime = time(NULL) + time_to_restore; + m_cooldownTime = time_to_restore ? (time(NULL) + time_to_restore) : 0; } void GameObject::SetGoArtKit(uint8 kit) diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 45d4d221d06..ebb1f9c8e57 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -255,7 +255,14 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) uint32 inviteCount; recvData >> inviteCount; - for (uint32 i = 0; i < inviteCount; ++i) + SQLTransaction trans; + if (inviteCount > 1) + trans = CharacterDatabase.BeginTransaction(); + + // client limits the amount of players to be invited to 100 + const int MaxPlayerInvites = 100; + + for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i) { uint64 invitee = 0; uint8 status = 0; @@ -265,8 +272,11 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) // 946684800 is 01/01/2000 00:00:00 - default response time CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent.GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); - sCalendarMgr->AddInvite(&calendarEvent, invite); + sCalendarMgr->AddInvite(&calendarEvent, invite, trans); } + + if (inviteCount > 1) + CharacterDatabase.CommitTransaction(trans); } sCalendarMgr->AddEvent(new CalendarEvent(calendarEvent, calendarEvent.GetEventId()), CALENDAR_SENDTYPE_ADD); @@ -350,10 +360,15 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); + SQLTransaction trans; + if (invites.size() > 1) + trans = CharacterDatabase.BeginTransaction(); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) - sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId())); + sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()), trans); + if (invites.size() > 1) + CharacterDatabase.CommitTransaction(trans); // should we change owner when somebody makes a copy of event owned by another person? } else diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index b9ecfffb8c3..71d51153b4c 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -233,7 +233,7 @@ void GmTicket::SetChatLog(std::list<uint32> time, std::string const& log) std::stringstream ss(log); std::stringstream newss; std::string line; - while (std::getline(ss, line)) + while (std::getline(ss, line) && !time.empty()) { newss << secsToTimeString(time.front()) << ": " << line << "\n"; time.pop_front(); diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index 42872bba22e..0810295c0cc 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -223,7 +223,7 @@ std::string Warden::Penalty(WardenCheck* check /*= NULL*/) void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData) { - if (!_warden) + if (!_warden || recvData.empty()) return; _warden->DecryptData(recvData.contents(), recvData.size()); diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index c60458323f7..3665a388854 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -49,8 +49,10 @@ class DatabaseWorkerPool { public: /* Activity state */ - DatabaseWorkerPool() : _queue(new ACE_Activation_Queue()), _connectionInfo(NULL) + DatabaseWorkerPool() : _connectionInfo(NULL) { + _messageQueue = new ACE_Message_Queue<ACE_SYNCH>(8 * 1024 * 1024, 8 * 1024 * 1024); + _queue = new ACE_Activation_Queue(_messageQueue); memset(_connectionCount, 0, sizeof(_connectionCount)); _connections.resize(IDX_SIZE); @@ -131,6 +133,7 @@ class DatabaseWorkerPool //! Deletes the ACE_Activation_Queue object and its underlying ACE_Message_Queue delete _queue; + delete _messageQueue; TC_LOG_INFO("sql.driver", "All connections on DatabasePool '%s' closed.", GetDatabaseName()); @@ -520,6 +523,7 @@ class DatabaseWorkerPool IDX_SIZE }; + ACE_Message_Queue<ACE_SYNCH>* _messageQueue; //! Message Queue used by ACE_Activation_Queue ACE_Activation_Queue* _queue; //! Queue shared by async worker threads. std::vector< std::vector<T*> > _connections; uint32 _connectionCount[2]; //! Counter of MySQL connections; diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index bc46b87fa27..dd0a9d5fdf4 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -377,9 +377,19 @@ class ByteBuffer return *this; } - uint8 * contents() { return &_storage[0]; } + uint8 * contents() + { + if (_storage.empty()) + throw ByteBufferException(); + return &_storage[0]; + } - const uint8 *contents() const { return &_storage[0]; } + const uint8 *contents() const + { + if (_storage.empty()) + throw ByteBufferException(); + return &_storage[0]; + } size_t size() const { return _storage.size(); } bool empty() const { return _storage.empty(); } |