Changeset - r23497:a0ab44ebd2fa
[Not reviewed]
master
! ! !
Henry Wilson - 5 years ago 2019-03-03 22:25:13
m3henry@googlemail.com
Codechange: Use override specifer for overriding member declarations

This is a C++11 feature that allows the compiler to check that a virtual
member declaration overrides a base-class member with the same signature.

Also src/blitter/32bpp_anim_sse4.hpp +38 is no longer erroneously marked
as virtual despite being a template.
85 files changed with 565 insertions and 565 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_config.hpp
Show inline comments
 
@@ -21,33 +21,33 @@ public:
 
	 * Get the config of a company.
 
	 */
 
	static AIConfig *GetConfig(CompanyID company, ScriptSettingSource source = SSS_DEFAULT);
 

	
 
	AIConfig() :
 
		ScriptConfig()
 
	{}
 

	
 
	AIConfig(const AIConfig *config);
 

	
 
	class AIInfo *GetInfo() const;
 

	
 
	/* virtual */ int GetSetting(const char *name) const;
 
	/* virtual */ void SetSetting(const char *name, int value);
 
	/* virtual */ void AddRandomDeviation();
 
	int GetSetting(const char *name) const override;
 
	void SetSetting(const char *name, int value) override;
 
	void AddRandomDeviation() override;
 

	
 
	/**
 
	 * When ever the AI Scanner is reloaded, all infos become invalid. This
 
	 *  function tells AIConfig about this.
 
	 * @param force_exact_match If true try to find the exact same version
 
	 *   as specified. If false any version is ok.
 
	 * @return \c true if the reset was successful, \c false if the AI was no longer
 
	 *  found.
 
	 */
 
	bool ResetInfo(bool force_exact_match);
 

	
 
protected:
 
	/* virtual */ void PushExtraConfigList();
 
	/* virtual */ void ClearConfigList();
 
	/* virtual */ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match);
 
	void PushExtraConfigList() override;
 
	void ClearConfigList() override;
 
	ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override;
 
};
 

	
 
#endif /* AI_CONFIG_HPP */
src/ai/ai_gui.cpp
Show inline comments
 
@@ -637,25 +637,25 @@ static void ShowAISettingsWindow(Company
 

	
 

	
 
/** Window for displaying the textfile of a AI. */
 
struct ScriptTextfileWindow : public TextfileWindow {
 
	CompanyID slot; ///< View the textfile of this CompanyID slot.
 

	
 
	ScriptTextfileWindow(TextfileType file_type, CompanyID slot) : TextfileWindow(file_type), slot(slot)
 
	{
 
		const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
 
		this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
 
	}
 

	
 
	/* virtual */ void SetStringParameters(int widget) const
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI);
 
			SetDParamStr(1, GetConfig(slot)->GetName());
 
		}
 
	}
 
};
 

	
 
/**
 
 * Open the AI version of the textfile window.
 
 * @param file_type The type of textfile to display.
 
 * @param slot The slot the Script is using.
src/ai/ai_instance.hpp
Show inline comments
 
@@ -16,23 +16,23 @@
 

	
 
/** Runtime information about an AI like a pointer to the squirrel vm and the current state. */
 
class AIInstance : public ScriptInstance {
 
public:
 
	AIInstance();
 

	
 
	/**
 
	 * Initialize the AI and prepare it for its first run.
 
	 * @param info The AI to create the instance of.
 
	 */
 
	void Initialize(class AIInfo *info);
 

	
 
	/* virtual */ int GetSetting(const char *name);
 
	/* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
 
	int GetSetting(const char *name) override;
 
	ScriptInfo *FindLibrary(const char *library, int version) override;
 

	
 
private:
 
	/* virtual */ void RegisterAPI();
 
	/* virtual */ void Died();
 
	/* virtual */ CommandCallback *GetDoCommandCallback();
 
	/* virtual */ void LoadDummyScript();
 
	void RegisterAPI() override;
 
	void Died() override;
 
	CommandCallback *GetDoCommandCallback() override;
 
	void LoadDummyScript() override;
 
};
 

	
 
#endif /* AI_INSTANCE_HPP */
src/ai/ai_scanner.hpp
Show inline comments
 
@@ -10,66 +10,66 @@
 
/** @file ai_scanner.hpp declarations of the class for AI scanner */
 

	
 
#ifndef AI_SCANNER_HPP
 
#define AI_SCANNER_HPP
 

	
 
#include "../script/script_scanner.hpp"
 

	
 
class AIScannerInfo : public ScriptScanner {
 
public:
 
	AIScannerInfo();
 
	~AIScannerInfo();
 

	
 
	/* virtual */ void Initialize();
 
	void Initialize() override;
 

	
 
	/**
 
	 * Select a random AI.
 
	 * @return A random AI from the pool.
 
	 */
 
	class AIInfo *SelectRandomAI() const;
 

	
 
	/**
 
	 * Check if we have an AI by name and version available in our list.
 
	 * @param nameParam The name of the AI.
 
	 * @param versionParam The version of the AI, or -1 if you want the latest.
 
	 * @param force_exact_match Only match name+version, never latest.
 
	 * @return NULL if no match found, otherwise the AI that matched.
 
	 */
 
	class AIInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
 

	
 
	/**
 
	 * Set the Dummy AI.
 
	 */
 
	void SetDummyAI(class AIInfo *info);
 

	
 
protected:
 
	/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
 
	/* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
 
	/* virtual */ Subdirectory GetDirectory() const { return AI_DIR; }
 
	/* virtual */ const char *GetScannerName() const { return "AIs"; }
 
	/* virtual */ void RegisterAPI(class Squirrel *engine);
 
	void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
 
	const char *GetFileName() const override { return PATHSEP "info.nut"; }
 
	Subdirectory GetDirectory() const override { return AI_DIR; }
 
	const char *GetScannerName() const override { return "AIs"; }
 
	void RegisterAPI(class Squirrel *engine) override;
 

	
 
private:
 
	AIInfo *info_dummy; ///< The dummy AI.
 
};
 

	
 
class AIScannerLibrary : public ScriptScanner {
 
public:
 
	/* virtual */ void Initialize();
 
	void Initialize() override;
 

	
 
	/**
 
	 * Find a library in the pool.
 
	 * @param library The library name to find.
 
	 * @param version The version the library should have.
 
	 * @return The library if found, NULL otherwise.
 
	 */
 
	class AILibrary *FindLibrary(const char *library, int version);
 

	
 
protected:
 
	/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
 
	/* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
 
	/* virtual */ Subdirectory GetDirectory() const { return AI_LIBRARY_DIR; }
 
	/* virtual */ const char *GetScannerName() const { return "AI Libraries"; }
 
	/* virtual */ void RegisterAPI(class Squirrel *engine);
 
	void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
 
	const char *GetFileName() const override { return PATHSEP "library.nut"; }
 
	Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; }
 
	const char *GetScannerName() const override { return "AI Libraries"; }
 
	void RegisterAPI(class Squirrel *engine) override;
 
};
 

	
 
#endif /* AI_SCANNER_HPP */
src/base_media_base.h
Show inline comments
 
@@ -167,25 +167,25 @@ struct BaseSet {
 

	
 
/**
 
 * Base for all base media (graphics, sounds)
 
 * @tparam Tbase_set the real set we're going to be
 
 */
 
template <class Tbase_set>
 
class BaseMedia : FileScanner {
 
protected:
 
	static Tbase_set *available_sets; ///< All available sets
 
	static Tbase_set *duplicate_sets; ///< All sets that aren't available, but needed for not downloading base sets when a newer version than the one on BaNaNaS is loaded.
 
	static const Tbase_set *used_set; ///< The currently used set
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override;
 

	
 
	/**
 
	 * Get the extension that is used to identify this set.
 
	 * @return the extension
 
	 */
 
	static const char *GetExtension();
 
public:
 
	/** The set as saved in the config file. */
 
	static const char *ini_set;
 

	
 
	/**
 
	 * Determine the graphics pack that has to be used.
src/blitter/32bpp_anim.hpp
Show inline comments
 
@@ -28,39 +28,39 @@ public:
 
	Blitter_32bppAnim() :
 
		anim_buf(NULL),
 
		anim_alloc(NULL),
 
		anim_buf_width(0),
 
		anim_buf_height(0),
 
		anim_buf_pitch(0)
 
	{
 
		this->palette = _cur_palette;
 
	}
 

	
 
	~Blitter_32bppAnim();
 

	
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
 
	/* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
 
	/* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash);
 
	/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
 
	/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
 
	/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
 
	/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
 
	/* virtual */ int BufferSize(int width, int height);
 
	/* virtual */ void PaletteAnimate(const Palette &palette);
 
	/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
 
	int BufferSize(int width, int height) override;
 
	void PaletteAnimate(const Palette &palette) override;
 
	Blitter::PaletteAnimation UsePaletteAnimation() override;
 

	
 
	/* virtual */ const char *GetName() { return "32bpp-anim"; }
 
	/* virtual */ int GetBytesPerPixel() { return 6; }
 
	/* virtual */ void PostResize();
 
	const char *GetName() override { return "32bpp-anim"; }
 
	int GetBytesPerPixel() override { return 6; }
 
	void PostResize() override;
 

	
 
	/**
 
	 * Look up the colour in the current palette.
 
	 */
 
	inline Colour LookupColourInPalette(uint index)
 
	{
 
		return this->palette.palette[index];
 
	}
 

	
 
	inline int ScreenToAnimOffset(const uint32 *video)
 
	{
 
		int raw_offset = video - (const uint32 *)_screen.dst_ptr;
 
@@ -68,16 +68,16 @@ public:
 
		int lines = raw_offset / _screen.pitch;
 
		int across = raw_offset % _screen.pitch;
 
		return across + (lines * this->anim_buf_pitch);
 
	}
 

	
 
	template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 
};
 

	
 
/** Factory for the 32bpp blitter with animation. */
 
class FBlitter_32bppAnim : public BlitterFactory {
 
public:
 
	FBlitter_32bppAnim() : BlitterFactory("32bpp-anim", "32bpp Animation Blitter (palette animation)") {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppAnim(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppAnim(); }
 
};
 

	
 
#endif /* BLITTER_32BPP_ANIM_HPP */
src/blitter/32bpp_anim_sse2.hpp
Show inline comments
 
@@ -19,25 +19,25 @@
 
#endif
 

	
 
#ifndef FULL_ANIMATION
 
#define FULL_ANIMATION 1
 
#endif
 

	
 
#include "32bpp_anim.hpp"
 
#include "32bpp_sse2.hpp"
 

	
 
/** A partially 32 bpp blitter with palette animation. */
 
class Blitter_32bppSSE2_Anim : public Blitter_32bppAnim {
 
public:
 
	/* virtual */ void PaletteAnimate(const Palette &palette);
 
	/* virtual */ const char *GetName() { return "32bpp-sse2-anim"; }
 
	void PaletteAnimate(const Palette &palette) override;
 
	const char *GetName() override { return "32bpp-sse2-anim"; }
 
};
 

	
 
/** Factory for the partially 32bpp blitter with animation. */
 
class FBlitter_32bppSSE2_Anim : public BlitterFactory {
 
public:
 
	FBlitter_32bppSSE2_Anim() : BlitterFactory("32bpp-sse2-anim", "32bpp partially SSE2 Animation Blitter (palette animation)", HasCPUIDFlag(1, 3, 26)) {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2_Anim(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppSSE2_Anim(); }
 
};
 

	
 
#endif /* WITH_SSE */
 
#endif /* BLITTER_32BPP_ANIM_HPP */
src/blitter/32bpp_anim_sse4.hpp
Show inline comments
 
@@ -26,29 +26,29 @@
 
#include "32bpp_anim_sse2.hpp"
 
#include "32bpp_sse4.hpp"
 

	
 
#undef MARGIN_NORMAL_THRESHOLD
 
#define MARGIN_NORMAL_THRESHOLD 4
 

	
 
/** The SSE4 32 bpp blitter with palette animation. */
 
class Blitter_32bppSSE4_Anim FINAL : public Blitter_32bppSSE2_Anim, public Blitter_32bppSSE_Base {
 
private:
 

	
 
public:
 
	template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent, bool animated>
 
	/* virtual */ void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
 
	void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override {
 
		return Blitter_32bppSSE_Base::Encode(sprite, allocator);
 
	}
 
	/* virtual */ const char *GetName() { return "32bpp-sse4-anim"; }
 
	const char *GetName() override { return "32bpp-sse4-anim"; }
 
};
 

	
 
/** Factory for the SSE4 32 bpp blitter (with palette animation). */
 
class FBlitter_32bppSSE4_Anim: public BlitterFactory {
 
public:
 
	FBlitter_32bppSSE4_Anim() : BlitterFactory("32bpp-sse4-anim", "SSE4 Blitter (palette animation)", HasCPUIDFlag(1, 2, 19)) {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE4_Anim(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppSSE4_Anim(); }
 
};
 

	
 
#endif /* WITH_SSE */
 
#endif /* BLITTER_32BPP_SSE4_ANIM_HPP */
src/blitter/32bpp_base.hpp
Show inline comments
 
@@ -11,37 +11,37 @@
 

	
 
#ifndef BLITTER_32BPP_BASE_HPP
 
#define BLITTER_32BPP_BASE_HPP
 

	
 
#include "base.hpp"
 
#include "../core/bitmath_func.hpp"
 
#include "../core/math_func.hpp"
 
#include "../gfx_func.h"
 

	
 
/** Base for all 32bpp blitters. */
 
class Blitter_32bppBase : public Blitter {
 
public:
 
	/* virtual */ uint8 GetScreenDepth() { return 32; }
 
	/* virtual */ void *MoveTo(void *video, int x, int y);
 
	/* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
 
	/* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash);
 
	/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
 
	/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
 
	/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
 
	/* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
 
	/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
 
	/* virtual */ int BufferSize(int width, int height);
 
	/* virtual */ void PaletteAnimate(const Palette &palette);
 
	/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
 
	/* virtual */ int GetBytesPerPixel() { return 4; }
 
	uint8 GetScreenDepth() override { return 32; }
 
	void *MoveTo(void *video, int x, int y) override;
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
 
	void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
 
	int BufferSize(int width, int height) override;
 
	void PaletteAnimate(const Palette &palette) override;
 
	Blitter::PaletteAnimation UsePaletteAnimation() override;
 
	int GetBytesPerPixel() override { return 4; }
 

	
 
	/**
 
	 * Look up the colour in the current palette.
 
	 */
 
	static inline Colour LookupColourInPalette(uint index)
 
	{
 
		return _cur_palette.palette[index];
 
	}
 

	
 
	/**
 
	 * Compose a colour based on RGBA values and the current pixel value.
 
	 */
src/blitter/32bpp_optimized.hpp
Show inline comments
 
@@ -14,28 +14,28 @@
 

	
 
#include "32bpp_simple.hpp"
 

	
 
/** The optimised 32 bpp blitter (without palette animation). */
 
class Blitter_32bppOptimized : public Blitter_32bppSimple {
 
public:
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteData {
 
		uint32 offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
 
		byte data[];                      ///< Data, all zoomlevels.
 
	};
 

	
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 

	
 
	/* virtual */ const char *GetName() { return "32bpp-optimized"; }
 
	const char *GetName() override { return "32bpp-optimized"; }
 

	
 
	template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 
};
 

	
 
/** Factory for the optimised 32 bpp blitter (without palette animation). */
 
class FBlitter_32bppOptimized : public BlitterFactory {
 
public:
 
	FBlitter_32bppOptimized() : BlitterFactory("32bpp-optimized", "32bpp Optimized Blitter (no palette animation)") {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppOptimized(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppOptimized(); }
 
};
 

	
 
#endif /* BLITTER_32BPP_OPTIMIZED_HPP */
src/blitter/32bpp_simple.hpp
Show inline comments
 
@@ -17,27 +17,27 @@
 

	
 
/** The most trivial 32 bpp blitter (without palette animation). */
 
class Blitter_32bppSimple : public Blitter_32bppBase {
 
	struct Pixel {
 
		uint8 r;  ///< Red-channel
 
		uint8 g;  ///< Green-channel
 
		uint8 b;  ///< Blue-channel
 
		uint8 a;  ///< Alpha-channel
 
		uint8 m;  ///< Remap-channel
 
		uint8 v;  ///< Brightness-channel
 
	};
 
public:
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 

	
 
	/* virtual */ const char *GetName() { return "32bpp-simple"; }
 
	const char *GetName() override { return "32bpp-simple"; }
 
};
 

	
 
/** Factory for the simple 32 bpp blitter. */
 
class FBlitter_32bppSimple : public BlitterFactory {
 
public:
 
	FBlitter_32bppSimple() : BlitterFactory("32bpp-simple", "32bpp Simple Blitter (no palette animation)") {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSimple(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppSimple(); }
 
};
 

	
 
#endif /* BLITTER_32BPP_SIMPLE_HPP */
src/blitter/32bpp_sse2.hpp
Show inline comments
 
@@ -73,32 +73,32 @@ public:
 
		SpriteInfo infos[ZOOM_LVL_COUNT];
 
		byte data[]; ///< Data, all zoomlevels.
 
	};
 

	
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
 
};
 

	
 
DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
 

	
 
/** The SSE2 32 bpp blitter (without palette animation). */
 
class Blitter_32bppSSE2 : public Blitter_32bppSimple, public Blitter_32bppSSE_Base {
 
public:
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
 
	void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 

	
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override {
 
		return Blitter_32bppSSE_Base::Encode(sprite, allocator);
 
	}
 

	
 
	/* virtual */ const char *GetName() { return "32bpp-sse2"; }
 
	const char *GetName() override { return "32bpp-sse2"; }
 
};
 

	
 
/** Factory for the SSE2 32 bpp blitter (without palette animation). */
 
class FBlitter_32bppSSE2 : public BlitterFactory {
 
public:
 
	FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppSSE2(); }
 
};
 

	
 
#endif /* WITH_SSE */
 
#endif /* BLITTER_32BPP_SSE2_HPP */
src/blitter/32bpp_sse4.hpp
Show inline comments
 
@@ -18,27 +18,27 @@
 
#define SSE_VERSION 4
 
#endif
 

	
 
#ifndef FULL_ANIMATION
 
#define FULL_ANIMATION 0
 
#endif
 

	
 
#include "32bpp_ssse3.hpp"
 

	
 
/** The SSE4 32 bpp blitter (without palette animation). */
 
class Blitter_32bppSSE4 : public Blitter_32bppSSSE3 {
 
public:
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
 
	void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 
	/* virtual */ const char *GetName() { return "32bpp-sse4"; }
 
	const char *GetName() override { return "32bpp-sse4"; }
 
};
 

	
 
/** Factory for the SSE4 32 bpp blitter (without palette animation). */
 
class FBlitter_32bppSSE4: public BlitterFactory {
 
public:
 
	FBlitter_32bppSSE4() : BlitterFactory("32bpp-sse4", "32bpp SSE4 Blitter (no palette animation)", HasCPUIDFlag(1, 2, 19)) {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE4(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppSSE4(); }
 
};
 

	
 
#endif /* WITH_SSE */
 
#endif /* BLITTER_32BPP_SSE4_HPP */
src/blitter/32bpp_ssse3.hpp
Show inline comments
 
@@ -18,27 +18,27 @@
 
#define SSE_VERSION 3
 
#endif
 

	
 
#ifndef FULL_ANIMATION
 
#define FULL_ANIMATION 0
 
#endif
 

	
 
#include "32bpp_sse2.hpp"
 

	
 
/** The SSSE3 32 bpp blitter (without palette animation). */
 
class Blitter_32bppSSSE3 : public Blitter_32bppSSE2 {
 
public:
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
 
	void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
 
	/* virtual */ const char *GetName() { return "32bpp-ssse3"; }
 
	const char *GetName() override { return "32bpp-ssse3"; }
 
};
 

	
 
/** Factory for the SSSE3 32 bpp blitter (without palette animation). */
 
class FBlitter_32bppSSSE3: public BlitterFactory {
 
public:
 
	FBlitter_32bppSSSE3() : BlitterFactory("32bpp-ssse3", "32bpp SSSE3 Blitter (no palette animation)", HasCPUIDFlag(1, 2, 9)) {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSSE3(); }
 
	Blitter *CreateInstance() override { return new Blitter_32bppSSSE3(); }
 
};
 

	
 
#endif /* WITH_SSE */
 
#endif /* BLITTER_32BPP_SSSE3_HPP */
src/blitter/8bpp_base.hpp
Show inline comments
 
@@ -8,29 +8,29 @@
 
 */
 

	
 
/** @file 8bpp_base.hpp Base for all 8 bpp blitters. */
 

	
 
#ifndef BLITTER_8BPP_BASE_HPP
 
#define BLITTER_8BPP_BASE_HPP
 

	
 
#include "base.hpp"
 

	
 
/** Base for all 8bpp blitters. */
 
class Blitter_8bppBase : public Blitter {
 
public:
 
	/* virtual */ uint8 GetScreenDepth() { return 8; }
 
	/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
 
	/* virtual */ void *MoveTo(void *video, int x, int y);
 
	/* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
 
	/* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash);
 
	/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
 
	/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
 
	/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
 
	/* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
 
	/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
 
	/* virtual */ int BufferSize(int width, int height);
 
	/* virtual */ void PaletteAnimate(const Palette &palette);
 
	/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
 
	/* virtual */ int GetBytesPerPixel() { return 1; }
 
	uint8 GetScreenDepth() override { return 8; }
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
 
	void *MoveTo(void *video, int x, int y) override;
 
	void SetPixel(void *video, int x, int y, uint8 colour) override;
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
 
	void DrawRect(void *video, int width, int height, uint8 colour) override;
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override;
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override;
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
 
	void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
 
	int BufferSize(int width, int height) override;
 
	void PaletteAnimate(const Palette &palette) override;
 
	Blitter::PaletteAnimation UsePaletteAnimation() override;
 
	int GetBytesPerPixel() override { return 1; }
 
};
 

	
 
#endif /* BLITTER_8BPP_BASE_HPP */
src/blitter/8bpp_optimized.hpp
Show inline comments
 
@@ -15,26 +15,26 @@
 
#include "8bpp_base.hpp"
 
#include "factory.hpp"
 

	
 
/** 8bpp blitter optimised for speed. */
 
class Blitter_8bppOptimized FINAL : public Blitter_8bppBase {
 
public:
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteData {
 
		uint32 offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
 
		byte data[];                   ///< Data, all zoomlevels.
 
	};
 

	
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 

	
 
	/* virtual */ const char *GetName() { return "8bpp-optimized"; }
 
	const char *GetName() override { return "8bpp-optimized"; }
 
};
 

	
 
/** Factory for the 8bpp blitter optimised for speed. */
 
class FBlitter_8bppOptimized : public BlitterFactory {
 
public:
 
	FBlitter_8bppOptimized() : BlitterFactory("8bpp-optimized", "8bpp Optimized Blitter (compression + all-ZoomLevel cache)") {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_8bppOptimized(); }
 
	Blitter *CreateInstance() override { return new Blitter_8bppOptimized(); }
 
};
 

	
 
#endif /* BLITTER_8BPP_OPTIMIZED_HPP */
src/blitter/8bpp_simple.hpp
Show inline comments
 
@@ -9,26 +9,26 @@
 

	
 
/** @file 8bpp_simple.hpp Simple (and slow) 8 bpp blitter. */
 

	
 
#ifndef BLITTER_8BPP_SIMPLE_HPP
 
#define BLITTER_8BPP_SIMPLE_HPP
 

	
 
#include "8bpp_base.hpp"
 
#include "factory.hpp"
 

	
 
/** Most trivial 8bpp blitter. */
 
class Blitter_8bppSimple FINAL : public Blitter_8bppBase {
 
public:
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 

	
 
	/* virtual */ const char *GetName() { return "8bpp-simple"; }
 
	const char *GetName() override { return "8bpp-simple"; }
 
};
 

	
 
/** Factory for the most trivial 8bpp blitter. */
 
class FBlitter_8bppSimple : public BlitterFactory {
 
public:
 
	FBlitter_8bppSimple() : BlitterFactory("8bpp-simple", "8bpp Simple Blitter (relative slow, but never wrong)") {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_8bppSimple(); }
 
	Blitter *CreateInstance() override { return new Blitter_8bppSimple(); }
 
};
 

	
 
#endif /* BLITTER_8BPP_SIMPLE_HPP */
src/blitter/null.hpp
Show inline comments
 
@@ -8,40 +8,40 @@
 
 */
 

	
 
/** @file null.hpp The blitter that doesn't blit. */
 

	
 
#ifndef BLITTER_NULL_HPP
 
#define BLITTER_NULL_HPP
 

	
 
#include "factory.hpp"
 

	
 
/** Blitter that does nothing. */
 
class Blitter_Null : public Blitter {
 
public:
 
	/* virtual */ uint8 GetScreenDepth() { return 0; }
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) {};
 
	/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) {};
 
	/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
 
	/* virtual */ void *MoveTo(void *video, int x, int y) { return NULL; };
 
	/* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {};
 
	/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {};
 
	/* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) {};
 
	/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height) {};
 
	/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height) {};
 
	/* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) {};
 
	/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) {};
 
	/* virtual */ int BufferSize(int width, int height) { return 0; };
 
	/* virtual */ void PaletteAnimate(const Palette &palette) { };
 
	/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation() { return Blitter::PALETTE_ANIMATION_NONE; };
 
	uint8 GetScreenDepth() override { return 0; }
 
	void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
 
	void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 
	void *MoveTo(void *video, int x, int y) override { return NULL; };
 
	void SetPixel(void *video, int x, int y, uint8 colour) override {};
 
	void DrawRect(void *video, int width, int height, uint8 colour) override {};
 
	void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {};
 
	void CopyFromBuffer(void *video, const void *src, int width, int height) override {};
 
	void CopyToBuffer(const void *video, void *dst, int width, int height) override {};
 
	void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {};
 
	void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override {};
 
	int BufferSize(int width, int height) override { return 0; };
 
	void PaletteAnimate(const Palette &palette) override { };
 
	Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; };
 

	
 
	/* virtual */ const char *GetName() { return "null"; }
 
	/* virtual */ int GetBytesPerPixel() { return 0; }
 
	const char *GetName() override { return "null"; }
 
	int GetBytesPerPixel() override { return 0; }
 
};
 

	
 
/** Factory for the blitter that does nothing. */
 
class FBlitter_Null : public BlitterFactory {
 
public:
 
	FBlitter_Null() : BlitterFactory("null", "Null Blitter (does nothing)") {}
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_Null(); }
 
	Blitter *CreateInstance() override { return new Blitter_Null(); }
 
};
 

	
 
#endif /* BLITTER_NULL_HPP */
src/fileio_func.h
Show inline comments
 
@@ -98,25 +98,25 @@ class TarScanner : FileScanner {
 
public:
 
	/** The mode of tar scanning. */
 
	enum Mode {
 
		NONE     = 0,      ///< Scan nothing.
 
		BASESET  = 1 << 0, ///< Scan for base sets.
 
		NEWGRF   = 1 << 1, ///< Scan for non-base sets.
 
		AI       = 1 << 2, ///< Scan for AIs and its libraries.
 
		SCENARIO = 1 << 3, ///< Scan for scenarios and heightmaps.
 
		GAME     = 1 << 4, ///< Scan for game scripts.
 
		ALL      = BASESET | NEWGRF | AI | SCENARIO | GAME, ///< Scan for everything.
 
	};
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL);
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL) override;
 

	
 
	bool AddFile(Subdirectory sd, const char *filename);
 

	
 
	/** Do the scan for Tars. */
 
	static uint DoScan(TarScanner::Mode mode);
 
};
 

	
 
