1 /*
2  *
3  *  Iter Vehemens ad Necem (IVAN)
4  *  Copyright (C) Timo Kiviluoto
5  *  Released under the GNU General
6  *  Public License
7  *
8  *  See LICENSING which should be included
9  *  along with this file for more details
10  *
11  */
12 
13 #ifndef __GAME_H__
14 #define __GAME_H__
15 
16 #include <map>
17 #include <vector>
18 #include <ctime>
19 
20 #include "femath.h"
21 #include "festring.h"
22 #include "ivandef.h"
23 
24 #ifndef LIGHT_BORDER
25 #define LIGHT_BORDER 80
26 #endif
27 
28 #define PLAYER game::GetPlayer()
29 
30 class area;
31 class level;
32 class dungeon;
33 class felist;
34 class team;
35 class character;
36 class gamescript;
37 class item;
38 class outputfile;
39 class inputfile;
40 class worldmap;
41 class god;
42 class square;
43 class wsquare;
44 class lsquare;
45 class bitmap;
46 class festring;
47 class rain;
48 class liquid;
49 class entity;
50 class olterrain;
51 struct explosion;
52 class bonesghost;
53 
54 typedef std::map<festring, long> valuemap;
55 typedef truth (*stringkeyhandler)(int, festring&);
56 typedef v2 (*positionkeyhandler)(v2, int);
57 typedef void (*positionhandler)(v2);
58 typedef void (*bitmapeditor)(bitmap*, truth);
59 
60 struct homedata
61 {
62   v2 Pos;
63   int Dungeon;
64   int Level;
65   int Room;
66 };
67 
68 outputfile& operator<<(outputfile&, const homedata*);
69 inputfile& operator>>(inputfile&, homedata*&);
70 
71 #ifdef VC
72 #pragma pack(1)
73 #endif
74 
75 struct configid
76 {
77   configid() = default;
configidconfigid78   configid(int Type, int Config) : Type(Type), Config(Config) { }
79   bool operator<(const configid& CI) const { return memcmp(this, &CI, sizeof(configid)) < 0; }
80   int Type NO_ALIGNMENT;
81   int Config NO_ALIGNMENT;
82 };
83 
84 #ifdef VC
85 #pragma pack()
86 #endif
87 
88 outputfile& operator<<(outputfile&, const configid&);
89 inputfile& operator>>(inputfile&, configid&);
90 
91 struct dangerid
92 {
93   dangerid() = default;
dangeriddangerid94   dangerid(double NakedDanger, double EquippedDanger) : NakedDanger(NakedDanger), EquippedDanger(EquippedDanger) { }
95   double NakedDanger;
96   double EquippedDanger;
97 };
98 
99 outputfile& operator<<(outputfile&, const dangerid&);
100 inputfile& operator>>(inputfile&, dangerid&);
101 
102 struct ivantime
103 {
104   int Day;
105   int Hour;
106   int Min;
107 };
108 
109 struct massacreid
110 {
111   massacreid() = default;
massacreidmassacreid112   massacreid(int Type, int Config, cfestring& Name)
113   : Type(Type), Config(Config), Name(Name) { }
114   bool operator<(const massacreid&) const;
115   int Type;
116   int Config;
117   festring Name;
118 };
119 
120 inline bool massacreid::operator<(const massacreid& MI) const
121 {
122   if(Type != MI.Type)
123     return Type < MI.Type;
124 
125   if(Config != MI.Config)
126     return Config < MI.Config;
127 
128   return Name < MI.Name;
129 }
130 
131 outputfile& operator<<(outputfile&, const massacreid&);
132 inputfile& operator>>(inputfile&, massacreid&);
133 
134 struct killreason
135 {
136   killreason() = default;
killreasonkillreason137   killreason(cfestring& String, int Amount) : String(String), Amount(Amount) { }
138   festring String;
139   int Amount;
140 };
141 
142 outputfile& operator<<(outputfile&, const killreason&);
143 inputfile& operator>>(inputfile&, killreason&);
144 
145 struct killdata
146 {
Amountkilldata147   killdata(int Amount = 0, double DangerSum = 0) : Amount(Amount), DangerSum(DangerSum) { }
148   int Amount;
149   double DangerSum;
150   std::vector<killreason> Reason;
151 };
152 
153 outputfile& operator<<(outputfile&, const killdata&);
154 inputfile& operator>>(inputfile&, killdata&);
155 
156 typedef std::map<configid, dangerid> dangermap;
157 typedef std::map<ulong, character*> characteridmap;
158 typedef std::map<ulong, item*> itemidmap;
159 typedef std::map<ulong, entity*> trapidmap;
160 typedef std::map<massacreid, killdata> massacremap;
161 typedef std::map<ulong, ulong> boneidmap;
162 typedef std::vector<item*> itemvector;
163 typedef std::vector<itemvector> itemvectorvector;
164 typedef std::vector<character*> charactervector;
165 
166 class quitrequest { };
167 class areachangerequest { };
168 
169 typedef void (*dbgdrawoverlay)();
170 
171 #define AUTOSAVE_SUFFIX ".AutoSave"
172 #define CUSTOM_KEYS_FILENAME "CustomCommandKeys.cfg"
173 class game
174 {
175  public:
176   static truth Init(cfestring& = CONST_S(""));
177   static void DeInit();
178   static void Run();
179   static festring SaveName(cfestring& = CONST_S(""),bool = false); //before all calls to this method, made still here on the header file
180   static void PrepareStretchRegionsLazy();
181   static void UpdateSRegionsXBRZ();
182   static void UpdateSRegionsXBRZ(bool bIsXBRZScale);
183   static void RegionSilhouetteEnable(bool b);
184   static void RegionListItemEnable(bool b);
185   static void UpdatePosAroundForXBRZ(v2 ScreenPos);
186   static void SRegionAroundDisable();
187   static void SRegionAroundAllow();
188   static void SRegionAroundDeny();
189   static void PrepareToClearNonVisibleSquaresAround(v2);
190   static void UpdatePlayerOnScreenSBSBlitdata();
191   static truth IsQuestItem(item*);
192   static int GetMoveCommandKey(int);
GetMoveVector(int I)193   static cv2 GetMoveVector(int I) { return MoveVector[I]; }
GetClockwiseMoveVector(int I)194   static cv2 GetClockwiseMoveVector(int I) { return ClockwiseMoveVector[I]; }
GetRelativeMoveVector(int I)195   static cv2 GetRelativeMoveVector(int I) { return RelativeMoveVector[I]; }
GetBasicMoveVector(int I)196   static cv2 GetBasicMoveVector(int I) { return BasicMoveVector[I]; }
GetLargeMoveVector(int I)197   static cv2 GetLargeMoveVector(int I) { return LargeMoveVector[I]; }
GetCurrentArea()198   static area* GetCurrentArea() { return CurrentArea; }
GetCurrentLevel()199   static level* GetCurrentLevel() { return CurrentLevel; }
GetLuxTable()200   static uchar*** GetLuxTable() { return LuxTable; }
GetPlayer()201   static character* GetPlayer() { return Player; }
202   static void SetPlayer(character*);
GetCamera()203   static v2 GetCamera() { return Camera; }
204   static void UpdateCameraX();
205   static void UpdateCameraY();
IsLoading()206   static truth IsLoading() { return Loading; }
SetIsLoading(truth What)207   static void SetIsLoading(truth What) { Loading = What; }
ForceJumpToPlayerBe()208   static truth ForceJumpToPlayerBe() { return JumpToPlayerBe; }
SetForceJumpToPlayerBe(truth What)209   static void SetForceJumpToPlayerBe(truth What) { JumpToPlayerBe = What; }
210   static level* GetLevel(int);
211   static void InitLuxTable();
212   static void DeInitLuxTable();
213   static cchar* Insult();
214   static truth TruthQuestion(cfestring&, int = 0, int = 0);
215   static void DrawEverything();
216   static void UpdateShowItemsAtPos(bool bAllowed,v2 v2AtPos=v2(0,0));
217   static void UpdateAltSilhouette(bool bAllowed);
218   static v2 CalculateStretchedBufferCoordinatesFromDungeonSquarePos(v2 v2SqrPos);
219   static int ItemUnderCode(int iCycleValue);
220   static int ItemUnderCorner(int val);
221   static int ItemUnderZoom(int val);
222   static bool ItemUnderHV(int val);
223   static truth Save(cfestring& = SaveName(CONST_S("")));
224   static int Load(cfestring& = SaveName(CONST_S("")));
225   static int GetCurrentSavefileVersion();
IsRunning()226   static truth IsRunning() { return Running; }
227   static void SetIsRunning(truth What);
228   static void UpdateCameraX(int);
229   static void UpdateCameraY(int);
GetCurrentLevelIndex()230   static int GetCurrentLevelIndex() { return CurrentLevelIndex; }
231   static int GetMoveCommandKeyBetweenPoints(v2, v2);
232   static void DrawEverythingNoBlit(truth = false);
GetGod(int I)233   static god* GetGod(int I) { return God[I]; }
GetAlignment(int I)234   static cchar* GetAlignment(int I) { return Alignment[I]; }
235   static void ApplyDivineTick();
236   static void ApplyDivineAlignmentBonuses(god*, int, truth);
237   static v2 GetDirectionVectorForKey(int);
238   static void ShowLevelMessage();
239   static double GetMinDifficulty();
240   static void TriggerQuestForGoldenEagleShirt();
241   static void CalculateGodNumber();
IncreaseTick()242   static void IncreaseTick() { ++Tick; }
GetTick()243   static ulong GetTick() { return Tick; }
GetAutoSaveFileName()244   static festring GetAutoSaveFileName() { return SaveName() + AUTOSAVE_SUFFIX; }
245   static int DirectionQuestion(cfestring&, truth = true, truth = false, int = 0, int = -1);
246   static void RemoveSaves(truth = true,truth onlyBackups=false);
IsInWilderness()247   static truth IsInWilderness() { return InWilderness; }
SetIsInWilderness(truth What)248   static void SetIsInWilderness(truth What) { InWilderness = What; }
GetWorldMap()249   static worldmap* GetWorldMap() { return WorldMap; }
SetAreaInLoad(area * What)250   static void SetAreaInLoad(area* What) { AreaInLoad = What; }
SetSquareInLoad(square * What)251   static void SetSquareInLoad(square* What) { SquareInLoad = What; }
GetAreaInLoad()252   static area* GetAreaInLoad() { return AreaInLoad; }
GetSquareInLoad()253   static square* GetSquareInLoad() { return SquareInLoad; }
254   static int GetLevels();
GetCurrentDungeon()255   static dungeon* GetCurrentDungeon() { return Dungeon[CurrentDungeonIndex]; }
GetDungeon(int I)256   static dungeon* GetDungeon(int I) { return Dungeon[I]; }
GetCurrentDungeonIndex()257   static int GetCurrentDungeonIndex() { return CurrentDungeonIndex; }
258   static void InitDungeons();
259   static truth OnScreen(v2);
260   static void DoEvilDeed(int);
261   static void SaveWorldMap(cfestring& = SaveName(CONST_S("")), truth = true);
262   static worldmap* LoadWorldMap(cfestring& = SaveName(CONST_S("")));
263   static void UpdateCamera();
264   static ulong CreateNewCharacterID(character*);
265   static ulong CreateNewItemID(item*);
266   static ulong CreateNewTrapID(entity*);
GetTeam(int I)267   static team* GetTeam(int I) { return Team[I]; }
GetTeams()268   static int GetTeams() { return Teams; }
269   static void Hostility(team*, team*);
270   static void CreateTeams();
271   static int StringQuestion(festring&, cfestring&, col16, festring::sizetype, festring::sizetype, truth, stringkeyhandler = 0);
272   static long NumberQuestion(cfestring&, int, truth = false);
273   static ulong IncreaseLOSTick();
GetLOSTick()274   static ulong GetLOSTick() { return LOSTick; }
SendLOSUpdateRequest()275   static void SendLOSUpdateRequest() { LOSUpdateRequested = true; }
RemoveLOSUpdateRequest()276   static void RemoveLOSUpdateRequest() { LOSUpdateRequested = false; }
GetPetrus()277   static character* GetPetrus() { return Petrus; }
SetPetrus(character * What)278   static void SetPetrus(character* What) { Petrus = What; }
279   static truth HandleQuitMessage();
280   static int GetDirectionForVector(v2);
281   static int GetPlayerAlignment();
282   static cchar* GetVerbalPlayerAlignment();
283   static void CreateGods();
284   static int GetScreenXSize();
285   static int GetScreenYSize();
286   static int GetMaxScreenXSize();
287   static int GetMaxScreenYSize();
288   static v2 CalculateScreenCoordinates(v2);
289   static void BusyAnimation();
290   static void BusyAnimation(bitmap*, truth);
291   static v2 PositionQuestion(cfestring&, v2, positionhandler = 0, positionkeyhandler = 0, truth = true);
292   static void LookHandler(v2);
293   static int AskForKeyPress(cfestring&);
294   static bool IsQuestionMode();
295   static truth AnimationController();
GetGameScript()296   static gamescript* GetGameScript() { return GameScript; }
297   static void InitScript();
GetGlobalValueMap()298   static valuemap& GetGlobalValueMap() { return GlobalValueMap; }
299   static void InitGlobalValueMap();
300   static void TextScreen(cfestring&, v2 = ZERO_V2, col16 = 0xFFFF, truth = true, truth = true, bitmapeditor = 0);
SetCursorPos(v2 What)301   static void SetCursorPos(v2 What) { CursorPos = What; }
DoZoom()302   static truth DoZoom() { return Zoom; }
SetDoZoom(truth What)303   static void SetDoZoom(truth What) { Zoom = What; }
304   static int KeyQuestion(cfestring&, int, int, ...);
305   static v2 LookKeyHandler(v2, int);
306   static v2 NameKeyHandler(v2, int);
307   static void End(festring, truth = true, truth = true);
308   static int CalculateRoughDirection(v2);
309   static long ScrollBarQuestion(cfestring&, long, long, long, long, long, col16, col16, col16, void (*)(long) = 0);
IsGenerating()310   static truth IsGenerating() { return Generating; }
SetIsGenerating(truth What)311   static void SetIsGenerating(truth What) { Generating = What; }
312   static void CalculateNextDanger();
313   static int Menu(std::vector<bitmap*> v, v2, cfestring&, cfestring&, col16, cfestring& = CONST_S(""), cfestring& = CONST_S(""));
314   static void InitDangerMap();
315   static const dangermap& GetDangerMap();
316   static truth TryTravel(int, int, int, truth = false, truth = true);
317   static truth LeaveArea(charactervector&, truth, truth);
318   static void EnterArea(charactervector&, int, int);
319   static int CompareLights(col24, col24);
320   static int CompareLightToInt(col24, col24);
321   static void CombineLights(col24&, col24);
322   static col24 CombineConstLights(col24, col24);
323   static truth IsDark(col24);
324   static void SetStandardListAttributes(felist&);
GetAveragePlayerArmStrengthExperience()325   static double GetAveragePlayerArmStrengthExperience() { return AveragePlayerArmStrengthExperience; }
GetAveragePlayerLegStrengthExperience()326   static double GetAveragePlayerLegStrengthExperience() { return AveragePlayerLegStrengthExperience; }
GetAveragePlayerDexterityExperience()327   static double GetAveragePlayerDexterityExperience() { return AveragePlayerDexterityExperience; }
GetAveragePlayerAgilityExperience()328   static double GetAveragePlayerAgilityExperience() { return AveragePlayerAgilityExperience; }
329   static void InitPlayerAttributeAverage();
330   static void UpdatePlayerAttributeAverage();
331   static void CallForAttention(v2, int);
332   static character* SearchCharacter(ulong);
333   static std::vector<character*> GetAllCharacters();
334   static characteridmap GetCharacterIDMapCopy();
335   static std::vector<item*> GetAllItems();
336   static itemidmap GetItemIDMapCopy();
337   static item* SearchItem(ulong);
338   static entity* SearchTrap(ulong);
339   static void AddCharacterID(character*, ulong);
340   static void RemoveCharacterID(ulong);
341   static void AddItemID(item*, ulong);
342   static void RemoveItemID(ulong);
343   static void UpdateItemID(item*, ulong);
344   static void AddTrapID(entity*, ulong);
345   static void RemoveTrapID(ulong);
346   static void UpdateTrapID(entity*, ulong);
GetStoryState()347   static int GetStoryState() { return StoryState; }
SetStoryState(int What)348   static void SetStoryState(int What) { StoryState = What; }
GetGloomyCaveStoryState()349   static int GetGloomyCaveStoryState() { return GloomyCaveStoryState; }
SetGloomyCaveStoryState(int What)350   static void SetGloomyCaveStoryState(int What) { GloomyCaveStoryState = What; }
GetXinrochTombStoryState()351   static int GetXinrochTombStoryState() { return XinrochTombStoryState; }
SetXinrochTombStoryState(int What)352   static void SetXinrochTombStoryState(int What) { XinrochTombStoryState = What; }
GetFreedomStoryState()353   static int GetFreedomStoryState() { return FreedomStoryState; }
SetFreedomStoryState(int What)354   static void SetFreedomStoryState(int What) { FreedomStoryState = What; }
GetAslonaStoryState()355   static int GetAslonaStoryState() { return AslonaStoryState; }
SetAslonaStoryState(int What)356   static void SetAslonaStoryState(int What) { AslonaStoryState = What; }
GetRebelStoryState()357   static int GetRebelStoryState() { return RebelStoryState; }
SetRebelStoryState(int What)358   static void SetRebelStoryState(int What) { RebelStoryState = What; }
PlayerIsGodChampion()359   static truth PlayerIsGodChampion() { return PlayerIsChampion; }
MakePlayerGodChampion()360   static void MakePlayerGodChampion() { PlayerIsChampion = true; } // No way to switch that back, only one championship per game.
PlayerHasBoat()361   static truth PlayerHasBoat() { return HasBoat; }
GivePlayerBoat()362   static void GivePlayerBoat() { HasBoat = true; }
SetIsInGetCommand(truth What)363   static void SetIsInGetCommand(truth What) { InGetCommand = What; }
IsInGetCommand()364   static truth IsInGetCommand() { return InGetCommand; }
365   static festring GetDataDir();
366   static festring GetSaveDir();
367   static festring GetScrshotDir();
368   static festring GetBoneDir();
369   static festring GetMusicDir();
PlayerWasHurtByExplosion()370   static truth PlayerWasHurtByExplosion() { return PlayerHurtByExplosion; }
SetPlayerWasHurtByExplosion(truth What)371   static void SetPlayerWasHurtByExplosion(truth What) { PlayerHurtByExplosion = What; }
SetCurrentArea(area * What)372   static void SetCurrentArea(area* What) { CurrentArea = What; }
SetCurrentLevel(level * What)373   static void SetCurrentLevel(level* What) { CurrentLevel = What; }
SetCurrentWSquareMap(wsquare *** What)374   static void SetCurrentWSquareMap(wsquare*** What) { CurrentWSquareMap = What; }
SetCurrentLSquareMap(lsquare *** What)375   static void SetCurrentLSquareMap(lsquare*** What) { CurrentLSquareMap = What; }
GetDefaultPolymorphTo()376   static festring& GetDefaultPolymorphTo() { return DefaultPolymorphTo; }
GetDefaultSummonMonster()377   static festring& GetDefaultSummonMonster() { return DefaultSummonMonster; }
GetDefaultChangeMaterial()378   static festring& GetDefaultChangeMaterial() { return DefaultChangeMaterial; }
GetDefaultDetectMaterial()379   static festring& GetDefaultDetectMaterial() { return DefaultDetectMaterial; }
380   static void SignalDeath(ccharacter*, ccharacter*, festring);
381   static void DisplayMassacreLists();
382   static void DisplayMassacreList(const massacremap&, cchar*, long);
383   static truth MassacreListsEmpty();
384   static void PlayVictoryMusic();
385   static void PlayDefeatMusic();
386   static void SetMapNote(lsquare* lsqrN,festring What);
387   static bool ToggleDrawMapOverlay();
388   static void SetDrawMapOverlay(bool b);
389   static void RefreshDrawMapOverlay();
390   static void DrawMapOverlay(bitmap* =NULL);
391   static void DrawMapNotesOverlay(bitmap* =NULL);
392   static lsquare* GetHighlightedMapNoteLSquare();
393   static bool ToggleShowMapNotes();
394   static bool CheckAddAutoMapNote(square* =NULL);
395   static int CheckAutoPickup(square* sqr = NULL);
396   static void UpdateAutoPickUpMatching();
397   static int RotateMapNotes();
398   static char MapNoteToken();
399   static bool IsAutoPickupMatch(cfestring fsName);
400 
401 #ifdef WIZARD
ActivateWizardMode()402   static void ActivateWizardMode() { WizardMode = true; }
WizardModeIsActive()403   static truth WizardModeIsActive() { return WizardMode; }
404   static void IncAutoPlayMode();
GetAutoPlayMode()405   static int GetAutoPlayMode() { return AutoPlayMode; }
406   static void AutoPlayModeApply();
DisableAutoPlayMode()407   static void DisableAutoPlayMode() {AutoPlayMode=0;AutoPlayModeApply();}
408   static void SeeWholeMap();
GetSeeWholeMapCheatMode()409   static int GetSeeWholeMapCheatMode() { return SeeWholeMapCheatMode; }
GoThroughWallsCheatIsActive()410   static truth GoThroughWallsCheatIsActive() { return GoThroughWallsCheat; }
GoThroughWalls()411   static void GoThroughWalls() { GoThroughWallsCheat = !GoThroughWallsCheat; }
412 #else
WizardModeIsActive()413   static truth WizardModeIsActive() { return false; }
GetSeeWholeMapCheatMode()414   static int GetSeeWholeMapCheatMode() { return 0; }
GoThroughWallsCheatIsActive()415   static truth GoThroughWallsCheatIsActive() { return false; }
GetAutoPlayMode()416   static int GetAutoPlayMode() { return 0; }
417 #endif
418 
WizardModeIsReallyActive()419   static truth WizardModeIsReallyActive() { return WizardMode; }
420   static void CreateBone();
GetQuestMonstersFound()421   static int GetQuestMonstersFound() { return QuestMonstersFound; }
SignalQuestMonsterFound()422   static void SignalQuestMonsterFound() { ++QuestMonstersFound; }
SetQuestMonstersFound(int What)423   static void SetQuestMonstersFound(int What) { QuestMonstersFound = What; }
424   static truth PrepareRandomBone(int);
GetBoneItemIDMap()425   static boneidmap& GetBoneItemIDMap() { return BoneItemIDMap; }
GetBoneCharacterIDMap()426   static boneidmap& GetBoneCharacterIDMap() { return BoneCharacterIDMap; }
427   static double CalculateAverageDanger(const charactervector&, character*);
428   static double CalculateAverageDangerOfAllNormalEnemies();
429   static bonesghost* CreateGhost();
TooGreatDangerFound()430   static truth TooGreatDangerFound() { return TooGreatDangerFoundTruth; }
SetTooGreatDangerFound(truth What)431   static void SetTooGreatDangerFound(truth What) { TooGreatDangerFoundTruth = What; }
432   static void CreateBusyAnimationCache();
433   static long GetScore();
434   static truth TweraifIsFree();
435   static truth IsXMas();
436   static int AddToItemDrawVector(const itemvector&);
437   static void ClearItemDrawVector();
438   static void ItemEntryDrawer(bitmap*, v2, uint);
439   static int AddToCharacterDrawVector(character*);
440   static void ClearCharacterDrawVector();
441   static void CharacterEntryDrawer(bitmap*, v2, uint);
442   static void GodEntryDrawer(bitmap*, v2, uint);
GetItemDrawVector()443   static itemvectorvector& GetItemDrawVector() { return ItemDrawVector; }
GetCharacterDrawVector()444   static charactervector& GetCharacterDrawVector() { return CharacterDrawVector; }
IsSumoWrestling()445   static truth IsSumoWrestling() { return SumoWrestling; }
SetIsSumoWrestling(truth What)446   static void SetIsSumoWrestling(truth What) { SumoWrestling = What; }
AllowHostilities()447   static truth AllowHostilities() { return !SumoWrestling; }
AllBodyPartsVanish()448   static truth AllBodyPartsVanish() { return SumoWrestling; }
449   static truth TryToEnterSumoArena();
450   static truth TryToExitSumoArena();
451   static truth EndSumoWrestling(int);
452   static character* GetSumo();
GetPlayerName()453   static cfestring& GetPlayerName() { return PlayerName; }
454   static rain* ConstructGlobalRain();
SetGlobalRainLiquid(liquid * What)455   static void SetGlobalRainLiquid(liquid* What) { GlobalRainLiquid = What; }
SetGlobalRainSpeed(v2 What)456   static void SetGlobalRainSpeed(v2 What) { GlobalRainSpeed = What; }
PlayerIsSumoChampion()457   static truth PlayerIsSumoChampion() { return PlayerSumoChampion; }
ChildTouristHasSpider()458   static truth ChildTouristHasSpider() { return TouristHasSpider; }
SetTouristHasSpider()459   static void SetTouristHasSpider() { TouristHasSpider = true; }
460   static v2 GetSunLightDirectionVector();
461   static int CalculateMinimumEmitationRadius(col24);
462   static ulong IncreaseSquarePartEmitationTicks();
GetLargeMoveDirection(int I)463   static cint GetLargeMoveDirection(int I) { return LargeMoveDirection[I]; }
464   static int Wish(character*, cchar*, cchar*, truth);
465   static int DefaultQuestion(festring&, festring, festring&, truth, stringkeyhandler = 0);
466   static void GetTime(ivantime&);
GetTurn()467   static long GetTurn() { return Turn; }
IncreaseTurn()468   static void IncreaseTurn() { ++Turn; ++iCurrentDungeonTurn; }
GetTotalMinutes()469   static int GetTotalMinutes() { return Tick * 60 / 2000; }
470   static truth PolymorphControlKeyHandler(int, festring&);
GetEquipmentMemory()471   static ulong* GetEquipmentMemory() { return EquipmentMemory; }
472   static truth PlayerIsRunning();
SetPlayerIsRunning(truth What)473   static void SetPlayerIsRunning(truth What) { PlayerRunning = What; }
474   static truth FillPetVector(cchar*);
475   static truth CommandQuestion();
476   static void NameQuestion();
477   static v2 CommandKeyHandler(v2, int);
478   static void CommandScreen(cfestring&, ulong, ulong, ulong&, ulong&);
479   static truth CommandAll();
GetDangerFound()480   static double GetDangerFound() { return DangerFound; }
SetDangerFound(double What)481   static void SetDangerFound(double What) { DangerFound = What; }
482   static col16 GetAttributeColor(int);
483   static void UpdateAttributeMemory();
484   static void InitAttributeMemory();
485   static void TeleportHandler(v2);
486   static void PetHandler(v2);
487   static truth SelectPet(int);
488   static double GetGameSituationDanger();
GetMonsterPortal()489   static olterrain* GetMonsterPortal() { return MonsterPortal; }
SetMonsterPortal(olterrain * What)490   static void SetMonsterPortal(olterrain* What) { MonsterPortal = What; }
GetCausePanicFlag()491   static truth GetCausePanicFlag() { return CausePanicFlag; }
SetCausePanicFlag(truth What)492   static void SetCausePanicFlag(truth What) { CausePanicFlag = What; }
493   static long GetTimeSpent();
494   static void AddSpecialCursor(v2, int);
495   static void RemoveSpecialCursors();
496   static void LearnAbout(god*);
497   static truth PlayerKnowsAllGods();
498   static void AdjustRelationsToAllGods(int);
499   static void SetRelationsToAllGods(int);
500   static void ShowDeathSmiley(bitmap*, truth);
SetEnterImage(cbitmap * What)501   static void SetEnterImage(cbitmap* What) { EnterImage = What; }
SetEnterTextDisplacement(v2 What)502   static void SetEnterTextDisplacement(v2 What){ EnterTextDisplacement = What; }
getDefaultItemsListWidth()503   static int getDefaultItemsListWidth(){ return iListWidth; }
AddDebugDrawOverlayFunction(dbgdrawoverlay ddo)504   static void AddDebugDrawOverlayFunction(dbgdrawoverlay ddo){vDbgDrawOverlayFunctions.push_back(ddo);}
GetCurrentDungeonTurnsCount()505   static int GetCurrentDungeonTurnsCount(){return iCurrentDungeonTurn;}
506   static int GetSaveFileVersionHardcoded();
507   static void ValidateCommandKeys(char Key1,char Key2,char Key3);
508   static truth ConfigureCustomKeys();
509   static festring ToCharIfPossible(int i);
510   static truth ValidateCustomCmdKey(int iNewKey, int iIgnoreIndex, bool bMoveKeys);
511   static festring GetMoveKeyDesc(int i);
512   static void LoadCustomCommandKeys();
GetWorldShape()513   static int GetWorldShape() { return WorldShape; }
SetWorldShape(int What)514   static void SetWorldShape(int What) { WorldShape = What; }
515  private:
516   static void UpdateCameraCoordinate(int&, int, int, int);
517   static cchar* const Alignment[];
518   static god** God;
519   static int CurrentLevelIndex;
520   static int CurrentDungeonIndex;
521   static cint MoveNormalCommandKey[];
522   static cint MoveAbnormalCommandKey[];
523   static cint MoveNetHackCommandKey[];
524   static int  MoveCustomCommandKey[];
525   static cv2 MoveVector[];
526   static cv2 ClockwiseMoveVector[];
527   static cv2 RelativeMoveVector[];
528   static cv2 BasicMoveVector[];
529   static cv2 LargeMoveVector[];
530   static uchar*** LuxTable;
531   static truth Running;
532   static character* Player;
533   static v2 Camera;
534   static ulong Tick;
535   static truth InWilderness;
536   static worldmap* WorldMap;
537   static area* AreaInLoad;
538   static square* SquareInLoad;
539   static dungeon** Dungeon;
540   static ulong NextCharacterID;
541   static ulong NextItemID;
542   static ulong NextTrapID;
543   static team** Team;
544   static ulong LOSTick;
545   static truth LOSUpdateRequested;
546   static character* Petrus;
547   static truth Loading;
548   static truth JumpToPlayerBe;
549   static gamescript* GameScript;
550   static valuemap GlobalValueMap;
551   static v2 CursorPos;
552   static truth Zoom;
553   static truth Generating;
554   static dangermap DangerMap;
555   static int NextDangerIDType;
556   static int NextDangerIDConfigIndex;
557   static double AveragePlayerArmStrengthExperience;
558   static double AveragePlayerLegStrengthExperience;
559   static double AveragePlayerDexterityExperience;
560   static double AveragePlayerAgilityExperience;
561   static characteridmap CharacterIDMap;
562   static itemidmap ItemIDMap;
563   static trapidmap TrapIDMap;
564   static int Teams;
565   static int Dungeons;
566   static int StoryState;
567   static int GloomyCaveStoryState;
568   static int XinrochTombStoryState;
569   static int FreedomStoryState;
570   static int AslonaStoryState;
571   static int RebelStoryState;
572   static truth InGetCommand;
573   static truth PlayerHurtByExplosion;
574   static area* CurrentArea;
575   static level* CurrentLevel;
576   static wsquare*** CurrentWSquareMap;
577   static lsquare*** CurrentLSquareMap;
578   static festring DefaultPolymorphTo;
579   static festring DefaultSummonMonster;
580   static festring DefaultWish;
581   static festring DefaultChangeMaterial;
582   static festring DefaultDetectMaterial;
583   static massacremap PlayerMassacreMap;
584   static massacremap PetMassacreMap;
585   static massacremap MiscMassacreMap;
586   static long PlayerMassacreAmount;
587   static long PetMassacreAmount;
588   static long MiscMassacreAmount;
589   static truth WizardMode;
590   static int AutoPlayMode;
591   static int SeeWholeMapCheatMode;
592   static truth GoThroughWallsCheat;
593   static int QuestMonstersFound;
594   static boneidmap BoneItemIDMap;
595   static boneidmap BoneCharacterIDMap;
596   static truth TooGreatDangerFoundTruth;
597   static bitmap* BusyAnimationCache[32];
598   static itemvectorvector ItemDrawVector;
599   static charactervector CharacterDrawVector;
600   static truth SumoWrestling;
601   static festring PlayerName;
602   static festring CurrentBaseSaveFileName;
603   static liquid* GlobalRainLiquid;
604   static v2 GlobalRainSpeed;
605   static long GlobalRainTimeModifier;
606   static truth PlayerSumoChampion;
607   static truth PlayerIsChampion; // This marks the player as a champion of some god.
608   static truth HasBoat; // Whether the player can sail the oceans of world map.
609   static truth TouristHasSpider;
610   static ulong SquarePartEmitationTick;
611   static cint LargeMoveDirection[];
612   static long Turn;
613   static ulong EquipmentMemory[MAX_EQUIPMENT_SLOTS];
614   static truth PlayerRunning;
615   static character* LastPetUnderCursor;
616   static charactervector PetVector;
617   static double DangerFound;
618   static int OldAttribute[ATTRIBUTES];
619   static int NewAttribute[ATTRIBUTES];
620   static int LastAttributeChangeTick[ATTRIBUTES];
621   static int NecroCounter;
622   static int CursorData;
623   static olterrain* MonsterPortal;
624   static truth CausePanicFlag;
625   static time_t TimePlayedBeforeLastLoad;
626   static time_t LastLoad;
627   static time_t GameBegan;
628   static std::vector<v2> SpecialCursorPos;
629   static std::vector<int> SpecialCursorData;
630   static truth PlayerHasReceivedAllGodsKnownBonus;
631   static cbitmap* EnterImage;
632   static v2 EnterTextDisplacement;
633   static blitdata bldAroundOnScreenTMP;
634   const static int iListWidth = 652;
635   static std::vector<dbgdrawoverlay> vDbgDrawOverlayFunctions;
636   static int iCurrentDungeonTurn;
637   static int WorldShape;
638 };
639 
CombineLights(col24 & L1,col24 L2)640 inline void game::CombineLights(col24& L1, col24 L2)
641 {
642   if(L2)
643   {
644     if(L1)
645     {
646       long Red1 = L1 & 0xFF0000, Red2 = L2 & 0xFF0000;
647       long New = Red1 >= Red2 ? Red1 : Red2;
648       long Green1 = L1 & 0xFF00, Green2 = L2 & 0xFF00;
649       New |= Green1 >= Green2 ? Green1 : Green2;
650       long Blue1 = L1 & 0xFF, Blue2 = L2 & 0xFF;
651       L1 = Blue1 >= Blue2 ? New | Blue1 : New | Blue2;
652     }
653     else
654       L1 = L2;
655   }
656 }
657 
CombineConstLights(col24 L1,col24 L2)658 inline col24 game::CombineConstLights(col24 L1, col24 L2)
659 {
660   CombineLights(L1, L2);
661   return L1;
662 }
663 
IsDark(col24 Light)664 inline truth game::IsDark(col24 Light)
665 {
666   return !Light
667     || ((Light & 0xFF0000) < (LIGHT_BORDER << 16)
668         && (Light & 0x00FF00) < (LIGHT_BORDER << 8)
669         && (Light & 0x0000FF) < LIGHT_BORDER);
670 }
671 
CompareLights(col24 L1,col24 L2)672 inline int game::CompareLights(col24 L1, col24 L2)
673 {
674   if(L1)
675   {
676     if((L1 & 0xFF0000) > (L2 & 0xFF0000)
677        || (L1 & 0x00FF00) > (L2 & 0x00FF00)
678        || (L1 & 0x0000FF) > (L2 & 0x0000FF))
679       return 1;
680     else if((L1 & 0xFF0000) == (L2 & 0xFF0000)
681             || (L1 & 0x00FF00) == (L2 & 0x00FF00)
682             || (L1 & 0x0000FF) == (L2 & 0x0000FF))
683       return 0;
684     else
685       return -1;
686   }
687   else
688     return -int(!!L2);
689 }
690 
CalculateScreenCoordinates(v2 Pos)691 inline v2 game::CalculateScreenCoordinates(v2 Pos)
692 {
693   return v2((Pos.X - Camera.X + 1) << 4, (Pos.Y - Camera.Y + 2) << 4);
694 }
695 
696 #endif
697