integrate tick variables

This commit is contained in:
Ted John 2016-05-20 22:56:45 +01:00
parent 74d9ca4814
commit 781c422c76
7 changed files with 18 additions and 24 deletions

View file

@ -145,10 +145,6 @@
// Of type viewport interaction
#define RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE 0x009DE570
#define RCT2_ADDRESS_LAST_TICK_COUNT 0x009DE580
#define RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE 0x009DE588
#define RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_X 0x009DEA52
#define RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Y 0x009DEA54
#define RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Z 0x009DEA56
@ -163,8 +159,6 @@
#define RCT2_ADDRESS_TEXTINPUT_WINDOWNUMBER 0x009DEB8A
#define RCT2_ADDRESS_TEXTINPUT_WINDOWCLASS 0x009DEB8C
#define RCT2_ADDRESS_CMDLINE 0x009E2D98
#define RCT2_ADDRESS_MOUSE_WRITE_INDEX 0x009E2DE4
#define RCT2_ADDRESS_MOUSE_READ_INDEX 0x009E2DE8
#define RCT2_ADDRESS_HFONT 0x009E2DEC
@ -496,7 +490,9 @@
#define RCT2_ADDRESS_PICKEDUP_PEEP_X 0x009DE554
#define RCT2_ADDRESS_PICKEDUP_PEEP_Y 0x009DE556
#define RCT2_ADDRESS_LAST_TICK_COUNT 0x009DE580
#define RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO 0x009DE584
#define RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE 0x009DE588
// Flags:
// 0x1 Enable selection
@ -530,6 +526,7 @@
#define RCT2_ADDRESS_GAME_PAUSED 0x009DEA6E
#define RCT2_ADDRESS_WINDOW_DPI 0x009DEA74
#define RCT2_ADDRESS_CMDLINE 0x009E2D98
#define RCT2_ADDRESS_LAND_RAISE_COST 0x009E2E1C
#define RCT2_ADDRESS_LAND_LOWER_COST 0x009E2E20
#define RCT2_ADDRESS_SELECTED_TERRAIN_EDGE 0x009E2E24

View file

@ -59,6 +59,8 @@
#define NUMBER_OF_AUTOSAVES_TO_KEEP 9
uint16 gTicksSinceLastUpdate;
uint32 gLastTickCount;
uint8 gGamePaused = 0;
int gGameSpeed = 1;
float gDayNightCycle = 0;
@ -261,7 +263,7 @@ void game_update()
if (gGameSpeed > 1) {
numUpdates = 1 << (gGameSpeed - 1);
} else {
numUpdates = RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, uint16) / 31;
numUpdates = gTicksSinceLastUpdate / 31;
numUpdates = clamp(1, numUpdates, 4);
}

View file

@ -130,8 +130,10 @@ extern uint16 gErrorStringId;
extern GAME_COMMAND_POINTER* new_game_command_table[67];
#define gCurrentTicks RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32)
#define gCurrentTicks RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32)
extern uint16 gTicksSinceLastUpdate;
extern uint32 gLastTickCount;
extern uint8 gGamePaused;
extern int gGameSpeed;
extern float gDayNightCycle;

View file

@ -271,7 +271,7 @@ static void input_scroll_right(int x, int y, int state)
switch (state) {
case MOUSE_STATE_RELEASED:
_ticksSinceDragStart += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16);
_ticksSinceDragStart += gTicksSinceLastUpdate;
if (x != 0 || y != 0) {
_ticksSinceDragStart = 1000;
input_scroll_drag_continue(x, y, w);
@ -541,7 +541,7 @@ static void input_viewport_drag_continue()
}
viewport = w->viewport;
_ticksSinceDragStart += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16);
_ticksSinceDragStart += gTicksSinceLastUpdate;
if (viewport == NULL) {
platform_show_cursor();
gInputState = INPUT_STATE_RESET;
@ -1346,7 +1346,7 @@ static void input_update_tooltip(rct_window *w, int widgetIndex, int x, int y)
{
if (gTooltipWidget.window_classification == 255) {
if (gTooltipNotShownTicks < 500 || (gTooltipCursorX == x && gTooltipCursorY == y)) {
gTooltipTimeout = RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, uint16);
gTooltipTimeout = gTicksSinceLastUpdate;
int time = 2000;
if (gTooltipNotShownTicks >= 1) {
@ -1368,7 +1368,7 @@ static void input_update_tooltip(rct_window *w, int widgetIndex, int x, int y)
) {
window_tooltip_close();
}
gTooltipTimeout += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, uint16);
gTooltipTimeout += gTicksSinceLastUpdate;
if (gTooltipTimeout >= 8000) {
window_close_by_class(WC_TOOLTIP);
}

View file

@ -161,7 +161,7 @@ void window_update_all()
gfx_draw_all_dirty_blocks();
// 1000 tick update
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_UPDATE_TICKS, sint16) += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16);
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_UPDATE_TICKS, sint16) += gTicksSinceLastUpdate;
if (RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_UPDATE_TICKS, sint16) >= 1000) {
RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_UPDATE_TICKS, sint16) = 0;
for (rct_window* w = RCT2_LAST_WINDOW; w >= g_window_list; w--)

View file

@ -91,7 +91,6 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
}
RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE) = hInstance;
RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, LPSTR) = lpCmdLine;
// argv = CommandLineToArgvA(lpCmdLine, &argc);
argv = (char**)windows_get_command_line_args(&argc);

View file

@ -141,7 +141,6 @@ int rct2_init()
log_verbose("initialising game");
gScenarioTicks = 0;
RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*);
util_srand((unsigned int)time(0));
if (!rct2_init_directories())
return 0;
@ -436,16 +435,11 @@ int check_file_path(int pathId)
void rct2_update()
{
int tick, tick2;
tick = SDL_GetTicks();
tick2 = tick - RCT2_GLOBAL(RCT2_ADDRESS_LAST_TICK_COUNT, sint32);
RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16) = tick2 = min(tick2, 500);
RCT2_GLOBAL(RCT2_ADDRESS_LAST_TICK_COUNT, sint32) = tick;
int tickCount = SDL_GetTicks();
gTicksSinceLastUpdate = min(tickCount - gLastTickCount, 500);
gLastTickCount = tickCount;
if (game_is_not_paused()) {
gPaletteEffectFrame += tick2;
gPaletteEffectFrame += gTicksSinceLastUpdate;
}
date_update_real_time_of_day();