summaryrefslogtreecommitdiff
path: root/game.cpp
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-07-03 15:33:54 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-07-03 15:33:54 +0200
commit5205d99629a9b15865e7a1950b49d8da40a91309 (patch)
tree91b3deb782dac4432d48935b0566805123951d92 /game.cpp
parent75a90df8bf7f38e746e021c23248e1607931132c (diff)
Load and save terrain objects, added ModelManager for object models.HEADmaster
Diffstat (limited to 'game.cpp')
-rw-r--r--game.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/game.cpp b/game.cpp
index 1288b0c..819b35c 100644
--- a/game.cpp
+++ b/game.cpp
@@ -171,9 +171,20 @@ void Game::handle_object() {
std::cerr << "got object for non-existing chunk, discarding" << std::endl;
return;
}
-
pos.y = chunk->find(pos.x, pos.z)->get_height(pos.x, pos.z);
- chunk->objects.push_back(Terrain::Chunk::ObjectPair(scene->tree, pos));
+
+ int64_t x = pos.x;
+ x -= x % Terrain::chunk_size;
+
+ int64_t z = pos.z;
+ z -= z % Terrain::chunk_size;
+
+ TerrainCacheObject::p ob = scene->terrain->tc->get_chunk(x, z, Terrain::chunk_size_total, Terrain::chunk_size_total);
+ ob->objects.push_back(pos);
+
+ models::ModelManager& model_mgr = models::ModelManager::get_instance();
+
+ chunk->objects.push_back(Terrain::Chunk::ObjectPair(model_mgr.get_model("tree"), pos));
}
Game& Game::get_instance() {
@@ -181,3 +192,10 @@ Game& Game::get_instance() {
game = new Game();
return *game;
}
+
+void Game::free() {
+ if(game) {
+ delete game;
+ game = NULL;
+ }
+}