town_cmd.c
changeset 2360 4e4ebe18e448
parent 2238 33361a216301
child 2425 e755ee29133a
equal deleted inserted replaced
2359:ff4f2e95cfc9 2360:4e4ebe18e448
    76 #include "table/town_land.h"
    76 #include "table/town_land.h"
    77 
    77 
    78 
    78 
    79 static void TownDrawHouseLift(TileInfo *ti)
    79 static void TownDrawHouseLift(TileInfo *ti)
    80 {
    80 {
    81 	AddChildSpriteScreen(0x5A3, 0xE, 0x3C - (_m[ti->tile].owner&0x7F));
    81 	AddChildSpriteScreen(0x5A3, 0xE, 0x3C - (_m[ti->tile].m1 & 0x7F));
    82 }
    82 }
    83 
    83 
    84 typedef void TownDrawTileProc(TileInfo *ti);
    84 typedef void TownDrawTileProc(TileInfo *ti);
    85 static TownDrawTileProc * const _town_draw_tile_procs[1] = {
    85 static TownDrawTileProc * const _town_draw_tile_procs[1] = {
    86 	TownDrawHouseLift
    86 	TownDrawHouseLift
   171 	if (!(_housetype_extra_flags[_m[tile].m4] & 0x20)) {
   171 	if (!(_housetype_extra_flags[_m[tile].m4] & 0x20)) {
   172 		DeleteAnimatedTile(tile);
   172 		DeleteAnimatedTile(tile);
   173 		return;
   173 		return;
   174 	}
   174 	}
   175 
   175 
   176 	if (!((old=_m[tile].owner)&0x80)) {
   176 	if (!((old = _m[tile].m1) & 0x80)) {
   177 		_m[tile].owner |= 0x80;
   177 		_m[tile].m1 |= 0x80;
   178 
   178 
   179 		do {
   179 		do {
   180 			i = (Random()&7) - 1;
   180 			i = (Random()&7) - 1;
   181 		} while (i < 0 || i == 1 || i*6==old);
   181 		} while (i < 0 || i == 1 || i*6==old);
   182 
   182 
   183 		SB(_m[tile].m5, 0, 6, i);
   183 		SB(_m[tile].m5, 0, 6, i);
   184 	}
   184 	}
   185 
   185 
   186 	a = _m[tile].owner&0x7F;
   186 	a = _m[tile].m1 & 0x7F;
   187 	b = (_m[tile].m5&0x3F) * 6;
   187 	b = (_m[tile].m5&0x3F) * 6;
   188 	a += (a < b) ? 1 : -1;
   188 	a += (a < b) ? 1 : -1;
   189 	_m[tile].owner = (_m[tile].owner&0x80)|a;
   189 	_m[tile].m1 = (_m[tile].m1 & 0x80) | a;
   190 
   190 
   191 	if (a == b) {
   191 	if (a == b) {
       
   192 		_m[tile].m1 &= 0x7F;
   192 		_m[tile].m5 &= 0x40;
   193 		_m[tile].m5 &= 0x40;
   193 		_m[tile].owner &= 0x7F;
       
   194 		DeleteAnimatedTile(tile);
   194 		DeleteAnimatedTile(tile);
   195 	}
   195 	}
   196 
   196 
   197 	MarkTileDirtyByTile(tile);
   197 	MarkTileDirtyByTile(tile);
   198 }
   198 }