POT
POT
POT
Main menu

Download

Forum

SVN

Class: OTS_OTBMFile

Source Location: /classes/OTS_OTBMFile.php

Class OTS_OTBMFile

Class Overview

Implements interfaces:

  • IteratorAggregate (internal interface)
  • Countable (internal interface)
  • ArrayAccess (internal interface)

OTBM format reader.

OTBM format reader. POT OTBM file parser is less strict then oryginal OTServ one. For instance it will read waypoints from version 1 OTBM file even that there were no waypoints in that format.

Located in /classes/OTS_OTBMFile.php [line 38]

OTS_FileLoader
   |
   --OTS_OTBMFile
Author(s):
API Tags:
Property-read:  OTS_HousesList $housesList: Houses list loaded from associated houses file.
Property-read:  int $width: Map width.
Property-read:  int $height: Map height.
Property-read:  string $description: Map description.
Property-read:  array $waypoints: List of tracks on map.
Example:  otbm.php

Information Tags:
Tutorial:  data/ directory resources
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From OTS_FileLoader

OTS_FileLoader::$cache
OTS_FileLoader::$root

Inherited From OTS_FileLoader

OTS_FileLoader::loadFile()
Opens file.
OTS_FileLoader::setCacheDriver()
Sets cache handler.
OTS_FileLoader::__clone()
Creates clone of object.
OTS_FileLoader::__set()
Magic PHP5 method.
OTS_FileLoader::__set_state()
Magic PHP5 method.
OTS_FileLoader::__sleep()
Magic PHP5 method.

Inherited From OTS_FileLoader

OTS_FileLoader::ESCAPE_CHAR
OTS_FileLoader::NODE_END
OTS_FileLoader::NODE_START

[ Top ]
Constant Summary
OTBM_ATTR_ACTION_ID   Action ID.
OTBM_ATTR_CHARGES   Number of charges.
OTBM_ATTR_COUNT   Amount.
OTBM_ATTR_DECAYING_STATE   Metamorphic stage.
OTBM_ATTR_DEPOT_ID   Depot ID.
OTBM_ATTR_DESC   Description.
OTBM_ATTR_DESCRIPTION   Description attribute.
OTBM_ATTR_DURATION   Time interval.
OTBM_ATTR_EXT_FILE   External file.
OTBM_ATTR_EXT_HOUSE_FILE   External houses file.
OTBM_ATTR_EXT_SPAWN_FILE   External spawns file.
OTBM_ATTR_HOUSEDOORID   ID of doors.
OTBM_ATTR_ITEM   Item.
OTBM_ATTR_RUNE_CHARGES   Rune changes amount.
OTBM_ATTR_SLEEPERGUID   Sleeping player ID.
OTBM_ATTR_SLEEPSTART   Time of sleep started.
OTBM_ATTR_TELE_DEST   Teleport destination.
OTBM_ATTR_TEXT   Text.
OTBM_ATTR_TILE_FLAGS   Tile flags.
OTBM_ATTR_UNIQUE_ID   Unique ID.
OTBM_ATTR_WRITTENBY   Sign author.
OTBM_ATTR_WRITTENDATE   Date of being written.
OTBM_NODE_HOUSETILE   Tile of house.
OTBM_NODE_ITEM   Item.
OTBM_NODE_ITEM_DEF   Item definition.
OTBM_NODE_MAP_DATA   Map data container.
OTBM_NODE_MONSTER   Monster.
OTBM_NODE_ROOTV1   Root node.
OTBM_NODE_SPAWNS   Spawns container.
OTBM_NODE_SPAWN_AREA   Spawn.
OTBM_NODE_TILE   Single tile.
OTBM_NODE_TILE_AREA   Map tiles fragment.
OTBM_NODE_TILE_REF   Tile reference.
OTBM_NODE_TILE_SQUARE   Tile.
OTBM_NODE_TOWN   Town.
OTBM_NODE_TOWNS   Towns container.
OTBM_NODE_WAYPOINT   Waypoint.
OTBM_NODE_WAYPOINTS   Waypoints list.

