# genworld.h

Go to the documentation of this file.

    00001 /* $Id: genworld.h 17248 2009-08-21 20:21:05Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef GENWORLD_H
    00013 #define GENWORLD_H
    00014
    00015 #include "company_type.h"
    00016
    00017 /*
    00018  * Order of these enums has to be the same as in lang/english.txt
    00019  * Otherwise you will get inconsistent behaviour.
    00020  */
    00021 enum {
    00022   LG_ORIGINAL     = 0,
    00023   LG_TERRAGENESIS = 1,
    00024
    00025   GENERATE_NEW_SEED = UINT_MAX,
    00026
    00027   GENWORLD_REDRAW_TIMEOUT = 200,
    00028 };
    00029
    00030 /* Modes for GenerateWorld */
    00031 enum GenerateWorldMode {
    00032   GW_NEWGAME   = 0,
    00033   GW_EMPTY     = 1,
    00034   GW_RANDOM    = 2,
    00035   GW_HEIGHTMAP = 3,
    00036 };
    00037
    00038 typedef void gw_done_proc();
    00039 typedef void gw_abort_proc();
    00040
    00041 struct gw_info {
    00042   bool active;
    00043   bool abort;
    00044   bool quit_thread;
    00045   bool threaded;
    00046   GenerateWorldMode mode;
    00047   CompanyID lc;
    00048   uint size_x;
    00049   uint size_y;
    00050   gw_done_proc *proc;
    00051   gw_abort_proc *abortp;
    00052   class ThreadObject *thread;
    00053 };
    00054
    00055 enum gwp_class {
    00056   GWP_MAP_INIT,
    00057   GWP_LANDSCAPE,
    00058   GWP_ROUGH_ROCKY,
    00059   GWP_TOWN,
    00060   GWP_INDUSTRY,
    00061   GWP_UNMOVABLE,
    00062   GWP_TREE,
    00063   GWP_GAME_INIT,
    00064   GWP_RUNTILELOOP,
    00065   GWP_GAME_START,
    00066   GWP_CLASS_COUNT
    00067 };
    00068
    00072 static inline bool IsGeneratingWorld()
    00073 {
    00074   extern gw_info _gw;
    00075
    00076   return _gw.active;
    00077 }
    00078
    00079 /* genworld.cpp */
    00080 bool IsGenerateWorldThreaded();
    00081 void GenerateWorldSetCallback(gw_done_proc *proc);
    00082 void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
    00083 void WaitTillGeneratedWorld();
    00084 void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
    00085 void AbortGeneratingWorld();
    00086 bool IsGeneratingWorldAborted();
    00087 void HandleGeneratingWorldAbortion();
    00088
    00089 /* genworld_gui.cpp */
    00090 void SetGeneratingWorldProgress(gwp_class cls, uint total);
    00091 void IncreaseGeneratingWorldProgress(gwp_class cls);
    00092 void PrepareGenerateWorldProgress();
    00093 void ShowGenerateWorldProgress();
    00094 void StartNewGameWithoutGUI(uint seed);
    00095 void ShowCreateScenario();
    00096 void StartScenarioEditor();
    00097
    00098 extern class ThreadMutex *_genworld_mapgen_mutex;
    00099 extern class ThreadMutex *_genworld_paint_mutex;
    00100
    00101 #endif /* GENWORLD_H */