Marauroa Database Structure: Difference between revisions

Content deleted Content added
imported>StephenIerodiaconou
No edit summary
Line 1:
= Basic idea behind Database storage =
WeArianne useuses a database to store game state information so that the gamegames becomescan abe truetruly persisten gamepersistent.
 
==Database Tables and Relationships ==
Line 113:
The rest of code is handled by the server itself, and it will create the tables if they don't exist.
 
= Storing objects in the database =
Objects are stored in the database to save their state. This is a heavy (intensive) operation, so we should cachedcache objects and store them only from time to time.
 
This decision is donemade atin RPManager,. thatIt will measurecalculates how often an object has to be stored.
 
You have to write the code to load all the database objects into RPWorld, and this action must be written at gameRPWorld.
 
== How objects are identified? ==
It is important to notice that RPObject.ID is only valid while the object is online. So there is no warrantiesguarantee that any new object won't have that same RPObject.ID once the previous object has been removed.
 
To solve this problem we store in each object a hidden attribute in each object called '''#db_id''' thatwhich gives ana unique id to each object regardless of whether the object is online at a particular point in time or not.
 
When thean object is loaded intoin to the game again, it will havebe assigned a new valid RPObject.ID. However, but thatthe object will still have a valid and unique persisten #db_id. Sowhich can be used when we need to store the object weagain. We can simply update the existing copy atalready on the database.