FreeOrion

Forums for the FreeOrion project
It is currently Thu May 23, 2013 3:23 pm

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Ship and fleet names
PostPosted: Thu Jul 08, 2010 7:47 pm 
Offline
Space Floater

Joined: Tue Jul 06, 2010 9:03 pm
Posts: 18
Every individual ship has a nice name, but all new fleets (just built or split from a larger fleet) have generic names like "New fleet XXXX" which is not so nice. My suggestion is to give the name of a ship to a new fleet if it consists of only that single ship. I think I'm able to implement that by myself if somebody tells me right direction in the source tree to dig in.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 7:55 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
You might want to look at this very old but still relevant feature request: http://sourceforge.net/tracker/?func=de ... tid=544945

I don't think giving the fleet and ship the same name is very useful... a more functional name for the fleet seems better. Naming something implies it has some significance, but fleets in FreeOrion are rather transient; they can be created or destroyed by moving around ships, and have no substantial meaning except from the ships they contain.

The function you'd probably want to be modifying is Fleet::GenerateFleetName in Fleet.cpp.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 8:32 pm 
Offline
Space Floater

Joined: Tue Jul 06, 2010 9:03 pm
Posts: 18
I mostly agree to that feature request, it sounds to me a right thing to do at least as an initial approach. None the less, I would be happy to see a fleet taking the name of a "master" ship in the fleet to make itself a nicer name than just a prefix and a number.

Speaking about details of implementation, GenerateFleetName() is a static function, and that holds it back from using dynamic data like ship list etc. I afraid it might have gone too far to make it now a member function of maybe even a virtual one. If it is not true, I would make it into something else before it's too late.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 8:59 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
Mirai wrote:
Speaking about details of implementation, GenerateFleetName() is a static function, and that holds it back from using dynamic data like ship list etc. I afraid it might have gone too far to make it now a member function of maybe even a virtual one. If it is not true, I would make it into something else before it's too late.

The parameters to GenerateFleetName includes a list of ship ids in the fleet to be named. There is no need to make GenerateFleetName non-static, it is best left static, as one can then generate names for hypothetical fleets composed of any set of ship ids, rather than only generating names for an existing fleet and its current set of ship ids.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 9:37 pm 
Offline
Space Floater

Joined: Tue Jul 06, 2010 9:03 pm
Posts: 18
Geoff the Medio wrote:
There is no need to make GenerateFleetName non-static, it is best left static, as one can then generate names for hypothetical fleets composed of any set of ship ids, rather than only generating names for an existing fleet and its current set of ship ids.
But now it can only generate names for hypothetical fleets, not for existing fleets. I mean it cannot use any ship data but their ids to make a good name for a fleet. Static functions are kind of double-edged weapon: they allow use without instantiation but at the same time they are disabled to access non-static members themselves. A frustrating property of them :? Maybe it is better to put a usual function into namespace with the name of a class (for example) so it could work both with static and non-static members than use a static function... I don't know.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 9:59 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
Mirai wrote:
But now it can only generate names for hypothetical fleets, not for existing fleets. I mean it cannot use any ship data but their ids to make a good name for a fleet.

What other information would you want to use besides the ids of the ships in the fleet?

Note that from the ids of the ships, you can get the Ship objects, and the ships' designs, just as you would have to if GenerateFleetName was a member function.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 10:24 pm 
Offline
Space Floater

Joined: Tue Jul 06, 2010 9:03 pm
Posts: 18
Geoff the Medio wrote:
Note that from the ids of the ships, you can get the Ship objects, and the ships' designs, just as you would have to if GenerateFleetName was a member function.
Using FindObjects()? It's virtual and can't be called from a static one. What function should I use to get ship objects inside static GenerateFleetName()? Maybe I just looked over the function I need.

Geoff the Medio wrote:
What other information would you want to use besides the ids of the ships in the fleet?
In order to implement the idea from that request, it is necessary to know ship types (hull types and ship parts), and in order to implement my idea, it is necessary to know number of ships and ship names.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 10:33 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
Mirai wrote:
What function should I use to get ship objects inside static GenerateFleetName()?

Code:
ObjectMap& objects = GetMainObjectMap();

int num_ships = ship_ids.size();

