Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More info on the project? #1

Closed
kevinburke opened this issue Apr 14, 2014 · 17 comments
Closed

More info on the project? #1

kevinburke opened this issue Apr 14, 2014 · 17 comments
Labels
question/help Helping someone with information on how to accomplish something.

Comments

@kevinburke
Copy link
Contributor

Where did you get the files from? Are you generating the variable/method names or are they coming from the source code?

How would I build this myself? What platforms are supported?

@IntelOrca
Copy link
Contributor

I am decompiling the game disassembly manually using IDA. The variable / method names are my own judgement at what the code is doing and also based on the OpenTTD 0.1 source code which is similar. The Roller Coaster Tycoon Techinical Information Depot has also been a useful resource.

The source compiles to a DLL. I patched the original game so that its entry point simply calls my DLL entry point instead. Code in the DLL then runs but is able to read/write to the original game's RAM and call methods. This means that the game can be gradually decompiled while still being playable. New features can also be implemented before the whole game has been decompiled.

The source code can only be compiled in Visual Studio due to the inline assembly used and also because RCT2 was compiled with an older version of Visual Studio. This will be the case until the whole game has been decompiled and running on SDL2 calls. Then it will be truly cross platform.

I will write up a manual on how to compile the game soon and how the new code is still able to call the original non-decompiled code.

To be able to help decompile the game, x86 assembly knowledge and reverse engineering experience is necessary.

Currently the game runs and renders in an SDL2 window which can be resized freely. The sound is still using DirectSound and the input is in the process of being decompiled. Many window functions have been decompiled now. Decompiling the code for all the windows in the game will be straight forward. Rendering of the viewports and game logic updating will be more complicated.

@kevinburke
Copy link
Contributor Author

Awesome! Wish I could help in some way; I've got limited experience with x86 to be honest (one compilers class).

Is there a way to estimate your progress on decompiling?

Also I tried the link on Tycoon Technical Depot but it's 404ing, http://www.gamespy.com/rctuk/tid/

@IntelOrca
Copy link
Contributor

I have currently named / identified the function of ~25% of the procedures in rct2.exe. I have maybe decompiled around ~15%.

Try this backup:
http://web.archive.org/web/20131221171341/http://www.strategyplanet.com/rctuk/tid/

@UnknownShadow200
Copy link

I've created a copy of the pages from the Technical Depot which relate to technical information, which you can access here.

(slightly off topic, but the "Ride Structure" part of the sv4structs page may be helpful in finding the meaning of some of the unknown variables in ride.h)

Still though, excellent work so far with this project!

@IntelOrca
Copy link
Contributor

Thanks for copying the pages, that is very useful.

The ride structure has changed slightly from RCT1 to RCT2, so each variable must be confirmed before assuming its the same. I am not sure how much it has changed or whether a lot of the variables have just been offset slightly. Its hard to tell at this stage.

@kevinburke
Copy link
Contributor Author

I've written a Go library to read ride formats into a Go struct. I've also
started adding the ride constants. https://github.com/kevinburke/rct-rides

Kevin Burke | Twilio
phone: 925.271.7005 | kev.inburke.com

On Thu, Apr 17, 2014 at 3:55 PM, UnknownShadow200
notifications@github.comwrote:

I've created a copy of the pages from the Technical Depot which relate to
technical information, which you can access herehttps://github.com/UnknownShadow200/RCTTechDepot-Archive
.

(slightly off topic, but the "Ride Structure" part of the sv4structs page
may be helpful in finding the meaning of some of the unknown variables in
ride.h)

Still though, excellent work so far with this project!


Reply to this email directly or view it on GitHubhttps://github.com/IntelOrca/issues/1#issuecomment-40700628
.

@bvanheu
Copy link

bvanheu commented Apr 25, 2014

Which version of IDA are you using?

@IntelOrca
Copy link
Contributor

IDA 5.0 freeware

@bvanheu
Copy link

bvanheu commented Apr 25, 2014

I don't have time to work on your project unfortunately :(

But I can decompile the whole thing with IDA 6.5 and hex-rays decompiler and provide C files.

Would that help you?

@IntelOrca
Copy link
Contributor

I don't think the automatic decompiler would work very well due to the game being written in assembly and therefore not following typical compiler conventions. Thanks for the offer though.

@bvanheu
Copy link

bvanheu commented Apr 25, 2014

Good point! Good luck with your project!

@UnknownShadow200
Copy link

@IntelOrca
(apologies for going off-topic again)
How would you feel about OpenRCT2 being used to expand the RCT2 section of the Tech Depot Archive?

@RollingStar
Copy link
Contributor

@UnknownShadow200 Keep them separate. Make a new page, probably with a new name, with all of the new findings. If the code is well-commented, separate documentation may not even be all that necessary.

@IntelOrca
Copy link
Contributor

@UnknownShadow200 that's fine

