Fix warnings with gcc in release.

This commit is contained in:
joris 2012-03-04 11:41:12 +01:00
parent f87a28f927
commit 2c92649760
5 changed files with 74 additions and 68 deletions

View file

@ -8,7 +8,7 @@
* *
* Copyright (c) 2004, 2005 darkbits Js_./ * Copyright (c) 2004, 2005 darkbits Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa * Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m * _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S * .)j(] .d_/ '-( P . S
@ -171,6 +171,7 @@ namespace gcn
textX = getWidth() - 4; textX = getWidth() - 4;
break; break;
default: default:
textX = 0;
//throw GCN_EXCEPTION("Unknown alignment."); //throw GCN_EXCEPTION("Unknown alignment.");
assert(!"Unknown alignment."); assert(!"Unknown alignment.");
} }

View file

@ -8,7 +8,7 @@
* *
* Copyright (c) 2004, 2005 darkbits Js_./ * Copyright (c) 2004, 2005 darkbits Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa * Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m * _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S * .)j(] .d_/ '-( P . S
@ -98,7 +98,7 @@ namespace gcn
void Label::draw(Graphics* graphics) void Label::draw(Graphics* graphics)
{ {
int textX; int textX = 0;
int textY = getHeight() / 2 - getFont()->getHeight() / 2; int textY = getHeight() / 2 - getFont()->getHeight() / 2;
switch (getAlignment()) switch (getAlignment())

View file

@ -8,7 +8,7 @@
* *
* Copyright (c) 2004, 2005 darkbits Js_./ * Copyright (c) 2004, 2005 darkbits Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa * Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m * _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S * .)j(] .d_/ '-( P . S
@ -249,7 +249,7 @@ namespace gcn
drawContent(graphics); drawContent(graphics);
int textX; int textX = 0;
int textY; int textY;
textY = ((int)getTitleBarHeight() - getFont()->getHeight()) / 2; textY = ((int)getTitleBarHeight() - getFont()->getHeight()) / 2;
switch (getAlignment()) switch (getAlignment())

View file

@ -424,7 +424,6 @@ static void DrawUnitOn(CUnit &unit, int red_phase)
CUnitType *type; CUnitType *type;
Uint32 color; Uint32 color;
SDL_Color c; SDL_Color c;
int bpp;
if (Editor.Running || ReplayRevealMap || unit.IsVisible(*ThisPlayer)) { if (Editor.Running || ReplayRevealMap || unit.IsVisible(*ThisPlayer)) {
type = unit.Type; type = unit.Type;
@ -465,6 +464,7 @@ static void DrawUnitOn(CUnit &unit, int red_phase)
if (my + h0 >= UI.Minimap.H) { // clip bottom side if (my + h0 >= UI.Minimap.H) { // clip bottom side
h0 = UI.Minimap.H - my; h0 = UI.Minimap.H - my;
} }
int bpp = 0;
if (!UseOpenGL) { if (!UseOpenGL) {
bpp = MinimapSurface->format->BytesPerPixel; bpp = MinimapSurface->format->BytesPerPixel;
SDL_GetRGB(color, TheScreen->format, &c.r, &c.g, &c.b); SDL_GetRGB(color, TheScreen->format, &c.r, &c.g, &c.b);
@ -493,14 +493,8 @@ static void DrawUnitOn(CUnit &unit, int red_phase)
void CMinimap::Update() void CMinimap::Update()
{ {
static int red_phase; static int red_phase;
int red_phase_changed;
int mx;
int my;
int n;
int visiontype; // 0 unexplored, 1 explored, >1 visible.
int bpp;
red_phase_changed = red_phase != (int)((FrameCounter / FRAMES_PER_SECOND) & 1); int red_phase_changed = red_phase != (int)((FrameCounter / FRAMES_PER_SECOND) & 1);
if (red_phase_changed) { if (red_phase_changed) {
red_phase = !red_phase; red_phase = !red_phase;
} }
@ -513,12 +507,7 @@ void CMinimap::Update()
memset(MinimapSurfaceGL, 0, MinimapTextureWidth * MinimapTextureHeight * 4); memset(MinimapSurfaceGL, 0, MinimapTextureWidth * MinimapTextureHeight * 4);
} }
} }
const int bpp = (!UseOpenGL) ? MinimapSurface->format->BytesPerPixel : 0;
if (!UseOpenGL) {
bpp = MinimapSurface->format->BytesPerPixel;
} else {
bpp = 0;
}
// //
// Draw the terrain // Draw the terrain
@ -535,8 +524,10 @@ void CMinimap::Update()
SDL_LockSurface(MinimapSurface); SDL_LockSurface(MinimapSurface);
SDL_LockSurface(MinimapTerrainSurface); SDL_LockSurface(MinimapTerrainSurface);
} }
for (my = 0; my < H; ++my) { int visiontype; // 0 unexplored, 1 explored, >1 visible.
for (mx = 0; mx < W; ++mx) {
for (int my = 0; my < H; ++my) {
for (int mx = 0; mx < W; ++mx) {
if (ReplayRevealMap) { if (ReplayRevealMap) {
visiontype = 2; visiontype = 2;
} else { } else {
@ -558,8 +549,6 @@ void CMinimap::Update()
Video.MapRGB(0, 0, 0, 0); Video.MapRGB(0, 0, 0, 0);
} }
} }
} }
} }
@ -567,16 +556,14 @@ void CMinimap::Update()
SDL_UnlockSurface(MinimapTerrainSurface); SDL_UnlockSurface(MinimapTerrainSurface);
} }
// //
// Draw units on map // Draw units on map
// //
for (n = 0; n < NumUnits; ++n) { for (int n = 0; n < NumUnits; ++n) {
if (Units[n]->IsVisibleOnMinimap()) { if (Units[n]->IsVisibleOnMinimap()) {
DrawUnitOn(*Units[n], red_phase); DrawUnitOn(*Units[n], red_phase);
} }
} }
if (!UseOpenGL) { if (!UseOpenGL) {
SDL_UnlockSurface(MinimapSurface); SDL_UnlockSurface(MinimapSurface);
} }

