duncan
Mom and Dad were wrong!
Public Types | Public Member Functions
server::World Class Reference

#include <world.h>

Inheritance diagram for server::World:
Inheritance graph
[legend]
Collaboration diagram for server::World:
Collaboration graph
[legend]

List of all members.

Public Types

typedef CharList< CharacterCList

Public Member Functions

 World (const std::string &)
 World (const World &)
const Worldoperator= (const World &)
void name_changed (Player *)
const PlayerPacket::pointer_t next_outgoing ()
void pop_outgoing ()
void update (double)
void join (Player *)
void disconnect (Player *)
void packet (net::data_t *, size_t, Player *)
net::maphash_t maphash ()
const std::string & mapname ()
bool is_vacant (double, double, Character *) const
size_t width () const
size_t height () const

Detailed Description

Store information about a world.

Contains a map, players, etc...

Author:
Harry Slatyer
Malcolm Gill

see LICENSE


Constructor & Destructor Documentation

World::World ( const std::string &  filename)

Initialise the queue of available indices, and load all the data.

Parameters:
filenamename of file
World::World ( const World o)

Copy constructor, differing from the default one in two ways: 1. copy-constructing a KDTree optimises it, so tree_age_ is set to 0 2. path_finder_ is initialised using this World, rather than being copy-constructed and pointing to o


Member Function Documentation

void World::disconnect ( Player p)

Remove a Player from the World.

Parameters:
ppointer to the player to be removed
size_t World::height ( ) const [virtual]

Get the map height.

Returns:
map height

Reimplemented from server::PathWorld.

bool World::is_vacant ( double  row,
double  col,
Character ignore 
) const [virtual]
Returns:
true iff the tile at the specified coordinate is not occupied by anything that would prevent a player from moving there.
Parameters:
rowcoordinate of top-left corner
colcoordinate of top-left corner
ignorepointer to Player to ignore

Reimplemented from server::PathWorld.

void World::join ( Player p)

Add a player to the queue for joining the world.

Parameters:
ppointer to player
net::maphash_t World::maphash ( )

Get the map hash.

Returns:
map hash
const std::string & World::mapname ( )

Get the map name.

Returns:
map name
void World::name_changed ( Player p)

Notify other players that a player has changed her name.

Parameters:
pplayer whose name changed
const PlayerPacket::pointer_t World::next_outgoing ( )

Gets a pointer to the next queued packet associated with this World.

Note:
does not remove the packet from the queue; call pop_outgoing for that.
Returns:
pointer to next PlayerPacket to be sent, or 0 (nullptr) if there is none.
const World & World::operator= ( const World o)

Same differences from default as copy constructor (since KDTree's operator= also optimises).

void World::packet ( net::data_t buf,
size_t  size,
Player p 
)

Process a packet from a client.

Parameters:
bufpacket data
sizesize (in bytes) of packet
ppeer from whom packet was sent
void World::pop_outgoing ( )

Discards a packet from the front of the queue of packets to be sent. Does nothing if the queue is empty.

void World::update ( double  dt)

Move all the players.

size_t World::width ( ) const [virtual]

Get the map width.

Returns:
map width

Reimplemented from server::PathWorld.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations