newnet: Make DROID_EMBARK and DROID_DISEMBARK synchronised.

Make unloading cyborgs synchronised, but can only unload all at once, not one at a time...
master
Cyp 2010-02-26 19:06:24 +01:00
parent 723cad56ed
commit 6f4b9f515d
8 changed files with 43 additions and 38 deletions

View File

@ -254,9 +254,9 @@ extern LOBBY_ERROR_TYPES LobbyError; // from src/multiint.c
** ie ("trunk", "2.1.3", ...)
************************************************************************************
**/
char VersionString[VersionStringSize] = "trunk, netcode 4.2";
char VersionString[VersionStringSize] = "trunk, netcode 4.3";
static int NETCODE_VERSION_MAJOR = 4;
static int NETCODE_VERSION_MINOR = 2;
static int NETCODE_VERSION_MINOR = 3;
static int NETCODE_HASH = 0; // unused for now
static int checkSockets(const SocketSet* set, unsigned int timeout);
@ -4040,8 +4040,6 @@ const char *messageTypeToString(unsigned messageType_)
case GAME_ALLIANCE: return "GAME_ALLIANCE";
case GAME_GIFT: return "GAME_GIFT";
case GAME_ARTIFACTS: return "GAME_ARTIFACTS";
case GAME_DROIDEMBARK: return "GAME_DROIDEMBARK";
case GAME_DROIDDISEMBARK: return "GAME_DROIDDISEMBARK";
case GAME_RESEARCHSTATUS: return "GAME_RESEARCHSTATUS";
case GAME_STRUCTUREINFO: return "GAME_STRUCTUREINFO";
case GAME_LASSAT: return "GAME_LASSAT";
@ -4053,6 +4051,8 @@ const char *messageTypeToString(unsigned messageType_)
case GAME_STRUCTDEST: return "GAME_STRUCTDEST";
case GAME_BUILDFINISHED: return "GAME_BUILDFINISHED";
case GAME_DEMOLISH: return "GAME_DEMOLISH";
case GAME_DROIDEMBARK: return "GAME_DROIDEMBARK";
case GAME_DROIDDISEMBARK: return "GAME_DROIDDISEMBARK";
case GAME_MAX_TYPE: return "GAME_MAX_TYPE";
}
return "(INVALID MESSAGE TYPE)";

View File

@ -98,8 +98,6 @@ typedef enum
GAME_ALLIANCE, ///< alliance data.
GAME_GIFT, ///< a luvly gift between players.
GAME_ARTIFACTS, ///< artifacts randomly placed.
GAME_DROIDEMBARK, ///< droid embarked on a Transporter
GAME_DROIDDISEMBARK, ///< droid disembarked from a Transporter
GAME_RESEARCHSTATUS, ///< research state.
GAME_STRUCTUREINFO, ///< Structure state.
GAME_LASSAT, ///< lassat firing.
@ -113,6 +111,8 @@ typedef enum
GAME_STRUCTDEST, ///< specify a strucutre to destroy, will be sent by all players at the same time, and have no effect, if synchronised.
GAME_BUILDFINISHED, ///< a building is complete.
GAME_DEMOLISH, ///< a demolish is complete.
GAME_DROIDEMBARK, ///< droid embarked on a Transporter
GAME_DROIDDISEMBARK, ///< droid disembarked from a Transporter
// End of redundant messages.
GAME_MAX_TYPE ///< Maximum+1 valid GAME_ type, *MUST* be last.
} MESSAGE_TYPES;

View File

