truelight@0: #ifndef FUNCTIONS_H truelight@0: #define FUNCTIONS_H truelight@0: truelight@0: /* vehicle.c */ truelight@0: truelight@0: /* window.c */ truelight@0: truelight@0: truelight@0: /* landscape.c */ truelight@0: void FindLandscapeHeight(TileInfo *ti, uint x, uint y); truelight@0: void FindLandscapeHeightByTile(TileInfo *ti, uint tile); truelight@0: uint GetTileSlope(uint tile, int *h); truelight@0: int GetTileZ(uint tile); truelight@0: truelight@0: void DoClearSquare(uint tile); truelight@0: void CDECL ModifyTile(uint tile, uint flags, ...); truelight@0: void SetMapExtraBits(uint tile, byte flags); truelight@0: uint GetMapExtraBits(uint tile); truelight@0: void RunTileLoop(); truelight@0: truelight@0: uint GetPartialZ(int x, int y, int corners); truelight@0: uint GetSlopeZ(int x, int y); truelight@0: uint32 GetTileTrackStatus(uint tile, int mode); truelight@0: void GetAcceptedCargo(uint tile, AcceptedCargo *ac); truelight@0: void ChangeTileOwner(uint tile, byte old_player, byte new_player); truelight@0: void AnimateTile(uint tile); truelight@0: void ClickTile(uint tile); truelight@0: void GetTileDesc(uint tile, TileDesc *td); truelight@0: void DrawTile(TileInfo *ti); truelight@0: truelight@0: uint TileAddWrap(TileIndex tile, int add); truelight@0: enum { truelight@0: TILE_WRAPPED = (uint)-1 truelight@0: }; truelight@0: truelight@0: bool IsValidTile(uint tile); truelight@0: truelight@0: #if !defined(NEW_ROTATION) truelight@0: static Point FORCEINLINE RemapCoords(int x, int y, int z) { Point pt = { (y-x)*2, y + x -z }; return pt; } truelight@0: #else truelight@0: static Point FORCEINLINE RemapCoords(int x, int y, int z) { Point pt = { (x + y)*2, x - y -z }; return pt; } truelight@0: #endif truelight@0: truelight@0: static Point FORCEINLINE RemapCoords2(int x, int y) { return RemapCoords(x, y, GetSlopeZ(x, y)); } truelight@0: truelight@0: /* game.c */ truelight@0: byte *GetString(byte *buffr, uint16 string); truelight@0: void InjectDparam(int amount); truelight@0: truelight@0: int32 GetParamInt32(); truelight@0: int GetParamInt16(); truelight@0: int GetParamInt8(); truelight@0: int GetParamUint16(); truelight@0: truelight@0: truelight@0: /* sound.c */ truelight@0: void SndPlayTileFx(int sound, TileIndex tile); truelight@0: void SndPlayVehicleFx(int sound, Vehicle *v); truelight@0: void SndPlayFx(int sound); truelight@0: truelight@0: /* clear_land.c */ truelight@0: void DrawHillyLandTile(TileInfo *ti); truelight@0: void DrawClearLandTile(TileInfo *ti, byte set); truelight@0: void DrawClearLandFence(TileInfo *ti, byte img); truelight@0: void TileLoopClearHelper(uint tile); truelight@0: truelight@0: /* station_land.c */ truelight@0: void StationPickerDrawSprite(int x, int y, int railtype, int image); truelight@0: truelight@0: /* track_land.c */ truelight@0: void DrawTrainDepotSprite(int x, int y, int image, int railtype); truelight@0: truelight@0: /* road_land.c */ truelight@0: void DrawRoadDepotSprite(int x, int y, int image); truelight@0: truelight@0: /* water_land.c */ truelight@0: void DrawShipDepotSprite(int x, int y, int image); truelight@0: void TileLoop_Water(uint tile); truelight@0: truelight@0: /* players.c */ truelight@0: bool CheckPlayerHasMoney(int32 cost); truelight@0: void SubtractMoneyFromPlayer(int32 cost); truelight@0: void SubtractMoneyFromPlayerFract(byte player, int32 cost); truelight@0: bool CheckOwnership(byte owner); truelight@0: bool CheckTileOwnership(uint tile); darkvater@2: StringID GetPlayerNameString(byte player, byte 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: void memswap(void *a, void *b, size_t size); truelight@0: truelight@0: /* ttd.c */ truelight@0: uint32 Random(); truelight@0: uint RandomRange(uint max); truelight@0: truelight@0: uint32 InteractiveRandom(); /* Used for random sequences that are not the same on the other end of the multiplayer link */ truelight@0: void SetDate(uint date); truelight@0: /* facedraw.c */ truelight@0: void DrawPlayerFace(uint32 face, int color, int x, int y); truelight@0: truelight@0: /* texteff.c */ truelight@0: void MoveAllTextEffects(); truelight@0: void AddTextEffect(StringID msg, int x, int y, uint16 duration); truelight@0: void InitTextEffects(); truelight@0: void DrawTextEffects(DrawPixelInfo *dpi); truelight@0: truelight@0: bool AddAnimatedTile(uint tile); truelight@0: void DeleteAnimatedTile(uint tile); truelight@0: void AnimateAnimatedTiles(); truelight@0: void InitializeAnimatedTiles(); truelight@0: truelight@0: /* tunnelbridge_cmd.c */ truelight@0: bool CheckTunnelInWay(uint tile, int z); truelight@0: bool CheckBridge_Stuff(byte bridge_type, int bridge_len); truelight@0: uint32 GetBridgeLength(TileIndex begin, TileIndex end); truelight@0: int CalcBridgeLenCostFactor(int x); truelight@0: truelight@0: /* network.c */ truelight@0: typedef void CommandCallback(bool success, uint tile, uint32 p1, uint32 p2); truelight@0: bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); truelight@0: truelight@0: void NetworkConnect(const char *hostname, int port); truelight@0: void NetworkReceive(); truelight@0: void NetworkSend(); truelight@0: void NetworkProcessCommands(); truelight@0: void NetworkListen(int port); darkvater@1: void NetworkInitialize(const char *hostname); truelight@0: void NetworkShutdown(); truelight@0: void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); truelight@0: void NetworkStartSync(); truelight@0: void NetworkUDPListen(int port); truelight@0: void NetworkUDPReceive(); truelight@0: void NetworkIPListInit(); truelight@0: bool NetworkUDPSearchServer(); truelight@0: truelight@0: /* misc_cmd.c */ truelight@0: void PlaceTreesRandomly(); truelight@0: truelight@0: uint GetTileDist(TileIndex xy1, TileIndex xy2); truelight@0: uint GetTileDist1D(TileIndex xy1, TileIndex xy2); truelight@0: uint GetTileDist1Db(TileIndex xy1, TileIndex xy2); truelight@0: uint GetTileDistAdv(TileIndex xy1, TileIndex xy2); truelight@0: bool CheckDistanceFromEdge(TileIndex tile, uint distance); truelight@0: truelight@0: void InitializeLandscapeVariables(bool only_constants); truelight@0: truelight@0: /* misc.c */ truelight@0: void DeleteName(StringID id); truelight@0: byte *GetName(int id, byte *buff); truelight@0: StringID AllocateName(const byte *name, byte skip); truelight@0: void ConvertDayToYMD(YearMonthDay *ymd, uint16 date); truelight@0: uint ConvertYMDToDay(uint year, uint month, uint day); truelight@0: uint ConvertIntDate(uint date); truelight@0: truelight@0: truelight@0: truelight@0: /* misc functions */ truelight@0: void MarkTileDirty(int x, int y); truelight@0: void MarkTileDirtyByTile(TileIndex tile); truelight@0: void InvalidateWindow(byte cls, WindowNumber number); truelight@0: void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index); truelight@0: void InvalidateWindowClasses(byte cls); truelight@0: void DeleteWindowById(WindowClass cls, WindowNumber number); truelight@0: truelight@0: void SetObjectToPlaceWnd(int icon, byte mode, Window *w); truelight@0: void SetObjectToPlace(int icon, byte mode, byte window_class, uint16 window_num); truelight@0: truelight@0: void ResetObjectToPlace(); 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); truelight@0: bool EnsureNoVehicleZ(TileIndex tile, byte z); truelight@0: void MarkAllViewportsDirty(int left, int top, int right, int bottom); truelight@0: void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost); truelight@0: void MarkWholeScreenDirty(); truelight@0: truelight@0: void DrawFoundation(TileInfo *ti, uint f); truelight@0: truelight@0: bool CheckIfAuthorityAllows(uint tile); truelight@0: Town *ClosestTownFromTile(uint tile, uint threshold); truelight@0: void ChangeTownRating(Town *t, int add, int max); truelight@0: truelight@0: uint GetRoadBitsByTile(TileIndex tile); truelight@0: int GetTownRadiusGroup(Town *t, uint tile); truelight@0: int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type); truelight@0: void ShowRenameSignWindow(SignStruct *ss); truelight@0: void ShowRenameCheckpointWindow(Checkpoint *cp); truelight@0: int FindFirstBit(uint32 x); truelight@0: void ShowHighscoreTable(int tbl); truelight@0: TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng); truelight@0: truelight@0: enum SaveOrLoadResult { truelight@0: SL_OK = 0, // completed successfully truelight@0: SL_ERROR = 1, // error that was caught before internal structures were modified truelight@0: SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load) truelight@0: }; truelight@0: enum SaveOrLoadMode { truelight@0: SL_INVALID = -1, truelight@0: SL_LOAD = 0, truelight@0: SL_SAVE = 1, truelight@0: SL_OLD_LOAD = 2, truelight@0: }; truelight@0: truelight@0: int SaveOrLoad(const char *filename, int mode); truelight@0: truelight@0: void AfterLoadTown(); truelight@0: void AskExitGame(); truelight@0: void AskExitToGameMenu(); truelight@0: truelight@0: 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@0: SLD_LOAD_GAME = 0, truelight@0: SLD_LOAD_SCENARIO = 1, truelight@0: SLD_SAVE_GAME = 2, truelight@0: SLD_SAVE_SCENARIO = 3, truelight@0: SLD_NEW_GAME = 4, truelight@0: }; truelight@0: void ShowSaveLoadDialog(int mode); truelight@0: truelight@0: void ttd_strlcpy(char *dst, const char *src, size_t len); truelight@0: truelight@0: // callback from drivers that is called if the game size changes dynamically truelight@0: void GameSizeChanged(); truelight@0: void ZoomInOrOutToCursor(bool in); truelight@0: bool MakeScreenshot(); truelight@0: bool MakeWorldScreenshot(int left, int top, int width, int height, int zoom); truelight@0: bool FileExists(const char *filename); truelight@0: bool ReadLanguagePack(int index); truelight@0: void InitializeLanguagePacks(); truelight@0: byte *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize); truelight@0: int GetLanguageList(char **languages, int max); truelight@0: truelight@0: const char *GetScreenshotFormatDesc(int i); truelight@0: void InitializeScreenshotFormats(); truelight@0: void SetScreenshotFormat(int i); truelight@0: void CheckSwitchToEuro(); truelight@0: truelight@0: void LoadFromConfig(); truelight@0: void SaveToConfig(); truelight@0: int ttd_main(int argc, char* argv[]); truelight@0: truelight@0: void DeterminePaths(); truelight@0: char * CDECL str_fmt(const char *str, ...); truelight@0: truelight@0: #endif /* FUNCTIONS_H */