2009-08-21 20:21:05 +00: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 15:11:33 +00:00
|
|
|
/** @file genworld.h Functions related to world/map generation. */
|
2007-03-01 01:24:44 +00: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 10:00:30 +00:00
|
|
|
#ifndef GENWORLD_H
|
|
|
|
#define GENWORLD_H
|
|
|
|
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_type.h"
|
2019-03-17 00:59:46 +00:00
|
|
|
#include <thread>
|
2019-04-10 16:35:43 +00:00
|
|
|
#if defined(__MINGW32__)
|
|
|
|
#include "3rdparty/mingw-std-threads/mingw.thread.h"
|
|
|
|
#endif
|
2008-01-12 14:10:35 +00:00
|
|
|
|
2010-01-18 14:58:32 +00:00
|
|
|
/** Constants related to world generation */
|
2010-05-13 09:44:44 +00:00
|
|
|
enum LandscapeGenerator {
|
2010-01-18 14:58:32 +00:00
|
|
|
/* Order of these enums has to be the same as in lang/english.txt
|
|
|
|
* Otherwise you will get inconsistent behaviour. */
|
2007-03-01 01:24:44 +00:00
|
|
|
LG_ORIGINAL = 0, ///< The original landscape generator
|
|
|
|
LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator
|
(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 10:00:30 +00:00
|
|
|
};
|
|
|
|
|
2018-10-10 23:33:37 +00:00
|
|
|
static const uint32 GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed
|
2010-05-13 09:44:44 +00:00
|
|
|
|
2010-01-18 14:58:32 +00:00
|
|
|
/** Modes for GenerateWorld */
|
2010-01-17 22:59:24 +00:00
|
|
|
enum GenWorldMode {
|
|
|
|
GWM_NEWGAME = 0, ///< Generate a map for a new game
|
|
|
|
GWM_EMPTY = 1, ///< Generate an empty map (sea-level)
|
|
|
|
GWM_RANDOM = 2, ///< Generate a random map for SE
|
|
|
|
GWM_HEIGHTMAP = 3, ///< Generate a newgame from a heightmap
|
2008-05-29 09:54:47 +00:00
|
|
|
};
|
|
|
|
|
2015-04-11 18:45:18 +00:00
|
|
|
/** Smoothness presets. */
|
|
|
|
enum TgenSmoothness {
|
|
|
|
TGEN_SMOOTHNESS_BEGIN, ///< First smoothness value.
|
|
|
|
TGEN_SMOOTHNESS_VERY_SMOOTH = TGEN_SMOOTHNESS_BEGIN, ///< Smoothness preset 'very smooth'.
|
|
|
|
TGEN_SMOOTHNESS_SMOOTH, ///< Smoothness preset 'smooth'.
|
|
|
|
TGEN_SMOOTHNESS_ROUGH, ///< Smoothness preset 'rough'.
|
|
|
|
TGEN_SMOOTHNESS_VERY_ROUGH, ///< Smoothness preset 'very rough'.
|
|
|
|
|
|
|
|
TGEN_SMOOTHNESS_END, ///< Used to iterate.
|
|
|
|
};
|
|
|
|
|
2021-03-24 22:25:51 +00:00
|
|
|
static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY = 5; ///< Value for custom terrain type in difficulty settings.
|
|
|
|
|
2010-09-20 19:15:31 +00:00
|
|
|
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4; ///< Value for custom sea level in difficulty settings.
|
|
|
|
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1; ///< Minimum percentage a user can specify for custom sea level.
|
|
|
|
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90; ///< Maximum percentage a user can specify for custom sea level.
|
2010-09-20 18:56:35 +00:00
|
|
|
|
2021-03-24 09:29:01 +00:00
|
|
|
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30; ///< When map height limit is auto, make this the lowest possible map height limit.
|
|
|
|
static const uint MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM = 15; ///< When map height limit is auto, the map height limit will be the higest peak plus this value.
|
|
|
|
|
2010-01-18 14:58:32 +00:00
|
|
|
typedef void GWDoneProc(); ///< Procedure called when the genworld process finishes
|
|
|
|
typedef void GWAbortProc(); ///< Called when genworld is aborted
|
(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 10:00:30 +00:00
|
|
|
|
2010-01-18 14:58:32 +00:00
|
|
|
/** Properties of current genworld process */
|
2010-01-17 22:59:24 +00:00
|
|
|
struct GenWorldInfo {
|
2007-03-01 01:24:44 +00:00
|
|
|
bool abort; ///< Whether to abort the thread ASAP
|
2010-01-17 22:59:24 +00:00
|
|
|
GenWorldMode mode; ///< What mode are we making a world in
|
2008-09-30 20:39:50 +00:00
|
|
|
CompanyID lc; ///< The local_company before generating
|
2007-03-01 01:24:44 +00:00
|
|
|
uint size_x; ///< X-size of the map
|
|
|
|
uint size_y; ///< Y-size of the map
|
2019-04-10 21:07:06 +00:00
|
|
|
GWDoneProc *proc; ///< Proc that is called when done (can be nullptr)
|
|
|
|
GWAbortProc *abortp; ///< Proc that is called when aborting (can be nullptr)
|
2007-03-07 12:11:48 +00: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 10:00:30 +00:00
|
|
|
|
2010-01-18 14:58:32 +00:00
|
|
|
/** Current stage of world generation process */
|
2010-01-17 22:59:24 +00:00
|
|
|
enum GenWorldProgress {
|
2007-03-01 01:24:44 +00:00
|
|
|
GWP_MAP_INIT, ///< Initialize/allocate the map, start economy
|
|
|
|
GWP_LANDSCAPE, ///< Create the landscape
|
2011-08-20 14:15:40 +00:00
|
|
|
GWP_RIVER, ///< Create the rivers
|
2007-03-01 01:24:44 +00:00
|
|
|
GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
|
|
|
|
GWP_TOWN, ///< Generate towns
|
|
|
|
GWP_INDUSTRY, ///< Generate industries
|
2010-08-08 10:59:30 +00:00
|
|
|
GWP_OBJECT, ///< Generate objects (radio tower, light houses)
|
2007-03-01 01:24:44 +00:00
|
|
|
GWP_TREE, ///< Generate trees
|
2021-06-12 07:56:59 +00:00
|
|
|
GWP_PUBLIC_ROADS,///< Generate public roads
|
2007-03-01 01:24:44 +00:00
|
|
|
GWP_GAME_INIT, ///< Initialize the game
|
|
|
|
GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc
|
2011-12-19 20:56:50 +00:00
|
|
|
GWP_RUNSCRIPT, ///< Runs the game script at most 2500 times, or when ever the script sleeps
|
2007-03-01 01:24:44 +00:00
|
|
|
GWP_GAME_START, ///< Really prepare to start the game
|
(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 10:00:30 +00:00
|
|
|
GWP_CLASS_COUNT
|
2007-03-07 12:11:48 +00: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 10:00:30 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* genworld.cpp */
|
2010-01-17 22:59:24 +00:00
|
|
|
void GenerateWorldSetCallback(GWDoneProc *proc);
|
|
|
|
void GenerateWorldSetAbortCallback(GWAbortProc *proc);
|
|
|
|
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
|
2007-03-07 11:47:46 +00:00
|
|
|
void AbortGeneratingWorld();
|
|
|
|
bool IsGeneratingWorldAborted();
|
|
|
|
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 10:00:30 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* genworld_gui.cpp */
|
2010-05-21 06:59:45 +00:00
|
|
|
void SetNewLandscapeType(byte landscape);
|
2010-01-17 22:59:24 +00:00
|
|
|
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
|
|
|
|
void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
|
2007-03-07 11:47:46 +00:00
|
|
|
void PrepareGenerateWorldProgress();
|
|
|
|
void ShowGenerateWorldProgress();
|
2018-10-10 23:33:37 +00:00
|
|
|
void StartNewGameWithoutGUI(uint32 seed);
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowCreateScenario();
|
|
|
|
void StartScenarioEditor();
|
(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 10:00:30 +00:00
|
|
|
|
2010-07-19 17:17:36 +00:00
|
|
|
extern bool _generating_world;
|
2009-05-03 15:44:05 +00: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 10:00:30 +00:00
|
|
|
#endif /* GENWORLD_H */
|