--- Jason Gauthier <[EMAIL PROTECTED]> wrote: > Here's why: > > You log in, and load your player. > You give another mortal your equipment. > you create 1024 (or however many) connections to the mud. > This uses all the file handles. > You quit. The mud cannot create another file handle, they're all in use. > Your pfile doesn't save. > Stop the connections, log in.. Viola! your old pfile with all your > equipment. > > Two ways to restrict this. Use the snippet I posted yesterday that keeps > track of the connections or keep the null file around. > > (fpReserve, in most cases)
Another alternative is to use a database to store the mud info. Then you can just keep the database connection open and won't have to worry about running out of file descriptors.. The other advantage to using a well designed database schema is that even in the event of a crash, your game state can be maintained.. (No more duplicating items with a crash bug). To give an example, in a relational database you could create 2 tables.. A character table, which would contain the characters name, race, hp, mana, class, etc. It would also contain a unique field called id. Then you have an object table which contains short description, object type, etc. It could also contain a field called carried_by which stores the character's id who is carrying the object. When you load a character, you sprintf(query, "SELECT * from object_data where carried_by = '%d'", ch->id)... And when you save a character you go through each object and sprintf(query, "UPDATE object_data set carried_by='%d' where id='%d'", ch->id, o->id)... This way if player A and player B log into the mud, and player A gives player B the "Divine sword of spiffyness". Then player B saves and player A doesn't, the mud crashes and they both log in again, ONLY player B will have the sword (the objects data got updated when player B saved, and the id only references player B). This is a little longer than I initially intended, but I hope you get the idea. ~Kender ===== -----BEGIN GEEK CODE BLOCK----- Version 3.1 GCS/L/C/O d-(+) s++:+ a-- C+++$>++++ UBLS++++$ P+++(--)$ L++>+++ E--- W+>++$ N !o K? w(--) !O M- !V PS+ PE(++) Y+ PGP->+ t- 5 X+() R(+) tv+@ b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++ ------END GEEK CODE BLOCK------ __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/

