Skip to content

Commit

Permalink
Merge branch 'master' into qt
Browse files Browse the repository at this point in the history
Conflicts:
	macosx/Warzone.xcodeproj/project.pbxproj
	tests/astartest.c
  • Loading branch information
perim committed Jan 30, 2011
2 parents 9344462 + 02fe1d9 commit 27741a2
Show file tree
Hide file tree
Showing 32 changed files with 509 additions and 641 deletions.
5 changes: 2 additions & 3 deletions COPYING.NONGPL
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ data/texpages/bdrops/backdrop0.png
data/texpages/bdrops/backdrop1.png
data/texpages/bdrops/backdrop2.png
- CC BY SA 3.0 - Copyright (c) 2007-2008 "B. V. Edwards" <cathuria>
data/texpages/bdrops/backdrop4.png
data/texpages/bdrops/backdrop6.png
- CC0 - Copyright (c) 2010 jorzi
- CC0 - Copyright (c) 2010-2011 jorzi
data/base/texpages/page-25-sky-urban.png
- CC BY 2.0 - Adapted from a photo Copyright (c) 2006 Mark A. Vargas
data/mods/global/newst_tiles/
- CC BY SA 3.0 - Copyright (c) 1999-2004 N.E.W.S.T., permission by "Frank Lamboy" <rman>
lib/framework/tagfile.*
- Public Domain
lib/netplay/miniupnpc/*
Expand Down
2 changes: 1 addition & 1 deletion data/base/structs/radarsensor.pie
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PIE 3
TYPE 0
TYPE 200
TEXTURE 0 page-59-more-weapons.png 256 256
LEVELS 1
LEVEL 1
Expand Down
Binary file modified data/base/texpages/bdrops/backdrop4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/framework/wzglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
#endif

// Tell Flex not to include unistd when it is not present.
#ifndef HAVE_UNISTD_H
#if !defined(HAVE_UNISTD_H) && !defined(YY_NO_UNISTD_H)
# define YY_NO_UNISTD_H
#endif

Expand Down
114 changes: 62 additions & 52 deletions lib/netplay/netplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ static void NET_DestroyPlayer(unsigned int index)
{
// Update player count in the lobby by disconnecting
// and reconnecting
NETregisterServer(0);
NETregisterServer(1);
NETregisterServer(2);
}
}
NET_InitPlayer(index, false); // reinitialize
Expand Down Expand Up @@ -733,6 +732,7 @@ static bool NETsendGAMESTRUCT(Socket* sock, const GAMESTRUCT* ourgamestruct)
*(uint32_t*)buffer = htonl(ourgamestruct->future4);
buffer += sizeof(uint32_t);

debug(LOG_NET, "sending GAMESTRUCT, size: %u", (unsigned int)sizeof(buf));

// Send over the GAMESTRUCT
result = writeAll(sock, buf, sizeof(buf));
Expand All @@ -748,8 +748,6 @@ static bool NETsendGAMESTRUCT(Socket* sock, const GAMESTRUCT* ourgamestruct)
return false;
}

debug(LOG_NET, "sending GAMESTRUCT");

return true;
}

Expand Down Expand Up @@ -2004,7 +2002,7 @@ static ssize_t readLobbyResponse(Socket* sock, unsigned int timeout)
if (lobbyStatusCode / 100 != 2) // Check whether status code is 2xx (success)
{
debug(LOG_ERROR, "Lobby error (%u): %s", (unsigned int)lobbyStatusCode, NetPlay.MOTD);
return SOCKET_ERROR;
return received;
}

debug(LOG_NET, "Lobby success (%u): %s", (unsigned int)lobbyStatusCode, NetPlay.MOTD);
Expand All @@ -2031,9 +2029,8 @@ static ssize_t readLobbyResponse(Socket* sock, unsigned int timeout)

static void NETregisterServer(int state)
{
static Socket* rs_socket[2] = {NULL, NULL};
static Socket* rs_socket = NULL;
static int registered = 0;
unsigned int i;

if (server_not_there)
{
Expand All @@ -2044,9 +2041,20 @@ static void NETregisterServer(int state)
{
switch(state)
{
// Update player counts
case 2:
{
if (!NETsendGAMESTRUCT(rs_socket, &gamestruct))
{
socketClose(rs_socket);
rs_socket = NULL;
}
}
break;

// Register a game with the lobby
case 1:
{
bool succesful = false;
uint32_t gameId = 0;
SocketAddress *const hosts = resolveHost(masterserver_name, masterserver_port);

Expand All @@ -2060,11 +2068,19 @@ static void NETregisterServer(int state)
return;
}

socketArrayClose(rs_socket, ARRAY_SIZE(rs_socket)); // Make sure there aren't any leftover sockets.
socketArrayOpen(rs_socket, ARRAY_SIZE(rs_socket), hosts, 15000);
// Close an existing socket.
if (rs_socket != NULL)
{
socketClose(rs_socket);
rs_socket = NULL;
}

// try each address from resolveHost until we successfully connect.
rs_socket = socketOpenAny(hosts, 1500);
deleteSocketAddress(hosts);

if (rs_socket[0] == NULL)
// No address succeeded.
if (rs_socket == NULL)
{
debug(LOG_ERROR, "Cannot connect to masterserver \"%s:%d\": %s", masterserver_name, masterserver_port, strSockError(getSockErr()));
free(NetPlay.MOTD);
Expand All @@ -2075,69 +2091,62 @@ static void NETregisterServer(int state)
}

// Get a game ID
if (writeAll(rs_socket[0], "gaId", sizeof("gaId")) == SOCKET_ERROR
|| readAll(rs_socket[0], &gameId, sizeof(gameId), 10000) != sizeof(gameId))
if (writeAll(rs_socket, "gaId", sizeof("gaId")) == SOCKET_ERROR
|| readAll(rs_socket, &gameId, sizeof(gameId), 10000) != sizeof(gameId))
{
free(NetPlay.MOTD);
if (asprintf(&NetPlay.MOTD, "Failed to retrieve a game ID: %s", strSockError(getSockErr())) == -1)
NetPlay.MOTD = NULL;
debug(LOG_ERROR, "%s", NetPlay.MOTD);

// The sockets have been invalidated, so get rid of it. (using them now may cause SIGPIPE).
socketArrayClose(rs_socket, ARRAY_SIZE(rs_socket));
// The socket has been invalidated, so get rid of it. (using them now may cause SIGPIPE).
socketClose(rs_socket);
rs_socket = NULL;
server_not_there = true;
return;
}

gamestruct.gameId = ntohl(gameId);
debug(LOG_NET, "Using game ID: %u", (unsigned int)gamestruct.gameId);

// Register our game with the server for all available address families
for (i = 0; i < ARRAY_SIZE(rs_socket); ++i)
// Register our game with the server
if (writeAll(rs_socket, "addg", sizeof("addg")) == SOCKET_ERROR
// and now send what the server wants
|| !NETsendGAMESTRUCT(rs_socket, &gamestruct))
{
if (rs_socket[i] == NULL)
continue;

if (writeAll(rs_socket[i], "addg", sizeof("addg")) == SOCKET_ERROR
// and now send what the server wants
|| !NETsendGAMESTRUCT(rs_socket[i], &gamestruct))
{
debug(LOG_ERROR, "Failed to register game with server: %s", strSockError(getSockErr()));
socketClose(rs_socket[i]);
rs_socket[i] = NULL;
}
debug(LOG_ERROR, "Failed to register game with server: %s", strSockError(getSockErr()));
socketClose(rs_socket);
rs_socket = NULL;
}

// Get the return codes
for (i = 0; i < ARRAY_SIZE(rs_socket); ++i)
if (readLobbyResponse(rs_socket, NET_TIMEOUT_DELAY) == SOCKET_ERROR)
{
if (rs_socket[i] == NULL)
continue;

if (readLobbyResponse(rs_socket[i], NET_TIMEOUT_DELAY) == SOCKET_ERROR)
{
socketClose(rs_socket[i]);
rs_socket[i] = NULL;
continue;
}

succesful = true;
}

if (!succesful)
{
server_not_there = true;
socketClose(rs_socket);
rs_socket = NULL;
return;
}

// Preserves another register
registered=state;
}
break;

// Unregister the game (close the socket)
case 0:
// we don't need this anymore, so clean up
socketArrayClose(rs_socket, ARRAY_SIZE(rs_socket));
{
if (rs_socket != NULL)
{
// we don't need this anymore, so clean up
socketClose(rs_socket);
rs_socket = NULL;
server_not_there = true;
}

// Preserves another unregister
registered=state;
}
break;
}
registered=state;
}
}

Expand Down Expand Up @@ -2431,9 +2440,10 @@ static void NETallowJoining(void)
}
NETfixDuplicatePlayerNames();

// Make sure the master server gets updated by disconnecting from it
// NETallowJoining will reconnect
NETregisterServer(0);
// Send the updated GAMESTRUCT to the masterserver
NETregisterServer(2);


// reset flags for new players
NetPlay.players[index].wzFile.isCancelled = false;
NetPlay.players[index].wzFile.isSending = false;
Expand Down
53 changes: 0 additions & 53 deletions lib/netplay/nettypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,56 +670,3 @@ void NETnetMessage(NetMessage const **message)
return;
}
}

/*typedef enum
{
test_a,
test_b,
} test_enum;*/