IntelOrca pushed a commit that referenced this issue Jun 18, 2014
IntelOrca pushed a commit that referenced this issue Jul 10, 2014
IntelOrca pushed a commit that referenced this issue Aug 16, 2014
IntelOrca pushed a commit that referenced this issue Dec 5, 2014
Fixed the buffer overflow. Increased the number of pixels again
IntelOrca pushed a commit that referenced this issue Dec 18, 2014
@bwrsandman
Copy link

I patched the original game so that its entry point simply calls my DLL entry point instead.

Could you provide more information on how this was done? Perhaps you wrote a script or you have designed a patch file.

I'd be interested in knowing how to reproduce those changes on the original rtc2.exe

@IntelOrca
Copy link
Contributor

I used CFF Explorer to modify openrct2.exe so that it imported openrct2.dll and the exported new main function.

I then used IDA to find the address of the WinMain function in openrct2.exe and a hex editor to overwrite the instructions at that address to stack the WinMain parameters and call the exported function using the virtual address provided by CFF explorer for the new main function in the DLL.

@bwrsandman
Copy link

I followed your instructions, using Ollydbg instead of IDA and I was able to export WinMain into a dll and then call it afterward (with the help of adresses.h).
Thanks a lot to the tips!

IntelOrca pushed a commit that referenced this issue Feb 6, 2015
IntelOrca pushed a commit that referenced this issue Feb 27, 2015
IntelOrca pushed a commit that referenced this issue Feb 27, 2015
Refactor sub_6A9DE1. Now uses known structures.
IntelOrca pushed a commit that referenced this issue May 11, 2015
IntelOrca pushed a commit that referenced this issue Dec 18, 2015
Some Objective-C Code Cleanup
IntelOrca pushed a commit that referenced this issue Jan 24, 2016
@Ziscor Ziscor mentioned this issue Jun 3, 2016
2 tasks
@Liampie Liampie mentioned this issue Jun 23, 2016
Broxzier referenced this issue in Broxzier/OpenRCT2 Dec 11, 2016
janisozaur added a commit that referenced this issue Feb 14, 2018
While looking at
#7176 (comment)
I got a crash with stacktrace:

    #0 0x7f9e81fa2e30 in object_entry_get_entry(int, unsigned long) ../src/openrct2/object/ObjectList.cpp:181
    #1 0x7f9e81fa24ae in get_loaded_object_entry(unsigned long) ../src/openrct2/object/ObjectList.cpp:142
    #2 0x7f9e8215d64f in S6Exporter::Export() ../src/openrct2/rct2/S6Exporter.cpp:169
    #3 0x7f9e8216de71 in scenario_save(char const*, int) ../src/openrct2/rct2/S6Exporter.cpp:757
    #4 0x7f9e81c932b0 in game_autosave() ../src/openrct2/Game.cpp:1590
    #5 0x7f9e828625b6 in scenario_autosave_check() ../src/openrct2/scenario/Scenario.cpp:297
    #6 0x7f9e81c8a958 in game_update() ../src/openrct2/Game.cpp:439
    #7 0x7f9e81c6731f in OpenRCT2::Context::Update() (/home/janisozaur/workspace/OpenRCT2/build/libopenrct2.so+0x10f331f)
    #8 0x7f9e81c6674c in OpenRCT2::Context::RunVariableFrame() (/home/janisozaur/workspace/OpenRCT2/build/libopenrct2.so+0x10f274c)
    #9 0x7f9e81c6402d in OpenRCT2::Context::RunFrame() (/home/janisozaur/workspace/OpenRCT2/build/libopenrct2.so+0x10f002d)
    #10 0x7f9e81c638f4 in OpenRCT2::Context::RunGameLoop() (/home/janisozaur/workspace/OpenRCT2/build/libopenrct2.so+0x10ef8f4)
    #11 0x7f9e81c627bf in OpenRCT2::Context::Launch() (/home/janisozaur/workspace/OpenRCT2/build/libopenrct2.so+0x10ee7bf)
    #12 0x7f9e81c5b08a in OpenRCT2::Context::RunOpenRCT2(int, char const**) ../src/openrct2/Context.cpp:170
    #13 0x56323695b95e in main ../src/openrct2-ui/Ui.cpp:60

Sadly I cannot reproduce it anymore
duncanspumpkin pushed a commit that referenced this issue Feb 5, 2019
rendello added a commit to rendello/OpenRCT2 that referenced this issue Apr 2, 2021
This commit ignores keypresses when the mod key is held.

The reasoning is that an odd interaction happens between SDL applications and
tiling window managers. Tiling window managers like Xmonad and i3 usually use
the mod ("windows") key and a number to change workspaces. When changing
workspaces, however, the WMs still send the number key through instead of
"eating" it. It's not clear why, exactly, but it seems universal.

