#include <stdint.h>
#include <cstdio>
#include <cstddef>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cassert>
Go to the source code of this file.
Defines | |
#define | __STDC_LIMIT_MACROS |
#define | VARARRAY_SIZE |
#define | fopen(file, mode) fopen(OTTD2FS(file), mode) |
#define | PATHSEP "/" |
#define | PATHSEPCHAR '/' |
#define | PERSONAL_DIR "" |
#define | assert_compile(expr) extern const int __ct_assert__[1 - 2 * !(expr)] |
#define | lengthof(x) (sizeof(x) / sizeof(x[0])) |
Return the length of an fixed size array. | |
#define | endof(x) (&x[lengthof(x)]) |
Get the end element of an fixed size array. | |
#define | lastof(x) (&x[lengthof(x) - 1]) |
Get the last element of an fixed size array. | |
#define | cpp_offsetof(s, m) (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8) |
#define | offsetof(s, m) cpp_offsetof(s, m) |
#define | NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__) |
#define | HAS_WCHAR |
#define | MAX_PATH 260 |
#define | MAX_UVALUE(type) ((type)~(type)0) |
The largest value that can be entered in a variable. | |
Typedefs | |
typedef unsigned char | byte |
typedef unsigned int | uint |
typedef unsigned char | uint8 |
typedef signed char | int8 |
typedef unsigned short | uint16 |
typedef signed short | int16 |
typedef unsigned int | uint32 |
typedef signed int | int32 |
typedef unsigned __int64 | uint64 |
typedef signed __int64 | int64 |
Functions | |
const char * | FS2OTTD (const char *name) |
const char * | OTTD2FS (const char *name) |
Convert from OpenTTD's encoding to that of the local environment. | |
assert_compile (sizeof(uint64)==8) | |
assert_compile (sizeof(uint32)==4) | |
assert_compile (sizeof(uint16)==2) | |
assert_compile (sizeof(uint8)==1) | |
void NORETURN CDECL | usererror (const char *str,...) |
Error handling for fatal user errors. | |
void NORETURN CDECL | error (const char *str,...) |
Error handling for fatal non-user errors. |
Definition in file stdafx.h.
#define endof | ( | x | ) | (&x[lengthof(x)]) |
Get the end element of an fixed size array.
x | The pointer to the first element of the array |
Definition at line 324 of file stdafx.h.
Referenced by DeliverGoodsToIndustry(), SmallStackSafeStackAlloc< T, length >::EndOf(), GetDebugString(), GetSavegameFormat(), GrowTown(), LoadFromHighScore(), StationViewWindow::OnPaint(), SaveOrLoad(), SaveToHighScore(), ShowRefitOptionsList(), and TerraformTileHeight().
#define lastof | ( | x | ) | (&x[lengthof(x) - 1]) |
Get the last element of an fixed size array.
x | The pointer to the first element of the array |
Definition at line 332 of file stdafx.h.
Referenced by FiosFileScanner::AddFile(), CheckExternalFiles(), CloneVehicleName(), CopyFromOldName(), DoAutosave(), DoDrawString(), DoDrawStringCentered(), DoDrawStringTruncated(), DrawNewsString(), DrawString(), DrawStringCentered(), DrawStringCenteredTruncated(), DrawStringMultiCenter(), DrawStringRightAligned(), DrawStringRightAlignedTruncated(), DrawStringTruncated(), FiosGetFileList(), FS2OTTD(), GamelogRevision(), GetDebugString(), GetFileTitle(), GetKeyboardLayout(), GetSaveLoadErrorString(), GetStringHeight(), GuiShowTooltips(), HandleSavegameLoadCrash(), IndustryDirectoryWindow::IndustryNameSorter(), ini_save_settings(), InsertTextBufferClipboard(), IsGoodGRFConfigList(), LoadFromHighScore(), NewGRFWindow::OnClick(), StationViewWindow::OnPaint(), OTTD2FS(), PrintGrfInfo(), RailVehicleLengthChanged(), SaveHighScoreValue(), FileScanner::Scan(), ShowHelp(), ShowRefitOptionsList(), CompanyStationsWindow::StationNameSorter(), VehicleNameSorter(), and VerifyTownName().
#define lengthof | ( | x | ) | (sizeof(x) / sizeof(x[0])) |
Return the length of an fixed size array.
Unlike sizeof this function returns the number of elements of the given type.
x | The pointer to the first element of the array |
Definition at line 316 of file stdafx.h.
Referenced by _GenerateWorld(), AddGenericCallback(), AddGRFString(), AddNewsItem(), AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(), AICargoList_IndustryProducing::AICargoList_IndustryProducing(), AIIndustryList_CargoAccepting::AIIndustryList_CargoAccepting(), AIIndustryList_CargoProducing::AIIndustryList_CargoProducing(), AITileList_IndustryAccepting::AITileList_IndustryAccepting(), AITileList_IndustryProducing::AITileList_IndustryProducing(), CalcHeightdiff(), AIRoad::CanBuildConnectedRoadPartsHere(), CanCargoServiceIndustry(), ChangeIndustryProduction(), CheckExternalFiles(), CheckNoiseToleranceLevel(), CmdBuildAirport(), CmdDoTownAction(), CmdRenamePresident(), CMSAForest(), CMSAMine(), DeterminePaths(), DoCommandP(), DrawNewsString(), error(), FiosGetFileList(), FixTTOEngines(), FormatBytes(), FS2OTTD(), GetAcceptanceAroundTiles(), AIIndustryType::GetAcceptedCargo(), GetCargoIDByBitnum(), IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid(), GetCurrentLocale(), GetDistanceFromNearbyHouse(), GetGenericCallbackResult(), AIIndustry::GetLastMonthProduction(), AIIndustry::GetLastMonthTransported(), GetMaskOfTownActions(), GetNewgrfCurrencyIdConverted(), AIIndustryType::GetProducedCargo(), GetProductionAroundTiles(), AIIndustry::GetStockpiledCargo(), GetVehicleSpriteGroup(), GraphicsNew(), IConsoleAliasExec(), IConsoleCmdExec(), IConsoleListSettings(), InitializeLanguagePacks(), InitializeUnicodeGlyphMap(), InsertTextBufferClipboard(), AIIndustry::IsCargoAccepted(), SmallSet< Tdir, items >::IsFull(), IsValidCommand(), AISubsidy::IsValidSubsidy(), load_intlist(), LookupWithBuildOnSlopes(), NewTrainPathfind(), NewGRFWindow::OnClick(), BuildRailToolbarWindow::OnKeyPress(), QueryWindow::OnPaint(), IndustryDirectoryWindow::OnPaint(), NewGRFWindow::OnQueryTextFinished(), OTTD2FS(), RemapTTOColour(), ResetGenericCallbacks(), SaveHighScoreValue(), SaveOrLoad(), SaveVersionInConfig(), FileScanner::Scan(), ScanPath(), SetCurrentGrfLangID(), ShowInfoF(), SlCalcConvFileLen(), SlCalcConvMemLen(), TriggerIndustryProduction(), UpdateStationAcceptance(), and usererror().
#define MAX_UVALUE | ( | type | ) | ((type)~(type)0) |
The largest value that can be entered in a variable.
type | the type of the variable |
Definition at line 372 of file stdafx.h.
Referenced by IConsoleLine::Truncate().
void NORETURN CDECL error | ( | const char * | s, | |
... | ||||
) |
Error handling for fatal non-user errors.
s | the string to print. |
Definition at line 103 of file openttd.cpp.
const char* OTTD2FS | ( | const char * | name | ) |
Convert from OpenTTD's encoding to that of the local environment.
When the project is built in UNICODE the system codepage is irrelevant and the converted string is wide. In ANSI mode, the UTF8 string is converted to multi-byte. OpenTTD internal encoding is UTF8. The returned value's contents can only be guaranteed until the next call to this function. So if the value is needed for anything else, use convert_from_fs
name | pointer to a valid string that will be converted (UTF8) |
Definition at line 236 of file os2.cpp.
References convert_to_fs(), lastof, and lengthof.
Referenced by SQConvert::DefSQAdvancedNonStaticCallback(), SQConvert::DefSQNonStaticCallback(), FioCreateDirectory(), and ttd_opendir().
void NORETURN CDECL usererror | ( | const char * | s, | |
... | ||||
) |
Error handling for fatal user errors.
s | the string to print. |
Definition at line 83 of file openttd.cpp.
Referenced by HandleInvalidSpriteRequest(), and InitializeLanguagePacks().