Fix a few strict-aliasing warnings and 2 types NETenum warnings (in multibot)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3993 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2008-03-10 13:31:08 +00:00
parent f0ab52dbd3
commit cd14124c47
4 changed files with 72 additions and 64 deletions

View File

@ -4513,14 +4513,14 @@ building the specified structure - returns TRUE if finds one*/
BOOL checkDroidsBuilding(STRUCTURE *psStructure) BOOL checkDroidsBuilding(STRUCTURE *psStructure)
{ {
DROID *psDroid; DROID *psDroid;
STRUCTURE *psStruct = NULL;
for (psDroid = apsDroidLists[psStructure->player]; psDroid != NULL; psDroid = for (psDroid = apsDroidLists[psStructure->player]; psDroid != NULL; psDroid =
psDroid->psNext) psDroid->psNext)
{ {
BASE_OBJECT *psStruct = NULL;
//check DORDER_BUILD, HELP_BUILD is handled the same //check DORDER_BUILD, HELP_BUILD is handled the same
orderStateObj(psDroid, DORDER_BUILD, (BASE_OBJECT **) &psStruct); orderStateObj(psDroid, DORDER_BUILD, &psStruct);
if (psStruct == psStructure) if ((STRUCTURE*)psStruct == psStructure)
{ {
return TRUE; return TRUE;
} }
@ -4533,14 +4533,14 @@ demolishing the specified structure - returns TRUE if finds one*/
BOOL checkDroidsDemolishing(STRUCTURE *psStructure) BOOL checkDroidsDemolishing(STRUCTURE *psStructure)
{ {
DROID *psDroid; DROID *psDroid;
STRUCTURE *psStruct = NULL;
for (psDroid = apsDroidLists[psStructure->player]; psDroid != NULL; psDroid = for (psDroid = apsDroidLists[psStructure->player]; psDroid != NULL; psDroid =
psDroid->psNext) psDroid->psNext)
{ {
BASE_OBJECT *psStruct = NULL;
//check DORDER_DEMOLISH //check DORDER_DEMOLISH
orderStateObj(psDroid, DORDER_DEMOLISH, (BASE_OBJECT **) &psStruct); orderStateObj(psDroid, DORDER_DEMOLISH, &psStruct);
if (psStruct == psStructure) if ((STRUCTURE*)psStruct == psStructure)
{ {
return TRUE; return TRUE;
} }
@ -4897,7 +4897,7 @@ BOOL vtolEmpty(DROID *psDroid)
// true if a vtol is waiting to be rearmed by a particular rearm pad // true if a vtol is waiting to be rearmed by a particular rearm pad
BOOL vtolReadyToRearm(DROID *psDroid, STRUCTURE *psStruct) BOOL vtolReadyToRearm(DROID *psDroid, STRUCTURE *psStruct)
{ {
STRUCTURE *psRearmPad; BASE_OBJECT *psRearmPad;
CHECK_DROID(psDroid); 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 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) && if (((STRUCTURE*)psRearmPad != psStruct) &&
!vtolOnRearmPad(psRearmPad, psDroid)) !vtolOnRearmPad((STRUCTURE*)psRearmPad, psDroid))
{ {
// target rearm pad is clear - let it go there // target rearm pad is clear - let it go there
return FALSE; return FALSE;

View File

@ -6064,35 +6064,39 @@ static BOOL selectConstruction(BASE_OBJECT *psObj)
/* Return the stats for a construction droid */ /* Return the stats for a construction droid */
static BASE_STATS *getConstructionStats(BASE_OBJECT *psObj) static BASE_STATS *getConstructionStats(BASE_OBJECT *psObj)
{ {
DROID *psDroid; DROID *psDroid = (DROID *)psObj;
BASE_STATS *Stats; BASE_STATS *Stats;
STRUCTURE *Structure; BASE_OBJECT *Structure;
UDWORD x, y; UDWORD x, y;
ASSERT( psObj != NULL && psObj->type == OBJ_DROID, ASSERT( psObj != NULL && psObj->type == OBJ_DROID,
"getConstructionStats: invalid droid pointer" ); "getConstructionStats: invalid droid pointer" );
psDroid = (DROID *)psObj;
//if(droidType(psDroid) != DROID_CONSTRUCT) return NULL; if (!(droidType(psDroid) == DROID_CONSTRUCT ||
if (!(droidType(psDroid) == DROID_CONSTRUCT || droidType(psDroid) == droidType(psDroid) == DROID_CYBORG_CONSTRUCT))
DROID_CYBORG_CONSTRUCT))
{ {
return NULL; 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; 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; return psDroid->psTarStats;
} else if( orderStateObj(psDroid, DORDER_HELPBUILD,(BASE_OBJECT**)&Structure) && }
(psDroid->order == DORDER_HELPBUILD || psDroid->order == DORDER_LINEBUILD)) { //Is helping else if( orderStateObj(psDroid, DORDER_HELPBUILD, &Structure) &&
return (BASE_STATS*)Structure->pStructureType; (psDroid->order == DORDER_HELPBUILD || psDroid->order == DORDER_LINEBUILD)) // Is helping
} else if (orderState(psDroid, DORDER_DEMOLISH)) { {
return (BASE_STATS*)((STRUCTURE*)Structure)->pStructureType;
}
else if (orderState(psDroid, DORDER_DEMOLISH))
{
return (BASE_STATS *)structGetDemolishStat(); return (BASE_STATS *)structGetDemolishStat();
} }
return NULL; return NULL;
} }

View File

@ -800,6 +800,7 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PI
case REF_RESEARCH: case REF_RESEARCH:
if (StructureIsResearching(Structure)) if (StructureIsResearching(Structure))
{ {
iIMDShape * shape = Object;
Stats = (BASE_STATS*)Buffer->Data2; Stats = (BASE_STATS*)Buffer->Data2;
if (!Stats) if (!Stats)
{ {
@ -809,7 +810,8 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PI
{ {
bOnHold = TRUE; bOnHold = TRUE;
} }
StatGetResearchImage(Stats,&Image,(iIMDShape**)&Object, &psResGraphic, FALSE); StatGetResearchImage(Stats,&Image,&shape, &psResGraphic, FALSE);
Object = shape;
if (psResGraphic) if (psResGraphic)
{ {
// we have a Stat associated with this research topic // 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)) else if(StatIsResearch(Stat))
{ {
iIMDShape * shape = Object;
/*IMDType = IMDTYPE_RESEARCH; /*IMDType = IMDTYPE_RESEARCH;
StatGetResearchImage(Stat,&Image,(iIMDShape**)&Object,TRUE); StatGetResearchImage(Stat,&Image,(iIMDShape**)&Object,TRUE);
//if Object != NULL the there must be a IMD so set the object to //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; Object = (void*)Stat;
}*/ }*/
StatGetResearchImage(Stat,&Image,(iIMDShape**)&Object, &psResGraphic, TRUE); StatGetResearchImage(Stat,&Image,&shape, &psResGraphic, TRUE);
Object = shape;
if (psResGraphic) if (psResGraphic)
{ {
//we have a Stat associated with this research topic //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) BOOL DroidIsDemolishing(DROID *Droid)
{ {
BASE_STATS *Stats; BASE_STATS *Stats;
STRUCTURE *Structure; BASE_OBJECT *Structure;
UDWORD x,y; UDWORD x,y;
//if(droidType(Droid) != DROID_CONSTRUCT) return FALSE; //if(droidType(Droid) != DROID_CONSTRUCT) return FALSE;
if (!(droidType(Droid) == DROID_CONSTRUCT || droidType(Droid) == if (!(droidType(Droid) == DROID_CONSTRUCT ||
DROID_CYBORG_CONSTRUCT)) droidType(Droid) == DROID_CYBORG_CONSTRUCT))
{ {
return FALSE; return FALSE;
} }
if(orderStateStatsLoc(Droid, DORDER_DEMOLISH,&Stats,&x,&y)) { // Moving to demolish location? if(orderStateStatsLoc(Droid, DORDER_DEMOLISH,&Stats,&x,&y)) // Moving to demolish location?
{
return TRUE; return TRUE;
}
} else if( orderStateObj(Droid, DORDER_DEMOLISH,(BASE_OBJECT**)&Structure) ) { // Is demolishing? else if( orderStateObj(Droid, DORDER_DEMOLISH,&Structure) ) // Is demolishing?
{
return TRUE; return TRUE;
} }
@ -2547,7 +2551,7 @@ BOOL DroidIsRepairing(DROID *Droid)
BOOL DroidIsBuilding(DROID *Droid) BOOL DroidIsBuilding(DROID *Droid)
{ {
BASE_STATS *Stats; BASE_STATS *Stats;
STRUCTURE *Structure; BASE_OBJECT *Structure;
UDWORD x,y; UDWORD x,y;
//if(droidType(Droid) != DROID_CONSTRUCT) return FALSE; //if(droidType(Droid) != DROID_CONSTRUCT) return FALSE;
@ -2561,9 +2565,9 @@ BOOL DroidIsBuilding(DROID *Droid)
{ {
// Moving to build location? // Moving to build location?
return FALSE; return FALSE;
}
} else if (orderStateObj(Droid, DORDER_BUILD,(BASE_OBJECT**)&Structure) || // Is building or helping? else if (orderStateObj(Droid, DORDER_BUILD,&Structure) ||
orderStateObj(Droid, DORDER_HELPBUILD,(BASE_OBJECT**)&Structure)) orderStateObj(Droid, DORDER_HELPBUILD,&Structure)) // Is building or helping?
{ {
return TRUE; return TRUE;
} }
@ -2598,13 +2602,13 @@ BOOL DroidGoingToBuild(DROID *Droid)
// //
STRUCTURE *DroidGetBuildStructure(DROID *Droid) STRUCTURE *DroidGetBuildStructure(DROID *Droid)
{ {
STRUCTURE *Structure; BASE_OBJECT *Structure;
if(!orderStateObj(Droid, DORDER_BUILD,(BASE_OBJECT**)&Structure)) { if(!orderStateObj(Droid, DORDER_BUILD,&Structure)) {
orderStateObj(Droid, DORDER_HELPBUILD,(BASE_OBJECT**)&Structure); orderStateObj(Droid, DORDER_HELPBUILD,&Structure);
} }
return Structure; return (STRUCTURE*)Structure;
} }
// Get the first factory assigned to a command droid // Get the first factory assigned to a command droid

View File

@ -147,8 +147,8 @@ BOOL sendDroidSecondary(const DROID* psDroid, SECONDARY_ORDER sec, SECONDARY_STA
BOOL recvDroidSecondary() BOOL recvDroidSecondary()
{ {
DROID* psDroid; DROID* psDroid;
SECONDARY_ORDER sec; SECONDARY_ORDER sec = DSO_ATTACK_RANGE;
SECONDARY_STATE state; SECONDARY_STATE state = DSS_NONE;
NETbeginDecode(NET_SECONDARY); NETbeginDecode(NET_SECONDARY);
{ {
@ -650,11 +650,11 @@ BOOL SendGroupOrderGroup(const DROID_GROUP* psGroup, DROID_ORDER order, uint32_t
// receive a group order. // receive a group order.
BOOL recvGroupOrder() BOOL recvGroupOrder()
{ {
DROID_ORDER order; DROID_ORDER order = DORDER_NONE;
BOOL subType, cmdOrder; BOOL subType, cmdOrder;
uint32_t destId, x, y; uint32_t destId, x, y;
OBJECT_TYPE destType; OBJECT_TYPE destType = OBJ_DROID; // Dummy initialisation to workaround NETenum macro
uint8_t droidCount, i; uint8_t droidCount, i;
uint32_t* droidIDs; uint32_t* droidIDs;
@ -792,7 +792,7 @@ BOOL recvDroidInfo()
{ {
uint32_t droidId; uint32_t droidId;
DROID* psDroid; DROID* psDroid;
DROID_ORDER order; DROID_ORDER order = DORDER_NONE;
BOOL subType; BOOL subType;
// Get the droid // Get the droid
@ -811,7 +811,7 @@ BOOL recvDroidInfo()
if (subType) if (subType)
{ {
uint32_t destId, destType; uint32_t destId, destType = 0;
NETuint32_t(&destId); NETuint32_t(&destId);
NETenum(&destType); NETenum(&destType);