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