Home » PLAYER'S HQ 1.13 » v1.13 General Gameplay Talk » Fast forward button
Fast forward button[message #259505] Sun, 15 August 2010 08:18 Go to next message

Registered:December 2007
Location: CA, USA
I got the hankering for a little tactical strategy today so I decided to get JA2 running again. The first thing that grabbed my attention was what has always bugged the heck out of my about JA2. Its way too slow especially when the computer has its turn. I dont really care to watch the bar roll across the screen while the AI calculates its turn and especially dont care about citizens.

For most games, I have a DLL I wrote 8 years ago which messes around with the millisecond timer or the high performance counter (timeGetTime/QueryPeformanceCounter) for a game respectively but that hack does not help with JA2. Despite massively better hardware the game runs just like it did on Pentium 2 I probably had 10 years ago.

Anyway I decided to do something about and updated to the latest code base and messed around with the game. What I found was that the game loop basically runs off WM_TIMER which is good I guess if you want the game to play the same on new and old hardware. With some tweaks, I was able to get it to run about I would guess 10x faster when pressing a key.

I would like to just have it trigger automatically during AI turns so it goes fast for those and revert back when its my turn and I can move.

Questions I have if someone has any insight:
1. Will speeding up the timers negatively effect the AI? Basically I suppose it could cut short the AI timeslice for mercs.
2. Is there a single flag which indicates that its the AI's turn (or rather not Players turn)?
Re: Fast forward button[message #259516] Sun, 15 August 2010 12:42 Go to previous messageGo to next message

Registered:November 2009
Location: Vault 13
I don't know if you aware of it but there are INI settings present to speed up the turn of enemy, militia, civilians and stuff.


but somehow I also like your idea and would like to see it work (can't help you with it though).
Re: Fast forward button[message #259543] Sun, 15 August 2010 17:44 Go to previous messageGo to next message

Registered:December 2007
Location: CA, USA
Thanks for responding. I found those but they only speed up the animation which is a very small part of the slowdown(except for like death animations). I did try them but my issue was more just the full turn which that does not seem to help too much with.

I'll clean up what I have and post a diff for evaluation as well as some explanation in case someone want to try to integrate it properly in to the main branch. Ended up changing a lot more than I really intended so its not a self contained as I'd like and a little messier than I'd like.

I think I found a couple of hooks to insert the auto speed up during other turns but likely is totally out of line with multiplayer which is a whole different beast anyway. Had issues with interrupts and haven't tested during a full game to see if there are other quirks.
Re: Fast forward button[message #259557] Sun, 15 August 2010 20:31 Go to previous messageGo to next message

Registered:December 2007
Location: CA, USA
Here the major outline of the changes:
  1. Set timeBeginPeriod(1) in WinMain in sgp.cpp to enable faster multimedia timers if not already at 1 ms.
  2. In Utils/Timer Control.cpp, set timer event update frequency to minimum resolution of the system (1 ms).
  3. Use QueryPerformanceCounter to track time, unlike timeGetTime it wont wrap around periodically
  4. Every BASETIMESLICE update the counters like we would have if we left update period alone above
  5. When the FastForwardMode is active then just update the timers every 1 ms instead of 10 ms. This artificially speeds up time.
  6. Disable the fast forward mode at start of team turns if its OUR_TEAM. and Enable if its someone elses turn.
Some of the issues I had:
  • Using GetAsyncKeyState to test for whether keys are pressed. I prefer this than trying to hook into the keyboard handling in the rest of the system. Probably ok for this application but would not suggest using it generally.
  • In sgp.cpp, I need to run GameLoop multiple times per trigger of its timer. This is due to that we only get timer updates every 1ms for both this and the other timers. Previously GameLoop would run 10 times for every update of other counters so it could easily clear out any pending actions in that time. Now it seems to have trouble with that so I loop and run it a couple of times in a row when FastFwd mode is on to help out.
  • Hook into TeamTurns.cpp for the automatic fastfwd mode, here at the start of team turns I turn on flag if its not OUR_TEAM. Also need to turn off when our team gets an interrupt request. At the end of interrupt I reset the flag again based on whose turn it is.
  • Couldn't figure out how to make the INI Editor allow Strings. It just wants numeric and boolean setting apparently.
Here are my files for the source directory. The ja2.patch file is the SVN patch file for

Here are my files for the data directory. The ja2data.patch file is the SVN patch file for

To enable:
  • Edit the Ja2_Options.ini file. (Without INI Editor since it cannot handle strings.)
  • Set [Graphic Settings]FAST_FORWARD_KEY to your preferred key. I used "FAST_FORWARD_KEY = SUBTRACT" to use the numpad - key.
  • Set [Graphic Settings]AUTO_FAST_FORWARD_MODE = TRUE to enable the automatic turn speed up.
Re: Fast forward button[message #298630] Sat, 11 February 2012 21:05 Go to previous message

Registered:December 2007
Location: CA, USA
Edit: Moved post to AI Turn Speed Up Mod [1.13 MP]

[Updated on: Sat, 11 February 2012 23:20] by Moderator

Previous Topic: multifunctional weapons
Next Topic: Hotkey editor?
Goto Forum:

Current Time: Tue Jun 02 20:55:41 EEST 2020

Total time taken to generate the page: 0.01570 seconds