0
|
1 |
#ifndef FUNCTIONS_H
|
|
2 |
#define FUNCTIONS_H
|
|
3 |
|
|
4 |
/* vehicle.c */
|
|
5 |
|
|
6 |
/* window.c */
|
|
7 |
|
|
8 |
|
|
9 |
/* landscape.c */
|
|
10 |
void FindLandscapeHeight(TileInfo *ti, uint x, uint y);
|
|
11 |
void FindLandscapeHeightByTile(TileInfo *ti, uint tile);
|
|
12 |
uint GetTileSlope(uint tile, int *h);
|
|
13 |
int GetTileZ(uint tile);
|
|
14 |
|
|
15 |
void DoClearSquare(uint tile);
|
|
16 |
void CDECL ModifyTile(uint tile, uint flags, ...);
|
|
17 |
void SetMapExtraBits(uint tile, byte flags);
|
|
18 |
uint GetMapExtraBits(uint tile);
|
|
19 |
void RunTileLoop();
|
|
20 |
|
|
21 |
uint GetPartialZ(int x, int y, int corners);
|
|
22 |
uint GetSlopeZ(int x, int y);
|
|
23 |
uint32 GetTileTrackStatus(uint tile, int mode);
|
|
24 |
void GetAcceptedCargo(uint tile, AcceptedCargo *ac);
|
|
25 |
void ChangeTileOwner(uint tile, byte old_player, byte new_player);
|
|
26 |
void AnimateTile(uint tile);
|
|
27 |
void ClickTile(uint tile);
|
|
28 |
void GetTileDesc(uint tile, TileDesc *td);
|
|
29 |
void DrawTile(TileInfo *ti);
|
|
30 |
|
|
31 |
uint TileAddWrap(TileIndex tile, int add);
|
|
32 |
enum {
|
|
33 |
TILE_WRAPPED = (uint)-1
|
|
34 |
};
|
|
35 |
|
|
36 |
bool IsValidTile(uint tile);
|
|
37 |
|
|
38 |
#if !defined(NEW_ROTATION)
|
|
39 |
static Point FORCEINLINE RemapCoords(int x, int y, int z) { Point pt = { (y-x)*2, y + x -z }; return pt; }
|
|
40 |
#else
|
|
41 |
static Point FORCEINLINE RemapCoords(int x, int y, int z) { Point pt = { (x + y)*2, x - y -z }; return pt; }
|
|
42 |
#endif
|
|
43 |
|
|
44 |
static Point FORCEINLINE RemapCoords2(int x, int y) { return RemapCoords(x, y, GetSlopeZ(x, y)); }
|
|
45 |
|
|
46 |
/* game.c */
|
|
47 |
byte *GetString(byte *buffr, uint16 string);
|
|
48 |
void InjectDparam(int amount);
|
|
49 |
|
|
50 |
int32 GetParamInt32();
|
|
51 |
int GetParamInt16();
|
|
52 |
int GetParamInt8();
|
|
53 |
int GetParamUint16();
|
|
54 |
|
|
55 |
|
|
56 |
/* sound.c */
|
|
57 |
void SndPlayTileFx(int sound, TileIndex tile);
|
|
58 |
void SndPlayVehicleFx(int sound, Vehicle *v);
|
|
59 |
void SndPlayFx(int sound);
|
|
60 |
|
|
61 |
/* clear_land.c */
|
|
62 |
void DrawHillyLandTile(TileInfo *ti);
|
|
63 |
void DrawClearLandTile(TileInfo *ti, byte set);
|
|
64 |
void DrawClearLandFence(TileInfo *ti, byte img);
|
|
65 |
void TileLoopClearHelper(uint tile);
|
|
66 |
|
|
67 |
/* station_land.c */
|
|
68 |
void StationPickerDrawSprite(int x, int y, int railtype, int image);
|
|
69 |
|
|
70 |
/* track_land.c */
|
|
71 |
void DrawTrainDepotSprite(int x, int y, int image, int railtype);
|
|
72 |
|
|
73 |
/* road_land.c */
|
|
74 |
void DrawRoadDepotSprite(int x, int y, int image);
|
|
75 |
|
|
76 |
/* water_land.c */
|
|
77 |
void DrawShipDepotSprite(int x, int y, int image);
|
|
78 |
void TileLoop_Water(uint tile);
|
|
79 |
|
|
80 |
/* players.c */
|
|
81 |
bool CheckPlayerHasMoney(int32 cost);
|
|
82 |
void SubtractMoneyFromPlayer(int32 cost);
|
|
83 |
void SubtractMoneyFromPlayerFract(byte player, int32 cost);
|
|
84 |
bool CheckOwnership(byte owner);
|
|
85 |
bool CheckTileOwnership(uint tile);
|
|
86 |
StringID GetPlayerNameString(byte player);
|
|
87 |
|
|
88 |
/* standard */
|
|
89 |
void ShowInfo(const char *str);
|
|
90 |
void CDECL ShowInfoF(const char *str, ...);
|
|
91 |
void NORETURN CDECL error(const char *str, ...);
|
|
92 |
void memswap(void *a, void *b, size_t size);
|
|
93 |
|
|
94 |
/* ttd.c */
|
|
95 |
uint32 Random();
|
|
96 |
uint RandomRange(uint max);
|
|
97 |
|
|
98 |
uint32 InteractiveRandom(); /* Used for random sequences that are not the same on the other end of the multiplayer link */
|
|
99 |
void SetDate(uint date);
|
|
100 |
/* facedraw.c */
|
|
101 |
void DrawPlayerFace(uint32 face, int color, int x, int y);
|
|
102 |
|
|
103 |
/* texteff.c */
|
|
104 |
void MoveAllTextEffects();
|
|
105 |
void AddTextEffect(StringID msg, int x, int y, uint16 duration);
|
|
106 |
void InitTextEffects();
|
|
107 |
void DrawTextEffects(DrawPixelInfo *dpi);
|
|
108 |
|
|
109 |
bool AddAnimatedTile(uint tile);
|
|
110 |
void DeleteAnimatedTile(uint tile);
|
|
111 |
void AnimateAnimatedTiles();
|
|
112 |
void InitializeAnimatedTiles();
|
|
113 |
|
|
114 |
/* tunnelbridge_cmd.c */
|
|
115 |
bool CheckTunnelInWay(uint tile, int z);
|
|
116 |
bool CheckBridge_Stuff(byte bridge_type, int bridge_len);
|
|
117 |
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
|
|
118 |
int CalcBridgeLenCostFactor(int x);
|
|
119 |
|
|
120 |
/* network.c */
|
|
121 |
typedef void CommandCallback(bool success, uint tile, uint32 p1, uint32 p2);
|
|
122 |
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
|
|
123 |
|
|
124 |
void NetworkConnect(const char *hostname, int port);
|
|
125 |
void NetworkReceive();
|
|
126 |
void NetworkSend();
|
|
127 |
void NetworkProcessCommands();
|
|
128 |
void NetworkListen(int port);
|
1
|
129 |
void NetworkInitialize(const char *hostname);
|
0
|
130 |
void NetworkShutdown();
|
|
131 |
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
|
132 |
void NetworkStartSync();
|
|
133 |
void NetworkUDPListen(int port);
|
|
134 |
void NetworkUDPReceive();
|
|
135 |
void NetworkIPListInit();
|
|
136 |
bool NetworkUDPSearchServer();
|
|
137 |
|
|
138 |
/* misc_cmd.c */
|
|
139 |
void PlaceTreesRandomly();
|
|
140 |
|
|
141 |
uint GetTileDist(TileIndex xy1, TileIndex xy2);
|
|
142 |
uint GetTileDist1D(TileIndex xy1, TileIndex xy2);
|
|
143 |
uint GetTileDist1Db(TileIndex xy1, TileIndex xy2);
|
|
144 |
uint GetTileDistAdv(TileIndex xy1, TileIndex xy2);
|
|
145 |
bool CheckDistanceFromEdge(TileIndex tile, uint distance);
|
|
146 |
|
|
147 |
void InitializeLandscapeVariables(bool only_constants);
|
|
148 |
|
|
149 |
/* misc.c */
|
|
150 |
void DeleteName(StringID id);
|
|
151 |
byte *GetName(int id, byte *buff);
|
|
152 |
StringID AllocateName(const byte *name, byte skip);
|
|
153 |
void ConvertDayToYMD(YearMonthDay *ymd, uint16 date);
|
|
154 |
uint ConvertYMDToDay(uint year, uint month, uint day);
|
|
155 |
uint ConvertIntDate(uint date);
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
/* misc functions */
|
|
160 |
void MarkTileDirty(int x, int y);
|
|
161 |
void MarkTileDirtyByTile(TileIndex tile);
|
|
162 |
void InvalidateWindow(byte cls, WindowNumber number);
|
|
163 |
void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index);
|
|
164 |
void InvalidateWindowClasses(byte cls);
|
|
165 |
void DeleteWindowById(WindowClass cls, WindowNumber number);
|
|
166 |
|
|
167 |
void SetObjectToPlaceWnd(int icon, byte mode, Window *w);
|
|
168 |
void SetObjectToPlace(int icon, byte mode, byte window_class, uint16 window_num);
|
|
169 |
|
|
170 |
void ResetObjectToPlace();
|
|
171 |
bool ScrollMainWindowToTile(TileIndex tile);
|
|
172 |
bool ScrollMainWindowTo(int x, int y);
|
|
173 |
void DrawSprite(uint32 img, int x, int y);
|
|
174 |
bool EnsureNoVehicle(TileIndex tile);
|
|
175 |
bool EnsureNoVehicleZ(TileIndex tile, byte z);
|
|
176 |
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
|
|
177 |
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost);
|
|
178 |
void MarkWholeScreenDirty();
|
|
179 |
|
|
180 |
void DrawFoundation(TileInfo *ti, uint f);
|
|
181 |
|
|
182 |
bool CheckIfAuthorityAllows(uint tile);
|
|
183 |
Town *ClosestTownFromTile(uint tile, uint threshold);
|
|
184 |
void ChangeTownRating(Town *t, int add, int max);
|
|
185 |
|
|
186 |
uint GetRoadBitsByTile(TileIndex tile);
|
|
187 |
int GetTownRadiusGroup(Town *t, uint tile);
|
|
188 |
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type);
|
|
189 |
void ShowRenameSignWindow(SignStruct *ss);
|
|
190 |
void ShowRenameCheckpointWindow(Checkpoint *cp);
|
|
191 |
int FindFirstBit(uint32 x);
|
|
192 |
void ShowHighscoreTable(int tbl);
|
|
193 |
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng);
|
|
194 |
|
|
195 |
enum SaveOrLoadResult {
|
|
196 |
SL_OK = 0, // completed successfully
|
|
197 |
SL_ERROR = 1, // error that was caught before internal structures were modified
|
|
198 |
SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load)
|
|
199 |
};
|
|
200 |
enum SaveOrLoadMode {
|
|
201 |
SL_INVALID = -1,
|
|
202 |
SL_LOAD = 0,
|
|
203 |
SL_SAVE = 1,
|
|
204 |
SL_OLD_LOAD = 2,
|
|
205 |
};
|
|
206 |
|
|
207 |
int SaveOrLoad(const char *filename, int mode);
|
|
208 |
|
|
209 |
void AfterLoadTown();
|
|
210 |
void AskExitGame();
|
|
211 |
void AskExitToGameMenu();
|
|
212 |
|
|
213 |
void RedrawAutosave();
|
|
214 |
|
|
215 |
StringID RemapOldStringID(StringID s);
|
|
216 |
|
|
217 |
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str);
|
|
218 |
|
|
219 |
enum {
|
|
220 |
SLD_LOAD_GAME = 0,
|
|
221 |
SLD_LOAD_SCENARIO = 1,
|
|
222 |
SLD_SAVE_GAME = 2,
|
|
223 |
SLD_SAVE_SCENARIO = 3,
|
|
224 |
SLD_NEW_GAME = 4,
|
|
225 |
};
|
|
226 |
void ShowSaveLoadDialog(int mode);
|
|
227 |
|
|
228 |
void ttd_strlcpy(char *dst, const char *src, size_t len);
|
|
229 |
|
|
230 |
// callback from drivers that is called if the game size changes dynamically
|
|
231 |
void GameSizeChanged();
|
|
232 |
void ZoomInOrOutToCursor(bool in);
|
|
233 |
bool MakeScreenshot();
|
|
234 |
bool MakeWorldScreenshot(int left, int top, int width, int height, int zoom);
|
|
235 |
bool FileExists(const char *filename);
|
|
236 |
bool ReadLanguagePack(int index);
|
|
237 |
void InitializeLanguagePacks();
|
|
238 |
byte *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
|
|
239 |
int GetLanguageList(char **languages, int max);
|
|
240 |
|
|
241 |
const char *GetScreenshotFormatDesc(int i);
|
|
242 |
void InitializeScreenshotFormats();
|
|
243 |
void SetScreenshotFormat(int i);
|
|
244 |
void CheckSwitchToEuro();
|
|
245 |
|
|
246 |
void LoadFromConfig();
|
|
247 |
void SaveToConfig();
|
|
248 |
int ttd_main(int argc, char* argv[]);
|
|
249 |
|
|
250 |
void DeterminePaths();
|
|
251 |
char * CDECL str_fmt(const char *str, ...);
|
|
252 |
|
|
253 |
#endif /* FUNCTIONS_H */
|