From e95b3cb3e1a054a9d6bd766d4904e569ac2b2a68 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 3 Jul 2011 15:26:40 +0200 Subject: Added terrain objects. --- terrain_cache.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'terrain_cache.cpp') diff --git a/terrain_cache.cpp b/terrain_cache.cpp index 01cc161..f0f757b 100644 --- a/terrain_cache.cpp +++ b/terrain_cache.cpp @@ -2,20 +2,28 @@ /* TerrainCacheObject */ -TerrainCacheObject::TerrainCacheObject(TerrainCache *cache, int64_t x, int64_t y, unsigned int width, unsigned int height, float *heights) { +TerrainCacheObject::TerrainCacheObject(TerrainCache *cache, int64_t x, int64_t y, unsigned int width, unsigned int height, + float *heights, std::list *objects) { this->cache = cache; this->x = x; this->y = y; this->width = width; this->height = height; + if(heights) this->heights = heights; else this->heights = cache->tl->get_chunk(x, y, width, height); + + if(objects) + this->objects.insert(this->objects.end(), objects->begin(), objects->end()); + else + this->objects = cache->tl->get_objects(x, y); } TerrainCacheObject::~TerrainCacheObject() { cache->tl->save_chunk(heights, x, y, width, height); + cache->tl->save_objects(objects, x, y); delete[] heights; } -- cgit v1.2.3