DECLARE_ENUM_AS_BIT_SET(TarScanner::Mode)
 

	
 
/* Implementation of opendir/readdir/closedir for Windows */
 
#if defined(_WIN32)
 
struct DIR;
src/fios.cpp
Show inline comments
 
@@ -267,25 +267,25 @@ class FiosFileScanner : public FileScann
 
	FileList &file_list;     ///< Destination of the found files.
 
public:
 
	/**
 
	 * Create the scanner
 
	 * @param fop Purpose of collecting the list.
 
	 * @param callback_proc The function that is called where you need to do the filtering.
 
	 * @param file_list Destination of the found files.
 
	 */
 
	FiosFileScanner(SaveLoadOperation fop, fios_getlist_callback_proc *callback_proc, FileList &file_list) :
 
			fop(fop), callback_proc(callback_proc), file_list(file_list)
 
	{}
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override;
 
};
 

	
 
/**
 
 * Try to add a fios item set with the given filename.
 
 * @param filename        the full path to the file to read
 
 * @param basepath_length amount of characters to chop of before to get a relative filename
 
 * @return true if the file is added.
 
 */
 
bool FiosFileScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
 
{
 
	const char *ext = strrchr(filename, '.');
 
	if (ext == NULL) return false;
 
@@ -664,25 +664,25 @@ public:
 
	/**
 
	 * Scan, but only if it's needed.
 
	 * @param rescan whether to force scanning even when it's not necessary
 
	 */
 
	void Scan(bool rescan)
 
	{
 
		if (this->scanned && !rescan) return;
 

	
 
		this->FileScanner::Scan(".id", SCENARIO_DIR, true, true);
 
		this->scanned = true;
 
	}
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override
 
	{
 
		FILE *f = FioFOpenFile(filename, "r", SCENARIO_DIR);
 
		if (f == NULL) return false;
 

	
 
		ScenarioIdentifier id;
 
		int fret = fscanf(f, "%i", &id.scenid);
 
		FioFCloseFile(f);
 
		if (fret != 1) return false;
 
		strecpy(id.filename, filename, lastof(id.filename));
 

	
 
		Md5 checksum;
 
		uint8 buffer[1024];
src/game/game_config.hpp
Show inline comments
 
@@ -33,16 +33,16 @@ public:
 

	
 
	/**
 
	 * When ever the Game Scanner is reloaded, all infos become invalid. This
 
	 *  function tells GameConfig about this.
 
	 * @param force_exact_match If true try to find the exact same version
 
	 *   as specified. If false any version is ok.
 
	 * @return \c true if the reset was successful, \c false if the Game was no longer
 
	 *  found.
 
	 */
 
	bool ResetInfo(bool force_exact_match);
 

	
 
protected:
 
	/* virtual */ ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match);
 
	ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override;
 
};
 

	
 
#endif /* GAME_CONFIG_HPP */
src/game/game_info.hpp
Show inline comments
 
@@ -31,25 +31,25 @@ public:
 
	static SQInteger Constructor(HSQUIRRELVM vm);
 

	
 
	/**
 
	 * Check if we can start this Game.
 
	 */
 
	bool CanLoadFromVersion(int version) const;
 

	
 
	/**
 
	 * Get the API version this Game is written for.
 
	 */
 
	const char *GetAPIVersion() const { return this->api_version; }
 

	
 
	/* virtual */ bool IsDeveloperOnly() const { return this->is_developer_only; }
 
	bool IsDeveloperOnly() const override { return this->is_developer_only; }
 

	
 
private:
 
	int min_loadable_version; ///< The Game can load savegame data if the version is equal or greater than this.
 
	bool is_developer_only;   ///< Is the script selectable by non-developers?
 
	const char *api_version;  ///< API version used by this Game.
 
};
 

	
 
/** All static information from an Game library like name, version, etc. */
 
class GameLibrary : public ScriptInfo {
 
public:
 
	GameLibrary() : ScriptInfo(), category(NULL) {};
 
	~GameLibrary();
src/game/game_instance.hpp
Show inline comments
 
@@ -16,23 +16,23 @@
 

	
 
/** Runtime information about a game script like a pointer to the squirrel vm and the current state. */
 
class GameInstance : public ScriptInstance {
 
public:
 
	GameInstance();
 

	
 
	/**
 
	 * Initialize the script and prepare it for its first run.
 
	 * @param info The GameInfo to start.
 
	 */
 
	void Initialize(class GameInfo *info);
 

	
 
	/* virtual */ int GetSetting(const char *name);
 
	/* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
 
	int GetSetting(const char *name) override;
 
	ScriptInfo *FindLibrary(const char *library, int version) override;
 

	
 
private:
 
	/* virtual */ void RegisterAPI();
 
	/* virtual */ void Died();
 
	/* virtual */ CommandCallback *GetDoCommandCallback();
 
	/* virtual */ void LoadDummyScript() {}
 
	void RegisterAPI() override;
 
	void Died() override;
 
	CommandCallback *GetDoCommandCallback() override;
 
	void LoadDummyScript() override {}
 
};
 

	
 
#endif /* GAME_INSTANCE_HPP */
src/game/game_scanner.hpp
Show inline comments
 
@@ -7,53 +7,53 @@
 
 * 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 game_scanner.hpp declarations of the class for Game scanner */
 

	
 
#ifndef GAME_SCANNER_HPP
 
#define GAME_SCANNER_HPP
 

	
 
#include "../script/script_scanner.hpp"
 

	
 
class GameScannerInfo : public ScriptScanner {
 
public:
 
	/* virtual */ void Initialize();
 
	void Initialize() override;
 

	
 
	/**
 
	 * Check if we have a game by name and version available in our list.
 
	 * @param nameParam The name of the game script.
 
	 * @param versionParam The version of the game script, or -1 if you want the latest.
 
	 * @param force_exact_match Only match name+version, never latest.
 
	 * @return NULL if no match found, otherwise the game script that matched.
 
	 */
 
	class GameInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
 

	
 
protected:
 
	/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
 
	/* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
 
	/* virtual */ Subdirectory GetDirectory() const { return GAME_DIR; }
 
	/* virtual */ const char *GetScannerName() const { return "Game Scripts"; }
 
	/* virtual */ void RegisterAPI(class Squirrel *engine);
 
	void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
 
	const char *GetFileName() const override { return PATHSEP "info.nut"; }
 
	Subdirectory GetDirectory() const override { return GAME_DIR; }
 
	const char *GetScannerName() const override { return "Game Scripts"; }
 
	void RegisterAPI(class Squirrel *engine) override;
 
};
 

	
 

	
 
class GameScannerLibrary : public ScriptScanner {
 
public:
 
	/* virtual */ void Initialize();
 
	void Initialize() override;
 

	
 
	/**
 
	 * Find a library in the pool.
 
	 * @param library The library name to find.
 
	 * @param version The version the library should have.
 
	 * @return The library if found, NULL otherwise.
 
	 */
 
	class GameLibrary *FindLibrary(const char *library, int version);
 

	
 
protected:
 
	/* virtual */ void GetScriptName(ScriptInfo *info, char *name, const char *last);
 
	/* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
 
	/* virtual */ Subdirectory GetDirectory() const { return GAME_LIBRARY_DIR; }
 
	/* virtual */ const char *GetScannerName() const { return "GS Libraries"; }
 
	/* virtual */ void RegisterAPI(class Squirrel *engine);
 
	void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
 
	const char *GetFileName() const override { return PATHSEP "library.nut"; }
 
	Subdirectory GetDirectory() const override { return GAME_LIBRARY_DIR; }
 
	const char *GetScannerName() const override { return "GS Libraries"; }
 
	void RegisterAPI(class Squirrel *engine) override;
 
};
 

	
 
#endif /* GAME_SCANNER_HPP */
src/game/game_text.cpp
Show inline comments
 
@@ -142,25 +142,25 @@ struct StringListReader : StringReader {
 
	/**
 
	 * Create the reader.
 
	 * @param data        The data to fill during reading.
 
	 * @param strings     The language strings we are reading.
 
	 * @param master      Are we reading the master file?
 
	 * @param translation Are we reading a translation?
 
	 */
 
	StringListReader(StringData &data, const LanguageStrings *strings, bool master, bool translation) :
 
			StringReader(data, strings->language, master, translation), p(strings->lines.Begin()), end(strings->lines.End())
 
	{
 
	}
 

	
 
	/* virtual */ char *ReadLine(char *buffer, const char *last)
 
	char *ReadLine(char *buffer, const char *last) override
 
	{
 
		if (this->p == this->end) return NULL;
 

	
 
		strecpy(buffer, *this->p, last);
 
		this->p++;
 

	
 
		return buffer;
 
	}
 
};
 

	
 
/** Class for writing an encoded language. */
 
struct TranslationWriter : LanguageWriter {
 
@@ -233,25 +233,25 @@ public:
 
	/** Initialise */
 
	LanguageScanner(GameStrings *gs, const char *exclude) : gs(gs), exclude(stredup(exclude)) {}
 
	~LanguageScanner() { free(exclude); }
 

	
 
	/**
 
	 * Scan.
 
	 */
 
	void Scan(const char *directory)
 
	{
 
		this->FileScanner::Scan(".txt", directory, false);
 
	}
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override
 
	{
 
		if (strcmp(filename, exclude) == 0) return true;
 

	
 
		*gs->raw_strings.Append() = ReadRawLanguageStrings(filename);
 
		return true;
 
	}
 
};
 

	
 
/**
 
 * Load all translations that we know of.
 
 * @return Container with all (compiled) translations.
 
 */
src/goal_gui.cpp
Show inline comments
 
@@ -41,37 +41,37 @@ enum GoalColumn {
 
struct GoalListWindow : public Window {
 
	Scrollbar *vscroll; ///< Reference to the scrollbar widget.
 

	
 
	GoalListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
 
	{
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_GOAL_SCROLLBAR);
 
		this->FinishInitNested(window_number);
 
		this->owner = (Owner)this->window_number;
 
		this->OnInvalidateData(0);
 
	}
 

	
 
	/* virtual */ void SetStringParameters(int widget) const
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget != WID_GOAL_CAPTION) return;
 

	
 
		if (this->window_number == INVALID_COMPANY) {
 
			SetDParam(0, STR_GOALS_SPECTATOR_CAPTION);
 
		} else {
 
			SetDParam(0, STR_GOALS_CAPTION);
 
			SetDParam(1, this->window_number);
 
		}
 
	}
 

	
 
	/* virtual */ void OnClick(Point pt, int widget, int click_count)
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		if (widget != WID_GOAL_LIST) return;
 

	
 
		int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
 
		int num = 0;
 
		const Goal *s;
 
		FOR_ALL_GOALS(s) {
 
			if (s->company == INVALID_COMPANY) {
 
				y--;
 
				if (y == 0) {
 
					this->HandleClick(s);
 
					return;
 
@@ -168,25 +168,25 @@ struct GoalListWindow : public Window {
 
				num_company++;
 
			}
 
		}
 

	
 
		/* Count the 'none' lines. */
 
		if (num_global  == 0) num_global = 1;
 
		if (num_company == 0) num_company = 1;
 

	
 
		/* Global, company and an empty line before the accepted ones. */
 
		return 3 + num_global + num_company;
 
	}
 

	
 
	/* virtual */ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		if (widget != WID_GOAL_LIST) return;
 
		Dimension d = maxdim(GetStringBoundingBox(STR_GOALS_GLOBAL_TITLE), GetStringBoundingBox(STR_GOALS_COMPANY_TITLE));
 

	
 
		resize->height = d.height;
 

	
 
		d.height *= 5;
 
		d.width += padding.width + WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT;
 
		d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		*size = maxdim(*size, d);
 
	}
 

	
 
@@ -263,25 +263,25 @@ struct GoalListWindow : public Window {
 

	
 
		int pos = -this->vscroll->GetPosition();
 
		const int cap = this->vscroll->GetCapacity();
 

	
 
		/* Draw partial list with global goals. */
 
		DrawPartialGoalList(pos, cap, x, y, right, progress_col_width, true, column);
 

	
 
		/* Draw partial list with company goals. */
 
		pos++;
 
		DrawPartialGoalList(pos, cap, x, y, right, progress_col_width, false, column);
 
	}
 

	
 
	/* virtual */ void OnPaint()
 
	void OnPaint() override
 
	{
 
		this->DrawWidgets();
 

	
 
		if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
 

	
 
		/* Calculate progress column width. */
 
		uint max_width = 0;
 
		Goal *s;
 
		FOR_ALL_GOALS(s) {
 
			if (s->progress != NULL) {
 
				SetDParamStr(0, s->progress);
 
				StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
 
@@ -290,35 +290,35 @@ struct GoalListWindow : public Window {
 
			}
 
		}
 

	
 
		NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GOAL_LIST);
 
		uint progress_col_width = min(max_width, wid->current_x);
 

	
 
		/* Draw goal list. */
 
		this->DrawListColumn(GC_PROGRESS, wid, progress_col_width);
 
		this->DrawListColumn(GC_GOAL, wid, progress_col_width);
 

	
 
	}
 

	
 
	/* virtual */ void OnResize()
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	/* virtual */ void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		this->vscroll->SetCount(this->CountLines());
 
		this->SetWidgetDirty(WID_GOAL_LIST);
 
	}
 
};
 

	
 
/** Widgets of the #GoalListWindow. */
 
static const NWidgetPart _nested_goals_list_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
 
		NWidget(WWT_CAPTION, COLOUR_BROWN, WID_GOAL_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
@@ -379,74 +379,74 @@ struct GoalQuestionWindow : public Windo
 
		assert(this->buttons > 0 && this->buttons < 4);
 

	
 
		this->CreateNestedTree();
 
		this->GetWidget<NWidgetStacked>(WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1);
 
		this->FinishInitNested(window_number);
 
	}
 

	
 
	~GoalQuestionWindow()
 
	{
 
		free(this->question);
 
	}
 

	
 
	/* virtual */ void SetStringParameters(int widget) const
 
	void SetStringParameters(int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_GQ_CAPTION:
 
				SetDParam(0, STR_GOAL_QUESTION_CAPTION_QUESTION + this->type);
 
				break;
 

	
 
			case WID_GQ_BUTTON_1:
 
				SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
 
				break;
 

	
 
			case WID_GQ_BUTTON_2:
 
				SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]);
 
				break;
 

	
 
			case WID_GQ_BUTTON_3:
 
				SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
 
				break;
 
		}
 
	}
 

	
 
	/* virtual */ void OnClick(Point pt, int widget, int click_count)
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_GQ_BUTTON_1:
 
				DoCommandP(0, this->window_number, this->button[0], CMD_GOAL_QUESTION_ANSWER);
 
				delete this;
 
				break;
 

	
 
			case WID_GQ_BUTTON_2:
 
				DoCommandP(0, this->window_number, this->button[1], CMD_GOAL_QUESTION_ANSWER);
 
				delete this;
 
				break;
 

	
 
			case WID_GQ_BUTTON_3:
 
				DoCommandP(0, this->window_number, this->button[2], CMD_GOAL_QUESTION_ANSWER);
 
				delete this;
 
				break;
 
		}
 
	}
 

	
 
	/* virtual */ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		if (widget != WID_GQ_QUESTION) return;
 

	
 
		SetDParamStr(0, this->question);
 
		size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WD_PAR_VSEP_WIDE;
 
	}
 

	
 
	/* virtual */ void DrawWidget(const Rect &r, int widget) const
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget != WID_GQ_QUESTION) return;
 

	
 
		SetDParamStr(0, this->question);
 
		DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK, SA_TOP | SA_HOR_CENTER);
 
	}
 
};
 

	
 
/** Widgets of the goal question window. */
 
static const NWidgetPart _nested_goal_question_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
src/ground_vehicle.hpp
Show inline comments
 
@@ -83,32 +83,32 @@ struct GroundVehicle : public Specialize
 
	uint16 gv_flags;           ///< @see GroundVehicleFlags.
 

	
 
	typedef GroundVehicle<T, Type> GroundVehicleBase; ///< Our type
 

	
 
	/**
 
	 * The constructor at SpecializedVehicle must be called.
 
	 */
 
	GroundVehicle() : SpecializedVehicle<T, Type>() {}
 

	
 
	void PowerChanged();
 
	void CargoChanged();
 
	int GetAcceleration() const;
 
	bool IsChainInDepot() const;
 
	bool IsChainInDepot() const override;
 

	
 
	/**
 
	 * Common code executed for crashed ground vehicles
 
	 * @param flooded was this vehicle flooded?
 
	 * @return number of victims
 
	 */
 
	/* virtual */ uint Crash(bool flooded)
 
	uint Crash(bool flooded) override
 
	{
 
		/* Crashed vehicles aren't going up or down */
 
		for (T *v = T::From(this); v != NULL; v = v->Next()) {
 
			ClrBit(v->gv_flags, GVF_GOINGUP_BIT);
 
			ClrBit(v->gv_flags, GVF_GOINGDOWN_BIT);
 
		}
 
		return this->Vehicle::Crash(flooded);
 
	}
 

	
 
	/**
 
	 * Calculates the total slope resistance for this vehicle.
 
	 * @return Slope resistance.
src/music/allegro_m.h
Show inline comments
 
@@ -8,42 +8,42 @@
 
 */
 

	
 
/** @file allegro_m.h Base support for playing music via allegro. */
 

	
 
#ifndef MUSIC_ALLEGRO_H
 
#define MUSIC_ALLEGRO_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** Allegro's music player. */
 
class MusicDriver_Allegro : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "allegro"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "allegro"; }
 
};
 

	
 
/** Factory for allegro's music player. */
 
class FMusicDriver_Allegro : public DriverFactoryBase {
 
public:
 
#if !defined(WITH_SDL) && defined(WITH_ALLEGRO)
 
	/* If SDL is not compiled in but Allegro is, chances are quite big
 
	 * that Allegro is going to be used. Then favour this sound driver
 
	 * over extmidi because with extmidi we get crashes. */
 
	static const int PRIORITY = 9;
 
#else
 
	static const int PRIORITY = 2;
 
#endif
 
	FMusicDriver_Allegro() : DriverFactoryBase(Driver::DT_MUSIC, PRIORITY, "allegro", "Allegro MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_Allegro(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_Allegro(); }
 
};
 

	
 
#endif /* MUSIC_ALLEGRO_H */
src/music/bemidi.h
Show inline comments
 
@@ -8,34 +8,34 @@
 
 */
 

	
 
/** @file bemidi.h Base of BeOS Midi support. */
 

	
 
#ifndef MUSIC_BEMIDI_H
 
#define MUSIC_BEMIDI_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** The midi player for BeOS. */
 
class MusicDriver_BeMidi : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "bemidi"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "bemidi"; }
 
};
 

	
 
/** Factory for the BeOS midi player. */
 
class FMusicDriver_BeMidi : public DriverFactoryBase {
 
public:
 
	FMusicDriver_BeMidi() : DriverFactoryBase(Driver::DT_MUSIC, 10, "bemidi", "BeOS MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_BeMidi(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_BeMidi(); }
 
};
 

	
 
#endif /* MUSIC_BEMIDI_H */
src/music/cocoa_m.h
Show inline comments
 
@@ -7,33 +7,33 @@
 
 * 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 cocoa_m.h Base of music playback via CoreAudio. */
 

	
 
#ifndef MUSIC_MACOSX_COCOA_H
 
#define MUSIC_MACOSX_COCOA_H
 

	
 
#include "music_driver.hpp"
 

	
 
class MusicDriver_Cocoa : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "cocoa"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "cocoa"; }
 
};
 

	
 
class FMusicDriver_Cocoa : public DriverFactoryBase {
 
public:
 
	FMusicDriver_Cocoa() : DriverFactoryBase(Driver::DT_MUSIC, 10, "cocoa", "Cocoa MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_Cocoa(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_Cocoa(); }
 
};
 

	
 
#endif /* MUSIC_MACOSX_COCOA_H */
src/music/dmusic.h
Show inline comments
 
@@ -10,34 +10,34 @@
 
/** @file dmusic.h Base of playing music via DirectMusic. */
 

	
 
#ifndef MUSIC_DMUSIC_H
 
#define MUSIC_DMUSIC_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** Music player making use of DirectX. */
 
class MusicDriver_DMusic : public MusicDriver {
 
public:
 
	virtual ~MusicDriver_DMusic();
 

	
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "dmusic"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "dmusic"; }
 
};
 

	
 
/** Factory for the DirectX music player. */
 
class FMusicDriver_DMusic : public DriverFactoryBase {
 
public:
 
	FMusicDriver_DMusic() : DriverFactoryBase(Driver::DT_MUSIC, 10, "dmusic", "DirectMusic MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_DMusic(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_DMusic(); }
 
};
 

	
 
#endif /* MUSIC_DMUSIC_H */
src/music/extmidi.h
Show inline comments
 
@@ -15,33 +15,33 @@
 
#include "music_driver.hpp"
 

	
 
class MusicDriver_ExtMidi : public MusicDriver {
 
private:
 
	char **params;
 
	char song[MAX_PATH];
 
	pid_t pid;
 

	
 
	void DoPlay();
 
	void DoStop();
 

	
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "extmidi"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "extmidi"; }
 
};
 

	
 
class FMusicDriver_ExtMidi : public DriverFactoryBase {
 
public:
 
	FMusicDriver_ExtMidi() : DriverFactoryBase(Driver::DT_MUSIC, 3, "extmidi", "External MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_ExtMidi(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_ExtMidi(); }
 
};
 

	
 
#endif /* MUSIC_EXTERNAL_H */
src/music/fluidsynth.h
Show inline comments
 
@@ -8,34 +8,34 @@
 
 */
 

	
 
/** @file fluidsynth.h Base for FluidSynth music playback. */
 

	
 
#ifndef MUSIC_FLUIDSYNTH_H
 
#define MUSIC_FLUIDSYNTH_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** Music driver making use of FluidSynth. */
 
class MusicDriver_FluidSynth : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "fluidsynth"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "fluidsynth"; }
 
};
 

	
 
/** Factory for the fluidsynth driver. */
 
class FMusicDriver_FluidSynth : public DriverFactoryBase {
 
public:
 
	FMusicDriver_FluidSynth() : DriverFactoryBase(Driver::DT_MUSIC, 5, "fluidsynth", "FluidSynth MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_FluidSynth(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_FluidSynth(); }
 
};
 

	
 
#endif /* MUSIC_FLUIDSYNTH_H */
src/music/null_m.h
Show inline comments
 
@@ -8,34 +8,34 @@
 
 */
 

	
 
/** @file null_m.h Base for the silent music playback. */
 

	
 
#ifndef MUSIC_NULL_H
 
#define MUSIC_NULL_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** The music player that does nothing. */
 
class MusicDriver_Null : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param) { return NULL; }
 
	const char *Start(const char * const *param) override { return NULL; }
 

	
 
	/* virtual */ void Stop() { }
 
	void Stop() override { }
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song) { }
 
	void PlaySong(const MusicSongInfo &song) override { }
 

	
 
	/* virtual */ void StopSong() { }
 
	void StopSong() override { }
 

	
 
	/* virtual */ bool IsSongPlaying() { return true; }
 
	bool IsSongPlaying() override { return true; }
 

	
 
	/* virtual */ void SetVolume(byte vol) { }
 
	/* virtual */ const char *GetName() const { return "null"; }
 
	void SetVolume(byte vol) override { }
 
	const char *GetName() const override { return "null"; }
 
};
 

	
 
/** Factory for the null music player. */
 
class FMusicDriver_Null : public DriverFactoryBase {
 
public:
 
	FMusicDriver_Null() : DriverFactoryBase(Driver::DT_MUSIC, 1, "null", "Null Music Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_Null(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_Null(); }
 
};
 

	
 
#endif /* MUSIC_NULL_H */
src/music/os2_m.h
Show inline comments
 
@@ -8,34 +8,34 @@
 
 */
 

	
 
/** @file os2_m.h Base for OS2 music playback. */
 

	
 
#ifndef MUSIC_OS2_H
 
#define MUSIC_OS2_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** OS/2's music player. */
 
class MusicDriver_OS2 : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "os2"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "os2"; }
 
};
 

	
 
/** Factory for OS/2's music player. */
 
class FMusicDriver_OS2 : public DriverFactoryBase {
 
public:
 
	FMusicDriver_OS2() : DriverFactoryBase(Driver::DT_MUSIC, 10, "os2", "OS/2 Music Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_OS2(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_OS2(); }
 
};
 

	
 
#endif /* MUSIC_OS2_H */
src/music/qtmidi.h
Show inline comments
 
@@ -7,33 +7,33 @@
 
 * 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 qtmidi.h Base of music playback via the QuickTime driver. */
 

	
 
#ifndef MUSIC_MACOSX_QUICKTIME_H
 
#define MUSIC_MACOSX_QUICKTIME_H
 

	
 
#include "music_driver.hpp"
 

	
 
class MusicDriver_QtMidi : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "qt"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "qt"; }
 
};
 

	
 
class FMusicDriver_QtMidi : public DriverFactoryBase {
 
public:
 
	FMusicDriver_QtMidi() : DriverFactoryBase(Driver::DT_MUSIC, 5, "qt", "QuickTime MIDI Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_QtMidi(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_QtMidi(); }
 
};
 

	
 
#endif /* MUSIC_MACOSX_QUICKTIME_H */
src/music/win32_m.h
Show inline comments
 
@@ -8,34 +8,34 @@
 
 */
 

	
 
/** @file win32_m.h Base for Windows music playback. */
 

	
 
#ifndef MUSIC_WIN32_H
 
#define MUSIC_WIN32_H
 

	
 
#include "music_driver.hpp"
 

	
 
/** The Windows music player. */
 
class MusicDriver_Win32 : public MusicDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void PlaySong(const MusicSongInfo &song);
 
	void PlaySong(const MusicSongInfo &song) override;
 

	
 
	/* virtual */ void StopSong();
 
	void StopSong() override;
 

	
 
	/* virtual */ bool IsSongPlaying();
 
	bool IsSongPlaying() override;
 

	
 
	/* virtual */ void SetVolume(byte vol);
 
	/* virtual */ const char *GetName() const { return "win32"; }
 
	void SetVolume(byte vol) override;
 
	const char *GetName() const override { return "win32"; }
 
};
 

	
 
/** Factory for Windows' music player. */
 
class FMusicDriver_Win32 : public DriverFactoryBase {
 
public:
 
	FMusicDriver_Win32() : DriverFactoryBase(Driver::DT_MUSIC, 5, "win32", "Win32 Music Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new MusicDriver_Win32(); }
 
	Driver *CreateInstance() const override { return new MusicDriver_Win32(); }
 
};
 

	
 
#endif /* MUSIC_WIN32_H */
src/network/network_client.cpp
Show inline comments
 
@@ -75,47 +75,47 @@ struct PacketReader : LoadFilter {
 
		if (to_write == in_packet) return;
 

	
 
		/* Allocate a new chunk and add the remaining data. */
 
		pbuf += to_write;
 
		to_write   = in_packet - to_write;
 
		this->buf  = *this->blocks.Append() = CallocT<byte>(CHUNK);
 
		this->bufe = this->buf + CHUNK;
 

	
 
		memcpy(this->buf, pbuf, to_write);
 
		this->buf += to_write;
 
	}
 

	
 
	/* virtual */ size_t Read(byte *rbuf, size_t size)
 
	size_t Read(byte *rbuf, size_t size) override
 
	{
 
		/* Limit the amount to read to whatever we still have. */
 
		size_t ret_size = size = min(this->written_bytes - this->read_bytes, size);
 
		this->read_bytes += ret_size;
 
		const byte *rbufe = rbuf + ret_size;
 

	
 
		while (rbuf != rbufe) {
 
			if (this->buf == this->bufe) {
 
				this->buf = *this->block++;
 
				this->bufe = this->buf + CHUNK;
 
			}
 

	
 
			size_t to_write = min(this->bufe - this->buf, rbufe - rbuf);
 
			memcpy(rbuf, this->buf, to_write);
 
			rbuf += to_write;
 
			this->buf += to_write;
 
		}
 

	
 
		return ret_size;
 
	}
 

	
 
	/* virtual */ void Reset()
 
	void Reset() override
 
	{
 
		this->read_bytes = 0;
 

	
 
		this->block = this->blocks.Begin();
 
		this->buf   = *this->block++;
 
		this->bufe  = this->buf + CHUNK;
 
	}
 
};
 

	
 

	
 
/**
 
 * Create an emergency savegame when the network connection is lost.
src/network/network_content_gui.cpp
Show inline comments
 
@@ -55,25 +55,25 @@ struct ContentTextfileWindow : public Te
 
			case CONTENT_TYPE_BASE_SOUNDS:   return STR_CONTENT_TYPE_BASE_SOUNDS;
 
			case CONTENT_TYPE_BASE_MUSIC:    return STR_CONTENT_TYPE_BASE_MUSIC;
 
			case CONTENT_TYPE_AI:            return STR_CONTENT_TYPE_AI;
 
			case CONTENT_TYPE_AI_LIBRARY:    return STR_CONTENT_TYPE_AI_LIBRARY;
 
			case CONTENT_TYPE_GAME:          return STR_CONTENT_TYPE_GAME_SCRIPT;
 
			case CONTENT_TYPE_GAME_LIBRARY:  return STR_CONTENT_TYPE_GS_LIBRARY;
 
			case CONTENT_TYPE_SCENARIO:      return STR_CONTENT_TYPE_SCENARIO;
 
			case CONTENT_TYPE_HEIGHTMAP:     return STR_CONTENT_TYPE_HEIGHTMAP;
 
			default: NOT_REACHED();
 
		}
 
	}
 

	
 
	/* virtual */ void SetStringParameters(int widget) const
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, this->GetTypeString());
 
			SetDParamStr(1, this->ci->name);
 
		}
 
	}
 
};
 

	
 
void ShowContentTextfileWindow(TextfileType file_type, const ContentInfo *ci)
 
{
 
	DeleteWindowById(WC_TEXTFILE, file_type);
 
	new ContentTextfileWindow(file_type, ci);
src/network/network_gui.cpp
Show inline comments
 
@@ -108,25 +108,25 @@ public:
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP));
 

	
 
		leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
 
		leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK).width + GetSpriteSize(SPR_BLOT).width + GetSpriteSize(SPR_FLAGS_BASE).width, 12);
 
		leaf->SetFill(0, 1);
 
		this->Add(leaf);
 

	
 
		/* First and last are always visible, the rest is implicitly zeroed */
 
		this->visible[0] = true;
 
		*lastof(this->visible) = true;
 
	}
 

	
 
	void SetupSmallestSize(Window *w, bool init_array)
 
	void SetupSmallestSize(Window *w, bool init_array) override
 
	{
 
		/* Oh yeah, we ought to be findable! */
 
		w->nested_array[WID_NG_HEADER] = this;
 

	
 
		this->smallest_y = 0; // Biggest child.
 
		this->fill_x = 1;
 
		this->fill_y = 0;
 
		this->resize_x = 1; // We only resize in this direction
 
		this->resize_y = 0; // We never resize in this direction
 

	
 
		/* First initialise some variables... */
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
@@ -134,25 +134,25 @@ public:
 
			this->smallest_y = max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
 
		}
 

	
 
		/* ... then in a second pass make sure the 'current' sizes are set. Won't change for most widgets. */
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			child_wid->current_x = child_wid->smallest_x;
 
			child_wid->current_y = this->smallest_y;
 
		}
 

	
 
		this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not
 
	}
 

	
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
 
	{
 
		assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 

	
 
		this->pos_x = x;
 
		this->pos_y = y;
 
		this->current_x = given_width;
 
		this->current_y = given_height;
 

	
 
		given_width -= this->tail->smallest_x;
 
		NWidgetBase *child_wid = this->head->next;
 
		/* The first and last widget are always visible, determine which other should be visible */
 
		for (uint i = 1; i < lengthof(this->visible) - 1; i++) {
 
@@ -174,35 +174,35 @@ public:
 
		child_wid = rtl ? this->tail : this->head;
 
		while (child_wid != NULL) {
 
			if (this->visible[i]) {
 
				child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
 
				position += child_wid->current_x;
 
			}
 

	
 
			child_wid = rtl ? child_wid->prev : child_wid->next;
 
			i += rtl ? -1 : 1;
 
		}
 
	}
 

	
 
	/* virtual */ void Draw(const Window *w)
 
	void Draw(const Window *w) override
 
	{
 
		int i = 0;
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			if (!this->visible[i++]) continue;
 

	
 
			child_wid->Draw(w);
 
		}
 
	}
 

	
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y)
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override
 
	{
 
		if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
 

	
 
		int i = 0;
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			if (!this->visible[i++]) continue;
 
			NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
 
			if (nwid != NULL) return nwid;
 
		}
 
		return NULL;
 
	}
 

	
src/network/network_server.cpp
Show inline comments
 
@@ -154,25 +154,25 @@ struct PacketWriter : SaveFilter {
 
	{
 
		if (this->current == NULL) return;
 

	
 
		Packet **p = &this->packets;
 
		while (*p != NULL) {
 
			p = &(*p)->next;
 
		}
 
		*p = this->current;
 

	
 
		this->current = NULL;
 
	}
 

	
 
	/* virtual */ void Write(byte *buf, size_t size)
 
	void Write(byte *buf, size_t size) override
 
	{
 
		/* We want to abort the saving when the socket is closed. */
 
		if (this->cs == NULL) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
 

	
 
		if (this->current == NULL) this->current = new Packet(PACKET_SERVER_MAP_DATA);
 

	
 
		if (this->mutex != NULL) this->mutex->BeginCritical();
 

	
 
		byte *bufe = buf + size;
 
		while (buf != bufe) {
 
			size_t to_write = min(SEND_MTU - this->current->size, bufe - buf);
 
			memcpy(this->current->buffer + this->current->size, buf, to_write);
 
@@ -181,25 +181,25 @@ struct PacketWriter : SaveFilter {
 

	
 
			if (this->current->size == SEND_MTU) {
 
				this->AppendQueue();
 
				if (buf != bufe) this->current = new Packet(PACKET_SERVER_MAP_DATA);
 
			}
 
		}
 

	
 
		if (this->mutex != NULL) this->mutex->EndCritical();
 

	
 
		this->total_size += size;
 
	}
 

	
 
	/* virtual */ void Finish()
 
	void Finish() override
 
	{
 
		/* We want to abort the saving when the socket is closed. */
 
		if (this->cs == NULL) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
 

	
 
		if (this->mutex != NULL) this->mutex->BeginCritical();
 

	
 
		/* Make sure the last packet is flushed. */
 
		this->AppendQueue();
 

	
 
		/* Add a packet stating that this is the end to the queue. */
 
		this->current = new Packet(PACKET_SERVER_MAP_DONE);
 
		this->AppendQueue();
src/newgrf_airport.cpp
Show inline comments
 
@@ -30,45 +30,45 @@ struct AirportScopeResolver : public Sco
 
	 * Constructor of the scope resolver for an airport.
 
	 * @param ro Surrounding resolver.
 
	 * @param tile %Tile for the callback, only valid for airporttile callbacks.
 
	 * @param st %Station of the airport for which the callback is run, or \c NULL for build gui.
 
	 * @param airport_id Type of airport for which the callback is run.
 
	 * @param layout Layout of the airport to build.
 
	 */
 
	AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout)
 
			: ScopeResolver(ro), st(st), airport_id(airport_id), layout(layout), tile(tile)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	/* virtual */ void StorePSA(uint pos, int32 value);
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
	void StorePSA(uint pos, int32 value) override;
 
};
 

	
 
/** Resolver object for airports. */
 
struct AirportResolverObject : public ResolverObject {
 
	AirportScopeResolver airport_scope;
 

	
 
	AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &this->airport_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
/**
 
 * Reset airport classes to their default state.
 
 * This includes initialising the defaults classes with an empty
 
 * entry, for standard airports.
 
 */
 
template <typename Tspec, typename Tid, Tid Tmax>
 
/* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults()
 
{
 
	AirportClass::Get(AirportClass::Allocate('SMAL'))->name = STR_AIRPORT_CLASS_SMALL;
 
	AirportClass::Get(AirportClass::Allocate('LARG'))->name = STR_AIRPORT_CLASS_LARGE;
src/newgrf_airporttiles.h
Show inline comments
 
@@ -29,36 +29,36 @@ struct AirportTileScopeResolver : public
 
	 * Constructor of the scope resolver specific for airport tiles.
 
	 * @param ats Specification of the airport tiles.
 
	 * @param tile %Tile for the callback, only valid for airporttile callbacks.
 
	 * @param st Station of the airport for which the callback is run, or \c NULL for build gui.
 
	 */
 
	AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
 
		: ScopeResolver(ro), st(st), tile(tile)
 
	{
 
		assert(st != NULL);
 
		this->airport_id = st->airport.type;
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
};
 

	
 
/** Resolver for tiles of an airport. */
 
struct AirportTileResolverObject : public ResolverObject {
 
	AirportTileScopeResolver tiles_scope; ///< Scope resolver for the tiles.
 

	
 
	AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &tiles_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 
};
 

	
 
/**
 
 * Defines the data structure of each individual tile of an airport.
 
 */
 
struct AirportTileSpec {
src/newgrf_canal.cpp
Show inline comments
 
@@ -21,44 +21,44 @@
 
/** Table of canal 'feature' sprite groups */
 
WaterFeature _water_feature[CF_END];
 

	
 
/** Scope resolver of a canal tile. */
 
struct CanalScopeResolver : public ScopeResolver {
 
	TileIndex tile; ///< Tile containing the canal.
 

	
 
	CanalScopeResolver(ResolverObject &ro, TileIndex tile)
 
		: ScopeResolver(ro), tile(tile)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
};
 

	
 
/** Resolver object for canals. */
 
struct CanalResolverObject : public ResolverObject {
 
	CanalScopeResolver canal_scope;
 

	
 
	CanalResolverObject(CanalFeature feature, TileIndex tile,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &this->canal_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
/* virtual */ uint32 CanalScopeResolver::GetRandomBits() const
 
{
 
	/* Return random bits only for water tiles, not station tiles */
 
	return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0;
 
}
 

	
 
/* virtual */ uint32 CanalScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
 
{
 
	switch (variable) {
 
		/* Height of tile */
src/newgrf_cargo.cpp
Show inline comments
 
@@ -10,25 +10,25 @@
 
/** @file newgrf_cargo.cpp Implementation of NewGRF cargoes. */
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "newgrf_spritegroup.h"
 

	
 
#include "safeguards.h"
 

	
 
/** Resolver of cargo. */
 
struct CargoResolverObject : public ResolverObject {
 
	CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
/* virtual */ const SpriteGroup *CargoResolverObject::ResolveReal(const RealSpriteGroup *group) const
 
{
 
	/* Cargo action 2s should always have only 1 "loaded" state, but some
 
	 * times things don't follow the spec... */
 
	if (group->num_loaded > 0) return group->loaded[0];
 
	if (group->num_loading > 0) return group->loading[0];
 

	
 
	return NULL;
 
}
 

	
src/newgrf_config.cpp
Show inline comments
 
@@ -624,25 +624,25 @@ compatible_grf:
 
}
 

	
 
/** Helper for scanning for files with GRF as extension */
 
class GRFFileScanner : FileScanner {
 
	uint next_update; ///< The next (realtime tick) we do update the screen.
 
	uint num_scanned; ///< The number of GRFs we have scanned.
 

	
 
public:
 
	GRFFileScanner() : next_update(_realtime_tick), num_scanned(0)
 
	{
 
	}
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override;
 

	
 
	/** Do the scan for GRFs. */
 
	static uint DoScan()
 
	{
 
		GRFFileScanner fs;
 
		int ret = fs.Scan(".grf", NEWGRF_DIR);
 
		/* The number scanned and the number returned may not be the same;
 
		 * duplicate NewGRFs and base sets are ignored in the return value. */
 
		_settings_client.gui.last_newgrf_count = fs.num_scanned;
 
		return ret;
 
	}
 
};
src/newgrf_engine.h
Show inline comments
 
@@ -31,51 +31,51 @@ struct VehicleScopeResolver : public Sco
 
	 * @param ro Surrounding resolver.
 
	 * @param engine_type Engine type
 
	 * @param v %Vehicle being resolved.
 
	 * @param info_view Indicates if the item is being drawn in an info window.
 
	 */
 
	VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view)
 
		: ScopeResolver(ro), v(v), self_type(engine_type), info_view(info_view)
 
	{
 
	}
 

	
 
	void SetVehicle(const Vehicle *v) { this->v = v; }
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	/* virtual */ uint32 GetTriggers() const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
	uint32 GetTriggers() const override;
 
};
 

	
 
/** Resolver for a vehicle (chain) */
 
struct VehicleResolverObject : public ResolverObject {
 
	/** Application of 'wagon overrides'. */
 
	enum WagonOverride {
 
		WO_NONE,     //!< Resolve no wagon overrides.
 
		WO_UNCACHED, //!< Resolve wagon overrides.
 
		WO_CACHED,   //!< Resolve wagon overrides using TrainCache::cached_override.
 
		WO_SELF,     //!< Resolve self-override (helicopter rotors and such).
 
	};
 

	
 
	VehicleScopeResolver self_scope;     ///< Scope resolver for the indicated vehicle.
 
	VehicleScopeResolver parent_scope;   ///< Scope resolver for its parent vehicle.
 

	
 
	VehicleScopeResolver relative_scope; ///< Scope resolver for an other vehicle in the chain.
 
	byte cached_relative_count;          ///< Relative position of the other vehicle.
 

	
 
	VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool info_view = false,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0);
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override;
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH   = 29;
 
static const uint ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 32;
 
static const uint VEHICLEINFO_FULL_VEHICLE_WIDTH    = 32;
 

	
 
struct VehicleSpriteSeq;
 

	
 
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
 
const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
 
void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
 

	
src/newgrf_generic.cpp
Show inline comments
 
@@ -33,46 +33,46 @@ struct GenericScopeResolver : public Sco
 

	
 
	/**
 
	 * Generic scope resolver.
 
	 * @param ro Surrounding resolver.
 
	 * @param ai_callback Callback comes from the AI.
 
	 */
 
	GenericScopeResolver(ResolverObject &ro, bool ai_callback)
 
		: ScopeResolver(ro), cargo_type(0), default_selection(0), src_industry(0), dst_industry(0), distance(0),
 
		event(), count(0), station_size(0), ai_callback(ai_callback)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 

	
 
private:
 
	bool ai_callback; ///< Callback comes from the AI.
 
};
 

	
 

	
 
/** Resolver object for generic objects/properties. */
 
struct GenericResolverObject : public ResolverObject {
 
	GenericScopeResolver generic_scope;
 

	
 
	GenericResolverObject(bool ai_callback, CallbackID callback = CBID_NO_CALLBACK);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &this->generic_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
struct GenericCallback {
 
	const GRFFile *file;
 
	const SpriteGroup *group;
 

	
 
	GenericCallback(const GRFFile *file, const SpriteGroup *group) :
 
		file(file),
 
		group(group)
 
	{ }
 
};
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -541,25 +541,25 @@ static void OpenGRFParameterWindow(GRFCo
 
}
 

	
 
/** Window for displaying the textfile of a NewGRF. */
 
struct NewGRFTextfileWindow : public TextfileWindow {
 
	const GRFConfig *grf_config; ///< View the textfile of this GRFConfig.
 

	
 
	NewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c) : TextfileWindow(file_type), grf_config(c)
 
	{
 
		const char *textfile = this->grf_config->GetTextfile(file_type);
 
		this->LoadTextfile(textfile, NEWGRF_DIR);
 
	}
 

	
 
	/* virtual */ void SetStringParameters(int widget) const
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, STR_CONTENT_TYPE_NEWGRF);
 
			SetDParamStr(1, this->grf_config->GetName());
 
		}
 
	}
 
};
 

	
 
void ShowNewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c)
 
{
 
	DeleteWindowById(WC_TEXTFILE, file_type);
 
	new NewGRFTextfileWindow(file_type, c);
src/newgrf_house.h
Show inline comments
 
@@ -35,39 +35,39 @@ struct HouseScopeResolver : public Scope
 
	 * @param town %Town containing the house.
 
	 * @param not_yet_constructed House is still under construction.
 
	 * @param initial_random_bits Random bits during construction checks.
 
	 * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
 
	 */
 
	HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
 
			bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers)
 
		: ScopeResolver(ro), house_id(house_id), tile(tile), town(town), not_yet_constructed(not_yet_constructed),
 
		initial_random_bits(initial_random_bits), watched_cargo_triggers(watched_cargo_triggers)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	/* virtual */ uint32 GetTriggers() const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
	uint32 GetTriggers() const override;
 
};
 

	
 
/** Resolver object to be used for houses (feature 07 spritegroups). */
 
struct HouseResolverObject : public ResolverObject {
 
	HouseScopeResolver house_scope;
 
	TownScopeResolver  town_scope;
 

	
 
	HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0,
 
			bool not_yet_constructed = false, uint8 initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF:   return &this->house_scope;
 
			case VSG_SCOPE_PARENT: return &this->town_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 
};
 

	
 
/**
 
 * Makes class IDs unique to each GRF file.
 
 * Houses can be assigned class IDs which are only comparable within the GRF
src/newgrf_industries.h
Show inline comments
 
@@ -25,42 +25,42 @@ struct IndustriesScopeResolver : public 
 
	 * Scope resolver for industries.
 
	 * @param ro Surrounding resolver.
 
	 * @param tile %Tile owned by the industry.
 
	 * @param industry %Industry being resolved.
 
	 * @param type Type of the industry.
 
	 * @param random_bits Random bits of the new industry.
 
	 */
 
	IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0)
 
		: ScopeResolver(ro), tile(tile), industry(industry), type(type), random_bits(random_bits)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	/* virtual */ uint32 GetTriggers() const;
 
	/* virtual */ void StorePSA(uint pos, int32 value);
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
	uint32 GetTriggers() const override;
 
	void StorePSA(uint pos, int32 value) override;
 
};
 

	
 
/** Resolver for industries. */
 
struct IndustriesResolverObject : public ResolverObject {
 
	IndustriesScopeResolver industries_scope; ///< Scope resolver for the industry.
 
	TownScopeResolver *town_scope;            ///< Scope resolver for the associated town (if needed and available, else \c NULL).
 

	
 
	IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits = 0,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 
	~IndustriesResolverObject();
 

	
 
	TownScopeResolver *GetTown();
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &industries_scope;
 
			case VSG_SCOPE_PARENT: {
 
				TownScopeResolver *tsr = this->GetTown();
 
				if (tsr != NULL) return tsr;
 
			}
 
			FALLTHROUGH;
 

	
 
			default:
 
				return ResolverObject::GetScope(scope, relative);
 
		}
src/newgrf_industrytiles.h
Show inline comments
 
@@ -23,38 +23,38 @@ struct IndustryTileScopeResolver : publi
 

	
 
	/**
 
	 * Constructor of the scope resolver for the industry tile.
 
	 * @param ro Surrounding resolver.
 
	 * @param industry %Industry owning the tile.
 
	 * @param tile %Tile of the industry.
 
	 */
 
	IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
 
		: ScopeResolver(ro), industry(industry), tile(tile)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	/* virtual */ uint32 GetTriggers() const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
	uint32 GetTriggers() const override;
 
};
 

	
 
/** Resolver for industry tiles. */
 
struct IndustryTileResolverObject : public ResolverObject {
 
	IndustryTileScopeResolver indtile_scope; ///< Scope resolver for the industry tile.
 
	IndustriesScopeResolver ind_scope;       ///< Scope resolver for the industry owning the tile.
 

	
 
	IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &indtile_scope;
 
			case VSG_SCOPE_PARENT: return &ind_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 
};
 

	
 
bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
 
uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
src/newgrf_object.h
Show inline comments
 
@@ -107,38 +107,38 @@ struct ObjectScopeResolver : public Scop
 
	/**
 
	 * Constructor of an object scope resolver.
 
	 * @param ro Surrounding resolver.
 
	 * @param obj Object being resolved.
 
	 * @param tile %Tile of the object.
 
	 * @param view View of the object.
 
	 */
 
	ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view = 0)
 
		: ScopeResolver(ro), obj(obj), tile(tile), view(view)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
};
 

	
 
/** A resolver object to be used with feature 0F spritegroups. */
 
struct ObjectResolverObject : public ResolverObject {
 
	ObjectScopeResolver object_scope; ///< The object scope resolver.
 
	TownScopeResolver *town_scope;    ///< The town scope resolver (created on the first call).
 

	
 
	ObjectResolverObject(const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view = 0,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0);
 
	~ObjectResolverObject();
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF:
 
				return &this->object_scope;
 

	
 
			case VSG_SCOPE_PARENT: {
 
				TownScopeResolver *tsr = this->GetTown();
 
				if (tsr != NULL) return tsr;
 
				FALLTHROUGH;
 
			}
 

	
 
			default:
src/newgrf_railtype.h
Show inline comments
 
@@ -23,39 +23,39 @@ struct RailTypeScopeResolver : public Sc
 

	
 
	/**
 
	 * Constructor of the railtype scope resolvers.
 
	 * @param ro Surrounding resolver.
 
	 * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
 
	 * @param context Are we resolving sprites for the upper halftile, or on a bridge?
 
	 */
 
	RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context)
 
		: ScopeResolver(ro), tile(tile), context(context)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
};
 

	
 
/** Resolver object for rail types. */
 
struct RailTypeResolverObject : public ResolverObject {
 
	RailTypeScopeResolver railtype_scope; ///< Resolver for the railtype scope.
 

	
 
	RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &this->railtype_scope;
 
			default:             return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = NULL);
 
SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false);
 

	
 
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile);
 

	
 
#endif /* NEWGRF_RAILTYPE_H */
src/newgrf_station.h
Show inline comments
 
@@ -33,59 +33,59 @@ struct StationScopeResolver : public Sco
 
	/**
 
	 * Constructor for station scopes.
 
	 * @param ro Surrounding resolver.
 
	 * @param statspec Station (type) specification.
 
	 * @param st Instance of the station.
 
	 * @param tile %Tile of the station.
 
	 */
 
	StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
 
		: ScopeResolver(ro), tile(tile), st(st), statspec(statspec), cargo_type(CT_INVALID), axis(INVALID_AXIS)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetTriggers() const;
 
	uint32 GetRandomBits() const override;
 
	uint32 GetTriggers() const override;
 

	
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
 
};
 

	
 
/** Station resolver. */
 
struct StationResolverObject : public ResolverObject {
 
	StationScopeResolver station_scope; ///< The station scope resolver.
 
	TownScopeResolver *town_scope;      ///< The town scope resolver (created on the first call).
 

	
 
	StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile,
 
			CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 
	~StationResolverObject();
 

	
 
	TownScopeResolver *GetTown();
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF:
 
				return &this->station_scope;
 

	
 
			case VSG_SCOPE_PARENT: {
 
				TownScopeResolver *tsr = this->GetTown();
 
				if (tsr != NULL) return tsr;
 
				FALLTHROUGH;
 
			}
 

	
 
			default:
 
				return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 

	
 
	/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
 
	const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
 
};
 

	
 
enum StationClassID {
 
	STAT_CLASS_BEGIN = 0,    ///< the lowest valid value
 
	STAT_CLASS_DFLT = 0,     ///< Default station class.
 
	STAT_CLASS_WAYP,         ///< Waypoint class.
 
	STAT_CLASS_MAX = 256,    ///< Maximum number of classes.
 
};
 
typedef SimpleTinyEnumT<StationClassID, byte> StationClassIDByte;
 
template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX, 8> {};
 

	
 
/** Allow incrementing of StationClassID variables */
src/newgrf_town.h
Show inline comments
 
@@ -37,22 +37,22 @@ struct TownScopeResolver : public ScopeR
 
	}
 

	
 
	virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	virtual void StorePSA(uint reg, int32 value);
 
};
 

	
 
/** Resolver of town properties. */
 
struct TownResolverObject : public ResolverObject {
 
	TownScopeResolver town_scope; ///< Scope resolver specific for towns.
 

	
 
	TownResolverObject(const struct GRFFile *grffile, Town *t, bool readonly);
 

	
 
	/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
 
	ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
 
	{
 
		switch (scope) {
 
			case VSG_SCOPE_SELF: return &town_scope;
 
			default: return ResolverObject::GetScope(scope, relative);
 
		}
 
	}
 
};
 

	
 
#endif /* NEWGRF_TOWN_H */
src/os/macosx/crashlog_osx.cpp
Show inline comments
 
@@ -43,56 +43,56 @@
 

	
 
/**
 
 * OSX implementation for the crash logger.
 
 */
 
class CrashLogOSX : public CrashLog {
 
	/** Signal that has been thrown. */
 
	int signum;
 

	
 
	char filename_log[MAX_PATH];        ///< Path of crash.log
 
	char filename_save[MAX_PATH];       ///< Path of crash.sav
 
	char filename_screenshot[MAX_PATH]; ///< Path of crash.(png|bmp|pcx)
 

	
 
	/* virtual */ char *LogOSVersion(char *buffer, const char *last) const
 
	char *LogOSVersion(char *buffer, const char *last) const override
 
	{
 
		int ver_maj, ver_min, ver_bug;
 
		GetMacOSVersion(&ver_maj, &ver_min, &ver_bug);
 

	
 
		const NXArchInfo *arch = NXGetLocalArchInfo();
 

	
 
		return buffer + seprintf(buffer, last,
 
				"Operating system:\n"
 
				" Name:     Mac OS X\n"
 
				" Release:  %d.%d.%d\n"
 
				" Machine:  %s\n"
 
				" Min Ver:  %d\n",
 
				ver_maj, ver_min, ver_bug,
 
				arch != NULL ? arch->description : "unknown",
 
				MAC_OS_X_VERSION_MIN_REQUIRED
 
		);
 
	}
 

	
 
	/* virtual */ char *LogError(char *buffer, const char *last, const char *message) const
 
	char *LogError(char *buffer, const char *last, const char *message) const override
 
	{
 
		return buffer + seprintf(buffer, last,
 
				"Crash reason:\n"
 
				" Signal:  %s (%d)\n"
 
				" Message: %s\n\n",
 
				strsignal(this->signum),
 
				this->signum,
 
				message == NULL ? "<none>" : message
 
		);
 
	}
 

	
 
	/* virtual */ char *LogStacktrace(char *buffer, const char *last) const
 
	char *LogStacktrace(char *buffer, const char *last) const override
 
