Introducing a Replaysystem to Fleetops

Program aborts? Network configuration? Graphic errors? Bugs? Post your question here.
posted on September 12th, 2016, 10:44 pm
Lately I got some spare time, therefore I added a replay system to Fleetops. It works by hooking the Directplay-Messagehandler of Fleetops and copying all incoming messages to the harddrive. Later the messages are restored. The game engine therefore thinks to be in a live session, but is in fact feeded with previously stored information. The Dev's are welcome to add or improve this patch for a 3.2.8 update. The changes are open source (native assembly).

The header of a replayfile (*.rep):

Bytes 0-3: 464F5270 Magic Number, this is a replay file.
Bytes 4-7: ???????? GUID of the saved game. Every replay file of the same game will have the same GUID, allowing an automated grouping of a large number of replay files.
Bytes 8-B: 000000?? Number of players. Reproducing a game from a replay file still requires a small manual set up. The Dev's could probably write easily an in-game wrapper for this small manual set up with only a few hours of work. I already implemented all necessary information in the replay file, if they want to do this.

Replay files are very small, 100 KB will be generated every minute. The folder "C:\FORep\" is used as working dir by the Replaysystem. The Dev's can easily change this by supplying new pointers to $10038912-$1003891D. Video commentaries can now be created based on replay files. There should be an additional section next to http://guide.fleetops.net/video to upload, rate and comment replay files. There are about 50 games every week, the number of available replays will therefore probably stack up very fast.

How to install:

1. Download the attached "Rep" folder and copy it into the Fleetopsfolder, for example "C:\Program Files\Activision\Star Trek Armada II Fleet Operations\Rep".
2. Download BPatch from
http://www.softpedia.com/get/System/Fil ... l#download. Copy the file "BPatch.exe" into the new "Rep" folder.
3. Execute the file "Apply Patch.bat", this will apply the patch (2.5KB).

A Fleetops with Replaysystem is fully compatible with a Fleetops without Replaysystem (no yellow block).

How to create a replay:

Now there are two new options available, indicated by the playername. Add "_repobs_" (lowercase) to a playername to watch and record a game at the same time. Therefore you can record every game you just observe.

Limitations for usual players:
-No known limitations

Limitations for _repobs_ players:
-Only the first game joined will be recorded correctly. Therefore, if a host get lost during game setup, you can't rejoin an other game with the same _repobs_ player. You have to exit Fleetops and restart it. Only the very first game joined will be recorded correctly. This is true for every _rep* player.
-A _rep* player must not be the Host of a game.

There is also a "_replay_" option. For a _replay_ player nothing shall be displayed, therefore causing no CPU Load. Therefore two players, an usual and a _replay_ player, can join a game on the same computer, while only the usual player causes a CPU Load, while the _replay_ player has a recording only task. Therefore you can record a game and be involved in it at the same time, without an increased CPU Load.

The Replaysystem will mute the application and the suppression of the graphics shall work on its own. It already happens to FO 3.2.7 that nothing is displayed until the application becomes the active window for the first time after launch. The Dev's might be able to always disable any graphical displaying for a _replay_ player.

Limitations for _replay_ players:
-The same as _repobs_ players
-And the Fleetopswindow must not become the active window, after the game started.

An example for a Setup: Two usual players are in the game setup. Then an other instance of Fleetops on the same computer is started and joins with the same name, but with also "_replay_" at the end. Then this _replay_ player joins the game of the two usual players and chooses observer for the team. You will realize that the _replay_ player is already muted at this point. After choosing "observer" with the _replay_ player you maybe want to open a few folders or other windows. This will dig the _replay_ player behind a few windows, therefore it won't become accidentally the active window by Alt+Tab. Just forget about the other _replay_ player. Then, back at the usual player, just launch the game as usual. The _replay_ player will then record the game in the background. After the end of the game you can exit the _replay_ player by executing the file "End replay.bat". Then execute "Save replay.bat" by drag and drop a file on it. The file dropped on "Save replay.bat" will be replaced with the last recorded replay. Then give the replayfile a name and add the number of players in brackets, decremented by yourself. You can also open the *.rep file in a hexeditor or notepad.exe and look at the last number in the first line of the replay file (Byte $B). This number have to be put into the brackets.

How to recreate a replay:

This will be explained with an example replay file: "Rep (Fed) vs. ShadoWdeGrey (Dom) (Duell II, 2 Players).rep". It is a 4.4 MB replay file, which contains a 40min 1v1, recorded by a _replay_ player.

1. Execute "Load Replay.bat" by drag and drop a replay file on it.
2. Goto "Multiplayer" and "Local Area Network", not "Tungle". Set up a game with the number of players in the replay file's name with usual playernames. For this example replay file first create a game as host and then add a second usual player with a second instance of Fleetops. Now this is a game with two usual players (1+1=2) on the same computer.
3. Now open an other instance of Fleetops, for this replayfile a third instance of Fleetops, and use _repobs_ in the players name, because nothing shall be suppressed of the replay. Now you only have to join the just created game with the number of players specified in the file's name.

After you did this, you will already see the true names from the replay file, instead of any name you just used before for this game setup. Then all other previous instances of Fleetops will automatically close, except the _repobs_ player. Then the replay launches automatically.

During the replay you can do everything like a real observer. You can end the replay anytime by going into the menu and then execute "End Replay.bat". But you can't (currently) halt the game by going into the menu and return to the game or pressing the pause key. However, I already implemented a solution to enable the Dev's to easily add this feature. Whenever the replay is paused, the value in $1003894C has to be set to nonzero and back to zero, whenever the replay resumes. Also the time the game was paused has to be measured and the value in $10038944 has to be incremented by this time, immediately before setting $1003894C back to zero. Until the Dev's have decided to do this, replays can't be halted. But you can switch to other windows with Alt+Tab without Problems.

