Cargo Transfers from the client |
Sat, 06 January 2007 12:01 |
|
sirgwain | | Senior Chief Petty Officer | Messages: 86
Registered: March 2004 Location: Tucson | |
|
I have a question about doing cargo transfers from the client. In current Stars!, there are two ways to do it. You can set a waypoint 0 transfer order, or you can open up the fleet transfer dialog and drag cargo from a planet (or other fleets) to your current fleet.
This is easy in old Stars! because the files are encrypted and therefore trusted. You can do all the work on the client side. In a server environment, however, you can't be so trusting. I have to put the fleet transfer dialog cargo transfers into the form of a request you submit to the server. I also have to make it seem like the transfer happens instantly from the client perspective (i.e. you load your colony ship with colonists and it shows up right away).
I would love to have all cargo transfers done as WP0 orders. It makes things simpler from a server perspective and the client just has to use the fleet transfer dialog to set/read the WP0 orders to display correctly. There is a problem with this approach though. You could conceivably transfer cargo from fleet A to fleet B to fleet C to the planet. If you have very minimal resources you have to ensure that these transfers are done in order on the server side, lest you have no resources to transfer when you need them. Right now, my WP0 orders are executed in the order the fleets were created, so it's non-deterministic.
To get around this I've created a CargoTransfer object. As the client performs cargo transfers with the Fleet Transfer dialog, it creates CargoTransfer objects detailing the transfer and adds them to an array. The server processes these transfers in the order they were added.
This is working ok, but it unfortunately means I have to have two methods on the server to do essentially the same operation, transfer cargo. I can't think of a better way to do it, but if anyone has any l33t ideas, please share them.
Report message to a moderator
|
|
|
Re: Cargo Transfers from the client |
Sat, 06 January 2007 15:36 |
|
|
Firstly, keep a separate array for each location.
Second, the way you're doing it by explicitly listing every player-cargo interaction would have to remain intact, but you might consider creating a clientside method to combine multiple transfer orders into a single order to send to the server. Rather like vector arithmetic. You'd have to be careful you don't create a bug tho. A heavy handed but effective security against this would be to have the combinations happen automatically after each transfer action and only combining the new order with the previous order(if valid). If you use location arrays(above) this could reduce orders significantly..depending on the complexity of your transfer order object.
Report message to a moderator
|
|
|
|
|
|
Re: Cargo Transfers from the client |
Thu, 18 January 2007 21:00 |
|
|
LEit wrote on Tue, 09 January 2007 13:35 | It's fairly rare, you need two players both with miners at the same location, or a SS with cargo stealing ships and some one else with cargo ships.
|
Some more common events where races can occur are recovering scrap from a significant battle that occurred in open space or extracting minerals from a mass packet.
Report message to a moderator
|
|
|
|
|
Re: Cargo Transfers from the client |
Tue, 30 January 2007 12:06 |
|
Iconian | | Officer Cadet 2nd Year | Messages: 233
Registered: January 2006 Location: Nevada, USA | |
|
I'm not a programmer, so maybe I'm misunderstanding, but my dad was a programmer for 20 years. He wrote a database a few years back in which he made certain that every person in the system had a particular ID that would never change. Perhaps I've missed grasping something, but I think that you should attach permanent ID's to every fleet. Once you build a ship it gets an ID number, and that ID number will never change. Though ships may come and go, be destroyed and scrapped and built and merged, all will retain their original ID's. I think my dad said that having that single ID made it much easier to keep track of everything in the system.
Hopefully this comment is even pertinent to this discussion . . .
Yeah, bread too.
Don't Let the Stars! Fade AwayReport message to a moderator
|
|
|