From 0b9d017e35a2d434df7d69a0d9fb2084d12c0c8f Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Fri, 17 Dec 2010 20:06:53 +0100 Subject: [PATCH 01/10] Nuke some dead code. Tired of seeing it while grepping. --- src/hci.c | 335 ++++++++++-------------------------------------------- 1 file changed, 60 insertions(+), 275 deletions(-) diff --git a/src/hci.c b/src/hci.c index a22028c6e..b95b156e3 100644 --- a/src/hci.c +++ b/src/hci.c @@ -532,10 +532,8 @@ BOOL intInitialise(void) //create the list for the selected player //needs to be UWORD sized for Patches - pList = (UWORD *) malloc(sizeof (UWORD) * MAXRESEARCH); + pList = (UWORD *) malloc(sizeof (UWORD) * MAXRESEARCH); pSList = (UWORD *) malloc(sizeof (UWORD) * MAXRESEARCH); - //pList = (UBYTE *) malloc(sizeof (UBYTE) * MAXRESEARCH); - //pSList = (UBYTE *) malloc(sizeof (UBYTE) * MAXRESEARCH); if (pList == NULL) { @@ -560,19 +558,6 @@ BOOL intInitialise(void) return false; } - if(GetGameMode() == GS_NORMAL) { - //load up the 'blank' template imd - - -/* - if (pNewDesignIMD == NULL) - { - DBERROR(("Unable to load Blank Template IMD")); - return false; - } - */ - } - /* Create storage for the feature list */ apsFeatureList = (FEATURE_STATS **)malloc(sizeof(FEATURE_STATS *) * MAXFEATURES); @@ -663,7 +648,6 @@ BOOL intInitialise(void) outlineNotOK = WZCOL_MAP_OUTLINE_BAD; // reset the previous objects - //memset(apsPreviousObj, 0, sizeof(apsPreviousObj)); intResetPreviousObj(); // reset the jump positions @@ -704,7 +688,6 @@ void intResetPreviousObj(void) /* Shut down the in game interface */ void interfaceShutDown(void) { -// widgEndScreen(psWScreen); widgReleaseScreen(psWScreen); free(apsStructStatsList); @@ -790,12 +773,7 @@ static void intDoScreenRefresh(void) BOOL OrderWasUp = false; // If the stats form is up then remove it, but remember that it was up. -/* if(widgGetFromID(psWScreen,IDSTAT_FORM) != NULL) { - StatsWasUp = true; -// intRemoveStatsNoAnim(); - }*/ - if ( (intMode == INT_STAT) && - widgGetFromID(psWScreen,IDSTAT_FORM) != NULL ) + if ((intMode == INT_STAT) && widgGetFromID(psWScreen,IDSTAT_FORM) != NULL) { StatsWasUp = true; } @@ -834,10 +812,6 @@ static void intDoScreenRefresh(void) OrderWasUp = true; } - // if(widgGetFromID(psWScreen,IDOBJ_FORM) != NULL) { - // intRemoveObjectNoAnim(); - // } - switch(objMode) { case IOBJ_MANUFACTURE: // The manufacture screen (factorys on bottom bar) @@ -944,9 +918,7 @@ static void intHidePowerBar(void) /* Remove the options widgets from the widget screen */ static void intRemoveOptions(void) { -// widgEndScreen(psWScreen); widgDelete(psWScreen, IDOPT_FORM); -// widgStartScreen(psWScreen); } @@ -958,8 +930,6 @@ static BOOL intAddEdit(void) W_LABINIT sLabInit; W_BUTINIT sButInit; -// widgEndScreen(psWScreen); - memset(&sFormInit, 0, sizeof(W_FORMINIT)); memset(&sLabInit, 0, sizeof(W_LABINIT)); memset(&sButInit, 0, sizeof(W_BUTINIT)); @@ -1014,9 +984,7 @@ static BOOL intAddEdit(void) /* Remove the edit widgets from the widget screen */ static void intRemoveEdit(void) { -// widgEndScreen(psWScreen); widgDelete(psWScreen, IDED_FORM); -// widgStartScreen(psWScreen); } #endif @@ -1216,11 +1184,7 @@ void intResetScreen(BOOL NoAnim) break; case INT_MISSIONRES: -// if(NoAnim) { - intRemoveMissionResultNoAnim(); -// }else{ -// intRemoveMissionResult(); -// } + intRemoveMissionResultNoAnim(); break; @@ -1242,13 +1206,11 @@ void intResetScreen(BOOL NoAnim) eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DESIGN_QUIT); } - // pc if(!bMultiPlayer) { gameTimeStart(); } - break; case INT_INTELMAP: @@ -1271,16 +1233,6 @@ void intResetScreen(BOOL NoAnim) break; -/* case INT_TUTORIAL: - //remove 3dView - intRemoveMessageView(); - - if(!bMultiPlayer) - { - gameTimeStart(); - } - break;*/ - case INT_TRANSPORTER: if(NoAnim) { @@ -1296,14 +1248,11 @@ void intResetScreen(BOOL NoAnim) } intMode = INT_NORMAL; - //clearSel() sets IntRefreshPending = true by calling intRefreshScreen() but if we're doing this then we won't need to refresh - hopefully! + //clearSel() sets IntRefreshPending = true by calling intRefreshScreen() but if we're doing this then we won't need to refresh - hopefully! IntRefreshPending = false; } - - - // calulate the center world coords for a structure stat given // top left tile coords static void intCalcStructCenter(STRUCTURE_STATS *psStats, UDWORD tilex, UDWORD tiley, uint16_t direction, UDWORD *pcx, UDWORD *pcy) @@ -1393,7 +1342,6 @@ static void intProcessOptions(UDWORD id) intAddStats(ppsStatsList, i, NULL, NULL); intMode = INT_EDITSTAT; editPosMode = IED_NOPOS; -// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); break; case IDOPT_STRUCT: intRemoveOptions(); @@ -1406,7 +1354,6 @@ static void intProcessOptions(UDWORD id) intAddStats(ppsStatsList, i, NULL, NULL); intMode = INT_EDITSTAT; editPosMode = IED_NOPOS; -// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); break; case IDOPT_FEATURE: intRemoveOptions(); @@ -1418,7 +1365,6 @@ static void intProcessOptions(UDWORD id) intAddStats(ppsStatsList, i, NULL, NULL); intMode = INT_EDITSTAT; editPosMode = IED_NOPOS; -// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); break; /* Close window buttons */ case IDOPT_TILE: @@ -1445,7 +1391,6 @@ static void intProcessOptions(UDWORD id) case IDOPT_CLOSE: intRemoveOptions(); intMode = INT_NORMAL; -// widgSetButtonState(psWScreen, IDRET_OPTIONS, 0); break; case IDOPT_IVISLIGHTING: if (pie_GetLightingState()) @@ -1574,8 +1519,6 @@ static void intProcessEditStats(UDWORD id) addConsoleMessage(buf, DEFAULT_JUSTIFY,SYSTEM_MESSAGE); #endif } -// else //Do we add this or does it not matter? -// ASSERT(false,"unexpected id [%d] found!",id); } @@ -1793,7 +1736,6 @@ INT_RETVAL intRunWidgets(void) case IDRET_OPTIONS: intResetScreen(false); -// widgSetButtonState(psWScreen, IDRET_OPTIONS, WBUT_CLICKLOCK); // commented out by ajl, now command droids menu (void)intAddOptions(); intMode = INT_OPTION; break; @@ -1837,7 +1779,7 @@ INT_RETVAL intRunWidgets(void) break; case IDRET_INTEL_MAP: -// //check if RMB was clicked + // check if RMB was clicked if (widgGetButtonKey(psWScreen) & WKEY_SECONDARY) { //set the current message to be the last non-proximity message added @@ -2037,10 +1979,6 @@ INT_RETVAL intRunWidgets(void) } } } -// if(!driveModeActive()) { -// ((DROID *)psObjSelected)->selected = false;//deselect the droid if build command successful -// DeSelectDroid((DROID*)psObjSelected); -// } if (!quickQueueMode) { @@ -2231,8 +2169,6 @@ static void intRunPower(void) //get the research points psResearch = (RESEARCH *)ppResearchList[statID - IDSTAT_START]; - -// if (asPlayerResList[selectedPlayer][psResearch - asResearch].researched != CANCELLED_RESEARCH) // has research been not been canceled if (IsResearchCancelled(&asPlayerResList[selectedPlayer][psResearch - asResearch])==0) { @@ -2457,23 +2393,23 @@ static void intAddObjectStats(BASE_OBJECT *psObj, UDWORD id) intAddStats(ppsStatsList, numStatsListEntries, psStats, psObj); - //get the tab positions for the new stat form - psForm = (W_TABFORM*)widgGetFromID(psWScreen,IDSTAT_TABFORM); - if (psForm != NULL) - { - newStatMajor = psForm->numMajor; - newStatMinor = psForm->asMajor[statMajor].numMinor; + // get the tab positions for the new stat form + psForm = (W_TABFORM*)widgGetFromID(psWScreen,IDSTAT_TABFORM); + if (psForm != NULL) + { + newStatMajor = psForm->numMajor; + newStatMinor = psForm->asMajor[statMajor].numMinor; - // Restore the tab positions. - if ( (!psStats) && (widgGetFromID(psWScreen,IDSTAT_FORM) != NULL) ) - { - //only restore if we've still got at least that many tabs - if (newStatMajor > statMajor && newStatMinor > statMinor) - { - widgSetTabs(psWScreen, IDSTAT_TABFORM, statMajor, statMinor); - } - } - } + // Restore the tab positions. + if ((!psStats) && (widgGetFromID(psWScreen,IDSTAT_FORM) != NULL)) + { + // only restore if we've still got at least that many tabs + if (newStatMajor > statMajor && newStatMinor > statMinor) + { + widgSetTabs(psWScreen, IDSTAT_TABFORM, statMajor, statMinor); + } + } + } intMode = INT_STAT; /* Note the object */ @@ -2495,10 +2431,6 @@ static void intSelectDroid(BASE_OBJECT *psObj) clearSel(); ((DROID*)psObj)->selected = true; driveSelectionChanged(); -// clearSelection(); -// ((DROID*)psObj)->selected = true; -// StopDriverMode(); -// StartDriverMode(); driveDisableControl(); } else { clearSelection(); @@ -2532,7 +2464,6 @@ static void intResetWindows(BASE_OBJECT *psObj) default: break; } - //intAddObjectStats(psObj, id); } } @@ -2658,7 +2589,6 @@ static void intProcessObject(UDWORD id) { camToggleStatus(); } - // intSetMapPos(asJumpPos[butIndex].x, asJumpPos[butIndex].y); asJumpPos[butIndex].x = 0; asJumpPos[butIndex].y = 0; @@ -2708,8 +2638,6 @@ static void intProcessObject(UDWORD id) } else if (psObj->type == OBJ_STRUCTURE) { -// clearSelection(); -// psObj->selected = true; if (StructIsFactory((STRUCTURE *)psObj)) { @@ -3637,9 +3565,6 @@ BOOL intAddReticule(void) //options button sButInit.style = WBUT_PLAIN; SetReticuleButPos(RETBUT_COMMAND,&sButInit); -// sButInit.x = 19+RETXOFFSET; -// sButInit.y = 35+RETYOFFSET; - // sButInit.pText = "O"; sButInit.pTip = _("Commanders (F6)"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_COMMANDDROID_UP; @@ -3653,9 +3578,6 @@ BOOL intAddReticule(void) sButInit.style = WBUT_PLAIN | WFORM_SECONDARY; sButInit.id = IDRET_INTEL_MAP; SetReticuleButPos(RETBUT_INTELMAP,&sButInit); -// sButInit.x = 19+RETXOFFSET; -// sButInit.y = 70+RETYOFFSET; - // sButInit.pText = "S"; sButInit.pTip = _("Intelligence Display (F5)"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_INTELMAP_UP; @@ -3669,9 +3591,6 @@ BOOL intAddReticule(void) sButInit.style = WBUT_PLAIN; sButInit.id = IDRET_MANUFACTURE; SetReticuleButPos(RETBUT_FACTORY,&sButInit); -// sButInit.x = 53+RETXOFFSET; -// sButInit.y = 17+RETYOFFSET; - // sButInit.pText = "M"; sButInit.pTip = _("Manufacture (F1)"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_MANUFACTURE_UP; @@ -3685,9 +3604,6 @@ BOOL intAddReticule(void) sButInit.style = WBUT_PLAIN; sButInit.id = IDRET_DESIGN; SetReticuleButPos(RETBUT_DESIGN,&sButInit); -// sButInit.x = 53+RETXOFFSET; -// sButInit.y = 88+RETYOFFSET; - // sButInit.pText = "D"; sButInit.pTip = _("Design (F4)"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_DESIGN_UP; @@ -3701,9 +3617,6 @@ BOOL intAddReticule(void) sButInit.style = WBUT_PLAIN; sButInit.id = IDRET_RESEARCH; SetReticuleButPos(RETBUT_RESEARCH,&sButInit); -// sButInit.x = 87+RETXOFFSET; -// sButInit.y = 35+RETYOFFSET; - // sButInit.pText = "R"; sButInit.pTip = _("Research (F2)"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_RESEARCH_UP; @@ -3717,9 +3630,6 @@ BOOL intAddReticule(void) sButInit.style = WBUT_PLAIN; sButInit.id = IDRET_BUILD; SetReticuleButPos(RETBUT_BUILD,&sButInit); -// sButInit.x = 87+RETXOFFSET; -// sButInit.y = 70+RETYOFFSET; - // sButInit.pText = "B"; sButInit.pTip = _("Build (F3)"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_BUILD_UP; @@ -3733,11 +3643,8 @@ BOOL intAddReticule(void) sButInit.style = WBUT_PLAIN; sButInit.id = IDRET_CANCEL; SetReticuleButPos(RETBUT_CANCEL,&sButInit); -// sButInit.x = 48+RETXOFFSET; -// sButInit.y = 49+RETYOFFSET; sButInit.width = RET_BUTWIDTH + 10; sButInit.height = RET_BUTHEIGHT + 8; - // sButInit.pText = "C"; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayReticuleButton; sButInit.UserData = IMAGE_CANCEL_UP; @@ -3745,7 +3652,6 @@ BOOL intAddReticule(void) { return false; } - // intCheckReticuleButtons(); ReticuleUp = true; } @@ -3838,8 +3744,6 @@ BOOL intAddOptions(void) UDWORD player; char aText[WIDG_MAXSTR]; -// widgEndScreen(psWScreen); - memset(&sFormInit, 0, sizeof(W_FORMINIT)); memset(&sLabInit, 0, sizeof(W_LABINIT)); memset(&sButInit, 0, sizeof(W_BUTINIT)); @@ -4167,7 +4071,6 @@ BOOL intAddOptions(void) widgSetButtonState(psWScreen, IDOPT_IVISLIGHTING, WBUT_CLICKLOCK); } -// widgStartScreen(psWScreen); widgSetButtonState(psWScreen, IDOPT_PLAYERSTART + selectedPlayer, WBUT_LOCK); return true; @@ -4283,14 +4186,6 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B //order the objects according to what they are orderObjectInterface(); -// wont ever get here cause if theres no research facility then the research reticule button -// is disabled so commented out. -// if (numObjects == 0 && objMode == IOBJ_RESEARCH) -// { -// audio_QueueTrack(ID_SOUND_RESEARCH_FAC_REQ); -// return false; -// } - // set the selected object if necessary if (psSelected == NULL) { @@ -4364,12 +4259,12 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B FormY = sFormInit.y; sFormInit.width = OBJ_BACKWIDTH; sFormInit.height = OBJ_BACKHEIGHT; -// If the window was closed then do open animation. + // If the window was closed then do open animation. if(Animate) { sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; } else { -// otherwise just recreate it. + // otherwise just recreate it. sFormInit.pDisplay = intDisplayPlainForm; } if (!widgAddForm(psWScreen, &sFormInit)) @@ -4455,7 +4350,7 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B //right click on a Template will put the production on hold sBFormInit2.style = WFORM_CLICKABLE | WFORM_SECONDARY; -// Action progress bar. + // Action progress bar. sBarInit.formID = IDOBJ_OBJSTART; sBarInit.id = IDOBJ_PROGBARSTART; sBarInit.style = WBAR_TROUGH | WIDG_HIDDEN; @@ -4469,16 +4364,15 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B sBarInit.sMinorCol = WZCOL_ACTION_PROGRESS_BAR_MINOR; sBarInit.pTip = _("Progress Bar"); - //object output bar ie manuf power o/p, research power o/p + // object output bar ie manuf power o/p, research power o/p memcpy(&sBarInit2,&sBarInit,sizeof(W_BARINIT)); sBarInit2.id = IDOBJ_POWERBARSTART; sBarInit2.style = WBAR_PLAIN; sBarInit2.x = STAT_POWERBARX; sBarInit2.y = STAT_POWERBARY; sBarInit2.size = 50; - //don't set the tip cos we haven't got a suitable text string at this point - 2/2/99 - //sBarInit2.pTip = _("Build Speed"); - sBarInit2.pTip = NULL; + // don't set the tip cos we haven't got a suitable text string at this point - 2/2/99 + sBarInit2.pTip = NULL; memset(&sLabInit,0,sizeof(W_LABINIT)); sLabInit.id = IDOBJ_COUNTSTART; @@ -4556,14 +4450,13 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B sBarInit2.size = WBAR_SCALE; } } - // sBFormInit.pTip = ((DROID *)psObj)->pName; sBFormInit.pTip = droidGetName((DROID *)psObj); break; case OBJ_STRUCTURE: - // Get the construction power of a structure.. + // Get the construction power of a structure Structure = (STRUCTURE *)psObj; switch(Structure->pStructureType->type) { case REF_FACTORY: @@ -4633,9 +4526,7 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B sLabIntObjText.id++; } // Add the power bar. - if (psObj->type != OBJ_DROID || - (((DROID *)psObj)->droidType == DROID_CONSTRUCT || - ((DROID *)psObj)->droidType == DROID_CYBORG_CONSTRUCT)) + if (psObj->type != OBJ_DROID || (((DROID *)psObj)->droidType == DROID_CONSTRUCT || ((DROID *)psObj)->droidType == DROID_CYBORG_CONSTRUCT)) { sBarInit2.formID = sBFormInit.id; sBarInit.iRange = GAME_TICKS_PER_SEC; @@ -4662,7 +4553,6 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B // the experience stars sLabInitCmdExp.formID = sBFormInit.id; sLabInitCmdExp.pCallback = intUpdateCommandExp; - // sLabInitCmdExp.pDisplay = intDisplayCommandExp; sLabInitCmdExp.pUserData = psObj; if (!widgAddLabel(psWScreen, &sLabInitCmdExp)) { @@ -4839,7 +4729,6 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B } } -// widgStartScreen(psWScreen); widgSetTabs(psWScreen, IDOBJ_TABFORM, (UWORD)displayForm, 0); // if the selected object isn't on one of the main buttons (too many objects) @@ -4883,7 +4772,6 @@ static BOOL intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,B intShowPowerBar(); } -// if ((objMode==IOBJ_RESEARCH) && bInTutorial) if (bInTutorial) { debug( LOG_NEVER, "Go with object open callback!\n" ); @@ -4924,7 +4812,7 @@ void intRemoveObject(void) widgDelete(psWScreen, IDOBJ_TABFORM); widgDelete(psWScreen, IDOBJ_CLOSE); -// Start the window close animation. + // Start the window close animation. Form = (W_TABFORM*)widgGetFromID(psWScreen,IDOBJ_FORM); if(Form) { Form->display = intClosePlainForm; @@ -4956,19 +4844,10 @@ static void intRemoveObjectNoAnim(void) widgDelete(psWScreen, IDOBJ_CLOSE); widgDelete(psWScreen, IDOBJ_FORM); - - ClearObjectBuffers(); ClearTopicBuffers(); intHidePowerBar(); - -/* if (bInTutorial) - { - DBPRINTF(("Go with object close callback!(noanim)\n")); - eventFireCallbackTrigger(CALL_OBJECTCLOSE); - }*/ - } @@ -5026,7 +4905,7 @@ void HandleClosingWindows(void) if(ClosingObject) { Widg = widgGetFromID(psWScreen,IDOBJ_FORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDOBJ_FORM); ClosingObject = false; @@ -5039,7 +4918,7 @@ void HandleClosingWindows(void) if(ClosingStats) { Widg = widgGetFromID(psWScreen,IDSTAT_FORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDSTAT_FORM); ClosingStats = false; @@ -5051,7 +4930,7 @@ void HandleClosingWindows(void) if(ClosingMessageView) { Widg = widgGetFromID(psWScreen,IDINTMAP_MSGVIEW); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDINTMAP_MSGVIEW); ClosingMessageView = false; @@ -5063,7 +4942,7 @@ void HandleClosingWindows(void) if(ClosingIntelMap) { Widg = widgGetFromID(psWScreen,IDINTMAP_FORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDINTMAP_FORM); ClosingIntelMap = false; @@ -5076,7 +4955,7 @@ void HandleClosingWindows(void) if(ClosingOrder) { Widg = widgGetFromID(psWScreen,IDORDER_FORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDORDER_FORM); ClosingOrder = false; @@ -5088,7 +4967,7 @@ void HandleClosingWindows(void) if(ClosingTrans) { Widg = widgGetFromID(psWScreen,IDTRANS_FORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDTRANS_FORM); ClosingTrans = false; @@ -5100,7 +4979,7 @@ void HandleClosingWindows(void) if(ClosingTransCont) { Widg = widgGetFromID(psWScreen,IDTRANS_CONTENTFORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDTRANS_CONTENTFORM); ClosingTransCont = false; @@ -5112,7 +4991,7 @@ void HandleClosingWindows(void) if(ClosingTransDroids) { Widg = widgGetFromID(psWScreen,IDTRANS_DROIDS); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, IDTRANS_DROIDS); ClosingTransDroids = false; @@ -5125,7 +5004,7 @@ void HandleClosingWindows(void) if(ClosingInGameOp) { Widg = widgGetFromID(psWScreen,INTINGAMEOP); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, INTINGAMEOP); ClosingInGameOp = false; @@ -5135,26 +5014,10 @@ void HandleClosingWindows(void) } } - //if(ClosingMissionRes) { - // Widg = widgGetFromID(psWScreen,IDMISSIONRES_FORM); - // if(Widg) { -// Has the window finished closing? - // if( ((UDWORD)Widg->pUserData) ) { - // intRemoveMissionResultNoAnim(); - // resetMissionPauseState(); //reset the pauses - // } - // } else { - // ClosingMissionRes = false; - // //reset the pauses - // resetMissionPauseState(); - // } - //} - - if(ClosingMultiMenu) { Widg = widgGetFromID(psWScreen,MULTIMENU_FORM); if(Widg) { -// Has the window finished closing? + // Has the window finished closing? if( Widg->pUserData ) { widgDelete(psWScreen, MULTIMENU_FORM); ClosingMultiMenu = false; @@ -5392,7 +5255,6 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, sButInit.y = STAT_SLDY; sButInit.width = iV_GetImageWidth(IntImages,IMAGE_INFINITE_DOWN); sButInit.height = iV_GetImageHeight(IntImages,IMAGE_INFINITE_DOWN); - // sButInit.pText = pCloseText; sButInit.pTip = _("Infinite Production"); sButInit.FontID = font_regular; sButInit.pDisplay = intDisplayButtonPressed; @@ -5563,8 +5425,8 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, (STAT_BUTWIDTH + STAT_GAP)) * ((STAT_HEIGHT - STAT_GAP) / (STAT_BUTHEIGHT + STAT_GAP)); -//================== adds L/R Scroll buttons =================================== -if (numForms(numStats, butPerForm)> MAX_TAB_SMALL_SHOWN) //only want these buttons when tab count >8 + //================== adds L/R Scroll buttons =================================== + if (numForms(numStats, butPerForm)> MAX_TAB_SMALL_SHOWN) //only want these buttons when tab count >8 { // Add the left tab scroll button memset(&sButInit, 0, sizeof(W_BUTINIT)); @@ -5601,7 +5463,7 @@ if (numForms(numStats, butPerForm)> MAX_TAB_SMALL_SHOWN) //only want these butto return false; } } -//==============buttons before tabbed form!========================== + //==============buttons before tabbed form!========================== // Add the tabbed form memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = IDSTAT_FORM; @@ -5623,11 +5485,10 @@ if (numForms(numStats, butPerForm)> MAX_TAB_SMALL_SHOWN) //only want these butto sFormInit.tabMajorGap = OBJ_TABOFFSET; sFormInit.pUserData = &StandardTab; sFormInit.pTabDisplay = intDisplayTab; - //Build menu can have up to 80 stats - so can research now 13/09/99 AB + // Build menu can have up to 80 stats - so can research now 13/09/99 AB // NOTE, there is really no limit now to the # of menu items we can have, // It is #defined in hci.h to be 200 now. [#define MAXSTRUCTURES 200] //Same goes for research. [#define MAXRESEARCH 200] -// if (( (objMode == IOBJ_MANUFACTURE) || (objMode == IOBJ_BUILD) || (objMode == IOBJ_RESEARCH)) && if (sFormInit.numMajor > MAX_TAB_STD_SHOWN) { //Just switching from normal sized tabs to smaller ones to fit more in form. sFormInit.pUserData = &SmallTab; @@ -5850,8 +5711,6 @@ donelab: sBarInit.id += 1; } -// widgStartScreen(psWScreen); - /* Set the correct page and button if necessary */ if (statID) { @@ -5889,7 +5748,6 @@ donelab: /* Select a command droid */ static BOOL selectCommand(BASE_OBJECT *psObj) { -// UDWORD i; DROID *psDroid; ASSERT( psObj != NULL && psObj->type == OBJ_DROID, @@ -5927,7 +5785,6 @@ static BOOL setCommandStats(WZ_DECL_UNUSED BASE_OBJECT *psObj, WZ_DECL_UNUSED BA /* Select a construction droid */ static BOOL selectConstruction(BASE_OBJECT *psObj) { -// UDWORD i; DROID *psDroid; ASSERT( psObj != NULL && psObj->type == OBJ_DROID, @@ -5935,20 +5792,11 @@ static BOOL selectConstruction(BASE_OBJECT *psObj) psDroid = (DROID *)psObj; //check the droid type - //if ( (psDroid->droidType == DROID_CONSTRUCT) && (psDroid->died == 0) ) - if ( (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == - DROID_CYBORG_CONSTRUCT) && (psDroid->died == 0) ) + if ((psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT) && (psDroid->died == 0)) { return true; } - /*for (i=0; i < psDroid->numProgs; i++) - { - if (psDroid->asProgs[i].psStats->order == ORDER_BUILD) - { - return true; - } - }*/ return false; } @@ -6141,16 +5989,6 @@ static BOOL setResearchStats(BASE_OBJECT *psObj, BASE_STATS *psStats) //meant to still be in the list but greyed out pPlayerRes = asPlayerResList[selectedPlayer] + count; - /*subtract the power required to research*/ - /*if (pPlayerRes->researched != CANCELLED_RESEARCH) - { - if (!usePower(selectedPlayer, pResearch->researchPower)) - { - addConsoleMessage("Research: No Power",DEFAULT_JUSTIFY,SYSTEM_MESSAGE); - return false; - } - }*/ - //set the subject up psResFacilty->psSubject = psStats; @@ -6167,12 +6005,9 @@ static BOOL setResearchStats(BASE_OBJECT *psObj, BASE_STATS *psStats) sendResearchStatus(psBuilding,count,selectedPlayer,true); // inform others, I'm researching this. MakeResearchStarted(pPlayerRes); - //psResFacilty->timeStarted = gameTime; psResFacilty->timeStarted = ACTION_START_TIME; - psResFacilty->timeStartHold = 0; - //this is no longer used...AB 30/06/99 - psResFacilty->timeToResearch = pResearch->researchPoints / - psResFacilty->researchPoints; + psResFacilty->timeStartHold = 0; + psResFacilty->timeToResearch = pResearch->researchPoints / psResFacilty->researchPoints; //check for zero research time - usually caused by 'silly' data! if (psResFacilty->timeToResearch == 0) { @@ -6277,18 +6112,7 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats) return false; } /*set the slider for this production */ - /*if (Quantity == 0) - { - widgSetSliderPos(psWScreen, IDSTAT_SLIDER, 0); - } - else - {*/ -//#ifdef INCLUDE_PRODSLIDER - widgSetSliderPos(psWScreen, IDSTAT_SLIDER, (UWORD)(ProductionRun-1)); -//#endif - //} - - + widgSetSliderPos(psWScreen, IDSTAT_SLIDER, (UWORD)(ProductionRun-1)); } else { // Stop manufacturing. //return half the power cost if cancelled mid production @@ -6346,8 +6170,6 @@ static BOOL intAddManufacture(STRUCTURE *psSelected) objMode = IOBJ_MANUFACTURE; /* Create the object screen with the required data */ - //return intAddObject((BASE_OBJECT *)apsStructLists[selectedPlayer], - return intAddObjectWindow((BASE_OBJECT *)interfaceStructList(), (BASE_OBJECT *)psSelected,true); } @@ -6367,8 +6189,6 @@ static BOOL intAddResearch(STRUCTURE *psSelected) objMode = IOBJ_RESEARCH; /* Create the object screen with the required data */ - //return intAddObject((BASE_OBJECT *)apsStructLists[selectedPlayer], - return intAddObjectWindow((BASE_OBJECT *)interfaceStructList(), (BASE_OBJECT *)psSelected,true); } @@ -6388,11 +6208,8 @@ static BOOL intAddCommand(DROID *psSelected) objMode = IOBJ_COMMAND; /* Create the object screen with the required data */ - //return intAddObject((BASE_OBJECT *)apsStructLists[selectedPlayer], - return intAddObjectWindow((BASE_OBJECT *)apsDroidLists[selectedPlayer], (BASE_OBJECT *)psSelected,true); - } @@ -6557,9 +6374,10 @@ void addIntelScreen(void) bRender3DOnly = true; radarOnScreen = false; - // Just display the 3d, no interface + // Just display the 3d, no interface displayWorld(); - // Upload the current display back buffer into system memory. + + // Upload the current display back buffer into system memory. pie_UploadDisplayBuffer(); radarOnScreen = radOnScreen; @@ -6569,40 +6387,18 @@ void addIntelScreen(void) //add all the intelligence screen interface (void)intAddIntelMap(); intMode = INT_INTELMAP; - - /*if (psCurrentMsg && psCurrentMsg->type == MSG_TUTORIAL) - { - //just display the message - if (psCurrentMsg->pViewData) - { - intAddMessageView(psCurrentMsg->type); - if (psCurrentMsg->pViewData->audioID != NO_AUDIO_MSG) - { - audio_PlayTrack(psCurrentMsg->pViewData->audioID); - } - intMode = INT_TUTORIAL; - } - } - else - { - widgSetButtonState(psWScreen, IDRET_INTEL_MAP, WBUT_CLICKLOCK); - //add the power bar - for looks! - (void)intAddPower(); - (void)intAddIntelMap(playImmediate); - intMode = INT_INTELMAP; - }*/ } //sets up the Transporter Screen as far as the interface is concerned void addTransporterInterface(DROID *psSelected, BOOL onMission) { - //if psSelected = NULL add interface but if psSelected != NULL make sure its not flying - if (!psSelected || (psSelected && !transporterFlying(psSelected))) - { - intResetScreen(false); - intAddTransporter(psSelected, onMission); - intMode = INT_TRANSPORTER; - } + // if psSelected = NULL add interface but if psSelected != NULL make sure its not flying + if (!psSelected || (psSelected && !transporterFlying(psSelected))) + { + intResetScreen(false); + intAddTransporter(psSelected, onMission); + intMode = INT_TRANSPORTER; + } } /*sets which list of structures to use for the interface*/ @@ -6622,7 +6418,6 @@ STRUCTURE* interfaceStructList(void) /*causes a reticule button to start flashing*/ void flashReticuleButton(UDWORD buttonID) { - W_TABFORM *psButton; //get the button for the id @@ -6632,13 +6427,11 @@ void flashReticuleButton(UDWORD buttonID) //set flashing byte to true psButton->UserData = (1 << 24) | psButton->UserData; } - } // stop a reticule button flashing void stopReticuleButtonFlash(UDWORD buttonID) { - WIDGET *psButton = widgGetFromID(psWScreen,buttonID); if (psButton) { @@ -6652,7 +6445,6 @@ void stopReticuleButtonFlash(UDWORD buttonID) flashTime = 0; psButton->UserData = PACKDWORD_QUAD(flashTime,flashing,DownTime,Index); } - } //displays the Power Bar @@ -6710,8 +6502,6 @@ BOOL intAddProximityButton(PROXIMITY_DISPLAY *psProxDisp, UDWORD inc) sBFormInit.majorID = 0; sBFormInit.minorID = 0; sBFormInit.style = WFORM_CLICKABLE; - //sBFormInit.width = iV_GetImageWidth(IntImages,IMAGE_GAM_ENMREAD); - //sBFormInit.height = iV_GetImageHeight(IntImages,IMAGE_GAM_ENMREAD); sBFormInit.width = PROX_BUTWIDTH; sBFormInit.height = PROX_BUTHEIGHT; //the x and y need to be set up each time the button is drawn - see intDisplayProximityBlips @@ -6954,7 +6744,7 @@ void intCheckReticuleButtons(void) only if research facility is free*/ void intCheckResearchButton(void) { - UWORD index, count; + UWORD index, count; STRUCTURE *psStruct; BOOL resFree = false; @@ -6974,9 +6764,7 @@ void intCheckResearchButton(void) if (resFree) { //set to value that won't be reached in fillResearchList - //needs to be UWORD sized for the Patches - index = (UWORD)(numResearch + 1); - //index = (UBYTE)(numResearch + 1); + index = (UWORD)(numResearch + 1); //calculate the list count = fillResearchList(pList,selectedPlayer, index, MAXRESEARCH); if (count) @@ -7124,7 +6912,6 @@ DROID *intGotoNextDroidType(DROID *CurrDroid,UDWORD droidType,BOOL AllowGroup) if(psDroid != CurrentDroid) { clearSel(); SelectDroid(psDroid); -// psDroid->selected = true; CurrentDroid = psDroid; Found = true; break; @@ -7143,7 +6930,6 @@ DROID *intGotoNextDroidType(DROID *CurrDroid,UDWORD droidType,BOOL AllowGroup) if(psDroid != CurrentDroid) { clearSel(); SelectDroid(psDroid); -// psDroid->selected = true; CurrentDroid = psDroid; Found = true; break; @@ -7194,4 +6980,3 @@ BOOL CoordInBuild(int x, int y) return true; } - From fd56775ad048ec01e581c81d4f4b9ae4559efdd7 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Fri, 17 Dec 2010 20:11:01 +0100 Subject: [PATCH 02/10] Remove never used INCLUDE_PRODSLIDER code from HCI. --- src/hci.c | 261 +----------------------------------------------------- 1 file changed, 3 insertions(+), 258 deletions(-) diff --git a/src/hci.c b/src/hci.c index b95b156e3..d974a9391 100644 --- a/src/hci.c +++ b/src/hci.c @@ -397,14 +397,6 @@ static BOOL powerBarUp = false; static BOOL StatsUp = false; static BASE_OBJECT *psStatsScreenOwner = NULL; -#ifdef INCLUDE_PRODSLIDER -// Size of a production run for manufacturing. -static UBYTE ProductionRun = 1; -#endif - -/* pointer to hold the imd to use for a new template in the design screen */ -//iIMDShape *pNewDesignIMD = NULL; - /* The previous object for each object bar */ static BASE_OBJECT *apsPreviousObj[IOBJ_MAX]; @@ -463,9 +455,6 @@ static SWORD CurrentDroidType = 0; /* Add the power bars */ static BOOL intAddPower(void); -/* Remove the power bars */ -//static void intRemovePower(void); - /* Set the shadow for the PowerBar */ static void intRunPower(void); @@ -504,10 +493,8 @@ BOOL intInitialise(void) widgSetTipColour(WZCOL_TOOLTIP_TEXT); if(GetGameMode() == GS_NORMAL) { -// WidgSetAudio(WidgetAudioCallback,ID_SOUND_HILIGHTBUTTON,ID_SOUND_SELECT); WidgSetAudio(WidgetAudioCallback,-1,ID_SOUND_SELECT); } else { -// WidgSetAudio(WidgetAudioCallback,FE_AUDIO_HILIGHTBUTTON,FE_AUDIO_SELECTBUT); WidgSetAudio(WidgetAudioCallback,-1,ID_SOUND_SELECT); } @@ -2177,14 +2164,6 @@ static void intRunPower(void) } } -#ifdef INCLUDE_PRODSLIDER - // Multiply the power quantity by the size of the production run. - if(objMode == IOBJ_MANUFACTURE) { - quantity *= widgGetSliderPos(psWScreen,IDSTAT_SLIDER) + 1; - } -#endif - - //update the power bars intSetShadowPower(quantity); } @@ -2198,70 +2177,6 @@ static void intRunPower(void) // Process stats screen. static void intRunStats(void) { -#ifdef INCLUDE_PRODSLIDER - UDWORD statID; - UDWORD Power = 0; - UBYTE Quantity; - BASE_OBJECT *psOwner; - STRUCTURE *psStruct; - FACTORY *psFactory; - - if(intMode != INT_EDITSTAT && objMode == IOBJ_MANUFACTURE) - { - psOwner = (BASE_OBJECT *)widgGetUserData(psWScreen, IDSTAT_SLIDERCOUNT); - psStruct = (STRUCTURE *)psOwner; - psFactory = (FACTORY *)psStruct->pFunctionality; - if (psFactory->psSubject) - { - Quantity = psFactory->quantity; - //adjust the infinity button if necessary - if (Quantity == NON_STOP_PRODUCTION) - { - widgSetButtonState(psWScreen, IDSTAT_INFINITE_BUTTON, - WBUT_CLICKLOCK); - } - } - else - { - //check if the infinite production button has been pressed - if (widgGetButtonState(psWScreen, IDSTAT_INFINITE_BUTTON) & - WBUT_CLICKLOCK) - { - Quantity = STAT_SLDSTOPS + 1; - } - else - { - Quantity = (UBYTE)(widgGetSliderPos(psWScreen,IDSTAT_SLIDER) + 1); - //Quantity = widgGetSliderPos(psWScreen,IDSTAT_SLIDER); - } - } - //check for available power if not non stop production - if (Quantity < STAT_SLDSTOPS) - { - /* Find out which button was hilited */ - statID = widgGetMouseOver(psWScreen); - if (statID >= IDSTAT_START && statID <= IDSTAT_END) - { - //get the template build points - Power = calcTemplatePower((DROID_TEMPLATE *)apsTemplateList[statID - IDSTAT_START]); - if (Power * Quantity > getPower(selectedPlayer)) - { - Quantity = (UBYTE)(getPower(selectedPlayer) / Power); - } - } - } - psFactory->quantity = Quantity; - - // fire the tutorial trigger if neccessary - if (bInTutorial && Quantity != ProductionRun && Quantity > 1) - { - eventFireCallbackTrigger((TRIGGER_TYPE)CALL_MANURUN); - } - - ProductionRun = Quantity; - } -#endif - BASE_OBJECT *psOwner; STRUCTURE *psStruct; FACTORY *psFactory; @@ -2862,25 +2777,6 @@ static void intProcessStats(UDWORD id) { // process the proximity blip buttons. } -#ifdef INCLUDE_PRODSLIDER - else if(id == IDSTAT_INFINITE_BUTTON) - { - // Process the infinte button. - //if the button is locked - unlock and vice versa - if (widgGetButtonState(psWScreen, IDSTAT_INFINITE_BUTTON) & - WBUT_CLICKLOCK) - { - //unlock - widgSetButtonState(psWScreen, IDSTAT_INFINITE_BUTTON, 0); - } - else - { - //lock - widgSetButtonState(psWScreen, IDSTAT_INFINITE_BUTTON, - WBUT_CLICKLOCK); - } - } -#endif else if(id == IDSTAT_LOOP_BUTTON) { // Process the loop button. @@ -3715,17 +3611,6 @@ BOOL intAddPower(void) return true; } - -/* Remove the power bar widgets */ -/*void intRemovePower(void) -{ - if (powerBarUp) - { - widgDelete(psWScreen, IDPOW_POWERBAR_T); - powerBarUp = false; - } -}*/ - /* Set the shadow power for the selected player */ // Now just sets the global variable ManuPower which is used in the power bar display callback. PD void intSetShadowPower(UDWORD quantity) @@ -4856,14 +4741,10 @@ void intRemoveStats(void) { W_TABFORM *Form; -#ifdef INCLUDE_PRODSLIDER - widgDelete(psWScreen, IDSTAT_SLIDERCOUNT); - widgDelete(psWScreen, IDSTAT_SLIDER); -#endif widgDelete(psWScreen, IDSTAT_CLOSE); widgDelete(psWScreen, IDSTAT_TABFORM); -// Start the window close animation. + // Start the window close animation. Form = (W_TABFORM*)widgGetFromID(psWScreen,IDSTAT_FORM); if(Form) { Form->display = intClosePlainForm; @@ -4882,10 +4763,6 @@ void intRemoveStats(void) /* Remove the stats widgets from the widget screen */ void intRemoveStatsNoAnim(void) { -#ifdef INCLUDE_PRODSLIDER - widgDelete(psWScreen, IDSTAT_SLIDERCOUNT); - widgDelete(psWScreen, IDSTAT_SLIDER); -#endif widgDelete(psWScreen, IDSTAT_CLOSE); widgDelete(psWScreen, IDSTAT_TABFORM); widgDelete(psWScreen, IDSTAT_FORM); @@ -5181,10 +5058,6 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, BOOL Animate = true; W_LABINIT sLabInit; FACTORY *psFactory; -#ifdef INCLUDE_PRODSLIDER - W_SLDINIT sSldInit; -#endif - //char sCaption[6]; // should this ever be called with psOwner == NULL? @@ -5228,12 +5101,12 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, sFormInit.y = (SWORD)STAT_Y; sFormInit.width = STAT_WIDTH; sFormInit.height = STAT_HEIGHT; -// If the window was closed then do open animation. + // If the window was closed then do open animation. if(Animate) { sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; } else { -// otherwise just recreate it. + // otherwise just recreate it. sFormInit.pDisplay = intDisplayPlainForm; } if (!widgAddForm(psWScreen, &sFormInit)) @@ -5242,83 +5115,6 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, return false; } -#ifdef INCLUDE_PRODSLIDER - // Add the quantity slider ( if it's a factory ). - if(objMode == IOBJ_MANUFACTURE) { - - //add the non stop production button - memset(&sButInit, 0, sizeof(W_BUTINIT)); - sButInit.formID = IDSTAT_FORM; - sButInit.id = IDSTAT_INFINITE_BUTTON; - sButInit.style = WBUT_PLAIN; - sButInit.x = STAT_SLDX + STAT_SLDWIDTH + 2; - sButInit.y = STAT_SLDY; - sButInit.width = iV_GetImageWidth(IntImages,IMAGE_INFINITE_DOWN); - sButInit.height = iV_GetImageHeight(IntImages,IMAGE_INFINITE_DOWN); - sButInit.pTip = _("Infinite Production"); - sButInit.FontID = font_regular; - sButInit.pDisplay = intDisplayButtonPressed; - sButInit.UserData = PACKDWORD_TRI(IMAGE_INFINITE_DOWN, IMAGE_INFINITE_HI, IMAGE_INFINITE_UP); - if (!widgAddButton(psWScreen, &sButInit)) - { - return false; - } - - //add the number display - memset(&sLabInit,0,sizeof(W_LABINIT)); - sLabInit.formID = IDSTAT_FORM; //0; - sLabInit.id = IDSTAT_SLIDERCOUNT; - sLabInit.style = WLAB_PLAIN; - sLabInit.x = (SWORD)(STAT_SLDX + STAT_SLDWIDTH + sButInit.width + 2); - sLabInit.y = STAT_SLDY + 3; - sLabInit.width = 16; - sLabInit.height = 16; - sLabInit.FontID = font_regular; - sLabInit.pUserData = psOwner; - //sLabInit.pCallback = intUpdateSlider; - sLabInit.pDisplay = intDisplayNumber; - if (!widgAddLabel(psWScreen, &sLabInit)) - { - return false; - } - - - memset(&sSldInit, 0, sizeof(W_SLDINIT)); - sSldInit.formID = IDSTAT_FORM; - sSldInit.id = IDSTAT_SLIDER; - sSldInit.style = WSLD_PLAIN; - sSldInit.x = STAT_SLDX; - sSldInit.y = STAT_SLDY; - sSldInit.width = STAT_SLDWIDTH; - sSldInit.height = STAT_SLDHEIGHT; - sSldInit.orientation = WSLD_LEFT; - sSldInit.numStops = STAT_SLDSTOPS-1; - sSldInit.barSize = iV_GetImageHeight(IntImages,IMAGE_SLIDER_BUT); - sSldInit.pos = 0; - if ( psOwner != NULL ) - { - psFactory = (FACTORY *)((STRUCTURE *)psOwner)->pFunctionality; - if (psFactory->psSubject) - { - if (psFactory->quantity > sSldInit.numStops) - { - sSldInit.pos = sSldInit.numStops; - } - else - { - sSldInit.pos = (UWORD)psFactory->quantity; - } - } - } - - sSldInit.pDisplay = intDisplaySlider; - if (!widgAddSlider(psWScreen, &sSldInit)) - { - return false; - } - } -#endif - // Add the quantity slider ( if it's a factory ). if(objMode == IOBJ_MANUFACTURE) { @@ -6079,57 +5875,6 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats) } } -#ifdef INCLUDE_PRODSLIDER - if (ProductionRun == 0) - { - //check if its because there isn't enough power - warning if it is - if (psStats) - { - (void)checkPower(selectedPlayer, ((DROID_TEMPLATE *)psStats)->powerPoints); - } - return false; - } - - Structure = (STRUCTURE*)psObj; - if (psStats != NULL) - { - //temp code to set non stop production up - if (ProductionRun == STAT_SLDSTOPS) - { - ProductionRun = NON_STOP_PRODUCTION; - } - /* check power if factory not on infinte production*/ - if (ProductionRun != NON_STOP_PRODUCTION) - { - if (!checkPower(selectedPlayer, ((DROID_TEMPLATE *)psStats)->powerPoints)) - { - return false; - } - } - /* Set the factory to build droid(s) */ - if (!structSetManufacture(Structure, (DROID_TEMPLATE *)psStats, ProductionRun)) - { - return false; - } - /*set the slider for this production */ - widgSetSliderPos(psWScreen, IDSTAT_SLIDER, (UWORD)(ProductionRun-1)); - } else { - // Stop manufacturing. - //return half the power cost if cancelled mid production - if (((FACTORY*)Structure->pFunctionality)->timeStarted != ACTION_START_TIME) - { - if (((FACTORY*)Structure->pFunctionality)->psSubject != NULL) - { - addPower(Structure->player, ((DROID_TEMPLATE *)((FACTORY*)Structure-> - pFunctionality)->psSubject)->powerPoints / 2); - } - } - ((FACTORY*)Structure->pFunctionality)->quantity = 0; - ((FACTORY*)Structure->pFunctionality)->psSubject = NULL; - intManufactureFinished(Structure); - } -#endif - return true; } From 40ef0f5788efcfcde38eaf9acbaa3bd0fcf1936d Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Fri, 17 Dec 2010 20:38:04 +0100 Subject: [PATCH 03/10] Fix warning about unused statements in switch statement. Remove unused define. --- src/hci.h | 3 --- src/order.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hci.h b/src/hci.h index 1430df7a8..b2e35da71 100644 --- a/src/hci.h +++ b/src/hci.h @@ -259,9 +259,6 @@ typedef enum { INT_MAXMODE, //leave as last so we can start the objMode at this value } INTMODE; -//NOT ANYMORE! 10/08/98 AB -//#define INCLUDE_PRODSLIDER // Include quantity slider in manufacture window. - extern INTMODE intMode; /* The widget screen */ diff --git a/src/order.c b/src/order.c index e66ca4dd4..fdf74feea 100644 --- a/src/order.c +++ b/src/order.c @@ -3097,6 +3097,8 @@ static void orderPlayOrderObjAudio( UDWORD player, BASE_OBJECT *psObj ) case DORDER_ATTACK: audio_QueueTrack( ID_SOUND_ON_OUR_WAY2 ); break; + default: + break; } } From d9813b37e5ab0ee36ecc630c016191b9828426ca Mon Sep 17 00:00:00 2001 From: Cyp Date: Wed, 8 Dec 2010 01:32:51 +0100 Subject: [PATCH 04/10] Fix crash when dumping too much syncDebug. --- lib/netplay/netplay.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/netplay/netplay.c b/lib/netplay/netplay.c index ea0e07881..6c67d8ef0 100644 --- a/lib/netplay/netplay.c +++ b/lib/netplay/netplay.c @@ -3089,7 +3089,7 @@ static void sendDebugSync(uint8_t *buf, uint32_t bufLen, uint32_t time) NETend(); } -static uint8_t debugSyncTmpBuf[1000000]; +static uint8_t debugSyncTmpBuf[2000000]; static void recvDebugSync(NETQUEUE queue) { uint32_t time = 0; @@ -3139,12 +3139,15 @@ bool checkDebugSync(uint32_t checkGameTime, uint32_t checkCrc) // Dump our version, and also erase it, so we only dump it at most once. debug(LOG_ERROR, "Inconsistent sync debug at gameTime %u. My version has %u lines, CRC = 0x%08X.", syncDebugGameTime[index], syncDebugNum[index], ~syncDebugCrcs[index] & 0xFFFFFFFF); bufSize += snprintf((char *)debugSyncTmpBuf + bufSize, ARRAY_SIZE(debugSyncTmpBuf) - bufSize, "===== BEGIN gameTime=%u, %u lines, CRC 0x%08X =====\n", syncDebugGameTime[index], syncDebugNum[index], ~syncDebugCrcs[index] & 0xFFFFFFFF); + bufSize = MIN(bufSize, ARRAY_SIZE(debugSyncTmpBuf)); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible. for (i = 0; i < syncDebugNum[index]; ++i) { bufSize += snprintf((char *)debugSyncTmpBuf + bufSize, ARRAY_SIZE(debugSyncTmpBuf) - bufSize, "[%s] %s\n", syncDebugFunctions[index][i], syncDebugStrings[index][i]); + bufSize = MIN(bufSize, ARRAY_SIZE(debugSyncTmpBuf)); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible. free(syncDebugStrings[index][i]); } bufSize += snprintf((char *)debugSyncTmpBuf + bufSize, ARRAY_SIZE(debugSyncTmpBuf) - bufSize, "===== END gameTime=%u, %u lines, CRC 0x%08X =====\n", syncDebugGameTime[index], syncDebugNum[index], ~syncDebugCrcs[index] & 0xFFFFFFFF); + bufSize = MIN(bufSize, ARRAY_SIZE(debugSyncTmpBuf)); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible. if (numDumps < 5) { ++numDumps; From 3e301fbe37e2fe4f88aafe9705fe65614cf53dda Mon Sep 17 00:00:00 2001 From: Cyp Date: Fri, 17 Dec 2010 23:44:58 +0100 Subject: [PATCH 05/10] Fix desynch when units are repaired, and the repair facility flag is not in the default position. Was droids moving without sending a net message to the flags, even though the flags aren't currently synchronised. --- src/structure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/structure.c b/src/structure.c index f6df765e1..6a6f7b14c 100644 --- a/src/structure.c +++ b/src/structure.c @@ -3215,7 +3215,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission) objTrace(psDroid->id, "Repair not needed - move to delivery point"); orderDroidLoc(psDroid, DORDER_MOVE, psRepairFac->psDeliveryPoint->coords.x, - psRepairFac->psDeliveryPoint->coords.y, ModeImmediate); + psRepairFac->psDeliveryPoint->coords.y, ModeQueue); // ModeQueue because delivery points are not yet synchronised! } continue; } @@ -3701,7 +3701,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission) objTrace(psDroid->id, "Repair complete - move to delivery point"); orderDroidLoc( psDroid, DORDER_MOVE, psRepairFac->psDeliveryPoint->coords.x, - psRepairFac->psDeliveryPoint->coords.y, ModeImmediate); + psRepairFac->psDeliveryPoint->coords.y, ModeQueue); // ModeQueue because delivery points are not yet synchronised! } } } From e98e5a41bb6b570b2b5a1479aa4fe7c9ee559546 Mon Sep 17 00:00:00 2001 From: Cyp Date: Sat, 18 Dec 2010 00:24:34 +0100 Subject: [PATCH 06/10] Make Esc be equivalent to clicking the return button in the pre-game "multiop" menu. Weird stuff could happen, such as the client thinking it's a host when it isn't. Changelog: Fix clients getting confused when trying to leave a game before it starts by pressing the Escape key. --- src/multiint.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/multiint.c b/src/multiint.c index c1d1e8c23..33051a095 100644 --- a/src/multiint.c +++ b/src/multiint.c @@ -3199,7 +3199,14 @@ void runMultiOptions(void) if (CancelPressed()) { - changeTitleMode(lastTitleMode); + if (multiRequestUp) + { + changeTitleMode(lastTitleMode); + } + else + { + processMultiopWidgets(CON_CANCEL); // "Press" the cancel button to clean up net connections and stuff. + } } } From c465f161bf0340617114ae4421895fcd00875b06 Mon Sep 17 00:00:00 2001 From: Cyp Date: Sat, 18 Dec 2010 02:42:58 +0100 Subject: [PATCH 07/10] Fix keyboard input being swallowed due to missing events such as SDL_KEYUP. This is due to a seemingly undocumented bug and/or feature in SDL, where SDL_EventState and SDL_SetEventFilter mysteriously discard all pending events. The following SDL code in SDL_EventState and SDL_SetEventFilter discards all pending events, with a comment saying it does so: while ( SDL_PollEvent(&bitbucket) > 0 ) ; There appears to be no documentation of this fact anywhere outside the comment in the SDL code. I am not aware of any logical reason why enabling events with SDL_EventState should cause less events to be received than otherwise. --- lib/framework/frame.c | 4 ++++ lib/widget/editbox.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/framework/frame.c b/lib/framework/frame.c index ecc2004f3..f105d80ce 100644 --- a/lib/framework/frame.c +++ b/lib/framework/frame.c @@ -35,6 +35,7 @@ #include "frameint.h" #include "frameresource.h" #include "input.h" +#include "lib/widget/scrap.h" #include "SDL_framerate.h" #include "physfs_ext.h" @@ -264,6 +265,9 @@ bool frameInitialise( /* Initialise the input system */ inputInitialise(); + // Initialise clipboard stuff. + init_scrap(); + /* Initialise the frame rate stuff */ InitFrameStuff(); diff --git a/lib/widget/editbox.c b/lib/widget/editbox.c index 3c98d6b90..e3662756f 100644 --- a/lib/widget/editbox.c +++ b/lib/widget/editbox.c @@ -114,8 +114,6 @@ W_EDITBOX* editBoxCreate(const W_EDBINIT* psInit) psWidget->blinkOffset = SDL_GetTicks(); - init_scrap(); - return psWidget; } From 3982ba62a4ceb32ff331b115e5e3e920a584da02 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Sat, 18 Dec 2010 13:48:01 +0100 Subject: [PATCH 08/10] Fix bad indentation and remove dead code in order.c --- src/order.c | 366 +++++++++++++++++++++------------------------------- 1 file changed, 150 insertions(+), 216 deletions(-) diff --git a/src/order.c b/src/order.c index fdf74feea..ca7df4a0b 100644 --- a/src/order.c +++ b/src/order.c @@ -1052,7 +1052,6 @@ void orderUpdateDroid(DROID *psDroid) { DROID *psSpotter = (DROID *)psDroid->psTarget; -// psFireTarget = orderStateObj((DROID *)psDroid->psTarget, DORDER_OBSERVE); if (psSpotter->action == DACTION_OBSERVE || (psSpotter->droidType == DROID_COMMAND && psSpotter->action == DACTION_ATTACK)) { @@ -1140,11 +1139,9 @@ void orderUpdateDroid(DROID *psDroid) { // not doing anything, make sure the droid is close enough // to the thing it is defending - //if ((psDroid->droidType != DROID_REPAIR) && - if ((!(psDroid->droidType == DROID_REPAIR || psDroid->droidType == - DROID_CYBORG_REPAIR)) && psDroid->psTarget != NULL && - psDroid->psTarget->type == OBJ_DROID && - ((DROID *)psDroid->psTarget)->droidType == DROID_COMMAND) + if ((!(psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR)) + && psDroid->psTarget != NULL && psDroid->psTarget->type == OBJ_DROID + && ((DROID *)psDroid->psTarget)->droidType == DROID_COMMAND) { // guarding a commander, allow more space orderCheckGuardPosition(psDroid, DEFEND_CMD_BASEDIST); @@ -1154,32 +1151,30 @@ void orderUpdateDroid(DROID *psDroid) orderCheckGuardPosition(psDroid, DEFEND_BASEDIST); } } - else if (psDroid->droidType == DROID_REPAIR || - psDroid->droidType == DROID_CYBORG_REPAIR) + else if (psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR) { // repairing something, make sure the droid doesn't go too far orderCheckGuardPosition(psDroid, REPAIR_MAXDIST); } - else if (psDroid->droidType == DROID_CONSTRUCT || - psDroid->droidType == DROID_CYBORG_CONSTRUCT) + else if (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT) { // repairing something, make sure the droid doesn't go too far orderCheckGuardPosition(psDroid, CONSTRUCT_MAXDIST); } - else if (psDroid->droidType == DROID_TRANSPORTER) - { - //check transporter isn't sitting there waiting to be filled when nothing exists! - if (psDroid->player == selectedPlayer && getDroidsToSafetyFlag() && - !missionDroidsRemaining(selectedPlayer)) - { - //check that nothing is on the transporter (transporter counts as first in group) - if (psDroid->psGroup && psDroid->psGroup->refCount < 2) - { - //the script can call startMission for this callback for offworld missions - eventFireCallbackTrigger((TRIGGER_TYPE)CALL_START_NEXT_LEVEL); - } - } - } + else if (psDroid->droidType == DROID_TRANSPORTER) + { + // check transporter isn't sitting there waiting to be filled when nothing exists! + if (psDroid->player == selectedPlayer && getDroidsToSafetyFlag() && + !missionDroidsRemaining(selectedPlayer)) + { + // check that nothing is on the transporter (transporter counts as first in group) + if (psDroid->psGroup && psDroid->psGroup->refCount < 2) + { + // the script can call startMission for this callback for offworld missions + eventFireCallbackTrigger((TRIGGER_TYPE)CALL_START_NEXT_LEVEL); + } + } + } else { //let vtols return to rearm @@ -1232,8 +1227,7 @@ void orderUpdateDroid(DROID *psDroid) //repair droids default to repairing droids within a given range psObj = NULL; - if ((psDroid->droidType == DROID_REPAIR || - psDroid->droidType == DROID_CYBORG_REPAIR)) + if ((psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR)) { if (psDroid->action == DACTION_NONE) { @@ -1250,8 +1244,7 @@ void orderUpdateDroid(DROID *psDroid) } //construct droids default to repairing structures within a given range psObj = NULL; - if ((psDroid->droidType == DROID_CONSTRUCT || - psDroid->droidType == DROID_CYBORG_CONSTRUCT)) + if ((psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)) { if (psDroid->action == DACTION_NONE) { @@ -2835,43 +2828,34 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) } } //check for transporters first - if (psObj->type == OBJ_DROID && ((DROID *)psObj)->droidType == DROID_TRANSPORTER - && psObj->player == psDroid->player) + if (psObj->type == OBJ_DROID && ((DROID *)psObj)->droidType == DROID_TRANSPORTER && psObj->player == psDroid->player) { order = DORDER_EMBARK; - - //Cannot test this here since bMultiPlayer will have been set to false -/* //in multiPlayer can only put cyborgs onto a Transporter - if (bMultiPlayer && psDroid->droidType != DROID_CYBORG) - { - order = DORDER_NONE; - } -*/ } // go to recover an artifact/oil drum - don't allow VTOL's to get this order else if (psObj->type == OBJ_FEATURE && (((FEATURE *)psObj)->psStats->subType == FEAT_GEN_ARTE || ((FEATURE *)psObj)->psStats->subType == FEAT_OIL_DRUM) ) { - if (isVtolDroid(psDroid)) - { - order = DORDER_NONE; - } - else - { - order = DORDER_RECOVER; - } + if (isVtolDroid(psDroid)) + { + order = DORDER_NONE; + } + else + { + order = DORDER_RECOVER; + } } // else default to attack if the droid has a weapon else if (psDroid->numWeaps > 0 && psObj->player != psDroid->player && !aiCheckAlliances(psObj->player , psDroid->player) ) { - //check valid weapon/prop combination - if (!validTarget((BASE_OBJECT *)psDroid, psObj, 0)) - { - order = DORDER_NONE; - } + // check valid weapon/prop combination + if (!validTarget((BASE_OBJECT *)psDroid, psObj, 0)) + { + order = DORDER_NONE; + } else { order = DORDER_ATTACK; @@ -2882,9 +2866,9 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) && !aiCheckAlliances(psObj->player , psDroid->player) ) { //check for standard sensor or VTOL intercept sensor - if (asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == STANDARD_SENSOR || - asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == VTOL_INTERCEPT_SENSOR || - asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == SUPER_SENSOR) + if (asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == STANDARD_SENSOR + || asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == VTOL_INTERCEPT_SENSOR + || asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type == SUPER_SENSOR) { // a sensor droid observing an object order = DORDER_OBSERVE; @@ -2907,23 +2891,14 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) psDroid->droidType != DROID_CONSTRUCT && psDroid->droidType != DROID_CYBORG_CONSTRUCT) { -// if (!isVtolDroid(psDroid)) - { - // get a droid to join a command droids group - cmdDroidAddDroid((DROID *) psObj, psDroid); - DeSelectDroid(psDroid); - - order = DORDER_NONE; - } -/* else - { - order = DORDER_FIRESUPPORT; - }*/ + // get a droid to join a command droids group + cmdDroidAddDroid((DROID *) psObj, psDroid); + DeSelectDroid(psDroid); + order = DORDER_NONE; } //repair droid else if (aiCheckAlliances(psObj->player, psDroid->player) && psObj->type == OBJ_DROID && - //psDroid->droidType == DROID_REPAIR && (psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR) && droidIsDamaged((DROID *)psObj)) @@ -2950,8 +2925,7 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) psObj->type == OBJ_STRUCTURE ) { psStruct = (STRUCTURE *) psObj; - ASSERT( psObj != NULL, - "chooseOrderObj: invalid structure pointer" ); + ASSERT(psObj != NULL, "Invalid structure pointer"); /* check whether construction droid */ order = DORDER_NONE; @@ -3007,7 +2981,6 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) /* check repair facility and in need of repair */ if ( psStruct->pStructureType->type == REF_REPAIR_FACILITY && psStruct->status == SS_BUILT) - // ((SDWORD)(PERCENT(psDroid->body,psDroid->originalBody)) < 100) ) { order = DORDER_RTR_SPECIFIED; } @@ -3021,12 +2994,10 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) //check for counter battery assignment else if (structSensorDroidWeapon(psStruct, psDroid)) { -// secondarySetState(psDroid, DSO_HALTTYPE, DSS_HALT_HOLD); order = DORDER_FIRESUPPORT; //inform display system setSensorAssigned(); //deselect droid - // psDroid->selected = false; DeSelectDroid(psDroid); } //REARM VTOLS @@ -3038,11 +3009,7 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) if (psStruct->pStructureType->type == REF_REARM_PAD) { //don't bother checking cos we want it to go there if directed - //check if need to be rearmed/repaired - //if (!vtolHappy(psDroid)) - { - order = DORDER_REARM; - } + order = DORDER_REARM; } } // Some droids shouldn't be guarding @@ -3056,13 +3023,11 @@ DROID_ORDER chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, BOOL altOrder) } } //check for constructor droid clearing up wrecked buildings - else if ( (psDroid->droidType == DROID_CONSTRUCT || - psDroid->droidType == DROID_CYBORG_CONSTRUCT) && - psObj->type == OBJ_FEATURE ) + else if ((psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT) + && psObj->type == OBJ_FEATURE) { psFeature = (FEATURE *) psObj; - ASSERT( psObj != NULL, - "chooseOrderObj: invalid feature pointer" ); + ASSERT(psObj != NULL, "Invalid feature pointer"); if (psFeature->psStats->subType == FEAT_BUILD_WRECK) { order = DORDER_CLEARWRECK; @@ -3128,16 +3093,16 @@ void orderSelectedObjAdd(UDWORD player, BASE_OBJECT *psObj, BOOL add) // note that an order list graphic needs to be displayed bOrderEffectDisplayed = false; - psDemolish = NULL; - for (psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) + psDemolish = NULL; + for (psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) { if (psCurr->selected) { order = chooseOrderObj(psCurr, psObj, (keyDown(KEY_LALT) || keyDown(KEY_RALT))); - if (order == DORDER_DEMOLISH && player == selectedPlayer) - { - psDemolish = psCurr; - } + if (order == DORDER_DEMOLISH && player == selectedPlayer) + { + psDemolish = psCurr; + } // see if the order can be added to the list if (!(add && orderDroidObjAdd(psCurr, order, &psObj))) { @@ -3163,21 +3128,21 @@ void orderSelectedStatsLocDir(UDWORD player, DROID_ORDER order, BASE_STATS *psSt //turn off the build queue availability until desired release date! #ifdef DISABLE_BUILD_QUEUE - add = false; + add = false; #endif - for(psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) + for(psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) { if (psCurr->selected) { - if (add) - { - orderDroidStatsLocDirAdd(psCurr, order, psStats, x, y, direction); - } - else - { - orderDroidStatsLocDir(psCurr, order, psStats, x, y, direction, ModeQueue); - } + if (add) + { + orderDroidStatsLocDirAdd(psCurr, order, psStats, x, y, direction); + } + else + { + orderDroidStatsLocDir(psCurr, order, psStats, x, y, direction, ModeQueue); + } } } } @@ -3190,21 +3155,21 @@ void orderSelectedStatsTwoLocDir(UDWORD player, DROID_ORDER order, BASE_STATS *p //turn off the build queue availability until desired release date! #ifdef DISABLE_BUILD_QUEUE - add = false; + add = false; #endif for(psCurr = apsDroidLists[player]; psCurr; psCurr=psCurr->psNext) { if (psCurr->selected) { - if (add) - { + if (add) + { orderDroidStatsTwoLocDirAdd(psCurr, order, psStats, x1, y1, x2, y2, direction); - } - else - { + } + else + { orderDroidStatsTwoLocDir(psCurr, order, psStats, x1, y1, x2, y2, direction, ModeQueue); - } + } } } } @@ -3289,23 +3254,21 @@ BOOL secondarySupported(DROID *psDroid, SECONDARY_ORDER sec) { supported = false; } - //don't allow factories to be assigned to commanders during a Limbo Expand mission - if ((sec == DSO_ASSIGN_PRODUCTION || sec == DSO_ASSIGN_CYBORG_PRODUCTION || - sec == DSO_ASSIGN_VTOL_PRODUCTION) && missionLimboExpand()) - { - supported = false; - } + // don't allow factories to be assigned to commanders during a Limbo Expand mission + if ((sec == DSO_ASSIGN_PRODUCTION || sec == DSO_ASSIGN_CYBORG_PRODUCTION || sec == DSO_ASSIGN_VTOL_PRODUCTION) + && missionLimboExpand()) + { + supported = false; + } break; case DSO_ATTACK_RANGE: case DSO_ATTACK_LEVEL: - if (psDroid->droidType == DROID_REPAIR || - psDroid->droidType == DROID_CYBORG_REPAIR) + if (psDroid->droidType == DROID_REPAIR || psDroid->droidType == DROID_CYBORG_REPAIR) { supported = false; } - if (psDroid->droidType == DROID_CONSTRUCT || - psDroid->droidType == DROID_CYBORG_CONSTRUCT) + if (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT) { supported = false; } @@ -3386,7 +3349,6 @@ SECONDARY_STATE secondaryGetState(DROID *psDroid, SECONDARY_ORDER sec) return (SECONDARY_STATE)(state & DSS_RTL_MASK); break; case DSO_FIRE_DESIGNATOR: -// *pState = state & DSS_FIREDES_MASK; if (cmdDroidGetDesignator(psDroid->player) == psDroid) { return DSS_FIREDES_SET; @@ -3439,7 +3401,7 @@ static char *secondaryPrintFactories(UDWORD state) void secondaryCheckDamageLevel(DROID *psDroid) { SECONDARY_STATE State; - unsigned int repairLevel; + unsigned int repairLevel; State = secondaryGetState(psDroid, DSO_REPAIR_LEVEL); if (State == DSS_REPLEV_LOW) @@ -3538,8 +3500,7 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat CurrState = (CurrState & ~DSS_ALEV_MASK) | State; if (State == DSS_ALEV_NEVER) { - if ( orderState(psDroid, DORDER_ATTACK) )// || -// orderState(psDroid, DORDER_FIRESUPPORT) ) + if (orderState(psDroid, DORDER_ATTACK)) { // just kill these orders orderDroid(psDroid, DORDER_STOP, ModeImmediate); @@ -3754,19 +3715,9 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat switch (State & DSS_RTL_MASK) { case DSS_RTL_REPAIR: -// if (FindARepairFacility() != NULL) - { - order = DORDER_RTR; - CurrState |= DSS_RTL_REPAIR; - // can't clear the selection here cos it breaks - // the secondary order screen -// psDroid->selected = false; -// psDroid->group = UBYTE_MAX; - } -// else -// { -// retVal = false; -// } + order = DORDER_RTR; + CurrState |= DSS_RTL_REPAIR; + // can't clear the selection here cos it breaks the secondary order screen break; case DSS_RTL_BASE: order = DORDER_RTB; @@ -3776,20 +3727,20 @@ BOOL secondarySetState(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE Stat psTransport = FindATransporter(psDroid->player); if (psTransport != NULL) { - //in multiPlayer can only put cyborgs onto a Transporter - if (bMultiPlayer && !cyborgDroid(psDroid)) - { - retVal = false; - } - else - { - order = DORDER_EMBARK; - CurrState |= DSS_RTL_TRANSPORT; - if (!orderState(psDroid, DORDER_EMBARK)) - { + // in multiPlayer can only put cyborgs onto a Transporter + if (bMultiPlayer && !cyborgDroid(psDroid)) + { + retVal = false; + } + else + { + order = DORDER_EMBARK; + CurrState |= DSS_RTL_TRANSPORT; + if (!orderState(psDroid, DORDER_EMBARK)) + { orderDroidObj(psDroid, DORDER_EMBARK, (BASE_OBJECT *)psTransport, ModeImmediate); - } - } + } + } } else { @@ -3967,7 +3918,6 @@ void orderMoralCheck(UDWORD player) // too many units, don't run return; } -// debug( LOG_NEVER, "moral check for player %d\n", player ); // calculate the overall leadership leadership = asRunData[player].leadership + 10; @@ -3993,7 +3943,6 @@ void orderMoralCheck(UDWORD player) { if (check > personLShip) { -// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id ); syncDebug("Person running."); orderDroid(psCurr, DORDER_RUN, ModeImmediate); } @@ -4002,7 +3951,6 @@ void orderMoralCheck(UDWORD player) { if (check > leadership) { -// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id ); syncDebug("Droid running."); orderDroid(psCurr, DORDER_RUN, ModeImmediate); } @@ -4061,7 +4009,6 @@ void orderGroupMoralCheck(DROID_GROUP *psGroup) { if (check > personLShip) { -// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id ); syncDebug("Person running."); orderDroidLoc(psCurr, DORDER_RUN, psRunData->sPos.x, psRunData->sPos.y, ModeImmediate); } @@ -4070,7 +4017,6 @@ void orderGroupMoralCheck(DROID_GROUP *psGroup) { if (check > leadership) { -// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id ); syncDebug("Droid running."); orderDroidLoc(psCurr, DORDER_RUN, psRunData->sPos.x, psRunData->sPos.y, ModeImmediate); } @@ -4082,44 +4028,44 @@ void orderGroupMoralCheck(DROID_GROUP *psGroup) void orderHealthCheck(DROID *psDroid) { DROID *psCurr; - SBYTE healthLevel = 0; - UDWORD retreatX = 0, retreatY = 0; + SBYTE healthLevel = 0; + UDWORD retreatX = 0, retreatY = 0; if (psDroid->droidType == DROID_TRANSPORTER) { return; } - //get the health value to compare with - if (psDroid->psGroup) - { - healthLevel = psDroid->psGroup->sRunData.healthLevel; - retreatX = psDroid->psGroup->sRunData.sPos.x; - retreatY = psDroid->psGroup->sRunData.sPos.y; - } + // get the health value to compare with + if (psDroid->psGroup) + { + healthLevel = psDroid->psGroup->sRunData.healthLevel; + retreatX = psDroid->psGroup->sRunData.sPos.x; + retreatY = psDroid->psGroup->sRunData.sPos.y; + } - //if health has not been set for the group - use players' - if (!healthLevel) - { - healthLevel = asRunData[psDroid->player].healthLevel; - } + // if health has not been set for the group - use players' + if (!healthLevel) + { + healthLevel = asRunData[psDroid->player].healthLevel; + } - //if not got a health level set then ignore - if (!healthLevel) - { - return; - } + // if not got a health level set then ignore + if (!healthLevel) + { + return; + } - //if pos has not been set for the group - use players' - if (retreatX == 0 && retreatY == 0) - { - retreatX = asRunData[psDroid->player].sPos.x; - retreatY = asRunData[psDroid->player].sPos.y; - } + // if pos has not been set for the group - use players' + if (retreatX == 0 && retreatY == 0) + { + retreatX = asRunData[psDroid->player].sPos.x; + retreatY = asRunData[psDroid->player].sPos.y; + } - if (PERCENT(psDroid->body, psDroid->originalBody) < healthLevel) - { - //order this droid to turn and run - // if already running - ignore + if (PERCENT(psDroid->body, psDroid->originalBody) < healthLevel) + { + // order this droid to turn and run - // if already running - ignore if (!(orderState(psDroid, DORDER_RUN) || orderState(psDroid, DORDER_RUNBURN) || orderState(psDroid, DORDER_RETREAT) || @@ -4127,33 +4073,26 @@ void orderHealthCheck(DROID *psDroid) orderState(psDroid, DORDER_RTR) || orderState(psDroid, DORDER_DESTRUCT))) { -// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psDroid->id ); syncDebug("Droid running."); - orderDroidLoc(psDroid, DORDER_RUN, retreatX, retreatY, ModeImmediate); - } + orderDroidLoc(psDroid, DORDER_RUN, retreatX, retreatY, ModeImmediate); + } - // order each unit in the same group to run - if (psDroid->psGroup) - { - for(psCurr = psDroid->psGroup->psList; psCurr; psCurr=psCurr->psGrpNext) - { - if (orderState(psCurr, DORDER_RUN) || - orderState(psCurr, DORDER_RUNBURN) || - orderState(psCurr, DORDER_RETREAT) || - orderState(psCurr, DORDER_RTB) || - orderState(psCurr, DORDER_RTR) || - orderState(psCurr, DORDER_DESTRUCT)) - { - // already running - ignore - continue; - } - -// debug( LOG_NEVER, " DORDER_RUN: droid %d\n", psCurr->id ); + // order each unit in the same group to run + if (psDroid->psGroup) + { + for(psCurr = psDroid->psGroup->psList; psCurr; psCurr=psCurr->psGrpNext) + { + if (orderState(psCurr, DORDER_RUN) || orderState(psCurr, DORDER_RUNBURN) || orderState(psCurr, DORDER_RETREAT) + || orderState(psCurr, DORDER_RTB) || orderState(psCurr, DORDER_RTR) || orderState(psCurr, DORDER_DESTRUCT)) + { + // already running - ignore + continue; + } syncDebug("Group running."); orderDroidLoc(psCurr, DORDER_RUN, retreatX, retreatY, ModeImmediate); - } - } - } + } + } + } } // set the state of a secondary order for a Factory, return false if failed. @@ -4161,16 +4100,16 @@ BOOL setFactoryState(STRUCTURE *psStruct, SECONDARY_ORDER sec, SECONDARY_STATE S { UDWORD CurrState; BOOL retVal; - FACTORY *psFactory; + FACTORY *psFactory; - if (!StructIsFactory(psStruct)) - { - ASSERT( false, "setFactoryState: structure is not a factory" ); - return false; - } + if (!StructIsFactory(psStruct)) + { + ASSERT( false, "setFactoryState: structure is not a factory" ); + return false; + } - psFactory = (FACTORY *)psStruct->pFunctionality; + psFactory = (FACTORY *)psStruct->pFunctionality; CurrState = psFactory->secondaryOrder; @@ -4229,13 +4168,9 @@ BOOL getFactoryState(STRUCTURE *psStruct, SECONDARY_ORDER sec, SECONDARY_STATE * { UDWORD state; - if (!StructIsFactory(psStruct)) - { - ASSERT( false, "getFactoryState: structure is not a factory" ); - return false; - } + ASSERT_OR_RETURN(false, StructIsFactory(psStruct), "Structure is not a factory"); - state = ((FACTORY *)psStruct->pFunctionality)->secondaryOrder; + state = ((FACTORY *)psStruct->pFunctionality)->secondaryOrder; switch (sec) { @@ -4300,8 +4235,7 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj) psStruct->asWeaps[0].lastFired = gameTime; //play 5 second countdown message - audio_QueueTrackPos( ID_SOUND_LAS_SAT_COUNTDOWN, - psObj->pos.x, psObj->pos.y, psObj->pos.z ); + audio_QueueTrackPos(ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y, psObj->pos.z); } break; From 9e892e6f7ea12bf4073fcbe2ef82bca1438f6bc5 Mon Sep 17 00:00:00 2001 From: Cyp Date: Sat, 18 Dec 2010 18:57:05 +0100 Subject: [PATCH 09/10] Unify the 34-line intDisplayStatsBar() and 55-line intDisplayDesignPowerBar() functions into a 45-line intDisplayBar() function. --- src/intdisplay.c | 113 +++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 77 deletions(-) diff --git a/src/intdisplay.c b/src/intdisplay.c index 68fd31d7e..22c6e41e8 100644 --- a/src/intdisplay.c +++ b/src/intdisplay.c @@ -2902,108 +2902,67 @@ void StatGetResearchImage(BASE_STATS *psStat, SDWORD *Image, iIMDShape **Shape, } } -/* Draws a stats bar for the design screen */ -void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) +static void intDisplayBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, bool isPowerBar) { - W_BARGRAPH *BarGraph = (W_BARGRAPH*)psWidget; - SDWORD x0, y0, iX, iY; - static char szVal[6], szCheckWidth[6] = "00000"; + W_BARGRAPH *BarGraph = (W_BARGRAPH *)psWidget; + char szVal[6]; + char const *szCheckWidth = "00000"; + int x0 = xOffset + BarGraph->x; + int y0 = yOffset + BarGraph->y; + int arbitaryOffset = 3; + int iX, iY; + int barWidth = 100, width; - x0 = xOffset + BarGraph->x; - y0 = yOffset + BarGraph->y; - -// //draw the background image -// iV_DrawImage(IntImages,IMAGE_DES_STATSBACK,x0,y0); - - //increment for the position of the level indicator - x0 += 3; - y0 += 3; - - /* indent to allow text value */ - iX = x0 + iV_GetTextWidth( szCheckWidth ); - iY = y0 + (iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR) - iV_GetTextLineSize())/2 - - iV_GetTextAboveBase(); - - //draw current value section - iV_DrawImageRect( IntImages, IMAGE_DES_STATSCURR, iX, y0, - BarGraph->majorSize, iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR)); - - /* draw text value */ - sprintf(szVal, "%d", BarGraph->iOriginal); - iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( szVal, x0, iY ); - - //draw the comparison value - only if not zero - if (BarGraph->minorSize != 0) + if (isPowerBar) { - y0 -= 1; - iV_DrawImage(IntImages,IMAGE_DES_STATSCOMP,iX+BarGraph->minorSize ,y0); + //draw the background image + iV_DrawImage(IntImages, IMAGE_DES_POWERBAR_LEFT, x0, y0); + iV_DrawImage(IntImages, IMAGE_DES_POWERBAR_RIGHT, x0 + psWidget->width - iV_GetImageWidth(IntImages, IMAGE_DES_POWERBAR_RIGHT), y0); } -} - - -/* Draws a Template Power Bar for the Design Screen */ -void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset, - UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) -{ - W_BARGRAPH *BarGraph = (W_BARGRAPH*)psWidget; - SDWORD x0, y0, iX, iY; - UDWORD width, barWidth; - static char szVal[6], szCheckWidth[6] = "00000"; - UBYTE arbitaryOffset; - - x0 = xOffset + BarGraph->x; - y0 = yOffset + BarGraph->y; - - //draw the background image - iV_DrawImage(IntImages,IMAGE_DES_POWERBAR_LEFT,x0,y0); - iV_DrawImage(IntImages,IMAGE_DES_POWERBAR_RIGHT, - //xOffset+psWidget->width-iV_GetImageWidth(IntImages, IMAGE_DES_POWERBAR_RIGHT),y0); - x0 + psWidget->width-iV_GetImageWidth(IntImages, IMAGE_DES_POWERBAR_RIGHT),y0); - - //increment for the position of the bars within the background image - arbitaryOffset = 3; + // Arbitrary increment for the position of the bars x0 += arbitaryOffset; y0 += arbitaryOffset; /* indent to allow text value */ - iX = x0 + iV_GetTextWidth( szCheckWidth ); - iY = y0 + (iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR) - iV_GetTextLineSize())/2 - - iV_GetTextAboveBase(); + iX = x0 + iV_GetTextWidth(szCheckWidth); + iY = y0 + (iV_GetImageHeight(IntImages, IMAGE_DES_STATSCURR) - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); - // Adjust the width based on the text drawn - barWidth = BarGraph->width - (iX - x0 + arbitaryOffset); - width = BarGraph->majorSize * barWidth / 100; - // Quick check that don't go over the end - ensure % is not > 100 - if (width > barWidth) + if (isPowerBar) { - width = barWidth; + // Adjust the width based on the text drawn + barWidth = BarGraph->width - (iX - x0 + arbitaryOffset); } //draw current value section - iV_DrawImageRect(IntImages,IMAGE_DES_STATSCURR, iX, y0, - width, iV_GetImageHeight(IntImages,IMAGE_DES_STATSCURR)); + width = MIN(BarGraph->majorSize * barWidth / 100, barWidth); + iV_DrawImageRect(IntImages, IMAGE_DES_STATSCURR, iX, y0, width, iV_GetImageHeight(IntImages, IMAGE_DES_STATSCURR)); /* draw text value */ sprintf(szVal, "%d", BarGraph->iOriginal); iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( szVal, x0, iY ); + iV_DrawText(szVal, x0, iY); //draw the comparison value - only if not zero if (BarGraph->minorSize != 0) { - y0 -= 1; - width = BarGraph->minorSize * barWidth / 100; - if (width > barWidth) - { - width = barWidth; - } - //iV_DrawImage(IntImages,IMAGE_DES_STATSCOMP,x0+BarGraph->minorSize ,y0); - iV_DrawImage(IntImages, IMAGE_DES_STATSCOMP, iX + width ,y0); + width = MIN(BarGraph->minorSize * barWidth / 100, barWidth); + iV_DrawImage(IntImages, IMAGE_DES_STATSCOMP, iX + width, y0 - 1); } } +/* Draws a stats bar for the design screen */ +void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) +{ + intDisplayBar(psWidget, xOffset, yOffset, false); +} + +/* Draws a Template Power Bar for the Design Screen */ +void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) +{ + intDisplayBar(psWidget, xOffset, yOffset, true); +} + // Widget callback function to play an audio track. From 0fe13d055a7e4526c6b91e5a56ad20e148b572c7 Mon Sep 17 00:00:00 2001 From: Cyp Date: Sat, 18 Dec 2010 20:01:09 +0100 Subject: [PATCH 10/10] Print distances and speeds in terms of tiles, not in 1/128ths of tiles. Changelog: Print distances and speeds in terms of tiles. --- lib/widget/bar.c | 3 +++ lib/widget/bar.h | 2 ++ lib/widget/widget.h | 2 ++ src/design.c | 21 +++++++++++++++++++++ src/intdisplay.c | 10 ++++++++-- 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/widget/bar.c b/lib/widget/bar.c index 32bb562b0..c27d7b4c7 100644 --- a/lib/widget/bar.c +++ b/lib/widget/bar.c @@ -121,6 +121,9 @@ W_BARGRAPH* barGraphCreate(const W_BARINIT* psInit) psWidget->majorCol = psInit->sMinorCol; } + psWidget->denominator = MAX(psInit->denominator, 1); + psWidget->precision = psInit->precision; + barGraphInitialise(psWidget); return psWidget; diff --git a/lib/widget/bar.h b/lib/widget/bar.h index 4c585371f..b7c4169e0 100644 --- a/lib/widget/bar.h +++ b/lib/widget/bar.h @@ -42,6 +42,8 @@ typedef struct _w_bargraph UWORD iRange; // Maximum range UWORD iValue; // Current value UWORD iOriginal; // hack to keep uncapped value around + int denominator; // Denominator, 1 by default. + int precision; // Number of places after the decimal point to display, 0 by default. PIELIGHT majorCol; // Colour for the major bar PIELIGHT minorCol; // Colour for the minor bar const char *pTip; // The tool tip for the graph diff --git a/lib/widget/widget.h b/lib/widget/widget.h index 1264340a1..7a22e8fb9 100644 --- a/lib/widget/widget.h +++ b/lib/widget/widget.h @@ -235,6 +235,8 @@ typedef struct UWORD size; ///< Initial percentage of the graph that is filled UWORD minorSize; ///< Percentage of second bar graph if there is one UWORD iRange; ///< Maximum range + int denominator; ///< Denominator, 1 by default. + int precision; ///< Number of places after the decimal point to display, 0 by default. PIELIGHT sCol; ///< Bar colour PIELIGHT sMinorCol; ///< Minor bar colour const char *pTip; ///< Tool tip text diff --git a/src/design.c b/src/design.c index ee5dc9f26..ef01040b2 100644 --- a/src/design.c +++ b/src/design.c @@ -1545,13 +1545,19 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats) /* Add the bar graphs*/ sBarInit.id = IDDES_SENSORRANGE; sBarInit.iRange = (UWORD)getMaxSensorRange();//DBAR_SENSORMAXRANGE; + sBarInit.pTip = _("Sensor Range"); + sBarInit.denominator = TILE_UNITS; + sBarInit.precision = 1; if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; } + sBarInit.denominator = 0; + sBarInit.precision = 0; sBarInit.id = IDDES_SENSORPOWER; sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP; sBarInit.iRange = (UWORD)getMaxSensorPower();//DBAR_SENSORMAXPOWER; + sBarInit.pTip = _("Sensor Power"); if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; @@ -1559,6 +1565,7 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats) sBarInit.id = IDDES_SENSORWEIGHT; sBarInit.y = DES_STATBAR_Y3; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP; sBarInit.iRange = (UWORD)getMaxComponentWeight();//DBAR_MAXWEIGHT; + sBarInit.pTip = _("Weight"); if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; @@ -1598,6 +1605,7 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats) /* Add the bar graphs */ sBarInit.id = IDDES_ECMPOWER; sBarInit.iRange = (UWORD)getMaxECMPower();//DBAR_ECMMAXPOWER; + sBarInit.pTip = _("ECM Power"); if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; @@ -1605,6 +1613,7 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats) sBarInit.id = IDDES_ECMWEIGHT; sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP; sBarInit.iRange = (UWORD)getMaxComponentWeight();//DBAR_MAXWEIGHT; + sBarInit.pTip = _("Weight"); if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; @@ -1714,10 +1723,14 @@ static BOOL _intSetSystemForm(COMPONENT_STATS *psStats) sBarInit.id = IDDES_WEAPRANGE; sBarInit.iRange = (UWORD)getMaxWeaponRange();//DBAR_WEAPMAXRANGE; sBarInit.pTip = _("Range"); + sBarInit.denominator = TILE_UNITS; + sBarInit.precision = 1; if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; } + sBarInit.denominator = 0; + sBarInit.precision = 0; sBarInit.id = IDDES_WEAPDAMAGE; sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP; sBarInit.iRange = (UWORD)getMaxWeaponDamage();//DBAR_WEAPMAXDAMAGE; @@ -1900,10 +1913,14 @@ static BOOL intSetPropulsionForm(PROPULSION_STATS *psStats) sBarInit.id = IDDES_PROPAIR; sBarInit.iRange = (UWORD)getMaxPropulsionSpeed();//DBAR_PROPMAXSPEED; sBarInit.pTip = _("Air Speed"); + sBarInit.denominator = TILE_UNITS; + sBarInit.precision = 2; if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; } + sBarInit.denominator = 0; + sBarInit.precision = 0; sBarInit.id = IDDES_PROPWEIGHT; sBarInit.y = DES_STATBAR_Y2; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP; sBarInit.iRange = (UWORD)getMaxComponentWeight();//DBAR_MAXWEIGHT; @@ -1937,6 +1954,8 @@ static BOOL intSetPropulsionForm(PROPULSION_STATS *psStats) sBarInit.id = IDDES_PROPROAD; sBarInit.pTip = _("Road Speed"); sBarInit.iRange = (UWORD)getMaxPropulsionSpeed();//DBAR_PROPMAXSPEED; + sBarInit.denominator = TILE_UNITS; + sBarInit.precision = 2; if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; @@ -1957,6 +1976,8 @@ static BOOL intSetPropulsionForm(PROPULSION_STATS *psStats) { return false; } + sBarInit.denominator = 0; + sBarInit.precision = 0; sBarInit.id = IDDES_PROPWEIGHT; sBarInit.y = DES_STATBAR_Y4; //+= DES_CLICKBARHEIGHT + DES_CLICKGAP; sBarInit.pTip = _("Weight"); diff --git a/src/intdisplay.c b/src/intdisplay.c index 22c6e41e8..342331181 100644 --- a/src/intdisplay.c +++ b/src/intdisplay.c @@ -2905,13 +2905,14 @@ void StatGetResearchImage(BASE_STATS *psStat, SDWORD *Image, iIMDShape **Shape, static void intDisplayBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, bool isPowerBar) { W_BARGRAPH *BarGraph = (W_BARGRAPH *)psWidget; - char szVal[6]; + char szVal[30]; char const *szCheckWidth = "00000"; int x0 = xOffset + BarGraph->x; int y0 = yOffset + BarGraph->y; int arbitaryOffset = 3; int iX, iY; int barWidth = 100, width; + int i, precisionFactor = 1, value; if (isPowerBar) { @@ -2939,7 +2940,12 @@ static void intDisplayBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, bool iV_DrawImageRect(IntImages, IMAGE_DES_STATSCURR, iX, y0, width, iV_GetImageHeight(IntImages, IMAGE_DES_STATSCURR)); /* draw text value */ - sprintf(szVal, "%d", BarGraph->iOriginal); + for (i = 0; i < BarGraph->precision; ++i) + { + precisionFactor *= 10; + } + value = (BarGraph->iOriginal * precisionFactor + BarGraph->denominator/2) / BarGraph->denominator; + sprintf(szVal, "%d%s%.*d", value/precisionFactor, precisionFactor == 1? "" : ".", BarGraph->precision, value%precisionFactor); iV_SetTextColour(WZCOL_TEXT_BRIGHT); iV_DrawText(szVal, x0, iY);