From 24a648756e9c6894a63ab485c8b4cb145913d784 Mon Sep 17 00:00:00 2001 From: Gerard Krol Date: Thu, 16 Apr 2009 10:52:49 +0200 Subject: [PATCH] Revert "Add display of the power produced, requested and efficiency to the interface." This reverts commit 41112b859d2e34a909611d71950dbe2229689826. --- src/intdisplay.c | 44 +++++++++++++++++++++++--------------------- src/power.c | 32 +++++--------------------------- src/power.h | 7 +------ 3 files changed, 29 insertions(+), 54 deletions(-) diff --git a/src/intdisplay.c b/src/intdisplay.c index dce7c3a6c..8db7d1480 100644 --- a/src/intdisplay.c +++ b/src/intdisplay.c @@ -576,14 +576,19 @@ void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC SDWORD x0,y0; SDWORD Avail,ManPow,realPower; SDWORD Empty; - SDWORD BarWidth; - static char string[20]; + SDWORD BarWidth, textWidth = 0; + SDWORD iX,iY; + static char szVal[8]; ManPow = ManuPower / POWERBAR_SCALE; Avail = getPower(selectedPlayer) / POWERBAR_SCALE; realPower = getPower(selectedPlayer) - ManuPower; BarWidth = BarGraph->width; + iV_SetFont(font_regular); + sprintf( szVal, "%d", realPower ); + textWidth = iV_GetTextWidth( szVal ); + BarWidth -= textWidth; if (ManPow > Avail) { @@ -614,30 +619,23 @@ void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON); pie_SetFogStatus(false); - iV_SetFont(font_regular); - - // display the amount of power - sprintf( string, "Power: %5d", realPower ); - iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( string, x0 + 3, y0+22 ); - - sprintf( string, "+%.0f", getPowerProducedLastSecond(selectedPlayer) ); - iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( string, x0 + 105, y0+22 ); - - sprintf( string, "-%.0f", getPowerRequestedLastSecond(selectedPlayer) ); - iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( string, x0 + 135, y0+22 ); - - // display the efficiency the economy is running at - sprintf( string, "Efficiency: %3d%%", (int)(getEconomyThrottle(selectedPlayer)*100) ); - iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( string, x0 + 197, y0+22 ); iV_DrawImage(IntImages,IMAGE_PBAR_TOP,x0,y0); + iX = x0 + 3; + iY = y0 + 9; + x0 += iV_GetImageWidth(IntImages,IMAGE_PBAR_TOP); + //fill in the empty section behind text + if(textWidth > 0) + { + iV_DrawImageRect(IntImages,IMAGE_PBAR_EMPTY, + x0,y0, + textWidth, iV_GetImageHeight(IntImages,IMAGE_PBAR_EMPTY)); + x0 += textWidth; + } + //draw required section if (ManPow > Avail) { @@ -675,6 +673,10 @@ void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC } iV_DrawImage(IntImages,IMAGE_PBAR_BOTTOM,x0,y0); + + /* draw text value */ + iV_SetTextColour(WZCOL_TEXT_BRIGHT); + iV_DrawText( szVal, iX, iY ); } diff --git a/src/power.c b/src/power.c index 15f3fb3e0..ac976f1f7 100644 --- a/src/power.c +++ b/src/power.c @@ -51,7 +51,7 @@ //flag used to check for power calculations to be done or not BOOL powerCalculated; -UDWORD lastPowerSystemUpdate; +UDWORD nextPowerSystemUpdate; /* Updates the current power based on the extracted power and a Power Generator*/ static void updateCurrentPower(POWER_GEN *psPowerGen, UDWORD player); @@ -82,23 +82,20 @@ void clearPlayerPower(void) asPower[player].powerProduced = 0; asPower[player].powerRequested = 0; asPower[player].economyThrottle = 1; - asPower[player].powerProducedLastSecond = 0; - asPower[player].powerRequestedLastSecond = 0; } - lastPowerSystemUpdate = 0; + nextPowerSystemUpdate = 0; } void throttleEconomy(void) { int player; float newThrottle; - int elapsed = gameTime - lastPowerSystemUpdate; - if (elapsed < 1000) + if (gameTime < nextPowerSystemUpdate) { return; } - lastPowerSystemUpdate = gameTime; + nextPowerSystemUpdate = gameTime + 1000; for (player = 0; player < MAX_PLAYERS; player++) { @@ -123,31 +120,12 @@ void throttleEconomy(void) asPower[player].economyThrottle += 0.02; } CLIP(asPower[player].economyThrottle, 0, 1); - //debug(LOG_WARNING, "player: %i, power: %f, throttle: %f, produced: %f, requested: %f", player, asPower[player].currentPower, asPower[player].economyThrottle, asPower[player].powerProduced, asPower[player].powerRequested); - asPower[player].powerProducedLastSecond *= 0.6; - asPower[player].powerRequestedLastSecond *= 0.6; - asPower[player].powerProducedLastSecond += 0.4*(asPower[player].powerProduced*elapsed/1000); - asPower[player].powerRequestedLastSecond += 0.4*(asPower[player].powerRequested*elapsed/1000); + debug(LOG_WARNING, "player: %i, power: %f, throttle: %f, produced: %f, requested: %f", player, asPower[player].currentPower, asPower[player].economyThrottle, asPower[player].powerProduced, asPower[player].powerRequested); asPower[player].powerProduced = 0; asPower[player].powerRequested = 0; } } -float getEconomyThrottle(int player) -{ - return asPower[player].economyThrottle; -} - -float getPowerProducedLastSecond(int player) -{ - return asPower[player].powerProducedLastSecond; -} - -float getPowerRequestedLastSecond(int player) -{ - return asPower[player].powerRequestedLastSecond; -} - /*Free the space used for playerPower */ void releasePlayerPower(void) { diff --git a/src/power.h b/src/power.h index 0c92f4d5f..308623399 100644 --- a/src/power.h +++ b/src/power.h @@ -42,8 +42,6 @@ typedef struct _player_power float powerProduced; ///< Power produced float powerRequested; ///< Power requested float economyThrottle; ///< Which percentage of the requested power is actually delivered - float powerProducedLastSecond; - float powerRequestedLastSecond; } PLAYER_POWER; /** Allocate the space for the playerPower. */ @@ -77,10 +75,7 @@ extern void setPower(int player, float power); /** Get the amount of power current held by the given player. */ extern float getPower(int player); - -float getEconomyThrottle(int player); -float getPowerProducedLastSecond(int player); -float getPowerRequestedLastSecond(int player); +extern float getExtractedPower(int player); /** Resets the power levels for all players when power is turned back on. */ void powerCalc(BOOL on);