175 if (tile >= ROADBASE && tile < POWERBASE) {
181 traffic =
min(traffic, 240);
185 if (traffic >= 240 &&
getRandom(5) == 0) {
192 if (sprite != NULL && sprite->control == -1) {
242 static const short PerimX[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2};
243 static const short PerimY[12] = {-2,-2,-2,-1, 0, 1, 2, 2, 2, 1, 0,-1};
246 for (
short z = 0; z < 12; z++) {
248 tx = pos->
posX + PerimX[z];
249 ty = pos->
posY + PerimY[z];
277 static const short PerimX[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2};
278 static const short PerimY[12] = {-2,-2,-2,-1, 0, 1, 2, 2, 2, 1, 0,-1};
281 for (
short z = 0; z < 12; z++) {
283 tx = pos.
posX + PerimX[z];
284 ty = pos.
posX + PerimY[z];
289 if (tile >= TELEBASE && tile <= TELELAST) {
363 for (
int i = 0; i < 4; i++) {
382 for (
int i = 0; i < 4; i++) {
384 return directions[i];
394 return directions[i];
457 static const MapTile targetLow[3] = {COMBASE, LHTHR, LHTHR};
463 MapTile l = targetLow[destZone];
464 MapTile h = targetHigh[destZone];
468 if (z >= l && z <= h) {
475 if (z >= l && z <= h) {
482 if (z >= l && z <= h) {
489 if (z >= l && z <= h) {
507 if (tile < ROADBASE || tile > LASTRAIL) {
511 if (tile >= POWERBASE && tile < LASTPOWER) {
DATA worldGet(int x, int y) const
void worldSet(int x, int y, DATA val)
bool driveDone(const Position &pos, ZoneType destZone)
bool findPerimeterTelecom(const Position &pos)
bool tryDrive(const Position &startPos, ZoneType destZone)
void pushPos(const Position &pos)
MapTile getTileFromMap(const Position &pos, Direction2 dir, MapTile defaultTile)
short makeTraffic(int x, int y, ZoneType dest)
short getRandom(short range)
Position curMapStackXY[MAX_TRAFFIC_DISTANCE+1]
Position stack.
short trafMaxY
Y coordinate of a position with heavy traffic.
short trafMaxX
X coordinate of a position with heavy traffic.
SimSprite * getSprite(int type)
unsigned short * map[WORLD_W]
short makeTrafficAt(int x, int y, ZoneType dest)
Direction2 tryGo(const Position &pos, Direction2 dirLast)
MapByte2 trafficDensityMap
Traffic density map.
static bool testBounds(int wx, int wy)
void addToTrafficDensityMap()
bool roadTest(MapValue tile)
bool findPerimeterRoad(Position *pos)
int posY
Vertical coordnate of the position.
int posX
Horizontal coordinate of the position.
bool move(Direction2 dir)
int destX
Destination X coordinate of the sprite.
int destY
Destination Y coordinate of the sprite.
Header file for Micropolis game engine.
@ ZT_NUM_DESTINATIONS
Number of available zones.
@ NUCLEAR
'Center' tile nuclear power plant.
@ PORT
Center tile of the seaport.
static T min(const T a, const T b)
@ SPRITE_HELICOPTER
Helicopter sprite.
static const int MAX_TRAFFIC_DISTANCE
static Direction2 rotate180(Direction2 dir)
@ DIR2_WEST
Direction pointing west.
@ DIR2_INVALID
Invalid direction.
@ DIR2_SOUTH
Direction pointing south.
@ DIR2_EAST
Direction pointing east.
@ DIR2_NORTH
Direction pointing north.
static Direction2 rotate90(Direction2 dir)