genworld.cpp File Reference

Functions to generate a map. More...

#include "stdafx.h"
#include "openttd.h"
#include "landscape.h"
#include "company_func.h"
#include "variables.h"
#include "thread/thread.h"
#include "command_func.h"
#include "genworld.h"
#include "gfxinit.h"
#include "window_func.h"
#include "network/network.h"
#include "heightmap.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "date_func.h"
#include "engine_func.h"
#include "newgrf_storage.h"
#include "water.h"
#include "blitter/factory.hpp"
#include "tilehighlight_func.h"
#include "saveload/saveload.h"
#include "void_map.h"
#include "town.h"
#include "newgrf.h"
#include "core/random_func.hpp"
#include "table/sprites.h"

Go to the source code of this file.

Functions

void GenerateClearTile ()
void GenerateIndustries ()
 This function will create random industries during game creation.
void GenerateUnmovables ()
void GenerateTrees ()
 Place new trees.
void StartupEconomy ()
void StartupCompanies ()
void StartupDisasters ()
void InitializeGame (uint size_x, uint size_y, bool reset_date, bool reset_settings)
bool IsGenerateWorldThreaded ()
 Tells if the world generation is done in a thread or not.
static void CleanupGeneration ()
 Clean up the 'mess' of generation.
static void _GenerateWorld (void *)
 The internal, real, generate function.
void GenerateWorldSetCallback (GWDoneProc *proc)
 Set here the function, if any, that you want to be called when landscape generation is done.
void GenerateWorldSetAbortCallback (GWAbortProc *proc)
 Set here the function, if any, that you want to be called when landscape generation is aborted.
void WaitTillGeneratedWorld ()
 This will wait for the thread to finish up his work.
void AbortGeneratingWorld ()
 Initializes the abortion process.
bool IsGeneratingWorldAborted ()
 Is the generation being aborted?
void HandleGeneratingWorldAbortion ()
 Really handle the abortion, i.e.
void GenerateWorld (GenWorldMode mode, uint size_x, uint size_y, bool reset_settings)
 Generate a world.

Variables

GenWorldInfo _gw
 Please only use this variable in genworld.h and genworld.cpp and nowhere else.
ThreadMutex_genworld_mapgen_mutex = ThreadMutex::New()
 Rights for the map generation.
ThreadMutex_genworld_paint_mutex = ThreadMutex::New()
 Rights for the painting.

Detailed Description

Functions to generate a map.

Definition in file genworld.cpp.


Function Documentation

static void CleanupGeneration (  )  [static]

Clean up the 'mess' of generation.

That is show windows again, reset thread variables and delete the progress window.

Definition at line 77 of file genworld.cpp.

References GenWorldInfo::abortp, GenWorldInfo::active, DeleteWindowById(), ThreadMutex::EndCritical(), MarkWholeScreenDirty(), GenWorldInfo::proc, SPR_CURSOR_MOUSE, CursorVars::sprite, and GenWorldInfo::threaded.

Referenced by _GenerateWorld(), and HandleGeneratingWorldAbortion().

void GenerateIndustries (  ) 

This function will create random industries during game creation.

It will scale the amount of industries by mapsize and difficulty level.

Definition at line 1862 of file industry_cmd.cpp.

References _settings_game, GameSettings::difficulty, GetScaledIndustryProbability(), GWP_INDUSTRY, lengthof, NUM_INDUSTRYTYPES, DifficultySettings::number_industries, PlaceInitialIndustry(), ScaleByMapSize(), and SetGeneratingWorldProgress().

Referenced by _GenerateWorld(), and BuildIndustryWindow::OnClick().

void GenerateTrees (  ) 

Place new trees.

This function takes care of the selected tree placer algorithm and place randomly the trees for a new game.

Definition at line 312 of file tree_cmd.cpp.

References _settings_game, GameSettings::game_creation, GWP_TREE, GameCreationSettings::landscape, PlaceMoreTrees(), PlaceTreesRandomly(), ScaleByMapSize(), SetGeneratingWorldProgress(), TP_IMPROVED, TP_NONE, TP_ORIGINAL, and GameCreationSettings::tree_placer.

Referenced by _GenerateWorld().

void GenerateWorld ( GenWorldMode  mode,
uint  size_x,
uint  size_y,
bool  reset_settings 
)
void GenerateWorldSetAbortCallback ( GWAbortProc proc  ) 

Set here the function, if any, that you want to be called when landscape generation is aborted.

Parameters:
proc callback procedure

Definition at line 208 of file genworld.cpp.

References GenWorldInfo::abortp.

Referenced by GenerateTerrainPerlin().

void GenerateWorldSetCallback ( GWDoneProc proc  ) 

Set here the function, if any, that you want to be called when landscape generation is done.

Parameters:
proc callback procedure

Definition at line 198 of file genworld.cpp.

References GenWorldInfo::proc.

void HandleGeneratingWorldAbortion (  ) 

Really handle the abortion, i.e.

clean up some of the mess

Definition at line 252 of file genworld.cpp.

References _switch_mode, GenWorldInfo::abortp, CleanupGeneration(), ThreadObject::Exit(), and GenWorldInfo::thread.

Referenced by _GenerateWorld().

bool IsGenerateWorldThreaded (  ) 

Tells if the world generation is done in a thread or not.

Returns:
the 'threaded' status

Definition at line 68 of file genworld.cpp.

References GenWorldInfo::quit_thread, and GenWorldInfo::threaded.

bool IsGeneratingWorldAborted (  ) 

Is the generation being aborted?

Returns:
the 'aborted' status

Definition at line 244 of file genworld.cpp.

References GenWorldInfo::abort.

void WaitTillGeneratedWorld (  ) 

This will wait for the thread to finish up his work.

It will not continue till the work is done.

Definition at line 217 of file genworld.cpp.

References ThreadMutex::BeginCritical(), ThreadMutex::EndCritical(), ThreadObject::Join(), GenWorldInfo::quit_thread, GenWorldInfo::thread, and GenWorldInfo::threaded.


Variable Documentation

Please only use this variable in genworld.h and genworld.cpp and nowhere else.

For speed improvements we need it to be global, but in no way the meaning of it is to use it anywhere else besides in the genworld.h and genworld.cpp! -- TrueLight

Definition at line 57 of file genworld.cpp.

Referenced by IsGeneratingWorld().


Generated on Sat Jul 17 18:43:29 2010 for OpenTTD by  doxygen 1.6.1