	{
 
		/* As backtrace() is only implemented in 10.5 or later,
 
		 * we're rolling our own here. Mostly based on
 
		 * http://stackoverflow.com/questions/289820/getting-the-current-stack-trace-on-mac-os-x
 
		 * and some details looked up in the Darwin sources. */
 
		buffer += seprintf(buffer, last, "\nStacktrace:\n");
 

	
 
		void **frame;
 
#if defined(__ppc__) || defined(__ppc64__)
 
		/* Apple says __builtin_frame_address can be broken on PPC. */
 
		__asm__ volatile("mr %0, r1" : "=r" (frame));
 
#else
src/os/unix/crashlog_unix.cpp
Show inline comments
 
@@ -31,45 +31,45 @@
 
#include <unistd.h>
 
#endif
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
 * Unix implementation for the crash logger.
 
 */
 
class CrashLogUnix : public CrashLog {
 
	/** Signal that has been thrown. */
 
	int signum;
 

	
 
	/* virtual */ char *LogOSVersion(char *buffer, const char *last) const
 
	char *LogOSVersion(char *buffer, const char *last) const override
 
	{
 
		struct utsname name;
 
		if (uname(&name) < 0) {
 
			return buffer + seprintf(buffer, last, "Could not get OS version: %s\n", strerror(errno));
 
		}
 

	
 
		return buffer + seprintf(buffer, last,
 
				"Operating system:\n"
 
				" Name:     %s\n"
 
				" Release:  %s\n"
 
				" Version:  %s\n"
 
				" Machine:  %s\n",
 
				name.sysname,
 
				name.release,
 
				name.version,
 
				name.machine
 
		);
 
	}
 

	
 
	/* virtual */ char *LogError(char *buffer, const char *last, const char *message) const
 
	char *LogError(char *buffer, const char *last, const char *message) const override
 
	{
 
		return buffer + seprintf(buffer, last,
 
				"Crash reason:\n"
 
				" Signal:  %s (%d)\n"
 
				" Message: %s\n\n",
 
				strsignal(this->signum),
 
				this->signum,
 
				message == NULL ? "<none>" : message
 
		);
 
	}
 

	
 
#if defined(SUNOS)
 
@@ -96,25 +96,25 @@ class CrashLogUnix : public CrashLog {
 
		if (dladdr((void *)pc, &dli) != 0) {
 
			*wp->bufptr += seprintf(*wp->bufptr, wp->last, " [%02i] %s(%s+0x%x) [0x%x]\n",
 
					wp->counter, dli.dli_fname, dli.dli_sname, (int)((byte *)pc - (byte *)dli.dli_saddr), (uint)pc);
 
		} else {
 
			*wp->bufptr += seprintf(*wp->bufptr, wp->last, " [%02i] [0x%x]\n", wp->counter, (uint)pc);
 
		}
 
		wp->counter++;
 

	
 
		return 0;
 
	}
 
#endif
 

	
 
	/* virtual */ char *LogStacktrace(char *buffer, const char *last) const
 
	char *LogStacktrace(char *buffer, const char *last) const override
 
	{
 
		buffer += seprintf(buffer, last, "Stacktrace:\n");
 
#if defined(__GLIBC__)
 
		void *trace[64];
 
		int trace_size = backtrace(trace, lengthof(trace));
 

	
 
		char **messages = backtrace_symbols(trace, trace_size);
 
		for (int i = 0; i < trace_size; i++) {
 
			buffer += seprintf(buffer, last, " [%02i] %s\n", i, messages[i]);
 
		}
 
		free(messages);
 
#elif defined(SUNOS)
src/os/windows/crashlog_win.cpp
Show inline comments
 
@@ -34,32 +34,32 @@ static const uint MAX_FRAMES     = 64;
 
#define PRINTF_PTR "0x%016IX"
 
#else
 
#define PRINTF_PTR "0x%08X"
 
#endif
 

	
 
/**
 
 * Windows implementation for the crash logger.
 
 */
 
class CrashLogWindows : public CrashLog {
 
	/** Information about the encountered exception */
 
	EXCEPTION_POINTERS *ep;
 

	
 
	/* virtual */ char *LogOSVersion(char *buffer, const char *last) const;
 
	/* virtual */ char *LogError(char *buffer, const char *last, const char *message) const;
 
	/* virtual */ char *LogStacktrace(char *buffer, const char *last) const;
 
	/* virtual */ char *LogRegisters(char *buffer, const char *last) const;
 
	/* virtual */ char *LogModules(char *buffer, const char *last) const;
 
	char *LogOSVersion(char *buffer, const char *last) const override;
 
	char *LogError(char *buffer, const char *last, const char *message) const override;
 
	char *LogStacktrace(char *buffer, const char *last) const override;
 
	char *LogRegisters(char *buffer, const char *last) const override;
 
	char *LogModules(char *buffer, const char *last) const override;
 
public:
 
#if defined(_MSC_VER)
 
	/* virtual */ int WriteCrashDump(char *filename, const char *filename_last) const;
 
	int WriteCrashDump(char *filename, const char *filename_last) const override;
 
	char *AppendDecodedStacktrace(char *buffer, const char *last) const;
 
#else
 
	char *AppendDecodedStacktrace(char *buffer, const char *last) const { return buffer; }
 
#endif /* _MSC_VER */
 

	
 
	/** Buffer for the generated crash log */
 
	char crashlog[65536];
 
	/** Buffer for the filename of the crash log */
 
	char crashlog_filename[MAX_PATH];
 
	/** Buffer for the filename of the crash dump */
 
	char crashdump_filename[MAX_PATH];
 
	/** Buffer for the filename of the crash screenshot */
src/saveload/saveload.cpp
Show inline comments
 
@@ -1835,33 +1835,33 @@ struct FileReader : LoadFilter {
 
	}
 

	
 
	/** Make sure everything is cleaned up. */
 
	~FileReader()
 
	{
 
		if (this->file != NULL) fclose(this->file);
 
		this->file = NULL;
 

	
 
		/* Make sure we don't double free. */
 
		_sl.sf = NULL;
 
	}
 

	
 
	/* virtual */ size_t Read(byte *buf, size_t size)
 
	size_t Read(byte *buf, size_t size) override
 
	{
 
		/* We're in the process of shutting down, i.e. in "failure" mode. */
 
		if (this->file == NULL) return 0;
 

	
 
		return fread(buf, 1, size, this->file);
 
	}
 

	
 
	/* virtual */ void Reset()
 
	void Reset() override
 
	{
 
		clearerr(this->file);
 
		if (fseek(this->file, this->begin, SEEK_SET)) {
 
			DEBUG(sl, 1, "Could not reset the file reading");
 
		}
 
	}
 
};
 

	
 
/** Yes, simply writing to a file. */
 
struct FileWriter : SaveFilter {
 
	FILE *file; ///< The file to write to.
 

	
 
@@ -1873,33 +1873,33 @@ struct FileWriter : SaveFilter {
 
	{
 
	}
 

	
 
	/** Make sure everything is cleaned up. */
 
	~FileWriter()
 
	{
 
		this->Finish();
 

	
 
		/* Make sure we don't double free. */
 
		_sl.sf = NULL;
 
	}
 

	
 
	/* virtual */ void Write(byte *buf, size_t size)
 
	void Write(byte *buf, size_t size) override
 
	{
 
		/* We're in the process of shutting down, i.e. in "failure" mode. */
 
		if (this->file == NULL) return;
 

	
 
		if (fwrite(buf, 1, size, this->file) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE);
 
	}
 

	
 
	/* virtual */ void Finish()
 
	void Finish() override
 
	{
 
		if (this->file != NULL) fclose(this->file);
 
		this->file = NULL;
 
	}
 
};
 

	
 
/*******************************************
 
 ********** START OF LZO CODE **************
 
 *******************************************/
 

	
 
#ifdef WITH_LZO
 
#include <lzo/lzo1x.h>
 
@@ -1909,25 +1909,25 @@ static const uint LZO_BUFFER_SIZE = 8192
 

	
 
/** Filter using LZO compression. */
 
struct LZOLoadFilter : LoadFilter {
 
	/**
 
	 * Initialise this filter.
 
	 * @param chain The next filter in this chain.
 
	 */
 
	LZOLoadFilter(LoadFilter *chain) : LoadFilter(chain)
 
	{
 
		if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize decompressor");
 
	}
 

	
 
	/* virtual */ size_t Read(byte *buf, size_t ssize)
 
	size_t Read(byte *buf, size_t ssize) override
 
	{
 
		assert(ssize >= LZO_BUFFER_SIZE);
 

	
 
		/* Buffer size is from the LZO docs plus the chunk header size. */
 
		byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2];
 
		uint32 tmp[2];
 
		uint32 size;
 
		lzo_uint len = ssize;
 

	
 
		/* Read header*/
 
		if (this->chain->Read((byte*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed");
 

	
 
@@ -1957,25 +1957,25 @@ struct LZOLoadFilter : LoadFilter {
 
/** Filter using LZO compression. */
 
struct LZOSaveFilter : SaveFilter {
 
	/**
 
	 * Initialise this filter.
 
	 * @param chain             The next filter in this chain.
 
	 * @param compression_level The requested level of compression.
 
	 */
 
	LZOSaveFilter(SaveFilter *chain, byte compression_level) : SaveFilter(chain)
 
	{
 
		if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
 
	}
 

	
 
	/* virtual */ void Write(byte *buf, size_t size)
 
	void Write(byte *buf, size_t size) override
 
	{
 
		const lzo_bytep in = buf;
 
		/* Buffer size is from the LZO docs plus the chunk header size. */
 
		byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2];
 
		byte wrkmem[LZO1X_1_MEM_COMPRESS];
 
		lzo_uint outlen;
 

	
 
		do {
 
			/* Compress up to LZO_BUFFER_SIZE bytes at once. */
 
			lzo_uint len = size > LZO_BUFFER_SIZE ? LZO_BUFFER_SIZE : (lzo_uint)size;
 
			lzo1x_1_compress(in, len, out + sizeof(uint32) * 2, &outlen, wrkmem);
 
			((uint32*)out)[1] = TO_BE32((uint32)outlen);
 
@@ -1996,42 +1996,42 @@ struct LZOSaveFilter : SaveFilter {
 
 *********************************************/
 

	
 
/** Filter without any compression. */
 
struct NoCompLoadFilter : LoadFilter {
 
	/**
 
	 * Initialise this filter.
 
	 * @param chain The next filter in this chain.
 
	 */
 
	NoCompLoadFilter(LoadFilter *chain) : LoadFilter(chain)
 
	{
 
	}
 

	
 
	/* virtual */ size_t Read(byte *buf, size_t size)
 
	size_t Read(byte *buf, size_t size) override
 
	{
 
		return this->chain->Read(buf, size);
 
	}
 
};
 

	
 
/** Filter without any compression. */
 
struct NoCompSaveFilter : SaveFilter {
 
	/**
 
	 * Initialise this filter.
 
	 * @param chain             The next filter in this chain.
 
	 * @param compression_level The requested level of compression.
 
	 */
 
	NoCompSaveFilter(SaveFilter *chain, byte compression_level) : SaveFilter(chain)
 
	{
 
	}
 

	
 
	/* virtual */ void Write(byte *buf, size_t size)
 
	void Write(byte *buf, size_t size) override
 
	{
 
		this->chain->Write(buf, size);
 
	}
 
};
 

	
 
/********************************************
 
 ********** START OF ZLIB CODE **************
 
 ********************************************/
 

	
 
#if defined(WITH_ZLIB)
 
#include <zlib.h>
 

	
 
@@ -2047,25 +2047,25 @@ struct ZlibLoadFilter : LoadFilter {
 
	ZlibLoadFilter(LoadFilter *chain) : LoadFilter(chain)
 
	{
 
		memset(&this->z, 0, sizeof(this->z));
 
		if (inflateInit(&this->z) != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize decompressor");
 
	}
 

	
 
	/** Clean everything up. */
 
	~ZlibLoadFilter()
 
	{
 
		inflateEnd(&this->z);
 
	}
 

	
 
	/* virtual */ size_t Read(byte *buf, size_t size)
 
	size_t Read(byte *buf, size_t size) override
 
	{
 
		this->z.next_out  = buf;
 
		this->z.avail_out = (uint)size;
 

	
 
		do {
 
			/* read more bytes from the file? */
 
			if (this->z.avail_in == 0) {
 
				this->z.next_in = this->fread_buf;
 
				this->z.avail_in = (uint)this->chain->Read(this->fread_buf, sizeof(this->fread_buf));
 
			}
 

	
 
			/* inflate the data */
 
@@ -2126,30 +2126,30 @@ struct ZlibSaveFilter : SaveFilter {
 
			int r = deflate(&this->z, mode);
 

	
 
			/* bytes were emitted? */
 
			if ((n = sizeof(buf) - this->z.avail_out) != 0) {
 
				this->chain->Write(buf, n);
 
			}
 
			if (r == Z_STREAM_END) break;
 

	
 
			if (r != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "zlib returned error code");
 
		} while (this->z.avail_in || !this->z.avail_out);
 
	}
 

	
 
	/* virtual */ void Write(byte *buf, size_t size)
 
	void Write(byte *buf, size_t size) override
 
	{
 
		this->WriteLoop(buf, size, 0);
 
	}
 

	
 
	/* virtual */ void Finish()
 
	void Finish() override
 
	{
 
		this->WriteLoop(NULL, 0, Z_FINISH);
 
		this->chain->Finish();
 
	}
 
};
 

	
 
#endif /* WITH_ZLIB */
 

	
 
/********************************************
 
 ********** START OF LZMA CODE **************
 
 ********************************************/
 

	
 
@@ -2176,25 +2176,25 @@ struct LZMALoadFilter : LoadFilter {
 
	LZMALoadFilter(LoadFilter *chain) : LoadFilter(chain), lzma(_lzma_init)
 
	{
 
		/* Allow saves up to 256 MB uncompressed */
 
		if (lzma_auto_decoder(&this->lzma, 1 << 28, 0) != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize decompressor");
 
	}
 

	
 
	/** Clean everything up. */
 
	~LZMALoadFilter()
 
	{
 
		lzma_end(&this->lzma);
 
	}
 

	
 
	/* virtual */ size_t Read(byte *buf, size_t size)
 
	size_t Read(byte *buf, size_t size) override
 
	{
 
		this->lzma.next_out  = buf;
 
		this->lzma.avail_out = size;
 

	
 
		do {
 
			/* read more bytes from the file? */
 
			if (this->lzma.avail_in == 0) {
 
				this->lzma.next_in  = this->fread_buf;
 
				this->lzma.avail_in = this->chain->Read(this->fread_buf, sizeof(this->fread_buf));
 
			}
 

	
 
			/* inflate the data */
 
@@ -2245,30 +2245,30 @@ struct LZMASaveFilter : SaveFilter {
 

	
 
			lzma_ret r = lzma_code(&this->lzma, action);
 

	
 
			/* bytes were emitted? */
 
			if ((n = sizeof(buf) - this->lzma.avail_out) != 0) {
 
				this->chain->Write(buf, n);
 
			}
 
			if (r == LZMA_STREAM_END) break;
 
			if (r != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "liblzma returned error code");
 
		} while (this->lzma.avail_in || !this->lzma.avail_out);
 
	}
 

	
 
	/* virtual */ void Write(byte *buf, size_t size)
 
	void Write(byte *buf, size_t size) override
 
	{
 
		this->WriteLoop(buf, size, LZMA_RUN);
 
	}
 

	
 
	/* virtual */ void Finish()
 
	void Finish() override
 
	{
 
		this->WriteLoop(NULL, 0, LZMA_FINISH);
 
		this->chain->Finish();
 
	}
 
};
 

	
 
#endif /* WITH_LIBLZMA */
 

	
 
/*******************************************
 
 ************* END OF CODE *****************
 
 *******************************************/
 

	
src/script/api/script_text.hpp
Show inline comments
 
@@ -36,25 +36,25 @@ public:
 
	const char *GetDecodedText();
 
};
 

	
 
/**
 
 * Internally used class to create a raw text in a Text object.
 
 * @api -all
 
 */
 
class RawText : public Text {
 
public:
 
	RawText(const char *text);
 
	~RawText();
 

	
 
	/* virtual */ const char *GetEncodedText() { return this->text; }
 
	const char *GetEncodedText() override { return this->text; }
 
private:
 
	const char *text;
 
};
 

	
 
/**
 
 * Class that handles all text related functions. You can define a language
 
 *  file in lang/english.txt, in the same format as OpenTTD does, including
 
 *  tags like {BLACK}, {STRING1} etc. The name given to this string is made
 
 *  available to you in ScriptText, for example: ScriptText.STR_NEWS, if your
 
 *  english.txt contains: STR_NEWS    :{BLACK}Welcome {COMPANY}!
 
 *
 
 * In translation files like lang/dutch.txt you can then translate such
src/script/script_scanner.hpp
Show inline comments
 
@@ -68,25 +68,25 @@ public:
 
	 * @return True iff we have a script matching.
 
	 */
 
	bool HasScript(const struct ContentInfo *ci, bool md5sum);
 

	
 
	/**
 
	 * Find a script of a #ContentInfo
 
	 * @param ci The information to compare to.
 
	 * @param md5sum Whether to check the MD5 checksum.
 
	 * @return A filename of a file of the content, else \c NULL.
 
	 */
 
	const char *FindMainScript(const ContentInfo *ci, bool md5sum);
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override;
 

	
 
	/**
 
	 * Rescan the script dir.
 
	 */
 
	void RescanDir();
 

	
 
protected:
 
	class Squirrel *engine; ///< The engine we're scanning with.
 
	char *main_script;      ///< The full path of the script.
 
	char *tar_file;         ///< If, which tar file the script was in.
 

	
 
	ScriptInfoList info_list;        ///< The list of all script.
src/settings_gui.cpp
Show inline comments
 
@@ -143,25 +143,25 @@ DropDownList *BuildMusicSetDropDownList(
 
/** Window for displaying the textfile of a BaseSet. */
 
template <class TBaseSet>
 
struct BaseSetTextfileWindow : public TextfileWindow {
 
	const TBaseSet* baseset; ///< View the textfile of this BaseSet.
 
	StringID content_type;   ///< STR_CONTENT_TYPE_xxx for title.
 

	
 
	BaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type) : TextfileWindow(file_type), baseset(baseset), content_type(content_type)
 
	{
 
		const char *textfile = this->baseset->GetTextfile(file_type);
 
		this->LoadTextfile(textfile, BASESET_DIR);
 
	}
 

	
 
	/* virtual */ void SetStringParameters(int widget) const
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget == WID_TF_CAPTION) {
 
			SetDParam(0, content_type);
 
			SetDParamStr(1, this->baseset->name);
 
		}
 
	}
 
};
 

	
 
/**
 
 * Open the BaseSet version of the textfile window.
 
 * @param file_type The type of textfile to display.
 
 * @param baseset The BaseSet to use.
src/sound/allegro_s.h
Show inline comments
 
@@ -8,28 +8,28 @@
 
 */
 

	
 
/** @file allegro_s.h Base fo playing sound via Allegro. */
 

	
 
#ifndef SOUND_ALLEGRO_H
 
#define SOUND_ALLEGRO_H
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the allegro sound driver. */
 
class SoundDriver_Allegro : public SoundDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param);
 

	
 
	/* virtual */ void Stop();
 
	void Stop();
 

	
 
	/* virtual */ void MainLoop();
 
	/* virtual */ const char *GetName() const { return "allegro"; }
 
	void MainLoop();
 
	const char *GetName() const { return "allegro"; }
 
};
 

	
 
/** Factory for the allegro sound driver. */
 
class FSoundDriver_Allegro : public DriverFactoryBase {
 
public:
 
	FSoundDriver_Allegro() : DriverFactoryBase(Driver::DT_SOUND, 4, "allegro", "Allegro Sound Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Allegro(); }
 
};
 

	
 
#endif /* SOUND_ALLEGRO_H */
src/sound/cocoa_s.h
Show inline comments
 
@@ -7,25 +7,25 @@
 
 * 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 cocoa_s.h Base for Cocoa sound handling. */
 

	
 
#ifndef SOUND_COCOA_H
 
#define SOUND_COCOA_H
 

	
 
#include "sound_driver.hpp"
 

	
 
class SoundDriver_Cocoa : public SoundDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	/* virtual */ const char *GetName() const { return "cocoa"; }
 
	void Stop() override;
 
	const char *GetName() const override { return "cocoa"; }
 
};
 

	
 
class FSoundDriver_Cocoa : public DriverFactoryBase {
 
public:
 
	FSoundDriver_Cocoa() : DriverFactoryBase(Driver::DT_SOUND, 10, "cocoa", "Cocoa Sound Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Cocoa(); }
 
	Driver *CreateInstance() const override { return new SoundDriver_Cocoa(); }
 
};
 

	
 
#endif /* SOUND_COCOA_H */
src/sound/null_s.h
Show inline comments
 
@@ -8,26 +8,26 @@
 
 */
 

	
 
/** @file null_s.h Base for the sound of silence. */
 

	
 
#ifndef SOUND_NULL_H
 
#define SOUND_NULL_H
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the null sound driver. */
 
class SoundDriver_Null : public SoundDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param) { return NULL; }
 
	const char *Start(const char * const *param) override { return NULL; }
 

	
 
	/* virtual */ void Stop() { }
 
	/* virtual */ const char *GetName() const { return "null"; }
 
	void Stop() override { }
 
	const char *GetName() const override { return "null"; }
 
};
 

	
 
/** Factory for the null sound driver. */
 
class FSoundDriver_Null : public DriverFactoryBase {
 
public:
 
	FSoundDriver_Null() : DriverFactoryBase(Driver::DT_SOUND, 1, "null", "Null Sound Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Null(); }
 
	Driver *CreateInstance() const override { return new SoundDriver_Null(); }
 
};
 

	
 
#endif /* SOUND_NULL_H */
src/sound/sdl_s.h
Show inline comments
 
@@ -8,26 +8,26 @@
 
 */
 

	
 
/** @file sdl_s.h Base fo playing sound via SDL. */
 

	
 
#ifndef SOUND_SDL_H
 
#define SOUND_SDL_H
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the SDL sound driver. */
 
class SoundDriver_SDL : public SoundDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	/* virtual */ const char *GetName() const { return "sdl"; }
 
	void Stop() override;
 
	const char *GetName() const override { return "sdl"; }
 
};
 

	
 
/** Factory for the SDL sound driver. */
 
class FSoundDriver_SDL : public DriverFactoryBase {
 
public:
 
	FSoundDriver_SDL() : DriverFactoryBase(Driver::DT_SOUND, 5, "sdl", "SDL Sound Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new SoundDriver_SDL(); }
 
	Driver *CreateInstance() const override { return new SoundDriver_SDL(); }
 
};
 

	
 
#endif /* SOUND_SDL_H */
src/sound/win32_s.h
Show inline comments
 
@@ -8,26 +8,26 @@
 
 */
 

	
 
/** @file win32_s.h Base for Windows sound handling. */
 

	
 
#ifndef SOUND_WIN32_H
 
#define SOUND_WIN32_H
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the sound driver for Windows. */
 
class SoundDriver_Win32 : public SoundDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	/* virtual */ const char *GetName() const { return "win32"; }
 
	void Stop() override;
 
	const char *GetName() const override { return "win32"; }
 
};
 

	
 
/** Factory for the sound driver for Windows. */
 
class FSoundDriver_Win32 : public DriverFactoryBase {
 
public:
 
	FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 9, "win32", "Win32 WaveOut Sound Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Win32(); }
 
	Driver *CreateInstance() const override { return new SoundDriver_Win32(); }
 
};
 

	
 
#endif /* SOUND_WIN32_H */
src/sound/xaudio2_s.h
Show inline comments
 
@@ -8,26 +8,26 @@
 
 */
 

	
 
/** @file xaudio2_s.h Base for XAudio2 sound handling. */
 

	
 
#ifndef SOUND_XAUDIO2_H
 
#define SOUND_XAUDIO2_H
 

	
 
#include "sound_driver.hpp"
 

	
 
/** Implementation of the XAudio2 sound driver. */
 
class SoundDriver_XAudio2 : public SoundDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	/* virtual */ const char *GetName() const { return "xaudio2"; }
 
	void Stop() override;
 
	const char *GetName() const override { return "xaudio2"; }
 
};
 

	
 
/** Factory for the XAudio2 sound driver. */
 
class FSoundDriver_XAudio2 : public DriverFactoryBase {
 
public:
 
	FSoundDriver_XAudio2() : DriverFactoryBase(Driver::DT_SOUND, 10, "xaudio2", "XAudio2 Sound Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new SoundDriver_XAudio2(); }
 
	Driver *CreateInstance() const override { return new SoundDriver_XAudio2(); }
 
};
 

	
 
#endif /* SOUND_XAUDIO2_H */
src/station_base.h
Show inline comments
 
@@ -481,56 +481,56 @@ public:
 
	CargoTypes always_accepted;       ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo)
 

	
 
	IndustryList industries_near; ///< Cached list of industries near the station that can accept cargo, @see DeliverGoodsToIndustry()
 
	Industry *industry;           ///< NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st)
 

	
 
	Station(TileIndex tile = INVALID_TILE);
 
	~Station();
 

	
 
	void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
 

	
 
	void MarkTilesDirty(bool cargo_change) const;
 

	
 
	void UpdateVirtCoord();
 
	void UpdateVirtCoord() override;
 

	
 
	void AfterStationTileSetChange(bool adding, StationType type);
 

	
 
	/* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
 
	/* virtual */ uint GetPlatformLength(TileIndex tile) const;
 
	uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override;
 
	uint GetPlatformLength(TileIndex tile) const override;
 
	void RecomputeCatchment();
 
	static void RecomputeCatchmentForAll();
 

	
 
	uint GetCatchmentRadius() const;
 
	Rect GetCatchmentRect() const;
 
	bool CatchmentCoversTown(TownID t) const;
 
	void RemoveFromAllNearbyLists();
 

	
 
	inline bool TileIsInCatchment(TileIndex tile) const
 
	{
 
		return this->catchment_tiles.HasTile(tile);
 
	}
 

	
 
	/* virtual */ inline bool TileBelongsToRailStation(TileIndex tile) const
 
	inline bool TileBelongsToRailStation(TileIndex tile) const override
 
	{
 
		return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
 
	}
 

	
 
	inline bool TileBelongsToAirport(TileIndex tile) const
 
	{
 
		return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
 
	}
 

	
 
	/* virtual */ uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const;
 
	uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override;
 

	
 
	/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
 
	void GetTileArea(TileArea *ta, StationType type) const override;
 
};
 

	
 
#define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var)
 

	
 
/** Iterator to iterate over all tiles belonging to an airport. */
 
class AirportTileIterator : public OrthogonalTileIterator {
 
private:
 
	const Station *st; ///< The station the airport is a part of.
 

	
 
public:
 
	/**
 
	 * Construct the iterator.
src/strgen/strgen.cpp
Show inline comments
 
@@ -106,32 +106,32 @@ struct FileStringReader : StringReader {
 
			StringReader(data, file, master, translation)
 
	{
 
		this->fh = fopen(file, "rb");
 
		if (this->fh == NULL) error("Could not open %s", file);
 
	}
 

	
 
	/** Free/close the file. */
 
	virtual ~FileStringReader()
 
	{
 
		fclose(this->fh);
 
	}
 

	
 
	/* virtual */ char *ReadLine(char *buffer, const char *last)
 
	char *ReadLine(char *buffer, const char *last) override
 
	{
 
		return fgets(buffer, ClampToU16(last - buffer + 1), this->fh);
 
	}
 

	
 
	/* virtual */ void HandlePragma(char *str);
 
	void HandlePragma(char *str) override;
 

	
 
	/* virtual */ void ParseFile()
 
	void ParseFile() override
 
	{
 
		this->StringReader::ParseFile();
 

	
 
		if (StrEmpty(_lang.name) || StrEmpty(_lang.own_name) || StrEmpty(_lang.isocode)) {
 
			error("Language must include ##name, ##ownname and ##isocode");
 
		}
 
	}
 
};
 

	
 
void FileStringReader::HandlePragma(char *str)
 
{
 
	if (!memcmp(str, "id ", 3)) {
src/strings.cpp
Show inline comments
 
@@ -2023,56 +2023,56 @@ bool MissingGlyphSearcher::FindMissingGl
 
				return true;
 
			}
 
		}
 
	}
 
	return false;
 
}
 

	
 
/** Helper for searching through the language pack. */
 
class LanguagePackGlyphSearcher : public MissingGlyphSearcher {
 
	uint i; ///< Iterator for the primary language tables.
 
	uint j; ///< Iterator for the secondary language tables.
 

	
 
	/* virtual */ void Reset()
 
	void Reset() override
 
	{
 
		this->i = 0;
 
		this->j = 0;
 
	}
 

	
 
	/* virtual */ FontSize DefaultSize()
 
	FontSize DefaultSize() override
 
	{
 
		return FS_NORMAL;
 
	}
 

	
 
	/* virtual */ const char *NextString()
 
	const char *NextString() override
 
	{
 
		if (this->i >= TEXT_TAB_END) return NULL;
 

	
 
		const char *ret = _langpack_offs[_langtab_start[this->i] + this->j];
 

	
 
		this->j++;
 
		while (this->i < TEXT_TAB_END && this->j >= _langtab_num[this->i]) {
 
			this->i++;
 
			this->j = 0;
 
		}
 

	
 
		return ret;
 
	}
 

	
 
	/* virtual */ bool Monospace()
 
	bool Monospace() override
 
	{
 
		return false;
 
	}
 

	
 
	/* virtual */ void SetFontNames(FreeTypeSettings *settings, const char *font_name)
 
	void SetFontNames(FreeTypeSettings *settings, const char *font_name) override
 
	{
 
#ifdef WITH_FREETYPE
 
		strecpy(settings->small.font,  font_name, lastof(settings->small.font));
 
		strecpy(settings->medium.font, font_name, lastof(settings->medium.font));
 
		strecpy(settings->large.font,  font_name, lastof(settings->large.font));
 
#endif /* WITH_FREETYPE */
 
	}
 
};
 

	
 
/**
 
 * Check whether the currently loaded language pack
 
 * uses characters that the currently loaded font
src/table/newgrf_debug_data.h
Show inline comments
 
@@ -60,32 +60,32 @@ static const NIVariable _niv_vehicles[] 
 
	NIV(0x49, "year of construction"),
 
	NIV(0x4A, "current rail type info"),
 
	NIV(0x4B, "long date of last service"),
 
	NIV(0x4C, "current max speed"),
 
	NIV(0x4D, "position in articulated vehicle"),
 
	NIV(0x60, "count vehicle id occurrences"),
 
	// 0x61 not useful, since it requires register 0x10F
 
	NIV(0x62, "Curvature/position difference to other vehicle"),
 
	NIV_END()
 
};
 

	
 
class NIHVehicle : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return Vehicle::Get(index)->GetGRF() != NULL; }
 
	uint GetParent(uint index) const                     { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); }
 
	const void *GetInstance(uint index)const             { return Vehicle::Get(index); }
 
	const void *GetSpec(uint index) const                { return Vehicle::Get(index)->GetEngine(); }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return Vehicle::Get(index)->GetGRFID(); }
 
	bool IsInspectable(uint index) const override        { return Vehicle::Get(index)->GetGRF() != NULL; }
 
	uint GetParent(uint index) const override            { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); }
 
	const void *GetInstance(uint index)const override    { return Vehicle::Get(index); }
 
	const void *GetSpec(uint index) const override       { return Vehicle::Get(index)->GetEngine(); }
 
	void SetStringParameters(uint index) const override  { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); }
 
	uint32 GetGRFID(uint index) const override                   { return Vehicle::Get(index)->GetGRFID(); }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		Vehicle *v = Vehicle::Get(index);
 
		VehicleResolverObject ro(v->engine_type, v, VehicleResolverObject::WO_CACHED);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_vehicle = {
 
	NULL,
 
	_nic_vehicles,
 
	_niv_vehicles,
 
	new NIHVehicle(),
 
@@ -123,32 +123,32 @@ static const NIVariable _niv_stations[] 
 
	NIV(0x62, "rating of cargo"),
 
	NIV(0x63, "time spent on route"),
 
	NIV(0x64, "information about last vehicle picking cargo up"),
 
	NIV(0x65, "amount of cargo acceptance"),
 
	NIV(0x66, "animation frame of nearby tile"),
 
	NIV(0x67, "land info of nearby tiles"),
 
	NIV(0x68, "station info of nearby tiles"),
 
	NIV(0x69, "information about cargo accepted in the past"),
 
	NIV_END()
 
};
 

	
 
class NIHStation : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return GetStationSpec(index) != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return GetStationSpec(index); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return GetStationSpec(index) != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return GetStationSpec(index); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		StationResolverObject ro(GetStationSpec(index), Station::GetByTile(index), index);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_station = {
 
	NULL,
 
	_nic_stations,
 
	_niv_stations,
 
	new NIHStation(),
 
};
 
@@ -188,32 +188,32 @@ static const NIVariable _niv_house[] = {
 
	NIV(0x60, "other building counts (old house type)"),
 
	NIV(0x61, "other building counts (new house type)"),
 
	NIV(0x62, "land info of nearby tiles"),
 
	NIV(0x63, "current animation frame of nearby house tile"),
 
	NIV(0x64, "cargo acceptance history of nearby stations"),
 
	NIV(0x65, "distance of nearest house matching a given criterion"),
 
	NIV(0x66, "class and ID of nearby house tile"),
 
	NIV(0x67, "GRFID of nearby house tile"),
 
	NIV_END()
 
};
 

	
 
class NIHHouse : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return HouseSpec::Get(GetHouseType(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return HouseSpec::Get(GetHouseType(index)); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		HouseResolverObject ro(GetHouseType(index), index, Town::GetByTile(index));
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_house = {
 
	NULL,
 
	_nic_house,
 
	_niv_house,
 
	new NIHHouse(),
 
};
 
@@ -238,32 +238,32 @@ static const NIVariable _niv_industrytil
 
	NIV(0x40, "construction state of tile"),
 
	NIV(0x41, "ground type"),
 
	NIV(0x42, "current town zone in nearest town"),
 
	NIV(0x43, "relative position"),
 
	NIV(0x44, "animation frame"),
 
	NIV(0x60, "land info of nearby tiles"),
 
	NIV(0x61, "animation stage of nearby tiles"),
 
	NIV(0x62, "get industry or airport tile ID at offset"),
 
	NIV_END()
 
};
 

	
 
class NIHIndustryTile : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return GetIndustryTileSpec(GetIndustryGfx(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return GetIndustryTileSpec(GetIndustryGfx(index)); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		IndustryTileResolverObject ro(GetIndustryGfx(index), index, Industry::GetByTile(index));
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_industrytile = {
 
	NULL,
 
	_nic_industrytiles,
 
	_niv_industrytiles,
 
	new NIHIndustryTile(),
 
};
 
@@ -337,41 +337,41 @@ static const NIVariable _niv_industries[
 
	NIV(0x61, "get random tile bits at offset"),
 
	NIV(0x62, "land info of nearby tiles"),
 
	NIV(0x63, "animation stage of nearby tiles"),
 
	NIV(0x64, "distance on nearest industry with given type"),
 
	NIV(0x65, "get town zone and Manhattan distance of closest town"),
 
	NIV(0x66, "get square of Euclidean distance of closes town"),
 
	NIV(0x67, "count of industry and distance of closest instance"),
 
	NIV(0x68, "count of industry and distance of closest instance with layout filter"),
 
	NIV_END()
 
};
 

	
 
class NIHIndustry : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return Industry::Get(index); }
 
	const void *GetSpec(uint index) const                { return GetIndustrySpec(Industry::Get(index)->type); }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return Industry::Get(index); }
 
	const void *GetSpec(uint index) const override       { return GetIndustrySpec(Industry::Get(index)->type); }
 
	void SetStringParameters(uint index) const override  { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		Industry *i = Industry::Get(index);
 
		IndustriesResolverObject ro(i->location.tile, i, i->type);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 

	
 
	uint GetPSASize(uint index, uint32 grfid) const      { return cpp_lengthof(PersistentStorage, storage); }
 
	uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); }
 

	
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override
 
	{
 
		const Industry *i = (const Industry *)this->GetInstance(index);
 
		if (i->psa == NULL) return NULL;
 
		return (int32 *)(&i->psa->storage);
 
	}
 
};
 

	
 
static const NIFeature _nif_industry = {
 
	_nip_industries,
 
	_nic_industries,
 
	_niv_industries,
 
	new NIHIndustry(),
 
@@ -402,32 +402,32 @@ static const NIVariable _niv_objects[] =
 
	NIV(0x46, "get square of Euclidean distance of closes town"),
 
	NIV(0x47, "colour"),
 
	NIV(0x48, "view"),
 
	NIV(0x60, "get object ID at offset"),
 
	NIV(0x61, "get random tile bits at offset"),
 
	NIV(0x62, "land info of nearby tiles"),
 
	NIV(0x63, "animation stage of nearby tiles"),
 
	NIV(0x64, "distance on nearest object with given type"),
 
	NIV_END()
 
};
 

	
 
class NIHObject : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return ObjectSpec::GetByTile(index)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return Object::GetByTile(index); }
 
	const void *GetSpec(uint index) const                { return ObjectSpec::GetByTile(index); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return ObjectSpec::GetByTile(index)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return Object::GetByTile(index); }
 
	const void *GetSpec(uint index) const override       { return ObjectSpec::GetByTile(index); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		ObjectResolverObject ro(ObjectSpec::GetByTile(index), Object::GetByTile(index), index);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_object = {
 
	NULL,
 
	_nic_objects,
 
	_niv_objects,
 
	new NIHObject(),
 
};
 
@@ -436,32 +436,32 @@ static const NIFeature _nif_object = {
 
/*** NewGRF rail types ***/
 

	
 
static const NIVariable _niv_railtypes[] = {
 
	NIV(0x40, "terrain type"),
 
	NIV(0x41, "enhanced tunnels"),
 
	NIV(0x42, "level crossing status"),
 
	NIV(0x43, "construction date"),
 
	NIV(0x44, "town zone"),
 
	NIV_END()
 
};
 

	
 
class NIHRailType : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return true; }
 
	uint GetParent(uint index) const                     { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return NULL; }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const                    { return 0; }
 
	bool IsInspectable(uint index) const override        { return true; }
 
	uint GetParent(uint index) const override            { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return NULL; }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const override           { return 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		/* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype.
 
		 * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */
 
		RailTypeResolverObject ro(NULL, index, TCX_NORMAL, RTSG_END);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_railtype = {
 
	NULL,
 
	NULL,
 
	_niv_railtypes,
 
@@ -472,32 +472,32 @@ static const NIFeature _nif_railtype = {
 
/*** NewGRF airport tiles ***/
 

	
 
#define NICAT(cb_id, bit) NIC(cb_id, AirportTileSpec, callback_mask, bit)
 
static const NICallback _nic_airporttiles[] = {
 
	NICAT(CBID_AIRPTILE_DRAW_FOUNDATIONS, CBM_AIRT_DRAW_FOUNDATIONS),
 
	NICAT(CBID_AIRPTILE_ANIM_START_STOP,  CBM_NO_BIT),
 
	NICAT(CBID_AIRPTILE_ANIM_NEXT_FRAME,  CBM_AIRT_ANIM_NEXT_FRAME),
 
	NICAT(CBID_AIRPTILE_ANIMATION_SPEED,  CBM_AIRT_ANIM_SPEED),
 
	NIC_END()
 
};
 

	
 
class NIHAirportTile : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return AirportTileSpec::Get(GetAirportGfx(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return AirportTileSpec::Get(GetAirportGfx(index)); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		AirportTileResolverObject ro(AirportTileSpec::GetByTile(index), index, Station::GetByTile(index));
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
static const NIFeature _nif_airporttile = {
 
	NULL,
 
	_nic_airporttiles,
 
	_niv_industrytiles, // Yes, they share this (at least now)
 
	new NIHAirportTile(),
 
};
 
@@ -510,40 +510,40 @@ static const NIVariable _niv_towns[] = {
 
	NIV(0x41, "town index"),
 
	NIV(0x82, "population"),
 
	NIV(0x94, "zone radius 0"),
 
	NIV(0x96, "zone radius 1"),
 
	NIV(0x98, "zone radius 2"),
 
	NIV(0x9A, "zone radius 3"),
 
	NIV(0x9C, "zone radius 4"),
 
	NIV(0xB6, "number of buildings"),
 
	NIV_END()
 
};
 

	
 
class NIHTown : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return Town::IsValidID(index); }
 
	uint GetParent(uint index) const                     { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const             { return Town::Get(index); }
 
	const void *GetSpec(uint index) const                { return NULL; }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_TOWN_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return 0; }
 
	bool PSAWithParameter() const                        { return true; }
 
	uint GetPSASize(uint index, uint32 grfid) const      { return cpp_lengthof(PersistentStorage, storage); }
 
	bool IsInspectable(uint index) const override        { return Town::IsValidID(index); }
 
	uint GetParent(uint index) const override            { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const override    { return Town::Get(index); }
 
	const void *GetSpec(uint index) const override       { return NULL; }
 
	void SetStringParameters(uint index) const override  { this->SetSimpleStringParameters(STR_TOWN_NAME, index); }
 
	uint32 GetGRFID(uint index) const override           { return 0; }
 
	bool PSAWithParameter() const override               { return true; }
 
	uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		TownResolverObject ro(NULL, Town::Get(index), true);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 

	
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override
 
	{
 
		Town *t = Town::Get(index);
 

	
 
		std::list<PersistentStorage *>::iterator iter;
 
		for (iter = t->psa_list.begin(); iter != t->psa_list.end(); iter++) {
 
			if ((*iter)->grfid == grfid) return (int32 *)(&(*iter)->storage[0]);
 
		}
 

	
 
		return NULL;
 
	}
 
};
 

	
src/thread/thread_os2.cpp
Show inline comments
 
@@ -32,31 +32,31 @@ public:
 
	/**
 
	 * Create a thread and start it, calling proc(param).
 
	 */
 
	ThreadObject_OS2(OTTDThreadFunc proc, void *param, bool self_destruct) :
 
		thread(0),
 
		proc(proc),
 
		param(param),
 
		self_destruct(self_destruct)
 
	{
 
		thread = _beginthread(stThreadProc, NULL, 1048576, this);
 
	}
 

	
 
	/* virtual */ bool Exit()
 
	bool Exit() override
 
	{
 
		_endthread();
 
		return true;
 
	}
 

	
 
	/* virtual */ void Join()
 
	void Join() override
 
	{
 
		DosWaitThread(&this->thread, DCWW_WAIT);
 
		this->thread = 0;
 
	}
 
private:
 
	/**
 
	 * On thread creation, this function is called, which calls the real startup
 
	 *  function. This to get back into the correct instance again.
 
	 */
 
	static void stThreadProc(void *thr)
 
	{
 
		((ThreadObject_OS2 *)thr)->ThreadProc();
 
@@ -97,51 +97,51 @@ class ThreadMutex_OS2 : public ThreadMut
 
private:
 
	HMTX mutex; ///< The mutex.
 
	HEV event;  ///< Event for waiting.
 
	uint recursive_count;     ///< Recursive lock count.
 

	
 
public:
 
	ThreadMutex_OS2() : recursive_count(0)
 
	{
 
		DosCreateMutexSem(NULL, &mutex, 0, FALSE);
 
		DosCreateEventSem(NULL, &event, 0, FALSE);
 
	}
 

	
 
	/* virtual */ ~ThreadMutex_OS2()
 
	~ThreadMutex_OS2() override
 
	{
 
		DosCloseMutexSem(mutex);
 
		DosCloseEventSem(event);
 
	}
 

	
 
	/* virtual */ void BeginCritical(bool allow_recursive = false)
 
	void BeginCritical(bool allow_recursive = false) override
 
	{
 
		/* os2 mutex is recursive by itself */
 
		DosRequestMutexSem(mutex, (unsigned long) SEM_INDEFINITE_WAIT);
 
		this->recursive_count++;
 
		if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
 
	}
 

	
 
	/* virtual */ void EndCritical(bool allow_recursive = false)
 
	void EndCritical(bool allow_recursive = false) override
 
	{
 
		if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
 
		this->recursive_count--;
 
		DosReleaseMutexSem(mutex);
 
	}
 

	
 
	/* virtual */ void WaitForSignal()
 
	void WaitForSignal() override
 
	{
 
		assert(this->recursive_count == 1); // Do we need to call Begin/EndCritical multiple times otherwise?
 
		this->EndCritical();
 
		DosWaitEventSem(event, SEM_INDEFINITE_WAIT);
 
		this->BeginCritical();
 
	}
 

	
 
	/* virtual */ void SendSignal()
 
	void SendSignal() override
 
	{
 
		DosPostEventSem(event);
 
	}
 
};
 

	
 
/* static */ ThreadMutex *ThreadMutex::New()
 
{
 
	return new ThreadMutex_OS2();
 
}
src/thread/thread_pthread.cpp
Show inline comments
 
@@ -36,32 +36,32 @@ public:
 
	 * Create a pthread and start it, calling proc(param).
 
	 */
 
	ThreadObject_pthread(OTTDThreadFunc proc, void *param, bool self_destruct, const char *name) :
 
		thread(0),
 
		proc(proc),
 
		param(param),
 
		self_destruct(self_destruct),
 
		name(name)
 
	{
 
		pthread_create(&this->thread, NULL, &stThreadProc, this);
 
	}
 

	
 
	/* virtual */ bool Exit()
 
	bool Exit() override
 
	{
 
		assert(pthread_self() == this->thread);
 
		/* For now we terminate by throwing an error, gives much cleaner cleanup */
 
		throw OTTDThreadExitSignal();
 
	}
 

	
 
	/* virtual */ void Join()
 
	void Join() override
 
	{
 
		/* You cannot join yourself */
 
		assert(pthread_self() != this->thread);
 
		pthread_join(this->thread, NULL);
 
		this->thread = 0;
 
	}
 
private:
 
	/**
 
	 * On thread creation, this function is called, which calls the real startup
 
	 *  function. This to get back into the correct instance again.
 
	 */
 
	static void *stThreadProc(void *thr)
 
@@ -120,72 +120,72 @@ private:
 
	pthread_t owner;          ///< Owning thread of the mutex.
 
	uint recursive_count;     ///< Recursive lock count.
 

	
 
public:
 
	ThreadMutex_pthread() : owner(0), recursive_count(0)
 
	{
 
		pthread_mutexattr_init(&this->attr);
 
		pthread_mutexattr_settype(&this->attr, PTHREAD_MUTEX_ERRORCHECK);
 
		pthread_mutex_init(&this->mutex, &this->attr);
 
		pthread_cond_init(&this->condition, NULL);
 
	}
 

	
 
	/* virtual */ ~ThreadMutex_pthread()
 
	~ThreadMutex_pthread() override
 
	{
 
		int err = pthread_cond_destroy(&this->condition);
 
		assert(err != EBUSY);
 
		err = pthread_mutex_destroy(&this->mutex);
 
		assert(err != EBUSY);
 
	}
 

	
 
	bool IsOwnedByCurrentThread() const
 
	{
 
		return this->owner == pthread_self();
 
	}
 

	
 
	/* virtual */ void BeginCritical(bool allow_recursive = false)
 
	void BeginCritical(bool allow_recursive = false) override
 
	{
 
		/* pthread mutex is not recursive by itself */
 
		if (this->IsOwnedByCurrentThread()) {
 
			if (!allow_recursive) NOT_REACHED();
 
		} else {
 
			int err = pthread_mutex_lock(&this->mutex);
 
			assert(err == 0);
 
			assert(this->recursive_count == 0);
 
			this->owner = pthread_self();
 
		}
 
		this->recursive_count++;
 
	}
 

	
 
	/* virtual */ void EndCritical(bool allow_recursive = false)
 
	void EndCritical(bool allow_recursive = false) override
 
	{
 
		assert(this->IsOwnedByCurrentThread());
 
		if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
 
		this->recursive_count--;
 
		if (this->recursive_count != 0) return;
 
		this->owner = 0;
 
		int err = pthread_mutex_unlock(&this->mutex);
 
		assert(err == 0);
 
	}
 

	
 
	/* virtual */ void WaitForSignal()
 
	void WaitForSignal() override
 
	{
 
		uint old_recursive_count = this->recursive_count;
 
		this->recursive_count = 0;
 
		this->owner = 0;
 
		int err = pthread_cond_wait(&this->condition, &this->mutex);
 
		assert(err == 0);
 
		this->owner = pthread_self();
 
		this->recursive_count = old_recursive_count;
 
	}
 

	
 
	/* virtual */ void SendSignal()
 
	void SendSignal() override
 
	{
 
		int err = pthread_cond_signal(&this->condition);
 
		assert(err == 0);
 
	}
 
};
 

	
 
/* static */ ThreadMutex *ThreadMutex::New()
 
{
 
	return new ThreadMutex_pthread();
 
}
src/thread/thread_win32.cpp
Show inline comments
 
@@ -40,40 +40,40 @@ public:
 
		thread(NULL),
 
		id(0),
 
		proc(proc),
 
		param(param),
 
		self_destruct(self_destruct),
 
		name(name)
 
	{
 
		this->thread = (HANDLE)_beginthreadex(NULL, 0, &stThreadProc, this, CREATE_SUSPENDED, &this->id);
 
		if (this->thread == NULL) return;
 
		ResumeThread(this->thread);
 
	}
 

	
 
	/* virtual */ ~ThreadObject_Win32()
 
	~ThreadObject_Win32() override
 
	{
 
		if (this->thread != NULL) {
 
			CloseHandle(this->thread);
 
			this->thread = NULL;
 
		}
 
	}
 

	
 
	/* virtual */ bool Exit()
 
	bool Exit() override
 
	{
 
		assert(GetCurrentThreadId() == this->id);
 
		/* For now we terminate by throwing an error, gives much cleaner cleanup */
 
		throw OTTDThreadExitSignal();
 
	}
 

	
 
	/* virtual */ void Join()
 
	void Join() override
 
	{
 
		/* You cannot join yourself */
 
		assert(GetCurrentThreadId() != this->id);
 
		WaitForSingleObject(this->thread, INFINITE);
 
	}
 

	
 
private:
 
	/**
 
	 * On thread creation, this function is called, which calls the real startup
 
	 *  function. This to get back into the correct instance again.
 
	 */
 
	static uint CALLBACK stThreadProc(void *thr)
 
@@ -117,51 +117,51 @@ class ThreadMutex_Win32 : public ThreadM
 
private:
 
	CRITICAL_SECTION critical_section; ///< The critical section we would enter.
 
	HANDLE event;                      ///< Event for signalling.
 
	uint recursive_count;     ///< Recursive lock count.
 

	
 
public:
 
	ThreadMutex_Win32() : recursive_count(0)
 
	{
 
		InitializeCriticalSection(&this->critical_section);
 
		this->event = CreateEvent(NULL, FALSE, FALSE, NULL);
 
	}
 

	
 
	/* virtual */ ~ThreadMutex_Win32()
 
	~ThreadMutex_Win32() override
 
	{
 
		DeleteCriticalSection(&this->critical_section);
 
		CloseHandle(this->event);
 
	}
 

	
 
	/* virtual */ void BeginCritical(bool allow_recursive = false)
 
	void BeginCritical(bool allow_recursive = false) override
 
	{
 
		/* windows mutex is recursive by itself */
 
		EnterCriticalSection(&this->critical_section);
 
		this->recursive_count++;
 
		if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
 
	}
 

	
 
	/* virtual */ void EndCritical(bool allow_recursive = false)
 
	void EndCritical(bool allow_recursive = false) override
 
	{
 
		if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
 
		this->recursive_count--;
 
		LeaveCriticalSection(&this->critical_section);
 
	}
 

	
 
	/* virtual */ void WaitForSignal()
 
	void WaitForSignal() override
 
	{
 
		assert(this->recursive_count == 1); // Do we need to call Begin/EndCritical multiple times otherwise?
 
		this->EndCritical();
 
		WaitForSingleObject(this->event, INFINITE);
 
		this->BeginCritical();
 
	}
 

	
 
	/* virtual */ void SendSignal()
 
	void SendSignal() override
 
	{
 
		SetEvent(this->event);
 
	}
 
};
 

	
 
/* static */ ThreadMutex *ThreadMutex::New()
 
{
 
	return new ThreadMutex_Win32();
 
}
src/toolbar_gui.cpp
Show inline comments
 
@@ -1323,25 +1323,25 @@ public:
 
	}
 

	
 
	/**
 
	 * Check whether the given widget type is a button for us.
 
	 * @param type the widget type to check.
 
	 * @return true if it is a button for us.
 
	 */
 
	bool IsButton(WidgetType type) const
 
	{
 
		return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
 
	}
 

	
 
	void SetupSmallestSize(Window *w, bool init_array)
 
	void SetupSmallestSize(Window *w, bool init_array) override
 
	{
 
		this->smallest_x = 0; // Biggest child
 
		this->smallest_y = 0; // Biggest child
 
		this->fill_x = 1;
 
		this->fill_y = 0;
 
		this->resize_x = 1; // We only resize in this direction
 
		this->resize_y = 0; // We never resize in this direction
 
		this->spacers = 0;
 

	
 
		uint nbuttons = 0;
 
		/* First initialise some variables... */
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
@@ -1356,25 +1356,25 @@ public:
 
		}
 

	
 
		/* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			child_wid->current_y = this->smallest_y;
 
			if (!this->IsButton(child_wid->type)) {
 
				child_wid->current_x = child_wid->smallest_x;
 
			}
 
		}
 
		_toolbar_width = nbuttons * this->smallest_x;
 
	}
 

	
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
 
	{
 
		assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 

	
 
		this->pos_x = x;
 
		this->pos_y = y;
 
		this->current_x = given_width;
 
		this->current_y = given_height;
 

	
 
		/* Figure out what are the visible buttons */
 
		memset(this->visible, 0, sizeof(this->visible));
 
		uint arrangable_count, button_count, spacer_count;
 
		const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count);
 
@@ -1419,40 +1419,40 @@ public:
 
			}
 
			child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl);
 
			position += child_wid->current_x;
 

	
 
			if (rtl) {
 
				cur_wid--;
 
			} else {
 
				cur_wid++;
 
			}
 
		}
 
	}
 

	
 
	/* virtual */ void Draw(const Window *w)
 
	void Draw(const Window *w) override
 
	{
 
		/* Draw brown-red toolbar bg. */
 
		GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_VERY_DARK_RED);
 
		GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, PC_DARK_RED, FILLRECT_CHECKER);
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != NULL; child_wid = rtl ? child_wid->prev : child_wid->next) {
 
			if (child_wid->type == NWID_SPACER) continue;
 
			if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
 

	
 
			child_wid->Draw(w);
 
		}
 
	}
 

	
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y)
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override
 
	{
 
		if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
 

	
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			if (child_wid->type == NWID_SPACER) continue;
 
			if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
 

	
 
			NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
 
			if (nwid != NULL) return nwid;
 
		}
 
		return NULL;
 
	}
 
