8 Commits

Author SHA1 Message Date
LeMagnesium
f44128f175 Split the 'clean unknown' demo and tests
- Demo : create a file called demo_clean_unknown with all the code to clean maps from unknown nodes extracted from tests.py
 - Tests : all tests are reactivated and the unknown nodes cleaning code is moved to a demo file
 - Maps : MapVessels can now retrieve a list of all available mapblock positions, and the isEmpty method is now called is_empty to be consistent with naming convention in the class
2016-02-22 17:40:09 +01:00
LeMagnesium
44b64d8780 Make the devel mod respect Minetest's mods naming convention 2016-02-21 16:11:05 +01:00
LeMagnesium
4b8a13c4a4 Moves sources, adds schematics and fixes map code
- The .py files are moved in a folder called 'src'
 - Schematics: Adds schematics. They are compatible with minetest's mts format. A Schematic object can import a mts file, read binary data, export its data into a BytesIO stream, and write its binary data to a file readable by minetest
 - Map: MapInterfaces can now be requested to copy a part of a map delimited by two positions in space into a Schematic object, later usable and savable. Mapblocks' nodes now show their correct position in the world. Mapblocks also store their mapblock position and the integer representing that position in the mapblock grid. MapVessels' methods' naming convention is also unified
 - Test: The picture building function is removed. Messages are added to the test functions, and a new one is implemented, removing all unknown items once provided with a map.sqlite file and another file containing all known nodes' itemstrings (dumped from the minetest server)
 - Tools: A mod was developed to be used in minetest in order to dump the known nodes list. Copy the mod and use /dumpnodes for this
2016-02-18 23:37:55 +01:00
LeMagnesium
b8cbe3b75b Set_node and mapblock implosion fixed, invref in development
* Inventory: Two functions added : is_empty(listname) and get_size(listname), both working in a similar fashion as their minetest API counterpart
 * Map:
  - Implosion fixed. The num_name_id_mappings variable is correctly set, all data are written to the correct byte streams. A function is added to check whether a position given to a function (list get/set_node) is correct and the mapblock is loaded.
  - Data storage type for static object data fixed
  - MapBlocks now have a get_meta(abspos) method. Abspos is the integer representing the position of the querried metadata inside the mapblock
  - MapVessels default to forcefully save a flagged mapblock before unloading it
  - A new method in MapInterface can flag a mapblock as modified. It is used in member methods to deal with the modification cache flags more easily
  - MapInterface has got another new function to check whether a mapblock is loaded or not and try to load it, all depending on a given position
  - MapInterface's save method is fixed
  - MapInterfaces can return a node's metadata using the get_meta(pos) method. It determines what mapblock contains the quierried node, and use the said mapblock's get_meta method to return a NodeMetaRef object
 * Metadata : Strings are stored as and decoded from arrays of integers, easier to convert from bytes without knowing what is float, what is int, and what is string
 * Nodes : The position argument in a Node object is now a key argument. The only mandatory parameter is the itemstring
 * Test : testSetNode now completly working. It doesn't change the node in (0,0,0) anymore. This node is a chest in the test map and is used to test metadata and inventory manipulation in the new invManip function called upon execution of test.py
2016-02-14 21:31:23 +01:00
LeMagnesium
c64b27d1de Code cleanup
- Removal of useless prints
 - writeU* code cleanup
2016-02-09 08:12:09 +00:00
LeMagnesium
20d51a325c Unstable implementation of set_node
- Errors: Add a new error called `IgnoreContentReplacementError` similar to what Minetest would consider as an attempt to replace CONTENT_IGNORE
 - Inventory: The serializing algorithm was fixed to put items in the right order. `InvRef` objects can now directly export data into a serialized string with `to_string`
 - Map:
    * New functions and methods are imported to be used.
    * Add `create_id_mappings` and `implode` along with `set_node`. They respectively update the name/id mapping table, export data into a binary blob to be written in the database, and set_node inside the node table
    * When writing a mapblock, the changes are commited. This will later be removed and a function which is still WIP called `save` will allow `MapInterface` objects to save all unstaged changes
    * Alternatively, setting a `MapVessel`'s `force_save_on_unload` field to `True` will save all unsaved mapblocks that are to be unloaded (for caching reasons)
    * `MapVessel`s also have a new method called `store` to write binary blobs in cache before writing
    * The cache mechanism might be removed later due to the principle of unstaged/uncommited changes inherent to sqlite's python module
    * When `MapInterface`s unload a mapblock, they print a warning message, it being about either saving or discarding the changes made depending on the value of the object's `force_save_on_unload` field
    * A counterpart to `MapInterface.loadMapBlock`, `MapInterface.saveMapBlock`, is created to act as a wrapper around the copy of a mapblock's binary blob data into the `MapVessel`'s cache

 - Metadata: A `NodeMetaRef` object can be initialized without any parameter, giving it default values (`.meta` is `dict`, `.pos` is `Pos` and `.inv` is `InvRef`)
 - Minetest: Every class in nodes.py is imported into the exposed namespace
 - Test: Two new functions were added, to test massive use of `get_node` and simple use of `set_node`. Note: None of them are stable as of now
2016-02-07 15:51:56 +01:00
LeMagnesium
bf22f10fe6 Implement get_node
- Reorganize the MapVessel
- Introduce MapInterfaces with cache size control
- New error : EmptyMapblockError
- MapVessel now reads a mapblock if it is not cached but asked for loading
- MapBlock now organizes all nodes in a single dict
- Fix param0 reading and AssertionError in MapBlock.explode
- Add get_node to MapBlock, used by MapInterface to read a node on the relevant MapBlock after loading it from its vessel
2016-01-25 20:16:30 +01:00
LeMagnesium
4f103d19fd Initial commit 2016-01-25 20:01:29 +01:00