[crossfire] map and player persistence question

Alex Schultz alex_sch at telus.net
Sat Sep 10 20:28:31 CDT 2005


Blake Delaney wrote:

>
     
     Hello,
     
     >
     
     
     >
     
     I'm trying to figure out how the persistence system
     
     >
     
     works in crossfire, for maps and for players.
     
     >
     
     
     >
     
     Note that anywhere I ask about the location of source
     
     >
     
     code, I'm talking about file and function names.
     
     >
     
     
     >
     
     Maps:
     
     >
     
     I noticed that a map will keep its state for a period
     
     >
     
     of time after I leave it. I also noticed that it will
     
     >
     
     lose all that state if enough time passes. From the
     
     >
     
     source code I noticed some sort of reset system.
     
     >
     
     That's about all I have figured out at the moment.
     
     >
     
     
     >
     
     How is it decided when to load a map into memory? 
     
     >
     
     Where is the source code that makes this decision?
     
     >
     
     
     >
     
     
     Maps are loaded into memory whenever:
1) a player enters a map that is currently not loaded
2) the weather code simulates weather on that map (however in that case 
it's unloaded right away after, unless a player is on it)
3) when a DM uses the "reset" command
The loading process is very fast (the cvs version had some changes a 
week ago or so that improved it further), such that the player probably 
won't notice the load time.

Most of this map related code should be in common/map.c
I don't have time atm to search for specific functions.

>
     
     How is it decided when to reset a map? 
     
     >
     
     
     After a certain timeout of inactivity on the map (I can't remember what 
the default time is, and individual maps can set it separately too), it 
is reset. Players entering the map when it tries to reset, or just 
periodically when the player is in it, will cause this timeout to reset.

>
     
     Is this done by simply
     
     >
     
     deleting the changed map in memory?
     
     >
     
     
     >
     
     
     It's done by unloading the map from memory, and unless it is an 
apartment or guild type map, it is not saved to disk when unloaded.

>
     
     Can a map ever reset with a player on it?
     
     >
     
     
     >
     
     
     No.

>
     
     Are there any maps that don't reset?
     
     >
     
     
     >
     
     
     Sort of, apartments and such do 'reset' in that they are unloaded from 
memory like the rest, however their contents is saved to disk and loaded 
again when the map is entered.

>
     
     Is there any mechanism for state changes to a map that
     
     >
     
     will not be cleared after a short amount of time? If
     
     >
     
     so where is the source code that deals with that?
     
     >
     
     
     >
     
     
     Well, if you're referring to the apartment style maps, you would want to 
look at the saving code in common/maps.c

>
     
     Are changed maps ever saved to disk for any reason in
     
     >
     
     crossfire?  By changed, I mean maps with items dropped
     
     >
     
     on them, or generated monsters, or whatever.
     
     >
     
     
     >
     
     
     Again, apartment/guild maps.

>
     
     Players:
     
     >
     
     When is a character saved to disk?  Is it only when
     
     >
     
     they go to bed?  Where is the source code that deals
     
     >
     
     with this?
     
     >
     
     
     >
     
     
     Players are saved to disk by one of four ways:
1) the save bed
2) periodic automatic save of character
3) the 'save' command
4) emergency save upon server shutdown

It shouldn't be too hard to find the code for that, but I don't have 
time to do that at the second.

>
     
     It seems that there is only one character allowed per
     
     >
     
     player.  Is that accurate?
     
     >
     
     
     >
     
     
     For a given username, yes. However there's nothing preventing you from 
getting multiple usernames, and this is a very common practice, and no 
public server I know of disallows it. There is no need for having an 
'account' style system where a single user has multiple characters 
grouped together because there simply isn't need to keep track of stuff 
like that, unlike commercial MMORPGs.

I don't have time for searching for specific functions at the moment, 
but somebody else can probably help you, and later I might have time to 
gather a list of which functions control the things you're rerfering to.

Alex Schultz

    
    


More information about the crossfire mailing list