View file

@ -360,10 +360,7 @@ static const char *icmsgsubtypenames[] = {
*/ */
static void NetworkSendRateLimitedClientMessage(CInitMessage *msg, unsigned long msecs) static void NetworkSendRateLimitedClientMessage(CInitMessage *msg, unsigned long msecs)
{ {
unsigned long now; const unsigned long now = GetTicks();
int n;
now = GetTicks();
if (now - NetLastPacketSent >= msecs) { if (now - NetLastPacketSent >= msecs) {
NetLastPacketSent = now; NetLastPacketSent = now;
if (msg->SubType == LastStateMsgType) { if (msg->SubType == LastStateMsgType) {
@ -372,8 +369,8 @@ static void NetworkSendRateLimitedClientMessage(CInitMessage *msg, unsigned long
NetStateMsgCnt = 0; NetStateMsgCnt = 0;
LastStateMsgType = msg->SubType; LastStateMsgType = msg->SubType;
} }
n = NetworkSendICMessage(NetworkServerIP, htons(NetworkServerPort), const int n = NetworkSendICMessage(NetworkServerIP, htons(NetworkServerPort), msg);
msg); UNUSED(n); // not used in release
if (!NetStateMsgCnt) { if (!NetStateMsgCnt) {
DebugPrint DebugPrint
("Sending Init Message (%s:%d): %d:%d(%d) %d.%d.%d.%d:%d\n" _C_ ("Sending Init Message (%s:%d): %d:%d(%d) %d.%d.%d.%d:%d\n" _C_
@ -488,6 +485,8 @@ void NetworkExitServerConnect()
if (Hosts[h].PlyNr) { if (Hosts[h].PlyNr) {
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
const int n = NetworkSendICMessage(Hosts[h].Host, Hosts[h].Port, &message); const int n = NetworkSendICMessage(Hosts[h].Host, Hosts[h].Port, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message ServerQuit: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message ServerQuit: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(Hosts[h].Host)) _C_ ntohs(Hosts[h].Port)); n _C_ NIPQUAD(ntohl(Hosts[h].Host)) _C_ ntohs(Hosts[h].Port));
} }
@ -1119,6 +1118,8 @@ void NetworkProcessServerRequest()
message.SubType = ICMAYT; // Probe for the client message.SubType = ICMAYT; // Probe for the client
message.MapUID = 0L; message.MapUID = 0L;
const int n = NetworkSendICMessage(Hosts[i].Host, Hosts[i].Port, &message); const int n = NetworkSendICMessage(Hosts[i].Host, Hosts[i].Port, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message AreYouThere: (%d) to %d.%d.%d.%d:%d (%ld:%ld)\n" _C_ DebugPrint("Sending InitReply Message AreYouThere: (%d) to %d.%d.%d.%d:%d (%ld:%ld)\n" _C_
n _C_ NIPQUAD(ntohl(Hosts[i].Host)) _C_ ntohs(Hosts[i].Port) _C_ n _C_ NIPQUAD(ntohl(Hosts[i].Host)) _C_ ntohs(Hosts[i].Port) _C_
FrameCounter _C_ (unsigned long)ServerSetupState.LastFrame[i]); FrameCounter _C_ (unsigned long)ServerSetupState.LastFrame[i]);
@ -1529,11 +1530,8 @@ static void ClientParseBadMap(const CInitMessage *)
*/ */
static void ServerParseHello(int h, const CInitMessage *msg) static void ServerParseHello(int h, const CInitMessage *msg)
{ {
int i, n;
CInitMessage message;
if (h == -1) { // it is a new client if (h == -1) { // it is a new client
for (i = 1; i < PlayerMax - 1; ++i) { for (int i = 1; i < PlayerMax - 1; ++i) {
// occupy first available slot // occupy first available slot
if (ServerSetupState.CompOpt[i] == 0) { if (ServerSetupState.CompOpt[i] == 0) {
if (Hosts[i].PlyNr == 0) { if (Hosts[i].PlyNr == 0) {
@ -1552,10 +1550,14 @@ static void ServerParseHello(int h, const CInitMessage *msg)
NetStates[h].State = ccs_connecting; NetStates[h].State = ccs_connecting;
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
} else { } else {
CInitMessage message;
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMGameFull; // Game is full - reject connnection message.SubType = ICMGameFull; // Game is full - reject connnection
message.MapUID = 0L; message.MapUID = 0L;
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message GameFull: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message GameFull: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
return; return;
@ -1563,13 +1565,15 @@ static void ServerParseHello(int h, const CInitMessage *msg)
} }
// this code path happens until client sends waiting (= has received this message) // this code path happens until client sends waiting (= has received this message)
ServerSetupState.LastFrame[h] = FrameCounter; ServerSetupState.LastFrame[h] = FrameCounter;
CInitMessage message;
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMWelcome; // Acknowledge: Client is welcome message.SubType = ICMWelcome; // Acknowledge: Client is welcome
message.u.Hosts[0].PlyNr = htons(h); // Host array slot number message.u.Hosts[0].PlyNr = htons(h); // Host array slot number
strncpy_s(message.u.Hosts[0].PlyName, sizeof(message.u.Hosts[0].PlyName), strncpy_s(message.u.Hosts[0].PlyName, sizeof(message.u.Hosts[0].PlyName),
Parameters::Instance.LocalPlayerName.c_str(), _TRUNCATE); // Name of server player Parameters::Instance.LocalPlayerName.c_str(), _TRUNCATE); // Name of server player
message.MapUID = 0L; message.MapUID = 0L;
for (i = 1; i < PlayerMax - 1; ++i) { // Info about other clients for (int i = 1; i < PlayerMax - 1; ++i) { // Info about other clients
if (i != h) { if (i != h) {
if (Hosts[i].PlyNr) { if (Hosts[i].PlyNr) {
message.u.Hosts[i].Host = Hosts[i].Host; message.u.Hosts[i].Host = Hosts[i].Host;
@ -1583,7 +1587,9 @@ static void ServerParseHello(int h, const CInitMessage *msg)
} }
} }
} }
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message Welcome: (%d) [PlyNr: %d] to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message Welcome: (%d) [PlyNr: %d] to %d.%d.%d.%d:%d\n" _C_
n _C_ h _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ h _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1601,9 +1607,6 @@ static void ServerParseHello(int h, const CInitMessage *msg)
*/ */
static void ServerParseResync(const int h) static void ServerParseResync(const int h)
{ {
int i;
int n;
CInitMessage message;
ServerSetupState.LastFrame[h] = FrameCounter; ServerSetupState.LastFrame[h] = FrameCounter;
switch (NetStates[h].State) { switch (NetStates[h].State) {
@ -1614,12 +1617,14 @@ static void ServerParseResync(const int h)
NetStates[h].State = ccs_synced; NetStates[h].State = ccs_synced;
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
/* Fall through */ /* Fall through */
case ccs_synced: case ccs_synced: {
CInitMessage message;
// this code path happens until client falls back to ICMWaiting // this code path happens until client falls back to ICMWaiting
// (indicating Resync has completed) // (indicating Resync has completed)
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMResync; message.SubType = ICMResync;
for (i = 1; i < PlayerMax - 1; ++i) { // Info about other clients for (int i = 1; i < PlayerMax - 1; ++i) { // Info about other clients
if (i != h) { if (i != h) {
if (Hosts[i].PlyNr) { if (Hosts[i].PlyNr) {
message.u.Hosts[i].Host = Hosts[i].Host; message.u.Hosts[i].Host = Hosts[i].Host;
@ -1633,7 +1638,9 @@ static void ServerParseResync(const int h)
} }
} }
} }
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message Resync: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message Resync: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1642,7 +1649,7 @@ static void ServerParseResync(const int h)
; ;
} }
break; break;
}
default: default:
DebugPrint("Server: ICMResync: Unhandled state %d Host %d\n" _C_ DebugPrint("Server: ICMResync: Unhandled state %d Host %d\n" _C_
NetStates[h].State _C_ h); NetStates[h].State _C_ h);
@ -1658,8 +1665,6 @@ static void ServerParseResync(const int h)
*/ */
static void ServerParseWaiting(const int h) static void ServerParseWaiting(const int h)
{ {
int i;
int n;
CInitMessage message; CInitMessage message;
// Don't leave uninitialized data at the end of message.u.MapPath, // Don't leave uninitialized data at the end of message.u.MapPath,
@ -1674,13 +1679,15 @@ static void ServerParseWaiting(const int h)
NetStates[h].State = ccs_connected; NetStates[h].State = ccs_connected;
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
/* Fall through */ /* Fall through */
case ccs_connected: case ccs_connected: {
// this code path happens until client acknowledges the map // this code path happens until client acknowledges the map
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMMap; // Send Map info to the client message.SubType = ICMMap; // Send Map info to the client
strncpy_s(message.u.MapPath, sizeof(message.u.MapPath), NetworkMapName.c_str(), NetworkMapName.size()); strncpy_s(message.u.MapPath, sizeof(message.u.MapPath), NetworkMapName.c_str(), NetworkMapName.size());
message.MapUID = htonl(Map.Info.MapUID); message.MapUID = htonl(Map.Info.MapUID);
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message Map: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message Map: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1689,10 +1696,11 @@ static void ServerParseWaiting(const int h)
; ;
} }
break; break;
}
case ccs_mapinfo: case ccs_mapinfo:
NetStates[h].State = ccs_synced; NetStates[h].State = ccs_synced;
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
for (i = 1; i < PlayerMax - 1; ++i) { for (int i = 1; i < PlayerMax - 1; ++i) {
if (i != h && Hosts[i].PlyNr) { if (i != h && Hosts[i].PlyNr) {
// Notify other clients // Notify other clients
NetStates[i].State = ccs_async; NetStates[i].State = ccs_async;
@ -1704,7 +1712,7 @@ static void ServerParseWaiting(const int h)
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
break; break;
case ccs_async: case ccs_async: {
// Server User has changed menu selection. This state is set by MENU code // Server User has changed menu selection. This state is set by MENU code
// OR we have received a new client/other client has changed data // OR we have received a new client/other client has changed data
@ -1714,7 +1722,9 @@ static void ServerParseWaiting(const int h)
message.SubType = ICMState; // Send new state info to the client message.SubType = ICMState; // Send new state info to the client
message.u.State = ServerSetupState; message.u.State = ServerSetupState;
message.MapUID = htonl(Map.Info.MapUID); message.MapUID = htonl(Map.Info.MapUID);
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1723,7 +1733,7 @@ static void ServerParseWaiting(const int h)
; ;
} }
break; break;
}
default: default:
DebugPrint("Server: ICMWaiting: Unhandled state %d Host %d\n" _C_ DebugPrint("Server: ICMWaiting: Unhandled state %d Host %d\n" _C_
NetStates[h].State _C_ h); NetStates[h].State _C_ h);
@ -1738,7 +1748,6 @@ static void ServerParseWaiting(const int h)
*/ */
static void ServerParseMap(const int h) static void ServerParseMap(const int h)
{ {
int n;
CInitMessage message; CInitMessage message;
ServerSetupState.LastFrame[h] = FrameCounter; ServerSetupState.LastFrame[h] = FrameCounter;
@ -1748,14 +1757,16 @@ static void ServerParseMap(const int h)
NetStates[h].State = ccs_mapinfo; NetStates[h].State = ccs_mapinfo;
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
/* Fall through */ /* Fall through */
case ccs_mapinfo: case ccs_mapinfo: {
// this code path happens until client acknoledges the state info // this code path happens until client acknoledges the state info
// by falling back to ICMWaiting with prev. State synced // by falling back to ICMWaiting with prev. State synced
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMState; // Send State info to the client message.SubType = ICMState; // Send State info to the client
message.u.State = ServerSetupState; message.u.State = ServerSetupState;
message.MapUID = htonl(Map.Info.MapUID); message.MapUID = htonl(Map.Info.MapUID);
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1764,6 +1775,7 @@ static void ServerParseMap(const int h)
; ;
} }
break; break;
}
default: default:
DebugPrint("Server: ICMMap: Unhandled state %d Host %d\n" _C_ DebugPrint("Server: ICMMap: Unhandled state %d Host %d\n" _C_
NetStates[h].State _C_ h); NetStates[h].State _C_ h);
@ -1779,8 +1791,6 @@ static void ServerParseMap(const int h)
*/ */
static void ServerParseState(const int h, const CInitMessage *msg) static void ServerParseState(const int h, const CInitMessage *msg)
{ {
int i;
int n;
CInitMessage message; CInitMessage message;
ServerSetupState.LastFrame[h] = FrameCounter; ServerSetupState.LastFrame[h] = FrameCounter;
@ -1798,20 +1808,22 @@ static void ServerParseState(const int h, const CInitMessage *msg)
// Add additional info usage here! // Add additional info usage here!
// Resync other clients (and us..) // Resync other clients (and us..)
for (i = 1; i < PlayerMax - 1; ++i) { for (int i = 1; i < PlayerMax - 1; ++i) {
if (Hosts[i].PlyNr) { if (Hosts[i].PlyNr) {
NetStates[i].State = ccs_async; NetStates[i].State = ccs_async;
} }
} }
/* Fall through */ /* Fall through */
case ccs_async: case ccs_async: {
// this code path happens until client acknoledges the state change reply // this code path happens until client acknoledges the state change reply
// by sending ICMResync // by sending ICMResync
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMState; // Send new state info to the client message.SubType = ICMState; // Send new state info to the client
message.u.State = ServerSetupState; message.u.State = ServerSetupState;
message.MapUID = htonl(Map.Info.MapUID); message.MapUID = htonl(Map.Info.MapUID);
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1820,6 +1832,7 @@ static void ServerParseState(const int h, const CInitMessage *msg)
; ;
} }
break; break;
}
default: default:
DebugPrint("Server: ICMState: Unhandled state %d Host %d\n" _C_ DebugPrint("Server: ICMState: Unhandled state %d Host %d\n" _C_
NetStates[h].State _C_ h); NetStates[h].State _C_ h);
@ -1834,7 +1847,6 @@ static void ServerParseState(const int h, const CInitMessage *msg)
*/ */
static void ServerParseGoodBye(const int h) static void ServerParseGoodBye(const int h)
{ {
int n;
CInitMessage message; CInitMessage message;
ServerSetupState.LastFrame[h] = FrameCounter; ServerSetupState.LastFrame[h] = FrameCounter;
@ -1844,12 +1856,14 @@ static void ServerParseGoodBye(const int h)
NetStates[h].MsgCnt = 0; NetStates[h].MsgCnt = 0;
NetStates[h].State = ccs_detaching; NetStates[h].State = ccs_detaching;
/* Fall through */ /* Fall through */
case ccs_detaching: case ccs_detaching: {
// this code path happens until client acknoledges the GoodBye // this code path happens until client acknoledges the GoodBye
// by sending ICMSeeYou; // by sending ICMSeeYou;
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMGoodBye; message.SubType = ICMGoodBye;
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message GoodBye: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message GoodBye: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
NetStates[h].MsgCnt++; NetStates[h].MsgCnt++;
@ -1858,6 +1872,7 @@ static void ServerParseGoodBye(const int h)
; ;
} }
break; break;
}
} }
} }
@ -1900,7 +1915,6 @@ static void ServerParseIAmHere(const int h)
*/ */
static int CheckVersions(const CInitMessage *msg) static int CheckVersions(const CInitMessage *msg)
{ {
int n;
CInitMessage message; CInitMessage message;
if (ntohl(msg->Stratagus) != StratagusVersion) { if (ntohl(msg->Stratagus) != StratagusVersion) {
@ -1915,7 +1929,9 @@ static int CheckVersions(const CInitMessage *msg)
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMEngineMismatch; // Stratagus engine version doesn't match message.SubType = ICMEngineMismatch; // Stratagus engine version doesn't match
message.MapUID = 0L; message.MapUID = 0L;
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message EngineMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message EngineMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
return -1; return -1;
@ -1933,7 +1949,9 @@ static int CheckVersions(const CInitMessage *msg)
message.Type = MessageInitReply; message.Type = MessageInitReply;
message.SubType = ICMProtocolMismatch; // Network protocol version doesn't match message.SubType = ICMProtocolMismatch; // Network protocol version doesn't match
message.MapUID = 0L; message.MapUID = 0L;
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message); const int n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
UNUSED(n); // unused in release
DebugPrint("Sending InitReply Message ProtocolMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_ DebugPrint("Sending InitReply Message ProtocolMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort)); n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
return -1; return -1;