93 ToolEffects::~ToolEffects()
123 WorldModificationsMap::const_iterator modIter;
124 FrontendMessages::const_iterator msgIter;
132 modIter != this->modifications.end(); modIter++) {
139 msgIter != this->frontendMessages.end(); msgIter++) {
140 (*msgIter)->sendMessage(mpolis);
171 WorldModificationsMap::const_iterator iter;
178 return (*iter).second;
194 BuildingProperties::BuildingProperties(
int xs,
int ys,
MapTile base,
201 buildingIsAnimated(anim)
205 BuildingProperties::~BuildingProperties()
220 3000, 3000, 5000, 10000,
260 tile |= value + WOODS2;
369 static short dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1, };
370 static short dy[8] = { -1, -1, -1, 0, 0, 1, 1, 1, };
375 for (i = 0; i < 8; i++) {
376 int xx = mapH + dx[i];
377 int yy = mapV + dy[i];
537 return (tileValue >= FIRSTRIVEDGE && tileValue <= LASTRUBBLE) ||
538 (tileValue >= POWERBASE + 2 && tileValue <= POWERBASE + 12) ||
539 (tileValue >= TINYEXP && tileValue <= LASTTINYEXP + 2);
551 if ((tileValue >= RESBASE - 1 && tileValue <=
PORTBASE - 1) ||
552 (tileValue >=
LASTPOWERPLANT + 1 && tileValue <= POLICESTATION + 4) ||
553 (tileValue >= CHURCH1BASE && tileValue <= CHURCH7LAST)) {
581 for (cnt = 0; cnt < sizeX; cnt++) {
586 for (cnt = 0; cnt < sizeY; cnt++) {
591 for (cnt = 0; cnt < sizeX; cnt++) {
596 for (cnt = 0; cnt < sizeY; cnt++) {
618 MapTile baseTile,
bool aniFlag,
621 for (
int dy = 0; dy < sizeY; dy++) {
622 int posY = topY + dy;
624 for (
int dx = 0; dx < sizeX; dx++) {
625 int posX = leftX + dx;
627 MapValue tileValue = baseTile | BNCNBIT;
631 }
else if (dy == 2 && aniFlag) {
658 int sizeX,
int sizeY,
662 if (leftX < 0 || leftX + sizeX >
WORLD_W) {
665 if (topY < 0 || topY + sizeY >
WORLD_H) {
670 for (
int dy = 0; dy < sizeY; dy++) {
671 int posY = topY + dy;
673 for (
int dx = 0; dx < sizeX; dx++) {
674 int posX = leftX + dx;
676 unsigned short tileValue = effects->
getMapTile(posX, posY);
678 if (tileValue ==
DIRT) {
686 if (!
tally(tileValue)) {
718 buildingProps->
sizeX,
719 buildingProps->
sizeY,
722 return prepareResult;
743 static short idArray[29] = {
744 DIRT, RIVER, TREEBASE, RUBBLE,
745 FLOOD,
RADTILE, FIRE, ROADBASE,
746 POWERBASE, RAILBASE, RESBASE, COMBASE,
750 HBRDG0, RADAR0, FOUNTAIN, INDBASE2,
752 FOOTBALLGAME1, VBRDG0, 952, 956,
816 if (z < 64 && z > 0)
return 13;
843 short tileNum =
map[mapH][mapV] &
LOMASK;
845 if (tileNum >=
COALSMOKE1 && tileNum < FOOTBALLGAME1) {
852 for (i = 1; i < 29; i++) {
853 if (tileNum < idArray[i]) {
872 if (i < 1 || i > 28) {
878 tileCategory = i + 1;
880 for (i = 0; i < 5; i++) {
887 status[0], status[1], status[2],
888 status[3], status[4],
904 int tileCategoryIndex,
905 int populationDensityIndex,
913 callback->showZoneStatus(
this, callbackVal, tileCategoryIndex, populationDensityIndex, landValueIndex, crimeRateIndex, pollutionIndex, growthRateIndex, x, y);
925 for (
int xx = x; xx < x + size; xx++) {
926 for (
int yy = y; yy < y + size; yy++) {
953 json += std::to_string(x);
955 json += std::to_string(y);
958 callback->didTool(
this, callbackVal, name, x, y);
984 ToolResult Micropolis::bulldozerTool(
short x,
short y)
988 ToolResult result = bulldozerTool(x, y, &effects);
991 effects.modifyWorld();
1039 int centerX = x + deltaH;
1040 int centerY = y + deltaV;
1046 "city",
"Explosion-High", dozeX, dozeY);
1049 putRubble(centerX - 1, centerY - 1, 3, effects);
1054 "city",
"Explosion-Low", dozeX, dozeY);
1057 putRubble(centerX - 1, centerY - 1, 4, effects);
1062 "city",
"Explosion-High", dozeX, dozeY);
1066 "city",
"Explosion-Low", dozeX, dozeY);
1069 putRubble(centerX - 1, centerY - 1, 6, effects);
1090 if (tile == RIVER || tile == REDGE || tile == CHANNEL) {
1311 ToolResult result = bulldozerTool(x, y, effects);
1336 ToolResult result = bulldozerTool(x, y, effects);
1367 result = bulldozerTool(x, y, effects);
1404 case TOOL_RESIDENTIAL:
1409 case TOOL_COMMERCIAL:
1414 case TOOL_INDUSTRIAL:
1419 case TOOL_FIRESTATION:
1424 case TOOL_POLICESTATION:
1433 result =
wireTool(tileX, tileY, &effects);
1436 case TOOL_BULLDOZER:
1437 result = bulldozerTool(tileX, tileY, &effects);
1445 result =
roadTool(tileX, tileY, &effects);
1454 result =
parkTool(tileX, tileY, &effects);
1462 case TOOL_COALPOWER:
1467 case TOOL_NUCLEARPOWER:
1482 result = waterTool(tileX, tileY, &effects);
1486 result =
landTool(tileX, tileY, &effects);
1517 makeSound(
"interface",
"UhUh", tileX <<4, tileY <<4);
1523 makeSound(
"interface",
"Sorry", tileX <<4, tileY <<4);
1539 short fromX,
short fromY,
short toX,
short toY)
1551 short dirX = (toX > fromX) ? 1 : -1;
1552 short dirY = (toY > fromY) ? 1 : -1;
1555 if (fromX == toX && fromY == toY) {
1559 doTool(tool, fromX, fromY);
1562 if (fromX == toX && fromY != toY) {
1564 while (fromY != toY) {
1566 doTool(tool, fromX, fromY);
1575 if (fromX != toX && fromY == toY) {
1577 while (fromX != toX) {
1579 doTool(tool, fromX, fromY);
1594 short numSubsteps =
min(dx, dy);
1596 while (fromX != toX || fromY != toY) {
1597 subX += numSubsteps;
1601 doTool(tool, fromX, fromY);
1604 subY += numSubsteps;
1608 doTool(tool, fromX, fromY);
const int sizeX
Number of tiles in horizontal direction.
const EditingTool tool
Tool needed for making the building.
const int sizeY
Number of tiles in vertical direction.
const bool buildingIsAnimated
Building has animated tiles.
const MapTile baseTile
Tile value at top-left in the map.
DATA worldGet(int x, int y) const
void toolDown(EditingTool tool, short tileX, short tileY)
void doZoneStatus(short mapH, short mapV)
ToolResult buildBuilding(int mapH, int mapV, const BuildingProperties *bprops, ToolEffects *effects)
bool tally(short tileValue)
ToolResult wireTool(short x, short y, ToolEffects *effects)
ToolResult putDownNetwork(short mapH, short mapV, ToolEffects *effects)
MapByte2 crimeRateMap
Crime rate map.
ToolResult networkTool(short x, short y, ToolEffects *effects)
ToolResult railroadTool(short x, short y, ToolEffects *effects)
void checkBorder(short xMap, short yMap, int sizeX, int sizeY, ToolEffects *effects)
ToolResult queryTool(short x, short y)
ToolResult connectTile(short x, short y, ConnectTileCommand cmd, ToolEffects *effects)
short getRandom(short range)
ToolResult putDownLand(short mapH, short mapV, ToolEffects *effects)
ToolResult putDownPark(short mapH, short mapV, ToolEffects *effects)
ToolResult putDownForest(short mapH, short mapV, ToolEffects *effects)
ToolResult parkTool(short x, short y, ToolEffects *effects)
ToolResult prepareBuildingSite(int leftX, int topY, int sizeX, int sizeY, ToolEffects *effects)
short checkSize(short tileValue)
unsigned short * map[WORLD_W]
ToolResult doTool(EditingTool tool, short tileX, short tileY)
void sendMessage(short Mnum, short x=NOWHERE, short y=NOWHERE, bool picture=false, bool important=false)
void makeSound(const std::string &channel, const std::string &sound, int x=-1, int y=-1)
MapByte2 pollutionDensityMap
Pollution density map.
int getDensity(short catNo, short mapH, short mapV)
ToolResult putDownWater(short mapH, short mapV, ToolEffects *effects)
void toolDrag(EditingTool tool, short fromX, short fromY, short toX, short toY)
static bool testBounds(int wx, int wy)
void putRubble(int x, int y, int size, ToolEffects *effects)
ToolResult landTool(short x, short y, ToolEffects *effects)
MapByte2 populationDensityMap
Population density map.
MapByte2 landValueMap
Land value map.
MapShort8 rateOfGrowthMap
void putBuilding(int leftX, int topY, int sizeX, int sizeY, MapTile baseTile, bool aniFlag, ToolEffects *effects)
void smoothTreesAt(int x, int y, bool preserve)
void didTool(std::string name, short x, short y)
ToolResult roadTool(short x, short y, ToolEffects *effects)
void doShowZoneStatus(int tileCategoryIndex, int populationDensityIndex, int landValueIndex, int crimeRateIndex, int pollutionIndex, int growthRateIndex, int x, int y)
Quad totalFunds
Funds of the player.
ToolResult forestTool(short x, short y, ToolEffects *effects)
ToolResult buildBuildingTool(short x, short y, const BuildingProperties *bprops, ToolEffects *effects)
int posY
Vertical coordnate of the position.
int posX
Horizontal coordinate of the position.
Header file for Micropolis game engine.
@ CONNECT_TILE_FIX
Fix zone (connect wire, road, and rail).
@ CONNECT_TILE_ROAD
Lay road and fix zone.
@ CONNECT_TILE_WIRE
Lay wire and fix zone.
@ CONNECT_TILE_RAILROAD
Lay rail and fix zone.
@ CONNECT_TILE_BULLDOZE
Bulldoze and fix zone.
@ LASTPOWERPLANT
Last tile of coal power plant.
@ NUCLEARBASE
First tile nuclear power plant.
@ COALBASE
First tile of coal power plant.
@ FIRESTBASE
First tile of fire station.
@ STADIUMBASE
First tile stadium.
@ LASTZONE
Also last tile nuclear power plant.
@ STADIUM
'Center tile' stadium.
@ NUCLEAR
'Center' tile nuclear power plant.
@ PORTBASE
Top-left tile of the seaport.
@ PORT
Center tile of the seaport.
@ COALSMOKE3
927 last animation tile for chimney at coal power plant (2, 1).
@ POWERPLANT
'Center' tile of coal power plant.
@ RADTILE
Radio-active contaminated tile.
@ INDBASE
Top-left tile of empty industrial zone.
@ COALSMOKE1
919 last animation tile for chimney at coal power plant (2, 0).
@ LASTPORT
Last tile of the seaport.
@ TOOLRESULT_FAILED
Cannot build here.
@ TOOLRESULT_OK
Build succeeded.
@ TOOLRESULT_NEED_BULLDOZE
Clear the area first.
@ TOOLRESULT_NO_MONEY
User has not enough money for tool.
static T min(const T a, const T b)
static T clamp(const T val, const T lower, const T upper)
static T absoluteValue(const T val)
@ STR202_POPULATIONDENSITY_LOW
Low.
@ STR202_LANDVALUE_HIGH_CLASS
High.
@ STR202_GROWRATE_STABLE
Stable.
@ STR202_LANDVALUE_LOWER_CLASS
Lower Class.
@ STR202_LANDVALUE_SLUM
Slum.
@ STR202_GROWRATE_DECLINING
Declining.
@ STR202_LANDVALUE_MIDDLE_CLASS
Middle Class.
@ STR202_GROWRATE_SLOWGROWTH
Slow Growth.
@ STR202_GROWRATE_FASTGROWTH
Fast Growth.
@ STR202_POLLUTION_NONE
None.
@ MESSAGE_BULLDOZE_AREA_FIRST
Area must be bulldozed first.
@ MESSAGE_NOT_ENOUGH_FUNDS
Insufficient funds to build that.