Index: source/network/NetMessage.cpp
===================================================================
--- source/network/NetMessage.cpp
+++ source/network/NetMessage.cpp
@@ -21,6 +21,7 @@
#include "ps/CLogger.h"
#include "ps/Game.h"
+#include "ps/BackportC++23.h"
#include "simulation2/Simulation2.h"
#undef ALLNETMSGS_DONT_CREATE_NMTS
@@ -216,7 +217,8 @@
break;
default:
- LOGERROR("CNetMessageFactory::CreateMessage(): Unknown message type '%d' received", header.GetType());
+ LOGERROR("CNetMessageFactory::CreateMessage(): Unknown message type '%d' received",
+ PS::backport::to_underlying(header.GetType()));
break;
}
Index: source/ps/BackportC++23.h
===================================================================
--- /dev/null
+++ source/ps/BackportC++23.h
@@ -0,0 +1,41 @@
+/* Copyright (C) 2023 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#ifndef INCLUDED_BACKPORTCPP23
+#define INCLUDED_BACKPORTCPP23
+
+#include
+
+/**
+ * An implementation of `std::to_underlying` (C++23) as we don't support the
+ * original one yet. The naming intentionally follows the standard to make
+ * the future replacement easier with less blame changing.
+ * TODO: remove as soon as std::to_underlying become available.
+ */
+namespace PS
+{
+namespace backport
+{
+template
+std::underlying_type_t to_underlying(Enum e)
+{
+ return static_cast>(e);
+}
+}
+}
+
+#endif // INCLUDED_BACKPORTCPP23
Index: source/simulation2/serialization/BinarySerializer.cpp
===================================================================
--- source/simulation2/serialization/BinarySerializer.cpp
+++ source/simulation2/serialization/BinarySerializer.cpp
@@ -22,6 +22,7 @@
#include "lib/alignment.h"
#include "lib/utf8.h"
#include "ps/CLogger.h"
+#include "ps/BackportC++23.h"
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptRequest.h"
@@ -52,7 +53,8 @@
case js::Scalar::Uint8Clamped:
return SCRIPT_TYPED_ARRAY_UINT8_CLAMPED;
default:
- LOGERROR("Cannot serialize unrecognized typed array view: %d", arrayType);
+ LOGERROR("Cannot serialize unrecognized typed array view: %d",
+ PS::backport::to_underlying(arrayType));
throw PSERROR_Serialize_InvalidScriptValue();
}
}