Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'bugfixes' into 3.1

  • Loading branch information...
commit fdf228249f32f498ed97bd81e4784e3b3ed69da0 2 parents 3ff8689 + abfae5f
automerge authored cybersphinx committed
View
7 lib/gamelib/gtime.h
@@ -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;
View
4 lib/netplay/netplay.cpp
@@ -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.
View
4 lib/sound/audio.cpp
@@ -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;
}
@@ -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;
}
}
View
2  lib/widget/button.cpp
@@ -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;
View
4 src/console.cpp
@@ -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;
@@ -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? */
View
33 src/display3d.cpp
@@ -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)
@@ -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);
}
@@ -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);
@@ -3807,7 +3807,7 @@ ENERGY_BAR toggleEnergyBars(void)
void assignSensorTarget( BASE_OBJECT *psObj )
{
bSensorTargetting = true;
- lastTargetAssignation = gameTime2;
+ lastTargetAssignation = realTime;
psSensorObj = psObj;
}
@@ -3815,7 +3815,7 @@ void assignSensorTarget( BASE_OBJECT *psObj )
void assignDestTarget( void )
{
bDestTargetting = true;
- lastDestAssignation = gameTime2;
+ lastDestAssignation = realTime;
destTargetX = mouseX();
destTargetY = mouseY();
destTileX = mouseTileX;
@@ -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)
{
@@ -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);
@@ -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);
@@ -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);
}
View
22 src/intdisplay.cpp
@@ -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);
@@ -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);
}
@@ -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;
}
@@ -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;
@@ -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;
}
@@ -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);
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
}
View
2  src/mapdisplay.cpp
@@ -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;
View
2  src/multilimit.cpp
@@ -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;
View
2  src/research.cpp
@@ -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)
{
@@ -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);
View
10 src/scores.cpp
@@ -295,7 +295,7 @@ UDWORD width,height;
if(!bDispStarted)
{
bDispStarted = true;
- dispST = gameTime2;
+ dispST = realTime;
audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
}
@@ -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;
@@ -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);
View
13 src/template.cpp
@@ -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();
@@ -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)
View
4 src/warcam.cpp
@@ -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
@@ -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();
Please sign in to comment.
Something went wrong with that request. Please try again.