Singleplayer

Singleplayer

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Singleplayer

Post by Silentwings »

This is a loose outline of a long term idea for creating a singleplayer mode within the engine. Essentially what I think it needs are

(1) A Spring.Reload, much like Spring.Restart, but that does not start a new instance of Spring.
(2) A new lua state & the attached baggage, essentially like luaintro but without the engine loading going on in the background, and with access to LuaSocket. Plus some trigger for this to load in place of the normal loading sequence.
(3) Integration of pr-downloader and a lua API for it.

I think that these three things would be enough to allow a game to have a fully fledged singleplayer mode, written in lua/chili in the usual way, with the ability to download its own content and then Spring.Reload into missions (made with the already existing systems) and back again.

Having had a nose around the code, I think most of the functionality for (2), and to a lesser extent (1), already exists. (3) looks like more work.

I'm putting this post here mostly to record the idea for later - I do plan to work on this one day but certainly not before Christmas. I'd also be interested to hear if
- if anyone who has already made singleplayer modes or mission systems thinks more/less would be needed/useful.
- if any of the engine devs would rate (1)-(3) as easy/feasible/impossible or suggest modifications.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Singleplayer

Post by gajop »

Silentwings wrote:This is a loose outline of a long term idea for creating a singleplayer mode within the engine. Essentially what I think it needs are

(1) A Spring.Reload, much like Spring.Restart, but that does not start a new instance of Spring.
(2) A new lua state & the attached baggage, essentially like luaintro but without the engine loading going on in the background, and with access to LuaSocket. Plus some trigger for this to load in place of the normal loading sequence.
(3) Integration of pr-downloader and a lua API for it.

I think that these three things would be enough to allow a game to have a fully fledged singleplayer mode, written in lua/chili in the usual way, with the ability to download its own content and then Spring.Reload into missions (made with the already existing systems).

Having had a nose around the code, I think most of the functionality for (2), and to a lesser extent (1), already exists. (3) looks like more work.

I'm putting this post here mostly to record the idea for later - I do plan to work on this one day but certainly not before Christmas. I'd also be interested to hear if
- if anyone who has already made singleplayer modes for their games thinks more/less would be needed/useful.
- if any of the engine devs would rate (1)-(3) as easy/feasible/impossible or suggest modifications.
(1) What would Spring.Reload do exactly? Restart Spring but in the same window, or something else? Note that Spring needs restarts between games and it would be too hard to code it not to. The main issue here is that Spring.Restart works with only one engine, so the multi-engine support other lobbies currently have is lost here - not sure how to solve this.
(2) Not entirely essential I think. It's just a minor (few seconds) inconvenience to load a nearly empty (ingame lobby-only) mod.
(3) Shouldn't be too hard I think, but I'll leave the pr-downloader lib linking to abma/jk. I could help to provide a Lua API for archive downloading and handling with unitsync (also pretty important).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Singleplayer

Post by knorke »

tl;dr:
:arrow: Test/fix Spring.Restart()
:arrow: How should players get into the in-mod menu? http://springrts.com/phpbb/viewtopic.php?f=64&t=30376
----
(I like to call in-mod singleplayer instead of in-engine, because the later can be confused with the default menu of spring.exe, with the beach picture)

In-mod singleplayer is imo already possible and has been done seperately by zwszg and by me.
You can have menus to setup up games/select missions, you can start the game, can return to the menu from within game, restart a mission...
When going from menu into starting a game via Spring.Restart , one can notice for a second how spring closes and then restarts. Bit strange, but not a big problem.
(Idea of Spring.Reload is to make that look smoother?)

I think all that is needed exists and it is only small quirks holding back in-mod singleplayer.
Two problems that I recall:
A) After initially having worked ok, Spring.Restart () had some problems.
http://springrts.com/mantis/view.php?id=4262 , http://springrts.com/mantis/view.php?id=4161 , http://springrts.com/mantis/view.php?id=4329
Latest mantis is status:feedback, so maybe should test again.

B) Once you get into the in-mod menu, everything is awesome. But how do you get there in the first place?
Needs a button in the lobby "Launch Single Player", which starts spring/the mod in with some "special argument" that tells the mod to show its SP screen.
This is what this thread was about: http://springrts.com/phpbb/viewtopic.php?f=64&t=30376
Silentwings wrote:with the ability to download its own content
[...]Integration of pr-downloader and a lua API for it.
Yes, needs a way to make sure that the player has all nessecary files .(for ex maps or mission files)

Beside "Lua-pr-downloader" there might be other ways:
a) Instead of spring.exe displaying its "archive XYZ not found"-message it starts pr-downloader, downloads the archive, then continues starting.
->Not sure if such functionality belongs into engine?

b) Lobbies already do download dependency files defined in modinfo.lua.
Idea: put all the nessecary files in there.
->For example could be made so that if the lobby downloads a game, it also downloads a mappack or a mission pack.
->I never actually tested that, because cumbersome to test.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Singleplayer

Post by zwzsg »

(1) : What need is Spring.Restart to be reliable. It doesn't really matter to me if it starts a new instance or wipe clean the state of the current instance. However it does matter that it work on all O.S., no matter where Spring is installed, and not break every couple engine version.

(2) : jK is working on it.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Singleplayer

Post by jK »

@1: c&p what gajop said
@2: it's named LuaIntro (and not LuaLoadscreen) for a reason
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Singleplayer

Post by Silentwings »

(1) @gajop: Yes, I am thinking of exactly Spring.Restart but in the same window/fullscreen. Bluntly, I think quit/restart with desktop visible everytime you restart a mission looks super ugly. I am not worried about relying on using the same Spring version for reload; it would be madness for a singleplayer game to demand one Spring version for its menu and another for its missions.

(2) @zwzsg, jK; If jK is working on it, I've not heard of it but of course I don't want to duplicate work, so this would be useful to know.

(3) Yes, I know abma has been thinking about doing this (in fact most of the plan above came out of discussion with abma).
In-mod singleplayer is imo already possible and has been done seperately by zwszg and by me.
And also by me - for BAR, although not released. Basically this is a list of the things I would want to fix/change before I'd feel happy to think of my missions as a "proper" singleplayer game. Without (1) it looks a bit cobbled together. Without (2) afaics the only way to get an ingame menu is with hacky stuff (did I miss something here?) and without (3) the whole thing has to come in one massive pre-packaged download (although I take knorkes point about modinfo dependencies - but its still a huge single download).
Last edited by Silentwings on 26 Sep 2014, 17:52, edited 4 times in total.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Singleplayer

Post by smoth »

Silentwings wrote:(1) @gajop: Yes, I am thinking of exactly Spring.Restart but in the same window. Bluntly, I think quit/restart with desktop visible everytime you restart a mission looks super ugly. I am not worried about relying on using the same Spring version for reload; it would be madness for a singleplayer game to demand one Spring version for its menu and another for its missions.
^ 100% in agreement!
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Singleplayer

Post by knorke »

With Spring.Restart the delay between closing the old spring instance and the new one starting is less than a second.
A longer delay might be confusing and cause thoughts of "Has it crashed?"
But like this it is "only a bit ugly" and if everything else works then it is not an essential problem to me.
Silentwings wrote:Without (2) afaics the only way to get an ingame menu is with hacky stuff (did I miss something here?)
Not sure what you consider hacky or why new Lua state is needed, so short description how my ingame menu works. There is a widget which that does:

Code: Select all

function widget:DrawScreen()
	if (menu==true) then 
		black()
		draw_buttons(gfx_buttons)
		drawmenu()
	end
The result is something like this: http://abload.de/img/st_singleplayermenuikar.png

Without black()-ing of the screen, one notice that the previous game is still running (paused) in the background: http://abload.de/img/screen00648r0ywb.png
Is it that what you consider hack?
I think it is okay because the player never notices what is happening.
Instead of just black one could of course have something nicer, like a background picture or some animation etc.
Also if a player has entered the menu he can chose to not start a new game and instead continue his current game by leaving the menu.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Singleplayer

Post by Silentwings »

Is it that what you consider hack? I think it is okay because the player never notices what is happening.
Yes (although I admit it's pretty strict to call it a hack) and I had also thought of doing exactly that. A new lua state as in (2) would not need a map loaded and then hidden, and would also be a natural place to build a lualobby in.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Singleplayer

Post by knorke »

Ok, but why is it bad?
There is imo only two disadvantages:
1) This way it is not possible to use the game graphics to create a dynamic 3D background, like for example C&C Generals has - https://www.youtube.com/watch?v=Q-LCdNQNMVA
But there is so many other ways to create decent looking menus or backgrounds, it acceptable imo.
2) On first time going into the SP menu (via the mentioned "Lauch Singleplayer" that lobbies would need to implent) spring is loading a map that is then never seen. Makes the loading take a little bit longer...but nothing problematic?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Singleplayer

Post by Silentwings »

Ok, but why is it bad?
It's not that bad, and of course it works (with slightly increased load time), but hiding the map behind a black wall after going all though that map load, pathing, associated shaders etc, is a hack.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Singleplayer

Post by zwzsg »

knorke wrote:possible to use the game graphics to create a dynamic 3D background, like for example C&C Generals has
Or like I've done in Spring five years ago:

Image

Image
Post Reply

Return to “Engine”