3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
16 #include "ivancommon.h"
29 # define LIGHT_BORDER 80
32 #define PLAYER game::GetPlayer()
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
);
72 outputfile
& operator<<(outputfile
&, const homedata
*);
73 inputfile
& operator>>(inputfile
&, homedata
*&);
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
&);
90 dangerid () : NakedDanger(0), EquippedDanger(0) {}
91 dangerid (double NakedDanger
, double EquippedDanger
) : NakedDanger(NakedDanger
), EquippedDanger(EquippedDanger
) {}
93 double EquippedDanger
;
96 outputfile
& operator<<(outputfile
&, const dangerid
&);
97 inputfile
& operator>>(inputfile
&, dangerid
&);
109 massacreid (int Type
, int Config
, cfestring
&Name
) : Type(Type
), Config(Config
), Name(Name
) { }
110 bool operator < (const massacreid
&) const;
117 inline bool massacreid::operator<(const massacreid
& MI
) const
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
&);
134 killreason (cfestring
&String
, int Amount
) : String(String
), Amount(Amount
) {}
140 outputfile
& operator<<(outputfile
&, const killreason
&);
141 inputfile
& operator>>(inputfile
&, killreason
&);
145 killdata (int Amount
=0, double DangerSum
=0) : Amount(Amount
), DangerSum(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
{};
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
) {}
190 static void InitPlaces ();
191 static truth
Init(cfestring
& = CONST_S(""));
192 static void DeInit();
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();
291 static valuemap
& GetGlobalValueMap() { return GlobalValueMap
; }
292 static truth
HasGlobalValue (cfestring
&name
);
293 static sLong
FindGlobalValue (cfestring
&name
, sLong defval
=-1, truth
* found
=0);
294 static sLong
FindGlobalValue (cfestring
&name
, truth
* found
=0);
296 // this will fail if there is no such constant
298 static sLong
GetGlobalConst (cfestring
&name
);
300 static void InitGlobalValueMap();
301 static void LoadGlobalValueMap (TextInput
&SaveFile
);
303 static void TextScreen(cfestring
&, v2
= ZERO_V2
, col16
= 0xFFFF, truth
= true, truth
= true, bitmapeditor
= 0);
304 static void SetCursorPos(v2 What
) { CursorPos
= What
; }
305 static truth
DoZoom() { return Zoom
; }
306 static void SetDoZoom(truth What
) { Zoom
= What
; }
307 static int KeyQuestion(cfestring
&, int, int, ...);
308 static v2
LookKeyHandler(v2
, int);
309 static v2
NameKeyHandler(v2
, int);
310 static void End(festring
, truth
= true, truth
= true);
311 static int CalculateRoughDirection(v2
);
312 static sLong
ScrollBarQuestion(cfestring
&, sLong
, sLong
, sLong
, sLong
, sLong
, col16
, col16
, col16
, void (*)(sLong
) = 0);
313 static truth
IsGenerating() { return Generating
; }
314 static void SetIsGenerating(truth What
) { Generating
= What
; }
315 static void CalculateNextDanger();
316 static int Menu(bitmap
*, v2
, cfestring
&, cfestring
&, col16
, cfestring
& = "", cfestring
& = "");
317 static void InitDangerMap();
318 static const dangermap
& GetDangerMap();
319 static truth
TryTravel(int, int, int, truth
= false, truth
= true);
320 static truth
LeaveArea(charactervector
&, truth
, truth
);
321 static void EnterArea(charactervector
&, int, int);
322 static int CompareLights(col24
, col24
);
323 static int CompareLightToInt(col24
, col24
);
324 static void CombineLights(col24
&, col24
);
325 static col24
CombineConstLights(col24
, col24
);
326 static truth
IsDark(col24
);
327 static void SetStandardListAttributes(felist
&);
328 static double GetAveragePlayerArmStrengthExperience() { return AveragePlayerArmStrengthExperience
; }
329 static double GetAveragePlayerLegStrengthExperience() { return AveragePlayerLegStrengthExperience
; }
330 static double GetAveragePlayerDexterityExperience() { return AveragePlayerDexterityExperience
; }
331 static double GetAveragePlayerAgilityExperience() { return AveragePlayerAgilityExperience
; }
332 static void InitPlayerAttributeAverage();
333 static void UpdatePlayerAttributeAverage();
334 static void CallForAttention(v2
, int);
335 static character
* SearchCharacter(feuLong
);
336 static item
* SearchItem(feuLong
);
337 static entity
* SearchTrap(feuLong
);
338 static void AddCharacterID(character
*, feuLong
);
339 static void RemoveCharacterID(feuLong
);
340 static void AddItemID(item
*, feuLong
);
341 static void RemoveItemID(feuLong
);
342 static void UpdateItemID(item
*, feuLong
);
343 static void AddTrapID(entity
*, feuLong
);
344 static void RemoveTrapID(feuLong
);
345 static void UpdateTrapID(entity
*, feuLong
);
346 static int GetStoryState() { return StoryState
; }
347 static void SetStoryState(int What
) { StoryState
= What
; }
348 static int GetXinrochTombStoryState() { return XinrochTombStoryState
; }
349 static void SetXinrochTombStoryState(int What
) { XinrochTombStoryState
= What
; }
350 static int GetMondedrPass () { return MondedrPass
; }
351 static void SetMondedrPass (int What
) { MondedrPass
= What
; }
352 static int GetRingOfThieves () { return RingOfThieves
; }
353 static void SetRingOfThieves (int What
) { RingOfThieves
= What
; }
354 static int GetMasamune () { return Masamune
; }
355 static void SetMasamune (int What
) { Masamune
= What
; }
356 static int GetMuramasa () { return Muramasa
; }
357 static void SetMuramasa (int What
) { Muramasa
= What
; }
358 static int GetLoricatusHammer () { return LoricatusHammer
; }
359 static void SetLoricatusHammer (int What
) { LoricatusHammer
= What
; }
360 static int GetLiberator () { return Liberator
; }
361 static void SetLiberator (int What
) { Liberator
= What
; }
362 static int GetOmmelBloodMission() { return OmmelBloodMission
; }
363 static void SetOmmelBloodMission(int What
) { OmmelBloodMission
= What
; }
364 static int GetRegiiTalkState() { return RegiiTalkState
; }
365 static void SetRegiiTalkState(int What
) { RegiiTalkState
= What
; }
366 static void SetIsInGetCommand(truth What
) { InGetCommand
= What
; }
367 static truth
IsInGetCommand() { return InGetCommand
; }
368 static festring
GetHomeDir();
369 static festring
GetSavePath();
370 static festring
GetGameDir();
371 static festring
GetBonePath();
372 static truth
PlayerWasHurtByExplosion() { return PlayerHurtByExplosion
; }
373 static void SetPlayerWasHurtByExplosion(truth What
) { PlayerHurtByExplosion
= What
; }
374 static void SetCurrentArea(area
* What
) { CurrentArea
= What
; }
375 static void SetCurrentLevel(level
* What
) { CurrentLevel
= What
; }
376 static void SetCurrentWSquareMap(wsquare
*** What
) { CurrentWSquareMap
= What
; }
377 static void SetCurrentLSquareMap(lsquare
*** What
) { CurrentLSquareMap
= What
; }
378 static festring
& GetDefaultPolymorphTo() { return DefaultPolymorphTo
; }
379 static festring
& GetDefaultSummonMonster() { return DefaultSummonMonster
; }
380 static festring
& GetDefaultChangeMaterial() { return DefaultChangeMaterial
; }
381 static festring
& GetDefaultDetectMaterial() { return DefaultDetectMaterial
; }
382 static festring
& GetDefaultTeam() { return DefaultTeam
; }
383 static void SignalDeath(ccharacter
*, ccharacter
*, festring
);
384 static void DisplayMassacreLists();
385 static void DisplayMassacreList(const massacremap
&, cchar
*, sLong
);
386 static truth
MassacreListsEmpty();
388 static void ActivateWizardMode() { WizardMode
= true; }
389 static void DeactivateWizardMode() { WizardMode
= false; }
390 static truth
WizardModeIsActive() { return WizardMode
; }
391 static void SeeWholeMap();
392 static int GetSeeWholeMapCheatMode() { return SeeWholeMapCheatMode
; }
393 static truth
GoThroughWallsCheatIsActive() { return GoThroughWallsCheat
; }
394 static void GoThroughWalls() { GoThroughWallsCheat
= !GoThroughWallsCheat
; }
396 static truth
WizardModeIsActive() { return false; }
397 static int GetSeeWholeMapCheatMode() { return 0; }
398 static truth
GoThroughWallsCheatIsActive() { return false; }
400 static truth
WizardModeIsReallyActive() { return WizardMode
; }
401 static void CreateBone();
402 static int GetQuestMonstersFound() { return QuestMonstersFound
; }
403 static void SignalQuestMonsterFound() { ++QuestMonstersFound
; }
404 static void SetQuestMonstersFound(int What
) { QuestMonstersFound
= What
; }
405 static truth
PrepareRandomBone(int);
406 static boneidmap
& GetBoneItemIDMap() { return BoneItemIDMap
; }
407 static boneidmap
& GetBoneCharacterIDMap() { return BoneCharacterIDMap
; }
408 static double CalculateAverageDanger(const charactervector
&, character
*);
409 static double CalculateAverageDangerOfAllNormalEnemies();
410 static character
* CreateGhost();
411 static truth
TooGreatDangerFound() { return TooGreatDangerFoundTruth
; }
412 static void SetTooGreatDangerFound(truth What
) { TooGreatDangerFoundTruth
= What
; }
413 static void CreateBusyAnimationCache();
414 static sLong
GetScore();
415 static truth
TweraifIsFree();
416 static truth
IsXMas();
417 static int AddToItemDrawVector(const itemvector
&);
418 static void ClearItemDrawVector();
419 static void ItemEntryDrawer(bitmap
*, v2
, uInt
);
420 static int AddToCharacterDrawVector(character
*);
421 static void ClearCharacterDrawVector();
422 static void CharacterEntryDrawer(bitmap
*, v2
, uInt
);
423 static void GodEntryDrawer(bitmap
*, v2
, uInt
);
424 static itemvectorvector
& GetItemDrawVector() { return ItemDrawVector
; }
425 static charactervector
& GetCharacterDrawVector() { return CharacterDrawVector
; }
426 static truth
IsSumoWrestling() { return SumoWrestling
; }
427 static void SetIsSumoWrestling(truth What
) { SumoWrestling
= What
; }
428 static truth
AllowHostilities() { return !SumoWrestling
; }
429 static truth
AllBodyPartsVanish() { return SumoWrestling
; }
430 static truth
TryToEnterSumoArena();
431 static truth
TryToExitSumoArena();
432 static truth
EndSumoWrestling(int);
433 static character
* GetSumo();
434 static cfestring
& GetPlayerName() { return PlayerName
; }
435 static rain
* ConstructGlobalRain();
436 static void SetGlobalRainLiquid(liquid
* What
) { GlobalRainLiquid
= What
; }
437 static void SetGlobalRainSpeed(v2 What
) { GlobalRainSpeed
= What
; }
438 static truth
PlayerIsSumoChampion() { return PlayerSumoChampion
; }
439 static truth
PlayerIsSolicitusChampion() { return PlayerSolicitusChampion
; }
440 static void MakePlayerSolicitusChampion() { PlayerSolicitusChampion
= true; }
441 static v2
GetSunLightDirectionVector();
442 static int CalculateMinimumEmitationRadius(col24
);
443 static feuLong
IncreaseSquarePartEmitationTicks();
444 static cint
GetLargeMoveDirection(int I
) { return LargeMoveDirection
[I
]; }
445 static bool Wish(character
*, cchar
*, cchar
*, bool canAbort
=false);
446 static festring
DefaultQuestion(festring
, festring
&, stringkeyhandler
= 0);
447 static void GetTime(ivantime
&);
448 static sLong
GetTurn() { return Turn
; }
449 static void IncreaseTurn() { ++Turn
; }
450 static int GetTotalMinutes() { return Tick
* 60 / 2000; }
451 static truth
PolymorphControlKeyHandler(int, festring
&);
452 static feuLong
* GetEquipmentMemory() { return EquipmentMemory
; }
453 static truth
PlayerIsRunning();
454 static void SetPlayerIsRunning(truth What
) { PlayerRunning
= What
; }
455 static truth
FillPetVector(cchar
*);
456 static truth
CommandQuestion();
457 static void NameQuestion();
458 static v2
CommandKeyHandler(v2
, int);
459 static void CommandScreen(cfestring
&, feuLong
, feuLong
, feuLong
&, feuLong
&);
460 static truth
CommandAll();
461 static double GetDangerFound() { return DangerFound
; }
462 static void SetDangerFound(double What
) { DangerFound
= What
; }
463 static col16
GetAttributeColor(int);
464 static void UpdateAttributeMemory();
465 static void InitAttributeMemory();
466 static void TeleportHandler(v2
);
467 static void PetHandler(v2
);
468 static truth
SelectPet(int);
469 static double GetGameSituationDanger();
470 static olterrain
* GetMonsterPortal() { return MonsterPortal
; }
471 static void SetMonsterPortal(olterrain
* What
) { MonsterPortal
= What
; }
472 static truth
GetCausePanicFlag() { return CausePanicFlag
; }
473 static void SetCausePanicFlag(truth What
) { CausePanicFlag
= What
; }
474 static sLong
GetTimeSpent();
475 static void AddSpecialCursor(v2
, int);
476 static void RemoveSpecialCursors();
477 static void LearnAbout(god
*);
478 static truth
PlayerKnowsAllGods();
479 static void AdjustRelationsToAllGods(int);
480 static void SetRelationsToAllGods(int);
481 static void ShowDeathSmiley(bitmap
*, truth
);
482 static void SetEnterImage(cbitmap
* What
) { EnterImage
= What
; }
483 static void SetEnterTextDisplacement (v2 What
) { EnterTextDisplacement
= What
; }
485 static int ListSelector (int defsel
, const cfestring title
, ...); // defsel<0: first
486 static int ListSelectorArray (int defsel
, cfestring
&title
, const char *items
[]); // defsel<0: first
488 static char GetAbnormalMoveKey (int idx
);
489 static void SetAbnormalMoveKey (int idx
, char ch
);
491 static truth
CheckDropLeftover (item
*i
);
493 static team
*FindTeam (cfestring
&name
);
494 //static team *FindTeam (const char *name);
496 static void ClearEventData ();
497 // return 'true' if event is 'eaten'
498 static truth
RunOnEvent (cfestring
&ename
);
499 static truth
RunOnCharEvent (character
*who
, cfestring
&ename
);
500 static truth
RunOnItemEvent (item
*what
, cfestring
&ename
);
502 static truth
RunAllowScriptStr (cfestring
&str
);
504 static festring
ldrGetVar (TextInput
*fl
, cfestring
&name
);
507 static truth
RunOnEventStr (cfestring
&name
, cfestring
&str
);
508 static truth
GetWord (festring
&w
);
509 static void SkipBlock (truth brcEaten
);
510 static void UpdateCameraCoordinate (int &, int, int, int);
511 static truth
DoOnEvent (truth brcEaten
, truth AllowScript
=false);
512 static int ParseFuncArgs (cfestring
&types
, std::vector
<FuncArg
> &args
, TextInput
*fl
=0, truth noterm
=false);
515 static cchar
* const Alignment
[];
517 static int CurrentLevelIndex
;
518 static int CurrentDungeonIndex
;
519 static cint MoveNormalCommandKey
[];
520 static int MoveAbnormalCommandKey
[];
521 static cv2 MoveVector
[];
522 static cv2 RelativeMoveVector
[];
523 static cv2 BasicMoveVector
[];
524 static cv2 LargeMoveVector
[];
525 static uChar
*** LuxTable
;
526 static truth Running
;
527 static character
* Player
;
530 static festring AutoSaveFileName
;
531 static truth InWilderness
;
532 static worldmap
* WorldMap
;
533 static area
* AreaInLoad
;
534 static square
* SquareInLoad
;
535 static dungeon
** Dungeon
;
536 static feuLong NextCharacterID
;
537 static feuLong NextItemID
;
538 static feuLong NextTrapID
;
540 static feuLong LOSTick
;
541 static truth LOSUpdateRequested
;
542 static character
* Petrus
;
543 static truth Loading
;
544 static truth JumpToPlayerBe
;
545 static gamescript
* GameScript
;
546 static valuemap GlobalValueMap
;
549 static truth Generating
;
550 static dangermap DangerMap
;
551 static int NextDangerIDType
;
552 static int NextDangerIDConfigIndex
;
553 static double AveragePlayerArmStrengthExperience
;
554 static double AveragePlayerLegStrengthExperience
;
555 static double AveragePlayerDexterityExperience
;
556 static double AveragePlayerAgilityExperience
;
557 static characteridmap CharacterIDMap
;
558 static itemidmap ItemIDMap
;
559 static trapidmap TrapIDMap
;
562 static int StoryState
;
563 static int XinrochTombStoryState
;
564 static int MondedrPass
;
565 static int RingOfThieves
;
568 static int LoricatusHammer
;
569 static int Liberator
;
570 static int OmmelBloodMission
;
571 static int RegiiTalkState
;
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 festring DefaultTeam
;
584 static massacremap PlayerMassacreMap
;
585 static massacremap PetMassacreMap
;
586 static massacremap MiscMassacreMap
;
587 static sLong PlayerMassacreAmount
;
588 static sLong PetMassacreAmount
;
589 static sLong MiscMassacreAmount
;
590 static truth WizardMode
;
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 liquid
* GlobalRainLiquid
;
603 static v2 GlobalRainSpeed
;
604 static sLong GlobalRainTimeModifier
;
605 static truth PlayerSumoChampion
;
606 static truth PlayerSolicitusChampion
;
607 static feuLong SquarePartEmitationTick
;
608 static cint LargeMoveDirection
[];
610 static feuLong EquipmentMemory
[MAX_EQUIPMENT_SLOTS
];
611 static truth PlayerRunning
;
612 static character
* LastPetUnderCursor
;
613 static charactervector PetVector
;
614 static double DangerFound
;
615 static int OldAttribute
[ATTRIBUTES
];
616 static int NewAttribute
[ATTRIBUTES
];
617 static int LastAttributeChangeTick
[ATTRIBUTES
];
618 static int NecroCounter
;
619 static int CursorData
;
620 static olterrain
* MonsterPortal
;
621 static truth CausePanicFlag
;
622 static time_t TimePlayedBeforeLastLoad
;
623 static time_t LastLoad
;
624 static time_t GameBegan
;
625 static std::vector
<v2
> SpecialCursorPos
;
626 static std::vector
<int> SpecialCursorData
;
627 static truth PlayerHasReceivedAllGodsKnownBonus
;
628 static cbitmap
* EnterImage
;
629 static v2 EnterTextDisplacement
;
631 static std::stack
<TextInput
*> mFEStack
;
634 static character
*mChar
;
635 static ccharacter
*mActor
;
636 static ccharacter
*mSecondActor
;
642 //K8 WARNING! ABSOLUTELY NON-PORTABLE AND CAUSES UB!
643 //#define BCLAMP(c) (((c)&0xff)|(255-((-(int)((c) < 256))>>24)))
644 #define BCLAMP(c) ((c) > 255 ? 255 : (c) < 0 ? 0 : (c))
645 inline void game::CombineLights (col24
&L1
, col24 L2
) {
648 #if! defined(IVAN_NEW_LIGHTS)
649 # if !defined(IVAN_NEW_INTENSITY)
650 sLong Red1
= (L1
&0xFF0000), Red2
= (L2
&0xFF0000);
651 sLong New
= (Red1
>= Red2
? Red1
: Red2
);
652 sLong Green1
= (L1
&0xFF00), Green2
= (L2
&0xFF00);
653 New
|= (Green1
>= Green2
? Green1
: Green2
);
654 sLong Blue1
= (L1
&0xFF), Blue2
= (L2
&0xFF);
655 L1
= New
|(Blue1
>= Blue2
? Blue1
: Blue2
);
657 int l1i
= (int)(0.2126*((L1
>>16)&0xFF)+0.7152*((L1
>>8)&0xFF)+0.0722*(L1
&0xFF)+0.5);
658 int l2i
= (int)(0.2126*((L2
>>16)&0xFF)+0.7152*((L2
>>8)&0xFF)+0.0722*(L2
&0xFF)+0.5);
659 //if (l2i > l1i) L1 = L2;
662 int r
= (int)(((L1
>>16)&0xFF)*(l1i
/255.0f
)+((L2
>>16)&0xFF)*(l2i
/255.0f
));
663 int g
= (int)(((L1
>>8)&0xFF)*(l1i
/255.0f
)+((L2
>>8)&0xFF)*(l2i
/255.0f
));
664 int b
= (int)((L1
&0xFF)*(l1i
/255.0f
)+(L2
&0xFF)*(l2i
/255.0f
));
668 L1
= (r
<<16)|(g
<<8)|b
;
671 # define L_COEFF (0.05f)
672 int r
= (int)(((L1
>>16)&0xFF)*L_COEFF
+((L2
>>16)&0xFF)*L_COEFF
);
673 int g
= (int)(((L1
>>8)&0xFF)*L_COEFF
+((L2
>>8)&0xFF)*L_COEFF
);
674 int b
= (int)((L1
&0xFF)*L_COEFF
+(L2
&0xFF)*L_COEFF
);
678 L1
= (r
<<16)|(g
<<8)|b
;
689 inline col24
game::CombineConstLights (col24 L1
, col24 L2
) {
690 CombineLights(L1
, L2
);
695 inline truth
game::IsDark (col24 Light
) {
698 ((Light
& 0xFF0000) < (LIGHT_BORDER
<< 16) &&
699 (Light
& 0x00FF00) < (LIGHT_BORDER
<< 8) &&
700 (Light
& 0x0000FF) < LIGHT_BORDER
);
703 inline int game::CompareLights (col24 L1
, col24 L2
) {
705 if ((L1
& 0xFF0000) > (L2
& 0xFF0000) ||
706 (L1
& 0x00FF00) > (L2
& 0x00FF00) ||
707 (L1
& 0x0000FF) > (L2
& 0x0000FF))
709 if ((L1
& 0xFF0000) == (L2
& 0xFF0000) ||
710 (L1
& 0x00FF00) == (L2
& 0x00FF00) ||
711 (L1
& 0x0000FF) == (L2
& 0x0000FF))
719 inline v2
game::CalculateScreenCoordinates (v2 Pos
) {
720 return v2((Pos
.X
-Camera
.X
+1)<<4, (Pos
.Y
-Camera
.Y
+2)<<4);