Update ifdef condition for MCST-LCC compiler (E2K)
[0ad.git] / source / tools / atlas / GameInterface / MessagePasserImpl.cpp
blobecd4a138840d6d11cc5784e744c8fc7dd873fb0c
1 /* Copyright (C) 2019 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
18 #include "precompiled.h"
20 #include <cstdio>
22 #include "MessagePasserImpl.h"
23 #include "Messages.h"
24 #include "Handlers/MessageHandler.h"
26 #include "lib/timer.h"
27 #include "ps/CLogger.h"
29 using namespace AtlasMessage;
31 double last_user_activity = 0.0;
33 void MessagePasserImpl::Add(IMessage* msg)
35 ENSURE(msg);
36 ENSURE(msg->GetType() == IMessage::Message);
38 if (m_Trace)
39 debug_printf("%8.3f add message: %s\n", timer_Time(), msg->GetName());
41 msgHandlers::const_iterator it = GetMsgHandlers().find(msg->GetName());
42 if (it != GetMsgHandlers().end())
44 it->second(msg);
46 else
48 debug_warn(L"Unrecognised message");
49 // CLogger might not be initialised, but this error will be sent
50 // to the debug output window anyway so people can still see it
51 LOGERROR("Unrecognised message (%s)", msg->GetName());
53 // Delete the object - we took ownership of it.
54 AtlasMessage::ShareableDelete(msg);
57 void MessagePasserImpl::Query(QueryMessage* msg, void(* UNUSED(timeoutCallback) )())
59 ENSURE(msg);
60 ENSURE(msg->GetType() == IMessage::Query);
62 if (m_Trace)
63 debug_printf("%8.3f add query: %s\n", timer_Time(), msg->GetName());
65 msgHandlers::const_iterator it = GetMsgHandlers().find(msg->GetName());
66 if (it != GetMsgHandlers().end())
68 it->second(msg);
70 else
72 debug_warn(L"Unrecognised message");
73 // CLogger might not be initialised, but this error will be sent
74 // to the debug output window anyway so people can still see it
75 LOGERROR("Unrecognised message (%s)", msg->GetName());
79 void MessagePasserImpl::SetTrace(bool t)
81 m_Trace = t;