Skip to content

Commit 034939d

Browse files
committed
[GEN][ZH] add superhackers release version to in-game options screen
1 parent a801bfb commit 034939d

File tree

8 files changed

+192
-54
lines changed

8 files changed

+192
-54
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
default: false
2626
type: boolean
2727
description: "Build extras"
28+
release:
29+
required: false
30+
type: string
31+
description: "Release build (true/false)"
2832

2933
jobs:
3034
build:
@@ -35,6 +39,13 @@ jobs:
3539
- name: Checkout Code
3640
uses: actions/checkout@v4
3741

42+
- uses: actions/checkout@v4
43+
- name: Download version file
44+
if: inputs.release == 'true'
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: version_files
48+
3849
- name: Cache VC6 Installation
3950
if: startsWith(inputs.preset, 'vc6')
4051
id: cache-vc6

.github/workflows/weekly-release.yml

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,46 @@ jobs:
5454
echo "changed=true" >> $GITHUB_OUTPUT
5555
fi
5656
57+
calculate-version:
58+
name: Generate version files
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
fetch-tags: true
66+
67+
- name: Create Version Files
68+
run: |
69+
BASE_TAG=$(cat .github/workflows/base-version.txt)
70+
IFS='.' read -r major minor patch <<<"$BASE_TAG"
71+
CURRENT_TAG=$(git tag --list "$major.$minor*" --sort=-v:refname | head -n1)
72+
73+
if [ -z "$CURRENT_TAG" ]; then
74+
CURRENT_TAG="$BASE_TAG"
75+
NEXT_TAG="$BASE_TAG"
76+
else
77+
IFS='.' read -r major minor patch <<<"$CURRENT_TAG"
78+
NEXT_TAG="$major.$minor.$((patch+1))"
79+
fi
80+
81+
echo "CURRENT_TAG: $CURRENT_TAG"
82+
echo "NEXT_TAG: $NEXT_TAG"
83+
84+
echo "$CURRENT_TAG" > current_tag.txt
85+
echo "$NEXT_TAG" > next_tag.txt
86+
87+
- name: Upload version files
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: version_files
91+
path: |
92+
next_tag.txt
93+
current_tag.txt
94+
5795
build-generals:
58-
needs: detect-scm-changes
96+
needs: [detect-scm-changes, calculate-version]
5997
if: needs.detect-scm-changes.outputs.changed == 'true'
6098
name: Build Generals${{ matrix.preset && '' }}
6199
strategy:
@@ -64,20 +102,23 @@ jobs:
64102
- preset: "vc6"
65103
tools: true
66104
extras: true
105+
release: true
67106
- preset: "win32-vcpkg"
68107
tools: true
69108
extras: true
109+
release: true
70110
fail-fast: false
71111
uses: ./.github/workflows/build-toolchain.yml
72112
with:
73113
game: "Generals"
74114
preset: ${{ matrix.preset }}
75115
tools: ${{ matrix.tools }}
76116
extras: ${{ matrix.extras }}
117+
release: ${{ matrix.release }}
77118
secrets: inherit
78119

79120
build-generalsmd:
80-
needs: detect-scm-changes
121+
needs: [detect-scm-changes, calculate-version]
81122
if: needs.detect-scm-changes.outputs.changed == 'true'
82123
name: Build GeneralsMD${{ matrix.preset && '' }}
83124
strategy:
@@ -86,16 +127,19 @@ jobs:
86127
- preset: "vc6"
87128
tools: true
88129
extras: true
130+
release: true
89131
- preset: "win32"
90132
tools: true
91133
extras: true
134+
release: true
92135
fail-fast: false
93136
uses: ./.github/workflows/build-toolchain.yml
94137
with:
95138
game: "GeneralsMD"
96139
preset: ${{ matrix.preset }}
97140
tools: ${{ matrix.tools }}
98141
extras: ${{ matrix.extras }}
142+
release: ${{ matrix.release }}
99143
secrets: inherit
100144

101145
create-release:
@@ -109,43 +153,40 @@ jobs:
109153
fetch-depth: 0
110154
fetch-tags: true
111155

156+
- uses: actions/checkout@v4
157+
- name: Download version file
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: version_files
161+
112162
- name: Read base version
113163
id: base_version
114164
run: echo "base_version=$(cat .github/workflows/base-version.txt)" >> $GITHUB_OUTPUT
115165

116166
- name: Get latest semver tag
117167
id: get_tag
118-
run: |
119-
BASE=${{ steps.base_version.outputs.base_version }}
120-
IFS='.' read -r major minor patch <<<"$BASE"
121-
TAG=$(git tag --list "$major.$minor*" --sort=-v:refname | head -n1)
122-
echo "latest_tag=$TAG" >> $GITHUB_OUTPUT
168+
run: echo "current_tag=$(cat current_tag.txt)" >> $GITHUB_OUTPUT
123169

