Fixed incorrect teleporting to house portal on logout
House now kicks guests when owner leaves More aggressively unload old house regions (experiment) Added DEBUG log type (currently unused, but shows up in cyan when used and the world is in development mode)
This commit is contained in:
@@ -268,16 +268,20 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean flagInactive(boolean force) {
|
||||
if (unload(this, force)) {
|
||||
active = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags the region as inactive.
|
||||
*/
|
||||
protected boolean flagInactive() {
|
||||
if(unload(this)) {
|
||||
active = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public boolean flagInactive() {
|
||||
return flagInactive(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,18 +345,22 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean unload(Region r) {
|
||||
return unload(r, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads a region.
|
||||
* @param r The region.
|
||||
*/
|
||||
private static boolean unload(Region r) {
|
||||
if (r.isViewed()) {
|
||||
public static boolean unload(Region r, boolean force) {
|
||||
if (!force && r.isViewed()) {
|
||||
log(CommunicationInfo.class, Log.ERR, "Players viewing region!");
|
||||
r.flagActive();
|
||||
return false;
|
||||
}
|
||||
for (RegionPlane p : r.planes) {
|
||||
if (!p.getPlayers().isEmpty()) {
|
||||
if (!force && !p.getPlayers().isEmpty()) {
|
||||
log(CommunicationInfo.class, Log.ERR, "Players still in region!");
|
||||
r.flagActive();
|
||||
return false;
|
||||
@@ -366,6 +374,7 @@ public class Region {
|
||||
}
|
||||
}
|
||||
}
|
||||
r.activityPulse.stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -855,6 +855,15 @@ object RegionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun removeRegion(id: Int) {
|
||||
if (lock.tryLock() || LOCK.tryLock(10000, TimeUnit.MILLISECONDS)) {
|
||||
val r = REGION_CACHE.remove(id)
|
||||
r?.flagInactive(true)
|
||||
LOCK.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the regionCache.
|
||||
* @return The regionCache.
|
||||
|
||||
@@ -343,7 +343,7 @@ public final class DynamicRegion extends Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flagInactive() {
|
||||
public boolean flagInactive(boolean force) {
|
||||
if (!permanent) {
|
||||
if (parentRegion != null && parentRegion.isActive()) {
|
||||
parentRegion.checkInactive();
|
||||
@@ -356,7 +356,7 @@ public final class DynamicRegion extends Region {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!super.flagInactive()) {
|
||||
if(!super.flagInactive(force)) {
|
||||
return false;
|
||||
}
|
||||
for (RegionPlane plane : getPlanes()) {
|
||||
@@ -381,7 +381,7 @@ public final class DynamicRegion extends Region {
|
||||
boolean allLinkedInactive = true;
|
||||
if (linked != null) {
|
||||
for (DynamicRegion r : linked) {
|
||||
allLinkedInactive &= r.flagInactive();
|
||||
allLinkedInactive &= r.flagInactive(force);
|
||||
}
|
||||
}
|
||||
return allLinkedInactive;
|
||||
|
||||
@@ -4,7 +4,8 @@ import com.github.ajalt.mordant.rendering.TextColors
|
||||
import com.github.ajalt.mordant.terminal.*
|
||||
import com.google.protobuf.ByteString.Output
|
||||
import core.ServerConstants
|
||||
import core.api.log
|
||||
import core.game.world.GameWorld
|
||||
import core.api.*
|
||||
import java.io.OutputStream
|
||||
import java.io.PrintStream
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -27,6 +28,13 @@ object SystemLogger {
|
||||
@JvmStatic
|
||||
fun processLogEntry(clazz: Class<*>, log: Log, message: String) {
|
||||
when (log) {
|
||||
Log.DEBUG -> {
|
||||
if (GameWorld.settings?.isDevMode != true)
|
||||
return
|
||||
val msg = TextColors.cyan("${getTime()}: [${clazz.simpleName}] $message")
|
||||
t.println(msg)
|
||||
}
|
||||
|
||||
Log.FINE -> {
|
||||
if (ServerConstants.LOG_LEVEL < LogLevel.VERBOSE)
|
||||
return
|
||||
@@ -88,5 +96,6 @@ enum class Log {
|
||||
FINE,
|
||||
INFO,
|
||||
WARN,
|
||||
ERR
|
||||
}
|
||||
ERR,
|
||||
DEBUG
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user