Skip to content

Commit

Permalink
Kill some dead code. Fix some indentation. Make HCI a tiny bit less h…
Browse files Browse the repository at this point in the history
…orrible.
  • Loading branch information
perim committed Dec 5, 2010
1 parent 06acd4c commit 843332f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 154 deletions.
6 changes: 0 additions & 6 deletions src/droid.c
Expand Up @@ -4650,12 +4650,6 @@ void deleteTemplateFromProduction(DROID_TEMPLATE *psTemplate, UBYTE player, QUEU
{
structSetManufacture(psStruct, psNextTemplate, ModeQueue); // ModeQueue because production lists aren't synchronised.
}
else
{
//nothing more to manufacture - reset the Subject and Tab on HCI Form
intManufactureFinished(psStruct);
//power is returned by factoryProdAdjust()
}
}

//tell the interface
Expand Down
178 changes: 30 additions & 148 deletions src/hci.c
Expand Up @@ -1619,18 +1619,6 @@ INT_RETVAL intRunWidgets(void)
/* Update the object list if necessary */
if (intMode == INT_OBJECT || intMode == INT_STAT || intMode == INT_CMDORDER)
{
/* switch (objMode)
{
case IOBJ_BUILD:
psObjList = (BASE_OBJECT *)apsDroidLists[selectedPlayer];
break;
case IOBJ_MANUFACTURE:
psObjList = (BASE_OBJECT *)apsStructLists[selectedPlayer];
break;
case IOBJ_RESEARCH:
psObjList = (BASE_OBJECT *)apsStructLists[selectedPlayer];
break;
}*/
// see if there is a dead object in the list
for(i=0; i<numObjects; i++)
{
Expand Down Expand Up @@ -1697,7 +1685,6 @@ INT_RETVAL intRunWidgets(void)
}
objectsChanged = false;


if(bLoadSaveUp)
{
if(runLoadSave(true))// check for file name.
Expand Down Expand Up @@ -2454,17 +2441,13 @@ static void intAddObjectStats(BASE_OBJECT *psObj, UDWORD id)
// NOTE! more pruning [future ref]
for(j=0; j<numStatsListEntries; j++)
{
//this can't be assumed cos we've added some more icons and they have higher #define values than QUESTIONMARK!
//entryIN = asResearch[pList[j]].iconID;
//if(entryIN<mapRIDToIcon(RID_ROCKET) || entryIN>mapRIDToIcon(RID_QUESTIONMARK))
iconNumber = mapIconToRID(asResearch[pList[j]].iconID);
if (iconNumber < 0)
iconNumber = mapIconToRID(asResearch[pList[j]].iconID);
if (iconNumber < 0)
{
pSList[count++] = pList[j];
}
}


//fill up the list with topics
for (i=0; i < numStatsListEntries; i++)
{
Expand Down Expand Up @@ -2903,15 +2886,15 @@ static void intProcessStats(UDWORD id)
widgSetTabs(psWScreen, IDOBJ_TABFORM, objMajor,objMinor);

// Close the object box as well if selecting a location to build- no longer hide/reveal
//or if selecting a structure to demolish
// or if selecting a structure to demolish
if (objMode == IOBJ_BUILDSEL || objMode == IOBJ_DEMOLISHSEL)
{
if(driveModeActive()) {
if (driveModeActive())
{
// Make sure weve got a construction droid selected.
//if(driveGetDriven()->droidType != DROID_CONSTRUCT) {
if(driveGetDriven()->droidType != DROID_CONSTRUCT &&
driveGetDriven()->droidType != DROID_CYBORG_CONSTRUCT) {
//PD30 driveSelectionChanged();
if (driveGetDriven()->droidType != DROID_CONSTRUCT
&& driveGetDriven()->droidType != DROID_CYBORG_CONSTRUCT)
{
driveDisableControl();
}
driveDisableTactical();
Expand All @@ -2920,15 +2903,12 @@ static void intProcessStats(UDWORD id)
}

intRemoveObject();
//hack to stop the stats window re-opening in demolish mode
if (objMode == IOBJ_DEMOLISHSEL)
{
IntRefreshPending = false;
}

// hack to stop the stats window re-opening in demolish mode
if (objMode == IOBJ_DEMOLISHSEL)
{
IntRefreshPending = false;
}
}


}
}
}
Expand Down Expand Up @@ -3090,47 +3070,24 @@ void intSetMapPos(UDWORD x, UDWORD y)
//
void intObjectSelected(BASE_OBJECT *psObj)
{
/* Remove whatever is up */
// intResetScreen(false);

if(psObj) {
// intResetScreen(true);
if(psObj)
{
setWidgetsStatus(true);
switch(psObj->type)
{
case OBJ_DROID:
/* stop build interface appearing for constuction droids
if (droidType((DROID *)psObj) == DROID_CONSTRUCT)
{
intResetScreen(false);
intAddBuild((DROID *)psObj);
}
else*/

// if(!OrderUp)
// {
// intResetScreen(false);
// }
// intAddOrder((DROID *)psObj);
// intMode = INT_ORDER;


if(!OrderUp)
{
intResetScreen(false);
//changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99
//intAddOrder((DROID *)psObj);
intAddOrder(psObj);
// changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99
intAddOrder(psObj);
intMode = INT_ORDER;
}
else
{
//changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99
//intAddOrder((DROID *)psObj);
intAddOrder(psObj);
// changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99
intAddOrder(psObj);
}


break;

case OBJ_STRUCTURE:
Expand Down Expand Up @@ -3161,29 +3118,20 @@ void intObjectSelected(BASE_OBJECT *psObj)

//widgHide(psWScreen, IDOBJ_FORM);
}
// for(psStruct = apsStructLists[selectedPlayer]; psStruct; psStruct=psStruct->psNext)
// {
// psStruct->selected = false;
// }
// ((STRUCTURE*)psObj)->selected = true; // wrong place?
}
break;
default:
break;
}
} else {
intResetScreen(false);
// if(OrderUp) {
// intRemoveOrder();
// }
}
}


// add the construction interface if a constructor droid is selected
void intConstructorSelected(DROID *psDroid)
{
// intResetScreen(false);
setWidgetsStatus(true);
intAddBuild(psDroid);
widgHide(psWScreen, IDOBJ_FORM);
Expand All @@ -3203,40 +3151,18 @@ extern void FinishStructurePosition(UDWORD xPos,UDWORD yPos,void *UserData);
static void intStartStructPosition(BASE_STATS *psStats)
{
init3DBuilding(psStats,NULL,NULL);

/*if ((intMode == INT_OBJECT || intMode == INT_STAT) && objMode == IOBJ_BUILDSEL) {
widgGetTabs(psWScreen, IDOBJ_TABFORM, &objMajor, &objMinor);
// Hide the object form while we select a position.
//widgHide(psWScreen,IDOBJ_TABFORM); only need to hide the top form -all else follows
widgHide(psWScreen,IDOBJ_FORM);
}*/
}


/* Stop looking for a structure location */
static void intStopStructPosition(void)
{
/* Check there is still a struct position running */
// if (intMode == INT_OBJECT && objMode == IOBJ_BUILDSEL) {
if ((intMode == INT_OBJECT || intMode == INT_STAT) && objMode == IOBJ_BUILDSEL) {
if ((intMode == INT_OBJECT || intMode == INT_STAT) && objMode == IOBJ_BUILDSEL)
{
// Reset the stats button
// widgGetTabs(psWScreen, IDOBJ_FORM, &objMajor, &objMinor);
// widgEndScreen(psWScreen);

/*if(DroidIsBuilding((DROID *)psObjSelected)) {
STRUCTURE *Structure = DroidGetBuildStructure((DROID *)psObjSelected);
ASSERT( Structure!=NULL,"Bad structure pointer" );
intSetStats(objStatID,(BASE_STATS*)Structure->pStructureType);
} else if(DroidGoingToBuild((DROID *)psObjSelected)) {
intSetStats(objStatID,DroidGetBuildStats((DROID *)psObjSelected));
} else {
intSetStats(objStatID,NULL);
}*/

// widgStartScreen(psWScreen);
objMode = IOBJ_BUILD;
}

kill3DBuilding();
}

Expand Down Expand Up @@ -3346,11 +3272,9 @@ void intBuildFinished(DROID *psDroid)
UDWORD droidID;
DROID *psCurr;

ASSERT( psDroid != NULL,
"intBuildFinished: Invalid droid pointer" );
ASSERT(psDroid != NULL, "Invalid droid pointer");

if ((intMode == INT_OBJECT || intMode == INT_STAT) &&
//(objMode == IOBJ_BUILDSEL || objMode == IOBJ_BUILD))
objMode == IOBJ_BUILD)
{
/* Find which button the droid is on and clear it's stats */
Expand Down Expand Up @@ -3380,7 +3304,6 @@ void intBuildStarted(DROID *psDroid)
"intBuildStarted: Invalid droid pointer" );

if ((intMode == INT_OBJECT || intMode == INT_STAT) &&
//(objMode == IOBJ_BUILDSEL || objMode == IOBJ_BUILD))
objMode == IOBJ_BUILD)
{
/* Find which button the droid is on and clear it's stats */
Expand Down Expand Up @@ -3581,14 +3504,14 @@ void intManufactureFinished(STRUCTURE *psBuilding)
{
break;
}
}
//order the list
orderFactories();
}
// order the list
orderFactories();

//now look thru the list to see which one corresponds to the factory that has just finished
structureID = 0;
for (psObj = apsObjectList[structureID]; structureID < numObjects; structureID++)
{
// now look thru the list to see which one corresponds to the factory that has just finished
structureID = 0;
for (psObj = apsObjectList[structureID]; structureID < numObjects; structureID++)
{
if ((STRUCTURE *)psObj == psBuilding)
{
intSetStats(structureID + IDOBJ_STATSTART, NULL);
Expand Down Expand Up @@ -4897,12 +4820,7 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B
/* Note the object */
psObjSelected = psSelected;
objStatID = statID;
// We don't want to be locking the button for command droids.
// widgSetButtonState(psWScreen, statID, WBUT_CLICKLOCK);

//changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99
//intAddOrder((DROID *)psSelected);
intAddOrder(psSelected);
intAddOrder(psSelected);
widgSetButtonState(psWScreen, statID, WBUT_CLICKLOCK);

intMode = INT_CMDORDER;
Expand Down Expand Up @@ -5279,11 +5197,8 @@ static void intSetStats(UDWORD id, BASE_STATS *psStats)
sLabInit.pText = "BUG! (d)";
sLabInit.FontID = font_regular;


if (psStats)
{
// sButInit.pText = "S";
//sFormInit.pTip = psStats->pName;
// If it's a droid the name might not be a stringID
if (psStats->ref >= REF_TEMPLATE_START &&
psStats->ref < REF_TEMPLATE_START + REF_RANGE)
Expand All @@ -5296,8 +5211,6 @@ static void intSetStats(UDWORD id, BASE_STATS *psStats)
}

BufferID = (sFormInit.id-IDOBJ_STATSTART)*2+1;
// DBPRINTF(("2 *sFormInit.id-IDOBJ_STATSTART : %d\n",BufferID));
// BufferID = GetObjectBuffer();
ASSERT( BufferID < NUM_OBJECTBUFFERS,"BufferID > NUM_OBJECTBUFFERS" );
ClearObjectButtonBuffer(BufferID);
RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]);
Expand All @@ -5308,23 +5221,17 @@ static void intSetStats(UDWORD id, BASE_STATS *psStats)
// Add a text label for the size of the production run.
sLabInit.pCallback = intUpdateQuantity;
sLabInit.pUserData = sBarInit.pUserData;
// sFormInit.pUserData = (void*)intGetObject(id);
}
else
{
// sButInit.pText = "NONE";
sFormInit.pTip = NULL;

BufferID = (sFormInit.id-IDOBJ_STATSTART)*2+1;
// DBPRINTF(("2 sFormInit.id-IDOBJ_STATSTART : %d\n",BufferID));
// BufferID = GetObjectBuffer();
ASSERT( BufferID < NUM_OBJECTBUFFERS,"BufferID > NUM_OBJECTBUFFERS" );
ClearObjectButtonBuffer(BufferID);
RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]);
sFormInit.pUserData = &ObjectBuffers[BufferID];

// sFormInit.pUserData = NULL;

/* Reset the stats screen button if necessary */
if ((INTMODE)objMode == INT_STAT && statID != 0)
{
Expand All @@ -5347,8 +5254,6 @@ static void intSetStats(UDWORD id, BASE_STATS *psStats)
{
widgSetButtonState(psWScreen, id, WBUT_CLICKLOCK);
}


}

/* Add the stats widgets to the widget screen */
Expand Down Expand Up @@ -6487,29 +6392,6 @@ static void intStatsRMBPressed(UDWORD id)
// Reset the button on the object form
intSetStats(objStatID, (BASE_STATS *)psNext);
}
#if 0
// set the current Template
psCurrTemplate = apsDroidTemplates[selectedPlayer];
while (psStats != psCurrTemplate)
{
//if get to the last template in the list, use this one
if (psCurrTemplate->psNext == NULL)
{
break;
}
psCurrTemplate = psCurrTemplate->psNext;
}

//close the stats screen
intResetScreen(true);
// open up the design screen
widgSetButtonState(psWScreen, IDRET_DESIGN, WBUT_CLICKLOCK);

/*add the power bar - for looks! */
intShowPowerBar();
(void)intAddDesign( true );
intMode = INT_DESIGN;
#endif
}
}

Expand Down

0 comments on commit 843332f

Please sign in to comment.