Token knowing its zone

The RPTools applications are written in Java. If you're interested in contributing to any project here by submitting patches to the source code, this is the forum to ask questions about how to do so. Please put the two-letter tool name abbreviation in your thread Title. To enter this group, go to the Usergroups page of your User Control Panel and join the Java Developer group.

Moderators: Azhrei, dorpond, trevor

Post Reply
Virenerus
Cave Troll
Posts: 36
Joined: Fri Jan 17, 2014 9:13 pm

Token knowing its zone

Post 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.

User avatar
aliasmask
Deity
Posts: 8579
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Token knowing its zone

Post by aliasmask »

Out of curiosity, is the term "zone" a java thing or do you mean the token layer?

Virenerus
Cave Troll
Posts: 36
Joined: Fri Jan 17, 2014 9:13 pm

Re: Token knowing its zone

Post by Virenerus »

Zone / Zonerenderer is the representation of a map in the code.

Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: Token knowing its zone

Post 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.

Post Reply

Return to “Java Programming Info”