(svn r184) -Fix: starting a new game in DesertLandscape crashed the game

This commit is contained in:
truelight 2004-09-08 17:44:29 +00:00
parent de18c544cc
commit 1a0a7ed763

View File

@ -14,7 +14,7 @@ byte _map_owner[TILES_X * TILES_Y];
byte _map2[TILES_X * TILES_Y]; byte _map2[TILES_X * TILES_Y];
byte _map_extra_bits[TILES_X * TILES_Y/4]; byte _map_extra_bits[TILES_X * TILES_Y/4];
extern const TileTypeProcs extern const TileTypeProcs
_tile_type_clear_procs, _tile_type_clear_procs,
_tile_type_rail_procs, _tile_type_rail_procs,
_tile_type_road_procs, _tile_type_road_procs,
@ -67,7 +67,7 @@ uint GetTileSlope(uint tile, int *h)
if (min >= c) min = c; if (min >= c) min = c;
d = _map_type_and_height[tile+TILE_XY(1,1)] & 0xF; d = _map_type_and_height[tile+TILE_XY(1,1)] & 0xF;
if (min >= d) min = d; if (min >= d) min = d;
r = 0; r = 0;
if ((a-=min)!=0) { r += (--a << 4) + 8; } if ((a-=min)!=0) { r += (--a << 4) + 8; }
if ((c-=min)!=0) { r += (--c << 4) + 4; } if ((c-=min)!=0) { r += (--c << 4) + 4; }
@ -136,7 +136,7 @@ uint GetPartialZ(int x, int y, int corners)
if (x - y >= 0) if (x - y >= 0)
z = (x - y) >> 1; z = (x - y) >> 1;
break; break;
case 2: case 2:
y^=0xF; y^=0xF;
if ( (x - y) >= 0) if ( (x - y) >= 0)
@ -213,7 +213,7 @@ uint GetPartialZ(int x, int y, int corners)
case 29: case 29:
z = 1 + (((x^0xF)+(y^0xF))>>1); z = 1 + (((x^0xF)+(y^0xF))>>1);
break; break;
case 30: case 30:
z = 1 + (((x^0xF)+(y^0xF))>>1); z = 1 + (((x^0xF)+(y^0xF))>>1);
break; break;
@ -270,7 +270,7 @@ void DrawFoundation(TileInfo *ti, uint f)
if(hasFoundation( &ti2, false )) sprite_base += 22*2; // foundation in NE direction if(hasFoundation( &ti2, false )) sprite_base += 22*2; // foundation in NE direction
if (f < 15) { if (f < 15) {
// leveled foundation // leveled foundation
if( sprite_base < SPR_SLOPES_BASE ) sprite_base = 990; // use original slope sprites if( sprite_base < SPR_SLOPES_BASE ) sprite_base = 990; // use original slope sprites
AddSortableSpriteToDraw(f-1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z); AddSortableSpriteToDraw(f-1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z);
@ -280,12 +280,12 @@ void DrawFoundation(TileInfo *ti, uint f)
} else { } else {
// inclined foundation // inclined foundation
sprite_base += 14; sprite_base += 14;
AddSortableSpriteToDraw( AddSortableSpriteToDraw(
HASBIT( (1<<1) | (1<<2) | (1<<4) | (1<<8), ti->tileh) ? sprite_base + (f - 15) : ti->tileh + 0x3DE - 1, HASBIT( (1<<1) | (1<<2) | (1<<4) | (1<<8), ti->tileh) ? sprite_base + (f - 15) : ti->tileh + 0x3DE - 1,
ti->x, ti->y, 1, 1, 1, ti->z ti->x, ti->y, 1, 1, 1, ti->z
); );
ti->tileh = _inclined_tileh[f - 15]; ti->tileh = _inclined_tileh[f - 15];
OffsetGroundSprite(31, 9); OffsetGroundSprite(31, 9);
} }
@ -380,7 +380,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
_additional_cash_required = ret; _additional_cash_required = ret;
return cost - ret; return cost - ret;
} }
DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags, CMD_LANDSCAPE_CLEAR); DoCommandByTile(TILE_FROM_XY(x,y), 0, 0, flags, CMD_LANDSCAPE_CLEAR);
// draw explosion animation... // draw explosion animation...
if ((x==sx || x==ex) && (y==sy || y==ey)) { if ((x==sx || x==ex) && (y==sy || y==ey)) {
@ -547,7 +547,7 @@ static void GenerateTerrain(int type, int flag)
w = p[2]; w = p[2];
h = p[1]; h = p[1];
if (direction & 1) { w = p[1]; h = p[2]; } if (direction & 1) { w = p[1]; h = p[2]; }
p += 8; p += 8;
if (flag & 4) { if (flag & 4) {
if (!(flag & 2)) { if (!(flag & 2)) {
@ -644,10 +644,10 @@ static void CreateDesertOrRainForest()
SetMapExtraBits(tile, 1); SetMapExtraBits(tile, 1);
break; break;
} }
mt = _map_type_and_height[tile + i]; mt = _map_type_and_height[TILE_MASK(tile + i)];
} while ((mt & 0xC) == 0 && (mt >> 4) != MP_WATER); } while ((mt & 0xC) == 0 && (mt >> 4) != MP_WATER);
} while (++tile != TILES_X*TILES_Y); } while (++tile != TILES_X*TILES_Y);
for(i=0; i!=256; i++) for(i=0; i!=256; i++)
RunTileLoop(); RunTileLoop();
@ -659,7 +659,7 @@ static void CreateDesertOrRainForest()
SetMapExtraBits(tile, 2); SetMapExtraBits(tile, 2);
break; break;
} }
} while ( !IS_TILETYPE(tile+i, MP_CLEAR) || (_map5[tile + i]&0x1C) != 0x14); } while ( !IS_TILETYPE(TILE_MASK(tile+i), MP_CLEAR) || (_map5[TILE_MASK(tile + i)]&0x1C) != 0x14);
} while (++tile != TILES_X*TILES_Y); } while (++tile != TILES_X*TILES_Y);
} }
@ -667,13 +667,13 @@ void GenerateLandscape()
{ {
int i,flag; int i,flag;
uint32 r; uint32 r;
if (_opt.landscape == LT_HILLY) { if (_opt.landscape == LT_HILLY) {
i = ((Random() & 0x7F) + 950) * LANDSCAPE_SIZE_FACTOR; i = ((Random() & 0x7F) + 950) * LANDSCAPE_SIZE_FACTOR;
do { do {
GenerateTerrain(2, 0); GenerateTerrain(2, 0);
} while (--i); } while (--i);
r = Random(); r = Random();
flag = (r & 3) | 4; flag = (r & 3) | 4;
i = (((r >> 16) & 0x7F) + 450) * LANDSCAPE_SIZE_FACTOR; i = (((r >> 16) & 0x7F) + 450) * LANDSCAPE_SIZE_FACTOR;
@ -685,7 +685,7 @@ void GenerateLandscape()
do { do {
GenerateTerrain(0, 0); GenerateTerrain(0, 0);
} while (--i); } while (--i);
r = Random(); r = Random();
flag = (r & 3) | 4; flag = (r & 3) | 4;
i = (((r >> 16) & 0xFF) + 1700) * LANDSCAPE_SIZE_FACTOR; i = (((r >> 16) & 0xFF) + 1700) * LANDSCAPE_SIZE_FACTOR;
@ -697,7 +697,7 @@ void GenerateLandscape()
i = ((Random() & 0x7F) + 410) * LANDSCAPE_SIZE_FACTOR; i = ((Random() & 0x7F) + 410) * LANDSCAPE_SIZE_FACTOR;
do { do {
GenerateTerrain(3, flag); GenerateTerrain(3, flag);
} while (--i); } while (--i);
} else { } else {
i = ((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes)*256 + 100) * LANDSCAPE_SIZE_FACTOR; i = ((Random() & 0x7F) + (3 - _opt.diff.quantity_sea_lakes)*256 + 100) * LANDSCAPE_SIZE_FACTOR;
@ -753,7 +753,7 @@ uint TileAddWrap(TileIndex tile, int addx, int addy)
int x, y; int x, y;
x = GET_TILE_X(tile) + addx; x = GET_TILE_X(tile) + addx;
y = GET_TILE_Y(tile) + addy; y = GET_TILE_Y(tile) + addy;
// Are we about to wrap? // Are we about to wrap?
if (x > 0 && x < TILE_X_MAX && y > 0 && y < TILE_Y_MAX) if (x > 0 && x < TILE_X_MAX && y > 0 && y < TILE_Y_MAX)
return tile + TILE_XY(addx, addy); return tile + TILE_XY(addx, addy);