Changeset 373b1b806ea5e64aaeaeb9e0ec0e0a38908d6b5e
- 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
| rc6fe5ae |
r373b1b8 |
|
| 49 | 49 | import net.driftingsouls.ds2.server.framework.Configuration; |
|---|
| 50 | 50 | import net.driftingsouls.ds2.server.framework.Context; |
|---|
| | 51 | import net.driftingsouls.ds2.server.framework.ContextInstance; |
|---|
| 51 | 52 | import net.driftingsouls.ds2.server.framework.ContextMap; |
|---|
| 52 | 53 | import net.driftingsouls.ds2.server.framework.templates.TemplateEngine; |
|---|
| … | … | |
| 65 | 66 | @DiscriminatorValue("net.driftingsouls.ds2.server.bases.Waffenfabrik") |
|---|
| 66 | 67 | public 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 { |
|---|
| 68 | 73 | Set<Ammo> ownerammobase = new HashSet<Ammo>(); |
|---|
| 69 | 74 | Map<Integer,Cargo> stats = new HashMap<Integer,Cargo>(); |
|---|
| 70 | 75 | Map<Integer,BigDecimal> usedcapacity = new HashMap<Integer,BigDecimal>(); |
|---|
| 71 | | |
|---|
| 72 | | protected ContextVars() { |
|---|
| | 76 | boolean init = false; |
|---|
| | 77 | |
|---|
| | 78 | public ContextVars() { |
|---|
| 73 | 79 | // EMPTY |
|---|
| 74 | 80 | } |
|---|
| … | … | |
| 88 | 94 | User user = base.getOwner(); |
|---|
| 89 | 95 | |
|---|
| 90 | | ContextVars vars = (ContextVars)context.getVariable(getClass(), "values"); |
|---|
| | 96 | ContextVars vars = context.get(ContextVars.class); |
|---|
| 91 | 97 | Integer lastUser = (Integer)context.getVariable(getClass(), "last_user"); |
|---|
| 92 | 98 | |
|---|
| 93 | 99 | List<Ammo> removelist = new ArrayList<Ammo>(); |
|---|
| 94 | 100 | |
|---|
| 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; |
|---|
| 98 | 103 | context.putVariable(getClass(), "last_user", user.getId()); |
|---|
| 99 | 104 | |
|---|
| … | … | |
| 297 | 302 | |
|---|
| 298 | 303 | loaddata( base ); |
|---|
| 299 | | ContextVars vars = (ContextVars)ContextMap.getContext().getVariable(getClass(), "values"); |
|---|
| | 304 | ContextVars vars = ContextMap.getContext().get(ContextVars.class); |
|---|
| 300 | 305 | |
|---|
| 301 | 306 | if( vars.usedcapacity.get(base.getId()).doubleValue() > 0 ) { |
|---|
| … | … | |
| 332 | 337 | public boolean isActive(Base base, int status, int field) { |
|---|
| 333 | 338 | loaddata( base ); |
|---|
| 334 | | ContextVars vars = (ContextVars)ContextMap.getContext().getVariable(getClass(), "values"); |
|---|
| | 339 | ContextVars vars = ContextMap.getContext().get(ContextVars.class); |
|---|
| 335 | 340 | if( vars.usedcapacity.get(base.getId()).doubleValue() > 0 ) { |
|---|
| 336 | 341 | return true; |
|---|
| … | … | |
| 345 | 350 | |
|---|
| 346 | 351 | Context context = ContextMap.getContext(); |
|---|
| 347 | | ContextVars vars = (ContextVars)context.getVariable(getClass(), "values"); |
|---|
| | 352 | ContextVars vars = context.get(ContextVars.class); |
|---|
| 348 | 353 | Map<Integer,Boolean> colcomplete = (Map<Integer,Boolean>)context.getVariable(getClass(), "colcomplete"); |
|---|
| 349 | 354 | if( colcomplete == null ) { |
|---|