]> git.lizzy.rs Git - dragonblocks_alpha.git/blobdiff - src/node.h
Fix NULL pointer bug in meshgen
[dragonblocks_alpha.git] / src / node.h
index 6028500cc621a7cc1a1a791b712c78c96298fe69..2ed4edd6720ce4d342209a85d6f70daddeb77a9e 100644 (file)
@@ -4,22 +4,41 @@
 #include <stdbool.h>
 #include "types.h"
 
+#define NODE_DEFINITION(type) ((type) < NODE_UNLOADED ? &node_definitions[NODE_UNKNOWN] : &node_definitions[(type)]);
+
 typedef enum
 {
-       NODE_INVALID,           // Used for unknown nodes received from server (caused by outdated clients)
+       NODE_UNKNOWN,       // Used for unknown nodes received from server (caused by outdated clients)
        NODE_AIR,
        NODE_GRASS,
        NODE_DIRT,
        NODE_STONE,
-       NODE_UNLOADED,          // Used for nodes in unloaded blocks
+       NODE_SNOW,
+       NODE_OAK_WOOD,
+       NODE_OAK_LEAVES,
+       NODE_PINE_WOOD,
+       NODE_PINE_LEAVES,
+       NODE_PALM_WOOD,
+       NODE_PALM_LEAVES,
+       NODE_SAND,
+       NODE_WATER,
+       NODE_LAVA,
+       NODE_VULCANO_STONE,
+       NODE_UNLOADED,      // Used for nodes in unloaded blocks
 } Node;
 
+struct MapNode;
+
 typedef struct
 {
-       bool visible;
        bool solid;
-} NodeDefintion;
+       size_t data_size;
+       void (*create)(struct MapNode *node);
+       void (*delete)(struct MapNode *node);
+       void (*serialize)(Blob *buffer, void *data);
+       void (*deserialize)(Blob *buffer, void *data);
+} NodeDefinition;
 
-extern NodeDefintion node_definitions[];
+extern NodeDefinition node_definitions[];
 
 #endif