@@ -17,18 +17,18 @@ public class UpdateServer implements IUpdateServer {
17
17
private Buffer fileDataBuffer = new Buffer (8 );
18
18
private Buffer inboundFile ;
19
19
private Buffer crcTableBuffer ;
20
- private HashTable immediateWriteQueue = new HashTable (4096 );
21
- private HashTable activeRequests = new HashTable (32 );
22
- private HashTable queuedRequests = new HashTable (4096 );
23
- private HashTable writeQueue = new HashTable (4096 );
20
+ private HashTable highPriorityWriteQueue = new HashTable (4096 );
21
+ private HashTable highPriorityOutgoingRequests = new HashTable (32 );
22
+ private HashTable standardPriorityOutgoingRequests = new HashTable (4096 );
23
+ private HashTable standardPriorityWriteQueue = new HashTable (4096 );
24
24
private UpdateServerNode currentResponse ;
25
25
private CRC32 crc32 = new CRC32 ();
26
26
private byte encryption = (byte ) 0 ;
27
- private int immediateResponses = 0 ;
28
- private int pendingWrites = 0 ;
29
- private int immediateWrites = 0 ;
30
- private int pendingResponses = 0 ;
31
- private boolean priorityRequest ;
27
+ private int highPriorityResponseCount = 0 ;
28
+ private int standardPriorityWriteCount = 0 ;
29
+ private int highPriorityWriteCount = 0 ;
30
+ private int standardPriorityResponseCount = 0 ;
31
+ private boolean highPriorityRequest ;
32
32
private NodeQueue pendingWriteQueue = new NodeQueue ();
33
33
private int blockOffset = 0 ;
34
34
private int msSinceLastUpdate = 0 ;
@@ -74,26 +74,26 @@ public void receiveConnection(GameSocket socket, boolean isLoggedIn) {
74
74
currentResponse = null ;
75
75
76
76
for (; ; ) {
77
- UpdateServerNode updateServerNode = (UpdateServerNode ) activeRequests .getNextNode ();
77
+ UpdateServerNode updateServerNode = (UpdateServerNode ) highPriorityOutgoingRequests .getNextNode ();
78
78
if (updateServerNode == null ) {
79
79
break ;
80
80
}
81
81
82
- immediateWriteQueue .put (updateServerNode .key , updateServerNode );
83
- immediateResponses --;
84
- immediateWrites ++;
82
+ highPriorityWriteQueue .put (updateServerNode .key , updateServerNode );
83
+ highPriorityResponseCount --;
84
+ highPriorityWriteCount ++;
85
85
}
86
86
87
87
for (; ; ) {
88
- UpdateServerNode updateServerNode = (UpdateServerNode ) queuedRequests .getNextNode ();
88
+ UpdateServerNode updateServerNode = (UpdateServerNode ) standardPriorityOutgoingRequests .getNextNode ();
89
89
if (updateServerNode == null ) {
90
90
break ;
91
91
}
92
92
93
93
pendingWriteQueue .unshift (updateServerNode );
94
- writeQueue .put (updateServerNode .key , updateServerNode );
95
- pendingResponses --;
96
- pendingWrites ++;
94
+ standardPriorityWriteQueue .put (updateServerNode .key , updateServerNode );
95
+ standardPriorityResponseCount --;
96
+ standardPriorityWriteCount ++;
97
97
}
98
98
99
99
if (encryption != 0 ) {
@@ -129,7 +129,7 @@ public boolean poll() {
129
129
currentMsSinceLastUpdate = 200 ;
130
130
}
131
131
msSinceLastUpdate += currentMsSinceLastUpdate ;
132
- if (pendingResponses == 0 && immediateResponses == 0 && pendingWrites == 0 && immediateWrites == 0 ) {
132
+ if (standardPriorityResponseCount == 0 && highPriorityResponseCount == 0 && standardPriorityWriteCount == 0 && highPriorityWriteCount == 0 ) {
133
133
return true ;
134
134
}
135
135
if (updateServerSocket == null ) {
@@ -142,29 +142,29 @@ public boolean poll() {
142
142
}
143
143
144
144
// Immediate file requests
145
- for (/**/ ; immediateResponses < 20 ; immediateResponses ++) {
146
- if (immediateWrites <= 0 ) {
145
+ for (/**/ ; highPriorityResponseCount < 20 ; highPriorityResponseCount ++) {
146
+ if (highPriorityWriteCount <= 0 ) {
147
147
break ;
148
148
}
149
- UpdateServerNode updateServerNode = (UpdateServerNode ) immediateWriteQueue .getNextNode ();
149
+ UpdateServerNode updateServerNode = (UpdateServerNode ) highPriorityWriteQueue .getNextNode ();
150
150
Buffer buffer = new Buffer (4 );
151
151
buffer .putByte (Opcode .PRIORITY_REQUEST .getValue ()); // immediate file request
152
152
buffer .putMediumBE ((int ) updateServerNode .key ); // file index + file id
153
153
updateServerSocket .sendDataFromBuffer (4 , 0 , buffer .buffer );
154
- activeRequests .put (updateServerNode .key , updateServerNode );
155
- immediateWrites --;
154
+ highPriorityOutgoingRequests .put (updateServerNode .key , updateServerNode );
155
+ highPriorityWriteCount --;
156
156
}
157
157
158
158
// Queuable file requests
159
- for (/**/ ; pendingResponses < 20 && pendingWrites > 0 ; pendingWrites --) {
159
+ for (/**/ ; standardPriorityResponseCount < 20 && standardPriorityWriteCount > 0 ; standardPriorityWriteCount --) {
160
160
UpdateServerNode updateServerNode = (UpdateServerNode ) pendingWriteQueue .next ();
161
161
Buffer buffer = new Buffer (4 );
162
162
buffer .putByte (Opcode .REQUEST .getValue ()); // queued file request
163
163
buffer .putMediumBE ((int ) updateServerNode .key ); // file index + file id
164
164
updateServerSocket .sendDataFromBuffer (4 , 0 , buffer .buffer );
165
165
updateServerNode .clear ();
166
- queuedRequests .put (updateServerNode .key , updateServerNode );
167
- pendingResponses ++;
166
+ standardPriorityOutgoingRequests .put (updateServerNode .key , updateServerNode );
167
+ standardPriorityResponseCount ++;
168
168
}
169
169
170
170
for (int i1 = 0 ; i1 < 100 ; i1 ++) {
@@ -232,18 +232,18 @@ public boolean poll() {
232
232
233
233
ioExceptions = 0 ;
234
234
crcMismatches = 0 ;
235
- currentResponse .cacheArchive .method196 ((currentResponse .key & 0xff0000L ) == 16711680L , (int ) (currentResponse .key & 0xffffL ), priorityRequest , inboundFile .buffer );
235
+ currentResponse .cacheArchive .method196 ((currentResponse .key & 0xff0000L ) == 16711680L , (int ) (currentResponse .key & 0xffffL ), highPriorityRequest , inboundFile .buffer );
236
236
}
237
237
238
238
currentResponse .unlink ();
239
239
currentResponse = null ;
240
240
inboundFile = null ;
241
241
blockOffset = 0 ;
242
242
243
- if (!priorityRequest ) {
244
- pendingResponses --;
243
+ if (!highPriorityRequest ) {
244
+ standardPriorityResponseCount --;
245
245
} else {
246
- immediateResponses --;
246
+ highPriorityResponseCount --;
247
247
}
248
248
} else {
249
249
if (blockOffset != 512 ) {
@@ -278,12 +278,12 @@ public boolean poll() {
278
278
int fileCompression = fileDataBuffer .getUnsignedByte ();
279
279
int fileSize = fileDataBuffer .getIntBE ();
280
280
long fileKey = ((long ) fileIndexId << 16 ) + fileId ;
281
- UpdateServerNode updateServerNode = (UpdateServerNode ) activeRequests .getNode (fileKey );
282
- priorityRequest = true ;
281
+ UpdateServerNode updateServerNode = (UpdateServerNode ) highPriorityOutgoingRequests .getNode (fileKey );
282
+ highPriorityRequest = true ;
283
283
284
284
if (updateServerNode == null ) {
285
- updateServerNode = (UpdateServerNode ) queuedRequests .getNode (fileKey );
286
- priorityRequest = false ;
285
+ updateServerNode = (UpdateServerNode ) standardPriorityOutgoingRequests .getNode (fileKey );
286
+ highPriorityRequest = false ;
287
287
}
288
288
289
289
if (updateServerNode == null ) {
@@ -325,45 +325,45 @@ public boolean poll() {
325
325
}
326
326
}
327
327
328
- public void method327 (boolean unknownBool , CacheArchive archive , int archiveIndexId , int fileId , byte arg4 , int expectedCrc ) {
328
+ public void method327 (boolean isPriority , CacheArchive archive , int archiveIndexId , int fileId , byte arg4 , int expectedCrc ) {
329
329
long fileKey = fileId + ((long ) archiveIndexId << 16 );
330
- UpdateServerNode updateServerNode = (UpdateServerNode ) immediateWriteQueue .getNode (fileKey );
330
+ UpdateServerNode updateServerNode = (UpdateServerNode ) highPriorityWriteQueue .getNode (fileKey );
331
331
332
332
if (updateServerNode == null ) {
333
- updateServerNode = (UpdateServerNode ) activeRequests .getNode (fileKey );
333
+ updateServerNode = (UpdateServerNode ) highPriorityOutgoingRequests .getNode (fileKey );
334
334
if (updateServerNode == null ) {
335
- updateServerNode = (UpdateServerNode ) writeQueue .getNode (fileKey );
335
+ updateServerNode = (UpdateServerNode ) standardPriorityWriteQueue .getNode (fileKey );
336
336
if (updateServerNode == null ) {
337
- if (!unknownBool ) {
338
- updateServerNode = (UpdateServerNode ) queuedRequests .getNode (fileKey );
337
+ if (!isPriority ) {
338
+ updateServerNode = (UpdateServerNode ) standardPriorityOutgoingRequests .getNode (fileKey );
339
339
if (updateServerNode != null )
340
340
return ;
341
341
}
342
342
updateServerNode = new UpdateServerNode ();
343
343
updateServerNode .crc = expectedCrc ;
344
344
updateServerNode .padding = arg4 ;
345
345
updateServerNode .cacheArchive = archive ;
346
- if (unknownBool ) {
347
- immediateWriteQueue .put (fileKey , updateServerNode );
348
- immediateWrites ++;
346
+ if (isPriority ) {
347
+ highPriorityWriteQueue .put (fileKey , updateServerNode );
348
+ highPriorityWriteCount ++;
349
349
} else {
350
350
pendingWriteQueue .push (updateServerNode );
351
- writeQueue .put (fileKey , updateServerNode );
352
- pendingWrites ++;
351
+ standardPriorityWriteQueue .put (fileKey , updateServerNode );
352
+ standardPriorityWriteCount ++;
353
353
}
354
- } else if (unknownBool ) {
354
+ } else if (isPriority ) {
355
355
updateServerNode .clear ();
356
- immediateWriteQueue .put (fileKey , updateServerNode );
357
- pendingWrites --;
358
- immediateWrites ++;
356
+ highPriorityWriteQueue .put (fileKey , updateServerNode );
357
+ standardPriorityWriteCount --;
358
+ highPriorityWriteCount ++;
359
359
}
360
360
}
361
361
}
362
362
}
363
363
364
364
public void method399 (int arg0 , int arg2 ) {
365
365
long l = (arg0 << 16 ) + arg2 ;
366
- UpdateServerNode updateServerNode = (UpdateServerNode ) writeQueue .getNode (l );
366
+ UpdateServerNode updateServerNode = (UpdateServerNode ) standardPriorityWriteQueue .getNode (l );
367
367
if (updateServerNode != null ) {
368
368
pendingWriteQueue .unshift (updateServerNode );
369
369
}
@@ -424,13 +424,13 @@ public int calculateDataLoaded(int volume, int file) {
424
424
}
425
425
426
426
@ Override
427
- public int getActiveCount (boolean pending , boolean immediate ) {
427
+ public int getActiveCount (boolean includeStandardPriority , boolean includeHighPriority ) {
428
428
int total = 0 ;
429
- if (immediate ) {
430
- total += immediateResponses + immediateWrites ;
429
+ if (includeHighPriority ) {
430
+ total += highPriorityResponseCount + highPriorityWriteCount ;
431
431
}
432
- if (pending ) {
433
- total += pendingResponses + pendingWrites ;
432
+ if (includeStandardPriority ) {
433
+ total += standardPriorityResponseCount + standardPriorityWriteCount ;
434
434
}
435
435
return total ;
436
436
}
0 commit comments