src/genworld.h
author bjarni
Thu, 19 Jun 2008 17:54:23 +0000
changeset 9561 f236daaaf93a
parent 9409 a4fc0d50c588
child 10207 c291a21b304e
permissions -rw-r--r--
(svn r13584) -Fix: [OSX] Fixed issue where 10.5 failed to switch to fullscreen
This is done by selecting the 32bpp-anim blitter by default as it seems Apple removed some 8bpp support
Since this is done at runtime the same binary will still select 8bpp on 10.3 and 10.4
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     1
/* $Id$ */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8934
diff changeset
     3
/** @file genworld.h Functions related to world/map generation. */
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
     4
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     5
#ifndef GENWORLD_H
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     6
#define GENWORLD_H
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     7
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 6248
diff changeset
     8
#include "player_type.h"
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 6248
diff changeset
     9
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    10
/*
c7e43c47a2b9 (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
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    12
 * Otherwise you will get inconsistent behaviour.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    13
 */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    14
enum {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    15
	LG_ORIGINAL     = 0,  ///< The original landscape generator
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    16
	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    17
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    18
	GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    19
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    20
9409
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    21
/* Modes for GenerateWorld */
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    22
enum GenerateWorldMode {
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    23
	GW_NEWGAME   = 0,    /* Generate a map for a new game */
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    24
	GW_EMPTY     = 1,    /* Generate an empty map (sea-level) */
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    25
	GW_RANDOM    = 2,    /* Generate a random map for SE */
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    26
	GW_HEIGHTMAP = 3,    /* Generate a newgame from a heightmap */
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    27
};
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    28
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    29
typedef void gw_done_proc();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    30
typedef void gw_abort_proc();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    31
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    32
struct gw_info {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    33
	bool active;           ///< Is generating world active
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    34
	bool abort;            ///< Whether to abort the thread ASAP
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    35
	bool wait_for_draw;    ///< Are we waiting on a draw event
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    36
	bool quit_thread;      ///< Do we want to quit the active thread
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    37
	bool threaded;         ///< Whether we run _GenerateWorld threaded
9409
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    38
	GenerateWorldMode mode;///< What mode are we making a world in
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    39
	PlayerID lp;           ///< The local_player before generating
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    40
	uint size_x;           ///< X-size of the map
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    41
	uint size_y;           ///< Y-size of the map
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    42
	gw_done_proc *proc;    ///< Proc that is called when done (can be NULL)
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    43
	gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL)
8934
f46812d21fe6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents: 8254
diff changeset
    44
	class ThreadObject *thread; ///< The thread we are in (can be NULL)
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    45
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    46
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    47
enum gwp_class {
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    48
	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    49
	GWP_LANDSCAPE,   ///< Create the landscape
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    50
	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    51
	GWP_TOWN,        ///< Generate towns
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    52
	GWP_INDUSTRY,    ///< Generate industries
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    53
	GWP_UNMOVABLE,   ///< Generate unmovables (radio tower, light houses)
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    54
	GWP_TREE,        ///< Generate trees
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    55
	GWP_GAME_INIT,   ///< Initialize the game
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    56
	GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    57
	GWP_GAME_START,  ///< Really prepare to start the game
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    58
	GWP_CLASS_COUNT
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    59
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    60
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    61
/**
c7e43c47a2b9 (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.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    63
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    64
static inline bool IsGeneratingWorld()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    65
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    66
	extern gw_info _gw;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    67
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    68
	return _gw.active;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    69
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    70
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    71
/* genworld.cpp */
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    72
void SetGeneratingWorldPaintStatus(bool status);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    73
bool IsGeneratingWorldReadyForPaint();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    74
bool IsGenerateWorldThreaded();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    75
void GenerateWorldSetCallback(gw_done_proc *proc);
5145
d4a8882b32ef (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);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    77
void WaitTillGeneratedWorld();
9409
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9111
diff changeset
    78
void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    79
void AbortGeneratingWorld();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    80
bool IsGeneratingWorldAborted();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    81
void HandleGeneratingWorldAbortion();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    82
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5899
diff changeset
    83
/* genworld_gui.cpp */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    84
void SetGeneratingWorldProgress(gwp_class cls, uint total);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    85
void IncreaseGeneratingWorldProgress(gwp_class cls);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    86
void PrepareGenerateWorldProgress();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    87
void ShowGenerateWorldProgress();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    88
void StartNewGameWithoutGUI(uint seed);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    89
void ShowCreateScenario();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    90
void StartScenarioEditor();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    91
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    92
#endif /* GENWORLD_H */