[1.4.8]T4-engine bug in engine/module.lua

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
Munin
Low Yeek
Posts: 7
Joined: Thu Oct 06, 2016 3:25 pm
Location: Germany

[1.4.8]T4-engine bug in engine/module.lua

#1 Post by Munin »

I wanted to cut down loading times by unpacking the engine and module files into directories of the same name sans the suffix.
This resulted in a black screen with only a mouse cursor and nothing else because the relevant code seems not to have been touched for quite some time.
The following changes in engine/module.lua made this work:

Code: Select all

function _M:createModule(short_name, incompatible)
	local dir = "/modules/"..short_name
-- MNI: fixed, path+added cache
	local init_exists=fs.exists(dir.."/mod/init.lua")
	local zip_file=short_name:find(".team$")
	print("Creating module", short_name, ":: (as dir)", init_exists, ":: (as team)", zip_file, "")
-- MNI: changed, use cache
	if init_exists then
		local mod = self:loadDefinition(dir, nil, incompatible)
		if mod and mod.short_name then
			return mod
		end
-- MNI: changed, use cache
	elseif zip_file then
...
end

function _M:loadDefinition(dir, team, incompatible)
-- MNI: fixed, path is the same no matter if zipped or not
	local mod_def=loadfile(dir.."/mod/init.lua")
--	print("Loading module definition from", dir.."/mod/init.lua")
	if mod_def then
...
		mod.load = function(mode)
			if mode == "setup" then
				core.display.setWindowTitle(mod.long_name)
				self:setupWrite(mod)
				if not team then
-- MNI: fixed, only mount base dir as with zipped
					fs.mount(fs.getRealPath(dir), "/", false)
-- MNI: added, in case further dirs are supposed to load as well
					for i, t in ipairs(mod.teams or {}) do
						local base=dir:gsub("/[^/]+$","/")
						local new_dir=base..t[1]:
							gsub(".team$",""):
							gsub("#name#",mod.short_name):
							gsub("#version#",("%d.%d.%d"):
								format(mod.version[1],mod.version[2],mod.version[3]))
						if fs.exists(new_dir) then
							print("Mounting additional dir:",new_dir)
							fs.mount(fs.getRealPath(new_dir),t[3],false)
						end
					end
				else
...
end
cu,
--
Bernd

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: [1.4.8]T4-engine bug in engine/module.lua

#2 Post by jenx »

Interesting. If this works as stated, this would be good to go in 1.5.0
MADNESS rocks

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: [1.4.8]T4-engine bug in engine/module.lua

#3 Post by darkgod »

? The game works very well in unpacked form, how do I think I develop ? ;)
Likely you didnt use the current names though, engine should unpack in game/engines/default/ and module in game/modules/tome/

Also I fail to see how this can make it *faster*. Opening thousands of files is usually a bottleneck for many OSes, having only a few archives open is actually faster (they are zip ziles yeah but not compressed so no loss there)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply