From d8fbf4bccc744646a01655182fb46d8848a2cd66 Mon Sep 17 00:00:00 2001 From: Cyp Date: Fri, 29 Oct 2010 05:45:26 +0200 Subject: [PATCH] Fix droid order lists not getting cleared when giving a non-queued order. Ended up removing SendGroupOrderSelected in the process. --- src/multibot.cpp | 21 --------------------- src/multiplay.h | 1 - src/order.c | 30 ++++++++++-------------------- 3 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/multibot.cpp b/src/multibot.cpp index 2749b229f..ada88f420 100644 --- a/src/multibot.cpp +++ b/src/multibot.cpp @@ -490,27 +490,6 @@ BOOL recvDroid(NETQUEUE queue) } -// //////////////////////////////////////////////////////////////////////////// -/*! - * Droid Group/selection orders. - * The SendDroidInfo function minimises comms by sending orders for whole groups, rather than each droid. - */ -BOOL SendGroupOrderSelected(uint8_t player, uint32_t x, uint32_t y, const BASE_OBJECT* psObj, BOOL altOrder) -{ - if (!bMultiMessages) - return true; - - for (DROID *psDroid = apsDroidLists[player]; psDroid != NULL; psDroid = psDroid->psNext) - { - if (psDroid->selected) - { - DROID_ORDER order = psObj? chooseOrderObj(psDroid, const_cast(psObj), altOrder) : chooseOrderLoc(psDroid, x, y, altOrder); - SendDroidInfo(psDroid, order, x, y, psObj, NULL, 0, 0, 0); - } - } - - return true; -} /* * This routine is called by the AI scripts * diff --git a/src/multiplay.h b/src/multiplay.h index 7ca983036..f477a2292 100644 --- a/src/multiplay.h +++ b/src/multiplay.h @@ -184,7 +184,6 @@ extern BOOL SendDestroyDroid (const DROID* psDroid); extern BOOL SendDemolishFinished(STRUCTURE *psS,DROID *psD); void sendQueuedDroidInfo(void); ///< Actually sends the droid orders which were queued by SendDroidInfo. extern BOOL SendDroidInfo (const DROID* psDroid, DROID_ORDER order, uint32_t x, uint32_t y, const BASE_OBJECT* psObj, const BASE_STATS *psStats, uint32_t x2, uint32_t y2, uint16_t direction); -extern BOOL SendGroupOrderSelected(uint8_t player, uint32_t x, uint32_t y, const BASE_OBJECT* psObj, BOOL altOrder); extern BOOL SendCmdGroup (DROID_GROUP *psGroup, UWORD x, UWORD y, BASE_OBJECT *psObj); extern BOOL SendGroupOrderGroup(const DROID_GROUP* psGroup, DROID_ORDER order, uint32_t x, uint32_t y, const BASE_OBJECT* psObj); diff --git a/src/order.c b/src/order.c index a5ab2dc70..6dbf75170 100644 --- a/src/order.c +++ b/src/order.c @@ -2105,6 +2105,8 @@ void orderDroid(DROID *psDroid, DROID_ORDER order, QUEUE_MODE mode) order == DORDER_TEMP_HOLD, "orderUnit: Invalid order" ); + orderClearDroidList(psDroid); + memset(&sOrder,0,sizeof(DROID_ORDER_DATA)); sOrder.order = order; @@ -2146,14 +2148,14 @@ void orderDroidLoc(DROID *psDroid, DROID_ORDER order, UDWORD x, UDWORD y, QUEUE_ ASSERT_OR_RETURN(, psDroid != NULL, "Invalid unit pointer"); ASSERT_OR_RETURN(, validOrderForLoc(order), "Invalid order for location"); + orderClearDroidList(psDroid); + if (mode == ModeQueue && bMultiPlayer) //ajl { SendDroidInfo(psDroid, order, x, y, NULL, NULL, 0, 0, 0); return; // Wait to receive our order before changing the droid. } - orderClearDroidList(psDroid); - memset(&sOrder,0,sizeof(DROID_ORDER_DATA)); sOrder.order = order; sOrder.x = (UWORD)x; @@ -2205,14 +2207,14 @@ void orderDroidObj(DROID *psDroid, DROID_ORDER order, BASE_OBJECT *psObj, QUEUE_ ASSERT(psDroid != NULL, "Invalid unit pointer"); ASSERT(validOrderForObj(order), "Invalid order for object"); + orderClearDroidList(psDroid); + if (mode == ModeQueue && bMultiPlayer) //ajl { SendDroidInfo(psDroid, order, 0, 0, psObj, NULL, 0, 0, 0); return; // Wait for the order to be received before changing the droid. } - orderClearDroidList(psDroid); - memset(&sOrder,0,sizeof(DROID_ORDER_DATA)); sOrder.order = order; sOrder.psObj = psObj; @@ -2313,6 +2315,8 @@ void orderDroidStatsLocDir(DROID *psDroid, DROID_ORDER order, BASE_STATS *psStat ASSERT(psDroid != NULL, "Invalid unit pointer"); ASSERT(order == DORDER_BUILD, "Invalid order for location"); + orderClearDroidList(psDroid); + if (mode == ModeQueue && bMultiPlayer) { SendDroidInfo(psDroid, order, x, y, NULL, psStats, 0, 0, direction); @@ -2360,6 +2364,8 @@ void orderDroidStatsTwoLocDir(DROID *psDroid, DROID_ORDER order, BASE_STATS *psS ASSERT(order == DORDER_LINEBUILD, "Invalid order for location"); ASSERT(x1 == x2 || y1 == y2, "Invalid locations for LINEBUILD"); + orderClearDroidList(psDroid); + if (mode == ModeQueue && bMultiPlayer) { SendDroidInfo(psDroid, order, x1, y1, NULL, psStats, x2, y2, direction); @@ -2754,13 +2760,6 @@ void orderSelectedLoc(uint32_t player, uint32_t x, uint32_t y, bool add) return; } - if (!add && bMultiMessages && SendGroupOrderSelected((UBYTE)player,x,y,NULL,keyDown(KEY_LALT) || keyDown(KEY_RALT)) ) - { // turn off multiplay messages,since we've send a group one instead. - // note that an order list graphic needs to be displayed - bOrderEffectDisplayed = false; - return; // Wait to receive our order before changing the droids. - } - // remove any units from their command group for(psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) { @@ -3125,15 +3124,6 @@ void orderSelectedObjAdd(UDWORD player, BASE_OBJECT *psObj, BOOL add) DROID *psCurr, *psDemolish; DROID_ORDER order; - if (!add && bMultiMessages && SendGroupOrderSelected((UBYTE)player,0,0,psObj,keyDown(KEY_LALT) || keyDown(KEY_RALT)) ) - { // turn off multiplay messages,since we've send a group one instead. - // note that an order list graphic needs to be displayed - bOrderEffectDisplayed = false; - orderPlayOrderObjAudio(player, psObj); - return; // Wait to receive our order before changing anything. - } - - // remove any units from their command group for(psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) {