Micropolis
emscripten.cpp
Go to the documentation of this file.
1 /* emscripten.cpp
2  *
3  * Micropolis, Unix Version. This game was released for the Unix platform
4  * in or about 1990 and has been modified for inclusion in the One Laptop
5  * Per Child program. Copyright (C) 1989 - 2007 Electronic Arts Inc. If
6  * you need assistance with this program, you may contact:
7  * http://wiki.laptop.org/go/Micropolis or email micropolis@laptop.org.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or (at
12  * your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details. You should have received a
18  * copy of the GNU General Public License along with this program. If
19  * not, see <http://www.gnu.org/licenses/>.
20  *
21  * ADDITIONAL TERMS per GNU GPL Section 7
22  *
23  * No trademark or publicity rights are granted. This license does NOT
24  * give you any right, title or interest in the trademark SimCity or any
25  * other Electronic Arts trademark. You may not distribute any
26  * modification of this program using the trademark SimCity or claim any
27  * affliation or association with Electronic Arts Inc. or its employees.
28  *
29  * Any propagation or conveyance of this program must include this
30  * copyright notice and these terms.
31  *
32  * If you convey this program (or any modifications of it) and assume
33  * contractual liability for the program to recipients of it, you agree
34  * to indemnify Electronic Arts for any liability that those contractual
35  * assumptions impose on Electronic Arts.
36  *
37  * You may not misrepresent the origins of this program; modified
38  * versions of the program must be marked as such and not identified as
39  * the original program.
40  *
41  * This disclaimer supplements the one included in the General Public
42  * License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS
43  * PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY
44  * OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF
45  * SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS
46  * DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES,
47  * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
48  * FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY
49  * RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING,
50  * USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST
51  * INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL
52  * MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE
53  * UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE
54  * WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE
55  * CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR
56  * ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
57  * JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED
58  * WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A
59  * CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
60  * NOT APPLY TO YOU.
61  */
62 
81 
82 
83 #include <emscripten/bind.h>
84 #include "micropolis.h"
85 
86 
88 
89 
90 using namespace emscripten;
91 
92 
94 // This file uses emscripten's embind to bind C++ classes,
95 // C structures, functions, enums, and contents into JavaScript,
96 // so you can even subclass C++ classes in JavaScript,
97 // for implementing plugins and user interfaces.
98 //
99 // Wrapping the entire Micropolis class from the Micropolis (open-source
100 // version of SimCity) code into Emscripten for JavaScript access is a
101 // large and complex task, mainly due to the size and complexity of the
102 // class. The class encompasses almost every aspect of the simulation,
103 // including map generation, simulation logic, user interface
104 // interactions, and more.
105 //
106 // Strategy for Wrapping
107 //
108 // 1. Core Simulation Logic: Focus on the core simulation aspects, such
109 // as the methods to run the simulation, update game states, and handle
110 // user inputs (like building tools and disaster simulations). This is
111 // crucial for any gameplay functionality.
112 //
113 // 2. Memory and Performance Considerations: JavaScript and WebAssembly
114 // run in a browser context, which can have memory limitations and
115 // performance constraints. Carefully manage memory allocation,
116 // especially when dealing with the game's map and various buffers.
117 //
118 // 3. Direct Memory Access: Provide JavaScript access to critical game
119 // data structures like the map buffer for efficient reading and
120 // writing. This can be done using Emscripten's heap access functions
121 // (HEAP8, HEAP16, HEAP32, etc.).
122 //
123 // 4. User Interface and Rendering: This part might not be necessary to
124 // wrap, as modern web technologies (HTML, CSS, WebGL) can be used for
125 // UI. However, providing some hooks for game state (like score, budget,
126 // etc.) to JavaScript might be helpful.
127 //
128 // 5. Callbacks and Interactivity: Ensure that key game events and
129 // callbacks are exposed to JavaScript, allowing for interactive and
130 // responsive gameplay.
131 //
132 // 6. Optimizations: Where possible, optimize C++ code for WebAssembly,
133 // focusing on critical paths in the simulation loop.
134 //
135 // Decisions and Explanations
136 //
137 // - Excluded Elements:
138 //
139 // - Low-level rendering or platform-specific code, as this can be
140 // handled more efficiently with web technologies.
141 //
142 // - Parts of the code that handle file I/O directly, as file access
143 // in a web context is typically handled differently (e.g., using
144 // browser APIs or server-side support).
145 //
146 // - Any networking or multiplayer code, as web-based
147 // implementations would differ significantly from desktop-based
148 // network code.
149 //
150 // - Included Elements:
151 //
152 // - Core game mechanics, such as map generation, zone simulation
153 // (residential, commercial, industrial), disaster simulation, and
154 // basic utilities.
155 //
156 // - Game state management, including budgeting, scoring, and city
157 // evaluation.
158 //
159 // - Direct memory access to critical structures like the map
160 // buffer, allowing efficient manipulation from JavaScript.
161 //
162 // - Essential callbacks and event handling mechanisms to ensure
163 // interactivity.
164 //
165 // Conclusion
166 //
167 // Given the complexity and size of the Micropolis class, wrapping the
168 // entire class directly is impractical. However, focusing on key areas
169 // essential for gameplay and providing efficient interfaces for
170 // critical data structures can create a functional and interactive city
171 // simulation in a web context. Further optimizations and adjustments
172 // would likely be needed based on testing and specific requirements of
173 // the web implementation.
174 //
175 // Implementation Notes
176 //
177 // The enum_, class_, constructor, function, and property functions
178 // from the emscripten namespace are used to specify how C++
179 // constructs should be exposed to JavaScript. You can use these to
180 // control which parts of your code are accessible and how they should
181 // be used from JavaScript.
182 //
183 // I've made some assumptions here:
184 //
185 // The types MapValue and MapTile are simple types (like integers or
186 // floats). If they are complex types, they would need their own
187 // bindings.
188 //
189 // I'm assuming that the copy constructor and copy assignment
190 // operator for the Position class are correctly implemented. If
191 // they aren't, then the Position object may not behave as expected
192 // in JavaScript.
193 //
194 // Micropolis Binding Design
195 //
196 // The Micropolis interface organizes the Micropolis class header into
197 // categories of functions that are relevant for interaction with the
198 // JavaScript user interface, scripts, or plugins. The aim is to expose
199 // functions that could help in monitoring and controlling game state
200 // effectively.
201 //
202 // - Exposed to JavaScript (Public Interface)
203 // - Simulation Control and Settings
204 // - void simTick()
205 // - void setSpeed(short speed)
206 // - void setGameLevel(GameLevel level)
207 // - void setCityName(const std::string &name)
208 // - void setYear(int year)
209 // - void pause()
210 // - void resume()
211 // - void setEnableDisasters(bool value)
212 // - void setAutoBudget(bool value)
213 // - void setAutoBulldoze(bool value)
214 // - void setAutoGoto(bool value)
215 // - void setEnableSound(bool value)
216 // - void setDoAnimation(bool value)
217 // - void doNewGame()
218 // - void doBudget()
219 // - void doScoreCard()
220 // - void updateFunds()
221 // - Gameplay Mechanics
222 // - void doTool(EditingTool tool, short tileX, short tileY)
223 // - void generateMap(int seed)
224 // - void clearMap()
225 // - void makeDisaster(DisasterType type)
226 // - void getDemands(float *resDemandResult, float *comDemandResult, float *indDemandResult)
227 // - Random Number Generation
228 // - int simRandom()
229 // - int getRandom(short range)
230 // - int getRandom16()
231 // - int getRandom16Signed()
232 // - short getERandom(short limit)
233 // - void randomlySeedRandom()
234 // - void seedRandom(int seed)
235 // - Game State and Data Access
236 // - int getTile(int x, int y)
237 // - void setTile(int x, int y, int tile)
238 // - void setFunds(Quad dollars)
239 // - Quad getCityPopulation()
240 // - void updateMaps()
241 // - void updateGraphs()
242 // - void updateEvaluation()
243 // - void updateBudget()
244 // - Events and Callbacks
245 // - void sendMessage(short messageNumber, short x = NOWHERE, short y = NOWHERE)
246 // - void makeSound(std::string channel, std::string sound, int x = -1, int y = -1)
247 // - Hidden from JavaScript (Private Interface)
248 // - Internal Simulation Mechanics
249 // - void simFrame()
250 // - void simulate()
251 // - void doSimInit()
252 // - void setValves()
253 // - void clearCensus()
254 // - void collectTax()
255 // - void mapScan(int x1, int x2)
256 // - Utility Functions
257 // - void initMapArrays()
258 // - void destroyMapArrays()
259 // - void initSimMemory()
260 // - void initGraphs()
261 // - Zone Handling
262 // - void doZone(const Position &pos)
263 // - void doResidential(const Position &pos, bool zonePower)
264 // - void doCommercial(const Position &pos, bool zonePower)
265 // - void doIndustrial(const Position &pos, bool zonePower)
266 // - Disaster Simulation
267 // - void doDisasters()
268 // - void scenarioDisaster()
269 // - void fireAnalysis()
270 // - void makeFire()
271 // - void makeFlood()
272 //
273 // Conclusion
274 //
275 // These exposed functions provide a comprehensive interface for
276 // scripting, plugins, and user interactions through JavaScript. The
277 // exposed set of functions includes random number generation,
278 // simulation control mechanisms, UI-triggered actions like budget
279 // updates, along with essential gameplay mechanics. The private section
280 // continues to encapsulate internal simulation details and complex data
281 // management routines integral to the game's core mechanics.
282 
283 
284 
285 EMSCRIPTEN_BINDINGS(MicropolisEngine) {
286 
287  // position.h
288 
289  enum_<Direction2>("Direction2")
290  .value("INVALID", Direction2::DIR2_INVALID)
291  .value("NORTH", Direction2::DIR2_NORTH)
292  .value("NORTH_EAST", Direction2::DIR2_NORTH_EAST)
293  .value("EAST", Direction2::DIR2_EAST)
294  .value("SOUTH_EAST", Direction2::DIR2_SOUTH_EAST)
295  .value("SOUTH", Direction2::DIR2_SOUTH)
296  .value("SOUTH_WEST", Direction2::DIR2_SOUTH_WEST)
297  .value("WEST", Direction2::DIR2_WEST)
298  .value("NORTH_WEST", Direction2::DIR2_NORTH_WEST)
299  ;
300 
301  class_<Position>("Position")
302  .constructor<>()
303  .constructor<int, int>()
304  .function("move", &Position::move)
305  .function("testBounds", &Position::testBounds)
306  .property("posX", &Position::posX)
307  .property("posY", &Position::posY)
308  ;
309 
310  function("increment45", &increment45);
311  function("increment90", &increment90);
312  function("rotate45", &rotate45);
313  function("rotate90", &rotate90);
314  function("rotate180", &rotate180);
315 
316  // tool.h
317 
318  class_<ToolEffects>("ToolEffects")
319  //.constructor<Micropolis*>() // TODO: wrap
320  .function("clear", &ToolEffects::clear)
321  .function("modifyWorld", &ToolEffects::modifyWorld)
322  .function("modifyIfEnoughFunding", &ToolEffects::modifyIfEnoughFunding)
323  .function("getMapValue", select_overload<MapValue(const Position&) const>(&ToolEffects::getMapValue))
324  .function("getMapTile", select_overload<MapTile(const Position&) const>(&ToolEffects::getMapTile))
325  .function("getCost", &ToolEffects::getCost)
326  .function("addCost", &ToolEffects::addCost)
327  .function("setMapValue", select_overload<void(const Position&, MapValue)>(&ToolEffects::setMapValue))
328  //.function("addFrontendMessage", &ToolEffects::addFrontendMessage) // TODO: wrap
329  ;
330 
331  enum_<MapTileBits>("MapTileBits")
332  .value("PWRBIT", PWRBIT)
333  .value("CONDBIT", CONDBIT)
334  .value("BURNBIT", BURNBIT)
335  .value("BULLBIT", BULLBIT)
336  .value("ANIMBIT", ANIMBIT)
337  .value("ZONEBIT", ZONEBIT)
338  .value("ALLBITS", ALLBITS)
339  .value("LOMASK", LOMASK)
340  .value("BLBNBIT", BLBNBIT)
341  .value("BLBNCNBIT", BLBNCNBIT)
342  .value("BNCNBIT", BNCNBIT)
343  ;
344 
345  enum_<EditingTool>("EditingTool")
346  .value("TOOL_RESIDENTIAL", TOOL_RESIDENTIAL)
347  .value("TOOL_COMMERCIAL", TOOL_COMMERCIAL)
348  .value("TOOL_INDUSTRIAL", TOOL_INDUSTRIAL)
349  .value("TOOL_FIRESTATION", TOOL_FIRESTATION)
350  .value("TOOL_POLICESTATION", TOOL_POLICESTATION)
351  .value("TOOL_QUERY", TOOL_QUERY)
352  .value("TOOL_WIRE", TOOL_WIRE)
353  .value("TOOL_BULLDOZER", TOOL_BULLDOZER)
354  .value("TOOL_RAILROAD", TOOL_RAILROAD)
355  .value("TOOL_ROAD", TOOL_ROAD)
356  .value("TOOL_STADIUM", TOOL_STADIUM)
357  .value("TOOL_PARK", TOOL_PARK)
358  .value("TOOL_SEAPORT", TOOL_SEAPORT)
359  .value("TOOL_COALPOWER", TOOL_COALPOWER)
360  .value("TOOL_NUCLEARPOWER", TOOL_NUCLEARPOWER)
361  .value("TOOL_AIRPORT", TOOL_AIRPORT)
362  .value("TOOL_NETWORK", TOOL_NETWORK)
363  .value("TOOL_WATER", TOOL_WATER)
364  .value("TOOL_LAND", TOOL_LAND)
365  .value("TOOL_FOREST", TOOL_FOREST)
366  .value("TOOL_COUNT", TOOL_COUNT)
367  .value("TOOL_FIRST", TOOL_FIRST)
368  .value("TOOL_LAST", TOOL_LAST);
369  ;
370 
371  // map_type.h
372  class_<Map<Byte, 1>>("MapByte1")
373  .constructor<Byte>()
374  .property("MAP_BLOCKSIZE", &Map<Byte, 1>::MAP_BLOCKSIZE)
375  .property("MAP_W", &Map<Byte, 1>::MAP_W)
376  .property("MAP_H", &Map<Byte, 1>::MAP_H)
377  .function("fill", &Map<Byte, 1>::fill)
378  .function("clear", &Map<Byte, 1>::clear)
379  .function("set", &Map<Byte, 1>::set)
380  .function("get", &Map<Byte, 1>::get)
381  .function("onMap", &Map<Byte, 1>::onMap)
382  .function("worldSet", &Map<Byte, 1>::worldSet)
383  .function("worldGet", &Map<Byte, 1>::worldGet)
384  .function("worldOnMap", &Map<Byte, 1>::worldOnMap)
385  //.function("getBase", &Map<Byte, 1>::getBase, allow_raw_pointers()) // TODO: wrap
386  .function("getTotalByteSize", &Map<Byte, 1>::getTotalByteSize)
387  ;
388 
389  class_<Map<Byte, 2>>("MapByte2")
390  .constructor<Byte>()
391  .property("MAP_BLOCKSIZE", &Map<Byte, 2>::MAP_BLOCKSIZE)
392  .property("MAP_W", &Map<Byte, 2>::MAP_W)
393  .property("MAP_H", &Map<Byte, 2>::MAP_H)
394  .function("fill", &Map<Byte, 2>::fill)
395  .function("clear", &Map<Byte, 2>::clear)
396  .function("set", &Map<Byte, 2>::set)
397  .function("get", &Map<Byte, 2>::get)
398  .function("onMap", &Map<Byte, 2>::onMap)
399  .function("worldSet", &Map<Byte, 2>::worldSet)
400  .function("worldGet", &Map<Byte, 2>::worldGet)
401  .function("worldOnMap", &Map<Byte, 2>::worldOnMap)
402  //.function("getBase", &Map<Byte, 2>::getBase, allow_raw_pointers()) // TODO: wrap
403  .function("getTotalByteSize", &Map<Byte, 2>::getTotalByteSize)
404  ;
405 
406  class_<Map<Byte, 4>>("MapByte4")
407  .constructor<Byte>()
408  .property("MAP_BLOCKSIZE", &Map<Byte, 4>::MAP_BLOCKSIZE)
409  .property("MAP_W", &Map<Byte, 4>::MAP_W)
410  .property("MAP_H", &Map<Byte, 4>::MAP_H)
411  .function("fill", &Map<Byte, 4>::fill)
412  .function("clear", &Map<Byte, 4>::clear)
413  .function("set", &Map<Byte, 4>::set)
414  .function("get", &Map<Byte, 4>::get)
415  .function("onMap", &Map<Byte, 4>::onMap)
416  .function("worldSet", &Map<Byte, 4>::worldSet)
417  .function("worldGet", &Map<Byte, 4>::worldGet)
418  .function("worldOnMap", &Map<Byte, 4>::worldOnMap)
419  //.function("getBase", &Map<Byte, 4>::getBase, allow_raw_pointers()) // TODO: wrap
420  .function("getTotalByteSize", &Map<Byte, 4>::getTotalByteSize)
421  ;
422 
423  class_<Map<short, 8>>("MapShort8")
424  .constructor<short>()
425  .property("MAP_BLOCKSIZE", &Map<short, 8>::MAP_BLOCKSIZE)
426  .property("MAP_W", &Map<short, 8>::MAP_W)
427  .property("MAP_H", &Map<short, 8>::MAP_H)
428  .function("fill", &Map<short, 8>::fill)
429  .function("clear", &Map<short, 8>::clear)
430  .function("set", &Map<short, 8>::set)
431  .function("get", &Map<short, 8>::get)
432  .function("onMap", &Map<short, 8>::onMap)
433  .function("worldSet", &Map<short, 8>::worldSet)
434  .function("worldGet", &Map<short, 8>::worldGet)
435  .function("worldOnMap", &Map<short, 8>::worldOnMap)
436  //.function("getBase", &Map<short, 8>::getBase, allow_raw_pointers()) // TODO: wrap
437  .function("getTotalByteSize", &Map<short, 8>::getTotalByteSize)
438  ;
439 
440 /*
441 
442 function createTypedArrayFromMap(mapInstance) {
443  var pointer = mapInstance.getBase();
444  var byteSize = mapInstance.getTotalByteSize();
445  var mapSize = mapInstance.MAP_W * mapInstance.MAP_H;
446  var arrayType;
447 
448  // Determine the correct Typed Array type based on DATA type
449  if (byteSize === mapSize) {
450  arrayType = Uint8Array;
451  } else if (byteSize === mapSize * 2) {
452  arrayType = Uint16Array;
453  } else {
454  console.error("Unsupported data type for Typed Array.");
455  return null;
456  }
457 
458  var typedArray = new arrayType(Module.HEAPU8.buffer, pointer, byteSize / arrayType.BYTES_PER_ELEMENT);
459  return typedArray;
460 }
461 
462 */
463 
464  // text.h
465 
466  enum_<Stri202>("Stri202")
467  .value("STR202_POPULATIONDENSITY_LOW", STR202_POPULATIONDENSITY_LOW) // 0: Low
468  .value("STR202_POPULATIONDENSITY_MEDIUM", STR202_POPULATIONDENSITY_MEDIUM) // 1: Medium
469  .value("STR202_POPULATIONDENSITY_HIGH", STR202_POPULATIONDENSITY_HIGH) // 2: High
470  .value("STR202_POPULATIONDENSITY_VERYHIGH", STR202_POPULATIONDENSITY_VERYHIGH) // 3: Very High
471  .value("STR202_LANDVALUE_SLUM", STR202_LANDVALUE_SLUM) // 4: Slum
472  .value("STR202_LANDVALUE_LOWER_CLASS", STR202_LANDVALUE_LOWER_CLASS) // 5: Lower Class
473  .value("STR202_LANDVALUE_MIDDLE_CLASS", STR202_LANDVALUE_MIDDLE_CLASS) // 6: Middle Class
474  .value("STR202_LANDVALUE_HIGH_CLASS", STR202_LANDVALUE_HIGH_CLASS) // 7: High
475  .value("STR202_CRIME_NONE", STR202_CRIME_NONE) // 8: Safe
476  .value("STR202_CRIME_LIGHT", STR202_CRIME_LIGHT) // 9: Light
477  .value("STR202_CRIME_MODERATE", STR202_CRIME_MODERATE) // 10: Moderate
478  .value("STR202_CRIME_DANGEROUS", STR202_CRIME_DANGEROUS) // 11: Dangerous
479  .value("STR202_POLLUTION_NONE", STR202_POLLUTION_NONE) // 12: None
480  .value("STR202_POLLUTION_MODERATE", STR202_POLLUTION_MODERATE) // 13: Moderate
481  .value("STR202_POLLUTION_HEAVY", STR202_POLLUTION_HEAVY) // 14: Heavy
482  .value("STR202_POLLUTION_VERY_HEAVY", STR202_POLLUTION_VERY_HEAVY) // 15: Very Heavy
483  .value("STR202_GROWRATE_DECLINING", STR202_GROWRATE_DECLINING) // 16: Declining
484  .value("STR202_GROWRATE_STABLE", STR202_GROWRATE_STABLE) // 17: Stable
485  .value("STR202_GROWRATE_SLOWGROWTH", STR202_GROWRATE_SLOWGROWTH) // 18: Slow Growth
486  .value("STR202_GROWRATE_FASTGROWTH", STR202_GROWRATE_FASTGROWTH) // 19: Fast Growth
487  ;
488 
489  enum_<MessageNumber>("MessageNumber")
490  .value("MESSAGE_NEED_MORE_RESIDENTIAL", MESSAGE_NEED_MORE_RESIDENTIAL) // 1: More residential zones needed.
491  .value("MESSAGE_NEED_MORE_COMMERCIAL", MESSAGE_NEED_MORE_COMMERCIAL) // 2: More commercial zones needed.
492  .value("MESSAGE_NEED_MORE_INDUSTRIAL", MESSAGE_NEED_MORE_INDUSTRIAL) // 3: More industrial zones needed.
493  .value("MESSAGE_NEED_MORE_ROADS", MESSAGE_NEED_MORE_ROADS) // 4: More roads required.
494  .value("MESSAGE_NEED_MORE_RAILS", MESSAGE_NEED_MORE_RAILS) // 5: Inadequate rail system.
495  .value("MESSAGE_NEED_ELECTRICITY", MESSAGE_NEED_ELECTRICITY) // 6: Build a Power Plant.
496  .value("MESSAGE_NEED_STADIUM", MESSAGE_NEED_STADIUM) // 7: Residents demand a Stadium.
497  .value("MESSAGE_NEED_SEAPORT", MESSAGE_NEED_SEAPORT) // 8: Industry requires a Sea Port.
498  .value("MESSAGE_NEED_AIRPORT", MESSAGE_NEED_AIRPORT) // 9: Commerce requires an Airport.
499  .value("MESSAGE_HIGH_POLLUTION", MESSAGE_HIGH_POLLUTION) // 10: Pollution very high.
500  .value("MESSAGE_HIGH_CRIME", MESSAGE_HIGH_CRIME) // 11: Crime very high.
501  .value("MESSAGE_TRAFFIC_JAMS", MESSAGE_TRAFFIC_JAMS) // 12: Frequent traffic jams reported.
502  .value("MESSAGE_NEED_FIRE_STATION", MESSAGE_NEED_FIRE_STATION) // 13: Citizens demand a Fire Department.
503  .value("MESSAGE_NEED_POLICE_STATION", MESSAGE_NEED_POLICE_STATION) // 14: Citizens demand a Police Department.
504  .value("MESSAGE_BLACKOUTS_REPORTED", MESSAGE_BLACKOUTS_REPORTED) // 15: Blackouts reported. Check power map.
505  .value("MESSAGE_TAX_TOO_HIGH", MESSAGE_TAX_TOO_HIGH) // 16: Citizens upset. The tax rate is too high.
506  .value("MESSAGE_ROAD_NEEDS_FUNDING", MESSAGE_ROAD_NEEDS_FUNDING) // 17: Roads deteriorating, due to lack of funds.
507  .value("MESSAGE_FIRE_STATION_NEEDS_FUNDING", MESSAGE_FIRE_STATION_NEEDS_FUNDING) // 18: Fire departments need funding.
508  .value("MESSAGE_POLICE_NEEDS_FUNDING", MESSAGE_POLICE_NEEDS_FUNDING) // 19: Police departments need funding.
509  .value("MESSAGE_FIRE_REPORTED", MESSAGE_FIRE_REPORTED) // 20: Fire reported!
510  .value("MESSAGE_MONSTER_SIGHTED", MESSAGE_MONSTER_SIGHTED) // 21: A Monster has been sighted!!
511  .value("MESSAGE_TORNADO_SIGHTED", MESSAGE_TORNADO_SIGHTED) // 22: Tornado reported!!
512  .value("MESSAGE_EARTHQUAKE", MESSAGE_EARTHQUAKE) // 23: Major earthquake reported!!!
513  .value("MESSAGE_PLANE_CRASHED", MESSAGE_PLANE_CRASHED) // 24: A plane has crashed!
514  .value("MESSAGE_SHIP_CRASHED", MESSAGE_SHIP_CRASHED) // 25: Shipwreck reported!
515  .value("MESSAGE_TRAIN_CRASHED", MESSAGE_TRAIN_CRASHED) // 26: A train crashed!
516  .value("MESSAGE_HELICOPTER_CRASHED", MESSAGE_HELICOPTER_CRASHED) // 27: A helicopter crashed!
517  .value("MESSAGE_HIGH_UNEMPLOYMENT", MESSAGE_HIGH_UNEMPLOYMENT) // 28: Unemployment rate is high.
518  .value("MESSAGE_NO_MONEY", MESSAGE_NO_MONEY) // 29: YOUR CITY HAS GONE BROKE!
519  .value("MESSAGE_FIREBOMBING", MESSAGE_FIREBOMBING) // 30: Firebombing reported!
520  .value("MESSAGE_NEED_MORE_PARKS", MESSAGE_NEED_MORE_PARKS) // 31: Need more parks.
521  .value("MESSAGE_EXPLOSION_REPORTED", MESSAGE_EXPLOSION_REPORTED) // 32: Explosion detected!
522  .value("MESSAGE_NOT_ENOUGH_FUNDS", MESSAGE_NOT_ENOUGH_FUNDS) // 33: Insufficient funds to build that.
523  .value("MESSAGE_BULLDOZE_AREA_FIRST", MESSAGE_BULLDOZE_AREA_FIRST) // 34: Area must be bulldozed first.
524  .value("MESSAGE_REACHED_TOWN", MESSAGE_REACHED_TOWN) // 35: Population has reached 2,000.
525  .value("MESSAGE_REACHED_CITY", MESSAGE_REACHED_CITY) // 36: Population has reached 10,000.
526  .value("MESSAGE_REACHED_CAPITAL", MESSAGE_REACHED_CAPITAL) // 37: Population has reached 50,000.
527  .value("MESSAGE_REACHED_METROPOLIS", MESSAGE_REACHED_METROPOLIS) // 38: Population has reached 100,000.
528  .value("MESSAGE_REACHED_MEGALOPOLIS", MESSAGE_REACHED_MEGALOPOLIS) // 39: Population has reached 500,000.
529  .value("MESSAGE_NOT_ENOUGH_POWER", MESSAGE_NOT_ENOUGH_POWER) // 40: Brownouts, build another Power Plant.
530  .value("MESSAGE_HEAVY_TRAFFIC", MESSAGE_HEAVY_TRAFFIC) // 41: Heavy Traffic reported.
531  .value("MESSAGE_FLOODING_REPORTED", MESSAGE_FLOODING_REPORTED) // 42: Flooding reported!!
532  .value("MESSAGE_NUCLEAR_MELTDOWN", MESSAGE_NUCLEAR_MELTDOWN) // 43: A Nuclear Meltdown has occurred!!!
533  .value("MESSAGE_RIOTS_REPORTED", MESSAGE_RIOTS_REPORTED) // 44: They're rioting in the streets!!
534  .value("MESSAGE_STARTED_NEW_CITY", MESSAGE_STARTED_NEW_CITY) // 45: Started a New City.
535  .value("MESSAGE_LOADED_SAVED_CITY", MESSAGE_LOADED_SAVED_CITY) // 46: Restored a Saved City.
536  .value("MESSAGE_SCENARIO_WON", MESSAGE_SCENARIO_WON) // 47: You won the scenario.
537  .value("MESSAGE_SCENARIO_LOST", MESSAGE_SCENARIO_LOST) // 48: You lose the scenario.
538  .value("MESSAGE_ABOUT_MICROPOLIS", MESSAGE_ABOUT_MICROPOLIS) // 49: About Micropolis.
539  .value("MESSAGE_SCENARIO_DULLSVILLE", MESSAGE_SCENARIO_DULLSVILLE) // 50: Dullsville scenario.
540  .value("MESSAGE_SCENARIO_SAN_FRANCISCO", MESSAGE_SCENARIO_SAN_FRANCISCO) // 51: San Francisco scenario.
541  .value("MESSAGE_SCENARIO_HAMBURG", MESSAGE_SCENARIO_HAMBURG) // 52: Hamburg scenario.
542  .value("MESSAGE_SCENARIO_BERN", MESSAGE_SCENARIO_BERN) // 53: Bern scenario.
543  .value("MESSAGE_SCENARIO_TOKYO", MESSAGE_SCENARIO_TOKYO) // 54: Tokyo scenario.
544  .value("MESSAGE_SCENARIO_DETROIT", MESSAGE_SCENARIO_DETROIT) // 55: Detroit scenario.
545  .value("MESSAGE_SCENARIO_BOSTON", MESSAGE_SCENARIO_BOSTON) // 56: Boston scenario.
546  .value("MESSAGE_SCENARIO_RIO_DE_JANEIRO", MESSAGE_SCENARIO_RIO_DE_JANEIRO) // 57: Rio de Janeiro scenario.
547  .value("MESSAGE_LAST", MESSAGE_LAST) // 57: Last valid message
548  ;
549 
550  // frontendmessage.h TODO
551 
552  // The FrontendMessage class is defined as an abstract base class with pure_virtual()
553  // for the sendMessage method.
554  // FrontendMessageDidTool and FrontendMessageMakeSound are bound as subclasses of FrontendMessage.
555  // The allow_subclass method is used to register them as valid subclasses.
556  // Constructors and properties are exposed for FrontendMessageDidTool and
557  // FrontendMessageMakeSound to create instances and access their members in JavaScript.
558 
559 /*
560  class_<FrontendMessage>("FrontendMessage")
561  .smart_ptr<std::shared_ptr<FrontendMessage>>("shared_ptr<FrontendMessage>")
562  .allow_subclass<FrontendMessageDidTool>("FrontendMessageDidTool")
563  .allow_subclass<FrontendMessageMakeSound>("FrontendMessageMakeSound")
564  .function("sendMessage", &FrontendMessage::sendMessage, pure_virtual())
565  ;
566 
567  class_<FrontendMessageDidTool, base<FrontendMessage>>("FrontendMessageDidTool")
568  .constructor<const char*, int, int>()
569  .property("tool", &FrontendMessageDidTool::tool)
570  .property("x", &FrontendMessageDidTool::x)
571  .property("y", &FrontendMessageDidTool::y)
572  ;
573 
574  class_<FrontendMessageMakeSound, base<FrontendMessage>>("FrontendMessageMakeSound")
575  .constructor<const char*, const char*, int, int>()
576  .property("channel", &FrontendMessageMakeSound::channel)
577  .property("sound", &FrontendMessageMakeSound::sound)
578  .property("x", &FrontendMessageMakeSound::x)
579  .property("y", &FrontendMessageMakeSound::y)
580  ;
581 */
582 
583  // micropolis.h
584 
585  constant("WORLD_W", WORLD_W);
586  constant("WORLD_H", WORLD_H);
587  constant("BITS_PER_TILE", BITS_PER_TILE);
588  constant("BYTES_PER_TILE", BYTES_PER_TILE);
589  constant("WORLD_W_2", WORLD_W_2);
590  constant("WORLD_H_2", WORLD_H_2);
591  constant("WORLD_W_4", WORLD_W_4);
592  constant("WORLD_H_4", WORLD_H_4);
593  constant("WORLD_W_8", WORLD_W_8);
594  constant("WORLD_H_8", WORLD_H_8);
595  constant("EDITOR_TILE_SIZE", EDITOR_TILE_SIZE);
596  constant("PASSES_PER_CITYTIME", PASSES_PER_CITYTIME);
597  constant("CITYTIMES_PER_MONTH", CITYTIMES_PER_MONTH);
598  constant("CITYTIMES_PER_YEAR", CITYTIMES_PER_YEAR);
599  constant("HISTORY_LENGTH", HISTORY_LENGTH);
600  constant("MISC_HISTORY_LENGTH", MISC_HISTORY_LENGTH);
601  constant("HISTORY_COUNT", HISTORY_COUNT);
602  constant("POWER_STACK_SIZE", POWER_STACK_SIZE);
603  constant("NOWHERE", NOWHERE);
604  constant("ISLAND_RADIUS", ISLAND_RADIUS);
605  constant("MAX_TRAFFIC_DISTANCE", MAX_TRAFFIC_DISTANCE);
606  constant("MAX_ROAD_EFFECT", MAX_ROAD_EFFECT);
607  constant("MAX_POLICE_STATION_EFFECT", MAX_POLICE_STATION_EFFECT);
608  constant("MAX_FIRE_STATION_EFFECT", MAX_FIRE_STATION_EFFECT);
609  constant("RES_VALVE_RANGE", RES_VALVE_RANGE);
610  constant("COM_VALVE_RANGE", COM_VALVE_RANGE);
611  constant("IND_VALVE_RANGE", IND_VALVE_RANGE);
612 
613  emscripten::enum_<HistoryType>("HistoryType")
614  .value("HISTORY_TYPE_RES", HISTORY_TYPE_RES)
615  .value("HISTORY_TYPE_COM", HISTORY_TYPE_COM)
616  .value("HISTORY_TYPE_IND", HISTORY_TYPE_IND)
617  .value("HISTORY_TYPE_MONEY", HISTORY_TYPE_MONEY)
618  .value("HISTORY_TYPE_CRIME", HISTORY_TYPE_CRIME)
619  .value("HISTORY_TYPE_POLLUTION", HISTORY_TYPE_POLLUTION)
620  .value("HISTORY_TYPE_COUNT", HISTORY_TYPE_COUNT)
621  ;
622 
623  // HistoryScale
624  emscripten::enum_<HistoryScale>("HistoryScale")
625  .value("HISTORY_SCALE_SHORT", HISTORY_SCALE_SHORT)
626  .value("HISTORY_SCALE_LONG", HISTORY_SCALE_LONG)
627  .value("HISTORY_SCALE_COUNT", HISTORY_SCALE_COUNT)
628  ;
629 
630  // MapType
631  emscripten::enum_<MapType>("MapType")
632  .value("MAP_TYPE_ALL", MAP_TYPE_ALL)
633  .value("MAP_TYPE_RES", MAP_TYPE_RES)
634  .value("MAP_TYPE_COM", MAP_TYPE_COM)
635  .value("MAP_TYPE_IND", MAP_TYPE_IND)
636  .value("MAP_TYPE_POWER", MAP_TYPE_POWER)
637  .value("MAP_TYPE_ROAD", MAP_TYPE_ROAD)
638  .value("MAP_TYPE_POPULATION_DENSITY", MAP_TYPE_POPULATION_DENSITY)
639  .value("MAP_TYPE_RATE_OF_GROWTH", MAP_TYPE_RATE_OF_GROWTH)
640  .value("MAP_TYPE_TRAFFIC_DENSITY", MAP_TYPE_TRAFFIC_DENSITY)
641  .value("MAP_TYPE_POLLUTION", MAP_TYPE_POLLUTION)
642  .value("MAP_TYPE_CRIME", MAP_TYPE_CRIME)
643  .value("MAP_TYPE_LAND_VALUE", MAP_TYPE_LAND_VALUE)
644  .value("MAP_TYPE_FIRE_RADIUS", MAP_TYPE_FIRE_RADIUS)
645  .value("MAP_TYPE_POLICE_RADIUS", MAP_TYPE_POLICE_RADIUS)
646  .value("MAP_TYPE_DYNAMIC", MAP_TYPE_DYNAMIC)
647  .value("MAP_TYPE_COUNT", MAP_TYPE_COUNT)
648  ;
649 
650  // SpriteType
651  emscripten::enum_<SpriteType>("SpriteType")
652  .value("SPRITE_NOTUSED", SPRITE_NOTUSED)
653  .value("SPRITE_TRAIN", SPRITE_TRAIN)
654  .value("SPRITE_HELICOPTER", SPRITE_HELICOPTER)
655  .value("SPRITE_AIRPLANE", SPRITE_AIRPLANE)
656  .value("SPRITE_SHIP", SPRITE_SHIP)
657  .value("SPRITE_MONSTER", SPRITE_MONSTER)
658  .value("SPRITE_TORNADO", SPRITE_TORNADO)
659  .value("SPRITE_EXPLOSION", SPRITE_EXPLOSION)
660  .value("SPRITE_BUS", SPRITE_BUS)
661  .value("SPRITE_COUNT", SPRITE_COUNT)
662  ;
663 
664  // ConnectTileCommand
665  emscripten::enum_<ConnectTileCommand>("ConnectTileCommand")
666  .value("CONNECT_TILE_FIX", CONNECT_TILE_FIX)
667  .value("CONNECT_TILE_BULLDOZE", CONNECT_TILE_BULLDOZE)
668  .value("CONNECT_TILE_ROAD", CONNECT_TILE_ROAD)
669  .value("CONNECT_TILE_RAILROAD", CONNECT_TILE_RAILROAD)
670  .value("CONNECT_TILE_WIRE", CONNECT_TILE_WIRE)
671  ;
672 
673  // ToolResult
674  emscripten::enum_<ToolResult>("ToolResult")
675  .value("TOOLRESULT_NO_MONEY", TOOLRESULT_NO_MONEY)
676  .value("TOOLRESULT_NEED_BULLDOZE", TOOLRESULT_NEED_BULLDOZE)
677  .value("TOOLRESULT_FAILED", TOOLRESULT_FAILED)
678  .value("TOOLRESULT_OK", TOOLRESULT_OK)
679  ;
680 
681  // Scenario
682  emscripten::enum_<Scenario>("Scenario")
683  .value("SC_NONE", SC_NONE)
684  .value("SC_DULLSVILLE", SC_DULLSVILLE)
685  .value("SC_SAN_FRANCISCO", SC_SAN_FRANCISCO)
686  .value("SC_HAMBURG", SC_HAMBURG)
687  .value("SC_BERN", SC_BERN)
688  .value("SC_TOKYO", SC_TOKYO)
689  .value("SC_DETROIT", SC_DETROIT)
690  .value("SC_BOSTON", SC_BOSTON)
691  .value("SC_RIO", SC_RIO)
692  .value("SC_COUNT", SC_COUNT)
693  ;
694 
695  // ZoneType
696  emscripten::enum_<ZoneType>("ZoneType")
697  .value("ZT_COMMERCIAL", ZT_COMMERCIAL)
698  .value("ZT_INDUSTRIAL", ZT_INDUSTRIAL)
699  .value("ZT_RESIDENTIAL", ZT_RESIDENTIAL)
700  .value("ZT_NUM_DESTINATIONS", ZT_NUM_DESTINATIONS)
701  ;
702 
703  // CityVotingProblems
704  emscripten::enum_<CityVotingProblems>("CityVotingProblems")
705  .value("CVP_CRIME", CVP_CRIME)
706  .value("CVP_POLLUTION", CVP_POLLUTION)
707  .value("CVP_HOUSING", CVP_HOUSING)
708  .value("CVP_TAXES", CVP_TAXES)
709  .value("CVP_TRAFFIC", CVP_TRAFFIC)
710  .value("CVP_UNEMPLOYMENT", CVP_UNEMPLOYMENT)
711  .value("CVP_FIRE", CVP_FIRE)
712  .value("CVP_NUMPROBLEMS", CVP_NUMPROBLEMS)
713  .value("CVP_PROBLEM_COMPLAINTS", CVP_PROBLEM_COMPLAINTS)
714  .value("PROBNUM", PROBNUM)
715  ;
716 
717  // CityClass
718  emscripten::enum_<CityClass>("CityClass")
719  .value("CC_VILLAGE", CC_VILLAGE)
720  .value("CC_TOWN", CC_TOWN)
721  .value("CC_CITY", CC_CITY)
722  .value("CC_CAPITAL", CC_CAPITAL)
723  .value("CC_METROPOLIS", CC_METROPOLIS)
724  .value("CC_MEGALOPOLIS", CC_MEGALOPOLIS)
725  .value("CC_NUM_CITIES", CC_NUM_CITIES)
726  ;
727 
728  // GameLevel
729  emscripten::enum_<GameLevel>("GameLevel")
730  .value("LEVEL_EASY", LEVEL_EASY)
731  .value("LEVEL_MEDIUM", LEVEL_MEDIUM)
732  .value("LEVEL_HARD", LEVEL_HARD)
733  .value("LEVEL_COUNT", LEVEL_COUNT)
734  .value("LEVEL_FIRST", LEVEL_FIRST)
735  .value("LEVEL_LAST", LEVEL_LAST)
736  ;
737 
738  emscripten::enum_<Tiles>("Tiles")
739  .value("DIRT", DIRT) // 0: Clear tile
740  // tile 1 ?
741  // Water:
742  .value("RIVER", RIVER) // 2
743  .value("REDGE", REDGE) // 3
744  .value("CHANNEL", CHANNEL) // 4
745  .value("FIRSTRIVEDGE", FIRSTRIVEDGE) // 5
746  // tile 6 -- 19 ?
747  .value("LASTRIVEDGE", LASTRIVEDGE) // 20
748  .value("WATER_LOW", WATER_LOW) // 2 (RIVER): First water tile
749  .value("WATER_HIGH", WATER_HIGH) // 20 (LASTRIVEDGE): Last water tile (inclusive)
750  .value("TREEBASE", TREEBASE) // 21
751  .value("WOODS_LOW", WOODS_LOW) // 21 (TREEBASE)
752  .value("LASTTREE", LASTTREE) // 36
753  .value("WOODS", WOODS) // 37
754  .value("UNUSED_TRASH1", UNUSED_TRASH1) // 38
755  .value("UNUSED_TRASH2", UNUSED_TRASH2) // 39
756  .value("WOODS_HIGH", WOODS_HIGH) // 39 (UNUSED_TRASH2): Why is an 'UNUSED' tile used?
757  .value("WOODS2", WOODS2) // 40
758  .value("WOODS3", WOODS3) // 41
759  .value("WOODS4", WOODS4) // 42
760  .value("WOODS5", WOODS5) // 43
761  // Rubble (4 tiles)
762  .value("RUBBLE", RUBBLE) // 44
763  .value("LASTRUBBLE", LASTRUBBLE) // 47
764  .value("FLOOD", FLOOD) // 48
765  // tile 49, 50 ?
766  .value("LASTFLOOD", LASTFLOOD) // 51
767  .value("RADTILE", RADTILE) // 52: Radio-active contaminated tile
768  .value("UNUSED_TRASH3", UNUSED_TRASH3) // 53
769  .value("UNUSED_TRASH4", UNUSED_TRASH4) // 54
770  .value("UNUSED_TRASH5", UNUSED_TRASH5) // 55
771  // Fire animation (8 tiles)
772  .value("FIRE", FIRE) // 56
773  .value("FIREBASE", FIREBASE) // 56 (FIRE)
774  .value("LASTFIRE", LASTFIRE) // 63
775  .value("HBRIDGE", HBRIDGE) // 64: Horizontal bridge
776  .value("ROADBASE", ROADBASE) // 64 (HBRIDGE)
777  .value("VBRIDGE", VBRIDGE) // 65: Vertical bridge
778  .value("ROADS", ROADS) // 66
779  .value("ROADS2", ROADS2) // 67
780  .value("ROADS3", ROADS3) // 68
781  .value("ROADS4", ROADS4) // 69
782  .value("ROADS5", ROADS5) // 70
783  .value("ROADS6", ROADS6) // 71
784  .value("ROADS7", ROADS7) // 72
785  .value("ROADS8", ROADS8) // 73
786  .value("ROADS9", ROADS9) // 74
787  .value("ROADS10", ROADS10) // 75
788  .value("INTERSECTION", INTERSECTION) // 76
789  .value("HROADPOWER", HROADPOWER) // 77
790  .value("VROADPOWER", VROADPOWER) // 78
791  .value("BRWH", BRWH) // 79
792  .value("LTRFBASE", LTRFBASE) // 80: First tile with low traffic
793  // tile 81 -- 94 ?
794  .value("BRWV", BRWV) // 95
795  // tile 96 -- 110 ?
796  .value("BRWXXX1", BRWXXX1) // 111
797  // tile 96 -- 110 ?
798  .value("BRWXXX2", BRWXXX2) // 127
799  // tile 96 -- 110 ?
800  .value("BRWXXX3", BRWXXX3) // 143
801  .value("HTRFBASE", HTRFBASE) // 144: First tile with high traffic
802  // tile 145 -- 158 ?
803  .value("BRWXXX4", BRWXXX4) // 159
804  // tile 160 -- 174 ?
805  .value("BRWXXX5", BRWXXX5) // 175
806  // tile 176 -- 190 ?
807  .value("BRWXXX6", BRWXXX6) // 191
808  // tile 192 -- 205 ?
809  .value("LASTROAD", LASTROAD) // 206
810  .value("BRWXXX7", BRWXXX7) // 207
811  // Power lines
812  .value("HPOWER", HPOWER) // 208
813  .value("VPOWER", VPOWER) // 209
814  .value("LHPOWER", LHPOWER) // 210
815  .value("LVPOWER", LVPOWER) // 211
816  .value("LVPOWER2", LVPOWER2) // 212
817  .value("LVPOWER3", LVPOWER3) // 213
818  .value("LVPOWER4", LVPOWER4) // 214
819  .value("LVPOWER5", LVPOWER5) // 215
820  .value("LVPOWER6", LVPOWER6) // 216
821  .value("LVPOWER7", LVPOWER7) // 217
822  .value("LVPOWER8", LVPOWER8) // 218
823  .value("LVPOWER9", LVPOWER9) // 219
824  .value("LVPOWER10", LVPOWER10) // 220
825  .value("RAILHPOWERV", RAILHPOWERV) // 221: Horizontal rail, vertical power
826  .value("RAILVPOWERH", RAILVPOWERH) // 222: Vertical rail, horizontal power
827  .value("POWERBASE", POWERBASE) // 208 (HPOWER)
828  .value("LASTPOWER", LASTPOWER) // 222 (RAILVPOWERH)
829  .value("UNUSED_TRASH6", UNUSED_TRASH6) // 223
830  // Rail
831  .value("HRAIL", HRAIL) // 224
832  .value("VRAIL", VRAIL) // 225
833  .value("LHRAIL", LHRAIL) // 226
834  .value("LVRAIL", LVRAIL) // 227
835  .value("LVRAIL2", LVRAIL2) // 228
836  .value("LVRAIL3", LVRAIL3) // 229
837  .value("LVRAIL4", LVRAIL4) // 230
838  .value("LVRAIL5", LVRAIL5) // 231
839  .value("LVRAIL6", LVRAIL6) // 232
840  .value("LVRAIL7", LVRAIL7) // 233
841  .value("LVRAIL8", LVRAIL8) // 234
842  .value("LVRAIL9", LVRAIL9) // 235
843  .value("LVRAIL10", LVRAIL10) // 236
844  .value("HRAILROAD", HRAILROAD) // 237
845  .value("VRAILROAD", VRAILROAD) // 238
846  .value("RAILBASE", RAILBASE) // 224 (HRAIL)
847  .value("LASTRAIL", LASTRAIL) // 238 (VRAILROAD)
848  .value("ROADVPOWERH", ROADVPOWERH) // 239: bogus?
849  // Residential zone tiles
850  .value("RESBASE", RESBASE) // 240: Empty residential, tiles 240--248
851  .value("FREEZ", FREEZ) // 244: center-tile of 3x3 empty residential
852  .value("HOUSE", HOUSE) // 249: Single tile houses until 260
853  .value("LHTHR", LHTHR) // 249 (HOUSE)
854  .value("HHTHR", HHTHR) // 260
855  .value("RZB", RZB) // 265: center tile first 3x3 tile residential
856  .value("HOSPITALBASE", HOSPITALBASE) // 405: Center of hospital (tiles 405--413)
857  .value("HOSPITAL", HOSPITAL) // 409: Center of hospital (tiles 405--413)
858  .value("CHURCHBASE", CHURCHBASE) // 414: Center of church (tiles 414--422)
859  .value("CHURCH0BASE", CHURCH0BASE) // 414 (CHURCHBASE): numbered alias
860  .value("CHURCH", CHURCH) // 418: Center of church (tiles 414--422)
861  .value("CHURCH0", CHURCH0) // 418 (CHURCH): numbered alias
862  // Commercial zone tiles
863  .value("COMBASE", COMBASE) // 423: Empty commercial, tiles 423--431
864  // tile 424 -- 426 ?
865  .value("COMCLR", COMCLR) // 427
866  // tile 428 -- 435 ?
867  .value("CZB", CZB) // 436
868  // tile 437 -- 608 ?
869  .value("COMLAST", COMLAST) // 609
870  // tile 610, 611 ?
871  // Industrial zone tiles.
872  .value("INDBASE", INDBASE) // 612: Top-left tile of empty industrial zone.
873  .value("INDCLR", INDCLR) // 616: Center tile of empty industrial zone.
874  .value("LASTIND", LASTIND) // 620: Last tile of empty industrial zone.
875  // Industrial zone population 0, value 0: 621 -- 629
876  .value("IND1", IND1) // 621: Top-left tile of first non-empty industry zone.
877  .value("IZB", IZB) // 625: Center tile of first non-empty industry zone.
878  // Industrial zone population 1, value 0: 630 -- 638
879  // Industrial zone population 2, value 0: 639 -- 647
880  .value("IND2", IND2) // 641
881  .value("IND3", IND3) // 644
882  // Industrial zone population 3, value 0: 648 -- 656
883  .value("IND4", IND4) // 649
884  .value("IND5", IND5) // 650
885  // Industrial zone population 0, value 1: 657 -- 665
886  // Industrial zone population 1, value 1: 666 -- 674
887  // Industrial zone population 2, value 1: 675 -- 683
888  .value("IND6", IND6) // 676
889  .value("IND7", IND7) // 677
890  // Industrial zone population 3, value 1: 684 -- 692
891  .value("IND8", IND8) // 686
892  .value("IND9", IND9) // 689
893  // Seaport
894  .value("PORTBASE", PORTBASE) // 693: Top-left tile of the seaport.
895  .value("PORT", PORT) // 698: Center tile of the seaport.
896  .value("LASTPORT", LASTPORT) // 708: Last tile of the seaport.
897  .value("AIRPORTBASE", AIRPORTBASE) // 709
898  // tile 710 ?
899  .value("RADAR", RADAR) // 711
900  // tile 712 -- 715 ?
901  .value("AIRPORT", AIRPORT) // 716
902  // tile 717 -- 744 ?
903  // Coal power plant (4x4).
904  .value("COALBASE", COALBASE) // 745: First tile of coal power plant.
905  .value("POWERPLANT", POWERPLANT) // 750: 'Center' tile of coal power plant.
906  .value("LASTPOWERPLANT", LASTPOWERPLANT) // 760: Last tile of coal power plant.
907  // Fire station (3x3).
908  .value("FIRESTBASE", FIRESTBASE) // 761: First tile of fire station.
909  .value("FIRESTATION", FIRESTATION) // 765: 'Center tile' of fire station.
910  // 769 last tile fire station.
911  .value("POLICESTBASE", POLICESTBASE) // 770
912  // tile 771 -- 773 ?
913  .value("POLICESTATION", POLICESTATION) // 774
914  // tile 775 -- 778 ?
915  // Stadium (4x4).
916  .value("STADIUMBASE", STADIUMBASE) // 779: First tile stadium.
917  .value("STADIUM", STADIUM) // 784: 'Center tile' stadium.
918  // Last tile stadium 794.
919  // tile 785 -- 799 ?
920  .value("FULLSTADIUM", FULLSTADIUM) // 800
921  // tile 801 -- 810 ?
922  // Nuclear power plant (4x4).
923  .value("NUCLEARBASE", NUCLEARBASE) // 811: First tile nuclear power plant.
924  .value("NUCLEAR", NUCLEAR) // 816: 'Center' tile nuclear power plant.
925  .value("LASTZONE", LASTZONE) // 826: Also last tile nuclear power plant.
926  .value("LIGHTNINGBOLT", LIGHTNINGBOLT) // 827
927  .value("HBRDG0", HBRDG0) // 828
928  .value("HBRDG1", HBRDG1) // 829
929  .value("HBRDG2", HBRDG2) // 830
930  .value("HBRDG3", HBRDG3) // 831
931  .value("HBRDG_END", HBRDG_END) // 832
932  .value("RADAR0", RADAR0) // 832
933  .value("RADAR1", RADAR1) // 833
934  .value("RADAR2", RADAR2) // 834
935  .value("RADAR3", RADAR3) // 835
936  .value("RADAR4", RADAR4) // 836
937  .value("RADAR5", RADAR5) // 837
938  .value("RADAR6", RADAR6) // 838
939  .value("RADAR7", RADAR7) // 839
940  .value("FOUNTAIN", FOUNTAIN) // 840
941  // tile 841 -- 843: fountain animation.
942  .value("INDBASE2", INDBASE2) // 844
943  .value("TELEBASE", TELEBASE) // 844 (INDBASE2)
944  // tile 845 -- 850 ?
945  .value("TELELAST", TELELAST) // 851
946  .value("SMOKEBASE", SMOKEBASE) // 852
947  // tile 853 -- 859 ?
948  .value("TINYEXP", TINYEXP) // 860
949  // tile 861 -- 863 ?
950  .value("SOMETINYEXP", SOMETINYEXP) // 864
951  // tile 865 -- 866 ?
952  .value("LASTTINYEXP", LASTTINYEXP) // 867
953  // tile 868 -- 882 ?
954  .value("TINYEXPLAST", TINYEXPLAST) // 883
955  // tile 884 -- 915 ?
956  .value("COALSMOKE1", COALSMOKE1) // 916: Chimney animation at coal power plant (2, 0).
957  // 919 last animation tile for chimney at coal power plant (2, 0).
958  .value("COALSMOKE2", COALSMOKE2) // 920: Chimney animation at coal power plant (3, 0).
959  // 923 last animation tile for chimney at coal power plant (3, 0).
960  .value("COALSMOKE3", COALSMOKE3) // 924: Chimney animation at coal power plant (2, 1).
961  // 927 last animation tile for chimney at coal power plant (2, 1).
962  .value("COALSMOKE4", COALSMOKE4) // 928: Chimney animation at coal power plant (3, 1).
963  // 931 last animation tile for chimney at coal power plant (3, 1).
964  .value("FOOTBALLGAME1", FOOTBALLGAME1) // 932
965  // tile 933 -- 939 ?
966  .value("FOOTBALLGAME2", FOOTBALLGAME2) // 940
967  // tile 941 -- 947 ?
968  .value("VBRDG0", VBRDG0) // 948
969  .value("VBRDG1", VBRDG1) // 949
970  .value("VBRDG2", VBRDG2) // 950
971  .value("VBRDG3", VBRDG3) // 951
972  .value("NUKESWIRL1", NUKESWIRL1) // 952
973  .value("NUKESWIRL2", NUKESWIRL2) // 953
974  .value("NUKESWIRL3", NUKESWIRL3) // 954
975  .value("NUKESWIRL4", NUKESWIRL4) // 955
976  // Tiles 956-959 unused (originally)
977  // TILE_COUNT = 960,
978  // Extended zones: 956-1019
979  .value("CHURCH1BASE", CHURCH1BASE) // 956
980  .value("CHURCH1", CHURCH1) // 960
981  .value("CHURCH1BASE", CHURCH1BASE) // 956
982  .value("CHURCH1", CHURCH1) // 960
983  .value("CHURCH2BASE", CHURCH2BASE) // 965
984  .value("CHURCH2", CHURCH2) // 969
985  .value("CHURCH3BASE", CHURCH3BASE) // 974
986  .value("CHURCH3", CHURCH3) // 978
987  .value("CHURCH4BASE", CHURCH4BASE) // 983
988  .value("CHURCH4", CHURCH4) // 987
989  .value("CHURCH5BASE", CHURCH5BASE) // 992
990  .value("CHURCH5", CHURCH5) // 996
991  .value("CHURCH6BASE", CHURCH6BASE) // 1001
992  .value("CHURCH6", CHURCH6) // 1005
993  .value("CHURCH7BASE", CHURCH7BASE) // 1010
994  .value("CHURCH7", CHURCH7) // 1014
995  .value("CHURCH7LAST", CHURCH7LAST) // 1018
996  // Tiles 1020-1023 unused
997  .value("TILE_COUNT", TILE_COUNT) // 1024
998  .value("TILE_INVALID", TILE_INVALID) // -1, Invalid tile (not used in the world map).
999  ;
1000 
1001  class_<SimSprite>("SimSprite")
1002  .property("name", &SimSprite::name)
1003  .property("type", &SimSprite::type)
1004  .property("frame", &SimSprite::frame)
1005  .property("x", &SimSprite::x)
1006  .property("y", &SimSprite::y)
1007  .property("width", &SimSprite::width)
1008  .property("height", &SimSprite::height)
1009  .property("xOffset", &SimSprite::xOffset)
1010  .property("yOffset", &SimSprite::yOffset)
1011  .property("xHot", &SimSprite::xHot)
1012  .property("yHot", &SimSprite::yHot)
1013  .property("origX", &SimSprite::origX)
1014  .property("origY", &SimSprite::origY)
1015  .property("destX", &SimSprite::destX)
1016  .property("destY", &SimSprite::destY)
1017  .property("count", &SimSprite::count)
1018  .property("soundCount", &SimSprite::soundCount)
1019  .property("dir", &SimSprite::dir)
1020  .property("newDir", &SimSprite::newDir)
1021  .property("step", &SimSprite::step)
1022  .property("flag", &SimSprite::flag)
1023  .property("control", &SimSprite::control)
1024  .property("turn", &SimSprite::turn)
1025  .property("accel", &SimSprite::accel)
1026  .property("speed", &SimSprite::speed)
1027  ;
1028 
1029  class_<Micropolis>("Micropolis")
1030 
1031  .constructor<>()
1032 
1033  // Simulation Control and Settings
1034  .function("simTick", &Micropolis::simTick)
1035  .function("setSpeed", &Micropolis::setSpeed)
1036  .function("setGameLevel", &Micropolis::setGameLevel)
1037  .function("setCityName", &Micropolis::setCityName)
1038  .function("setYear", &Micropolis::setYear)
1039  .function("pause", &Micropolis::pause)
1040  .function("resume", &Micropolis::resume)
1041  .function("setEnableDisasters", &Micropolis::setEnableDisasters)
1042  .function("setAutoBudget", &Micropolis::setAutoBudget)
1043  .function("setAutoBulldoze", &Micropolis::setAutoBulldoze)
1044  .function("setAutoGoto", &Micropolis::setAutoGoto)
1045  .function("setEnableSound", &Micropolis::setEnableSound)
1046  .function("setDoAnimation", &Micropolis::setDoAnimation)
1047  .function("doNewGame", &Micropolis::doNewGame)
1048  .function("doBudget", &Micropolis::doBudget)
1049  .function("doScoreCard", &Micropolis::doScoreCard)
1050  .function("updateFunds", &Micropolis::updateFunds)
1051 
1052  // Game State and Statistics
1053  .property("simSpeed", &Micropolis::simSpeed)
1054  .property("simSpeedMeta", &Micropolis::simSpeedMeta)
1055  .property("simPaused", &Micropolis::simPaused)
1056  .property("disasterEvent", &Micropolis::disasterEvent)
1057  .property("disasterWait", &Micropolis::disasterWait)
1058  .property("scenario", &Micropolis::scenario)
1059  .property("heatSteps", &Micropolis::heatSteps)
1060  .property("heatFlow", &Micropolis::heatFlow)
1061  .property("heatRule", &Micropolis::heatRule)
1062  .property("heatWrap", &Micropolis::heatWrap)
1063  .property("totalFunds", &Micropolis::totalFunds)
1064  .property("cityPop", &Micropolis::cityPop)
1065  .property("cityTime", &Micropolis::cityTime)
1066  .property("cityYear", &Micropolis::cityYear)
1067  .property("cityMonth", &Micropolis::cityMonth)
1068  .property("cityYes", &Micropolis::cityYes)
1069  .property("cityScore", &Micropolis::cityScore)
1070  .property("cityClass", &Micropolis::cityClass)
1071  .property("gameLevel", &Micropolis::gameLevel)
1072  .property("mapSerial", &Micropolis::mapSerial)
1073  .property("trafficAverage", &Micropolis::trafficAverage)
1074  .property("pollutionAverage", &Micropolis::pollutionAverage)
1075  .property("crimeAverage", &Micropolis::crimeAverage)
1076  .property("landValueAverage", &Micropolis::landValueAverage)
1077  .property("startingYear", &Micropolis::startingYear)
1078  .property("generatedCitySeed", &Micropolis::generatedCitySeed)
1079  .property("cityPopDelta", &Micropolis::cityPopDelta)
1080  .property("cityAssessedValue", &Micropolis::cityAssessedValue)
1081  .property("cityScoreDelta", &Micropolis::cityScoreDelta)
1082  .property("trafficAverage", &Micropolis::trafficAverage)
1083  .property("pollutionAverage", &Micropolis::pollutionAverage)
1084  .property("crimeAverage", &Micropolis::crimeAverage)
1085  .property("totalPop", &Micropolis::totalPop)
1086  .property("totalZonePop", &Micropolis::totalZonePop)
1087  .property("hospitalPop", &Micropolis::hospitalPop)
1088  .property("churchPop", &Micropolis::churchPop)
1089  .property("stadiumPop", &Micropolis::stadiumPop)
1090  .property("coalPowerPop", &Micropolis::coalPowerPop)
1091  .property("nuclearPowerPop", &Micropolis::nuclearPowerPop)
1092 
1093  // Resource Management
1094  .property("roadTotal", &Micropolis::roadTotal)
1095  .property("railTotal", &Micropolis::railTotal)
1096  .property("resPop", &Micropolis::resPop)
1097  .property("comPop", &Micropolis::comPop)
1098  .property("indPop", &Micropolis::indPop)
1099  .property("policeStationPop", &Micropolis::policeStationPop)
1100  .property("fireStationPop", &Micropolis::fireStationPop)
1101  .property("seaportPop", &Micropolis::seaportPop)
1102  .property("airportPop", &Micropolis::airportPop)
1103  .property("cashFlow", &Micropolis::cashFlow)
1104  .property("cityTax", &Micropolis::cityTax)
1105  .property("roadEffect", &Micropolis::roadEffect)
1106  .property("policeEffect", &Micropolis::policeEffect)
1107  .property("fireEffect", &Micropolis::fireEffect)
1108 
1109  // User Interface and Preferences
1110  .property("autoGoto", &Micropolis::autoGoto)
1111  .property("autoBudget", &Micropolis::autoBudget)
1112  .property("autoBulldoze", &Micropolis::autoBulldoze)
1113  .property("enableSound", &Micropolis::enableSound)
1114  .property("enableDisasters", &Micropolis::enableDisasters)
1115  .property("doAnimation", &Micropolis::doAnimation)
1116  .property("doMessages", &Micropolis::doMessages)
1117  .property("doNotices", &Micropolis::doNotices)
1118 
1119  // Gameplay Mechanics
1120  .property("cityFileName", &Micropolis::cityFileName)
1121  .property("cityName", &Micropolis::cityName)
1122  .function("doTool", &Micropolis::doTool)
1123  .function("generateMap", &Micropolis::generateMap)
1124  .function("clearMap", &Micropolis::clearMap)
1125  //.function("getDemands", &Micropolis::getDemands, allow_raw_pointers()) // TODO: wrap
1126 
1127  // Random Number Generation
1128  .function("simRandom", &Micropolis::simRandom)
1129  .function("getRandom", &Micropolis::getRandom)
1130  .function("getRandom16", &Micropolis::getRandom16)
1131  .function("getRandom16Signed", &Micropolis::getRandom16Signed)
1132  .function("getERandom", &Micropolis::getERandom)
1133  .function("randomlySeedRandom", &Micropolis::randomlySeedRandom)
1134  .function("seedRandom", &Micropolis::seedRandom)
1135 
1136  // Game State and Data Access
1137  .function("getTile", &Micropolis::getTile)
1138  .function("setTile", &Micropolis::setTile)
1139  .function("setFunds", &Micropolis::setFunds)
1140  .function("updateMaps", &Micropolis::updateMaps)
1141  .function("updateGraphs", &Micropolis::updateGraphs)
1142  .function("updateEvaluation", &Micropolis::updateEvaluation)
1143  .function("updateBudget", &Micropolis::updateBudget)
1144 
1145  // City History Arrays
1146  //.function("getResidentialHistory", &Micropolis::getResidentialHistory, allow_raw_pointers()) // TODO: wrap
1147  //.function("getCommercialHistory", &Micropolis::getCommercialHistory, allow_raw_pointers()) // TODO: wrap
1148  //.function("getIndustrialHistory", &Micropolis::getIndustrialHistory, allow_raw_pointers()) // TODO: wrap
1149 
1150  // Events and Callbacks
1151  .function("sendMessage", &Micropolis::sendMessage)
1152  .function("makeSound", &Micropolis::makeSound)
1153 
1154  ;
1155 
1156 }
1157 
1158 
Definition: map_type.h:113
Quad roadEffect
Definition: micropolis.h:1201
short indPop
Definition: micropolis.h:996
short stadiumPop
Number of stadiums.
Definition: micropolis.h:1025
void setTile(int x, int y, int tile)
void setDoAnimation(bool value)
Definition: utilities.cpp:384
void seedRandom(int seed)
Definition: random.cpp:177
short crimeAverage
Definition: micropolis.h:1063
Quad cityPopDelta
Definition: micropolis.h:1581
GameLevel gameLevel
Difficulty level of the game (0..2)
Definition: micropolis.h:2334
Scenario scenario
Scenario being played.
Definition: micropolis.h:2338
Quad policeEffect
Definition: micropolis.h:1206
std::string cityFileName
Filename of the last loaded city.
Definition: micropolis.h:1904
void updateBudget()
Definition: budget.cpp:327
short churchPop
Number of churches.
Definition: micropolis.h:1023
void simTick()
Quad cityTime
Definition: micropolis.h:1092
short resPop
Definition: micropolis.h:982
short getRandom(short range)
Definition: random.cpp:110
void setAutoGoto(bool value)
Definition: utilities.cpp:356
bool doAnimation
Definition: micropolis.h:1887
int getRandom16()
Definition: random.cpp:130
bool enableDisasters
Enable disasters.
Definition: micropolis.h:2346
short cityScoreDelta
Definition: micropolis.h:1611
short totalZonePop
Definition: micropolis.h:1020
short pollutionAverage
Definition: micropolis.h:1072
Quad fireEffect
Definition: micropolis.h:1211
short airportPop
Definition: micropolis.h:1055
std::string cityName
Name of the city.
Definition: micropolis.h:1909
void setFunds(int dollars)
short policeStationPop
Definition: micropolis.h:1030
void updateFunds()
Definition: update.cpp:127
int generatedCitySeed
Definition: micropolis.h:1741
void setAutoBulldoze(bool value)
Definition: utilities.cpp:342
short disasterWait
Count-down timer for the disaster.
Definition: micropolis.h:2102
void setEnableSound(bool value)
Definition: utilities.cpp:370
void setEnableDisasters(bool value)
Definition: utilities.cpp:317
Quad cityPop
Definition: micropolis.h:1574
bool doNotices
Definition: micropolis.h:1891
short totalPop
Definition: micropolis.h:1004
short cityYes
Definition: micropolis.h:1551
Quad cityAssessedValue
Definition: micropolis.h:1591
short landValueAverage
Definition: micropolis.h:1080
void randomlySeedRandom()
Definition: random.cpp:165
bool doMessages
Definition: micropolis.h:1889
short coalPowerPop
Definition: micropolis.h:1040
void pause()
Definition: utilities.cpp:148
short hospitalPop
Number of hospitals.
Definition: micropolis.h:1022
Quad cityMonth
Definition: micropolis.h:1098
bool simPaused
Definition: micropolis.h:1877
void generateMap(int seed)
Definition: generate.cpp:129
ToolResult doTool(EditingTool tool, short tileX, short tileY)
Definition: tool.cpp:1397
short trafficAverage
Definition: micropolis.h:1618
int mapSerial
The invalidateMaps method increases the map serial number every time the maps changes.
Definition: micropolis.h:2122
int simRandom()
Definition: random.cpp:98
short startingYear
Definition: micropolis.h:1109
bool enableSound
Enable sound.
Definition: micropolis.h:2344
void sendMessage(short Mnum, short x=NOWHERE, short y=NOWHERE, bool picture=false, bool important=false)
Definition: message.cpp:390
Scenario disasterEvent
The disaster for which a count-down is running.
Definition: micropolis.h:2101
void doScoreCard()
Definition: evaluate.cpp:479
void makeSound(const std::string &channel, const std::string &sound, int x=-1, int y=-1)
Quad cityYear
Definition: micropolis.h:1104
void setGameLevel(GameLevel level)
Definition: utilities.cpp:235
bool autoBudget
Definition: micropolis.h:2330
int getTile(int x, int y)
short cityScore
Definition: micropolis.h:1604
CityClass cityClass
City class, affected by city population.
Definition: micropolis.h:1593
short nuclearPowerPop
Definition: micropolis.h:1045
void resume()
Definition: utilities.cpp:164
void clearMap()
Definition: generate.cpp:175
short fireStationPop
Definition: micropolis.h:1035
int getRandom16Signed()
Definition: random.cpp:137
short comPop
Definition: micropolis.h:989
bool autoGoto
Definition: micropolis.h:1960
void doNewGame()
Definition: utilities.cpp:306
short cityTax
Definition: micropolis.h:1224
short railTotal
Definition: micropolis.h:970
short getERandom(short limit)
Definition: random.cpp:155
short seaportPop
Definition: micropolis.h:1050
short roadTotal
Definition: micropolis.h:963
Quad totalFunds
Funds of the player.
Definition: micropolis.h:2315
void doBudget()
Definition: budget.cpp:97
bool autoBulldoze
Definition: micropolis.h:2323
void setAutoBudget(bool value)
Definition: utilities.cpp:328
int posY
Vertical coordnate of the position.
Definition: position.h:169
int posX
Horizontal coordinate of the position.
Definition: position.h:168
bool move(Direction2 dir)
Definition: position.cpp:161
bool testBounds()
Definition: position.h:177
int x
X coordinate of the sprite in pixels?
Definition: micropolis.h:891
int destX
Destination X coordinate of the sprite.
Definition: micropolis.h:901
int yHot
Offset of the hot-spot relative to SimSprite::y?
Definition: micropolis.h:898
int type
Type of the sprite (TRA – BUS).
Definition: micropolis.h:889
int destY
Destination Y coordinate of the sprite.
Definition: micropolis.h:902
std::string name
Name of the sprite.
Definition: micropolis.h:888
int y
Y coordinate of the sprite in pixels?
Definition: micropolis.h:892
int frame
Frame (0 means non-active sprite)
Definition: micropolis.h:890
int xHot
Offset of the hot-spot relative to SimSprite::x?
Definition: micropolis.h:897
void setMapValue(const Position &pos, MapValue mapVal)
Definition: tool.cpp:186
bool modifyIfEnoughFunding()
Definition: tool.cpp:152
MapTile getMapTile(const Position &pos) const
Definition: tool.h:242
void modifyWorld()
Definition: tool.cpp:121
void addCost(int amount)
Definition: tool.h:275
int getCost() const
Definition: tool.h:266
void clear()
Definition: tool.cpp:103
MapValue getMapValue(const Position &pos) const
Definition: tool.cpp:169
static const int WORLD_H
Definition: map_type.h:95
static const int WORLD_W
Definition: map_type.h:90
Header file for Micropolis game engine.
static const int CITYTIMES_PER_YEAR
Definition: micropolis.h:205
static const int WORLD_H_8
Definition: micropolis.h:185
@ SC_TOKYO
Tokyo (scary monster)
Definition: micropolis.h:704
@ SC_NONE
No scenario (free playing)
Definition: micropolis.h:698
@ SC_BOSTON
Boston (nuclear meltdown)
Definition: micropolis.h:706
@ SC_BERN
Bern (traffic)
Definition: micropolis.h:703
@ SC_COUNT
Number of scenarios.
Definition: micropolis.h:709
@ SC_SAN_FRANCISCO
San francisco (earthquake)
Definition: micropolis.h:701
@ SC_RIO
Rio (flooding)
Definition: micropolis.h:707
@ SC_HAMBURG
Hamburg (fire bombs)
Definition: micropolis.h:702
@ SC_DULLSVILLE
Dullsville (boredom)
Definition: micropolis.h:700
@ SC_DETROIT
Detroit (crime)
Definition: micropolis.h:705
static const int HISTORY_LENGTH
Definition: micropolis.h:210
@ ZT_RESIDENTIAL
Residential zone.
Definition: micropolis.h:720
@ ZT_COMMERCIAL
Commercial zone.
Definition: micropolis.h:718
@ ZT_INDUSTRIAL
Industrial zone.
Definition: micropolis.h:719
@ ZT_NUM_DESTINATIONS
Number of available zones.
Definition: micropolis.h:722
static const int WORLD_W_2
Definition: micropolis.h:151
static const int PASSES_PER_CITYTIME
Definition: micropolis.h:195
@ CONNECT_TILE_FIX
Fix zone (connect wire, road, and rail).
Definition: micropolis.h:351
@ CONNECT_TILE_ROAD
Lay road and fix zone.
Definition: micropolis.h:353
@ CONNECT_TILE_WIRE
Lay wire and fix zone.
Definition: micropolis.h:355
@ CONNECT_TILE_RAILROAD
Lay rail and fix zone.
Definition: micropolis.h:354
@ CONNECT_TILE_BULLDOZE
Bulldoze and fix zone.
Definition: micropolis.h:352
static const int POWER_STACK_SIZE
Definition: micropolis.h:226
@ MAP_TYPE_POLLUTION
Pollution.
Definition: micropolis.h:316
@ MAP_TYPE_POPULATION_DENSITY
Population density.
Definition: micropolis.h:313
@ MAP_TYPE_DYNAMIC
Dynamic filter.
Definition: micropolis.h:321
@ MAP_TYPE_LAND_VALUE
Land value.
Definition: micropolis.h:318
@ MAP_TYPE_FIRE_RADIUS
Fire station coverage radius.
Definition: micropolis.h:319
@ MAP_TYPE_CRIME
Crime rate.
Definition: micropolis.h:317
@ MAP_TYPE_ALL
All zones.
Definition: micropolis.h:307
@ MAP_TYPE_IND
Industrial zones.
Definition: micropolis.h:310
@ MAP_TYPE_COM
Commercial zones.
Definition: micropolis.h:309
@ MAP_TYPE_RES
Residential zones.
Definition: micropolis.h:308
@ MAP_TYPE_ROAD
Roads.
Definition: micropolis.h:312
@ MAP_TYPE_POWER
Power connectivity.
Definition: micropolis.h:311
@ MAP_TYPE_COUNT
Number of map types.
Definition: micropolis.h:323
@ MAP_TYPE_RATE_OF_GROWTH
Rate of growth.
Definition: micropolis.h:314
@ MAP_TYPE_TRAFFIC_DENSITY
Traffic.
Definition: micropolis.h:315
@ MAP_TYPE_POLICE_RADIUS
Police station coverage radius.
Definition: micropolis.h:320
static const int CITYTIMES_PER_MONTH
Definition: micropolis.h:200
@ HISTORY_TYPE_CRIME
Crime history type.
Definition: micropolis.h:287
@ HISTORY_TYPE_MONEY
Money history type.
Definition: micropolis.h:286
@ HISTORY_TYPE_POLLUTION
Pollution history type.
Definition: micropolis.h:288
@ HISTORY_TYPE_IND
Industry history type.
Definition: micropolis.h:285
@ HISTORY_TYPE_COUNT
Number of history types.
Definition: micropolis.h:290
@ HISTORY_TYPE_RES
Residiential history type.
Definition: micropolis.h:283
@ HISTORY_TYPE_COM
Commercial history type.
Definition: micropolis.h:284
static const int HISTORY_COUNT
Definition: micropolis.h:221
@ LASTPOWERPLANT
Last tile of coal power plant.
Definition: micropolis.h:581
@ NUCLEARBASE
First tile nuclear power plant.
Definition: micropolis.h:603
@ COALBASE
First tile of coal power plant.
Definition: micropolis.h:579
@ HTRFBASE
First tile with high traffic.
Definition: micropolis.h:452
@ WATER_LOW
First water tile.
Definition: micropolis.h:392
@ FIRESTBASE
First tile of fire station.
Definition: micropolis.h:584
@ RAILHPOWERV
Horizontal rail, vertical power.
Definition: micropolis.h:477
@ HBRIDGE
Horizontal bridge.
Definition: micropolis.h:426
@ WATER_HIGH
Last water tile (inclusive)
Definition: micropolis.h:393
@ STADIUMBASE
First tile stadium.
Definition: micropolis.h:594
@ VBRIDGE
Vertical bridge.
Definition: micropolis.h:428
@ LASTZONE
Also last tile nuclear power plant.
Definition: micropolis.h:605
@ STADIUM
'Center tile' stadium.
Definition: micropolis.h:595
@ NUCLEAR
'Center' tile nuclear power plant.
Definition: micropolis.h:604
@ PORTBASE
Top-left tile of the seaport.
Definition: micropolis.h:567
@ IZB
Center tile of first non-empty industry zone.
Definition: micropolis.h:542
@ PORT
Center tile of the seaport.
Definition: micropolis.h:568
@ COALSMOKE3
927 last animation tile for chimney at coal power plant (2, 1).
Definition: micropolis.h:644
@ POWERPLANT
'Center' tile of coal power plant.
Definition: micropolis.h:580
@ INDCLR
Center tile of empty industrial zone.
Definition: micropolis.h:537
@ COALSMOKE4
931 last animation tile for chimney at coal power plant (3, 1).
Definition: micropolis.h:647
@ RADTILE
Radio-active contaminated tile.
Definition: micropolis.h:415
@ FIRESTATION
'Center tile' of fire station.
Definition: micropolis.h:585
@ LTRFBASE
First tile with low traffic.
Definition: micropolis.h:443
@ DIRT
Clear tile.
Definition: micropolis.h:382
@ INDBASE
Top-left tile of empty industrial zone.
Definition: micropolis.h:536
@ IND1
Top-left tile of first non-empty industry zone.
Definition: micropolis.h:541
@ COALSMOKE1
919 last animation tile for chimney at coal power plant (2, 0).
Definition: micropolis.h:638
@ RAILVPOWERH
Vertical rail, horizontal power.
Definition: micropolis.h:478
@ LASTIND
Last tile of empty industrial zone.
Definition: micropolis.h:538
@ TILE_INVALID
Invalid tile (not used in the world map).
Definition: micropolis.h:689
@ LASTPORT
Last tile of the seaport.
Definition: micropolis.h:569
@ COALSMOKE2
923 last animation tile for chimney at coal power plant (3, 0).
Definition: micropolis.h:641
static const int ISLAND_RADIUS
Definition: micropolis.h:239
static const int BYTES_PER_TILE
Definition: micropolis.h:143
static const int WORLD_H_2
Definition: micropolis.h:157
@ CC_CAPITAL
Capital, > 50000 citizens.
Definition: micropolis.h:754
@ CC_MEGALOPOLIS
Megalopolis, > 500000 citizens.
Definition: micropolis.h:756
@ CC_METROPOLIS
Metropolis, > 100000 citizens.
Definition: micropolis.h:755
@ CC_CITY
City, > 10000 citizens.
Definition: micropolis.h:753
@ CC_VILLAGE
Village.
Definition: micropolis.h:751
@ CC_TOWN
Town, > 2000 citizens.
Definition: micropolis.h:752
@ CC_NUM_CITIES
Number of city classes.
Definition: micropolis.h:758
static const int WORLD_W_8
Definition: micropolis.h:179
static const int MAX_FIRE_STATION_EFFECT
Definition: micropolis.h:263
@ HISTORY_SCALE_SHORT
Short scale data (10 years)
Definition: micropolis.h:297
@ HISTORY_SCALE_COUNT
Number of history scales available.
Definition: micropolis.h:300
@ HISTORY_SCALE_LONG
Long scale data (120 years)
Definition: micropolis.h:298
static const int EDITOR_TILE_SIZE
Definition: micropolis.h:190
@ LEVEL_FIRST
First game level value.
Definition: micropolis.h:769
@ LEVEL_MEDIUM
Intermediate game level.
Definition: micropolis.h:764
@ LEVEL_EASY
Simple game level.
Definition: micropolis.h:763
@ LEVEL_HARD
Difficult game level.
Definition: micropolis.h:765
@ LEVEL_LAST
Last game level value.
Definition: micropolis.h:770
@ LEVEL_COUNT
Number of game levels.
Definition: micropolis.h:767
@ TOOLRESULT_FAILED
Cannot build here.
Definition: micropolis.h:366
@ TOOLRESULT_OK
Build succeeded.
Definition: micropolis.h:367
@ TOOLRESULT_NEED_BULLDOZE
Clear the area first.
Definition: micropolis.h:365
@ TOOLRESULT_NO_MONEY
User has not enough money for tool.
Definition: micropolis.h:364
static const int NOWHERE
Definition: micropolis.h:233
@ CVP_NUMPROBLEMS
Number of problems.
Definition: micropolis.h:742
@ CVP_FIRE
Fire.
Definition: micropolis.h:740
@ CVP_POLLUTION
Pollution.
Definition: micropolis.h:735
@ CVP_TAXES
Taxes.
Definition: micropolis.h:737
@ CVP_HOUSING
Housing.
Definition: micropolis.h:736
@ CVP_UNEMPLOYMENT
Unemployment.
Definition: micropolis.h:739
@ CVP_TRAFFIC
Traffic.
Definition: micropolis.h:738
@ CVP_PROBLEM_COMPLAINTS
Number of problems to complain about.
Definition: micropolis.h:744
@ CVP_CRIME
Crime.
Definition: micropolis.h:734
static const int MAX_ROAD_EFFECT
Definition: micropolis.h:253
@ SPRITE_AIRPLANE
Airplane sprite.
Definition: micropolis.h:333
@ SPRITE_TORNADO
Tornado sprite.
Definition: micropolis.h:336
@ SPRITE_MONSTER
Scary monster.
Definition: micropolis.h:335
@ SPRITE_TRAIN
Train sprite.
Definition: micropolis.h:331
@ SPRITE_HELICOPTER
Helicopter sprite.
Definition: micropolis.h:332
@ SPRITE_BUS
Bus sprite.
Definition: micropolis.h:338
@ SPRITE_SHIP
Ship.
Definition: micropolis.h:334
@ SPRITE_EXPLOSION
Explosion sprite.
Definition: micropolis.h:337
@ SPRITE_COUNT
Number of sprite objects.
Definition: micropolis.h:340
static const int WORLD_H_4
Definition: micropolis.h:171
static const int BITS_PER_TILE
Definition: micropolis.h:137
static const int MISC_HISTORY_LENGTH
Definition: micropolis.h:215
static const int MAX_POLICE_STATION_EFFECT
Definition: micropolis.h:258
static const int WORLD_W_4
Definition: micropolis.h:165
static const int MAX_TRAFFIC_DISTANCE
Definition: micropolis.h:248
static Direction2 rotate45(Direction2 dir, int count=1)
Definition: position.h:127
static Direction2 rotate180(Direction2 dir)
Definition: position.h:147
@ DIR2_SOUTH_EAST
Direction pointing south-east.
Definition: position.h:91
@ DIR2_NORTH_EAST
Direction pointing north-east.
Definition: position.h:89
@ DIR2_WEST
Direction pointing west.
Definition: position.h:94
@ DIR2_INVALID
Invalid direction.
Definition: position.h:87
@ DIR2_SOUTH
Direction pointing south.
Definition: position.h:92
@ DIR2_EAST
Direction pointing east.
Definition: position.h:90
@ DIR2_NORTH_WEST
Direction pointing north-west.
Definition: position.h:95
@ DIR2_SOUTH_WEST
Direction pointing south-west.
Definition: position.h:93
@ DIR2_NORTH
Direction pointing north.
Definition: position.h:88
static Direction2 increment45(Direction2 dir, int count=1)
Definition: position.h:106
static Direction2 rotate90(Direction2 dir)
Definition: position.h:137
static Direction2 increment90(Direction2 dir)
Definition: position.h:117
@ STR202_POPULATIONDENSITY_LOW
Low.
Definition: text.h:85
@ STR202_LANDVALUE_HIGH_CLASS
High.
Definition: text.h:93
@ STR202_CRIME_DANGEROUS
Dangerous.
Definition: text.h:98
@ STR202_POPULATIONDENSITY_HIGH
High.
Definition: text.h:87
@ STR202_GROWRATE_STABLE
Stable.
Definition: text.h:106
@ STR202_LANDVALUE_LOWER_CLASS
Lower Class.
Definition: text.h:91
@ STR202_POPULATIONDENSITY_VERYHIGH
Very High.
Definition: text.h:88
@ STR202_CRIME_LIGHT
Light.
Definition: text.h:96
@ STR202_POLLUTION_MODERATE
Moderate.
Definition: text.h:101
@ STR202_LANDVALUE_SLUM
Slum.
Definition: text.h:90
@ STR202_POLLUTION_VERY_HEAVY
Very Heavy.
Definition: text.h:103
@ STR202_GROWRATE_DECLINING
Declining.
Definition: text.h:105
@ STR202_POLLUTION_HEAVY
Heavy.
Definition: text.h:102
@ STR202_LANDVALUE_MIDDLE_CLASS
Middle Class.
Definition: text.h:92
@ STR202_POPULATIONDENSITY_MEDIUM
Medium.
Definition: text.h:86
@ STR202_GROWRATE_SLOWGROWTH
Slow Growth.
Definition: text.h:107
@ STR202_GROWRATE_FASTGROWTH
Fast Growth.
Definition: text.h:108
@ STR202_CRIME_MODERATE
Moderate.
Definition: text.h:97
@ STR202_CRIME_NONE
Safe.
Definition: text.h:95
@ STR202_POLLUTION_NONE
None.
Definition: text.h:100
@ MESSAGE_TAX_TOO_HIGH
Citizens upset. The tax rate is too high.
Definition: text.h:128
@ MESSAGE_SCENARIO_WON
You won the scenario.
Definition: text.h:159
@ MESSAGE_SCENARIO_SAN_FRANCISCO
San Francisco scenario.
Definition: text.h:163
@ MESSAGE_FIRE_REPORTED
20: Fire reported !
Definition: text.h:132
@ MESSAGE_SHIP_CRASHED
25: Shipwreck reported !
Definition: text.h:137
@ MESSAGE_REACHED_MEGALOPOLIS
Population has reached 500,000.
Definition: text.h:151
@ MESSAGE_PLANE_CRASHED
A plane has crashed !
Definition: text.h:136
@ MESSAGE_SCENARIO_DETROIT
55: Detroit scenario.
Definition: text.h:167
@ MESSAGE_BULLDOZE_AREA_FIRST
Area must be bulldozed first.
Definition: text.h:146
@ MESSAGE_RIOTS_REPORTED
They're rioting in the streets !!
Definition: text.h:156
@ MESSAGE_SCENARIO_LOST
You lose the scenario.
Definition: text.h:160
@ MESSAGE_TRAIN_CRASHED
A train crashed !
Definition: text.h:138
@ MESSAGE_SCENARIO_RIO_DE_JANEIRO
57: Rio de Janeiro scenario.
Definition: text.h:169
@ MESSAGE_HIGH_UNEMPLOYMENT
Unemployment rate is high.
Definition: text.h:140
@ MESSAGE_NEED_MORE_RAILS
5: Inadequate rail system.
Definition: text.h:117
@ MESSAGE_BLACKOUTS_REPORTED
15: Blackouts reported. Check power map.
Definition: text.h:127
@ MESSAGE_SCENARIO_BOSTON
Boston scenario.
Definition: text.h:168
@ MESSAGE_ROAD_NEEDS_FUNDING
Roads deteriorating, due to lack of funds.
Definition: text.h:129
@ MESSAGE_LAST
Last valid message.
Definition: text.h:171
@ MESSAGE_NEED_MORE_INDUSTRIAL
More industrial zones needed.
Definition: text.h:115
@ MESSAGE_NOT_ENOUGH_POWER
40: Brownouts, build another Power Plant.
Definition: text.h:152
@ MESSAGE_HELICOPTER_CRASHED
A helicopter crashed !
Definition: text.h:139
@ MESSAGE_NUCLEAR_MELTDOWN
A Nuclear Meltdown has occurred !!!
Definition: text.h:155
@ MESSAGE_NEED_MORE_PARKS
Need more parks.
Definition: text.h:143
@ MESSAGE_MONSTER_SIGHTED
A Monster has been sighted !!
Definition: text.h:133
@ MESSAGE_REACHED_TOWN
35: Population has reached 2,000.
Definition: text.h:147
@ MESSAGE_REACHED_METROPOLIS
Population has reached 100,000.
Definition: text.h:150
@ MESSAGE_NEED_MORE_ROADS
More roads required.
Definition: text.h:116
@ MESSAGE_EXPLOSION_REPORTED
Explosion detected !
Definition: text.h:144
@ MESSAGE_SCENARIO_HAMBURG
Hamburg scenario.
Definition: text.h:164
@ MESSAGE_TORNADO_SIGHTED
Tornado reported !!
Definition: text.h:134
@ MESSAGE_NEED_AIRPORT
Commerce requires an Airport.
Definition: text.h:121
@ MESSAGE_HEAVY_TRAFFIC
Heavy Traffic reported.
Definition: text.h:153
@ MESSAGE_POLICE_NEEDS_FUNDING
Police departments need funding.
Definition: text.h:131
@ MESSAGE_NEED_POLICE_STATION
Citizens demand a Police Department.
Definition: text.h:126
@ MESSAGE_NO_MONEY
YOUR CITY HAS GONE BROKE!
Definition: text.h:141
@ MESSAGE_HIGH_CRIME
Crime very high.
Definition: text.h:123
@ MESSAGE_SCENARIO_BERN
Bern scenario.
Definition: text.h:165
@ MESSAGE_REACHED_CITY
Population has reached 10,000.
Definition: text.h:148
@ MESSAGE_SCENARIO_TOKYO
Tokyo scenario.
Definition: text.h:166
@ MESSAGE_REACHED_CAPITAL
Population has reached 50,000.
Definition: text.h:149
@ MESSAGE_FIREBOMBING
30: Firebombing reported !
Definition: text.h:142
@ MESSAGE_NEED_FIRE_STATION
Citizens demand a Fire Department.
Definition: text.h:125
@ MESSAGE_ABOUT_MICROPOLIS
About micropolis.
Definition: text.h:161
@ MESSAGE_LOADED_SAVED_CITY
Restored a Saved City.
Definition: text.h:158
@ MESSAGE_STARTED_NEW_CITY
45: Started a New City.
Definition: text.h:157
@ MESSAGE_NEED_ELECTRICITY
Build a Power Plant.
Definition: text.h:118
@ MESSAGE_NEED_MORE_COMMERCIAL
More commercial zones needed.
Definition: text.h:114
@ MESSAGE_NOT_ENOUGH_FUNDS
Insufficient funds to build that.
Definition: text.h:145
@ MESSAGE_SCENARIO_DULLSVILLE
50: Dullsville scenario.
Definition: text.h:162
@ MESSAGE_NEED_SEAPORT
Industry requires a Sea Port.
Definition: text.h:120
@ MESSAGE_FIRE_STATION_NEEDS_FUNDING
Fire departments need funding.
Definition: text.h:130
@ MESSAGE_HIGH_POLLUTION
10: Pollution very high.
Definition: text.h:122
@ MESSAGE_NEED_STADIUM
Residents demand a Stadium.
Definition: text.h:119
@ MESSAGE_TRAFFIC_JAMS
Frequent traffic jams reported.
Definition: text.h:124
@ MESSAGE_FLOODING_REPORTED
Flooding reported !!
Definition: text.h:154
@ MESSAGE_EARTHQUAKE
Major earthquake reported !!!
Definition: text.h:135
@ MESSAGE_NEED_MORE_RESIDENTIAL
More residential zones needed.
Definition: text.h:113
unsigned short MapTile
Definition: tool.h:108
@ BURNBIT
bit 13, tile can be lit.
Definition: tool.h:122
@ LOMASK
Mask for the Tiles part of the tile.
Definition: tool.h:129
@ ZONEBIT
bit 10, tile is the center tile of the zone.
Definition: tool.h:125
@ CONDBIT
bit 14. tile can conduct electricity.
Definition: tool.h:121
@ PWRBIT
bit 15, tile has power.
Definition: tool.h:120
@ BULLBIT
bit 12, tile is bulldozable.
Definition: tool.h:123
@ ANIMBIT
bit 11, tile is animated.
Definition: tool.h:124
@ ALLBITS
Mask for the bits-part of the tile.
Definition: tool.h:128
unsigned short MapValue
Definition: tool.h:94