Split bMultiPlayer into bMultiPlayer and bMultiMessages - fixes a ton of bugs relating to the game thinking it's not in multiplayer mode when it is, but has multi messages off.

Previous commit was misnamed, it was actually a commit of patch #1440.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9408 4a71c877-e1ca-e34f-864e-861f7616d084
master
Guangcong Luo 2010-01-22 20:44:50 +00:00 committed by Git SVN Gateway
parent d187d6fab4
commit 302582d8b6
21 changed files with 68 additions and 65 deletions

View File

@ -353,6 +353,7 @@ bool ParseCommandLine(int argc, const char** argv)
}
NetPlay.bComms = false;
bMultiPlayer = false;
bMultiMessages = false;
NetPlay.players[0].allocated = true;
if (strcmp(token, "CAM_1A") && strcmp(token, "CAM_2A") && strcmp(token, "CAM_3A"))
{

View File

@ -4094,7 +4094,7 @@ void intProcessDesign(UDWORD id)
if ( psTempl )
{
if (bMultiPlayer) //ajl. inform others of template destruction.
if (bMultiMessages) //ajl. inform others of template destruction.
{
SendDestroyTemplate(psTempl);
}
@ -4670,7 +4670,7 @@ static BOOL saveTemplate(void)
ASSERT_OR_RETURN( false, psTempl != NULL, "Template is NULL in saveTemplate()!");
psTempl->multiPlayerID = (objID<<3)|selectedPlayer;
objID++;
if (bMultiPlayer)
if (bMultiMessages)
{
sendTemplate(psTempl);
}

View File

@ -511,7 +511,7 @@ void driveUpdate(void)
if(DirectControl) {
if(psDrivenDroid != NULL) {
if(bMultiPlayer && (driveBumpTime < gameTime)) // send latest info about driven droid.
if(bMultiMessages && (driveBumpTime < gameTime)) // send latest info about driven droid.
{
SendDroidInfo(psDrivenDroid,DORDER_MOVE,psDrivenDroid->pos.x,psDrivenDroid->pos.y, NULL);
}

View File

@ -383,7 +383,7 @@ void removeDroidBase(DROID *psDel)
}
//ajl, inform others of destruction.
if (bMultiPlayer
if (bMultiMessages
&& !(psDel->player != selectedPlayer && psDel->order == DORDER_RECYCLE))
{
ASSERT_OR_RETURN( , droidOnMap(psDel), "Asking other players to destroy droid driving off the map");
@ -984,7 +984,7 @@ BOOL droidStartBuild(DROID *psDroid)
}
psStruct->body /= 10; // structures start at 10% health
if (bMultiPlayer)
if (bMultiMessages)
{
if(myResponsibility(psDroid->player) )
{
@ -2560,7 +2560,7 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
}
// ajl. droid will be created, so inform others
if(bMultiPlayer)
if(bMultiMessages)
{
if (SendDroid(pTemplate, x, y, (UBYTE)player, psDroid->id) == false)
{

View File

@ -490,7 +490,7 @@ bool removeFeature(FEATURE *psDel)
ASSERT_OR_RETURN(false, psDel != NULL, "Invalid feature pointer");
ASSERT_OR_RETURN(false, !psDel->died, "Feature already dead");
if(bMultiPlayer && !ingame.localJoiningInProgress)
if(bMultiMessages && !ingame.localJoiningInProgress)
{
SendDestroyFeature(psDel); // inform other players of destruction
}

View File

@ -428,6 +428,7 @@ BOOL runSinglePlayerMenu(void)
// game.type is switched to SKIRMISH in startMultiOptions()
NetPlay.bComms = false;
bMultiPlayer = false;
bMultiMessages = false;
game.type = CAMPAIGN;
NetPlay.players[0].allocated = true;
// make sure we have a valid color choice for our SP game. Valid values are 0, 4-7
@ -540,6 +541,7 @@ BOOL runMultiPlayerMenu(void)
NETdiscoverUPnPDevices();
ingame.bHostSetup = true;
bMultiPlayer = true;
bMultiMessages = true;
game.type = SKIRMISH; // needed?
changeTitleMode(MULTIOPTION);
break;

View File

@ -2594,6 +2594,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
game = saveGameData.sGame;
productionPlayer= selectedPlayer;
bMultiPlayer = saveGameData.multiPlayer;
bMultiMessages = bMultiPlayer;
cmdDroidMultiExpBoost(true);
NetPlay.bComms = (saveGameData.sNetPlay).bComms;
@ -3426,11 +3427,6 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
//after the clock has been reset need to check if any res_extractors are active
checkResExtractorsActive();
// if (multiPlayerInUse)
// {
// bMultiPlayer = true; // reenable multi player messages.
// multiPlayerInUse = false;
// }
// initViewPosition();
//check if limbo_expand mission has changed to an expand mission for user save game (mid-mission)
@ -3479,11 +3475,6 @@ error:
/* Start the game clock */
gameTimeStart();
// if (multiPlayerInUse)
// {
// bMultiPlayer = true; // reenable multi player messages.
// multiPlayerInUse = false;
// }
return false;
}
@ -4732,6 +4723,7 @@ bool gameLoadV(PHYSFS_file* fileHandle, unsigned int version)
PLAYERSTATS playerStats;
bMultiPlayer = saveGameData.multiPlayer;
bMultiMessages = bMultiPlayer;
productionPlayer = selectedPlayer;
game = saveGameData.sGame;
cmdDroidMultiExpBoost(true);

View File

@ -343,17 +343,17 @@ void orderGroupLoc(DROID_GROUP *psGroup, DROID_ORDER order, UDWORD x, UDWORD y)
ASSERT_OR_RETURN(, psGroup != NULL,
"orderGroupLoc: invalid droid group" );
if(bMultiPlayer)
if(bMultiMessages)
{
SendGroupOrderGroup(psGroup,order,x,y,NULL);
bMultiPlayer = false;
bMultiMessages = false;
for(psCurr=psGroup->psList; psCurr; psCurr = psCurr->psGrpNext)
{
orderDroidLoc(psCurr, order, x,y);
}
bMultiPlayer = true;
bMultiMessages = true;
}
else
{
@ -372,17 +372,17 @@ void orderGroupObj(DROID_GROUP *psGroup, DROID_ORDER order, BASE_OBJECT *psObj)
ASSERT_OR_RETURN(, psGroup != NULL,
"orderGroupObj: invalid droid group" );
if(bMultiPlayer)
if(bMultiMessages)
{
SendGroupOrderGroup(psGroup,order,0,0,psObj);
bMultiPlayer = false;
bMultiMessages = false;
for(psCurr = psGroup->psList; psCurr; psCurr = psCurr->psGrpNext)
{
orderDroidObj(psCurr, order, (BASE_OBJECT *)psObj);
}
bMultiPlayer = true;
bMultiMessages = true;
}
else
{

View File

@ -1886,7 +1886,7 @@ void unloadTransporter(DROID *psTransporter, UDWORD x, UDWORD y, BOOL goingHome)
}
// Inform all other players
if (bMultiPlayer)
if (bMultiMessages)
{
sendDroidDisEmbark(psDroid, psTransporter);
}
@ -1921,7 +1921,7 @@ void unloadTransporter(DROID *psTransporter, UDWORD x, UDWORD y, BOOL goingHome)
// Set the launch time so the transporter doesn't just disappear for CAMSTART/CAMCHANGE
transporterSetLaunchTime(gameTime);
}
}
}
}

View File

@ -310,7 +310,7 @@ static BOOL moveDroidToBase(DROID *psDroid, UDWORD x, UDWORD y, BOOL bFormation)
CHECK_DROID(psDroid);
if(bMultiPlayer && (psDroid->sMove.Status != MOVEWAITROUTE))
if(bMultiMessages && (psDroid->sMove.Status != MOVEWAITROUTE))
{
if(SendDroidMove(psDroid,x,y,bFormation) == false)
{// dont make the move since we'll recv it anyway

View File

@ -64,7 +64,7 @@ static void ProcessDroidOrder(DROID *psDroid, DROID_ORDER order, UDWORD x, UDWOR
// happy vtol = vtol ready to go back to attack.
BOOL sendHappyVtol(const DROID* psDroid)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
if (!myResponsibility(psDroid->player))
@ -123,7 +123,7 @@ BOOL recvHappyVtol()
// Send
BOOL sendDroidSecondary(const DROID* psDroid, SECONDARY_ORDER sec, SECONDARY_STATE state)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
NETbeginEncode(NET_SECONDARY, NET_ALL_PLAYERS);
@ -194,7 +194,7 @@ BOOL recvDroidSecondary()
BOOL sendDroidSecondaryAll(const DROID* psDroid)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
NETbeginEncode(NET_SECONDARY_ALL, NET_ALL_PLAYERS);
@ -245,7 +245,7 @@ BOOL recvDroidSecondaryAll()
*/
BOOL sendDroidEmbark(const DROID* psDroid, const DROID* psTransporter)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
NETbeginEncode(NET_DROIDEMBARK, NET_ALL_PLAYERS);
@ -332,7 +332,7 @@ BOOL recvDroidEmbark()
*/
BOOL sendDroidDisEmbark(const DROID* psDroid, const DROID* psTransporter)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
NETbeginEncode(NET_DROIDDISEMBARK, NET_ALL_PLAYERS);
@ -432,7 +432,7 @@ BOOL recvDroidDisEmbark()
// posibly Send an updated droid movement order.
BOOL SendDroidMove(const DROID* psDroid, uint32_t x, uint32_t y, BOOL formation)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
ASSERT(x > 0 && y > 0, "SendDroidMove: Invalid move order");
@ -516,7 +516,7 @@ BOOL recvDroidMove()
// Send a new Droid to the other players
BOOL SendDroid(const DROID_TEMPLATE* pTemplate, uint32_t x, uint32_t y, uint8_t player, uint32_t id)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
ASSERT(x != 0 && y != 0, "SendDroid: Invalid droid coordinates");
@ -644,7 +644,7 @@ typedef enum {
*/
BOOL SendGroupOrderSelected(uint8_t player, uint32_t x, uint32_t y, const BASE_OBJECT* psObj)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
NETbeginEncode(NET_GROUPORDER, NET_ALL_PLAYERS);
@ -718,7 +718,7 @@ BOOL SendGroupOrderGroup(const DROID_GROUP* psGroup, DROID_ORDER order, uint32_t
return false;
}
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
NETbeginEncode(NET_GROUPORDER, NET_ALL_PLAYERS);
@ -910,7 +910,7 @@ BOOL recvGroupOrder()
// Droid update information
BOOL SendDroidInfo(const DROID* psDroid, DROID_ORDER order, uint32_t x, uint32_t y, const BASE_OBJECT* psObj)
{
if (!bMultiPlayer)
if (!bMultiMessages)
return true;
if (!myResponsibility(psDroid->player))
@ -1088,7 +1088,7 @@ static void ProcessDroidOrder(DROID *psDroid, DROID_ORDER order, uint32_t x, uin
// Inform other players that a droid has been destroyed
BOOL SendDestroyDroid(const DROID* psDroid)
{
if (!bMultiPlayer)
if (!bMultiMessages)
{
return true;
}

View File

@ -422,7 +422,7 @@ void formAlliance(uint8_t p1, uint8_t p2, BOOL prop, BOOL allowAudio, BOOL allow
audio_QueueTrack(ID_ALLIANCE_ACC);
}
if (bMultiPlayer && prop)
if (bMultiMessages && prop)
{
sendAlliance(p1, p2, ALLIANCE_FORMED, false);
}

View File

@ -667,6 +667,7 @@ void runConnectionScreen(void )
case CON_CANCEL: //cancel
changeTitleMode(MULTI);
bMultiPlayer = false;
bMultiMessages = false;
break;
case CON_TYPESID_MORE:
widgDelete(psWScreen,FRONTEND_BOTFORM);
@ -2812,6 +2813,7 @@ void startMultiplayerGame(void)
{
decideWRF(); // set up swrf & game.map
bMultiPlayer = true;
bMultiMessages = true;
NET_PlayerConnectionStatus = 0; // reset disconnect conditions
if (NetPlay.isHost)
@ -2999,6 +3001,7 @@ void frontendMultiMessages(void)
war_SetFog(!game.fog);
bMultiPlayer = true;
bMultiMessages = true;
changeTitleMode(STARTGAME);
bHosted = false;
break;

View File

@ -266,7 +266,8 @@ BOOL hostCampaign(char *sGame, char *sPlayer)
ingame.localJoiningInProgress = true;
ingame.JoiningInProgress[selectedPlayer] = true;
bMultiPlayer = true; // enable messages
bMultiPlayer = true;
bMultiMessages = true; // enable messages
loadMultiStats(sPlayer,&playerStats); // stats stuff
setMultiStats(selectedPlayer, playerStats, false);
@ -385,6 +386,7 @@ static BOOL cleanMap(UDWORD player)
BOOL firstFact,firstRes;
bMultiPlayer = false;
bMultiMessages = false;
firstFact = true;
firstRes = true;
@ -510,6 +512,7 @@ static BOOL cleanMap(UDWORD player)
// reverseObjectList((BASE_OBJECT**)&apsStructLists[player]);
bMultiPlayer = true;
bMultiMessages = true;
return true;
}
@ -635,6 +638,7 @@ BOOL multiGameShutdown(void)
ingame.bHostSetup = false; // Dont attempt a host
NetPlay.isHost = false;
bMultiPlayer = false; // Back to single player mode
bMultiMessages = false;
selectedPlayer = 0; // Back to use player 0 (single player friendly)
return true;

View File

@ -74,6 +74,7 @@
// globals.
bool isMPDirtyBit = false; // When we are forced to use turnOffMultiMsg() we set this
BOOL bMultiPlayer = false; // true when more than 1 player.
BOOL bMultiMessages = false; // == bMultiPlayer unless multimessages are disabled
BOOL openchannels[MAX_PLAYERS]={true};
UBYTE bDisplayMultiJoiningStatus;
@ -126,18 +127,18 @@ BOOL turnOffMultiMsg(BOOL bDoit)
// This is spammed multiple times.
debug(LOG_NEVER, "multiple calls to turn off");
}
if(bMultiPlayer)
if(bMultiMessages)
{
bMultiPlayer = false;
bMultiMessages = false;
bTemp = true;
isMPDirtyBit = true;
bMultiMessages = true;
}
}
else // turn on msgs.
{
if(bTemp)
{
bMultiPlayer = true;
bMultiMessages = true;
bTemp = false;
}
}

View File

@ -76,6 +76,7 @@ extern MULTIPLAYERGAME game; // the game description.
extern MULTIPLAYERINGAME ingame; // the game description.
extern BOOL bMultiPlayer; // true when more than 1 player.
extern BOOL bMultiMessages; // == bMultiPlayer unless multi messages are disabled
extern UDWORD selectedPlayer;
extern BOOL openchannels[MAX_PLAYERS];
extern UBYTE bDisplayMultiJoiningStatus; // draw load progress?

View File

@ -2143,7 +2143,7 @@ void orderDroid(DROID *psDroid, DROID_ORDER order)
sOrder.order = order;
orderDroidBase(psDroid, &sOrder);
if(bMultiPlayer)
if(bMultiMessages)
{
SendDroidInfo(psDroid, order, 0, 0, NULL);
}
@ -2179,7 +2179,7 @@ void orderDroidLoc(DROID *psDroid, DROID_ORDER order, UDWORD x, UDWORD y)
orderClearDroidList(psDroid);
if(bMultiPlayer) //ajl
if(bMultiMessages) //ajl
{
SendDroidInfo(psDroid, order, x, y, NULL);
turnOffMultiMsg(true); // msgs off.
@ -2240,7 +2240,7 @@ void orderDroidObj(DROID *psDroid, DROID_ORDER order, BASE_OBJECT *psObj)
orderClearDroidList(psDroid);
if(bMultiPlayer) //ajl
if(bMultiMessages) //ajl
{
SendDroidInfo(psDroid, order, 0, 0, psObj);
}
@ -2574,7 +2574,7 @@ BOOL orderDroidList(DROID *psDroid)
orderDroidBase(psDroid, &sOrder);
//don't send BUILD orders in multiplayer
if(bMultiPlayer && !(sOrder.order == DORDER_BUILD || sOrder.order == DORDER_LINEBUILD))
if(bMultiMessages && !(sOrder.order == DORDER_BUILD || sOrder.order == DORDER_LINEBUILD))
{
SendDroidInfo(psDroid, sOrder.order , sOrder.x, sOrder.y,sOrder.psObj);
}
@ -2763,7 +2763,7 @@ void orderSelectedLoc(uint32_t player, uint32_t x, uint32_t y, bool add)
return;
}
if (!add && bMultiPlayer && SendGroupOrderSelected((UBYTE)player,x,y,NULL) )
if (!add && bMultiMessages && SendGroupOrderSelected((UBYTE)player,x,y,NULL) )
{ // turn off multiplay messages,since we've send a group one instead.
turnOffMultiMsg(true);
}
@ -3117,7 +3117,7 @@ void orderSelectedObjAdd(UDWORD player, BASE_OBJECT *psObj, BOOL add)
DROID *psCurr, *psDemolish;
DROID_ORDER order;
if (!add && bMultiPlayer && SendGroupOrderSelected((UBYTE)player,0,0,psObj) )
if (!add && bMultiMessages && SendGroupOrderSelected((UBYTE)player,0,0,psObj) )
{ // turn off multiplay messages,since we've send a group one instead.
turnOffMultiMsg(true);
}
@ -3539,15 +3539,13 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat
UDWORD CurrState, factType, prodType;
STRUCTURE *psStruct;
SDWORD factoryInc, order;
BOOL retVal, bMultiPlayGame = false;
BOOL retVal;
DROID *psTransport, *psCurr, *psNext;
if(bMultiPlayer)
if(bMultiMessages)
{
//store the value before overwriting
bMultiPlayGame = bMultiPlayer;
sendDroidSecondary(psDroid,sec,State);
turnOffMultiMsg(true); // msgs off.
}
@ -3820,7 +3818,7 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat
if (psTransport != NULL)
{
//in multiPlayer can only put cyborgs onto a Transporter
if (bMultiPlayGame && !cyborgDroid(psDroid))
if (bMultiPlayer && !cyborgDroid(psDroid))
{
retVal = false;
}
@ -4339,7 +4337,7 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj)
// send the weapon fire
if(bMultiPlayer)
if(bMultiMessages)
{
sendLasSat(player,psStruct,psObj);
}

View File

@ -4419,7 +4419,7 @@ BOOL scrCompleteResearch(void)
researchResult(researchIndex, (UBYTE)player, false, NULL, false);
if(bMultiPlayer && (gameTime > 2 ))
if(bMultiMessages && (gameTime > 2 ))
{
SendResearch((UBYTE)player, researchIndex, false);
}
@ -11393,7 +11393,7 @@ BOOL scrAssembleWeaponTemplate(void)
pNewTemplate->psNext = apsDroidTemplates[player];
apsDroidTemplates[player] = pNewTemplate; //apsTemplateList?
if (bMultiPlayer)
if (bMultiMessages)
{
sendTemplate(pNewTemplate);
}

View File

@ -1174,7 +1174,7 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints)
intBuildFinished(psDroid);
}
if((bMultiPlayer) && myResponsibility(psStruct->player))
if((bMultiMessages) && myResponsibility(psStruct->player))
{
SendBuildFinished(psStruct);
}
@ -2575,7 +2575,7 @@ static BOOL structPlaceDroid(STRUCTURE *psStructure, DROID_TEMPLATE *psTempl,
//set the droids order to that of the factory - AB 22/04/99
psNewDroid->secondaryOrder = psStructure->pFunctionality->factory.secondaryOrder;
if(bMultiPlayer)
if(bMultiMessages)
{
sendDroidSecondaryAll(psNewDroid);
}
@ -3384,7 +3384,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
//check if Research is complete
if (pPlayerRes->currentPoints >= pResearch->researchPoints)
{
if(bMultiPlayer)
if(bMultiMessages)
{
SendResearch(psStructure->player, pSubject->ref - REF_RESEARCH_START, true);
}
@ -3784,7 +3784,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
//check for fully armed and fully repaired
if (vtolHappy(psDroid))
{
if( bMultiPlayer)
if( bMultiMessages)
{
sendHappyVtol(psDroid);
}
@ -5052,7 +5052,7 @@ BOOL destroyStruct(STRUCTURE *psDel)
CHECK_STRUCTURE(psDel);
if (bMultiPlayer)
if (bMultiMessages)
{
SendDestroyStructure(psDel);
}
@ -6333,7 +6333,7 @@ BOOL electronicDamage(BASE_OBJECT *psTarget, UDWORD damage, UBYTE attackPlayer)
(void)giftSingleDroid(psDroid, attackPlayer);
// tell the world!
if (bMultiPlayer)
if (bMultiMessages)
{
uint8_t giftType = DROID_GIFT, droid_count = 1;

View File

@ -1421,7 +1421,7 @@ void transporterRemoveDroid(UDWORD id)
addDroid(psDroid, apsDroidLists);
//inform all other players about that
if (bMultiPlayer)
if (bMultiMessages)
{
sendDroidDisEmbark(psDroid,psCurrTransporter);
}
@ -1521,7 +1521,7 @@ void transporterAddDroid(DROID *psTransporter, DROID *psDroidToAdd)
// adding to transporter unit's group list
grpJoin(psTransporter->psGroup, psDroidToAdd);
if (bMultiPlayer)
if (bMultiMessages)
{
//inform all other players to update their local lists
sendDroidEmbark(psDroidToAdd,psTransporter);

View File

@ -126,6 +126,7 @@ TITLECODE titleLoop(void)
{
ingame.bHostSetup = true;
bMultiPlayer = true;
bMultiMessages = true;
game.type = SKIRMISH; // needed?
changeTitleMode(MULTIOPTION);
hostlaunch = false; // reset the bool to default state.