mud++0.35/etc/
mud++0.35/etc/guilds/
mud++0.35/help/propert/
mud++0.35/mudC/
mud++0.35/player/
mud++0.35/src/interface/
mud++0.35/src/os/cygwin32/
mud++0.35/src/os/win32/
mud++0.35/src/os/win32/bcppbuilder/
mud++0.35/src/osaddon/
mud++0.35/src/util/
/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project.  All 
................................................ contributions are welcome. 
....Copyright(C).1995.Melvin.Smith.............. Enjoy. 
------------------------------------------------------------------------------
Melvin Smith (aka Fusion)         msmith@hom.net 
MUD++ development mailing list    mudpp@van.ml.org
------------------------------------------------------------------------------
room.h
*/

#ifndef _ROOM_H
#define _ROOM_H

#include "io.h"
#include "string.h"
#include "llist.h"
#include "vector.h"
#include "nameable.h"
#include "streamable.h"
#include "exit.h"
#include "mudobj.h"
#include "thing.h"
#include "trigs.h"

class Area;
class Repop;
class Description;
class Object;
class Char;
class PC;
class NPC;

// Do not change these values unless you are changing the navigation
// and movement code. The orientation value depends on 0-3 in many
// instances being n,e,s,w
const int DIR_UNDEFINED	= -1;
const int DIR_NORTH		= 0;
const int DIR_EAST		= 1;
const int DIR_SOUTH		= 2;
const int DIR_WEST		= 3; 
const int DIR_UP		= 4; 
const int DIR_DOWN		= 5;
const int MAX_DIR		= 6; 

// Unused
const int DIR_NORTH_EAST	= 6;
const int DIR_NORTH_WEST	= 7;
const int DIR_SOUTH_EAST	= 8;
const int DIR_SOUTH_WEST	= 9;

const int SECTOR_NONE		= 0; // undefined 
const int SECTOR_GROUND		= 1; // need good pair of Nikes
const int SECTOR_AIR		= 2; // flying
const int SECTOR_WATER		= 3; // need boat
const int SECTOR_UNDERWATER	= 4; // need breathe-water ability

const int ROOM_DARK			= 1;
const int ROOM_SAFE			= 2;
const int ROOM_NOSUMMON		= 3;
const int ROOM_NOLEAVE		= 4;
const int ROOM_DEATHTRAP	= 5;
const int ROOM_DRAIN		= 6;
const int ROOM_FASTHP		= 7;
const int ROOM_FASTMANA		= 8;
const int ROOM_NOHP			= 9;
const int ROOM_NOMANA		= 10;
const int ROOM_SHIELD		= 11;
const int ROOM_INDOORS		= 12;


const int MAX_ROOM_BIT_FIELDS = 1;

class Room : virtual public Nameable, public Streamable, public MudObject
{
	private:
		static int total_count;

	protected:
		Area * area;
		String key;		// Index key
		Vector vec;
		String desc;				// Detailed room desc
		Exit * exits[ MAX_DIR ];
		unsigned long room_bits[ MAX_ROOM_BIT_FIELDS ];
		int sector; // ground, air, water, underwater
		int terrain; // ease of movement 
		int temp;   // temperature - function of environ and inside heat sources

	public:
		LList<Repop> repops;
		LList<Description> ed;
		LList<Object> inv;
		LList<Char> chars;

		Room()
		:	area(0), sector(SECTOR_GROUND), terrain(3)
		{ 
			total_count++;
			memset( exits, 0, sizeof( exits[0] ) * MAX_DIR );
			memset( room_bits, 0, sizeof( room_bits[0] ) * MAX_ROOM_BIT_FIELDS );
		}

		Room( Area *x )
		:	area(x), sector(SECTOR_GROUND), terrain(3)
		{
			total_count++;
			memset( exits, 0, sizeof( exits[0] ) * MAX_DIR );
			memset( room_bits, 0, sizeof( room_bits[0] ) * MAX_ROOM_BIT_FIELDS );
		}

		Room( Area *x, const String & y )
		:	area(x), key(y), sector(SECTOR_GROUND), terrain(3)
		{
			total_count++;
			memset( exits, 0, sizeof( exits[0] ) * MAX_DIR );
			memset( room_bits, 0, sizeof( room_bits[0] ) * MAX_ROOM_BIT_FIELDS );
		}

		~Room();
		virtual vmtype getVMType() { return VMT_ROOM; }

		void setKey( const String & x ) { key = x; }
		const String & getScope() const;
		const String getKey() const { return key; }
		bool roomBitIsSet( int x ) { return IS_SET( room_bits, x ); }
		void clrRoomBit( int x ) { CLR_BIT( room_bits, x ); }
		void setRoomBit( int x ) { SET_BIT( room_bits, x ); }
		void toggleRoomBit( int x ) { TOGGLE_BIT( room_bits, x ); }
		void pulse();
		int writeTo( Output & ) const;
		int readFrom( StaticInput & );
		void hardLink();
		void addRepop( Repop * );
		void addRepop( int, Repop * );
		Repop * rmRepop( int );
		Repop * rmRepop();
		void repop(); 
		Area *getArea() { return area; } 
		void addObjInv( Object * );
		void rmObjInv( Object * );
		void addCharInv( Char * );
		void rmCharInv( Char * );
		bool getSector() { return sector; }
		void setSector( int x ) { sector = x; }
		bool getTerrain() { return terrain; }
		void setTerrain( int x ) { terrain = x; }
		bool isIndoors() { return IS_SET( room_bits, ROOM_INDOORS ); }
		void out( const char * );
		void out( const String & x ) { out( x.chars() ); }
		void outAllChar( const String & x ) { out( x.chars() ); }
		void outAllChar( const char * x ) { out( x ); }
		void interp( const String &, Char *, Char *, Object *, Object * );
		void outAllExcept( const String &, Thing *, Thing * );
		void outAllCharExcept( const char *, Char *, Char * );
		void outAllCharExcept( const String &, Char *, Char * );
		const String & getDesc() { return desc; }
		void setDesc( const String & x) { desc = x; }
		const String & getExtraDesc( const String & x ) { return getExtraDesc( x.chars() ); }
		const String & getExtraDesc( const char * );
		void addExtraDesc( Description * d ) { ed.addTop( d ); }
		Exit * getExit( int );
		Room *toRoom( int );
		void addExit( Exit *, int );
		void deleteExit( int ); 
		Char *getChar( const String & ); // player or mob
		Char *getChar( countedThing & ); // player or mob
		PC *getPC( const String & );     // player
		NPC *getNPC( const String & );     // mob
		Object *getObj( const String & );
		Object *getObj( countedThing & );
		bool isRoom( void ) const { return true; }
		virtual Room * asRoom() { return this; }
		void describeItself( String & );

		static int getTotalCount() { return total_count; }

		friend class RoomEditor;

		//Triggers part
		bool TgUpdate();
		bool TgDroppedItem( Char * caller, Object * what );
		bool TgPickedItem( Char * caller, Object * what );
		bool TgStrangeCmd( Char * caller, const String & cmd, const String & args);
		bool TgSaidIn( Char * caller, const char * what );
		bool TgSaidIn( Char * caller, const String & what );
		bool TgEntered( Char * caller, Room * from );
		bool TgLeft( Char * caller, Room * to ); // exit to ?
		bool TgSocialedIn( Char * caller,Char * target,  const Social * social );

};

extern const bitType sector_list[];
extern const bitType room_bit_list[];

inline Repop * Room::rmRepop()
	{	return repops.remove(); }

inline void Room::outAllCharExcept( const String & x, Char * y, Char * z )
	{	outAllCharExcept( x.chars(), y, z );	}

inline int lookupRoomBit( const String & x )
	{	return lookupBit( room_bit_list, x ); }

inline const char * lookupRoomBitName( int x )
	{	return lookupBitName( room_bit_list, x ); }

inline const char * lookupSectorName( int x )
	{	return lookupBitName( sector_list, x );	}

inline int lookupSector( const String & x )
	{	return lookupBit( sector_list, x );	}

#endif