[ Top ]
Property Summary
array   $waypoints   List of map tracks.

[ Top ]
Method Summary
int   count()   Returns amount of towns loaded.
string   current()  
string   getDescription()   Returns map description.
int   getHeight()   Returns map height.
OTS_HousesList   getHousesList()   Loads map's houses list.
ArrayIterator   getIterator()   Returns iterator handle for loops.
int   getTownID()   Returns town's ID.
string   getTownName()   Returns name of given town's ID.
array   getTownsList()  
OTS_MapCoords|bool   getTownTemple()   Returns town's temple position.
array   getWaypointsList()   Returns map waypoints list.
int   getWidth()   Returns map width.
bool   hasTownId()   Checks if given town ID exists on list.
bool   hasTownName()   Checks if given town name exists on list.
int   key()  
void   loadFile()   Loads OTBM file content.
void   next()  
bool   offsetExists()   Checks if given element exists.
mixed   offsetGet()   Returns item from given position.
void   offsetSet()   This method is implemented for ArrayAccess interface.
void   offsetUnset()   This method is implemented for ArrayAccess interface.
void   rewind()  
bool   valid()  
mixed   __get()   Magic PHP5 method.
string   __toString()   Returns string representation of object.
void   __wakeup()   Magic PHP5 method.

[ Top ]
Properties
array   $waypoints = array() [line 280]

List of map tracks.

List of map tracks.

API Tags:
Access:  protected

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
Methods
count  [line 633]

  int count( )

Returns amount of towns loaded.

Returns amount of towns loaded.


API Tags:
Return:  Count of towns.
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.6
Since:  0.0.6
Since:  0.0.8

Implementation of:
Countable::count

[ Top ]
current  [line 644]

  string current( )


API Tags:
Return:  Town name.
Deprecated:  0.1.0 Use getIterator().
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.6
Since:  0.0.8
Since:  0.0.6

[ Top ]
getDescription  [line 514]

  string getDescription( )

Returns map description.

Returns map description.


API Tags:
Return:  Map description.
Access:  public

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
getHeight  [line 504]

  int getHeight( )

Returns map height.

Returns map height.


API Tags:
Return:  Map height.
Access:  public

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
getHousesList  [line 484]

  OTS_HousesList getHousesList( )

Loads map's houses list.

Loads map's houses list.


API Tags:
Return:  Houses from external file.
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Since:  0.0.6
Since:  0.1.0

[ Top ]
getIterator  [line 698]

  ArrayIterator getIterator( )

Returns iterator handle for loops.

Returns iterator handle for loops.


API Tags:
Return:  Towns list iterator.
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Since:  0.0.6
Since:  0.1.0

Implementation of:
IteratorAggregate::getIterator

[ Top ]
getTownID  [line 556]

  int getTownID( string $name  )

Returns town's ID.

Returns town's ID.

Parameters:
string   $name:  Town.

API Tags:
Return:  ID.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.6
Throws:  OutOfBoundsException If not found.
Since:  0.0.6

[ Top ]
getTownName  [line 589]

  string getTownName( int $id  )

Returns name of given town's ID.

Returns name of given town's ID.

Parameters:
int   $id:  Town ID.

API Tags:
Return:  Name.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.6
Throws:  OutOfBoundsException If not found.
Since:  0.0.6

[ Top ]
getTownsList  [line 603]

  array getTownsList( )


API Tags:
Return:  List of towns.
Deprecated:  0.1.0 Use this class object as array for iterations, counting and methods for field fetching.
Access:  public

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
getTownTemple  [line 614]

  OTS_MapCoords|bool getTownTemple( int $id  )

Returns town's temple position.

Returns town's temple position.

Parameters:
int   $id:  Town id.

API Tags:
Return:  Point on map (false if not found).
Access:  public

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
getWaypointsList  [line 530]

  array getWaypointsList( )

Returns map waypoints list.

Returns map waypoints list. Each item of returned array is sub-array with list of waypoints.


API Tags:
Return:  List of tracks.
Access:  public

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
getWidth  [line 494]

  int getWidth( )

