data dirs renamed
[k8-i-v-a-n.git] / src / game / game.h
blobf4bd434b6fba1b49f19563c1f6a3c8dcc52b6238
1 /*
3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
6 * Public License
8 * See LICENSING which should be included
9 * along with this file for more details
13 #ifndef __GAME_H__
14 #define __GAME_H__
16 #include "ivancommon.h"
18 #include <ctime>
19 #include <map>
20 #include <stack>
21 #include <vector>
23 #include "femath.h"
24 #include "festring.h"
25 #include "ivandef.h"
28 #ifndef LIGHT_BORDER
29 # define LIGHT_BORDER 80
30 #endif
32 #define PLAYER game::GetPlayer()
35 class area;
36 class level;
37 class dungeon;
38 class felist;
39 class team;
40 class character;
41 class gamescript;
42 class item;
43 class outputfile;
44 class inputfile;
45 class worldmap;
46 class god;
47 class square;
48 class wsquare;
49 class lsquare;
50 class bitmap;
51 class festring;
52 class rain;
53 class liquid;
54 class entity;
55 class olterrain;
56 struct explosion;
58 typedef std::map<festring, sLong> valuemap;
59 typedef truth (*stringkeyhandler)(int, festring&);
60 typedef v2 (*positionkeyhandler)(v2, int);
61 typedef void (*positionhandler)(v2);
62 typedef void (*bitmapeditor)(bitmap*, truth);
65 struct homedata {
66 v2 Pos;
67 int Dungeon;
68 int Level;
69 int Room;
72 outputfile& operator<<(outputfile&, const homedata*);
73 inputfile& operator>>(inputfile&, homedata*&);
76 struct configid {
77 configid () {}
78 configid (int Type, int Config) : Type(Type), Config(Config) {}
79 bool operator < (const configid& CI) const { return memcmp(this, &CI, sizeof(configid)) < 0; }
81 int Type NO_ALIGNMENT;
82 int Config NO_ALIGNMENT;
85 outputfile& operator<<(outputfile&, const configid&);
86 inputfile& operator>>(inputfile&, configid&);
89 struct dangerid {
90 dangerid () : NakedDanger(0), EquippedDanger(0) {}
91 dangerid (double NakedDanger, double EquippedDanger) : NakedDanger(NakedDanger), EquippedDanger(EquippedDanger) {}
92 double NakedDanger;
93 double EquippedDanger;
96 outputfile& operator<<(outputfile&, const dangerid&);
97 inputfile& operator>>(inputfile&, dangerid&);
100 struct ivantime {
101 int Day;
102 int Hour;
103 int Min;
107 struct massacreid {
108 massacreid () {}
109 massacreid (int Type, int Config, cfestring &Name) : Type(Type), Config(Config), Name(Name) { }
110 bool operator < (const massacreid &) const;
112 int Type;
113 int Config;
114 festring Name;
117 inline bool massacreid::operator<(const massacreid& MI) const
119 if(Type != MI.Type)
120 return Type < MI.Type;
122 if(Config != MI.Config)
123 return Config < MI.Config;
125 return Name < MI.Name;
128 outputfile& operator<<(outputfile&, const massacreid&);
129 inputfile& operator>>(inputfile&, massacreid&);
132 struct killreason {
133 killreason () {}
134 killreason (cfestring &String, int Amount) : String(String), Amount(Amount) {}
136 festring String;
137 int Amount;
140 outputfile& operator<<(outputfile&, const killreason&);
141 inputfile& operator>>(inputfile&, killreason&);
144 struct killdata {
145 killdata (int Amount=0, double DangerSum=0) : Amount(Amount), DangerSum(DangerSum) {}
147 int Amount;
148 double DangerSum;
149 std::vector<killreason> Reason;
152 outputfile& operator<<(outputfile&, const killdata&);
153 inputfile& operator>>(inputfile&, killdata&);
156 typedef std::map<configid, dangerid> dangermap;
157 typedef std::map<feuLong, character*> characteridmap;
158 typedef std::map<feuLong, item*> itemidmap;
159 typedef std::map<feuLong, entity*> trapidmap;
160 typedef std::map<massacreid, killdata> massacremap;
161 typedef std::map<feuLong, feuLong> boneidmap;
162 typedef std::vector<item*> itemvector;
163 typedef std::vector<itemvector> itemvectorvector;
164 typedef std::vector<character*> charactervector;
167 class quitrequest {};
168 class areachangerequest {};
171 enum ArgTypes {
172 FARG_UNDEFINED,
173 FARG_STRING,
174 FARG_NUMBER
177 struct FuncArg {
178 FuncArg () : type(FARG_UNDEFINED), sval(""), ival(0) {}
179 FuncArg (cfestring &aVal) : type(FARG_STRING), sval(aVal), ival(0) {}
180 FuncArg (sLong aVal) : type(FARG_NUMBER), sval(""), ival(aVal) {}
182 ArgTypes type;
183 festring sval;
184 sLong ival;
188 class game {
189 public:
190 static void InitPlaces ();
191 static truth Init(cfestring& = CONST_S(""));
192 static void DeInit();
193 static void Run();
194 static int GetMoveCommandKey(int);
195 static int MoveVectorToDirection (cv2 &mv); // -1: none
196 static cv2 GetMoveVector(int I) { return MoveVector[I]; }
197 static cv2 GetRelativeMoveVector(int I) { return RelativeMoveVector[I]; }
198 static cv2 GetBasicMoveVector(int I) { return BasicMoveVector[I]; }
199 static cv2 GetLargeMoveVector(int I) { return LargeMoveVector[I]; }
200 static area* GetCurrentArea() { return CurrentArea; }
201 static level* GetCurrentLevel() { return CurrentLevel; }
202 static uChar*** GetLuxTable() { return LuxTable; }
203 static character* GetPlayer() { return Player; }
204 static void SetPlayer(character*);
205 static v2 GetCamera() { return Camera; }
206 static void UpdateCameraX();
207 static void UpdateCameraY();
208 static truth IsLoading() { return Loading; }
209 static void SetIsLoading(truth What) { Loading = What; }
210 static truth ForceJumpToPlayerBe() { return JumpToPlayerBe; }
211 static void SetForceJumpToPlayerBe(truth What) { JumpToPlayerBe = What; }
212 static level* GetLevel(int);
213 static void InitLuxTable();
214 static void DeInitLuxTable();
215 static cchar* Insult();
216 static truth TruthQuestion(cfestring&, int = 0, int = 0);
217 static void DrawEverything();
218 static truth Save(cfestring& = SaveName(""));
219 static int Load(cfestring& = SaveName(""));
220 static truth IsRunning() { return Running; }
221 static void SetIsRunning(truth What) { Running = What; }
222 static void UpdateCameraX(int);
223 static void UpdateCameraY(int);
224 static int GetCurrentLevelIndex() { return CurrentLevelIndex; }
225 static int GetMoveCommandKeyBetweenPoints(v2, v2);
226 static void DrawEverythingNoBlit(truth = false);
227 static god* GetGod(int I) { return God[I]; }
228 static cchar* GetAlignment(int I) { return Alignment[I]; }
229 static void ApplyDivineTick();
230 static void ApplyDivineAlignmentBonuses(god*, int, truth);
231 static v2 GetDirectionVectorForKey(int);
232 static festring SaveName(cfestring& = CONST_S(""));
233 static void ShowLevelMessage();
234 static double GetMinDifficulty();
235 static void TriggerQuestForGoldenEagleShirt();
236 static void CalculateGodNumber();
237 static void IncreaseTick() { ++Tick; }
238 static feuLong GetTick() { return Tick; }
239 static festring GetAutoSaveFileName() { return AutoSaveFileName; }
240 static int DirectionQuestion(cfestring&, truth = true, truth = false);
241 static void RemoveSaves(truth = true);
242 static truth IsInWilderness() { return InWilderness; }
243 static void SetIsInWilderness(truth What) { InWilderness = What; }
244 static worldmap* GetWorldMap() { return WorldMap; }
245 static void SetAreaInLoad(area* What) { AreaInLoad = What; }
246 static void SetSquareInLoad(square* What) { SquareInLoad = What; }
247 static area* GetAreaInLoad() { return AreaInLoad; }
248 static square* GetSquareInLoad() { return SquareInLoad; }
249 static int GetLevels();
250 static dungeon* GetCurrentDungeon() { return Dungeon[CurrentDungeonIndex]; }
251 static dungeon* GetDungeon(int I) { return Dungeon[I]; }
252 static int GetCurrentDungeonIndex() { return CurrentDungeonIndex; }
253 static void InitDungeons();
254 static truth OnScreen(v2);
255 static void DoEvilDeed(int);
256 static void SaveWorldMap(cfestring& = SaveName(""), truth = true);
257 static worldmap* LoadWorldMap(cfestring& = SaveName(""));
258 static void UpdateCamera();
259 static feuLong CreateNewCharacterID(character*);
260 static feuLong CreateNewItemID(item*);
261 static feuLong CreateNewTrapID(entity*);
262 static team* GetTeam(int I) { return Team[I]; }
263 static int GetTeams() { return Teams; }
264 static void Hostility(team*, team*);
265 static void CreateTeams();
266 static festring StringQuestion(cfestring&, col16, festring::sizetype, festring::sizetype, truth, stringkeyhandler = 0);
267 static sLong NumberQuestion(cfestring&, int, truth = false);
268 static feuLong IncreaseLOSTick();
269 static feuLong GetLOSTick() { return LOSTick; }
270 static void SendLOSUpdateRequest() { LOSUpdateRequested = true; }
271 static void RemoveLOSUpdateRequest() { LOSUpdateRequested = false; }
272 static character* GetPetrus() { return Petrus; }
273 static void SetPetrus(character* What) { Petrus = What; }
274 static truth HandleQuitMessage();
275 static int GetDirectionForVector(v2);
276 static cchar* GetVerbalPlayerAlignment();
277 static void CreateGods();
278 static int GetScreenXSize() { return 42; }
279 static int GetScreenYSize() { return 26; }
280 static v2 CalculateScreenCoordinates(v2);
281 static void BusyAnimation();
282 static void BusyAnimation(bitmap*, truth);
283 static v2 PositionQuestion(cfestring&, v2, positionhandler = 0, positionkeyhandler = 0, truth = true);
284 static void LookHandler(v2);
285 static int AskForKeyPress(cfestring&);
286 static void AskForEscPress(cfestring &Topic);
287 static truth AnimationController();
288 static gamescript* GetGameScript() { return GameScript; }
289 static void InitScript();
290 static valuemap& GetGlobalValueMap() { return GlobalValueMap; }
291 static void InitGlobalValueMap();
292 static void LoadGlobalValueMap (inputfile &SaveFile);
293 static void TextScreen(cfestring&, v2 = ZERO_V2, col16 = 0xFFFF, truth = true, truth = true, bitmapeditor = 0);
294 static void SetCursorPos(v2 What) { CursorPos = What; }
295 static truth DoZoom() { return Zoom; }
296 static void SetDoZoom(truth What) { Zoom = What; }
297 static int KeyQuestion(cfestring&, int, int, ...);
298 static v2 LookKeyHandler(v2, int);
299 static v2 NameKeyHandler(v2, int);
300 static void End(festring, truth = true, truth = true);
301 static int CalculateRoughDirection(v2);
302 static sLong ScrollBarQuestion(cfestring&, sLong, sLong, sLong, sLong, sLong, col16, col16, col16, void (*)(sLong) = 0);
303 static truth IsGenerating() { return Generating; }
304 static void SetIsGenerating(truth What) { Generating = What; }
305 static void CalculateNextDanger();
306 static int Menu(bitmap*, v2, cfestring&, cfestring&, col16, cfestring& = "", cfestring& = "");
307 static void InitDangerMap();
308 static const dangermap& GetDangerMap();
309 static truth TryTravel(int, int, int, truth = false, truth = true);
310 static truth LeaveArea(charactervector&, truth, truth);
311 static void EnterArea(charactervector&, int, int);
312 static int CompareLights(col24, col24);
313 static int CompareLightToInt(col24, col24);
314 static void CombineLights(col24&, col24);
315 static col24 CombineConstLights(col24, col24);
316 static truth IsDark(col24);
317 static void SetStandardListAttributes(felist&);
318 static double GetAveragePlayerArmStrengthExperience() { return AveragePlayerArmStrengthExperience; }
319 static double GetAveragePlayerLegStrengthExperience() { return AveragePlayerLegStrengthExperience; }
320 static double GetAveragePlayerDexterityExperience() { return AveragePlayerDexterityExperience; }
321 static double GetAveragePlayerAgilityExperience() { return AveragePlayerAgilityExperience; }
322 static void InitPlayerAttributeAverage();
323 static void UpdatePlayerAttributeAverage();
324 static void CallForAttention(v2, int);
325 static character* SearchCharacter(feuLong);
326 static item* SearchItem(feuLong);
327 static entity* SearchTrap(feuLong);
328 static void AddCharacterID(character*, feuLong);
329 static void RemoveCharacterID(feuLong);
330 static void AddItemID(item*, feuLong);
331 static void RemoveItemID(feuLong);
332 static void UpdateItemID(item*, feuLong);
333 static void AddTrapID(entity*, feuLong);
334 static void RemoveTrapID(feuLong);
335 static void UpdateTrapID(entity*, feuLong);
336 static int GetStoryState() { return StoryState; }
337 static void SetStoryState(int What) { StoryState = What; }
338 static int GetMondedrPass () { return MondedrPass; }
339 static void SetMondedrPass (int What) { MondedrPass = What; }
340 static int GetRingOfThieves () { return RingOfThieves; }
341 static void SetRingOfThieves (int What) { RingOfThieves = What; }
342 static int GetMasamune () { return Masamune; }
343 static void SetMasamune (int What) { Masamune = What; }
344 static int GetMuramasa () { return Muramasa; }
345 static void SetMuramasa (int What) { Muramasa = What; }
346 static int GetLoricatusHammer () { return LoricatusHammer; }
347 static void SetLoricatusHammer (int What) { LoricatusHammer = What; }
348 static int GetLiberator () { return Liberator; }
349 static void SetLiberator (int What) { Liberator = What; }
350 static int GetOmmelBloodMission() { return OmmelBloodMission; }
351 static void SetOmmelBloodMission(int What) { OmmelBloodMission = What; }
352 static int GetRegiiTalkState() { return RegiiTalkState; }
353 static void SetRegiiTalkState(int What) { RegiiTalkState = What; }
354 static void SetIsInGetCommand(truth What) { InGetCommand = What; }
355 static truth IsInGetCommand() { return InGetCommand; }
356 static festring GetHomeDir();
357 static festring GetSavePath();
358 static festring GetGameDir();
359 static festring GetBonePath();
360 static truth PlayerWasHurtByExplosion() { return PlayerHurtByExplosion; }
361 static void SetPlayerWasHurtByExplosion(truth What) { PlayerHurtByExplosion = What; }
362 static void SetCurrentArea(area* What) { CurrentArea = What; }
363 static void SetCurrentLevel(level* What) { CurrentLevel = What; }
364 static void SetCurrentWSquareMap(wsquare*** What) { CurrentWSquareMap = What; }
365 static void SetCurrentLSquareMap(lsquare*** What) { CurrentLSquareMap = What; }
366 static festring& GetDefaultPolymorphTo() { return DefaultPolymorphTo; }
367 static festring& GetDefaultSummonMonster() { return DefaultSummonMonster; }
368 static festring& GetDefaultChangeMaterial() { return DefaultChangeMaterial; }
369 static festring& GetDefaultDetectMaterial() { return DefaultDetectMaterial; }
370 static festring& GetDefaultTeam() { return DefaultTeam; }
371 static void SignalDeath(ccharacter*, ccharacter*, festring);
372 static void DisplayMassacreLists();
373 static void DisplayMassacreList(const massacremap&, cchar*, sLong);
374 static truth MassacreListsEmpty();
375 #ifdef WIZARD
376 static void ActivateWizardMode() { WizardMode = true; }
377 static void DeactivateWizardMode() { WizardMode = false; }
378 static truth WizardModeIsActive() { return WizardMode; }
379 static void SeeWholeMap();
380 static int GetSeeWholeMapCheatMode() { return SeeWholeMapCheatMode; }
381 static truth GoThroughWallsCheatIsActive() { return GoThroughWallsCheat; }
382 static void GoThroughWalls() { GoThroughWallsCheat = !GoThroughWallsCheat; }
383 #else
384 static truth WizardModeIsActive() { return false; }
385 static int GetSeeWholeMapCheatMode() { return 0; }
386 static truth GoThroughWallsCheatIsActive() { return false; }
387 #endif
388 static truth WizardModeIsReallyActive() { return WizardMode; }
389 static void CreateBone();
390 static int GetQuestMonstersFound() { return QuestMonstersFound; }
391 static void SignalQuestMonsterFound() { ++QuestMonstersFound; }
392 static void SetQuestMonstersFound(int What) { QuestMonstersFound = What; }
393 static truth PrepareRandomBone(int);
394 static boneidmap& GetBoneItemIDMap() { return BoneItemIDMap; }
395 static boneidmap& GetBoneCharacterIDMap() { return BoneCharacterIDMap; }
396 static double CalculateAverageDanger(const charactervector&, character*);
397 static double CalculateAverageDangerOfAllNormalEnemies();
398 static character* CreateGhost();
399 static truth TooGreatDangerFound() { return TooGreatDangerFoundTruth; }
400 static void SetTooGreatDangerFound(truth What) { TooGreatDangerFoundTruth = What; }
401 static void CreateBusyAnimationCache();
402 static sLong GetScore();
403 static truth TweraifIsFree();
404 static truth IsXMas();
405 static int AddToItemDrawVector(const itemvector&);
406 static void ClearItemDrawVector();
407 static void ItemEntryDrawer(bitmap*, v2, uInt);
408 static int AddToCharacterDrawVector(character*);
409 static void ClearCharacterDrawVector();
410 static void CharacterEntryDrawer(bitmap*, v2, uInt);
411 static void GodEntryDrawer(bitmap*, v2, uInt);
412 static itemvectorvector& GetItemDrawVector() { return ItemDrawVector; }
413 static charactervector& GetCharacterDrawVector() { return CharacterDrawVector; }
414 static truth IsSumoWrestling() { return SumoWrestling; }
415 static void SetIsSumoWrestling(truth What) { SumoWrestling = What; }
416 static truth AllowHostilities() { return !SumoWrestling; }
417 static truth AllBodyPartsVanish() { return SumoWrestling; }
418 static truth TryToEnterSumoArena();
419 static truth TryToExitSumoArena();
420 static truth EndSumoWrestling(int);
421 static character* GetSumo();
422 static cfestring& GetPlayerName() { return PlayerName; }
423 static rain* ConstructGlobalRain();
424 static void SetGlobalRainLiquid(liquid* What) { GlobalRainLiquid = What; }
425 static void SetGlobalRainSpeed(v2 What) { GlobalRainSpeed = What; }
426 static truth PlayerIsSumoChampion() { return PlayerSumoChampion; }
427 static truth PlayerIsSolicitusChampion() { return PlayerSolicitusChampion; }
428 static void MakePlayerSolicitusChampion() { PlayerSolicitusChampion = true; }
429 static v2 GetSunLightDirectionVector();
430 static int CalculateMinimumEmitationRadius(col24);
431 static feuLong IncreaseSquarePartEmitationTicks();
432 static cint GetLargeMoveDirection(int I) { return LargeMoveDirection[I]; }
433 static bool Wish(character*, cchar*, cchar*, bool canAbort=false);
434 static festring DefaultQuestion(festring, festring&, stringkeyhandler = 0);
435 static void GetTime(ivantime&);
436 static sLong GetTurn() { return Turn; }
437 static void IncreaseTurn() { ++Turn; }
438 static int GetTotalMinutes() { return Tick * 60 / 2000; }
439 static truth PolymorphControlKeyHandler(int, festring&);
440 static feuLong* GetEquipmentMemory() { return EquipmentMemory; }
441 static truth PlayerIsRunning();
442 static void SetPlayerIsRunning(truth What) { PlayerRunning = What; }
443 static truth FillPetVector(cchar*);
444 static truth CommandQuestion();
445 static void NameQuestion();
446 static v2 CommandKeyHandler(v2, int);
447 static void CommandScreen(cfestring&, feuLong, feuLong, feuLong&, feuLong&);
448 static truth CommandAll();
449 static double GetDangerFound() { return DangerFound; }
450 static void SetDangerFound(double What) { DangerFound = What; }
451 static col16 GetAttributeColor(int);
452 static void UpdateAttributeMemory();
453 static void InitAttributeMemory();
454 static void TeleportHandler(v2);
455 static void PetHandler(v2);
456 static truth SelectPet(int);
457 static double GetGameSituationDanger();
458 static olterrain* GetMonsterPortal() { return MonsterPortal; }
459 static void SetMonsterPortal(olterrain* What) { MonsterPortal = What; }
460 static truth GetCausePanicFlag() { return CausePanicFlag; }
461 static void SetCausePanicFlag(truth What) { CausePanicFlag = What; }
462 static sLong GetTimeSpent();
463 static void AddSpecialCursor(v2, int);
464 static void RemoveSpecialCursors();
465 static void LearnAbout(god*);
466 static truth PlayerKnowsAllGods();
467 static void AdjustRelationsToAllGods(int);
468 static void SetRelationsToAllGods(int);
469 static void ShowDeathSmiley(bitmap*, truth);
470 static void SetEnterImage(cbitmap* What) { EnterImage = What; }
471 static void SetEnterTextDisplacement (v2 What) { EnterTextDisplacement = What; }
473 static int ListSelector (int defsel, const cfestring title, ...); // defsel<0: first
474 static int ListSelectorArray (int defsel, cfestring &title, const char *items[]); // defsel<0: first
476 static char GetAbnormalMoveKey (int idx);
477 static void SetAbnormalMoveKey (int idx, char ch);
479 static truth CheckDropLeftover (item *i);
481 static team *FindTeam (cfestring &name);
482 //static team *FindTeam (const char *name);
484 static void ClearEventData ();
485 // return 'true' if event is 'eaten'
486 static truth RunOnEvent (cfestring &ename);
487 static truth RunOnCharEvent (character *who, cfestring &ename);
488 static truth RunOnItemEvent (item *what, cfestring &ename);
490 static truth RunAllowScriptStr (cfestring &str);
492 static festring ldrGetVar (inputfile *fl, cfestring &name);
494 private:
495 static truth RunOnEventStr (cfestring &name, cfestring &str);
496 static truth GetWord (festring &w);
497 static void SkipBlock (truth brcEaten);
498 static void UpdateCameraCoordinate (int &, int, int, int);
499 static truth DoOnEvent (truth brcEaten, truth AllowScript=false);
500 static int ParseFuncArgs (cfestring &types, std::vector<FuncArg> &args, inputfile *fl=0, truth noterm=false);
502 private:
503 static cchar* const Alignment[];
504 static god** God;
505 static int CurrentLevelIndex;
506 static int CurrentDungeonIndex;
507 static cint MoveNormalCommandKey[];
508 static int MoveAbnormalCommandKey[];
509 static cv2 MoveVector[];
510 static cv2 RelativeMoveVector[];
511 static cv2 BasicMoveVector[];
512 static cv2 LargeMoveVector[];
513 static uChar*** LuxTable;
514 static truth Running;
515 static character* Player;
516 static v2 Camera;
517 static feuLong Tick;
518 static festring AutoSaveFileName;
519 static truth InWilderness;
520 static worldmap* WorldMap;
521 static area* AreaInLoad;
522 static square* SquareInLoad;
523 static dungeon** Dungeon;
524 static feuLong NextCharacterID;
525 static feuLong NextItemID;
526 static feuLong NextTrapID;
527 static team** Team;
528 static feuLong LOSTick;
529 static truth LOSUpdateRequested;
530 static character* Petrus;
531 static truth Loading;
532 static truth JumpToPlayerBe;
533 static gamescript* GameScript;
534 static valuemap GlobalValueMap;
535 static v2 CursorPos;
536 static truth Zoom;
537 static truth Generating;
538 static dangermap DangerMap;
539 static int NextDangerIDType;
540 static int NextDangerIDConfigIndex;
541 static double AveragePlayerArmStrengthExperience;
542 static double AveragePlayerLegStrengthExperience;
543 static double AveragePlayerDexterityExperience;
544 static double AveragePlayerAgilityExperience;
545 static characteridmap CharacterIDMap;
546 static itemidmap ItemIDMap;
547 static trapidmap TrapIDMap;
548 static int Teams;
549 static int Dungeons;
550 static int StoryState;
551 static int MondedrPass;
552 static int RingOfThieves;
553 static int Masamune;
554 static int Muramasa;
555 static int LoricatusHammer;
556 static int Liberator;
557 static int OmmelBloodMission;
558 static int RegiiTalkState;
559 static truth InGetCommand;
560 static truth PlayerHurtByExplosion;
561 static area* CurrentArea;
562 static level* CurrentLevel;
563 static wsquare*** CurrentWSquareMap;
564 static lsquare*** CurrentLSquareMap;
565 static festring DefaultPolymorphTo;
566 static festring DefaultSummonMonster;
567 static festring DefaultWish;
568 static festring DefaultChangeMaterial;
569 static festring DefaultDetectMaterial;
570 static festring DefaultTeam;
571 static massacremap PlayerMassacreMap;
572 static massacremap PetMassacreMap;
573 static massacremap MiscMassacreMap;
574 static sLong PlayerMassacreAmount;
575 static sLong PetMassacreAmount;
576 static sLong MiscMassacreAmount;
577 static truth WizardMode;
578 static int SeeWholeMapCheatMode;
579 static truth GoThroughWallsCheat;
580 static int QuestMonstersFound;
581 static boneidmap BoneItemIDMap;
582 static boneidmap BoneCharacterIDMap;
583 static truth TooGreatDangerFoundTruth;
584 static bitmap* BusyAnimationCache[32];
585 static itemvectorvector ItemDrawVector;
586 static charactervector CharacterDrawVector;
587 static truth SumoWrestling;
588 static festring PlayerName;
589 static liquid* GlobalRainLiquid;
590 static v2 GlobalRainSpeed;
591 static sLong GlobalRainTimeModifier;
592 static truth PlayerSumoChampion;
593 static truth PlayerSolicitusChampion;
594 static feuLong SquarePartEmitationTick;
595 static cint LargeMoveDirection[];
596 static sLong Turn;
597 static feuLong EquipmentMemory[MAX_EQUIPMENT_SLOTS];
598 static truth PlayerRunning;
599 static character* LastPetUnderCursor;
600 static charactervector PetVector;
601 static double DangerFound;
602 static int OldAttribute[ATTRIBUTES];
603 static int NewAttribute[ATTRIBUTES];
604 static int LastAttributeChangeTick[ATTRIBUTES];
605 static int NecroCounter;
606 static int CursorData;
607 static olterrain* MonsterPortal;
608 static truth CausePanicFlag;
609 static time_t TimePlayedBeforeLastLoad;
610 static time_t LastLoad;
611 static time_t GameBegan;
612 static std::vector<v2> SpecialCursorPos;
613 static std::vector<int> SpecialCursorData;
614 static truth PlayerHasReceivedAllGodsKnownBonus;
615 static cbitmap* EnterImage;
616 static v2 EnterTextDisplacement;
618 static std::stack<inputfile *> mFEStack;
620 public:
621 static character *mChar;
622 static ccharacter *mActor;
623 static ccharacter *mSecondActor;
624 static item *mItem;
625 static int mResult;
628 inline void game::CombineLights(col24& L1, col24 L2)
630 if(L2)
632 if(L1)
634 sLong Red1 = L1 & 0xFF0000, Red2 = L2 & 0xFF0000;
635 sLong New = Red1 >= Red2 ? Red1 : Red2;
636 sLong Green1 = L1 & 0xFF00, Green2 = L2 & 0xFF00;
637 New |= Green1 >= Green2 ? Green1 : Green2;
638 sLong Blue1 = L1 & 0xFF, Blue2 = L2 & 0xFF;
639 L1 = Blue1 >= Blue2 ? New | Blue1 : New | Blue2;
641 else
642 L1 = L2;
646 inline col24 game::CombineConstLights(col24 L1, col24 L2)
648 CombineLights(L1, L2);
649 return L1;
652 inline truth game::IsDark(col24 Light)
654 return !Light
655 || ((Light & 0xFF0000) < (LIGHT_BORDER << 16)
656 && (Light & 0x00FF00) < (LIGHT_BORDER << 8)
657 && (Light & 0x0000FF) < LIGHT_BORDER);
660 inline int game::CompareLights(col24 L1, col24 L2)
662 if(L1)
664 if((L1 & 0xFF0000) > (L2 & 0xFF0000)
665 || (L1 & 0x00FF00) > (L2 & 0x00FF00)
666 || (L1 & 0x0000FF) > (L2 & 0x0000FF))
667 return 1;
668 else if((L1 & 0xFF0000) == (L2 & 0xFF0000)
669 || (L1 & 0x00FF00) == (L2 & 0x00FF00)
670 || (L1 & 0x0000FF) == (L2 & 0x0000FF))
671 return 0;
672 else
673 return -1;
675 else
676 return -int(!!L2);
679 inline v2 game::CalculateScreenCoordinates(v2 Pos)
681 return v2((Pos.X - Camera.X + 1) << 4, (Pos.Y - Camera.Y + 2) << 4);
684 #endif