area.h
mud++0.33/src/area.h · 4.6 KB
From the archive mud++0.33.tar.gz
Download the archive « Back to the archive contents
/*
....[@@@..[@@@..............[@.................. 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-list@mailhost.net
------------------------------------------------------------------------------
area.h
*/
#ifndef _AREA_H
#define _AREA_H
#include "string.h"
#include "io.h"
#include "bit.h"
#include "vmobject.h"
#include "affect.h"
#include "vector.h"
#include "combat.h"
#include "hash.h"
#include "room.h"
#include "object.h"
#include "npc.h"
#include "mudobj.h"
// Area is not really a thing but the methods for Thing are applicable
class Area : virtual public Nameable, virtual public Streamable,
public MudObject
{
protected:
String file;
String key;
String repop_messg;
String builder;
String title;
int min_level;
int max_level;
int security;
int a_flags;
int repop_time;
int timer;
int mods;
int dirty_bit;
public:
HashTable<Room> roomIndex;
HashTable<Object> objIndex;
HashTable<NPC> npcIndex;
Area()
: repop_messg("Bonk!"), min_level(0), max_level(0),
security(1), a_flags(0), repop_time(2), timer(0),
mods(0), dirty_bit(0)
{
}
Area( const String & x )
: key(x), min_level(0), max_level(0),
repop_time(2), timer(0), mods(0), dirty_bit(0)
{
file << x << ".are";
}
virtual vmtype getVMType() { return VMT_AREA; }
void setDirtyBit() { dirty_bit = 1; }
void rmDirtyBit() { dirty_bit = 0; }
int getDirtyBit() { return dirty_bit; }
void addAffect( Affect * ) {} // area affects (conceivable)
void rmAffect( int ) {}
Affect * getAffect( int ) { return 0; }
// Send text to all players in an area.
virtual void outAllChar( const char * );
virtual void outAllChar( const String & x ) { outAllChar( x.chars() ); }
virtual void outAllCharExcept( const char *, PC * );
virtual void outAllCharExcept( const String & x, PC * pc ) { outAllCharExcept( x, pc ); }
void setKey( const String & x ) { key = x; }
const String & getKey() const { return key; }
int reload();
int readFrom( StaticInput & );
int writeTo( Output & ) const;
int load();
int save() const;
void hardLink();
const String & getFile() const { return file; }
void setFile( const String & x ) { file = x; }
const String & getBuilder() const { return builder; }
void setBuilder( const String & x ) { builder = x; }
int getSecurity() const { return security; }
int getRepopTime() const { return repop_time; }
void setRepopTime( int t ) { if( t > 0 ) repop_time = t; }
const String & getRepopMessg() const { return repop_messg; }
void setRepopMessg( const String & x ) { repop_messg = x; }
void setTitle( const String & x ) { title = x; }
const String & getTitle() { return title; }
void setMinLevel( int x ) { min_level = x; }
void setMaxLevel( int x ) { max_level = x; }
int getMinLevel() { return min_level; }
int getMaxLevel() { return max_level; }
Object *lookupObj( const String & x ) { return objIndex.lookup( x ); }
Object *lookupObj( const char * x ) { return objIndex.lookup( x ); }
Object *createObj( const String & );
void addObj( const String & x, Object * y ) { objIndex.add( x, y ); }
NPC *lookupNPC( const String & x ) { return npcIndex.lookup( x ); }
NPC *lookupNPC( const char * x ) { return npcIndex.lookup( x ); }
NPC *createNPC( const String & );
void addNPC( const String & x, NPC * y ) { npcIndex.add( x, y ); }
Room * lookupRoom( const String & x ) { return roomIndex.lookup( x ); }
Room * lookupRoom( const char * x ) { return roomIndex.lookup( x ); }
void repop();
void tick() { if( ++timer >= repop_time ) repop(); }
void addRoom( Room * );
void removeRoom( Room * );
virtual bool isCastle( void ) const { return false; }
bool isArea( void ) const { return true; }
virtual Area * asArea() { return this; }
};
inline int Area::load()
{
char buf[ 4096 ];
InputFile in( file );
if( in )
{
if( *in.getword( buf ) != 'A' )
return -1;
in.getword( buf ); // get the index
return readFrom( in );
}
return -1;
}
inline int Area::save() const
{
OutputFile out( file );
if( out )
return writeTo( out );
return -1;
}
#endif