| Prev | Next |
Except database resources, in OTServ you have another source of data - data/ directory. It contains all files essential for world content like map, spells, items definitions etc. which are stored in physical disk files (usualy XML, but sometimes also in binary format). POT provides classes to handle also those resources. Each kind of resource has it's list classes. Many of them also has single object classes but not every.
Note that unlike database resources, data/ directory resources lists doesnt contain underline (_) before "List" part of class name.
All list classes (except OTS_SpellsList) are simple aggregators for single items. All of those lists implements Iterator, Countable and ArrayAccess interfaces. It means that they can be used nearly as pure arrays - you can use then in foreach loop, count items within them using simple count() call and access items by using array acces operators (square brackets).
Vocations list is the most simple resource - vocations file contains just IDs-names pairs assignments. Vocations list only translates vocation ID into it's name and vice-versa:
Vocations are simple string names, there is no objective wrapper for it.
Monsters list class is also not very complicated - only differences are that you put monsters directory path, not any particular file name; also monsters are represented by objects not by simple strings.
Next resource is items list. To load it you have to create instance of OTS_ItemsList class and pass items directory path as constructor's parameter. It will load both items.xml file (definitions of item types) and items.otb (additional info and IDs mapping).
Warning - items are stored in both XML (items.xml) and binary (items.otb) files. Loading binary files in PHP is extremly slow as well as items.xml file is quite big usualy so loading it also takes much time. To speed it up you should use cache drivers.
A bit different then other resource lists is spells list - it does not implement any of interfaces mentiones in previous paragraph. It contains 3 sub-arrays which are groups of spells: conjures, instants and runes. Every spell is represented by OTS_Spell class object.
POT can parse binary map format - OTBM (this is the only map format supported by POT as it is the only currently supported map format by OTServ). OTBM format is extended case of general OTB format. Map file can be loaded with OTS_OTBMFile class. Loaded map acts also as towns list:
Warning - loading binary OTBM files in PHP is extremly slow as well as map files are usualy quite big. To speed it up you should use cache drivers.
When map is loaded it can also contain reference to external houses list - if so, then you can fetch this list by calling OTS_OTBMFile::getHousesList.
Houses list is usualy connected with map file, but you can also load it directly by creating instance of OTS_HousesList class.
All those resources are parts of entire POT enviroment. They are necessary for some routines - for example player's items managing requires items list to be loaded. But created instances of those resources are only local. You can create them freely but they doesn't affect other parts of POT. In order to load those resources globaly into POT instance you will have to read about global resources.
| Prev | Up | Next |
| List objects | POT | Global resources |