2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef FUNCTIONS_H
|
|
|
|
#define FUNCTIONS_H
|
|
|
|
|
2005-03-27 18:15:27 +00:00
|
|
|
void DoClearSquare(TileIndex tile);
|
2005-01-22 20:23:18 +00:00
|
|
|
void RunTileLoop(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-23 13:48:16 +00:00
|
|
|
uint GetPartialZ(int x, int y, Slope corners);
|
2004-08-09 17:04:08 +00:00
|
|
|
uint GetSlopeZ(int x, int y);
|
2005-03-27 18:15:27 +00:00
|
|
|
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode);
|
|
|
|
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
|
|
|
|
void ChangeTileOwner(TileIndex tile, byte old_player, byte new_player);
|
|
|
|
void AnimateTile(TileIndex tile);
|
|
|
|
void ClickTile(TileIndex tile);
|
|
|
|
void GetTileDesc(TileIndex tile, TileDesc *td);
|
2005-02-17 10:56:19 +00:00
|
|
|
void UpdateTownMaxPass(Town *t);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-03-27 18:15:27 +00:00
|
|
|
bool IsValidTile(TileIndex tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-03 07:43:00 +00:00
|
|
|
static inline Point RemapCoords(int x, int y, int z)
|
|
|
|
{
|
2004-08-09 17:04:08 +00:00
|
|
|
#if !defined(NEW_ROTATION)
|
2004-12-23 14:46:16 +00:00
|
|
|
Point pt;
|
|
|
|
pt.x = (y - x) * 2;
|
|
|
|
pt.y = y + x - z;
|
2004-08-09 17:04:08 +00:00
|
|
|
#else
|
2004-12-23 14:46:16 +00:00
|
|
|
Point pt;
|
|
|
|
pt.x = (x + y) * 2;
|
|
|
|
pt.y = x - y - z;
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif
|
2004-12-03 07:43:00 +00:00
|
|
|
return pt;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-03 07:43:00 +00:00
|
|
|
static inline Point RemapCoords2(int x, int y)
|
|
|
|
{
|
|
|
|
return RemapCoords(x, y, GetSlopeZ(x, y));
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* clear_land.c */
|
2005-09-18 20:56:44 +00:00
|
|
|
void DrawHillyLandTile(const TileInfo *ti);
|
|
|
|
void DrawClearLandTile(const TileInfo *ti, byte set);
|
2005-07-28 19:18:27 +00:00
|
|
|
void DrawClearLandFence(const TileInfo *ti);
|
2005-03-04 10:34:44 +00:00
|
|
|
void TileLoopClearHelper(TileIndex tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* water_land.c */
|
|
|
|
void DrawShipDepotSprite(int x, int y, int image);
|
2005-06-24 12:38:35 +00:00
|
|
|
void TileLoop_Water(TileIndex tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* players.c */
|
|
|
|
bool CheckPlayerHasMoney(int32 cost);
|
|
|
|
void SubtractMoneyFromPlayer(int32 cost);
|
2005-09-18 20:56:44 +00:00
|
|
|
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost);
|
2006-10-14 22:22:48 +00:00
|
|
|
bool CheckOwnership(Owner owner);
|
2005-06-24 12:38:35 +00:00
|
|
|
bool CheckTileOwnership(TileIndex tile);
|
2005-09-30 20:37:25 +00:00
|
|
|
StringID GetPlayerNameString(PlayerID player, uint index);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* standard */
|
|
|
|
void ShowInfo(const char *str);
|
|
|
|
void CDECL ShowInfoF(const char *str, ...);
|
|
|
|
void NORETURN CDECL error(const char *str, ...);
|
|
|
|
|
2005-07-15 21:28:26 +00:00
|
|
|
/* openttd.c */
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2006-08-28 10:14:37 +00:00
|
|
|
/**************
|
|
|
|
* Warning: DO NOT enable this unless you understand what it does
|
|
|
|
*
|
|
|
|
* If enabled, in a network game all randoms will be dumped to the
|
|
|
|
* stdout if the first client joins (or if you are a client). This
|
|
|
|
* is to help finding desync problems.
|
|
|
|
*
|
|
|
|
* Warning: DO NOT enable this unless you understand what it does
|
|
|
|
**************/
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2005-03-24 14:33:05 +00:00
|
|
|
//#define RANDOM_DEBUG
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2005-07-15 20:29:06 +00:00
|
|
|
|
|
|
|
// Enable this to produce higher quality random numbers.
|
|
|
|
// Doesn't work with network yet.
|
|
|
|
//#define MERSENNE_TWISTER
|
|
|
|
|
|
|
|
// Mersenne twister functions
|
|
|
|
void SeedMT(uint32 seed);
|
|
|
|
uint32 RandomMT(void);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef MERSENNE_TWISTER
|
|
|
|
static inline uint32 Random(void) { return RandomMT(); }
|
|
|
|
uint RandomRange(uint max);
|
|
|
|
#else
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
#ifdef RANDOM_DEBUG
|
|
|
|
#define Random() DoRandom(__LINE__, __FILE__)
|
2005-01-23 19:02:53 +00:00
|
|
|
uint32 DoRandom(int line, const char *file);
|
2004-12-04 17:54:56 +00:00
|
|
|
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
|
2005-01-23 19:02:53 +00:00
|
|
|
uint DoRandomRange(uint max, int line, const char *file);
|
2004-12-04 17:54:56 +00:00
|
|
|
#else
|
2005-01-22 20:23:18 +00:00
|
|
|
uint32 Random(void);
|
2004-12-04 17:54:56 +00:00
|
|
|
uint RandomRange(uint max);
|
|
|
|
#endif
|
2005-07-15 20:29:06 +00:00
|
|
|
#endif // MERSENNE_TWISTER
|
|
|
|
|
|
|
|
static inline TileIndex RandomTileSeed(uint32 r) { return TILE_MASK(r); }
|
|
|
|
static inline TileIndex RandomTile(void) { return TILE_MASK(Random()); }
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
|
2004-09-13 22:49:11 +00:00
|
|
|
uint InteractiveRandomRange(uint max);
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
/* facedraw.c */
|
|
|
|
void DrawPlayerFace(uint32 face, int color, int x, int y);
|
|
|
|
|
|
|
|
/* texteff.c */
|
2005-01-22 20:23:18 +00:00
|
|
|
void MoveAllTextEffects(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
void AddTextEffect(StringID msg, int x, int y, uint16 duration);
|
2005-01-22 20:23:18 +00:00
|
|
|
void InitTextEffects(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
void DrawTextEffects(DrawPixelInfo *dpi);
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void InitTextMessage(void);
|
|
|
|
void DrawTextMessage(void);
|
2004-12-13 11:17:59 +00:00
|
|
|
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...);
|
2005-01-22 20:23:18 +00:00
|
|
|
void UndrawTextMessage(void);
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
bool AddAnimatedTile(TileIndex tile);
|
|
|
|
void DeleteAnimatedTile(TileIndex tile);
|
2005-01-22 20:23:18 +00:00
|
|
|
void AnimateAnimatedTiles(void);
|
|
|
|
void InitializeAnimatedTiles(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* tunnelbridge_cmd.c */
|
2005-11-14 19:48:04 +00:00
|
|
|
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
|
2004-08-09 17:04:08 +00:00
|
|
|
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
|
|
|
|
int CalcBridgeLenCostFactor(int x);
|
|
|
|
|
|
|
|
/* misc_cmd.c */
|
2005-01-22 20:23:18 +00:00
|
|
|
void PlaceTreesRandomly(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
void InitializeLandscapeVariables(bool only_constants);
|
|
|
|
|
|
|
|
/* misc.c */
|
2006-10-16 10:26:22 +00:00
|
|
|
bool IsCustomName(StringID id);
|
2004-08-09 17:04:08 +00:00
|
|
|
void DeleteName(StringID id);
|
2005-02-06 20:53:31 +00:00
|
|
|
char *GetName(int id, char *buff);
|
2004-12-04 17:54:56 +00:00
|
|
|
|
|
|
|
// AllocateNameUnique also tests if the name used is not used anywere else
|
|
|
|
// and if it is used, it returns an error.
|
|
|
|
#define AllocateNameUnique(name, skip) RealAllocateName(name, skip, true)
|
|
|
|
#define AllocateName(name, skip) RealAllocateName(name, skip, false)
|
2005-02-06 20:53:31 +00:00
|
|
|
StringID RealAllocateName(const char *name, byte skip, bool check_double);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* misc functions */
|
|
|
|
void MarkTileDirty(int x, int y);
|
|
|
|
void MarkTileDirtyByTile(TileIndex tile);
|
2005-12-24 15:01:17 +00:00
|
|
|
void InvalidateWindow(WindowClass cls, WindowNumber number);
|
|
|
|
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
|
|
|
|
void InvalidateWindowClasses(WindowClass cls);
|
2006-10-07 14:30:13 +00:00
|
|
|
void InvalidateWindowClassesData(WindowClass cls);
|
2004-08-09 17:04:08 +00:00
|
|
|
void DeleteWindowById(WindowClass cls, WindowNumber number);
|
2005-01-13 16:50:20 +00:00
|
|
|
void DeleteWindowByClass(WindowClass cls);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-06-06 13:47:06 +00:00
|
|
|
void SetObjectToPlaceWnd(CursorID icon, byte mode, Window *w);
|
|
|
|
void SetObjectToPlace(CursorID icon, byte mode, WindowClass window_class, WindowNumber window_num);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void ResetObjectToPlace(void);
|
2004-09-03 19:59:05 +00:00
|
|
|
|
|
|
|
bool ScrollWindowTo(int x, int y, Window * w);
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
bool ScrollMainWindowToTile(TileIndex tile);
|
|
|
|
bool ScrollMainWindowTo(int x, int y);
|
|
|
|
void DrawSprite(uint32 img, int x, int y);
|
|
|
|
bool EnsureNoVehicle(TileIndex tile);
|
2006-05-09 09:56:09 +00:00
|
|
|
bool EnsureNoVehicleOnGround(TileIndex tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
|
|
|
|
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost);
|
2005-06-15 16:58:15 +00:00
|
|
|
void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
void DrawFoundation(TileInfo *ti, uint f);
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
bool CheckIfAuthorityAllows(TileIndex tile);
|
|
|
|
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
|
2004-08-09 17:04:08 +00:00
|
|
|
void ChangeTownRating(Town *t, int add, int max);
|
|
|
|
|
2006-06-10 08:37:41 +00:00
|
|
|
uint GetTownRadiusGroup(const Town* t, TileIndex tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
int FindFirstBit(uint32 x);
|
2005-01-13 16:28:47 +00:00
|
|
|
void ShowHighscoreTable(int difficulty, int8 rank);
|
2004-08-09 17:04:08 +00:00
|
|
|
TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng);
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void AfterLoadTown(void);
|
2006-03-02 02:22:15 +00:00
|
|
|
void UpdatePatches(void);
|
2005-01-22 20:23:18 +00:00
|
|
|
void AskExitGame(void);
|
|
|
|
void AskExitToGameMenu(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void RedrawAutosave(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
StringID RemapOldStringID(StringID s);
|
|
|
|
|
|
|
|
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str);
|
|
|
|
|
|
|
|
enum {
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
SLD_LOAD_GAME,
|
|
|
|
SLD_LOAD_SCENARIO,
|
|
|
|
SLD_SAVE_GAME,
|
|
|
|
SLD_SAVE_SCENARIO,
|
|
|
|
SLD_LOAD_HEIGHTMAP,
|
|
|
|
SLD_NEW_GAME,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
void ShowSaveLoadDialog(int mode);
|
|
|
|
|
|
|
|
// callback from drivers that is called if the game size changes dynamically
|
2005-01-22 20:23:18 +00:00
|
|
|
void GameSizeChanged(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
bool FileExists(const char *filename);
|
|
|
|
bool ReadLanguagePack(int index);
|
2005-01-22 20:23:18 +00:00
|
|
|
void InitializeLanguagePacks(void);
|
2006-03-25 09:22:10 +00:00
|
|
|
const char *GetCurrentLocale(const char *param);
|
2005-02-06 08:38:09 +00:00
|
|
|
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void LoadFromConfig(void);
|
|
|
|
void SaveToConfig(void);
|
2005-04-13 23:03:31 +00:00
|
|
|
void CheckConfig(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
int ttd_main(int argc, char* argv[]);
|
2006-09-04 17:30:30 +00:00
|
|
|
void HandleExitGameRequest(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void DeterminePaths(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-09-02 16:05:59 +00:00
|
|
|
void CSleep(int milliseconds);
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif /* FUNCTIONS_H */
|