Returns map width.

Returns map width.


API Tags:
Return:  Map width.
Access:  public

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
hasTownId  [line 543]

  bool hasTownId( int $id  )

Checks if given town ID exists on list.

Checks if given town ID exists on list.

Parameters:
int   $id:  ID.

API Tags:
Return:  If town is set then true.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.6
Since:  0.0.6
Since:  0.1.3

[ Top ]
hasTownName  [line 576]

  bool hasTownName( string $name  )

Checks if given town name exists on list.

Checks if given town name exists on list.

Parameters:
string   $name:  Town.

API Tags:
Return:  If town is set then true.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.6
Since:  0.0.6
Since:  0.1.3

[ Top ]
key  [line 665]

  int key( )


API Tags:
Return:  Current position key.
Deprecated:  0.1.0 Use getIterator().
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.6
Since:  0.0.8
Since:  0.0.6

[ Top ]
loadFile  [line 305]

  void loadFile( string $file  )

Loads OTBM file content.

Loads OTBM file content.

Parameters:
string   $file:  Filename.

API Tags:
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Throws:  E_OTS_FileLoaderError When error occurs during file operation.
Since:  0.0.6
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of stream.

Redefinition of:
OTS_FileLoader::loadFile()
Opens file.

[ Top ]
next  [line 654]

  void next( )


API Tags:
Deprecated:  0.1.0 Use getIterator().
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.6
Since:  0.0.8
Since:  0.0.6

[ Top ]
offsetExists  [line 711]

  bool offsetExists( string|int $offset  )

Checks if given element exists.

Checks if given element exists.

Parameters:
string|int   $offset:  Array key.

API Tags:
Return:  True if it's set.
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Since:  0.0.6
Since:  0.1.0

Implementation of:
ArrayAccess::offsetExists

[ Top ]
offsetGet  [line 733]

  mixed offsetGet( string|int $offset  )

Returns item from given position.

Returns item from given position.

Parameters:
string|int   $offset:  Array key.

API Tags:
Return:  If key is an integer (type-sensitive!) then returns town name. If it's a string then return associated ID found by town name. False if offset is not set.
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Since:  0.0.6
Since:  0.1.0

Implementation of:
ArrayAccess::offsetGet

[ Top ]
offsetSet  [line 764]

  void offsetSet( string|int $offset, mixed $value  )

This method is implemented for ArrayAccess interface.

This method is implemented for ArrayAccess interface. In fact you can't write/append to towns list. Any call to this method will cause E_OTS_ReadOnly raise.

Parameters:
string|int   $offset:  Array key.
mixed   $value:  Field value.

API Tags:
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Throws:  E_OTS_ReadOnly Always - this class is read-only.
Since:  0.1.0
Since:  0.0.6

Implementation of:
ArrayAccess::offsetSet

[ Top ]
offsetUnset  [line 777]

  void offsetUnset( string|int $offset  )

This method is implemented for ArrayAccess interface.

This method is implemented for ArrayAccess interface. In fact you can't write/append to towns list. Any call to this method will cause E_OTS_ReadOnly raise.

Parameters:
string|int   $offset:  Array key.

API Tags:
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Throws:  E_OTS_ReadOnly Always - this class is read-only.
Since:  0.1.0
Since:  0.0.6

Implementation of:
ArrayAccess::offsetUnset

[ Top ]
rewind  [line 686]

  void rewind( )


API Tags:
Deprecated:  0.1.0 Use getIterator().
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.6
Since:  0.0.8
Since:  0.0.6

[ Top ]
valid  [line 676]

  bool valid( )


API Tags:
Return:  If iterator has anything more.
Deprecated:  0.1.0 Use getIterator().
Access:  public

Information Tags:
Version:  0.0.8
Version:  0.0.6
Since:  0.0.8
Since:  0.0.6

[ Top ]
__get  [line 791]

  mixed __get( string $name  )

Magic PHP5 method.

Magic PHP5 method.

Parameters:
string   $name:  Property name.

API Tags:
Return:  Property value.
Access:  public

