#include "tile.h"
#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+#define CLAMPERR "Tile init error! z-coord must be 0-9, clamping to %d\n"
typedef struct
{
Tile *tile_init(Point3i pos, enum Terrain ter)
{
Tile_t *t = malloc(sizeof(Tile_t));
+ bool clamped = false;
+
t->position = pos;
t->terrain = ter;
+ if(pos.z < 0){
+ clamped = true;
+ t->position.z = 0;
+ } else if (pos.z > 9) {
+ clamped = true;
+ t->position.z = 9;
+ }
+ if(clamped == true){
+ //TODO: err output
+ //fprintf(stderr, CLAMPERR, t->position.z);
+ }
+
return (Tile *) t;
}