Fix: Data races on cursor state in OpenGL backends
[openttd-github.git] / src / network / core / core.cpp
blob0aeb9c65ce7dac3716b375c6a1f1661217270cea
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD 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, version 2.
4 * OpenTTD 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.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /**
9 * @file core.cpp Functions used to initialize/shut down the core network
12 #include "../../stdafx.h"
13 #include "../../debug.h"
14 #include "os_abstraction.h"
15 #include "packet.h"
17 #include "../../safeguards.h"
20 /**
21 * Initializes the network core (as that is needed for some platforms
22 * @return true if the core has been initialized, false otherwise
24 bool NetworkCoreInitialize()
26 /* Let's load the network in windows */
27 #ifdef _WIN32
29 WSADATA wsa;
30 DEBUG(net, 3, "[core] loading windows socket library");
31 if (WSAStartup(MAKEWORD(2, 0), &wsa) != 0) {
32 DEBUG(net, 0, "[core] WSAStartup failed, network unavailable");
33 return false;
36 #endif /* _WIN32 */
38 return true;
41 /**
42 * Shuts down the network core (as that is needed for some platforms
44 void NetworkCoreShutdown()
46 #if defined(_WIN32)
47 WSACleanup();
48 #endif
52 /**
53 * Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet
54 * @param p the packet to write the data to
55 * @param grf the GRFIdentifier to serialize
57 void NetworkSocketHandler::SendGRFIdentifier(Packet *p, const GRFIdentifier *grf)
59 uint j;
60 p->Send_uint32(grf->grfid);
61 for (j = 0; j < sizeof(grf->md5sum); j++) {
62 p->Send_uint8 (grf->md5sum[j]);
66 /**
67 * Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet
68 * @param p the packet to read the data from
69 * @param grf the GRFIdentifier to deserialize
71 void NetworkSocketHandler::ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf)
73 uint j;
74 grf->grfid = p->Recv_uint32();
75 for (j = 0; j < sizeof(grf->md5sum); j++) {
76 grf->md5sum[j] = p->Recv_uint8();