1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Move rct2_update into Context

This commit is contained in:
Ted John
2017-06-25 23:45:19 +01:00
parent 1b042506d9
commit 7fbcf1ab0b
6 changed files with 42 additions and 44 deletions

View File

@@ -683,7 +683,6 @@ private:
gfx_invalidate_screen();
// Check if the window has been resized in windowed mode and update the config file accordingly
// This is called in rct2_update and is only called after resizing a window has finished
sint32 nonWindowFlags =
#ifndef __MACOSX__
SDL_WINDOW_MAXIMIZED |

View File

@@ -48,11 +48,13 @@ extern "C"
#include "editor.h"
#include "game.h"
#include "interface/chat.h"
#include "interface/console.h"
#include "interface/themes.h"
#include "intro.h"
#include "localisation/localisation.h"
#include "network/http.h"
#include "network/network.h"
#include "network/twitch.h"
#include "object_list.h"
#include "platform/platform.h"
#include "rct1.h"
@@ -80,9 +82,10 @@ namespace OpenRCT2
ITrackDesignRepository * _trackDesignRepository = nullptr;
IScenarioRepository * _scenarioRepository = nullptr;
bool _isWindowMinimised = false;
uint32 _lastTick = 0;
uint32 _accumulator = 0;
bool _isWindowMinimised = false;
uint32 _lastTick = 0;
uint32 _accumulator = 0;
uint32 _lastUpdateTick = 0;
/** If set, will end the OpenRCT2 game loop. Intentially private to this module so that the flag can not be set back to false. */
bool _finished = false;
@@ -178,7 +181,7 @@ namespace OpenRCT2
if (!gOpenRCT2Headless)
{
GetContext()->GetUiContext()->CreateWindow();
_uiContext->CreateWindow();
}
// TODO add configuration option to allow multiple instances
@@ -404,7 +407,7 @@ namespace OpenRCT2
_lastTick = currentTick;
_accumulator += elapsed;
GetContext()->GetUiContext()->ProcessMessages();
_uiContext->ProcessMessages();
if (_accumulator < UPDATE_TIME_MS)
{
@@ -414,7 +417,7 @@ namespace OpenRCT2
_accumulator -= UPDATE_TIME_MS;
rct2_update();
Update();
if (!_isWindowMinimised && !gOpenRCT2Headless)
{
platform_draw();
@@ -442,7 +445,7 @@ namespace OpenRCT2
_lastTick = currentTick;
_accumulator += elapsed;
GetContext()->GetUiContext()->ProcessMessages();
_uiContext->ProcessMessages();
while (_accumulator >= UPDATE_TIME_MS)
{
@@ -450,7 +453,7 @@ namespace OpenRCT2
if(draw)
sprite_position_tween_store_a();
rct2_update();
Update();
_accumulator -= UPDATE_TIME_MS;
@@ -470,6 +473,37 @@ namespace OpenRCT2
}
}
void Update()
{
uint32 currentUpdateTick = platform_get_ticks();
gTicksSinceLastUpdate = std::min<uint32>(currentUpdateTick - _lastUpdateTick, 500);
_lastUpdateTick = currentUpdateTick;
if (game_is_not_paused())
{
gPaletteEffectFrame += gTicksSinceLastUpdate;
}
date_update_real_time_of_day();
if (gIntroState != INTRO_STATE_NONE)
{
intro_update();
}
else if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gOpenRCT2Headless)
{
title_update();
}
else
{
game_update();
}
twitch_update();
chat_update();
console_update();
}
bool OpenParkAutoDetectFormat(IStream * stream)
{
ClassifiedFile info;

View File

@@ -63,7 +63,6 @@
#define NUMBER_OF_AUTOSAVES_TO_KEEP 9
uint16 gTicksSinceLastUpdate;
uint32 gLastTickCount;
uint8 gGamePaused = 0;
sint32 gGameSpeed = 1;
float gDayNightCycle = 0;

View File

@@ -143,7 +143,6 @@ extern uint32 gCurrentTicks;
#endif
extern uint16 gTicksSinceLastUpdate;
extern uint32 gLastTickCount;
extern uint8 gGamePaused;
extern sint32 gGameSpeed;
extern float gDayNightCycle;

View File

@@ -411,38 +411,6 @@ sint32 check_file_paths()
return 1;
}
void rct2_update()
{
sint32 tickCount = platform_get_ticks();
gTicksSinceLastUpdate = min(tickCount - gLastTickCount, 500);
gLastTickCount = tickCount;
if (game_is_not_paused()) {
gPaletteEffectFrame += gTicksSinceLastUpdate;
}
date_update_real_time_of_day();
// TODO: screenshot countdown process
// network_update() is called in game_update
// check_cmdline_arg();
// Screens
if (gIntroState != INTRO_STATE_NONE) {
intro_update();
} else if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gOpenRCT2Headless) {
title_update();
} else {
game_update();
}
//stop_completed_sounds(); // removes other sounds that are no longer playing in directsound
twitch_update();
chat_update();
console_update();
}
/**
*
* rct2: 0x00674E6C

View File

@@ -173,7 +173,6 @@ bool rct2_init();
sint32 rct2_init_directories();
sint32 rct2_startup_checks();
void rct2_dispose();
void rct2_update();
void substitute_path(char *dest, size_t size, const char *path, const char *filename);
sint32 check_mutex();
sint32 check_file_paths();