124170
- name: Calculate next version
125171
id: next_version
126-
run: |
127-
BASE=${{ steps.base_version.outputs.base_version }}
128-
TAG=${{ steps.get_tag.outputs.latest_tag }}
129-
if [ -z "$TAG" ]; then
130-
NEXT_TAG="$BASE"
131-
else
132-
IFS='.' read -r major minor patch <<<"$TAG"
133-
NEXT_TAG="$major.$minor.$((patch+1))"
134-
fi
135-
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
172+
run: echo "next_tag=$(cat next_tag.txt)" >> $GITHUB_OUTPUT
136173

137174
- name: Collect commits since last release
138175
id: changelog
139176
run: |
140-
TAG=${{ steps.get_tag.outputs.latest_tag }}
177+
TAG=${{ steps.get_tag.outputs.current_tag }}
141178
if [ -z "$TAG" ]; then
142-
echo "commits<<EOF" >> $GITHUB_OUTPUT
143-
git log --pretty=format:"- %s" >> $GITHUB_OUTPUT
144-
echo "EOF" >> $GITHUB_OUTPUT
179+
{
180+
echo "commits<<EOF"
181+
git log --pretty=format:"- %s" | head -n10 | grep -v "Sync Generals repos"
182+
echo "EOF"
183+
} >> $GITHUB_OUTPUT
145184
else
146-
echo "commits<<EOF" >> $GITHUB_OUTPUT
147-
git log "$TAG"..HEAD --pretty=format:"- %s" |grep -v "Sync Generals repos" >> $GITHUB_OUTPUT
148-
echo "EOF" >> $GITHUB_OUTPUT
185+
{
186+
echo "commits<<EOF"
187+
git log "$TAG"..HEAD --pretty=format:"- %s" | grep -v "Sync Generals repos"
188+
echo "EOF"
189+
} >> $GITHUB_OUTPUT
149190
fi
150191
151192
# Generals vc6
@@ -221,8 +262,8 @@ jobs:
221262
222263
### Known issues
223264
224-
- Fullscreen executable is currently broken. You must add the `-win` parameter to run the game in windowed mode.
225-
265+
- Fullscreen execution can freeze the game. For that case, you should add the `-win` parameter to run the game in windowed mode.
266+
226267
### Changelog
227268
${{ steps.changelog.outputs.commits }}
228269
files: |

