From f3f810b49ffb694b35385365a798dd1293d74188 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Tue, 6 Mar 2007 22:38:33 +0000 Subject: [PATCH] Change the meaning of holdsToken(): now the token(s) specified must be EXACTLY held. I think this is ok because all callers currently pass a single token at a time, but I have not verified this for every project. Please verify this for your project! Added holdsAnyToken() which has the old behavior of returning true if any bit is on. I think we should change all the projects' various isSupportPlus() methods to be just called isSupport() and those will return holdsAnyToken(SUPPORT | ADMIN | etc); If you need to check if a user has a single SUPPORT token but is not an admin, you can do that by hand. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4617 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/crowd/data/TokenRing.as | 15 +++++++++++++-- src/java/com/threerings/crowd/data/TokenRing.java | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/as/com/threerings/crowd/data/TokenRing.as b/src/as/com/threerings/crowd/data/TokenRing.as index 8c0bddb9a..f9f2239ff 100644 --- a/src/as/com/threerings/crowd/data/TokenRing.as +++ b/src/as/com/threerings/crowd/data/TokenRing.as @@ -74,11 +74,22 @@ public class TokenRing extends SimpleStreamableObject } /** - * Returns true if this token ring contains the specified token. + * Returns true if this token ring contains the specified token or tokens, + * exactly. + * For example, if you pass in the OR of two or more tokens, + * then the ring must contain all of those tokens. */ public function holdsToken (token :int) :Boolean { - return (_tokens & token) != 0; + return (_token & token) == token; + } + + /** + * Returns true if this token ring contains any one of the specified tokens. + */ + public function holdsAnyToken (tokens :int) :Boolean + { + return (_tokens & tokens) != 0; } /** diff --git a/src/java/com/threerings/crowd/data/TokenRing.java b/src/java/com/threerings/crowd/data/TokenRing.java index 824368e8e..67f764a1a 100644 --- a/src/java/com/threerings/crowd/data/TokenRing.java +++ b/src/java/com/threerings/crowd/data/TokenRing.java @@ -49,11 +49,22 @@ public class TokenRing extends SimpleStreamableObject } /** - * Returns true if this token ring contains the specified token. + * Returns true if this token ring contains the specified token or tokens, + * exactly. + * For example, if you pass in the OR of two or more tokens, + * then the ring must contain all of those tokens. */ public boolean holdsToken (int token) { - return (_tokens & token) != 0; + return (_tokens & token) == token; + } + + /** + * Returns true if this token ring contains any one of the specified tokens. + */ + public boolean holdsAnyToken (int tokens) + { + return (_tokens & tokens) != 0; } /**