~ubuntu-branches/ubuntu/lucid/warzone2100/lucid

« back to all changes in this revision

Viewing changes to src/multiplay.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger, Paul Wise, Christoph Egger
  • Date: 2009-06-29 17:12:52 UTC
  • mfrom: (1.1.11 upstream) (2.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090629171252-5ddnlfg3zfchrega
Tags: 2.2.1+dfsg1-1
[ Paul Wise ]
* New upstream release (Closes: #534962)
* Adjust the flex build-depends to take account of the conflict
  with all the versions of flex 2.5.34 (LP: #372872)
* Make the -music Recommends more strict, 2.1 music doesn't work
  with 2.2.
* Upstream moved the downloads to sourceforge, update the watch file
* Bump Standards-Version, no changes needed
* Drop use of dh_desktop since it no longer does anything
* Recommend the new warzone2100-video package, version 2.2 or similar
* Mention the warzone2100 crash reports in the -dbg package description

[ Christoph Egger ]
* Replace CC-2.0 graphic from cybersphinx, create a new tarball
* Add myself to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
        This file is part of Warzone 2100.
3
3
        Copyright (C) 1999-2004  Eidos Interactive
4
 
        Copyright (C) 2005-2007  Warzone Resurrection Project
 
4
        Copyright (C) 2005-2009  Warzone Resurrection Project
5
5
 
6
6
        Warzone 2100 is free software; you can redistribute it and/or modify
7
7
        it under the terms of the GNU General Public License as published by
88
88
/* multiplayer message stack stuff */
89
89
/////////////////////////////////////
90
90
#define MAX_MSG_STACK   100                             // must be *at least* 64
91
 
#define MAX_STR                 MAX_STR_LENGTH
92
91
 
93
 
static char msgStr[MAX_MSG_STACK][MAX_STR];
 
92
static char msgStr[MAX_MSG_STACK][MAX_STR_LENGTH];
94
93
static SDWORD msgPlFrom[MAX_MSG_STACK];
95
94
static SDWORD msgPlTo[MAX_MSG_STACK];
96
95
static SDWORD callbackType[MAX_MSG_STACK];
124
123
        {
125
124
                if(bTemp == true)
126
125
                {
127
 
                        debug(LOG_NET, "turnOffMultiMsg: multiple calls to turn off");
 
126
                        // Surely, this should be a Assert?
 
127
                        debug(LOG_ERROR, "multiple calls to turn off");
128
128
                }
129
129
                if(bMultiPlayer)
130
130
                {
704
704
                case NET_RESEARCH:                                      // some research has been done.
705
705
                        recvResearch();
706
706
                        break;
707
 
                case NET_LEAVING:                                       // player leaving nicely
708
 
                {
709
 
                        uint32_t player_id;
710
 
                        BOOL host;
711
 
 
712
 
                        resetReadyStatus(false);
713
 
 
714
 
                        NETbeginDecode(NET_LEAVING);
715
 
                                NETuint32_t(&player_id);
716
 
                                NETbool(&host);                 // Added to check for host quit here -- Buggy
717
 
                        NETend();
718
 
                        if (player_id >= MAX_PLAYERS)
719
 
                        {
720
 
                                debug(LOG_ERROR, "Bad NET_LEAVING received, player ID is %d", (int)player_id);
721
 
                                break;
722
 
                        }
723
 
                        MultiPlayerLeave(player_id);
724
 
                        if (host)                               // host has quit, need to quit too.
725
 
                        {
726
 
                                //stopJoining();                //NOT defined here, checking if we need it or not.
727
 
                                debug(LOG_NET, "***Need to call stopJoining()");
728
 
                                addConsoleMessage(_("The host has left the game!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
729
 
                        }
730
 
                        break;
731
 
                }
732
707
                case NET_OPTIONS:
733
708
                        recvOptions();
734
709
                        break;
777
752
                        break;
778
753
                case NET_KICK:
779
754
                {
 
755
                        // FIX ME: in game kick ?  Is this even possible with current code?
780
756
                        uint32_t player_id;
 
757
                        char reason[MAX_KICK_REASON];
781
758
 
782
759
                        NETbeginDecode(NET_KICK);
783
760
                                NETuint32_t(&player_id);
 
761
                                NETstring( reason, MAX_KICK_REASON);
784
762
                        NETend();
785
763
 
786
764
                        if (NetPlay.dpidPlayer == player_id)  // we've been told to leave.
787
765
                        {
 
766
                                debug(LOG_ERROR, "You were kicked because, %s", reason);
788
767
                                setPlayerHasLost(true);
789
768
                        }
790
769
                        break;
1055
1034
 
1056
1035
        if (!ingame.localOptionsReceived)
1057
1036
        {
 
1037
                if(!bMultiPlayer)
 
1038
                {
 
1039
                        // apparently we are not in a mp game, so dump the message to the console.
 
1040
                        addConsoleMessage(pStr,LEFT_JUSTIFY, SYSTEM_MESSAGE);
 
1041
                }
1058
1042
                return true;
1059
1043
        }
1060
1044
 
1126
1110
        }
1127
1111
 
1128
1112
        //This is for local display
1129
 
        for(i = 0; NetPlay.players[i].dpid != NetPlay.dpidPlayer; i++); //findplayer
1130
 
        sstrcat(display, NetPlay.players[i].name);              // name
1131
 
        sstrcat(display, ": ");                                         // seperator
1132
 
        sstrcat(display, pStr);                                         // add message
1133
 
 
1134
 
        addConsoleMessage(display, DEFAULT_JUSTIFY, selectedPlayer);    // display
 
1113
        for (i = 0; i < ARRAY_SIZE(NetPlay.players); ++i)
 
1114
        {
 
1115
                if (NetPlay.players[i].dpid == NetPlay.dpidPlayer)
 
1116
                {
 
1117
                        sstrcat(display, NetPlay.players[i].name);              // name
 
1118
                        sstrcat(display, ": ");                                         // seperator
 
1119
                        sstrcat(display, pStr);                                         // add message
 
1120
 
 
1121
                        addConsoleMessage(display, DEFAULT_JUSTIFY, selectedPlayer);    // display
 
1122
                        break;
 
1123
                }
 
1124
        }
 
1125
 
1135
1126
 
1136
1127
        return true;
1137
1128
}
1260
1251
        NETend();
1261
1252
 
1262
1253
 
1263
 
        for (i = 0; NetPlay.players[i].dpid != dpid; i++);              //findplayer
 
1254
        for (i = 0; i < MAX_PLAYERS; i++)               //findplayer
 
1255
        {
 
1256
                if (NetPlay.players[i].dpid == dpid)
 
1257
                {
 
1258
                        break;
 
1259
                }
 
1260
        }
 
1261
 
 
1262
        ASSERT_OR_RETURN(false, i != MAX_PLAYERS, "Failed to find player's dpid %u", dpid);
1264
1263
 
1265
1264
        //console callback - find real number of the player
1266
1265
        for (j = 0; i < MAX_PLAYERS; j++)
1272
1271
                }
1273
1272
        }
1274
1273
 
1275
 
        ASSERT(player != MAX_PLAYERS, "recvTextMessage: failed to find owner of dpid %d", dpid);
 
1274
        ASSERT_OR_RETURN(false, player != MAX_PLAYERS, "Failed to find 'real' owner of dpid %u", dpid);
1276
1275
 
1277
1276
        sstrcpy(msg, NetPlay.players[i].name);
1278
1277
        // Seperator
1353
1352
                NETstring(pTempl->aName, sizeof(pTempl->aName));
1354
1353
                NETuint8_t(&pTempl->NameVersion);
1355
1354
 
1356
 
                for (i = 0; i < DROID_MAXCOMP; i++)
 
1355
                for (i = 0; i < ARRAY_SIZE(pTempl->asParts); ++i)
1357
1356
                {
1358
1357
                        // signed, but sent as a bunch of bits...
1359
1358
                        NETint32_t(&pTempl->asParts[i]);
1391
1390
                NETstring(pT->aName, sizeof(pT->aName));
1392
1391
                NETuint8_t(&pT->NameVersion);
1393
1392
 
1394
 
                for (i = 0; i < DROID_MAXCOMP; i++)
 
1393
                for (i = 0; i < ARRAY_SIZE(pT->asParts); ++i)
1395
1394
                {
1396
1395
                        // signed, but sent as a bunch of bits...
1397
1396
                        NETint32_t(&pT->asParts[i]);
1910
1909
                N_("Cyan")
1911
1910
        };
1912
1911
 
1913
 
        ASSERT(player < ARRAY_SIZE(playerColors), "player number (%d) exceeds maximum (%zu)", player, ARRAY_SIZE(playerColors));
 
1912
        ASSERT(player < ARRAY_SIZE(playerColors), "player number (%d) exceeds maximum (%lu)", player, (unsigned long) ARRAY_SIZE(playerColors));
1914
1913
 
1915
1914
        if (player >= ARRAY_SIZE(playerColors))
1916
1915
        {