Removed unneeded files, also fixed heading calculation

Tags #story[829]
This commit is contained in:
Michael Rausch
2017-04-30 23:29:15 +12:00
parent d07c660eb9
commit e7f9954970
21 changed files with 15 additions and 1292 deletions
@@ -133,9 +133,7 @@ public class BoatLocationMessage extends Message {
allocateBuffer();
writeHeaderToBuffer();
heading = (heading + 180.0) % 360.0;
long headingToSend = (long)((heading/360.0)*49152.0);
long headingToSend = (long)((heading/360.0) * 65535.0);
putByte((byte) messageVersionNumber);
putInt(time, 6);
@@ -3,6 +3,7 @@ package seng302.server.messages;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.SocketChannel;
@@ -170,7 +171,6 @@ public abstract class Message {
return buffer;
}
/**
* Rewind the buffer to the beginning
*/
@@ -185,11 +185,13 @@ public abstract class Message {
* @return
*/
public static byte[] intToByteArray(long val, int len){
long vor = val;
int index = 0;
byte[] data = new byte[len];
for (int i = 0; i < len; i++){
data[len - index - 1] = (byte) ((val >>> (8 * index)));
data[len - index - 1] = (byte) (val & 0xFF);
val >>>= 8;
index++;
}
@@ -202,9 +204,9 @@ public abstract class Message {
*/
public static void reverse(byte[] data) {
for (int left = 0, right = data.length - 1; left < right; left++, right--) {
byte temp = data[left];
data[left] = data[right];
data[right] = temp;
byte temp = (byte) (data[left] & 0xff);
data[left] = (byte) (data[right] & 0xff);
data[right] = (byte) (temp & 0xff);
}
}
@@ -1,11 +1,7 @@
package seng302.server.messages;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.SocketChannel;
import java.nio.channels.WritableByteChannel;
import java.util.List;
import java.util.zip.CRC32;