Repository navigation
build(pathfinder): Include PreRTS.h in new pathfinder source files - #3523
PedroTiago23 wants to merge 2 commits into
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughCoordinate and pathfinding headers and source files add includes for math, game definitions and types, coordinates, debugging, and game memory. No declarations or runtime behavior changed. ChangesCoordinate and pathfinding includes
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
[Low impact] The PR appears safe to merge; no actionable issues were found.
|
|
Without PreRTS, it compiles fine with VC6 and MSCV, so maybe it is a compiler specific issue. Which compiler are you using? PreRTS.h includes a lot of headers. I think it would be good to figure out which header(s) in particular the compiler is missing. |
It's strange because I'm using VC6 inside the Docker build container. Wouldn't this mean that the environment should be the same for everyone, provided they have the project and run a clean build using the Linux Docker environment? Or am I mistaken? In any case, here is some information that may be relevant to my development environment: OS: Linux cachyos-x8664 7.2.9-2-cachyos x86_64 GNU/Linux Docker version: Docker client=29.9.0; server=29.9.0 Build image used: Compiler configuration: The build configuration also reports the following: These details also indicate that I am using the legacy VC6 compiler. Dockerfile: 1: FROM debian:12.10-slim
4: ARG CMAKE_VERSION="3.31.6"
5: ARG GIT_VERSION="2.49.0"
32: RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-windows-x86_64.zip \
33: && unzip cmake-${CMAKE_VERSION}-windows-x86_64.zip -d /build/tools/ \
34: && mv /build/tools/cmake-${CMAKE_VERSION}-windows-x86_64 /build/tools/cmake \
38: RUN wget https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-64-bit.zip \
39: && unzip MinGit-${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-64-bit.zip -d /build/tools/ \
44: RUN wget https://github.com/itsmattkc/MSVC600/archive/refs/heads/master.zip \
46: && mv /build/tools/MSVC600-master/ /build/tools/vs6 \Regarding For reference, here is a short excerpt from the errors produced when I ran As shown above, After investigating the files in the My approach was to add only the specific dependencies missing from each file. One clear example was the missing After making these changes and rerunning However, if the project builds normally on everyone else's machine and these problems occur only in my environment, I may be overlooking something simple. I intend to try compiling the project on another machine I own, which runs Linux Mint. If a clean build fails there as well, that might indicate that this is an issue worth investigating. Could a build cache or precompiled headers be masking the problem in other environments? I noticed that the project uses several precompiled headers, including |
|
Add PreRTS.h to the top of GameEngine CPP's |
Just to confirm, would you prefer me to restore I initially tried replacing it with specific headers to avoid unnecessary dependencies, but I noticed the comment in |
|
I think there is likely an issue within the docker build |
I’m using I tested a clean build of The container invokes Could you clarify which build command and configuration you use? I’d like to make sure I’m following the intended build procedure and understand whether there might be a difference between our environments. |
Could you at least try to see if that would solve the problem. I am with Mauller that if it compiles on VC6 and MSVC, than it is weird it doesn't in linux/docker and would suggest a build pipeline issue. But lets see what works and doesn't work. Btw, is this related to #3555 ? |
|
Yes |
The problem might actually be related to the pre-compiled header issue for docker builds #3555 We might need it, but If the issue was not including PreRTS.h in the cpp files then it would have failed to compile in VC6 and VS22 when @Skyaero42 split the files out. |
tintinhamans
left a comment
There was a problem hiding this comment.
tested this rebased onto current main. needs #include "trig.h" in ICoord2D.h now that it uses Sqrt instead of sqrt. with that added, a clean Docker/VC6 build of z_generals passes without #3555's workaround. could you rebase and add that include?
ede3078 to
c67d5b6
Compare
|
Thanks for the feedback! I've rebased the PR onto the current main, added |
|
I had claude have a go at it Why
|
| Error | Symbol | Defined in |
|---|---|---|
| C2501 | ICoord2D |
Lib/BaseType.h |
| C2501 | ObjectID |
Common/GameType.h |
| C2065 | MSGNEW |
Common/GameMemory.h |
| C2065 | DEBUG_ASSERTCRASH |
Common/Debug.h |
The compiler isn't the difference: the Docker image uses VC6 too. VC6's cl.exe reports itself as version 12.00, hence "MSVC 12".
Fix:
- Start
PathfindCellInfo.cppwith#include "PreRTS.h", like every other GameEngine source file. - Make
PathfindCellInfo.hself-contained:#pragma once #include "Lib/BaseType.h" #include "Common/GameType.h"
To reproduce on Windows, configure a build with -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON.
Why does Docker turn precompiled headers off?
The original Docker build PR (#1774) doesn't say why. The most likely reason is that VC6 precompiled headers are unreliable under Wine. VC6 saves a precompiled header as a raw copy of compiler memory and must load it back at the same address. Under Wine (and under ASLR on modern Windows) that often fails with C1859/C1852 errors, at random.
This turns out to be useful: a build without precompiled headers catches missing includes like these. The clang-tidy setup turns them off for the same reason.
To test whether precompiled headers now work under Wine, remove that flag and rebuild with FORCE_CMAKE=true.
Would a modern MSVC in Docker avoid this?
Only partly:
- Precompiled headers: modern MSVC handles them much better, but C1859 is still possible, so it isn't guaranteed under Wine.
- Purpose of the Docker build: it exists to produce VC6 binaries (
ENV PRESET=vc6), which are needed for retail compatibility. Modern MSVC generates different code, especially floating-point code, so it can't replace VC6. It could only be an additional build. - These errors: they would fail the same way with modern MSVC as long as precompiled headers are off.
Bottom line: fix the includes. The code is then correct with any compiler and build setup.
So it looks like it is better to include PreRTS rather than assume it is auto-included (precompiled).
Imho this means we should untangle PreRTS.h at some point and use proper includes for each file. PathFindCellInfo.h e.g. doesn't need all the stuff it pulls in.
That makes sense. I agree that, in the future, we should reduce the reliance on However, for this PR, I believe the current changes are sufficient. I ran a clean Docker/VC6 build, which completed successfully with the six I think it's best to keep this PR focused on the minimal, tested fix and leave the broader header-dependency cleanup for a separate future change. |
|
See this comment #3555 (comment) |
Oh, okay. perfect. |
| */ | ||
|
|
||
| #include "PreRTS.h" | ||
| #include "Common/Debug.h" |
There was a problem hiding this comment.
Doesn't match the title's description, but I think it fixes a bug reported here?
#3333 (comment)
There was a problem hiding this comment.
This PR addresses the missing include convention exposed by the Pathfinder source split and the resulting Docker build failure. It doesn't attempt to fix the pathfinding behavior issues tracked in #3333; those broader changes should remain separate.
| */ | ||
|
|
||
| #include "PreRTS.h" | ||
| #include "Common/GameDefines.h" |
There was a problem hiding this comment.
No, it’s redundant. PreRTS.h already includes "Common/GameDefines.h". I’ll remove it.
|
|
||
| #pragma once | ||
|
|
||
| #include "trig.h" |
There was a problem hiding this comment.
This fixes an oversight from the deterministic math right?
There was a problem hiding this comment.
Yes, this is related to the use of the project's "Sqrt" function. "ICoord2D::length()" calls "Sqrt(double)", which is declared in "trig.h", so the include is needed.
|
|
||
| #include "PreRTS.h" | ||
| #include "Common/Debug.h" | ||
| #include "Common/GameMemory.h" |
There was a problem hiding this comment.
These includes were left over from my earlier attempt to replace PreRTS.h with individual dependencies. Since PreRTS.h already provides them, they are redundant here. I'll remove them.
c67d5b6 to
8220c34
Compare
I encountered some linker errors involving s_forceCleanCells and s_useFixedPathfinding while performing a clean build on Linux (CachyOS). Upon investigating the cause, I found that adding the "PreRTS.h" header to certain files resolved the issue for my build. These files are:
PathNode.cpp
PathfindCellInfo.cpp
PathfindCellList.cpp
PathfindConstants.cpp
PathfindZoneManager.cpp
ZoneBlock.cpp
After making this addition, the compilation completed successfully.
As I am new to contributing and still find debugging build processes challenging, I used AI to assist in investigating the issue. One of the most insightful pieces of information the AI provided was a reference to PR #3429. I suspect the refactoring in that PR might be related to the issue, though this is just a hypothesis; I haven't investigated it deeply yet, as I am still getting familiar with the project.
For testing purposes, I invite everyone to try compiling the current project on a Linux machine. If you encounter compilation issues, please try using my fork by following the steps below:
git clone https://github.com/TheSuperHackers/GeneralsGameCode.git
cd GeneralsGameCode
git fetch https://github.com/PedroTiago23/GeneralsGameCode.git fix/pathfinder-prertsh-include
git switch --detach FETCH_HEAD
./scripts/docker-build.sh --clean --game zh
Assuming, of course, that Docker is installed and running.