Micropolis
tool.cpp File Reference

Implements tool actions and effects for Micropolis game. More...

#include "micropolis.h"

Go to the source code of this file.

Functions

static short checkBigZone (MapTile id, short *deltaHPtr, short *deltaVPtr)
 

Variables

static const short gCostOf []
 
static const short gToolSize []
 
static short idArray [29]
 
static const BuildingProperties residentialZoneBuilding
 
static const BuildingProperties commercialZoneBuilding
 
static const BuildingProperties industrialZoneBuilding
 
static const BuildingProperties policeStationBuilding
 
static const BuildingProperties fireStationBuilding
 
static const BuildingProperties stadiumBuilding
 
static const BuildingProperties coalPowerBuilding
 
static const BuildingProperties nuclearPowerBuilding
 
static const BuildingProperties seaportBuilding
 
static const BuildingProperties airportBuilding
 

Detailed Description

Implements tool actions and effects for Micropolis game.

This file defines the behavior and effects of various tools (like bulldozer, road construction, zone creation) used in Micropolis. It includes functions for handling tool actions, applying their effects to the game world, and managing the cost and consequences of these actions. The file also contains logic for specific tools such as query, wire, park, land alteration, and various zone constructions (residential, commercial, industrial, etc.).

Definition in file tool.cpp.

Function Documentation

◆ checkBigZone()

static short checkBigZone ( MapTile  id,
short *  deltaHPtr,
short *  deltaVPtr 
)
static

Compute where the 'center' (at (1,1)) of the zone is, depending on where the user clicked.

Only inner tiles are recognized, and possibly not even complete (ie stadium while game is playing).

Parameters
idTile character value of the tile that the user clicked on.
deltaHPtrPointer where horizontal position correction is written to.
deltaVPtrPointer where vertical position correction is written to.
Returns
Size of the zone clicked at (or 0 if clicked outside zone).
Todo:
Make this table driven.

Definition at line 402 of file tool.cpp.

References COALSMOKE3, NUCLEAR, PORT, POWERPLANT, and STADIUM.

Referenced by Micropolis::bulldozerTool().

Variable Documentation

◆ airportBuilding

const BuildingProperties airportBuilding
static
Initial value:
=
BuildingProperties(6, 6, AIRPORTBASE, TOOL_AIRPORT, "Airp", false)

Building properties of a airport.

Definition at line 1278 of file tool.cpp.

◆ coalPowerBuilding

const BuildingProperties coalPowerBuilding
static
Initial value:
=
BuildingProperties(4, 4, COALBASE, TOOL_COALPOWER, "Coal", false)
@ COALBASE
First tile of coal power plant.
Definition: micropolis.h:579

Building properties of a coal power station.

Definition at line 1266 of file tool.cpp.

◆ commercialZoneBuilding

const BuildingProperties commercialZoneBuilding
static
Initial value:
=
BuildingProperties(3, 3, COMBASE, TOOL_COMMERCIAL, "Com", false)

Building properties of a commercial zone.

Definition at line 1246 of file tool.cpp.

◆ fireStationBuilding

const BuildingProperties fireStationBuilding
static
Initial value:
=
BuildingProperties(3, 3, FIRESTBASE, TOOL_FIRESTATION, "Fire", false)
@ FIRESTBASE
First tile of fire station.
Definition: micropolis.h:584

Building properties of a fire station.

Definition at line 1258 of file tool.cpp.

◆ gCostOf

const short gCostOf[]
static
Initial value:
= {
100, 100, 100, 500,
500, 0, 5, 1,
20, 10, 5000, 10,
3000, 3000, 5000, 10000,
100, 0, 0, 0,
0,
}

Cost of each tool. Maybe move this information to eg BuildingProperties?

Definition at line 216 of file tool.cpp.

Referenced by Micropolis::buildBuilding(), Micropolis::bulldozerTool(), Micropolis::prepareBuildingSite(), Micropolis::putDownLand(), and Micropolis::putDownNetwork().

◆ gToolSize

const short gToolSize[]
static
Initial value:
= {
3, 3, 3, 3,
3, 1, 1, 1,
1, 1, 4, 1,
4, 4, 4, 6,
1, 1, 1, 1,
0,
}

Size of each tool.

Note
Actually it is the size of the building rather than the tool.
Todo:
This information is duplicated in the BuildingProperties at least.

Definition at line 230 of file tool.cpp.

Referenced by Micropolis::toolDrag().

◆ idArray

short idArray[29]
static
Initial value:
= {
DIRT, RIVER, TREEBASE, RUBBLE,
FLOOD, RADTILE, FIRE, ROADBASE,
POWERBASE, RAILBASE, RESBASE, COMBASE,
INDBASE, PORTBASE, AIRPORTBASE, COALBASE,
HBRDG0, RADAR0, FOUNTAIN, INDBASE2,
FOOTBALLGAME1, VBRDG0, 952, 956,
9999,
}
@ NUCLEARBASE
First tile nuclear power plant.
Definition: micropolis.h:603
@ STADIUMBASE
First tile stadium.
Definition: micropolis.h:594
@ PORTBASE
Top-left tile of the seaport.
Definition: micropolis.h:567
@ RADTILE
Radio-active contaminated tile.
Definition: micropolis.h:415
@ DIRT
Clear tile.
Definition: micropolis.h:382
@ INDBASE
Top-left tile of empty industrial zone.
Definition: micropolis.h:536

Definition at line 743 of file tool.cpp.

◆ industrialZoneBuilding

const BuildingProperties industrialZoneBuilding
static
Initial value:
=
BuildingProperties(3, 3, INDBASE, TOOL_INDUSTRIAL, "Ind", false)

Building properties of a industrial zone.

Definition at line 1250 of file tool.cpp.

◆ nuclearPowerBuilding

const BuildingProperties nuclearPowerBuilding
static
Initial value:
=
BuildingProperties(4, 4, NUCLEARBASE, TOOL_NUCLEARPOWER, "Nuc", true)

Building properties of a nuclear power station.

Definition at line 1270 of file tool.cpp.

◆ policeStationBuilding

const BuildingProperties policeStationBuilding
static
Initial value:
=
BuildingProperties(3, 3, POLICESTBASE, TOOL_POLICESTATION, "Pol", false)

Building properties of a police station.

Definition at line 1254 of file tool.cpp.

◆ residentialZoneBuilding

const BuildingProperties residentialZoneBuilding
static
Initial value:
=
BuildingProperties(3, 3, RESBASE, TOOL_RESIDENTIAL, "Res", false)

Building properties of a residential zone.

Definition at line 1242 of file tool.cpp.

◆ seaportBuilding

const BuildingProperties seaportBuilding
static
Initial value:
=
BuildingProperties(4, 4, PORTBASE, TOOL_SEAPORT, "Seap", false)

Building properties of a seaport.

Definition at line 1274 of file tool.cpp.

◆ stadiumBuilding

const BuildingProperties stadiumBuilding
static
Initial value:
=
BuildingProperties(4, 4, STADIUMBASE, TOOL_STADIUM, "Stad", false)

Building properties of a stadium.

Definition at line 1262 of file tool.cpp.