Skip to content

Commit 3d1ea7d

Browse files
bruno-dasilvaclaude
authored andcommitted
feat: add Engine.FeatureSupport.hasChecksums constant
Lets Lua code check whether Spring.GetPrevFrameChecksum() is available without nil-guarding its return value, addressing PR review feedback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 020f6a6 commit 3d1ea7d

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

rts/Lua/LuaConstEngine.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @field noHandicapForReclaim boolean Whether handicap is applied to income from reclaim
2929
* @field groupAddDoesntSelect boolean Whether 'group add' also selects the group (does both if false)
3030
* @field deadTeamsKeepUnitLimit boolean Whether engine redistributes dead team unitlimit to allies (false) or keeps it as-is (true)
31+
* @field hasChecksums boolean Whether the engine was built with SYNCCHECK (i.e. Spring.GetPrevFrameChecksum() returns a value)
3132
*/
3233

3334
/***
@@ -73,7 +74,7 @@ bool LuaConstEngine::PushEntries(lua_State* L)
7374
*
7475
* will be compatible even on engines that don't yet know about the entry at all. */
7576
lua_pushliteral(L, "FeatureSupport");
76-
lua_createtable(L, 0, 11);
77+
lua_createtable(L, 0, 12);
7778
LuaPushNamedBool(L, "NegativeGetUnitCurrentCommand", true);
7879
LuaPushNamedBool(L, "hasExitOnlyYardmaps", true);
7980
LuaPushNamedNumber(L, "rmlUiApiVersion", 1);
@@ -87,6 +88,11 @@ bool LuaConstEngine::PushEntries(lua_State* L)
8788
LuaPushNamedBool(L, "noHandicapForReclaim", true);
8889
LuaPushNamedBool(L, "groupAddDoesntSelect", true);
8990
LuaPushNamedBool(L, "deadTeamsKeepUnitLimit", false);
91+
#ifdef SYNCCHECK
92+
LuaPushNamedBool(L, "hasChecksums", true);
93+
#else
94+
LuaPushNamedBool(L, "hasChecksums", false);
95+
#endif
9096
lua_rawset(L, -3);
9197

9298
lua_pushliteral(L, "textColorCodes");

rts/Lua/LuaSyncedRead.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,8 @@ int LuaSyncedRead::GetGameSeconds(lua_State* L)
946946
* built with `LUA_NUMBER = float`, which cannot represent a 32-bit
947947
* checksum losslessly.
948948
*
949-
* Returns `nil` on builds without `SYNCCHECK`.
949+
* Returns `nil` on builds without `SYNCCHECK`. Check
950+
* `Engine.FeatureSupport.hasChecksums` to detect availability.
950951
*
951952
* @function Spring.GetPrevFrameChecksum
952953
*

0 commit comments

Comments
 (0)