Additional restriction on ship switching

Talk among developers, and propose and discuss general development planning/tackling/etc... feature in this forum.
Post Reply
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Additional restriction on ship switching

Post by javier »

There have been a discussion at the general modding forum about the "feature" that allows a player to fill a ship with cargo, switch to a lighter one and fly to another place to recover the first vessel and sell the cargo aboard.
We seemed to have an agreement the right thing to do is to not allow switch to another vessel if the cargo in the hold doesn't fit in the new one, but after looking the code, we discovered the change cannot be done in python, but in c++ function buyShip, who could be found in source basecomputer.cpp, so I'm opening this request in this forum.

Though this was initially related to the pu mod, I think this is a bug/cheat that must be ironed out in main vs also, and should be simple enough.
bgaskey
Elite Venturer
Elite Venturer
Posts: 718
Joined: Wed Mar 07, 2007 9:05 pm
Location: Rimward of Eden

Post by bgaskey »

I don't really think this is the bug/exploit. I think the problem is that ship transportation is free and carries no risk :? . It should have a cost even in system.

On a tangent, is all of your cargo save together or is each ship's cargo saved separately i.e. can you fill multiple ships (dodo,llama,plowshare) or just fill the largest?

Edit: and the cost of ship transportation should be based on the weight of cargo among other things, lowering the exploitness of the 'exploit'
Xit
Bounty Hunter
Bounty Hunter
Posts: 186
Joined: Mon Aug 06, 2007 2:34 am
Location: Cambs

Post by Xit »

We raised the issue in the Economic Niggles thread that it really takes a lot of planning out of the game that we can transport ships instantly too, there should be some real world delay to getting ships transported so that we can't just have one special ship for each purpose that's always available to us.

Quite how to implement this or what constitutes a realistic delay escapes me though, it seems to be at odds with the current missions.
Save The Economy
http://vegastrike.sourceforge.net/forum ... hp?t=10605

My boxes: Dual Opteron 280s, Geforce 7600, 2GB RAM, but waiting for a new PSU! grrr...
500 MHz Compaq laptop that gives DC electric burns
bgaskey
Elite Venturer
Elite Venturer
Posts: 718
Joined: Wed Mar 07, 2007 9:05 pm
Location: Rimward of Eden

Post by bgaskey »

Nah. A delay would just bore players waiting. just make us pay some cash money $$ :wink:
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

No, it's definitively a bug, and it could have some nasty lateral effects combined with mission scripting. Maybe I opened in the wrong forum, should have been in the Bug Triage.
Xit
Bounty Hunter
Bounty Hunter
Posts: 186
Joined: Mon Aug 06, 2007 2:34 am
Location: Cambs

Post by Xit »

Hehe what about if we request the ship to be brought in system, we take on the mission that we need it for... and then we have to meet the requested ship in system and do a docking manuever with it to take over control? :lol: It might impact on your mission slightly whilst still giving you realistic options?
Save The Economy
http://vegastrike.sourceforge.net/forum ... hp?t=10605

My boxes: Dual Opteron 280s, Geforce 7600, 2GB RAM, but waiting for a new PSU! grrr...
500 MHz Compaq laptop that gives DC electric burns
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

We have discussed that already in http://vegastrike.sourceforge.net/forum ... hp?t=10501
and there was a consensus it overcomplicated things. We're looking for a feasible solution, and the simpler we come with was that. My personal opinion is that it is also the right one.
bgaskey
Elite Venturer
Elite Venturer
Posts: 718
Joined: Wed Mar 07, 2007 9:05 pm
Location: Rimward of Eden

Post by bgaskey »

yeah. we definitely need a simple solution like...oh idk...making people pay a bundle to have enormous ships filled with millions of dollars of foodstuffs teleported to the nearest mining base. I'm sure i've posted this before, but i'm too lazy to find the thread right now. :wink:
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

I think I almost get it. This is the code that puts the cargo in the new unit:

Code: Select all

                      for (int i=playerUnit->numCargo()-1;i>=0;--i) {
                        Cargo c = playerUnit->GetCargo(i);
                        if ((c.mission!=0&&j==0)||(c.mission==0&&j==1&&c.GetCategory().find("upgrades")!=0)) {
                          for (int k=c.quantity;k>0;--k) {
                            c.quantity=k;
                            if (newPart->CanAddCargo(c)) {
                              newPart->AddCargo(c);
                              playerUnit->RemoveCargo(i,c.quantity,true);
                              break;
                            }
                          }
                        }
I modified it to return false in case that newPart->CanAddCargo(c) failed, and it worked. It's only a test, I know you loose the cargo already moved.

Code: Select all

                      for (int i=playerUnit->numCargo()-1;i>=0;--i) {
                        Cargo c = playerUnit->GetCargo(i);
                        if ((c.mission!=0&&j==0)||(c.mission==0&&j==1&&c.GetCategory().find("upgrades")!=0)) {
                          for (int k=c.quantity;k>0;--k) {
                            c.quantity=k;
                            if (newPart->CanAddCargo(c)) {
                              newPart->AddCargo(c);
                              playerUnit->RemoveCargo(i,c.quantity,true);
                              break;
                            }
// Test code
                            else {printf("Test 2\n"); return false;}
                          }
                        }
A slightly more refined version of this should be enough.
bgaskey
Elite Venturer
Elite Venturer
Posts: 718
Joined: Wed Mar 07, 2007 9:05 pm
Location: Rimward of Eden

Post by bgaskey »

Love to help out but i really only know python. I can read c and c++ well enough but I have trouble with syntax. good luck 8)
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

It seems to work. :P
I'm attaching a diff file with the change to be revised by developers.
As you could note, there is a printf call that should be replaced with a better feedback to inform the user about the failure condition.

One more point. The function exits with a false value, like when the player has not enough credits to buy. Python scripts using this function should not assume this is the only reason of failure.
You do not have the required permissions to view the files attached to this post.
Post Reply