--- a/src/station_cmd.cpp Sun Aug 12 18:32:47 2007 +0000
+++ b/src/station_cmd.cpp Sun Aug 12 21:28:34 2007 +0000
@@ -1529,21 +1529,6 @@
return ret;
}
-void GetFSMportsLayout(byte *layout, int width, int length, const FSMportsSpec *fsmportspec, byte set)
-{
- if (fsmportspec != NULL) {
- /* Custom layout defined, follow it. */
- memcpy(layout, fsmportspec->layouts[set],
- (length * width) + 2); // width*length sprites, plus orientation byte, and preview minipic sprite
- return;
- }
-
- while (--width >= 0) {
- layout = CreateMulti(layout, length, 4);
- layout = CreateMulti(layout, length, 6);
- }
-}
-
/** Place an Airport.
* @param tile tile where airport will be built
* @param flags operation to perform
@@ -1671,14 +1656,11 @@
* the tiles have the correct land/water statuses.
*/
if (fsmportsspec->layout_mask != NULL) {
- byte *mask_ptr;
- byte mask;
- mask_ptr = (byte*)alloca((w * h) + 2);
- memcpy(mask_ptr, fsmportsspec->layout_mask[layout_set], (w * h) + 2); // width*length flagbytes, plus orientation byte
+ const byte *mask_ptr = fsmportsspec->layout_mask[layout_set]; // width*length flagbytes, plus orientation byte
mask_ptr++; //skip orientation
mask_ptr++; //skip 0x00
BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
- mask = *mask_ptr++;
+ byte mask = *mask_ptr++;
if (mask & 0x80) {
/* do water tests */
if (IsTileType(tile_cur, MP_WATER) && IsClearWaterTile(tile_cur)) {
@@ -1708,8 +1690,7 @@
cost.AddCost(_price.build_airport * w * h);
if (flags & DC_EXEC) {
- byte *layout_ptr;
- byte layout;
+ const byte *layout_ptr;
int fsmportspecindex = 0;
st->airport_tile = tile;
@@ -1733,8 +1714,7 @@
fsmportspecindex = AllocateFSMportsSpecToStation(fsmportsspec, st, flags & DC_EXEC);
if (fsmportspecindex == -1) return CMD_ERROR;
- layout_ptr = (byte*)alloca((w * h) + 2);
- GetFSMportsLayout(layout_ptr, w, h, fsmportsspec, layout_set);
+ layout_ptr = fsmportsspec->layouts[layout_set];
st->FSMport_orientation = *layout_ptr++; //orientation
layout_ptr++; //skip minipic ID
} else {
@@ -1743,7 +1723,7 @@
{
BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
- layout = *layout_ptr++;
+ byte layout = *layout_ptr++;
MakeAirport(tile_cur, st->owner, st->index, layout - (newfsmairport ? 0 : (layout < 67) ? 8 : 24));
if (newfsmairport) {
SetCustomFSMportsSpecIndex(tile_cur, fsmportspecindex); //set top bit of m6 to indicate an fsmportsspec
@@ -1794,19 +1774,16 @@
if (v->u.air.targetairport == st->index && v->u.air.state != FLYING) return CMD_ERROR;
}
- byte *layout_ptr;
- byte layout;
- byte *mask_ptr;
+ const byte *layout_ptr;
+ const byte *mask_ptr;
if (newfsmairport) {
- layout_ptr = (byte*)alloca((w * h) + 2);
- GetFSMportsLayout(layout_ptr, w, h, fsmportsspec, layout_set);
+ layout_ptr = fsmportsspec->layouts[layout_set];
layout_ptr++; //skip orientation
layout_ptr++; //skip minipic ID
if (fsmportsspec->layout_mask != NULL) {
- mask_ptr = (byte*)alloca((w * h) + 2);
- memcpy(mask_ptr, fsmportsspec->layout_mask[layout_set], (w * h) + 2); // width*length flagbytes, plus orientation byte
+ mask_ptr = fsmportsspec->layout_mask[layout_set]; // width*length flagbytes, plus orientation byte
mask_ptr++; //skip orientation
mask_ptr++; //skip 0x00
} else {
@@ -1819,7 +1796,7 @@
{
BEGIN_TILE_LOOP(tile_cur, w, h, tile)
- layout = *layout_ptr++;
+ byte layout = *layout_ptr++;
if ((byte)layout != (byte)255) {
if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR;