Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Aug 23, 2025

This change marks the first use case for tinkering with shadowed files and recovers 481 higher resolution textures in Zero Hour by re-prioritizing textures by size on game startup.

This was implemented by directly reordering the texture order inside the multimap on game start - as opposed to testing each file instance on texture loading for the largest texture size. This was done to favor level load performance over game startup performance.

It should be pretty fast though.

Original Zero Hour

The football stadium using downscaled Zero Hour textures.

shot_20250823_185540_1

Zero Hour with this change

The football stadium using higher resolution Generals textures.

shot_20250823_185352_1

The re-prioritized textures are

Attached as a TXT file because of its size.

log.txt

TODO

  • Replicate in Generals

@xezon xezon added Art Is art related Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour labels Aug 23, 2025
@AlseeAns
Copy link

i really loved this

@MarcosV2020
Copy link

Yeah, much better!

@xezon xezon force-pushed the xezon/impl-texture-prioritization branch from dd7987a to c199d7f Compare October 16, 2025 20:29
@xezon xezon force-pushed the xezon/impl-texture-prioritization branch from c199d7f to 52d5e06 Compare October 16, 2025 20:31
@xezon
Copy link
Author

xezon commented Oct 16, 2025

Rebased.

@xezon xezon requested a review from Skyaero42 October 16, 2025 21:24
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

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

Ok

@xezon
Copy link
Author

xezon commented Oct 17, 2025

Replicated in Generals with conflicts. Code is disabled in Generals because it is of no use for the retail game.

I have revisited the Zero Hour implementation because I came to the conclusion that we should not change the default overwrite behavior of textures with this change. It would raise eyebrows if some (larger) textures are overwriting while others are not.

To mitigate this issue, I have restricted the reprioritization of textures to the original Textures.big and TexturesZH.big archives, so that this change specifically targets the retail game setup and not Mods.

@xezon
Copy link
Author

xezon commented Oct 17, 2025

D:\Projects\TheSuperHackers\GeneralsGameCode>FOR /F "delims=" %b IN ('git merge-base --fork-point main') DO git diff %b  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git diff 6748e68e7e56b78634a42e1bf34230b1cc58ea1b  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch
Checking patch Generals/GameEngine/Include/Common/GameDefines.h...
error: Generals/GameEngine/Include/Common/GameDefines.h: No such file or directory
Checking patch Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DFileSystem.h...
Checking patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp...
error: while searching for:
        return (fileType == FILE_TYPE_TGA || fileType == FILE_TYPE_DDS);
}

//-------------------------------------------------------------------------------------------------
/**
        Sets the file name, and finds the GDI asset if present.

error: patch failed: Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp:119
error: while searching for:
        // save the filename
        strlcpy( m_filename, filename, _MAX_PATH );

        char name[_MAX_PATH];
        const Int EXT_LEN = 32;
        char extension[EXT_LEN];
        extension[0] = 0;
        strcpy(name, filename);
        Int i = strlen(name);
        i--;
        Int extLen = 1;
        while(i>0 && extLen < EXT_LEN) {
                if (name[i] == '.') {
                        strcpy(extension, name+i);
                        name[i] = 0;
                        break;
                }
                i--;
                extLen++;
        }
        Int j = 0;
        // Strip out spaces.
        for (i=0; name[i]; i++) {
                if (name[i] != ' ') {
                        name[j] = name[i];
                        j++;
                }
        }
        name[j] = 0;

        // test the extension to recognize a few key file types
        GameFileType fileType = FILE_TYPE_COMPLETELY_UNKNOWN;  // MBL FILE_TYPE_UNKNOWN change due to compile error
        if( stricmp( extension, ".w3d" ) == 0 )
                fileType = FILE_TYPE_W3D;
        else if( stricmp( extension, ".tga" ) == 0 )
                fileType = FILE_TYPE_TGA;
        else if( stricmp( extension, ".dds" ) == 0 )
                fileType = FILE_TYPE_DDS;



        // We need to be able to grab w3d's from a localization dir, since Germany hates exploding people units.
        if( fileType == FILE_TYPE_W3D )

error: patch failed: Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp:146
error: while searching for:
                strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath));

        }

        // We need to be able to grab images from a localization dir, because Art has a fetish for baked-in text.  Munkee.
        if( isImageFileType(fileType) )
        {
                static const char *localizedPathFormat = "Data/%s/Art/Textures/";
                sprintf(m_filePath,localizedPathFormat, GetRegistryLanguage().str());

error: patch failed: Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp:192
Hunk #7 succeeded at 253 (offset -29 lines).
Hunk #8 succeeded at 267 (offset -29 lines).
Hunk #9 succeeded at 346 (offset -11 lines).
Hunk #10 succeeded at 419 (offset -11 lines).
Hunk #11 succeeded at 456 (offset -11 lines).
Applied patch Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DFileSystem.h cleanly.
Applying patch Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp with 3 rejects...
Hunk #1 applied cleanly.
Hunk #2 applied cleanly.
Hunk #3 applied cleanly.
Rejected hunk #4.
Rejected hunk #5.
Rejected hunk #6.
Hunk #7 applied cleanly.
Hunk #8 applied cleanly.
Hunk #9 applied cleanly.
Hunk #10 applied cleanly.
Hunk #11 applied cleanly.

@Skyaero42
Copy link

Still approved

@xezon xezon merged commit b838c65 into TheSuperHackers:main Oct 18, 2025
17 checks passed
@xezon xezon deleted the xezon/impl-texture-prioritization branch October 18, 2025 13:52
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Art Is art related Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants