Giving more than one order possible ?

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Giving more than one order possible ?

#1 Post by vincele »

I would like to know if it's possible to give multiple successive orders to objects. For example :

Code: Select all

fleetA->moveTo(somwhere);
ShipPartOfFleetA->ColonizePlanet(somewherePlanetP);
With colonization happening only after fleet arrived to destination...
If such thing is possible, where can I find a code example ?

Thanks
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Giving more than one order possible ?

#2 Post by Dilvish »

possible to code, yes, but not really as a combination of multiple current Orders, I don't think. It would be a significant change from current handling, and I don't think there is anything close enough to count as an example. But to see how colonization is currently handled you can look at ColonizeOrder::ExecuteImpl() in util/Order.cpp
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Giving more than one order possible ?

#3 Post by vincele »

Background : I want to do something like having a context/popup menu entry in objectWnd's planets that do : "1 choose a suitable colony ship (find the nearest), 2 send it to the system this planet is in, 3 colonize it"

1 & 2 working OK
I want to do step 3...

Looking at Order.*, I'm wondering if :

Code: Select all

class FO_COMMON_API Order {
private:
    Order* m_next_order; // a pointer to the next order to execute if *this is successful
};
would enable what I want ?

Something wrong with this idea ?
I've not looked at the server or marshalling sides of things at all, BTW...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Giving more than one order possible ?

#4 Post by Dilvish »

vincele wrote:would enable what I want ? Something wrong with this idea ?
I've not looked at the server or marshalling sides of things at all, BTW...
I don't see anything inherently wrong with the idea. "would enable" is of course much too strong of a description, "could be part of enabling" seems more like it.

In addition to the necessary coding for specifying a 'next order', there's the issue of how to support it -- right now Orders are (I think universally) executed 'immediately' (immediately on the client side pretty much just for display purposes, and then immediately upon turn end on the server side which is where it really counts). It's my recollection that the server goes through all the Orders, executes them if possible, and discards them. So if you want the server managing this handling for Orders to carry-over to the next turn would have to be added, and would probably be even more messy than regular Orders to provide 'undo' support for.

It is seeming to me that the simplest approach would be to handle such a thing purely on the client side, with the client keeping track of when it is time to submit the next order to the server, and not necessarily adding any attributes to the Order class at all. That would probably come with the caveat that the latter portion of multi-part Orders would be lost upon save/load (unless you add some new carry_over_order_list attribute to the Empire class).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: Giving more than one order possible ?

#5 Post by Mitten.O »

I think this would be really useful. In the later game it is annoying when you are churning out colony ships and have to first remember to move them somewhere and then remember to make them colonize there. The same to a lesser extent with moving fleets to the front lines. Ideally you could say what a ship should do already when you start buildind it.
That would probably come with the caveat that the latter portion of multi-part Orders would be lost upon save/load (unless you add some new carry_over_order_list attribute to the Empire class).
There is actually a thing called SaveGameUIData inside PlayerSaveGameData. That might be a good place to store them, too.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Giving more than one order possible ?

#6 Post by MatGB »

Mitten.O wrote: Ideally you could say what a ship should do already when you start buildind it.
I don't have a problem with warships needing orders on launch, as I have zero clue what they'll be needed for when I queue them up in the mid to late game, it'll depend entirely on how well various fights are going and whether an AI is attacking from an unexpected quarter.

But I would really love it if you could mark a colony ship in some way when you queue it so that at the very least it tells you where it's going and at best gets itself there, the number of times I've loaded a game up after a few days, played a couple turns, had a colony ship complete and go "hmm, where was that for" and then go through the entire objects menu and not have a clue why I'd queued it is not an insignificant number (I don't colonise much, doesn't mean I don't do it at all, but when I do it's for a reason. 11 turns later I barely remember that reason even if I've not slept since).

Even if it was very simple like the ship or fleet being auto assigned a name based on the potential colony world you right clicked on for a suitability search, having to order it there manually is still better than having zero clue what it was intended for.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: Giving more than one order possible ?

#7 Post by vincele »

Dilvish wrote:So if you want the server managing this handling for Orders to carry-over to the next turn would have to be added, and would probably be even more messy than regular Orders to provide 'undo' support for.
Is the undo support useful for the server-side ? I would imagine it is only for the client...
Dilvish wrote:It is seeming to me that the simplest approach would be to handle such a thing purely on the client side, with the client keeping track of when it is time to submit the next order to the server, and not necessarily adding any attributes to the Order class at all. That would probably come with the caveat that the latter portion of multi-part Orders would be lost upon save/load (unless you add some new carry_over_order_list attribute to the Empire class).
OK the client-side seems sensible choice. The storing into savegame is not my priority though, I'll have to modify my ship selection code to handle multiple species first, then hook the action in the sidepanel's context menu too before venturing into order sequencing and savegame handling.

Currently the ship arrival sitrep acts as the next action sequencing trigger, for manual intervention...

Thanks for the infos and ideas
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Giving more than one order possible ?

#8 Post by Geoff the Medio »

Client-side implementation of something of this sort would probably work similarly to the existing automatic explore command for fleets in the right-click menu. The server knows nothing about how this works, and it's all done by the client giving orders to a set of fleets that it remembers the player has marked as exploring.

User avatar
Vezzra
Release Manager, Design
Posts: 6100
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Giving more than one order possible ?

#9 Post by Vezzra »

Before anyone puts too much effort into colony ship management, I want to point out that we had already a rather lengthy discussion on the topic of streamlining colonization earlier this year. IIRC we didn't reach any decision, but there are ideas in that thread worth pursuing IMO. So, before going to great lengths to implement some sophisticated colony ship management, I think we'd better decide what we want to do about the whole colonization mechanics. Personally I strongly in favor of revising this mechanic, as it's awfully micromanagy ATM.

I had already intended to bring that topic up again for 0.4.5, so I thought I mention that here.

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: Giving more than one order possible ?

#10 Post by em3 »

On a side note, Endless Space, which otherwise is not a highly remarkable game, has a button indicating the number of idle fleets and clicking it cycles selection among them.

This requires, of course, existence of perpetual orders, like "patrol", "blockade" or something like that.

The downside is that you have to explicitly park your fleets in the systems they reside. On the other hand this helps prevent fleets being lost while they should be somewhere doing something.
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Giving more than one order possible ?

#11 Post by Geoff the Medio »

FreeOrion has hotkey commands for cycling through fleets and idle fleets. I think "idle" means not moving in this context.

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: Giving more than one order possible ?

#12 Post by em3 »

Geoff the Medio wrote:I think "idle" means not moving in this context.
... and that's the issue here. If you could mark a fleet as "it is not moving and I like it this way", then this functionality would actually become useful.

I believe that number of truly idle fleets would be worthy of a top bar indicator just as well as wasted production or research...
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Giving more than one order possible ?

#13 Post by MatGB »

Geoff the Medio wrote:FreeOrion has hotkey commands for cycling through fleets and idle fleets. I think "idle" means not moving in this context.
How had I not noticed that before?

"First"? What's that?

Also, having clicked it to see if I can change it, my game has now frozen.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Giving more than one order possible ?

#14 Post by Geoff the Medio »

MatGB wrote:"First"? What's that?
No idea.
Also, having clicked it to see if I can change it, my game has now frozen.
Define "frozen"?

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Giving more than one order possible ?

#15 Post by MatGB »

See support thread, but clicking any of the options in keyboard shortcuts stops the interface from responding in any way at all. The mouse moves around, but that appears to be just the system/windows mouse.

Re the hotkeys, idle wasn't set at all, manually editing config to the following gets it to work:

Code: Select all

      <map>
        <design>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_d</design>
        <end_turn>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_RETURN</end_turn>
        <menu>GGK_F10</menu>
        <open_chat>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_t</open_chat>
        <production>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_p</production>
        <research>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_r</research>
        <return_to_map>GGK_ESCAPE</return_to_map>
        <sit_rep>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_n</sit_rep>
        <zoom_home_system>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_h</zoom_home_system>
        <zoom_in>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_z</zoom_in>
        <zoom_in_alt>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_KP_PLUS</zoom_in_alt>
        <zoom_next_fleet>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_g</zoom_next_fleet>
        <zoom_next_idle_fleet>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_l</zoom_next_idle_fleet>
        <zoom_next_system>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_GREATER</zoom_next_system>
        <zoom_out>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_x</zoom_out>
        <zoom_out_alt>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_KP_MINUS</zoom_out_alt>
        <zoom_prev_fleet>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_f</zoom_prev_fleet>
        <zoom_prev_idle_fleet>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_k</zoom_prev_idle_fleet>
        <zoom_prev_system>MOD_KEY_LCTRL | MOD_KEY_RCTRL+GGK_LESS</zoom_prev_system>
      </map>
but it does seem to have a bunch of defunct/dead fleets in memory as it's taking me to places that haven't had fleets for ages. So a very useful feature that's not quite working right.

I shall play more with various hotkeys in my next few games.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply