Changeset 373b1b806ea5e64aaeaeb9e0ec0e0a38908d6b5e

Show
Ignore:
Timestamp:
05/22/08 19:13:37 (5 months ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1211476417 +0200
git-parent:

[325fbc928af7eb9110e8e82e634cc619be16e294]

git-author:
Christopher Jung <bktheg@web.de> 1211476417 +0200
Message:

[ref] ContextVars? der Waffenfabrik wird nun ueber Context.get stat Context.getVariable angesteuert

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/net/driftingsouls/ds2/server/bases/Waffenfabrik.java

    rc6fe5ae r373b1b8  
    4949import net.driftingsouls.ds2.server.framework.Configuration; 
    5050import net.driftingsouls.ds2.server.framework.Context; 
     51import net.driftingsouls.ds2.server.framework.ContextInstance; 
    5152import net.driftingsouls.ds2.server.framework.ContextMap; 
    5253import net.driftingsouls.ds2.server.framework.templates.TemplateEngine; 
     
    6566@DiscriminatorValue("net.driftingsouls.ds2.server.bases.Waffenfabrik") 
    6667public class Waffenfabrik extends DefaultBuilding { 
    67         private static class ContextVars { 
     68        /** 
     69         * Daten von einer oder mehreren Waffenfabriken 
     70         */ 
     71        @ContextInstance(ContextInstance.Scope.REQUEST) 
     72        public static class ContextVars { 
    6873                Set<Ammo> ownerammobase = new HashSet<Ammo>(); 
    6974                Map<Integer,Cargo> stats = new HashMap<Integer,Cargo>(); 
    7075                Map<Integer,BigDecimal> usedcapacity = new HashMap<Integer,BigDecimal>(); 
    71                  
    72                 protected ContextVars() { 
     76                boolean init = false; 
     77                 
     78                public ContextVars() { 
    7379                        // EMPTY 
    7480                } 
     
    8894                User user = base.getOwner(); 
    8995                 
    90                 ContextVars vars = (ContextVars)context.getVariable(getClass(), "values"); 
     96                ContextVars vars = context.get(ContextVars.class); 
    9197                Integer lastUser = (Integer)context.getVariable(getClass(), "last_user"); 
    9298                 
    9399                List<Ammo> removelist = new ArrayList<Ammo>(); 
    94100                 
    95                 if( (vars == null) || (user.getId() != lastUser.intValue()) ) { 
    96                         vars = new ContextVars(); 
    97                         context.putVariable(getClass(), "values", vars); 
     101                if( (vars.init == false) || (user.getId() != lastUser.intValue()) ) { 
     102                        vars.init = true; 
    98103                        context.putVariable(getClass(), "last_user", user.getId()); 
    99104                 
     
    297302                 
    298303                loaddata( base ); 
    299                 ContextVars vars = (ContextVars)ContextMap.getContext().getVariable(getClass(), "values"); 
     304                ContextVars vars = ContextMap.getContext().get(ContextVars.class); 
    300305         
    301306                if( vars.usedcapacity.get(base.getId()).doubleValue() > 0 ) { 
     
    332337        public boolean isActive(Base base, int status, int field) { 
    333338                loaddata( base ); 
    334                 ContextVars vars = (ContextVars)ContextMap.getContext().getVariable(getClass(), "values"); 
     339                ContextVars vars = ContextMap.getContext().get(ContextVars.class); 
    335340                if( vars.usedcapacity.get(base.getId()).doubleValue() > 0 ) { 
    336341                        return true; 
     
    345350                 
    346351                Context context = ContextMap.getContext(); 
    347                 ContextVars vars = (ContextVars)context.getVariable(getClass(), "values"); 
     352                ContextVars vars = context.get(ContextVars.class); 
    348353                Map<Integer,Boolean> colcomplete = (Map<Integer,Boolean>)context.getVariable(getClass(), "colcomplete"); 
    349354                if( colcomplete == null ) {