Generals/Code/GameEngine/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ set(GAMEENGINE_SRC
1919
Include/Common/CDManager.h
2020
Include/Common/ClientUpdateModule.h
2121
Include/Common/CommandLine.h
22-
Include/Common/CopyProtection.h
2322
Include/Common/crc.h
2423
Include/Common/CRCDebug.h
2524
Include/Common/CriticalSection.h
@@ -40,6 +39,7 @@ set(GAMEENGINE_SRC
4039
Include/Common/FunctionLexicon.h
4140
Include/Common/GameAudio.h
4241
Include/Common/GameCommon.h
42+
# Include/Common/GameDefines.h
4343
Include/Common/GameEngine.h
4444
Include/Common/GameLOD.h
4545
Include/Common/GameMemory.h
@@ -588,7 +588,6 @@ set(GAMEENGINE_SRC
588588
Source/Common/System/AsciiString.cpp
589589
Source/Common/System/BuildAssistant.cpp
590590
Source/Common/System/CDManager.cpp
591-
Source/Common/System/CopyProtection.cpp
592591
Source/Common/System/CriticalSection.cpp
593592
Source/Common/System/DataChunk.cpp
594593
Source/Common/System/Debug.cpp
@@ -1078,6 +1077,7 @@ target_include_directories(g_gameengine PUBLIC
10781077

10791078
target_include_directories(g_gameengine PRIVATE
10801079
Include/Precompiled
1080+
${CMAKE_BINARY_DIR}/Generals/Code/Main
10811081
)
10821082

10831083
target_link_libraries(g_gameengine PRIVATE

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
#include "Common/GameLOD.h"
4141
#include "Common/Registry.h"
4242
#include "Common/version.h"
43+
#include "GeneratedVersion.h"
4344

45+
#include "GameClient/ClientInstance.h"
4446
#include "GameClient/GameClient.h"
4547
#include "GameClient/InGameUI.h"
4648
#include "GameClient/WindowLayout.h"
@@ -223,14 +225,24 @@ enum Detail CPP_11(: Int)
223225

224226
OptionPreferences::OptionPreferences( void )
225227
{
226-
// note, the superclass will put this in the right dir automatically, this is just a leaf name
227-
load("Options.ini");
228+
loadFromIniFile();
228229
}
229230

230231
OptionPreferences::~OptionPreferences()
231232
{
232233
}
233234

235+
Bool OptionPreferences::loadFromIniFile()
236+
{
237+
if (rts::ClientInstance::getInstanceId() > 1u)
238+
{
239+
AsciiString fname;
240+
fname.format("Options_Instance%.2u.ini", rts::ClientInstance::getInstanceId());
241+
return load(fname);
242+
}
243+
244+
return load("Options.ini");
245+
}
234246

235247
Int OptionPreferences::getCampaignDifficulty(void)
236248
{
@@ -278,7 +290,7 @@ void OptionPreferences::setLANIPAddress( AsciiString IP )
278290
void OptionPreferences::setLANIPAddress( UnsignedInt IP )
279291
{
280292
AsciiString tmp;
281-
tmp.format("%d.%d.%d.%d", ((IP & 0xff000000) >> 24), ((IP & 0xff0000) >> 16), ((IP & 0xff00) >> 8), (IP & 0xff));
293+
tmp.format("%d.%d.%d.%d", PRINTF_IP_AS_4_INTS(IP));
282294
(*this)["IPAddress"] = tmp;
283295
}
284296

@@ -306,7 +318,7 @@ void OptionPreferences::setOnlineIPAddress( AsciiString IP )
306318
void OptionPreferences::setOnlineIPAddress( UnsignedInt IP )
307319
{
308320
AsciiString tmp;
309-
tmp.format("%d.%d.%d.%d", ((IP & 0xff000000) >> 24), ((IP & 0xff0000) >> 16), ((IP & 0xff00) >> 8), (IP & 0xff));
321+
tmp.format("%d.%d.%d.%d", PRINTF_IP_AS_4_INTS(IP));
310322
(*this)["GameSpyIPAddress"] = tmp;
311323
}
312324

@@ -1415,7 +1427,9 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
14151427
}
14161428
else
14171429
{
1418-
GadgetStaticTextSetText( labelVersion, versionString );
1430+
UnicodeString fullVersion;
1431+
fullVersion.format(L"%s - TheSuperHackers %s", versionString.str(), SUPERHACKERS_VERSION_WIDE);
1432+
GadgetStaticTextSetText(labelVersion, fullVersion);
14191433
}
14201434

14211435

Generals/Code/Main/CMakeLists.txt

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,61 @@ target_link_libraries(g_generals PRIVATE
2020
gi_always
2121
imm32
2222
milesstub
23-
safedisc
2423
vfw32
2524
winmm
2625
)
2726

27+
if(EXISTS "${CMAKE_SOURCE_DIR}/next_tag.txt")
28+
file(READ "${CMAKE_SOURCE_DIR}/next_tag.txt" GAME_VERSION)
29+
string(STRIP "${GAME_VERSION}" GAME_VERSION)
30+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ "${GAME_VERSION}")
31+
set(VERSION_MAJOR "${CMAKE_MATCH_1}")
32+
set(VERSION_MINOR "${CMAKE_MATCH_2}")
33+
set(VERSION_BUILDNUM "${CMAKE_MATCH_3}")
34+
else()
35+
if (IS_VS6_BUILD)
36+
set(VERSION_MAJOR "1")
37+
set(VERSION_MINOR "7")
38+
set(VERSION_BUILDNUM "601")
39+
else()
40+
set(VERSION_MAJOR "1")
41+
set(VERSION_MINOR "8")
42+
set(VERSION_BUILDNUM "601")
43+
endif()
44+
endif()
45+
2846
# TODO Originally referred to build host and user, replace with git info perhaps?
2947
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/GeneratedVersion.h
3048
"#pragma once
3149
32-
#define VERSION_LOCALBUILDNUM 0
33-
#define VERSION_BUILDUSER \"Someone\"
34-
#define VERSION_BUILDLOC \"Someplace\"
50+
#define VERSION_BUILDUSER \"TheSuperHackers\"
51+
#define VERSION_BUILDLOC \"GitHub\"
52+
#define SUPERHACKERS_VERSION_WIDE L\"${GAME_VERSION}\"
3553
"
3654
)
3755

3856
# Based on original binary values for these variables.
57+
if (IS_VS6_BUILD)
3958
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BuildVersion.h
4059
"#pragma once
4160
42-
#define VERSION_MAJOR 1
43-
#define VERSION_MINOR 8
44-
#define VERSION_BUILDNUM 601
61+
#define VERSION_MAJOR ${VERSION_MAJOR}
62+
#define VERSION_MINOR ${VERSION_MINOR}
63+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
64+
#define VERSION_LOCALBUILDNUM 9001 // it's over 9000!
4565
"
4666
)
67+
else()
68+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BuildVersion.h
69+
"#pragma once
70+
71+
#define VERSION_MAJOR ${VERSION_MAJOR}
72+
#define VERSION_MINOR ${VERSION_MINOR}
73+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
74+
#define VERSION_LOCALBUILDNUM 602
75+
"
76+
)
77+
endif()
4778

4879
target_link_options(g_generals PRIVATE "/NODEFAULTLIB:libci.lib")
4980

@@ -59,6 +90,13 @@ target_sources(g_generals PRIVATE
5990
)
6091

6192
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
93+
# VS2005 and later adds default manifest, we need to turn it off to prevent conflict with custom manifest
94+
if(NOT IS_VS6_BUILD)
95+
target_link_options(g_generals PRIVATE
96+
"/MANIFEST:NO"
97+
)
98+
endif()
99+
62100
target_sources(g_generals PRIVATE
63101
RTS.RC
64102
)

0 commit comments

Comments
 (0)