Skip to content

Prepare main branch for building using the exports#41

Open
gynt wants to merge 8 commits intomainfrom
feature/builds-polyfill-and-constants
Open

Prepare main branch for building using the exports#41
gynt wants to merge 8 commits intomainfrom
feature/builds-polyfill-and-constants

Conversation

@gynt
Copy link
Contributor

@gynt gynt commented Feb 25, 2026

@gynt gynt requested a review from TheRedDaemon February 25, 2026 23:50
Comment on lines +128 to +131
# We could reinstate this later:
## set(OPEN_SHC_DLL_DEST "${CRUSADER_DIR}/ucp/modules/${OPEN_SHC_NAME}-${OPEN_SHC_VERSION}" CACHE PATH "Path for OpenSHC.dll and OpenSHC.pdb")
# For now it is easier to put it in a dll subfolder
set(OPEN_SHC_DLL_DEST "${CMAKE_BINARY_DIR}/dll" CACHE PATH "Path for OpenSHC.dll and OpenSHC.pdb")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue that is solved here? Does reccmp not follow Symlinks?

I would contest that a bit, since it breaks the "debugging with game" flow.
The main reason for the DLL is the partial replacement and being able to run the game with it.
The flow "reimplement and check reimplementation state" could be done exe only.

Copy link
Contributor Author

@gynt gynt Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no big issue. What it solved was that I couldn't find the dll file, as the path to the _original/ucp/modules/OpenSHC-1.41.0 folder makes the location of the dll file in an unexpected place for reccmp. I can also adapt reccmp of course. It is kind of the question of what should work "out of the box" and what is an advanced usage users need to configure. I had the thought that the reccmp flow on the dll should work out of the box (as building the exe doesn't work without all reimplementations for known functions). But I can see clearly the argument for "debugging with game" flow to be optimal.

What about adding a cmake statement to also copy the dll and pdb to the build-RelWithDebInfo/dll/ subdirectory that reccmp expects? Then the "debugging with game" is default but the other situation also works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I actually really want to have my cake and eat it, because I feel it should be possible.

So, I assume you tried to set the reccmp-build.yml of the dll to basically this:

project: .
targets:
  STRONGHOLDCRUSADER:
    path: ../../_original/ucp/modules/OpenSHC-1.41.0/OpenSHC.dll
    pdb: ../../_original/ucp/modules/OpenSHC-1.41.0/OpenSHC.pdb

and it did not work?
Strangely enough it works with pointing to the game exe in reccmp-user.yml.

I would prefer two options and of them A:
A. It would just work.
B. Copying the files to another place for scan.

Can you ask the reccmp people again, why this does not work?
Unless it is actually an entirely different problem?

Copy link
Contributor Author

@gynt gynt Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go this route:

project: .
targets:
  STRONGHOLDCRUSADER:
    path: ../../_original/ucp/modules/OpenSHC-1.41.0/OpenSHC.dll
    pdb: ../../_original/ucp/modules/OpenSHC-1.41.0/OpenSHC.pdb

I will test if it works just fine!

Copy link
Contributor

@TheRedDaemon TheRedDaemon Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it on my setup. Should work. If you manage to confirm this, please change the reccmp-build.yml and remove the change in the CMakeLists.txt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the hash of the game in the file name and every enum?

Also, I remember the discussion from here: #10
Did you conclude that a difference in naming between struct and func would not be helpful?

Copy link
Contributor Author

@gynt gynt Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the file version independent way of getting a source of truth. Currently the steam exe is the source of truth, so this hash is in the enum. Future versions we support (if we ever go there, currently we decided against it), get their own file with their hash in the file name. The enum will consist of mostly the same enum names as the steam exe, but of course different enum values as addresess are different.

Regarding data versus code, the first .data section of the .exe starts at 0x59e000, so anything lower is func, and everything higher is struct. The usage context of the enum names is obvious enough to know the distinction, so I think it is fine without F and D

Copy link
Contributor

@TheRedDaemon TheRedDaemon Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Add a "Closes #10" to the description then. This was what closes it directly with the merge, right?

You can resolve this comment here yourselve then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this enum for?
Are these really completely general, or should they rather be part of or be themselves a normal game enum?
I also feel the precomp is not be good place, since unlike the addresses or the Ghidra data types, these are not really "unchangeable" meta structures.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are they not "unchangeable"? Because we could expand the list in the future triggering a rebuild of all files? Or because we need to change it when we go 800x800 on maps?
I considered this file for constant integer values that are systematically used across the code but never used as an enum (e.g. in a switch-case statement). Constants we deduce from what they must have used as a macro or constant at some point in the source code but which has been completely inlined. What could be added is the amount of preallocated space for the unit array, etcetera.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I should have added more focus on the "meta structures" part.
At the moment I see the Precomp as place for the meta structures and basically Windows.h and would prefer to keep the game related logic out of it. So the addresses enum is fine (it is reasonably big anyway), but these constant would see use in the actual game logic and I would prefer it to be with other game code as well as only imported where they are really used.

Also, I think we should not have a Constants enum. If values are logically related and of an integer type (and also not stored somewhere, then we would have the size enum thing), then they should be grouped in a properly named enum, alternatively in a Namespace (which would need to happen if they are not integer or sized).
In any other case, they should just be "normal" constants.

In fact, maybe we should add these structures in a OpenSHC::Constants namespace anyway and maybe also split the files. The reality is that we choose the route of many files anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, anything that pops up in actual code lines should be inside OpenSHC namespace. Makes sense!

.gitignore Outdated
/reccmp/**/*.json

# Users should use git add --force for these:
/cmake/openshc-sources.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we can create a flow that does not involve such git tricks.
What is the issue and intention behind this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is laziness. I usually do git add . and commit. However, the cmake/openshc-sources.txt that is upstream should reflect the required state for the latest buildable binary. Locally, it can have fewer, or additional lines, depending on what is being worked on (to reduce rebuild times). Auto adding the local developing state of that file when doing git add . would be annoying.

I can remove this feature on the upstream .gitignore and only use this trick locally. Fine by me!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I think this trickery would be confusing for others.

Using an alternative source file though might be practical, if only for testing. I created this issue: #42

However, one thing: Is this branch still lacking an empty openshc-source.txt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points. I will revert after the weekend and close this then. Further discussion goes into #42

Copy link
Contributor

@TheRedDaemon TheRedDaemon Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert after the weekend and close this then.

This confuses me. You already remove the gitignore trick. The only thing leaving me confused was the missing openshc-sources.txt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might already have a solution for #42 with #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ADDRESS] Manage function and struct addresses via enum

2 participants