Mercurial > fife-parpg
comparison engine/core/model/model.cpp @ 33:112fc4af772d
moved grid ownership to model in similar way as with pathers
author | jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 11 Jul 2008 15:42:54 +0000 |
parents | 4a0efb7baf70 |
children | bf7f838e6684 |
comparison
equal
deleted
inserted
replaced
32:75b6394ced14 | 33:112fc4af772d |
---|---|
28 // First block: files included from the FIFE root src directory | 28 // First block: files included from the FIFE root src directory |
29 // Second block: files included from the same folder | 29 // Second block: files included from the same folder |
30 #include "util/structures/purge.h" | 30 #include "util/structures/purge.h" |
31 #include "model/metamodel/abstractpather.h" | 31 #include "model/metamodel/abstractpather.h" |
32 #include "model/metamodel/object.h" | 32 #include "model/metamodel/object.h" |
33 #include "model/metamodel/grids/cellgrid.h" | |
33 #include "structures/map.h" | 34 #include "structures/map.h" |
34 #include "util/base/exception.h" | 35 #include "util/base/exception.h" |
35 | 36 |
36 #include "model.h" | 37 #include "model.h" |
37 | 38 |
45 Model::~Model() { | 46 Model::~Model() { |
46 purge(m_maps); | 47 purge(m_maps); |
47 for(std::list<namespace_t>::iterator nspace = m_namespaces.begin(); nspace != m_namespaces.end(); ++nspace) | 48 for(std::list<namespace_t>::iterator nspace = m_namespaces.begin(); nspace != m_namespaces.end(); ++nspace) |
48 purge(nspace->second); | 49 purge(nspace->second); |
49 purge(m_pathers); | 50 purge(m_pathers); |
51 purge(m_created_grids); | |
52 purge(m_adopted_grids); | |
50 } | 53 } |
51 | 54 |
52 Map* Model::createMap(const std::string& identifier) { | 55 Map* Model::createMap(const std::string& identifier) { |
53 std::list<Map*>::const_iterator it = m_maps.begin(); | 56 std::list<Map*>::const_iterator it = m_maps.begin(); |
54 for(; it != m_maps.end(); ++it) { | 57 for(; it != m_maps.end(); ++it) { |
72 return *it; | 75 return *it; |
73 } | 76 } |
74 } | 77 } |
75 return NULL; | 78 return NULL; |
76 } | 79 } |
80 | |
81 void Model::adoptCellGrid(CellGrid* grid) { | |
82 m_adopted_grids.push_back(grid); | |
83 } | |
84 | |
85 CellGrid* Model::getCellGrid(const std::string& gridtype) { | |
86 std::vector<CellGrid*>::const_iterator it = m_adopted_grids.begin(); | |
87 for(; it != m_adopted_grids.end(); ++it) { | |
88 if ((*it)->getType() == gridtype) { | |
89 CellGrid* newcg = (*it)->clone(); | |
90 m_created_grids.push_back(newcg); | |
91 return newcg; | |
92 } | |
93 } | |
94 return NULL; | |
95 } | |
96 | |
77 | 97 |
78 Map* Model::getMap(const std::string& identifier) const { | 98 Map* Model::getMap(const std::string& identifier) const { |
79 std::list<Map*>::const_iterator it = m_maps.begin(); | 99 std::list<Map*>::const_iterator it = m_maps.begin(); |
80 for(; it != m_maps.end(); ++it) { | 100 for(; it != m_maps.end(); ++it) { |
81 if((*it)->getId() == identifier) | 101 if((*it)->getId() == identifier) |