Changeset - r25795:e4c377f6ca9d
[Not reviewed]
master
0 4 0
Loïc Guilloux - 3 years ago 2021-07-10 12:59:17
glx22@users.noreply.github.com
Codechange: Don't explicitly unset _generating_world outside of genworld.cpp (#9418)
4 files changed with 18 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/industry_gui.cpp
Show inline comments
 
@@ -605,15 +605,15 @@ public:
 
		if (!confirmed) return;
 

	
 
		if (Town::GetNumItems() == 0) {
 
			ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO);
 
		} else {
 
			extern void GenerateIndustries();
 
			_generating_world = true;
 
			Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
 
			GenerateIndustries();
 
			_generating_world = false;
 
			old_generating_world.Restore();
 
		}
 
	}
 

	
 
	static void AskRemoveAllIndustriesCallback(Window *w, bool confirmed)
 
	{
 
		if (!confirmed) return;
 
@@ -709,21 +709,21 @@ public:
 
				SetDParam(0, indsp->name);
 
				ShowErrorMessage(STR_ERROR_CAN_T_BUILD_HERE, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO, pt.x, pt.y);
 
				return;
 
			}
 

	
 
			Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
 
			_generating_world = true;
 
			Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
 
			_ignore_restrictions = true;
 

	
 
			DoCommandP(tile, (layout_index << 8) | this->selected_type, seed,
 
					CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), &CcBuildIndustry);
 

	
 
			cur_company.Restore();
 
			old_generating_world.Restore();
 
			_ignore_restrictions = false;
 
			_generating_world = false;
 
		} else {
 
			success = DoCommandP(tile, (layout_index << 8) | this->selected_type, seed, CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY));
 
		}
 

	
 
		/* If an industry has been built, just reset the cursor and the system */
 
		if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
src/terraform_cmd.cpp
Show inline comments
 
@@ -13,12 +13,13 @@
 
#include "bridge_map.h"
 
#include "viewport_func.h"
 
#include "genworld.h"
 
#include "object_base.h"
 
#include "company_base.h"
 
#include "company_func.h"
 
#include "core/backup_type.hpp"
 

	
 
#include "table/strings.h"
 

	
 
#include <map>
 
#include <set>
 

	
 
@@ -276,26 +277,26 @@ CommandCost CmdTerraformLand(TileIndex t
 

	
 
			/* Is the tile already cleared? */
 
			const ClearedObjectArea *coa = FindClearedObject(t);
 
			bool indirectly_cleared = coa != nullptr && coa->first_tile != t;
 

	
 
			/* Check tiletype-specific things, and add extra-cost */
 
			const bool curr_gen = _generating_world;
 
			if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land
 
			Backup<bool> old_generating_world(_generating_world, FILE_LINE);
 
			if (_game_mode == GM_EDITOR) old_generating_world.Change(true); // used to create green terraformed land
 
			DoCommandFlag tile_flags = flags | DC_AUTO | DC_FORCE_CLEAR_TILE;
 
			if (pass == 0) {
 
				tile_flags &= ~DC_EXEC;
 
				tile_flags |= DC_NO_MODIFY_TOWN_RATING;
 
			}
 
			CommandCost cost;
 
			if (indirectly_cleared) {
 
				cost = DoCommand(t, 0, 0, tile_flags, CMD_LANDSCAPE_CLEAR);
 
			} else {
 
				cost = _tile_type_procs[GetTileType(t)]->terraform_tile_proc(t, tile_flags, z_min, tileh);
 
			}
 
			_generating_world = curr_gen;
 
			old_generating_world.Restore();
 
			if (cost.Failed()) {
 
				_terraform_err_tile = t;
 
				return cost;
 
			}
 
			if (pass == 1) total_cost.AddCost(cost);
 
		}
src/terraform_gui.cpp
Show inline comments
 
@@ -5,12 +5,13 @@
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file terraform_gui.cpp GUI related to terraforming the map. */
 

	
 
#include "stdafx.h"
 
#include "core/backup_type.hpp"
 
#include "clear_map.h"
 
#include "company_func.h"
 
#include "company_base.h"
 
#include "gui.h"
 
#include "window_gui.h"
 
#include "window_func.h"
 
@@ -51,21 +52,21 @@ void CcTerraform(const CommandCost &resu
 

	
 
/** Scenario editor command that generates desert areas */
 
static void GenerateDesertArea(TileIndex end, TileIndex start)
 
{
 
	if (_game_mode != GM_EDITOR) return;
 

	
 
	_generating_world = true;
 
	Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
 

	
 
	TileArea ta(start, end);
 
	for (TileIndex tile : ta) {
 
		SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT);
 
		DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
 
		MarkTileDirtyByTile(tile);
 
	}
 
	_generating_world = false;
 
	old_generating_world.Restore();
 
	InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
 
}
 

	
 
/** Scenario editor command that generates rocky areas */
 
static void GenerateRockyArea(TileIndex end, TileIndex start)
 
{
 
@@ -494,21 +495,21 @@ static const NWidgetPart _nested_scen_ed
 
 */
 
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
 
{
 
	if (confirmed) {
 
		/* Set generating_world to true to get instant-green grass after removing
 
		 * company property. */
 
		_generating_world = true;
 
		Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
 

	
 
		/* Delete all companies */
 
		for (Company *c : Company::Iterate()) {
 
			ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
 
			delete c;
 
		}
 

	
 
		_generating_world = false;
 
		old_generating_world.Restore();
 

	
 
		/* Delete all station signs */
 
		for (BaseStation *st : BaseStation::Iterate()) {
 
			/* There can be buoys, remove them */
 
			if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
 
			if (!st->IsInUse()) delete st;
src/town_gui.cpp
Show inline comments
 
@@ -24,12 +24,13 @@
 
#include "sortlist_type.h"
 
#include "road_cmd.h"
 
#include "landscape.h"
 
#include "querystring_gui.h"
 
#include "window_func.h"
 
#include "townname_func.h"
 
#include "core/backup_type.hpp"
 
#include "core/geometry_func.hpp"
 
#include "genworld.h"
 
#include "stringfilter_type.h"
 
#include "widgets/dropdown_func.h"
 
#include "town_kdtree.h"
 

	
 
@@ -1181,21 +1182,22 @@ public:
 

	
 
			case WID_TF_TOWN_NAME_RANDOM:
 
				this->RandomTownName();
 
				this->SetFocusedWidget(WID_TF_TOWN_NAME_EDITBOX);
 
				break;
 

	
 
			case WID_TF_MANY_RANDOM_TOWNS:
 
				_generating_world = true;
 
			case WID_TF_MANY_RANDOM_TOWNS: {
 
				Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
 
				UpdateNearestTownForRoadTiles(true);
 
				if (!GenerateTowns(this->town_layout)) {
 
					ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_TOWN, STR_ERROR_NO_SPACE_FOR_TOWN, WL_INFO);
 
				}
 
				UpdateNearestTownForRoadTiles(false);
 
				_generating_world = false;
 
				old_generating_world.Restore();
 
				break;
 
			}
 

	
 
			case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM:
 
				this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL);
 
				this->UpdateButtons(false);
 
				break;
 

	
0 comments (0 inline, 0 general)