Don't exit a reproduced replay by "Exit to Desktop", this will cause Fleetops to crash and the loaded replay will not be unloaded. In this condition nothing will be recorded anymore, but you can resolve this by executing the file "Unload Replay manually.bat".

All other replays after the very first replay in this attachment should probably be posted somewhere else, until the Dev's created a sections next to http://guide.fleetops.net/video for them. This thread should be preserved for technical questions, for example corrupted replay files.

Attachments

FORep.zip
(2.8 KiB) Downloaded 303 times
Rep (Fed) vs. ShadoWdeGrey (Dom) (Duell II, 2 Players).zip
(1.25 MiB) Downloaded 317 times
posted on September 13th, 2016, 11:39 am
Last edited by DOCa Cola on September 13th, 2016, 12:02 pm, edited 1 time in total.
Reason: edit
Nice work.
I haven't checked it yet, but one issue i could think of is the seed for the random number generator which may be inconsistent between game sessions which affect probabilities of weapon hits and ship AI decisions.

Another thing that may not be known well. There is a actually a replay function hidden in Armada 2 already. And it works for the most part. There were some inherent issues with that as well and we never came around fixing it.
It works similar to your approach but obviously is mostly integrated with the game already.

[Edit]
I just looked into my old code. Actually i already implemented an easy way to activate the replay function from back when we tested it. To activate just create an empty file called unsupportedextension_replay in the data directory of Fleet Operations.
If i remember correctly savegames are then automatically generated for each game and can be loaded via the load savegame functionality afterwards. It even has controls to start/stop etc. But once again, there were some breaking bugs. I don't remember the details though.
[/Edit]

While i am glad that there are still new people working on fixing and implementing new features to Armada, the FO team won't invest further time to fix the Armada engine. Our goal now is working towards FO-NX.
posted on September 13th, 2016, 1:15 pm
This is amazing!

I am hosting my first FO event for the UFP (not their first event, but mine hosting it)
Perhaps I can use this feature to the games we play!!!

Thanks again for this. It's cool!
posted on September 13th, 2016, 5:22 pm
The Replaysystem is not a bugfix or an enhancement for the replay function hidden in Armada 2, it is a completely new feature from scratch.

The seed for the random number generator is shared with the setup information, which is recorded and reproduced as well. Until now every game was recorded perfectly 1:1 without any flaws.
posted on September 13th, 2016, 10:34 pm
Nice work! :D
posted on September 14th, 2016, 2:27 am
This. I want this.

It sounds like it shouldn't have any problems integrating with Tryptic's Mod. I'll take a look as soon as I get a good chance.

If it does work well, do you mind if I include it in Tryptic's Mod from here on out? My goal has been to create an ongoing version of Armada Fleet Ops with as many stable features as possible
posted on September 14th, 2016, 3:30 pm
Yes this is nice i get that the dev team is not puting any more work in to the old mod but i'm sure they could add a tab next to the videos replay as the person ask as that's very little work for them to do that.
posted on September 15th, 2016, 9:57 pm
The Replaysystem should work with every Mod. But a replay for a Mod should be indicated by the filename with "... [Tryptics Mod 2.5].rep" at the end in square brackets. The version of a Mod used in a replay file must always match the version of the reproducing application. A *[Tryptics Mod 2.5].rep file will only work with a Fleetopsapplication with the same version, not with FO 3.2.7 or TM 2.0 or TM 3.0. Therefore it is important to add this information to the filename, if it is not a standard FO 3.2.7 replay file.
posted on January 1st, 2018, 9:34 pm
After the Dev's were uninterested to write a wrapper for the replaysystem I have now written one myself, which was very easy compared to writing the replaysystem. After the replaysystem was added to Fleetops by the "Apply Patch.bat" the long way for replays is still possible, additionally to the following almost one click procedures from the wrapper:

Reproducing a Replay: After copying the attached folder to any normal path you only have to drag and drop a replayfile on "Reproduce Replay.bat" in the folder "Reproduce Replay from file (While NOT being connected to Tungle)", then the replay will start automatically. You will have to wait less then a minute until the Wrapper has set up and started the replay. You can then end the replay by pressing Esc for longer than one second.

Creating a Replay: Start "Create Replay.bat" in the folder "Create a new Replay (While being connected to Tungle)". The Wrapper will start a new instance of Fleetops and create a new user with a "_replay_" name. You then have only to choose the game to being recorded and then choosing "observer" as team for the "_replay_" player. After that, to prevent the new instance from getting activated during the replay, you should use the file "Hide FOReplaywindow.bat", which will render the new FO-instance invisible. The Window will reappear by using the file "Show FOReplaywindow.bat". After the recording is done use the file "Save Replay to file.bat", which will create a file like "romms, Michael (Ice Fever v0_1, 53 min).rep". You can arbitrarily change the filename.

"Create Replay.bat" creates only a replay file without causing a higher CPU Load by displaying graphics. "Create Observer.bat" will also create a replay while actually observing a game (with full CPU Load for all graphics).

A special feature: The wrapper checks if the map, the replay was played on, was a customize map and not a standard map and attaches the map in this case to the replayfile. The wrapper checks every replayfile dropped on "Reproduce Replay.bat" whether it contains mapdata, which will then be copied to the Appdata of Fleetops.

This topic https://www.fleetops.net/forums/general ... lays-13013 should be marked as sticky, then it will always appear under "List of Awesome Youtube replays".

Attachments

Wrapper.zip
(245.64 KiB) Downloaded 278 times
Reply

Who is online

Users browsing this forum: No registered users and 3 guests