tron@2186: /* $Id$ */ tron@2186: belugas@6505: /** @file functions.h */ belugas@6505: truelight@0: #ifndef FUNCTIONS_H truelight@0: #define FUNCTIONS_H truelight@0: KUDr@5887: #include "gfx.h" KUDr@5887: celestar@1377: void UpdateTownMaxPass(Town *t); truelight@0: belugas@6505: /* clear_land.cpp */ 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: belugas@6505: /* water_land.cpp */ truelight@0: void DrawShipDepotSprite(int x, int y, int image); tron@1977: void TileLoop_Water(TileIndex tile); truelight@0: belugas@6505: /* players.cpp */ glx@9629: bool CheckPlayerHasMoney(CommandCost cost); glx@9629: void SubtractMoneyFromPlayer(CommandCost cost); glx@9629: void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cost); Darkvater@4849: bool CheckOwnership(Owner owner); tron@1977: bool CheckTileOwnership(TileIndex tile); truelight@0: truelight@0: /* standard */ truelight@0: void ShowInfo(const char *str); truelight@0: void CDECL ShowInfoF(const char *str, ...); truelight@0: belugas@6505: /* openttd.cpp */ 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); rubidium@6573: uint32 RandomMT(); ludde@2073: ludde@2073: ludde@2073: #ifdef MERSENNE_TWISTER rubidium@6573: static inline uint32 Random() { 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 rubidium@6573: uint32 Random(); 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); } rubidium@6573: static inline TileIndex RandomTile() { return TILE_MASK(Random()); } ludde@2073: ludde@2073: rubidium@6573: uint32 InteractiveRandom(); // 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: belugas@6505: /* texteff.cpp */ tron@1977: bool AddAnimatedTile(TileIndex tile); tron@1977: void DeleteAnimatedTile(TileIndex tile); rubidium@6573: void AnimateAnimatedTiles(); rubidium@6573: void InitializeAnimatedTiles(); truelight@0: belugas@6505: /* tunnelbridge_cmd.cpp */ 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: belugas@6505: /* misc_cmd.cpp */ rubidium@6573: void PlaceTreesRandomly(); truelight@0: truelight@0: void InitializeLandscapeVariables(bool only_constants); truelight@0: belugas@6505: /* misc.cpp */ peter1138@4862: bool IsCustomName(StringID id); truelight@0: void DeleteName(StringID id); rubidium@9694: char *GetName(char *buff, StringID id, const char *last); truelight@543: truelight@543: #define AllocateName(name, skip) RealAllocateName(name, skip, false) tron@1328: StringID RealAllocateName(const char *name, byte skip, bool check_double); rubidium@6573: void ConvertNameArray(); 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: peter1138@5919: void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w); peter1138@5919: void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num); truelight@0: rubidium@6573: void ResetObjectToPlace(); darkvater@152: rubidium@9694: bool ScrollWindowTo(int x, int y, Window *w, bool instant = false); darkvater@152: rubidium@9625: bool ScrollMainWindowToTile(TileIndex tile, bool instant = false); rubidium@9625: bool ScrollMainWindowTo(int x, int y, bool instant = false); peter1138@5919: void DrawSprite(SpriteID img, SpriteID pal, 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); glx@9629: void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost); glx@9629: void ShowFeederIncomeAnimation(int x, int y, int z, Money cost); 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); rubidium@9628: void ShowHighscoreTable(int difficulty, int8 rank); rubidium@9628: truelight@0: int FindFirstBit(uint32 x); rubidium@9628: int CountBitsSet(uint32 value); truelight@0: rubidium@6573: void AfterLoadTown(); rubidium@6573: void UpdatePatches(); rubidium@6573: void AskExitGame(); rubidium@6573: void AskExitToGameMenu(); truelight@0: rubidium@6573: void RedrawAutosave(); 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: belugas@6505: /* callback from drivers that is called if the game size changes dynamically */ rubidium@6573: void GameSizeChanged(); truelight@0: bool FileExists(const char *filename); Darkvater@3329: const char *GetCurrentLocale(const char *param); tron@1310: void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize); truelight@0: rubidium@6573: void LoadFromConfig(); rubidium@6573: void SaveToConfig(); rubidium@6573: void CheckConfig(); truelight@0: int ttd_main(int argc, char* argv[]); rubidium@6573: void HandleExitGameRequest(); truelight@0: truelight@0: #endif /* FUNCTIONS_H */