Mod+1 -> Goes to workspace OpenRCT2#1
Mod+2 -> Goes to workspace OpenRCT2#2
 ...
Mod+9 -> Goes to workspace OpenRCT2#9

Most applications don't even see the number key being sent, so if you move to
workspace 1, Firefox won't type "1" into the browser bar, Vim won't type "1"
into your file, etc. But SDL applications, for whatever reason, DO see this
keydown. Of course, they'll handle it like a regular key press. So if you move
to workspace 1, which contains OpenRCT, it inadvertently toggles x-ray mode.

I first found this bug in another SDL game, The Powder Toy. After some
discussion with the devs, they fixed it like this, by ignoring keydown events
when the mod key is pressed, since the mod key is reserved for the window
manager anyway. It works well and should be in the next release.

The-Powder-Toy/The-Powder-Toy@c761938...93b920a

I did the same thing here.
rendello added a commit to rendello/OpenRCT2 that referenced this issue Apr 2, 2021
This commit ignores keypresses when the mod key is held.

The reasoning is that an odd interaction happens between SDL applications and
tiling window managers. Tiling window managers like Xmonad and i3 usually use
the mod ("windows") key and a number to change workspaces. When changing
workspaces, however, the WMs still send the number key through instead of
"eating" it. It's not clear why, exactly, but it seems universal.

Mod+1 -> Goes to workspace OpenRCT2#1
Mod+2 -> Goes to workspace OpenRCT2#2
...
Mod+9 -> Goes to workspace OpenRCT2#9

Most applications don't even see the number key being sent, so if you move to
workspace 1, Firefox won't type "1" into the browser bar, Vim won't type "1"
into your file, etc. But SDL applications, for whatever reason, DO see this
keydown. Of course, they'll handle it like a regular key press. So if you move
to workspace 1, which contains OpenRCT, it inadvertently toggles x-ray mode.

I first found this bug in another SDL game, The Powder Toy. After some
discussion with the devs, they fixed it like this, by ignoring keydown events
when the mod key is pressed, since the mod key is reserved for the window
manager anyway. It works well and should be in the next release.

The-Powder-Toy/The-Powder-Toy@c761938...93b920a

I did the same thing here.
IntelOrca pushed a commit to rendello/OpenRCT2 that referenced this issue Oct 8, 2021
This commit ignores keypresses when the mod key is held.

The reasoning is that an odd interaction happens between SDL applications and
tiling window managers. Tiling window managers like Xmonad and i3 usually use
the mod ("windows") key and a number to change workspaces. When changing
workspaces, however, the WMs still send the number key through instead of
"eating" it. It's not clear why, exactly, but it seems universal.

Mod+1 -> Goes to workspace OpenRCT2#1
Mod+2 -> Goes to workspace OpenRCT2#2
...
Mod+9 -> Goes to workspace OpenRCT2#9

Most applications don't even see the number key being sent, so if you move to
workspace 1, Firefox won't type "1" into the browser bar, Vim won't type "1"
into your file, etc. But SDL applications, for whatever reason, DO see this
keydown. Of course, they'll handle it like a regular key press. So if you move
to workspace 1, which contains OpenRCT, it inadvertently toggles x-ray mode.

I first found this bug in another SDL game, The Powder Toy. After some
discussion with the devs, they fixed it like this, by ignoring keydown events
when the mod key is pressed, since the mod key is reserved for the window
manager anyway. It works well and should be in the next release.

The-Powder-Toy/The-Powder-Toy@c761938...93b920a

I did the same thing here.
IntelOrca added a commit that referenced this issue Oct 8, 2021
Ignores keypresses when the mod key is held.

The reasoning is that an odd interaction happens between SDL applications and
tiling window managers. Tiling window managers like Xmonad and i3 usually use
the mod ("windows") key and a number to change workspaces. When changing
workspaces, however, the WMs still send the number key through instead of
"eating" it. It's not clear why, exactly, but it seems universal.

Mod+1 -> Goes to workspace #1
Mod+2 -> Goes to workspace #2
...
Mod+9 -> Goes to workspace #9

Most applications don't even see the number key being sent, so if you move to
workspace 1, Firefox won't type "1" into the browser bar, Vim won't type "1"
into your file, etc. But SDL applications, for whatever reason, DO see this
keydown. Of course, they'll handle it like a regular key press. So if you move
to workspace 1, which contains OpenRCT, it inadvertently toggles x-ray mode.

I first found this bug in another SDL game, The Powder Toy. After some
discussion with the devs, they fixed it like this, by ignoring keydown events
when the mod key is pressed, since the mod key is reserved for the window
manager anyway. It works well and should be in the next release.

The-Powder-Toy/The-Powder-Toy@c761938...93b920a

I did the same thing here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question/help Helping someone with information on how to accomplish something.
Projects
None yet
Development

No branches or pull requests

6 participants