@ -21,6 +21,10 @@ Fix production completed and research completed sounds.
Fix destroying droid templates. Can probably go out of synch, if destroying a template just before the droid is produced, due to trying to produce an unknown type of droid (so the other players would see the new droid, but the droid owner wouldn't).
Fix unloading single units from transporters. Currently just unload everything, if trying to unload a unit.
Check if commanders work.
********************
* src/structure.c: *
********************
@ -47,11 +51,6 @@ Make modified code for placing structures in debug mode less hackish.
******************
Check the researchResult function. Should a message be sent there, and if so, then should wait for it?
***************
* src/order.c *
***************
Just before transporterAddDroid, it changes the droid state directly. Should either not test for selectedPlayer, or should not change the droid state directly. See also: unloadTransporter.
*********************
* src/scriptfuncs.c *
*********************

View File

@ -1927,7 +1927,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

@ -649,6 +649,8 @@ BOOL recvGroupOrder(NETQUEUE queue)
continue; // continue working on next droid; crossing fingers...
}
syncDebugDroid(psDroid, '<');
/*
* If the current order not is a command order and we are not a
* commander yet are in the commander group remove us from it.
@ -673,6 +675,8 @@ BOOL recvGroupOrder(NETQUEUE queue)
*/
ProcessDroidOrder(psDroid, order, x, y, 0, 0);
}
syncDebugDroid(psDroid, '>');
}
return true;
@ -840,7 +844,8 @@ static void ProcessDroidOrder(DROID *psDroid, DROID_ORDER order, uint32_t x, uin
{
// Don't bother if it is close
if (abs(psDroid->pos.x - x) < (TILE_UNITS/2)
&& abs(psDroid->pos.y - y) < (TILE_UNITS/2))
&& abs(psDroid->pos.y - y) < (TILE_UNITS/2)
&& order != DORDER_DISEMBARK)
{
return;
}

View File

@ -610,8 +610,8 @@ BOOL recvMessage(void)
//case GAME_STRUCTDEST: //28 down, 14 to go.
//case GAME_SECONDARY: // 7 down, 36 to go.
//case GAME_SECONDARY_ALL://36 down, 6 to go. <--- Removed completely...
case GAME_DROIDEMBARK:
case GAME_DROIDDISEMBARK:
//case GAME_DROIDEMBARK: //39 down, 3 to go.
//case GAME_DROIDDISEMBARK://40down, 2 to go.
//case GAME_GIFT: //32 down, 10 to go
//case NET_SCORESUBMIT:
//case GAME_VTOL: //37 down, 5 to go. <--- Removed completely, the VTOLs are happy without them.

View File

@ -850,26 +850,22 @@ void orderUpdateDroid(DROID *psDroid)
else if (abs((SDWORD)psDroid->pos.x - (SDWORD)psDroid->psTarget->pos.x) < TILE_UNITS
&& abs((SDWORD)psDroid->pos.y - (SDWORD)psDroid->psTarget->pos.y) < TILE_UNITS)
{
// if in multiPlayer, only want to process if this player's droid
if (!bMultiPlayer || psDroid->player == selectedPlayer)
{
// save the target of current droid (the transporter)
DROID * transporter = (DROID *)psDroid->psTarget;
// save the target of current droid (the transporter)
DROID * transporter = (DROID *)psDroid->psTarget;
// Make sure that it really is a valid droid
CHECK_DROID(transporter);
// Make sure that it really is a valid droid
CHECK_DROID(transporter);
// order the droid to stop so moveUpdateDroid does not process this unit
orderDroid(psDroid, DORDER_STOP);
setDroidTarget(psDroid, NULL);
psDroid->psTarStats = NULL;
secondarySetState(psDroid, DSO_RETURN_TO_LOC, DSS_NONE);
// order the droid to stop so moveUpdateDroid does not process this unit
orderDroid(psDroid, DORDER_STOP);
setDroidTarget(psDroid, NULL);
psDroid->psTarStats = NULL;
secondarySetState(psDroid, DSO_RETURN_TO_LOC, DSS_NONE);
/* We must add the droid to the transporter only *after*
* processing changing its orders (see above).
*/
transporterAddDroid(transporter, psDroid);
}
/* We must add the droid to the transporter only *after*
* processing changing its orders (see above).
*/
transporterAddDroid(transporter, psDroid);
}
else if (psDroid->action == DACTION_NONE)
{
@ -891,11 +887,7 @@ void orderUpdateDroid(DROID *psDroid)
if (psDroid->action != DACTION_MOVE && psDroid->action != DACTION_MOVEFIRE &&
psDroid->sMove.Status == MOVEINACTIVE && psDroid->sMove.iVertSpeed == 0)
{
//only need to unload if this player's droid
if (psDroid->player == selectedPlayer)
{
unloadTransporter(psDroid, psDroid->pos.x, psDroid->pos.y, false);
}
unloadTransporter(psDroid, psDroid->pos.x, psDroid->pos.y, false);
//reset the transporter's order
psDroid->order = DORDER_NONE;
}
@ -2739,7 +2731,7 @@ DROID_ORDER chooseOrderLoc(DROID *psDroid, UDWORD x,UDWORD y, BOOL altOrder)
{
/* in MultiPlayer - if ALT-key is pressed then need to get the Transporter
* to fly to location and all units disembark */
if (keyDown(KEY_LALT) || keyDown(KEY_RALT))
if (altOrder)
{
order = DORDER_DISEMBARK;
}

View File

@ -1363,6 +1363,15 @@ void transporterRemoveDroid(UDWORD id)
ASSERT( psCurrTransporter != NULL, "transporterRemoveUnit:can't remove units" );
if (bMultiMessages)
{
// Not sure how to fix this...
debug(LOG_ERROR, "TODO: Can't unload single droids, sending order to unload all at once, because this code is so convoluted.");
// All at once is better than nothing...
orderDroidLoc(psCurrTransporter, DORDER_DISEMBARK, psCurrTransporter->pos.x, psCurrTransporter->pos.y);
return;
}
currID = IDTRANS_CONTSTART;
for (psDroid = psCurrTransporter->psGroup->psList; psDroid != NULL && psDroid !=
psCurrTransporter; psDroid = psNext)