Skip to content

Commit

Permalink
Add / fix debug lines.
Browse files Browse the repository at this point in the history
Clear structure when host restarts game.

Fixes ticket:2205
  • Loading branch information
buginator committed Oct 23, 2010
1 parent e98e49f commit cad197a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 24 deletions.
7 changes: 4 additions & 3 deletions lib/netplay/netplay.c
Expand Up @@ -3476,7 +3476,7 @@ static void NETallowJoining(void)
}
else if (strcmp(buffer, "join") == 0)
{
debug(LOG_NET, "cmd: join. Sending GAMESTRUCT");
debug(LOG_NET, "cmd: join. Sending GAMESTRUCT to %u", i);
if (!NETsendGAMESTRUCT(tmp_socket[i], &gamestruct))
{
debug(LOG_ERROR, "Failed to respond (with GAMESTRUCT) to 'join' command, socket (%p) error: %s", tmp_socket[i], strSockError(getSockErr()));
Expand Down Expand Up @@ -3908,17 +3908,18 @@ BOOL NETfindGame(void)
return false;
}

debug(LOG_NET, "receiving info on %u game(s)", (unsigned int)gamesavailable);
debug(LOG_NET, "receiving info on %u game(s)", gamesavailable);

// Clear old games from list.
memset(NetPlay.games, 0x00, sizeof(NetPlay.games));

while (gamecount < gamesavailable)
{
debug(LOG_NET, "trying to retrieve GAMESTRUCT from %u", gamecount);
// Attempt to receive a game description structure
if (!NETrecvGAMESTRUCT(&NetPlay.games[gamecount]))
{
debug(LOG_NET, "only %u game(s) received", (unsigned int)gamecount);
debug(LOG_NET, "only %u game(s) received", gamecount);
// If we fail, success depends on the amount of games that we've read already
freeaddrinfo(hosts);
return gamecount;
Expand Down
61 changes: 40 additions & 21 deletions src/multiint.c
Expand Up @@ -2608,35 +2608,54 @@ static void processMultiopWidgets(UDWORD id)
break;

case MULTIOP_HOST:
debug(LOG_NET, "MULTIOP_HOST enabled");
sstrcpy(game.name, widgGetString(psWScreen, MULTIOP_GNAME)); // game name
sstrcpy(sPlayer, widgGetString(psWScreen, MULTIOP_PNAME)); // pname
sstrcpy(game.map, widgGetString(psWScreen, MULTIOP_MAP)); // add the name
{
MULTISTRUCTLIMITS *plimits = NULL;
int limitcount = 0;

resetReadyStatus(false);
resetDataHash();
removeWildcards((char*)sPlayer);
debug(LOG_NET, "MULTIOP_HOST enabled (trying to host a game)");
sstrcpy(game.name, widgGetString(psWScreen, MULTIOP_GNAME)); // game name
sstrcpy(sPlayer, widgGetString(psWScreen, MULTIOP_PNAME)); // pname
sstrcpy(game.map, widgGetString(psWScreen, MULTIOP_MAP)); // add the name

if (!hostCampaign((char*)game.name,(char*)sPlayer))
{
addConsoleMessage(_("Sorry! Failed to host the game."), DEFAULT_JUSTIFY, SYSTEM_MESSAGE);
break;
}
bHosted = true;
if (ingame.numStructureLimits)
{
plimits = ingame.pStructureLimits; // save limits if it was already set
limitcount = ingame.numStructureLimits;
}
// clear out old values
memset(&ingame, 0x0, sizeof(ingame));
// fix the things we reset
ingame.bHostSetup = true;
ingame.localOptionsReceived = true;
if (limitcount)
{
ingame.pStructureLimits = plimits;
ingame.numStructureLimits = limitcount;
}
resetReadyStatus(false);
resetDataHash();
removeWildcards((char*)sPlayer);

widgDelete(psWScreen,MULTIOP_REFRESH);
widgDelete(psWScreen,MULTIOP_HOST);
if (!hostCampaign((char*)game.name,(char*)sPlayer))
{
addConsoleMessage(_("Sorry! Failed to host the game."), DEFAULT_JUSTIFY, SYSTEM_MESSAGE);
break;
}
bHosted = true;

ingame.localOptionsReceived = true;
widgDelete(psWScreen,MULTIOP_REFRESH);
widgDelete(psWScreen,MULTIOP_HOST);

addGameOptions(false); // update game options box.
addChatBox();
ingame.localOptionsReceived = true;

disableMultiButs();
addGameOptions(false); // update game options box.
addChatBox();

addPlayerBox(!ingame.bHostSetup || bHosted); //to make sure host can't skip player selection menu (sets game.skdiff to UBYTE_MAX for humans)
break;
disableMultiButs();

addPlayerBox(!ingame.bHostSetup || bHosted); //to make sure host can't skip player selection menu (sets game.skdiff to UBYTE_MAX for humans)
break;
}
case MULTIOP_CHATEDIT:

// don't send empty lines to other players in the lobby
Expand Down
2 changes: 2 additions & 0 deletions src/multijoin.c
Expand Up @@ -250,6 +250,8 @@ BOOL MultiPlayerLeave(UDWORD playerIndex)
// A Remote Player has joined the game.
BOOL MultiPlayerJoin(UDWORD playerIndex)
{
debug(LOG_NET, "Remote Player %u has joined, isHost :%s", playerIndex, NetPlay.isHost ? "true": "false");

if(widgGetFromID(psWScreen,IDRET_FORM)) // if ingame.
{
audio_QueueTrack( ID_CLAN_ENTER );
Expand Down
1 change: 1 addition & 0 deletions src/multiopt.c
Expand Up @@ -68,6 +68,7 @@ void sendOptions()
{
unsigned int i;

debug(LOG_NET, "Broadcasting NET_OPTIONS");
NETbeginEncode(NET_OPTIONS, NET_ALL_PLAYERS);

// First send information about the game
Expand Down

0 comments on commit cad197a

Please sign in to comment.