Cleanup part 1 (#213)

* Clean up part 1

- Removed lots of dead code
- Removed unncessary files not in use
- Cleaned up small bits of code
- Removed a few warnings
- Server.java ---> GameEngine.java
- Constants.java ---> GameConstants.java

* Cape Dye

Rewrote cape dying

* Packaging

- redone ----> com.rebotted

* PacketSender/clean up

- ActionSender ---> PacketSender
- Moved many more packets to packetsender
- Cleaned up more dead code

* Merge Client/Player

- Merged Client.java with Player.java (both were doing same thing so redundant to have both)
- Removed some more dead code
- Tidy a few small things up

* Quests/more clean up

- Removed more dead code
- Made quests static in order to clean them up a bit

* More cleanup

- Removed some more of the dead quest code
- Correcting naming of some of the shop variables
This commit is contained in:
Mr Extremez
2019-11-25 11:08:56 -06:00
committed by Daniel Ginovker
parent 3d1ae1b288
commit d876a923b9
379 changed files with 80684 additions and 83170 deletions
@@ -0,0 +1,82 @@
package com.rebotted.net;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
public class RS2ProtocolEncoder implements ProtocolEncoder {
/**
* Only CodecFactory can create us.
*/
protected RS2ProtocolEncoder() {
}
@Override
/**
* Encodes a message.
* @param session
* @param message
* @param out
*/
public void encode(IoSession session, Object message,
ProtocolEncoderOutput out) throws Exception {
try {
synchronized (session) {
Packet p = (Packet) message;
byte[] data = p.getData();
int dataLength = p.getLength();
ByteBuffer buffer;
if (!p.isBare()) {
buffer = ByteBuffer.allocate(dataLength + 3);
int id = p.getId();
buffer.put((byte) id);
if (p.getSize() != Packet.Size.Fixed) { // variable length
// Logger.log("variable length: id="+id+",dataLength="+dataLength);
if (p.getSize() == Packet.Size.VariableByte) {
if (dataLength > 255) {
// then we can represent
// with 8 bits!
throw new IllegalArgumentException(
"Tried to send packet length "
+ dataLength
+ " in 8 bits [pid="
+ p.getId() + "]");
}
buffer.put((byte) dataLength);
} else if (p.getSize() == Packet.Size.VariableShort) {
if (dataLength > 65535) {
// then we can represent
// with 16 bits!
throw new IllegalArgumentException(
"Tried to send packet length "
+ dataLength
+ " in 16 bits [pid="
+ p.getId() + "]");
}
buffer.put((byte) (dataLength >> 8));
buffer.put((byte) dataLength);
}
}
} else {
buffer = ByteBuffer.allocate(dataLength);
}
buffer.put(data, 0, dataLength);
buffer.flip();
out.write(buffer);
}
} catch (Exception err) {
err.printStackTrace();
}
}
@Override
/**
* Releases resources used by this encoder.
* @param session
*/
public void dispose(IoSession session) throws Exception {
}
}