truelight@4300: /* $Id$ */ truelight@4300: truelight@4300: #ifndef GENWORLD_H truelight@4300: #define GENWORLD_H truelight@4300: truelight@4300: /* If OTTDThread isn't defined, define it to a void, but make sure to undefine truelight@4300: * it after this include. This makes including genworld.h easier, as you truelight@4300: * don't need to include thread.h before it, while it stays possible to truelight@4300: * include it after it, and still work. truelight@4300: */ truelight@4300: #ifndef OTTDThread truelight@4300: #define TEMPORARY_OTTDTHREAD_DEFINITION truelight@4300: #define OTTDThread void truelight@4300: #endif truelight@4300: truelight@4300: /* truelight@4300: * Order of these enums has to be the same as in lang/english.txt truelight@4300: * Otherwise you will get inconsistent behaviour. truelight@4300: */ truelight@4300: enum { truelight@4300: LG_ORIGINAL = 0, //! The original landscape generator truelight@4300: LG_TERRAGENESIS = 1, //! TerraGenesis Perlin landscape generator truelight@4300: truelight@4300: GENERATE_NEW_SEED = (uint)-1, //! Create a new random seed truelight@4300: }; truelight@4300: truelight@4300: typedef void gw_done_proc(void); rubidium@5145: typedef void gw_abort_proc(void); truelight@4300: truelight@4300: typedef struct gw_info { truelight@4300: bool active; //! Is generating world active truelight@4300: bool abort; //! Whether to abort the thread ASAP truelight@4300: bool wait_for_draw; //! Are we waiting on a draw event truelight@4300: bool quit_thread; //! Do we want to quit the active thread truelight@4300: bool threaded; //! Whether we run _GenerateWorld threaded truelight@4300: int mode; //! What mode are we making a world in truelight@4300: byte lp; //! The local_player before generating truelight@4300: uint size_x; //! X-size of the map truelight@4300: uint size_y; //! Y-size of the map truelight@4300: gw_done_proc *proc; //! Proc that is called when done (can be NULL) rubidium@5145: gw_abort_proc *abortp; //! Proc that is called when aborting (can be NULL) truelight@4300: OTTDThread *thread; //! The thread we are in (can be NULL) truelight@4300: } gw_info; truelight@4300: truelight@4300: #ifdef TEMPORARY_OTTDTHREAD_DEFINITION truelight@4300: #undef OTTDThread truelight@4300: #undef TEMPORARY_OTTDTHREAD_DEFINITION truelight@4300: #endif truelight@4300: truelight@4300: typedef enum gwp_classes { truelight@4300: GWP_MAP_INIT, /* Initialize/allocate the map, start economy */ truelight@4300: GWP_LANDSCAPE, /* Create the landscape */ truelight@4300: GWP_ROUGH_ROCKY, /* Make rough and rocky areas */ truelight@4300: GWP_TOWN, /* Generate towns */ truelight@4300: GWP_INDUSTRY, /* Generate industries */ truelight@4300: GWP_UNMOVABLE, /* Generate unmovables (radio tower, light houses) */ truelight@4300: GWP_TREE, /* Generate trees */ truelight@4300: GWP_GAME_INIT, /* Initialize the game */ truelight@4300: GWP_RUNTILELOOP, /* Runs the tile loop 1280 times to make snow etc */ truelight@4300: GWP_GAME_START, /* Really prepare to start the game */ truelight@4300: GWP_CLASS_COUNT truelight@4300: } gwp_class; truelight@4300: truelight@4300: /** truelight@4300: * Check if we are currently in the process of generating a world. truelight@4300: */ truelight@4300: static inline bool IsGeneratingWorld(void) truelight@4300: { truelight@4300: extern gw_info _gw; truelight@4300: truelight@4300: return _gw.active; truelight@4300: } truelight@4300: truelight@4300: /* genworld.c */ truelight@4300: void SetGeneratingWorldPaintStatus(bool status); truelight@4300: bool IsGeneratingWorldReadyForPaint(void); truelight@4300: bool IsGenerateWorldThreaded(void); truelight@4300: void GenerateWorldSetCallback(gw_done_proc *proc); rubidium@5145: void GenerateWorldSetAbortCallback(gw_abort_proc *proc); truelight@4300: void WaitTillGeneratedWorld(void); truelight@4300: void GenerateWorld(int mode, uint size_x, uint size_y); truelight@4300: void AbortGeneratingWorld(void); truelight@4300: bool IsGeneratingWorldAborted(void); truelight@4300: void HandleGeneratingWorldAbortion(void); truelight@4300: truelight@4300: /* genworld_gui.c */ truelight@4300: void SetGeneratingWorldProgress(gwp_class class, uint total); truelight@4300: void IncreaseGeneratingWorldProgress(gwp_class class); truelight@4300: void PrepareGenerateWorldProgress(void); truelight@4300: void ShowGenerateWorldProgress(void); truelight@4300: void StartNewGameWithoutGUI(uint seed); truelight@4300: void ShowCreateScenario(void); truelight@4300: truelight@4300: #endif /* GENWORLD_H */