ID:265797
Nov 26 2007, 10:56 am
|
|
In my game, I want to only keep savefiles that logged into the game in a certain frame of time, and delete the files of players that haven't. The problem is that I don't want to have a constant loop going on for a check that only needs to happen once or twice a year, but I also want the game to be purely automatic; that is, no work would need to be done by a human for the game to keep functioning. What is the best way to do this?
|
In response to Dever
|
|
Don't savefiles have a timeout argument in New()?
|
In response to Kaiochao2536
|
|
That determines how long to wait to access the file if it is currently locked.
|
I would create a variable in the world's main savefile that holds when to preform the check again. When you start the world, check to see if the check again variable is smaller than world.realtime. If so, the amount of time has elapsed, and you can preform your savefile check.
For the savefiles themselves, simply give them a version variable. Everytime you preform the savefile check, see if it's version number is the same as the current version number (prolly have to save it with the time to wait variable in the world's main savefile), and remove any that do not match. If the person hasn't logged in since the last check was preformed, thier savefile will have an old version number and can then be deleted. |
In response to Xooxer
|
|
That would get complicated and end up screwing up. If you just save the last login, then you can setup the function to just delete saves last logged in from any time, instead of based on the checks themselves. I don't see the point of having this version thing. All savefiles that existed at the the time of the check would have it, and those after wouldn't. And it would only be telling you when you last did the check. Which could just be saved by itself. Which even then you would still know when the last checks were done if you were using a system where it automatically did it on schedule. So the only thing that needs to be saved is the date on logins.
|
In response to Dever
|
|
Dever wrote:
That would get complicated and end up screwing up. If you just save the last login, then you can setup the function to just delete saves last logged in from any time, instead of based on the checks themselves. I don't see the point of having this version thing. All savefiles that existed at the the time of the check would have it, and those after wouldn't. And it would only be telling you when you last did the check. Which could just be saved by itself. Which even then you would still know when the last checks were done if you were using a system where it automatically did it on schedule. So the only thing that needs to be saved is the date on logins. You basically just re-stated what I said in differnt terms. The version would be the last login. It could be a timestamp or an arbitrary number. It's just a variable to track how old a savefile is. And he wanted to automate this, not just type in some date and delete everything before that date. The world would need to track when to next preform the check, as well as what version to stop deleting at (something I forgot to include). Sooo... The world would start, it checks to see if it should preform a check. If so, check each savefile. If it's version is older than the oldest version the world allows (which would need to be updated everytime the check is preformed), then delete the savefile. It's not complicated at all, nor would it "screw up". It's the same thing you just said, in fact. ~X |
In response to Xooxer
|
|
Its because you said the version is updated when you do check, and all files that weren't logged in before the last check would be deleted. Which seems forces constrictions on when you can do the check. If you just save the date of logins, then you can run checks at anytime without causing any conflicts. But if you still insist on version numbers, then the version number would have to updated everyday. Which really if you're saying I'm just saying you said, I had said it first infact. You said that later on pretty much taking what I said and turning into something less powerful.
And I just don't think deleting savefiles should be something ran automatically. |
In response to Dever
|
|
Uh, yeah. What?
I have an extremely difficult time understanding what you're saying. How would a version put force contstrictions.. wait, what? Ok, I think you mean a version number would restrict the options avaiable, but that's not true. He wants to preform this check only once or twice a year. Why would you need to update a version every day? Update it once after the check is made. Whenever someone logs in with an older version number, set it to the new one. If they don't log in by the time the next check is made, thier version will be out of date. I don't understand how that's functionally any different than storing a timestamp. And yes, you did basically re-state what I said, unless my inablitiy to understand you is mutual. ~X |
In response to Dever
|
|
It's important that the game will be able to maintain itself as much as possible without a human. That's one of the goals I put towards myself when designing it.
|
In response to Xooxer
|
|
I am really skeptic about this method, as that means I'd have to depend on re/booting the world for the check to be performed. I want savefiles to be deleted (almost) exactly when the period has passed.
|
In response to DivineO'peanut
|
|
Set and save the world's next time to check. Save a time stamp on each saved file.
You should only care about save files when there are people to around to care. During mob.Login(), see if it is time to check. If so, delete any save files with earlier time stamps and update/save the world's next time to check. |
In response to DivineO'peanut
|
|
I just assumed rebooting would be an option, as it is in every other game.
If your world will run for a long time, just have a loop that sleeps the 6 months or a year between each test. That would really simplify things. |
In response to Xooxer
|
|
I didn't mean the world would be running for a long time, I just don't want to depend on rebooting the world for the check to be performed in case it runs for a long time. I can, of course, just save the time left to sleep when the server shuts down, but I wonder if sleeping for 6 months just for performing a savefile sweep is efficient?
|
In response to ACWraith
|
|
The reason for deleting the savefiles doesn't relate to the players, but rather saving room for more important savefiles (the active ones), and not overloading the server with savefiles. I don't care for the players when doing this, but rather the server. Even though doing this when someone logs in would probably work fine, it seems kinda hacky.
|
In response to DivineO'peanut
|
|
proc/Save(mob/M) There's what I would attempt; mostly pseudo-code I guess here. :D This should delete any file that hasn't been used in six months. Could world.realtime ever exceed the max length for an integer in Byond? |
In response to EGUY
|
|
Er, you don't understand. Doing the swipe is no problem, the problem is how to check when to do it. I want to call a proc similar to <code>checkfiles()</code> every X amount of time, but seeing as that amount is large, I don't want to perform a loop which will be running all the time only to check for something which happens once in a few months. You should read the rest of the thread to get a better idea of what I mean.
|
Games do need maintence by a human. And if it only needs to be done once or a twice year, then theres no reason a person couldn't activate it. You could just save last logged in var in the save, and have a clean up function. It would go through the files and check if the last login was so long ago, and delete it if its too long.