Planeshift
Public Member Functions | Protected Member Functions | Protected Attributes

ZoneHandler Class Reference

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

#include <zonehandler.h>

List of all members.

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

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

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.

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.

Used for showing users load progress.

Definition at line 208 of file zonehandler.h.

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

Definition at line 207 of file zonehandler.h.

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.

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: