TinyMUSH 3.3
TinyMUSH Server
|
flatfile implementation More...
#include "config.h"
#include "constants.h"
#include "typedefs.h"
#include "macros.h"
#include "externs.h"
#include "prototypes.h"
#include <stdbool.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
Functions | |
BOOLEXP * | getboolexp1 (FILE *f) |
Get boolean subexpression from file. More... | |
BOOLEXP * | getboolexp (FILE *f) |
Read a boolean expression from the flat file. More... | |
int | unscramble_attrnum (int attrnum) |
Fix up attribute numbers from foreign muds. More... | |
void | get_list (FILE *f, dbref i, int new_strings) |
Read attribute list from flat file. More... | |
void | putbool_subexp (FILE *f, BOOLEXP *b) |
Write a boolean sub-expression to the flat file. More... | |
void | putboolexp (FILE *f, BOOLEXP *b) |
Write boolean expression to the flat file. More... | |
void | upgrade_flags (FLAG *flags1, FLAG *flags2, FLAG *flags3, dbref thing, int db_format, int db_version) |
Convert foreign flags to MUSH format. More... | |
void | efo_convert (void) |
Fix things up for Exits-From-Objects. More... | |
void | fix_mux_zones (void) |
Convert MUX-style zones to 3.0-style zones. More... | |
void | fix_typed_quotas (void) |
Explode standard quotas into typed quotas. More... | |
dbref | db_read_flatfile (FILE *f, int *db_format, int *db_version, int *db_flags) |
Read a flatfile. More... | |
int | db_read (void) |
Read a DB. More... | |
int | db_write_object_out (FILE *f, dbref i, int db_format __attribute__((unused)), int flags, int *n_atrt) |
Write an object to a DB. More... | |
dbref | db_write_flatfile (FILE *f, int format, int version) |
Write a db to Flat File. More... | |
dbref | db_write (void) |
Write DB to file. More... | |
FILE * | db_module_flatfile (char *filename, bool wrflag) |
Open a file pointer for a module to use when writing a flatfile. More... | |
Variables | |
struct object * | db |
int | g_version |
int | g_format |
int | g_flags |
int | anum_alc_top |
int * | used_attrs_table |
flatfile implementation
FILE * db_module_flatfile | ( | char * | filename, |
bool | wrflag | ||
) |
Open a file pointer for a module to use when writing a flatfile.
filename | Filename |
wrflag | Open for write or read access. |
int db_read | ( | void | ) |
Read a DB.
Fetch the database info
Unroll the data returned
Load the attribute numbers
Unroll the data into flags and name
Houston, we have a problem
Load the object structures
Unroll the data into objnum and object
We read the entire object structure in and copy it into place
Check to see if it's a player
dbref db_read_flatfile | ( | FILE * | f, |
int * | db_format, | ||
int * | db_version, | ||
int * | db_flags | ||
) |
Read a flatfile.
f | File |
db_format | DB Format |
db_version | DB Version |
db_flags | DB Flags |
Misc tag
Record number of players
MUX and MUSH header, 2nd char selects type
The following things are common across 2.x, MUX, and 3.0.
Otherwise extract feature flags
More generic switch.
3.0 VERSION
2.0 VERSION
MUX VERSION
SIZE
USER-NAMED ATTRIBUTE
< skip ':'
If not AF_ODARK, is AF_VISUAL. Strip AF_ODARK.
OPEN USER ATTRIBUTE SLOT
NEXT ATTR TO ALLOC WHEN NO FREELIST
MUX and MUSH entries
CONTENTS and EXITS
EXITS
LINK
NEXT
LOCK
OWNER
PARENT
PENNIES
FLAGS
ATTRIBUTES
check to see if it's a player
EOF marker
dbref db_write | ( | void | ) |
Write DB to file.
Lock the database
Write database information
Roll up various paramaters needed for startup into one record. This should be the only data record of its type
"TM3" is our unique key
Dump user-named attribute info
First, calculate the number of attribute entries we can fit in a block, allowing for some minor DBM key overhead. This should not change unless the size of VNAME_SIZE or LBUF_SIZE changes, in which case you'd have to reload anyway
Step through the attribute number array, writing stuff in 'num' sized chunks
Only write the dirty attribute numbers and clear the flag
No valid attributes in this block, delete it
Something is dirty in this block, write all of the attribute numbers in this block
j is an offset of attribute numbers into the current block
Write the block: Block number is our key
Dump object structures using the same block-based method we use to dump attribute numbers
Step through the object structure array, writing stuff in 'num' sized chunks
We assume you always do a dbck before dump, and Going objects are really destroyed!
Only write the dirty objects and clear the flag
No valid objects in this block, delete it
Something is dirty in this block, write all of the objects in this block
j is an offset of object numbers into the current block
Write the block: Block number is our key
Unlock the database
dbref db_write_flatfile | ( | FILE * | f, |
int | format, | ||
int | version | ||
) |
Write a db to Flat File.
f | File |
format | Format of the flatfile |
version | Version of the flatfile |
Attribute cleaning, if standalone.
Non-user defined attributes are always considered used.
Walk the database. Mark all the attribute numbers in use.
Count up how many attributes we're deleting.
Walk the table we've created of used statuses. When we find free slots, walk backwards to the first used slot at the end of the table. Write the number of the free slot into that used slot. Keep a mapping of what things used to be.
Count up our renumbers.
The new end of the attribute table is the first thing we've renumbered.
Write database information. TinyMUSH 2 wrote '+V', MUX wrote '+X', 3.0 writes '+T'.
Dump user-named attribute info
Dump object and attribute info
int db_write_object_out | ( | FILE * | f, |
dbref | i, | ||
int db_format | __attribute__(unused), | ||
int | flags, | ||
int * | n_atrt | ||
) |
Write an object to a DB.
f | File |
i | DBref of object |
db_format | DB Format |
flags | Flags |
n_atrt | Number of attributes |
write the attribute list
void efo_convert | ( | void | ) |
Fix things up for Exits-From-Objects.
swap Exits and Link
void fix_mux_zones | ( | void | ) |
Convert MUX-style zones to 3.0-style zones.
For all objects in the database where Zone(thing) != NOTHING, set the CONTROL_OK flag on them.
For all objects in the database that are ZMOs (that have other objects zoned to them), copy the EnterLock of those objects to the ControlLock.
void fix_typed_quotas | ( | void | ) |
Explode standard quotas into typed quotas.
If we have a pre-2.2 or MUX database, only the QUOTA and RQUOTA attributes exist. For simplicity's sake, we assume that players will have the same quotas for all types, equal to the current value. This is going to produce incorrect values for RQUOTA; this is easily fixed by a @quota/fix done from within-game.
If we have a early beta 2.2 release, we have quotas which are spread out over ten attributes. We're going to have to grab those, make the new quotas, and then delete the old attributes.
void get_list | ( | FILE * | f, |
dbref | i, | ||
int | new_strings | ||
) |
Read attribute list from flat file.
f | File |
i | DBref |
new_strings | New string |
read # then string
Store the attr
Silently discard
ignore newlines. They're due to v(r).
end of list
We've found a bad spot. I hope things aren't too bad.
BOOLEXP * getboolexp | ( | FILE * | f | ) |
Read a boolean expression from the flat file.
f | File |
parse error, we lose
BOOLEXP * getboolexp1 | ( | FILE * | f | ) |
Get boolean subexpression from file.
f | File |
obsolete NOTHING key, eat it
if last character is : then this is an attribute lock. A last character of / means an eval lock
dbref or attribute
This is either an attribute, eval, or constant lock. Constant locks are of the form <num>, while attribute and eval locks are of the form <anam-or-anum>:<string> or <aname-or-anum>/<string> respectively. The characters <nl>, |, and & terminate the string.
Look the name up as an attribute. If not found, create a new attribute.
if last character is : then this is an attribute lock. A last character of / means an eval lock
bomb out
void putbool_subexp | ( | FILE * | f, |
BOOLEXP * | b | ||
) |
Write a boolean sub-expression to the flat file.
f | File |
b | Boolean sub-expression |
void putboolexp | ( | FILE * | f, |
BOOLEXP * | b | ||
) |
Write boolean expression to the flat file.
f | File |
b | Boolean expression |
int unscramble_attrnum | ( | int | attrnum | ) |
Fix up attribute numbers from foreign muds.
attrnum | attribute numbers |
TinyMUSH 2.2: Deal with different attribute numbers.
void upgrade_flags | ( | FLAG * | flags1, |
FLAG * | flags2, | ||
FLAG * | flags3, | ||
dbref | thing, | ||
int | db_format, | ||
int | db_version | ||
) |
Convert foreign flags to MUSH format.
flags1 | Flag |
flags2 | Flag |
flags3 | Flag |
thing | DBref of thing |
db_format | DB Format |
db_version | DB Version |
TinyMUSH 2.2 to 3.0 flag conversion
This is the unimplemented TICKLER flag.
TinyMUX to 3.0 flag conversion
This used to be an object set NO_COMMAND. We unset the flag.
And if it wasn't NO_COMMAND, then it should be COMMANDS.
This used to be the COMPRESS flag, which didn't do anything.
Players set MONITOR should be set WATCHER as well.
Native TinyMUSH 3.0 database. The only thing we have to do is clear the redirection flag, as nothing is ever redirected at startup.
< this flag is now obsolete
|
extern |
Restart definitions struct database