Stat update & Mob skill animation & Yellow EXP patch + Packet logging
Solved a deadlock case within character stat locks that would sometimes tangle up during stat update dispatch operations. Fixed skill animation being unproperly casted when a mob tries to use a skill even though it couldn't possibly use from its current skillset. Fixed a bug with EXP gain (on where the solo player is on a party) where the EXP would appear in yellow even after soloing a mob. Added packet logging. Happy Easter, folks!
This commit is contained in:
@@ -21,13 +21,20 @@
|
||||
*/
|
||||
package net.mina;
|
||||
|
||||
import constants.ServerConstants;
|
||||
import client.MapleClient;
|
||||
import constants.OpcodeConstants;
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
|
||||
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
|
||||
import tools.HexTool;
|
||||
import tools.MapleAESOFB;
|
||||
import tools.data.input.ByteArrayByteStream;
|
||||
import tools.data.input.GenericLittleEndianAccessor;
|
||||
import net.opcodes.RecvOpcode;
|
||||
import tools.FilePrinter;
|
||||
|
||||
public class MaplePacketDecoder extends CumulativeProtocolDecoder {
|
||||
private static final String DECODER_STATE_KEY = MaplePacketDecoder.class.getName() + ".STATE";
|
||||
@@ -68,8 +75,32 @@ public class MaplePacketDecoder extends CumulativeProtocolDecoder {
|
||||
rcvdCrypto.crypt(decryptedPacket);
|
||||
MapleCustomEncryption.decryptData(decryptedPacket);
|
||||
out.write(decryptedPacket);
|
||||
if (ServerConstants.USE_DEBUG_SHOW_PACKET){ // packet traffic log: Atoot's idea, applied using auto-identation thanks to lrenex
|
||||
int packetLen = decryptedPacket.length;
|
||||
int pHeader = readFirstShort(decryptedPacket);
|
||||
String pHeaderStr = Integer.toHexString(pHeader).toUpperCase();
|
||||
String op = lookupSend(pHeader);
|
||||
String Send = "ClientSend:" + op + " [" + pHeaderStr + "] (" + packetLen + ")\r\n";
|
||||
if (packetLen <= 3000) {
|
||||
String SendTo = Send + HexTool.toString(decryptedPacket) + "\r\n" + HexTool.toStringFromAscii(decryptedPacket);
|
||||
System.out.println(SendTo);
|
||||
if (op == null) {
|
||||
System.out.println("UnknownPacket:" + SendTo);
|
||||
}
|
||||
} else {
|
||||
FilePrinter.print(FilePrinter.PACKET_STREAM + MapleSessionCoordinator.getSessionRemoteAddress(session) + ".txt", HexTool.toString(new byte[]{decryptedPacket[0], decryptedPacket[1]}) + "...");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String lookupSend(int val) {
|
||||
return OpcodeConstants.recvOpcodeNames.get(val);
|
||||
}
|
||||
|
||||
private int readFirstShort(byte[] arr) {
|
||||
return new GenericLittleEndianAccessor(new ByteArrayByteStream(arr)).readShort();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.mina;
|
||||
|
||||
import constants.ServerConstants;
|
||||
import client.MapleClient;
|
||||
import constants.OpcodeConstants;
|
||||
import net.opcodes.SendOpcode;
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoder;
|
||||
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
|
||||
import tools.MapleAESOFB;
|
||||
import tools.HexTool;
|
||||
import tools.data.input.ByteArrayByteStream;
|
||||
import tools.data.input.GenericLittleEndianAccessor;
|
||||
import tools.FilePrinter;
|
||||
|
||||
public class MaplePacketEncoder implements ProtocolEncoder {
|
||||
|
||||
@@ -39,6 +47,23 @@ public class MaplePacketEncoder implements ProtocolEncoder {
|
||||
try {
|
||||
final MapleAESOFB send_crypto = client.getSendCrypto();
|
||||
final byte[] input = (byte[]) message;
|
||||
if (ServerConstants.USE_DEBUG_SHOW_PACKET) {
|
||||
int packetLen = input.length;
|
||||
int pHeader = readFirstShort(input);
|
||||
String pHeaderStr = Integer.toHexString(pHeader).toUpperCase();
|
||||
String op = lookupRecv(pHeader);
|
||||
String Recv = "ServerSend:" + op + " [" + pHeaderStr + "] (" + packetLen + ")\r\n";
|
||||
if (packetLen <= 50000) {
|
||||
String RecvTo = Recv + HexTool.toString(input) + "\r\n" + HexTool.toStringFromAscii(input);
|
||||
System.out.println(RecvTo);
|
||||
if (op == null) {
|
||||
System.out.println("UnknownPacket:" + RecvTo);
|
||||
}
|
||||
} else {
|
||||
FilePrinter.print(FilePrinter.PACKET_STREAM + MapleSessionCoordinator.getSessionRemoteAddress(session) + ".txt", HexTool.toString(new byte[]{input[0], input[1]}) + " ...");
|
||||
}
|
||||
}
|
||||
|
||||
final byte[] unencrypted = new byte[input.length];
|
||||
System.arraycopy(input, 0, unencrypted, 0, input.length);
|
||||
final byte[] ret = new byte[unencrypted.length + 4];
|
||||
@@ -59,6 +84,14 @@ public class MaplePacketEncoder implements ProtocolEncoder {
|
||||
out.write(IoBuffer.wrap(((byte[]) message)));
|
||||
}
|
||||
}
|
||||
|
||||
private String lookupRecv(int val) {
|
||||
return OpcodeConstants.sendOpcodeNames.get(val);
|
||||
}
|
||||
|
||||
private int readFirstShort(byte[] arr) {
|
||||
return new GenericLittleEndianAccessor(new ByteArrayByteStream(arr)).readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(IoSession session) throws Exception {}
|
||||
|
||||
@@ -86,6 +86,7 @@ import client.inventory.manipulator.MapleCashidGenerator;
|
||||
import client.newyear.NewYearCardRecord;
|
||||
import constants.ItemConstants;
|
||||
import constants.GameConstants;
|
||||
import constants.OpcodeConstants;
|
||||
import constants.ServerConstants;
|
||||
import java.util.TimeZone;
|
||||
import net.server.coordinator.MapleSessionCoordinator;
|
||||
@@ -969,6 +970,7 @@ public class Server {
|
||||
online = true;
|
||||
|
||||
MapleSkillbookInformationProvider.getInstance();
|
||||
OpcodeConstants.generateOpcodeNames();
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
||||
@@ -126,7 +126,9 @@ public final class MoveLifeHandler extends AbstractMovementPacketHandler {
|
||||
nextSkillLevel = skillToUse.getRight();
|
||||
nextUse = MobSkillFactory.getMobSkill(nextSkillId, nextSkillLevel);
|
||||
|
||||
if (!(nextUse != null && nextUse.getHP() >= (int) (((float) monster.getHp() / monster.getMaxHp()) * 100) && mobMp >= nextUse.getMpCon())) {
|
||||
if (!(nextUse != null && monster.canUseSkill(nextUse) && nextUse.getHP() >= (int) (((float) monster.getHp() / monster.getMaxHp()) * 100) && mobMp >= nextUse.getMpCon())) {
|
||||
// thanks OishiiKawaiiDesu for noticing mobs trying to cast skills they are not supposed to be able
|
||||
|
||||
nextSkillId = 0;
|
||||
nextSkillLevel = 0;
|
||||
nextUse = null;
|
||||
|
||||
Reference in New Issue
Block a user