Changeset - r17629:21e9dfd343cd
[Not reviewed]
master
0 51 0
rubidium - 13 years ago 2011-05-02 16:14:23
rubidium@openttd.org
(svn r22410) -Document: some more bits ;)
51 files changed with 241 insertions and 39 deletions:
0 comments (0 inline, 0 general)
src/debug.h
Show inline comments
 
@@ -58,12 +58,18 @@
 
void SetDebugString(const char *s);
 
const char *GetDebugString();
 

	
 
/* Shorter form for passing filename and linenumber */
 
#define FILE_LINE __FILE__, __LINE__
 

	
 
/**
 
 * Get the tick counter from the CPU (high precision timing).
 
 * @return The count.
 
 */
 
uint64 ottd_rdtsc();
 

	
 
/* Used for profiling
 
 *
 
 * Usage:
 
 * TIC();
 
 *   --Do your code--
 
 * TOC("A name", 1);
 
@@ -80,13 +86,12 @@ const char *GetDebugString();
 
 * Is the correct usage for multiple TIC() / TOC() calls.
 
 *
 
 * TIC() / TOC() creates its own block, so make sure not the mangle
 
 *  it with another block.
 
 **/
 
#define TIC() {\
 
	extern uint64 ottd_rdtsc();\
 
	uint64 _xxx_ = ottd_rdtsc();\
 
	static uint64 __sum__ = 0;\
 
	static uint32 __i__ = 0;
 

	
 
#define TOC(str, count)\
 
	__sum__ += ottd_rdtsc() - _xxx_;\
src/music.cpp
Show inline comments
 
@@ -8,25 +8,26 @@
 
 */
 

	
 
/** @file music.cpp The songs that OpenTTD knows. */
 

	
 
#include "stdafx.h"
 

	
 
/* The type of set we're replacing */
 
/** The type of set we're replacing */
 
#define SET_TYPE "music"
 
#include "base_media_func.h"
 

	
 
INSTANTIATE_BASE_MEDIA_METHODS(BaseMedia<MusicSet>, MusicSet)
 

	
 
/** Names corresponding to the music set's files */
 
static const char * const _music_file_names[] = {
 
	"theme",
 
	"old_0", "old_1", "old_2", "old_3", "old_4", "old_5", "old_6", "old_7", "old_8", "old_9",
 
	"new_0", "new_1", "new_2", "new_3", "new_4", "new_5", "new_6", "new_7", "new_8", "new_9",
 
	"ezy_0", "ezy_1", "ezy_2", "ezy_3", "ezy_4", "ezy_5", "ezy_6", "ezy_7", "ezy_8", "ezy_9",
 
};
 
/** Make sure we aren't messing things up. */
 
assert_compile(lengthof(_music_file_names) == NUM_SONGS_AVAILABLE);
 

	
 
template <class T, size_t Tnum_files, Subdirectory Tsubdir>
 
/* static */ const char * const *BaseSet<T, Tnum_files, Tsubdir>::file_names = _music_file_names;
 

	
 
template <class Tbase_set>
src/music/allegro_m.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying();
 

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

	
 
/** Factory for allegro's music player. */
 
class FMusicDriver_Allegro: public MusicDriverFactory<FMusicDriver_Allegro> {
 
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. */
src/music/bemidi.cpp
Show inline comments
 
@@ -13,14 +13,16 @@
 
#include "../openttd.h"
 
#include "bemidi.h"
 

	
 
/* BeOS System Includes */
 
#include <MidiSynthFile.h>
 

	
 
/** The file we're playing. */
 
static BMidiSynthFile midiSynthFile;
 

	
 
/** Factory for BeOS' midi player. */
 
static FMusicDriver_BeMidi iFMusicDriver_BeMidi;
 

	
 
const char *MusicDriver_BeMidi::Start(const char * const *parm)
 
{
 
	return NULL;
 
}
src/music/bemidi.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying();
 

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

	
 
/** Factory for the BeOS midi player. */
 
class FMusicDriver_BeMidi: public MusicDriverFactory<FMusicDriver_BeMidi> {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "bemidi"; }
 
