summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-15 21:29:07 +0000
committerrubidium <rubidium@openttd.org>2009-03-15 21:29:07 +0000
commite0fa11dd707044b6783f21220d733020cc2ad0fd (patch)
treebfaf4a103c8206096e8fd446b62226313a2de00f
parent8e919eb63be7beb77f4176951fc66d38f232cc14 (diff)
downloadopenttd-e0fa11dd707044b6783f21220d733020cc2ad0fd.tar.xz
(svn r15731) -Codechange: unify submarine creation
-rw-r--r--src/disaster_cmd.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index e328c76e2..210840fa5 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -875,12 +875,10 @@ static void Disaster_Big_Ufo_Init()
}
-/* Curious submarine #1, just floats around */
-static void Disaster_Small_Submarine_Init()
+static void Disaster_Submarine_Init(DisasterSubType subtype)
{
if (!Vehicle::CanAllocateItem()) return;
- Vehicle *v = new DisasterVehicle();
int y;
Direction dir;
uint32 r = Random();
@@ -893,31 +891,23 @@ static void Disaster_Small_Submarine_Init()
y = TILE_SIZE / 2;
dir = DIR_SE;
}
- InitializeDisasterVehicle(v, x, y, 0, dir, ST_Small_Submarine);
+
+ Vehicle *v = new DisasterVehicle();
+ InitializeDisasterVehicle(v, x, y, 0, dir, subtype);
v->age = 0;
}
+/* Curious submarine #1, just floats around */
+static void Disaster_Small_Submarine_Init()
+{
+ Disaster_Submarine_Init(ST_Small_Submarine);
+}
+
/* Curious submarine #2, just floats around */
static void Disaster_Big_Submarine_Init()
{
- if (!Vehicle::CanAllocateItem()) return;
-
- Vehicle *v = new DisasterVehicle();
- int y;
- Direction dir;
- uint32 r = Random();
- int x = TileX(r) * TILE_SIZE + TILE_SIZE / 2;
-
- if (HasBit(r, 31)) {
- y = MapMaxX() * TILE_SIZE - TILE_SIZE / 2 - 1;
- dir = DIR_NW;
- } else {
- y = TILE_SIZE / 2;
- dir = DIR_SE;
- }
- InitializeDisasterVehicle(v, x, y, 0, dir, ST_Big_Submarine);
- v->age = 0;
+ Disaster_Submarine_Init(ST_Big_Submarine);
}