@@ -1461,25 +1461,25 @@ public:
 
	 * Get the arrangement of the buttons for the toolbar.
 
	 * @param width the new width of the toolbar.
 
	 * @param arrangable_count output of the number of visible items.
 
	 * @param button_count output of the number of visible buttons.
 
	 * @param spacer_count output of the number of spacers.
 
	 * @return the button configuration.
 
	 */
 
	virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0;
 
};
 

	
 
/** Container for the 'normal' main toolbar */
 
class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
 
	/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
 
	const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
 
	{
 
		static const uint SMALLEST_ARRANGEMENT = 14;
 
		static const uint BIGGEST_ARRANGEMENT  = 20;
 

	
 
		/* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
 
		 * The total number of buttons should be equal to arrangable_count * 2.
 
		 * No bad things happen, but we could see strange behaviours if we have buttons < (arrangable_count * 2) like a
 
		 * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
 
		 * enough space.
 
		 */
 
		static const byte arrange14[] = {
 
			WID_TN_PAUSE,
 
@@ -1784,40 +1784,40 @@ class NWidgetMainToolbarContainer : publ
 
		static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 };
 

	
 
		button_count = arrangable_count = full_buttons;
 
		spacer_count = this->spacers;
 
		return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
 
	}
 
};
 

	
 
/** Container for the scenario editor's toolbar */
 
