Changes in src/World.cpp [244d26:24a5e0]
- File:
-
- 1 edited
-
src/World.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/World.cpp
r244d26 r24a5e0 47 47 OBSERVE; 48 48 molecule *mol = NULL; 49 mol = new molecule(periode); 50 molecules_deprecated->insert(mol); 49 mol = NewMolecule(); 51 50 assert(!molecules.count(currMoleculeId)); 51 mol->setId(currMoleculeId++); 52 52 // store the molecule by ID 53 molecules[ currMoleculeId++] = mol;53 molecules[mol->getId()] = mol; 54 54 mol->signOn(this); 55 55 return mol; 56 } 57 58 void World::destroyMolecule(molecule* mol){ 59 OBSERVE; 60 destroyMolecule(mol->getId()); 61 } 62 63 void World::destroyMolecule(moleculeId_t id){ 64 OBSERVE; 65 molecule *mol = molecules[id]; 66 assert(mol); 67 DeleteMolecule(mol); 68 molecules.erase(id); 56 69 } 57 70 … … 83 96 } 84 97 85 void World::destroyAtom( int id) {98 void World::destroyAtom(atomId_t id) { 86 99 OBSERVE; 87 100 atom *atom = atoms[id]; … … 131 144 132 145 World::World() : 146 periode(new periodentafel), 147 atoms(), 133 148 currAtomId(0), 149 molecules(), 134 150 currMoleculeId(0), 135 periode(new periodentafel), 136 molecules_deprecated(new MoleculeListClass), 137 atoms(), 138 molecules() 151 molecules_deprecated(new MoleculeListClass(this)) 139 152 { 140 153 molecules_deprecated->signOn(this); … … 145 158 delete molecules_deprecated; 146 159 delete periode; 147 AtomSet::iterator iter; 148 for(iter=atoms.begin();iter!=atoms.end();++iter){ 149 DeleteAtom((*iter).second); 160 MoleculeSet::iterator molIter; 161 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ 162 DeleteMolecule((*molIter).second); 163 } 164 molecules.clear(); 165 AtomSet::iterator atIter; 166 for(atIter=atoms.begin();atIter!=atoms.end();++atIter){ 167 DeleteAtom((*atIter).second); 150 168 } 151 169 atoms.clear(); … … 188 206 // should see that it gets the updated new world 189 207 delete oldWorld; 208 return theWorld; 190 209 } 191 210
Note:
See TracChangeset
for help on using the changeset viewer.
