2025-07-28 05:59 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0004983Spring engineGeneralpublic2016-01-02 16:40
Reporterabma 
Assigned Tohokomoko 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusclosedResolutionfixed 
Product Version100.0+git 
Target VersionFixed in Version 
Summary0004983: allow games to include default start script for singleplayer
DescriptionProblem:
addition to https://springrts.com/mantis/view.php?id=4360 "better singleplayer experience" which is closed because 'it can be done in lua now.'

This is true, Lua can do all nessecary singleplayer scripting.

However one problem remains unsolved:
Before the game's Lua can take over, first the game has to be started.
This starting has to happen with some special settings (for ex: via modoptions) so that the game knows that it is not being played in multiplayer match and should instead go into its singleplayer mode.

Currently there exist two possible solutions:

1) launcher-programms that start the engine with startscript
(in most primitive form basically a batch file: "spring.exe -MyStartScript.txt")

2) more recently: springsettings.cfg with entry DefaultStartScript=MyStartScript.txt

Both solutions require the game to be shipped with some sort of custom installer. (problematic)
It can also not be run from the singleplayer-menus of lobbies and can not be downloaded by automatic downloaders.


Suggestion:
-game-archive include a startscript
-when lobby detects a startscript in the game-archive then it uses that to launch the game.
-the startscript file could for example be in: gamedata\defaultstartscript

Steps To Reproduceuse a lobby to download any spring-game with singleplayer (kernel panic, spring tanks,..) and try to play their singleplayer.
Additional InformationNot sure if this is correct bugtracker.
I guess it would be like validAIs.lua/validMaps.lua or other files that would need to be implemented in engine and lobbies, too.


Related: zwzsg's post https://springrts.com/mantis/view.php?id=4360#c13011 :
"There could be a convention that if a game archive contains a file spmenu.txt, then lobbies should use that file as a startscript when asking to run a single player game."


springlobby:
https://github.com/springlobby/springlobby/issues/368
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0015401

hokomoko (developer)

Having the script inside the archive is impossible since the script is what tells you which archive to use.

defaultstartscript.txt should solve most of the issues

~0015402

user744

> "Having the script inside the archive is impossible since the script is what tells you which archive to use."
I do not understand this. Does not unitsync already read stuff from inside the archive and pass it to lobbies? For example the game-name, version, description from modinfo.lua? And LuaAI.lua and validMaps.lua and modoptions and other files.
Startscript is just another string, how does it differ from the mentioned things?


> "defaultstartscript.txt should solve most of the issues"
No, it does not because defaultstartscript is per ENGINE.
This feature-request looks similiar, but is about defaultstartscript per GAME.
Reason:
Only the later helps lobbies (say: springlobby but also Lua-menus) to implent a singleplayer-menu that can launch the SP-experience of games in sensible way.

~0015409

hokomoko (developer)

Is this an engine issue?
It seems to me that you're trying to encourage a convention of putting some default script.txt in the main folder of the mod, which may be interesting to lobbies but is irrelevant once spring.exe is started

~0015423

user744

> Is this an engine issue?
a matter of unitsync.
Or not?

> encourage a convention of putting some default script.txt in the main folder of the mod
That sounds like a loose agreement, which is useless.
To my understanding lobbies read archive-content via engine's unitsync, and that is the way the startscript should be read too.
If the script is a physical file in mod or an string-entry in modinfo.lua or elsewhere can be discussed.

~0015424

hokomoko (developer)

> a matter of unitsync.
Already implemented:
> To my understanding lobbies read archive-content via engine's unitsync

Unless I'm mistaken, you can already read whatever file you want with unitsync.

I can't see any option other than the loose agreement.
What function would you add to unitsync?

~0015425

user744

Last edited: 2016-01-02 13:16

View 4 revisions

I do not know how this stuff works.
But as far I see, other files inside the mod are NOT read "by loose agreement", it is in code.
Lobbies do not read "whatever they want."
For example here:
https://github.com/spring/spring/blob/9bec15418279f1ecd87a5586d5f4ae44f8fee0ad/rts/System/FileSystem/ArchiveScanner.cpp#L1222
or here: https://github.com/spring/spring/blob/47426d061b96707e44f208bb6677ad7948da06b7/tools/unitsync/unitsync.cpp#L1340

All the files like modoptions.lua, validMaps.lua etc have a comment in engine:
//used by lobbies

> "irrelevant once spring.exe is started"
Same with for example validMaps.lua, it is only relevant pre-game too.

> What function would you add to unitsync?
I do not know if this is unitsync stuff, I just guess so.
Something like: getDefaultStartScriptFromGame()

~0015426

hokomoko (developer)

Last edited: 2016-01-02 13:24

View 2 revisions

https://github.com/spring/spring/blob/47426d061b96707e44f208bb6677ad7948da06b7/tools/unitsync/unitsync.cpp#L2044

You can open any file you want.
Just open startscript.txt write it to the FS and run spring with it.

validmaps etc. need a special function to read in UnitSync because they're lua files.

~0015427

user744

Interessting.
But not sure if that is good way when lobbies have to play with raw files like that, a standard function that is used by all lobbies seems cleaner. (like for other files)