class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
 
	uint panel_widths[2]; ///< The width of the two panels (the text panel and date panel)
 

	
 
	void SetupSmallestSize(Window *w, bool init_array)
 
	void SetupSmallestSize(Window *w, bool init_array) override
 
	{
 
		this->NWidgetToolbarContainer::SetupSmallestSize(w, init_array);
 

	
 
		/* Find the size of panel_widths */
 
		uint i = 0;
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
 

	
 
			assert(i < lengthof(this->panel_widths));
 
			this->panel_widths[i++] = child_wid->current_x;
 
			_toolbar_width += child_wid->current_x;
 
		}
 
	}
 

	
 
	/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
 
	const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override
 
	{
 
		static const byte arrange_all[] = {
 
			WID_TE_PAUSE,
 
			WID_TE_FAST_FORWARD,
 
			WID_TE_SETTINGS,
 
			WID_TE_SAVE,
 
			WID_TE_SPACER,
 
			WID_TE_DATE_PANEL,
 
			WID_TE_SMALL_MAP,
 
			WID_TE_ZOOM_IN,
 
			WID_TE_ZOOM_OUT,
 
			WID_TE_LAND_GENERATE,
src/video/allegro_v.h
Show inline comments
 
@@ -8,39 +8,39 @@
 
 */
 

	
 
/** @file allegro_v.h Base of the Allegro video driver. */
 

	
 
#ifndef VIDEO_ALLEGRO_H
 
#define VIDEO_ALLEGRO_H
 

	
 
#include "video_driver.hpp"
 

	
 
/** The allegro video driver. */
 
class VideoDriver_Allegro : public VideoDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void MakeDirty(int left, int top, int width, int height);
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	/* virtual */ void MainLoop();
 
	void MainLoop() override;
 

	
 
	/* virtual */ bool ChangeResolution(int w, int h);
 
	bool ChangeResolution(int w, int h) override;
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	bool ToggleFullscreen(bool fullscreen) override;
 

	
 
	/* virtual */ bool AfterBlitterChange();
 
	bool AfterBlitterChange() override;
 

	
 
	/* virtual */ bool ClaimMousePointer();
 
	bool ClaimMousePointer() override;
 

	
 
	/* virtual */ const char *GetName() const { return "allegro"; }
 
	const char *GetName() const override { return "allegro"; }
 
};
 

	
 
/** Factory for the allegro video driver. */
 
class FVideoDriver_Allegro : public DriverFactoryBase {
 
public:
 
	FVideoDriver_Allegro() : DriverFactoryBase(Driver::DT_VIDEO, 4, "allegro", "Allegro Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Allegro(); }
 
	Driver *CreateInstance() const override { return new VideoDriver_Allegro(); }
 
};
 

	
 
#endif /* VIDEO_ALLEGRO_H */
src/video/cocoa/cocoa_v.h
Show inline comments
 
@@ -7,73 +7,73 @@
 
 * 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 cocoa_v.h The Cocoa video driver. */
 

	
 
#ifndef VIDEO_COCOA_H
 
#define VIDEO_COCOA_H
 

	
 
#include "../video_driver.hpp"
 

	
 
class VideoDriver_Cocoa : public VideoDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/** Stop the video driver */
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/** Mark dirty a screen region
 
	 * @param left x-coordinate of left border
 
	 * @param top  y-coordinate of top border
 
	 * @param width width or dirty rectangle
 
	 * @param height height of dirty rectangle
 
	 */
 
	/* virtual */ void MakeDirty(int left, int top, int width, int height);
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	/** Programme main loop */
 
	/* virtual */ void MainLoop();
 
	void MainLoop() override;
 

	
 
	/** Change window resolution
 
	 * @param w New window width
 
	 * @param h New window height
 
	 * @return Whether change was successful
 
	 */
 
	/* virtual */ bool ChangeResolution(int w, int h);
 
	bool ChangeResolution(int w, int h) override;
 

	
 
	/** Set a new window mode
 
	 * @param fullscreen Whether to set fullscreen mode or not
 
	 * @return Whether changing the screen mode was successful
 
	 */
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	bool ToggleFullscreen(bool fullscreen) override;
 

	
 
	/** Callback invoked after the blitter was changed.
 
	 * @return True if no error.
 
	 */
 
	/* virtual */ bool AfterBlitterChange();
 
	bool AfterBlitterChange() override;
 

	
 
	/**
 
	 * An edit box lost the input focus. Abort character compositing if necessary.
 
	 */
 
	/* virtual */ void EditBoxLostFocus();
 
	void EditBoxLostFocus() override;
 

	
 
	/** Return driver name
 
	 * @return driver name
 
	 */
 
	/* virtual */ const char *GetName() const { return "cocoa"; }
 
	const char *GetName() const override { return "cocoa"; }
 
};
 

	
 
class FVideoDriver_Cocoa : public DriverFactoryBase {
 
public:
 
	FVideoDriver_Cocoa() : DriverFactoryBase(Driver::DT_VIDEO, 10, "cocoa", "Cocoa Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Cocoa(); }
 
	Driver *CreateInstance() const override { return new VideoDriver_Cocoa(); }
 
};
 

	
 

	
 
/**
 
 * Generic display driver for cocoa
 
 * On grounds to not duplicate some code, it contains a few variables
 
 * which are not used by all device drivers.
 
 */
 
class CocoaSubdriver {
 
public:
 
	int device_width;     ///< Width of device in pixel
 
	int device_height;    ///< Height of device in pixel
src/video/dedicated_v.h
Show inline comments
 
@@ -8,42 +8,42 @@
 
 */
 

	
 
/** @file dedicated_v.h Base for the dedicated video driver. */
 

	
 
#ifndef VIDEO_DEDICATED_H
 
#define VIDEO_DEDICATED_H
 

	
 
#include "video_driver.hpp"
 

	
 
/** The dedicated server video driver. */
 
class VideoDriver_Dedicated : public VideoDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void MakeDirty(int left, int top, int width, int height);
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	/* virtual */ void MainLoop();
 
	void MainLoop() override;
 

	
 
	/* virtual */ bool ChangeResolution(int w, int h);
 
	bool ChangeResolution(int w, int h) override;
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "dedicated"; }
 
	/* virtual */ bool HasGUI() const { return false; }
 
	bool ToggleFullscreen(bool fullscreen) override;
 
	const char *GetName() const override { return "dedicated"; }
 
	bool HasGUI() const override { return false; }
 
};
 

	
 
/** Factory for the dedicated server video driver. */
 
class FVideoDriver_Dedicated : public DriverFactoryBase {
 
public:
 
#ifdef DEDICATED
 
	/* Automatically select this dedicated driver when making a dedicated
 
	 * server build. */
 
	static const int PRIORITY = 10;
 
#else
 
	static const int PRIORITY = 0;
 
#endif
 
	FVideoDriver_Dedicated() : DriverFactoryBase(Driver::DT_VIDEO, PRIORITY, "dedicated", "Dedicated Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Dedicated(); }
 
	Driver *CreateInstance() const override { return new VideoDriver_Dedicated(); }
 
};
 

	
 
#endif /* VIDEO_DEDICATED_H */
src/video/null_v.h
Show inline comments
 
@@ -11,35 +11,35 @@
 

	
 
#ifndef VIDEO_NULL_H
 
#define VIDEO_NULL_H
 

	
 
#include "video_driver.hpp"
 

	
 
/** The null video driver. */
 
class VideoDriver_Null : public VideoDriver {
 
private:
 
	uint ticks; ///< Amount of ticks to run.
 

	
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void MakeDirty(int left, int top, int width, int height);
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	/* virtual */ void MainLoop();
 
	void MainLoop() override;
 

	
 
	/* virtual */ bool ChangeResolution(int w, int h);
 
	bool ChangeResolution(int w, int h) override;
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "null"; }
 
	/* virtual */ bool HasGUI() const { return false; }
 
	bool ToggleFullscreen(bool fullscreen) override;
 
	const char *GetName() const override { return "null"; }
 
	bool HasGUI() const override { return false; }
 
};
 

	
 
/** Factory the null video driver. */
 
class FVideoDriver_Null : public DriverFactoryBase {
 
public:
 
	FVideoDriver_Null() : DriverFactoryBase(Driver::DT_VIDEO, 0, "null", "Null Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Null(); }
 
	Driver *CreateInstance() const override { return new VideoDriver_Null(); }
 
};
 

	
 
#endif /* VIDEO_NULL_H */
src/video/sdl_v.h
Show inline comments
 
@@ -8,47 +8,47 @@
 
 */
 

	
 
/** @file sdl_v.h Base of the SDL video driver. */
 

	
 
#ifndef VIDEO_SDL_H
 
#define VIDEO_SDL_H
 

	
 
#include "video_driver.hpp"
 

	
 
/** The SDL video driver. */
 
class VideoDriver_SDL : public VideoDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void MakeDirty(int left, int top, int width, int height);
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	/* virtual */ void MainLoop();
 
	void MainLoop() override;
 

	
 
	/* virtual */ bool ChangeResolution(int w, int h);
 
	bool ChangeResolution(int w, int h) override;
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	bool ToggleFullscreen(bool fullscreen) override;
 

	
 
	/* virtual */ bool AfterBlitterChange();
 
	bool AfterBlitterChange() override;
 

	
 
	/* virtual */ void AcquireBlitterLock();
 
	void AcquireBlitterLock() override;
 

	
 
	/* virtual */ void ReleaseBlitterLock();
 
	void ReleaseBlitterLock() override;
 

	
 
	/* virtual */ bool ClaimMousePointer();
 
	bool ClaimMousePointer() override;
 

	
 
	/* virtual */ const char *GetName() const { return "sdl"; }
 
	const char *GetName() const override { return "sdl"; }
 
private:
 
	int PollEvent();
 
	bool CreateMainSurface(uint w, uint h);
 
	void SetupKeyboard();
 
};
 

	
 
/** Factory for the SDL video driver. */
 
class FVideoDriver_SDL : public DriverFactoryBase {
 
public:
 
	FVideoDriver_SDL() : DriverFactoryBase(Driver::DT_VIDEO, 5, "sdl", "SDL Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_SDL(); }
 
	Driver *CreateInstance() const override { return new VideoDriver_SDL(); }
 
};
 

	
 
#endif /* VIDEO_SDL_H */
src/video/win32_v.h
Show inline comments
 
@@ -8,47 +8,47 @@
 
 */
 

	
 
/** @file win32_v.h Base of the Windows video driver. */
 

	
 
#ifndef VIDEO_WIN32_H
 
#define VIDEO_WIN32_H
 

	
 
#include "video_driver.hpp"
 

	
 
/** The video driver for windows. */
 
class VideoDriver_Win32 : public VideoDriver {
 
public:
 
	/* virtual */ const char *Start(const char * const *param);
 
	const char *Start(const char * const *param) override;
 

	
 
	/* virtual */ void Stop();
 
	void Stop() override;
 

	
 
	/* virtual */ void MakeDirty(int left, int top, int width, int height);
 
	void MakeDirty(int left, int top, int width, int height) override;
 

	
 
	/* virtual */ void MainLoop();
 
	void MainLoop() override;
 

	
 
	/* virtual */ bool ChangeResolution(int w, int h);
 
	bool ChangeResolution(int w, int h) override;
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	bool ToggleFullscreen(bool fullscreen) override;
 

	
 
	/* virtual */ bool AfterBlitterChange();
 
	bool AfterBlitterChange() override;
 

	
 
	/* virtual */ void AcquireBlitterLock();
 
	void AcquireBlitterLock() override;
 

	
 
	/* virtual */ void ReleaseBlitterLock();
 
	void ReleaseBlitterLock() override;
 

	
 
	/* virtual */ bool ClaimMousePointer();
 
	bool ClaimMousePointer() override;
 

	
 
	/* virtual */ void EditBoxLostFocus();
 
	void EditBoxLostFocus() override;
 

	
 
	/* virtual */ const char *GetName() const { return "win32"; }
 
	const char *GetName() const override { return "win32"; }
 

	
 
	bool MakeWindow(bool full_screen);
 
};
 

	
 
/** The factory for Windows' video driver. */
 
class FVideoDriver_Win32 : public DriverFactoryBase {
 
public:
 
	FVideoDriver_Win32() : DriverFactoryBase(Driver::DT_VIDEO, 10, "win32", "Win32 GDI Video Driver") {}
 
	/* virtual */ Driver *CreateInstance() const { return new VideoDriver_Win32(); }
 
	Driver *CreateInstance() const override { return new VideoDriver_Win32(); }
 
};
 

	
 
#endif /* VIDEO_WIN32_H */
src/waypoint_base.h
Show inline comments
 
@@ -16,41 +16,41 @@
 

	
 
/** Representation of a waypoint. */
 
struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
 
	uint16 town_cn;    ///< The N-1th waypoint for this town (consecutive number)
 

	
 
	/**
 
	 * Create a waypoint at the given tile.
 
	 * @param tile The location of the waypoint.
 
	 */
 
	Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
 
	~Waypoint();
 

	
 
	void UpdateVirtCoord();
 
	void UpdateVirtCoord() override;
 

	
 
	/* virtual */ inline bool TileBelongsToRailStation(TileIndex tile) const
 
	inline bool TileBelongsToRailStation(TileIndex tile) const override
 
	{
 
		return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
 
	}
 

	
 
	/* virtual */ uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const;
 
	uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override;
 

	
 
	/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
 
	void GetTileArea(TileArea *ta, StationType type) const override;
 

	
 
	/* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const
 
	uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
 
	{
 
		return 1;
 
	}
 

	
 
	/* virtual */ uint GetPlatformLength(TileIndex tile) const
 
	uint GetPlatformLength(TileIndex tile) const override
 
	{
 
		return 1;
 
	}
 

	
 
	/**
 
	 * Is this a single tile waypoint?
 
	 * @return true if it is.
 
	 */
 
	inline bool IsSingleTile() const
 
	{
 
		return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
 
	}
src/widget_type.h
Show inline comments
 
@@ -284,29 +284,29 @@ DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
 
class NWidgetCore : public NWidgetResizeBase {
 
public:
 
	NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
 

	
 
	void SetIndex(int index);
 
	void SetDataTip(uint32 widget_data, StringID tool_tip);
 

	
 
	inline void SetLowered(bool lowered);
 
	inline bool IsLowered() const;
 
	inline void SetDisabled(bool disabled);
 
	inline bool IsDisabled() const;
 

	
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	/* virtual */ bool IsHighlighted() const;
 
	/* virtual */ TextColour GetHighlightColour() const;
 
	/* virtual */ void SetHighlighted(TextColour highlight_colour);
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 
	bool IsHighlighted() const override;
 
	TextColour GetHighlightColour() const override;
 
	void SetHighlighted(TextColour highlight_colour) override;
 

	
 
	NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget.
 
	Colours colour;            ///< Colour of this widget.
 
	int index;                 ///< Index of the nested widget in the widget array of the window (\c -1 means 'not used').
 
	uint32 widget_data;        ///< Data of the widget. @see Widget::data
 
	StringID tool_tip;         ///< Tooltip of the widget. @see Widget::tootips
 
	int scrollbar_index;       ///< Index of an attached scrollbar.
 
	TextColour highlight_colour; ///< Colour of highlight.
 
};
 

	
 
/**
 
 * Highlight the widget or not.
 
@@ -362,30 +362,30 @@ inline bool NWidgetCore::IsDisabled() co
 

	
 

	
 
/**
 
 * Baseclass for container widgets.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetContainer : public NWidgetBase {
 
public:
 
	NWidgetContainer(WidgetType tp);
 
	~NWidgetContainer();
 

	
 
	void Add(NWidgetBase *wid);
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 

	
 
	/** Return whether the container is empty. */
 
	inline bool IsEmpty() { return head == NULL; }
 

	
 
	/* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
 
	NWidgetBase *GetWidgetOfType(WidgetType tp) override;
 

	
 
protected:
 
	NWidgetBase *head; ///< Pointer to first widget in container.
 
	NWidgetBase *tail; ///< Pointer to last widget in container.
 
};
 

	
 
/** Display planes with zero size for #NWidgetStacked. */
 
enum StackedZeroSizePlanes {
 
	SZSP_VERTICAL = INT_MAX / 2, ///< Display plane with zero size horizontally, and filling and resizing vertically.
 
	SZSP_HORIZONTAL,             ///< Display plane with zero size vertically, and filling and resizing horizontally.
 
	SZSP_NONE,                   ///< Display plane with zero size in both directions (none filling and resizing).
 

	
 
@@ -399,55 +399,55 @@ enum StackedZeroSizePlanes {
 
 *
 
 * There are also a number of special planes (defined in #StackedZeroSizePlanes) that have zero size in one direction (and are stretchable in
 
 * the other direction) or have zero size in both directions. They are used to make all child planes of the widget disappear.
 
 * Unlike switching between the regular display planes (that all have the same size), switching from or to one of the zero-sized planes means that
 
 * a #Window::ReInit() is needed to re-initialize the window since its size changes.
 
 */
 
class NWidgetStacked : public NWidgetContainer {
 
public:
 
	NWidgetStacked();
 

	
 
	void SetIndex(int index);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 

	
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	void Draw(const Window *w) override;
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 

	
 
	void SetDisplayedPlane(int plane);
 

	
 
	int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only).
 
	int index;       ///< If non-negative, index in the #Window::nested_array.
 
};
 

	
 
/** Nested widget container flags, */
 
enum NWidContainerFlags {
 
	NCB_EQUALSIZE = 0, ///< Containers should keep all their (resizing) children equally large.
 

	
 
	NC_NONE = 0,                       ///< All flags cleared.
 
	NC_EQUALSIZE = 1 << NCB_EQUALSIZE, ///< Value of the #NCB_EQUALSIZE flag.
 
};
 
DECLARE_ENUM_AS_BIT_SET(NWidContainerFlags)
 

	
 
/** Container with pre/inter/post child space. */
 
class NWidgetPIPContainer : public NWidgetContainer {
 
public:
 
	NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE);
 

	
 
	void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
 

	
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	void Draw(const Window *w) override;
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 

	
 
protected:
 
	NWidContainerFlags flags; ///< Flags of the container.
 
	uint8 pip_pre;            ///< Amount of space before first widget.
 
	uint8 pip_inter;          ///< Amount of space between widgets.
 
	uint8 pip_post;           ///< Amount of space after last widget.
 
};
 

	
 
/**
 
 * Horizontal container.
 
 * @ingroup NestedWidgets
 
 */
 
@@ -491,102 +491,102 @@ public:
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetMatrix : public NWidgetPIPContainer {
 
public:
 
	NWidgetMatrix();
 

	
 
	void SetIndex(int index);
 
	void SetColour(Colours colour);
 
	void SetClicked(int clicked);
 
	void SetCount(int count);
 
	void SetScrollbar(Scrollbar *sb);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 

	
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	/* virtual */ void Draw(const Window *w);
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 
	void Draw(const Window *w) override;
 
protected:
 
	int index;      ///< If non-negative, index in the #Window::nested_array.
 
	Colours colour; ///< Colour of this widget.
 
	int clicked;    ///< The currently clicked widget.
 
	int count;      ///< Amount of valid widgets.
 
	Scrollbar *sb;  ///< The scrollbar we're associated with.
 
private:
 
	int widget_w;   ///< The width of the child widget including inter spacing.
 
	int widget_h;   ///< The height of the child widget including inter spacing.
 
	int widgets_x;  ///< The number of visible widgets in horizontal direction.
 
	int widgets_y;  ///< The number of visible widgets in vertical direction.
 

	
 
	void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
 
};
 

	
 

	
 
/**
 
 * Spacer widget.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetSpacer : public NWidgetResizeBase {
 
public:
 
	NWidgetSpacer(int length, int height);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 

	
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ void SetDirty(const Window *w) const;
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	void Draw(const Window *w) override;
 
	void SetDirty(const Window *w) const override;
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 
};
 

	
 
/**
 
 * Nested widget with a child.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetBackground : public NWidgetCore {
 
public:
 
	NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = NULL);
 
	~NWidgetBackground();
 

	
 
	void Add(NWidgetBase *nwid);
 
	void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
 

	
 
	/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 

	
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
	/* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
 
	void Draw(const Window *w) override;
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 
	NWidgetBase *GetWidgetOfType(WidgetType tp) override;
 

	
 
private:
 
	NWidgetPIPContainer *child; ///< Child widget.
 
};
 

	
 
/**
 
 * Nested widget to display a viewport in a window.
 
 * After initializing the nested widget tree, call #InitializeViewport(). After changing the window size,
 
 * call #UpdateViewportCoordinates() eg from Window::OnResize().
 
 * If the #disp_flags field contains the #ND_NO_TRANSPARENCY bit, the viewport will disable transparency.
 
 * Shading to grey-scale is controlled with the #ND_SHADE_GREY bit (used for B&W news papers), the #ND_SHADE_DIMMED gives dimmed colours (for colour news papers).
 
 * @todo Class derives from #NWidgetCore, but does not use #colour, #widget_data, or #tool_tip.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetViewport : public NWidgetCore {
 
public:
 
	NWidgetViewport(int index);
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void Draw(const Window *w) override;
 

	
 
	void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
 
	void UpdateViewportCoordinates(Window *w);
 
};
 

	
 
/**
 
 * Scrollbar data structure
 
 */
 
class Scrollbar {
 
private:
 
	const bool is_vertical; ///< Scrollbar has vertical orientation.
 
	uint16 count;           ///< Number of elements in the list.
 
@@ -742,46 +742,46 @@ public:
 
	int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const;
 
};
 

	
 
/**
 
 * Nested widget to display and control a scrollbar in a window.
 
 * Also assign the scrollbar to other widgets using #SetScrollbar() to make the mousewheel work.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
 
public:
 
	NWidgetScrollbar(WidgetType tp, Colours colour, int index);
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void Draw(const Window *w) override;
 

	
 
	static void InvalidateDimensionCache();
 
	static Dimension GetVerticalDimension();
 
	static Dimension GetHorizontalDimension();
 

	
 
private:
 
	static Dimension vertical_dimension;   ///< Cached size of vertical scrollbar button.
 
	static Dimension horizontal_dimension; ///< Cached size of horizontal scrollbar button.
 
};
 

	
 
/**
 
 * Leaf widget.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetLeaf : public NWidgetCore {
 
public:
 
	NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip);
 

	
 
	/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
 
	/* virtual */ void Draw(const Window *w);
 
	void SetupSmallestSize(Window *w, bool init_array) override;
 
	void Draw(const Window *w) override;
 

	
 
	bool ButtonHit(const Point &pt);
 

	
 
	static void InvalidateDimensionCache();
 

	
 
	static Dimension dropdown_dimension;  ///< Cached size of a dropdown widget.
 
	static Dimension resizebox_dimension; ///< Cached size of a resizebox widget.
 
	static Dimension closebox_dimension;  ///< Cached size of a closebox widget.
 
private:
 
	static Dimension shadebox_dimension;  ///< Cached size of a shadebox widget.
 
	static Dimension debugbox_dimension;  ///< Cached size of a debugbox widget.
 
	static Dimension defsizebox_dimension; ///< Cached size of a defsizebox widget.
0 comments (0 inline, 0 general)