src/genworld.h
branchcpp_gui
changeset 6298 c30fe89622df
parent 6285 187e3ef04cc9
equal deleted inserted replaced
6297:4bf29d14edba 6298:c30fe89622df
    24 	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
    24 	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
    25 
    25 
    26 	GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed
    26 	GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed
    27 };
    27 };
    28 
    28 
    29 typedef void gw_done_proc(void);
    29 typedef void gw_done_proc();
    30 typedef void gw_abort_proc(void);
    30 typedef void gw_abort_proc();
    31 
    31 
    32 typedef struct gw_info {
    32 struct gw_info {
    33 	bool active;           ///< Is generating world active
    33 	bool active;           ///< Is generating world active
    34 	bool abort;            ///< Whether to abort the thread ASAP
    34 	bool abort;            ///< Whether to abort the thread ASAP
    35 	bool wait_for_draw;    ///< Are we waiting on a draw event
    35 	bool wait_for_draw;    ///< Are we waiting on a draw event
    36 	bool quit_thread;      ///< Do we want to quit the active thread
    36 	bool quit_thread;      ///< Do we want to quit the active thread
    37 	bool threaded;         ///< Whether we run _GenerateWorld threaded
    37 	bool threaded;         ///< Whether we run _GenerateWorld threaded
    40 	uint size_x;           ///< X-size of the map
    40 	uint size_x;           ///< X-size of the map
    41 	uint size_y;           ///< Y-size of the map
    41 	uint size_y;           ///< Y-size of the map
    42 	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)
    43 	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)
    44 	OTTDThread *thread;    ///< The thread we are in (can be NULL)
    44 	OTTDThread *thread;    ///< The thread we are in (can be NULL)
    45 } gw_info;
    45 };
    46 
    46 
    47 #ifdef TEMPORARY_OTTDTHREAD_DEFINITION
    47 #ifdef TEMPORARY_OTTDTHREAD_DEFINITION
    48 #undef OTTDThread
    48 #undef OTTDThread
    49 #undef TEMPORARY_OTTDTHREAD_DEFINITION
    49 #undef TEMPORARY_OTTDTHREAD_DEFINITION
    50 #endif
    50 #endif
    51 
    51 
    52 typedef enum gwp_classes {
    52 enum gwp_class {
    53 	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
    53 	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
    54 	GWP_LANDSCAPE,   ///< Create the landscape
    54 	GWP_LANDSCAPE,   ///< Create the landscape
    55 	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
    55 	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
    56 	GWP_TOWN,        ///< Generate towns
    56 	GWP_TOWN,        ///< Generate towns
    57 	GWP_INDUSTRY,    ///< Generate industries
    57 	GWP_INDUSTRY,    ///< Generate industries
    59 	GWP_TREE,        ///< Generate trees
    59 	GWP_TREE,        ///< Generate trees
    60 	GWP_GAME_INIT,   ///< Initialize the game
    60 	GWP_GAME_INIT,   ///< Initialize the game
    61 	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
    62 	GWP_GAME_START,  ///< Really prepare to start the game
    62 	GWP_GAME_START,  ///< Really prepare to start the game
    63 	GWP_CLASS_COUNT
    63 	GWP_CLASS_COUNT
    64 } gwp_class;
    64 };
    65 
    65 
    66 /**
    66 /**
    67  * 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.
    68  */
    68  */
    69 static inline bool IsGeneratingWorld(void)
    69 static inline bool IsGeneratingWorld()
    70 {
    70 {
    71 	extern gw_info _gw;
    71 	extern gw_info _gw;
    72 
    72 
    73 	return _gw.active;
    73 	return _gw.active;
    74 }
    74 }
    75 
    75 
    76 /* genworld.cpp */
    76 /* genworld.cpp */
    77 void SetGeneratingWorldPaintStatus(bool status);
    77 void SetGeneratingWorldPaintStatus(bool status);
    78 bool IsGeneratingWorldReadyForPaint(void);
    78 bool IsGeneratingWorldReadyForPaint();
    79 bool IsGenerateWorldThreaded(void);
    79 bool IsGenerateWorldThreaded();
    80 void GenerateWorldSetCallback(gw_done_proc *proc);
    80 void GenerateWorldSetCallback(gw_done_proc *proc);
    81 void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
    81 void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
    82 void WaitTillGeneratedWorld(void);
    82 void WaitTillGeneratedWorld();
    83 void GenerateWorld(int mode, uint size_x, uint size_y);
    83 void GenerateWorld(int mode, uint size_x, uint size_y);
    84 void AbortGeneratingWorld(void);
    84 void AbortGeneratingWorld();
    85 bool IsGeneratingWorldAborted(void);
    85 bool IsGeneratingWorldAborted();
    86 void HandleGeneratingWorldAbortion(void);
    86 void HandleGeneratingWorldAbortion();
    87 
    87 
    88 /* genworld_gui.cpp */
    88 /* genworld_gui.cpp */
    89 void SetGeneratingWorldProgress(gwp_class cls, uint total);
    89 void SetGeneratingWorldProgress(gwp_class cls, uint total);
    90 void IncreaseGeneratingWorldProgress(gwp_class cls);
    90 void IncreaseGeneratingWorldProgress(gwp_class cls);
    91 void PrepareGenerateWorldProgress(void);
    91 void PrepareGenerateWorldProgress();
    92 void ShowGenerateWorldProgress(void);
    92 void ShowGenerateWorldProgress();
    93 void StartNewGameWithoutGUI(uint seed);
    93 void StartNewGameWithoutGUI(uint seed);
    94 void ShowCreateScenario(void);
    94 void ShowCreateScenario();
    95 void StartScenarioEditor(void);
    95 void StartScenarioEditor();
    96 
    96 
    97 #endif /* GENWORLD_H */
    97 #endif /* GENWORLD_H */