Page 1 of 1

Token knowing its zone

Posted: Thu Jan 30, 2014 9:31 am
by Virenerus
Hey. While going through the API I found the token does not actually know on which zone it is. Most functions that want to get the zone of a layer just use the current one. Is there a particular reason for it? Any serialization that does not support cyclical references or something?

Would be cool if someone knows this.
Thanks guys.

Re: Token knowing its zone

Posted: Thu Jan 30, 2014 10:37 am
by aliasmask
Out of curiosity, is the term "zone" a java thing or do you mean the token layer?

Re: Token knowing its zone

Posted: Thu Jan 30, 2014 10:52 am
by Virenerus
Zone / Zonerenderer is the representation of a map in the code.

Re: Token knowing its zone

Posted: Thu Jan 30, 2014 2:19 pm
by Lee
I think you most likely saw that each zone is aware of what tokens are on it. When it serializes it carries the token's GUID (I think). A token is not aware of what zone it's in because a copy of the token can exist on different zones, even library types (even if that would cause crazy **** to happen), making it a dubious field to have. I'm not saying it's the right way, and heaven knows how horrible the token search methodology is in the main source (i.e. iterate through zones, iterate through tokens within the zone). What's worse is, with this scheme, copies of a token found in other zones do not get updated when the token's model changes.

You're likely going to rewrite/refactor the models like I did, so good luck with that :lol:

Again, a better "token" architecture has been discussed for 2.0 where there is only one instance of the model, and potentially many copies of its image asset across all maps. Search the forums, if you're interested.