EnderWiggin / Custom-Salem

client for Salem MMO
Other
22 stars 23 forks source link

Adding tooltip for item weight. #15

Open ecraven opened 9 years ago

ecraven commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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