Planeshift
ZoneHandler Class Reference

Ensures all regions that need to be loaded are. More...

#include <zonehandler.h>

Public Member Functions

void HandleDelayAndAnim (int32_t loadDelay, csVector2 start, csVector2 dest, csString background, csString widgetName)
 Handles delay and dot animation. More...
 
void HandleMessage (MsgEntry *me)
 Handles messages from the server. More...
 
bool IsLoading () const
 Returns if this is loading a zone. More...
 
bool IsValid () const
 Returns whether the zone handler is valid. More...
 
void LoadZone (csVector3 pos, float yrot, const char *sector, csVector3 vel, bool force=false)
 Loads a zone and places the user into it. More...
 
void MovePlayerTo (const csVector3 &Pos, float yRot, const csString &newSector, const csVector3 &Vel)
 Moves player to given location. More...
 
void OnDrawingFinished ()
 Called after drawing on screen has finished. More...
 
 ZoneHandler (MsgHandler *mh, psCelClient *cc)
 Basic constructor. More...
 
virtual ~ZoneHandler ()
 Basic deconstructor. More...
 
- Public Member Functions inherited from psClientNetSubscriber
virtual void HandleMessage (MsgEntry *msg, Client *)
 Interprets a received message and executes the command. More...
 
virtual bool Verify (MsgEntry *, unsigned int, Client *&)
 
virtual ~psClientNetSubscriber ()
 

Protected Member Functions

bool FindLoadWindow (bool force=false, const char *widgetName="LoadWindow")
 Finds the loading window. More...
 
ZoneLoadInfoFindZone (const char *sector) const
 Finds load info for a specific sector. More...
 
bool LoadZoneInfo ()
 Extracts zone information out of a XML. More...
 

Protected Attributes

psCelClientcelclient
 Pointer to cel client instance. More...
 
csString forcedBackgroundImg
 String which holds the background of the loading screen. More...
 
csTicks forcedLoadingEndTime
 Holds how long the loading shall be delayed. More...
 
csTicks forcedLoadingStartTime
 Holds how long the loading shall be delayed. More...
 
csString forcedWidgetName
 Holds the widget name used to replace the load window. More...
 
size_t loadCount
 The number of items that are being loaded. More...
 
bool loading
 Whether a new zone is currently being loaded. More...
 
pawsProgressBarloadProgressBar
 Used for showing users load progress. More...
 
pawsLoadWindowloadWindow
 A load window that can be shown to users while loading. More...
 
psMoveState moveState
 
csRef< MsgHandlermsghandler
 Message Handler to subscribe to. More...
 
csVector3 newPos
 The target location the player will move to after loading. More...
 
csVector3 newVel
 The velocity the player will have after loading. More...
 
float newyrot
 The rotation the player will have after loading. More...
 
csString sectorToLoad
 The sector that needs to be loaded. More...
 
bool valid
 Whether the loading was successful. More...
 
csHash< ZoneLoadInfo *, const char * > zonelist
 Mapping of names of zones to their load info. More...
 

Detailed Description

Ensures all regions that need to be loaded are.

Listens for crossing sector boundaries and makes sure that we have all the right stuff loaded in each zone.

Definition at line 105 of file zonehandler.h.

Constructor & Destructor Documentation

ZoneHandler::ZoneHandler ( MsgHandler mh,
psCelClient cc 
)

Basic constructor.

Sets initial values and calls LoadZoneInfo(). Sets valid to true if everything checked out good

Parameters
mhThe message handler to subscribe messages to
ccUsed to get player information out of
virtual ZoneHandler::~ZoneHandler ( )
virtual

Basic deconstructor.

Member Function Documentation

bool ZoneHandler::FindLoadWindow ( bool  force = false,
const char *  widgetName = "LoadWindow" 
)
protected

Finds the loading window.

Checks if there is a loading window. If there is not a loading window or the loading window does not have a progress bar, false is returned.

Parameters
forceIf true it will force the window to be searched even if we have it already
widgetNameif defined it will hook the loading windows to the defined name
Returns
True if a valid window was found, false otherwise.
ZoneLoadInfo* ZoneHandler::FindZone ( const char *  sector) const
protected

Finds load info for a specific sector.

Searches zonelist for the key specified in sector. If it is not found null is returned and an error is printed

Parameters
sectorThe sector to look for
Returns
The load info for the sector or null
void ZoneHandler::HandleDelayAndAnim ( int32_t  loadDelay,
csVector2  start,
csVector2  dest,
csString  background,
csString  widgetName 
)

Handles delay and dot animation.

