2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/** @file functions.h */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef FUNCTIONS_H
|
|
|
|
#define FUNCTIONS_H
|
|
|
|
|
2007-01-13 14:43:46 +00:00
|
|
|
#include "gfx.h"
|
|
|
|
|
2005-02-17 10:56:19 +00:00
|
|
|
void UpdateTownMaxPass(Town *t);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* clear_land.cpp */
|
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
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* water_land.cpp */
|
2004-08-09 17:04:08 +00:00
|
|
|
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
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* players.cpp */
|
2007-06-18 10:48:15 +00:00
|
|
|
bool CheckPlayerHasMoney(CommandCost cost);
|
|
|
|
void SubtractMoneyFromPlayer(CommandCost cost);
|
|
|
|
void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost 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);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* standard */
|
|
|
|
void ShowInfo(const char *str);
|
|
|
|
void CDECL ShowInfoF(const char *str, ...);
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* openttd.cpp */
|
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);
|
2007-03-07 11:47:46 +00:00
|
|
|
uint32 RandomMT();
|
2005-07-15 20:29:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef MERSENNE_TWISTER
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline uint32 Random() { return RandomMT(); }
|
2005-07-15 20:29:06 +00:00
|
|
|
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
|
2007-03-07 11:47:46 +00:00
|
|
|
uint32 Random();
|
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); }
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline TileIndex RandomTile() { return TILE_MASK(Random()); }
|
2005-07-15 20:29:06 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
uint32 InteractiveRandom(); // 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);
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* texteff.cpp */
|
2007-10-08 19:56:21 +00:00
|
|
|
void AddAnimatedTile(TileIndex tile);
|
2005-06-24 12:38:35 +00:00
|
|
|
void DeleteAnimatedTile(TileIndex tile);
|
2007-03-07 11:47:46 +00:00
|
|
|
void AnimateAnimatedTiles();
|
|
|
|
void InitializeAnimatedTiles();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* tunnelbridge_cmd.cpp */
|
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);
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* misc_cmd.cpp */
|
2007-03-07 11:47:46 +00:00
|
|
|
void PlaceTreesRandomly();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
void InitializeLandscapeVariables(bool only_constants);
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* misc.cpp */
|
2006-10-16 10:26:22 +00:00
|
|
|
bool IsCustomName(StringID id);
|
2004-08-09 17:04:08 +00:00
|
|
|
void DeleteName(StringID id);
|
2007-07-24 17:01:23 +00:00
|
|
|
char *GetName(char *buff, StringID id, const char *last);
|
2004-12-04 17:54:56 +00:00
|
|
|
|
|
|
|
#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);
|
2007-03-07 11:47:46 +00:00
|
|
|
void ConvertNameArray();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* misc functions */
|
2007-09-09 10:13:17 +00:00
|
|
|
/**
|
|
|
|
* Mark a tile given by its coordinate dirty for repaint.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2004-08-09 17:04:08 +00:00
|
|
|
void MarkTileDirty(int x, int y);
|
2007-09-09 10:13:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark a tile given by its index dirty for repaint.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2004-08-09 17:04:08 +00:00
|
|
|
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
|
|
|
|
2007-01-14 19:57:49 +00:00
|
|
|
void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, byte mode, Window *w);
|
|
|
|
void SetObjectToPlace(CursorID icon, SpriteID pal, byte mode, WindowClass window_class, WindowNumber window_num);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ResetObjectToPlace();
|
2004-09-03 19:59:05 +00:00
|
|
|
|
2007-07-24 17:01:23 +00:00
|
|
|
bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
|
2004-09-03 19:59:05 +00:00
|
|
|
|
2007-05-28 16:46:16 +00:00
|
|
|
bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
|
|
|
|
bool ScrollMainWindowTo(int x, int y, bool instant = false);
|
2006-05-09 09:56:09 +00:00
|
|
|
bool EnsureNoVehicleOnGround(TileIndex tile);
|
2007-09-09 10:13:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark all viewports dirty for repaint.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2004-08-09 17:04:08 +00:00
|
|
|
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
|
2007-06-21 14:32:27 +00:00
|
|
|
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost);
|
|
|
|
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
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);
|
2005-01-13 16:28:47 +00:00
|
|
|
void ShowHighscoreTable(int difficulty, int8 rank);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-06-12 22:13:49 +00:00
|
|
|
int FindFirstBit(uint32 x);
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void AfterLoadTown();
|
|
|
|
void UpdatePatches();
|
|
|
|
void AskExitGame();
|
|
|
|
void AskExitToGameMenu();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void RedrawAutosave();
|
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);
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
/* callback from drivers that is called if the game size changes dynamically */
|
2007-03-07 11:47:46 +00:00
|
|
|
void GameSizeChanged();
|
2004-08-09 17:04:08 +00:00
|
|
|
bool FileExists(const char *filename);
|
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
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void LoadFromConfig();
|
|
|
|
void SaveToConfig();
|
|
|
|
void CheckConfig();
|
2004-08-09 17:04:08 +00:00
|
|
|
int ttd_main(int argc, char* argv[]);
|
2007-03-07 11:47:46 +00:00
|
|
|
void HandleExitGameRequest();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
#endif /* FUNCTIONS_H */
|