aboutsummaryrefslogtreecommitdiff
path: root/games/spring/files/patch-boost-1.66
blob: 69ac45e63cebb5a9d83f2517b6a50a30f19baf5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
https://github.com/spring/spring/commit/a61970779994
https://github.com/spring/spring/commit/f2f84f38e04a
https://github.com/spring/spring/commit/318c003c7273
https://github.com/spring/spring/commit/5048e2a3446c

--- rts/Net/AutohostInterface.cpp.orig	2014-10-07 20:09:51 UTC
+++ rts/Net/AutohostInterface.cpp
@@ -116,68 +116,60 @@ std::string AutohostInterface::TryBindSocket(
 			const std::string& remoteIP, int remotePort,
 			const std::string& localIP, int localPort)
 {
-	std::string errorMsg = "";
+	std::string errorMsg;
 
 	ip::address localAddr;
 	ip::address remoteAddr;
 	boost::system::error_code err;
+
 	try {
 		socket.open(ip::udp::v6(), err); // test IP v6 support
+
 		const bool supportsIPv6 = !err;
 
 		remoteAddr = netcode::WrapIP(remoteIP, &err);
-		if (err) {
+
+		if (err)
 			throw std::runtime_error("Failed to parse address " + remoteIP + ": " + err.message());
-		}
 
-		if (!supportsIPv6 && remoteAddr.is_v6()) {
+		if (!supportsIPv6 && remoteAddr.is_v6())
 			throw std::runtime_error("IP v6 not supported, can not use address " + remoteAddr.to_string());
-		}
 
 		if (localIP.empty()) {
 			// use the "any" address as local "from"
 			if (remoteAddr.is_v6()) {
 				localAddr = ip::address_v6::any();
 			} else {
-				if (supportsIPv6) {
-					socket.close();
-				}
+				socket.close();
 				socket.open(ip::udp::v4());
+
 				localAddr = ip::address_v4::any();
 			}
 		} else {
 			localAddr = netcode::WrapIP(localIP, &err);
-			if (err) {
+
+			if (err)
 				throw std::runtime_error("Failed to parse local IP " + localIP + ": " + err.message());
-			}
-			if (localAddr.is_v6() != remoteAddr.is_v6()) {
+
+			if (localAddr.is_v6() != remoteAddr.is_v6())
 				throw std::runtime_error("Local IP " + localAddr.to_string() + " and remote IP " + remoteAddr.to_string() + " are IP v4/v6 mixed");
-			}
 		}
 
 		socket.bind(ip::udp::endpoint(localAddr, localPort));
-
-		boost::asio::socket_base::non_blocking_io command(true);
-		socket.io_control(command);
-
-		// A similar, slighly less verbose message is already in GameServer
-		//LOG("Connecting (UDP) to IP (v%i) %s Port %i",
-		//		(remoteAddr.is_v6() ? 6 : 4), remoteAddr.c_str(), remotePort);
+		socket.non_blocking(true);
 		socket.connect(ip::udp::endpoint(remoteAddr, remotePort));
-	} catch (const std::runtime_error& ex) { // includes also boost::system::system_error, as it inherits from runtime_error
+	} catch (const std::runtime_error& ex) {
+		// also includes asio::system_error, inherits from runtime_error
 		socket.close();
 		errorMsg = ex.what();
-		if (errorMsg.empty()) {
+
+		if (errorMsg.empty())
 			errorMsg = "Unknown problem";
-		}
 	}
 
 	return errorMsg;
 }
 
-AutohostInterface::~AutohostInterface()
-{
-}
 
 void AutohostInterface::SendStart()
 {
--- rts/Net/AutohostInterface.h.orig	2014-10-07 20:09:51 UTC
+++ rts/Net/AutohostInterface.h
@@ -28,7 +28,7 @@ class AutohostInterface (public)
 	 */
 	AutohostInterface(const std::string& remoteIP, int remotePort,
 			const std::string& localIP = "", int localPort = 0);
-	virtual ~AutohostInterface();
+	virtual ~AutohostInterface() {}
 
 	bool IsInitialized() const { return initialized; }
 
--- rts/System/FileSystem/Archives/SevenZipArchive.cpp.orig	2014-10-07 20:09:51 UTC
+++ rts/System/FileSystem/Archives/SevenZipArchive.cpp
@@ -3,7 +3,6 @@
 #include "SevenZipArchive.h"
 
 #include <algorithm>
-#include <boost/system/error_code.hpp>
 #include <stdexcept>
 #include <string.h> //memcpy
 
@@ -86,7 +85,7 @@ IArchive* CSevenZipArchiveFactory::DoCreateArchive(con
 	return new CSevenZipArchive(filePath);
 }
 
-const char* CSevenZipArchive::GetErrorStr(int err)
+static inline const char* GetErrorStr(int err)
 {
 	switch(err) {
 	case SZ_OK:
@@ -108,6 +107,27 @@ const char* CSevenZipArchive::GetErrorStr(int err)
 }
 
 
+static inline std::string GetSystemErrorStr(WRes wres)
+{
+#ifdef USE_WINDOWS_FILE
+	LPSTR messageBuffer = nullptr;
+	size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+								 NULL, wres, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
+
+	std::string errorstr(messageBuffer, size);
+
+	//Free the buffer.
+	LocalFree(messageBuffer);
+#else
+	std::string errorstr(strerror(wres));
+#endif
+
+	return errorstr;
+}
+
+
+
+
 CSevenZipArchive::CSevenZipArchive(const std::string& name):
 	CBufferedArchive(name, false),
 	blockIndex(0xFFFFFFFF),
@@ -126,9 +146,8 @@ CSevenZipArchive::CSevenZipArchive(const std::string& 
 
 	WRes wres = InFile_Open(&archiveStream.file, name.c_str());
 	if (wres) {
-		boost::system::error_code e(wres, boost::system::get_system_category());
 		LOG_L(L_ERROR, "Error opening \"%s\": %s (%i)",
-				name.c_str(), e.message().c_str(), e.value());
+				name.c_str(), GetSystemErrorStr(wres).c_str(), (int) wres);
 		return;
 	}
 
--- rts/System/FileSystem/Archives/SevenZipArchive.h.orig	2014-10-07 20:09:51 UTC
+++ rts/System/FileSystem/Archives/SevenZipArchive.h
@@ -95,7 +95,6 @@ class CSevenZipArchive : public CBufferedArchive (priv
 		int packedSize;
 	};
 	int GetFileName(const CSzArEx* db, int i);
-	const char* GetErrorStr(int res);
 
 	std::vector<FileData> fileData;
 	UInt16 *tempBuf;
--- rts/System/Net/UDPListener.cpp.orig	2014-10-07 20:09:51.000000000 +0000
+++ rts/System/Net/UDPListener.cpp
@@ -34,8 +34,7 @@ UDPListener::UDPListener(int port, const std::string& 
 	const std::string err = TryBindSocket(port, &socket, ip);
 
 	if (err.empty()) {
-		boost::asio::socket_base::non_blocking_io socketCommand(true);
-		socket->io_control(socketCommand);
+		socket->non_blocking(true);
 
 		mySocket = socket;
 		SetAcceptingConnections(true);