mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 02:19:41 +00:00
(svn r22410) -Document: some more bits ;)
This commit is contained in:
parent
e9837ff1ec
commit
4d5dbf5170
@ -61,6 +61,12 @@ 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:
|
||||
@ -83,7 +89,6 @@ const char *GetDebugString();
|
||||
* it with another block.
|
||||
**/
|
||||
#define TIC() {\
|
||||
extern uint64 ottd_rdtsc();\
|
||||
uint64 _xxx_ = ottd_rdtsc();\
|
||||
static uint64 __sum__ = 0;\
|
||||
static uint32 __i__ = 0;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#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"
|
||||
|
||||
@ -24,6 +24,7 @@ static const char * const _music_file_names[] = {
|
||||
"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>
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "music_driver.hpp"
|
||||
|
||||
/** Allegro's music player. */
|
||||
class MusicDriver_Allegro: public MusicDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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)
|
||||
|
@ -16,8 +16,10 @@
|
||||
/* 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)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "music_driver.hpp"
|
||||
|
||||
/** The midi player for BeOS. */
|
||||
class MusicDriver_BeMidi: public MusicDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "music_driver.hpp"
|
||||
|
||||
/** Music player making use of DirectX. */
|
||||
class MusicDriver_DMusic: public MusicDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -26,9 +26,11 @@
|
||||
#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)
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <pspaudiolib.h>
|
||||
#endif /* PSP */
|
||||
|
||||
/** The state of playing. */
|
||||
enum MidiState {
|
||||
MIDI_STOPPED = 0,
|
||||
MIDI_PLAYING = 1,
|
||||
@ -39,7 +40,7 @@ static struct {
|
||||
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)
|
||||
@ -51,6 +52,7 @@ static void AudioOutCallback(void *buf, unsigned int _reqn, void *userdata)
|
||||
}
|
||||
#endif /* PSP */
|
||||
|
||||
/** Factory for the libtimidity driver. */
|
||||
static FMusicDriver_LibTimidity iFMusicDriver_LibTimidity;
|
||||
|
||||
const char *MusicDriver_LibTimidity::Start(const char * const *param)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "music_driver.hpp"
|
||||
|
||||
/** Music driver making use of libtimidity. */
|
||||
class MusicDriver_LibTimidity: public MusicDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,20 +14,41 @@
|
||||
|
||||
#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:
|
||||
|
@ -12,5 +12,5 @@
|
||||
#include "../stdafx.h"
|
||||
#include "null_m.h"
|
||||
|
||||
/** The factory for the music player that does nothing. */
|
||||
static FMusicDriver_Null iFMusicDriver_Null;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#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; }
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -29,6 +29,11 @@
|
||||
* 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;
|
||||
@ -39,6 +44,7 @@ static long CDECL MidiSendCommand(const char *cmd, ...)
|
||||
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)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "music_driver.hpp"
|
||||
|
||||
/** OS/2's music player. */
|
||||
class MusicDriver_OS2: public MusicDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "music_driver.hpp"
|
||||
|
||||
/** The Windows music player. */
|
||||
class MusicDriver_Win32: public MusicDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -275,6 +275,7 @@ static void DistributeQueue(CommandQueue *queue, const NetworkClientSocket *owne
|
||||
}
|
||||
}
|
||||
|
||||
/** Distribute the commands of ourself and the clients. */
|
||||
void NetworkDistributeCommands()
|
||||
{
|
||||
/* First send the server's commands. */
|
||||
|
@ -25,7 +25,9 @@
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -72,7 +74,6 @@ static void NetworkGameListHandleDelayedInsert()
|
||||
* 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)
|
||||
|
@ -72,11 +72,13 @@ struct NetworkCompanyState {
|
||||
|
||||
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)
|
||||
@ -98,6 +100,7 @@ enum NetworkAction {
|
||||
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
|
||||
|
||||
|
@ -238,6 +238,13 @@ uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Sta
|
||||
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;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#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. */
|
||||
@ -93,10 +93,10 @@ struct AirportSpec {
|
||||
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. */
|
||||
|
@ -13,6 +13,10 @@
|
||||
|
||||
#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>
|
||||
|
@ -323,7 +323,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec)
|
||||
* 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
|
||||
*/
|
||||
@ -394,6 +394,13 @@ uint32 GetTerrainType(TileIndex tile, TileContext context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
@ -667,8 +667,8 @@ const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8
|
||||
|
||||
/** 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.
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -205,7 +205,7 @@ char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
|
||||
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 */
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
/** The sprite picker. */
|
||||
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, NULL, 0, SmallVector<SpriteID, 256>() };
|
||||
|
||||
/**
|
||||
|
@ -46,9 +46,9 @@ 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)
|
||||
{
|
||||
|
@ -14,17 +14,21 @@
|
||||
|
||||
#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
|
||||
@ -43,8 +47,8 @@ static const IndustryType IT_AI_UNKNOWN = 0xFE; ///< The AI has no specific indu
|
||||
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 */
|
||||
|
@ -35,6 +35,12 @@ static uint32 _industry_creation_random_bits;
|
||||
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;
|
||||
@ -386,6 +392,16 @@ static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *i
|
||||
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;
|
||||
|
@ -87,6 +87,14 @@ static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, Tile
|
||||
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);
|
||||
@ -104,6 +112,12 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp
|
||||
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 */
|
||||
|
@ -1392,6 +1392,9 @@ static const WindowDesc _message_options_desc(
|
||||
_nested_message_options_widgets, lengthof(_nested_message_options_widgets)
|
||||
);
|
||||
|
||||
/**
|
||||
* Show the settings window for news messages.
|
||||
*/
|
||||
void ShowMessageOptions()
|
||||
{
|
||||
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
||||
|
@ -119,6 +119,13 @@ struct NewsTypeData {
|
||||
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),
|
||||
@ -129,6 +136,7 @@ struct NewsTypeData {
|
||||
}
|
||||
};
|
||||
|
||||
/** Information about a single item of news. */
|
||||
struct NewsItem {
|
||||
NewsItem *prev; ///< Previous news item
|
||||
NewsItem *next; ///< Next news item
|
||||
@ -149,7 +157,7 @@ struct NewsItem {
|
||||
free(this->free_data);
|
||||
}
|
||||
|
||||
uint64 params[10];
|
||||
uint64 params[10]; ///< Parameters for string resolving.
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -186,7 +186,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@ -69,7 +69,17 @@ public:
|
||||
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 */
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef PF_PERFORMANCE_TIMER_HPP
|
||||
#define PF_PERFORMANCE_TIMER_HPP
|
||||
|
||||
extern uint64 ottd_rdtsc();
|
||||
#include "../debug.h"
|
||||
|
||||
struct CPerformanceTimer
|
||||
{
|
||||
|
@ -151,9 +151,12 @@ public:
|
||||
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);
|
||||
|
@ -65,7 +65,7 @@ FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_pena
|
||||
/**
|
||||
* 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
|
||||
|
@ -12,7 +12,14 @@
|
||||
#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)) {
|
||||
@ -34,9 +41,4 @@ struct CYapfCostBase {
|
||||
}
|
||||
};
|
||||
|
||||
struct CostRailSettings {
|
||||
/* look-ahead signal penalty */
|
||||
};
|
||||
|
||||
|
||||
#endif /* YAPF_COSTBASE_HPP */
|
||||
|
@ -17,7 +17,6 @@
|
||||
template <class Types>
|
||||
class CYapfCostRailT
|
||||
: public CYapfCostBase
|
||||
, public CostRailSettings
|
||||
{
|
||||
public:
|
||||
typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class)
|
||||
|
10
src/pbs.h
10
src/pbs.h
@ -30,7 +30,17 @@ struct PBSTileInfo {
|
||||
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) {}
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "sound_driver.hpp"
|
||||
|
||||
/** Implementation of the allegro sound driver. */
|
||||
class SoundDriver_Allegro: public SoundDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -24,6 +25,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#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; }
|
||||
@ -22,6 +23,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "sound_driver.hpp"
|
||||
|
||||
/** Implementation of the SDL sound driver. */
|
||||
class SoundDriver_SDL: public SoundDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -22,6 +23,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,15 +14,21 @@
|
||||
|
||||
#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:
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#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);
|
||||
@ -22,6 +23,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "video_driver.hpp"
|
||||
|
||||
/** The allegro video driver. */
|
||||
class VideoDriver_Allegro: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "video_driver.hpp"
|
||||
|
||||
/** The dedicated server video driver. */
|
||||
class VideoDriver_Dedicated: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* virtual */ const char *GetName() const { return "dedicated"; }
|
||||
};
|
||||
|
||||
/** Factory for the dedicated server video driver. */
|
||||
class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
|
||||
public:
|
||||
#ifdef DEDICATED
|
||||
|
@ -14,9 +14,10 @@
|
||||
|
||||
#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);
|
||||
@ -33,6 +34,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "video_driver.hpp"
|
||||
|
||||
/** The SDL video driver. */
|
||||
class VideoDriver_SDL: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -30,6 +31,7 @@ public:
|
||||
/* 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;
|
||||
|
@ -15,20 +15,47 @@
|
||||
#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:
|
||||
|
@ -224,6 +224,11 @@ static void CALLBACK TrackMouseTimerProc(HWND hwnd, UINT msg, UINT event, DWORD
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "video_driver.hpp"
|
||||
|
||||
/** The video driver for windows. */
|
||||
class VideoDriver_Win32: public VideoDriver {
|
||||
public:
|
||||
/* virtual */ const char *Start(const char * const *param);
|
||||
@ -32,6 +33,7 @@ public:
|
||||
bool MakeWindow(bool full_screen);
|
||||
};
|
||||
|
||||
/** The factory for Windows' video driver. */
|
||||
class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {
|
||||
public:
|
||||
static const int priority = 10;
|
||||
|
Loading…
Reference in New Issue
Block a user