Page 1 of 1

unitdefs inconsistency running spring.exe vs springlobby

Posted: 17 Sep 2017, 07:01
by raaar
I've been told my game crashes on singleplayer when run through weblobby.

I test my game using springlobby's singleplayer mode and it works.

I confirmed the problem, it's a "attempt to compare number with string" error when processing unitdefs_post and doing this

Code: Select all

	...
	local mv = unitDef.maxvelocity
	if (mv and mv > 0) then               <---------------- fails here
		Spring.Echo(unitDef.name.." HERE! "..mv)
	...
I also get the error by running the spring 103 exe directly,

in the context of unitdefs_post , it seems it reads the unitdefs values as strings if run through the exe or weblobby, but reads them as floats when started through springlobby(edited)
[f=-000001] Stratos HERE! 4.80000019 <------ from springlobby
vs
[f=-000001] Stratos HERE! 4.8 <------ from exe/weblobby

i can fix it with a "tonumber(...)", but the fact that the exact same game package produces different results is disturbing
(same game, same map, same engine binary)

Re: unitdefs inconsistency running spring.exe vs springlobby

Posted: 17 Sep 2017, 12:35
by Kloot
Compare "script.txt" generated by both lobbies with "_script.txt" generated by Spring when running standalone.

Re: unitdefs inconsistency running spring.exe vs springlobby

Posted: 17 Sep 2017, 17:00
by raaar
you mean the "_script.txt" on my spring data directory, right?

_script_binary.txt
from running spring.exe 103.0
(440 Bytes) Downloaded 11 times
_script_springlobby.txt
springlobby
(1.08 KiB) Downloaded 16 times
_script_weblobby.txt
weblobby
(628 Bytes) Downloaded 9 times

the mod options change, there's nothing about unit restrictions, and the unitdef where the issue first showed up was processed in all three cases.

(these were generated after the fix)

Re: unitdefs inconsistency running spring.exe vs springlobby

Posted: 17 Sep 2017, 17:35
by Kloot
the mod options change
Precisely, and what relation exists between unitdefs_post, the mod-option (string) "velocitymult" and the line referencing (number) unitDef.maxvelocity?

Re: unitdefs inconsistency running spring.exe vs springlobby

Posted: 17 Sep 2017, 18:09
by raaar
ah, that's why it worked through springlobby, having that option made it replace that attribute with the number value in unitdefs_post before reaching that code block.

Lua auto-converts when multiplying string with number, but throws an error if it's a comparison.