static void NETcoder(PACKETDIR dir)
{
(void)dir;
/* static const char original[] = "THIS IS A TEST STRING";
char str[sizeof(original)];
BOOL b = true;
uint32_t u32 = 32;
uint16_t u16 = 16;
uint8_t u8 = 8;
int32_t i32 = -32;
int16_t i16 = -16;
int8_t i8 = -8;
test_enum te = test_b;
sstrcpy(str, original);
if (dir == PACKET_ENCODE)
NETbeginEncode(0, 0);
else
NETbeginDecode(0, 0);
NETbool(&b); assert(b == true);
NETuint32_t(&u32); assert(u32 == 32);
NETuint16_t(&u16); assert(u16 == 16);
NETuint8_t(&u8); assert(u8 == 8);
NETint32_t(&i32); assert(i32 == -32);
NETint16_t(&i16); assert(i16 == -16);
NETint8_t(&i8); assert(i8 == -8);
NETstring(str, sizeof(str)); assert(strncmp(str, original, sizeof(str) - 1) == 0);
NETenum(&te); assert(te == test_b);*/
}

void NETtest()
{
/*NETMSG cmp;
memset(&cmp, 0, sizeof(cmp));
memset(&NetMsg, 0, sizeof(NetMsg));
*/
NETcoder(PACKET_ENCODE);
/*
memcpy(&cmp, &NetMsg, sizeof(cmp));
NETcoder(PACKET_DECODE);
ASSERT(memcmp(&cmp, &NetMsg, sizeof(cmp)) == 0, "nettypes unit test failed");
fprintf(stdout, "\tNETtypes self-test: PASSED\n");*/
ASSERT(false, "nettypes test disabled, since it doesn't compile anymore.");
}
2 changes: 0 additions & 2 deletions lib/netplay/nettypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,4 @@ static inline void NETauto(Rotation *vp) { NETRotation(vp); }

void NETnetMessage(NetMessage const **message); ///< If decoding, must delete the NETMESSAGE.

void NETtest(void);

#endif
7 changes: 3 additions & 4 deletions lib/sound/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,16 @@ void playListTest()
PlayList_Quit();
PlayList_Init();
PlayList_Read("music");
if (numSongs != 2)
if (numSongs != 3)
{
debug(LOG_ERROR, "Use the default playlist for selftest!");
fprintf(stderr, "Use the default playlist for selftest!");
}
cur = PlayList_CurrentSong();
next = PlayList_NextSong();
assert(cur != NULL && next != NULL && cur != next);
next = PlayList_NextSong();
assert(cur == next); // loop around
assert(songList);
assert(numSongs == 2);
assert(numSongs == 3);
}
fprintf(stdout, "\tPlaylist self-test: PASSED\n");
}
Loading

0 comments on commit 27741a2

Please sign in to comment.