Sign in to follow this  
Followers 0
Charmaka

Museums and plugins

6 posts in this topic

I find myself in a bit of a quandary with regards to museums of other players and plugins. 

For ItemSorter (and now, ItemBags), lets say I want to check if another player has an item i just found in their museum.

The standard way of interacting with a museum now is cgCHA(ChaId).HasItemInMuseum( ItyId, ItrId ) (thanks for this Aaron), which first checks if the specified museum is loaded and requests it from the server if it is not. To see if a museum has already been loaded it checks cgCHA(ChaId).MuseumCollectionLoaded.

For your own character all of this works out nicely - museum is loaded and MuseumCollectionLoaded is set to true. Every few minutes (when a request is made against your own museum it seems) the server pushes out your own museum collection again in order to 'update' your museum client-side. I havent figured out what triggers this, but it all works nicely (and automatically) for your own museum.

For other people's museums, however, a few things happen differently.

  • MuseumCollectionLoaded may or may not be set to true for the museum of another player once you have requested it and loaded it.
  • When MuseumCollectionLoaded is stuck on false, checking if an item exists in another player's museum will request their museum from the server every time so it gets updated too often (and causes noticeable lag when its a big museum).
  • When MuseumCollectionLoaded is set to true, another player's museum is never updated for you after that.

i have not been able to figure out why sometimes MuseumCollectionLoaded gets stuck on false. All I know is that any attempt to set it to true fails and it is immediately set back to false.

Ideally there would be a happy medium, similar to how your own museum works, where once you request a player's museum it gets updated every now and then.

So my quandary is how to handle checking other people's museums when some museums update every request and others never update unless you force it to do cgCHA(Chaid).FetchMuseumCollectionFromServer()? What is the mechanism that triggers your own museum to be updated at intervals? How often is too often in terms of server resources and bandwidth consumption (museums of the top 30+ players are huge objects)?

 

On a side note:

The player side of me says "Cool - it keeps track of the names of items I have added to the museum!"

The plugin dev side of me says "Does anyone check item names in their museum? Or do they just look if the image is there/not there?"

I wonder if item names for museum items are necessary since they make the object data from the server much bigger (the following multiplied by 625 item types for a full museum):

"919":{"6":"Opposing Candy Skull of Buffett","2":"Mosquito Candy Skull","3":"Styptic Candy Skull of the Leprechaun","4":"Aphonic Candy Skull of Fogginess","5":"Thawing Candy Skull of the Professor","1":"Candy Skull"}

compared to

"919":{"1":true,"2":true,"3":true,"4":true,"5":true,"6":true,"7":false}

or even 

919:[0,1,1,1,1,1,1,0]

 

Edited by Charmaka

Share this post


Link to post
Share on other sites

Even further compression could be obtained by encoding each line as a single int using bit shifting

919:126 // ( = 0*1 + 1*2 + 1*4 + 1 * 8 + 1 * 16 + 1 * 32 + 1 * 64 + 0 * 128 )

Then just return an array of these

[ ..., 126, ...]

This will get us down to about 625 * 5 = 3k bytes per museum.

Of course if you want to go really crazy you can push that down even further.. Each entry fits in a char, so we could just pile them all into a string - but we cant quite because of unicode - so it needs to be a uuencoded buffer. That would get us down to about 625/3 * 4 = 832 bytes per museum. For comparison that single line of the museum
was 217b.

Even further would be to compress the buffer with a fast compression algorithm before uuencoding. (That way nearly empty museums would be almost zero bytes)

 

1 person likes this

Share this post


Link to post
Share on other sites
On 03/11/2016 at 8:49 AM, Charmaka said:

The plugin dev side of me says "Does anyone check item names in their museum? Or do they just look if the image is there/not there?"

The latter for me


0]

 

 

Share this post


Link to post
Share on other sites

Personally I would prefer to forget the specific item names and use just one byte per item. I already get the idea that the museum is slowing down page loading unnecessarily.

Share this post


Link to post
Share on other sites
3 hours ago, Nescio said:

Personally I would prefer to forget the specific item names and use just one byte per item. I already get the idea that the museum is slowing down page loading unnecessarily.

If you are not using the JungleCharmakaFixes plugin: _returnValues.toString().length

Those are all the past objects/data sent to you from the server. If you have a moderately full museum, without the plugin, that array will be huge (100mb+)  after just a few days.

And the amount of bandwidth that eats up is significant (bliss found that out the hard way when he had to use prepaid data to connect to doh from the hospital recently).

(For anyone interested, the other big contributor to _returnValues and bandwidth are the complete arrays of item ids for inv, mule, storage, keybag, and potionbag - all of which are sent each and every time a new item is dropped/opened/added.)

Share this post


Link to post
Share on other sites
24 minutes ago, Charmaka said:

(For anyone interested, the other big contributor to _returnValues and bandwidth are the complete arrays of item ids for inv, mule, storage, keybag, and potionbag - all of which are sent each and every time a new item is dropped/opened/added.)

Definitely feeling this effect every time I get a full mule....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0