Files @ r24860:fb2788d47d86
Branch filter:

Location: cpp/openttd-patchpack/source/src/genworld.h - annotation

Michael Lutz
Codechange: [OSX] Only keep a total dirty rect for drawing.

When drawing an 8bpp screen buffer, palette resolving was done for each
dirty rectangle. In areas with high activity, this would mean a pixel might
have been resolved multiple times. Also, if too many individual updates
were queued, the whole screen would be refreshed, even if unnecessary.

All other drivers only keep one overall dirty rect, so do it here as well.
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r12768:980ae0491352
r9111:983de9c5a848
r6179:c0508e7aefec
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r5475:3f5cd13d1b63
r10208:ef8fcc3dc4ca
r23587:821735a25dec
r8254:b96be9ebfc6e
r14299:dd117ea5dfbf
r15173:a59afd6301a6
r14299:dd117ea5dfbf
r14299:dd117ea5dfbf
r6179:c0508e7aefec
r6179:c0508e7aefec
r15173:a59afd6301a6
r11825:adc3045ab0f2
r23013:aaf297d79037
r5475:3f5cd13d1b63
r14299:dd117ea5dfbf
r14291:b7b327a367bf
r14291:b7b327a367bf
r14291:b7b327a367bf
r14291:b7b327a367bf
r14291:b7b327a367bf
r9409:e2f52fd75f31
r9409:e2f52fd75f31
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r22067:d003cbe50494
r16127:bc7a0303d95c
r16127:bc7a0303d95c
r16127:bc7a0303d95c
r16126:3b43532e6039
r14299:dd117ea5dfbf
r14299:dd117ea5dfbf
r5475:3f5cd13d1b63
r14299:dd117ea5dfbf
r14291:b7b327a367bf
r6179:c0508e7aefec
r6179:c0508e7aefec
r6179:c0508e7aefec
r14291:b7b327a367bf
r10207:a1fc2f2a33db
r6179:c0508e7aefec
r6179:c0508e7aefec
r23607:36c15679007d
r23607:36c15679007d
r23587:821735a25dec
r6248:b940b09d7ab8
r5475:3f5cd13d1b63
r14299:dd117ea5dfbf
r14291:b7b327a367bf
r6179:c0508e7aefec
r6179:c0508e7aefec
r17949:186ea361bd8c
r6179:c0508e7aefec
r6179:c0508e7aefec
r6179:c0508e7aefec
r15734:ae8e2e185874
r6179:c0508e7aefec
r6179:c0508e7aefec
r6179:c0508e7aefec
r18753:19e74c935c2d
r6179:c0508e7aefec
r5475:3f5cd13d1b63
r6248:b940b09d7ab8
r5475:3f5cd13d1b63
r6179:c0508e7aefec
r6247:96e840dbefcc
r14291:b7b327a367bf
r14291:b7b327a367bf
r6247:96e840dbefcc
r14291:b7b327a367bf
r6247:96e840dbefcc
r6247:96e840dbefcc
r6247:96e840dbefcc
r5475:3f5cd13d1b63
r6179:c0508e7aefec
r15227:6ee8e499e653
r14291:b7b327a367bf
r14291:b7b327a367bf
r6247:96e840dbefcc
r6247:96e840dbefcc
r23013:aaf297d79037
r6247:96e840dbefcc
r6247:96e840dbefcc
r5475:3f5cd13d1b63
r15521:545d58d62089
r11825:adc3045ab0f2
r5475:3f5cd13d1b63
/*
 * This file is part of OpenTTD.
 * 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.
 * 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.
 * 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/>.
 */

/** @file genworld.h Functions related to world/map generation. */

#ifndef GENWORLD_H
#define GENWORLD_H

#include "company_type.h"
#include <thread>

