author | truelight |
Sat, 04 Dec 2004 17:54:56 +0000 | |
changeset 543 | e3b43338096b |
parent 536 | aef4753985d3 |
child 619 | 2a8675eeeb3f |
permissions | -rw-r--r-- |
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); |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
152
diff
changeset
|
23 |
uint32 GetTileTrackStatus(uint tile, TransportType mode); |
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
430
diff
changeset
|
24 |
void GetAcceptedCargo(uint tile, AcceptedCargo ac); |
0 | 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 |
||
131
16e59d059384
(svn r132) -Fix: [1014278] TileAddWrap() gave wrong results. Fixed now.
truelight
parents:
105
diff
changeset
|
31 |
uint TileAddWrap(TileIndex tile, int addx, int addy); |
0 | 32 |
enum { |
33 |
TILE_WRAPPED = (uint)-1 |
|
34 |
}; |
|
35 |
||
36 |
bool IsValidTile(uint tile); |
|
37 |
||
536 | 38 |
static inline Point RemapCoords(int x, int y, int z) |
39 |
{ |
|
0 | 40 |
#if !defined(NEW_ROTATION) |
536 | 41 |
Point pt = { (y - x) * 2, y + x - z }; |
0 | 42 |
#else |
536 | 43 |
Point pt = { (x + y) * 2, x - y - z }; |
0 | 44 |
#endif |
536 | 45 |
return pt; |
46 |
} |
|
0 | 47 |
|
536 | 48 |
static inline Point RemapCoords2(int x, int y) |
49 |
{ |
|
50 |
return RemapCoords(x, y, GetSlopeZ(x, y)); |
|
51 |
} |
|
0 | 52 |
|
53 |
/* game.c */ |
|
54 |
byte *GetString(byte *buffr, uint16 string); |
|
55 |
void InjectDparam(int amount); |
|
56 |
||
57 |
int32 GetParamInt32(); |
|
58 |
int GetParamInt16(); |
|
59 |
int GetParamInt8(); |
|
60 |
int GetParamUint16(); |
|
61 |
||
62 |
||
63 |
/* clear_land.c */ |
|
64 |
void DrawHillyLandTile(TileInfo *ti); |
|
65 |
void DrawClearLandTile(TileInfo *ti, byte set); |
|
66 |
void DrawClearLandFence(TileInfo *ti, byte img); |
|
67 |
void TileLoopClearHelper(uint tile); |
|
68 |
||
69 |
/* station_land.c */ |
|
70 |
void StationPickerDrawSprite(int x, int y, int railtype, int image); |
|
71 |
||
72 |
/* track_land.c */ |
|
73 |
void DrawTrainDepotSprite(int x, int y, int image, int railtype); |
|
415
423de36034b8
(svn r612) [newgrf] Fix: custom waypoints on monorail/maglev are displayed correctly
dominik
parents:
395
diff
changeset
|
74 |
void DrawWaypointSprite(int x, int y, int image, int railtype); |
0 | 75 |
|
76 |
/* road_land.c */ |
|
77 |
void DrawRoadDepotSprite(int x, int y, int image); |
|
78 |
||
79 |
/* water_land.c */ |
|
80 |
void DrawShipDepotSprite(int x, int y, int image); |
|
81 |
void TileLoop_Water(uint tile); |
|
82 |
||
83 |
/* players.c */ |
|
84 |
bool CheckPlayerHasMoney(int32 cost); |
|
85 |
void SubtractMoneyFromPlayer(int32 cost); |
|
86 |
void SubtractMoneyFromPlayerFract(byte player, int32 cost); |
|
87 |
bool CheckOwnership(byte owner); |
|
88 |
bool CheckTileOwnership(uint tile); |
|
2
104b2984cd3e
(svn r3) -[1005611] Player Window patch: When looking in dropdownlist for player stuff, it will say
darkvater
parents:
1
diff
changeset
|
89 |
StringID GetPlayerNameString(byte player, byte index); |
0 | 90 |
|
91 |
/* standard */ |
|
92 |
void ShowInfo(const char *str); |
|
93 |
void CDECL ShowInfoF(const char *str, ...); |
|
94 |
void NORETURN CDECL error(const char *str, ...); |
|
95 |
||
96 |
/* ttd.c */ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
97 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
98 |
// ************** |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
99 |
// * Warning: DO NOT enable this unless you understand what it does |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
100 |
// * |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
101 |
// * If enabled, in a network game all randoms will be dumped to the |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
102 |
// * stdout if the first client joins (or if you are a client). This |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
103 |
// * is to help finding desync problems. |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
104 |
// * |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
105 |
// * Warning: DO NOT enable this unless you understand what it does |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
106 |
// ************** |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
107 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
108 |
//#define RANDOM_DEBUG |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
109 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
110 |
#ifdef RANDOM_DEBUG |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
111 |
#define Random() DoRandom(__LINE__, __FILE__) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
112 |
uint32 DoRandom(uint line, char *file); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
113 |
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
114 |
uint DoRandomRange(uint max, uint line, char *file); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
115 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
116 |
uint32 Random(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
117 |
uint RandomRange(uint max); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
118 |
#endif |
0 | 119 |
|
206 | 120 |
void InitPlayerRandoms(); |
121 |
||
0 | 122 |
uint32 InteractiveRandom(); /* Used for random sequences that are not the same on the other end of the multiplayer link */ |
239 | 123 |
uint InteractiveRandomRange(uint max); |
124 |
||
0 | 125 |
void SetDate(uint date); |
126 |
/* facedraw.c */ |
|
127 |
void DrawPlayerFace(uint32 face, int color, int x, int y); |
|
128 |
||
129 |
/* texteff.c */ |
|
130 |
void MoveAllTextEffects(); |
|
131 |
void AddTextEffect(StringID msg, int x, int y, uint16 duration); |
|
132 |
void InitTextEffects(); |
|
133 |
void DrawTextEffects(DrawPixelInfo *dpi); |
|
134 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
135 |
void InitTextMessage(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
136 |
void DrawTextMessage(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
137 |
void AddTextMessage(uint16 color, uint8 duration, const char *message, ...); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
138 |
void UndrawTextMessage(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
139 |
void TextMessageDailyLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
140 |
|
0 | 141 |
bool AddAnimatedTile(uint tile); |
142 |
void DeleteAnimatedTile(uint tile); |
|
143 |
void AnimateAnimatedTiles(); |
|
144 |
void InitializeAnimatedTiles(); |
|
145 |
||
146 |
/* tunnelbridge_cmd.c */ |
|
147 |
bool CheckTunnelInWay(uint tile, int z); |
|
148 |
bool CheckBridge_Stuff(byte bridge_type, int bridge_len); |
|
149 |
uint32 GetBridgeLength(TileIndex begin, TileIndex end); |
|
150 |
int CalcBridgeLenCostFactor(int x); |
|
151 |
||
152 |
typedef void CommandCallback(bool success, uint tile, uint32 p1, uint32 p2); |
|
153 |
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); |
|
154 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
155 |
/* network.c */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
156 |
void NetworkUDPClose(void); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
157 |
void NetworkStartUp(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
158 |
void NetworkShutDown(void); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
159 |
void NetworkGameLoop(void); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
160 |
void NetworkUDPGameLoop(void); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
161 |
bool NetworkServerStart(void); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
162 |
bool NetworkClientConnectGame(const byte* host, unsigned short port); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
163 |
void NetworkQueryServer(const byte* host, unsigned short port, bool game_info); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
164 |
void NetworkReboot(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
165 |
void NetworkDisconnect(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
166 |
void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); |
0 | 167 |
|
168 |
/* misc_cmd.c */ |
|
169 |
void PlaceTreesRandomly(); |
|
170 |
||
171 |
uint GetTileDist(TileIndex xy1, TileIndex xy2); |
|
172 |
uint GetTileDist1D(TileIndex xy1, TileIndex xy2); |
|
173 |
uint GetTileDist1Db(TileIndex xy1, TileIndex xy2); |
|
174 |
uint GetTileDistAdv(TileIndex xy1, TileIndex xy2); |
|
175 |
bool CheckDistanceFromEdge(TileIndex tile, uint distance); |
|
176 |
||
177 |
void InitializeLandscapeVariables(bool only_constants); |
|
178 |
||
179 |
/* misc.c */ |
|
180 |
void DeleteName(StringID id); |
|
181 |
byte *GetName(int id, byte *buff); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
182 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
183 |
// AllocateNameUnique also tests if the name used is not used anywere else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
184 |
// and if it is used, it returns an error. |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
185 |
#define AllocateNameUnique(name, skip) RealAllocateName(name, skip, true) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
186 |
#define AllocateName(name, skip) RealAllocateName(name, skip, false) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
187 |
StringID RealAllocateName(const byte *name, byte skip, bool check_double); |
0 | 188 |
void ConvertDayToYMD(YearMonthDay *ymd, uint16 date); |
189 |
uint ConvertYMDToDay(uint year, uint month, uint day); |
|
190 |
uint ConvertIntDate(uint date); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
191 |
void CSleep(int milliseconds); |
0 | 192 |
|
193 |
||
194 |
/* misc functions */ |
|
195 |
void MarkTileDirty(int x, int y); |
|
196 |
void MarkTileDirtyByTile(TileIndex tile); |
|
197 |
void InvalidateWindow(byte cls, WindowNumber number); |
|
198 |
void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index); |
|
199 |
void InvalidateWindowClasses(byte cls); |
|
200 |
void DeleteWindowById(WindowClass cls, WindowNumber number); |
|
201 |
||
202 |
void SetObjectToPlaceWnd(int icon, byte mode, Window *w); |
|
203 |
void SetObjectToPlace(int icon, byte mode, byte window_class, uint16 window_num); |
|
204 |
||
205 |
void ResetObjectToPlace(); |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
131
diff
changeset
|
206 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
131
diff
changeset
|
207 |
bool ScrollWindowToTile(TileIndex tile, Window * w); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
131
diff
changeset
|
208 |
bool ScrollWindowTo(int x, int y, Window * w); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
131
diff
changeset
|
209 |
|
0 | 210 |
bool ScrollMainWindowToTile(TileIndex tile); |
211 |
bool ScrollMainWindowTo(int x, int y); |
|
212 |
void DrawSprite(uint32 img, int x, int y); |
|
213 |
bool EnsureNoVehicle(TileIndex tile); |
|
214 |
bool EnsureNoVehicleZ(TileIndex tile, byte z); |
|
215 |
void MarkAllViewportsDirty(int left, int top, int right, int bottom); |
|
216 |
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost); |
|
217 |
void MarkWholeScreenDirty(); |
|
218 |
||
219 |
void DrawFoundation(TileInfo *ti, uint f); |
|
220 |
||
221 |
bool CheckIfAuthorityAllows(uint tile); |
|
222 |
Town *ClosestTownFromTile(uint tile, uint threshold); |
|
223 |
void ChangeTownRating(Town *t, int add, int max); |
|
224 |
||
225 |
uint GetRoadBitsByTile(TileIndex tile); |
|
226 |
int GetTownRadiusGroup(Town *t, uint tile); |
|
227 |
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
228 |
void ShowNetworkChatQueryWindow(byte desttype, byte dest); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
229 |
void ShowNetworkGiveMoneyWindow(byte player); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
230 |
void ShowNetworkNeedGamePassword(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
231 |
void ShowNetworkNeedCompanyPassword(); |
0 | 232 |
void ShowRenameSignWindow(SignStruct *ss); |
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
393
diff
changeset
|
233 |
void ShowRenameWaypointWindow(Waypoint *cp); |
0 | 234 |
int FindFirstBit(uint32 x); |
235 |
void ShowHighscoreTable(int tbl); |
|
236 |
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng); |
|
237 |
||
238 |
enum SaveOrLoadResult { |
|
239 |
SL_OK = 0, // completed successfully |
|
240 |
SL_ERROR = 1, // error that was caught before internal structures were modified |
|
241 |
SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load) |
|
242 |
}; |
|
243 |
enum SaveOrLoadMode { |
|
244 |
SL_INVALID = -1, |
|
245 |
SL_LOAD = 0, |
|
246 |
SL_SAVE = 1, |
|
247 |
SL_OLD_LOAD = 2, |
|
248 |
}; |
|
249 |
||
250 |
int SaveOrLoad(const char *filename, int mode); |
|
251 |
||
252 |
void AfterLoadTown(); |
|
253 |
void AskExitGame(); |
|
254 |
void AskExitToGameMenu(); |
|
255 |
||
256 |
void RedrawAutosave(); |
|
257 |
||
258 |
StringID RemapOldStringID(StringID s); |
|
259 |
||
260 |
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str); |
|
261 |
||
262 |
enum { |
|
263 |
SLD_LOAD_GAME = 0, |
|
264 |
SLD_LOAD_SCENARIO = 1, |
|
265 |
SLD_SAVE_GAME = 2, |
|
266 |
SLD_SAVE_SCENARIO = 3, |
|
267 |
SLD_NEW_GAME = 4, |
|
268 |
}; |
|
269 |
void ShowSaveLoadDialog(int mode); |
|
270 |
||
271 |
void ttd_strlcpy(char *dst, const char *src, size_t len); |
|
272 |
||
273 |
// callback from drivers that is called if the game size changes dynamically |
|
274 |
void GameSizeChanged(); |
|
275 |
bool FileExists(const char *filename); |
|
276 |
bool ReadLanguagePack(int index); |
|
277 |
void InitializeLanguagePacks(); |
|
278 |
byte *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize); |
|
279 |
int GetLanguageList(char **languages, int max); |
|
280 |
||
281 |
void CheckSwitchToEuro(); |
|
282 |
||
283 |
void LoadFromConfig(); |
|
284 |
void SaveToConfig(); |
|
285 |
int ttd_main(int argc, char* argv[]); |
|
223
0e5cc5a65df6
(svn r224) -Fix: Music now finally works on WinXP. DirectMusic is now default for an OS >= WinNT4 (WinNT4, Win2k, WinXP), and MIDI driver for lower OS's (Win95, Win98, WinME, etc).
darkvater
parents:
211
diff
changeset
|
286 |
byte GetOSVersion(); |
0 | 287 |
|
288 |
void DeterminePaths(); |
|
289 |
char * CDECL str_fmt(const char *str, ...); |
|
290 |
||
291 |
#endif /* FUNCTIONS_H */ |