MCPcopy Create free account
hub / github.com/SimHacker/micropolis / modifyWorld

Method modifyWorld

MicropolisCore/src/MicropolisEngine/src/tool.cpp:113–136  ·  view source on GitHub ↗

* Perform the effects stored in the object to the simulator world. * @param sim Simulator object to modify. * @post Effects have been copied to the simulator world, and the #ToolEffects * object is ready for the next use. */

Source from the content-addressed store, hash-verified

111 * object is ready for the next use.
112 */
113void ToolEffects::modifyWorld()
114{
115 WorldModificationsMap::const_iterator modIter;
116 FrontendMessages::const_iterator msgIter;
117 Micropolis *mpolis = this->sim;
118
119 mpolis->spend(this->cost); // Spend the costs
120 mpolis->updateFunds();
121
122 /* Modify the world. */
123 for (modIter = this->modifications.begin();
124 modIter != this->modifications.end(); modIter++) {
125 Position pos(modIter->first);
126 mpolis->map[pos.posX][pos.posY] = modIter->second;
127 }
128
129 /* And finally send the messages. */
130 for (msgIter = this->frontendMessages.begin();
131 msgIter != this->frontendMessages.end(); msgIter++) {
132 (*msgIter)->sendMessage(mpolis);
133 }
134
135 this->clear();
136}
137
138/**
139 * If there are enough funds, apply the effects.

Callers 3

modifyIfEnoughFundingMethod · 0.95
smoothTreesAtMethod · 0.80
bulldozerToolMethod · 0.80

Calls 4

clearMethod · 0.95
updateFundsMethod · 0.80
spendMethod · 0.65
sendMessageMethod · 0.45

Tested by

no test coverage detected