	/* virtual */ const char *GetDescription() { return "BeOS MIDI Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new MusicDriver_BeMidi(); }
src/music/dmusic.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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 */ const char *Start(const char * const *param);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying();
 

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

	
 
/** Factory for the DirectX music player. */
 
class FMusicDriver_DMusic: public MusicDriverFactory<FMusicDriver_DMusic> {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "dmusic"; }
 
	/* virtual */ const char *GetDescription() { return "DirectMusic MIDI Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new MusicDriver_DMusic(); }
src/music/extmidi.cpp
Show inline comments
 
@@ -23,15 +23,17 @@
 
#include <unistd.h>
 
#include <signal.h>
 
#include <sys/stat.h>
 
#include <errno.h>
 

	
 
#ifndef EXTERNAL_PLAYER
 
/** The default external midi player. */
 
#define EXTERNAL_PLAYER "timidity"
 
#endif
 

	
 
/** Factory for the midi player that uses external players. */
 
static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
 

	
 
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
 
{
 
	if (strcmp(_video_driver->GetName(), "allegro") == 0 ||
 
			strcmp(_sound_driver->GetName(), "allegro") == 0) {
src/music/libtimidity.cpp
Show inline comments
 
@@ -23,12 +23,13 @@
 
#include <errno.h>
 
#include <timidity.h>
 
#if defined(PSP)
 
#include <pspaudiolib.h>
 
#endif /* PSP */
 

	
 
/** The state of playing. */
 
enum MidiState {
 
	MIDI_STOPPED = 0,
 
	MIDI_PLAYING = 1,
 
};
 

	
 
static struct {
 
@@ -36,24 +37,25 @@ static struct {
 
	MidSongOptions options;
 
	MidSong *song;
 

	
 
	MidiState status;
 
	uint32 song_length;
 
	uint32 song_position;
 
} _midi;
 
} _midi; ///< Metadata about the midi we're playing.
 

	
 
#if defined(PSP)
 
static void AudioOutCallback(void *buf, unsigned int _reqn, void *userdata)
 
{
 
	memset(buf, 0, _reqn * PSP_NUM_AUDIO_CHANNELS);
 
	if (_midi.status == MIDI_PLAYING) {
 
		mid_song_read_wave(_midi.song, buf, _reqn * PSP_NUM_AUDIO_CHANNELS);
 
	}
 
}
 
#endif /* PSP */
 

	
 
/** Factory for the libtimidity driver. */
 
static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity;
 

	
 
const char *MusicDriver_LibTimidity::Start(const char * const *param)
 
{
 
	_midi.status = MIDI_STOPPED;
 
	_midi.song = NULL;
src/music/libtimidity.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#ifndef MUSIC_LIBTIMIDITY_H
 
#define MUSIC_LIBTIMIDITY_H
 

	
 
#include "music_driver.hpp"
 

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

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying();
 

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

	
 
/** Factory for the libtimidity driver. */
 
class FMusicDriver_LibTimidity: public MusicDriverFactory<FMusicDriver_LibTimidity> {
 
public:
 
	static const int priority = 5;
 
	/* virtual */ const char *GetName() { return "libtimidity"; }
 
	/* virtual */ const char *GetDescription() { return "LibTimidity MIDI Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new MusicDriver_LibTimidity(); }
src/music/music_driver.hpp
Show inline comments
 
@@ -11,26 +11,47 @@
 

	
 
#ifndef MUSIC_MUSIC_DRIVER_HPP
 
#define MUSIC_MUSIC_DRIVER_HPP
 

	
 
#include "../driver.h"
 

	
 
/** Driver for all music playback. */
 
class MusicDriver: public Driver {
 
public:
 
	/**
 
	 * Play a particular song.
 
	 * @param filename The name of file with the song to play.
 
	 */
 
	virtual void PlaySong(const char *filename) = 0;
 

	
 
	/**
 
	 * Stop playing the current song.
 
	 */
 
	virtual void StopSong() = 0;
 

	
 
	/**
 
	 * Are we currently playing a song?
 
	 * @return True if a song is being played.
 
	 */
 
	virtual bool IsSongPlaying() = 0;
 

	
 
	/**
 
	 * Set the volume, if possible.
 
	 * @param vol The new volume.
 
	 */
 
	virtual void SetVolume(byte vol) = 0;
 
};
 

	
 
/** Base of the factory for the music drivers. */
 
class MusicDriverFactoryBase: public DriverFactoryBase {
 
};
 

	
 
/**
 
 * Factory for the music drivers.
 
 * @tparam T The type of the music factory to register.
 
 */
 
template <class T>
 
class MusicDriverFactory: public MusicDriverFactoryBase {
 
public:
 
	MusicDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_MUSIC, ((T *)this)->priority); }
 

	
 
	/**
src/music/null_m.cpp
Show inline comments
 
@@ -9,8 +9,8 @@
 

	
 
/** @file null_m.cpp The music playback that is silent. */
 

	
 
#include "../stdafx.h"
 
#include "null_m.h"
 

	
 
/** The factory for the music player that does nothing. */
 
static FMusicDriver_Null iFMusicDriver_Null;
 

	
src/music/null_m.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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; }
 

	
 
	/* virtual */ void Stop() { }
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying() { return true; }
 

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

	
 
/** Factory for the null music player. */
 
class FMusicDriver_Null: public MusicDriverFactory<FMusicDriver_Null> {
 
public:
 
	static const int priority = 1;
 
	/* virtual */ const char *GetName() { return "null"; }
 
	/* virtual */ const char *GetDescription() { return "Null Music Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new MusicDriver_Null(); }
src/music/os2_m.cpp
Show inline comments
 
@@ -26,22 +26,28 @@
 
 **********************/
 

	
 
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
 
 * eh? Anyone would think they both came from the same place originally! ;)
 
 */
 

	
 
/**
 
 * Send a midi command.
 
 * @param cmd The command to send.
 
 * @return The result of sending it.
 
 */
 
static long CDECL MidiSendCommand(const char *cmd, ...)
 
{
 
	va_list va;
 
	char buf[512];
 
	va_start(va, cmd);
 
	vseprintf(buf, lastof(buf), cmd, va);
 
	va_end(va);
 
	return mciSendString(buf, NULL, 0, NULL, 0);
 
}
 

	
 
/** OS/2's music player's factory. */
 
static FMusicDriver_OS2 iFMusicDriver_OS2;
 

	
 
void MusicDriver_OS2::PlaySong(const char *filename)
 
{
 
	MidiSendCommand("close all");
 

	
src/music/os2_m.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying();
 

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

	
 
/** Factory for OS/2's music player. */
 
class FMusicDriver_OS2: public MusicDriverFactory<FMusicDriver_OS2> {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "os2"; }
 
	/* virtual */ const char *GetDescription() { return "OS/2 Music Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new MusicDriver_OS2(); }
src/music/win32_m.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool IsSongPlaying();
 

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

	
 
/** Factory for Windows' music player. */
 
class FMusicDriver_Win32: public MusicDriverFactory<FMusicDriver_Win32> {
 
public:
 
	static const int priority = 5;
 
	/* virtual */ const char *GetName() { return "win32"; }
 
	/* virtual */ const char *GetDescription() { return "Win32 Music Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new MusicDriver_Win32(); }
src/network/network_command.cpp
Show inline comments
 
@@ -272,12 +272,13 @@ static void DistributeQueue(CommandQueue
 
		DistributeCommandPacket(*cp, owner);
 
		NetworkAdminCmdLogging(owner, cp);
 
		free(cp);
 
	}
 
}
 

	
 
/** Distribute the commands of ourself and the clients. */
 
void NetworkDistributeCommands()
 
{
 
	/* First send the server's commands. */
 
	DistributeQueue(&_local_wait_queue, NULL);
 

	
 
	/* Then send the queues of the others. */
src/network/network_gamelist.cpp
Show inline comments
 
@@ -22,13 +22,15 @@
 
#include "network_udp.h"
 
#include "network_gamelist.h"
 
#include "../newgrf_text.h"
 

	
 
NetworkGameList *_network_game_list = NULL;
 

	
 
/** Mutex for handling delayed insertion/querying of servers. */
 
static ThreadMutex *_network_game_list_mutex = ThreadMutex::New();
 
/** The games to insert when the GUI thread has time for us. */
 
static NetworkGameList *_network_game_delayed_insertion_list = NULL;
 

	
 
/**
 
 * Add a new item to the linked gamelist, but do it delayed in the next tick
 
 * or so to prevent race conditions.
 
 * @param item the item to add. Will be freed once added.
 
@@ -69,13 +71,12 @@ static void NetworkGameListHandleDelayed
 
}
 

	
 
/**
 
 * Add a new item to the linked gamelist. If the IP and Port match
 
 * return the existing item instead of adding it again
 
 * @param address the address of the to-be added item
 
 * @param port the port the server is running on
 
 * @return a point to the newly added or already existing item
 
 */
 
NetworkGameList *NetworkGameListAddItem(NetworkAddress address)
 
{
 
	const char *hostname = address.GetHostname();
 

	
src/network/network_type.h
Show inline comments
 
@@ -69,17 +69,19 @@ struct NetworkCompanyState {
 
	char password[NETWORK_PASSWORD_LENGTH];         ///< The password for the company
 
	uint16 months_empty;                            ///< How many months the company is empty
 
};
 

	
 
struct NetworkClientInfo;
 

	
 
/** The type of password we're asking for. */
 
enum NetworkPasswordType {
 
	NETWORK_GAME_PASSWORD,
 
	NETWORK_COMPANY_PASSWORD,
 
	NETWORK_GAME_PASSWORD,    ///< The password of the game.
 
	NETWORK_COMPANY_PASSWORD, ///< The password of the company.
 
};
 

	
 
/** Destination of our chat messages. */
 
enum DestType {
 
	DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
 
	DESTTYPE_TEAM,      ///< Send message/notice to everyone playing the same company (Team)
 
	DESTTYPE_CLIENT,    ///< Send message/notice to only a certain client (Private)
 
};
 

	
 
@@ -95,12 +97,13 @@ enum NetworkAction {
 
	NETWORK_ACTION_NAME_CHANGE,
 
	NETWORK_ACTION_COMPANY_SPECTATOR,
 
	NETWORK_ACTION_COMPANY_JOIN,
 
	NETWORK_ACTION_COMPANY_NEW,
 
};
 

	
 
/** The error codes we send around in the protocols. */
 
enum NetworkErrorCode {
 
	NETWORK_ERROR_GENERAL, // Try to use this one like never
 

	
 
	/* Signals from clients */
 
	NETWORK_ERROR_DESYNC,
 
	NETWORK_ERROR_SAVEGAME_FAILED,
src/newgrf_airport.cpp
Show inline comments
 
@@ -235,12 +235,19 @@ uint16 GetAirportCallback(CallbackID cal
 
	const SpriteGroup *group = SpriteGroup::Resolve(st->airport.GetSpec()->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
}
 

	
 
/**
 
 * Get a custom text for the airport.
 
 * @param as The airport type's specification.
 
 * @param layout The layout index.
 
 * @param callback The callback to call.
 
 * @return The custom text.
 
 */
 
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
 
{
 
	const SpriteGroup *group;
 
	ResolverObject object;
 

	
 
	NewAirportResolver(&object, INVALID_TILE, NULL, as->GetIndex(), layout);
src/newgrf_airport.h
Show inline comments
 
@@ -16,13 +16,13 @@
 
#include "date_type.h"
 
#include "map_type.h"
 
#include "newgrf_class.h"
 
#include "newgrf_commons.h"
 
#include "gfx_type.h"
 

	
 
/* Copy from station_map.h */
 
/** Copy from station_map.h */
 
typedef byte StationGfx;
 

	
 
/** Tile-offset / AirportTileID pair. */
 
struct AirportTileTable {
 
	TileIndexDiffC ti; ///< Tile offset from  the top-most airport tile.
 
	StationGfx gfx;    ///< AirportTile to use for this tile.
 
@@ -90,16 +90,16 @@ struct AirportSpec {
 
	byte GetIndex() const
 
	{
 
		assert(this >= specs && this < endof(specs));
 
		return (byte)(this - specs);
 
	}
 

	
 
	static AirportSpec dummy;
 
	static AirportSpec dummy; ///< The dummy airport.
 

	
 
private:
 
	static AirportSpec specs[NUM_AIRPORTS];
 
	static AirportSpec specs[NUM_AIRPORTS]; ///< Specs of the airports.
 
};
 

	
 
/** Information related to airport classes. */
 
typedef NewGRFClass<AirportSpec, AirportClassID, APC_MAX> AirportClass;
 

	
 
void BindAirportSpecs();
src/newgrf_class_func.h
Show inline comments
 
@@ -10,12 +10,16 @@
 
/** @file newgrf_class_func.h Implementation of the NewGRF class' functions. */
 

	
 
#include "newgrf_class.h"
 

	
 
#include "table/strings.h"
 

	
 
/**
 
 * Helper for defining the class method's signatures.
 
 * @param type The type of the class.
 
 */
 
#define DEFINE_NEWGRF_CLASS_METHOD(type) \
 
	template <typename Tspec, typename Tid, Tid Tmax> \
 
	type NewGRFClass<Tspec, Tid, Tmax>
 

	
 
/** Instantiate the array. */
 
template <typename Tspec, typename Tid, Tid Tmax>
src/newgrf_commons.cpp
Show inline comments
 
@@ -320,13 +320,13 @@ void ObjectOverrideManager::SetEntitySpe
 
}
 

	
 
/**
 
 * Function used by houses (and soon industries) to get information
 
 * on type of "terrain" the tile it is queries sits on.
 
 * @param tile TileIndex of the tile been queried
 
 * @param upper_halftile If true, query upper halftile in case of rail tiles.
 
 * @param context The context of the tile.
 
 * @return value corresponding to the grf expected format:
 
 *         Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline
 
 */
 
uint32 GetTerrainType(TileIndex tile, TileContext context)
 
{
 
	switch (_settings_game.game_creation.landscape) {
 
@@ -391,12 +391,19 @@ uint32 GetTerrainType(TileIndex tile, Ti
 
			return has_snow ? 4 : 0;
 
		}
 
		default:        return 0;
 
	}
 
}
 

	
 
/**
 
 * Get the tile at the given offset.
 
 * @param parameter The NewGRF "encoded" offset.
 
 * @param tile The tile to base the offset from.
 
 * @param signed_offsets Whether the offsets are to be interpreted as signed or not.
 
 * @return The tile at the offset.
 
 */
 
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets)
 
{
 
	int8 x = GB(parameter, 0, 4);
 
	int8 y = GB(parameter, 4, 4);
 

	
 
	if (signed_offsets && x >= 8) x -= 16;
src/newgrf_config.cpp
Show inline comments
 
@@ -664,14 +664,14 @@ const GRFConfig *FindGRFConfig(uint32 gr
 
}
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
/** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */
 
struct UnknownGRF : public GRFIdentifier {
 
	UnknownGRF *next;
 
	GRFTextWrapper *name;
 
	UnknownGRF *next;     ///< The next unknown GRF.
 
	GRFTextWrapper *name; ///< Name of the GRF.
 
};
 

	
 
/**
 
 * Finds the name of a NewGRF in the list of names for unknown GRFs. An
 
 * unknown GRF is a GRF where the .grf is not found during scanning.
 
 *
src/newgrf_config.h
Show inline comments
 
@@ -202,12 +202,12 @@ bool FillGRFDetails(GRFConfig *config, b
 
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
 

	
 
/* In newgrf_gui.cpp */
 
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
 

	
 
#ifdef ENABLE_NETWORK
 
/* For communication about GRFs over the network */
 
/** For communication about GRFs over the network */
 
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
 
GRFTextWrapper *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NEWGRF_CONFIG_H */
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -32,12 +32,13 @@
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_station.h"
 
#include "newgrf_town.h"
 

	
 
#include "table/strings.h"
 

	
 
/** The sprite picker. */
 
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector<SpriteID, 256>() };
 

	
 
/**
 
 * Get the feature index related to the window number.
 
 * @param window_number The window to get the feature index from.
 
 * @return the feature index
src/newgrf_generic.cpp
Show inline comments
 
@@ -43,15 +43,15 @@ void ResetGenericCallbacks()
 
	}
 
}
 

	
 

	
 
/**
 
 * Add a generic feature callback sprite group to the appropriate feature list.
 
 * @param feature
 
 * @param file
 
 * @param group
 
 * @param feature The feature for the callback.
 
 * @param file The GRF of the callback.
 
 * @param group The sprite group of the callback.
 
 */
 
void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group)
 
{
 
	if (feature >= lengthof(_gcl)) {
 
		grfmsg(5, "AddGenericCallback: Unsupported feature 0x%02X", feature);
 
		return;
src/newgrf_generic.h
Show inline comments
 
@@ -11,23 +11,27 @@
 

	
 
#ifndef NEWGRF_GENERIC_H
 
#define NEWGRF_GENERIC_H
 

	
 
#include "cargo_type.h"
 
#include "industry_type.h"
 
#include "newgrf.h"
 

	
 
struct SpriteGroup;
 

	
 
/** AI events for asking the NewGRF for information. */
 
enum AIConstructionEvent {
 
	AICE_TRAIN_CHECK_RAIL_ENGINE     = 0x00, ///< Check if we should build an engine
 
	AICE_TRAIN_CHECK_ELRAIL_ENGINE   = 0x01,
 
	AICE_TRAIN_CHECK_MONORAIL_ENGINE = 0x02,
 
	AICE_TRAIN_CHECK_MAGLEV_ENGINE   = 0x03,
 
	AICE_TRAIN_GET_RAIL_WAGON        = 0x08,
 
	AICE_TRAIN_GET_ELRAIL_WAGON      = 0x09,
 
	AICE_TRAIN_GET_MONORAIL_WAGON    = 0x0A,
 
	AICE_TRAIN_GET_MAGLEV_WAGON      = 0x0B,
 
	AICE_TRAIN_GET_RAILTYPE          = 0x0F,
 
	AICE_TRAIN_CHECK_ELRAIL_ENGINE   = 0x01, ///< Check if we should build an engine
 
	AICE_TRAIN_CHECK_MONORAIL_ENGINE = 0x02, ///< Check if we should build an engine
 
	AICE_TRAIN_CHECK_MAGLEV_ENGINE   = 0x03, ///< Check if we should build an engine
 
	AICE_TRAIN_GET_RAIL_WAGON        = 0x08, ///< Check if we should build an engine
 
	AICE_TRAIN_GET_ELRAIL_WAGON      = 0x09, ///< Check if we should build an engine
 
	AICE_TRAIN_GET_MONORAIL_WAGON    = 0x0A, ///< Check if we should build an engine
 
	AICE_TRAIN_GET_MAGLEV_WAGON      = 0x0B, ///< Check if we should build an engine
 
	AICE_TRAIN_GET_RAILTYPE          = 0x0F, ///< Check if we should build a railtype
 

	
 
	AICE_ROAD_CHECK_ENGINE           = 0x00, ///< Check if we should build an engine
 
	AICE_ROAD_GET_FIRST_ENGINE       = 0x01, ///< Unused, we check all
 
	AICE_ROAD_GET_NUMBER_ENGINES     = 0x02, ///< Unused, we check all
 

	
 
	AICE_SHIP_CHECK_ENGINE           = 0x00, ///< Check if we should build an engine
 
@@ -40,11 +44,11 @@ enum AIConstructionEvent {
 
};
 

	
 
static const IndustryType IT_AI_UNKNOWN = 0xFE; ///< The AI has no specific industry in mind.
 
static const IndustryType IT_AI_TOWN    = 0xFF; ///< The AI actually wants to transport to/from a town, not an industry.
 

	
 
void ResetGenericCallbacks();
 
void AddGenericCallback(uint8 feature, const struct GRFFile *file, const struct SpriteGroup *group);
 
void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group);
 

	
 
uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const struct GRFFile **file);
 
uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file);
 

	
 
#endif /* NEWGRF_GENERIC_H */
src/newgrf_industries.cpp
Show inline comments
 
@@ -32,12 +32,18 @@ static uint32 _industry_creation_random_
 
/* Since the industry IDs defined by the GRF file don't necessarily correlate
 
 * to those used by the game, the IDs used for overriding old industries must be
 
 * translated when the idustry spec is set. */
 
IndustryOverrideManager _industry_mngr(NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES, INVALID_INDUSTRYTYPE);
 
IndustryTileOverrideManager _industile_mngr(NEW_INDUSTRYTILEOFFSET, NUM_INDUSTRYTILES, INVALID_INDUSTRYTILE);
 

	
 
/**
 
 * Map the GRF local type to an industry type.
 
 * @param grf_type The GRF local type.
 
 * @param grf_id The GRF of the local type.
 
 * @return The industry type in the global scope.
 
 */
 
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id)
 
{
 
	if (grf_type == IT_INVALID) return IT_INVALID;
 
	if (!HasBit(grf_type, 7)) return GB(grf_type, 0, 6);
 

	
 
	return _industry_mngr.GetID(GB(grf_type, 0, 6), grf_id);
 
@@ -383,12 +389,22 @@ static void NewIndustryResolver(Resolver
 
	res->count           = 0;
 

	
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 
	res->grffile         = (indspec != NULL ? indspec->grf_prop.grffile : NULL);
 
}
 

	
 
/**
 
 * Perform an industry callback.
 
 * @param callback The callback to perform.
 
 * @param param1 The first parameter.
 
 * @param param2 The second parameter.
 
 * @param industry The industry to do the callback for.
 
 * @param type The type of industry to do the callback for.
 
 * @param tile The tile associated with the callback.
 
 * @return The callback result.
 
 */
 
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile)
 
{
 
	ResolverObject object;
 
	const SpriteGroup *group;
 

	
 
	NewIndustryResolver(&object, tile, industry, type);
src/newgrf_railtype.cpp
Show inline comments
 
@@ -84,12 +84,20 @@ static inline void NewRailTypeResolver(R
 
	res->last_value      = 0;
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 
}
 

	
 
/**
 
 * Get the sprite to draw for the given tile.
 
 * @param rti The rail type data (spec).
 
 * @param tile The tile to get the sprite for.
 
 * @param rtsg The type of sprite to draw.
 
 * @param content Where are we drawing the tile?
 
 * @return The sprite to draw.
 
 */
 
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context)
 
{
 
	assert(rtsg < RTSG_END);
 

	
 
	if (rti->group[rtsg] == NULL) return 0;
 

	
 
@@ -101,12 +109,18 @@ SpriteID GetCustomRailSprite(const Railt
 
	group = SpriteGroup::Resolve(rti->group[rtsg], &object);
 
	if (group == NULL || group->GetNumResults() == 0) return 0;
 

	
 
	return group->GetResult();
 
}
 

	
 
/**
 
 * Perform a reverse railtype lookup to get the GRF internal ID.
 
 * @param railtype The global (OpenTTD) railtype.
 
 * @param grffile The GRF to do the lookup for.
 
 * @return the GRF internal ID.
 
 */
 
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
 
{
 
	/* No rail type table present, return rail type as-is */
 
	if (grffile == NULL || grffile->railtype_max == 0) return railtype;
 

	
 
	/* Look for a matching rail type label in the table */
src/news_gui.cpp
Show inline comments
 
@@ -1389,11 +1389,14 @@ static const WindowDesc _message_options
 
	WDP_AUTO, 0, 0,
 
	WC_GAME_OPTIONS, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_message_options_widgets, lengthof(_nested_message_options_widgets)
 
);
 

	
 
/**
 
 * Show the settings window for news messages.
 
 */
 
void ShowMessageOptions()
 
{
 
	DeleteWindowById(WC_GAME_OPTIONS, 0);
 
	new MessageOptionsWindow(&_message_options_desc);
 
}
src/news_type.h
Show inline comments
 
@@ -116,22 +116,30 @@ struct NewsTypeData {
 
	const char * const name;    ///< Name
 
	const byte age;             ///< Maximum age of news items (in days)
 
	const SoundFx sound;        ///< Sound
 
	NewsDisplay display;        ///< Display mode (off, summary, full)
 
	const StringID description; ///< Description of the news type in news settings window
 

	
 
	/**
 
	 * Construct this entry.
 
	 * @param name The name of the type.
 
	 * @param age The maximum age for these messages.
 
	 * @param sound The sound to play.
 
	 * @param description The description for this type of messages.
 
	 */
 
	NewsTypeData(const char *name, byte age, SoundFx sound, StringID description) :
 
		name(name),
 
		age(age),
 
		sound(sound),
 
		display(ND_FULL),
 
		description(description)
 
	{
 
	}
 
};
 

	
 
/** Information about a single item of news. */
 
struct NewsItem {
 
	NewsItem *prev;              ///< Previous news item
 
	NewsItem *next;              ///< Next news item
 
	StringID string_id;          ///< Message text
 
	Date date;                   ///< Date of the news
 
	NewsSubtype subtype;         ///< News subtype @see NewsSubtype
 
@@ -146,13 +154,13 @@ struct NewsItem {
 

	
 
	~NewsItem()
 
	{
 
		free(this->free_data);
 
	}
 

	
 
	uint64 params[10];
 
	uint64 params[10]; ///< Parameters for string resolving.
 
};
 

	
 
/**
 
 * Data that needs to be stored for company news messages.
 
 * The problem with company news messages are the custom name
 
 * of the companies and the fact that the company data is reset,
src/order_backup.cpp
Show inline comments
 
@@ -183,13 +183,13 @@ CommandCost CmdClearOrderBackup(TileInde
 
		return;
 
	}
 
}
 

	
 
/**
 
 * Reset the OrderBackups from GUI/game logic.
 
 * @param tile     The tile of the order backup.
 
 * @param t        The tile of the order backup.
 
 * @param from_gui Whether the call came from the GUI, i.e. whether
 
 *                 it must be synced over the network.
 
 */
 
/* static */ void OrderBackup::Reset(TileIndex t, bool from_gui)
 
{
 
	/* The user has CLIENT_ID_SERVER as default when network play is not active,
src/order_backup.h
Show inline comments
 
@@ -66,10 +66,20 @@ public:
 
	static void Reset(TileIndex tile = INVALID_TILE, bool from_gui = true);
 

	
 
	static void ClearGroup(GroupID group);
 
	static void ClearVehicle(const Vehicle *v);
 
};
 

	
 
/**
 
 * Iterator over all order backups from a given ID.
 
 * @param var The variable to iterate with.
 
 * @param start The start of the iteration.
 
 */
 
#define FOR_ALL_ORDER_BACKUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderBackup, order_backup_index, var, start)
 

	
 
/**
 
 * Iterator over all order backups.
 
 * @param var The variable to iterate with.
 
 */
 
#define FOR_ALL_ORDER_BACKUPS(var) FOR_ALL_ORDER_BACKUPS_FROM(var, 0)
 

	
 
#endif /* ORDER_BACKUP_H */
src/pathfinder/pf_performance_timer.hpp
Show inline comments
 
@@ -9,13 +9,13 @@
 

	
 
/** @file pf_performance_timer.hpp Performance timer for pathfinders. */
 

	
 
#ifndef PF_PERFORMANCE_TIMER_HPP
 
#define PF_PERFORMANCE_TIMER_HPP
 

	
 
extern uint64 ottd_rdtsc();
 
#include "../debug.h"
 

	
 
struct CPerformanceTimer
 
{
 
	int64    m_start;
 
	int64    m_acc;
 

	
src/pathfinder/yapf/nodelist.hpp
Show inline comments
 
@@ -148,15 +148,18 @@ public:
 
	FORCEINLINE Titem_ *FindClosedNode(const Key& key)
 
	{
 
		Titem_ *item = m_closed.Find(key);
 
		return item;
 
	}
 

	
 
	/** The number of items. */
 
	FORCEINLINE int TotalCount() {return m_arr.Length();}
 
	/** Get a particular item. */
 
	FORCEINLINE Titem_& ItemAt(int idx) {return m_arr[idx];}
 

	
 
	/** Helper for creating output of this array. */
 
	template <class D> void Dump(D &dmp) const
 
	{
 
		dmp.WriteStructT("m_arr", &m_arr);
 
	}
 
};
 

	
src/pathfinder/yapf/yapf.h
Show inline comments
 
@@ -62,13 +62,13 @@ Track YapfTrainChooseTrack(const Train *
 
 */
 
FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penalty);
 

	
 
/**
 
 * Used when user sends train to the nearest depot or if train needs servicing using YAPF.
 
 * @param v            train that needs to go to some depot
 
 * @param max_penalty  max distance (int pathfinder penalty) from the current train position
 
 * @param max_distance max distance (int pathfinder penalty) from the current train position
 
 *                     (used also as optimization - the pathfinder can stop path finding if max_penalty
 
 *                     was reached and no depot was seen)
 
 * @return             the data about the depot
 
 */
 
FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_distance);
 

	
src/pathfinder/yapf/yapf_costbase.hpp
Show inline comments
 
@@ -9,13 +9,20 @@
 

	
 
/** @file yapf_costbase.hpp Handling of cost determination. */
 

	
 
#ifndef YAPF_COSTBASE_HPP
 
#define YAPF_COSTBASE_HPP
 

	
 
/** Base implementation for cost accounting. */
 
struct CYapfCostBase {
 
	/**
 
	 * Does the given track direction on the given tile yeild an uphill penalty?
 
	 * @param tile The tile to check.
 
	 * @param td   The track direction to check.
 
	 * @return True if there's a slope, otherwise false.
 
	 */
 
	FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
 
	{
 
		if (IsDiagonalTrackdir(td)) {
 
			if (IsBridgeTile(tile)) {
 
				/* it is bridge ramp, check if we are entering the bridge */
 
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are leaving it, no penalty
 
@@ -31,12 +38,7 @@ struct CYapfCostBase {
 
			}
 
		}
 
		return false;
 
	}
 
};
 

	
 
struct CostRailSettings {
 
	/* look-ahead signal penalty */
 
};
 

	
 

	
 
#endif /* YAPF_COSTBASE_HPP */
src/pathfinder/yapf/yapf_costrail.hpp
Show inline comments
 
@@ -14,13 +14,12 @@
 

	
 
#include "../../pbs.h"
 

	
 
template <class Types>
 
class CYapfCostRailT
 
	: public CYapfCostBase
 
	, public CostRailSettings
 
{
 
public:
 
	typedef typename Types::Tpf Tpf;              ///< the pathfinder class (derived from THIS class)
 
	typedef typename Types::TrackFollower TrackFollower;
 
	typedef typename Types::NodeList::Titem Node; ///< this will be our node type
 
	typedef typename Node::Key Key;               ///< key to hash tables
src/pbs.h
Show inline comments
 
@@ -27,13 +27,23 @@ void UnreserveRailTrack(TileIndex tile, 
 
/** This struct contains information about the end of a reserved path. */
 
struct PBSTileInfo {
 
	TileIndex tile;      ///< Tile the path ends, INVALID_TILE if no valid path was found.
 
	Trackdir  trackdir;  ///< The reserved trackdir on the tile.
 
	bool      okay;      ///< True if tile is a safe waiting position, false otherwise.
 

	
 
	/**
 
	 * Create an empty PBSTileInfo.
 
	 */
 
	PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {}
 

	
 
	/**
 
	 * Create a PBSTileInfo with given tile, track direction and safe waiting position information.
 
	 * @param _t The tile where the path ends.
 
	 * @param _td The reserved track dir on the tile.
 
	 * @param _okay Whether the tile is a safe waiting point or not.
 
	 */
 
	PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {}
 
};
 

	
 
PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res = NULL);
 
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false);
 
bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false);
src/sound/allegro_s.h
Show inline comments
 
@@ -11,22 +11,24 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

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

	
 
/** Factory for the allegro sound driver. */
 
class FSoundDriver_Allegro: public SoundDriverFactory<FSoundDriver_Allegro> {
 
public:
 
	static const int priority = 4;
 
	/* virtual */ const char *GetName() { return "allegro"; }
 
	/* virtual */ const char *GetDescription() { return "Allegro Sound Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new SoundDriver_Allegro(); }
src/sound/null_s.h
Show inline comments
 
@@ -11,20 +11,22 @@
 

	
 
#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; }
 

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

	
 
/** Factory for the null sound driver. */
 
class FSoundDriver_Null: public SoundDriverFactory<FSoundDriver_Null> {
 
public:
 
	static const int priority = 1;
 
	/* virtual */ const char *GetName() { return "null"; }
 
	/* virtual */ const char *GetDescription() { return "Null Sound Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new SoundDriver_Null(); }
src/sound/sdl_s.h
Show inline comments
 
@@ -11,20 +11,22 @@
 

	
 
#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);
 

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

	
 
/** Factory for the SDL sound driver. */
 
class FSoundDriver_SDL: public SoundDriverFactory<FSoundDriver_SDL> {
 
public:
 
	static const int priority = 5;
 
	/* virtual */ const char *GetName() { return "sdl"; }
 
	/* virtual */ const char *GetDescription() { return "SDL Sound Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new SoundDriver_SDL(); }
src/sound/sound_driver.hpp
Show inline comments
 
@@ -11,21 +11,27 @@
 

	
 
#ifndef SOUND_SOUND_DRIVER_HPP
 
#define SOUND_SOUND_DRIVER_HPP
 

	
 
#include "../driver.h"
 

	
 
/** Base for all sound drivers. */
 
class SoundDriver: public Driver {
 
public:
 
	/* Called once every tick */
 
	/** Called once every tick */
 
	virtual void MainLoop() {}
 
};
 

	
 
/** Base of the factory for the sound drivers. */
 
class SoundDriverFactoryBase: public DriverFactoryBase {
 
};
 

	
 
/**
 
 * Factory for the sound drivers.
 
 * @tparam T The type of the sound factory to register.
 
 */
 
template <class T>
 
class SoundDriverFactory: public SoundDriverFactoryBase {
 
public:
 
	SoundDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_SOUND, ((T *)this)->priority); }
 

	
 
	/**
src/sound/win32_s.h
Show inline comments
 
@@ -11,20 +11,22 @@
 

	
 
#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);
 

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

	
 
/** Factory for the sound driver for Windows. */
 
class FSoundDriver_Win32: public SoundDriverFactory<FSoundDriver_Win32> {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "win32"; }
 
	/* virtual */ const char *GetDescription() { return "Win32 WaveOut Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new SoundDriver_Win32(); }
src/video/allegro_v.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool ChangeResolution(int w, int h);
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "allegro"; }
 
};
 

	
 
/** Factory for the allegro video driver. */
 
class FVideoDriver_Allegro: public VideoDriverFactory<FVideoDriver_Allegro> {
 
public:
 
	static const int priority = 4;
 
	/* virtual */ const char *GetName() { return "allegro"; }
 
	/* virtual */ const char *GetDescription() { return "Allegro Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Allegro(); }
src/video/dedicated_v.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool ChangeResolution(int w, int h);
 

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

	
 
/** Factory for the dedicated server video driver. */
 
class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
 
public:
 
#ifdef DEDICATED
 
	/* Automatically select this dedicated driver when making a dedicated
 
	 * server build. */
 
	static const int priority = 10;
src/video/null_v.h
Show inline comments
 
@@ -11,15 +11,16 @@
 

	
 
#ifndef VIDEO_NULL_H
 
#define VIDEO_NULL_H
 

	
 
#include "video_driver.hpp"
 

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

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

	
 
	/* virtual */ void Stop();
 

	
 
@@ -30,12 +31,13 @@ public:
 
	/* virtual */ bool ChangeResolution(int w, int h);
 

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

	
 
/** Factory the null video driver. */
 
class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
 
public:
 
	static const int priority = 0;
 
	/* virtual */ const char *GetName() { return "null"; }
 
	/* virtual */ const char *GetDescription() { return "Null Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Null(); }
src/video/sdl_v.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -27,12 +28,13 @@ public:
 
	/* virtual */ bool ChangeResolution(int w, int h);
 

	
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "sdl"; }
 
};
 

	
 
/** Factory for the SDL video driver. */
 
class FVideoDriver_SDL: public VideoDriverFactory<FVideoDriver_SDL> {
 
public:
 
	static const int priority = 5;
 
	/* virtual */ const char *GetName() { return "sdl"; }
 
	/* virtual */ const char *GetDescription() { return "SDL Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_SDL(); }
src/video/video_driver.hpp
Show inline comments
 
@@ -12,26 +12,53 @@
 
#ifndef VIDEO_VIDEO_DRIVER_HPP
 
#define VIDEO_VIDEO_DRIVER_HPP
 

	
 
#include "../driver.h"
 
#include "../core/geometry_type.hpp"
 

	
 
/** The base of all video drivers. */
 
class VideoDriver: public Driver {
 
public:
 
	/**
 
	 * Mark a particular area dirty.
 
	 * @param left   The left most line of the dirty area.
 
	 * @param top    The top most line of the dirty area.
 
	 * @param width  The width of the dirty area.
 
	 * @param height The height of the dirty area.
 
	 */
 
	virtual void MakeDirty(int left, int top, int width, int height) = 0;
 

	
 
	/**
 
	 * Perform the actual drawing.
 
	 */
 
	virtual void MainLoop() = 0;
 

	
 
	/**
 
	 * Change the resolution of the window.
 
	 * @param w The new width.
 
	 * @param h The new height.
 
	 * @return True if the change succeeded.
 
	 */
 
	virtual bool ChangeResolution(int w, int h) = 0;
 

	
 
	/**
 
	 * Change the full screen setting.
 
	 * @param fullscreen The new setting.
 
	 * @return True if the change succeeded.
 
	 */
 
	virtual bool ToggleFullscreen(bool fullscreen) = 0;
 
};
 

	
 
/** Base of the factory for the video drivers. */
 
class VideoDriverFactoryBase: public DriverFactoryBase {
 
};
 

	
 
/**
 
 * Factory for the video drivers.
 
 * @tparam T The type of the video factory to register.
 
 */
 
template <class T>
 
class VideoDriverFactory: public VideoDriverFactoryBase {
 
public:
 
	VideoDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_VIDEO, ((T *)this)->priority); }
 

	
 
	/**
src/video/win32_v.cpp
Show inline comments
 
@@ -221,12 +221,17 @@ static void CALLBACK TrackMouseTimerProc
 
	if (!PtInRect(&rc, pt) || (WindowFromPoint(pt) != hwnd)) {
 
		KillTimer(hwnd, event);
 
		PostMessage(hwnd, WM_MOUSELEAVE, 0, 0L);
 
	}
 
}
 

	
 
/**
 
 * Instantiate a new window.
 
 * @param full_screen Whether to make a full screen window or not.
 
 * @return True if the window could be created.
 
 */
 
bool VideoDriver_Win32::MakeWindow(bool full_screen)
 
{
 
	_fullscreen = full_screen;
 

	
 
	/* recreate window? */
 
	if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) {
src/video/win32_v.h
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#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);
 

	
 
	/* virtual */ void Stop();
 

	
 
@@ -29,12 +30,13 @@ public:
 
	/* virtual */ bool ToggleFullscreen(bool fullscreen);
 
	/* virtual */ const char *GetName() const { return "win32"; }
 

	
 
	bool MakeWindow(bool full_screen);
 
};
 

	
 
/** The factory for Windows' video driver. */
 
class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {
 
public:
 
	static const int priority = 10;
 
	/* virtual */ const char *GetName() { return "win32"; }
 
	/* virtual */ const char *GetDescription() { return "Win32 GDI Video Driver"; }
 
	/* virtual */ Driver *CreateInstance() { return new VideoDriver_Win32(); }
0 comments (0 inline, 0 general)