beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
178 stars 95 forks source link

Adding name constants for LuaSyncedCtrl.cpp and LuaSyncedRead.cpp #1541

Open 12345swordy opened 3 weeks ago

12345swordy commented 3 weeks ago

Attempting to fix #1530 CC @sprunk Let me know if I did something wrong in this PR

sprunk commented 3 weeks ago

Generally anything not within a loop that starts like this:

for (lua_pushnil(L); lua_next(L, SOME_NUMBER) != 0; lua_pop(L, 1)) {

is not applicable.

A caveat is that sometimes it's a var passed from outside the loop. For example https://github.com/beyond-all-reason/spring/blob/ce86af7df7524a799d804e903e7851a6f7c85ae1/rts/Lua/LuaUnsyncedCtrl.cpp#L1296 unitIndexInTable is passed -1 from here: https://github.com/beyond-all-reason/spring/blob/ce86af7df7524a799d804e903e7851a6f7c85ae1/rts/Lua/LuaUnsyncedCtrl.cpp#L1320