mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Merge branch 'master' of git@bitbucket.org:Major-/apollo.git into pathfinding.
This commit is contained in:
@@ -161,7 +161,8 @@ public final class CollisionMatrix {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix)).toString();
|
||||
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix))
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,8 +210,9 @@ public final class CollisionMatrix {
|
||||
* @throws ArrayIndexOutOfBoundsException If the specified coordinate pair does not fit in this matrix.
|
||||
*/
|
||||
private int indexOf(int x, int y) {
|
||||
Preconditions.checkElementIndex(x, width, "X coordinate must be [0, " + width + "), received " + x + ".");
|
||||
Preconditions.checkElementIndex(y, length, "Y coordinate must be [0, " + length + "), received " + y + ".");
|
||||
int index = y * width + x;
|
||||
Preconditions.checkElementIndex(index, matrix.length, "Index out of bounds.");
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,4 +100,9 @@ public final class ApolloHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelReadComplete(ChannelHandlerContext ctx) {
|
||||
ctx.flush();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import java.nio.charset.Charset;
|
||||
import org.apollo.net.codec.jaggrab.JagGrabRequestDecoder;
|
||||
import org.apollo.net.codec.jaggrab.JagGrabResponseEncoder;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
/**
|
||||
* A {@link ChannelInitializer} for the JAGGRAB protocol.
|
||||
*
|
||||
@@ -29,7 +31,7 @@ public final class JagGrabChannelInitializer extends ChannelInitializer<SocketCh
|
||||
/**
|
||||
* The character set used in the request.
|
||||
*/
|
||||
private static final Charset JAGGRAB_CHARSET = Charset.forName("US-ASCII");
|
||||
private static final Charset JAGGRAB_CHARSET = Charsets.US_ASCII;
|
||||
|
||||
/**
|
||||
* The maximum length of a request, in bytes.
|
||||
|
||||
@@ -90,7 +90,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
response.writeByte(LoginConstants.STATUS_EXCHANGE_DATA);
|
||||
response.writeLong(0);
|
||||
response.writeLong(serverSeed);
|
||||
ctx.channel().writeAndFlush(response);
|
||||
ctx.channel().write(response);
|
||||
|
||||
setState(LoginDecoderState.LOGIN_HEADER);
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
ByteBuf buffer = ctx.alloc().buffer(1);
|
||||
buffer.writeByte(response);
|
||||
|
||||
ctx.writeAndFlush(buffer).addListener(ChannelFutureListener.CLOSE);
|
||||
ctx.write(buffer).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public final class LoginSession extends Session {
|
||||
}
|
||||
}
|
||||
|
||||
ChannelFuture future = channel.writeAndFlush(new LoginResponse(status, rights, flagged));
|
||||
ChannelFuture future = channel.write(new LoginResponse(status, rights, flagged));
|
||||
|
||||
destroy();
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class OnDemandRequestWorker extends RequestWorker<OnDemandRequest,
|
||||
ByteBuf chunkData = Unpooled.wrappedBuffer(tmp, 0, chunkSize);
|
||||
|
||||
OnDemandResponse response = new OnDemandResponse(desc, length, chunk, chunkData);
|
||||
channel.writeAndFlush(response);
|
||||
channel.write(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.apollo.update;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apollo.Service;
|
||||
import org.apollo.fs.IndexedFileSystem;
|
||||
@@ -27,6 +30,11 @@ public final class UpdateService extends Service {
|
||||
*/
|
||||
private static final int THREADS_PER_REQUEST_TYPE = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
/**
|
||||
* The logger for this class.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger(UpdateService.class.getName());
|
||||
|
||||
/**
|
||||
* The update dispatcher.
|
||||
*/
|
||||
@@ -59,9 +67,6 @@ public final class UpdateService extends Service {
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the threads in the pool.
|
||||
*/
|
||||
@Override
|
||||
public void start() {
|
||||
int release = getContext().getRelease().getReleaseNumber();
|
||||
@@ -72,23 +77,18 @@ public final class UpdateService extends Service {
|
||||
workers.add(new OnDemandRequestWorker(dispatcher, new IndexedFileSystem(base, true)));
|
||||
workers.add(new HttpRequestWorker(dispatcher, new IndexedFileSystem(base, true)));
|
||||
}
|
||||
|
||||
for (RequestWorker<?, ?> worker : workers) {
|
||||
service.submit(worker);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Error adding request workers - " + ex.getMessage());
|
||||
} catch (FileNotFoundException reason) {
|
||||
logger.log(Level.SEVERE, "Unable to find index or data files from the file system.", reason);
|
||||
}
|
||||
|
||||
workers.forEach(service::submit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the threads in the pool.
|
||||
*/
|
||||
public void stop() {
|
||||
for (RequestWorker<?, ?> worker : workers) {
|
||||
worker.stop();
|
||||
}
|
||||
|
||||
workers.forEach(RequestWorker::stop);
|
||||
service.shutdownNow();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user