121 callback->didGenerateMap(
this, callbackVal, seed);
154 Position terrainPos(terrainXStart, terrainYStart);
179 for (x = 0; x <
WORLD_W; x++) {
180 for (y = 0; y <
WORLD_H; y++) {
192 for (x = 0; x <
WORLD_W; x++) {
193 for (y = 0; y <
WORLD_H; y++) {
194 if (
map[x][y] > WOODS) {
209 for (x = 0; x <
WORLD_W; x++) {
210 for (y = 0; y <
WORLD_H; y++) {
211 if ((x < 5) || (x >=
WORLD_W - 5) ||
212 (y < 5) || (y >=
WORLD_H - 5)) {
220 for (x = 0; x <
WORLD_W - 5; x += 2) {
232 for (y = 0; y <
WORLD_H - 5; y += 2) {
269 while (numLakes > 0) {
287 while (numPlops > 0) {
322 while (numTrees > 0) {
342 short Amount, x, xloc, yloc;
350 for (x = 0; x < Amount; x++) {
361 void Micropolis::smoothRiver()
363 static short dx[4] = { -1, 0, 1, 0 };
364 static short dy[4] = { 0, 1, 0, -1 };
365 static short REdTab[16] = {
371 short bitIndex, z, xTemp, yTemp;
374 for (x = 0; x <
WORLD_W; x++) {
375 for (y = 0; y <
WORLD_H; y++) {
377 if (
map[x][y] == REDGE) {
380 for (z = 0; z < 4; z++) {
381 bitIndex = bitIndex << 1;
386 (((
map[xTemp][yTemp] &
LOMASK) < WOODS_LOW) ||
387 ((
map[xTemp][yTemp] &
LOMASK) > WOODS_HIGH))) {
392 temp = REdTab[bitIndex & 15];
394 if ((temp != RIVER) &&
406 bool Micropolis::isTree(
MapValue cell)
408 if ((cell &
LOMASK) >= WOODS_LOW && (cell &
LOMASK) <= WOODS_HIGH) {
416 void Micropolis::smoothTrees()
419 for (x = 0; x <
WORLD_W; x++) {
420 for (y = 0; y <
WORLD_H; y++) {
421 if (isTree(
map[x][y])) {
444 static short dx[4] = { -1, 0, 1, 0 };
445 static short dy[4] = { 0, 1, 0, -1 };
446 static const short treeTable[16] = {
459 for (z = 0; z < 4; z++) {
460 bitIndex = bitIndex << 1;
461 int xTemp = x + dx[z];
462 int yTemp = y + dy[z];
469 int temp = treeTable[bitIndex & 15];
495 doBRiver(terrainPos, riverDir, riverDir);
498 terrainDir =
doBRiver(terrainPos, riverDir, riverDir);
501 doSRiver(terrainPos, riverDir, terrainDir);
530 terrainDir = riverDir;
536 terrainDir =
rotate45(terrainDir, 7);
539 pos.
move(terrainDir);
571 terrainDir = riverDir;
577 terrainDir =
rotate45(terrainDir, 7);
580 pos.
move(terrainDir);
608 if (mChar != CHANNEL) {
612 if (temp == CHANNEL) {
616 map[xLoc][yLoc] = mChar;
627 { 0, 0, 0, REDGE, REDGE, REDGE, 0, 0, 0 },
628 { 0, 0, REDGE, RIVER, RIVER, RIVER, REDGE, 0, 0 },
629 { 0, REDGE, RIVER, RIVER, RIVER, RIVER, RIVER, REDGE, 0 },
630 { REDGE, RIVER, RIVER, RIVER, RIVER, RIVER, RIVER, RIVER, REDGE },
631 { REDGE, RIVER, RIVER, RIVER, CHANNEL, RIVER, RIVER, RIVER, REDGE },
632 { REDGE, RIVER, RIVER, RIVER, RIVER, RIVER, RIVER, RIVER, REDGE },
633 { 0, REDGE, RIVER, RIVER, RIVER, RIVER, RIVER, REDGE, 0 },
634 { 0, 0, REDGE, RIVER, RIVER, RIVER, REDGE, 0, 0 },
635 { 0, 0, 0, REDGE, REDGE, REDGE, 0, 0, 0 },
638 for (x = 0; x < 9; x++) {
639 for (y = 0; y < 9; y++) {
654 { 0, 0, REDGE, REDGE, 0, 0 },
655 { 0, REDGE, RIVER, RIVER, REDGE, 0 },
656 { REDGE, RIVER, RIVER, RIVER, RIVER, REDGE },
657 { REDGE, RIVER, RIVER, RIVER, RIVER, REDGE },
658 { 0, REDGE, RIVER, RIVER, REDGE, 0 },
659 { 0, 0, REDGE, REDGE, 0, 0 },
662 for (x = 0; x < 6; x++) {
663 for (y = 0; y < 6; y++) {
670 void Micropolis::smoothWater()
676 for (x = 0; x <
WORLD_W; x++) {
677 for (y = 0; y <
WORLD_H; y++) {
702 for (x = 0; x <
WORLD_W; x++) {
703 for (y = 0; y <
WORLD_H; y++) {
710 bool makeRiver =
true;
734 for (x = 0; x <
WORLD_W; x++) {
735 for (y = 0; y <
WORLD_H; y++) {
740 if (tile >= WOODS_LOW && tile <= WOODS_HIGH) {
750 if (tile == RIVER || tile == CHANNEL) {
void makeSingleLake(const Position &pos)
bool doInitialEval
Need to perform initial city evaluation.
void generateSomeCity(int seed)
void seedRandom(int seed)
void doRivers(const Position &terrainPos)
void putOnMap(MapValue mChar, short xLoc, short yLoc)
Scenario scenario
Scenario being played.
void generateSomeRandomCity()
Direction2 doSRiver(const Position &riverPos, Direction2 riverDir, Direction2 terrainDir)
MapTile getTileFromMap(const Position &pos, Direction2 dir, MapTile defaultTile)
std::string cityFileName
Filename of the last loaded city.
short getRandom(short range)
unsigned short * map[WORLD_W]
void generateMap(int seed)
Direction2 doBRiver(const Position &riverPos, Direction2 riverDir, Direction2 terrainDir)
static bool testBounds(int wx, int wy)
void plopSRiver(const Position &pos)
void treeSplash(short xloc, short yloc)
void smoothTreesAt(int x, int y, bool preserve)
short getERandom(short limit)
void plopBRiver(const Position &pos)
int posY
Vertical coordnate of the position.
int posX
Horizontal coordinate of the position.
bool move(Direction2 dir)
Header file for Micropolis game engine.
@ SC_NONE
No scenario (free playing)
@ WATER_LOW
First water tile.
@ WATER_HIGH
Last water tile (inclusive)
@ TILE_INVALID
Invalid tile (not used in the world map).
static const int ISLAND_RADIUS
static Direction2 rotate45(Direction2 dir, int count=1)
static Direction2 rotate180(Direction2 dir)
@ DIR2_BEGIN
First valid direction.
@ DIR2_END
End-condition for directions.
@ DIR2_NORTH
Direction pointing north.
static Direction2 increment90(Direction2 dir)