PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
.cfg file question

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Development Discussion
Display posts from previous:   

Author Message
coltain



Joined: 20 Mar 2007
Posts: 87
Location: Poland

PostPosted: Wed Dec 19, 2007 6:17 pm    Post subject: .cfg file question Reply with quote

When I read a cfg file (using ReadConfigFile(filename)) do I have to unload this .cfg file??? Or is it unloaded automaticly when script ends (or exits by return)???

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Thu Dec 20, 2007 1:08 pm    Post subject: Reply with quote

You don't have to but it's good practice to.

If you do not unload it it should be unloaded for you when it's no longer referenced.

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 345
Location: San Diego, California

PostPosted: Thu Dec 20, 2007 8:58 pm    Post subject: Reply with quote

When you load a config file with ReadConfigFile() it parses it and stores it internally for faster usage later on when you use it in other scripts (it has to be read in the same way though)

If you unload it in a script, it removes the data from the cache and has to be reparsed again.

Author Message
coltain



Joined: 20 Mar 2007
Posts: 87
Location: Poland

PostPosted: Sat Dec 22, 2007 7:28 pm    Post subject: Reply with quote

So what is better???

for eg.

I have readconfigfile(something) in my AI script (for setup). This script is used by about 10000 mobiles. Is it better not to unload this config after setup or it is better to unload it?

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 345
Location: San Diego, California

PostPosted: Sat Dec 22, 2007 7:41 pm    Post subject: Reply with quote

If you only need a config file once then unload it.
If you write to a config file you must unload it to have it updated in memory.

Most the time you don't want to unload a config file because it will have to be removed/reread.

The config file on the first use is parsed and stored in memory.
Every time after that, it is retrieved from memory for speed.
If you call UnloadConfigFile() then the next time ReadConfigFile() is used, the file must be read from disk and parsed back into memory.

Post new topic   Reply to topic    PenUltima Online Forum Index -> Development Discussion All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty