aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp34
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h2
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp1
-rw-r--r--src/server/worldserver/Main.cpp59
4 files changed, 61 insertions, 35 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index b57b8b698ea..5cb8c1c4ef0 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -704,29 +704,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
{
if (e.GetScriptType() == SMART_SCRIPT_TYPE_CREATURE)
{
- uint32 entry = 0;
- if (e.entryOrGuid >= 0)
- entry = e.entryOrGuid;
- else
- {
- if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(uint32(abs(e.entryOrGuid))))
- entry = creatureData->id;
- }
-
- CreatureTextMap::const_iterator sList = sCreatureTextMgr->GetTextMap().find(entry);
- if (sList == sCreatureTextMgr->GetTextMap().end())
- {
- TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u could not find Text for Creature %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
- return false;
- }
-
- CreatureTextHolder const& textHolder = sList->second;
- CreatureTextHolder::const_iterator itr = textHolder.find(e.action.talk.textGroupID);
- if (itr == textHolder.end())
- {
- TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u could not find TextGroup %u for Creature %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.talk.textGroupID, entry);
+ if (!IsTextValid(e, e.action.talk.textGroupID))
return false;
- }
}
break;
}
@@ -1207,13 +1186,15 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return true;
}
-/*bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id) // unused
+bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id) // unused
{
bool error = false;
uint32 entry = 0;
+
if (e.entryOrGuid >= 0)
entry = uint32(e.entryOrGuid);
- else {
+ else
+ {
entry = uint32(abs(e.entryOrGuid));
CreatureData const* data = sObjectMgr->GetCreatureData(entry);
if (!data)
@@ -1224,15 +1205,18 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
else
entry = data->id;
}
+
if (!entry || !sCreatureTextMgr->TextExist(entry, uint8(id)))
error = true;
+
if (error)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u using non-existent Text id %d, skipped.", e.entryOrGuid, e.GetScriptType(), e.source_type, e.GetActionType(), id);
return false;
}
+
return true;
-}*/
+}
void SmartAIMgr::LoadHelperStores()
{
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 51105d5b433..bdd1dfc6ae0 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -1614,7 +1614,7 @@ class SmartAIMgr
return true;
}
- //bool IsTextValid(SmartScriptHolder const& e, uint32 id);
+ bool IsTextValid(SmartScriptHolder const& e, uint32 id);
// Helpers
void LoadHelperStores();
diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp
index cf80f21d290..645588c0bc5 100644
--- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp
@@ -165,6 +165,7 @@ class boss_prince_taldaram : public CreatureScript
{
Talk(SAY_VANISH);
DoCast(me, SPELL_VANISH);
+ me->SetInCombatState(true); // Prevents the boss from resetting
events.DelayEvents(500);
events.ScheduleEvent(EVENT_JUST_VANISHED, 500);
if (Unit* embraceTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index bd028069c62..6c93343b8de 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -88,6 +88,7 @@ bool StartDB();
void StopDB();
void WorldUpdateLoop();
void ClearOnlineAccounts();
+void ShutdownCLIThread(std::thread* cliThread);
void ShutdownThreadPool(std::vector<std::thread>& threadPool);
variables_map GetConsoleArguments(int argc, char** argv, std::string& cfg_file, std::string& cfg_service);
@@ -277,11 +278,26 @@ extern int main(int argc, char** argv)
TC_LOG_INFO("server.worldserver", "Halting process...");
+ ShutdownCLIThread(cliThread);
+
+ OpenSSLCrypto::threadsCleanup();
+
+ // 0 - normal shutdown
+ // 1 - shutdown at error
+ // 2 - restart command used, this code can be used by restarter for restart Trinityd
+
+ return World::GetExitCode();
+}
+
+void ShutdownCLIThread(std::thread* cliThread)
+{
if (cliThread != nullptr)
{
#ifdef _WIN32
+ // First try to cancel any I/O in the CLI thread
if (!CancelSynchronousIo(cliThread->native_handle()))
{
+ // if CancelSynchronousIo() fails, print the error and try with old way
DWORD errorCode = GetLastError();
LPSTR errorBuffer;
@@ -290,22 +306,47 @@ extern int main(int argc, char** argv)
if (!formatReturnCode)
errorBuffer = "Unknown error";
- TC_LOG_ERROR("server.worldserver", "Error cancelling I/O of CliThread, error code %u, detail: %s",
+ TC_LOG_DEBUG("server.worldserver", "Error cancelling I/O of CliThread, error code %u, detail: %s",
errorCode, errorBuffer);
LocalFree(errorBuffer);
+
+ // send keyboard input to safely unblock the CLI thread
+ INPUT_RECORD b[4];
+ HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
+ b[0].EventType = KEY_EVENT;
+ b[0].Event.KeyEvent.bKeyDown = TRUE;
+ b[0].Event.KeyEvent.uChar.AsciiChar = 'X';
+ b[0].Event.KeyEvent.wVirtualKeyCode = 'X';
+ b[0].Event.KeyEvent.wRepeatCount = 1;
+
+ b[1].EventType = KEY_EVENT;
+ b[1].Event.KeyEvent.bKeyDown = FALSE;
+ b[1].Event.KeyEvent.uChar.AsciiChar = 'X';
+ b[1].Event.KeyEvent.wVirtualKeyCode = 'X';
+ b[1].Event.KeyEvent.wRepeatCount = 1;
+
+ b[2].EventType = KEY_EVENT;
+ b[2].Event.KeyEvent.bKeyDown = TRUE;
+ b[2].Event.KeyEvent.dwControlKeyState = 0;
+ b[2].Event.KeyEvent.uChar.AsciiChar = '\r';
+ b[2].Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
+ b[2].Event.KeyEvent.wRepeatCount = 1;
+ b[2].Event.KeyEvent.wVirtualScanCode = 0x1c;
+
+ b[3].EventType = KEY_EVENT;
+ b[3].Event.KeyEvent.bKeyDown = FALSE;
+ b[3].Event.KeyEvent.dwControlKeyState = 0;
+ b[3].Event.KeyEvent.uChar.AsciiChar = '\r';
+ b[3].Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
+ b[3].Event.KeyEvent.wVirtualScanCode = 0x1c;
+ b[3].Event.KeyEvent.wRepeatCount = 1;
+ DWORD numb;
+ WriteConsoleInput(hStdIn, b, 4, &numb);
}
#endif
cliThread->join();
delete cliThread;
}
-
- OpenSSLCrypto::threadsCleanup();
-
- // 0 - normal shutdown
- // 1 - shutdown at error
- // 2 - restart command used, this code can be used by restarter for restart Trinityd
-
- return World::GetExitCode();
}
void ShutdownThreadPool(std::vector<std::thread>& threadPool)