Parameters
loadDelayDelay of loading screen
startStart of dot animation
destDestination of dot animation
backgroundThe loading background
widgetNameThe name of the widget to use for this loading.
void ZoneHandler::HandleMessage ( MsgEntry me)
virtual

Handles messages from the server.

Handles psNewSectorMessage by loading the target zone and will call ForceLoadScreen if there is no load delay

Parameters
meThe message to create the psNewSectorMessage out of

Implements psClientNetSubscriber.

bool ZoneHandler::IsLoading ( ) const
inline

Returns if this is loading a zone.

Returns
loading

Definition at line 175 of file zonehandler.h.

bool ZoneHandler::IsValid ( ) const
inline

Returns whether the zone handler is valid.

Returns
valid

Definition at line 184 of file zonehandler.h.

void ZoneHandler::LoadZone ( csVector3  pos,
float  yrot,
const char *  sector,
csVector3  vel,
bool  force = false 
)

Loads a zone and places the user into it.

After the zone is found (from the sector parameter), the player is moved to a temporary off screen location. While there the loading screen is displayed and the zone is loaded. After the zone has finished loading, the player is moved to the target position.

Parameters
posThe target position in the new zone
yrotThe target rotation angle in the new zone
sectorThe name of the target zone
velTarget velocity
forceWhether to force the loading of the target zone
bool ZoneHandler::LoadZoneInfo ( )
protected

Extracts zone information out of a XML.

Checks "/planeshift/data/zoneinfo.xml" for a valid XML. Each element named "zone" under "zonelist" has a ZoneLoadInfo created out of it. All ZoneLoadInfo are then added to zonelist based on their sector

Returns
False if the file failed to load, true otherwise
void ZoneHandler::MovePlayerTo ( const csVector3 &  Pos,
float  yRot,
const csString &  newSector,
const csVector3 &  Vel 
)

Moves player to given location.

Parameters
PosTarget position to move to
newSectorTarget sector to move to
VelTarget velocity
void ZoneHandler::OnDrawingFinished ( )

Called after drawing on screen has finished.

Checks if player just crossed boundary between sectors and loads/unloads needed maps

Member Data Documentation

psCelClient* ZoneHandler::celclient
protected

Pointer to cel client instance.

Definition at line 192 of file zonehandler.h.

csString ZoneHandler::forcedBackgroundImg
protected

String which holds the background of the loading screen.

Definition at line 201 of file zonehandler.h.

csTicks ZoneHandler::forcedLoadingEndTime
protected

Holds how long the loading shall be delayed.

Definition at line 202 of file zonehandler.h.

csTicks ZoneHandler::forcedLoadingStartTime
protected

Holds how long the loading shall be delayed.

Definition at line 203 of file zonehandler.h.

csString ZoneHandler::forcedWidgetName
protected

Holds the widget name used to replace the load window.

Definition at line 204 of file zonehandler.h.

size_t ZoneHandler::loadCount
protected

The number of items that are being loaded.

Definition at line 205 of file zonehandler.h.

bool ZoneHandler::loading
protected

Whether a new zone is currently being loaded.

Definition at line 200 of file zonehandler.h.

pawsProgressBar* ZoneHandler::loadProgressBar
protected

Used for showing users load progress.

Definition at line 208 of file zonehandler.h.

pawsLoadWindow* ZoneHandler::loadWindow
protected

A load window that can be shown to users while loading.

Definition at line 207 of file zonehandler.h.

psMoveState ZoneHandler::moveState
protected

Definition at line 199 of file zonehandler.h.

csRef<MsgHandler> ZoneHandler::msghandler
protected

Message Handler to subscribe to.

Definition at line 191 of file zonehandler.h.

csVector3 ZoneHandler::newPos
protected

The target location the player will move to after loading.

Definition at line 196 of file zonehandler.h.

csVector3 ZoneHandler::newVel
protected

The velocity the player will have after loading.

Definition at line 197 of file zonehandler.h.

float ZoneHandler::newyrot
protected

The rotation the player will have after loading.

Definition at line 198 of file zonehandler.h.

csString ZoneHandler::sectorToLoad
protected

The sector that needs to be loaded.

Definition at line 195 of file zonehandler.h.

bool ZoneHandler::valid
protected

Whether the loading was successful.

Definition at line 194 of file zonehandler.h.

csHash<ZoneLoadInfo*, const char*> ZoneHandler::zonelist
protected

Mapping of names of zones to their load info.

Definition at line 190 of file zonehandler.h.


The documentation for this class was generated from the following file: