id
int64
0
877k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
66
repo_stars
int64
94
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
11 values
repo_extraction_date
stringclasses
197 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
1,539,433
spritecache.h
EnergeticBark_OpenTTD-3DS/src/spritecache.h
/* $Id$ */ /** @file spritecache.h Functions to cache sprites in memory. */ #ifndef SPRITECACHE_H #define SPRITECACHE_H #include "gfx_type.h" struct Sprite { byte height; uint16 width; int16 x_offs; int16 y_offs; byte data[VARARRAY_SIZE]; }; extern uint _sprite_cache_size; const void *GetRawSprite(SpriteID sprite, SpriteType type); bool SpriteExists(SpriteID sprite); static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type) { assert(type != ST_RECOLOUR); return (Sprite*)GetRawSprite(sprite, type); } static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type) { assert(type == ST_RECOLOUR); return (byte*)GetRawSprite(sprite, type); } void GfxInitSpriteMem(); void IncreaseSpriteLRU(); bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id); void DupSprite(SpriteID old_spr, SpriteID new_spr); #endif /* SPRITECACHE_H */
892
C++
.h
30
28.066667
74
0.777908
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,434
window_type.h
EnergeticBark_OpenTTD-3DS/src/window_type.h
/* $Id$ */ /** @file window_type.h Types related to windows */ #ifndef WINDOW_TYPE_H #define WINDOW_TYPE_H #include "core/enum_type.hpp" /** * Window classes */ enum WindowClass { WC_NONE, WC_MAIN_WINDOW = WC_NONE, WC_MAIN_TOOLBAR, WC_STATUS_BAR, WC_BUILD_TOOLBAR, WC_NEWS_WINDOW, WC_TOWN_DIRECTORY, WC_STATION_LIST, WC_TOWN_VIEW, WC_FOUND_TOWN, WC_SMALLMAP, WC_TRAINS_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_AIRCRAFT_LIST, WC_VEHICLE_VIEW, WC_VEHICLE_DETAILS, WC_VEHICLE_REFIT, WC_VEHICLE_ORDERS, WC_STATION_VIEW, WC_VEHICLE_DEPOT, WC_BUILD_VEHICLE, WC_BUILD_BRIDGE, WC_ERRMSG, WC_BUILD_STATION, WC_BUS_STATION, WC_TRUCK_STATION, WC_BUILD_DEPOT, WC_COMPANY, WC_FINANCES, WC_COMPANY_COLOUR, WC_QUERY_STRING, WC_SAVELOAD, WC_SELECT_GAME, WC_TOOLBAR_MENU, WC_INCOME_GRAPH, WC_OPERATING_PROFIT, WC_TOOLTIPS, WC_INDUSTRY_VIEW, WC_COMPANY_MANAGER_FACE, WC_LAND_INFO, WC_TOWN_AUTHORITY, WC_SUBSIDIES_LIST, WC_GRAPH_LEGEND, WC_DELIVERED_CARGO, WC_PERFORMANCE_HISTORY, WC_COMPANY_VALUE, WC_COMPANY_LEAGUE, WC_BUY_COMPANY, WC_PAYMENT_RATES, WC_ENGINE_PREVIEW, WC_MUSIC_WINDOW, WC_MUSIC_TRACK_SELECTION, WC_SCEN_LAND_GEN, WC_SCEN_INDUSTRY, WC_SCEN_BUILD_TOOLBAR, WC_BUILD_TREES, WC_SEND_NETWORK_MSG, WC_DROPDOWN_MENU, WC_BUILD_INDUSTRY, WC_GAME_OPTIONS, WC_NETWORK_WINDOW, WC_INDUSTRY_DIRECTORY, WC_MESSAGE_HISTORY, WC_CHEATS, WC_PERFORMANCE_DETAIL, WC_CONSOLE, WC_EXTRA_VIEW_PORT, WC_CLIENT_LIST, WC_NETWORK_STATUS_WINDOW, WC_CUSTOM_CURRENCY, WC_REPLACE_VEHICLE, WC_HIGHSCORE, WC_ENDSCREEN, WC_SIGN_LIST, WC_GENERATE_LANDSCAPE, WC_GENERATE_PROGRESS_WINDOW, WC_CONFIRM_POPUP_QUERY, WC_TRANSPARENCY_TOOLBAR, WC_VEHICLE_TIMETABLE, WC_BUILD_SIGNAL, WC_COMPANY_PASSWORD_WINDOW, WC_OSK, WC_WAYPOINT_VIEW, WC_SELECT_STATION, WC_AI_DEBUG, WC_AI_LIST, WC_AI_SETTINGS, WC_INVALID = 0xFFFF }; struct Window; /** Number to differentiate different windows of the same class */ typedef int32 WindowNumber; #endif /* WINDOW_TYPE_H */
2,010
C++
.h
103
17.553398
66
0.767246
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,435
newgrf_house.h
EnergeticBark_OpenTTD-3DS/src/newgrf_house.h
/* $Id$ */ /** @file newgrf_house.h Functions related to NewGRF houses. */ #ifndef NEWGRF_HOUSE_H #define NEWGRF_HOUSE_H #include "town_type.h" #include "newgrf_callbacks.h" #include "tile_cmd.h" /** * Makes class IDs unique to each GRF file. * Houses can be assigned class IDs which are only comparable within the GRF * file they were defined in. This mapping ensures that if two houses have the * same class as defined by the GRF file, the classes are different within the * game. An array of HouseClassMapping structs is created, and the array index * of the struct that matches both the GRF ID and the class ID is the class ID * used in the game. * * Although similar to the HouseIDMapping struct above, this serves a different * purpose. Since the class ID is not saved anywhere, this mapping does not * need to be persistent; it just needs to keep class ids unique. */ struct HouseClassMapping { uint32 grfid; ////< The GRF ID of the file this class belongs to uint8 class_id; ////< The class id within the grf file }; HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid); void InitializeBuildingCounts(); void IncreaseBuildingCount(Town *t, HouseID house_id); void DecreaseBuildingCount(Town *t, HouseID house_id); void DrawNewHouseTile(TileInfo *ti, HouseID house_id); void AnimateNewHouseTile(TileIndex tile); void ChangeHouseAnimationFrame(const struct GRFFile *file, TileIndex tile, uint16 callback_result); uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile); bool CanDeleteHouse(TileIndex tile); bool NewHouseTileLoop(TileIndex tile); enum HouseTrigger { /* The tile of the house has been triggered during the tileloop. */ HOUSE_TRIGGER_TILE_LOOP = 0x01, /* * The top tile of a (multitile) building has been triggered during and all * the tileloop other tiles of the same building get the same random value. */ HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02, }; void TriggerHouse(TileIndex t, HouseTrigger trigger); #endif /* NEWGRF_HOUSE_H */
2,074
C++
.h
45
44.288889
121
0.774417
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,436
tar_type.h
EnergeticBark_OpenTTD-3DS/src/tar_type.h
/* $Id$ */ /** @file tar_type.h Structs, typedefs and macros used for TAR file handling. */ #ifndef TAR_TYPE_H #define TAR_TYPE_H #include <map> #include <string> /** The define of a TarList. */ struct TarListEntry { const char *filename; const char *dirname; /* MSVC goes copying around this struct after initialisation, so it tries * to free filename, which isn't set at that moment... but because it * initializes the variable with garbage, it's going to segfault. */ TarListEntry() : filename(NULL), dirname(NULL) {} ~TarListEntry() { free((void*)this->filename); free((void*)this->dirname); } }; struct TarFileListEntry { const char *tar_filename; size_t size; size_t position; }; typedef std::map<std::string, TarListEntry> TarList; typedef std::map<std::string, TarFileListEntry> TarFileList; extern TarList _tar_list; extern TarFileList _tar_filelist; #define FOR_ALL_TARS(tar) for (tar = _tar_filelist.begin(); tar != _tar_filelist.end(); tar++) typedef bool FioTarFileListCallback(const char *filename, int size, void *userdata); FILE *FioTarFileList(const char *tar, const char *mode, size_t *filesize, FioTarFileListCallback *callback, void *userdata); #endif /* TAR_TYPE_H */
1,211
C++
.h
29
40
124
0.742321
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,437
sprite.h
EnergeticBark_OpenTTD-3DS/src/sprite.h
/* $Id$ */ /** @file sprite.h Base for drawing complex sprites. */ #ifndef SPRITE_H #define SPRITE_H #include "gfx_type.h" #define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START) #define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner])) /** * Whether a sprite comes from the original graphics files or a new grf file * (either supplied by OpenTTD or supplied by the user). * * @param sprite The sprite to check * @return True if it is a new sprite, or false if it is original. */ #define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE) /* The following describes bunch of sprites to be drawn together in a single 3D * bounding box. Used especially for various multi-sprite buildings (like * depots or stations): */ /** A tile child sprite and palette to draw for stations etc, with 3D bounding box */ struct DrawTileSeqStruct { int8 delta_x; ///< \c 0x80 is sequence terminator int8 delta_y; int8 delta_z; byte size_x; byte size_y; byte size_z; PalSpriteID image; }; /** Ground palette sprite of a tile, together with its child sprites */ struct DrawTileSprites { PalSpriteID ground; ///< Palette and sprite for the ground const DrawTileSeqStruct *seq; ///< Array of child sprites. Terminated with a terminator entry }; /** * This structure is the same for both Industries and Houses. * Buildings here reference a general type of construction */ struct DrawBuildingsTileStruct { PalSpriteID ground; PalSpriteID building; byte subtile_x; byte subtile_y; byte width; byte height; byte dz; byte draw_proc; // this allows to specify a special drawing procedure. }; /** Iterate through all DrawTileSeqStructs in DrawTileSprites. */ #define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++) bool SkipSpriteData(byte type, uint16 num); #endif /* SPRITE_H */
1,894
C++
.h
51
35.352941
95
0.747679
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,438
aircraft.h
EnergeticBark_OpenTTD-3DS/src/aircraft.h
/* $Id$ */ /** @file aircraft.h Base for aircraft. */ #ifndef AIRCRAFT_H #define AIRCRAFT_H #include "station_map.h" #include "station_base.h" #include "vehicle_base.h" #include "engine_func.h" #include "engine_base.h" /** An aircraft can be one ot those types */ enum AircraftSubType { AIR_HELICOPTER = 0, ///< an helicopter AIR_AIRCRAFT = 2, ///< an airplane AIR_SHADOW = 4, ///< shadow of the aircraft AIR_ROTOR = 6 ///< rotor of an helicopter }; /** Check if the aircraft type is a normal flying device; eg * not a rotor or a shadow * @param v vehicle to check * @return Returns true if the aircraft is a helicopter/airplane and * false if it is a shadow or a rotor) */ static inline bool IsNormalAircraft(const Vehicle *v) { assert(v->type == VEH_AIRCRAFT); /* To be fully correct the commented out functionality is the proper one, * but since value can only be 0 or 2, it is sufficient to only check <= 2 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */ return v->subtype <= AIR_AIRCRAFT; } /** * Calculates cargo capacity based on an aircraft's passenger * and mail capacities. * @param cid Which cargo type to calculate a capacity for. * @param avi Which engine to find a cargo capacity for. * @return New cargo capacity value. */ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi); /** * This is the Callback method after the construction attempt of an aircraft * @param success indicates completion (or not) of the operation * @param tile of depot where aircraft is built * @param p1 unused * @param p2 unused */ void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); /** Handle Aircraft specific tasks when a an Aircraft enters a hangar * @param *v Vehicle that enters the hangar */ void HandleAircraftEnterHangar(Vehicle *v); /** Get the size of the sprite of an aircraft sprite heading west (used for lists) * @param engine The engine to get the sprite from * @param width The width of the sprite * @param height The height of the sprite */ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height); /** * Updates the status of the Aircraft heading or in the station * @param st Station been updated */ void UpdateAirplanesOnNewStation(const Station *st); /** Update cached values of an aircraft. * Currently caches callback 36 max speed. * @param v Vehicle */ void UpdateAircraftCache(Vehicle *v); void AircraftLeaveHangar(Vehicle *v); void AircraftNextAirportPos_and_Order(Vehicle *v); void SetAircraftPosition(Vehicle *v, int x, int y, int z); byte GetAircraftFlyingAltitude(const Vehicle *v); /** * This class 'wraps' Vehicle; you do not actually instantiate this class. * You create a Vehicle using AllocateVehicle, so it is added to the pool * and you reinitialize that to a Train using: * v = new (v) Aircraft(); * * As side-effect the vehicle type is set correctly. */ struct Aircraft : public Vehicle { /** Initializes the Vehicle to an aircraft */ Aircraft() { this->type = VEH_AIRCRAFT; } /** We want to 'destruct' the right class. */ virtual ~Aircraft() { this->PreDestructor(); } const char *GetTypeString() const { return "aircraft"; } void MarkDirty(); void UpdateDeltaXY(Direction direction); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; } bool IsPrimaryVehicle() const { return IsNormalAircraft(this); } SpriteID GetImage(Direction direction) const; int GetDisplaySpeed() const { return this->cur_speed; } int GetDisplayMaxSpeed() const { return this->max_speed; } Money GetRunningCost() const; bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); } void Tick(); void OnNewDay(); TileIndex GetOrderStationLocation(StationID station); bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); }; Station *GetTargetAirportIfValid(const Vehicle *v); #endif /* AIRCRAFT_H */
4,025
C++
.h
99
38.828283
114
0.747441
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,439
cheat_func.h
EnergeticBark_OpenTTD-3DS/src/cheat_func.h
/* $Id$ */ /** @file cheat_func.h Functions related to cheating. */ #ifndef CHEAT_FUNC_H #define CHEAT_FUNC_H #include "cheat_type.h" extern Cheats _cheats; void ShowCheatWindow(); /** * Return true if any cheat has been used, false otherwise * @return has a cheat been used? */ bool CheatHasBeenUsed(); #endif /* CHEAT_FUNC_H */
340
C++
.h
13
24.384615
58
0.721875
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,440
sdl.h
EnergeticBark_OpenTTD-3DS/src/sdl.h
/* $Id$ */ /** @file sdl.h SDL support. */ #ifndef SDL_H #define SDL_H const char *SdlOpen(uint32 x); void SdlClose(uint32 x); #ifdef WIN32 #define DYNAMICALLY_LOADED_SDL #endif #ifdef DYNAMICALLY_LOADED_SDL #include <SDL.h> struct SDLProcs { int (SDLCALL *SDL_Init)(Uint32); int (SDLCALL *SDL_InitSubSystem)(Uint32); char *(SDLCALL *SDL_GetError)(); void (SDLCALL *SDL_QuitSubSystem)(Uint32); void (SDLCALL *SDL_UpdateRect)(SDL_Surface *, Sint32, Sint32, Uint32, Uint32); void (SDLCALL *SDL_UpdateRects)(SDL_Surface *, int, SDL_Rect *); int (SDLCALL *SDL_SetColors)(SDL_Surface *, SDL_Color *, int, int); void (SDLCALL *SDL_WM_SetCaption)(const char *, const char *); int (SDLCALL *SDL_ShowCursor)(int); void (SDLCALL *SDL_FreeSurface)(SDL_Surface *); int (SDLCALL *SDL_PollEvent)(SDL_Event *); void (SDLCALL *SDL_WarpMouse)(Uint16, Uint16); uint32 (SDLCALL *SDL_GetTicks)(); int (SDLCALL *SDL_OpenAudio)(SDL_AudioSpec *, SDL_AudioSpec*); void (SDLCALL *SDL_PauseAudio)(int); void (SDLCALL *SDL_CloseAudio)(); int (SDLCALL *SDL_LockSurface)(SDL_Surface*); void (SDLCALL *SDL_UnlockSurface)(SDL_Surface*); SDLMod (SDLCALL *SDL_GetModState)(); void (SDLCALL *SDL_Delay)(Uint32); void (SDLCALL *SDL_Quit)(); SDL_Surface *(SDLCALL *SDL_SetVideoMode)(int, int, int, Uint32); int (SDLCALL *SDL_EnableKeyRepeat)(int, int); void (SDLCALL *SDL_EnableUNICODE)(int); void (SDLCALL *SDL_VideoDriverName)(char *, int); SDL_Rect **(SDLCALL *SDL_ListModes)(void *, int); Uint8 *(SDLCALL *SDL_GetKeyState)(int *); SDL_Surface *(SDLCALL *SDL_LoadBMP_RW)(SDL_RWops *, int); SDL_RWops *(SDLCALL *SDL_RWFromFile)(const char *, const char *); int (SDLCALL *SDL_SetColorKey)(SDL_Surface *, Uint32, Uint32); void (SDLCALL *SDL_WM_SetIcon)(SDL_Surface *, Uint8 *); Uint32 (SDLCALL *SDL_MapRGB)(SDL_PixelFormat *, Uint8, Uint8, Uint8); int (SDLCALL *SDL_VideoModeOK)(int, int, int, Uint32); }; extern SDLProcs sdl_proc; #define SDL_CALL sdl_proc. #else #define SDL_CALL #endif #endif /* SDL_H */
2,054
C++
.h
52
36.923077
80
0.704967
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,441
sound_func.h
EnergeticBark_OpenTTD-3DS/src/sound_func.h
/* $Id$ */ /** @file sound_func.h Functions related to sound. */ #ifndef SOUND_FUNC_H #define SOUND_FUNC_H #include "sound_type.h" #include "vehicle_type.h" #include "tile_type.h" extern MusicFileSettings msf; bool SoundInitialize(const char *filename); uint GetNumOriginalSounds(); void SndPlayTileFx(SoundFx sound, TileIndex tile); void SndPlayVehicleFx(SoundFx sound, const Vehicle *v); void SndPlayFx(SoundFx sound); void SndCopyToPool(); #endif /* SOUND_FUNC_H */
476
C++
.h
15
30.266667
55
0.777533
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,442
station_map.h
EnergeticBark_OpenTTD-3DS/src/station_map.h
/* $Id$ */ /** @file station_map.h Maps accessors for stations. */ #ifndef STATION_MAP_H #define STATION_MAP_H #include "rail_map.h" #include "road_map.h" #include "water_map.h" #include "station_func.h" #include "station_base.h" #include "rail.h" typedef byte StationGfx; /** Get Station ID from a tile * @pre Tile \t must be part of the station * @param t Tile to query station ID from * @return Station ID of the station at \a t */ static inline StationID GetStationIndex(TileIndex t) { assert(IsTileType(t, MP_STATION)); return (StationID)_m[t].m2; } static inline Station *GetStationByTile(TileIndex t) { return GetStation(GetStationIndex(t)); } enum { GFX_RADAR_LARGE_FIRST = 31, GFX_RADAR_LARGE_LAST = 42, GFX_WINDSACK_FIRST = 50, GFX_WINDSACK_LAST = 53, GFX_DOCK_BASE_WATER_PART = 4, GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4, GFX_RADAR_INTERNATIONAL_FIRST = 66, GFX_RADAR_INTERNATIONAL_LAST = 77, GFX_RADAR_METROPOLITAN_FIRST = 78, GFX_RADAR_METROPOLITAN_LAST = 89, GFX_RADAR_DISTRICTWE_FIRST = 121, GFX_RADAR_DISTRICTWE_LAST = 132, GFX_WINDSACK_INTERCON_FIRST = 140, GFX_WINDSACK_INTERCON_LAST = 143, }; static inline StationType GetStationType(TileIndex t) { return (StationType)GB(_m[t].m6, 3, 3); } static inline RoadStopType GetRoadStopType(TileIndex t) { assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS); return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS; } static inline StationGfx GetStationGfx(TileIndex t) { assert(IsTileType(t, MP_STATION)); return _m[t].m5; } static inline void SetStationGfx(TileIndex t, StationGfx gfx) { assert(IsTileType(t, MP_STATION)); _m[t].m5 = gfx; } static inline uint8 GetStationAnimationFrame(TileIndex t) { assert(IsTileType(t, MP_STATION)); return _me[t].m7; } static inline void SetStationAnimationFrame(TileIndex t, uint8 frame) { assert(IsTileType(t, MP_STATION)); _me[t].m7 = frame; } static inline bool IsRailwayStation(TileIndex t) { return GetStationType(t) == STATION_RAIL; } static inline bool IsRailwayStationTile(TileIndex t) { return IsTileType(t, MP_STATION) && IsRailwayStation(t); } static inline bool IsAirport(TileIndex t) { return GetStationType(t) == STATION_AIRPORT; } bool IsHangar(TileIndex t); /** * Is the station at \a t a truck stop? * @param t Tile to check * @return \c true if station is a truck stop, \c false otherwise */ static inline bool IsTruckStop(TileIndex t) { return GetStationType(t) == STATION_TRUCK; } /** * Is the station at \a t a bus stop? * @param t Tile to check * @return \c true if station is a bus stop, \c false otherwise */ static inline bool IsBusStop(TileIndex t) { return GetStationType(t) == STATION_BUS; } /** * Is the station at \a t a road station? * @pre Tile at \a t is a station tile * @param t Tile to check * @return \c true if station at the tile is a bus top or a truck stop, \c false otherwise */ static inline bool IsRoadStop(TileIndex t) { assert(IsTileType(t, MP_STATION)); return IsTruckStop(t) || IsBusStop(t); } static inline bool IsRoadStopTile(TileIndex t) { return IsTileType(t, MP_STATION) && IsRoadStop(t); } static inline bool IsStandardRoadStopTile(TileIndex t) { return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET; } static inline bool IsDriveThroughStopTile(TileIndex t) { return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET; } /** * Gets the direction the road stop entrance points towards. */ static inline DiagDirection GetRoadStopDir(TileIndex t) { StationGfx gfx = GetStationGfx(t); assert(IsRoadStopTile(t)); if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) { return (DiagDirection)(gfx); } else { return (DiagDirection)(gfx - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); } } static inline bool IsOilRig(TileIndex t) { return GetStationType(t) == STATION_OILRIG; } static inline bool IsDock(TileIndex t) { return GetStationType(t) == STATION_DOCK; } static inline bool IsDockTile(TileIndex t) { return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK; } static inline bool IsBuoy(TileIndex t) { return GetStationType(t) == STATION_BUOY; } static inline bool IsBuoyTile(TileIndex t) { return IsTileType(t, MP_STATION) && IsBuoy(t); } static inline bool IsHangarTile(TileIndex t) { return IsTileType(t, MP_STATION) && IsHangar(t); } static inline Axis GetRailStationAxis(TileIndex t) { assert(IsRailwayStation(t)); return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X; } static inline Track GetRailStationTrack(TileIndex t) { return AxisToTrack(GetRailStationAxis(t)); } static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2) { assert(IsRailwayStationTile(t2)); return IsRailwayStationTile(t1) && IsCompatibleRail(GetRailType(t1), GetRailType(t2)) && GetRailStationAxis(t1) == GetRailStationAxis(t2) && GetStationIndex(t1) == GetStationIndex(t2) && !IsStationTileBlocked(t1); } /** * Get the reservation state of the rail station * @pre IsRailwayStationTile(t) * @param t the station tile * @return reservation state */ static inline bool GetRailwayStationReservation(TileIndex t) { assert(IsRailwayStationTile(t)); return HasBit(_m[t].m6, 2); } /** * Set the reservation state of the rail station * @pre IsRailwayStationTile(t) * @param t the station tile * @param b the reservation state */ static inline void SetRailwayStationReservation(TileIndex t, bool b) { assert(IsRailwayStationTile(t)); SB(_m[t].m6, 2, 1, b ? 1 : 0); } /** * Get the reserved track bits for a waypoint * @pre IsRailwayStationTile(t) * @param t the tile * @return reserved track bits */ static inline TrackBits GetRailStationReservation(TileIndex t) { return GetRailwayStationReservation(t) ? AxisToTrackBits(GetRailStationAxis(t)) : TRACK_BIT_NONE; } static inline DiagDirection GetDockDirection(TileIndex t) { StationGfx gfx = GetStationGfx(t); assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART); return (DiagDirection)(gfx); } static inline TileIndexDiffC GetDockOffset(TileIndex t) { static const TileIndexDiffC buoy_offset = {0, 0}; static const TileIndexDiffC oilrig_offset = {2, 0}; static const TileIndexDiffC dock_offset[DIAGDIR_END] = { {-2, 0}, { 0, 2}, { 2, 0}, { 0, -2}, }; assert(IsTileType(t, MP_STATION)); if (IsBuoy(t)) return buoy_offset; if (IsOilRig(t)) return oilrig_offset; assert(IsDock(t)); return dock_offset[GetDockDirection(t)]; } static inline bool IsCustomStationSpecIndex(TileIndex t) { assert(IsTileType(t, MP_STATION)); return _m[t].m4 != 0; } static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex) { assert(IsTileType(t, MP_STATION)); _m[t].m4 = specindex; } static inline uint GetCustomStationSpecIndex(TileIndex t) { assert(IsTileType(t, MP_STATION)); return _m[t].m4; } static inline void SetStationTileRandomBits(TileIndex t, byte random_bits) { assert(IsTileType(t, MP_STATION)); SB(_m[t].m3, 4, 4, random_bits); } static inline byte GetStationTileRandomBits(TileIndex t) { assert(IsTileType(t, MP_STATION)); return GB(_m[t].m3, 4, 4); } static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section) { SetTileType(t, MP_STATION); SetTileOwner(t, o); _m[t].m2 = sid; _m[t].m3 = 0; _m[t].m4 = 0; _m[t].m5 = section; SB(_m[t].m6, 2, 1, 0); SB(_m[t].m6, 3, 3, st); _me[t].m7 = 0; } static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt) { MakeStation(t, o, sid, STATION_RAIL, section + a); SetRailType(t, rt); SetRailwayStationReservation(t, false); } static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d) { MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d); SetRoadTypes(t, rt); SetRoadOwner(t, ROADTYPE_ROAD, o); SetRoadOwner(t, ROADTYPE_TRAM, o); } static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a) { MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a); SetRoadTypes(t, rt); SetRoadOwner(t, ROADTYPE_ROAD, road); SetRoadOwner(t, ROADTYPE_TRAM, tram); } static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section) { MakeStation(t, o, sid, STATION_AIRPORT, section); } static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc) { /* Make the owner of the buoy tile the same as the current owner of the * water tile. In this way, we can reset the owner of the water to its * original state when the buoy gets removed. */ MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0); SetWaterClass(t, wc); } static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc) { MakeStation(t, o, sid, STATION_DOCK, d); MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d)); SetWaterClass(t + TileOffsByDiagDir(d), wc); } static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc) { MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0); SetWaterClass(t, wc); } #endif /* STATION_MAP_H */
9,409
C++
.h
311
28.524116
150
0.742946
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,443
currency.h
EnergeticBark_OpenTTD-3DS/src/currency.h
/* $Id$ */ /** @file currency.h Functions to handle different currencies. */ #ifndef CURRENCY_H #define CURRENCY_H #include "date_type.h" #include "strings_type.h" enum { CF_NOEURO = 0, CF_ISEURO = 1, NUM_CURRENCY = 29, CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1 }; struct CurrencySpec { uint16 rate; char separator; Year to_euro; char prefix[16]; char suffix[16]; /** * The currency symbol is represented by two possible values, prefix and suffix * Usage of one or the other is determined by symbol_pos. * 0 = prefix * 1 = suffix * 2 = both : Special case only for custom currency. * It is not a spec from Newgrf, * rather a way to let users do what they want with custom curency */ byte symbol_pos; StringID name; }; extern CurrencySpec _currency_specs[NUM_CURRENCY]; /* XXX small hack, but makes the rest of the code a bit nicer to read */ #define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID]) #define _currency ((const CurrencySpec*)&_currency_specs[_game_mode == GM_MENU ? _settings_newgame.locale.currency : _settings_game.locale.currency]) uint GetMaskOfAllowedCurrencies(); void CheckSwitchToEuro(); void ResetCurrencies(bool preserve_custom = true); StringID *BuildCurrencyDropdown(); byte GetNewgrfCurrencyIdConverted(byte grfcurr_id); #endif /* CURRENCY_H */
1,334
C++
.h
40
31.4
149
0.735981
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,444
engine_base.h
EnergeticBark_OpenTTD-3DS/src/engine_base.h
/* $Id$ */ /** @file engine_base.h Base class for engines. */ #ifndef ENGINE_BASE_H #define ENGINE_BASE_H #include "engine_type.h" #include "economy_type.h" #include "oldpool.h" #include "core/smallvec_type.hpp" DECLARE_OLD_POOL(Engine, Engine, 6, 10000) struct Engine : PoolItem<Engine, EngineID, &_Engine_pool> { char *name; ///< Custom name of engine Date intro_date; Date age; uint16 reliability; uint16 reliability_spd_dec; uint16 reliability_start, reliability_max, reliability_final; uint16 duration_phase_1, duration_phase_2, duration_phase_3; byte lifelength; byte flags; uint8 preview_company_rank; byte preview_wait; CompanyMask company_avail; uint8 image_index; ///< Original vehicle image index VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc. EngineInfo info; union { RailVehicleInfo rail; RoadVehicleInfo road; ShipVehicleInfo ship; AircraftVehicleInfo air; } u; /* NewGRF related data */ const struct GRFFile *grffile; const struct SpriteGroup *group[NUM_CARGO + 2]; uint16 internal_id; ///< ID within the GRF file uint16 overrides_count; struct WagonOverride *overrides; uint16 list_position; Engine(); Engine(VehicleType type, EngineID base); ~Engine(); inline bool IsValid() const { return this->info.climates != 0; } CargoID GetDefaultCargoType() const; bool CanCarryCargo() const; uint GetDisplayDefaultCapacity() const; Money GetRunningCost() const; Money GetCost() const; uint GetDisplayMaxSpeed() const; uint GetPower() const; uint GetDisplayWeight() const; uint GetDisplayMaxTractiveEffort() const; }; struct EngineIDMapping { uint32 grfid; ///< The GRF ID of the file the entity belongs to uint16 internal_id; ///< The internal ID within the GRF file VehicleTypeByte type; ///< The engine type uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) }; /** * Stores the mapping of EngineID to the internal id of newgrfs. * Note: This is not part of Engine, as the data in the EngineOverrideManager and the engine pool get resetted in different cases. */ struct EngineOverrideManager : SmallVector<EngineIDMapping, 256> { static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries void ResetToDefaultMapping(); EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid); }; extern EngineOverrideManager _engine_mngr; static inline bool IsEngineIndex(uint index) { return index < GetEnginePoolSize(); } #define FOR_ALL_ENGINES_FROM(e, start) for (e = GetEngine(start); e != NULL; e = (e->index + 1U < GetEnginePoolSize()) ? GetEngine(e->index + 1U) : NULL) if (e->IsValid()) #define FOR_ALL_ENGINES(e) FOR_ALL_ENGINES_FROM(e, 0) #define FOR_ALL_ENGINES_OF_TYPE(e, engine_type) FOR_ALL_ENGINES(e) if (e->type == engine_type) static inline const EngineInfo *EngInfo(EngineID e) { return &GetEngine(e)->info; } static inline const RailVehicleInfo *RailVehInfo(EngineID e) { return &GetEngine(e)->u.rail; } static inline const RoadVehicleInfo *RoadVehInfo(EngineID e) { return &GetEngine(e)->u.road; } static inline const ShipVehicleInfo *ShipVehInfo(EngineID e) { return &GetEngine(e)->u.ship; } static inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e) { return &GetEngine(e)->u.air; } #endif /* ENGINE_TYPE_H */
3,363
C++
.h
96
33.145833
171
0.751156
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,445
road_type.h
EnergeticBark_OpenTTD-3DS/src/road_type.h
/* $Id$ */ /** @file road_type.h Enums and other types related to roads. */ #ifndef ROAD_TYPE_H #define ROAD_TYPE_H #include "core/enum_type.hpp" /** * The different roadtypes we support * * @note currently only ROADTYPE_ROAD and ROADTYPE_TRAM are supported. */ enum RoadType { ROADTYPE_BEGIN = 0, ///< Used for iterations ROADTYPE_ROAD = 0, ///< Basic road type ROADTYPE_TRAM = 1, ///< Trams ROADTYPE_END, ///< Used for iterations INVALID_ROADTYPE = 0xFF ///< flag for invalid roadtype }; DECLARE_POSTFIX_INCREMENT(RoadType); /** * The different roadtypes we support, but then a bitmask of them * @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported. */ enum RoadTypes { ROADTYPES_NONE = 0, ///< No roadtypes ROADTYPES_ROAD = 1 << ROADTYPE_ROAD, ///< Road ROADTYPES_TRAM = 1 << ROADTYPE_TRAM, ///< Trams ROADTYPES_ALL = ROADTYPES_ROAD | ROADTYPES_TRAM, ///< Road + trams ROADTYPES_END, ///< Used for iterations? INVALID_ROADTYPES = 0xFF ///< Invalid roadtypes }; DECLARE_ENUM_AS_BIT_SET(RoadTypes); template <> struct EnumPropsT<RoadTypes> : MakeEnumPropsT<RoadTypes, byte, ROADTYPES_NONE, ROADTYPES_END, INVALID_ROADTYPES> {}; typedef TinyEnumT<RoadTypes> RoadTypesByte; /** * Enumeration for the road parts on a tile. * * This enumeration defines the possible road parts which * can be build on a tile. */ enum RoadBits { ROAD_NONE = 0U, ///< No road-part is build ROAD_NW = 1U, ///< North-west part ROAD_SW = 2U, ///< South-west part ROAD_SE = 4U, ///< South-east part ROAD_NE = 8U, ///< North-east part ROAD_X = ROAD_SW | ROAD_NE, ///< Full road along the x-axis (south-west + north-east) ROAD_Y = ROAD_NW | ROAD_SE, ///< Full road along the y-axis (north-west + south-east) ROAD_ALL = ROAD_X | ROAD_Y ///< Full 4-way crossing }; DECLARE_ENUM_AS_BIT_SET(RoadBits); #endif /* ROAD_TYPE_H */
2,143
C++
.h
51
40.254902
128
0.612284
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,446
newgrf_config.h
EnergeticBark_OpenTTD-3DS/src/newgrf_config.h
/* $Id$ */ /** @file newgrf_config.h Functions to find and configure NewGRFs. */ #ifndef NEWGRF_CONFIG_H #define NEWGRF_CONFIG_H #include "strings_type.h" /** GRF config bit flags */ enum GCF_Flags { GCF_SYSTEM, ///< GRF file is an openttd-internal system grf GCF_UNSAFE, ///< GRF file is unsafe for static usage GCF_STATIC, ///< GRF file is used statically (can be used in any MP game) GCF_COMPATIBLE, ///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) GCF_COPY, ///< The data is copied from a grf in _all_grfs GCF_INIT_ONLY, ///< GRF file is processed up to GLS_INIT GCF_RESERVED, ///< GRF file passed GLS_RESERVE stage }; /** Status of GRF */ enum GRFStatus { GCS_UNKNOWN, ///< The status of this grf file is unknown GCS_DISABLED, ///< GRF file is disabled GCS_NOT_FOUND, ///< GRF file was not found in the local cache GCS_INITIALISED, ///< GRF file has been initialised GCS_ACTIVATED ///< GRF file has been activated }; /** Encountered GRF bugs */ enum GRFBugs { GBUG_VEH_LENGTH, ///< Length of rail vehicle changes when not inside a depot GBUG_VEH_REFIT, ///< Articulated vehicles carry different cargos resp. are differently refittable than specified in purchase list }; /** Status of post-gameload GRF compatibility check */ enum GRFListCompatibility { GLC_ALL_GOOD, ///< All GRF needed by game are present GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different chacksum) GRF found in at least one case GLC_NOT_FOUND ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE) }; /** Basic data to distinguish a GRF. Used in the server list window */ struct GRFIdentifier { uint32 grfid; ///< GRF ID (defined by Action 0x08) uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) }; /** Information about why GRF had problems during initialisation */ struct GRFError { char *custom_message; ///< Custom message (if present) char *data; ///< Additional data for message and custom_message StringID message; ///< Default message StringID severity; ///< Info / Warning / Error / Fatal uint8 num_params; ///< Number of additinal parameters for custom_message (0, 1 or 2) uint8 param_number[2]; ///< GRF parameters to show for custom_message }; /** Information about GRF, used in the game and (part of it) in savegames */ struct GRFConfig : public GRFIdentifier { char *filename; ///< Filename - either with or without full path char *name; ///< NOSAVE: GRF name (Action 0x08) char *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B) uint8 flags; ///< NOSAVE: GCF_Flags, bitset GRFStatus status; ///< NOSAVE: GRFStatus, enum uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs uint32 param[0x80]; ///< GRF parameters uint8 num_params; ///< Number of used parameters bool windows_paletted; ///< Whether the NewGRF is Windows paletted or not struct GRFConfig *next; ///< NOSAVE: Next item in the linked list bool IsOpenTTDBaseGRF() const; }; extern GRFConfig *_all_grfs; ///< First item in list of all scanned NewGRFs extern GRFConfig *_grfconfig; ///< First item in list of current GRF set up extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up extern GRFConfig *_grfconfig_static; ///< First item in list of static GRF set up void ScanNewGRFFiles(); const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL); GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF); GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only); void AppendStaticGRFConfigs(GRFConfig **dst); void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); void ClearGRFConfig(GRFConfig **config); void ClearGRFConfigList(GRFConfig **config); void ResetGRFConfig(bool defaults); GRFListCompatibility IsGoodGRFConfigList(); bool FillGRFDetails(GRFConfig *config, bool is_static); 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 */ #define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>" char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create); #endif /* ENABLE_NETWORK */ #endif /* NEWGRF_CONFIG_H */
4,614
C++
.h
87
51.390805
132
0.724933
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,447
transparency.h
EnergeticBark_OpenTTD-3DS/src/transparency.h
/* $Id$ */ /** @file transparency.h Functions related to transparency. */ #ifndef TRANSPARENCY_H #define TRANSPARENCY_H #include "gfx_func.h" /** * Transparency option bits: which position in _transparency_opt stands for which transparency. * If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. * If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. */ enum TransparencyOption { TO_SIGNS = 0, ///< signs TO_TREES, ///< trees TO_HOUSES, ///< town buildings TO_INDUSTRIES, ///< industries TO_BUILDINGS, ///< company buildings - depots, stations, HQ, ... TO_BRIDGES, ///< bridges TO_STRUCTURES, ///< unmovable structures TO_CATENARY, ///< catenary TO_LOADING, ///< loading indicators TO_END, }; typedef uint TransparencyOptionBits; ///< transparency option bits extern TransparencyOptionBits _transparency_opt; extern TransparencyOptionBits _transparency_lock; extern TransparencyOptionBits _invisibility_opt; /** * Check if the transparency option bit is set * and if we aren't in the game menu (there's never transparency) * * @param to the structure which transparency option is ask for */ static inline bool IsTransparencySet(TransparencyOption to) { return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); } /** * Check if the invisibility option bit is set * and if we aren't in the game menu (there's never transparency) * * @param to the structure which invisibility option is ask for */ static inline bool IsInvisibilitySet(TransparencyOption to) { return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); } /** * Toggle the transparency option bit * * @param to the transparency option to be toggled */ static inline void ToggleTransparency(TransparencyOption to) { ToggleBit(_transparency_opt, to); } /** * Toggle the invisibility option bit * * @param to the structure which invisibility option is toggle */ static inline void ToggleInvisibility(TransparencyOption to) { ToggleBit(_invisibility_opt, to); } /** * Toggles between invisible and solid state. * If object is transparent, then it is made invisible. * Used by the keyboard shortcuts. * * @param to the object type which invisibility option to toggle */ static inline void ToggleInvisibilityWithTransparency(TransparencyOption to) { if (IsInvisibilitySet(to)) { ClrBit(_invisibility_opt, to); ClrBit(_transparency_opt, to); } else { SetBit(_invisibility_opt, to); SetBit(_transparency_opt, to); } } /** * Toggle the transparency lock bit * * @param to the transparency option to be locked or unlocked */ static inline void ToggleTransparencyLock(TransparencyOption to) { ToggleBit(_transparency_lock, to); } /** Set or clear all non-locked transparency options */ static inline void ResetRestoreAllTransparency() { /* if none of the non-locked options are set */ if ((_transparency_opt & ~_transparency_lock) == 0) { /* set all non-locked options */ _transparency_opt |= GB(~_transparency_lock, 0, TO_END); } else { /* clear all non-locked options */ _transparency_opt &= _transparency_lock; } MarkWholeScreenDirty(); } #endif /* TRANSPARENCY_H */
3,262
C++
.h
104
29.548077
112
0.749046
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,449
company_base.h
EnergeticBark_OpenTTD-3DS/src/company_base.h
/* $Id$ */ /** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */ #ifndef COMPANY_BASE_H #define COMPANY_BASE_H #include "company_type.h" #include "oldpool.h" #include "road_type.h" #include "rail_type.h" #include "date_type.h" #include "engine_type.h" #include "livery.h" #include "autoreplace_type.h" #include "economy_type.h" #include "tile_type.h" struct CompanyEconomyEntry { Money income; Money expenses; int32 delivered_cargo; int32 performance_history; ///< company score (scale 0-1000) Money company_value; }; /* The third parameter and the number after >> MUST be the same, * otherwise more (or less) companies will be allowed to be * created than what MAX_COMPANIES specifies! */ DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1) struct Company : PoolItem<Company, CompanyByte, &_Company_pool> { Company(uint16 name_1 = 0, bool is_ai = false); ~Company(); uint32 name_2; uint16 name_1; char *name; uint16 president_name_1; uint32 president_name_2; char *president_name; CompanyManagerFace face; Money money; byte money_fraction; Money current_loan; byte colour; Livery livery[LS_END]; RailTypes avail_railtypes; RoadTypes avail_roadtypes; byte block_preview; uint32 cargo_types; ///< which cargo types were transported the last year TileIndex location_of_HQ; ///< northern tile of HQ ; INVALID_TILE when there is none TileIndex last_build_coordinate; OwnerByte share_owners[4]; Year inaugurated_year; byte num_valid_stat_ent; byte quarters_of_bankrupcy; CompanyMask bankrupt_asked; ///< which companies were asked about buying it? int16 bankrupt_timeout; Money bankrupt_value; bool is_ai; class AIInstance *ai_instance; class AIInfo *ai_info; Money yearly_expenses[3][EXPENSES_END]; CompanyEconomyEntry cur_economy; CompanyEconomyEntry old_economy[24]; EngineRenewList engine_renew_list; ///< Defined later bool engine_renew; bool renew_keep_length; int16 engine_renew_months; uint32 engine_renew_money; uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this) inline bool IsValid() const { return this->name_1 != 0; } }; static inline bool IsValidCompanyID(CompanyID company) { return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid(); } #define FOR_ALL_COMPANIES_FROM(d, start) for (d = GetCompany(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? GetCompany(d->index + 1U) : NULL) if (d->IsValid()) #define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0) static inline byte ActiveCompanyCount() { const Company *c; byte count = 0; FOR_ALL_COMPANIES(c) count++; return count; } Money CalculateCompanyValue(const Company *c); extern uint _next_competitor_start; extern uint _cur_company_tick_index; #endif /* COMPANY_BASE_H */
2,907
C++
.h
85
32.247059
176
0.758053
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,450
debug.h
EnergeticBark_OpenTTD-3DS/src/debug.h
/* $Id$ */ /** @file debug.h Functions related to debugging. */ #ifndef DEBUG_H #define DEBUG_H /* Debugging messages policy: * These should be the severities used for direct DEBUG() calls * maximum debugging level should be 10 if really deep, deep * debugging is needed. * (there is room for exceptions, but you have to have a good cause): * 0 - errors or severe warnings * 1 - other non-fatal, non-severe warnings * 2 - crude progress indicator of functionality * 3 - important debugging messages (function entry) * 4 - debugging messages (crude loop status, etc.) * 5 - detailed debugging information * 6.. - extremely detailed spamming */ #ifdef NO_DEBUG_MESSAGES #if defined(__GNUC__) && (__GNUC__ < 3) #define DEBUG(name, level, args...) { } #else #define DEBUG(name, level, ...) { } #endif #else /* NO_DEBUG_MESSAGES */ #if defined(__GNUC__) && (__GNUC__ < 3) #define DEBUG(name, level, args...) if ((level == 0) || ( _debug_ ## name ## _level >= level)) debug(#name, args) #else #define DEBUG(name, level, ...) if (level == 0 || _debug_ ## name ## _level >= level) debug(#name, __VA_ARGS__) #endif extern int _debug_ai_level; extern int _debug_driver_level; extern int _debug_grf_level; extern int _debug_map_level; extern int _debug_misc_level; extern int _debug_ms_level; extern int _debug_net_level; extern int _debug_sprite_level; extern int _debug_oldloader_level; extern int _debug_ntp_level; extern int _debug_npf_level; extern int _debug_yapf_level; extern int _debug_freetype_level; extern int _debug_sl_level; extern int _debug_station_level; extern int _debug_gamelog_level; extern int _debug_desync_level; void CDECL debug(const char *dbg, ...); #endif /* NO_DEBUG_MESSAGES */ void SetDebugString(const char *s); const char *GetDebugString(); /* MSVCRT of course has to have a different syntax for long long *sigh* */ #if defined(_MSC_VER) || defined(__MINGW32__) #define OTTD_PRINTF64 "I64" #else #define OTTD_PRINTF64 "ll" #endif /* Used for profiling * * Usage: * TIC(); * --Do your code-- * TOC("A name", 1); * * When you run the TIC() / TOC() multiple times, you can increase the '1' * to only display average stats every N values. Some things to know: * * for (int i = 0; i < 5; i++) { * TIC(); * --Do yuor code-- * TOC("A name", 5); * } * * Is the correct usage for multiple TIC() / TOC() calls. * * TIC() / TOC() creates it's own block, so make sure not the mangle * it with an other 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_;\ if (++__i__ == count) {\ DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ __i__ = 0;\ __sum__ = 0;\ }\ } void ShowInfo(const char *str); void CDECL ShowInfoF(const char *str, ...); #endif /* DEBUG_H */
2,975
C++
.h
93
30.010753
115
0.656098
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,451
company_manager_face.h
EnergeticBark_OpenTTD-3DS/src/company_manager_face.h
/* $Id$ */ /** @file company_manager_face.h Functionality related to the company manager's face */ #ifndef COMPANY_MANAGER_FACE_H #define COMPANY_MANAGER_FACE_H #include "core/random_func.hpp" #include "core/bitmath_func.hpp" #include "table/sprites.h" #include "company_type.h" /** The gender/race combinations that we have faces for */ enum GenderEthnicity { GENDER_FEMALE = 0, ///< This bit set means a female, otherwise male ETHNICITY_BLACK = 1, ///< This bit set means black, otherwise white GE_WM = 0, ///< A male of Caucasian origin (white) GE_WF = 1 << GENDER_FEMALE, ///< A female of Caucasian origin (white) GE_BM = 1 << ETHNICITY_BLACK, ///< A male of African origin (black) GE_BF = 1 << ETHNICITY_BLACK | 1 << GENDER_FEMALE, ///< A female of African origin (black) GE_END, }; DECLARE_ENUM_AS_BIT_SET(GenderEthnicity); ///< See GenderRace as a bitset /** Bitgroups of the CompanyManagerFace variable */ enum CompanyManagerFaceVariable { CMFV_GENDER, CMFV_ETHNICITY, CMFV_GEN_ETHN, CMFV_HAS_MOUSTACHE, CMFV_HAS_TIE_EARRING, CMFV_HAS_GLASSES, CMFV_EYE_COLOUR, CMFV_CHEEKS, CMFV_CHIN, CMFV_EYEBROWS, CMFV_MOUSTACHE, CMFV_LIPS, CMFV_NOSE, CMFV_HAIR, CMFV_JACKET, CMFV_COLLAR, CMFV_TIE_EARRING, CMFV_GLASSES, CMFV_END }; DECLARE_POSTFIX_INCREMENT(CompanyManagerFaceVariable); /** Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw */ struct CompanyManagerFaceBitsInfo { byte offset; ///< Offset in bits into the CompanyManagerFace byte length; ///< Number of bits used in the CompanyManagerFace byte valid_values[GE_END]; ///< The number of valid values per gender/ethnicity SpriteID first_sprite[GE_END]; ///< The first sprite per gender/ethnicity }; /** Lookup table for indices into the CompanyManagerFace, valid ranges and sprites */ static const CompanyManagerFaceBitsInfo _cmf_info[] = { /* Index off len WM WF BM BF WM WF BM BF * CMFV_GENDER */ { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = male, 1 = female /* CMFV_ETHNICITY */ { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< 0 = (Western-)Caucasian, 1 = African(-American)/Black /* CMFV_GEN_ETHN */ { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } }, ///< Shortcut to get/set gender _and_ ethnicity /* CMFV_HAS_MOUSTACHE */ { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } }, ///< Females do not have a moustache /* CMFV_HAS_TIE_EARRING */ { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } }, ///< Draw the earring for females or not. For males the tie is always drawn. /* CMFV_HAS_GLASSES */ { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } }, ///< Whether to draw glasses or not /* CMFV_EYE_COLOUR */ { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } }, ///< Palette modification /* CMFV_CHEEKS */ { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } }, ///< Cheeks are only indexed by their gender/ethnicity /* CMFV_CHIN */ { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } }, /* CMFV_EYEBROWS */ { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } }, /* CMFV_MOUSTACHE */ { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } }, ///< Depends on CMFV_HAS_MOUSTACHE /* CMFV_LIPS */ { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } }, ///< Depends on !CMFV_HAS_MOUSTACHE /* CMFV_NOSE */ { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } }, ///< Depends on !CMFV_HAS_MOUSTACHE /* CMFV_HAIR */ { 20, 4, { 9, 5, 5, 4 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } }, /* CMFV_JACKET */ { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } }, /* CMFV_COLLAR */ { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } }, /* CMFV_TIE_EARRING */ { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } }, ///< Depends on CMFV_HAS_TIE_EARRING /* CMFV_GLASSES */ { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } ///< Depends on CMFV_HAS_GLASSES }; assert_compile(lengthof(_cmf_info) == CMFV_END); /** * Gets the company manager's face bits for the given company manager's face variable * @param cmf the face to extract the bits from * @param cmfv the face variable to get the data of * @param ge the gender and ethnicity of the face * @pre _cmf_info[cmfv].valid_values[ge] != 0 * @return the requested bits */ static inline uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) { assert(_cmf_info[cmfv].valid_values[ge] != 0); return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length); } /** * Sets the company manager's face bits for the given company manager's face variable * @param cmf the face to write the bits to * @param cmfv the face variable to write the data of * @param ge the gender and ethnicity of the face * @param val the new value * @pre val < _cmf_info[cmfv].valid_values[ge] */ static inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) { assert(val < _cmf_info[cmfv].valid_values[ge]); SB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length, val); } /** * Increase/Decrease the company manager's face variable by the given amount. * If the new value greater than the max value for this variable it will be set to 0. * Or is it negativ (< 0) it will be set to max value. * * @param cmf the company manager face to write the bits to * @param cmfv the company manager face variable to write the data of * @param ge the gender and ethnicity of the company manager's face * @param amount the amount which change the value * * @pre 0 <= val < _cmf_info[cmfv].valid_values[ge] */ static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount) { int8 val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv /* scales the new value to the correct scope */ if (val >= _cmf_info[cmfv].valid_values[ge]) { val = 0; } else if (val < 0) { val = _cmf_info[cmfv].valid_values[ge] - 1; } SetCompanyManagerFaceBits(cmf, cmfv, ge, val); // save the new value } /** * Checks whether the company manager's face bits have a valid range * @param cmf the face to extract the bits from * @param cmfv the face variable to get the data of * @param ge the gender and ethnicity of the face * @return true if and only if the bits are valid */ static inline bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) { return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length) < _cmf_info[cmfv].valid_values[ge]; } /** * Scales a company manager's face bits variable to the correct scope * @param cmfv the face variable to write the data of * @param ge the gender and ethnicity of the face * @param val the to value to scale * @pre val < (1U << _cmf_info[cmfv].length), i.e. val has a value of 0..2^(bits used for this variable)-1 * @return the scaled value */ static inline uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val) { assert(val < (1U << _cmf_info[cmfv].length)); return (val * _cmf_info[cmfv].valid_values[ge]) >> _cmf_info[cmfv].length; } /** * Scales all company manager's face bits to the correct scope * * @param cmf the company manager's face to write the bits to */ static inline void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf) { IncreaseCompanyManagerFaceBits(cmf, CMFV_ETHNICITY, GE_WM, 0); // scales the ethnicity GenderEthnicity ge = (GenderEthnicity)GB(cmf, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // gender & ethnicity of the face /* Is a male face with moustache. Need to reduce CPU load in the loop. */ bool is_moust_male = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0; for (CompanyManagerFaceVariable cmfv = CMFV_EYE_COLOUR; cmfv < CMFV_END; cmfv++) { // scales all other variables /* The moustache variable will be scaled only if it is a male face with has a moustache */ if (cmfv != CMFV_MOUSTACHE || is_moust_male) { IncreaseCompanyManagerFaceBits(cmf, cmfv, ge, 0); } } } /** * Make a random new face. * If it is for the advanced company manager's face window then the new face have the same gender * and ethnicity as the old one, else the gender is equal and the ethnicity is random. * * @param cmf the company manager's face to write the bits to * @param ge the gender and ethnicity of the old company manager's face * @param adv if it for the advanced company manager's face window * * @pre scale 'ge' to a valid gender/ethnicity combination */ static inline void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv) { cmf = InteractiveRandom(); // random all company manager's face bits /* scale ge: 0 == GE_WM, 1 == GE_WF, 2 == GE_BM, 3 == GE_BF (and maybe in future: ...) */ ge = (GenderEthnicity)((uint)ge % GE_END); /* set the gender (and ethnicity) for the new company manager's face */ if (adv) { SetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, ge, ge); } else { SetCompanyManagerFaceBits(cmf, CMFV_GENDER, ge, HasBit(ge, GENDER_FEMALE)); } /* scales all company manager's face bits to the correct scope */ ScaleAllCompanyManagerFaceBits(cmf); } /** * Gets the sprite to draw for the given company manager's face variable * @param cmf the face to extract the data from * @param cmfv the face variable to get the sprite of * @param ge the gender and ethnicity of the face * @pre _cmf_info[cmfv].valid_values[ge] != 0 * @return sprite to draw */ static inline SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge) { assert(_cmf_info[cmfv].valid_values[ge] != 0); return _cmf_info[cmfv].first_sprite[ge] + GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length); } void DrawCompanyManagerFace(CompanyManagerFace face, int colour, int x, int y); bool IsValidCompanyManagerFace(CompanyManagerFace cmf); #endif /* COMPANY_MANAGER_FACE_H */
10,470
C++
.h
204
49.406863
167
0.666927
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,452
music.h
EnergeticBark_OpenTTD-3DS/src/music.h
/* $Id$ */ /** @file music.h Base for the music handling. */ #ifndef MUSIC_H #define MUSIC_H #define NUM_SONGS_PLAYLIST 33 #define NUM_SONGS_AVAILABLE 22 struct SongSpecs { char filename[MAX_PATH]; char song_name[64]; }; extern const SongSpecs _origin_songs_specs[]; #endif /* MUSIC_H */
296
C++
.h
12
23
49
0.730216
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,454
signs_type.h
EnergeticBark_OpenTTD-3DS/src/signs_type.h
/* $Id$ */ /** @file signs_type.h Types related to signs */ #ifndef SIGNS_TYPE_H #define SIGNS_TYPE_H typedef uint16 SignID; struct Sign; enum { INVALID_SIGN = 0xFFFF, MAX_LENGTH_SIGN_NAME_BYTES = 31, ///< The maximum length of a sign name in bytes including '\0' MAX_LENGTH_SIGN_NAME_PIXELS = 255, ///< The maximum length of a sign name in pixels }; #endif /* SIGNS_TYPE_H */
388
C++
.h
12
30.583333
98
0.705405
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,455
effectvehicle_func.h
EnergeticBark_OpenTTD-3DS/src/effectvehicle_func.h
/* $Id$ */ /** @file effectvehicle_func.h Functions related to effect vehicles. */ #ifndef EFFECTVEHICLE_FUNC_H #define EFFECTVEHICLE_FUNC_H #include "vehicle_type.h" /** Effect vehicle types */ enum EffectVehicleType { EV_CHIMNEY_SMOKE = 0, EV_STEAM_SMOKE = 1, EV_DIESEL_SMOKE = 2, EV_ELECTRIC_SPARK = 3, EV_SMOKE = 4, EV_EXPLOSION_LARGE = 5, EV_BREAKDOWN_SMOKE = 6, EV_EXPLOSION_SMALL = 7, EV_BULLDOZER = 8, EV_BUBBLE = 9 }; Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type); Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type); Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type); #endif /* EFFECTVEHICLE_FUNC_H */
763
C++
.h
22
32.954545
95
0.708844
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,456
vehicle_func.h
EnergeticBark_OpenTTD-3DS/src/vehicle_func.h
/* $Id$ */ /** @file vehicle_func.h Functions related to vehicles. */ #ifndef VEHICLE_FUNC_H #define VEHICLE_FUNC_H #include "tile_type.h" #include "strings_type.h" #include "gfx_type.h" #include "direction_type.h" #include "cargo_type.h" #include "command_type.h" #include "vehicle_type.h" #include "engine_type.h" #include "transport_type.h" #include "newgrf_config.h" #define is_custom_sprite(x) (x >= 0xFD) #define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD) #define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE) typedef Vehicle *VehicleFromPosProc(Vehicle *v, void *data); void VehicleServiceInDepot(Vehicle *v); Vehicle *GetLastVehicleInChain(Vehicle *v); const Vehicle *GetLastVehicleInChain(const Vehicle *v); uint CountVehiclesInChain(const Vehicle *v); bool IsEngineCountable(const Vehicle *v); void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc); void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc); bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc); bool HasVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc); void CallVehicleTicks(); uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour); void InitializeTrains(); byte VehicleRandomBits(); void ResetVehiclePosHash(); void ResetVehicleColourMap(); bool CanRefitTo(EngineID engine_type, CargoID cid_to); CargoID FindFirstRefittableCargo(EngineID engine_type); CommandCost GetRefitCost(EngineID engine_type); void ViewportAddVehicles(DrawPixelInfo *dpi); SpriteID GetRotorImage(const Vehicle *v); void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBugs bug_type, bool critical); StringID VehicleInTheWayErrMsg(const Vehicle *v); bool HasVehicleOnTunnelBridge(TileIndex tile, TileIndex endtile, const Vehicle *ignore = NULL); void DecreaseVehicleValue(Vehicle *v); void CheckVehicleBreakdown(Vehicle *v); void AgeVehicle(Vehicle *v); void VehicleEnteredDepotThisTick(Vehicle *v); void VehicleMove(Vehicle *v, bool update_viewport); void MarkSingleVehicleDirty(const Vehicle *v); UnitID GetFreeUnitNumber(VehicleType type); void TrainConsistChanged(Vehicle *v, bool same_length); void TrainPowerChanged(Vehicle *v); Money GetTrainRunningCost(const Vehicle *v); CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id); void VehicleEnterDepot(Vehicle *v); bool CanBuildVehicleInfrastructure(VehicleType type); void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2); /** Position information of a vehicle after it moved */ struct GetNewVehiclePosResult { int x, y; ///< x and y position of the vehicle after moving TileIndex old_tile; ///< Current tile of the vehicle TileIndex new_tile; ///< Tile of the vehicle after moving }; GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v); Direction GetDirectionTowards(const Vehicle *v, int x, int y); static inline bool IsCompanyBuildableVehicleType(VehicleType type) { switch (type) { case VEH_TRAIN: case VEH_ROAD: case VEH_SHIP: case VEH_AIRCRAFT: return true; default: return false; } } static inline bool IsCompanyBuildableVehicleType(const BaseVehicle *v) { return IsCompanyBuildableVehicleType(v->type); } const struct Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v); /** * Get the colour map for an engine. This used for unbuilt engines in the user interface. * @param engine_type ID of engine * @param company ID of company * @return A ready-to-use palette modifier */ SpriteID GetEnginePalette(EngineID engine_type, CompanyID company); /** * Get the colour map for a vehicle. * @param v Vehicle to get colour map for * @return A ready-to-use palette modifier */ SpriteID GetVehiclePalette(const Vehicle *v); extern const uint32 _veh_build_proc_table[]; extern const uint32 _veh_sell_proc_table[]; extern const uint32 _veh_refit_proc_table[]; extern const uint32 _send_to_depot_proc_table[]; /* Functions to find the right command for certain vehicle type */ static inline uint32 GetCmdBuildVeh(VehicleType type) { return _veh_build_proc_table[type]; } static inline uint32 GetCmdBuildVeh(const BaseVehicle *v) { return GetCmdBuildVeh(v->type); } static inline uint32 GetCmdSellVeh(VehicleType type) { return _veh_sell_proc_table[type]; } static inline uint32 GetCmdSellVeh(const BaseVehicle *v) { return GetCmdSellVeh(v->type); } static inline uint32 GetCmdRefitVeh(VehicleType type) { return _veh_refit_proc_table[type]; } static inline uint32 GetCmdRefitVeh(const BaseVehicle *v) { return GetCmdRefitVeh(v->type); } static inline uint32 GetCmdSendToDepot(VehicleType type) { return _send_to_depot_proc_table[type]; } static inline uint32 GetCmdSendToDepot(const BaseVehicle *v) { return GetCmdSendToDepot(v->type); } bool EnsureNoVehicleOnGround(TileIndex tile); void StopAllVehicles(); extern VehicleID _vehicle_id_ctr_day; extern const Vehicle *_place_clicked_vehicle; extern VehicleID _new_vehicle_id; extern uint16 _returned_refit_capacity; bool CanVehicleUseStation(EngineID engine_type, const struct Station *st); bool CanVehicleUseStation(const Vehicle *v, const struct Station *st); #endif /* VEHICLE_FUNC_H */
5,293
C++
.h
138
36.811594
129
0.803557
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,457
direction_func.h
EnergeticBark_OpenTTD-3DS/src/direction_func.h
/* $Id$ */ /** @file direction_func.h Different functions related to conversions between directions. */ #ifndef DIRECTION_FUNC_H #define DIRECTION_FUNC_H #include "direction_type.h" /** * Return the reverse of a direction * * @param d The direction to get the reverse from * @return The reverse Direction */ static inline Direction ReverseDir(Direction d) { return (Direction)(4 ^ d); } /** * Calculate the difference between to directions * * @param d0 The first direction as the base * @param d1 The second direction as the offset from the base * @return The difference how the second directions drifts of the first one. */ static inline DirDiff DirDifference(Direction d0, Direction d1) { return (DirDiff)((d0 + 8 - d1) % 8); } /** * Applies two differences together * * This function adds two differences together and return the resulting * difference. So adding two DIRDIFF_REVERSE together results in the * DIRDIFF_SAME difference. * * @param d The first difference * @param delta The second difference to add on * @return The resulting difference */ static inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta) { return (DirDiff)((d + delta) % 8); } /** * Change a direction by a given difference * * This functions returns a new direction of the given direction * which is rotated by the given difference. * * @param d The direction to get a new direction from * @param delta The offset/drift applied to the direction * @return The new direction */ static inline Direction ChangeDir(Direction d, DirDiff delta) { return (Direction)((d + delta) % 8); } /** * Returns the reverse direction of the given DiagDirection * * @param d The DiagDirection to get the reverse from * @return The reverse direction */ static inline DiagDirection ReverseDiagDir(DiagDirection d) { return (DiagDirection)(2 ^ d); } /** * Applies a difference on a DiagDirection * * This function applies a difference on a DiagDirection and returns * the new DiagDirection. * * @param d The DiagDirection * @param delta The difference to applie on * @return The new direction which was calculated */ static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta) { return (DiagDirection)((d + delta) % 4); } /** * Convert a Direction to a DiagDirection. * * This function can be used to convert the 8-way Direction to * the 4-way DiagDirection. If the direction cannot be mapped its * "rounded clockwise". So DIR_N becomes DIAGDIR_NE. * * @param dir The direction to convert * @return The resulting DiagDirection, maybe "rounded clockwise". */ static inline DiagDirection DirToDiagDir(Direction dir) { return (DiagDirection)(dir >> 1); } /** * Convert a DiagDirection to a Direction. * * This function can be used to convert the 4-way DiagDirection * to the 8-way Direction. As 4-way are less than 8-way not all * possible directions can be calculated. * * @param dir The direction to convert * @return The resulting Direction */ static inline Direction DiagDirToDir(DiagDirection dir) { return (Direction)(dir * 2 + 1); } /** * Select the other axis as provided. * * This is basically the not-operator for the axis. * * @param a The given axis * @return The other axis */ static inline Axis OtherAxis(Axis a) { return (Axis)(a ^ 1); } /** * Convert a DiagDirection to the axis. * * This function returns the axis which belongs to the given * DiagDirection. The axis X belongs to the DiagDirection * north-east and south-west. * * @param d The DiagDirection * @return The axis which belongs to the direction */ static inline Axis DiagDirToAxis(DiagDirection d) { return (Axis)(d & 1); } /** * Converts an Axis to a DiagDirection * * This function returns the DiagDirection which * belongs to the axis. As 2 directions are mapped to an axis * this function returns the one which points to south, * either south-west (on X axis) or south-east (on Y axis) * * @param a The axis * @return The direction pointed to south */ static inline DiagDirection AxisToDiagDir(Axis a) { return (DiagDirection)(2 - a); } /** * Converts an Axis to a Direction * * This function returns the Direction which * belongs to the axis. As 2 directions are mapped to an axis * this function returns the one which points to south, * either south-west (on X axis) or south-east (on Y axis) * * @param a The axis * @return The direction pointed to south */ static inline Direction AxisToDirection(Axis a) { return (Direction)(5 - 2 * a); } /** * Convert an axis and a flag for north/south into a DiagDirection * @param xy axis to convert * @param ns north -> 0, south -> 1 * @return the desired DiagDirection */ static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns) { return (DiagDirection)(xy * 3 ^ ns * 2); } /** * Checks if an interger value is a valid DiagDirection * * @param d The value to check * @return True if the value belongs to a DiagDirection, else false */ static inline bool IsValidDiagDirection(DiagDirection d) { return d < DIAGDIR_END; } /** * Checks if an integer value is a valid Direction * * @param d The value to check * @return True if the value belongs to a Direction, else false */ static inline bool IsValidDirection(Direction d) { return d < DIR_END; } /** * Checks if an integer value is a valid Axis * * @param d The value to check * @return True if the value belongs to an Axis, else false */ static inline bool IsValidAxis(Axis d) { return d < AXIS_END; } #endif /* DIRECTION_H */
5,542
C++
.h
204
25.382353
92
0.746988
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,458
slope_func.h
EnergeticBark_OpenTTD-3DS/src/slope_func.h
/* $Id$ */ /** @file slope_func.h Functions related to slopes. */ #ifndef SLOPE_FUNC_H #define SLOPE_FUNC_H #include "core/math_func.hpp" #include "slope_type.h" #include "direction_type.h" #include "tile_type.h" /** * Rangecheck for Corner enumeration. * * @param corner A #Corner. * @return true iff corner is in a valid range. */ static inline bool IsValidCorner(Corner corner) { return IsInsideMM(corner, 0, CORNER_END); } /** * Checks if a slope is steep. * * @param s The given #Slope. * @return True if the slope is steep, else false. */ static inline bool IsSteepSlope(Slope s) { return (s & SLOPE_STEEP) != 0; } /** * Checks for non-continuous slope on halftile foundations. * * @param s The given #Slope. * @return True if the slope is non-continuous, else false. */ static inline bool IsHalftileSlope(Slope s) { return (s & SLOPE_HALFTILE) != 0; } /** * Removes a halftile slope from a slope * * Non-halftile slopes remain unmodified. * * @param s A #Slope. * @return The slope s without it's halftile slope. */ static inline Slope RemoveHalftileSlope(Slope s) { return s & ~SLOPE_HALFTILE_MASK; } /** * Return the complement of a slope. * * This method returns the complement of a slope. The complement of a * slope is a slope with raised corner which aren't raised in the given * slope. * * @pre The slope must neither be steep nor a halftile slope. * @param s The #Slope to get the complement. * @return a complement Slope of the given slope. */ static inline Slope ComplementSlope(Slope s) { assert(!IsSteepSlope(s) && !IsHalftileSlope(s)); return s ^ SLOPE_ELEVATED; } /** * Tests if a specific slope has exactly one corner raised. * * @param s The #Slope * @return true iff exactly one corner is raised */ static inline bool IsSlopeWithOneCornerRaised(Slope s) { return (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N); } /** * Returns the slope with a specific corner raised. * * @param corner The #Corner. * @return The #Slope with corner "corner" raised. */ static inline Slope SlopeWithOneCornerRaised(Corner corner) { assert(IsValidCorner(corner)); return (Slope)(1 << corner); } /** * Tests if a slope has a highest corner (i.e. one corner raised or a steep slope). * * Note: A halftile slope is ignored. * * @param s The #Slope. * @return true iff the slope has a highest corner. */ static inline bool HasSlopeHighestCorner(Slope s) { s = RemoveHalftileSlope(s); return IsSteepSlope(s) || IsSlopeWithOneCornerRaised(s); } /** * Returns the highest corner of a slope (one corner raised or a steep slope). * * @pre The slope must be a slope with one corner raised or a steep slope. A halftile slope is ignored. * @param s The #Slope. * @return Highest corner. */ static inline Corner GetHighestSlopeCorner(Slope s) { switch (RemoveHalftileSlope(s)) { case SLOPE_W: case SLOPE_STEEP_W: return CORNER_W; case SLOPE_S: case SLOPE_STEEP_S: return CORNER_S; case SLOPE_E: case SLOPE_STEEP_E: return CORNER_E; case SLOPE_N: case SLOPE_STEEP_N: return CORNER_N; default: NOT_REACHED(); } } /** * Returns the leveled halftile of a halftile slope. * * @pre The slope must be a halftile slope. * @param s The #Slope. * @return The corner of the leveled halftile. */ static inline Corner GetHalftileSlopeCorner(Slope s) { assert(IsHalftileSlope(s)); return (Corner)((s >> 6) & 3); } /** * Returns the height of the highest corner of a slope relative to TileZ (= minimal height) * * @param s The #Slope. * @return Relative height of highest corner. */ static inline uint GetSlopeMaxZ(Slope s) { if (s == SLOPE_FLAT) return 0; if (IsSteepSlope(s)) return 2 * TILE_HEIGHT; return TILE_HEIGHT; } /** * Returns the opposite corner. * * @param corner A #Corner. * @return The opposite corner to "corner". */ static inline Corner OppositeCorner(Corner corner) { return (Corner)(corner ^ 2); } /** * Tests if a specific slope has exactly three corners raised. * * @param s The #Slope * @return true iff exactly three corners are raised */ static inline bool IsSlopeWithThreeCornersRaised(Slope s) { return !IsHalftileSlope(s) && !IsSteepSlope(s) && IsSlopeWithOneCornerRaised(ComplementSlope(s)); } /** * Returns the slope with all except one corner raised. * * @param corner The #Corner. * @return The #Slope with all corners but "corner" raised. */ static inline Slope SlopeWithThreeCornersRaised(Corner corner) { return ComplementSlope(SlopeWithOneCornerRaised(corner)); } /** * Returns a specific steep slope * * @param corner A #Corner. * @return The steep #Slope with "corner" as highest corner. */ static inline Slope SteepSlope(Corner corner) { return SLOPE_STEEP | SlopeWithThreeCornersRaised(OppositeCorner(corner)); } /** * Tests if a specific slope is an inclined slope. * * @param s The #Slope * @return true iff the slope is inclined. */ static inline bool IsInclinedSlope(Slope s) { return (s == SLOPE_NW) || (s == SLOPE_SW) || (s == SLOPE_SE) || (s == SLOPE_NE); } /** * Returns the direction of an inclined slope. * * @param s A #Slope * @return The direction the slope goes up in. Or INVALID_DIAGDIR if the slope is not an inclined slope. */ static inline DiagDirection GetInclinedSlopeDirection(Slope s) { switch (s) { case SLOPE_NE: return DIAGDIR_NE; case SLOPE_SE: return DIAGDIR_SE; case SLOPE_SW: return DIAGDIR_SW; case SLOPE_NW: return DIAGDIR_NW; default: return INVALID_DIAGDIR; } } /** * Returns the slope, that is inclined in a specific direction. * * @param dir A #DiagDirection * @return The #Slope that goes up in direction dir. */ static inline Slope InclinedSlope(DiagDirection dir) { switch (dir) { case DIAGDIR_NE: return SLOPE_NE; case DIAGDIR_SE: return SLOPE_SE; case DIAGDIR_SW: return SLOPE_SW; case DIAGDIR_NW: return SLOPE_NW; default: NOT_REACHED(); } } /** * Adds a halftile slope to a slope. * * @param s #Slope without a halftile slope. * @param corner The #Corner of the halftile. * @return The #Slope s with the halftile slope added. */ static inline Slope HalftileSlope(Slope s, Corner corner) { assert(IsValidCorner(corner)); return (Slope)(s | SLOPE_HALFTILE | (corner << 6)); } /** * Tests for FOUNDATION_NONE. * * @param f Maybe a #Foundation. * @return true iff f is a foundation. */ static inline bool IsFoundation(Foundation f) { return f != FOUNDATION_NONE; } /** * Tests if the foundation is a leveled foundation. * * @param f The #Foundation. * @return true iff f is a leveled foundation. */ static inline bool IsLeveledFoundation(Foundation f) { return f == FOUNDATION_LEVELED; } /** * Tests if the foundation is an inclined foundation. * * @param f The #Foundation. * @return true iff f is an inclined foundation. */ static inline bool IsInclinedFoundation(Foundation f) { return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y); } /** * Tests if a foundation is a non-continuous foundation, i.e. halftile-foundation or FOUNDATION_STEEP_BOTH. * * @param f The #Foundation. * @return true iff f is a non-continuous foundation */ static inline bool IsNonContinuousFoundation(Foundation f) { return IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1); } /** * Returns the halftile corner of a halftile-foundation * * @pre f != FOUNDATION_STEEP_BOTH * * @param f The #Foundation. * @return The #Corner with track. */ static inline Corner GetHalftileFoundationCorner(Foundation f) { assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1)); return (Corner)(f - FOUNDATION_HALFTILE_W); } /** * Tests if a foundation is a special rail foundation for single horizontal/vertical track. * * @param f The #Foundation. * @return true iff f is a special rail foundation for single horizontal/vertical track. */ static inline bool IsSpecialRailFoundation(Foundation f) { return IsInsideMM(f, FOUNDATION_RAIL_W, FOUNDATION_RAIL_N + 1); } /** * Returns the track corner of a special rail foundation * * @param f The #Foundation. * @return The #Corner with track. */ static inline Corner GetRailFoundationCorner(Foundation f) { assert(IsSpecialRailFoundation(f)); return (Corner)(f - FOUNDATION_RAIL_W); } /** * Returns the foundation needed to flatten a slope. * The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED. * * @param s The current #Slope. * @return The needed #Foundation. */ static inline Foundation FlatteningFoundation(Slope s) { return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED); } /** * Returns the along a specific axis inclined foundation. * * @param axis The #Axis. * @return The needed #Foundation. */ static inline Foundation InclinedFoundation(Axis axis) { return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y); } /** * Returns the halftile foundation for single horizontal/vertical track. * * @param corner The #Corner with the track. * @return The wanted #Foundation. */ static inline Foundation HalftileFoundation(Corner corner) { assert(IsValidCorner(corner)); return (Foundation)(FOUNDATION_HALFTILE_W + corner); } /** * Returns the special rail foundation for single horizontal/vertical track. * * @param corner The #Corner with the track. * @return The wanted #Foundation. */ static inline Foundation SpecialRailFoundation(Corner corner) { assert(IsValidCorner(corner)); return (Foundation)(FOUNDATION_RAIL_W + corner); } #endif /* SLOPE_FUNC_H */
9,606
C++
.h
357
25.114846
108
0.732335
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,459
depot_base.h
EnergeticBark_OpenTTD-3DS/src/depot_base.h
/* $Id$ */ /** @file depot_base.h Base for all depots (except hangars) */ #ifndef DEPOT_BASE_H #define DEPOT_BASE_H #include "tile_type.h" #include "depot_type.h" #include "oldpool.h" #include "town_type.h" DECLARE_OLD_POOL(Depot, Depot, 3, 8000) struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> { TileIndex xy; TownID town_index; Depot(TileIndex xy = INVALID_TILE) : xy(xy) {} ~Depot(); inline bool IsValid() const { return this->xy != INVALID_TILE; } }; static inline bool IsValidDepotID(DepotID index) { return index < GetDepotPoolSize() && GetDepot(index)->IsValid(); } Depot *GetDepotByTile(TileIndex tile); #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid()) #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0) #endif /* DEPOT_BASE_H */
881
C++
.h
24
35
167
0.70331
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,460
sortlist_type.h
EnergeticBark_OpenTTD-3DS/src/sortlist_type.h
/* $Id$ */ /** @file sortlist_type.h Base types for having sorted lists in GUIs. */ #ifndef SORTLIST_TYPE_H #define SORTLIST_TYPE_H #include "core/enum_type.hpp" #include "core/bitmath_func.hpp" #include "core/mem_func.hpp" #include "core/sort_func.hpp" #include "core/smallvec_type.hpp" #include "date_type.h" enum SortListFlags { VL_NONE = 0, ///< no sort VL_DESC = 1 << 0, ///< sort descending or ascending VL_RESORT = 1 << 1, ///< instruct the code to resort the list in the next loop VL_REBUILD = 1 << 2, ///< rebuild the sort list VL_FIRST_SORT = 1 << 3, ///< sort with qsort first VL_FILTER = 1 << 4, ///< filter disabled/enabled VL_END = 1 << 5, }; DECLARE_ENUM_AS_BIT_SET(SortListFlags); struct Listing { bool order; ///< Ascending/descending byte criteria; ///< Sorting criteria }; struct Filtering { bool state; ///< Filter on/off byte criteria; ///< Filtering criteria }; template <typename T, typename F = const char*> class GUIList : public SmallVector<T, 32> { public: typedef int CDECL SortFunction(const T*, const T*); typedef bool CDECL FilterFunction(const T*, F); protected: SortFunction * const *sort_func_list; ///< the sort criteria functions FilterFunction * const *filter_func_list; ///< the filter criteria functions SortListFlags flags; ///< used to control sorting/resorting/etc. uint8 sort_type; ///< what criteria to sort on uint8 filter_type; ///< what criteria to filter on uint16 resort_timer; ///< resort list after a given amount of ticks if set /** * Check if the list is sortable * * @return true if we can sort the list */ bool IsSortable() const { return (this->data != NULL && this->items >= 2); } /** * Reset the resort timer */ void ResetResortTimer() { /* Resort every 10 days */ this->resort_timer = DAY_TICKS * 10; } public: GUIList() : sort_func_list(NULL), filter_func_list(NULL), flags(VL_FIRST_SORT), sort_type(0), filter_type(0), resort_timer(1) {}; /** * Get the sorttype of the list * * @return The current sorttype */ uint8 SortType() const { return this->sort_type; } /** * Set the sorttype of the list * * @param n_type the new sort type */ void SetSortType(uint8 n_type) { if (this->sort_type != n_type) { SETBITS(this->flags, VL_RESORT | VL_FIRST_SORT); this->sort_type = n_type; } } /** * Export current sort conditions * * @return the current sort conditions */ Listing GetListing() const { Listing l; l.order = HASBITS(this->flags, VL_DESC); l.criteria = this->sort_type; return l; } /** * Import sort conditions * * @param l The sort conditions we want to use */ void SetListing(Listing l) { if (l.order) { SETBITS(this->flags, VL_DESC); } else { CLRBITS(this->flags, VL_DESC); } this->sort_type = l.criteria; SETBITS(this->flags, VL_FIRST_SORT); } /** * Get the filtertype of the list * * @return The current filtertype */ uint8 FilterType() const { return this->filter_type; } /** * Set the filtertype of the list * * @param n_type the new filter type */ void SetFilterType(uint8 n_type) { if (this->filter_type != n_type) { this->filter_type = n_type; } } /** * Export current filter conditions * * @return the current filter conditions */ Filtering GetFiltering() const { Filtering f; f.state = HASBITS(this->flags, VL_FILTER); f.criteria = this->filter_type; return f; } /** * Import filter conditions * * @param f The filter conditions we want to use */ void SetFiltering(Filtering f) { if (f.state) { SETBITS(this->flags, VL_FILTER); } else { CLRBITS(this->flags, VL_FILTER); } this->filter_type = f.criteria; } /** * Check if a resort is needed next loop * If used the resort timer will decrease every call * till 0. If 0 reached the resort bit will be set and * the timer will be reset. * * @return true if resort bit is set for next loop */ bool NeedResort() { if (--this->resort_timer == 0) { SETBITS(this->flags, VL_RESORT); this->ResetResortTimer(); return true; } return false; } /** * Force a resort next Sort call * Reset the resort timer if used too. */ void ForceResort() { SETBITS(this->flags, VL_RESORT); } /** * Check if the sort order is descending * * @return true if the sort order is descending */ bool IsDescSortOrder() const { return HASBITS(this->flags, VL_DESC); } /** * Toogle the sort order * Since that is the worst condition for the sort function * reverse the list here. */ void ToggleSortOrder() { this->flags ^= VL_DESC; if (this->IsSortable()) MemReverseT(this->data, this->items); } /** * Sort the list. * For the first sorting we use qsort since it is * faster for irregular sorted data. After that we * use gsort. * * @param compare The function to compare two list items * @return true if the list sequence has been altered * */ bool Sort(SortFunction *compare) { /* Do not sort if the resort bit is not set */ if (!HASBITS(this->flags, VL_RESORT)) return false; CLRBITS(this->flags, VL_RESORT); this->ResetResortTimer(); /* Do not sort when the list is not sortable */ if (!this->IsSortable()) return false; const bool desc = HASBITS(this->flags, VL_DESC); if (HASBITS(this->flags, VL_FIRST_SORT)) { CLRBITS(this->flags, VL_FIRST_SORT); QSortT(this->data, this->items, compare, desc); return true; } GSortT(this->data, this->items, compare, desc); return true; } /** * Hand the array of sort function pointers to the sort list * * @param n_funcs The pointer to the first sort func */ void SetSortFuncs(SortFunction * const *n_funcs) { this->sort_func_list = n_funcs; } /** * Overload of Sort() * Overloaded to reduce external code * * @return true if the list sequence has been altered */ bool Sort() { assert(this->sort_func_list != NULL); return this->Sort(this->sort_func_list[this->sort_type]); } /** * Check if the filter is enabled * * @return true if the filter is enabled */ bool IsFilterEnabled() const { return HASBITS(this->flags, VL_FILTER); } /** * Enable or disable the filter * * @param state If filtering should be enabled or disabled */ void SetFilterState(bool state) { if (state) { SETBITS(this->flags, VL_FILTER); } else { CLRBITS(this->flags, VL_FILTER); } } /** * Filter the list. * * @param decide The function to decide about an item * @param filter_data Additional data passed to the filter function * @return true if the list has been altered by filtering */ bool Filter(FilterFunction *decide, F filter_data) { /* Do not filter if the filter bit is not set */ if (!HASBITS(this->flags, VL_FILTER)) return false; bool changed = false; for (uint iter = 0; iter < this->items;) { T *item = &this->data[iter]; if (!decide(item, filter_data)) { this->Erase(item); changed = true; } else { iter++; } } return changed; } /** * Hand the array of filter function pointers to the sort list * * @param n_funcs The pointer to the first filter func */ void SetFilterFuncs(FilterFunction * const *n_funcs) { this->filter_func_list = n_funcs; } /** * Filter the data with the currently selected filter. * * @param filter_data Additional data passed to the filter function. * @return true if the list has been altered by filtering */ bool Filter(F filter_data) { if (this->filter_func_list == NULL) return false; return this->Filter(this->filter_func_list[this->filter_type], filter_data); } /** * Check if a rebuild is needed * @return true if a rebuild is needed */ bool NeedRebuild() const { return HASBITS(this->flags, VL_REBUILD); } /** * Force that a rebuild is needed */ void ForceRebuild() { SETBITS(this->flags, VL_REBUILD); } /** * Notify the sortlist that the rebuild is done * * @note This forces a resort */ void RebuildDone() { CLRBITS(this->flags, VL_REBUILD); SETBITS(this->flags, VL_RESORT | VL_FIRST_SORT); } }; #endif /* SORTLIST_TYPE_H */
8,304
C++
.h
342
21.564327
96
0.668099
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,462
bridge_map.h
EnergeticBark_OpenTTD-3DS/src/bridge_map.h
/* $Id$ */ /** @file bridge_map.h Map accessor functions for bridges. */ #ifndef BRIDGE_MAP_H #define BRIDGE_MAP_H #include "direction_func.h" #include "rail_type.h" #include "transport_type.h" #include "road_map.h" #include "bridge.h" /** * Checks if this is a bridge, instead of a tunnel * @param t The tile to analyze * @pre IsTileType(t, MP_TUNNELBRIDGE) * @return true if the structure is a bridge one */ static inline bool IsBridge(TileIndex t) { assert(IsTileType(t, MP_TUNNELBRIDGE)); return HasBit(_m[t].m5, 7); } /** * checks if there is a bridge on this tile * @param t The tile to analyze * @return true if a bridge is present */ static inline bool IsBridgeTile(TileIndex t) { return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t); } /** * checks for the possibility that a bridge may be on this tile * These are in fact all the tile types on which a bridge can be found * @param t The tile to analyze * @return true if a bridge migh be present */ static inline bool MayHaveBridgeAbove(TileIndex t) { return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) || IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_UNMOVABLE); } /** * checks if a bridge is set above the ground of this tile * @param t The tile to analyze * @pre MayHaveBridgeAbove(t) * @return true if a bridge is detected above */ static inline bool IsBridgeAbove(TileIndex t) { assert(MayHaveBridgeAbove(t)); return GB(_m[t].m6, 6, 2) != 0; } /** * Determines the type of bridge on a tile * @param t The tile to analyze * @pre IsBridgeTile(t) * @return The bridge type */ static inline BridgeType GetBridgeType(TileIndex t) { assert(IsBridgeTile(t)); return GB(_m[t].m6, 2, 4); } /** * Get the axis of the bridge that goes over the tile. Not the axis or the ramp. * @param t The tile to analyze * @pre IsBridgeAbove(t) * @return the above mentioned axis */ static inline Axis GetBridgeAxis(TileIndex t) { assert(IsBridgeAbove(t)); return (Axis)(GB(_m[t].m6, 6, 2) - 1); } /** * Finds the end of a bridge in the specified direction starting at a middle tile * @param t the bridge tile to find the bridge ramp for * @param d the direction to search in */ TileIndex GetBridgeEnd(TileIndex t, DiagDirection d); /** * Finds the northern end of a bridge starting at a middle tile * @param t the bridge tile to find the bridge ramp for */ TileIndex GetNorthernBridgeEnd(TileIndex t); /** * Finds the southern end of a bridge starting at a middle tile * @param t the bridge tile to find the bridge ramp for */ TileIndex GetSouthernBridgeEnd(TileIndex t); /** * Starting at one bridge end finds the other bridge end * @param t the bridge ramp tile to find the other bridge ramp for */ TileIndex GetOtherBridgeEnd(TileIndex t); /** * Get the height ('z') of a bridge in pixels. * @param tile the bridge ramp tile to get the bridge height from * @return the height of the bridge in pixels */ uint GetBridgeHeight(TileIndex tile); /** * Remove the bridge over the given axis. * @param t the tile to remove the bridge from * @param a the axis of the bridge to remove * @pre MayHaveBridgeAbove(t) */ static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a) { assert(MayHaveBridgeAbove(t)); ClrBit(_m[t].m6, 6 + a); } /** * Removes bridges from the given, that is bridges along the X and Y axis. * @param t the tile to remove the bridge from * @pre MayHaveBridgeAbove(t) */ static inline void ClearBridgeMiddle(TileIndex t) { ClearSingleBridgeMiddle(t, AXIS_X); ClearSingleBridgeMiddle(t, AXIS_Y); } /** * Set that there is a bridge over the given axis. * @param t the tile to add the bridge to * @param a the axis of the bridge to add * @pre MayHaveBridgeAbove(t) */ static inline void SetBridgeMiddle(TileIndex t, Axis a) { assert(MayHaveBridgeAbove(t)); SetBit(_m[t].m6, 6 + a); } /** * Generic part to make a bridge ramp for both roads and rails. * @param t the tile to make a bridge ramp * @param o the new owner of the bridge ramp * @param bridgetype the type of bridge this bridge ramp belongs to * @param d the direction this ramp must be facing * @param tt the transport type of the bridge * @param rt the road or rail type * @note this function should not be called directly. */ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, uint rt) { SetTileType(t, MP_TUNNELBRIDGE); SetTileOwner(t, o); _m[t].m2 = 0; _m[t].m3 = rt; _m[t].m4 = 0; _m[t].m5 = 1 << 7 | tt << 2 | d; SB(_m[t].m6, 2, 4, bridgetype); _me[t].m7 = 0; } /** * Make a bridge ramp for roads. * @param t the tile to make a bridge ramp * @param o the new owner of the bridge ramp * @param bridgetype the type of bridge this bridge ramp belongs to * @param d the direction this ramp must be facing * @param r the road type of the bridge */ static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RoadTypes r) { MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0); SetRoadOwner(t, ROADTYPE_ROAD, o); if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o); SetRoadTypes(t, r); } /** * Make a bridge ramp for rails. * @param t the tile to make a bridge ramp * @param o the new owner of the bridge ramp * @param bridgetype the type of bridge this bridge ramp belongs to * @param d the direction this ramp must be facing * @param r the rail type of the bridge */ static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r) { MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL, r); } /** * Make a bridge ramp for aqueducts. * @param t the tile to make a bridge ramp * @param o the new owner of the bridge ramp * @param d the direction this ramp must be facing */ static inline void MakeAqueductBridgeRamp(TileIndex t, Owner o, DiagDirection d) { MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER, 0); } #endif /* BRIDGE_MAP_H */
6,168
C++
.h
196
29.688776
122
0.714574
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,463
water.h
EnergeticBark_OpenTTD-3DS/src/water.h
/* $Id$ */ /** @file water.h Functions related to water (management) */ #ifndef WATER_H #define WATER_H void TileLoop_Water(TileIndex tile); bool FloodHalftile(TileIndex t); void DoFloodTile(TileIndex target); void ConvertGroundTilesIntoWaterTiles(); void DrawShipDepotSprite(int x, int y, int image); void DrawWaterClassGround(const struct TileInfo *ti); void DrawShoreTile(Slope tileh); void MakeWaterKeepingClass(TileIndex tile, Owner o); #endif /* WATER_H */
470
C++
.h
13
34.615385
60
0.795556
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,464
clear_map.h
EnergeticBark_OpenTTD-3DS/src/clear_map.h
/* $Id$ */ /** @file clear_map.h Map accessors for 'clear' tiles */ #ifndef CLEAR_MAP_H #define CLEAR_MAP_H #include "bridge_map.h" #include "industry_type.h" /** * Ground types. Valid densities in comments after the enum. */ enum ClearGround { CLEAR_GRASS = 0, ///< 0-3 CLEAR_ROUGH = 1, ///< 3 CLEAR_ROCKS = 2, ///< 3 CLEAR_FIELDS = 3, ///< 3 CLEAR_SNOW = 4, ///< 0-3 CLEAR_DESERT = 5 ///< 1,3 }; /** * Get the type of clear tile. * @param t the tile to get the clear ground type of * @pre IsTileType(t, MP_CLEAR) * @return the ground type */ static inline ClearGround GetClearGround(TileIndex t) { assert(IsTileType(t, MP_CLEAR)); return (ClearGround)GB(_m[t].m5, 2, 3); } /** * Set the type of clear tile. * @param t the tile to set the clear ground type of * @param ct the ground type * @pre IsTileType(t, MP_CLEAR) */ static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; } /** * Get the density of a non-field clear tile. * @param t the tile to get the density of * @pre IsTileType(t, MP_CLEAR) * @return the density */ static inline uint GetClearDensity(TileIndex t) { assert(IsTileType(t, MP_CLEAR)); return GB(_m[t].m5, 0, 2); } /** * Increment the density of a non-field clear tile. * @param t the tile to increment the density of * @param d the amount to increment the density with * @pre IsTileType(t, MP_CLEAR) */ static inline void AddClearDensity(TileIndex t, int d) { assert(IsTileType(t, MP_CLEAR)); // XXX incomplete _m[t].m5 += d; } /** * Get the counter used to advance to the next clear density/field type. * @param t the tile to get the counter of * @pre IsTileType(t, MP_CLEAR) * @return the value of the counter */ static inline uint GetClearCounter(TileIndex t) { assert(IsTileType(t, MP_CLEAR)); return GB(_m[t].m5, 5, 3); } /** * Increments the counter used to advance to the next clear density/field type. * @param t the tile to increment the counter of * @param c the amount to increment the counter with * @pre IsTileType(t, MP_CLEAR) */ static inline void AddClearCounter(TileIndex t, int c) { assert(IsTileType(t, MP_CLEAR)); // XXX incomplete _m[t].m5 += c << 5; } /** * Sets the counter used to advance to the next clear density/field type. * @param t the tile to set the counter of * @param c the amount to set the counter to * @pre IsTileType(t, MP_CLEAR) */ static inline void SetClearCounter(TileIndex t, uint c) { assert(IsTileType(t, MP_CLEAR)); // XXX incomplete SB(_m[t].m5, 5, 3, c); } /** * Sets ground type and density in one go, also sets the counter to 0 * @param t the tile to set the ground type and density for * @param type the new ground type of the tile * @param density the density of the ground tile * @pre IsTileType(t, MP_CLEAR) */ static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) { assert(IsTileType(t, MP_CLEAR)); // XXX incomplete _m[t].m5 = 0 << 5 | type << 2 | density; } /** * Get the field type (production stage) of the field * @param t the field to get the type of * @pre GetClearGround(t) == CLEAR_FIELDS * @return the field type */ static inline uint GetFieldType(TileIndex t) { assert(GetClearGround(t) == CLEAR_FIELDS); return GB(_m[t].m3, 0, 4); } /** * Set the field type (production stage) of the field * @param t the field to get the type of * @param f the field type * @pre GetClearGround(t) == CLEAR_FIELDS */ static inline void SetFieldType(TileIndex t, uint f) { assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete SB(_m[t].m3, 0, 4, f); } /** * Get the industry (farm) that made the field * @param t the field to get creating industry of * @pre GetClearGround(t) == CLEAR_FIELDS * @return the industry that made the field */ static inline IndustryID GetIndustryIndexOfField(TileIndex t) { assert(GetClearGround(t) == CLEAR_FIELDS); return(IndustryID) _m[t].m2; } /** * Set the industry (farm) that made the field * @param t the field to get creating industry of * @param i the industry that made the field * @pre GetClearGround(t) == CLEAR_FIELDS */ static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i) { assert(GetClearGround(t) == CLEAR_FIELDS); _m[t].m2 = i; } /** * Is there a fence at the south eastern border? * @param t the tile to check for fences * @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) * @return 0 if there is no fence, otherwise the fence type */ static inline uint GetFenceSE(TileIndex t) { assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); return GB(_m[t].m4, 2, 3); } /** * Sets the type of fence (and whether there is one) for the south * eastern border. * @param t the tile to check for fences * @param h 0 if there is no fence, otherwise the fence type * @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) */ static inline void SetFenceSE(TileIndex t, uint h) { assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete SB(_m[t].m4, 2, 3, h); } /** * Is there a fence at the south western border? * @param t the tile to check for fences * @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) * @return 0 if there is no fence, otherwise the fence type */ static inline uint GetFenceSW(TileIndex t) { assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); return GB(_m[t].m4, 5, 3); } /** * Sets the type of fence (and whether there is one) for the south * western border. * @param t the tile to check for fences * @param h 0 if there is no fence, otherwise the fence type * @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) */ static inline void SetFenceSW(TileIndex t, uint h) { assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete SB(_m[t].m4, 5, 3, h); } /** * Make a clear tile. * @param t the tile to make a clear tile * @param g the type of ground * @param density the density of the grass/snow/desert etc */ static inline void MakeClear(TileIndex t, ClearGround g, uint density) { /* If this is a non-bridgeable tile, clear the bridge bits while the rest * of the tile information is still here. */ if (!MayHaveBridgeAbove(t)) SB(_m[t].m6, 6, 2, 0); SetTileType(t, MP_CLEAR); SetTileOwner(t, OWNER_NONE); _m[t].m2 = 0; _m[t].m3 = 0; _m[t].m4 = 0 << 5 | 0 << 2; SetClearGroundDensity(t, g, density); // Sets m5 SB(_m[t].m6, 2, 4, 0); // Other bits are "tropic zone" and "bridge above" _me[t].m7 = 0; } /** * Make a (farm) field tile. * @param t the tile to make a farm field * @param field_type the 'growth' level of the field * @param industry the industry this tile belongs to */ static inline void MakeField(TileIndex t, uint field_type, IndustryID industry) { SetTileType(t, MP_CLEAR); SetTileOwner(t, OWNER_NONE); _m[t].m2 = industry; _m[t].m3 = field_type; _m[t].m4 = 0 << 5 | 0 << 2; SetClearGroundDensity(t, CLEAR_FIELDS, 3); SB(_m[t].m6, 2, 4, 0); _me[t].m7 = 0; } #endif /* CLEAR_MAP_H */
7,020
C++
.h
233
28.339056
85
0.696225
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,465
zoom_func.h
EnergeticBark_OpenTTD-3DS/src/zoom_func.h
/* $Id$ */ /** @file zoom_func.h Functions related to zooming. */ #ifndef ZOOM_FUNC_H #define ZOOM_FUNC_H #include "zoom_type.h" extern ZoomLevel _saved_scrollpos_zoom; /** * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) * When shifting right, value is rounded up * @param value value to shift * @param zoom zoom level to shift to * @return shifted value */ static inline int ScaleByZoom(int value, ZoomLevel zoom) { if (zoom == ZOOM_LVL_NORMAL) return value; int izoom = zoom - ZOOM_LVL_NORMAL; return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom; } /** * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) * When shifting right, value is rounded up * @param value value to shift * @param zoom zoom level to shift to * @return shifted value */ static inline int UnScaleByZoom(int value, ZoomLevel zoom) { if (zoom == ZOOM_LVL_NORMAL) return value; int izoom = zoom - ZOOM_LVL_NORMAL; return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom; } /** * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) * @param value value to shift * @param zoom zoom level to shift to * @return shifted value */ static inline int ScaleByZoomLower(int value, ZoomLevel zoom) { if (zoom == ZOOM_LVL_NORMAL) return value; int izoom = zoom - ZOOM_LVL_NORMAL; return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom; } /** * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) * @param value value to shift * @param zoom zoom level to shift to * @return shifted value */ static inline int UnScaleByZoomLower(int value, ZoomLevel zoom) { if (zoom == ZOOM_LVL_NORMAL) return value; int izoom = zoom - ZOOM_LVL_NORMAL; return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom; } #endif /* ZOOM_FUNC_H */
1,898
C++
.h
57
31.54386
90
0.703603
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,466
ship.h
EnergeticBark_OpenTTD-3DS/src/ship.h
/* $Id$ */ /** @file ship.h Base for ships. */ #ifndef SHIP_H #define SHIP_H #include "vehicle_base.h" #include "engine_func.h" #include "engine_base.h" #include "economy_func.h" void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2); void RecalcShipStuff(Vehicle *v); void GetShipSpriteSize(EngineID engine, uint &width, uint &height); /** * This class 'wraps' Vehicle; you do not actually instantiate this class. * You create a Vehicle using AllocateVehicle, so it is added to the pool * and you reinitialize that to a Train using: * v = new (v) Ship(); * * As side-effect the vehicle type is set correctly. */ struct Ship: public Vehicle { /** Initializes the Vehicle to a ship */ Ship() { this->type = VEH_SHIP; } /** We want to 'destruct' the right class. */ virtual ~Ship() { this->PreDestructor(); } const char *GetTypeString() const { return "ship"; } void MarkDirty(); void UpdateDeltaXY(Direction direction); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; } void PlayLeaveStationSound() const; bool IsPrimaryVehicle() const { return true; } SpriteID GetImage(Direction direction) const; int GetDisplaySpeed() const { return this->cur_speed / 2; } int GetDisplayMaxSpeed() const { return this->max_speed / 2; } Money GetRunningCost() const; bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; } void Tick(); void OnNewDay(); TileIndex GetOrderStationLocation(StationID station); bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); }; #endif /* SHIP_H */
1,624
C++
.h
41
37.780488
106
0.739048
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,467
texteff.hpp
EnergeticBark_OpenTTD-3DS/src/texteff.hpp
/* $Id$ */ /** @file texteff.hpp Functions related to text effects. */ #ifndef TEXTEFF_HPP #define TEXTEFF_HPP #include "gfx_type.h" /** * Text effect modes. */ enum TextEffectMode { TE_RISING, ///< Make the text effect slowly go upwards TE_STATIC, ///< Keep the text effect static INVALID_TE_ID = 0xFFFF, }; typedef uint16 TextEffectID; void MoveAllTextEffects(); TextEffectID AddTextEffect(StringID msg, int x, int y, uint16 duration, TextEffectMode mode); void InitTextEffects(); void DrawTextEffects(DrawPixelInfo *dpi); void UpdateTextEffect(TextEffectID effect_id, StringID msg); void RemoveTextEffect(TextEffectID effect_id); /* misc_gui.cpp */ TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID colour); void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID colour); void HideFillingPercent(TextEffectID *te_id); #endif /* TEXTEFF_HPP */
902
C++
.h
25
34.52
93
0.781106
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
true
true
false
1,539,468
command_func.h
EnergeticBark_OpenTTD-3DS/src/command_func.h
/* $Id$ */ /** @file command_func.h Functions related to commands. */ #ifndef COMMAND_FUNC_H #define COMMAND_FUNC_H #include "command_type.h" /** * Checks if a command failes. * * As you see the parameter is not a command but the return value of a command, * the CommandCost class. This function checks if the command executed by * the CommandProc function failed and returns true if it does. * * @param cost The return value of a CommandProc call * @return true if the command failes * @see CmdSucceded */ static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); } /** * Checks if a command succeeded. * * As #CmdFailed this function checks if a command succeeded * * @param cost The return value of a CommandProc call * @return true if the command succeeded * @see CmdSucceeded */ static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); } /** * Define a default return value for a failed command. * * This variable contains a CommandCost object with is declared as "failed". * Other functions just need to return this error if there is an error, * which doesn't need to specific by a StringID. */ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID); /** * Returns from a function with a specific StringID as error. * * This macro is used to return from a function. The parameter contains the * StringID which will be returned. * * @param errcode The StringID to return */ #define return_cmd_error(errcode) return CommandCost(errcode); /** * Execute a command */ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL); CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags); /** * Execute a network safe DoCommand function */ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true); bool DoCommandP(const CommandContainer *container, bool my_cmd = true); #ifdef ENABLE_NETWORK /** * Send a command over the network */ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text); #endif /* ENABLE_NETWORK */ extern Money _additional_cash_required; extern StringID _error_message; /** * Checks if a integer value belongs to a command. */ bool IsValidCommand(uint32 cmd); /** * Returns the flags from a given command. */ byte GetCommandFlags(uint32 cmd); /** * Returns the current money available which can be used for a command. */ Money GetAvailableMoneyForCommand(); /** * Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags * @param cmd_flags Flags from GetCommandFlags * @return flags for DoCommand */ static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags) { DoCommandFlag flags = DC_NONE; if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER; if (cmd_flags & CMD_AUTO) flags |= DC_AUTO; if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES; return flags; } #endif /* COMMAND_FUNC_H */
3,085
C++
.h
88
33.295455
145
0.759557
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,469
livery.h
EnergeticBark_OpenTTD-3DS/src/livery.h
/* $Id$ */ /** @file livery.h Functions/types related to livery colours. */ #ifndef LIVERY_H #define LIVERY_H #include "company_type.h" /* List of different livery schemes. */ enum LiveryScheme { LS_BEGIN = 0, LS_DEFAULT = 0, /* Rail vehicles */ LS_STEAM, LS_DIESEL, LS_ELECTRIC, LS_MONORAIL, LS_MAGLEV, LS_DMU, LS_EMU, LS_PASSENGER_WAGON_STEAM, LS_PASSENGER_WAGON_DIESEL, LS_PASSENGER_WAGON_ELECTRIC, LS_PASSENGER_WAGON_MONORAIL, LS_PASSENGER_WAGON_MAGLEV, LS_FREIGHT_WAGON, /* Road vehicles */ LS_BUS, LS_TRUCK, /* Ships */ LS_PASSENGER_SHIP, LS_FREIGHT_SHIP, /* Aircraft */ LS_HELICOPTER, LS_SMALL_PLANE, LS_LARGE_PLANE, /* Trams (appear on Road Vehicles tab) */ LS_PASSENGER_TRAM, LS_FREIGHT_TRAM, LS_END }; DECLARE_POSTFIX_INCREMENT(LiveryScheme); /* List of different livery classes, used only by the livery GUI. */ enum LiveryClass { LC_OTHER, LC_RAIL, LC_ROAD, LC_SHIP, LC_AIRCRAFT, LC_END }; struct Livery { bool in_use; ///< Set if this livery should be used instead of the default livery. byte colour1; ///< First colour, for all vehicles. byte colour2; ///< Second colour, for vehicles with 2CC support. }; /** * Reset the livery schemes to the company's primary colour. * This is used on loading games without livery information and on new company start up. * @param c Company to reset. */ void ResetCompanyLivery(Company *c); #endif /* LIVERY_H */
1,422
C++
.h
60
21.716667
88
0.732541
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,470
viewport_func.h
EnergeticBark_OpenTTD-3DS/src/viewport_func.h
/* $Id$ */ /** @file viewport_func.h Functions related to (drawing on) viewports. */ #ifndef VIEWPORT_FUNC_H #define VIEWPORT_FUNC_H #include "gfx_type.h" #include "viewport_type.h" #include "vehicle_type.h" #include "strings_type.h" #include "window_type.h" #include "tile_type.h" void SetSelectionRed(bool); void DeleteWindowViewport(Window *w); void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom); ViewPort *IsPtInWindowViewport(const Window *w, int x, int y); Point GetTileBelowCursor(); void UpdateViewportPosition(Window *w); void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str); bool DoZoomInOutWindow(int how, Window *w); void ZoomInOrOutToCursorWindow(bool in, Window * w); Point GetTileZoomCenterWindow(bool in, Window * w); void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out); static inline void MaxZoomInOut(int how, Window *w) { while (DoZoomInOutWindow(how, w)) {}; } void OffsetGroundSprite(int x, int y); void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL); void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL); void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL); void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 colour = 0, uint16 width = 0); void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL); void StartSpriteCombine(); void EndSpriteCombine(); bool HandleViewportClicked(const ViewPort *vp, int x, int y); void PlaceObject(); void SetRedErrorSquare(TileIndex tile); void SetTileSelectSize(int w, int h); void SetTileSelectBigSize(int ox, int oy, int sx, int sy); Vehicle *CheckMouseOverVehicle(); void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom); bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant = false); bool ScrollMainWindowToTile(TileIndex tile, bool instant = false); bool ScrollMainWindowTo(int x, int y, int z = -1, bool instant = false); extern Point _tile_fract_coords; #endif /* VIEWPORT_FUNC_H */
2,403
C++
.h
45
51.977778
220
0.770513
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,471
ini_type.h
EnergeticBark_OpenTTD-3DS/src/ini_type.h
/* $Id$ */ /** @file ini_type.h Types related to reading/writing '*.ini' files. */ #ifndef INI_TYPE_H #define INI_TYPE_H /** Types of groups */ enum IniGroupType { IGT_VARIABLES = 0, ///< values of the form "landscape = hilly" IGT_LIST = 1, ///< a list of values, seperated by \n and terminated by the next group block }; /** A single "line" in an ini file. */ struct IniItem { IniItem *next; ///< The next item in this group char *name; ///< The name of this item char *value; ///< The value of this item char *comment; ///< The comment associated with this item /** * Construct a new in-memory item of an Ini file. * @param parent the group we belong to * @param name the name of the item * @param len the length of the name of the item */ IniItem(struct IniGroup *parent, const char *name, size_t len = 0); /** Free everything we loaded. */ ~IniItem(); /** * Replace the current value with another value. * @param value the value to replace with. */ void SetValue(const char *value); }; /** A group within an ini file. */ struct IniGroup { IniGroup *next; ///< the next group within this file IniGroupType type; ///< type of group IniItem *item; ///< the first item in the group IniItem **last_item; ///< the last item in the group char *name; ///< name of group char *comment; ///< comment for group /** * Construct a new in-memory group of an Ini file. * @param parent the file we belong to * @param name the name of the group * @param len the length of the name of the group */ IniGroup(struct IniFile *parent, const char *name, size_t len = 0); /** Free everything we loaded. */ ~IniGroup(); /** * Get the item with the given name, and if it doesn't exist * and create is true it creates a new item. * @param name name of the item to find. * @param create whether to create an item when not found or not. * @return the requested item or NULL if not found. */ IniItem *GetItem(const char *name, bool create); /** * Clear all items in the group */ void Clear(); }; /** The complete ini file. */ struct IniFile { IniGroup *group; ///< the first group in the ini IniGroup **last_group; ///< the last group in the ini char *comment; ///< last comment in file const char **list_group_names; ///< NULL terminated list with group names that are lists /** * Construct a new in-memory Ini file representation. * @param list_group_names A NULL terminated list with groups that should be * loaded as lists instead of variables. */ IniFile(const char **list_group_names = NULL); /** Free everything we loaded. */ ~IniFile(); /** * Get the group with the given name, and if it doesn't exist * create a new group. * @param name name of the group to find. * @param len the maximum length of said name. * @return the requested group. */ IniGroup *GetGroup(const char *name, size_t len = 0); /** * Remove the group with the given name. * @param name name of the group to remove. */ void RemoveGroup(const char *name); /** * Load the Ini file's data from the disk. * @param filename the file to load. * @pre nothing has been loaded yet. */ void LoadFromDisk(const char *filename); /** * Save the Ini file's data to the disk. * @param filename the file to save to. * @return true if saving succeeded. */ bool SaveToDisk(const char *filename); }; #endif /* INI_TYPE_H */
3,516
C++
.h
101
32.366337
97
0.666568
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,472
station_func.h
EnergeticBark_OpenTTD-3DS/src/station_func.h
/* $Id$ */ /** @file station_func.h Functions related to stations. */ #ifndef STATION_FUNC_H #define STATION_FUNC_H #include "station_type.h" #include "sprite.h" #include "oldpool.h" #include "rail_type.h" #include "road_type.h" #include "tile_type.h" #include "cargo_type.h" #include "vehicle_type.h" #include "core/smallvec_type.hpp" void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius); typedef SmallVector<Station*, 1> StationList; void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList *stations); void ShowStationViewWindow(StationID station); void UpdateAllStationVirtCoord(); void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad); void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad); const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx); void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image); bool HasStationInUse(StationID station, CompanyID company); RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); uint GetNumRoadStops(const Station *st, RoadStopType type); RoadStop * AllocateRoadStop(); void ClearSlot(Vehicle *v); void DeleteOilRig(TileIndex t); /* Check if a rail station tile is traversable. */ bool IsStationTileBlocked(TileIndex tile); /* Check if a rail station tile is electrifiable. */ bool IsStationTileElectrifiable(TileIndex tile); void UpdateAirportsNoise(); #endif /* STATION_FUNC_H */
1,553
C++
.h
34
44.205882
108
0.804391
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,473
mixer.h
EnergeticBark_OpenTTD-3DS/src/mixer.h
/* $Id$ */ /** @file mixer.h Functions to mix sound samples. */ #ifndef MIXER_H #define MIXER_H struct MixerChannel; enum { MX_AUTOFREE = 1, // MX_8BIT = 2, // MX_STEREO = 4, // MX_UNSIGNED = 8, }; bool MxInitialize(uint rate); void MxMixSamples(void *buffer, uint samples); MixerChannel *MxAllocateChannel(); void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, size_t size, uint rate, uint flags); void MxSetChannelVolume(MixerChannel *mc, uint left, uint right); void MxActivateChannel(MixerChannel*); #endif /* MIXER_H */
534
C++
.h
18
28.222222
89
0.742633
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,474
bridge.h
EnergeticBark_OpenTTD-3DS/src/bridge.h
/* $Id$ */ /** @file bridge.h Header file for bridges */ #ifndef BRIDGE_H #define BRIDGE_H #include "gfx_type.h" #include "direction_type.h" #include "tile_cmd.h" /** This enum is related to the definition of bridge pieces, * which is used to determine the proper sprite table to use * while drawing a given bridge part. */ enum BridgePieces { BRIDGE_PIECE_NORTH = 0, BRIDGE_PIECE_SOUTH, BRIDGE_PIECE_INNER_NORTH, BRIDGE_PIECE_INNER_SOUTH, BRIDGE_PIECE_MIDDLE_ODD, BRIDGE_PIECE_MIDDLE_EVEN, BRIDGE_PIECE_HEAD, BRIDGE_PIECE_INVALID, }; DECLARE_POSTFIX_INCREMENT(BridgePieces); enum { MAX_BRIDGES = 13 }; typedef uint BridgeType; /** Struct containing information about a single bridge type */ struct BridgeSpec { Year avail_year; ///< the year where it becomes available byte min_length; ///< the minimum length (not counting start and end tile) byte max_length; ///< the maximum length (not counting start and end tile) uint16 price; ///< the price multiplier uint16 speed; ///< maximum travel speed SpriteID sprite; ///< the sprite which is used in the GUI SpriteID pal; ///< the palette which is used in the GUI StringID material; ///< the string that contains the bridge description StringID transport_name[2]; ///< description of the bridge, when built for road or rail PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge byte flags; ///< bit 0 set: disable drawing of far pillars. }; extern BridgeSpec _bridge[MAX_BRIDGES]; Foundation GetBridgeFoundation(Slope tileh, Axis axis); bool HasBridgeFlatRamp(Slope tileh, Axis axis); static inline const BridgeSpec *GetBridgeSpec(BridgeType i) { assert(i < lengthof(_bridge)); return &_bridge[i]; } void DrawBridgeMiddle(const TileInfo *ti); bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE); int CalcBridgeLenCostFactor(int x); void ResetBridges(); #endif /* BRIDGE_H */
2,050
C++
.h
54
36.203704
95
0.716305
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,475
aystar.h
EnergeticBark_OpenTTD-3DS/src/aystar.h
/* $Id$ */ /** @file aystar.h * This file has the header for AyStar * AyStar is a fast pathfinding routine and is used for things like * AI_pathfinding and Train_pathfinding. * For more information about AyStar (A* Algorithm), you can look at * http://en.wikipedia.org/wiki/A-star_search_algorithm */ #ifndef AYSTAR_H #define AYSTAR_H #include "queue.h" #include "tile_type.h" #include "track_type.h" //#define AYSTAR_DEBUG enum { AYSTAR_FOUND_END_NODE, AYSTAR_EMPTY_OPENLIST, AYSTAR_STILL_BUSY, AYSTAR_NO_PATH, AYSTAR_LIMIT_REACHED, AYSTAR_DONE }; enum{ AYSTAR_INVALID_NODE = -1, }; struct AyStarNode { TileIndex tile; Trackdir direction; uint user_data[2]; }; /* The resulting path has nodes looking like this. */ struct PathNode { AyStarNode node; /* The parent of this item */ PathNode *parent; }; /* For internal use only * We do not save the h-value, because it is only needed to calculate the f-value. * h-value should _always_ be the distance left to the end-tile. */ struct OpenListNode { int g; PathNode path; }; struct AyStar; /* * This function is called to check if the end-tile is found * return values can be: * AYSTAR_FOUND_END_NODE : indicates this is the end tile * AYSTAR_DONE : indicates this is not the end tile (or direction was wrong) */ /* * The 2nd parameter should be OpenListNode, and NOT AyStarNode. AyStarNode is * part of OpenListNode and so it could be accessed without any problems. * The good part about OpenListNode is, and how AIs use it, that you can * access the parent of the current node, and so check if you, for example * don't try to enter the file tile with a 90-degree curve. So please, leave * this an OpenListNode, it works just fine -- TrueLight */ typedef int32 AyStar_EndNodeCheck(AyStar *aystar, OpenListNode *current); /* * This function is called to calculate the G-value for AyStar Algorithm. * return values can be: * AYSTAR_INVALID_NODE : indicates an item is not valid (e.g.: unwalkable) * Any value >= 0 : the g-value for this tile */ typedef int32 AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent); /* * This function is called to calculate the H-value for AyStar Algorithm. * Mostly, this must result the distance (Manhattan way) between the * current point and the end point * return values can be: * Any value >= 0 : the h-value for this tile */ typedef int32 AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent); /* * This function request the tiles around the current tile and put them in tiles_around * tiles_around is never resetted, so if you are not using directions, just leave it alone. * Warning: never add more tiles_around than memory allocated for it. */ typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current); /* * If the End Node is found, this function is called. * It can do, for example, calculate the route and put that in an array */ typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current); /* For internal use, see aystar.cpp */ typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g); typedef int AyStar_Main(AyStar *aystar); typedef int AyStar_Loop(AyStar *aystar); typedef int AyStar_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent); typedef void AyStar_Free(AyStar *aystar); typedef void AyStar_Clear(AyStar *aystar); struct AyStar { /* These fields should be filled before initting the AyStar, but not changed * afterwards (except for user_data and user_path)! (free and init again to change them) */ /* These should point to the application specific routines that do the * actual work */ AyStar_CalculateG *CalculateG; AyStar_CalculateH *CalculateH; AyStar_GetNeighbours *GetNeighbours; AyStar_EndNodeCheck *EndNodeCheck; AyStar_FoundEndNode *FoundEndNode; /* These are completely untouched by AyStar, they can be accesed by * the application specific routines to input and output data. * user_path should typically contain data about the resulting path * afterwards, user_target should typically contain information about * what where looking for, and user_data can contain just about * everything */ void *user_path; void *user_target; uint user_data[10]; /* How many loops are there called before AyStarMain_Main gives * control back to the caller. 0 = until done */ byte loops_per_tick; /* If the g-value goes over this number, it stops searching * 0 = infinite */ uint max_path_cost; /* The maximum amount of nodes that will be expanded, 0 = infinite */ uint max_search_nodes; /* These should be filled with the neighbours of a tile by * GetNeighbours */ AyStarNode neighbours[12]; byte num_neighbours; /* These will contain the methods for manipulating the AyStar. Only * main() should be called externally */ AyStar_AddStartNode *addstart; AyStar_Main *main; AyStar_Loop *loop; AyStar_Free *free; AyStar_Clear *clear; AyStar_CheckTile *checktile; /* These will contain the open and closed lists */ /* The actual closed list */ Hash ClosedListHash; /* The open queue */ Queue OpenListQueue; /* An extra hash to speed up the process of looking up an element in * the open list */ Hash OpenListHash; }; void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g); int AyStarMain_Main(AyStar *aystar); int AyStarMain_Loop(AyStar *aystar); int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent); void AyStarMain_Free(AyStar *aystar); void AyStarMain_Clear(AyStar *aystar); /* Initialize an AyStar. You should fill all appropriate fields before * callling init_AyStar (see the declaration of AyStar for which fields are * internal */ void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets); #endif /* AYSTAR_H */
5,855
C++
.h
151
36.860927
92
0.760437
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,476
sound_type.h
EnergeticBark_OpenTTD-3DS/src/sound_type.h
/* $Id$ */ /** @file sound_type.h Types related to sounds. */ #ifndef SOUND_TYPE_H #define SOUND_TYPE_H #include "core/enum_type.hpp" struct MusicFileSettings { byte playlist; byte music_vol; byte effect_vol; byte custom_1[33]; byte custom_2[33]; bool playing; bool shuffle; }; struct FileEntry { uint8 file_slot; size_t file_offset; size_t file_size; uint16 rate; uint8 bits_per_sample; uint8 channels; uint8 volume; uint8 priority; }; enum SoundFx { SND_BEGIN = 0, SND_02_SPLAT = 0, // 0 == 0x00 ! SND_03_FACTORY_WHISTLE, SND_04_TRAIN, SND_05_TRAIN_THROUGH_TUNNEL, SND_06_SHIP_HORN, SND_07_FERRY_HORN, SND_08_PLANE_TAKE_OFF, SND_09_JET, SND_0A_TRAIN_HORN, SND_0B_MINING_MACHINERY, SND_0C_ELECTRIC_SPARK, SND_0D_STEAM, SND_0E_LEVEL_CROSSING, SND_0F_VEHICLE_BREAKDOWN, SND_10_TRAIN_BREAKDOWN, SND_11_CRASH, SND_12_EXPLOSION, // 16 == 0x10 SND_13_BIG_CRASH, SND_14_CASHTILL, SND_15_BEEP, // 19 == 0x13 SND_16_MORSE, // 20 == 0x14 SND_17_SKID_PLANE, SND_18_HELICOPTER, SND_19_BUS_START_PULL_AWAY, SND_1A_BUS_START_PULL_AWAY_WITH_HORN, SND_1B_TRUCK_START, SND_1C_TRUCK_START_2, SND_1D_APPLAUSE, SND_1E_OOOOH, SND_1F_SPLAT, // 29 == 0x1D SND_20_SPLAT_2, // 30 == 0x1E SND_21_JACKHAMMER, SND_22_CAR_HORN, SND_23_CAR_HORN_2, SND_24_SHEEP, SND_25_COW, SND_26_HORSE, SND_27_BLACKSMITH_ANVIL, SND_28_SAWMILL, // 38 == 0x26 ! SND_00_GOOD_YEAR, // 39 == 0x27 ! SND_01_BAD_YEAR, // 40 == 0x28 ! SND_29_RIP, // 41 == 0x29 ! SND_2A_EXTRACT_AND_POP, SND_2B_COMEDY_HIT, SND_2C_MACHINERY, SND_2D_RIP_2, SND_2E_EXTRACT_AND_POP, SND_2F_POP, SND_30_CARTOON_SOUND, SND_31_EXTRACT, SND_32_POP_2, SND_33_PLASTIC_MINE, SND_34_WIND, SND_35_COMEDY_BREAKDOWN, SND_36_CARTOON_CRASH, SND_37_BALLOON_SQUEAK, SND_38_CHAINSAW, SND_39_HEAVY_WIND, SND_3A_COMEDY_BREAKDOWN_2, SND_3B_JET_OVERHEAD, SND_3C_COMEDY_CAR, SND_3D_ANOTHER_JET_OVERHEAD, SND_3E_COMEDY_CAR_2, SND_3F_COMEDY_CAR_3, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, SND_41_MAGLEV, SND_42_LOON_BIRD, SND_43_LION, SND_44_MONKEYS, SND_45_PLANE_CRASHING, SND_46_PLANE_ENGINE_SPUTTERING, SND_47_MAGLEV_2, SND_48_DISTANT_BIRD, // 72 == 0x48 SND_END }; /** Define basic enum properties */ template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {}; typedef TinyEnumT<SoundFx> SoundFxByte; #endif /* SOUND_TYPE_H */
2,633
C++
.h
105
23.142857
103
0.646032
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,477
town.h
EnergeticBark_OpenTTD-3DS/src/town.h
/* $Id$ */ /** @file town.h Base of the town class. */ #ifndef TOWN_H #define TOWN_H #include "oldpool.h" #include "core/bitmath_func.hpp" #include "core/random_func.hpp" #include "cargo_type.h" #include "tile_type.h" #include "date_type.h" #include "town_type.h" #include "company_type.h" #include "settings_type.h" #include "strings_type.h" #include "viewport_type.h" #include "economy_type.h" #include "map_type.h" #include "command_type.h" enum { HOUSE_NO_CLASS = 0, NEW_HOUSE_OFFSET = 110, HOUSE_MAX = 512, INVALID_TOWN = 0xFFFF, INVALID_HOUSE_ID = 0xFFFF, /* There can only be as many classes as there are new houses, plus one for * NO_CLASS, as the original houses don't have classes. */ HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1, }; enum BuildingFlags { TILE_NO_FLAG = 0, TILE_SIZE_1x1 = 1U << 0, TILE_NOT_SLOPED = 1U << 1, TILE_SIZE_2x1 = 1U << 2, TILE_SIZE_1x2 = 1U << 3, TILE_SIZE_2x2 = 1U << 4, BUILDING_IS_ANIMATED = 1U << 5, BUILDING_IS_CHURCH = 1U << 6, BUILDING_IS_STADIUM = 1U << 7, BUILDING_HAS_1_TILE = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2, BUILDING_2_TILES_X = TILE_SIZE_2x1 | TILE_SIZE_2x2, BUILDING_2_TILES_Y = TILE_SIZE_1x2 | TILE_SIZE_2x2, BUILDING_HAS_4_TILES = TILE_SIZE_2x2, }; DECLARE_ENUM_AS_BIT_SET(BuildingFlags) enum HouseZonesBits { HZB_BEGIN = 0, HZB_TOWN_EDGE = 0, HZB_TOWN_OUTSKIRT, HZB_TOWN_OUTER_SUBURB, HZB_TOWN_INNER_SUBURB, HZB_TOWN_CENTRE, HZB_END, }; assert_compile(HZB_END == 5); DECLARE_POSTFIX_INCREMENT(HouseZonesBits) enum HouseZones { ///< Bit Value Meaning HZ_NOZNS = 0x0000, ///< 0 This is just to get rid of zeros, meaning none HZ_ZON1 = 1U << HZB_TOWN_EDGE, ///< 0..4 1,2,4,8,10 which town zones the building can be built in, Zone1 been the further suburb HZ_ZON2 = 1U << HZB_TOWN_OUTSKIRT, HZ_ZON3 = 1U << HZB_TOWN_OUTER_SUBURB, HZ_ZON4 = 1U << HZB_TOWN_INNER_SUBURB, HZ_ZON5 = 1U << HZB_TOWN_CENTRE, ///< center of town HZ_ZONALL = 0x001F, ///< 1F This is just to englobe all above types at once HZ_SUBARTC_ABOVE = 0x0800, ///< 11 800 can appear in sub-arctic climate above the snow line HZ_TEMP = 0x1000, ///< 12 1000 can appear in temperate climate HZ_SUBARTC_BELOW = 0x2000, ///< 13 2000 can appear in sub-arctic climate below the snow line HZ_SUBTROPIC = 0x4000, ///< 14 4000 can appear in subtropical climate HZ_TOYLND = 0x8000 ///< 15 8000 can appear in toyland climate }; DECLARE_ENUM_AS_BIT_SET(HouseZones) enum HouseExtraFlags { NO_EXTRA_FLAG = 0, BUILDING_IS_HISTORICAL = 1U << 0, ///< this house will only appear during town generation in random games, thus the historical BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able to SYNCHRONISED_CALLBACK_1B = 1U << 2, ///< synchronized callback 1B will be performed, on multi tile houses CALLBACK_1A_RANDOM_BITS = 1U << 3, ///< callback 1A needs random bits }; DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags) template <typename T> struct BuildingCounts { T id_count[HOUSE_MAX]; T class_count[HOUSE_CLASS_MAX]; }; static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation DECLARE_OLD_POOL(Town, Town, 3, 8000) struct Town : PoolItem<Town, TownID, &_Town_pool> { TileIndex xy; /* Current population of people and amount of houses. */ uint32 num_houses; uint32 population; /* Town name */ uint32 townnamegrfid; uint16 townnametype; uint32 townnameparts; char *name; /* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */ ViewportSign sign; /* Makes sure we don't build certain house types twice. * bit 0 = Building funds received * bit 1 = CHURCH * bit 2 = STADIUM */ byte flags12; /* level of noise that all the airports are generating */ uint16 noise_reached; /* Which companies have a statue? */ CompanyMask statues; /* Company ratings as well as a mask that determines which companies have a rating. */ CompanyMask have_ratings; uint8 unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe) CompanyByte exclusivity; ///< which company has exclusivity uint8 exclusive_counter; ///< months till the exclusivity expires int16 ratings[MAX_COMPANIES]; /* Maximum amount of passengers and mail that can be transported. */ uint32 max_pass; uint32 max_mail; uint32 new_max_pass; uint32 new_max_mail; uint32 act_pass; uint32 act_mail; uint32 new_act_pass; uint32 new_act_mail; /* Amount of passengers that were transported. */ byte pct_pass_transported; byte pct_mail_transported; /* Amount of food and paper that was transported. Actually a bit mask would be enough. */ uint16 act_food; uint16 act_water; uint16 new_act_food; uint16 new_act_water; /* Time until we rebuild a house. */ uint16 time_until_rebuild; /* When to grow town next time. */ uint16 grow_counter; int16 growth_rate; /* Fund buildings program in action? */ byte fund_buildings_months; /* Fund road reconstruction in action? */ byte road_build_months; /* If this is a larger town, and should grow more quickly. */ bool larger_town; TownLayoutByte layout; ///< town specific road layout /* NOSAVE: UpdateTownRadius updates this given the house count. */ uint32 squared_town_zone_radius[HZB_END]; /* NOSAVE: The number of each type of building in the town. */ BuildingCounts<uint16> building_counts; /** * Creates a new town */ Town(TileIndex tile = INVALID_TILE); /** Destroy the town */ ~Town(); inline bool IsValid() const { return this->xy != INVALID_TILE; } void InitializeLayout(TownLayout layout); /** Calculate the max town noise * The value is counted using the population divided by the content of the * entry in town_noise_population corespondig to the town's tolerance. * To this result, we add 3, which is the noise of the lowest airport. * So user can at least buld that airport * @return the maximum noise level the town will tolerate */ inline uint16 MaxTownNoise() const { if (this->population == 0) return 0; // no population? no noise return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3); } }; struct HouseSpec { /* Standard properties */ Year min_year; ///< introduction year of the house Year max_year; ///< last year it can be built byte population; ///< population (Zero on other tiles in multi tile house.) byte removal_cost; ///< cost multiplier for removing it StringID building_name; ///< building name uint16 remove_rating_decrease; ///< rating decrease if removed byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below) byte cargo_acceptance[3]; ///< acceptance level for the cargo slots CargoID accepts_cargo[3]; ///< 3 input cargo slots BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...) HouseZones building_availability; ///< where can it be built (climates, zones) bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf) /* NewHouses properties */ HouseID substitute_id; ///< which original house this one is based on struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house HouseID override; ///< which house this one replaces uint16 callback_mask; ///< House callback flags byte random_colour[4]; ///< 4 "random" colours byte probability; ///< Relative probability of appearing (16 is the standard value) HouseExtraFlags extra_flags; ///< some more flags HouseClassID class_id; ///< defines the class this house has (grf file based) @See HouseGetVariable, prop 0x44 byte animation_frames; ///< number of animation frames byte animation_speed; ///< amount of time between each of those frames byte processing_time; ///< Periodic refresh multiplier byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it /* grf file related properties*/ uint8 local_id; ///< id defined by the grf file for this house const struct GRFFile *grffile; ///< grf file that introduced this house /** * Get the cost for removing this house * @return the cost (inflation corrected etc) */ Money GetRemovalCost() const; }; extern HouseSpec _house_specs[HOUSE_MAX]; uint32 GetWorldPopulation(); void UpdateTownVirtCoord(Town *t); void UpdateAllTownVirtCoords(); void InitializeTown(); void ShowTownViewWindow(TownID town); void ExpandTown(Town *t); Town *CreateRandomTown(uint attempts, TownSize size, bool city, TownLayout layout); enum { ROAD_REMOVE = 0, UNMOVEABLE_REMOVE = 1, TUNNELBRIDGE_REMOVE = 1, INDUSTRY_REMOVE = 2 }; /** This is the number of ticks between towns being processed for building new * houses or roads. This value originally came from the size of the town array * in TTD. */ static const byte TOWN_GROWTH_FREQUENCY = 70; /** Simple value that indicates the house has reached the final stage of * construction. */ static const byte TOWN_HOUSE_COMPLETED = 3; /** This enum is used in conjonction with town->flags12. * IT simply states what bit is used for. * It is pretty unrealistic (IMHO) to only have one church/stadium * per town, NO MATTER the population of it. * And there are 5 more bits available on flags12... */ enum { TOWN_IS_FUNDED = 0, ///< Town has received some funds for TOWN_HAS_CHURCH = 1, ///< There can be only one church by town. TOWN_HAS_STADIUM = 2 ///< There can be only one stadium by town. }; bool CheckforTownRating(DoCommandFlag flags, Town *t, byte type); static inline HouseSpec *GetHouseSpecs(HouseID house_id) { assert(house_id < HOUSE_MAX); return &_house_specs[house_id]; } TileIndexDiff GetHouseNorthPart(HouseID &house); /** * Check if a TownID is valid. * @param index to inquiry in the pool of town * @return true if it exists */ static inline bool IsValidTownID(TownID index) { return index < GetTownPoolSize() && GetTown(index)->IsValid(); } static inline TownID GetMaxTownIndex() { /* TODO - This isn't the real content of the function, but * with the new pool-system this will be replaced with one that * _really_ returns the highest index. Now it just returns * the next safe value we are sure about everything is below. */ return GetTownPoolSize() - 1; } static inline uint GetNumTowns() { extern uint _total_towns; return _total_towns; } /** * Return a random valid town. */ static inline Town *GetRandomTown() { int num = RandomRange(GetNumTowns()); TownID index = INVALID_TOWN; while (num >= 0) { num--; index++; /* Make sure we have a valid town */ while (!IsValidTownID(index)) { index++; assert(index <= GetMaxTownIndex()); } } return GetTown(index); } Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX); #define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid()) #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) extern Town *_cleared_town; extern int _cleared_town_rating; extern uint32 _cur_town_ctr; extern uint32 _cur_town_iter; void ResetHouses(); void ClearTownHouse(Town *t, TileIndex tile); void UpdateTownMaxPass(Town *t); void UpdateTownRadius(Town *t); bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags); Town *ClosestTownFromTile(TileIndex tile, uint threshold); void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags); HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile); void SetTownRatingTestMode(bool mode); uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t); bool GenerateTowns(TownLayout layout); bool GenerateTownName(uint32 *townnameparts); /** * Calculate a hash value from a tile position * * @param x The X coordinate * @param y The Y coordinate * @return The hash of the tile */ static inline uint TileHash(uint x, uint y) { uint hash = x >> 4; hash ^= x >> 6; hash ^= y >> 4; hash -= y >> 6; return hash; } /** * Get the last two bits of the TileHash * from a tile position. * * @see TileHash() * @param x The X coordinate * @param y The Y coordinate * @return The last two bits from hash of the tile */ static inline uint TileHash2Bit(uint x, uint y) { return GB(TileHash(x, y), 0, 2); } #endif /* TOWN_H */
13,194
C++
.h
330
38.00303
163
0.69796
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,479
station_gui.h
EnergeticBark_OpenTTD-3DS/src/station_gui.h
/* $Id$ */ /** @file station_gui.h Contains enums and function declarations connected with stations GUI */ #ifndef STATION_GUI_H #define STATION_GUI_H #include "command_type.h" /** Enum for StationView, referring to _station_view_widgets and _station_view_expanded_widgets */ enum StationViewWidgets { SVW_CLOSEBOX = 0, ///< Close 'X' button SVW_CAPTION = 1, ///< Caption of the window SVW_WAITING = 3, ///< List of waiting cargo SVW_ACCEPTLIST = 5, ///< List of accepted cargos SVW_RATINGLIST = 5, ///< Ratings of cargos SVW_LOCATION = 6, ///< 'Location' button SVW_RATINGS = 7, ///< 'Ratings' button SVW_ACCEPTS = 7, ///< 'Accepts' button SVW_RENAME = 8, ///< 'Rename' button SVW_TRAINS = 9, ///< List of scheduled trains button SVW_ROADVEHS, ///< List of scheduled road vehs button SVW_PLANES, ///< List of scheduled planes button SVW_SHIPS, ///< List of scheduled ships button SVW_RESIZE, ///< Resize button }; enum StationCoverageType { SCT_PASSENGERS_ONLY, SCT_NON_PASSENGERS_ONLY, SCT_ALL }; int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies); void CheckRedrawStationCoverage(const Window *w); void ShowSelectStationIfNeeded(CommandContainer cmd, int w, int h); #endif /* STATION_GUI_H */
1,336
C++
.h
31
41.290323
98
0.691596
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,480
newgrf_text.h
EnergeticBark_OpenTTD-3DS/src/newgrf_text.h
/* $Id$ */ /** @file newgrf_text.h Header of Action 04 "universal holder" structure and functions */ #ifndef NEWGRF_TEXT_H #define NEWGRF_TEXT_H StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, const char *text_to_add, StringID def_string); StringID GetGRFStringID(uint32 grfid, uint16 stringid); const char *GetGRFStringPtr(uint16 stringid); void CleanUpStrings(); void SetCurrentGrfLangID(byte language_id); char *TranslateTTDPatchCodes(uint32 grfid, const char *str); bool CheckGrfLangID(byte lang_id, byte grf_version); void PrepareTextRefStackUsage(byte numEntries); void StopTextRefStackUsage(); void SwitchToNormalRefStack(); void SwitchToErrorRefStack(); void RewindTextRefStack(); uint RemapNewGRFStringControlCode(uint scc, char **buff, const char **str, int64 *argv); #endif /* NEWGRF_TEXT_H */
846
C++
.h
18
45.666667
129
0.804136
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,481
news_func.h
EnergeticBark_OpenTTD-3DS/src/news_func.h
/* $Id$ */ /** @file news_func.h Functions related to news. */ #ifndef NEWS_FUNC_H #define NEWS_FUNC_H #include "news_type.h" #include "vehicle_type.h" #include "station_type.h" void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b, void *free_data = NULL); void NewsLoop(); void InitNewsItemStructs(); extern NewsItem _statusbar_news_item; extern bool _news_ticker_sound; extern NewsTypeData _news_type_data[NT_END]; /** * Delete a news item type about a vehicle * if the news item type is INVALID_STRING_ID all news about the vehicle get * deleted */ void DeleteVehicleNews(VehicleID, StringID news); /** Delete news associated with given station */ void DeleteStationNews(StationID); #endif /* NEWS_FUNC_H */
751
C++
.h
22
32.545455
105
0.761111
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,482
economy_func.h
EnergeticBark_OpenTTD-3DS/src/economy_func.h
/* $Id$ */ /** @file economy_func.h Functions related to the economy. */ #ifndef ECONOMY_FUNC_H #define ECONOMY_FUNC_H #include "core/geometry_type.hpp" #include "economy_type.h" #include "cargo_type.h" #include "vehicle_type.h" #include "tile_type.h" #include "town_type.h" #include "industry_type.h" #include "company_type.h" #include "station_type.h" void ResetPriceBaseMultipliers(); void SetPriceBaseMultiplier(uint price, byte factor); void ResetEconomy(); extern const ScoreInfo _score_info[]; extern int _score_part[MAX_COMPANIES][SCORE_END]; extern Economy _economy; extern Subsidy _subsidies[MAX_COMPANIES]; /* Prices and also the fractional part. */ extern Prices _price; extern uint16 _price_frac[NUM_PRICES]; extern Money _cargo_payment_rates[NUM_CARGO]; extern uint16 _cargo_payment_rates_frac[NUM_CARGO]; int UpdateCompanyRatingAndValue(Company *c, bool update); Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode); void DeleteSubsidyWithTown(TownID index); void DeleteSubsidyWithIndustry(IndustryID index); void DeleteSubsidyWithStation(StationID index); void StartupIndustryDailyChanges(bool init_counter); Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type); uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount); void VehiclePayment(Vehicle *front_v); void LoadUnloadStation(Station *st); Money GetPriceByIndex(uint8 index); #endif /* ECONOMY_FUNC_H */
1,463
C++
.h
37
38.27027
99
0.80226
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,483
tunnelbridge.h
EnergeticBark_OpenTTD-3DS/src/tunnelbridge.h
/* $Id$ */ /** @file tunnelbridge.h Header file for things common for tunnels and bridges */ #ifndef TUNNELBRIDGE_H #define TUNNELBRIDGE_H #include "tile_type.h" /** * Calculates the length of a tunnel or a bridge (without end tiles) * @return length of bridge/tunnel middle */ static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end) { int x1 = TileX(begin); int y1 = TileY(begin); int x2 = TileX(end); int y2 = TileY(end); return abs(x2 + y2 - x1 - y1) - 1; } extern TileIndex _build_tunnel_endtile; #endif /* TUNNELBRIDGE_H */
561
C++
.h
19
27.736842
81
0.728972
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,484
pathfind.h
EnergeticBark_OpenTTD-3DS/src/pathfind.h
/* $Id$ */ /** @file pathfind.h The oldest pathfinder that's supported. */ #ifndef PATHFIND_H #define PATHFIND_H #include "direction_type.h" enum { STR_FACTOR = 2, DIAG_FACTOR = 3 }; //#define PF_BENCH // perform simple benchmarks on the train pathfinder (not //supported on all archs) struct TrackPathFinder; typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length); typedef void TPFAfterProc(TrackPathFinder *tpf); typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length); #define PATHFIND_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links) #define PATHFIND_GET_LINK_PTR(tpf, link_offs) (TrackPathFinderLink*)((byte*)tpf->links + (link_offs)) /* y7 y6 y5 y4 y3 y2 y1 y0 x7 x6 x5 x4 x3 x2 x1 x0 * y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 0 0 * 0 0 y7 y6 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 * 0 0 0 0 y5 y4 y3 y2 y1 y0 x4 x3 x2 x1 x0 0 */ #define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5) struct TrackPathFinderLink { TileIndex tile; uint16 flags; uint16 next; }; struct RememberData { uint16 cur_length; byte depth; Track last_choosen_track; }; struct TrackPathFinder { int num_links_left; TrackPathFinderLink *new_link; TPFEnumProc *enum_proc; void *userdata; RememberData rd; TrackdirByte the_dir; TransportType tracktype; uint sub_type; bool disable_tile_hash; uint16 hash_head[0x400]; TileIndex hash_tile[0x400]; ///< stores the link index when multi link. TrackPathFinderLink links[0x400]; ///< hopefully, this is enough. }; /** Some flags to modify the behaviour of original pathfinder */ enum PathfindFlags { PATHFIND_FLAGS_NONE = 0, PATHFIND_FLAGS_SHIP_MODE = 0x0800, ///< pathfinder with some optimizations for ships, but does not work for other types. PATHFIND_FLAGS_DISABLE_TILE_HASH = 0x1000, ///< do not check for searching in circles }; DECLARE_ENUM_AS_BIT_SET(PathfindFlags) void FollowTrack(TileIndex tile, PathfindFlags flags, TransportType tt, uint sub_type, DiagDirection direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data); void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypes railtypes, DiagDirection direction, NTPEnumProc *enum_proc, void *data); /** * Calculates the tile of given station that is closest to a given tile * for this we assume the station is a rectangle, * as defined by its top tile (st->train_tile) and its width/height (st->trainst_w, st->trainst_h) * @param station The station to calculate the distance to * @param tile The tile from where to calculate the distance * @return The closest station tile to the given tile. */ static inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile) { const Station *st = GetStation(station); /* If the rail station is (temporarily) not present, use the station sign to drive near the station */ if (st->train_tile == INVALID_TILE) return st->xy; uint minx = TileX(st->train_tile); // topmost corner of station uint miny = TileY(st->train_tile); uint maxx = minx + st->trainst_w - 1; // lowermost corner of station uint maxy = miny + st->trainst_h - 1; /* we are going the aim for the x coordinate of the closest corner * but if we are between those coordinates, we will aim for our own x coordinate */ uint x = ClampU(TileX(tile), minx, maxx); /* same for y coordinate, see above comment */ uint y = ClampU(TileY(tile), miny, maxy); /* return the tile of our target coordinates */ return TileXY(x, y); } #endif /* PATHFIND_H */
3,571
C++
.h
82
41.585366
174
0.738653
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,485
screenshot.h
EnergeticBark_OpenTTD-3DS/src/screenshot.h
/* $Id$ */ /** @file screenshot.h Functions to make screenshots. */ #ifndef SCREENSHOT_H #define SCREENSHOT_H void InitializeScreenshotFormats(); const char *GetScreenshotFormatDesc(int i); void SetScreenshotFormat(int i); enum ScreenshotType { SC_NONE, SC_VIEWPORT, SC_WORLD }; bool MakeScreenshot(); void SetScreenshotType(ScreenshotType t); bool IsScreenshotRequested(); extern char _screenshot_format_name[8]; extern uint _num_screenshot_formats; extern uint _cur_screenshot_format; #endif /* SCREENSHOT_H */
524
C++
.h
19
26
56
0.798793
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,486
waypoint.h
EnergeticBark_OpenTTD-3DS/src/waypoint.h
/* $Id$ */ /** @file waypoint.h Base of waypoints. */ #ifndef WAYPOINT_H #define WAYPOINT_H #include "waypoint_type.h" #include "oldpool.h" #include "rail_map.h" #include "command_type.h" #include "station_type.h" #include "town_type.h" #include "viewport_type.h" #include "date_type.h" DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000) struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> { TileIndex xy; ///< Tile of waypoint TownID town_index; ///< Town associated with the waypoint uint16 town_cn; ///< The Nth waypoint for this town (consecutive number) StringID string; ///< C000-C03F have special meaning in old games char *name; ///< Custom name. If not set, town + town_cn is used for naming ViewportSign sign; ///< Dimensions of sign (not saved) Date build_date; ///< Date of construction OwnerByte owner; ///< Whom this waypoint belongs to byte stat_id; ///< ID of waypoint within the waypoint class (not saved) uint32 grfid; ///< ID of GRF file byte localidx; ///< Index of station within GRF file byte deleted; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted. Waypoint(TileIndex tile = INVALID_TILE); ~Waypoint(); inline bool IsValid() const { return this->xy != INVALID_TILE; } }; static inline bool IsValidWaypointID(WaypointID index) { return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid(); } #define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (wp->IsValid()) #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0) /** * Fetch a waypoint by tile * @param tile Tile of waypoint * @return Waypoint */ static inline Waypoint *GetWaypointByTile(TileIndex tile) { assert(IsRailWaypointTile(tile)); return GetWaypoint(GetWaypointIndex(tile)); } CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove); Station *ComposeWaypointStation(TileIndex tile); void ShowWaypointWindow(const Waypoint *wp); void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype); void UpdateAllWaypointSigns(); void UpdateWaypointSign(Waypoint *wp); void RedrawWaypointSign(const Waypoint *wp); #endif /* WAYPOINT_H */
2,341
C++
.h
54
41.62963
186
0.738767
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,487
cargotype.h
EnergeticBark_OpenTTD-3DS/src/cargotype.h
/* $Id$ */ /** @file cargotype.h Types/functions related to cargos. */ #ifndef CARGOTYPE_H #define CARGOTYPE_H #include "cargo_type.h" #include "gfx_type.h" #include "strings_type.h" #include "landscape_type.h" typedef uint32 CargoLabel; enum TownEffect { TE_NONE, TE_PASSENGERS, TE_MAIL, TE_GOODS, TE_WATER, TE_FOOD, }; struct CargoSpec { uint8 bitnum; CargoLabel label; uint8 legend_colour; uint8 rating_colour; uint8 weight; uint16 initial_payment; uint8 transit_days[2]; bool is_freight; TownEffect town_effect; ///< The effect this cargo type has on towns uint16 multipliertowngrowth; uint8 callback_mask; StringID name; StringID name_single; StringID units_volume; StringID quantifier; StringID abbrev; SpriteID sprite; uint16 classes; const struct GRFFile *grffile; ///< NewGRF where 'group' belongs to const struct SpriteGroup *group; bool IsValid() const; }; extern uint32 _cargo_mask; extern CargoSpec _cargo[NUM_CARGO]; /* Set up the default cargo types for the given landscape type */ void SetupCargoForClimate(LandscapeID l); /* Retrieve cargo details for the given cargo ID */ const CargoSpec *GetCargo(CargoID c); /* Get the cargo icon for a given cargo ID */ SpriteID GetCargoSprite(CargoID i); /* Get the cargo ID with the cargo label */ CargoID GetCargoIDByLabel(CargoLabel cl); CargoID GetCargoIDByBitnum(uint8 bitnum); static inline bool IsCargoInClass(CargoID c, uint16 cc) { return (GetCargo(c)->classes & cc) != 0; } #endif /* CARGOTYPE_H */
1,514
C++
.h
56
25.196429
70
0.773454
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,488
statusbar_gui.h
EnergeticBark_OpenTTD-3DS/src/statusbar_gui.h
/* $Id$ */ /** @file statusbar_gui.h Functions, definitions and such used only by the GUI. */ #ifndef STATUSBAR_GUI_H #define STATUSBAR_GUI_H enum StatusBarInvalidate { SBI_SAVELOAD_START, ///< started saving SBI_SAVELOAD_FINISH, ///< finished saving SBI_SHOW_TICKER, ///< start scolling news SBI_SHOW_REMINDER, ///< show a reminder (dot on the right side of the statusbar) SBI_NEWS_DELETED, ///< abort current news display (active news were deleted) SBI_END }; bool IsNewsTickerShown(); void ShowStatusBar(); #endif /* STATUSBAR_GUI_H */
560
C++
.h
15
35.6
83
0.725926
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,489
tgp.h
EnergeticBark_OpenTTD-3DS/src/tgp.h
/* $Id$ */ /** @file tgp.h Functions for the Perlin noise enhanced map generator. */ #ifndef TGP_H #define TGP_H void GenerateTerrainPerlin(); #endif /* TGP_H */
166
C++
.h
6
26
73
0.705128
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,490
effectvehicle_base.h
EnergeticBark_OpenTTD-3DS/src/effectvehicle_base.h
/* $Id$ */ /** @file effectvehicle_base.h Base class for all effect vehicles. */ #ifndef EFFECTVEHICLE_BASE_H #define EFFECTVEHICLE_BASE_H #include "vehicle_base.h" /** * This class 'wraps' Vehicle; you do not actually instantiate this class. * You create a Vehicle using AllocateVehicle, so it is added to the pool * and you reinitialize that to a Train using: * v = new (v) Train(); * * As side-effect the vehicle type is set correctly. * * A special vehicle is one of the following: * - smoke * - electric sparks for trains * - explosions * - bulldozer (road works) * - bubbles (industry) */ struct EffectVehicle : public Vehicle { /** Initializes the Vehicle to a special vehicle */ EffectVehicle() { this->type = VEH_EFFECT; } /** We want to 'destruct' the right class. */ virtual ~EffectVehicle() {} const char *GetTypeString() const { return "special vehicle"; } void UpdateDeltaXY(Direction direction); void Tick(); }; #endif /* EFFECTVEHICLE_BASE_H */
996
C++
.h
30
31.266667
74
0.715328
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,491
console_type.h
EnergeticBark_OpenTTD-3DS/src/console_type.h
/* $Id$ */ /** @file console_type.h Globally used console related types. */ #ifndef CONSOLE_TYPE_H #define CONSOLE_TYPE_H enum IConsoleModes { ICONSOLE_FULL, ICONSOLE_OPENED, ICONSOLE_CLOSED }; enum ConsoleColour { CC_DEFAULT = 1, CC_ERROR = 3, CC_WARNING = 13, CC_INFO = 8, CC_DEBUG = 5, CC_COMMAND = 2, CC_WHITE = 12, }; #endif /* CONSOLE_TYPE_H */
380
C++
.h
19
18.210526
64
0.671348
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,492
date_type.h
EnergeticBark_OpenTTD-3DS/src/date_type.h
/* $Id$ */ /** @file date_type.h Types related to the dates in OpenTTD. */ #ifndef DATE_TYPE_H #define DATE_TYPE_H /** * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On * an overflow the new day begun and 65535 / 885 = 74. * 1 tick is approximately 30 ms. * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally */ enum { DAY_TICKS = 74, ///< ticks per day DAYS_IN_YEAR = 365, ///< days per year DAYS_IN_LEAP_YEAR = 366, ///< sometimes, you need one day more... }; /* * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are * primarily used for loading newgrf and savegame data and returning some * newgrf (callback) functions that were in the original (TTD) inherited * format, where '_date == 0' meant that it was 1920-01-01. */ /** The minimum starting year/base year of the original TTD */ #define ORIGINAL_BASE_YEAR 1920 /** The original ending year */ #define ORIGINAL_END_YEAR 2051 /** The maximum year of the original TTD */ #define ORIGINAL_MAX_YEAR 2090 /** * The offset in days from the '_date == 0' till * 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)' */ #define DAYS_TILL_ORIGINAL_BASE_YEAR (DAYS_IN_YEAR * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400) /* The absolute minimum & maximum years in OTTD */ #define MIN_YEAR 0 /* MAX_YEAR, nicely rounded value of the number of years that can * be encoded in a single 32 bits date, about 2^31 / 366 years. */ #define MAX_YEAR 5000000 typedef int32 Date; typedef uint16 DateFract; typedef int32 Year; typedef uint8 Month; typedef uint8 Day; /** * Data structure to convert between Date and triplet (year, month, and day). * @see ConvertDateToYMD(), ConvertYMDToDate() */ struct YearMonthDay { Year year; ///< Year (0...) Month month; ///< Month (0..11) Day day; ///< Day (1..31) }; static const Year INVALID_YEAR = -1; static const Date INVALID_DATE = -1; #endif /* DATE_TYPE_H */
2,057
C++
.h
54
36.444444
151
0.697137
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,493
cmd_helper.h
EnergeticBark_OpenTTD-3DS/src/cmd_helper.h
/* $Id$ */ /** @file cmd_helper.h Helper functions to extract data from command parameters. */ #ifndef CMD_HELPER_H #define CMD_HELPER_H #include "direction_type.h" #include "road_type.h" template<uint N> static inline void ExtractValid(); template<> inline void ExtractValid<1>() {} template<typename T> struct ExtractBits; template<> struct ExtractBits<Axis> { static const uint Count = 1; }; template<> struct ExtractBits<DiagDirection> { static const uint Count = 2; }; template<> struct ExtractBits<RoadBits> { static const uint Count = 4; }; template<typename T, uint N, typename U> static inline T Extract(U v) { /* Check if there are enough bits in v */ ExtractValid<N + ExtractBits<T>::Count <= sizeof(U) * 8>(); return (T)GB(v, N, ExtractBits<T>::Count); } #endif
804
C++
.h
19
40.631579
83
0.716129
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,494
company_gui.h
EnergeticBark_OpenTTD-3DS/src/company_gui.h
/* $Id$ */ /** @file company_gui.h GUI Functions related to companies. */ #ifndef COMPANY_GUI_H #define COMPANY_GUI_H #include "company_type.h" uint16 GetDrawStringCompanyColour(CompanyID company); void DrawCompanyIcon(CompanyID c, int x, int y); void ShowCompanyStations(CompanyID company); void ShowCompanyFinances(CompanyID company); void ShowCompany(CompanyID company); void InvalidateCompanyWindows(const Company *c); void DeleteCompanyWindows(CompanyID company); #endif /* COMPANY_GUI_H */
503
C++
.h
13
37.153846
62
0.809524
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,495
functions.h
EnergeticBark_OpenTTD-3DS/src/functions.h
/* $Id$ */ /** @file functions.h Some generic functions that actually shouldn't be here. */ #ifndef FUNCTIONS_H #define FUNCTIONS_H #include "core/random_func.hpp" #include "command_type.h" #include "tile_cmd.h" /* clear_land.cpp */ void DrawHillyLandTile(const TileInfo *ti); void DrawClearLandTile(const TileInfo *ti, byte set); void DrawClearLandFence(const TileInfo *ti); void TileLoopClearHelper(TileIndex tile); /* company_cmd.cpp */ bool CheckCompanyHasMoney(CommandCost cost); void SubtractMoneyFromCompany(CommandCost cost); void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cost); bool CheckOwnership(Owner owner); bool CheckTileOwnership(TileIndex tile); void InitializeLandscapeVariables(bool only_constants); /* misc functions */ /** * Mark a tile given by its coordinate dirty for repaint. * * @ingroup dirty */ void MarkTileDirty(int x, int y); /** * Mark a tile given by its index dirty for repaint. * * @ingroup dirty */ void MarkTileDirtyByTile(TileIndex tile); /** * Mark all viewports dirty for repaint. * * @ingroup dirty */ void MarkAllViewportsDirty(int left, int top, int right, int bottom); void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost); void ShowFeederIncomeAnimation(int x, int y, int z, Money cost); void AskExitGame(); void AskExitToGameMenu(); void RedrawAutosave(); int ttd_main(int argc, char *argv[]); void HandleExitGameRequest(); #endif /* FUNCTIONS_H */
1,449
C++
.h
46
29.956522
80
0.780576
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,496
pbs.h
EnergeticBark_OpenTTD-3DS/src/pbs.h
/* $Id$ */ /** @file pbs.h PBS support routines */ #ifndef PBS_H #define PBS_H #include "tile_type.h" #include "direction_type.h" #include "track_type.h" #include "vehicle_type.h" TrackBits GetReservedTrackbits(TileIndex t); void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b); bool TryReserveRailTrack(TileIndex tile, Track t); void UnreserveRailTrack(TileIndex tile, Track t); /** 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. PBSTileInfo() : tile(INVALID_TILE), trackdir(INVALID_TRACKDIR), okay(false) {} PBSTileInfo(TileIndex _t, Trackdir _td, bool _okay) : tile(_t), trackdir(_td), okay(_okay) {} }; PBSTileInfo FollowTrainReservation(const Vehicle *v, bool *train_on_res = NULL); bool IsSafeWaitingPosition(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg = false); bool IsWaitingPositionFree(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg = false); Vehicle *GetTrainForReservation(TileIndex tile, Track track); /** * Check whether some of tracks is reserved on a tile. * * @param tile the tile * @param tracks the tracks to test * @return true if at least on of tracks is reserved */ static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks) { return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE; } #endif /* PBS_H */
1,653
C++
.h
36
44.25
130
0.757632
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,497
vehiclelist.h
EnergeticBark_OpenTTD-3DS/src/vehiclelist.h
/* $Id$ */ /** @file vehiclelist.h Functions and type for generating vehicle lists. */ #ifndef VEHICLELIST_H #define VEHICLELIST_H #include "core/smallvec_type.hpp" typedef SmallVector<const Vehicle *, 32> VehicleList; void GenerateVehicleSortList(VehicleList *list, VehicleType type, Owner owner, uint32 index, uint16 window_type); void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list, bool individual_wagons = false); #endif /* VEHICLELIST_H */
511
C++
.h
9
55.111111
144
0.794355
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,498
genworld.h
EnergeticBark_OpenTTD-3DS/src/genworld.h
/* $Id$ */ /** @file genworld.h Functions related to world/map generation. */ #ifndef GENWORLD_H #define GENWORLD_H #include "company_type.h" /* * Order of these enums has to be the same as in lang/english.txt * Otherwise you will get inconsistent behaviour. */ enum { LG_ORIGINAL = 0, ///< The original landscape generator LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator GENERATE_NEW_SEED = UINT_MAX, ///< Create a new random seed }; /* Modes for GenerateWorld */ enum GenerateWorldMode { GW_NEWGAME = 0, ///< Generate a map for a new game GW_EMPTY = 1, ///< Generate an empty map (sea-level) GW_RANDOM = 2, ///< Generate a random map for SE GW_HEIGHTMAP = 3, ///< Generate a newgame from a heightmap }; typedef void gw_done_proc(); typedef void gw_abort_proc(); struct gw_info { bool active; ///< Is generating world active bool abort; ///< Whether to abort the thread ASAP bool wait_for_draw; ///< Are we waiting on a draw event bool quit_thread; ///< Do we want to quit the active thread bool threaded; ///< Whether we run _GenerateWorld threaded GenerateWorldMode mode;///< What mode are we making a world in CompanyID lc; ///< The local_company before generating uint size_x; ///< X-size of the map uint size_y; ///< Y-size of the map gw_done_proc *proc; ///< Proc that is called when done (can be NULL) gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL) class ThreadObject *thread; ///< The thread we are in (can be NULL) }; enum gwp_class { GWP_MAP_INIT, ///< Initialize/allocate the map, start economy GWP_LANDSCAPE, ///< Create the landscape GWP_ROUGH_ROCKY, ///< Make rough and rocky areas GWP_TOWN, ///< Generate towns GWP_INDUSTRY, ///< Generate industries GWP_UNMOVABLE, ///< Generate unmovables (radio tower, light houses) GWP_TREE, ///< Generate trees GWP_GAME_INIT, ///< Initialize the game GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc GWP_GAME_START, ///< Really prepare to start the game GWP_CLASS_COUNT }; /** * Check if we are currently in the process of generating a world. */ static inline bool IsGeneratingWorld() { extern gw_info _gw; return _gw.active; } /* genworld.cpp */ void SetGeneratingWorldPaintStatus(bool status); bool IsGeneratingWorldReadyForPaint(); bool IsGenerateWorldThreaded(); void GenerateWorldSetCallback(gw_done_proc *proc); void GenerateWorldSetAbortCallback(gw_abort_proc *proc); void WaitTillGeneratedWorld(); void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y); void AbortGeneratingWorld(); bool IsGeneratingWorldAborted(); void HandleGeneratingWorldAbortion(); /* genworld_gui.cpp */ void SetGeneratingWorldProgress(gwp_class cls, uint total); void IncreaseGeneratingWorldProgress(gwp_class cls); void PrepareGenerateWorldProgress(); void ShowGenerateWorldProgress(); void StartNewGameWithoutGUI(uint seed); void ShowCreateScenario(); void StartScenarioEditor(); #endif /* GENWORLD_H */
3,096
C++
.h
78
38.038462
76
0.720706
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,499
toolbar_gui.h
EnergeticBark_OpenTTD-3DS/src/toolbar_gui.h
/* $Id$ */ /** @file toolbar_gui.h Stuff related to the (main) toolbar. */ #ifndef TOOLBAR_GUI_H #define TOOLBAR_GUI_H void AllocateToolbar(); #endif /* TOOLBAR_GUI_H */
174
C++
.h
6
27.333333
63
0.695122
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,501
industry.h
EnergeticBark_OpenTTD-3DS/src/industry.h
/* $Id$ */ /** @file industry.h Base of all industries. */ #ifndef INDUSTRY_H #define INDUSTRY_H #include "oldpool.h" #include "core/random_func.hpp" #include "newgrf_storage.h" #include "cargo_type.h" #include "economy_type.h" #include "map_type.h" #include "slope_type.h" #include "date_type.h" #include "town_type.h" #include "industry_type.h" #include "landscape_type.h" enum { INVALID_INDUSTRY = 0xFFFF, NEW_INDUSTRYOFFSET = 37, ///< original number of industries NUM_INDUSTRYTYPES = 64, ///< total number of industries, new and old INDUSTRYTILE_NOANIM = 0xFF, ///< flag to mark industry tiles as having no animation NEW_INDUSTRYTILEOFFSET = 175, ///< original number of tiles INVALID_INDUSTRYTYPE = NUM_INDUSTRYTYPES, ///< one above amount is considered invalid NUM_INDUSTRYTILES = 512, ///< total number of industry tiles, new and old INVALID_INDUSTRYTILE = NUM_INDUSTRYTILES, ///< one above amount is considered invalid INDUSTRY_COMPLETED = 3, ///< final stage of industry construction. }; enum { CLEAN_RANDOMSOUNDS, ///< Free the dynamically allocated sounds table CLEAN_TILELSAYOUT, ///< Free the dynamically allocated tile layout structure }; enum IndustryLifeType { INDUSTRYLIFE_BLACK_HOLE = 0, ///< Like power plants and banks INDUSTRYLIFE_EXTRACTIVE = 1 << 0, ///< Like mines INDUSTRYLIFE_ORGANIC = 1 << 1, ///< Like forests INDUSTRYLIFE_PROCESSING = 1 << 2, ///< Like factories }; /* Procedures that can be run to check whether an industry may * build at location the given to the procedure */ enum CheckProc { CHECK_NOTHING, CHECK_FOREST, CHECK_REFINERY, CHECK_FARM, CHECK_PLANTATION, CHECK_WATER, CHECK_LUMBERMILL, CHECK_BUBBLEGEN, CHECK_OIL_RIG, CHECK_END, }; /** How was the industry created */ enum IndustryConstructionType { ICT_UNKNOWN, ///< in previous game version or without newindustries activated ICT_NORMAL_GAMEPLAY, ///< either by user or random creation proccess ICT_MAP_GENERATION, ///< during random map creation ICT_SCENARIO_EDITOR ///< while scenarion edition }; enum IndustryBehaviour { INDUSTRYBEH_NONE = 0, INDUSTRYBEH_PLANT_FIELDS = 1 << 0, ///< periodically plants fileds around itself (temp and artic farms) INDUSTRYBEH_CUT_TREES = 1 << 1, ///< cuts trees and produce first output cargo from them (lumber mill) INDUSTRYBEH_BUILT_ONWATER = 1 << 2, ///< is built on water (oil rig) INDUSTRYBEH_TOWN1200_MORE = 1 << 3, ///< can only be built in towns larger than 1200 inhabitants (temperate bank) INDUSTRYBEH_ONLY_INTOWN = 1 << 4, ///< can only be built in towns (arctic/tropic banks, water tower) INDUSTRYBEH_ONLY_NEARTOWN = 1 << 5, ///< is always built near towns (toy shop) INDUSTRYBEH_PLANT_ON_BUILT = 1 << 6, ///< Fields are planted around when built (all farms) INDUSTRYBEH_DONT_INCR_PROD = 1 << 7, ///< do not increase production (oil wells) in the temperate climate INDUSTRYBEH_BEFORE_1950 = 1 << 8, ///< can only be built before 1950 (oil wells) INDUSTRYBEH_AFTER_1960 = 1 << 9, ///< can only be built after 1960 (oil rigs) INDUSTRYBEH_AI_AIRSHIP_ROUTES = 1 << 10, ///< ai will attempt to establish air/ship routes to this industry (oil rig) INDUSTRYBEH_AIRPLANE_ATTACKS = 1 << 11, ///< can be exploded by a military airplane (oil refinery) INDUSTRYBEH_CHOPPER_ATTACKS = 1 << 12, ///< can be exploded by a military helicopter (factory) INDUSTRYBEH_CAN_SUBSIDENCE = 1 << 13, ///< can cause a subsidence (coal mine, shaft that collapses) /* The following flags are only used for newindustries and do no represent any normal behaviour */ INDUSTRYBEH_PROD_MULTI_HNDLING = 1 << 14, ///< Automatic production multiplier handling INDUSTRYBEH_PRODCALLBACK_RANDOM = 1 << 15, ///< Production callback needs random bits in var 10 INDUSTRYBEH_NOBUILT_MAPCREATION = 1 << 16, ///< Do not force one instance of this type to appear on map generation INDUSTRYBEH_CANCLOSE_LASTINSTANCE = 1 << 17, ///< Allow closing down the last instance of this type }; DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour); DECLARE_OLD_POOL(Industry, Industry, 3, 8000) /** * Defines the internal data of a functionnal industry */ struct Industry : PoolItem<Industry, IndustryID, &_Industry_pool> { typedef PersistentStorageArray<uint32, 16> PersistentStorage; TileIndex xy; ///< coordinates of the primary tile the industry is built one byte width; byte height; const Town *town; ///< Nearest town CargoID produced_cargo[2]; ///< 2 production cargo slots uint16 produced_cargo_waiting[2]; ///< amount of cargo produced per cargo uint16 incoming_cargo_waiting[3]; ///< incoming cargo waiting to be processed byte production_rate[2]; ///< production rate for each cargo byte prod_level; ///< general production level CargoID accepts_cargo[3]; ///< 3 input cargo slots uint16 this_month_production[2]; ///< stats of this month's production per cargo uint16 this_month_transported[2]; ///< stats of this month's transport per cargo byte last_month_pct_transported[2]; ///< percentage transported per cargo in the last full month uint16 last_month_production[2]; ///< total units produced per cargo in the last full month uint16 last_month_transported[2]; ///< total units transported per cargo in the last full month uint16 counter; ///< used for animation and/or production (if available cargo) IndustryType type; ///< type of industry. OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE byte random_colour; ///< randomized colour of the industry, for display purpose Year last_prod_year; ///< last year of production byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry OwnerByte founder; ///< Founder of the industry Date construction_date; ///< Date of the construction of the industry uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry byte selected_layout; ///< Which tile layout was used when creating the industry byte random_triggers; ///< Triggers for the random uint16 random; ///< Random value used for randomisation of all kinds of things PersistentStorage psa; ///< Persistent storage for NewGRF industries. Industry(TileIndex tile = INVALID_TILE) : xy(tile) {} ~Industry(); inline bool IsValid() const { return this->xy != INVALID_TILE; } }; struct IndustryTileTable { TileIndexDiffC ti; IndustryGfx gfx; }; /** Data related to the handling of grf files. Common to both industry and industry tile */ struct GRFFileProps { uint16 subst_id; uint16 local_id; ///< id defined by the grf file for this industry struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the industry const struct GRFFile *grffile; ///< grf file that introduced this industry uint16 override; ///< id of the entity been replaced by }; /** * Defines the data structure for constructing industry. */ struct IndustrySpec { const IndustryTileTable * const *table;///< List of the tiles composing the industry byte num_table; ///< Number of elements in the table uint8 cost_multiplier; ///< Base construction cost multiplier. uint32 removal_cost_multiplier; ///< Base removal cost multiplier. uint16 raw_industry_cost_multiplier; ///< Multiplier for the raw industries cost uint32 prospecting_chance; ///< Chance prospecting succeeds IndustryType conflicting[3]; ///< Industries this industry cannot be close to byte check_proc; ///< Index to a procedure to check for conflicting circumstances CargoID produced_cargo[2]; byte production_rate[2]; byte minimal_cargo; ///< minimum amount of cargo transported to the stations ///< If the waiting cargo is less than this number, no cargo is moved to it CargoID accepts_cargo[3]; ///< 3 accepted cargos uint16 input_cargo_multiplier[3][2]; ///< Input cargo multipliers (multiply amount of incoming cargo for the produced cargos) IndustryLifeType life_type; ///< This is also known as Industry production flag, in newgrf specs byte climate_availability; ///< Bitmask, giving landscape enums as bit position IndustryBehaviour behaviour; ///< How this industry will behave, and how others entities can use it byte map_colour; ///< colour used for the small map StringID name; ///< Displayed name of the industry StringID new_industry_text; ///< Message appearing when the industry is built StringID closure_text; ///< Message appearing when the industry closes StringID production_up_text; ///< Message appearing when the industry's production is increasing StringID production_down_text; ///< Message appearing when the industry's production is decreasing StringID station_name; ///< Default name for nearby station byte appear_ingame[NUM_LANDSCAPE]; ///< Probability of appearance in game byte appear_creation[NUM_LANDSCAPE]; ///< Probability of appearance during map creation uint8 number_of_sounds; ///< Number of sounds available in the sounds array const uint8 *random_sounds; ///< array of random sounds. /* Newgrf data */ uint16 callback_flags; ///< Flags telling which grf callback is set uint8 cleanup_flag; ///< flags indicating which data should be freed upon cleaning up bool enabled; ///< entity still avaible (by default true).newgrf can disable it, though struct GRFFileProps grf_prop; ///< properties related the the grf file /** * Is an industry with the spec a raw industry? * @return true if it should be handled as a raw industry */ bool IsRawIndustry() const; /** * Get the cost for constructing this industry * @return the cost (inflation corrected etc) */ Money GetConstructionCost() const; /** * Get the cost for removing this industry * Take note that the cost will always be zero for non-grf industries. * Only if the grf author did specified a cost will it be applicable. * @return the cost (inflation corrected etc) */ Money GetRemovalCost() const; }; /** * Defines the data structure of each indivudual tile of an industry. */ struct IndustryTileSpec { CargoID accepts_cargo[3]; ///< Cargo accepted by this tile uint8 acceptance[3]; ///< Level of aceptance per cargo type Slope slopes_refused; ///< slope pattern on which this tile cannot be built byte anim_production; ///< Animation frame to start when goods are produced byte anim_next; ///< Next frame in an animation bool anim_state; ///< When true, the tile has to be drawn using the animation ///< state instead of the construction state /* Newgrf data */ uint8 callback_flags; ///< Flags telling which grf callback is set uint16 animation_info; ///< Information about the animation (is it looping, how many loops etc) uint8 animation_speed; ///< The speed of the animation uint8 animation_triggers; ///< When to start the animation uint8 animation_special_flags; ///< Extra flags to influence the animation bool enabled; ///< entity still avaible (by default true).newgrf can disable it, though struct GRFFileProps grf_prop; }; /* industry_cmd.cpp*/ const IndustrySpec *GetIndustrySpec(IndustryType thistype); ///< Array of industries data const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx); ///< Array of industry tiles data void ResetIndustries(); void PlantRandomFarmField(const Industry *i); void ReleaseDisastersTargetingIndustry(IndustryID); /* writable arrays of specs */ extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]; extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]; static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx) { /* the 0xFF should be GFX_WATERTILE_SPECIALCHECK but for reasons of include mess, * we'll simplify the writing. * Basically, the first test is required since the GFX_WATERTILE_SPECIALCHECK value * will never be assigned as a tile index and is only required in order to do some * tests while building the industry (as in WATER REQUIRED */ if (gfx != 0xFF) { assert(gfx < INVALID_INDUSTRYTILE); const IndustryTileSpec *it = &_industry_tile_specs[gfx]; return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override; } else { return gfx; } } /* smallmap_gui.cpp */ void BuildIndustriesLegend(); /* industry_cmd.cpp */ void SetIndustryDailyChanges(); /** * Check if an Industry exists whithin the pool of industries * @param index of the desired industry * @return true if it is inside the pool */ static inline bool IsValidIndustryID(IndustryID index) { return index < GetIndustryPoolSize() && GetIndustry(index)->IsValid(); } static inline IndustryID GetMaxIndustryIndex() { /* TODO - This isn't the real content of the function, but * with the new pool-system this will be replaced with one that * _really_ returns the highest index. Now it just returns * the next safe value we are sure about everything is below. */ return GetIndustryPoolSize() - 1; } extern int _total_industries; // general counter extern uint16 _industry_counts[NUM_INDUSTRYTYPES]; // Number of industries per type ingame static inline uint GetNumIndustries() { return _total_industries; } /** Increment the count of industries for this type * @param type IndustryType to increment * @pre type < INVALID_INDUSTRYTYPE */ static inline void IncIndustryTypeCount(IndustryType type) { assert(type < INVALID_INDUSTRYTYPE); _industry_counts[type]++; _total_industries++; } /** Decrement the count of industries for this type * @param type IndustryType to decrement * @pre type < INVALID_INDUSTRYTYPE */ static inline void DecIndustryTypeCount(IndustryType type) { assert(type < INVALID_INDUSTRYTYPE); _industry_counts[type]--; _total_industries--; } /** get the count of industries for this type * @param type IndustryType to query * @pre type < INVALID_INDUSTRYTYPE */ static inline uint8 GetIndustryTypeCount(IndustryType type) { assert(type < INVALID_INDUSTRYTYPE); return min(_industry_counts[type], 0xFF); // callback expects only a byte, so cut it } /** Resets both the total_industries and the _industry_counts * This way, we centralize all counts activities */ static inline void ResetIndustryCounts() { _total_industries = 0; memset(&_industry_counts, 0, sizeof(_industry_counts)); } /** * Return a random valid industry. */ static inline Industry *GetRandomIndustry() { int num = RandomRange(GetNumIndustries()); IndustryID index = INVALID_INDUSTRY; if (GetNumIndustries() == 0) return NULL; while (num >= 0) { num--; index++; /* Make sure we have a valid industry */ while (!IsValidIndustryID(index)) { index++; assert(index <= GetMaxIndustryIndex()); } } return GetIndustry(index); } #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) if (i->IsValid()) #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) static const uint8 IT_INVALID = 255; #endif /* INDUSTRY_H */
16,305
C++
.h
314
49.735669
180
0.691632
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,502
map_type.h
EnergeticBark_OpenTTD-3DS/src/map_type.h
/* $Id$ */ /** @file map_type.h Types related to maps. */ #ifndef MAP_TYPE_H #define MAP_TYPE_H /** * Data that is stored per tile. Also used TileExtended for this. * Look at docs/landscape.html for the exact meaning of the members. */ struct Tile { byte type_height; ///< The type (bits 4..7) and height of the northern corner byte m1; ///< Primarily used for ownership information uint16 m2; ///< Primarily used for indices to towns, industries and stations byte m3; ///< General purpose byte m4; ///< General purpose byte m5; ///< General purpose byte m6; ///< Primarily used for bridges and rainforest/desert }; /** * Data that is stored per tile. Also used Tile for this. * Look at docs/landscape.html for the exact meaning of the members. */ struct TileExtended { byte m7; ///< Primarily used for newgrf support }; /** * An offset value between to tiles. * * This value is used fro the difference between * to tiles. It can be added to a tileindex to get * the resulting tileindex of the start tile applied * with this saved difference. * * @see TileDiffXY(int, int) */ typedef int32 TileIndexDiff; /** * A pair-construct of a TileIndexDiff. * * This can be used to save the difference between to * tiles as a pair of x and y value. */ struct TileIndexDiffC { int16 x; ///< The x value of the coordinate int16 y; ///< The y value of the coordinate }; /** * Approximation of the length of a straight track, relative to a diagonal * track (ie the size of a tile side). * * #defined instead of const so it can * stay integer. (no runtime float operations) Is this needed? * Watch out! There are _no_ brackets around here, to prevent intermediate * rounding! Be careful when using this! * This value should be sqrt(2)/2 ~ 0.7071 */ #define STRAIGHT_TRACK_LENGTH 7071/10000 #endif /* MAP_TYPE_H */
1,926
C++
.h
57
31.964912
86
0.693713
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,504
win32.h
EnergeticBark_OpenTTD-3DS/src/win32.h
/* $Id$ */ /** @file win32.h declarations of functions for MS windows systems */ #ifndef WIN32_H #define WIN32_H #include <windows.h> bool MyShowCursor(bool show); typedef void (*Function)(int); bool LoadLibraryList(Function proc[], const char *dll); char *convert_from_fs(const wchar_t *name, char *utf8_buf, size_t buflen); wchar_t *convert_to_fs(const char *name, wchar_t *utf16_buf, size_t buflen); /* Function shortcuts for UTF-8 <> UNICODE conversion. When unicode is not * defined these macros return the string passed to them, with UNICODE * they return a pointer to the converted string. The only difference between * XX_TO_YY and XX_TO_YY_BUFFER is that with the buffer variant you can * specify where to put the converted string (and how long it can be). Without * the buffer and internal buffer is used, of max 512 characters */ #if defined(UNICODE) # define MB_TO_WIDE(str) OTTD2FS(str) # define MB_TO_WIDE_BUFFER(str, buffer, buflen) convert_to_fs(str, buffer, buflen) # define WIDE_TO_MB(str) FS2OTTD(str) # define WIDE_TO_MB_BUFFER(str, buffer, buflen) convert_from_fs(str, buffer, buflen) #else extern uint _codepage; // local code-page in the system @see win32_v.cpp:WM_INPUTLANGCHANGE # define MB_TO_WIDE(str) (str) # define MB_TO_WIDE_BUFFER(str, buffer, buflen) (str) # define WIDE_TO_MB(str) (str) # define WIDE_TO_MB_BUFFER(str, buffer, buflen) (str) #endif /* Override SHGetFolderPath with our custom implementation */ #if defined(SHGetFolderPath) #undef SHGetFolderPath #endif #define SHGetFolderPath OTTDSHGetFolderPath HRESULT OTTDSHGetFolderPath(HWND, int, HANDLE, DWORD, LPTSTR); #if defined(__MINGW32__) #define SHGFP_TYPE_CURRENT 0 #endif /* __MINGW32__ */ #endif /* WIN32_H */
1,724
C++
.h
38
43.973684
91
0.75716
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,505
callback_table.h
EnergeticBark_OpenTTD-3DS/src/callback_table.h
/* $Id$ */ /** @file callback_table.h Table with all command callbacks. */ #ifndef CALLBACK_TABLE_H #define CALLBACK_TABLE_H #include "command_type.h" extern CommandCallback *_callback_table[]; extern const int _callback_table_count; #endif /* CALLBACK_TABLE_H */
269
C++
.h
8
32
63
0.75
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,506
newgrf_industrytiles.h
EnergeticBark_OpenTTD-3DS/src/newgrf_industrytiles.h
/* $Id$ */ /** @file newgrf_industrytiles.h NewGRF handling of industry tiles. */ #ifndef NEWGRF_INDUSTRYTILES_H #define NEWGRF_INDUSTRYTILES_H enum IndustryAnimationTrigger { IAT_CONSTRUCTION_STATE_CHANGE, IAT_TILELOOP, IAT_INDUSTRY_TICK, IAT_INDUSTRY_RECEIVED_CARGO, IAT_INDUSTRY_DISTRIBUTES_CARGO, }; 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); bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index); void AnimateNewIndustryTile(TileIndex tile); bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random()); bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat); enum IndustryTileTrigger { /* The tile of the industry has been triggered during the tileloop. */ INDTILE_TRIGGER_TILE_LOOP = 0x01, /* The industry has been triggered via it's tick. */ INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02, /* Cargo has been delivered. */ INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04, }; void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger); void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger); #endif /* NEWGRF_INDUSTRYTILES_H */
1,445
C++
.h
28
49.928571
164
0.811923
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,507
fileio_type.h
EnergeticBark_OpenTTD-3DS/src/fileio_type.h
/* $Id$ */ /** @file fileio_type.h Types for Standard In/Out file operations */ #ifndef FILEIO_TYPE_H #define FILEIO_TYPE_H #include "core/enum_type.hpp" /** * The different kinds of subdirectories OpenTTD uses */ enum Subdirectory { BASE_DIR, ///< Base directory for all subdirectories SAVE_DIR, ///< Base directory for all savegames AUTOSAVE_DIR, ///< Subdirectory of save for autosaves SCENARIO_DIR, ///< Base directory for all scenarios HEIGHTMAP_DIR, ///< Subdirectory of scenario for heightmaps GM_DIR, ///< Subdirectory for all music DATA_DIR, ///< Subdirectory for all data (GRFs, sample.cat, intro game) LANG_DIR, ///< Subdirectory for all translation files AI_DIR, ///< Subdirectory for all AI files AI_LIBRARY_DIR,///< Subdirectory for all AI libraries NUM_SUBDIRS, ///< Number of subdirectories NO_DIRECTORY, ///< A path without any base directory }; /** * Types of searchpaths OpenTTD might use */ enum Searchpath { SP_FIRST_DIR, SP_WORKING_DIR = SP_FIRST_DIR, ///< Search in the working directory SP_PERSONAL_DIR, ///< Search in the personal directory SP_SHARED_DIR, ///< Search in the shared directory, like 'Shared Files' under Windows SP_BINARY_DIR, ///< Search in the directory where the binary resides SP_INSTALLATION_DIR, ///< Search in the installation directory SP_APPLICATION_BUNDLE_DIR, ///< Search within the application bundle SP_AUTODOWNLOAD_DIR, ///< Search within the autodownload directory NUM_SEARCHPATHS }; DECLARE_POSTFIX_INCREMENT(Searchpath); #endif /* FILEIO_TYPE_H */
1,646
C++
.h
38
41.473684
102
0.695815
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,508
gamelog.h
EnergeticBark_OpenTTD-3DS/src/gamelog.h
/* $Id$ */ /** @file gamelog.h Functions to be called to log possibly unsafe game events */ #ifndef GAMELOG_H #define GAMELOG_H #include "newgrf_config.h" enum GamelogActionType { GLAT_START, ///< Game created GLAT_LOAD, ///< Game loaded GLAT_GRF, ///< GRF changed GLAT_CHEAT, ///< Cheat was used GLAT_SETTING, ///< Setting changed GLAT_GRFBUG, ///< GRF bug was triggered GLAT_EMERGENCY, ///< Emergency savegame GLAT_END, ///< So we know how many GLATs are there GLAT_NONE = 0xFF, ///< No logging active; in savegames, end of list }; void GamelogStartAction(GamelogActionType at); void GamelogStopAction(); void GamelogReset(); typedef void GamelogPrintProc(const char *s); void GamelogPrint(GamelogPrintProc *proc); // needed for WIN32 / WINCE crash.log void GamelogPrintDebug(int level); void GamelogPrintConsole(); void GamelogEmergency(); bool GamelogTestEmergency(); void GamelogRevision(); void GamelogMode(); void GamelogOldver(); void GamelogSetting(const char *name, int32 oldval, int32 newval); void GamelogGRFUpdate(const GRFConfig *oldg, const GRFConfig *newg); void GamelogGRFAddList(const GRFConfig *newg); void GamelogGRFRemove(uint32 grfid); void GamelogGRFAdd(const GRFConfig *newg); void GamelogGRFCompatible(const GRFIdentifier *newg); void GamelogTestRevision(); void GamelogTestMode(); void GamelogTestGRF(); bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id); void GamelogGetOriginalGRFMD5Checksum(uint32 grfid, byte *md5sum); #endif /* GAMELOG_H */
1,560
C++
.h
40
37.4
80
0.756146
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,509
gamelog_internal.h
EnergeticBark_OpenTTD-3DS/src/gamelog_internal.h
/* $Id$ */ /** @file gamelog_internal.h Declaration shared among gamelog.cpp and saveload/gamelog_sl.cpp */ #ifndef GAMELOG_INTERNAL_H #define GAMELOG_INTERNAL_H #include "network/core/config.h" /** Type of logged change */ enum GamelogChangeType { GLCT_MODE, ///< Scenario editor x Game, different landscape GLCT_REVISION, ///< Changed game revision string GLCT_OLDVER, ///< Loaded from savegame without logged data GLCT_SETTING, ///< Non-networksafe setting value changed GLCT_GRFADD, ///< Removed GRF GLCT_GRFREM, ///< Added GRF GLCT_GRFCOMPAT, ///< Loading compatible GRF GLCT_GRFPARAM, ///< GRF parameter changed GLCT_GRFMOVE, ///< GRF order changed GLCT_GRFBUG, ///< GRF bug triggered GLCT_EMERGENCY, ///< Emergency savegame GLCT_END, ///< So we know how many GLCTs are there GLCT_NONE = 0xFF, ///< In savegames, end of list }; /** Contains information about one logged change */ struct LoggedChange { GamelogChangeType ct; ///< Type of change logged in this struct union { struct { byte mode; ///< new game mode - Editor x Game byte landscape; ///< landscape (temperate, arctic, ...) } mode; struct { char text[NETWORK_REVISION_LENGTH]; ///< revision string, _openttd_revision uint32 newgrf; ///< _openttd_newgrf_version uint16 slver; ///< _sl_version byte modified; ///< _openttd_revision_modified } revision; struct { uint32 type; ///< type of savegame, @see SavegameType uint32 version; ///< major and minor version OR ttdp version } oldver; GRFIdentifier grfadd; ///< ID and md5sum of added GRF struct { uint32 grfid; ///< ID of removed GRF } grfrem; GRFIdentifier grfcompat; ///< ID and new md5sum of changed GRF struct { uint32 grfid; ///< ID of GRF with changed parameters } grfparam; struct { uint32 grfid; ///< ID of moved GRF int32 offset; ///< offset, positive = move down } grfmove; struct { char *name; ///< name of the setting int32 oldval; ///< old value int32 newval; ///< new value } setting; struct { uint64 data; ///< additional data uint32 grfid; ///< ID of problematic GRF byte bug; ///< type of bug, @see enum GRFBugs } grfbug; }; }; /** Contains information about one logged action that caused at least one logged change */ struct LoggedAction { LoggedChange *change; ///< First logged change in this action uint32 changes; ///< Number of changes in this action GamelogActionType at; ///< Type of action uint16 tick; ///< Tick when it happened }; extern LoggedAction *_gamelog_action; extern uint _gamelog_actions; #endif /* GAMELOG_INTERNAL_H */
2,724
C++
.h
73
34.671233
96
0.67323
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,510
map_func.h
EnergeticBark_OpenTTD-3DS/src/map_func.h
/* $Id$ */ /** @file map_func.h Functions related to maps. */ #ifndef MAP_FUNC_H #define MAP_FUNC_H #include "tile_type.h" #include "map_type.h" #include "direction_func.h" extern uint _map_tile_mask; /** * 'Wraps' the given tile to it is within the map. It does * this by masking the 'high' bits of. * @param x the tile to 'wrap' */ #define TILE_MASK(x) ((x) & _map_tile_mask) /** * Pointer to the tile-array. * * This variable points to the tile-array which contains the tiles of * the map. */ extern Tile *_m; /** * Pointer to the extended tile-array. * * This variable points to the extended tile-array which contains the tiles * of the map. */ extern TileExtended *_me; /** * Allocate a new map with the given size. */ void AllocateMap(uint size_x, uint size_y); /** * Logarithm of the map size along the X side. * @note try to avoid using this one * @return 2^"return value" == MapSizeX() */ static inline uint MapLogX() { extern uint _map_log_x; return _map_log_x; } /** * Logarithm of the map size along the y side. * @note try to avoid using this one * @return 2^"return value" == MapSizeY() */ static inline uint MapLogY() { extern uint _map_log_y; return _map_log_y; } /** * Get the size of the map along the X * @return the number of tiles along the X of the map */ static inline uint MapSizeX() { extern uint _map_size_x; return _map_size_x; } /** * Get the size of the map along the Y * @return the number of tiles along the Y of the map */ static inline uint MapSizeY() { extern uint _map_size_y; return _map_size_y; } /** * Get the size of the map * @return the number of tiles of the map */ static inline uint MapSize() { extern uint _map_size; return _map_size; } /** * Gets the maximum X coordinate within the map, including MP_VOID * @return the maximum X coordinate */ static inline uint MapMaxX() { return MapSizeX() - 1; } /** * Gets the maximum Y coordinate within the map, including MP_VOID * @return the maximum Y coordinate */ static inline uint MapMaxY() { return MapSizeY() - 1; } /** * Scales relative to the number of tiles. */ uint ScaleByMapSize(uint); /** * Scale relative to the circumference of the map. */ uint ScaleByMapSize1D(uint); /** * An offset value between to tiles. * * This value is used fro the difference between * to tiles. It can be added to a tileindex to get * the resulting tileindex of the start tile applied * with this saved difference. * * @see TileDiffXY(int, int) */ typedef int32 TileIndexDiff; /** * Returns the TileIndex of a coordinate. * * @param x The x coordinate of the tile * @param y The y coordinate of the tile * @return The TileIndex calculated by the coordinate */ static inline TileIndex TileXY(uint x, uint y) { return (y * MapSizeX()) + x; } /** * Calculates an offset for the given coordinate(-offset). * * This function calculate an offset value which can be added to an * #TileIndex. The coordinates can be negative. * * @param x The offset in x direction * @param y The offset in y direction * @return The resulting offset value of the given coordinate * @see ToTileIndexDiff(TileIndexDiffC) */ static inline TileIndexDiff TileDiffXY(int x, int y) { /* Multiplication gives much better optimization on MSVC than shifting. * 0 << shift isn't optimized to 0 properly. * Typically x and y are constants, and then this doesn't result * in any actual multiplication in the assembly code.. */ return (y * MapSizeX()) + x; } static inline TileIndex TileVirtXY(uint x, uint y) { return (y >> 4 << MapLogX()) + (x >> 4); } /** * Get the X component of a tile * @param tile the tile to get the X component of * @return the X component */ static inline uint TileX(TileIndex tile) { return tile & MapMaxX(); } /** * Get the Y component of a tile * @param tile the tile to get the Y component of * @return the Y component */ static inline uint TileY(TileIndex tile) { return tile >> MapLogX(); } /** * Return the offset between to tiles from a TileIndexDiffC struct. * * This function works like #TileDiffXY(int, int) and returns the * difference between two tiles. * * @param tidc The coordinate of the offset as TileIndexDiffC * @return The difference between two tiles. * @see TileDiffXY(int, int) */ static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc) { return (tidc.y << MapLogX()) + tidc.x; } #ifndef _DEBUG /** * Adds to tiles together. * * @param x One tile * @param y An other tile to add * @return The resulting tile(index) */ #define TILE_ADD(x,y) ((x) + (y)) #else extern TileIndex TileAdd(TileIndex tile, TileIndexDiff add, const char *exp, const char *file, int line); #define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__)) #endif /** * Adds a given offset to a tile. * * @param tile The tile to add an offset on it * @param x The x offset to add to the tile * @param y The y offset to add to the tile */ #define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y)) /** * Adds an offset to a tile and check if we are still on the map. */ TileIndex TileAddWrap(TileIndex tile, int addx, int addy); /** * Returns the TileIndexDiffC offset from a DiagDirection. * * @param dir The given direction * @return The offset as TileIndexDiffC value */ static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir) { extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END]; assert(IsValidDiagDirection(dir)); return _tileoffs_by_diagdir[dir]; } /** * Returns the TileIndexDiffC offset from a Direction. * * @param dir The given direction * @return The offset as TileIndexDiffC value */ static inline TileIndexDiffC TileIndexDiffCByDir(Direction dir) { extern const TileIndexDiffC _tileoffs_by_dir[DIR_END]; assert(IsValidDirection(dir)); return _tileoffs_by_dir[dir]; } /** * Add a TileIndexDiffC to a TileIndex and returns the new one. * * Returns tile + the diff given in diff. If the result tile would end up * outside of the map, INVALID_TILE is returned instead. * * @param tile The base tile to add the offset on * @param diff The offset to add on the tile * @return The resulting TileIndex */ static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff) { int x = TileX(tile) + diff.x; int y = TileY(tile) + diff.y; if (x < 0 || y < 0 || x > (int)MapMaxX() || y > (int)MapMaxY()) return INVALID_TILE; else return TileXY(x, y); } /** * Returns the diff between two tiles * * @param tile_a from tile * @param tile_b to tile * @return the difference between tila_a and tile_b */ static inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b) { TileIndexDiffC difference; difference.x = TileX(tile_a) - TileX(tile_b); difference.y = TileY(tile_a) - TileY(tile_b); return difference; } /* Functions to calculate distances */ uint DistanceManhattan(TileIndex, TileIndex); ///< also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads) uint DistanceSquare(TileIndex, TileIndex); ///< euclidian- or L2-Norm squared uint DistanceMax(TileIndex, TileIndex); ///< also known as L-Infinity-Norm uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map /** * Starts a loop which iterates to a square of tiles * * This macro starts 2 nested loops which iterates over a square of tiles. * * @param var The name of the variable which contains the current tile * @param w The width (x-width) of the square * @param h The heigth (y-width) of the square * @param tile The start tile of the square */ #define BEGIN_TILE_LOOP(var, w, h, tile) \ { \ int h_cur = h; \ uint var = tile; \ do { \ int w_cur = w; \ do { /** * Ends the square-loop used before * * @see BEGIN_TILE_LOOP */ #define END_TILE_LOOP(var, w, h, tile) \ } while (++var, --w_cur != 0); \ } while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \ } /** * Convert a DiagDirection to a TileIndexDiff * * @param dir The DiagDirection * @return The resulting TileIndexDiff * @see TileIndexDiffCByDiagDir */ static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir) { extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END]; assert(IsValidDiagDirection(dir)); return ToTileIndexDiff(_tileoffs_by_diagdir[dir]); } /** * Convert a Direction to a TileIndexDiff. * * @param dir The direction to convert from * @return The resulting TileIndexDiff */ static inline TileIndexDiff TileOffsByDir(Direction dir) { extern const TileIndexDiffC _tileoffs_by_dir[DIR_END]; assert(IsValidDirection(dir)); return ToTileIndexDiff(_tileoffs_by_dir[dir]); } /** * Adds a DiagDir to a tile. * * @param tile The current tile * @param dir The direction in which we want to step * @return the moved tile */ static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir) { return TILE_ADD(tile, TileOffsByDiagDir(dir)); } /** * A callback function type for searching tiles. * * @param tile The tile to test * @param user_data additional data for the callback function to use * @return A boolean value, depend on the definition of the function. */ typedef bool TestTileOnSearchProc(TileIndex tile, void *user_data); /** * Searches for some cirumstances of a tile around a given tile with a helper function. */ bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data); /** * Searches for some cirumstances of a tile around a given rectangle with a helper function. */ bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOnSearchProc proc, void *user_data); /** * Get a random tile out of a given seed. * @param r the random 'seed' * @return a valid tile */ static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); } /** * Get a valid random tile. * @note a define so 'random' gets inserted in the place where it is actually * called, thus making the random traces more explicit. * @return a valid tile */ #define RandomTile() RandomTileSeed(Random()) #endif /* MAP_FUNC_H */
10,506
C++
.h
364
27.024725
143
0.707491
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,511
articulated_vehicles.h
EnergeticBark_OpenTTD-3DS/src/articulated_vehicles.h
/* $Id$ */ /** @file articulated_vehicles.h Functions related to articulated vehicles. */ #ifndef ARTICULATED_VEHICLES_H #define ARTICULATED_VEHICLES_H #include "vehicle_type.h" #include "engine_type.h" uint CountArticulatedParts(EngineID engine_type, bool purchase_window); uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type); void AddArticulatedParts(Vehicle **vl, VehicleType type); uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type); uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type); bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *cargo_type); bool IsArticulatedVehicleRefittable(EngineID engine); void CheckConsistencyOfArticulatedVehicle(const Vehicle *v); #endif /* ARTICULATED_VEHICLES_H */
876
C++
.h
15
57
114
0.840936
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,512
widget_type.h
EnergeticBark_OpenTTD-3DS/src/widget_type.h
/* $Id$ */ /** @file widget_type.h Definitions about widgets. */ #ifndef WIDGET_TYPE_H #define WIDGET_TYPE_H #include "core/bitmath_func.hpp" #include "strings_type.h" #include "gfx_type.h" /* How the resize system works: First, you need to add a WWT_RESIZEBOX to the widgets, and you need to add the flag WDF_RESIZABLE to the window. Now the window is ready to resize itself. As you may have noticed, all widgets have a RESIZE_XXX in their line. This lines controls how the widgets behave on resize. RESIZE_NONE means it doesn't do anything. Any other option let's one of the borders move with the changed width/height. So if a widget has RESIZE_RIGHT, and the window is made 5 pixels wider by the user, the right of the window will also be made 5 pixels wider. Now, what if you want to clamp a widget to the bottom? Give it the flag RESIZE_TB. This is RESIZE_TOP + RESIZE_BOTTOM. Now if the window gets 5 pixels bigger, both the top and bottom gets 5 bigger, so the whole widgets moves downwards without resizing, and appears to be clamped to the bottom. Nice aint it? You should know one more thing about this system. Most windows can't handle an increase of 1 pixel. So there is a step function, which let the windowsize only be changed by X pixels. You configure this after making the window, like this: w->resize.step_height = 10; Now the window will only change in height in steps of 10. You can also give a minimum width and height. The default value is the default height/width of the window itself. You can change this AFTER window - creation, with: w->resize.width or w->resize.height. That was all.. good luck, and enjoy :) -- TrueLight */ enum DisplayFlags { RESIZE_NONE = 0, ///< no resize required RESIZE_LEFT = 1, ///< left resize flag RESIZE_RIGHT = 2, ///< rigth resize flag RESIZE_TOP = 4, ///< top resize flag RESIZE_BOTTOM = 8, ///< bottom resize flag RESIZE_LR = RESIZE_LEFT | RESIZE_RIGHT, ///< combination of left and right resize flags RESIZE_RB = RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of right and bottom resize flags RESIZE_TB = RESIZE_TOP | RESIZE_BOTTOM, ///< combination of top and bottom resize flags RESIZE_LRB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_BOTTOM, ///< combination of left, right and bottom resize flags RESIZE_LRTB = RESIZE_LEFT | RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of all resize flags RESIZE_RTB = RESIZE_RIGHT | RESIZE_TOP | RESIZE_BOTTOM, ///< combination of right, top and bottom resize flag /* The following flags are used by the system to specify what is disabled, hidden, or clicked * They are used in the same place as the above RESIZE_x flags, Widget visual_flags. * These states are used in exceptions. If nothing is specified, they will indicate * Enabled, visible or unclicked widgets*/ WIDG_DISABLED = 4, ///< widget is greyed out, not available WIDG_HIDDEN = 5, ///< widget is made invisible WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact }; DECLARE_ENUM_AS_BIT_SET(DisplayFlags); enum { WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions }; /** * Window widget types */ enum WidgetType { WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget array WWT_PANEL, ///< Simple depressed panel WWT_INSET, ///< Pressed (inset) panel, most commonly used as combo box _text_ area WWT_IMGBTN, ///< Button with image WWT_IMGBTN_2, ///< Button with diff image when clicked WWT_TEXTBTN, ///< Button with text WWT_TEXTBTN_2, ///< Button with diff text when clicked WWT_LABEL, ///< Centered label WWT_TEXT, ///< Pure simple text WWT_MATRIX, ///< List of items underneath each other WWT_SCROLLBAR, ///< Vertical scrollbar WWT_FRAME, ///< Frame WWT_CAPTION, ///< Window caption (window title between closebox and stickybox) WWT_HSCROLLBAR, ///< Horizontal scrollbar WWT_STICKYBOX, ///< Sticky box (normally at top-right of a window) WWT_SCROLL2BAR, ///< 2nd vertical scrollbar WWT_RESIZEBOX, ///< Resize box (normally at bottom-right of a window) WWT_CLOSEBOX, ///< Close box (at top-left of a window) WWT_DROPDOWN, ///< Raised drop down list (regular) WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only) WWT_EDITBOX, ///< a textbox for typing WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!! WWT_MASK = 0x1F, WWB_PUSHBUTTON = 1 << 5, WWB_MASK = 0xE0, WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON, WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON, }; /** Marker for the "end of widgets" in a Window(Desc) widget table. */ #define WIDGETS_END WWT_LAST, RESIZE_NONE, INVALID_COLOUR, 0, 0, 0, 0, 0, STR_NULL /** * Window widget data structure */ struct Widget { WidgetType type; ///< Widget type DisplayFlags display_flags; ///< Resize direction, alignment, etc. during resizing Colours colour; ///< Widget colour, see docs/ottd-colourtext-palette.png int16 left; ///< The left edge of the widget int16 right; ///< The right edge of the widget int16 top; ///< The top edge of the widget int16 bottom; ///< The bottom edge of the widget uint16 data; ///< The String/Image or special code (list-matrixes) of a widget StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget }; #endif /* WIDGET_TYPE_H */
5,734
C++
.h
107
50.785047
118
0.684914
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,514
elrail_func.h
EnergeticBark_OpenTTD-3DS/src/elrail_func.h
/* $Id$ */ /** @file elrail_func.h header file for electrified rail specific functions */ #ifndef ELRAIL_FUNC_H #define ELRAIL_FUNC_H #include "rail.h" #include "transparency.h" #include "tile_cmd.h" #include "settings_type.h" /** * Test if a rail type has catenary * @param rt Rail type to test */ static inline bool HasCatenary(RailType rt) { return HasBit(GetRailTypeInfo(rt)->flags, RTF_CATENARY); } /** * Test if we should draw rail catenary * @param rt Rail type to test */ static inline bool HasCatenaryDrawn(RailType rt) { return HasCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_settings_game.vehicle.disable_elrails; } /** * Draws overhead wires and pylons for electric railways. * @param ti The TileInfo struct of the tile being drawn * @see DrawCatenaryRailway */ void DrawCatenary(const TileInfo *ti); void DrawCatenaryOnTunnel(const TileInfo *ti); void DrawCatenaryOnBridge(const TileInfo *ti); bool SettingsDisableElrail(int32 p1); ///< _settings_game.disable_elrail callback #endif /* ELRAIL_FUNC_H */
1,044
C++
.h
34
29.117647
102
0.763473
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,515
tilehighlight_func.h
EnergeticBark_OpenTTD-3DS/src/tilehighlight_func.h
/* $Id$ */ /** @file tilehighlight_func.h Functions related to tile highlights. */ #ifndef TILEHIGHLIGHT_FUNC_H #define TILEHIGHLIGHT_FUNC_H #include "gfx_type.h" #include "window_type.h" #include "viewport_type.h" #include "tilehighlight_type.h" typedef void PlaceProc(TileIndex tile); void PlaceProc_DemolishArea(TileIndex tile); bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile); bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc); void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w); void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num); void ResetObjectToPlace(); void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method); void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process); void VpSetPresizeRange(TileIndex from, TileIndex to); void VpSetPlaceSizingLimit(int limit); void UpdateTileSelection(); extern PlaceProc *_place_proc; extern TileHighlightData _thd; #endif /* TILEHIGHLIGHT_FUNC_H */
1,217
C++
.h
23
51.521739
130
0.832911
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,516
string_type.h
EnergeticBark_OpenTTD-3DS/src/string_type.h
/* $Id$ */ /** @file string_type.h Types for strings. */ #ifndef STRING_TYPE_H #define STRING_TYPE_H /** * Valid filter types for IsValidChar. */ enum CharSetFilter { CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff CS_NUMERAL, ///< Only numeric ones CS_ALPHA, ///< Only alphabetic values }; typedef uint32 WChar; #endif /* STRING_TYPE_H */
400
C++
.h
14
26.857143
76
0.664042
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,517
oldpool_func.h
EnergeticBark_OpenTTD-3DS/src/oldpool_func.h
/* $Id$ */ /** @file oldpool_func.h Functions related to the old pool. */ #ifndef OLDPOOL_FUNC_H #define OLDPOOL_FUNC_H #include "oldpool.h" /** * Allocate a pool item; possibly allocate a new block in the pool. * @param first the first pool item to start searching * @pre first <= Tpool->GetSize() * @pre CanAllocateItem() * @return the allocated pool item */ template<typename T, typename Tid, OldMemoryPool<T> *Tpool> T *PoolItem<T, Tid, Tpool>::AllocateSafeRaw(uint &first) { uint last_minus_one = Tpool->GetSize() - 1; for (T *t = Tpool->Get(first); t != NULL; t = ((uint)t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) { if (!t->IsValid()) { first = t->index; Tid index = t->index; memset(t, 0, Tpool->item_size); t->index = index; return t; } } /* Check if we can add a block to the pool */ if (Tpool->AddBlockToPool()) return AllocateRaw(first); /* One should *ALWAYS* be sure to have enough space before making vehicles! */ NOT_REACHED(); } /** * Check whether we can allocate an item in this pool. This to prevent the * need to actually construct the object and then destructing it again, * which could be *very* costly. * @param count the number of items to create * @return true if and only if at least count items can be allocated. */ template<typename T, typename Tid, OldMemoryPool<T> *Tpool> bool PoolItem<T, Tid, Tpool>::CanAllocateItem(uint count) { uint last_minus_one = Tpool->GetSize() - 1; uint orig_count = count; for (T *t = Tpool->Get(Tpool->first_free_index); count > 0 && t != NULL; t = ((uint)t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) { if (!t->IsValid()) count--; } if (count == 0) return true; /* Check if we can add a block to the pool */ if (Tpool->AddBlockToPool()) return CanAllocateItem(orig_count); return false; } #endif /* OLDPOOL_FUNC_H */
1,877
C++
.h
49
36.040816
149
0.684675
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,518
autoreplace_type.h
EnergeticBark_OpenTTD-3DS/src/autoreplace_type.h
/* $Id$ */ /** @file autoreplace_type.h Types related to autoreplacing. */ #ifndef AUTOREPLACE_TYPE_H #define AUTOREPLACE_TYPE_H struct EngineRenew; /** * A list to group EngineRenew directives together (such as per-company). */ typedef EngineRenew *EngineRenewList; #endif /* AUTOREPLACE_TYPE_H */
306
C++
.h
10
28.9
73
0.75945
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,519
town_map.h
EnergeticBark_OpenTTD-3DS/src/town_map.h
/* $Id$ */ /** @file town_map.h Accessors for towns */ #ifndef TOWN_MAP_H #define TOWN_MAP_H #include "town.h" #include "tile_map.h" /** * Get the index of which town this house/street is attached to. * @param t the tile * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) * @return TownID */ static inline TownID GetTownIndex(TileIndex t) { assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_ROAD)); // XXX incomplete return _m[t].m2; } /** * Set the town index for a road or house tile. * @param t the tile * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) * @param index the index of the town * @pre IsTileType(t, MP_ROAD) || IsTileType(t, MP_HOUSE) */ static inline void SetTownIndex(TileIndex t, TownID index) { assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_ROAD)); _m[t].m2 = index; } /** * Gets the town associated with the house or road tile * @param t the tile to get the town of * @return the town */ static inline Town *GetTownByTile(TileIndex t) { return GetTown(GetTownIndex(t)); } /** * Get the type of this house, which is an index into the house spec array * Since m4 is only a byte and we want to support 512 houses, we use the bit 6 * of m3 as an additional bit to house type. * @param t the tile * @pre IsTileType(t, MP_HOUSE) * @return house type */ static inline HouseID GetHouseType(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return _m[t].m4 | (GB(_m[t].m3, 6, 1) << 8); } /** * Set the house type. * @param t the tile * @param house_id the new house type * @pre IsTileType(t, MP_HOUSE) */ static inline void SetHouseType(TileIndex t, HouseID house_id) { assert(IsTileType(t, MP_HOUSE)); _m[t].m4 = GB(house_id, 0, 8); SB(_m[t].m3, 6, 1, GB(house_id, 8, 1)); } /** * Check if the lift of this animated house has a destination * @param t the tile * @return has destination */ static inline bool LiftHasDestination(TileIndex t) { return HasBit(_me[t].m7, 0); } /** * Set the new destination of the lift for this animated house, and activate * the LiftHasDestination bit. * @param t the tile * @param dest new destination */ static inline void SetLiftDestination(TileIndex t, byte dest) { SetBit(_me[t].m7, 0); SB(_me[t].m7, 1, 3, dest); } /** * Get the current destination for this lift * @param t the tile * @return destination */ static inline byte GetLiftDestination(TileIndex t) { return GB(_me[t].m7, 1, 3); } /** * Stop the lift of this animated house from moving. * Clears the first 4 bits of m7 at once, clearing the LiftHasDestination bit * and the destination. * @param t the tile */ static inline void HaltLift(TileIndex t) { SB(_me[t].m7, 0, 4, 0); } /** * Get the position of the lift on this animated house * @param t the tile * @return position, from 0 to 36 */ static inline byte GetLiftPosition(TileIndex t) { return GB(_m[t].m6, 2, 6); } /** * Set the position of the lift on this animated house * @param t the tile * @param pos position, from 0 to 36 */ static inline void SetLiftPosition(TileIndex t, byte pos) { SB(_m[t].m6, 2, 6, pos); } /** * Get the current animation frame for this house * @param t the tile * @pre IsTileType(t, MP_HOUSE) * @return frame number */ static inline byte GetHouseAnimationFrame(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return GB(_m[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6); } /** * Set a new animation frame for this house * @param t the tile * @param frame the new frame number * @pre IsTileType(t, MP_HOUSE) */ static inline void SetHouseAnimationFrame(TileIndex t, byte frame) { assert(IsTileType(t, MP_HOUSE)); SB(_m[t].m6, 2, 6, GB(frame, 0, 6)); SB(_m[t].m3, 5, 1, GB(frame, 6, 1)); } /** * Get the completion of this house * @param t the tile * @return true if it is, false if it is not */ static inline bool IsHouseCompleted(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return HasBit(_m[t].m3, 7); } /** * Mark this house as been completed * @param t the tile * @param status */ static inline void SetHouseCompleted(TileIndex t, bool status) { assert(IsTileType(t, MP_HOUSE)); SB(_m[t].m3, 7, 1, !!status); } /** * Make the tile a house. * @param t tile index * @param tid Town index * @param counter of construction step * @param stage of construction (used for drawing) * @param type of house. Index into house specs array * @param random_bits required for newgrf houses * @pre IsTileType(t, MP_CLEAR) */ static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits) { assert(IsTileType(t, MP_CLEAR)); SetTileType(t, MP_HOUSE); _m[t].m1 = random_bits; _m[t].m2 = tid; _m[t].m3 = 0; SetHouseType(t, type); SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED); _m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter); SetHouseAnimationFrame(t, 0); _me[t].m7 = GetHouseSpecs(type)->processing_time; } /** * House Construction Scheme. * Construction counter, for buildings under construction. Incremented on every * periodic tile processing. * On wraparound, the stage of building in is increased. * GetHouseBuildingStage is taking care of the real stages, * (as the sprite for the next phase of house building) * (Get|Inc)HouseConstructionTick is simply a tick counter between the * different stages */ /** * Gets the building stage of a house * Since the stage is used for determining what sprite to use, * if the house is complete (and that stage no longuer is available), * fool the system by returning the TOWN_HOUSE_COMPLETE (3), * thus showing a beautiful complete house. * @param t the tile of the house to get the building stage of * @pre IsTileType(t, MP_HOUSE) * @return the building stage of the house */ static inline byte GetHouseBuildingStage(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(_m[t].m5, 3, 2); } /** * Gets the construction stage of a house * @param t the tile of the house to get the construction stage of * @pre IsTileType(t, MP_HOUSE) * @return the construction stage of the house */ static inline byte GetHouseConstructionTick(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return IsHouseCompleted(t) ? 0 : GB(_m[t].m5, 0, 3); } /** * Sets the increment stage of a house * It is working with the whole counter + stage 5 bits, making it * easier to work: the wraparound is automatic. * @param t the tile of the house to increment the construction stage of * @pre IsTileType(t, MP_HOUSE) */ static inline void IncHouseConstructionTick(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); AB(_m[t].m5, 0, 5, 1); if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) { /* House is now completed. * Store the year of construction as well, for newgrf house purpose */ SetHouseCompleted(t, true); } } /** * Sets the age of the house to zero. * Needs to be called after the house is completed. During construction stages the map space is used otherwise. * @param t the tile of this house * @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t) */ static inline void ResetHouseAge(TileIndex t) { assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)); _m[t].m5 = 0; } /** * Increments the age of the house. * @param t the tile of this house * @pre IsTileType(t, MP_HOUSE) */ static inline void IncrementHouseAge(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++; } /** * Get the age of the house * @param t the tile of this house * @pre IsTileType(t, MP_HOUSE) * @return year */ static inline Year GetHouseAge(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return IsHouseCompleted(t) ? _m[t].m5 : 0; } /** * Set the random bits for this house. * This is required for newgrf house * @param t the tile of this house * @param random the new random bits * @pre IsTileType(t, MP_HOUSE) */ static inline void SetHouseRandomBits(TileIndex t, byte random) { assert(IsTileType(t, MP_HOUSE)); _m[t].m1 = random; } /** * Get the random bits for this house. * This is required for newgrf house * @param t the tile of this house * @pre IsTileType(t, MP_HOUSE) * @return random bits */ static inline byte GetHouseRandomBits(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return _m[t].m1; } /** * Set the activated triggers bits for this house. * This is required for newgrf house * @param t the tile of this house * @param triggers the activated triggers * @pre IsTileType(t, MP_HOUSE) */ static inline void SetHouseTriggers(TileIndex t, byte triggers) { assert(IsTileType(t, MP_HOUSE)); SB(_m[t].m3, 0, 5, triggers); } /** * Get the already activated triggers bits for this house. * This is required for newgrf house * @param t the tile of this house * @pre IsTileType(t, MP_HOUSE) * @return triggers */ static inline byte GetHouseTriggers(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return GB(_m[t].m3, 0, 5); } /** * Get the amount of time remaining before the tile loop processes this tile. * @param t the house tile * @pre IsTileType(t, MP_HOUSE) * @return time remaining */ static inline byte GetHouseProcessingTime(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); return _me[t].m7; } /** * Set the amount of time remaining before the tile loop processes this tile. * @param t the house tile * @param time the time to be set * @pre IsTileType(t, MP_HOUSE) */ static inline void SetHouseProcessingTime(TileIndex t, byte time) { assert(IsTileType(t, MP_HOUSE)); _me[t].m7 = time; } /** * Decrease the amount of time remaining before the tile loop processes this tile. * @param t the house tile * @pre IsTileType(t, MP_HOUSE) */ static inline void DecHouseProcessingTime(TileIndex t) { assert(IsTileType(t, MP_HOUSE)); _me[t].m7--; } #endif /* TOWN_MAP_H */
9,836
C++
.h
352
26.181818
115
0.714437
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,520
vehicle_gui_base.h
EnergeticBark_OpenTTD-3DS/src/vehicle_gui_base.h
/* $Id$ */ /** @file vehicle_gui_base.h Functions/classes shared between the different vehicle list GUIs. */ #ifndef VEHICLE_GUI_BASE_H #define VEHICLE_GUI_BASE_H #include "sortlist_type.h" /** Start of functions regarding vehicle list windows */ enum { PLY_WND_PRC__OFFSET_TOP_WIDGET = 26, PLY_WND_PRC__SIZE_OF_ROW_TINY = 13, PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26, PLY_WND_PRC__SIZE_OF_ROW_BIG = 39, }; typedef GUIList<const Vehicle*> GUIVehicleList; struct BaseVehicleListWindow: public Window { GUIVehicleList vehicles; ///< The list of vehicles Listing *sorting; ///< Pointer to the vehicle type related sorting. VehicleType vehicle_type; ///< The vehicle type that is sorted static const StringID vehicle_sorter_names[]; static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[]; BaseVehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs); } void DrawVehicleListItems(int x, VehicleID selected_vehicle); void SortVehicleList(); void BuildVehicleList(Owner owner, uint16 index, uint16 window_type); }; struct Sorting { Listing aircraft; Listing roadveh; Listing ship; Listing train; }; extern Sorting _sorting; #endif /* VEHICLE_GUI_BASE_H */
1,302
C++
.h
35
35.257143
104
0.763347
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,522
slope_type.h
EnergeticBark_OpenTTD-3DS/src/slope_type.h
/* $Id$ */ /** * @file slope_type.h Definitions of a slope. * This file defines the enumeration and helper functions for handling * the slope info of a tile. */ #ifndef SLOPE_TYPE_H #define SLOPE_TYPE_H #include "core/enum_type.hpp" /** * Enumeration of tile corners */ enum Corner { CORNER_W = 0, CORNER_S = 1, CORNER_E = 2, CORNER_N = 3, CORNER_END, CORNER_INVALID = 0xFF }; /** * Enumeration for the slope-type. * * This enumeration use the chars N,E,S,W corresponding the * direction north, east, south and west. The top corner of a tile * is the north-part of the tile. The whole slope is encoded with * 5 bits, 4 bits for each corner and 1 bit for a steep-flag. * * For halftile slopes an extra 3 bits are used to represent this * properly; 1 bit for a halftile-flag and 2 bits to encode which * extra side (corner) is leveled when the slope of the first 5 * bits is applied. This means that there can only be one leveled * slope for steep slopes, which is logical because two leveled * slopes would mean that it is not a steep slope as halftile * slopes only span one height level. */ enum Slope { SLOPE_FLAT = 0x00, ///< a flat tile SLOPE_W = 0x01, ///< the west corner of the tile is raised SLOPE_S = 0x02, ///< the south corner of the tile is raised SLOPE_E = 0x04, ///< the east corner of the tile is raised SLOPE_N = 0x08, ///< the north corner of the tile is raised SLOPE_STEEP = 0x10, ///< indicates the slope is steep SLOPE_NW = SLOPE_N | SLOPE_W, ///< north and west corner are raised SLOPE_SW = SLOPE_S | SLOPE_W, ///< south and west corner are raised SLOPE_SE = SLOPE_S | SLOPE_E, ///< south and east corner are raised SLOPE_NE = SLOPE_N | SLOPE_E, ///< north and east corner are raised SLOPE_EW = SLOPE_E | SLOPE_W, ///< east and west corner are raised SLOPE_NS = SLOPE_N | SLOPE_S, ///< north and south corner are raised SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S, ///< north, west and south corner are raised SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E, ///< west, south and east corner are raised SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N, ///< south, east and north corner are raised SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W, ///< east, north and west corner are raised SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS, ///< a steep slope falling to east (from west) SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE, ///< a steep slope falling to north (from south) SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, ///< a steep slope falling to west (from east) SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW, ///< a steep slope falling to south (from north) SLOPE_HALFTILE = 0x20, ///< one halftile is leveled (non continuous slope) SLOPE_HALFTILE_MASK = 0xE0, ///< three bits used for halftile slopes SLOPE_HALFTILE_W = SLOPE_HALFTILE | (CORNER_W << 6), ///< the west halftile is leveled (non continuous slope) SLOPE_HALFTILE_S = SLOPE_HALFTILE | (CORNER_S << 6), ///< the south halftile is leveled (non continuous slope) SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6), ///< the east halftile is leveled (non continuous slope) SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6), ///< the north halftile is leveled (non continuous slope) }; DECLARE_ENUM_AS_BIT_SET(Slope) /** * Enumeration for Foundations. */ enum Foundation { FOUNDATION_NONE, ///< The tile has no foundation, the slope remains unchanged. FOUNDATION_LEVELED, ///< The tile is leveled up to a flat slope. FOUNDATION_INCLINED_X, ///< The tile has an along X-axis inclined foundation. FOUNDATION_INCLINED_Y, ///< The tile has an along Y-axis inclined foundation. FOUNDATION_STEEP_LOWER, ///< The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on the lower halftile. /* Halftile foundations */ FOUNDATION_STEEP_BOTH, ///< The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is leveled. FOUNDATION_HALFTILE_W, ///< Level west halftile non-continuously. FOUNDATION_HALFTILE_S, ///< Level south halftile non-continuously. FOUNDATION_HALFTILE_E, ///< Level east halftile non-continuously. FOUNDATION_HALFTILE_N, ///< Level north halftile non-continuously. /* Special anti-zig-zag foundations for single horizontal/vertical track */ FOUNDATION_RAIL_W, ///< Foundation for TRACK_BIT_LEFT, but not a leveled foundation. FOUNDATION_RAIL_S, ///< Foundation for TRACK_BIT_LOWER, but not a leveled foundation. FOUNDATION_RAIL_E, ///< Foundation for TRACK_BIT_RIGHT, but not a leveled foundation. FOUNDATION_RAIL_N, ///< Foundation for TRACK_BIT_UPPER, but not a leveled foundation. FOUNDATION_INVALID = 0xFF ///< Used inside "rail_cmd.cpp" to indicate invalid slope/track combination. }; #endif /* SLOPE_TYPE_H */
5,530
C++
.h
89
60.168539
156
0.629145
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,523
newgrf_generic.h
EnergeticBark_OpenTTD-3DS/src/newgrf_generic.h
/* $Id$ */ /** @file newgrf_generic.h Functions related to generic callbacks. */ #ifndef NEWGRF_GENERIC_H #define NEWGRF_GENERIC_H 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_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 AICE_SHIP_GET_FIRST_ENGINE = 0x01, ///< Unused, we check all AICE_SHIP_GET_NUMBER_ENGINES = 0x02, ///< Unused, we check all AICE_AIRCRAFT_CHECK_ENGINE = 0x00, ///< Check if we should build an engine AICE_STATION_GET_STATION_ID = 0x00, ///< Get a station ID to build }; void ResetGenericCallbacks(); void AddGenericCallback(uint8 feature, const struct GRFFile *file, const struct 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); #endif /* NEWGRF_GENERIC_H */
1,596
C++
.h
27
57.111111
254
0.713919
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,525
strings_type.h
EnergeticBark_OpenTTD-3DS/src/strings_type.h
/* $Id$ */ /** @file strings_type.h Types related to strings. */ #ifndef STRINGS_TYPE_H #define STRINGS_TYPE_H /** * Numeric value that represents a string, independent of the selected language. */ typedef uint16 StringID; static const StringID INVALID_STRING_ID = 0xFFFF; ///< Constant representing an invalid string enum { MAX_LANG = 64, ///< Maximal number of languages supported by the game }; /** Directions a text can go to */ enum TextDirection { TD_LTR, ///< Text is written left-to-right by default TD_RTL, ///< Text is written right-to-left by default }; /** Information about a language */ struct Language { char *name; ///< The internal name of the language char *file; ///< The name of the language as it appears on disk }; /** Used for dynamic language support */ struct DynamicLanguages { int num; ///< Number of languages int curr; ///< Currently selected language index char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language). TextDirection text_dir; ///< Text direction of the currently selected language Language ent[MAX_LANG]; ///< Information about the languages }; /** Special string constants */ enum SpecialStrings { /* special strings for town names. the town name is generated dynamically on request. */ SPECSTR_TOWNNAME_START = 0x20C0, SPECSTR_TOWNNAME_ENGLISH = SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_FRENCH, SPECSTR_TOWNNAME_GERMAN, SPECSTR_TOWNNAME_AMERICAN, SPECSTR_TOWNNAME_LATIN, SPECSTR_TOWNNAME_SILLY, SPECSTR_TOWNNAME_SWEDISH, SPECSTR_TOWNNAME_DUTCH, SPECSTR_TOWNNAME_FINNISH, SPECSTR_TOWNNAME_POLISH, SPECSTR_TOWNNAME_SLOVAKISH, SPECSTR_TOWNNAME_NORWEGIAN, SPECSTR_TOWNNAME_HUNGARIAN, SPECSTR_TOWNNAME_AUSTRIAN, SPECSTR_TOWNNAME_ROMANIAN, SPECSTR_TOWNNAME_CZECH, SPECSTR_TOWNNAME_SWISS, SPECSTR_TOWNNAME_DANISH, SPECSTR_TOWNNAME_TURKISH, SPECSTR_TOWNNAME_ITALIAN, SPECSTR_TOWNNAME_CATALAN, SPECSTR_TOWNNAME_LAST = SPECSTR_TOWNNAME_CATALAN, /* special strings for player names on the form "TownName transport". */ SPECSTR_PLAYERNAME_START = 0x70EA, SPECSTR_PLAYERNAME_ENGLISH = SPECSTR_PLAYERNAME_START, SPECSTR_PLAYERNAME_FRENCH, SPECSTR_PLAYERNAME_GERMAN, SPECSTR_PLAYERNAME_AMERICAN, SPECSTR_PLAYERNAME_LATIN, SPECSTR_PLAYERNAME_SILLY, SPECSTR_PLAYERNAME_LAST = SPECSTR_PLAYERNAME_SILLY, SPECSTR_ANDCO_NAME = 0x70E6, SPECSTR_PRESIDENT_NAME = 0x70E7, SPECSTR_SONGNAME = 0x70E8, /* reserve MAX_LANG strings for the *.lng files */ SPECSTR_LANGUAGE_START = 0x7100, SPECSTR_LANGUAGE_END = SPECSTR_LANGUAGE_START + MAX_LANG - 1, /* reserve 32 strings for various screen resolutions */ SPECSTR_RESOLUTION_START = SPECSTR_LANGUAGE_END + 1, SPECSTR_RESOLUTION_END = SPECSTR_RESOLUTION_START + 0x1F, /* reserve 32 strings for screenshot formats */ SPECSTR_SCREENSHOT_START = SPECSTR_RESOLUTION_END + 1, SPECSTR_SCREENSHOT_END = SPECSTR_SCREENSHOT_START + 0x1F, }; #endif /* STRINGS_TYPE_H */
3,075
C++
.h
79
37.012658
139
0.751426
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,526
settings_internal.h
EnergeticBark_OpenTTD-3DS/src/settings_internal.h
/* $Id$ */ /** @file settings_internal.h Functions and types used internally for the settings configurations. */ #ifndef SETTINGS_INTERNAL_H #define SETTINGS_INTERNAL_H #include "saveload/saveload.h" #include "settings_type.h" /** Convention/Type of settings. This is then further specified if necessary * with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h * @see VarTypes * @see SettingDescBase */ enum SettingDescTypeLong { /* 4 bytes allocated a maximum of 16 types for GenericType */ SDT_BEGIN = 0, SDT_NUMX = 0, ///< any number-type SDT_BOOLX = 1, ///< a boolean number SDT_ONEOFMANY = 2, ///< bitmasked number where only ONE bit may be set SDT_MANYOFMANY = 3, ///< bitmasked number where MULTIPLE bits may be set SDT_INTLIST = 4, ///< list of integers seperated by a comma ',' SDT_STRING = 5, ///< string with a pre-allocated buffer SDT_END, /* 10 more possible primitives */ }; template <> struct EnumPropsT<SettingDescTypeLong> : MakeEnumPropsT<SettingDescTypeLong, byte, SDT_BEGIN, SDT_END, SDT_END> {}; typedef TinyEnumT<SettingDescTypeLong> SettingDescType; enum SettingGuiFlagLong { /* 8 bytes allocated for a maximum of 8 flags * Flags directing saving/loading of a variable */ SGF_NONE = 0, SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled SGF_NOCOMMA = 1 << 1, ///< number without any thousand seperators (no formatting) SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer) SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in inside a game SGF_END = 1 << 7, }; DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong); template <> struct EnumPropsT<SettingGuiFlagLong> : MakeEnumPropsT<SettingGuiFlagLong, byte, SGF_NONE, SGF_END, SGF_END> {}; typedef TinyEnumT<SettingGuiFlagLong> SettingGuiFlag; typedef bool OnChange(int32 var); ///< callback prototype on data modification typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error struct SettingDescBase { const char *name; ///< name of the setting. Used in configuration file and for console const void *def; ///< default value given when none is present SettingDescType cmd; ///< various flags for the variable SettingGuiFlag flags; ///< handles how a setting would show up in the GUI (text/currency, etc.) int32 min, max; ///< minimum and maximum values int32 interval; ///< the interval to use between settings in the 'settings' window. If interval is '0' the interval is dynamically determined const char *many; ///< ONE/MANY_OF_MANY: string of possible values for this type StringID str; ///< (translated) string with descriptive text; gui and console OnChange *proc; ///< callback procedure for when the value is changed OnConvert *proc_cnvt; ///< callback procedure when loading value mechanism fails }; struct SettingDesc { SettingDescBase desc; ///< Settings structure (going to configuration file) SaveLoad save; ///< Internal structure (going to savegame, parts to config) }; /* NOTE: The only difference between SettingDesc and SettingDescGlob is * that one uses global variables as a source and the other offsets * in a struct which are bound to a certain variable during runtime. * The only way to differentiate between these two is to check if an object * has been passed to the function or not. If not, then it is a global variable * and save->variable has its address, otherwise save->variable only holds the * offset in a certain struct */ typedef SettingDesc SettingDescGlobVarList; const SettingDesc *GetSettingFromName(const char *name, uint *i); bool SetSettingValue(uint index, int32 value); bool SetSettingValue(uint index, const char *value); #endif /* SETTINGS_H */
4,165
C++
.h
70
57.671429
150
0.730637
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,527
vehicle_base.h
EnergeticBark_OpenTTD-3DS/src/vehicle_base.h
/* $Id$ */ /** @file vehicle_base.h Base class for all vehicles. */ #ifndef VEHICLE_BASE_H #define VEHICLE_BASE_H #include "vehicle_type.h" #include "track_type.h" #include "rail_type.h" #include "road_type.h" #include "cargo_type.h" #include "direction_type.h" #include "gfx_type.h" #include "command_type.h" #include "date_type.h" #include "company_base.h" #include "company_type.h" #include "oldpool.h" #include "order_base.h" #include "cargopacket.h" #include "texteff.hpp" #include "group_type.h" #include "engine_type.h" #include "order_func.h" #include "transport_type.h" /** Road vehicle states */ enum RoadVehicleStates { /* * Lower 4 bits are used for vehicle track direction. (Trackdirs) * When in a road stop (bit 5 or bit 6 set) these bits give the * track direction of the entry to the road stop. * As the entry direction will always be a diagonal * direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3 * are needed to hold this direction. Bit 1 is then used to show * that the vehicle is using the second road stop bay. * Bit 2 is then used for drive-through stops to show the vehicle * is stopping at this road stop. */ /* Numeric values */ RVSB_IN_DEPOT = 0xFE, ///< The vehicle is in a depot RVSB_WORMHOLE = 0xFF, ///< The vehicle is in a tunnel and/or bridge /* Bit numbers */ RVS_USING_SECOND_BAY = 1, ///< Only used while in a road stop RVS_IS_STOPPING = 2, ///< Only used for drive-through stops. Vehicle will stop here RVS_DRIVE_SIDE = 4, ///< Only used when retrieving move data RVS_IN_ROAD_STOP = 5, ///< The vehicle is in a road stop RVS_IN_DT_ROAD_STOP = 6, ///< The vehicle is in a drive-through road stop /* Bit sets of the above specified bits */ RVSB_IN_ROAD_STOP = 1 << RVS_IN_ROAD_STOP, ///< The vehicle is in a road stop RVSB_IN_ROAD_STOP_END = RVSB_IN_ROAD_STOP + TRACKDIR_END, RVSB_IN_DT_ROAD_STOP = 1 << RVS_IN_DT_ROAD_STOP, ///< The vehicle is in a drive-through road stop RVSB_IN_DT_ROAD_STOP_END = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END, RVSB_TRACKDIR_MASK = 0x0F, ///< The mask used to extract track dirs RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09 ///< Only bits 0 and 3 are used to encode the trackdir for road stops }; enum VehStatus { VS_HIDDEN = 0x01, VS_STOPPED = 0x02, VS_UNCLICKABLE = 0x04, VS_DEFPAL = 0x08, VS_TRAIN_SLOWING = 0x10, VS_SHADOW = 0x20, VS_AIRCRAFT_BROKEN = 0x40, VS_CRASHED = 0x80, }; enum VehicleFlags { VF_LOADING_FINISHED, VF_CARGO_UNLOADING, VF_BUILT_AS_PROTOTYPE, VF_TIMETABLE_STARTED, ///< Whether the vehicle has started running on the timetable yet. VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically. VF_AUTOFILL_PRES_WAIT_TIME, ///< Whether non-destructive auto-fill should preserve waiting times }; struct VehicleRail { /* Link between the two ends of a multiheaded engine */ Vehicle *other_multiheaded_part; /* Cached wagon override spritegroup */ const struct SpriteGroup *cached_override; uint16 last_speed; // NOSAVE: only used in UI uint16 crash_anim_pos; /* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */ uint32 cached_power; ///< total power of the consist. uint16 cached_max_speed; ///< max speed of the consist. (minimum of the max speed of all vehicles in the consist) uint16 cached_total_length; ///< Length of the whole train, valid only for first engine. uint8 cached_veh_length; ///< length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback bool cached_tilt; ///< train can tilt; feature provides a bonus in curves /* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */ uint32 cached_weight; ///< total weight of the consist. uint32 cached_veh_weight; ///< weight of the vehicle. uint32 cached_max_te; ///< max tractive effort of consist /** * Position/type of visual effect. * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear) * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric) * bit 6 = disable visual effect. * bit 7 = disable powered wagons. */ byte cached_vis_effect; byte user_def_data; /* NOSAVE: for wagon override - id of the first engine in train * 0xffff == not in train */ EngineID first_engine; uint16 flags; TrackBitsByte track; byte force_proceed; RailTypeByte railtype; RailTypes compatible_railtypes; }; enum VehicleRailFlags { VRF_REVERSING = 0, /* used to calculate if train is going up or down */ VRF_GOINGUP = 1, VRF_GOINGDOWN = 2, /* used to store if a wagon is powered or not */ VRF_POWEREDWAGON = 3, /* used to reverse the visible direction of the vehicle */ VRF_REVERSE_DIRECTION = 4, /* used to mark train as lost because PF can't find the route */ VRF_NO_PATH_TO_DESTINATION = 5, /* used to mark that electric train engine is allowed to run on normal rail */ VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6, /* used for vehicle var 0xFE bit 8 (toggled each time the train is reversed, accurate for first vehicle only) */ VRF_TOGGLE_REVERSE = 7, /* used to mark a train that can't get a path reservation */ VRF_TRAIN_STUCK = 8, }; struct VehicleAir { uint16 crashed_counter; uint16 cached_max_speed; byte pos; byte previous_pos; StationID targetairport; byte state; }; struct VehicleRoad { byte state; ///< @see RoadVehicleStates byte frame; uint16 blocked_ctr; byte overtaking; byte overtaking_ctr; uint16 crashed_ctr; byte reverse_ctr; struct RoadStop *slot; byte slot_age; EngineID first_engine; byte cached_veh_length; RoadType roadtype; RoadTypes compatible_roadtypes; }; struct VehicleEffect { uint16 animation_state; byte animation_substate; }; struct VehicleDisaster { uint16 image_override; VehicleID big_ufo_destroyer_target; }; struct VehicleShip { TrackBitsByte state; }; DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125) /* Some declarations of functions, so we can make them friendly */ struct SaveLoad; extern const SaveLoad *GetVehicleDescription(VehicleType vt); struct LoadgameState; extern bool LoadOldVehicle(LoadgameState *ls, int num); struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle { private: Vehicle *next; ///< pointer to the next vehicle in the chain Vehicle *previous; ///< NOSAVE: pointer to the previous vehicle in the chain Vehicle *first; ///< NOSAVE: pointer to the first vehicle in the chain Vehicle *next_shared; ///< pointer to the next vehicle that shares the order Vehicle *previous_shared; ///< NOSAVE: pointer to the previous vehicle in the shared order chain public: friend const SaveLoad *GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code friend void AfterLoadVehicles(bool part_of_load); ///< So we can set the previous and first pointers while loading friend bool LoadOldVehicle(LoadgameState *ls, int num); ///< So we can set the proper next pointer while loading char *name; ///< Name of vehicle TileIndex tile; ///< Current tile index /** * Heading for this tile. * For airports and train stations this tile does not necessarily belong to the destination station, * but it can be used for heuristical purposes to estimate the distance. */ TileIndex dest_tile; Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract Money value; /* Used for timetabling. */ uint32 current_order_time; ///< How many ticks have passed since this order started. int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is. /* Boundaries for the current position in the world and a next hash link. * NOSAVE: All of those can be updated with VehiclePositionChanged() */ Rect coord; Vehicle *next_hash; Vehicle *next_new_hash; Vehicle **old_new_hash; SpriteID colourmap; // NOSAVE: cached colour mapping /* Related to age and service time */ Year build_year; Date age; // Age in days Date max_age; // Maximum age Date date_of_last_service; Date service_interval; uint16 reliability; uint16 reliability_spd_dec; byte breakdown_ctr; byte breakdown_delay; byte breakdowns_since_last_service; byte breakdown_chance; int32 x_pos; // coordinates int32 y_pos; byte z_pos; DirectionByte direction; // facing OwnerByte owner; // which company owns the vehicle? byte spritenum; // currently displayed sprite index // 0xfd == custom sprite, 0xfe == custom second head sprite // 0xff == reserved for another custom sprite uint16 cur_image; // sprite number for this vehicle byte x_extent; // x-extent of vehicle bounding box byte y_extent; // y-extent of vehicle bounding box byte z_extent; // z-extent of vehicle bounding box int8 x_offs; // x offset for vehicle sprite int8 y_offs; // y offset for vehicle sprite EngineID engine_type; TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object UnitID unitnumber; // unit number, for display purposes only uint16 max_speed; ///< maximum speed uint16 cur_speed; ///< current speed byte subspeed; ///< fractional speed byte acceleration; ///< used by train & aircraft uint32 motion_counter; byte progress; /* for randomized variational spritegroups * bitmask used to resolve them; parts of it get reseeded when triggers * of corresponding spritegroups get matched */ byte random_bits; byte waiting_triggers; ///< triggers to be yet matched StationID last_station_visited; CargoID cargo_type; ///< type of cargo this vehicle is carrying byte cargo_subtype; ///< Used for livery refits (NewGRF variations) uint16 cargo_cap; ///< total capacity CargoList cargo; ///< The cargo this vehicle is carrying byte day_counter; ///< Increased by one for each day byte tick_counter; ///< Increased by one for each tick byte running_ticks; ///< Number of ticks this vehicle was not stopped this day byte vehstatus; ///< Status Order current_order; ///< The current order (+ status, like: loading) VehicleOrderID cur_order_index; ///< The index to the current order union { OrderList *list; ///< Pointer to the order list for this vehicle Order *old; ///< Only used during conversion of old save games } orders; byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) uint16 load_unload_time_rem; GroupID group_id; ///< Index of group Pool array byte subtype; ///< subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes) union { VehicleRail rail; VehicleAir air; VehicleRoad road; VehicleEffect effect; VehicleDisaster disaster; VehicleShip ship; } u; /* cached oftenly queried NewGRF values */ uint8 cache_valid; ///< Whether the caches are valid uint32 cached_var40; ///< Cache for NewGRF var 40 uint32 cached_var41; ///< Cache for NewGRF var 41 uint32 cached_var42; ///< Cache for NewGRF var 42 uint32 cached_var43; ///< Cache for NewGRF var 43 /** * Allocates a lot of vehicles. * @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only) * @param num number of vehicles to allocate room for * @return true if there is room to allocate all the vehicles */ static bool AllocateList(Vehicle **vl, int num); /** Create a new vehicle */ Vehicle(); /** Destroy all stuff that (still) needs the virtual functions to work properly */ void PreDestructor(); /** We want to 'destruct' the right class. */ virtual ~Vehicle(); void BeginLoading(); void LeaveStation(); /** * Handle the loading of the vehicle; when not it skips through dummy * orders and does nothing in all other cases. * @param mode is the non-first call for this vehicle in this tick? */ void HandleLoading(bool mode = false); /** * Get a string 'representation' of the vehicle type. * @return the string representation. */ virtual const char *GetTypeString() const { return "base vehicle"; } /** * Marks the vehicles to be redrawn and updates cached variables * * This method marks the area of the vehicle on the screen as dirty. * It can be use to repaint the vehicle. * * @ingroup dirty */ virtual void MarkDirty() {} /** * Updates the x and y offsets and the size of the sprite used * for this vehicle. * @param direction the direction the vehicle is facing */ virtual void UpdateDeltaXY(Direction direction) {} /** * Sets the expense type associated to this vehicle type * @param income whether this is income or (running) expenses of the vehicle */ virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; } /** * Play the sound associated with leaving the station */ virtual void PlayLeaveStationSound() const {} /** * Whether this is the primary vehicle in the chain. */ virtual bool IsPrimaryVehicle() const { return false; } /** * Gets the sprite to show for the given direction * @param direction the direction the vehicle is facing * @return the sprite for the given vehicle in the given direction */ virtual SpriteID GetImage(Direction direction) const { return 0; } /** * Gets the speed in km-ish/h that can be sent into SetDParam for string processing. * @return the vehicle's speed */ virtual int GetDisplaySpeed() const { return 0; } /** * Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing. * @return the vehicle's maximum speed */ virtual int GetDisplayMaxSpeed() const { return 0; } /** * Gets the running cost of a vehicle * @return the vehicle's running cost */ virtual Money GetRunningCost() const { return 0; } /** * Check whether the vehicle is in the depot. * @return true if and only if the vehicle is in the depot. */ virtual bool IsInDepot() const { return false; } /** * Check whether the vehicle is in the depot *and* stopped. * @return true if and only if the vehicle is in the depot and stopped. */ virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; } /** * Calls the tick handler of the vehicle */ virtual void Tick() {}; /** * Calls the new day handler of the vehicle */ virtual void OnNewDay() {}; /** * Gets the running cost of a vehicle that can be sent into SetDParam for string processing. * @return the vehicle's running cost */ Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); } /** * Gets the profit vehicle had this year. It can be sent into SetDParam for string processing. * @return the vehicle's profit this year */ Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); } /** * Gets the profit vehicle had last year. It can be sent into SetDParam for string processing. * @return the vehicle's profit last year */ Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); } /** * Set the next vehicle of this vehicle. * @param next the next vehicle. NULL removes the next vehicle. */ void SetNext(Vehicle *next); /** * Get the next vehicle of this vehicle. * @note articulated parts are also counted as vehicles. * @return the next vehicle or NULL when there isn't a next vehicle. */ inline Vehicle *Next() const { return this->next; } /** * Get the previous vehicle of this vehicle. * @note articulated parts are also counted as vehicles. * @return the previous vehicle or NULL when there isn't a previous vehicle. */ inline Vehicle *Previous() const { return this->previous; } /** * Get the first vehicle of this vehicle chain. * @return the first vehicle of the chain. */ inline Vehicle *First() const { return this->first; } /** * Get the first order of the vehicles order list. * @return first order of order list. */ inline Order *GetFirstOrder() const { return (this->orders.list == NULL) ? NULL : this->orders.list->GetFirstOrder(); } /** * Adds this vehicle to a shared vehicle chain. * @param shared_chain a vehicle of the chain with shared vehicles. * @pre !this->IsOrderListShared() */ void AddToShared(Vehicle *shared_chain); /** * Removes the vehicle from the shared order list. */ void RemoveFromShared(); /** * Get the next vehicle of the shared vehicle chain. * @return the next shared vehicle or NULL when there isn't a next vehicle. */ inline Vehicle *NextShared() const { return this->next_shared; } /** * Get the previous vehicle of the shared vehicle chain * @return the previous shared vehicle or NULL when there isn't a previous vehicle. */ inline Vehicle *PreviousShared() const { return this->previous_shared; } /** * Get the first vehicle of this vehicle chain. * @return the first vehicle of the chain. */ inline Vehicle *FirstShared() const { return (this->orders.list == NULL) ? this->First() : this->orders.list->GetFirstSharedVehicle(); } /** * Check if we share our orders with another vehicle. * @return true if there are other vehicles sharing the same order */ inline bool IsOrderListShared() const { return this->orders.list != NULL && this->orders.list->IsShared(); } /** * Get the number of orders this vehicle has. * @return the number of orders this vehicle has. */ inline VehicleOrderID GetNumOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumOrders(); } /** * Copy certain configurations and statistics of a vehicle after successful autoreplace/renew * The function shall copy everything that cannot be copied by a command (like orders / group etc), * and that shall not be resetted for the new vehicle. * @param src The old vehicle */ inline void CopyVehicleConfigAndStatistics(const Vehicle *src) { this->unitnumber = src->unitnumber; this->cur_order_index = src->cur_order_index; this->current_order = src->current_order; this->dest_tile = src->dest_tile; this->profit_this_year = src->profit_this_year; this->profit_last_year = src->profit_last_year; this->current_order_time = src->current_order_time; this->lateness_counter = src->lateness_counter; this->service_interval = src->service_interval; } bool NeedsAutorenewing(const Company *c) const; /** * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement. * * @see NeedsAutomaticServicing() * @return true if the vehicle should go to a depot if a opportunity presents itself. */ bool NeedsServicing() const; /** * Checks if the current order should be interupted for a service-in-depot-order. * @see NeedsServicing() * @return true if the current order should be interupted. */ bool NeedsAutomaticServicing() const; /** * Determine the location for the station where the vehicle goes to next. * Things done for example are allocating slots in a road stop or exact * location of the platform is determined for ships. * @param station the station to make the next location of the vehicle. * @return the location (tile) to aim for. */ virtual TileIndex GetOrderStationLocation(StationID station) { return INVALID_TILE; } /** * Find the closest depot for this vehicle and tell us the location, * DestinationID and whether we should reverse. * @param location where do we go to? * @param destination what hangar do we go to? * @param reverse should the vehicle be reversed? * @return true if a depot could be found. */ virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) { return false; } /** * Send this vehicle to the depot using the given command(s). * @param flags the command flags (like execute and such). * @param command the command to execute. * @return the cost of the depot action. */ CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command); }; /** * This class 'wraps' Vehicle; you do not actually instantiate this class. * You create a Vehicle using AllocateVehicle, so it is added to the pool * and you reinitialize that to a Train using: * v = new (v) Train(); * * As side-effect the vehicle type is set correctly. */ struct DisasterVehicle : public Vehicle { /** Initializes the Vehicle to a disaster vehicle */ DisasterVehicle() { this->type = VEH_DISASTER; } /** We want to 'destruct' the right class. */ virtual ~DisasterVehicle() {} const char *GetTypeString() const { return "disaster vehicle"; } void UpdateDeltaXY(Direction direction); void Tick(); }; /** * This class 'wraps' Vehicle; you do not actually instantiate this class. * You create a Vehicle using AllocateVehicle, so it is added to the pool * and you reinitialize that to a Train using: * v = new (v) Train(); * * As side-effect the vehicle type is set correctly. */ struct InvalidVehicle : public Vehicle { /** Initializes the Vehicle to a invalid vehicle */ InvalidVehicle() { this->type = VEH_INVALID; } /** We want to 'destruct' the right class. */ virtual ~InvalidVehicle() {} const char *GetTypeString() const { return "invalid vehicle"; } void Tick() {} }; static inline VehicleID GetMaxVehicleIndex() { /* TODO - This isn't the real content of the function, but * with the new pool-system this will be replaced with one that * _really_ returns the highest index. Now it just returns * the next safe value we are sure about everything is below. */ return GetVehiclePoolSize() - 1; } static inline uint GetNumVehicles() { return GetVehiclePoolSize(); } #define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid()) #define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0) /** * Check if an index is a vehicle-index (so between 0 and max-vehicles) * @param index of the vehicle to query * @return Returns true if the vehicle-id is in range */ static inline bool IsValidVehicleID(uint index) { return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid(); } /** Generates sequence of free UnitID numbers */ struct FreeUnitIDGenerator { bool *cache; ///< array of occupied unit id numbers UnitID maxid; ///< maximum ID at the moment of constructor call UnitID curid; ///< last ID returned ; 0 if none /** Initializes the structure. Vehicle unit numbers are supposed not to change after * struct initialization, except after each call to this->NextID() the returned value * is assigned to a vehicle. * @param type type of vehicle * @param owner owner of vehicles */ FreeUnitIDGenerator(VehicleType type, CompanyID owner); /** Returns next free UnitID. Supposes the last returned value was assigned to a vehicle. */ UnitID NextID(); /** Releases allocated memory */ ~FreeUnitIDGenerator() { free(this->cache); } }; /* Returns order 'index' of a vehicle or NULL when it doesn't exists */ static inline Order *GetVehicleOrder(const Vehicle *v, int index) { return (v->orders.list == NULL) ? NULL : v->orders.list->GetOrderAt(index); } /** * Returns the last order of a vehicle, or NULL if it doesn't exists * @param v Vehicle to query * @return last order of a vehicle, if available */ static inline Order *GetLastVehicleOrder(const Vehicle *v) { return (v->orders.list == NULL) ? NULL : v->orders.list->GetLastOrder(); } /** * Returns the Trackdir on which the vehicle is currently located. * Works for trains and ships. * Currently works only sortof for road vehicles, since they have a fuzzy * concept of being "on" a trackdir. Dunno really what it returns for a road * vehicle that is halfway a tile, never really understood that part. For road * vehicles that are at the beginning or end of the tile, should just return * the diagonal trackdir on which they are driving. I _think_. * For other vehicles types, or vehicles with no clear trackdir (such as those * in depots), returns 0xFF. */ Trackdir GetVehicleTrackdir(const Vehicle *v); void CheckVehicle32Day(Vehicle *v); static const int32 INVALID_COORD = 0x7fffffff; #endif /* VEHICLE_BASE_H */
25,120
C++
.h
593
39.89882
174
0.708414
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,528
newgrf_cargo.h
EnergeticBark_OpenTTD-3DS/src/newgrf_cargo.h
/* $Id$ */ /** @file newgrf_cargo.h Cargo support for NewGRFs. */ #ifndef NEWGRF_CARGO_H #define NEWGRF_CARGO_H #include "newgrf_callbacks.h" #include "cargo_type.h" #include "gfx_type.h" enum CargoClass { CC_NOAVAILABLE = 0, ///< No cargo class has been specified CC_PASSENGERS = 1 << 0, ///< Passengers CC_MAIL = 1 << 1, ///< Mail CC_EXPRESS = 1 << 2, ///< Express cargo (Goods, Food, Candy, but also possible for passengers) CC_ARMOURED = 1 << 3, ///< Armoured cargo (Valuables, Gold, Diamonds) CC_BULK = 1 << 4, ///< Bulk cargo (Coal, Grain etc., Ores, Fruit) CC_PIECE_GOODS = 1 << 5, ///< Piece goods (Livestock, Wood, Steel, Paper) CC_LIQUID = 1 << 6, ///< Liquids (Oil, Water, Rubber) CC_REFRIGERATED = 1 << 7, ///< Refrigerated cargo (Food, Fruit) CC_HAZARDOUS = 1 << 8, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.) CC_COVERED = 1 << 9, ///< Covered/Sheltered Freight (Transporation in Box Vans, Silo Wagons, etc.) CC_SPECIAL = 1 << 15 ///< Special bit used for livery refit tricks instead of normal cargoes. }; static const CargoID CT_DEFAULT = NUM_CARGO + 0; static const CargoID CT_PURCHASE = NUM_CARGO + 1; static const CargoID CT_DEFAULT_NA = NUM_CARGO + 2; /* Forward declarations of structs used */ struct CargoSpec; struct GRFFile; SpriteID GetCustomCargoSprite(const CargoSpec *cs); uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs); CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit = false); uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile); #endif /* NEWGRF_CARGO_H */
1,690
C++
.h
32
51.1875
105
0.681212
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,529
newgrf_town.h
EnergeticBark_OpenTTD-3DS/src/newgrf_town.h
/* $Id$ */ /** @file newgrf_town.h Functions to handle the town part of NewGRF towns. */ #ifndef NEWGRF_TOWN_H #define NEWGRF_TOWN_H /* Currently there is no direct town resolver; we only need to get town * variable results from inside stations, house tiles and industry tiles. */ uint32 TownGetVariable(byte variable, byte parameter, bool *available, const Town *t); #endif /* NEWGRF_TOWN_H */
401
C++
.h
8
48.375
86
0.75
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,530
textbuf_gui.h
EnergeticBark_OpenTTD-3DS/src/textbuf_gui.h
/* $Id$ */ /** @file textbuf_gui.h Stuff related to the text buffer GUI. */ #ifndef TEXTBUF_GUI_H #define TEXTBUF_GUI_H #include "window_type.h" #include "string_type.h" #include "strings_type.h" #include "core/enum_type.hpp" struct Textbuf { char *buf; ///< buffer in which text is saved uint16 maxsize, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxsize is in bytes (including terminating '\0') uint16 size, width; ///< the current size of the string. Width specifies screensize in pixels, size is in bytes bool caret; ///< is the caret ("_") visible or not uint16 caretpos; ///< the current position of the caret in the buffer, in bytes uint16 caretxoffs; ///< the current position of the caret in pixels }; bool HandleCaret(Textbuf *tb); void DeleteTextBufferAll(Textbuf *tb); bool DeleteTextBufferChar(Textbuf *tb, int delmode); bool InsertTextBufferChar(Textbuf *tb, uint32 key); bool InsertTextBufferClipboard(Textbuf *tb); bool MoveTextBufferPos(Textbuf *tb, int navmode); void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth); void UpdateTextBufferSize(Textbuf *tb); /** Flags used in ShowQueryString() call */ enum QueryStringFlags { QSF_NONE = 0, QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change QSF_ENABLE_DEFAULT = 0x02, ///< enable the 'Default' button ("\0" is returned) }; DECLARE_ENUM_AS_BIT_SET(QueryStringFlags) typedef void QueryCallbackProc(Window*, bool); void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags); void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback); /** The number of 'characters' on the on-screen keyboard. */ static const uint OSK_KEYBOARD_ENTRIES = 50; /** * The number of characters has to be OSK_KEYBOARD_ENTRIES. However, these * have to be UTF-8 encoded, which means up to 4 bytes per character. * Furthermore the string needs to be '\0'-terminated. */ extern char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES * 4 + 1]; #endif /* TEXTBUF_GUI_H */
2,214
C++
.h
43
49.860465
153
0.737599
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,531
driver.h
EnergeticBark_OpenTTD-3DS/src/driver.h
/* $Id$ */ /** @file driver.h Base for all drivers (video, sound, music, etc). */ #ifndef DRIVER_H #define DRIVER_H #include "core/enum_type.hpp" #include "core/string_compare_type.hpp" #include "string_func.h" #include <map> const char *GetDriverParam(const char * const *parm, const char *name); bool GetDriverParamBool(const char * const *parm, const char *name); int GetDriverParamInt(const char * const *parm, const char *name, int def); class Driver { public: virtual const char *Start(const char * const *parm) = 0; virtual void Stop() = 0; virtual ~Driver() { } enum Type { DT_BEGIN = 0, DT_SOUND = 0, DT_MUSIC, DT_VIDEO, DT_END, }; }; DECLARE_POSTFIX_INCREMENT(Driver::Type); class DriverFactoryBase { private: Driver::Type type; const char *name; int priority; typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers; static Drivers &GetDrivers() { static Drivers &s_drivers = *new Drivers(); return s_drivers; } static Driver **GetActiveDriver(Driver::Type type) { static Driver *s_driver[3] = { NULL, NULL, NULL }; return &s_driver[type]; } static const char *GetDriverTypeName(Driver::Type type) { static const char *driver_type_name[] = { "sound", "music", "video" }; return driver_type_name[type]; } protected: void RegisterDriver(const char *name, Driver::Type type, int priority); public: DriverFactoryBase() : name(NULL) {} virtual ~DriverFactoryBase(); /** Shuts down all active drivers */ static void ShutdownDrivers() { for (Driver::Type dt = Driver::DT_BEGIN; dt < Driver::DT_END; dt++) { Driver *driver = *GetActiveDriver(dt); if (driver != NULL) driver->Stop(); } } static const Driver *SelectDriver(const char *name, Driver::Type type); static char *GetDriversInfo(char *p, const char *last); /** * Get a nice description of the driver-class. */ virtual const char *GetDescription() = 0; /** * Create an instance of this driver-class. */ virtual Driver *CreateInstance() = 0; }; #endif /* DRIVER_H */
2,044
C++
.h
74
25.283784
76
0.708783
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,532
newgrf_spritegroup.h
EnergeticBark_OpenTTD-3DS/src/newgrf_spritegroup.h
/* $Id$ */ /** @file newgrf_spritegroup.h Action 2 handling. */ #ifndef NEWGRF_SPRITEGROUP_H #define NEWGRF_SPRITEGROUP_H #include "town_type.h" #include "industry_type.h" #include "core/bitmath_func.hpp" #include "gfx_type.h" #include "engine_type.h" #include "tile_type.h" #include "newgrf_cargo.h" #include "newgrf_callbacks.h" #include "newgrf_generic.h" #include "newgrf_storage.h" /** * Gets the value of a so-called newgrf "register". * @param i index of the register * @pre i < 0x110 * @return the value of the register */ static inline uint32 GetRegister(uint i) { extern TemporaryStorageArray<uint32, 0x110> _temp_store; return _temp_store.Get(i); } struct SpriteGroup; /* 'Real' sprite groups contain a list of other result or callback sprite * groups. */ struct RealSpriteGroup { /* Loaded = in motion, loading = not moving * Each group contains several spritesets, for various loading stages */ /* XXX: For stations the meaning is different - loaded is for stations * with small amount of cargo whilst loading is for stations with a lot * of da stuff. */ byte num_loaded; ///< Number of loaded groups byte num_loading; ///< Number of loading groups const SpriteGroup **loaded; ///< List of loaded groups (can be SpriteIDs or Callback results) const SpriteGroup **loading; ///< List of loading groups (can be SpriteIDs or Callback results) }; /* Shared by deterministic and random groups. */ enum VarSpriteGroupScope { VSG_SCOPE_SELF, /* Engine of consists for vehicles, city for stations. */ VSG_SCOPE_PARENT, /* Any vehicle in the consist (vehicles only) */ VSG_SCOPE_RELATIVE, }; enum DeterministicSpriteGroupSize { DSG_SIZE_BYTE, DSG_SIZE_WORD, DSG_SIZE_DWORD, }; enum DeterministicSpriteGroupAdjustType { DSGA_TYPE_NONE, DSGA_TYPE_DIV, DSGA_TYPE_MOD, }; enum DeterministicSpriteGroupAdjustOperation { DSGA_OP_ADD, ///< a + b DSGA_OP_SUB, ///< a - b DSGA_OP_SMIN, ///< (signed) min(a, b) DSGA_OP_SMAX, ///< (signed) max(a, b) DSGA_OP_UMIN, ///< (unsigned) min(a, b) DSGA_OP_UMAX, ///< (unsigned) max(a, b) DSGA_OP_SDIV, ///< (signed) a / b DSGA_OP_SMOD, ///< (signed) a % b DSGA_OP_UDIV, ///< (unsigned) a / b DSGA_OP_UMOD, ///< (unsigned) a & b DSGA_OP_MUL, ///< a * b DSGA_OP_AND, ///< a & b DSGA_OP_OR, ///< a | b DSGA_OP_XOR, ///< a ^ b DSGA_OP_STO, ///< store a into temporary storage, indexed by b. return a DSGA_OP_RST, ///< return b DSGA_OP_STOP, ///< store a into persistent storage, indexed by b, return a DSGA_OP_ROR, ///< rotate a b positions to the right DSGA_OP_SCMP, ///< (signed) comparision (a < b -> 0, a == b = 1, a > b = 2) DSGA_OP_UCMP, ///< (unsigned) comparision (a < b -> 0, a == b = 1, a > b = 2) }; struct DeterministicSpriteGroupAdjust { DeterministicSpriteGroupAdjustOperation operation; DeterministicSpriteGroupAdjustType type; byte variable; byte parameter; ///< Used for variables between 0x60 and 0x7F inclusive. byte shift_num; uint32 and_mask; uint32 add_val; uint32 divmod_val; const SpriteGroup *subroutine; }; struct DeterministicSpriteGroupRange { const SpriteGroup *group; uint32 low; uint32 high; }; struct DeterministicSpriteGroup { VarSpriteGroupScope var_scope; DeterministicSpriteGroupSize size; byte num_adjusts; byte num_ranges; DeterministicSpriteGroupAdjust *adjusts; DeterministicSpriteGroupRange *ranges; // Dynamically allocated /* Dynamically allocated, this is the sole owner */ const SpriteGroup *default_group; }; enum RandomizedSpriteGroupCompareMode { RSG_CMP_ANY, RSG_CMP_ALL, }; struct RandomizedSpriteGroup { VarSpriteGroupScope var_scope; ///< Take this object: RandomizedSpriteGroupCompareMode cmp_mode; ///< Check for these triggers: byte triggers; byte count; byte lowest_randbit; ///< Look for this in the per-object randomized bitmask: byte num_groups; ///< must be power of 2 const SpriteGroup **groups; ///< Take the group with appropriate index: }; /* This contains a callback result. A failed callback has a value of * CALLBACK_FAILED */ struct CallbackResultSpriteGroup { uint16 result; }; /* A result sprite group returns the first SpriteID and the number of * sprites in the set */ struct ResultSpriteGroup { SpriteID sprite; byte num_sprites; }; struct TileLayoutSpriteGroup { byte num_sprites; ///< Number of sprites in the spriteset, used for loading stages struct DrawTileSprites *dts; }; struct IndustryProductionSpriteGroup { uint8 version; uint16 substract_input[3]; uint16 add_output[2]; uint8 again; }; /* List of different sprite group types */ enum SpriteGroupType { SGT_INVALID, SGT_REAL, SGT_DETERMINISTIC, SGT_RANDOMIZED, SGT_CALLBACK, SGT_RESULT, SGT_TILELAYOUT, SGT_INDUSTRY_PRODUCTION, }; /* Common wrapper for all the different sprite group types */ struct SpriteGroup { SpriteGroupType type; union { RealSpriteGroup real; DeterministicSpriteGroup determ; RandomizedSpriteGroup random; CallbackResultSpriteGroup callback; ResultSpriteGroup result; TileLayoutSpriteGroup layout; IndustryProductionSpriteGroup indprod; } g; }; SpriteGroup *AllocateSpriteGroup(); void InitializeSpriteGroupPool(); struct ResolverObject { CallbackID callback; uint32 callback_param1; uint32 callback_param2; bool procedure_call; ///< true if we are currently resolving a var 0x7E procedure result. byte trigger; byte count; uint32 last_value; uint32 reseed; VarSpriteGroupScope scope; bool info_view; ///< Indicates if the item is being drawn in an info window BaseStorageArray *psa; ///< The persistent storage array of this resolved object. const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to union { struct { const struct Vehicle *self; const struct Vehicle *parent; EngineID self_type; } vehicle; struct { TileIndex tile; } canal; struct { TileIndex tile; const struct Station *st; const struct StationSpec *statspec; CargoID cargo_type; } station; struct { TileIndex tile; Town *town; HouseID house_id; } house; struct { TileIndex tile; Industry *ind; IndustryGfx gfx; IndustryType type; } industry; struct { const struct CargoSpec *cs; } cargo; struct { CargoID cargo_type; uint8 default_selection; IndustryType src_industry; IndustryType dst_industry; uint8 distance; AIConstructionEvent event; uint8 count; uint8 station_size; } generic; } u; uint32 (*GetRandomBits)(const struct ResolverObject*); uint32 (*GetTriggers)(const struct ResolverObject*); void (*SetTriggers)(const struct ResolverObject*, int); uint32 (*GetVariable)(const struct ResolverObject*, byte, byte, bool*); const SpriteGroup *(*ResolveReal)(const struct ResolverObject*, const SpriteGroup*); ResolverObject() : procedure_call(false) { } }; /* Base sprite group resolver */ const SpriteGroup *Resolve(const SpriteGroup *group, ResolverObject *object); #endif /* NEWGRF_SPRITEGROUP_H */
6,982
C++
.h
228
28.368421
96
0.745674
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,533
openttd.h
EnergeticBark_OpenTTD-3DS/src/openttd.h
/* $Id$ */ /** @file openttd.h Some generic types. */ #ifndef OPENTTD_H #define OPENTTD_H enum GameMode { GM_MENU, GM_NORMAL, GM_EDITOR, }; enum SwitchMode { SM_NONE, SM_NEWGAME, SM_EDITOR, SM_LOAD, SM_MENU, SM_SAVE, SM_GENRANDLAND, SM_LOAD_SCENARIO, SM_START_SCENARIO, SM_START_HEIGHTMAP, SM_LOAD_HEIGHTMAP, }; /* Display Options */ enum { DO_SHOW_TOWN_NAMES = 0, DO_SHOW_STATION_NAMES = 1, DO_SHOW_SIGNS = 2, DO_FULL_ANIMATION = 3, DO_FULL_DETAIL = 5, DO_WAYPOINTS = 6, }; extern GameMode _game_mode; extern SwitchMode _switch_mode; extern bool _exit_game; extern int8 _pause_game; #endif /* OPENTTD_H */
665
C++
.h
36
16.722222
42
0.681672
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,534
squirrel_helper_type.hpp
EnergeticBark_OpenTTD-3DS/src/script/squirrel_helper_type.hpp
/* $Id$ */ /** @file squirrel_helper_type.hpp Helper structs for converting Squirrel data structures to C++. */ #ifndef SQUIRREL_HELPER_TYPE_HPP #define SQUIRREL_HELPER_TYPE_HPP struct Array { int32 size; int32 array[VARARRAY_SIZE]; }; #endif /* SQUIRREL_HELPER_TYPE_HPP */
280
C++
.h
9
29.444444
100
0.749064
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
true
true
false
1,539,538
squirrel_std.hpp
EnergeticBark_OpenTTD-3DS/src/script/squirrel_std.hpp
/* $Id$ */ /** @file squirrel_std.hpp defines the Squirrel Standard Function class */ #ifndef SQUIRREL_STD_HPP #define SQUIRREL_STD_HPP #if defined(__APPLE__) /* Which idiotic system makes 'require' a macro? :s Oh well.... */ #undef require #endif /* __APPLE__ */ /** * By default we want to give a set of standard commands to a SQ script. * Most of them are easy wrappers around internal functions. Of course we * could just as easy include things like the stdmath of SQ, but of those * functions we are sure they work on all our supported targets. */ class SquirrelStd { public: /** * Make an integer absolute. */ static SQInteger abs(HSQUIRRELVM vm); /** * Get the lowest of two integers. */ static SQInteger min(HSQUIRRELVM vm); /** * Get the highest of two integers. */ static SQInteger max(HSQUIRRELVM vm); /** * Load an other file on runtime. * @note This is always loaded on the root-level, no matter where you call this. * @note The filename is always relative from the script it is called from. Absolute calls are NOT allowed! */ static SQInteger require(HSQUIRRELVM vm); /** * Enable/disable stack trace showing for handled exceptions. */ static SQInteger notifyallexceptions(HSQUIRRELVM vm); }; /** * Register all standard functions we want to give to a script. */ void squirrel_register_std(Squirrel *engine); /** * Register all standard functions that are available on first startup. * @note this set is very limited, and is only ment to load other scripts and things like that. */ void squirrel_register_global_std(Squirrel *engine); #endif /* SQUIRREL_STD_HPP */
1,636
C++
.h
49
31.265306
108
0.736675
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
true
true
false
1,539,545
cocoa_keys.h
EnergeticBark_OpenTTD-3DS/src/video/cocoa/cocoa_keys.h
/* $Id$ */ /** @file cocoa_keys.h Mappings of Cocoa keys. */ #ifndef COCOA_KEYS_H #define COCOA_KEYS_H /* From SDL_QuartzKeys.h * These are the Macintosh key scancode constants -- from Inside Macintosh */ #define QZ_ESCAPE 0x35 #define QZ_F1 0x7A #define QZ_F2 0x78 #define QZ_F3 0x63 #define QZ_F4 0x76 #define QZ_F5 0x60 #define QZ_F6 0x61 #define QZ_F7 0x62 #define QZ_F8 0x64 #define QZ_F9 0x65 #define QZ_F10 0x6D #define QZ_F11 0x67 #define QZ_F12 0x6F #define QZ_PRINT 0x69 #define QZ_SCROLLOCK 0x6B #define QZ_PAUSE 0x71 #define QZ_POWER 0x7F #define QZ_BACKQUOTE 0x0A #define QZ_BACKQUOTE2 0x32 #define QZ_1 0x12 #define QZ_2 0x13 #define QZ_3 0x14 #define QZ_4 0x15 #define QZ_5 0x17 #define QZ_6 0x16 #define QZ_7 0x1A #define QZ_8 0x1C #define QZ_9 0x19 #define QZ_0 0x1D #define QZ_MINUS 0x1B #define QZ_EQUALS 0x18 #define QZ_BACKSPACE 0x33 #define QZ_INSERT 0x72 #define QZ_HOME 0x73 #define QZ_PAGEUP 0x74 #define QZ_NUMLOCK 0x47 #define QZ_KP_EQUALS 0x51 #define QZ_KP_DIVIDE 0x4B #define QZ_KP_MULTIPLY 0x43 #define QZ_TAB 0x30 #define QZ_q 0x0C #define QZ_w 0x0D #define QZ_e 0x0E #define QZ_r 0x0F #define QZ_t 0x11 #define QZ_y 0x10 #define QZ_u 0x20 #define QZ_i 0x22 #define QZ_o 0x1F #define QZ_p 0x23 #define QZ_LEFTBRACKET 0x21 #define QZ_RIGHTBRACKET 0x1E #define QZ_BACKSLASH 0x2A #define QZ_DELETE 0x75 #define QZ_END 0x77 #define QZ_PAGEDOWN 0x79 #define QZ_KP7 0x59 #define QZ_KP8 0x5B #define QZ_KP9 0x5C #define QZ_KP_MINUS 0x4E #define QZ_CAPSLOCK 0x39 #define QZ_a 0x00 #define QZ_s 0x01 #define QZ_d 0x02 #define QZ_f 0x03 #define QZ_g 0x05 #define QZ_h 0x04 #define QZ_j 0x26 #define QZ_k 0x28 #define QZ_l 0x25 #define QZ_SEMICOLON 0x29 #define QZ_QUOTE 0x27 #define QZ_RETURN 0x24 #define QZ_KP4 0x56 #define QZ_KP5 0x57 #define QZ_KP6 0x58 #define QZ_KP_PLUS 0x45 #define QZ_LSHIFT 0x38 #define QZ_z 0x06 #define QZ_x 0x07 #define QZ_c 0x08 #define QZ_v 0x09 #define QZ_b 0x0B #define QZ_n 0x2D #define QZ_m 0x2E #define QZ_COMMA 0x2B #define QZ_PERIOD 0x2F #define QZ_SLASH 0x2C #if 1 /* Panther now defines right side keys */ #define QZ_RSHIFT 0x3C #endif #define QZ_UP 0x7E #define QZ_KP1 0x53 #define QZ_KP2 0x54 #define QZ_KP3 0x55 #define QZ_KP_ENTER 0x4C #define QZ_LCTRL 0x3B #define QZ_LALT 0x3A #define QZ_LMETA 0x37 #define QZ_SPACE 0x31 #if 1 /* Panther now defines right side keys */ #define QZ_RMETA 0x36 #define QZ_RALT 0x3D #define QZ_RCTRL 0x3E #endif #define QZ_LEFT 0x7B #define QZ_DOWN 0x7D #define QZ_RIGHT 0x7C #define QZ_KP0 0x52 #define QZ_KP_PERIOD 0x41 /* Wierd, these keys are on my iBook under MacOS X */ #define QZ_IBOOK_ENTER 0x34 #define QZ_IBOOK_LEFT 0x3B #define QZ_IBOOK_RIGHT 0x3C #define QZ_IBOOK_DOWN 0x3D #define QZ_IBOOK_UP 0x3E #endif
3,616
C++
.h
123
28.341463
77
0.583309
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,546
cocoa_v.h
EnergeticBark_OpenTTD-3DS/src/video/cocoa/cocoa_v.h
/* $Id$ */ /** @file cocoa_v.h The Cocoa video driver. */ #ifndef VIDEO_COCOA_H #define VIDEO_COCOA_H #include <AvailabilityMacros.h> #include "../video_driver.hpp" class VideoDriver_Cocoa: public VideoDriver { public: /* virtual */ const char *Start(const char * const *param); /* virtual */ void Stop(); /* virtual */ void MakeDirty(int left, int top, int width, int height); /* virtual */ void MainLoop(); /* virtual */ bool ChangeResolution(int w, int h); /* virtual */ bool ToggleFullscreen(bool fullscreen); }; class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> { public: static const int priority = 10; /* virtual */ const char *GetName() { return "cocoa"; } /* virtual */ const char *GetDescription() { return "Cocoa Video Driver"; } /* virtual */ Driver *CreateInstance() { return new VideoDriver_Cocoa(); } }; class CocoaSubdriver { public: virtual ~CocoaSubdriver() {} virtual void Draw() = 0; virtual void MakeDirty(int left, int top, int width, int height) = 0; virtual void UpdatePalette(uint first_color, uint num_colors) = 0; virtual uint ListModes(OTTD_Point *modes, uint max_modes) = 0; virtual bool ChangeResolution(int w, int h) = 0; virtual bool IsFullscreen() = 0; virtual int GetWidth() = 0; virtual int GetHeight() = 0; virtual void *GetPixelBuffer() = 0; /* Convert local coordinate to window server (CoreGraphics) coordinate */ virtual CGPoint PrivateLocalToCG(NSPoint *p) = 0; virtual NSPoint GetMouseLocation(NSEvent *event) = 0; virtual bool MouseIsInsideView(NSPoint *pt) = 0; virtual bool IsActive() = 0; }; extern CocoaSubdriver *_cocoa_subdriver; CocoaSubdriver *QZ_CreateFullscreenSubdriver(int width, int height, int bpp); #ifdef ENABLE_COCOA_QUICKDRAW CocoaSubdriver *QZ_CreateWindowQuickdrawSubdriver(int width, int height, int bpp); #endif #ifdef ENABLE_COCOA_QUARTZ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 CocoaSubdriver *QZ_CreateWindowQuartzSubdriver(int width, int height, int bpp); #endif #endif void QZ_GameSizeChanged(); void QZ_GameLoop(); void QZ_ShowMouse(); void QZ_HideMouse(); uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_id, int display_depth); #endif /* VIDEO_COCOA_H */
2,252
C++
.h
56
38.232143
102
0.748846
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,539,552
geometry_type.hpp
EnergeticBark_OpenTTD-3DS/src/core/geometry_type.hpp
/* $Id$ */ /** @file geometry_type.hpp All geometry types in OpenTTD. */ #ifndef GEOMETRY_TYPE_HPP #define GEOMETRY_TYPE_HPP #if defined(__AMIGA__) /* AmigaOS already has a Point declared */ #define Point OTTD_Point #endif /* __AMIGA__ */ #if defined(__APPLE__) /* Mac OS X already has both Rect and Point declared */ #define Rect OTTD_Rect #define Point OTTD_Point #endif /* __APPLE__ */ /** Coordinates of a point in 2D */ struct Point { int x; int y; }; /** Dimensions (a width and height) of a rectangle in 2D */ struct Dimension { int width; int height; }; /** Specification of a rectangle with absolute coordinates of all edges */ struct Rect { int left; int top; int right; int bottom; }; /** * Specification of a rectangle with an absolute top-left coordinate and a * (relative) width/height */ struct PointDimension { int x; int y; int width; int height; }; /** A pair of two integers */ struct Pair { int a; int b; }; #endif /* GEOMETRY_TYPE_HPP */
992
C++
.h
46
19.847826
74
0.703743
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
true
true
false
1,539,553
string_compare_type.hpp
EnergeticBark_OpenTTD-3DS/src/core/string_compare_type.hpp
/* $Id$ */ /** @file string_compare_type.hpp Comparator class for "const char *" so it can be used as a key for std::map */ #ifndef STRING_COMPARE_TYPE_HPP #define STRING_COMPARE_TYPE_HPP struct StringCompare { bool operator () (const char *a, const char *b) const { return strcmp(a, b) < 0; } }; #endif /* STRING_COMPARE_TYPE_HPP */
343
C++
.h
11
29.363636
112
0.698171
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
true
false
true
true
true
false
1,539,557
endian_type.hpp
EnergeticBark_OpenTTD-3DS/src/core/endian_type.hpp
/* $Id$ */ /** @file endian_type.hpp Definition of various endian-dependant macros. */ #ifndef ENDIAN_TYPE_HPP #define ENDIAN_TYPE_HPP #if defined(ARM) || defined(__arm__) || defined(__alpha__) #define OTTD_ALIGNMENT 1 #else #define OTTD_ALIGNMENT 0 #endif #define TTD_LITTLE_ENDIAN 0 #define TTD_BIG_ENDIAN 1 /* Windows has always LITTLE_ENDIAN */ #if defined(WIN32) || defined(__OS2__) || defined(WIN64) || defined(N3DS) #define TTD_ENDIAN TTD_LITTLE_ENDIAN #elif !defined(TESTING) /* Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile */ #if defined(STRGEN) #include "endian_host.h" #else #include "endian_target.h" #endif #endif /* WIN32 || __OS2__ || WIN64 */ #endif /* ENDIAN_TYPE_HPP */
752
C++
.h
23
30.956522
98
0.713693
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
true
true
false
1,539,561
smallvec_type.hpp
EnergeticBark_OpenTTD-3DS/src/core/smallvec_type.hpp
/* $Id$ */ /** @file smallvec_type.hpp Simple vector class that allows allocating an item without the need to copy this->data needlessly. */ #ifndef SMALLVEC_TYPE_HPP #define SMALLVEC_TYPE_HPP #include "alloc_func.hpp" #include "math_func.hpp" /** * Simple vector template class. * * @note There are no asserts in the class so you have * to care about that you grab an item which is * inside the list. * * @param T The type of the items stored * @param S The steps of allocation */ template <typename T, uint S> class SmallVector { protected: T *data; ///< The pointer to the first item uint items; ///< The number of items stored uint capacity; ///< The avalible space for storing items public: SmallVector() : data(NULL), items(0), capacity(0) { } ~SmallVector() { free(this->data); } /** * Remove all items from the list. */ FORCEINLINE void Clear() { /* In fact we just reset the item counter avoiding the need to * probably reallocate the same amount of memory the list was * previously using. */ this->items = 0; } /** * Remove all items from the list and free allocated memory. */ void Reset() { this->items = 0; this->capacity = 0; free(data); data = NULL; } /** * Compact the list down to the smallest block size boundary. */ FORCEINLINE void Compact() { uint capacity = Align(this->items, S); if (capacity >= this->capacity) return; this->capacity = capacity; this->data = ReallocT(this->data, this->capacity); } /** * Append an item and return it. */ FORCEINLINE T *Append() { if (this->items == this->capacity) { this->capacity += S; this->data = ReallocT(this->data, this->capacity); } return &this->data[this->items++]; } /** * Search for the first occurence of an item. * The '!=' operator of T is used for comparison. * @param item Item to search for * @return The position of the item, or End() when not present */ FORCEINLINE const T *Find(const T &item) const { const T *pos = this->Begin(); const T *end = this->End(); while (pos != end && *pos != item) pos++; return pos; } /** * Search for the first occurence of an item. * The '!=' operator of T is used for comparison. * @param item Item to search for * @return The position of the item, or End() when not present */ FORCEINLINE T *Find(const T &item) { T *pos = this->Begin(); const T *end = this->End(); while (pos != end && *pos != item) pos++; return pos; } /** * Tests whether a item is present in the vector. * The '!=' operator of T is used for comparison. * @param item Item to test for * @return true iff the item is present */ FORCEINLINE bool Contains(const T &item) const { return this->Find(item) != this->End(); } /** Removes given item from this map * @param item item to remove * @note it has to be pointer to item in this map. It is overwritten by the last item. */ FORCEINLINE void Erase(T *item) { assert(item >= this->Begin() && item < this->End()); *item = this->data[--this->items]; } /** * Tests whether a item is present in the vector, and appends it to the end if not. * The '!=' operator of T is used for comparison. * @param item Item to test for * @return true iff the item is was already present */ FORCEINLINE bool Include(const T &item) { bool is_member = this->Contains(item); if (!is_member) *this->Append() = item; return is_member; } /** * Get the number of items in the list. */ FORCEINLINE uint Length() const { return this->items; } /** * Get the pointer to the first item (const) * * @return the pointer to the first item */ FORCEINLINE const T *Begin() const { return this->data; } /** * Get the pointer to the first item * * @return the pointer to the first item */ FORCEINLINE T *Begin() { return this->data; } /** * Get the pointer behind the last valid item (const) * * @return the pointer behind the last valid item */ FORCEINLINE const T *End() const { return &this->data[this->items]; } /** * Get the pointer behind the last valid item * * @return the pointer behind the last valid item */ FORCEINLINE T *End() { return &this->data[this->items]; } /** * Get the pointer to item "number" (const) * * @param index the position of the item * @return the pointer to the item */ FORCEINLINE const T *Get(uint index) const { return &this->data[index]; } /** * Get the pointer to item "number" * * @param index the position of the item * @return the pointer to the item */ FORCEINLINE T *Get(uint index) { return &this->data[index]; } /** * Get item "number" (const) * * @param index the positon of the item * @return the item */ FORCEINLINE const T &operator[](uint index) const { return this->data[index]; } /** * Get item "number" * * @param index the positon of the item * @return the item */ FORCEINLINE T &operator[](uint index) { return this->data[index]; } }; /** * Simple vector template class, with automatic free. * * @note There are no asserts in the class so you have * to care about that you grab an item which is * inside the list. * * @param T The type of the items stored, must be a pointer * @param S The steps of allocation */ template <typename T, uint S> class AutoFreeSmallVector : public SmallVector<T, S> { public: ~AutoFreeSmallVector() { this->Clear(); } /** * Remove all items from the list. */ FORCEINLINE void Clear() { for (uint i = 0; i < this->items; i++) { free(this->data[i]); } this->items = 0; } }; #endif /* SMALLVEC_TYPE_HPP */
5,687
C++
.h
239
21.230126
129
0.666051
EnergeticBark/OpenTTD-3DS
34
1
4
GPL-2.0
9/20/2024, 10:44:59 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false