Skip to content

Conversation

@ecraven
Copy link

@ecraven ecraven commented Mar 19, 2015

Item weight is calculated when an item is taken (to the mouse cursor)
and then shown in the tooltip.
Item weight data is persisted across sessions in Salem/itemWeight.ser.

Item weight is calculated when an item is taken (to the mouse cursor)
and then shown in the tooltip.
Item weight data is persisted across sessions in Salem/itemWeight.ser.
@ecraven
Copy link
Author

ecraven commented Mar 19, 2015

Note, this is probably some of the ugliest code I've ever written. It does the following:
It intercepts "weight" messages in GameUI, to calculate the weight change.
It intercepts the "take" message in WItem, to know which item is being taken.
The actual weight calculation is in GameUI, which knows which item is taken and how much it weighs. It has a hashtable (serialized and deserialized to keep the information across sessions) of resource name -> double.
It works fine, however it is definitely not nice (so much interconnection between theoretically unrelated components).
Please comment on whether there's any chance you'll accept this (with any changes you may want), until the server actually sends weights...

@LOMS
Copy link

LOMS commented Mar 20, 2015

Well, you can't use resname as a key. Buckets with liquids can weight different, gear with diffirent slots will have different weight, bags can weight different, piles of something can weight different etc.

@ecraven
Copy link
Author

ecraven commented Mar 20, 2015

LOMS: yes, however I don't think there is any correct way of handling those without the server explicitly sending the weights. I'd rather have mostly correct weights than no weights at all :) I've been testing this for some hours of playing, it seems to work fine so far (except for the problems with items that can weight different weights, but as I said, I don't think we can solve this client-side).
Note: there's no problem with weight-reducing containers like backpacks, the server reports the correct weight when they are taken.

@ecraven
Copy link
Author

ecraven commented Mar 20, 2015

also, clay pots for example do not change weight if they contain less or more fluid..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants