; (N>c@s&dZdkZdkZdkZdkZdkZdkZdfdYZdZdZ dZ dfdYZ d d Z d fd YZ d ZdZddfddfddfddfddfddffZdZdZdZdZdZdfdYZeZdS(s8Routines to manage and store data from a local database.NsdictDBcBsbtZdZdZdZdZdZdZddZdZ d Z d Z RS( sDStore information for server databases. This class mimics a standard dictionary type in many ways. (It defines the getitem, get, keys, values, and items methods.) However, it is specifically tailored for the server databases. (IE. data from a dump/pdump/sdump/etc. - the sector and unit databases.) This tailoring is done in two ways. First, there is a seamless tracking of secondary indexes. Any series of keys may be used to designate any number of secondary index at the creation time of this class. When an update is made, not only is the item inserted into the primary database, but a reference is updated in the secondary databases. (EG. The plane/ship/land units use a secondary database that is indexed by x and y.) Second, there is an automatic detection of updated items. Any time an update is made to the database, an entry is filed in a special 'update' database. This is used by the Tk graphics routines to ensure that only updated information is redrawn. Since Tk redraws tend to be very time consuming, partial redraws become extremely important. Note: Don't manually update the dictionaries with inserts, modifications, or deletes. All changes should be done through the updates() method. (To delete a value, update its value to None.) cCs|i}tt|ddd}tgt|i}d}xo|ii D]^}t |i |}x$|D]}||tj oPqsqsW||d3|||<|d}qTWhd|i<d|<d|<d|i<d|ii|ihd|<dg<dg<dd<d|<dS(Nsprimary_keytypesprimary_headerssprimary_valuess timestampissecondary_keys(sselfs __setstate__skeysseckeys(sselfskeysseckeys((s=/mnt/gmirror/ports/games/ptkei/work/ptkei-1.18.1/src/empDb.pys__init__scCs|i|SdS(N(sselfsprimarysk(sselfsk((s=/mnt/gmirror/ports/games/ptkei/work/ptkei-1.18.1/src/empDb.pys __getitem__scCsh}x^|iiD]M}xD|iD]6}|i|o||d||Return a token for the country; resolve any outstanding names.N(sidsselfsplayersfoundResolotionsnamesCN_OWNED(sselfsnamesid((s=/mnt/gmirror/ports/games/ptkei/work/ptkei-1.18.1/src/empDb.pys resolveNameIds cCs!||_|i|ttSdS(s&Note the current player's id and name.N(sidsselfsplayersfoundResolotionsnamesCN_OWNED(sselfsnamesid((s=/mnt/gmirror/ports/games/ptkei/work/ptkei-1.18.1/src/empDb.pys resolvePlayers cCs|ii|o_|i|}xA|D]9\}}t||}|d|jo||d(?P\S\S\S) (?P\S\S\S) +(?P\d+) (?P\d+)s8:(?P\d+):(?P\d+)(?: (?P\d\d\d\d))?sEmpTimecBs tZdZhdd<dd<dd<dd<d d <d d <d d<dd<dd<dd<dd<ddtZdZdZdZdZdZdZdZRS(s*Wrapper class for database IO. This class is used as a wrapper when reading/writing the database to disk. It isn't used when accessing the database - calls to megaDB hit the database directly. This class is used only for disk IO. This class has three public attributes: filename - the name of the file that stores the database. newDatabase - Boolean flag determines if this is a new database. needSave - Boolean flag that determines if the database should be saved upon exiting the client. The attributes newDatabase and needSave are both set externally from this class. They are reset in the empQueue module when a connection is made to an empire server. Note: There is generally only one instance of this class - empDb.DBIO. s"Error saving/loading the database.f32.299999999999997c Cszhd|i<dtddf<dtdfddf<dtdfddf<dtdfddf<d tddd fddf<d td dddf<d hd h<<dh<dh<dh<dhdd<dd<dd<dd<<dhdddf<dd<dd<dd<d d!<d"d#<d$d#<d%d#<d&d#<d'd#<d(d#<d)d#<d*d#<d+d#<d,d#<d-d#<d.d#<d/d0<d1d0<d2d0<d3d0<d4d#<d5d0<d6d#<d7d#<d8d0d0d0d0g<d9d0d0d0d0g<d:d0d0d0d0g<d;d#<d<g<d=g<<d>hd?d@<dAf<dBdC<dDd!<dEdC<dFdC<dGdC<dHdC<dIdC<dJdC<dKdL<dMdL<dNdL<dOdC<<dPh<dQhdRf<dSg<<dThdRf<dSg<<dUt<dVhdWd!<dXd!<dYd@<<dZtl b<