antistasi-1.x icon indicating copy to clipboard operation
antistasi-1.x copied to clipboard

Save on disconnect

Open StefArma opened this issue 7 years ago • 6 comments

For some reason, when i quit a singleplayer game some things are saved regardless i persistent saved or not.

  • Garrison amount (i had 30 garrison in a base, AAF attack succesful and right before i loose the base were 10 in the garrison, close game, reopen the base is mine but garrison is 10.
  • Garage vehicle. remove or add a vehicle, close game, reopen (ofc without saving) and it will remember it.
  • (WiP)

I already checked all the handledisconnect, the only one i found is abou calling fn_save_player which is in the \Save folder

StefArma avatar Feb 28 '18 16:02 StefArma

Yes, I know the solution. It's been tough.

It seems when you copy arrays from another variable, whatever variable you change, the other does the same, it's like a quantic entanglement :) Even when the array is stored in different space (profileNameSpace).

To avoid this, you must do it in this way:

newVar = +oldVar; or newVar = []; newVar = newVar + oldVar;

So, anything you change, like staticsToSave, garrisons etc.. has to be done this way in the load account, saveFuncs and saveLoop.

I have to update WotP in github so you will know what I mean :)

Barbolani77 avatar Feb 28 '18 17:02 Barbolani77

Irrelevant to the issue, it doesn't 'seem' that arrays behave as references to objects, but they are indeed made to behave this way. You can read about that on the wiki page dedicated to arrays.

Sparker95 avatar Feb 28 '18 20:02 Sparker95

Just try and if its solved you owe me some vodka, because I checked those scripts and those variables are not there. This, or Skynett :)

Barbolani77 avatar Mar 01 '18 09:03 Barbolani77

https://github.com/A3Antistasi/antistasiofficial/blob/a2ef95b3209112c43160619105a00d5e12284302/AntistasiOfficial.Altis/Save/fn_saveGame.sqf#L56-L57

look at theese lines, might be an issue that there isn't a _ before the garage thingie? Also _hr is in the private [ ], jng isn't

StefArma avatar Apr 20 '18 08:04 StefArma

this is the garrison part

https://github.com/A3Antistasi/antistasiofficial/blob/a2ef95b3209112c43160619105a00d5e12284302/AntistasiOfficial.Altis/Save/fn_saveGame.sqf#L257-L262

but garrison looks into the private [ ]

StefArma avatar Apr 20 '18 08:04 StefArma

vehInGarage is defined as a global variable in file initVar.sqf so i don't think that's the problem (even if handling it in a global variable is probably not best option as you don't know which part of the code access/modify it)

zalexki avatar Apr 20 '18 12:04 zalexki