https://sourceforge.net/tracker/index.p ... tid=119507
https://sourceforge.net/tracker/index.p ... tid=119507
I'm thinking when the ship is bought both ends need to know to update, w/o destroying the ship though.. maybe something along this line...ace123 wrote:Buying ships is kinda a hack as it is. It has to do with the assumption
throughout vega Strike that 1 User = 1 Player/cockpit = 1 Unit. Changing
stats of an existing unit is not easy, so a new Unit is created to replace
the old one.
In single player mode, this is relatively transparent--you stay docked to
the base, and your Cockpit's "parent" unit starts pointing to the new
unit.
However, in multiplayer mode, this is made more complicated by the fact
that units have ID numbers (serial in VS terminology). When the units are
swapped, the server could choose to use the same logic as before--assigning
it even the same ID number, but then you'll get into serious trouble since
the Client will be out-of-sync.
The way we overcome this is to kill the ship on the client, and then
respawn, which loads a saved game--hopefully in the new ship. If you're
wondering why we don't just make a specialized message called "SWITCHSHIP"
or something, you're right--that could theoretically be added; however, it
would require duplicating some of the respawn/load logic anyway.
It does save before killing you, so you shouldn't lose anything, but when
you respawn, you *should* be in the newly bought ship.
Server
Code: Select all
if (purchaseship) {
get new id
send new id to client
while (noACK) {
resend new id to client
}
Code: Select all
get new id
updateID(new id)
send ACK