Skip to content

Commit

Permalink
Merge branch 'bugfixes' into 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
automerge authored and cybersphinx committed Oct 5, 2012
2 parents 3ff8689 + abfae5f commit fdf2282
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 60 deletions.
7 changes: 1 addition & 6 deletions lib/gamelib/gtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@ extern UDWORD gameTime;
/// The current time in the graphical display of the game world.
/// Should be close to gameTime, up to GAME_UNITS_PER_TICK behind.
extern UDWORD graphicsTime;
/** The current time in the game world - never stops.
* FIXME Then isn't it the real time, not the game time? Rename from gameTime2 to realTime?
* Think it did stop (opposite of what the above comment says), if the graphics rendering couldn't keep up. If needed, that feature can be added back.
* And it was previously affected by the game speed modifier, which explains how the game speed modifier affected the GUI speed...
*/
/// The current time in the real world - never stops, and not reset between games.
extern UDWORD realTime;
#define gameTime2 realTime

/// The difference between the previous and current gameTime.
extern UDWORD deltaGameTime;
Expand Down
4 changes: 2 additions & 2 deletions lib/netplay/netplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1701,13 +1701,13 @@ static void NETcheckPlayers(void)
if (NetPlay.players[i].allocated == 0) continue; // not allocated means that it most likely it is a AI player
if (NetPlay.players[i].heartbeat == 0 && NetPlay.players[i].heartattacktime == 0) // looks like they are dead
{
NetPlay.players[i].heartattacktime = gameTime2; // mark when this occured
NetPlay.players[i].heartattacktime = realTime; // mark when this occured
}
else
{
if (NetPlay.players[i].heartattacktime)
{
if (NetPlay.players[i].heartattacktime + (15 * GAME_TICKS_PER_SEC) < gameTime2) // wait 15 secs
if (NetPlay.players[i].heartattacktime + (15 * GAME_TICKS_PER_SEC) < realTime) // wait 15 secs
{
debug(LOG_NET, "Kicking due to client heart attack");
NetPlay.players[i].kick = true; // if still dead, then kick em.
Expand Down
4 changes: 2 additions & 2 deletions lib/sound/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool audio_GetPreviousQueueTrackRadarBlipPos( SDWORD *iX, SDWORD *iY )
return false;
}

if (gameTime2 > g_iPreviousSampleTime + 5*GAME_TICKS_PER_SEC)
if (realTime > g_iPreviousSampleTime + 5*GAME_TICKS_PER_SEC)
{
return false;
}
Expand Down Expand Up @@ -539,7 +539,7 @@ static void audio_UpdateQueue( void )
g_sPreviousSample.y = psSample->y;
g_sPreviousSample.z = psSample->z;
g_sPreviousSample.iTrack = psSample->iTrack;
g_iPreviousSampleTime = gameTime2;
g_iPreviousSampleTime = realTime;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/widget/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void buttonRun(W_BUTTON *psButton)
{
if (psButton->state & WBUTS_FLASH)
{
if (((gameTime2/250) % 2) == 0) {
if (((realTime/250) % 2) == 0) {
psButton->state &= ~WBUTS_FLASHON;
} else {
psButton->state |= WBUTS_FLASHON;
Expand Down
4 changes: 2 additions & 2 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ bool addConsoleMessage(const char *Text, CONSOLE_TEXT_JUSTIFICATION jusType, SDW
sstrcpy(consoleStorage[messageIndex].text, messageText);

/* Set the time when it was added - this might not be needed */
consoleStorage[messageIndex].timeAdded = gameTime2;
consoleStorage[messageIndex].timeAdded = realTime;

/* This is the present newest message */
consoleStorage[messageIndex].psNext = NULL;
Expand Down Expand Up @@ -380,7 +380,7 @@ void updateConsoleMessages( void )
}

/* Time to kill the top one ?*/
if(gameTime2 - consoleMessages->timeAdded > messageDuration)
if(realTime - consoleMessages->timeAdded > messageDuration)
{
consoleMessages->id = messageId++;
/* Is this the only message? */
Expand Down
33 changes: 10 additions & 23 deletions src/display3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void NotifyUserOfError(char *msg)
{
errorWaiting = true;
ssprintf(errorMessage, "%s", msg);
lastErrorTime = gameTime2;
lastErrorTime = realTime;
}

static Blueprint getTileBlueprint(int mapX, int mapY)
Expand Down Expand Up @@ -550,7 +550,7 @@ static void NetworkDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
ASSERT( psWidget->type == WIDG_BUTTON,"Not a button" );

// cheap way to do a button flash
if ( (gameTime2/250) % 2 == 0 )
if ( (realTime/250) % 2 == 0 )
{
ImageID = UNPACKDWORD_TRI_B(psWidget->UserData);
}
Expand Down Expand Up @@ -772,7 +772,7 @@ void draw3DScene( void )
}
if (errorWaiting)
{
if (lastErrorTime + (60 * GAME_TICKS_PER_SEC) < gameTime2)
if (lastErrorTime + (60 * GAME_TICKS_PER_SEC) < realTime)
{
char trimMsg[255];
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
Expand Down Expand Up @@ -3807,15 +3807,15 @@ ENERGY_BAR toggleEnergyBars(void)
void assignSensorTarget( BASE_OBJECT *psObj )
{
bSensorTargetting = true;
lastTargetAssignation = gameTime2;
lastTargetAssignation = realTime;
psSensorObj = psObj;
}

/// Set everything up for when the player selects the destination
void assignDestTarget( void )
{
bDestTargetting = true;
lastDestAssignation = gameTime2;
lastDestAssignation = realTime;
destTargetX = mouseX();
destTargetY = mouseY();
destTileX = mouseTileX;
Expand All @@ -3833,7 +3833,7 @@ static void processSensorTarget( void )

if(bSensorTargetting)
{
if( (gameTime2 - lastTargetAssignation) < TARGET_TO_SENSOR_TIME)
if( (realTime - lastTargetAssignation) < TARGET_TO_SENSOR_TIME)
{
if(!psSensorObj->died && psSensorObj->sDisplay.frameNumber == currentGameFrame)
{
Expand All @@ -3849,7 +3849,7 @@ static void processSensorTarget( void )
}
iV_DrawImage(IntImages,index,x,y);

offset = (SWORD)(12+ ((TARGET_TO_SENSOR_TIME)-(gameTime2-
offset = (SWORD)(12+ ((TARGET_TO_SENSOR_TIME)-(realTime-
lastTargetAssignation))/2);

x0 = (SWORD)(x-offset);
Expand Down Expand Up @@ -3892,12 +3892,12 @@ static void processDestinationTarget( void )

if(bDestTargetting)
{
if( (gameTime2 - lastDestAssignation) < DEST_TARGET_TIME)
if( (realTime - lastDestAssignation) < DEST_TARGET_TIME)
{
x = (SWORD)destTargetX;
y = (SWORD)destTargetY;

offset = (SWORD)(((DEST_TARGET_TIME)-(gameTime2-lastDestAssignation))/2);
offset = (SWORD)(((DEST_TARGET_TIME)-(realTime-lastDestAssignation))/2);

x0 = (SWORD)(x-offset);
y0 = (SWORD)(y-offset);
Expand Down Expand Up @@ -4141,20 +4141,7 @@ static void showWeaponRange(BASE_OBJECT *psObj)

static void showSensorRange2(BASE_OBJECT *psObj)
{
uint32_t sensorRange;

if(psObj->type == OBJ_DROID)
{
DROID *psDroid = (DROID*)psObj;
sensorRange = asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].range;
}
else
{
STRUCTURE *psStruct = (STRUCTURE*)psObj;
sensorRange = structSensorRange(psStruct);
}

showEffectCircle(psObj->pos, sensorRange, 80, EFFECT_EXPLOSION, EXPLOSION_TYPE_LASER);
showEffectCircle(psObj->pos, psObj->sensorRange, 80, EFFECT_EXPLOSION, EXPLOSION_TYPE_LASER);
showWeaponRange(psObj);
}

Expand Down
22 changes: 11 additions & 11 deletions src/intdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
if (Avail < 0)
{
const char *need = _("Need more resources!");
if ((gameTime2 / 1250) % 5 == 0 )
if ((realTime / 1250) % 5 == 0 )
{
iV_SetTextColour(WZCOL_BLACK);
iV_SetFont(font_small);
Expand Down Expand Up @@ -875,7 +875,7 @@ void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
//need to flash the button if a factory is on hold production
if (bOnHold)
{
if (((gameTime2/250) % 2) == 0)
if (((realTime/250) % 2) == 0)
{
iV_DrawImage(IntImages,IMAGE_BUT0_DOWN,xOffset+Form->x,yOffset+Form->y);
}
Expand Down Expand Up @@ -1209,7 +1209,7 @@ void intOpenPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_
Form->Ax1 = (UWORD)Tx1;
Form->Ay0 = (UWORD)(Ty0 + (Form->height/2) - 4);
Form->Ay1 = (UWORD)(Ty0 + (Form->height/2) + 4);
Form->startTime = gameTime2;
Form->startTime = realTime;
} else {
FormOpenCount = 0;
}
Expand All @@ -1219,7 +1219,7 @@ void intOpenPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_
Form->animCount++;

Range = (Form->height/2)-4;
Duration = (gameTime2 - Form->startTime) << 16 ;
Duration = (realTime - Form->startTime) << 16 ;
APos = (Range * (Duration / FORM_OPEN_ANIM_DURATION) ) >> 16;

Ay0 = Ty0 + (Form->height/2) - 4 - APos;
Expand Down Expand Up @@ -1276,7 +1276,7 @@ void intClosePlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
Form->Ay0 = (UWORD)(yOffset+Form->y);
Form->Ax1 = (UWORD)(Form->Ax0 + Form->width);
Form->Ay1 = (UWORD)(Form->Ay0 + Form->height);
Form->startTime = gameTime2;
Form->startTime = realTime;
} else {
FormCloseCount = 0;
}
Expand All @@ -1286,7 +1286,7 @@ void intClosePlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
Form->animCount++;

Range = (Form->height/2)-4;
Duration = (gameTime2 - Form->startTime) << 16 ;
Duration = (realTime - Form->startTime) << 16 ;
APos = (Range * (Duration / FORM_OPEN_ANIM_DURATION) ) >> 16;

Form->Ay0 = (UWORD)(yOffset + Form->y + APos);
Expand Down Expand Up @@ -1359,7 +1359,7 @@ void intDisplayMissionClock(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
iV_DrawImage(IntImages, UNPACKDWORD_TRI_B(psWidget->UserData), x, y);
// Need to flash the timer when < 5 minutes remaining, but > 4 minutes
flash = UNPACKDWORD_TRI_A(psWidget->UserData);
if (flash && ((gameTime2 / 250) % 2) == 0)
if (flash && ((realTime / 250) % 2) == 0)
{
iV_DrawImage(IntImages, UNPACKDWORD_TRI_C(psWidget->UserData), x, y);
}
Expand Down Expand Up @@ -1414,7 +1414,7 @@ void intDisplayImageHilight(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
flash = UNPACKDWORD_TRI_A(psWidget->UserData);
if (flash && psWidget->id == IDTRANS_LAUNCH)
{
if (((gameTime2/250) % 2) == 0)
if (((realTime/250) % 2) == 0)
{
iV_DrawImage(IntImages,UNPACKDWORD_TRI_B(psWidget->UserData),x,y);
}
Expand Down Expand Up @@ -1533,7 +1533,7 @@ void intDisplayButtonFlash(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_
Down = 1;
} */

if ( /* Down && */ (gameTime2/250) % 2 == 0 )
if ( /* Down && */ (realTime/250) % 2 == 0 )
{
ImageID = UNPACKDWORD_TRI_B(psWidget->UserData);
}
Expand Down Expand Up @@ -3007,10 +3007,10 @@ void WidgetAudioCallback(int AudioID)

// Don't allow a widget beep if one was made in the last WIDGETBEEPGAP milliseconds
// This stops double beeps happening (which seems to happen all the time)
TimeSinceLastWidgetBeep=gameTime2-LastTimeAudio;
TimeSinceLastWidgetBeep=realTime-LastTimeAudio;
if (TimeSinceLastWidgetBeep<0 || TimeSinceLastWidgetBeep>WIDGETBEEPGAP)
{
LastTimeAudio=gameTime2;
LastTimeAudio=realTime;
audio_PlayTrack(AudioID);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void renderResearchToBuffer(RESEARCH *psResearch, UDWORD OriginX, UDWORD OriginY

// Rotate round
// full rotation once every 2 seconds..
angle = (gameTime2 % ROTATE_TIME) * 360 / ROTATE_TIME;
angle = (realTime % ROTATE_TIME) * 360 / ROTATE_TIME;

Position.x = 0;
Position.y = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/multilimit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
// draw image
pie_SetGeometricOffset( x+35 ,y+(psWidget->height/2)+9);
rotation.x = -15;
rotation.y = ((gameTime2/45)%360) ; //45
rotation.y = ((realTime/45)%360) ; //45
rotation.z = 0;
position.x = 0;
position.y = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/research.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE
for (psCurr = apsStructLists[player]; psCurr != NULL; psCurr = psCurr->psNext)
{
structureSensorUpgrade(psCurr);
visTilesUpdate(psCurr);
}
for (psCurr = mission.apsStructLists[player]; psCurr != NULL; psCurr = psCurr->psNext)
{
Expand All @@ -968,6 +969,7 @@ void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE
for (psDroid = apsDroidLists[player]; psDroid != NULL; psDroid = psDroid->psNext)
{
droidSensorUpgrade(psDroid);
visTilesUpdate(psDroid);
if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
{
upgradeTransporterDroids(psDroid, droidSensorUpgrade);
Expand Down
10 changes: 5 additions & 5 deletions src/scores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ UDWORD width,height;
if(!bDispStarted)
{
bDispStarted = true;
dispST = gameTime2;
dispST = realTime;
audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
}

Expand Down Expand Up @@ -337,11 +337,11 @@ UDWORD width,height;
/* Draw the interior grey */
pie_BoxFill(x, y, x + width, y + height, WZCOL_MENU_SCORES_INTERIOR);

if( ((gameTime2 - dispST) > infoBars[index].queTime) )
if( ((realTime - dispST) > infoBars[index].queTime) )
{
/* Now draw amount filled */
const float mul = (gameTime2 - dispST < BAR_CRAWL_TIME) ?
(float)(gameTime2 - dispST) / (float)BAR_CRAWL_TIME
const float mul = (realTime - dispST < BAR_CRAWL_TIME) ?
(float)(realTime - dispST) / (float)BAR_CRAWL_TIME
: 1.f;

const float length = (float)infoBars[index].percent / 100.f * (float)infoBars[index].width * mul;
Expand Down Expand Up @@ -401,7 +401,7 @@ void dispAdditionalInfo( void )
if (Cheated)
{
// A quick way to flash the text
((gameTime2 / 250) % 2) ? iV_SetTextColour(WZCOL_RED) : iV_SetTextColour(WZCOL_YELLOW);
((realTime / 250) % 2) ? iV_SetTextColour(WZCOL_RED) : iV_SetTextColour(WZCOL_YELLOW);
sprintf( text, _("You cheated!"));
iV_DrawText( text, (pie_GetVideoBufferWidth() - iV_GetTextWidth(text))/2, 360 + D_H );
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
Expand Down
13 changes: 9 additions & 4 deletions src/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ bool researchedTemplate(DROID_TEMPLATE *psCurr, int player, bool allowRedundant)
return researchedEverything;
}

static char const *templatesFilename()
{
return bMultiPlayer? "templates.ini" : "templatesCampaign.ini";
}

bool initTemplates()
{
WzConfig ini("templates.ini");
WzConfig ini(templatesFilename());
if (ini.status() != QSettings::NoError)
{
debug(LOG_FATAL, "Could not open templates.ini");
debug(LOG_FATAL, "Could not open %s", templatesFilename());
return false;
}
QStringList list = ini.childGroups();
Expand Down Expand Up @@ -188,10 +193,10 @@ bool initTemplates()
bool storeTemplates()
{
// Write stored templates (back) to file
WzConfig ini("templates.ini");
WzConfig ini(templatesFilename());
if (ini.status() != QSettings::NoError || !ini.isWritable())
{
debug(LOG_FATAL, "Could not open templates.ini");
debug(LOG_FATAL, "Could not open %s", templatesFilename());
return false;
}
for (DROID_TEMPLATE *psCurr = apsDroidTemplates[selectedPlayer]; psCurr != NULL; psCurr = psCurr->psNext)
Expand Down
4 changes: 2 additions & 2 deletions src/warcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ void camAllignWithTarget(BASE_OBJECT *psTarget)
trackingCamera.oldDistance = getViewDistance(); //distance;

/* Store away when we started */
trackingCamera.lastUpdate = gameTime2;
trackingCamera.lastUpdate = realTime;
}

#define GROUP_SELECTED 0xFFFFFFFF
Expand Down Expand Up @@ -1014,7 +1014,7 @@ bool bFlying;
CheckScrollLimits();

/* Store away our last update as acceleration and velocity are all fn()/dt */
trackingCamera.lastUpdate = gameTime2;
trackingCamera.lastUpdate = realTime;
if(bFullInfo)
{
flushConsoleMessages();
Expand Down

0 comments on commit fdf2282

Please sign in to comment.