for (std::vector<int>::const_iterator it = ship_ids.begin(); it != ship_ids.end(); ++it) {
    int ship_id = *it;
    const Ship* ship = objects.Object<Ship>(ship_id);
    if (!ship) {
        Logger().errorStream() << "huh? no ship?!";
        continue;
    }
    const ShipDesign* design = ship->Design();
    if (!design) {
        // etc.
    }
    // see ShipDesign for parts and hull
}


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 10:57 pm 
Offline
Space Floater

Joined: Tue Jul 06, 2010 9:03 pm
Posts: 18
Oh, thanks :)
I see, I see... It's a typical piece of code for such situation... found it in many places across source files.
Now I get it. Everything is virtually cross-linked using global functions in AppInterface.
(I expected to find something like cross-references between objects in relational fashion, like a fleet object
contaiting a collection of pointers to ship objects etc. accessible from everywhere inside the fleet object)


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Thu Jul 08, 2010 11:16 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
Mirai wrote:
Everything is virtually cross-linked using global functions in AppInterface.
(I expected to find something like cross-references between objects in relational fashion)

I'm not sure exactly what you mean by "virtually cross-linked" or "relational fashion", but each object tracks what other objects are relevant to it by ID number. For example, fleets know their ships, and a ship knows its fleet, and both know their system.

If you want to inspect those objects, then you look them up in the library of objects in the gamestate (an "ObjectMap" in this case).

The main ObjectMap also lets you iterate through the objects, or find objects or IDs of objects or get objects that match predicates, including what type of object (Building, Ship, Planet, etc.) or a few others.

A few UniverseObject subclasses also have helper functions to return a vector of pointers to objects they contain, but this is somewhat nonstandard.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Fri Jul 09, 2010 8:11 am 
Offline
Graphics Lead Emeritus
User avatar

Joined: Mon Mar 08, 2004 6:17 pm
Posts: 1933
Location: 52°16'N 10°31'E
I agree that fleets should be named other than New Fleet XXX. These are hard to remember and force the player to rename them by hand, if he is bothered by it.

Quote:
- Colonization Fleet
- Patrol Fleet
- War fleet
- Reconaissance Fleet
- Invasion Fleet


This is nice, but should be extended by an actual name, like "Colonization Fleet Achilles". You can take the string from the ship name list.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Fri Jul 09, 2010 7:02 pm 
Offline
Space Krill

Joined: Mon Jul 05, 2010 6:49 pm
Posts: 4
Noob putting in my 2-cents.

Since real naval fleets tend to use generic fleet names like "Task Group 5" I have no problem with the genreal concept. My only niggle would be removing the word "New" & make it just "Fleet xxx"


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Fri Jul 09, 2010 8:37 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
It might be useful to have an option to set what naming scheme is used for new fleets: always "Fleet XXX" or automatically named something descriptive based on the dropped-in ships.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Fri Jul 09, 2010 11:31 pm 
Offline
Space Floater

Joined: Tue Jul 06, 2010 9:03 pm
Posts: 18
pd wrote:
This is nice, but should be extended by an actual name, like "Colonization Fleet Achilles". You can take the string from the ship name list.
Good idea! I like that. Btw, this is equal to that old feature request from 2005 plus my suggestion.
The question is how to choose main/master/leader ship in a fleet to make the fleet name like
"fleet name = <fleet traits based name> + <leader ship name>".
Manually renamed ships/fleets should not take automatically generated name later.


Top
 Profile  
 
 Post subject: Re: Ship and fleet names
PostPosted: Sat Jul 10, 2010 12:05 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7891
Location: Vancouver, BC
Mirai wrote:
...how to choose main/master/leader ship...

You can just randomly pick a ship in the fleet, or or pick a ship that is sterotypical of the purpose you've assigned to the fleet. For example, in a fleet with 6 battleships and one colony ship, you'd probably call it a battle fleet and pick one of the battleships. It's not really important to worry about this, though.

Edit: Or, just generate a new name for the fleet that doesn't have anything to do with the names of any of the ships in the fleet. Just pick a name from the list of ships names for new ships, and assign it to the fleet. /Edit

Quote:
Manually renamed ships/fleets should not take automatically generated name later.

You only really need to automatically name ships when creating a new fleet. To do that just use the set of ship IDs from which the fleet is being created, and don't attempt to rename the fleet later if the ships it contains change.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group