genworld.h

Go to the documentation of this file.
00001 /* $Id: genworld.h 23611 2011-12-19 20:56:50Z truebrain $ */
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 
00018 enum LandscapeGenerator {
00019   /* Order of these enums has to be the same as in lang/english.txt
00020    * Otherwise you will get inconsistent behaviour. */
00021   LG_ORIGINAL     = 0,  
00022   LG_TERRAGENESIS = 1,  
00023 };
00024 
00025 static const uint GENERATE_NEW_SEED = UINT_MAX; 
00026 
00028 enum GenWorldMode {
00029   GWM_NEWGAME   = 0, 
00030   GWM_EMPTY     = 1, 
00031   GWM_RANDOM    = 2, 
00032   GWM_HEIGHTMAP = 3, 
00033 };
00034 
00035 static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4; 
00036 static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1;    
00037 static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90;   
00038 
00039 typedef void GWDoneProc();  
00040 typedef void GWAbortProc(); 
00041 
00043 struct GenWorldInfo {
00044   bool abort;            
00045   bool quit_thread;      
00046   bool threaded;         
00047   GenWorldMode mode;     
00048   CompanyID lc;          
00049   uint size_x;           
00050   uint size_y;           
00051   GWDoneProc *proc;      
00052   GWAbortProc *abortp;   
00053   class ThreadObject *thread; 
00054 };
00055 
00057 enum GenWorldProgress {
00058   GWP_MAP_INIT,    
00059   GWP_LANDSCAPE,   
00060   GWP_RIVER,       
00061   GWP_ROUGH_ROCKY, 
00062   GWP_TOWN,        
00063   GWP_INDUSTRY,    
00064   GWP_OBJECT,      
00065   GWP_TREE,        
00066   GWP_GAME_INIT,   
00067   GWP_RUNTILELOOP, 
00068   GWP_RUNSCRIPT,   
00069   GWP_GAME_START,  
00070   GWP_CLASS_COUNT
00071 };
00072 
00073 /* genworld.cpp */
00074 bool IsGenerateWorldThreaded();
00075 void GenerateWorldSetCallback(GWDoneProc *proc);
00076 void GenerateWorldSetAbortCallback(GWAbortProc *proc);
00077 void WaitTillGeneratedWorld();
00078 void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
00079 void AbortGeneratingWorld();
00080 bool IsGeneratingWorldAborted();
00081 void HandleGeneratingWorldAbortion();
00082 
00083 /* genworld_gui.cpp */
00084 void SetNewLandscapeType(byte landscape);
00085 void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
00086 void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
00087 void PrepareGenerateWorldProgress();
00088 void ShowGenerateWorldProgress();
00089 void StartNewGameWithoutGUI(uint seed);
00090 void ShowCreateScenario();
00091 void StartScenarioEditor();
00092 
00093 extern bool _generating_world;
00094 
00095 #endif /* GENWORLD_H */