2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 17:11:33 +02:00
|
|
|
/** @file genworld.cpp Functions to generate a map. */
|
2007-03-01 02:24:44 +01:00
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
#include "stdafx.h"
|
2007-04-12 15:07:15 +02:00
|
|
|
#include "landscape.h"
|
2008-09-30 22:51:04 +02:00
|
|
|
#include "company_func.h"
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
#include "genworld.h"
|
|
|
|
#include "gfxinit.h"
|
2007-12-19 21:45:46 +01:00
|
|
|
#include "window_func.h"
|
2007-01-02 18:34:03 +01:00
|
|
|
#include "network/network.h"
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
#include "heightmap.h"
|
2008-01-09 10:57:48 +01:00
|
|
|
#include "viewport_func.h"
|
2007-12-26 14:50:40 +01:00
|
|
|
#include "date_func.h"
|
2008-03-31 02:17:39 +02:00
|
|
|
#include "engine_func.h"
|
2008-01-22 18:48:08 +01:00
|
|
|
#include "water.h"
|
2011-08-24 14:11:10 +02:00
|
|
|
#include "video/video_driver.hpp"
|
2008-05-07 15:10:15 +02:00
|
|
|
#include "tilehighlight_func.h"
|
2009-01-04 16:32:25 +01:00
|
|
|
#include "saveload/saveload.h"
|
2009-01-21 03:31:55 +01:00
|
|
|
#include "void_map.h"
|
2009-02-04 23:52:34 +01:00
|
|
|
#include "town.h"
|
2009-12-15 01:00:51 +01:00
|
|
|
#include "newgrf.h"
|
2010-01-15 17:41:15 +01:00
|
|
|
#include "core/random_func.hpp"
|
2010-06-05 15:32:42 +02:00
|
|
|
#include "core/backup_type.hpp"
|
2011-08-21 14:48:46 +02:00
|
|
|
#include "progress.h"
|
2011-12-10 17:05:26 +01:00
|
|
|
#include "error.h"
|
2011-12-19 21:56:34 +01:00
|
|
|
#include "game/game.hpp"
|
2011-12-19 21:56:50 +01:00
|
|
|
#include "game/game_instance.hpp"
|
2014-04-23 23:12:09 +02:00
|
|
|
#include "string_func.h"
|
2019-03-17 01:59:46 +01:00
|
|
|
#include "thread.h"
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2014-04-23 22:13:33 +02:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2008-01-13 02:21:35 +01:00
|
|
|
|
2007-03-07 12:47:46 +01:00
|
|
|
void GenerateClearTile();
|
|
|
|
void GenerateIndustries();
|
2010-08-08 12:59:30 +02:00
|
|
|
void GenerateObjects();
|
2007-03-07 12:47:46 +01:00
|
|
|
void GenerateTrees();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2007-03-07 12:47:46 +01:00
|
|
|
void StartupEconomy();
|
2008-09-30 22:39:50 +02:00
|
|
|
void StartupCompanies();
|
2007-03-07 12:47:46 +01:00
|
|
|
void StartupDisasters();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2009-08-07 00:00:32 +02:00
|
|
|
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2010-01-18 15:58:32 +01:00
|
|
|
/**
|
|
|
|
* Please only use this variable in genworld.h and genworld.cpp and
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
* nowhere else. For speed improvements we need it to be global, but
|
|
|
|
* in no way the meaning of it is to use it anywhere else besides
|
2011-11-30 02:22:18 +01:00
|
|
|
* in the genworld.h and genworld.cpp!
|
2010-01-18 15:58:32 +01:00
|
|
|
*/
|
2010-01-17 23:59:24 +01:00
|
|
|
GenWorldInfo _gw;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2010-07-19 19:17:36 +02:00
|
|
|
/** Whether we are generating the map or not. */
|
|
|
|
bool _generating_world;
|
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
/**
|
|
|
|
* Tells if the world generation is done in a thread or not.
|
2010-01-18 15:58:32 +01:00
|
|
|
* @return the 'threaded' status
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
*/
|
2007-03-07 12:47:46 +01:00
|
|
|
bool IsGenerateWorldThreaded()
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
|
|
|
return _gw.threaded && !_gw.quit_thread;
|
|
|
|
}
|
|
|
|
|
2009-03-12 15:28:55 +01:00
|
|
|
/**
|
2010-08-02 22:47:27 +02:00
|
|
|
* Clean up the 'mess' of generation. That is, show windows again, reset
|
|
|
|
* thread variables, and delete the progress window.
|
2009-03-12 15:28:55 +01:00
|
|
|
*/
|
|
|
|
static void CleanupGeneration()
|
|
|
|
{
|
|
|
|
_generating_world = false;
|
|
|
|
|
2016-08-15 20:32:48 +02:00
|
|
|
SetMouseCursorBusy(false);
|
2009-03-12 15:28:55 +01:00
|
|
|
/* Show all vital windows again, because we have hidden them */
|
|
|
|
if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
|
2011-08-21 14:48:46 +02:00
|
|
|
SetModalProgress(false);
|
2019-04-10 23:07:06 +02:00
|
|
|
_gw.proc = nullptr;
|
|
|
|
_gw.abortp = nullptr;
|
2009-03-12 15:28:55 +01:00
|
|
|
_gw.threaded = false;
|
|
|
|
|
2011-12-19 21:50:21 +01:00
|
|
|
DeleteWindowByClass(WC_MODAL_PROGRESS);
|
2011-12-10 17:05:26 +01:00
|
|
|
ShowFirstError();
|
2009-03-12 15:28:55 +01:00
|
|
|
MarkWholeScreenDirty();
|
|
|
|
}
|
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
/**
|
|
|
|
* The internal, real, generate function.
|
|
|
|
*/
|
2019-03-17 01:59:46 +01:00
|
|
|
static void _GenerateWorld()
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
2010-06-05 15:32:42 +02:00
|
|
|
/* Make sure everything is done via OWNER_NONE. */
|
2019-04-22 10:10:04 +02:00
|
|
|
Backup<CompanyID> _cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
2010-06-05 15:32:42 +02:00
|
|
|
|
2019-03-11 00:45:39 +01:00
|
|
|
std::unique_lock<std::mutex> lock(_modal_progress_work_mutex, std::defer_lock);
|
2008-04-17 21:53:13 +02:00
|
|
|
try {
|
|
|
|
_generating_world = true;
|
2019-03-11 00:45:39 +01:00
|
|
|
lock.lock();
|
2014-04-26 18:55:30 +02:00
|
|
|
if (_network_dedicated) DEBUG(net, 1, "Generating map, please wait...");
|
2008-04-17 21:53:13 +02:00
|
|
|
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
|
2008-05-29 17:13:28 +02:00
|
|
|
if (_settings_game.game_creation.generation_seed == GENERATE_NEW_SEED) _settings_game.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
|
|
|
|
_random.SetSeed(_settings_game.game_creation.generation_seed);
|
2008-04-17 21:53:13 +02:00
|
|
|
SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
|
2009-04-19 12:31:30 +02:00
|
|
|
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
|
2008-04-17 21:53:13 +02:00
|
|
|
|
2014-02-23 23:03:08 +01:00
|
|
|
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
|
|
|
|
2008-04-17 21:53:13 +02:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
|
|
|
|
/* Must start economy early because of the costs. */
|
|
|
|
StartupEconomy();
|
|
|
|
|
|
|
|
/* Don't generate landscape items when in the scenario editor. */
|
2010-01-17 23:59:24 +01:00
|
|
|
if (_gw.mode == GWM_EMPTY) {
|
2010-08-08 12:59:30 +02:00
|
|
|
SetGeneratingWorldProgress(GWP_OBJECT, 1);
|
2008-04-17 21:53:13 +02:00
|
|
|
|
2009-01-21 03:31:55 +01:00
|
|
|
/* Make sure the tiles at the north border are void tiles if needed. */
|
|
|
|
if (_settings_game.construction.freeform_edges) {
|
2019-02-09 00:05:25 +01:00
|
|
|
for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0));
|
|
|
|
for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y));
|
2009-01-21 03:31:55 +01:00
|
|
|
}
|
|
|
|
|
2009-02-08 13:25:13 +01:00
|
|
|
/* Make the map the height of the setting */
|
2008-05-29 17:13:28 +02:00
|
|
|
if (_game_mode != GM_MENU) FlatEmptyWorld(_settings_game.game_creation.se_flat_world_height);
|
2008-04-17 21:53:13 +02:00
|
|
|
|
|
|
|
ConvertGroundTilesIntoWaterTiles();
|
2010-08-08 12:59:30 +02:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_OBJECT);
|
2008-04-17 21:53:13 +02:00
|
|
|
} else {
|
|
|
|
GenerateLandscape(_gw.mode);
|
|
|
|
GenerateClearTile();
|
|
|
|
|
2019-11-14 21:13:15 +01:00
|
|
|
/* Only generate towns, tree and industries in newgame mode. */
|
2008-04-17 21:53:13 +02:00
|
|
|
if (_game_mode != GM_EDITOR) {
|
2009-03-12 16:14:22 +01:00
|
|
|
if (!GenerateTowns(_settings_game.economy.town_layout)) {
|
2010-06-05 15:32:42 +02:00
|
|
|
_cur_company.Restore();
|
2009-03-12 16:14:22 +01:00
|
|
|
HandleGeneratingWorldAbortion();
|
2019-11-14 21:13:15 +01:00
|
|
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
|
|
|
|
if (_network_dedicated) {
|
|
|
|
/* Exit the game to prevent a return to main menu. */
|
|
|
|
DEBUG(net, 0, "Generating map failed, aborting");
|
|
|
|
_exit_game = true;
|
|
|
|
}
|
2009-03-12 16:14:22 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-04-17 21:53:13 +02:00
|
|
|
GenerateIndustries();
|
2010-08-08 12:59:30 +02:00
|
|
|
GenerateObjects();
|
2008-04-17 21:53:13 +02:00
|
|
|
GenerateTrees();
|
|
|
|
}
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
|
2008-04-17 21:53:13 +02:00
|
|
|
/* These are probably pointless when inside the scenario editor. */
|
|
|
|
SetGeneratingWorldProgress(GWP_GAME_INIT, 3);
|
2008-09-30 22:39:50 +02:00
|
|
|
StartupCompanies();
|
2008-04-17 21:53:13 +02:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
|
|
|
|
StartupEngines();
|
|
|
|
IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
|
|
|
|
StartupDisasters();
|
|
|
|
_generating_world = false;
|
|
|
|
|
|
|
|
/* No need to run the tile loop in the scenario editor. */
|
2010-01-17 23:59:24 +01:00
|
|
|
if (_gw.mode != GWM_EMPTY) {
|
2008-04-17 21:53:13 +02:00
|
|
|
uint i;
|
|
|
|
|
|
|
|
SetGeneratingWorldProgress(GWP_RUNTILELOOP, 0x500);
|
|
|
|
for (i = 0; i < 0x500; i++) {
|
|
|
|
RunTileLoop();
|
2012-04-17 21:43:43 +02:00
|
|
|
_tick_counter++;
|
2008-04-17 21:53:13 +02:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_RUNTILELOOP);
|
|
|
|
}
|
2011-12-19 21:56:34 +01:00
|
|
|
|
|
|
|
if (_game_mode != GM_EDITOR) {
|
|
|
|
Game::StartNew();
|
2011-12-19 21:56:50 +01:00
|
|
|
|
2019-04-10 23:07:06 +02:00
|
|
|
if (Game::GetInstance() != nullptr) {
|
2011-12-19 21:56:50 +01:00
|
|
|
SetGeneratingWorldProgress(GWP_RUNSCRIPT, 2500);
|
|
|
|
_generating_world = true;
|
|
|
|
for (i = 0; i < 2500; i++) {
|
|
|
|
Game::GameLoop();
|
|
|
|
IncreaseGeneratingWorldProgress(GWP_RUNSCRIPT);
|
|
|
|
if (Game::GetInstance()->IsSleeping()) break;
|
|
|
|
}
|
|
|
|
_generating_world = false;
|
|
|
|
}
|
2011-12-19 21:56:34 +01:00
|
|
|
}
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
|
2014-02-23 23:03:08 +01:00
|
|
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
|
|
|
|
|
2008-04-17 21:53:13 +02:00
|
|
|
ResetObjectToPlace();
|
2010-06-05 15:32:42 +02:00
|
|
|
_cur_company.Trash();
|
|
|
|
_current_company = _local_company = _gw.lc;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2008-04-17 21:53:13 +02:00
|
|
|
SetGeneratingWorldProgress(GWP_GAME_START, 1);
|
|
|
|
/* Call any callback */
|
2019-04-10 23:07:06 +02:00
|
|
|
if (_gw.proc != nullptr) _gw.proc();
|
2008-04-17 21:53:13 +02:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_GAME_START);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2009-03-12 15:28:55 +01:00
|
|
|
CleanupGeneration();
|
2019-03-11 00:45:39 +01:00
|
|
|
lock.unlock();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2009-12-15 01:00:51 +01:00
|
|
|
ShowNewGRFError();
|
|
|
|
|
2014-04-26 18:55:30 +02:00
|
|
|
if (_network_dedicated) DEBUG(net, 1, "Map generated, starting game");
|
2010-04-08 23:14:49 +02:00
|
|
|
DEBUG(desync, 1, "new_map: %08x", _settings_game.game_creation.generation_seed);
|
2007-04-28 17:06:32 +02:00
|
|
|
|
2008-12-29 22:50:25 +01:00
|
|
|
if (_debug_desync_level > 0) {
|
|
|
|
char name[MAX_PATH];
|
2014-04-23 23:12:09 +02:00
|
|
|
seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
|
2016-09-04 18:06:50 +02:00
|
|
|
SaveOrLoad(name, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false);
|
2008-12-29 22:50:25 +01:00
|
|
|
}
|
2008-04-17 21:53:13 +02:00
|
|
|
} catch (...) {
|
2014-02-23 23:03:08 +01:00
|
|
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP, true);
|
2010-06-05 15:32:42 +02:00
|
|
|
if (_cur_company.IsValid()) _cur_company.Restore();
|
2008-04-17 21:53:13 +02:00
|
|
|
_generating_world = false;
|
|
|
|
throw;
|
|
|
|
}
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set here the function, if any, that you want to be called when landscape
|
2010-01-18 15:58:32 +01:00
|
|
|
* generation is done.
|
|
|
|
* @param proc callback procedure
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
*/
|
2010-01-17 23:59:24 +01:00
|
|
|
void GenerateWorldSetCallback(GWDoneProc *proc)
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
|
|
|
_gw.proc = proc;
|
|
|
|
}
|
|
|
|
|
2006-11-22 15:14:02 +01:00
|
|
|
/**
|
|
|
|
* Set here the function, if any, that you want to be called when landscape
|
2010-01-18 15:58:32 +01:00
|
|
|
* generation is aborted.
|
|
|
|
* @param proc callback procedure
|
2006-11-22 15:14:02 +01:00
|
|
|
*/
|
2010-01-17 23:59:24 +01:00
|
|
|
void GenerateWorldSetAbortCallback(GWAbortProc *proc)
|
2006-11-22 15:14:02 +01:00
|
|
|
{
|
|
|
|
_gw.abortp = proc;
|
|
|
|
}
|
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
/**
|
|
|
|
* This will wait for the thread to finish up his work. It will not continue
|
2010-01-18 15:58:32 +01:00
|
|
|
* till the work is done.
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
*/
|
2007-03-07 12:47:46 +01:00
|
|
|
void WaitTillGeneratedWorld()
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
2019-03-17 01:59:46 +01:00
|
|
|
if (!_gw.thread.joinable()) return;
|
2009-05-03 17:44:05 +02:00
|
|
|
|
2019-03-11 00:45:39 +01:00
|
|
|
_modal_progress_work_mutex.unlock();
|
|
|
|
_modal_progress_paint_mutex.unlock();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
_gw.quit_thread = true;
|
2019-03-17 01:59:46 +01:00
|
|
|
_gw.thread.join();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
_gw.threaded = false;
|
2019-03-11 00:45:39 +01:00
|
|
|
_modal_progress_work_mutex.lock();
|
|
|
|
_modal_progress_paint_mutex.lock();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the abortion process
|
|
|
|
*/
|
2007-03-07 12:47:46 +01:00
|
|
|
void AbortGeneratingWorld()
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
|
|
|
_gw.abort = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the generation being aborted?
|
2010-01-18 15:58:32 +01:00
|
|
|
* @return the 'aborted' status
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
*/
|
2007-03-07 12:47:46 +01:00
|
|
|
bool IsGeneratingWorldAborted()
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
|
|
|
return _gw.abort;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Really handle the abortion, i.e. clean up some of the mess
|
|
|
|
*/
|
2007-03-07 12:47:46 +01:00
|
|
|
void HandleGeneratingWorldAbortion()
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
|
|
|
/* Clean up - in SE create an empty map, otherwise, go to intro menu */
|
|
|
|
_switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU;
|
|
|
|
|
2019-04-10 23:07:06 +02:00
|
|
|
if (_gw.abortp != nullptr) _gw.abortp();
|
2006-11-22 15:14:02 +01:00
|
|
|
|
2009-03-12 15:28:55 +01:00
|
|
|
CleanupGeneration();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2019-03-17 01:59:46 +01:00
|
|
|
if (_gw.thread.joinable() && _gw.thread.get_id() == std::this_thread::get_id()) throw OTTDThreadExitSignal();
|
2009-03-12 16:14:22 +01:00
|
|
|
|
|
|
|
SwitchToMode(_switch_mode);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a world.
|
2010-01-18 15:58:32 +01:00
|
|
|
* @param mode The mode of world generation (see GenWorldMode).
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
* @param size_x The X-size of the map.
|
|
|
|
* @param size_y The Y-size of the map.
|
2009-09-19 11:51:14 +02:00
|
|
|
* @param reset_settings Whether to reset the game configuration (used for restart)
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
*/
|
2010-01-17 23:59:24 +01:00
|
|
|
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings)
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
{
|
2011-08-21 14:48:46 +02:00
|
|
|
if (HasModalProgress()) return;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
_gw.mode = mode;
|
|
|
|
_gw.size_x = size_x;
|
|
|
|
_gw.size_y = size_y;
|
2011-08-21 14:48:46 +02:00
|
|
|
SetModalProgress(true);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
_gw.abort = false;
|
2019-04-10 23:07:06 +02:00
|
|
|
_gw.abortp = nullptr;
|
2008-09-30 22:39:50 +02:00
|
|
|
_gw.lc = _local_company;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
_gw.quit_thread = false;
|
|
|
|
_gw.threaded = true;
|
|
|
|
|
|
|
|
/* This disables some commands and stuff */
|
2008-09-30 22:39:50 +02:00
|
|
|
SetLocalCompany(COMPANY_SPECTATOR);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2010-08-22 11:18:01 +02:00
|
|
|
InitializeGame(_gw.size_x, _gw.size_y, true, reset_settings);
|
2009-11-21 17:39:36 +01:00
|
|
|
PrepareGenerateWorldProgress();
|
|
|
|
|
2010-08-22 11:18:01 +02:00
|
|
|
/* Load the right landscape stuff, and the NewGRFs! */
|
2006-11-24 19:39:22 +01:00
|
|
|
GfxLoadSprites();
|
|
|
|
LoadStringWidthTable();
|
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
/* Re-init the windowing system */
|
|
|
|
ResetWindowSystem();
|
|
|
|
|
|
|
|
/* Create toolbars */
|
2009-02-09 03:57:15 +01:00
|
|
|
SetupColoursAndInitialWindow();
|
2009-11-21 17:39:36 +01:00
|
|
|
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
|
2019-03-17 01:59:46 +01:00
|
|
|
if (_gw.thread.joinable()) _gw.thread.join();
|
2008-06-08 17:27:57 +02:00
|
|
|
|
2019-03-17 01:59:46 +01:00
|
|
|
if (!UseThreadedModelProgress() || !VideoDriver::GetInstance()->HasGUI() || !StartNewThread(&_gw.thread, "ottd:genworld", &_GenerateWorld)) {
|
2006-12-26 18:36:18 +01:00
|
|
|
DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
_gw.threaded = false;
|
2019-03-11 00:45:39 +01:00
|
|
|
_modal_progress_work_mutex.unlock();
|
2019-03-17 01:59:46 +01:00
|
|
|
_GenerateWorld();
|
2019-03-11 00:45:39 +01:00
|
|
|
_modal_progress_work_mutex.lock();
|
2006-11-07 15:41:53 +01:00
|
|
|
return;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
|
2011-12-10 17:05:26 +01:00
|
|
|
UnshowCriticalError();
|
2006-11-07 15:41:53 +01:00
|
|
|
/* Remove any open window */
|
|
|
|
DeleteAllNonVitalWindows();
|
2006-11-07 14:06:02 +01:00
|
|
|
/* Hide vital windows, because we don't allow to use them */
|
2006-11-07 15:41:53 +01:00
|
|
|
HideVitalWindows();
|
|
|
|
|
|
|
|
/* Don't show the dialog if we don't have a thread */
|
|
|
|
ShowGenerateWorldProgress();
|
2006-11-07 14:06:02 +01:00
|
|
|
|
|
|
|
/* Centre the view on the map */
|
2019-04-10 23:07:06 +02:00
|
|
|
if (FindWindowById(WC_MAIN_WINDOW, 0) != nullptr) {
|
2007-05-31 09:21:33 +02:00
|
|
|
ScrollMainWindowToTile(TileXY(MapSizeX() / 2, MapSizeY() / 2), true);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 12:00:30 +02:00
|
|
|
}
|
|
|
|
}
|