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 __ROOM_H__ 14 #define __ROOM_H__ 15 16 #include "v2.h" 17 18 class room; 19 class item; 20 class olterrain; 21 class lsquare; 22 class festring; 23 class outputfile; 24 class inputfile; 25 class character; 26 27 typedef room* (*roomspawner)(); 28 29 class roomprototype 30 { 31 public: 32 roomprototype(roomspawner, cchar*); Spawn()33 room* Spawn() const { return Spawner(); } 34 room* SpawnAndLoad(inputfile&) const; GetClassID()35 cchar* GetClassID() const { return ClassID; } GetIndex()36 int GetIndex() const { return Index; } 37 private: 38 int Index; 39 roomspawner Spawner; 40 cchar* ClassID; 41 }; 42 43 class room 44 { 45 public: 46 typedef roomprototype prototype; room()47 room() : LastMasterSearchTick(0), MasterID(0) { } 48 virtual ~room() = default; 49 virtual void Save(outputfile&) const; 50 virtual void Load(inputfile&); Enter(character *)51 virtual void Enter(character*) { } GetPos()52 v2 GetPos() const { return Pos; } SetPos(v2 What)53 void SetPos(v2 What) { Pos = What; } GetSize()54 v2 GetSize() const { return Size; } SetSize(v2 What)55 void SetSize(v2 What) { Size = What; } SetIndex(int What)56 void SetIndex(int What) { Index = What; } GetIndex()57 int GetIndex() const { return Index; } 58 character* GetMaster() const; SetMasterID(ulong What)59 void SetMasterID(ulong What) { MasterID = What; } PickupItem(character *,item *,int)60 virtual truth PickupItem(character*, item*, int) { return true; } DropItem(character *,item *,int)61 virtual truth DropItem(character*, item*, int) { return true; } GetDivineMaster()62 int GetDivineMaster() const { return DivineMaster; } SetDivineMaster(int What)63 void SetDivineMaster(int What) { DivineMaster = What; } KickSquare(character *,lsquare *)64 virtual void KickSquare(character*, lsquare*) { } ConsumeItem(character *,item *,int)65 virtual truth ConsumeItem(character*, item*, int) { return true; } AllowDropGifts()66 virtual truth AllowDropGifts() const { return true; } Drink(character *)67 virtual truth Drink(character*) const { return true; } HasDrinkHandler()68 virtual truth HasDrinkHandler() const { return false; } Dip(character *)69 virtual truth Dip(character*) const { return true; } HasDipHandler()70 virtual truth HasDipHandler() const { return false; } TeleportSquare(character *,lsquare *)71 virtual void TeleportSquare(character*, lsquare*) { } 72 virtual const prototype* GetProtoType() const = 0; GetType()73 int GetType() const { return GetProtoType()->GetIndex(); } 74 virtual void DestroyTerrain(character*); AllowSpoil(citem *)75 virtual truth AllowSpoil(citem*) const { return true; } 76 virtual truth CheckDestroyTerrain(character*); GetGodRelationAdjustment()77 virtual int GetGodRelationAdjustment() const { return -50; } AllowKick(ccharacter *,const lsquare *)78 virtual truth AllowKick(ccharacter*, const lsquare*) const { return true; } 79 truth MasterIsActive() const; 80 truth CheckKickSquare(ccharacter*, const lsquare*) const; HostileAction(character *)81 virtual void HostileAction(character*) const { } AllowAltarPolymorph()82 virtual truth AllowAltarPolymorph() const { return true; } AllowFoodSearch()83 virtual truth AllowFoodSearch() const { return true; } ReceiveVomit(character *)84 virtual void ReceiveVomit(character*) { } 85 virtual truth IsOKToDestroyWalls(ccharacter*) const; AddItemEffect(item *)86 virtual void AddItemEffect(item*) { } 87 void FinalProcessForBone(); SetFlags(ulong What)88 void SetFlags(ulong What) { Flags = What; } DontGenerateMonsters()89 truth DontGenerateMonsters() const { return Flags & NO_MONSTER_GENERATION; } 90 protected: 91 mutable character* Master; 92 mutable ulong LastMasterSearchTick; 93 v2 Pos; 94 v2 Size; 95 ulong MasterID; 96 int Index; 97 int DivineMaster; 98 ulong Flags; 99 }; 100 101 #ifdef __FILE_OF_STATIC_ROOM_PROTOTYPE_DEFINITIONS__ 102 #define ROOM_PROTO(name)\ 103 template<> const roomprototype\ 104 name##sysbase::ProtoType(reinterpret_cast<roomspawner>(&name##sysbase::Spawn), #name); 105 #else 106 #define ROOM_PROTO(name) 107 #endif 108 109 #define ROOM(name, base)\ 110 class name;\ 111 typedef simplesysbase<name, base, roomprototype> name##sysbase;\ 112 ROOM_PROTO(name)\ 113 class name : public name##sysbase 114 115 #endif 116