Author Topic: Help !!! Want to grab objects information in sector .  (Read 348 times)

yliu182

  • Wayfarer
  • *
  • Posts: 5
    • View Profile
Help !!! Want to grab objects information in sector .
« on: March 16, 2012, 10:00:40 pm »
I have studied the source code of PlaneShift for a couple of weeks and wonder is it possible to develop a way to automatically grab the information of all the 3D objects in a map region. 

I know that in a game region, all the 3D objects information are stored in a map file (a xml or binary file), this map file will be loaded into the game engine, and tells the game engine that there is a tree at location A and there is a stone wall at location B. Based on this map file, the game engine will create a 3D world including all the objects. But in the source code, I cannot find where exactly this objects information has been stored when a map file is loaded. I hope to be able to grab these object information, such that when I play the game, every time when I enter into a new region, I can get a list of all the objects in this region and their locations.

If my understanding is correct, this should be doable, since the game engine should use this information to create and render the 3D world, the difficulty is how to grab this information and make it available to me.

I have been think about this problem for long time, hope there is someone in this forum who has idea about it, any suggestion and comment are highly appreciated. Thank you all !

Aiwendil

  • Hydlaa Citizen
  • *
  • Posts: 463
    • View Profile
Re: Help !!! Want to grab objects information in sector .
« Reply #1 on: March 17, 2012, 05:57:20 am »
I fear it's not as easy as you make it sound. Basically you have to make a difference between the map data and the item data. So your example with the tree coming from a xml file might be right (at least I think trees are no objects for PS) but this is not true for dropped items (or items places by GMs/devs on the map). So the xml files will contain nothing about the items at camp banish, the explorers camp, the interior of the RCD or all furnaces/anvils/preparation tables that have an item label. And of course the xml files don't contain infos about all items dropped by players.

Now lets assume you are only interested in the static geometry of the maps. Ahm yeah...I hope Rly is not around to read this now. ;) Well, the client (okay, in fact all parts of PS) load the map geometry through some magic in Background loader (src/plugins/common/bgloader/*). For gathering infos on objects src/plugins/common/bgloader/loader_objetcts.cpp might be most interesting for you. But as I said...the background loader is magic only RlyDontKnow understands. If it works great...if it doesn't...blame him. ;)

Now to the dynamic objects. Those are not in any xml files. Their position is saved in the item_instances database table (src/server/database/item_instances.sql). Of course only the PS server has access to that database table. As far as I understand it the server caches all items at the start with CacheManager::LoadWorldItems (src/server/cachemanager) and keeps them updated with src/server/bulkobjects/psitem.cpp.

And finally the client. As the client has no access to the database it gets it's infos about the dynamic objects through the network connection with the server. The majority of work happens here in src/client/pscelclient.cpp



But in the end I have no clue so what I said here might be very wrong. I'm not a PS dev so try to get hold of one of those to get better infos. And I don't really understand why you want infos about the objects at all. If you use PS as base of your own game you already have all those infos in the map xml files you created..and you have full access to the database storing all dynamic object data. If this is for PS I doubt client modifications allowing a player to have statistics about all objects in the current sector are allowed by the devs. So be careful what you do with these infos.