src/genworld.h
author richk
Tue, 17 Jun 2008 13:41:57 +0000
branchNewGRF_ports
changeset 10995 311b38c7f9a7
parent 10991 d8811e327d12
permissions -rw-r--r--
(svn r13549) [NewGRF_ports] -Change: Make recolouring of groundtile (0x0f80) specific to NewGRF_ports only.
Also base groundsprite on airport_tile of station. This prevents mixed colour groundtiles in an airport.
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     1
/* $Id$ */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     2
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10211
diff changeset
     3
/** @file genworld.h Functions related to world/map generation. */
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
     4
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     5
#ifndef GENWORLD_H
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     6
#define GENWORLD_H
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     7
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6574
diff changeset
     8
#include "player_type.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6574
diff changeset
     9
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    10
/*
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    11
 * Order of these enums has to be the same as in lang/english.txt
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    12
 * Otherwise you will get inconsistent behaviour.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    13
 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    14
enum {
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    15
	LG_ORIGINAL     = 0,  ///< The original landscape generator
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    16
	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    17
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    18
	GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    19
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    20
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    21
/* Modes for GenerateWorld */
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    22
enum GenerateWorldMode {
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    23
	GW_NEWGAME   = 0,    /* Generate a map for a new game */
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    24
	GW_EMPTY     = 1,    /* Generate an empty map (sea-level) */
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    25
	GW_RANDOM    = 2,    /* Generate a random map for SE */
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    26
	GW_HEIGHTMAP = 3,    /* Generate a newgame from a heightmap */
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    27
};
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    28
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    29
typedef void gw_done_proc();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    30
typedef void gw_abort_proc();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    31
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    32
struct gw_info {
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    33
	bool active;           ///< Is generating world active
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    34
	bool abort;            ///< Whether to abort the thread ASAP
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    35
	bool wait_for_draw;    ///< Are we waiting on a draw event
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    36
	bool quit_thread;      ///< Do we want to quit the active thread
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    37
	bool threaded;         ///< Whether we run _GenerateWorld threaded
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    38
	GenerateWorldMode mode;///< What mode are we making a world in
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    39
	PlayerID lp;           ///< The local_player before generating
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    40
	uint size_x;           ///< X-size of the map
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    41
	uint size_y;           ///< Y-size of the map
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    42
	gw_done_proc *proc;    ///< Proc that is called when done (can be NULL)
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    43
	gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL)
10211
c1391c8ed5c6 (svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents: 6872
diff changeset
    44
	class ThreadObject *thread; ///< The thread we are in (can be NULL)
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    45
};
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    46
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    47
enum gwp_class {
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    48
	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    49
	GWP_LANDSCAPE,   ///< Create the landscape
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    50
	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    51
	GWP_TOWN,        ///< Generate towns
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    52
	GWP_INDUSTRY,    ///< Generate industries
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    53
	GWP_UNMOVABLE,   ///< Generate unmovables (radio tower, light houses)
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    54
	GWP_TREE,        ///< Generate trees
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    55
	GWP_GAME_INIT,   ///< Initialize the game
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    56
	GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    57
	GWP_GAME_START,  ///< Really prepare to start the game
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    58
	GWP_CLASS_COUNT
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    59
};
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    60
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    61
/**
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    62
 * Check if we are currently in the process of generating a world.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    63
 */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    64
static inline bool IsGeneratingWorld()
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    65
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    66
	extern gw_info _gw;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    67
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    68
	return _gw.active;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    69
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    70
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    71
/* genworld.cpp */
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    72
void SetGeneratingWorldPaintStatus(bool status);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    73
bool IsGeneratingWorldReadyForPaint();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    74
bool IsGenerateWorldThreaded();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    75
void GenerateWorldSetCallback(gw_done_proc *proc);
5145
4c5761bb0176 (svn r7237) -Fix: TGP landscape generation could leak memory if aborted during the generation of the heightmap.
rubidium
parents: 4300
diff changeset
    76
void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    77
void WaitTillGeneratedWorld();
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10724
diff changeset
    78
void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    79
void AbortGeneratingWorld();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    80
bool IsGeneratingWorldAborted();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    81
void HandleGeneratingWorldAbortion();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    82
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6150
diff changeset
    83
/* genworld_gui.cpp */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    84
void SetGeneratingWorldProgress(gwp_class cls, uint total);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    85
void IncreaseGeneratingWorldProgress(gwp_class cls);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    86
void PrepareGenerateWorldProgress();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    87
void ShowGenerateWorldProgress();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    88
void StartNewGameWithoutGUI(uint seed);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    89
void ShowCreateScenario();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    90
void StartScenarioEditor();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    91
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    92
#endif /* GENWORLD_H */