Skip to content

[GEN][ZH] Generate git version information and print it in the Game Window title, Options Menu (and Main Menu) #1219

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xezon
Copy link

@xezon xezon commented Jun 30, 2025

This change generates information from git and makes it available in the game.

The Window Title now prints additional version information unique to this project. R stands for revision and it simply shows the commit count. We can tweak this if we want to show git tag or commit hash, but for now this appears to be sufficient. The label "By" is technically localized.

The Options Menu (and the Main Menu: "MainMenu.wnd:LabelVersion") also print additional information, including the last commit time (UTC). It also shows the EXE and INI crc's.

versioninfo

TODO

  • Replicate in Generals
  • Log out version
  • Fix constness

@xezon xezon added this to the Code foundation build up milestone Jun 30, 2025
@xezon xezon requested a review from OmniBlade June 30, 2025 20:23
@xezon xezon added Enhancement Is new feature or request GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Jun 30, 2025
@xezon
Copy link
Author

xezon commented Jul 1, 2025

One more thing we can do here is log out the version too.

@@ -108,36 +119,15 @@ UnicodeString Version::getUnicodeVersion( void )
return version;
}

UnicodeString Version::getFullUnicodeVersion( void )
Copy link
Author

Choose a reason for hiding this comment

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

I removed this function because it was almost a duplicate of the one above. I combined what it does with the function above.

NameKeyType versionID = TheNameKeyGenerator->nameToKey( AsciiString("OptionsMenu.wnd:LabelVersion") );
GameWindow *labelVersion = TheWindowManager->winGetWindowFromId( NULL, versionID );
UnicodeString versionString;
versionString.format(TheGameText->fetch("Version:Format2").str(), (GetRegistryVersion() >> 16), (GetRegistryVersion() & 0xffff));
Copy link
Author

Choose a reason for hiding this comment

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

Previously, this read the version number from the registry. This is crazy. The version in the registry is meaningless. For example, changing the version from 1 04 to 1 05 in the registry will not magically upgrade the executable.

version.format(TheGameText->fetch("Version:Format3").str(), m_major, m_minor, m_buildNum);
else
version.format(TheGameText->fetch("Version:Format4").str(), m_major, m_minor, m_buildNum, m_localBuildNum,
m_buildUser.getCharAt(0), m_buildUser.getCharAt(1));

Choose a reason for hiding this comment

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

I'd be inclined to change this to use the git commit author. You hard code this elsewhere to be "SuperHackers" which I assume is intended to be like a nintendo seal of approval, but anyone forking the repo and building it without changing that will also make a SuperHackers stamped binary.

Copy link
Author

Choose a reason for hiding this comment

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

Yes this Build User thing needs more work, because as you say, it is not really unique to us publishing it, if it is embedded as a plain string. I do not know what to do with it at this time.

Using Git Commit Author does not work, because that name is not stable. At least not for the CI builds. For local builds it probably would be fine.

We can use Git Commit Author, and override that with the build user if that is set (from CI).

Choose a reason for hiding this comment

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

In the original game, it seems that the build user was effectively the username of whoever authored the final build which the commit author is kind of an analog to. I like the idea of passing something from the CI which will differ if built on someone elses such as the repo owner and then falling back to commit author for local builds.

Copy link
Author

Choose a reason for hiding this comment

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

Improved. Now, VERSION_BUILDUSER (and VERSION_BUILDLOC) are empty strings, so build user will default to last git commit author name.

I do not yet know how we generate VERSION_BUILDUSER and VERSION_BUILDLOC, but that can be another change in the future.

…info, fix getAsciiVersion to be consistent with getUnicodeVersion, add comment, remove ( void ), fix Version function ordering
@xezon
Copy link
Author

xezon commented Jul 2, 2025

One more thing we can do here is log out the version too.

  • Fixed. Log will now print:
================================================================================
Generals version 1.4.601 Debug
Build date: Jul  2 2025 19:27:54
Build location: 
Build user: 
Build git revision: ~543
Build git version: ~33142610
Build git commit time: 2025-06-30 20:22:40
Build git commit author: xezon
================================================================================
  • Build user now falls back to git commit author name if the build user is empty.

  • Also fixed getAsciiVersion to be consistent with getUnicodeVersion.

  • Added comments to public functions of Version class.

  • Removed all the useless (void) function arguments in Version class.

@xezon xezon requested a review from OmniBlade July 2, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Is new feature or request Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement build version/commit hash display to identify exact build version
2 participants