summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-11 18:17:21 +0000
committersmatz <smatz@openttd.org>2009-05-11 18:17:21 +0000
commit15a5a33c70c068d39dfec6b3c0b1c999d347be00 (patch)
tree09853ddbf1ccceba5d73abddbc8d231825e10693
parente1e6687bfd2e8e41ecafa3e4b9d5ff7d38aebcb6 (diff)
downloadopenttd-15a5a33c70c068d39dfec6b3c0b1c999d347be00.tar.xz
(svn r16280) -Fix (r13731): crash after using the 'Reset landscape' function
-Fix: remove all waypoint signs and buoys after resetting landscape
-rw-r--r--src/terraform_gui.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 478ed3e30..94e15282a 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -22,9 +22,11 @@
#include "textbuf_gui.h"
#include "genworld.h"
#include "tree_map.h"
+#include "station_map.h"
#include "landscape_type.h"
#include "tilehighlight_func.h"
#include "settings_type.h"
+#include "waypoint.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -623,24 +625,34 @@ static OnButtonClick * const _editor_terraform_button_proc[] = {
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
{
if (confirmed) {
- Company *c;
-
/* Set generating_world to true to get instant-green grass after removing
* company property. */
_generating_world = true;
- /* Delete all stations owned by a company */
- Station *st;
- FOR_ALL_STATIONS(st) {
- if (IsValidCompanyID(st->owner)) delete st;
- }
-
/* Delete all companies */
+ Company *c;
FOR_ALL_COMPANIES(c) {
ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
delete c;
}
+
_generating_world = false;
+
+ /* Delete all station signs */
+ Station *st;
+ FOR_ALL_STATIONS(st) {
+ /* There can be buoys, remove them */
+ if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ delete st;
+ }
+
+ /* The same for waypoints */
+ Waypoint *wp;
+ FOR_ALL_WAYPOINTS(wp) {
+ delete wp;
+ }
+
+ MarkWholeScreenDirty();
}
}