ZeroK-RTS / Zero-K

Open source RTS game running on the Spring/Recoil engine
https://zero-k.info
GNU General Public License v2.0
662 stars 200 forks source link

Replace `include("bla.h")` with `Spring.Utilities.Bla` #5207

Open sprunk opened 3 months ago

sprunk commented 3 months ago

Including the file over and over in each gadget recreates the whole table (-> waste of cycles, garbage collector pressure) and pollutes the gadget with a ton of mostly useless globals.

1) For custom commands, the utilities table exists. Change

VFS.Include("LuaRules/Configs/customcmds.h")
Spring.Echo(CMD_FOO)

into

local CMD_FOO = Spring.Utilities.CMD.FOO
Spring.Echo(CMD_FOO)

2) create a Spring.Utilities subtable for other similar includes: keysym.h, colors.h[.lua] and apply the same treatment as above to gadgets.

sprunk commented 3 months ago
  1. IterableMap