diff --git a/src/droid.c b/src/droid.c index f38b5a177..75c73e1fb 100644 --- a/src/droid.c +++ b/src/droid.c @@ -4031,7 +4031,7 @@ UDWORD getDroidEffectiveLevel(DROID *psDroid) { UDWORD level = getDroidLevel(psDroid); UDWORD cmdLevel = cmdGetCommanderLevel(psDroid); - + return MAX(level, cmdLevel); } @@ -4513,14 +4513,14 @@ building the specified structure - returns TRUE if finds one*/ BOOL checkDroidsBuilding(STRUCTURE *psStructure) { DROID *psDroid; - STRUCTURE *psStruct = NULL; for (psDroid = apsDroidLists[psStructure->player]; psDroid != NULL; psDroid = psDroid->psNext) { + BASE_OBJECT *psStruct = NULL; //check DORDER_BUILD, HELP_BUILD is handled the same - orderStateObj(psDroid, DORDER_BUILD, (BASE_OBJECT **) &psStruct); - if (psStruct == psStructure) + orderStateObj(psDroid, DORDER_BUILD, &psStruct); + if ((STRUCTURE*)psStruct == psStructure) { return TRUE; } @@ -4533,14 +4533,14 @@ demolishing the specified structure - returns TRUE if finds one*/ BOOL checkDroidsDemolishing(STRUCTURE *psStructure) { DROID *psDroid; - STRUCTURE *psStruct = NULL; for (psDroid = apsDroidLists[psStructure->player]; psDroid != NULL; psDroid = psDroid->psNext) { + BASE_OBJECT *psStruct = NULL; //check DORDER_DEMOLISH - orderStateObj(psDroid, DORDER_DEMOLISH, (BASE_OBJECT **) &psStruct); - if (psStruct == psStructure) + orderStateObj(psDroid, DORDER_DEMOLISH, &psStruct); + if ((STRUCTURE*)psStruct == psStructure) { return TRUE; } @@ -4897,7 +4897,7 @@ BOOL vtolEmpty(DROID *psDroid) // true if a vtol is waiting to be rearmed by a particular rearm pad BOOL vtolReadyToRearm(DROID *psDroid, STRUCTURE *psStruct) { - STRUCTURE *psRearmPad; + BASE_OBJECT *psRearmPad; CHECK_DROID(psDroid); @@ -4908,10 +4908,10 @@ BOOL vtolReadyToRearm(DROID *psDroid, STRUCTURE *psStruct) } // If a unit has been ordered to rearm make sure it goes to the correct base - if (orderStateObj(psDroid, DORDER_REARM, (BASE_OBJECT **)&psRearmPad)) + if (orderStateObj(psDroid, DORDER_REARM, &psRearmPad)) { - if ((psRearmPad != psStruct) && - !vtolOnRearmPad(psRearmPad, psDroid)) + if (((STRUCTURE*)psRearmPad != psStruct) && + !vtolOnRearmPad((STRUCTURE*)psRearmPad, psDroid)) { // target rearm pad is clear - let it go there return FALSE; @@ -5460,7 +5460,7 @@ BOOL checkValidWeaponForProp(DROID_TEMPLATE *psTemplate) if (asPropulsionTypes[psPropStats->propulsionType].travel == AIR) { //check weapon stat for indirect - if (!proj_Direct(asWeaponStats + psTemplate->asWeaps[0]) + if (!proj_Direct(asWeaponStats + psTemplate->asWeaps[0]) || !asWeaponStats[psTemplate->asWeaps[0]].vtolAttackRuns) { bValid = FALSE; diff --git a/src/hci.c b/src/hci.c index 9fe3553fe..31174dce8 100644 --- a/src/hci.c +++ b/src/hci.c @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** - * @file hci.c + * @file hci.c * * Functions for the in game interface. * (Human Computer Interface - thanks to Alex for the file name). @@ -6064,34 +6064,38 @@ static BOOL selectConstruction(BASE_OBJECT *psObj) /* Return the stats for a construction droid */ static BASE_STATS *getConstructionStats(BASE_OBJECT *psObj) { - DROID *psDroid; + DROID *psDroid = (DROID *)psObj; BASE_STATS *Stats; - STRUCTURE *Structure; - UDWORD x,y; + BASE_OBJECT *Structure; + UDWORD x, y; ASSERT( psObj != NULL && psObj->type == OBJ_DROID, "getConstructionStats: invalid droid pointer" ); - psDroid = (DROID *)psObj; - //if(droidType(psDroid) != DROID_CONSTRUCT) return NULL; - if (!(droidType(psDroid) == DROID_CONSTRUCT || droidType(psDroid) == - DROID_CYBORG_CONSTRUCT)) - { - return NULL; - } + if (!(droidType(psDroid) == DROID_CONSTRUCT || + droidType(psDroid) == DROID_CYBORG_CONSTRUCT)) + { + return NULL; + } - if(orderStateStatsLoc(psDroid, DORDER_BUILD,&Stats,&x,&y)) { // Moving to build location? + if(orderStateStatsLoc(psDroid, DORDER_BUILD, &Stats, &x, &y)) // Moving to build location? + { return Stats; - } else if( orderStateObj(psDroid, DORDER_BUILD,(BASE_OBJECT**)&Structure) && - psDroid->order == DORDER_BUILD ) { // Is building + } + else if( orderStateObj(psDroid, DORDER_BUILD, &Structure) && + psDroid->order == DORDER_BUILD ) // Is building + { return psDroid->psTarStats; - } else if( orderStateObj(psDroid, DORDER_HELPBUILD,(BASE_OBJECT**)&Structure) && - (psDroid->order == DORDER_HELPBUILD || psDroid->order == DORDER_LINEBUILD)) { //Is helping - return (BASE_STATS*)Structure->pStructureType; - } else if (orderState(psDroid, DORDER_DEMOLISH)) { - return (BASE_STATS *)structGetDemolishStat(); - } - + } + else if( orderStateObj(psDroid, DORDER_HELPBUILD, &Structure) && + (psDroid->order == DORDER_HELPBUILD || psDroid->order == DORDER_LINEBUILD)) // Is helping + { + return (BASE_STATS*)((STRUCTURE*)Structure)->pStructureType; + } + else if (orderState(psDroid, DORDER_DEMOLISH)) + { + return (BASE_STATS *)structGetDemolishStat(); + } return NULL; } diff --git a/src/intdisplay.c b/src/intdisplay.c index 775d4d296..244a63f9f 100644 --- a/src/intdisplay.c +++ b/src/intdisplay.c @@ -800,6 +800,7 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PI case REF_RESEARCH: if (StructureIsResearching(Structure)) { + iIMDShape * shape = Object; Stats = (BASE_STATS*)Buffer->Data2; if (!Stats) { @@ -809,7 +810,8 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PI { bOnHold = TRUE; } - StatGetResearchImage(Stats,&Image,(iIMDShape**)&Object, &psResGraphic, FALSE); + StatGetResearchImage(Stats,&Image,&shape, &psResGraphic, FALSE); + Object = shape; if (psResGraphic) { // we have a Stat associated with this research topic @@ -1052,6 +1054,7 @@ void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE } else if(StatIsResearch(Stat)) { + iIMDShape * shape = Object; /*IMDType = IMDTYPE_RESEARCH; StatGetResearchImage(Stat,&Image,(iIMDShape**)&Object,TRUE); //if Object != NULL the there must be a IMD so set the object to @@ -1060,7 +1063,8 @@ void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE { Object = (void*)Stat; }*/ - StatGetResearchImage(Stat,&Image,(iIMDShape**)&Object, &psResGraphic, TRUE); + StatGetResearchImage(Stat,&Image,&shape, &psResGraphic, TRUE); + Object = shape; if (psResGraphic) { //we have a Stat associated with this research topic @@ -2500,22 +2504,22 @@ void CreateBlankButton(RENDERED_BUTTON *Buffer,BOOL Down, UDWORD buttonType) BOOL DroidIsDemolishing(DROID *Droid) { BASE_STATS *Stats; - STRUCTURE *Structure; + BASE_OBJECT *Structure; UDWORD x,y; //if(droidType(Droid) != DROID_CONSTRUCT) return FALSE; - if (!(droidType(Droid) == DROID_CONSTRUCT || droidType(Droid) == - DROID_CYBORG_CONSTRUCT)) - { - return FALSE; - } - - if(orderStateStatsLoc(Droid, DORDER_DEMOLISH,&Stats,&x,&y)) { // Moving to demolish location? + if (!(droidType(Droid) == DROID_CONSTRUCT || + droidType(Droid) == DROID_CYBORG_CONSTRUCT)) + { + return FALSE; + } + if(orderStateStatsLoc(Droid, DORDER_DEMOLISH,&Stats,&x,&y)) // Moving to demolish location? + { return TRUE; - - } else if( orderStateObj(Droid, DORDER_DEMOLISH,(BASE_OBJECT**)&Structure) ) { // Is demolishing? - + } + else if( orderStateObj(Droid, DORDER_DEMOLISH,&Structure) ) // Is demolishing? + { return TRUE; } @@ -2547,7 +2551,7 @@ BOOL DroidIsRepairing(DROID *Droid) BOOL DroidIsBuilding(DROID *Droid) { BASE_STATS *Stats; - STRUCTURE *Structure; + BASE_OBJECT *Structure; UDWORD x,y; //if(droidType(Droid) != DROID_CONSTRUCT) return FALSE; @@ -2561,9 +2565,9 @@ BOOL DroidIsBuilding(DROID *Droid) { // Moving to build location? return FALSE; - - } else if (orderStateObj(Droid, DORDER_BUILD,(BASE_OBJECT**)&Structure) || // Is building or helping? - orderStateObj(Droid, DORDER_HELPBUILD,(BASE_OBJECT**)&Structure)) + } + else if (orderStateObj(Droid, DORDER_BUILD,&Structure) || + orderStateObj(Droid, DORDER_HELPBUILD,&Structure)) // Is building or helping? { return TRUE; } @@ -2598,13 +2602,13 @@ BOOL DroidGoingToBuild(DROID *Droid) // STRUCTURE *DroidGetBuildStructure(DROID *Droid) { - STRUCTURE *Structure; + BASE_OBJECT *Structure; - if(!orderStateObj(Droid, DORDER_BUILD,(BASE_OBJECT**)&Structure)) { - orderStateObj(Droid, DORDER_HELPBUILD,(BASE_OBJECT**)&Structure); + if(!orderStateObj(Droid, DORDER_BUILD,&Structure)) { + orderStateObj(Droid, DORDER_HELPBUILD,&Structure); } - return Structure; + return (STRUCTURE*)Structure; } // Get the first factory assigned to a command droid diff --git a/src/multibot.c b/src/multibot.c index 4d81cb9a7..67c5a9748 100644 --- a/src/multibot.c +++ b/src/multibot.c @@ -147,8 +147,8 @@ BOOL sendDroidSecondary(const DROID* psDroid, SECONDARY_ORDER sec, SECONDARY_STA BOOL recvDroidSecondary() { DROID* psDroid; - SECONDARY_ORDER sec; - SECONDARY_STATE state; + SECONDARY_ORDER sec = DSO_ATTACK_RANGE; + SECONDARY_STATE state = DSS_NONE; NETbeginDecode(NET_SECONDARY); { @@ -404,7 +404,7 @@ BOOL recvDroidMove() if (!IdToDroid(droid, player, &psDroid)) { - debug(LOG_ERROR, "recvDroidMove: Packet from %d refers to non-existent droid %d!", + debug(LOG_ERROR, "recvDroidMove: Packet from %d refers to non-existent droid %d!", NETgetSource(), (int)droid); return FALSE; } @@ -485,7 +485,7 @@ BOOL recvDroid() // If we can not find the template ask for the entire droid instead if (!pT) { - debug(LOG_ERROR, "recvDroid: Packet from %d refers to non-existent template %d!", + debug(LOG_ERROR, "recvDroid: Packet from %d refers to non-existent template %d!", NETgetSource(), (int)templateID); return FALSE; } @@ -650,11 +650,11 @@ BOOL SendGroupOrderGroup(const DROID_GROUP* psGroup, DROID_ORDER order, uint32_t // receive a group order. BOOL recvGroupOrder() { - DROID_ORDER order; + DROID_ORDER order = DORDER_NONE; BOOL subType, cmdOrder; uint32_t destId, x, y; - OBJECT_TYPE destType; + OBJECT_TYPE destType = OBJ_DROID; // Dummy initialisation to workaround NETenum macro uint8_t droidCount, i; uint32_t* droidIDs; @@ -708,7 +708,7 @@ BOOL recvGroupOrder() // Retrieve the droid associated with the current ID if (!IdToDroid(droidIDs[i], ANYPLAYER, &psDroid)) { - debug(LOG_ERROR, "recvGroupOrder: Packet from %d refers to non-existent droid %d!", + debug(LOG_ERROR, "recvGroupOrder: Packet from %d refers to non-existent droid %d!", NETgetSource(), (int)droidIDs[i]); continue; // continue working on next droid; crossing fingers... } @@ -792,7 +792,7 @@ BOOL recvDroidInfo() { uint32_t droidId; DROID* psDroid; - DROID_ORDER order; + DROID_ORDER order = DORDER_NONE; BOOL subType; // Get the droid @@ -800,7 +800,7 @@ BOOL recvDroidInfo() if (!IdToDroid(droidId, ANYPLAYER, &psDroid)) { - debug(LOG_ERROR, "recvDroidInfo: Packet from %d refers to non-existent droid %d!", + debug(LOG_ERROR, "recvDroidInfo: Packet from %d refers to non-existent droid %d!", NETgetSource(), (int)droidId); return FALSE; } @@ -811,7 +811,7 @@ BOOL recvDroidInfo() if (subType) { - uint32_t destId, destType; + uint32_t destId, destType = 0; NETuint32_t(&destId); NETenum(&destType);