Client Timestamp update + Cosmetic NPCs & H Beacon patch + Log rework

Fixed Music command not playing soundtracks at all.
Fixed stylish scripts stucking player NPC interactions in certain cases.
Reviewed client mistimed view on items, quest expirations, BBS threads, etc.
Fixed Homing Beacon skill provoking autoflag in mobs with same objectid in different maps.
Solved DB leak cases with removing pets from inventory.
Reviewed logging throughout the source, aiming to normalize the varied-spaced log content within the facilities.
Fixed a bug that would occur when trying to reaccess Horntail expedition.
This commit is contained in:
ronancpl
2019-01-07 12:10:41 -02:00
parent 35ea13420e
commit b47dd03a3e
110 changed files with 511 additions and 585 deletions

View File

@@ -11,55 +11,67 @@ import java.util.Calendar;
public class FilePrinter {
public static final String
ACCOUNT_STUCK = "accountStuck.txt",
EXCEPTION_CAUGHT = "exceptionCaught.txt",
CLIENT_START = "clientStartError.txt",
ADD_PLAYER = "addPlayer.txt",
MAPLE_MAP = "mapleMap.txt",
ERROR38 = "error38.txt",
PACKET_LOG = "log.txt",
CASHITEM_BOUGHT = "cashlog.txt",
EXCEPTION = "exceptions.txt",
SQL_EXCEPTION = "sqlexceptions.txt",
PACKET_HANDLER = "PacketHandler/",
PORTAL = "portals/",
PORTAL_STUCK = "portalblocks/",
NPC = "npcs/",
INVOCABLE = "invocable/",
REACTOR = "reactors/",
QUEST = "quests/",
ITEM = "items/",
MOB_MOVEMENT = "mobmovement.txt",
MAP_SCRIPT = "mapscript/",
DIRECTION = "directions/",
SAVE_CHAR = "saveToDB.txt",
INSERT_CHAR = "insertCharacter.txt",
LOAD_CHAR = "loadCharFromDB.txt",
UNHANDLED_EVENT = "doesNotExist.txt",
SESSION = "sessions.txt",
EXPLOITS = "exploits/",
STORAGE = "storage/",
PACKET_LOGS = "packetlogs/",
DELETED_CHARACTERS = "deletedchars/",
FREDRICK = "fredrick/",
NPC_UNCODED = "uncodedNPCs.txt",
QUEST_UNCODED = "uncodedQuests.txt",
AUTOSAVING_CHARACTER = "saveCharAuto.txt",
SAVING_CHARACTER = "saveChar.txt",
USED_COMMANDS = "usedCommands.txt",
DEADLOCK_ERROR = "deadlocks.txt",
DEADLOCK_STACK = "deadlocks/path.txt",
DEADLOCK_LOCKS = "deadlocks/locks.txt",
DEADLOCK_STATE = "deadlocks/state.txt",
DISPOSED_LOCKS = "deadlocks/disposed.txt";
AUTOBAN_WARNING = "game/AutoBanWarning.txt", // log naming version by Vcoc
AUTOBAN_DC = "game/AutoBanDC.txt",
ACCOUNT_STUCK = "players/AccountStuck.txt",
COMMAND_GM = "reports/Gm.txt",
COMMAND_BUG = "reports/Bug.txt",
LOG_TRADE = "interactions/Trades.txt",
LOG_EXPEDITION = "interactions/Expeditions.txt",
LOG_LEAF = "interactions/MapleLeaves.txt",
LOG_GACHAPON = "interactions/Gachapon.txt",
LOG_CHAT = "interactions/ChatLog.txt",
EXCEPTION_CAUGHT = "game/ExceptionCaught.txt",
CLIENT_START = "game/ClientStartError.txt",
MAPLE_MAP = "game/MapleMap.txt",
ERROR38 = "game/Error38.txt",
PACKET_LOG = "game/Log.txt",
CASHITEM_BOUGHT = "interactions/CashLog.txt",
EXCEPTION = "game/Exceptions.txt",
SQL_EXCEPTION = "game/SqlExceptions.txt",
PACKET_HANDLER = "game/packethandler/",
PORTAL = "game/portals/",
PORTAL_STUCK = "game/portalblocks/",
NPC = "game/npcs/",
INVOCABLE = "game/invocable/",
REACTOR = "game/reactors/",
QUEST = "game/quests/",
ITEM = "game/items/",
MOB_MOVEMENT = "game/MobMovement.txt",
MAP_SCRIPT = "game/mapscript/",
DIRECTION = "game/directions/",
SAVE_CHAR = "players/SaveToDB.txt",
INSERT_CHAR = "players/InsertCharacter.txt",
LOAD_CHAR = "players/LoadCharFromDB.txt",
CREATED_CHAR = "players/createdchars/",
DELETED_CHAR = "players/deletedchars/",
UNHANDLED_EVENT = "game/DoesNotExist.txt",
SESSION = "players/Sessions.txt",
EXPLOITS = "game/exploits/",
STORAGE = "game/storage/",
PACKET_LOGS = "game/packetlogs/",
FREDRICK = "game/npcs/fredrick/",
NPC_UNCODED = "game/npcs/UncodedNPCs.txt",
QUEST_UNCODED = "game/quests/UncodedQuests.txt",
AUTOSAVING_CHARACTER = "players/SaveCharAuto.txt",
SAVING_CHARACTER = "players/SaveChar.txt",
USED_COMMANDS = "commands/UsedCommands.txt",
DEADLOCK_ERROR = "deadlocks/Deadlocks.txt",
DEADLOCK_STACK = "deadlocks/Path.txt",
DEADLOCK_LOCKS = "deadlocks/Locks.txt",
DEADLOCK_STATE = "deadlocks/State.txt",
DISPOSED_LOCKS = "deadlocks/Disposed.txt";
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //for file system purposes, it's nice to use yyyy-MM-dd
private static final String FILE_PATH = "logs/" + sdf.format(Calendar.getInstance().getTime()) + "/"; // + sdf.format(Calendar.getInstance().getTime()) + "/"
private static final String ERROR = "error/";
public static void printError(final String name, final Throwable t) {
String stringT = getString(t);
System.out.println("Error thrown: " + name);
System.out.println(getString(t));
System.out.println(stringT);
System.out.println();
FileOutputStream out = null;
final String file = FILE_PATH + ERROR + name;
try {
@@ -68,8 +80,9 @@ public class FilePrinter {
outputFile.getParentFile().mkdirs();
}
out = new FileOutputStream(file, true);
out.write(getString(t).getBytes());
out.write("\n---------------------------------\r\n".getBytes());
out.write(stringT.getBytes());
out.write("\r\n---------------------------------\r\n".getBytes());
out.write("\r\n".getBytes()); // thanks Vcoc for suggesting review body log structure
} catch (IOException ess) {
ess.printStackTrace();
} finally {
@@ -84,8 +97,11 @@ public class FilePrinter {
}
public static void printError(final String name, final Throwable t, final String info) {
String stringT = getString(t);
System.out.println("Error thrown: " + name);
System.out.println(getString(t));
System.out.println(stringT);
System.out.println();
FileOutputStream out = null;
final String file = FILE_PATH + ERROR + name;
try {
@@ -95,8 +111,9 @@ public class FilePrinter {
}
out = new FileOutputStream(file, true);
out.write((info + "\r\n").getBytes());
out.write(getString(t).getBytes());
out.write("\n---------------------------------\r\n".getBytes());
out.write(stringT.getBytes());
out.write("\r\n---------------------------------\r\n".getBytes());
out.write("\r\n".getBytes());
} catch (IOException ess) {
ess.printStackTrace();
} finally {
@@ -113,6 +130,7 @@ public class FilePrinter {
public static void printError(final String name, final String s) {
System.out.println("Error thrown: " + name);
System.out.println(s);
System.out.println();
FileOutputStream out = null;
final String file = FILE_PATH + ERROR + name;
try {
@@ -122,7 +140,8 @@ public class FilePrinter {
}
out = new FileOutputStream(file, true);
out.write(s.getBytes());
//out.write("\n---------------------------------\n".getBytes());
//out.write("\r\n---------------------------------\r\n".getBytes());
out.write("\r\n".getBytes());
} catch (IOException ess) {
ess.printStackTrace();
} finally {
@@ -143,6 +162,7 @@ public class FilePrinter {
public static void print(final String name, final String s, boolean line) {
System.out.println("Log: " + name);
System.out.println(s);
System.out.println();
FileOutputStream out = null;
String file = FILE_PATH + name;
try {
@@ -152,10 +172,10 @@ public class FilePrinter {
}
out = new FileOutputStream(file, true);
out.write(s.getBytes());
out.write("\r\n".getBytes());
if (line) {
out.write("---------------------------------\r\n".getBytes());
out.write("\r\n---------------------------------\r\n".getBytes());
}
out.write("\r\n".getBytes());
} catch (IOException ess) {
ess.printStackTrace();
} finally {

View File

@@ -6,9 +6,6 @@ import java.util.Date;
import client.MapleClient;
import net.server.Server;
import net.server.channel.Channel;
import net.server.world.MapleParty;
import net.server.world.MaplePartyCharacter;
import server.MapleItemInformationProvider;
import server.MapleTrade;
import server.expeditions.MapleExpedition;
@@ -34,7 +31,7 @@ public class LogHelper {
log += item.getQuantity() + " " + itemName + " from " + name2 + " to " + name1 + " \r\n";;
}
log += "\r\n\r\n";
FilePrinter.print("trades.txt", log);
FilePrinter.print(FilePrinter.LOG_TRADE, log);
}
public static void logExpedition(MapleExpedition expedition) {
@@ -50,8 +47,8 @@ public class LogHelper {
for (String message: expedition.getBossLogs()){
log += message;
}
log += "\r\n\r\n";
FilePrinter.print("expeditions.txt", log);
log += "\r\n";
FilePrinter.print(FilePrinter.LOG_EXPEDITION, log);
}
public static String getTimeString(long then){
@@ -63,20 +60,20 @@ public class LogHelper {
public static void logLeaf(MapleCharacter player, boolean gotPrize, String operation) {
String timeStamp = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date());
String log = player.getName() + (gotPrize ? " used a maple leaf to buy " + operation : " redeemed " + operation + " VP for a leaf") + " - " + timeStamp + "\r\n";
FilePrinter.print("mapleleaves.txt", log);
String log = player.getName() + (gotPrize ? " used a maple leaf to buy " + operation : " redeemed " + operation + " VP for a leaf") + " - " + timeStamp;
FilePrinter.print(FilePrinter.LOG_LEAF, log);
}
public static void logGacha(MapleCharacter player, int itemid, String map) {
String itemName = MapleItemInformationProvider.getInstance().getName(itemid);
String timeStamp = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date());
String log = player.getName() + " got a " + itemName + "(" + itemid + ") from the " + map + " gachapon. - " + timeStamp + "\r\n";
FilePrinter.print("gachapon.txt", log);
String log = player.getName() + " got a " + itemName + "(" + itemid + ") from the " + map + " gachapon. - " + timeStamp;
FilePrinter.print(FilePrinter.LOG_GACHAPON, log);
}
public static void logChat(MapleClient player, String chatType, String text){
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
FilePrinter.print("chat.txt", "[" + sdf.format(Calendar.getInstance().getTime()) + "] (" + chatType + ") " +player.getPlayer().getName() + ": " + text + "\r\n");
FilePrinter.print(FilePrinter.LOG_CHAT, "[" + sdf.format(Calendar.getInstance().getTime()) + "] (" + chatType + ") " +player.getPlayer().getName() + ": " + text);
}
}

View File

@@ -49,7 +49,7 @@ public class MapleLogger {
return;
}
String packet = op.toString() + "\r\n" + HexTool.toString((byte[]) message);
FilePrinter.printError(FilePrinter.PACKET_LOGS + c.getAccountName() + "-" + c.getPlayer().getName() + ".txt", packet + "\r\n\r\n");
FilePrinter.printError(FilePrinter.PACKET_LOGS + c.getAccountName() + "-" + c.getPlayer().getName() + ".txt", packet);
}
private static final boolean isRecvBlocked(RecvOpcode op){

View File

@@ -120,7 +120,7 @@ import server.maps.AbstractMapleMapObject;
public class MaplePacketCreator {
public static final List<Pair<MapleStat, Integer>> EMPTY_STATUPDATE = Collections.emptyList();
private final static long FT_UT_OFFSET = 116444592000000000L; // EDT
private final static long FT_UT_OFFSET = 116444628000000000L;
private final static long DEFAULT_TIME = 150842304000000000L;//00 80 05 BB 46 E6 17 02
public final static long ZERO_TIME = 94354848000000000L;//00 40 E0 FD 3B 37 4F 01
private final static long PERMANENT = 150841440000000000L; // 00 C0 9B 90 7D E5 17 02
@@ -363,7 +363,7 @@ public class MaplePacketCreator {
}
private static void addExpirationTime(final MaplePacketLittleEndianWriter mplew, long time) {
mplew.writeLong(getTime(time));
mplew.writeLong(getTime(time)); // offset expiration time issue found thanks to Thora
}
private static void addItemInfo(final MaplePacketLittleEndianWriter mplew, Item item) {
@@ -1064,8 +1064,8 @@ public class MaplePacketCreator {
mplew.write(spawnPoint);
mplew.writeShort(chr.getHp());
mplew.writeBool(false);
mplew.writeLong(getTime(Server.getInstance().getCurrentTime()));
mplew.skip(8);
mplew.writeLong(0); // getTime(Server.getInstance().getCurrentTime())?
mplew.skip(ServerConstants.DEBUG_VALUES[0]);
return mplew.getPacket();
}
@@ -1081,8 +1081,8 @@ public class MaplePacketCreator {
mplew.writeBool(true);
mplew.writeInt(spawnPosition.x); // spawn position placement thanks to Arnah (Vertisy)
mplew.writeInt(spawnPosition.y);
mplew.writeLong(getTime(Server.getInstance().getCurrentTime()));
mplew.skip(8);
mplew.writeLong(0); // getTime(Server.getInstance().getCurrentTime())?
mplew.skip(ServerConstants.DEBUG_VALUES[0]);
return mplew.getPacket();
}
@@ -2867,7 +2867,7 @@ public class MaplePacketCreator {
mplew.write(1);
mplew.writeShort(quest);
mplew.write(2);
mplew.writeLong(time);
mplew.writeLong(getTime(time));
return mplew.getPacket();
}