src/genworld.h
branchcpp_gui
changeset 6285 187e3ef04cc9
parent 6150 648233476115
child 6298 c30fe89622df
child 6573 7624f942237f
equal deleted inserted replaced
6284:45d0233e7d79 6285:187e3ef04cc9
     1 /* $Id$ */
     1 /* $Id$ */
       
     2 
       
     3 /** @file genworld.h */
     2 
     4 
     3 #ifndef GENWORLD_H
     5 #ifndef GENWORLD_H
     4 #define GENWORLD_H
     6 #define GENWORLD_H
     5 
     7 
     6 /* If OTTDThread isn't defined, define it to a void, but make sure to undefine
     8 /* If OTTDThread isn't defined, define it to a void, but make sure to undefine
    16 /*
    18 /*
    17  * Order of these enums has to be the same as in lang/english.txt
    19  * Order of these enums has to be the same as in lang/english.txt
    18  * Otherwise you will get inconsistent behaviour.
    20  * Otherwise you will get inconsistent behaviour.
    19  */
    21  */
    20 enum {
    22 enum {
    21 	LG_ORIGINAL     = 0,  //! The original landscape generator
    23 	LG_ORIGINAL     = 0,  ///< The original landscape generator
    22 	LG_TERRAGENESIS = 1,  //! TerraGenesis Perlin landscape generator
    24 	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
    23 
    25 
    24 	GENERATE_NEW_SEED = (uint)-1, //! Create a new random seed
    26 	GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed
    25 };
    27 };
    26 
    28 
    27 typedef void gw_done_proc(void);
    29 typedef void gw_done_proc(void);
    28 typedef void gw_abort_proc(void);
    30 typedef void gw_abort_proc(void);
    29 
    31 
    30 typedef struct gw_info {
    32 typedef struct gw_info {
    31 	bool active;           //! Is generating world active
    33 	bool active;           ///< Is generating world active
    32 	bool abort;            //! Whether to abort the thread ASAP
    34 	bool abort;            ///< Whether to abort the thread ASAP
    33 	bool wait_for_draw;    //! Are we waiting on a draw event
    35 	bool wait_for_draw;    ///< Are we waiting on a draw event
    34 	bool quit_thread;      //! Do we want to quit the active thread
    36 	bool quit_thread;      ///< Do we want to quit the active thread
    35 	bool threaded;         //! Whether we run _GenerateWorld threaded
    37 	bool threaded;         ///< Whether we run _GenerateWorld threaded
    36 	int mode;              //! What mode are we making a world in
    38 	int mode;              ///< What mode are we making a world in
    37 	PlayerID lp;               //! The local_player before generating
    39 	PlayerID lp;           ///< The local_player before generating
    38 	uint size_x;           //! X-size of the map
    40 	uint size_x;           ///< X-size of the map
    39 	uint size_y;           //! Y-size of the map
    41 	uint size_y;           ///< Y-size of the map
    40 	gw_done_proc *proc;    //! Proc that is called when done (can be NULL)
    42 	gw_done_proc *proc;    ///< Proc that is called when done (can be NULL)
    41 	gw_abort_proc *abortp; //! Proc that is called when aborting (can be NULL)
    43 	gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL)
    42 	OTTDThread *thread;    //! The thread we are in (can be NULL)
    44 	OTTDThread *thread;    ///< The thread we are in (can be NULL)
    43 } gw_info;
    45 } gw_info;
    44 
    46 
    45 #ifdef TEMPORARY_OTTDTHREAD_DEFINITION
    47 #ifdef TEMPORARY_OTTDTHREAD_DEFINITION
    46 #undef OTTDThread
    48 #undef OTTDThread
    47 #undef TEMPORARY_OTTDTHREAD_DEFINITION
    49 #undef TEMPORARY_OTTDTHREAD_DEFINITION
    48 #endif
    50 #endif
    49 
    51 
    50 typedef enum gwp_classes {
    52 typedef enum gwp_classes {
    51 	GWP_MAP_INIT,    /* Initialize/allocate the map, start economy */
    53 	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
    52 	GWP_LANDSCAPE,   /* Create the landscape */
    54 	GWP_LANDSCAPE,   ///< Create the landscape
    53 	GWP_ROUGH_ROCKY, /* Make rough and rocky areas */
    55 	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
    54 	GWP_TOWN,        /* Generate towns */
    56 	GWP_TOWN,        ///< Generate towns
    55 	GWP_INDUSTRY,    /* Generate industries */
    57 	GWP_INDUSTRY,    ///< Generate industries
    56 	GWP_UNMOVABLE,   /* Generate unmovables (radio tower, light houses) */
    58 	GWP_UNMOVABLE,   ///< Generate unmovables (radio tower, light houses)
    57 	GWP_TREE,        /* Generate trees */
    59 	GWP_TREE,        ///< Generate trees
    58 	GWP_GAME_INIT,   /* Initialize the game */
    60 	GWP_GAME_INIT,   ///< Initialize the game
    59 	GWP_RUNTILELOOP, /* Runs the tile loop 1280 times to make snow etc */
    61 	GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc
    60 	GWP_GAME_START,  /* Really prepare to start the game */
    62 	GWP_GAME_START,  ///< Really prepare to start the game
    61 	GWP_CLASS_COUNT
    63 	GWP_CLASS_COUNT
    62 } gwp_class;
    64 } gwp_class;
    63 
    65 
    64 /**
    66 /**
    65  * Check if we are currently in the process of generating a world.
    67  * Check if we are currently in the process of generating a world.
    69 	extern gw_info _gw;
    71 	extern gw_info _gw;
    70 
    72 
    71 	return _gw.active;
    73 	return _gw.active;
    72 }
    74 }
    73 
    75 
    74 /* genworld.c */
    76 /* genworld.cpp */
    75 void SetGeneratingWorldPaintStatus(bool status);
    77 void SetGeneratingWorldPaintStatus(bool status);
    76 bool IsGeneratingWorldReadyForPaint(void);
    78 bool IsGeneratingWorldReadyForPaint(void);
    77 bool IsGenerateWorldThreaded(void);
    79 bool IsGenerateWorldThreaded(void);
    78 void GenerateWorldSetCallback(gw_done_proc *proc);
    80 void GenerateWorldSetCallback(gw_done_proc *proc);
    79 void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
    81 void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
    81 void GenerateWorld(int mode, uint size_x, uint size_y);
    83 void GenerateWorld(int mode, uint size_x, uint size_y);
    82 void AbortGeneratingWorld(void);
    84 void AbortGeneratingWorld(void);
    83 bool IsGeneratingWorldAborted(void);
    85 bool IsGeneratingWorldAborted(void);
    84 void HandleGeneratingWorldAbortion(void);
    86 void HandleGeneratingWorldAbortion(void);
    85 
    87 
    86 /* genworld_gui.c */
    88 /* genworld_gui.cpp */
    87 void SetGeneratingWorldProgress(gwp_class cls, uint total);
    89 void SetGeneratingWorldProgress(gwp_class cls, uint total);
    88 void IncreaseGeneratingWorldProgress(gwp_class cls);
    90 void IncreaseGeneratingWorldProgress(gwp_class cls);
    89 void PrepareGenerateWorldProgress(void);
    91 void PrepareGenerateWorldProgress(void);
    90 void ShowGenerateWorldProgress(void);
    92 void ShowGenerateWorldProgress(void);
    91 void StartNewGameWithoutGUI(uint seed);
    93 void StartNewGameWithoutGUI(uint seed);