Changeset - r6179:c0508e7aefec
[Not reviewed]
master
0 23 0
belugas - 17 years ago 2007-03-01 01:24:44
belugas@openttd.org
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
23 files changed with 338 insertions and 272 deletions:
0 comments (0 inline, 0 general)
src/debug.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file debug.h */
 

	
 
#ifndef DEBUG_H
 
#define DEBUG_H
 

	
 
/* Debugging messages policy:
 
 * These should be the severities used for direct DEBUG() calls
 
 * maximum debugging level should be 10 if really deep, deep
 
@@ -88,13 +90,13 @@ const char *GetDebugString(void);
 
#if defined(_MSC_VER) || defined(__MINGW32__)
 
	#define OTTD_PRINTF64 "I64"
 
#else
 
	#define OTTD_PRINTF64 "ll"
 
#endif
 

	
 
// Used for profiling
 
/* Used for profiling */
 
#define TIC() {\
 
	extern uint64 _rdtsc(void);\
 
	uint64 _xxx_ = _rdtsc();\
 
	static uint64 __sum__ = 0;\
 
	static uint32 __i__ = 0;
 

	
src/depot_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** depot_gui.cpp */
 
/** @file depot_gui.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "functions.h"
 
#include "train.h"
 
#include "roadveh.h"
src/fileio.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file fileio.cpp Standard In/Out file operations*/
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "fileio.h"
 
#include "functions.h"
 
#include "string.h"
 
#include "macros.h"
 
@@ -28,13 +30,13 @@ typedef struct {
 
	uint usage_count[MAX_HANDLES];      ///< count how many times this file has been opened
 
#endif /* LIMITED_FDS */
 
} Fio;
 

	
 
static Fio _fio;
 

	
 
// Get current position in file
 
/* Get current position in file */
 
uint32 FioGetPos(void)
 
{
 
	return _fio.pos + (_fio.buffer - _fio.buffer_start) - FIO_BUFFER_SIZE;
 
}
 

	
 
void FioSeekTo(uint32 pos, int mode)
 
@@ -54,13 +56,13 @@ static void FioRestoreFile(int slot)
 
		FioOpenFile(slot, _fio.filename[slot]);
 
	}
 
	_fio.usage_count[slot]++;
 
}
 
#endif /* LIMITED_FDS */
 

	
 
// Seek to a file and a position
 
/* Seek to a file and a position */
 
void FioSeekToFile(uint32 pos)
 
{
 
	FILE *f;
 
#if defined(LIMITED_FDS)
 
	/* Make sure we have this file open */
 
	FioRestoreFile(pos >> 24);
 
@@ -174,13 +176,13 @@ FILE *FioFOpenFile(const char *filename)
 
#if !defined(WIN32)
 
	if (f == NULL) {
 
		strtolower(buf + strlen(_paths.data_dir) - 1);
 
		f = fopen(buf, "rb");
 

	
 
#if defined SECOND_DATA_DIR
 
		// tries in the 2nd data directory
 
		/* tries in the 2nd data directory */
 
		if (f == NULL) {
 
			snprintf(buf, lengthof(buf), "%s%s", _paths.second_data_dir, filename);
 
			strtolower(buf + strlen(_paths.second_data_dir) - 1);
 
			f = fopen(buf, "rb");
 
		}
 
#endif
src/fileio.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file fileio.h Declarations for Standard In/Out file operations*/
 

	
 
#ifndef FILEIO_H
 
#define FILEIO_H
 

	
 
void FioSeekTo(uint32 pos, int mode);
 
void FioSeekToFile(uint32 pos);
 
uint32 FioGetPos(void);
src/fios.cpp
Show inline comments
 
@@ -401,13 +401,13 @@ static byte FiosGetHeightmapListCallback
 

	
 
	if (strcasecmp(ext, ".bmp") == 0) return FIOS_TYPE_BMP;
 

	
 
	return FIOS_TYPE_INVALID;
 
}
 

	
 
// Get a list of Heightmaps
 
/* Get a list of Heightmaps */
 
FiosItem *FiosGetHeightmapList(int mode)
 
{
 
	static char *_fios_hmap_path = NULL;
 

	
 
	if (_fios_hmap_path == NULL) {
 
		_fios_hmap_path = MallocT<char>(MAX_PATH);
src/fios.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file fios.h Declarations for savegames operations */
 

	
 
#ifndef FIOS_H
 
#define FIOS_H
 

	
 
/* Deals with finding savegames */
 
typedef struct {
 
	byte type;
 
@@ -23,47 +25,47 @@ enum {
 
	FIOS_TYPE_PNG          =   8,
 
	FIOS_TYPE_BMP          =   9,
 
	FIOS_TYPE_INVALID      = 255,
 
};
 

	
 
/* Variables to display file lists */
 
extern FiosItem *_fios_list; // defined in misc_gui.c
 
extern int _fios_num;        // defined in fios.c, read_only version of _fios_count
 
extern int _saveload_mode;   // defined in misc_gui.c
 
extern FiosItem *_fios_list; ///< defined in misc_gui.cpp
 
extern int _fios_num;        ///< defined in fios.cpp, read_only version of _fios_count
 
extern int _saveload_mode;   ///< defined in misc_gui.cpp
 

	
 
// Get a list of savegames
 
/* Get a list of savegames */
 
FiosItem *FiosGetSavegameList(int mode);
 
// Get a list of scenarios
 
/* Get a list of scenarios */
 
FiosItem *FiosGetScenarioList(int mode);
 
// Get a list of Heightmaps
 
/* Get a list of Heightmaps */
 
FiosItem *FiosGetHeightmapList(int mode);
 
// Free the list of savegames
 
/* Free the list of savegames */
 
void FiosFreeSavegameList(void);
 
// Browse to. Returns a filename w/path if we reached a file.
 
/* Browse to. Returns a filename w/path if we reached a file. */
 
char *FiosBrowseTo(const FiosItem *item);
 
// Return path, free space and stringID
 
/* Return path, free space and stringID */
 
StringID FiosGetDescText(const char **path, uint32 *total_free);
 
// Delete a name
 
/* Delete a name */
 
bool FiosDelete(const char *name);
 
// Make a filename from a name
 
/* Make a filename from a name */
 
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
 
// Allocate a new FiosItem
 
/* Allocate a new FiosItem */
 
FiosItem *FiosAlloc(void);
 

	
 
int CDECL compare_FiosItems(const void *a, const void *b);
 

	
 
/* Implementation of opendir/readdir/closedir for Windows */
 
#if defined(WIN32)
 
#include <windows.h>
 
typedef struct DIR DIR;
 

	
 
typedef struct dirent { // XXX - only d_name implemented
 
	wchar_t *d_name; /* name of found file */
 
	wchar_t *d_name; // name of found file
 
	/* little hack which will point to parent DIR struct which will
 
	 * save us a call to GetFileAttributes if we want information
 
	 * about the file (for example in function fio_bla */
 
	 * about the file (for example in function fio_bla) */
 
	DIR *dir;
 
} dirent;
 

	
 
struct DIR {
 
	HANDLE hFind;
 
	/* the dirent returned by readdir.
src/fontcache.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file fontcache.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "functions.h"
 
#include "macros.h"
 
#include "debug.h"
 
#include "table/sprites.h"
src/functions.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file functions.h */
 

	
 
#ifndef FUNCTIONS_H
 
#define FUNCTIONS_H
 

	
 
#include "gfx.h"
 

	
 
void DoClearSquare(TileIndex tile);
 
@@ -31,36 +33,36 @@ static inline Point RemapCoords(int x, i
 
static inline Point RemapCoords2(int x, int y)
 
{
 
	return RemapCoords(x, y, GetSlopeZ(x, y));
 
}
 

	
 

	
 
/* clear_land.c */
 
/* clear_land.cpp */
 
void DrawHillyLandTile(const TileInfo *ti);
 
void DrawClearLandTile(const TileInfo *ti, byte set);
 
void DrawClearLandFence(const TileInfo *ti);
 
void TileLoopClearHelper(TileIndex tile);
 

	
 
/* water_land.c */
 
/* water_land.cpp */
 
void DrawShipDepotSprite(int x, int y, int image);
 
void TileLoop_Water(TileIndex tile);
 

	
 
/* players.c */
 
/* players.cpp */
 
bool CheckPlayerHasMoney(int32 cost);
 
void SubtractMoneyFromPlayer(int32 cost);
 
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost);
 
bool CheckOwnership(Owner owner);
 
bool CheckTileOwnership(TileIndex tile);
 
StringID GetPlayerNameString(PlayerID player, uint index);
 

	
 
/* standard */
 
void ShowInfo(const char *str);
 
void CDECL ShowInfoF(const char *str, ...);
 
void NORETURN CDECL error(const char *str, ...);
 

	
 
/* openttd.c */
 
/* openttd.cpp */
 

	
 
/**************
 
 * Warning: DO NOT enable this unless you understand what it does
 
 *
 
 * If enabled, in a network game all randoms will be dumped to the
 
 *  stdout if the first client joins (or if you are a client). This
 
@@ -98,19 +100,19 @@ uint32 RandomMT(void);
 
#endif // MERSENNE_TWISTER
 

	
 
static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
 
static inline TileIndex RandomTile(void) { return TILE_MASK(Random()); }
 

	
 

	
 
uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
 
uint32 InteractiveRandom(void); // Used for random sequences that are not the same on the other end of the multiplayer link
 
uint InteractiveRandomRange(uint max);
 

	
 
/* facedraw.c */
 
/* facedraw.cpp */
 
void DrawPlayerFace(uint32 face, int color, int x, int y);
 

	
 
/* texteff.c */
 
/* texteff.cpp */
 
void MoveAllTextEffects(void);
 
void AddTextEffect(StringID msg, int x, int y, uint16 duration);
 
void InitTextEffects(void);
 
void DrawTextEffects(DrawPixelInfo *dpi);
 

	
 
void InitTextMessage(void);
 
@@ -120,29 +122,29 @@ void UndrawTextMessage(void);
 

	
 
bool AddAnimatedTile(TileIndex tile);
 
void DeleteAnimatedTile(TileIndex tile);
 
void AnimateAnimatedTiles(void);
 
void InitializeAnimatedTiles(void);
 

	
 
/* tunnelbridge_cmd.c */
 
/* tunnelbridge_cmd.cpp */
 
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
 
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
 
int CalcBridgeLenCostFactor(int x);
 

	
 
/* misc_cmd.c */
 
/* misc_cmd.cpp */
 
void PlaceTreesRandomly(void);
 

	
 
void InitializeLandscapeVariables(bool only_constants);
 

	
 
/* misc.c */
 
/* misc.cpp */
 
bool IsCustomName(StringID id);
 
void DeleteName(StringID id);
 
char *GetName(char *buff, StringID id, const char* last);
 

	
 
// AllocateNameUnique also tests if the name used is not used anywere else
 
//  and if it is used, it returns an error.
 
/* AllocateNameUnique also tests if the name used is not used anywere else
 
 * and if it is used, it returns an error. */
 
#define AllocateNameUnique(name, skip) RealAllocateName(name, skip, true)
 
#define AllocateName(name, skip) RealAllocateName(name, skip, false)
 
StringID RealAllocateName(const char *name, byte skip, bool check_double);
 
void ConvertNameArray(void);
 

	
 
/* misc functions */
 
@@ -200,13 +202,13 @@ enum {
 
	SLD_SAVE_SCENARIO,
 
	SLD_LOAD_HEIGHTMAP,
 
	SLD_NEW_GAME,
 
};
 
void ShowSaveLoadDialog(int mode);
 

	
 
// callback from drivers that is called if the game size changes dynamically
 
/* callback from drivers that is called if the game size changes dynamically */
 
void GameSizeChanged(void);
 
bool FileExists(const char *filename);
 
bool ReadLanguagePack(int index);
 
void InitializeLanguagePacks(void);
 
const char *GetCurrentLocale(const char *param);
 
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
src/genworld.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file genworld.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "functions.h"
 
#include "player.h"
 
#include "table/sprites.h"
 
#include "variables.h"
 
@@ -84,47 +86,47 @@ static void *_GenerateWorld(void *arg)
 
	if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom();
 
	_random_seeds[0][0] = _random_seeds[0][1] = _patches.generation_seed;
 
	SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
 
	SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, 0, WC_MAIN_WINDOW, 0);
 

	
 
	IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
 
	// Must start economy early because of the costs.
 
	/* Must start economy early because of the costs. */
 
	StartupEconomy();
 

	
 
	// Don't generate landscape items when in the scenario editor.
 
	/* Don't generate landscape items when in the scenario editor. */
 
	if (_gw.mode == GW_EMPTY) {
 
		SetGeneratingWorldProgress(GWP_UNMOVABLE, 1);
 

	
 
		/* Make the map the height of the patch setting */
 
		if (_game_mode != GM_MENU) FlatEmptyWorld(_patches.se_flat_world_height);
 

	
 
		ConvertGroundTilesIntoWaterTiles();
 
		IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
 
	} else {
 
		GenerateLandscape(_gw.mode);
 
		GenerateClearTile();
 

	
 
		// only generate towns, tree and industries in newgame mode.
 
		/* only generate towns, tree and industries in newgame mode. */
 
		if (_game_mode != GM_EDITOR) {
 
			GenerateTowns();
 
			GenerateIndustries();
 
			GenerateUnmovables();
 
			GenerateTrees();
 
		}
 
	}
 

	
 
	// These are probably pointless when inside the scenario editor.
 
	/* These are probably pointless when inside the scenario editor. */
 
	SetGeneratingWorldProgress(GWP_GAME_INIT, 3);
 
	StartupPlayers();
 
	IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
 
	StartupEngines();
 
	IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
 
	StartupDisasters();
 
	_generating_world = false;
 

	
 
	// No need to run the tile loop in the scenario editor.
 
	/* No need to run the tile loop in the scenario editor. */
 
	if (_gw.mode != GW_EMPTY) {
 
		uint i;
 

	
 
		SetGeneratingWorldProgress(GWP_RUNTILELOOP, 0x500);
 
		for (i = 0; i < 0x500; i++) {
 
			RunTileLoop();
 
@@ -227,13 +229,13 @@ void HandleGeneratingWorldAbortion(void)
 

	
 
	OTTDExitThread();
 
}
 

	
 
/**
 
 * Generate a world.
 
 * @param mode The mode of world generation (@see GenerateWorldModes).
 
 * @param mode The mode of world generation (see GenerateWorldModes).
 
 * @param size_x The X-size of the map.
 
 * @param size_y The Y-size of the map.
 
 */
 
void GenerateWorld(int mode, uint size_x, uint size_y)
 
{
 
	if (_gw.active) return;
src/genworld.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file genworld.h */
 

	
 
#ifndef GENWORLD_H
 
#define GENWORLD_H
 

	
 
/* If OTTDThread isn't defined, define it to a void, but make sure to undefine
 
 *  it after this include. This makes including genworld.h easier, as you
 
 *  don't need to include thread.h before it, while it stays possible to
 
@@ -15,52 +17,52 @@
 

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

	
 
	GENERATE_NEW_SEED = (uint)-1, //! Create a new random seed
 
	GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed
 
};
 

	
 
typedef void gw_done_proc(void);
 
typedef void gw_abort_proc(void);
 

	
 
typedef struct gw_info {
 
	bool active;           //! Is generating world active
 
	bool abort;            //! Whether to abort the thread ASAP
 
	bool wait_for_draw;    //! Are we waiting on a draw event
 
	bool quit_thread;      //! Do we want to quit the active thread
 
	bool threaded;         //! Whether we run _GenerateWorld threaded
 
	int mode;              //! What mode are we making a world in
 
	PlayerID lp;               //! The local_player before generating
 
	uint size_x;           //! X-size of the map
 
	uint size_y;           //! Y-size of the map
 
	gw_done_proc *proc;    //! Proc that is called when done (can be NULL)
 
	gw_abort_proc *abortp; //! Proc that is called when aborting (can be NULL)
 
	OTTDThread *thread;    //! The thread we are in (can be NULL)
 
	bool active;           ///< Is generating world active
 
	bool abort;            ///< Whether to abort the thread ASAP
 
	bool wait_for_draw;    ///< Are we waiting on a draw event
 
	bool quit_thread;      ///< Do we want to quit the active thread
 
	bool threaded;         ///< Whether we run _GenerateWorld threaded
 
	int mode;              ///< What mode are we making a world in
 
	PlayerID lp;           ///< The local_player before generating
 
	uint size_x;           ///< X-size of the map
 
	uint size_y;           ///< Y-size of the map
 
	gw_done_proc *proc;    ///< Proc that is called when done (can be NULL)
 
	gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL)
 
	OTTDThread *thread;    ///< The thread we are in (can be NULL)
 
} gw_info;
 

	
 
#ifdef TEMPORARY_OTTDTHREAD_DEFINITION
 
#undef OTTDThread
 
#undef TEMPORARY_OTTDTHREAD_DEFINITION
 
#endif
 

	
 
typedef enum gwp_classes {
 
	GWP_MAP_INIT,    /* Initialize/allocate the map, start economy */
 
	GWP_LANDSCAPE,   /* Create the landscape */
 
	GWP_ROUGH_ROCKY, /* Make rough and rocky areas */
 
	GWP_TOWN,        /* Generate towns */
 
	GWP_INDUSTRY,    /* Generate industries */
 
	GWP_UNMOVABLE,   /* Generate unmovables (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_GAME_START,  /* Really prepare to start the game */
 
	GWP_MAP_INIT,    ///< Initialize/allocate the map, start economy
 
	GWP_LANDSCAPE,   ///< Create the landscape
 
	GWP_ROUGH_ROCKY, ///< Make rough and rocky areas
 
	GWP_TOWN,        ///< Generate towns
 
	GWP_INDUSTRY,    ///< Generate industries
 
	GWP_UNMOVABLE,   ///< Generate unmovables (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_GAME_START,  ///< Really prepare to start the game
 
	GWP_CLASS_COUNT
 
} gwp_class;
 

	
 
/**
 
 * Check if we are currently in the process of generating a world.
 
 */
 
@@ -68,25 +70,25 @@ static inline bool IsGeneratingWorld(voi
 
{
 
	extern gw_info _gw;
 

	
 
	return _gw.active;
 
}
 

	
 
/* genworld.c */
 
/* genworld.cpp */
 
void SetGeneratingWorldPaintStatus(bool status);
 
bool IsGeneratingWorldReadyForPaint(void);
 
bool IsGenerateWorldThreaded(void);
 
void GenerateWorldSetCallback(gw_done_proc *proc);
 
void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
 
void WaitTillGeneratedWorld(void);
 
void GenerateWorld(int mode, uint size_x, uint size_y);
 
void AbortGeneratingWorld(void);
 
bool IsGeneratingWorldAborted(void);
 
void HandleGeneratingWorldAbortion(void);
 

	
 
/* genworld_gui.c */
 
/* genworld_gui.cpp */
 
void SetGeneratingWorldProgress(gwp_class cls, uint total);
 
void IncreaseGeneratingWorldProgress(gwp_class cls);
 
void PrepareGenerateWorldProgress(void);
 
void ShowGenerateWorldProgress(void);
 
void StartNewGameWithoutGUI(uint seed);
 
void ShowCreateScenario(void);
src/genworld_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file genworld_gui.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "heightmap.h"
 
#include "functions.h"
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
@@ -395,13 +397,13 @@ static void GenerateLandscapeWndProc(Win
 
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, w, CS_NUMERAL);
 
			break;
 
		case GLAND_TREE_TEXT: case GLAND_TREE_PULLDOWN: // Tree placer
 
			ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
 
			break;
 
		case GLAND_LANDSCAPE_TEXT: case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation
 
		/*case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
 
		/* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
 
			if (mode == GLWP_HEIGHTMAP) {
 
				ShowDropDownMenu(w, rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
 
			} else {
 
				ShowDropDownMenu(w, landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
 
			}
 
			break;
 
@@ -446,13 +448,13 @@ static void GenerateLandscapeWndProc(Win
 
			case GLAND_INDUSTRY_PULLDOWN:
 
				_opt_newgame.diff.number_industries = e->we.dropdown.index;
 
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
 
				DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
 
				break;
 
			case GLAND_LANDSCAPE_PULLDOWN:
 
			/*case GLAND_HEIGHTMAP_PULLDOWN: */
 
			/* case GLAND_HEIGHTMAP_PULLDOWN: */
 
				if (mode == GLWP_HEIGHTMAP) {
 
					_patches_newgame.heightmap_rotation = e->we.dropdown.index;
 
				} else {
 
					_patches_newgame.land_generator = e->we.dropdown.index;
 
				}
 
				break;
src/gfx.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file gfx.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "functions.h"
 
#include "macros.h"
 
#include "spritecache.h"
 
#include "strings.h"
 
@@ -18,17 +20,17 @@
 
#include "debug.h"
 

	
 
#ifdef _DEBUG
 
bool _dbg_screen_rect;
 
#endif
 

	
 
byte _dirkeys;        // 1 = left, 2 = up, 4 = right, 8 = down
 
byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 
bool _fullscreen;
 
CursorVars _cursor;
 
bool _ctrl_pressed;   // Is Ctrl pressed?
 
bool _shift_pressed;  // Is Shift pressed?
 
bool _ctrl_pressed;   ///< Is Ctrl pressed?
 
bool _shift_pressed;  ///< Is Shift pressed?
 
byte _fast_forward;
 
bool _left_button_down;
 
bool _left_button_clicked;
 
bool _right_button_down;
 
bool _right_button_clicked;
 
DrawPixelInfo _screen;
 
@@ -85,22 +87,22 @@ void GfxScroll(int left, int top, int wi
 
	if (_cursor.visible) UndrawMouseCursor();
 
	UndrawTextMessage();
 

	
 
	p = _screen.pitch;
 

	
 
	if (yo > 0) {
 
		// Calculate pointers
 
		/*Calculate pointers */
 
		dst = _screen.dst_ptr + (top + height - 1) * p + left;
 
		src = dst - yo * p;
 

	
 
		// Decrease height and increase top
 
		/* Decrease height and increase top */
 
		top += yo;
 
		height -= yo;
 
		assert(height > 0);
 

	
 
		// Adjust left & width
 
		/* Adjust left & width */
 
		if (xo >= 0) {
 
			dst += xo;
 
			left += xo;
 
			width -= xo;
 
		} else {
 
			src -= xo;
 
@@ -110,39 +112,39 @@ void GfxScroll(int left, int top, int wi
 
		for (ht = height; ht > 0; --ht) {
 
			memcpy(dst, src, width);
 
			src -= p;
 
			dst -= p;
 
		}
 
	} else {
 
		// Calculate pointers
 
		/* Calculate pointers */
 
		dst = _screen.dst_ptr + top * p + left;
 
		src = dst - yo * p;
 

	
 
		// Decrese height. (yo is <=0).
 
		/* Decrese height. (yo is <=0). */
 
		height += yo;
 
		assert(height > 0);
 

	
 
		// Adjust left & width
 
		/* Adjust left & width */
 
		if (xo >= 0) {
 
			dst += xo;
 
			left += xo;
 
			width -= xo;
 
		} else {
 
			src -= xo;
 
			width += xo;
 
		}
 

	
 
		// the y-displacement may be 0 therefore we have to use memmove,
 
		// because source and destination may overlap
 
		/* the y-displacement may be 0 therefore we have to use memmove,
 
		 * because source and destination may overlap */
 
		for (ht = height; ht > 0; --ht) {
 
			memmove(dst, src, width);
 
			src += p;
 
			dst += p;
 
		}
 
	}
 
	// This part of the screen is now dirty.
 
	/* This part of the screen is now dirty. */
 
	_video_driver->make_dirty(left, top, width, height);
 
}
 

	
 

	
 
void GfxFillRect(int left, int top, int right, int bottom, int color)
 
{
 
@@ -209,13 +211,13 @@ void GfxDrawLine(int x, int y, int x2, i
 
	int dy;
 
	int dx;
 
	int stepx;
 
	int stepy;
 
	int frac;
 

	
 
	// Check clipping first
 
	/* Check clipping first */
 
	{
 
		DrawPixelInfo *dpi = _cur_dpi;
 
		int t;
 

	
 
		if (x < dpi->left && x2 < dpi->left) return;
 

	
 
@@ -289,13 +291,13 @@ static int TruncateString(char *str, int
 

	
 
	for (ddd_pos = str; (c = Utf8Consume((const char **)&str)) != '\0'; ) {
 
		if (IsPrintable(c)) {
 
			w += GetCharacterWidth(size, c);
 

	
 
			if (w >= maxw) {
 
				// string got too big... insert dotdotdot
 
				/* string got too big... insert dotdotdot */
 
				ddd_pos[0] = ddd_pos[1] = ddd_pos[2] = '.';
 
				ddd_pos[3] = 0;
 
				return ddd_w;
 
			}
 
		} else {
 
			if (c == SCC_SETX) str++;
 
@@ -306,13 +308,13 @@ static int TruncateString(char *str, int
 
			} else if (c == SCC_BIGFONT) {
 
				size = FS_LARGE;
 
				ddd = GetCharacterWidth(size, '.') * 3;
 
			}
 
		}
 

	
 
		// Remember the last position where three dots fit.
 
		/* Remember the last position where three dots fit. */
 
		if (w + ddd < maxw) {
 
			ddd_w = w + ddd;
 
			ddd_pos = str;
 
		}
 
	}
 

	
 
@@ -1541,22 +1543,22 @@ void DoPaletteAnimations(void)
 
	uint i;
 
	uint j;
 

	
 
	d = &_cur_palette[217];
 
	memcpy(old_val, d, c * sizeof(*old_val));
 

	
 
	// Dark blue water
 
	/* Dark blue water */
 
	s = (_opt.landscape == LT_CANDY) ? ev->ac : ev->a;
 
	j = EXTR(320, 5);
 
	for (i = 0; i != 5; i++) {
 
		*d++ = s[j];
 
		j++;
 
		if (j == 5) j = 0;
 
	}
 

	
 
	// Glittery water
 
	/* Glittery water */
 
	s = (_opt.landscape == LT_CANDY) ? ev->bc : ev->b;
 
	j = EXTR(128, 15);
 
	for (i = 0; i != 5; i++) {
 
		*d++ = s[j];
 
		j += 3;
 
		if (j >= 15) j -= 15;
 
@@ -1567,22 +1569,22 @@ void DoPaletteAnimations(void)
 
	for (i = 0; i != 5; i++) {
 
		*d++ = s[j];
 
		j++;
 
		if (j == 5) j = 0;
 
	}
 

	
 
	// Oil refinery fire animation
 
	/* Oil refinery fire animation */
 
	s = ev->oil_ref;
 
	j = EXTR2(512, 7);
 
	for (i = 0; i != 7; i++) {
 
		*d++ = s[j];
 
		j++;
 
		if (j == 7) j = 0;
 
	}
 

	
 
	// Radio tower blinking
 
	/* Radio tower blinking */
 
	{
 
		byte i = (_timer_counter >> 1) & 0x7F;
 
		byte v;
 

	
 
		(v = 255, i < 0x3f) ||
 
		(v = 128, i < 0x4A || i >= 0x75) ||
 
@@ -1599,33 +1601,33 @@ void DoPaletteAnimations(void)
 
		d->r = v;
 
		d->g = 0;
 
		d->b = 0;
 
		d++;
 
	}
 

	
 
	// Handle lighthouse and stadium animation
 
	/* Handle lighthouse and stadium animation */
 
	s = ev->lighthouse;
 
	j = EXTR(256, 4);
 
	for (i = 0; i != 4; i++) {
 
		*d++ = s[j];
 
		j++;
 
		if (j == 4) j = 0;
 
	}
 

	
 
	// Animate water for old DOS graphics
 
	/* Animate water for old DOS graphics */
 
	if (_use_dos_palette) {
 
		// Dark blue water DOS
 
		/* Dark blue water DOS */
 
		s = (_opt.landscape == LT_CANDY) ? ev->ac : ev->a;
 
		j = EXTR(320, 5);
 
		for (i = 0; i != 5; i++) {
 
			*d++ = s[j];
 
			j++;
 
			if (j == 5) j = 0;
 
		}
 

	
 
		// Glittery water DOS
 
		/* Glittery water DOS */
 
		s = (_opt.landscape == LT_CANDY) ? ev->bc : ev->b;
 
		j = EXTR(128, 15);
 
		for (i = 0; i != 5; i++) {
 
			*d++ = s[j];
 
			j += 3;
 
			if (j >= 15) j -= 15;
 
@@ -1667,17 +1669,17 @@ byte GetCharacterWidth(FontSize size, WC
 
	return GetGlyphWidth(size, key);
 
}
 

	
 

	
 
void ScreenSizeChanged(void)
 
{
 
	// check the dirty rect
 
	/* check the dirty rect */
 
	if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width;
 
	if (_invalid_rect.bottom >= _screen.height) _invalid_rect.bottom = _screen.height;
 

	
 
	// screen size changed and the old bitmap is invalid now, so we don't want to undraw it
 
	/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
 
	_cursor.visible = false;
 
}
 

	
 
void UndrawMouseCursor(void)
 
{
 
	if (_cursor.visible) {
 
@@ -1698,13 +1700,13 @@ void DrawMouseCursor(void)
 
	int w;
 
	int h;
 

	
 
	/* Redraw mouse cursor but only when it's inside the window */
 
	if (!_cursor.in_window) return;
 

	
 
	// Don't draw the mouse cursor if it's already drawn
 
	/* Don't draw the mouse cursor if it's already drawn */
 
	if (_cursor.visible) {
 
		if (!_cursor.dirty) return;
 
		UndrawMouseCursor();
 
	}
 

	
 
	w = _cursor.size.x;
 
@@ -1728,19 +1730,19 @@ void DrawMouseCursor(void)
 
	if (h <= 0) return;
 
	_cursor.draw_pos.y = y;
 
	_cursor.draw_size.y = h;
 

	
 
	assert(w * h < (int)sizeof(_cursor_backup));
 

	
 
	// Make backup of stuff below cursor
 
	/* Make backup of stuff below cursor */
 
	memcpy_pitch(
 
		_cursor_backup,
 
		_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch,
 
		_cursor.draw_size.x, _cursor.draw_size.y, _screen.pitch, _cursor.draw_size.x);
 

	
 
	// Draw cursor on screen
 
	/* Draw cursor on screen */
 
	_cur_dpi = &_screen;
 
	DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x, _cursor.pos.y);
 

	
 
	_video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
 

	
 
	_cursor.visible = true;
 
@@ -1803,35 +1805,35 @@ void DrawDirtyBlocks(void)
 
				int top;
 
				int right = x + 64;
 
				int bottom = y;
 
				byte *p = b;
 
				int h2;
 

	
 
				// First try coalescing downwards
 
				/* First try coalescing downwards */
 
				do {
 
					*p = 0;
 
					p += DIRTY_BYTES_PER_LINE;
 
					bottom += 8;
 
				} while (bottom != h && *p != 0);
 

	
 
				// Try coalescing to the right too.
 
				/* Try coalescing to the right too. */
 
				h2 = (bottom - y) >> 3;
 
				assert(h2 > 0);
 
				p = b;
 

	
 
				while (right != w) {
 
					byte *p2 = ++p;
 
					int h = h2;
 
					// Check if a full line of dirty flags is set.
 
					/* Check if a full line of dirty flags is set. */
 
					do {
 
						if (!*p2) goto no_more_coalesc;
 
						p2 += DIRTY_BYTES_PER_LINE;
 
					} while (--h != 0);
 

	
 
					// Wohoo, can combine it one step to the right!
 
					// Do that, and clear the bits.
 
					/* Wohoo, can combine it one step to the right!
 
					 * Do that, and clear the bits. */
 
					right += 64;
 

	
 
					h = h2;
 
					p2 = p;
 
					do {
 
						*p2 = 0;
 
@@ -2002,15 +2004,15 @@ void CursorTick(void)
 
	if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0)
 
		SwitchAnimatedCursor();
 
}
 

	
 
void SetMouseCursor(SpriteID sprite, SpriteID pal)
 
{
 
	// Turn off animation
 
	/* Turn off animation */
 
	_cursor.animate_timeout = 0;
 
	// Set cursor
 
	/* Set cursor */
 
	SetCursorSprite(sprite, pal);
 
}
 

	
 
void SetAnimatedMouseCursor(const AnimCursor *table)
 
{
 
	_cursor.animate_list = table;
src/gfx.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file gfx.h */
 

	
 
#ifndef GFX_H
 
#define GFX_H
 

	
 

	
 
enum WindowKeyCodes {
 
	WKC_SHIFT = 0x8000,
 
	WKC_CTRL  = 0x4000,
 
	WKC_ALT   = 0x2000,
 
	WKC_META  = 0x1000,
 

	
 
	// Special ones
 
	/* Special ones */
 
	WKC_NONE        =  0,
 
	WKC_ESC         =  1,
 
	WKC_BACKSPACE   =  2,
 
	WKC_INSERT      =  3,
 
	WKC_DELETE      =  4,
 

	
 
	WKC_PAGEUP      =  5,
 
	WKC_PAGEDOWN    =  6,
 
	WKC_END         =  7,
 
	WKC_HOME        =  8,
 

	
 
	// Arrow keys
 
	/* Arrow keys */
 
	WKC_LEFT        =  9,
 
	WKC_UP          = 10,
 
	WKC_RIGHT       = 11,
 
	WKC_DOWN        = 12,
 

	
 
	// Return & tab
 
	/* Return & tab */
 
	WKC_RETURN      = 13,
 
	WKC_TAB         = 14,
 

	
 
	// Numerical keyboard
 
	/* Numerical keyboard */
 
	WKC_NUM_0       = 16,
 
	WKC_NUM_1       = 17,
 
	WKC_NUM_2       = 18,
 
	WKC_NUM_3       = 19,
 
	WKC_NUM_4       = 20,
 
	WKC_NUM_5       = 21,
 
@@ -47,16 +49,16 @@ enum WindowKeyCodes {
 
	WKC_NUM_MUL     = 27,
 
	WKC_NUM_MINUS   = 28,
 
	WKC_NUM_PLUS    = 29,
 
	WKC_NUM_ENTER   = 30,
 
	WKC_NUM_DECIMAL = 31,
 

	
 
	// Space
 
	/* Space */
 
	WKC_SPACE       = 32,
 

	
 
	// Function keys
 
	/* Function keys */
 
	WKC_F1          = 33,
 
	WKC_F2          = 34,
 
	WKC_F3          = 35,
 
	WKC_F4          = 36,
 
	WKC_F5          = 37,
 
	WKC_F6          = 38,
 
@@ -64,21 +66,21 @@ enum WindowKeyCodes {
 
	WKC_F8          = 40,
 
	WKC_F9          = 41,
 
	WKC_F10         = 42,
 
	WKC_F11         = 43,
 
	WKC_F12         = 44,
 

	
 
	// backquote is the key left of "1"
 
	// we only store this key here, no matter what character is really mapped to it
 
	// on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °)
 
	/* backquote is the key left of "1"
 
	 * we only store this key here, no matter what character is really mapped to it
 
	 * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
 
	WKC_BACKQUOTE   = 45,
 
	WKC_PAUSE       = 46,
 

	
 
	// 0-9 are mapped to 48-57
 
	// A-Z are mapped to 65-90
 
	// a-z are mapped to 97-122
 
	/* 0-9 are mapped to 48-57
 
	 * A-Z are mapped to 65-90
 
	 * a-z are mapped to 97-122 */
 
};
 

	
 
enum GameModes {
 
	GM_MENU,
 
	GM_NORMAL,
 
	GM_EDITOR
 
@@ -135,17 +137,17 @@ typedef struct Colour {
 
	byte g;
 
	byte b;
 
} Colour;
 

	
 

	
 

	
 
extern byte _dirkeys;        // 1 = left, 2 = up, 4 = right, 8 = down
 
extern byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 
extern bool _fullscreen;
 
extern CursorVars _cursor;
 
extern bool _ctrl_pressed;   // Is Ctrl pressed?
 
extern bool _shift_pressed;  // Is Shift pressed?
 
extern bool _ctrl_pressed;   ///< Is Ctrl pressed?
 
extern bool _shift_pressed;  ///< Is Shift pressed?
 
extern byte _fast_forward;
 

	
 
extern bool _left_button_down;
 
extern bool _left_button_clicked;
 
extern bool _right_button_down;
 
extern bool _right_button_clicked;
 
@@ -165,13 +167,13 @@ extern Colour _cur_palette[256];
 

	
 
void HandleKeypress(uint32 key);
 
void HandleMouseEvents(void);
 
void CSleep(int milliseconds);
 
void UpdateWindows(void);
 

	
 
uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
 
uint32 InteractiveRandom(void); //< Used for random sequences that are not the same on the other end of the multiplayer link
 
uint InteractiveRandomRange(uint max);
 
void DrawTextMessage(void);
 
void DrawMouseCursor(void);
 
void ScreenSizeChanged(void);
 
void HandleExitGameRequest(void);
 
void GameSizeChanged(void);
 
@@ -189,14 +191,14 @@ typedef enum FontSizes {
 
DECLARE_POSTFIX_INCREMENT(FontSize);
 

	
 
void RedrawScreenRect(int left, int top, int right, int bottom);
 
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
 

	
 

	
 
// XXX doesn't really belong here, but the only
 
// consumers always use it in conjunction with DoDrawString()
 
/* XXX doesn't really belong here, but the only
 
 * consumers always use it in conjunction with DoDrawString() */
 
#define UPARROW   "\xEE\x8A\x80"
 
#define DOWNARROW "\xEE\x8A\xAA"
 

	
 

	
 
int DrawStringCentered(int x, int y, StringID str, uint16 color);
 
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color);
 
@@ -228,13 +230,13 @@ void SetDirtyBlocks(int left, int top, i
 
void MarkWholeScreenDirty(void);
 

	
 
void GfxInitPalettes(void);
 

	
 
bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height);
 

	
 
/* window.c */
 
/* window.cpp */
 
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
 

	
 
void SetMouseCursor(CursorID cursor);
 
void SetMouseCursor(SpriteID sprite, SpriteID pal);
 
void SetAnimatedMouseCursor(const AnimCursor *table);
 
void CursorTick(void);
 
@@ -242,13 +244,13 @@ void DrawMouseCursor(void);
 
void ScreenSizeChanged(void);
 
void UndrawMouseCursor(void);
 
bool ChangeResInGame(int w, int h);
 
void SortResolutions(int count);
 
void ToggleFullScreen(bool fs);
 

	
 
/* gfx.c */
 
/* gfx.cpp */
 
#define ASCII_LETTERSTART 32
 
extern FontSize _cur_fontsize;
 

	
 
byte GetCharacterWidth(FontSize size, uint32 key);
 

	
 
static inline byte GetCharacterHeight(FontSize size)
 
@@ -288,13 +290,13 @@ enum {
 
 */
 
VARDEF byte _colour_gradient[16][8];
 

	
 
VARDEF bool _use_dos_palette;
 

	
 
typedef enum StringColorFlags {
 
	IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
 
	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
 
} StringColorFlags;
 

	
 

	
 
#ifdef _DEBUG
 
extern bool _dbg_screen_rect;
 
#endif
src/gfxinit.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file gfxinit.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "debug.h"
 
#include "functions.h"
 
#include "gfx.h"
 
#include "gfxinit.h"
 
@@ -14,19 +16,19 @@
 
#include "md5.h"
 
#include "variables.h"
 
#include "fontcache.h"
 
#include <string.h>
 

	
 
typedef struct MD5File {
 
	const char * filename;     // filename
 
	md5_byte_t hash[16]; // md5 sum of the file
 
	const char * filename;     ///< filename
 
	md5_byte_t hash[16];       ///< md5 sum of the file
 
} MD5File;
 

	
 
typedef struct FileList {
 
	MD5File basic[4];     // grf files that always have to be loaded
 
	MD5File landscape[3]; // landscape specific grf files
 
	MD5File basic[4];          ///< grf files that always have to be loaded
 
	MD5File landscape[3];      ///< landscape specific grf files
 
} FileList;
 

	
 
enum {
 
	SKIP = 0xFFFE,
 
	END  = 0xFFFF
 
};
 
@@ -107,13 +109,13 @@ static bool CheckMD5Digest(const MD5File
 
 * returns true if the checksum is correct */
 
static bool FileMD5(const MD5File file, bool warn)
 
{
 
	FILE *f;
 
	char buf[MAX_PATH];
 

	
 
	// open file
 
	/* open file */
 
	snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, file.filename);
 
	f = fopen(buf, "rb");
 

	
 
#if !defined(WIN32)
 
	if (f == NULL) {
 
		strtolower(buf + strlen(_paths.data_dir) - 1);
 
@@ -160,13 +162,13 @@ static bool FileMD5(const MD5File file, 
 
 * If neither are found, Windows palette is assumed.
 
 *
 
 * (Note: Also checks sample.cat for corruption) */
 
void CheckExternalFiles(void)
 
{
 
	uint i;
 
	// count of files from this version
 
	/* count of files from this version */
 
	uint dos = 0;
 
	uint win = 0;
 

	
 
	for (i = 0; i < 2; i++) if (FileMD5(files_dos.basic[i], true)) dos++;
 
	for (i = 0; i < 3; i++) if (FileMD5(files_dos.landscape[i], true)) dos++;
 

	
 
@@ -199,64 +201,64 @@ void CheckExternalFiles(void)
 
		_use_dos_palette = false;
 
	}
 
}
 

	
 

	
 
static const SpriteID trg1idx[] = {
 
	   0,    1, // Mouse cursor, ZZZ
 
	   0,    1, ///< Mouse cursor, ZZZ
 
/* Medium font */
 
	   2,   92, // ' ' till 'z'
 
	   2,   92, ///< ' ' till 'z'
 
	SKIP,   36,
 
	 160,  160, // Move ¾ to the correct position
 
	  98,   98, // Up arrow
 
	 160,  160, ///< Move ¾ to the correct position
 
	  98,   98, ///< Up arrow
 
	 131,  133,
 
	SKIP,    1, // skip currency sign
 
	SKIP,    1, ///< skip currency sign
 
	 135,  135,
 
	SKIP,    1,
 
	 137,  137,
 
	SKIP,    1,
 
	 139,  139,
 
	 140,  140, // TODO Down arrow
 
	 140,  140, ///< @todo Down arrow
 
	 141,  141,
 
	 142,  142, // TODO Check mark
 
	 143,  143, // TODO Cross
 
	 142,  142, ///< @todo Check mark
 
	 143,  143, ///< @todo Cross
 
	 144,  144,
 
	 145,  145, // TODO Right arrow
 
	 145,  145, ///< @todo Right arrow
 
	 146,  149,
 
	 118,  122, // Transport markers
 
	 118,  122, ///< Transport markers
 
	SKIP,    2,
 
	 157,  157,
 
	 114,  115, // Small up/down arrows
 
	 114,  115, ///< Small up/down arrows
 
	SKIP,    1,
 
	 161,  225,
 
/* Small font */
 
	 226,  316, // ' ' till 'z'
 
	 226,  316, ///< ' ' till 'z'
 
	SKIP,   36,
 
	 384,  384, // Move ¾ to the correct position
 
	 322,  322, // Up arrow
 
	 384,  384, ///< Move ¾ to the correct position
 
	 322,  322, ///< Up arrow
 
	 355,  357,
 
	SKIP,    1, // skip currency sign
 
	SKIP,    1, ///< skip currency sign
 
	 359,  359,
 
	SKIP,    1,
 
	 361,  361,
 
	SKIP,    1,
 
	 363,  363,
 
	 364,  364, // TODO Down arrow
 
	 364,  364, ////< @todo Down arrow
 
	 365,  366,
 
	SKIP,    1,
 
	 368,  368,
 
	 369,  369, // TODO Right arrow
 
	 369,  369, ///< @todo Right arrow
 
	 370,  373,
 
	SKIP,    7,
 
	 381,  381,
 
	SKIP,    3,
 
	 385,  449,
 
/* Big font */
 
	 450,  540, // ' ' till 'z'
 
	 450,  540, ///< ' ' till 'z'
 
	SKIP,   36,
 
	 608,  608, // Move ¾ to the correct position
 
	 608,  608, ///< Move ¾ to the correct position
 
	SKIP,    1,
 
	 579,  581,
 
	SKIP,    1,
 
	 583,  583,
 
	SKIP,    5,
 
	 589,  589,
 
@@ -285,57 +287,57 @@ static const SpriteID trg1idx[] = {
 
 * amount of sprites and add them to the end of the list, with the index of
 
 * the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no
 
 * correspondence of any kind with the ID's in the grf file, but results in
 
 * a maximum use of sprite slots. */
 
static const SpriteID _openttd_grf_indexes[] = {
 
	SPR_IMG_AUTORAIL, SPR_CURSOR_WAYPOINT, // icons etc
 
	134, 134,  // euro symbol medium size
 
	582, 582,  // euro symbol large size
 
	358, 358,  // euro symbol tiny
 
	134, 134,  ///< euro symbol medium size
 
	582, 582,  ///<  euro symbol large size
 
	358, 358,  ///<  euro symbol tiny
 
	SPR_CURSOR_CANAL, SPR_IMG_FASTFORWARD, // more icons
 
	648, 648, // nordic char: æ
 
	616, 616, // nordic char: Æ
 
	666, 666, // nordic char: ø
 
	634, 634, // nordic char: Ø
 
	648, 648, ///<  nordic char: æ
 
	616, 616, ///<  nordic char: Æ
 
	666, 666, ///<  nordic char: ø
 
	634, 634, ///<  nordic char: Ø
 
	SPR_PIN_UP, SPR_CURSOR_CLONE_TRAIN, // more icons
 
	382, 383, // ¼ ½ tiny
 
	158, 159, // ¼ ½ medium
 
	606, 607, // ¼ ½ large
 
	360, 360, // ¦ tiny
 
	362, 362, // ¨ tiny
 
	136, 136, // ¦ medium
 
	138, 138, // ¨ medium
 
	584, 584, // ¦ large
 
	586, 586, // ¨ large
 
	626, 626, // Ð large
 
	658, 658, // ð large
 
	374, 374, // ´ tiny
 
	378, 378, // ¸ tiny
 
	150, 150, // ´ medium
 
	154, 154, // ¸ medium
 
	598, 598, // ´ large
 
	602, 602, // ¸ large
 
	640, 640, // Þ large
 
	672, 672, // þ large
 
	380, 380, // º tiny
 
	156, 156, // º medium
 
	604, 604, // º large
 
	317, 320, // { | } ~ tiny
 
	 93,  96, // { | } ~ medium
 
	541, 544, // { | } ~ large
 
	382, 383, ///<  ¼ ½ tiny
 
	158, 159, ///<  ¼ ½ medium
 
	606, 607, ///<  ¼ ½ large
 
	360, 360, ///<  ¦ tiny
 
	362, 362, ///<  ¨ tiny
 
	136, 136, ///<  ¦ medium
 
	138, 138, ///<  ¨ medium
 
	584, 584, ///<  ¦ large
 
	586, 586, ///<  ¨ large
 
	626, 626, ///<  Ğ large
 
	658, 658, ///<  ğ large
 
	374, 374, ///<  ´ tiny
 
	378, 378, ///<  ¸ tiny
 
	150, 150, ///<  ´ medium
 
	154, 154, ///<  ¸ medium
 
	598, 598, ///<  ´ large
 
	602, 602, ///<  ¸ large
 
	640, 640, ///<  Ş large
 
	672, 672, ///<  ş large
 
	380, 380, ///<  º tiny
 
	156, 156, ///<  º medium
 
	604, 604, ///<  º large
 
	317, 320, ///<  { | } ~ tiny
 
	 93,  96, ///<  { | } ~ medium
 
	541, 544, ///<  { | } ~ large
 
	SPR_HOUSE_ICON, SPR_HOUSE_ICON,
 
	585, 585, // § large
 
	587, 587, // © large
 
	592, 592, // ® large
 
	594, 597, // ° ± ² ³ large
 
	633, 633, // × large
 
	665, 665, // ÷ large
 
	585, 585, ///<  § large
 
	587, 587, ///<  © large
 
	592, 592, ///<  ® large
 
	594, 597, ///<  ° ± ² ³ large
 
	633, 633, ///<  × large
 
	665, 665, ///<  ÷ large
 
	SPR_SELL_TRAIN, SPR_SHARED_ORDERS_ICON,
 
	377, 377, // · small
 
	153, 153, // · medium
 
	601, 601, // · large
 
	377, 377, ///<  · small
 
	153, 153, ///<  · medium
 
	601, 601, ///<  · large
 
	SPR_WARNING_SIGN, SPR_WARNING_SIGN,
 
	END
 
};
 

	
 

	
 
static void LoadSpriteTables(void)
src/gfxinit.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file gfxinit.h */
 

	
 
#ifndef GFXINIT_H
 
#define GFXINIT_H
 

	
 
void CheckExternalFiles(void);
 
void GfxLoadSprites(void);
 

	
src/graph_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file graph_gui.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
#include "functions.h"
 
#include "window.h"
 
@@ -25,27 +27,27 @@ static uint _legend_excluded_cargo;
 

	
 
enum {
 
	GRAPH_MAX_DATASETS = 16,
 
	GRAPH_AXIS_LABEL_COLOUR = 16,
 
	GRAPH_AXIS_LINE_COLOUR  = 215,
 

	
 
	GRAPH_X_POSITION_BEGINNING  = 44,  // Start the graph 44 pixels from gw->left
 
	GRAPH_X_POSITION_SEPARATION = 22,  // There are 22 pixels between each X value
 
	GRAPH_X_POSITION_BEGINNING  = 44,  ///< Start the graph 44 pixels from gw->left
 
	GRAPH_X_POSITION_SEPARATION = 22,  ///< There are 22 pixels between each X value
 

	
 
	/* How many horizontal lines to draw. 9 is convenient as that means the
 
	 * distance between them is the height of the graph / 8, which is the same
 
	GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw.
 
	/* 9 is convenient as that means the distance between them is the height of the graph / 8,
 
	 * which is the same
 
	 * as height >> 3. */
 
	GRAPH_NUM_LINES_Y = 9,
 
};
 

	
 
/* Apparently these don't play well with enums. */
 
static const int64 INVALID_DATAPOINT     = INT64_MAX; // Value used for a datapoint that shouldn't be drawn.
 
static const uint  INVALID_DATAPOINT_POS = UINT_MAX;  // Used to determine if the previous point was drawn.
 

	
 
typedef struct GraphDrawer {
 
	uint excluded_data; // bitmask of the datasets that shouldn't be displayed.
 
	uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
 
	byte num_dataset;
 
	byte num_on_x_axis;
 
	bool has_negative_values;
 
	byte num_vert_lines;
 

	
 
	/* The starting month and year that values are plotted against. If month is
 
@@ -55,24 +57,24 @@ typedef struct GraphDrawer {
 

	
 
	/* These values are used if the graph is being plotted against values
 
	 * rather than the dates specified by month and year. */
 
	uint16 x_values_start;
 
	uint16 x_values_increment;
 

	
 
	int left, top;  // Where to start drawing the graph, in pixels.
 
	uint height;    // The height of the graph in pixels.
 
	int left, top;  ///< Where to start drawing the graph, in pixels.
 
	uint height;    ///< The height of the graph in pixels.
 
	StringID format_str_y_axis;
 
	byte colors[GRAPH_MAX_DATASETS];
 
	int64 cost[GRAPH_MAX_DATASETS][24]; // last 2 years
 
	int64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
 
} GraphDrawer;
 

	
 
static void DrawGraph(const GraphDrawer *gw)
 
{
 
	uint x, y;            // Reused whenever x and y coordinates are needed.
 
	int64 highest_value;  // Highest value to be drawn.
 
	int x_axis_offset;    // Distance from the top of the graph to the x axis.
 
	uint x, y;            ///< Reused whenever x and y coordinates are needed.
 
	int64 highest_value;  ///< Highest value to be drawn.
 
	int x_axis_offset;    ///< Distance from the top of the graph to the x axis.
 

	
 
	/* the colors and cost array of GraphDrawer must accomodate
 
	 * both values for cargo and players. So if any are higher, quit */
 
	assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS);
 
	assert(gw->num_vert_lines > 0);
 

	
 
@@ -327,13 +329,13 @@ static void SetupGraphDrawerForPlayers(G
 
{
 
	const Player* p;
 
	uint excluded_players = _legend_excluded_players;
 
	byte nums;
 
	int mo,yr;
 

	
 
	// Exclude the players which aren't valid
 
	/* Exclude the players which aren't valid */
 
	FOR_ALL_PLAYERS(p) {
 
		if (!p->is_active) SETBIT(excluded_players, p->index);
 
	}
 
	gd->excluded_data = excluded_players;
 
	gd->num_vert_lines = 24;
 

	
 
@@ -917,13 +919,13 @@ static void PerformanceRatingDetailWndPr
 
		case WE_PAINT: {
 
			byte x;
 
			uint16 y = 14;
 
			int total_score = 0;
 
			int color_done, color_notdone;
 

	
 
			// Draw standard stuff
 
			/* Draw standard stuff */
 
			DrawWindowWidgets(w);
 

	
 
			/* Check if the currently selected player is still active. */
 
			if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) {
 
				if (_performance_rating_detail_player != INVALID_PLAYER) {
 
					/* Raise and disable the widget for the previous selection. */
 
@@ -946,94 +948,94 @@ static void PerformanceRatingDetailWndPr
 
				}
 
			}
 

	
 
			/* If there are no active players, don't display anything else. */
 
			if (_performance_rating_detail_player == INVALID_PLAYER) break;
 

	
 
			// Paint the player icons
 
			/* Paint the player icons */
 
			for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
 
				if (!GetPlayer(i)->is_active) {
 
					// Check if we have the player as an active player
 
					/* Check if we have the player as an active player */
 
					if (!IsWindowWidgetDisabled(w, i + 13)) {
 
						// Bah, player gone :(
 
						/* Bah, player gone :( */
 
						DisableWindowWidget(w, i + 13);
 

	
 
						// We need a repaint
 
						/* We need a repaint */
 
						SetWindowDirty(w);
 
					}
 
					continue;
 
				}
 

	
 
				// Check if we have the player marked as inactive
 
				/* Check if we have the player marked as inactive */
 
				if (IsWindowWidgetDisabled(w, i + 13)) {
 
					// New player! Yippie :p
 
					/* New player! Yippie :p */
 
					EnableWindowWidget(w, i + 13);
 
					// We need a repaint
 
					/* We need a repaint */
 
					SetWindowDirty(w);
 
				}
 

	
 
				x = (i == _performance_rating_detail_player) ? 1 : 0;
 
				DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
 
			}
 

	
 
			// The colors used to show how the progress is going
 
			/* The colors used to show how the progress is going */
 
			color_done = _colour_gradient[COLOUR_GREEN][4];
 
			color_notdone = _colour_gradient[COLOUR_RED][4];
 

	
 
			// Draw all the score parts
 
			/* Draw all the score parts */
 
			for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
 
				int val    = _score_part[_performance_rating_detail_player][i];
 
				int needed = _score_info[i].needed;
 
				int score  = _score_info[i].score;
 

	
 
				y += 20;
 
				// SCORE_TOTAL has his own rulez ;)
 
				/* SCORE_TOTAL has his own rulez ;) */
 
				if (i == SCORE_TOTAL) {
 
					needed = total_score;
 
					score = SCORE_MAX;
 
				} else {
 
					total_score += score;
 
				}
 

	
 
				DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
 

	
 
				// Draw the score
 
				/* Draw the score */
 
				SetDParam(0, score);
 
				DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
 

	
 
				// Calculate the %-bar
 
				/* Calculate the %-bar */
 
				if (val > needed) {
 
					x = 50;
 
				} else if (val == 0) {
 
					x = 0;
 
				} else {
 
					x = val * 50 / needed;
 
				}
 

	
 
				// SCORE_LOAN is inversed
 
				/* SCORE_LOAN is inversed */
 
				if (val < 0 && i == SCORE_LOAN) x = 0;
 

	
 
				// Draw the bar
 
				/* Draw the bar */
 
				if (x !=  0) GfxFillRect(112,     y - 2, 112 + x,  y + 10, color_done);
 
				if (x != 50) GfxFillRect(112 + x, y - 2, 112 + 50, y + 10, color_notdone);
 

	
 
				// Calculate the %
 
				/* Calculate the % */
 
				x = (val <= needed) ? val * 100 / needed : 100;
 

	
 
				// SCORE_LOAN is inversed
 
				/* SCORE_LOAN is inversed */
 
				if (val < 0 && i == SCORE_LOAN) x = 0;
 

	
 
				// Draw it
 
				/* Draw it */
 
				SetDParam(0, x);
 
				DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
 

	
 
				// SCORE_LOAN is inversed
 
				/* SCORE_LOAN is inversed */
 
				if (i == SCORE_LOAN) val = needed - val;
 

	
 
				// Draw the amount we have against what is needed
 
				//  For some of them it is in currency format
 
				/* Draw the amount we have against what is needed
 
				 * For some of them it is in currency format */
 
				SetDParam(0, val);
 
				SetDParam(1, needed);
 
				switch (i) {
 
					case SCORE_MIN_PROFIT:
 
					case SCORE_MIN_INCOME:
 
					case SCORE_MAX_INCOME:
 
@@ -1047,15 +1049,15 @@ static void PerformanceRatingDetailWndPr
 
			}
 

	
 
			break;
 
		}
 

	
 
		case WE_CLICK:
 
			// Check which button is clicked
 
			/* Check which button is clicked */
 
			if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) {
 
				// Is it no on disable?
 
				/* Is it no on disable? */
 
				if (!IsWindowWidgetDisabled(w, e->we.click.widget)) {
 
					RaiseWindowWidget(w, _performance_rating_detail_player + 13);
 
					_performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13);
 
					LowerWindowWidget(w, _performance_rating_detail_player + 13);
 
					SetWindowDirty(w);
 
				}
 
@@ -1083,21 +1085,21 @@ static void PerformanceRatingDetailWndPr
 
			SetWindowDirty(w);
 

	
 
			break;
 
		}
 

	
 
		case WE_TICK: {
 
			// Update the player score every 5 days
 
			/* Update the player score every 5 days */
 
			if (--w->custom[0] == 0) {
 
				w->custom[0] = DAY_TICKS;
 
				if (--w->custom[1] == 0) {
 
					Player *p2;
 

	
 
					w->custom[1] = 5;
 
					FOR_ALL_PLAYERS(p2) {
 
						// Skip if player is not active
 
						/* Skip if player is not active */
 
						if (p2->is_active) UpdateCompanyRatingAndValue(p2, false);
 
					}
 
					SetWindowDirty(w);
 
				}
 
			}
 

	
src/gui.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file gui.h */
 

	
 
#ifndef GUI_H
 
#define GUI_H
 

	
 
#include "station.h"
 
#include "window.h"
 
#include "string.h"
 

	
 
/* main_gui.c */
 
/* main_gui.cpp */
 
void SetupColorsAndInitialWindow(void);
 
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
 
/* settings_gui.c */
 
/* settings_gui.cpp */
 
void ShowGameOptions(void);
 
void ShowGameDifficulty(void);
 
void ShowPatchesSelection(void);
 
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right);
 

	
 
/* graph_gui.c */
 
/* graph_gui.cpp */
 
void ShowOperatingProfitGraph(void);
 
void ShowIncomeGraph(void);
 
void ShowDeliveredCargoGraph(void);
 
void ShowPerformanceHistoryGraph(void);
 
void ShowCompanyValueGraph(void);
 
void ShowCargoPaymentRates(void);
 
void ShowCompanyLeagueTable(void);
 
void ShowPerformanceRatingDetail(void);
 

	
 
/* news_gui.c */
 
/* news_gui.cpp */
 
void ShowLastNewsMessage(void);
 
void ShowMessageOptions(void);
 
void ShowMessageHistory(void);
 

	
 
/* rail_gui.c */
 
/* rail_gui.cpp */
 
void ShowBuildRailToolbar(RailType railtype, int button);
 
void PlaceProc_BuyLand(TileIndex tile);
 
void ReinitGuiAfterToggleElrail(bool disable);
 

	
 
/* train_gui.c */
 
/* train_gui.cpp */
 
void ShowTrainViewWindow(const Vehicle *v);
 
void ShowOrdersWindow(const Vehicle *v);
 

	
 
/* road_gui.c */
 
/* road_gui.cpp */
 
void ShowBuildRoadToolbar(void);
 
void ShowBuildRoadScenToolbar(void);
 
void ShowRoadVehViewWindow(const Vehicle *v);
 

	
 
/* dock_gui.c */
 
/* dock_gui.cpp */
 
void ShowBuildDocksToolbar(void);
 
void ShowShipViewWindow(const Vehicle *v);
 

	
 
/* aircraft_gui.c */
 
/* aircraft_gui.cpp */
 
void ShowBuildAirToolbar(void);
 

	
 
/* terraform_gui.c */
 
/* terraform_gui.cpp */
 
void ShowTerraformToolbar(Window *link = NULL);
 

	
 
/* tgp_gui.c */
 
/* tgp_gui.cpp */
 
void ShowGenerateLandscape(void);
 
void ShowHeightmapLoad(void);
 

	
 
void PlaceProc_DemolishArea(TileIndex tile);
 
void PlaceProc_LevelLand(TileIndex tile);
 
bool GUIPlaceProcDragXY(const WindowEvent *e);
 
@@ -72,13 +74,13 @@ enum { // max 32 - 4 = 28 types
 
	GUI_PlaceProc_DesertArea      = 2 << 4,
 
	GUI_PlaceProc_WaterArea       = 3 << 4,
 
	GUI_PlaceProc_ConvertRailArea = 4 << 4,
 
	GUI_PlaceProc_RockyArea       = 5 << 4,
 
};
 

	
 
/* misc_gui.c */
 
/* misc_gui.cpp */
 
void PlaceLandBlockInfo(void);
 
void ShowAboutWindow(void);
 
void ShowBuildTreesToolbar(void);
 
void ShowBuildTreesScenToolbar(void);
 
void ShowTownDirectory(void);
 
void ShowIndustryDirectory(void);
 
@@ -117,23 +119,23 @@ void UpdateTextBufferSize(Textbuf *tb);
 
void BuildFileList(void);
 
void SetFiosType(const byte fiostype);
 

	
 
/* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
 
extern const byte _fios_colors[];
 

	
 
/* bridge_gui.c */
 
/* bridge_gui.cpp */
 
void ShowBuildBridgeWindow(uint start, uint end, byte type);
 

	
 
void ShowBuildIndustryWindow(void);
 
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter);
 
void ShowQuery(StringID caption, StringID message, Window *w, void (*callback)(Window*, bool));
 
void ShowMusicWindow(void);
 

	
 
/* main_gui.c */
 
/* main_gui.cpp */
 
void HandleOnEditText(const char *str);
 
VARDEF bool _station_show_coverage;
 
VARDEF PlaceProc *_place_proc;
 

	
 
/* vehicle_gui.c */
 
/* vehicle_gui.cpp */
 
void InitializeGUI(void);
 

	
 
#endif /* GUI_H */
src/hal.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file hal.h Hardware Abstraction Layer declarations */
 

	
 
#ifndef HAL_H
 
#define HAL_H
 

	
 
typedef struct {
 
	const char *(*start)(const char * const *parm);
 
	void (*stop)(void);
src/heightmap.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file heightmap.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "variables.h"
 
#include "functions.h"
 
#include "heightmap.h"
 
#include "clear_map.h"
 
@@ -223,13 +225,13 @@ static bool ReadHeightmapBMP(char *filen
 
{
 
	FILE *f;
 
	BmpInfo info;
 
	BmpData data;
 
	BmpBuffer buffer;
 

	
 
	// Init BmpData
 
	/* Init BmpData */
 
	memset(&data, 0, sizeof(data));
 

	
 
	f = fopen(filename, "rb");
 
	if (f == NULL) {
 
		ShowErrorMessage(STR_PNGMAP_ERR_FILE_NOT_FOUND, STR_BMPMAP_ERROR, 0, 0);
 
		return false;
src/heightmap.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file heightmap.h */
 

	
 
#ifndef HEIGHTMAP_H
 
#define HEIGHTMAP_H
 

	
 
/*
 
 * Order of these enums has to be the same as in lang/english.txt
 
 * Otherwise you will get inconsistent behaviour.
 
 */
 
enum {
 
	HM_COUNTER_CLOCKWISE, //! Rotate the map counter clockwise 45 degrees
 
	HM_CLOCKWISE,         //! Rotate the map clockwise 45 degrees
 
	HM_COUNTER_CLOCKWISE, ///< Rotate the map counter clockwise 45 degrees
 
	HM_CLOCKWISE,         ///< Rotate the map clockwise 45 degrees
 
};
 

	
 
/**
 
 * Get the dimensions of a heightmap.
 
 * @param filename to query
 
 * @param x dimension x
 
 * @param y dimension y
 
 * @return Returns false if loading of the image failed.
 
 */
 
bool GetHeightmapDimensions(char *filename, uint *x, uint *y);
 

	
 
/**
 
 * Load a heightmap from file and change the map in his current dimensions
 
 *  to a landscape representing the heightmap.
 
 * It converts pixels to height. The brighter, the higher.
 
 * @param filename of the heighmap file to be imported
 
 */
 
void LoadHeightmap(char *filename);
 

	
 
/**
 
 * Make an empty world where all tiles are of height 'tile_height'.
 
 * @param tile_height of the desired new empty world
 
 */
 
void FlatEmptyWorld(byte tile_height);
 

	
 
#endif /* HEIGHTMAP_H */
src/helpers.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file helpers.cpp */
 

	
 
#include "stdafx.h"
 

	
 
#include "openttd.h"
 
#include "engine.h"
 

	
 
#include <new>
 
@@ -9,57 +12,80 @@
 

	
 
/* Engine list manipulators - current implementation is only C wrapper around CBlobT<EngineID> (see yapf/blob.hpp) */
 

	
 
/* we cannot expose CBlobT directly to C so we must cast EngineList* to CBlobT<EngineID>* always when we are called from C */
 
#define B (*(CBlobT<EngineID>*)el)
 

	
 
/** Create Engine List (and initialize it to empty) */
 
/** Create Engine List (and initialize it to empty)
 
 * @param el list to be created
 
 */
 
void EngList_Create(EngineList *el)
 
{
 
	// call CBlobT constructor explicitly
 
	/* call CBlobT constructor explicitly */
 
	new (&B) CBlobT<EngineID>();
 
}
 

	
 
/** Destroy Engine List (and free its contents) */
 
/** Destroy Engine List (and free its contents)
 
 * @param el list to be destroyed
 
 */
 
void EngList_Destroy(EngineList *el)
 
{
 
	// call CBlobT destructor explicitly
 
	/* call CBlobT destructor explicitly */
 
	B.~CBlobT<EngineID>();
 
}
 

	
 
/** Return number of items stored in the Engine List */
 
/** Return number of items stored in the Engine List
 
 * @param el list for count inquiry
 
 * @return the desired count
 
 */
 
uint EngList_Count(const EngineList *el)
 
{
 
	return B.Size();
 
}
 

	
 
/** Add new item at the end of Engine List */
 
/** Add new item at the end of Engine List
 
 * @param el list o which to add an engine
 
 * @param eif engine to add to the list
 
 */
 
void EngList_Add(EngineList *el, EngineID eid)
 
{
 
	B.Append(eid);
 
}
 

	
 
/** Return pointer to the items array held by Engine List */
 
/** Return pointer to the items array held by Engine List
 
 * @param el list from which the array pointer has to be returned
 
 * @return the pointer required
 
 */
 
EngineID* EngList_Items(EngineList *el)
 
{
 
	return B.Data();
 
}
 

	
 
/** Clear the Engine List (by invalidating all its items == reseting item count to zero) */
 
/** Clear the Engine List (by invalidating all its items == reseting item count to zero)
 
 * @param el list to be cleared
 
 */
 
void EngList_RemoveAll(EngineList *el)
 
{
 
	B.Clear();
 
}
 

	
 
/** Sort all items using qsort() and given 'CompareItems' function */
 
/** Sort all items using qsort() and given 'CompareItems' function
 
 * @param el list to be sorted
 
 * @param compare function for evaluation of the quicksort
 
 */
 
void EngList_Sort(EngineList *el, EngList_SortTypeFunction compare)
 
{
 
	qsort(B.Data(), B.Size(), sizeof(**el), compare);
 
}
 

	
 
/** Sort selected range of items (on indices @ <begin, begin+num_items-1>) */
 
/** Sort selected range of items (on indices @ <begin, begin+num_items-1>)
 
 * @param el list to be sorted
 
 * @param compare function for evaluation of the quicksort
 
 * @param begin start of sorting
 
 * @param count of items to be sorted
 
 */
 
void EngList_SortPartial(EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
 
{
 
	assert(begin <= (uint)B.Size());
 
	assert(begin + num_items <= (uint)B.Size());
 
	qsort(B.Data() + begin, num_items, sizeof(**el), compare);
 
}
src/helpers.hpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file helpers.hpp */
 

	
 
#ifndef HELPERS_HPP
 
#define HELPERS_HPP
 

	
 
/** @file helpers.hpp */
 
#include "macros.h"
 

	
 
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
 
*  from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
 
template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
 
{
src/window.h
Show inline comments
 
@@ -40,38 +40,37 @@ typedef void WindowProc(Window *w, Windo
 
    the default height/width of the window itself. You can change this
 
    AFTER window-creation, with:
 
     w->resize.width or w->resize.height.
 
   That was all.. good luck, and enjoy :) -- TrueLight */
 

	
 
typedef enum ResizeFlags {
 
	RESIZE_NONE   = 0,
 
	RESIZE_NONE   = 0,  ///< no resize required
 

	
 
	RESIZE_LEFT   = 1,
 
	RESIZE_RIGHT  = 2,
 
	RESIZE_TOP    = 4,
 
	RESIZE_BOTTOM = 8,
 
	RESIZE_LEFT   = 1,  ///< left resize flag
 
	RESIZE_RIGHT  = 2,  ///< rigth resize flag
 
	RESIZE_TOP    = 4,  ///< top resize flag
 
	RESIZE_BOTTOM = 8,  ///< bottom resize flag
 

	
 
	RESIZE_LR     = RESIZE_LEFT  | RESIZE_RIGHT,
 
	RESIZE_RB     = RESIZE_RIGHT | RESIZE_BOTTOM,
 
	RESIZE_TB     = RESIZE_TOP   | RESIZE_BOTTOM,
 
	RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM,
 
	RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,
 
	RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM,
 
	RESIZE_LR     = RESIZE_LEFT  | RESIZE_RIGHT,   ///<  combination of left and right resize flags
 
	RESIZE_RB     = RESIZE_RIGHT | RESIZE_BOTTOM,  ///<  combination of right and bottom resize flags
 
	RESIZE_TB     = RESIZE_TOP   | RESIZE_BOTTOM,  ///<  combination of top and bottom resize flags
 
	RESIZE_LRB    = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags
 
	RESIZE_LRTB   = RESIZE_LEFT  | RESIZE_RIGHT  | RESIZE_TOP | RESIZE_BOTTOM,  ///<  combination of all resize flags
 
	RESIZE_RTB    = RESIZE_RIGHT | RESIZE_TOP    | RESIZE_BOTTOM, ///<  combination of right, top and bottom resize flag
 

	
 
	/* The following flags are used by the system to specify what is disabled, hidden, or clicked
 
	 * They are used in the same place as the above RESIZE_x flags, Widget visual_flags.
 
	 * These states are used in exceptions. If nothing is specified, they will indicate
 
	 * Enabled, visible or unclicked widgets*/
 
	WIDG_DISABLED = 4,  ///< widget is greyed out, not available
 
	WIDG_HIDDEN   = 5,  ///< widget is made invisible
 
	WIDG_LOWERED  = 6,  ///< widget is paint lowered, a pressed button in fact
 
} ResizeFlag;
 

	
 
/* used to indicate the end of widgets' list for vararg functions */
 
enum {
 
	WIDGET_LIST_END = -1,
 
	WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions
 
};
 

	
 
typedef struct Widget {
 
	byte type;                        ///< Widget type, see WindowWidgetTypes
 
	byte display_flags;               ///< Resize direction, alignment, etc. during resizing, see ResizeFlags
 
	byte color;                       ///< Widget colour, see docs/ottd-colourtext-palette.png
 
@@ -234,13 +233,12 @@ typedef struct Scrollbar {
 
	uint16 count, cap, pos;
 
} Scrollbar;
 

	
 
typedef struct ResizeInfo {
 
	uint width; ///< Minimum width and height
 
	uint height;
 

	
 
	uint step_width; ///< In how big steps the width and height go
 
	uint step_height;
 
} ResizeInfo;
 

	
 
typedef struct WindowMessage {
 
		int msg;
 
@@ -428,13 +426,13 @@ typedef struct {
 
	int height;
 
	uint16 counter;
 
} scroller_d;
 
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
 

	
 
typedef enum SortListFlags {
 
	VL_NONE    = 0x00,
 
	VL_NONE    = 0x00,  ///< no sort
 
	VL_DESC    = 0x01,  ///< sort descending or ascending
 
	VL_RESORT  = 0x02,  ///< instruct the code to resort the list in the next loop
 
	VL_REBUILD = 0x04,  ///< create sort-listing to use for qsort and friends
 
	VL_END     = 0x08
 
} SortListFlags;
 

	
0 comments (0 inline, 0 general)