Fixed several AI bugs, added log system

- Fixes 0000031: Incap is not working correctly
- NPC AI now considers deathblow values correctly
- AI state transition further debugged
- Pet now follows owner after killing attacker
- Added debug log system
- Cleaned up system console from system.out messages
This commit is contained in:
CharonInferar
2014-07-06 23:47:56 +02:00
parent 7eca666dbe
commit 81a811a425
21 changed files with 612 additions and 118 deletions
+60
View File
@@ -0,0 +1,60 @@
package tools;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.nio.file.*;
public class CharonPacketLogger extends Thread {
private static final CharonPacketLogger instance = new CharonPacketLogger();
private BlockingQueue<String> itemsToLog =
new ArrayBlockingQueue<String>(100);
private static final String SHUTDOWN_REQ = "SHUTDOWN";
private volatile boolean shuttingDown, loggerTerminated;
public static CharonPacketLogger getLogger() {
return instance;
}
private CharonPacketLogger() {
start();
}
public void run() {
try {
String item;
while ((item = itemsToLog.take()) != SHUTDOWN_REQ) {
System.out.println(item);
}
} catch (InterruptedException iex) {
} finally {
loggerTerminated = true;
}
}
public void log(String str) {
if (shuttingDown || loggerTerminated) return;
try {
itemsToLog.put(str);
} catch (InterruptedException iex) {
Thread.currentThread().interrupt();
throw new RuntimeException("Unexpected interruption");
}
}
public void log(String str,Path path) {
if (shuttingDown || loggerTerminated) return;
try {
itemsToLog.put(str);
CharonPacketUtils.appendToLog(str, path);
} catch (InterruptedException iex) {
Thread.currentThread().interrupt();
throw new RuntimeException("Unexpected interruption");
}
}
public void shutDown() throws InterruptedException {
shuttingDown = true;
itemsToLog.put(SHUTDOWN_REQ);
}
}