unmovable_cmd.c
changeset 1489 ce8d086d677b
parent 1335 a635854c23b6
child 1493 ea21c3f7feea
equal deleted inserted replaced
1488:cf51e91f3b98 1489:ce8d086d677b
   286 restart:
   286 restart:
   287 		r = Random();
   287 		r = Random();
   288 		dir = r >> 30;
   288 		dir = r >> 30;
   289 		r %= (dir == 0 || dir == 2) ? MapMaxY() : MapMaxX();
   289 		r %= (dir == 0 || dir == 2) ? MapMaxY() : MapMaxX();
   290 		tile =
   290 		tile =
   291           (dir==0)?TILE_XY(0,r):0 +             // left
   291 			(dir==0)?TILE_XY(0,r):0 +             // left
   292           (dir==1)?TILE_XY(r,0):0 +             // top
   292 			(dir==1)?TILE_XY(r,0):0 +             // top
   293 			(dir == 2) ? TILE_XY(MapMaxX(), r) : 0 + // right
   293 			(dir == 2) ? TILE_XY(MapMaxX(), r) : 0 + // right
   294 			(dir == 3) ? TILE_XY(r, MapMaxY()) : 0;  // bottom
   294 			(dir == 3) ? TILE_XY(r, MapMaxY()) : 0;  // bottom
   295 		j = 20;
   295 		j = 20;
   296 		do {
   296 		do {
   297 			if (--j == 0)
   297 			if (--j == 0)
   307 	} while (--i);
   307 	} while (--i);
   308 }
   308 }
   309 
   309 
   310 extern int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
   310 extern int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
   311 
   311 
   312 /* p1				= relocate HQ
   312 /* p1      = relocate HQ
   313 	 p1&0xFF	= player whose HQ is up for relocation
   313  * p1&0xFF = player whose HQ is up for relocation
   314 */
   314  */
   315 int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   315 int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   316 {
   316 {
   317 	TileIndex tile = TILE_FROM_XY(x,y);
   317 	TileIndex tile = TILE_FROM_XY(x,y);
   318 	Player *p = DEREF_PLAYER(_current_player);
   318 	Player *p = DEREF_PLAYER(_current_player);
   319 	int score;
   319 	int score;
   320 	int32 cost = 0;
   320 	int32 cost = 0;
   321 
   321 
   322 	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
   322 	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
   323 
   323 
   324   cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
   324 	cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
   325 
   325 
   326 	if (cost == CMD_ERROR)
   326 	if (cost == CMD_ERROR)
   327 		return CMD_ERROR;
   327 		return CMD_ERROR;
   328 
   328 
   329 	if (p1) {
   329 	if (p1) {
   415 		DoClearSquare(tile);
   415 		DoClearSquare(tile);
   416 	}
   416 	}
   417 }
   417 }
   418 
   418 
   419 const TileTypeProcs _tile_type_unmovable_procs = {
   419 const TileTypeProcs _tile_type_unmovable_procs = {
   420 	DrawTile_Unmovable,						/* draw_tile_proc */
   420         DrawTile_Unmovable,             /* draw_tile_proc */
   421 	GetSlopeZ_Unmovable,					/* get_slope_z_proc */
   421         GetSlopeZ_Unmovable,            /* get_slope_z_proc */
   422 	ClearTile_Unmovable,					/* clear_tile_proc */
   422         ClearTile_Unmovable,            /* clear_tile_proc */
   423 	GetAcceptedCargo_Unmovable,		/* get_accepted_cargo_proc */
   423         GetAcceptedCargo_Unmovable,     /* get_accepted_cargo_proc */
   424 	GetTileDesc_Unmovable,				/* get_tile_desc_proc */
   424         GetTileDesc_Unmovable,          /* get_tile_desc_proc */
   425 	GetTileTrackStatus_Unmovable,	/* get_tile_track_status_proc */
   425         GetTileTrackStatus_Unmovable,   /* get_tile_track_status_proc */
   426 	ClickTile_Unmovable,					/* click_tile_proc */
   426         ClickTile_Unmovable,            /* click_tile_proc */
   427 	AnimateTile_Unmovable,				/* animate_tile_proc */
   427         AnimateTile_Unmovable,          /* animate_tile_proc */
   428 	TileLoop_Unmovable,						/* tile_loop_clear */
   428         TileLoop_Unmovable,             /* tile_loop_clear */
   429 	ChangeTileOwner_Unmovable,		/* change_tile_owner_clear */
   429         ChangeTileOwner_Unmovable,      /* change_tile_owner_clear */
   430 	NULL,													/* get_produced_cargo_proc */
   430         NULL,                           /* get_produced_cargo_proc */
   431 	NULL,													/* vehicle_enter_tile_proc */
   431         NULL,                           /* vehicle_enter_tile_proc */
   432 	NULL,													/* vehicle_leave_tile_proc */
   432         NULL,                           /* vehicle_leave_tile_proc */
   433 	GetSlopeTileh_Unmovable,			/* get_slope_tileh_proc */
   433         GetSlopeTileh_Unmovable,        /* get_slope_tileh_proc */
   434 };
   434 };