/** Constants related to world generation */
enum LandscapeGenerator {
	/* Order of these enums has to be the same as in lang/english.txt
	 * Otherwise you will get inconsistent behaviour. */
	LG_ORIGINAL     = 0,  ///< The original landscape generator
	LG_TERRAGENESIS = 1,  ///< TerraGenesis Perlin landscape generator
};

static const uint32 GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed

/** Modes for GenerateWorld */
enum GenWorldMode {
	GWM_NEWGAME   = 0, ///< Generate a map for a new game
	GWM_EMPTY     = 1, ///< Generate an empty map (sea-level)
	GWM_RANDOM    = 2, ///< Generate a random map for SE
	GWM_HEIGHTMAP = 3, ///< Generate a newgame from a heightmap
};

/** Smoothness presets. */
enum TgenSmoothness {
	TGEN_SMOOTHNESS_BEGIN,      ///< First smoothness value.
	TGEN_SMOOTHNESS_VERY_SMOOTH = TGEN_SMOOTHNESS_BEGIN, ///< Smoothness preset 'very smooth'.
	TGEN_SMOOTHNESS_SMOOTH,     ///< Smoothness preset 'smooth'.
	TGEN_SMOOTHNESS_ROUGH,      ///< Smoothness preset 'rough'.
	TGEN_SMOOTHNESS_VERY_ROUGH, ///< Smoothness preset 'very rough'.

	TGEN_SMOOTHNESS_END,        ///< Used to iterate.
};

static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4; ///< Value for custom sea level in difficulty settings.
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1;    ///< Minimum percentage a user can specify for custom sea level.
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90;   ///< Maximum percentage a user can specify for custom sea level.

typedef void GWDoneProc();  ///< Procedure called when the genworld process finishes
typedef void GWAbortProc(); ///< Called when genworld is aborted

/** Properties of current genworld process */
struct GenWorldInfo {
	bool abort;            ///< Whether to abort the thread ASAP
	bool quit_thread;      ///< Do we want to quit the active thread
	bool threaded;         ///< Whether we run _GenerateWorld threaded
	GenWorldMode mode;     ///< What mode are we making a world in
	CompanyID lc;          ///< The local_company before generating
	uint size_x;           ///< X-size of the map
	uint size_y;           ///< Y-size of the map
	GWDoneProc *proc;      ///< Proc that is called when done (can be nullptr)
	GWAbortProc *abortp;   ///< Proc that is called when aborting (can be nullptr)
	std::thread thread;    ///< The thread we are in (joinable if a thread was created)
};

/** Current stage of world generation process */
enum GenWorldProgress {
	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
	GWP_LANDSCAPE,   ///< Create the landscape
	GWP_RIVER,       ///< Create the rivers
	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
	GWP_TOWN,        ///< Generate towns
	GWP_INDUSTRY,    ///< Generate industries
	GWP_OBJECT,      ///< Generate objects (radio tower, light houses)
	GWP_TREE,        ///< Generate trees
	GWP_GAME_INIT,   ///< Initialize the game
	GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc
	GWP_RUNSCRIPT,   ///< Runs the game script at most 2500 times, or when ever the script sleeps
	GWP_GAME_START,  ///< Really prepare to start the game
	GWP_CLASS_COUNT
};

/* genworld.cpp */
bool IsGenerateWorldThreaded();
void GenerateWorldSetCallback(GWDoneProc *proc);
void GenerateWorldSetAbortCallback(GWAbortProc *proc);
void WaitTillGeneratedWorld();
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
void AbortGeneratingWorld();
bool IsGeneratingWorldAborted();
void HandleGeneratingWorldAbortion();

/* genworld_gui.cpp */
void SetNewLandscapeType(byte landscape);
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total);
void IncreaseGeneratingWorldProgress(GenWorldProgress cls);
void PrepareGenerateWorldProgress();
void ShowGenerateWorldProgress();
void StartNewGameWithoutGUI(uint32 seed);
void ShowCreateScenario();
void StartScenarioEditor();

extern bool _generating_world;

#endif /* GENWORLD_H */