jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

BUG DS - Bank balance file missing? #41

Closed jpcsupplies closed 8 years ago

jpcsupplies commented 8 years ago

In my dedicated server; I noticed on the last restart that there does not appear to be a bankbalance file in the content folder...

This is on a hosted service so they probably just terminate the server instead of issuing a shutdown command.. assuming i am not going mad.. are we able to write out the bank file on server save events maybe?

midspace commented 8 years ago

There is no event fired when a game is saved. I wish there were. We can't tell when a game is saved otherwise.

I hope they don't kill the server process, that would be wrong. Currently the mod only saves when it is shut down, which requires the game to shut down. I'll have to check how it's running on a Dedicated Server to see what is happening.

jpcsupplies commented 8 years ago

well any other trigger events we can catch or maybe a timer ? or even a manual save command i suppose.. i could probably add that, i just need to call the same module as fires on shutdown i assume; although will that mess the global arrays up i wonder..

my original logic had i got the csv system to work; would have been - open file load data into global array from file close file

change stuff

open file write updated data from global array to file close/save file rinse repeat

having previously done 5 years in a POS vendor support department, all the various things that can go wrong; did go wrong, ie cause pcs, programs and networks to mess up. Which made me adopt that file logic as gospel to minimize lost data on any projects I subsequently made.. plus closing the files between uses meant 1: external programs can make changes immediately apparent in game, and 2: simple on error retry routines on in use files allowed files to be shared that otherwise couldnt on my other projects.. making singleuser programs multiuser. I once made a chat program that simply had clients using an on error routine to mash a common text file; very dirty way to work, but work it did, at near realtime.

midspace commented 8 years ago

The mod will now save at the same time the game saves: https://github.com/jpcsupplies/Economy_mod/commit/2b60ac873fdea32b6c8d409ea0e068606f2d9681

jpcsupplies commented 8 years ago

Keen added a way to catch saves? or you did something tricky ?

midspace commented 8 years ago

If you are online, the Ramblers server needs restarting. It hasn't got the recent updates, so players cannot connect.

midspace commented 8 years ago

Keen have a way to catch saves. It wasn't well known. http://forums.keenswh.com/threads/modding-api-new-requests.7141893/page-7#post-1286835483

I'd rather not have up save changes after every update.

  1. is performance issues. Disk been a higher bottleneck then memory in terms of performance, especially since we don't spec the hardware. We don't know how quickly, or how often changes can be made when you have dozens of players on a server.
  2. The Econ accounts must remain in sync with the game. If a player spends millions of credits on a big new ship, and we save the credit transfer, only for the server to fall over with an error (Weld a laser antenna lately?), when the game reloads, that player will be mighty unhappy. For it to remain in sync, the mod must save its data when the game does, and only then and not at any other time.
jpcsupplies commented 8 years ago

yer i concur with point 2 a lot, a timewarp is better than property being out of sync with assets.. stops people trying to crash server on purpose to exploit back their money lol