tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef FUNCTIONS_H truelight@0: #define FUNCTIONS_H truelight@0: tron@1589: void DoClearSquare(TileIndex tile); tron@1093: void RunTileLoop(void); truelight@0: tron@3636: uint GetPartialZ(int x, int y, Slope corners); truelight@0: uint GetSlopeZ(int x, int y); tron@1589: uint32 GetTileTrackStatus(TileIndex tile, TransportType mode); tron@1589: void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac); tron@1589: void ChangeTileOwner(TileIndex tile, byte old_player, byte new_player); tron@1589: void AnimateTile(TileIndex tile); tron@1589: void ClickTile(TileIndex tile); tron@1589: void GetTileDesc(TileIndex tile, TileDesc *td); celestar@1377: void UpdateTownMaxPass(Town *t); truelight@0: tron@1589: bool IsValidTile(TileIndex tile); truelight@0: tron@536: static inline Point RemapCoords(int x, int y, int z) tron@536: { truelight@0: #if !defined(NEW_ROTATION) truelight@781: Point pt; truelight@781: pt.x = (y - x) * 2; truelight@781: pt.y = y + x - z; truelight@0: #else truelight@781: Point pt; truelight@781: pt.x = (x + y) * 2; truelight@781: pt.y = x - y - z; truelight@0: #endif tron@536: return pt; tron@536: } truelight@0: tron@536: static inline Point RemapCoords2(int x, int y) tron@536: { tron@536: return RemapCoords(x, y, GetSlopeZ(x, y)); tron@536: } truelight@0: truelight@0: truelight@0: /* clear_land.c */ Darkvater@2436: void DrawHillyLandTile(const TileInfo *ti); Darkvater@2436: void DrawClearLandTile(const TileInfo *ti, byte set); tron@2220: void DrawClearLandFence(const TileInfo *ti); tron@1420: void TileLoopClearHelper(TileIndex tile); truelight@0: truelight@0: /* water_land.c */ truelight@0: void DrawShipDepotSprite(int x, int y, int image); tron@1977: void TileLoop_Water(TileIndex tile); truelight@0: truelight@0: /* players.c */ truelight@0: bool CheckPlayerHasMoney(int32 cost); truelight@0: void SubtractMoneyFromPlayer(int32 cost); Darkvater@2436: void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost); Darkvater@4849: bool CheckOwnership(Owner owner); tron@1977: bool CheckTileOwnership(TileIndex tile); tron@2475: StringID GetPlayerNameString(PlayerID player, uint index); truelight@0: truelight@0: /* standard */ truelight@0: void ShowInfo(const char *str); truelight@0: void CDECL ShowInfoF(const char *str, ...); truelight@0: void NORETURN CDECL error(const char *str, ...); truelight@0: Darkvater@2075: /* openttd.c */ truelight@543: rubidium@4432: /************** rubidium@4432: * Warning: DO NOT enable this unless you understand what it does rubidium@4432: * rubidium@4432: * If enabled, in a network game all randoms will be dumped to the rubidium@4432: * stdout if the first client joins (or if you are a client). This rubidium@4432: * is to help finding desync problems. rubidium@4432: * rubidium@4432: * Warning: DO NOT enable this unless you understand what it does rubidium@4432: **************/ truelight@543: truelight@1539: //#define RANDOM_DEBUG truelight@543: ludde@2073: ludde@2073: // Enable this to produce higher quality random numbers. ludde@2073: // Doesn't work with network yet. ludde@2073: //#define MERSENNE_TWISTER ludde@2073: ludde@2073: // Mersenne twister functions ludde@2073: void SeedMT(uint32 seed); ludde@2073: uint32 RandomMT(void); ludde@2073: ludde@2073: ludde@2073: #ifdef MERSENNE_TWISTER ludde@2073: static inline uint32 Random(void) { return RandomMT(); } ludde@2073: uint RandomRange(uint max); ludde@2073: #else ludde@2073: truelight@543: #ifdef RANDOM_DEBUG truelight@543: #define Random() DoRandom(__LINE__, __FILE__) truelight@1120: uint32 DoRandom(int line, const char *file); truelight@543: #define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__) truelight@1120: uint DoRandomRange(uint max, int line, const char *file); truelight@543: #else tron@1093: uint32 Random(void); truelight@543: uint RandomRange(uint max); ludde@2073: #endif ludde@2073: #endif // MERSENNE_TWISTER ludde@2051: ludde@2073: static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); } ludde@2073: static inline TileIndex RandomTile(void) { return TILE_MASK(Random()); } ludde@2073: ludde@2073: tron@1093: uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */ signde@239: uint InteractiveRandomRange(uint max); signde@239: truelight@0: /* facedraw.c */ truelight@0: void DrawPlayerFace(uint32 face, int color, int x, int y); truelight@0: truelight@0: /* texteff.c */ tron@1093: void MoveAllTextEffects(void); truelight@0: void AddTextEffect(StringID msg, int x, int y, uint16 duration); tron@1093: void InitTextEffects(void); truelight@0: void DrawTextEffects(DrawPixelInfo *dpi); truelight@0: tron@1093: void InitTextMessage(void); tron@1093: void DrawTextMessage(void); truelight@619: void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...); tron@1093: void UndrawTextMessage(void); truelight@543: tron@1977: bool AddAnimatedTile(TileIndex tile); tron@1977: void DeleteAnimatedTile(TileIndex tile); tron@1093: void AnimateAnimatedTiles(void); tron@1093: void InitializeAnimatedTiles(void); truelight@0: truelight@0: /* tunnelbridge_cmd.c */ tron@2639: bool CheckBridge_Stuff(byte bridge_type, uint bridge_len); truelight@0: uint32 GetBridgeLength(TileIndex begin, TileIndex end); truelight@0: int CalcBridgeLenCostFactor(int x); truelight@0: truelight@0: /* misc_cmd.c */ tron@1093: void PlaceTreesRandomly(void); truelight@0: truelight@0: void InitializeLandscapeVariables(bool only_constants); truelight@0: truelight@0: /* misc.c */ peter1138@4862: bool IsCustomName(StringID id); truelight@0: void DeleteName(StringID id); Darkvater@4912: char *GetName(char *buff, StringID id, const char* last); truelight@543: truelight@543: // AllocateNameUnique also tests if the name used is not used anywere else truelight@543: // and if it is used, it returns an error. truelight@543: #define AllocateNameUnique(name, skip) RealAllocateName(name, skip, true) truelight@543: #define AllocateName(name, skip) RealAllocateName(name, skip, false) tron@1328: StringID RealAllocateName(const char *name, byte skip, bool check_double); peter1138@5108: void ConvertNameArray(void); truelight@0: truelight@0: /* misc functions */ truelight@0: void MarkTileDirty(int x, int y); truelight@0: void MarkTileDirtyByTile(TileIndex tile); tron@2788: void InvalidateWindow(WindowClass cls, WindowNumber number); tron@2788: void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index); tron@2788: void InvalidateWindowClasses(WindowClass cls); bjarni@4766: void InvalidateWindowClassesData(WindowClass cls); truelight@0: void DeleteWindowById(WindowClass cls, WindowNumber number); darkvater@999: void DeleteWindowByClass(WindowClass cls); truelight@0: Darkvater@1914: void SetObjectToPlaceWnd(CursorID icon, byte mode, Window *w); Darkvater@1914: void SetObjectToPlace(CursorID icon, byte mode, WindowClass window_class, WindowNumber window_num); truelight@0: tron@1093: void ResetObjectToPlace(void); darkvater@152: darkvater@152: bool ScrollWindowTo(int x, int y, Window * w); darkvater@152: truelight@0: bool ScrollMainWindowToTile(TileIndex tile); truelight@0: bool ScrollMainWindowTo(int x, int y); truelight@0: void DrawSprite(uint32 img, int x, int y); truelight@0: bool EnsureNoVehicle(TileIndex tile); tron@3794: bool EnsureNoVehicleOnGround(TileIndex tile); truelight@0: void MarkAllViewportsDirty(int left, int top, int right, int bottom); truelight@0: void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost); celestar@1935: void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost); truelight@0: truelight@0: void DrawFoundation(TileInfo *ti, uint f); truelight@0: tron@1977: bool CheckIfAuthorityAllows(TileIndex tile); tron@1977: Town *ClosestTownFromTile(TileIndex tile, uint threshold); truelight@0: void ChangeTownRating(Town *t, int add, int max); truelight@0: tron@4000: uint GetTownRadiusGroup(const Town* t, TileIndex tile); truelight@0: int FindFirstBit(uint32 x); darkvater@998: void ShowHighscoreTable(int difficulty, int8 rank); truelight@0: TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng); truelight@0: tron@1093: void AfterLoadTown(void); Darkvater@3121: void UpdatePatches(void); tron@1093: void AskExitGame(void); tron@1093: void AskExitToGameMenu(void); truelight@0: tron@1093: void RedrawAutosave(void); truelight@0: truelight@0: StringID RemapOldStringID(StringID s); truelight@0: truelight@0: void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str); truelight@0: truelight@0: enum { truelight@4300: SLD_LOAD_GAME, truelight@4300: SLD_LOAD_SCENARIO, truelight@4300: SLD_SAVE_GAME, truelight@4300: SLD_SAVE_SCENARIO, truelight@4300: SLD_LOAD_HEIGHTMAP, truelight@4300: SLD_NEW_GAME, truelight@0: }; truelight@0: void ShowSaveLoadDialog(int mode); truelight@0: truelight@0: // callback from drivers that is called if the game size changes dynamically tron@1093: void GameSizeChanged(void); truelight@0: bool FileExists(const char *filename); truelight@0: bool ReadLanguagePack(int index); tron@1093: void InitializeLanguagePacks(void); Darkvater@3329: const char *GetCurrentLocale(const char *param); tron@1310: void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize); truelight@0: tron@1093: void LoadFromConfig(void); tron@1093: void SaveToConfig(void); Darkvater@1688: void CheckConfig(void); truelight@0: int ttd_main(int argc, char* argv[]); rubidium@4548: void HandleExitGameRequest(void); truelight@0: tron@1093: void DeterminePaths(void); truelight@0: Darkvater@2380: void CSleep(int milliseconds); truelight@0: #endif /* FUNCTIONS_H */