> validmaps etc. need a special function to read in UnitSync because they're lua files.
I think lua is not the point there, unitsync existed when those files were still textfiles too. The advantage is that it is a standard way for all lobbies, not many unique different implementations.

~0015428

hokomoko (developer)

I'm not going to add a function that does:
1) Open startscript.txt
2) Read it to a buffer
3) Close startscript.txt

~0015429

user744

Then please un-assign yourself from this entry so maybe others can do it.

~0015430

gajop (developer)

Suggestion:
-game-archive include a startscript
-when lobby detects a startscript in the game-archive then it uses that to launch the game.
-the startscript file could for example be in: gamedata\defaultstartscript

What's the point of all this? Investing work to eventually end up with DefaultArchive=MyArchive which would end up executing the startscript contained in it?

~0015431

user744

Last edited: 2016-01-02 14:27

View 2 revisions

> What's the point of all this?
So that in lobby you can select a game, click a "Start Singleplayer" and then it launches the Lua-singleplayer-menu of that game.
Such Lua-Singleplayer already exists/existed/is WIP, but there is no way to launch them from lobbies.

~0015432

gajop (developer)

standalone startscripts is a bad idea for game archives since they don't contain maps, the correct springsettings.cfg and probably other settings

Generally, when distributing games you want to specify a minimum of:
- list of game(mod) archives
- list of required map archives (and maybe an additional validmaps config)
- working engine versions
- AIs or (validais.lua thingy that still isn't integrated iirc)
- springsettings.cfg (probably in parts platform specific)
- entry point: used to run the lua lobby if its provided (probably, but not necessarily a startscript)
^ All that is what users should obtain via pr-downloader when they download games, the gamearchive with a startscript is not enough (at least because you also need a map to run it)

~0015433

user744

Lobbies can download the needed engine/map for multiplayer rooms and replays, why shouldnt it be possible for SP too.

> list of game(mod) archives
modname is in the startscript.

> list of required map archives
The initial mapname is contained in the startscript.
TBD is what happens if the map changes. (for example next mission is on different map)
The game's lua can check if a map exists and display a message to download a mappack. (some games already do that)
Maybe in future something better is possible, maybe engine will download stuff, maybe games can add dependency on maps, imo this is OT here.

>(and maybe an additional validmaps config)
Not nessecary because once ingame the game has full control, including what maps it wants to offer to player.

> AIs or (validais.lua thingy that still isn't integrated iirc)
AI (if needed) is in startscript.
validais.lua is not nessecary because once ingame the game has full control, including what AIs it wants to offer to player.

> springsettings.cfg
Imo not for the game to decide. The user (read: its lobby/engine install) knows better what settings work on that platform. games should save their stuff elsewhere and not interfere with springsettings. imo OT.

> entry point: used to run the lua lobby if its provided
This is about a SP-button in EXISTING lobbies. If you want to go back to multiplayer, you simply quit.
+Notes

-Issue History
Date Modified Username Field Change
2015-10-15 14:58 user744 New Issue
2015-10-15 15:13 hokomoko Changeset attached => spring develop c30ebbf6
2015-12-26 20:15 hokomoko Note Added: 0015401
2015-12-26 20:15 hokomoko Status new => closed
2015-12-26 20:15 hokomoko Assigned To => hokomoko
2015-12-26 20:15 hokomoko Resolution open => fixed
2015-12-27 06:39 user744 Note Added: 0015402
2015-12-27 06:39 user744 Status closed => feedback
2015-12-27 06:39 user744 Resolution fixed => reopened
2015-12-30 14:38 hokomoko Note Added: 0015409
2016-01-02 12:20 user744 Note Added: 0015423
2016-01-02 12:20 user744 Status feedback => assigned
2016-01-02 12:29 hokomoko Note Added: 0015424
2016-01-02 13:12 user744 Note Added: 0015425
2016-01-02 13:13 user744 Note Edited: 0015425 View Revisions
2016-01-02 13:14 user744 Note Edited: 0015425 View Revisions
2016-01-02 13:16 user744 Note Edited: 0015425 View Revisions
2016-01-02 13:23 hokomoko Note Added: 0015426
2016-01-02 13:24 hokomoko Note Edited: 0015426 View Revisions
2016-01-02 13:40 user744 Note Added: 0015427
2016-01-02 13:47 hokomoko Note Added: 0015428
2016-01-02 13:47 hokomoko Status assigned => closed
2016-01-02 13:47 hokomoko Resolution reopened => no change required
2016-01-02 14:06 user744 Note Added: 0015429
2016-01-02 14:06 user744 Status closed => feedback
2016-01-02 14:06 user744 Resolution no change required => reopened
2016-01-02 14:19 gajop Note Added: 0015430
2016-01-02 14:26 user744 Note Added: 0015431
2016-01-02 14:26 user744 Status feedback => assigned
2016-01-02 14:27 user744 Note Edited: 0015431 View Revisions
2016-01-02 14:42 gajop Note Added: 0015432
2016-01-02 14:58 user744 Note Added: 0015433
2016-01-02 16:18 abma Status assigned => closed
2016-01-02 16:18 abma Resolution reopened => fixed
2016-01-02 16:40 abma Reporter user744 => abma
+Issue History