truelight@4300: /* $Id$ */ truelight@4300: rubidium@10455: /** @file genworld.h Functions related to world/map generation. */ belugas@6505: truelight@4300: #ifndef GENWORLD_H truelight@4300: #define GENWORLD_H truelight@4300: rubidium@9724: #include "player_type.h" rubidium@9724: 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 { belugas@6505: LG_ORIGINAL = 0, ///< The original landscape generator belugas@6505: LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator truelight@4300: belugas@6505: GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed truelight@4300: }; truelight@4300: glx@10776: /* Modes for GenerateWorld */ glx@10776: enum GenerateWorldMode { glx@10776: GW_NEWGAME = 0, /* Generate a map for a new game */ glx@10776: GW_EMPTY = 1, /* Generate an empty map (sea-level) */ glx@10776: GW_RANDOM = 2, /* Generate a random map for SE */ glx@10776: GW_HEIGHTMAP = 3, /* Generate a newgame from a heightmap */ glx@10776: }; glx@10776: rubidium@6573: typedef void gw_done_proc(); rubidium@6573: typedef void gw_abort_proc(); truelight@4300: rubidium@6574: struct gw_info { belugas@6505: bool active; ///< Is generating world active belugas@6505: bool abort; ///< Whether to abort the thread ASAP belugas@6505: bool wait_for_draw; ///< Are we waiting on a draw event belugas@6505: bool quit_thread; ///< Do we want to quit the active thread belugas@6505: bool threaded; ///< Whether we run _GenerateWorld threaded glx@10776: GenerateWorldMode mode;///< What mode are we making a world in belugas@6505: PlayerID lp; ///< The local_player before generating belugas@6505: uint size_x; ///< X-size of the map belugas@6505: uint size_y; ///< Y-size of the map belugas@6505: gw_done_proc *proc; ///< Proc that is called when done (can be NULL) belugas@6505: gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL) rubidium@10172: class ThreadObject *thread; ///< The thread we are in (can be NULL) rubidium@6574: }; truelight@4300: rubidium@6574: enum gwp_class { belugas@6505: GWP_MAP_INIT, ///< Initialize/allocate the map, start economy belugas@6505: GWP_LANDSCAPE, ///< Create the landscape belugas@6505: GWP_ROUGH_ROCKY, ///< Make rough and rocky areas belugas@6505: GWP_TOWN, ///< Generate towns belugas@6505: GWP_INDUSTRY, ///< Generate industries belugas@6505: GWP_UNMOVABLE, ///< Generate unmovables (radio tower, light houses) belugas@6505: GWP_TREE, ///< Generate trees belugas@6505: GWP_GAME_INIT, ///< Initialize the game belugas@6505: GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc belugas@6505: GWP_GAME_START, ///< Really prepare to start the game truelight@4300: GWP_CLASS_COUNT rubidium@6574: }; truelight@4300: truelight@4300: /** truelight@4300: * Check if we are currently in the process of generating a world. truelight@4300: */ rubidium@6573: static inline bool IsGeneratingWorld() truelight@4300: { truelight@4300: extern gw_info _gw; truelight@4300: truelight@4300: return _gw.active; truelight@4300: } truelight@4300: belugas@6505: /* genworld.cpp */ truelight@4300: void SetGeneratingWorldPaintStatus(bool status); rubidium@6573: bool IsGeneratingWorldReadyForPaint(); rubidium@6573: bool IsGenerateWorldThreaded(); truelight@4300: void GenerateWorldSetCallback(gw_done_proc *proc); rubidium@5145: void GenerateWorldSetAbortCallback(gw_abort_proc *proc); rubidium@6573: void WaitTillGeneratedWorld(); glx@10776: void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y); rubidium@6573: void AbortGeneratingWorld(); rubidium@6573: bool IsGeneratingWorldAborted(); rubidium@6573: void HandleGeneratingWorldAbortion(); truelight@4300: belugas@6505: /* genworld_gui.cpp */ rubidium@5838: void SetGeneratingWorldProgress(gwp_class cls, uint total); rubidium@5838: void IncreaseGeneratingWorldProgress(gwp_class cls); rubidium@6573: void PrepareGenerateWorldProgress(); rubidium@6573: void ShowGenerateWorldProgress(); truelight@4300: void StartNewGameWithoutGUI(uint seed); rubidium@6573: void ShowCreateScenario(); rubidium@6573: void StartScenarioEditor(); truelight@4300: truelight@4300: #endif /* GENWORLD_H */