Project

General

Profile

« Previous | Next » 

Revision 82d6e038

Added by Leszek Koltunski over 4 years ago

Port changes to ObjectList from the deferred-jobs branch.

View differences:

src/main/java/org/distorted/objects/RubikObjectList.java
54 54
  ;
55 55

  
56 56
  public static final int NUM_OBJECTS = values().length;
57
  public static final int MAX_SIZE;
57
  public static final int MAX_NUM_OBJECTS;
58 58
  public static final int MAX_LEVEL;
59
  public static final int MAX_OBJECT_SIZE;
59 60

  
60 61
  private final int[] mObjectSizes, mMaxLevels, mIconIDs;
61 62
  private final Class<? extends RubikObject> mObjectClass;
......
66 67
  static
67 68
    {
68 69
    mNumAll = 0;
69
    int size, i = 0;
70
    int num, i = 0;
70 71
    objects = new RubikObjectList[NUM_OBJECTS];
71
    int maxSize  = Integer.MIN_VALUE;
72
    int maxLevel = Integer.MIN_VALUE;
72
    int maxNum  = Integer.MIN_VALUE;
73
    int maxLevel= Integer.MIN_VALUE;
74
    int maxSize = Integer.MIN_VALUE;
73 75

  
74 76
    for(RubikObjectList object: RubikObjectList.values())
75 77
      {
76 78
      objects[i] = object;
77 79
      i++;
78
      size = object.mObjectSizes.length;
79
      mNumAll += size;
80
      if( size> maxSize ) maxSize = size;
80
      num = object.mObjectSizes.length;
81
      mNumAll += num;
82
      if( num> maxNum ) maxNum = num;
81 83

  
82
      for(int j=0; j<size; j++)
84
      for(int j=0; j<num; j++)
83 85
        {
84 86
        if( object.mMaxLevels[j] > maxLevel ) maxLevel = object.mMaxLevels[j];
87
        if( object.mObjectSizes[j] > maxSize) maxSize  = object.mObjectSizes[j];
85 88
        }
86 89
      }
87 90

  
88
    MAX_SIZE = maxSize;
89
    MAX_LEVEL= maxLevel;
91
    MAX_NUM_OBJECTS = maxNum;
92
    MAX_LEVEL       = maxLevel;
93
    MAX_OBJECT_SIZE = maxSize;
90 94
    }
91 95

  
92 96
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/scores/RubikScores.java
27 27

  
28 28
import java.util.UUID;
29 29

  
30
import static org.distorted.objects.RubikObjectList.MAX_SIZE;
30
import static org.distorted.objects.RubikObjectList.MAX_NUM_OBJECTS;
31 31
import static org.distorted.objects.RubikObjectList.NUM_OBJECTS;
32 32
import static org.distorted.objects.RubikObjectList.MAX_LEVEL;
33 33

  
......
52 52

  
53 53
  private RubikScores()
54 54
    {
55
    mRecords   = new long[NUM_OBJECTS][MAX_SIZE][MAX_LEVEL];
56
    mSubmitted = new int [NUM_OBJECTS][MAX_SIZE][MAX_LEVEL];
55
    mRecords   = new long[NUM_OBJECTS][MAX_NUM_OBJECTS][MAX_LEVEL];
56
    mSubmitted = new int [NUM_OBJECTS][MAX_NUM_OBJECTS][MAX_LEVEL];
57 57

  
58 58
    for(int i=0; i<NUM_OBJECTS; i++)
59
      for(int j=0; j<MAX_SIZE; j++)
59
      for(int j=0; j<MAX_NUM_OBJECTS; j++)
60 60
        for(int k=0; k<MAX_LEVEL; k++)
61 61
          {
62 62
          mRecords[i][j][k]   = NO_RECORD;
......
235 235
            time = Long.parseLong(timeStr);
236 236
            subm = Integer.parseInt(submStr);
237 237

  
238
            if( sizeIndex>=0 && sizeIndex<MAX_SIZE && subm>=0 && subm<=1 )
238
            if( sizeIndex>=0 && sizeIndex<MAX_NUM_OBJECTS && subm>=0 && subm<=1 )
239 239
              {
240 240
              mRecords  [object][sizeIndex][level] = time;
241 241
              mSubmitted[object][sizeIndex][level] = subm;
......
309 309
    mNameIsVerified = true;
310 310

  
311 311
    for(int i=0; i<NUM_OBJECTS; i++)
312
      for(int j=0; j<MAX_SIZE   ; j++)
312
      for(int j=0; j<MAX_NUM_OBJECTS; j++)
313 313
        for(int k=0; k<MAX_LEVEL; k++)
314 314
          {
315 315
          mSubmitted[i][j][k]=1;

Also available in: Unified diff