Information Tags:
Version:  0.1.0
Version:  0.0.6
Throws:  OutOfBoundsException For non-supported properties.
Since:  0.1.0
Since:  0.0.6

[ Top ]
__toString  [line 826]

  string __toString( )

Returns string representation of object.

Returns string representation of object. If any display driver is currently loaded then it uses it's method.


API Tags:
Return:  String representation of object.
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.0.6
Since:  0.0.6
Since:  0.1.3

[ Top ]
__wakeup  [line 291]

  void __wakeup( )

Magic PHP5 method.

Magic PHP5 method. Allows object unserialisation.


API Tags:
Access:  public

Information Tags:
Version:  0.0.6
Throws:  E_OTS_FileLoaderError When error occurs during file operation.
Since:  0.0.6

[ Top ]
Constants
OTBM_ATTR_ACTION_ID = 4 [line 55]

Action ID.

Action ID.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_CHARGES = 22 [line 151]

Number of charges.

Number of charges.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_COUNT = 15 [line 102]

Amount.

Amount.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_DECAYING_STATE = 17 [line 116]

Metamorphic stage.

Metamorphic stage.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_DEPOT_ID = 10 [line 79]

Depot ID.

Depot ID.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_DESC = 7 [line 67]

Description.

Description.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_DESCRIPTION = 1 [line 43]

Description attribute.

Description attribute.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_DURATION = 16 [line 109]

Time interval.

Time interval.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_EXT_FILE = 2 [line 47]

External file.

External file.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_EXT_HOUSE_FILE = 13 [line 91]

External houses file.

External houses file.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_EXT_SPAWN_FILE = 11 [line 83]

External spawns file.

External spawns file.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_HOUSEDOORID = 14 [line 95]

ID of doors.

ID of doors.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_ITEM = 9 [line 75]

Item.

Item.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_RUNE_CHARGES = 12 [line 87]

Rune changes amount.

Rune changes amount.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_SLEEPERGUID = 20 [line 137]

Sleeping player ID.

Sleeping player ID.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_SLEEPSTART = 21 [line 144]

Time of sleep started.

Time of sleep started.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_TELE_DEST = 8 [line 71]

Teleport destination.

Teleport destination.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_TEXT = 6 [line 63]

Text.

Text.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_TILE_FLAGS = 3 [line 51]

Tile flags.

Tile flags.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_UNIQUE_ID = 5 [line 59]

Unique ID.

Unique ID.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_ATTR_WRITTENBY = 19 [line 130]

Sign author.

Sign author.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_ATTR_WRITTENDATE = 18 [line 123]

Date of being written.

Date of being written.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_NODE_HOUSETILE = 14 [line 208]

Tile of house.

Tile of house.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_ITEM = 6 [line 176]

Item.

Item.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_ITEM_DEF = 3 [line 164]

Item definition.

Item definition.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_MAP_DATA = 2 [line 160]

Map data container.

Map data container.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_MONSTER = 11 [line 196]

Monster.

Monster.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_ROOTV1 = 1 [line 156]

Root node.

Root node.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_SPAWNS = 9 [line 188]

Spawns container.

Spawns container.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_SPAWN_AREA = 10 [line 192]

Spawn.

Spawn.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_TILE = 5 [line 172]

Single tile.

Single tile.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_TILE_AREA = 4 [line 168]

Map tiles fragment.

Map tiles fragment.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_TILE_REF = 8 [line 184]

Tile reference.

Tile reference.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_TILE_SQUARE = 7 [line 180]

Tile.

Tile.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_TOWN = 13 [line 204]

Town.

Town.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_TOWNS = 12 [line 200]

Towns container.

Towns container.

Information Tags:
Version:  0.0.6
Since:  0.0.6

[ Top ]
OTBM_NODE_WAYPOINT = 16 [line 222]

Waypoint.

Waypoint.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]
OTBM_NODE_WAYPOINTS = 15 [line 215]

Waypoints list.

Waypoints list.

Information Tags:
Version:  0.1.6
Version:  0.0.6
Since:  0.0.6
Since:  0.1.6

[ Top ]