src/station_cmd.cpp
branchgamebalance
changeset 9910 0b2aebc8283e
parent 9909 dce9a6923bb7
child 9911 0b8b245a2391
equal deleted inserted replaced
9909:dce9a6923bb7 9910:0b2aebc8283e
   197 
   197 
   198 	{
   198 	{
   199 		Station *s;
   199 		Station *s;
   200 
   200 
   201 		FOR_ALL_STATIONS(s) {
   201 		FOR_ALL_STATIONS(s) {
   202 			if (s != st && s->town==t) {
   202 			if (s != st && s->town == t) {
   203 				uint str = M(s->string_id);
   203 				uint str = M(s->string_id);
   204 				if (str <= 0x20) {
   204 				if (str <= 0x20) {
   205 					if (str == M(STR_SV_STNAME_FOREST))
   205 					if (str == M(STR_SV_STNAME_FOREST))
   206 						str = M(STR_SV_STNAME_WOODS);
   206 						str = M(STR_SV_STNAME_WOODS);
   207 					CLRBIT(free_names, str);
   207 					CLRBIT(free_names, str);
   228 			goto done;
   228 			goto done;
   229 		}
   229 		}
   230 	}
   230 	}
   231 
   231 
   232 	/* check close enough to town to get central as name? */
   232 	/* check close enough to town to get central as name? */
   233 	if (DistanceMax(tile,t->xy) < 8) {
   233 	if (DistanceMax(tile, t->xy) < 8) {
   234 		found = M(STR_SV_STNAME);
   234 		found = M(STR_SV_STNAME);
   235 		if (HASBIT(free_names, M(STR_SV_STNAME))) goto done;
   235 		if (HASBIT(free_names, M(STR_SV_STNAME))) goto done;
   236 
   236 
   237 		found = M(STR_SV_STNAME_CENTRAL);
   237 		found = M(STR_SV_STNAME_CENTRAL);
   238 		if (HASBIT(free_names, M(STR_SV_STNAME_CENTRAL))) goto done;
   238 		if (HASBIT(free_names, M(STR_SV_STNAME_CENTRAL))) goto done;
   270 	}
   270 	}
   271 
   271 
   272 	/* check direction compared to town */
   272 	/* check direction compared to town */
   273 	{
   273 	{
   274 		static const int8 _direction_and_table[] = {
   274 		static const int8 _direction_and_table[] = {
   275 			~( (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
   275 			~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
   276 			~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
   276 			~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
   277 			~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ),
   277 			~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
   278 			~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) ),
   278 			~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
   279 		};
   279 		};
   280 
   280 
   281 		free_names &= _direction_and_table[
   281 		free_names &= _direction_and_table[
   282 			(TileX(tile) < TileX(t->xy)) +
   282 			(TileX(tile) < TileX(t->xy)) +
   283 			(TileY(tile) < TileY(t->xy)) * 2];
   283 			(TileY(tile) < TileY(t->xy)) * 2];
   284 	}
   284 	}
   285 
   285 
   286 	tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30));
   286 	tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
   287 	if (tmp == 0) {
   287 	if (tmp == 0) {
   288 		_error_message = STR_3007_TOO_MANY_STATIONS_LOADING;
   288 		_error_message = STR_3007_TOO_MANY_STATIONS_LOADING;
   289 		return false;
   289 		return false;
   290 	}
   290 	}
   291 	found = FindFirstBit(tmp);
   291 	found = FindFirstBit(tmp);
   366 	for (uint i = 0; i < num_items; i++) {
   366 	for (uint i = 0; i < num_items; i++) {
   367 		SetDParam(i + 1, GetCargo(cargo[i])->name);
   367 		SetDParam(i + 1, GetCargo(cargo[i])->name);
   368 	}
   368 	}
   369 
   369 
   370 	SetDParam(0, st->index);
   370 	SetDParam(0, st->index);
   371 	AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
   371 	AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
   372 }
   372 }
   373 
   373 
   374 // Get a list of the cargo types being produced around the tile.
   374 // Get a list of the cargo types being produced around the tile.
   375 void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile,
   375 void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile,
   376 	int w, int h, int rad)
   376 	int w, int h, int rad)
   644 		}
   644 		}
   645 
   645 
   646 		int flat_z = z;
   646 		int flat_z = z;
   647 		if (tileh != SLOPE_FLAT) {
   647 		if (tileh != SLOPE_FLAT) {
   648 			// need to check so the entrance to the station is not pointing at a slope.
   648 			// need to check so the entrance to the station is not pointing at a slope.
   649 			if ((invalid_dirs&1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
   649 			if ((invalid_dirs & 1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
   650 					(invalid_dirs&2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
   650 					(invalid_dirs & 2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
   651 					(invalid_dirs&4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
   651 					(invalid_dirs & 4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
   652 					(invalid_dirs&8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
   652 					(invalid_dirs & 8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
   653 				return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   653 				return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   654 			}
   654 			}
   655 			cost += _eco->GetPrice(CEconomy::TERRAFORM);
   655 			cost += _eco->GetPrice(CEconomy::TERRAFORM);
   656 			flat_z += TILE_HEIGHT;
   656 			flat_z += TILE_HEIGHT;
   657 		}
   657 		}
   746 
   746 
   747 static inline byte *CreateSingle(byte *layout, int n)
   747 static inline byte *CreateSingle(byte *layout, int n)
   748 {
   748 {
   749 	int i = n;
   749 	int i = n;
   750 	do *layout++ = 0; while (--i);
   750 	do *layout++ = 0; while (--i);
   751 	layout[((n-1) >> 1)-n] = 2;
   751 	layout[((n - 1) >> 1) - n] = 2;
   752 	return layout;
   752 	return layout;
   753 }
   753 }
   754 
   754 
   755 static inline byte *CreateMulti(byte *layout, int n, byte b)
   755 static inline byte *CreateMulti(byte *layout, int n, byte b)
   756 {
   756 {
   757 	int i = n;
   757 	int i = n;
   758 	do *layout++ = b; while (--i);
   758 	do *layout++ = b; while (--i);
   759 	if (n > 4) {
   759 	if (n > 4) {
   760 		layout[0-n] = 0;
   760 		layout[0 - n] = 0;
   761 		layout[n-1-n] = 0;
   761 		layout[n - 1 - n] = 0;
   762 	}
   762 	}
   763 	return layout;
   763 	return layout;
   764 }
   764 }
   765 
   765 
   766 static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec)
   766 static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec)
  1621 
  1621 
  1622 		if (flags & DC_EXEC) {
  1622 		if (flags & DC_EXEC) {
  1623 			DeleteAnimatedTile(tile_cur);
  1623 			DeleteAnimatedTile(tile_cur);
  1624 			DoClearSquare(tile_cur);
  1624 			DoClearSquare(tile_cur);
  1625 		}
  1625 		}
  1626 	} END_TILE_LOOP(tile_cur, w,h,tile)
  1626 	} END_TILE_LOOP(tile_cur, w, h, tile)
  1627 
  1627 
  1628 	if (flags & DC_EXEC) {
  1628 	if (flags & DC_EXEC) {
  1629 		for (uint i = 0; i < afc->nof_depots; ++i) {
  1629 		for (uint i = 0; i < afc->nof_depots; ++i) {
  1630 			DeleteWindowById(
  1630 			DeleteWindowById(
  1631 				WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i])
  1631 				WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i])
  2793 	/* Used by newstations for graphic variations */
  2793 	/* Used by newstations for graphic variations */
  2794 	SLE_CONDVAR(Station, random_bits,                SLE_UINT16,                 27, SL_MAX_VERSION),
  2794 	SLE_CONDVAR(Station, random_bits,                SLE_UINT16,                 27, SL_MAX_VERSION),
  2795 	SLE_CONDVAR(Station, waiting_triggers,           SLE_UINT8,                  27, SL_MAX_VERSION),
  2795 	SLE_CONDVAR(Station, waiting_triggers,           SLE_UINT8,                  27, SL_MAX_VERSION),
  2796 	SLE_CONDVAR(Station, num_specs,                  SLE_UINT8,                  27, SL_MAX_VERSION),
  2796 	SLE_CONDVAR(Station, num_specs,                  SLE_UINT8,                  27, SL_MAX_VERSION),
  2797 
  2797 
       
  2798 	SLE_CONDLST(Station, loading_vehicles,           REF_VEHICLE,                57, SL_MAX_VERSION),
       
  2799 
  2798 	// reserve extra space in savegame here. (currently 32 bytes)
  2800 	// reserve extra space in savegame here. (currently 32 bytes)
  2799 	SLE_CONDNULL(32, 2, SL_MAX_VERSION),
  2801 	SLE_CONDNULL(32, 2, SL_MAX_VERSION),
  2800 
  2802 
  2801 	SLE_END()
  2803 	SLE_END()
  2802 };
  2804 };