Fix logger bug, vertQual.next/pre missing ULTRA, subdim array compare
This commit is contained in:
@@ -64,6 +64,8 @@ public enum VerticalQuality
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case ULTRA:
|
||||
return VerticalQuality.HIGH;
|
||||
case HIGH:
|
||||
return VerticalQuality.MEDIUM;
|
||||
case MEDIUM:
|
||||
@@ -84,6 +86,8 @@ public enum VerticalQuality
|
||||
case LOW:
|
||||
return VerticalQuality.MEDIUM;
|
||||
case HIGH:
|
||||
return VerticalQuality.ULTRA;
|
||||
case ULTRA:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class LodDimensionFileHandler
|
||||
// close the reader and delete the file.
|
||||
inputStream.close();
|
||||
file.delete();
|
||||
LOGGER.info("Outdated LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
LOGGER.info("Outdated LOD region file for region: (" + regionX + "," + regionZ + ")[" + tempDetailLevel + "]"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ ". File has been deleted.");
|
||||
@@ -257,7 +257,7 @@ public class LodDimensionFileHandler
|
||||
// close the reader and ignore the file, we don't
|
||||
// want to accidentally delete anything the user may want.
|
||||
inputStream.close();
|
||||
LOGGER.info("Newer LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
LOGGER.info("Newer LOD region file for region: (" + regionX + "," + regionZ + ")[" + tempDetailLevel + "]"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ " this region will not be written to in order to protect the newer file.");
|
||||
@@ -266,7 +266,7 @@ public class LodDimensionFileHandler
|
||||
}
|
||||
else if (fileVersion < LOD_SAVE_FILE_VERSION)
|
||||
{
|
||||
LOGGER.info("Old LOD region file for region: (" + regionX + "," + regionZ + ")"
|
||||
LOGGER.info("Old LOD region file for region: (" + regionX + "," + regionZ + ")[" + tempDetailLevel + "]"
|
||||
+ " version found: " + fileVersion
|
||||
+ ", version requested: " + LOD_SAVE_FILE_VERSION
|
||||
+ ". File will be loaded and updated to new format in next save.");
|
||||
@@ -279,6 +279,7 @@ public class LodDimensionFileHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.debug("Loading LOD region file for region: (" + regionX + "," + regionZ + ")[" + tempDetailLevel + "]");
|
||||
// this file is a readable version,
|
||||
// read and add the data to our region
|
||||
DataInputStream dataStream = new DataInputStream(inputStream);
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.seibel.lod.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.objects.lod.LodRegion;
|
||||
import com.seibel.lod.core.objects.lod.RegionPos;
|
||||
import com.seibel.lod.core.util.DataPointUtil;
|
||||
import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
|
||||
@@ -56,11 +57,14 @@ public class LodSubDimensionFolderFinder
|
||||
*/
|
||||
public static File determineSubDimensionFolder() throws IOException
|
||||
{
|
||||
if (FIRST_SEEN_PLAYER_DATA == null)
|
||||
{
|
||||
if (FIRST_SEEN_PLAYER_DATA == null) {
|
||||
LOGGER.debug("Creating FIRST SEEN PLAYER DATA for testing...");
|
||||
FIRST_SEEN_PLAYER_DATA = PLAYER_DATA;
|
||||
PLAYER_DATA = new LodSubDimensionFolderFinder.PlayerData(MC);
|
||||
LOGGER.debug("Created FIRST SEEN PLAYER DATA: {}", FIRST_SEEN_PLAYER_DATA);
|
||||
}
|
||||
LOGGER.debug("Creating PLAYER DATA for testing...");
|
||||
PLAYER_DATA = new LodSubDimensionFolderFinder.PlayerData(MC);
|
||||
LOGGER.debug("Created PLAYER DATA: {}", PLAYER_DATA);
|
||||
|
||||
|
||||
// relevant positions
|
||||
@@ -73,6 +77,7 @@ public class LodSubDimensionFolderFinder
|
||||
// chunk from the newly loaded dimension
|
||||
IChunkWrapper newlyLoadedChunk = MC.getWrappedClientWorld().tryGetChunk(playerChunkPos);
|
||||
// check if this chunk is valid to test
|
||||
LOGGER.debug("Getting chunk for testing...");
|
||||
if (!LodSubDimensionFolderFinder.CanDetermineDimensionFolder(newlyLoadedChunk))
|
||||
return null;
|
||||
|
||||
@@ -82,6 +87,7 @@ public class LodSubDimensionFolderFinder
|
||||
newlyLoadedDim.regions.set(playerRegionPos.x, playerRegionPos.z, new LodRegion(LodUtil.BLOCK_DETAIL_LEVEL, playerRegionPos, VERTICAL_QUALITY_TO_TEST_WITH));
|
||||
|
||||
// generate a LOD to test against
|
||||
LOGGER.debug("Generating LOD for testing...");
|
||||
boolean lodGenerated = ApiShared.lodBuilder.generateLodNodeFromChunk(newlyLoadedDim, newlyLoadedChunk, new LodBuilderConfig(DistanceGenerationMode.FULL), true, true);
|
||||
if (!lodGenerated)
|
||||
return null;
|
||||
@@ -102,7 +108,7 @@ public class LodSubDimensionFolderFinder
|
||||
newChunkData[x][z] = array;
|
||||
}
|
||||
}
|
||||
boolean newChunkHasData = isDataEmpty(newChunkData);
|
||||
boolean newChunkHasData = !isDataEmpty(newChunkData);
|
||||
|
||||
// check if the chunk is actually empty
|
||||
if (!newChunkHasData)
|
||||
@@ -113,13 +119,13 @@ public class LodSubDimensionFolderFinder
|
||||
|
||||
String message = "Error: the chunk at (" + playerChunkPos.getX() + "," + playerChunkPos.getZ() + ") has a height of [" + newlyLoadedChunk.getHeight() + "] but the LOD generated is empty!";
|
||||
LOGGER.error(message);
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
String message = "Warning: The chunk at (" + playerChunkPos.getX() + "," + playerChunkPos.getZ() + ") is empty.";
|
||||
LOGGER.warn(message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -180,10 +186,11 @@ public class LodSubDimensionFolderFinder
|
||||
// {
|
||||
// // TODO do something with this information
|
||||
// }
|
||||
LOGGER.trace("Comparing the two LODs:\n {}\n===================++\n {}\n\n", newChunkData, testChunkData);
|
||||
|
||||
|
||||
// check if the chunk is actually empty
|
||||
if (!isDataEmpty(newChunkData))
|
||||
if (isDataEmpty(testChunkData))
|
||||
{
|
||||
String message = "The test chunk for dimension folder [" + LodUtil.shortenString(testDimFolder.getName(), 8) + "] and chunk pos (" + playerChunkPos.getX() + "," + playerChunkPos.getZ() + ") is empty. Is that correct?";
|
||||
LOGGER.info(message);
|
||||
@@ -205,6 +212,9 @@ public class LodSubDimensionFolderFinder
|
||||
equalLines++;
|
||||
}
|
||||
totalLineCount++;
|
||||
if (!DataPointUtil.doesItExist(newChunkData[x][z][y]) || !DataPointUtil.doesItExist(testChunkData[x][z][y])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,6 +222,7 @@ public class LodSubDimensionFolderFinder
|
||||
|
||||
// determine if this world is closer to the newly loaded world
|
||||
double percentEqual = (double) equalLines / (double) totalLineCount;
|
||||
LOGGER.info("Equal lines: [" + equalLines + "] Total lines: [" + totalLineCount + "] Percent equal: [" + percentEqual + "]");
|
||||
if (equalLines > mostEqualLines)
|
||||
{
|
||||
mostEqualLines = equalLines;
|
||||
@@ -302,13 +313,13 @@ public class LodSubDimensionFolderFinder
|
||||
{
|
||||
if (dataPoint != 0)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,12 +36,18 @@ public class ConfigBasedLogger {
|
||||
public boolean canMaybeLog() {return mode != LoggerMode.DISABLED;}
|
||||
|
||||
public void log(Level level, String str, Object... param) {
|
||||
|
||||
Message msg = ApiShared.LOGGER.getMessageFactory().newMessage(str, param);
|
||||
String msgStr = msg.getFormattedMessage();
|
||||
if (mode.levelForFile.isLessSpecificThan(level)) {
|
||||
ApiShared.LOGGER.atLevel(level).withLocation().log(msgStr);
|
||||
Level logLevel = level.isLessSpecificThan(Level.INFO) ? Level.INFO : level;
|
||||
if (param.length > 0 && param[param.length-1] instanceof Throwable)
|
||||
ApiShared.LOGGER.atLevel(logLevel).withLocation().withThrowable((Throwable)param[param.length-1]).log(msgStr);
|
||||
else ApiShared.LOGGER.atLevel(logLevel).withLocation().log(msgStr);
|
||||
}
|
||||
if (mode.levelForChat.isLessSpecificThan(level)) {
|
||||
if (param.length > 0 && param[param.length-1] instanceof Throwable)
|
||||
ClientApi.logToChat(level, msgStr + "\nat\n" + ((Throwable) param[param.length-1]).getStackTrace().toString());
|
||||
ClientApi.logToChat(level, msgStr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.message.Message;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -47,9 +48,14 @@ public class ConfigBasedSpamLogger {
|
||||
Message msg = ApiShared.LOGGER.getMessageFactory().newMessage(str, param);
|
||||
String msgStr = msg.getFormattedMessage();
|
||||
if (mode.levelForFile.isLessSpecificThan(level)) {
|
||||
ApiShared.LOGGER.atLevel(level).withLocation().log(msgStr);
|
||||
Level logLevel = level.isLessSpecificThan(Level.INFO) ? Level.INFO : level;
|
||||
if (param.length > 0 && param[param.length-1] instanceof Throwable)
|
||||
ApiShared.LOGGER.atLevel(logLevel).withLocation().withThrowable((Throwable)param[param.length-1]).log(msgStr);
|
||||
else ApiShared.LOGGER.atLevel(logLevel).withLocation().log(msgStr);
|
||||
}
|
||||
if (mode.levelForChat.isLessSpecificThan(level)) {
|
||||
if (param.length > 0 && param[param.length-1] instanceof Throwable)
|
||||
ClientApi.logToChat(level, msgStr + "\nat\n" + ((Throwable) param[param.length-1]).getStackTrace().toString());
|
||||
ClientApi.logToChat(level, msgStr);
|
||||
}
|
||||
}
|
||||
@@ -79,9 +85,14 @@ public class ConfigBasedSpamLogger {
|
||||
Message msg = ApiShared.LOGGER.getMessageFactory().newMessage(str, param);
|
||||
String msgStr = msg.getFormattedMessage();
|
||||
if (mode.levelForFile.isLessSpecificThan(level)) {
|
||||
ApiShared.LOGGER.atLevel(level).withLocation().log(msgStr);
|
||||
Level logLevel = level.isLessSpecificThan(Level.INFO) ? Level.INFO : level;
|
||||
if (param.length > 0 && param[param.length-1] instanceof Throwable)
|
||||
ApiShared.LOGGER.atLevel(logLevel).withLocation().withThrowable((Throwable)param[param.length-1]).log(msgStr);
|
||||
else ApiShared.LOGGER.atLevel(logLevel).withLocation().log(msgStr);
|
||||
}
|
||||
if (mode.levelForChat.isLessSpecificThan(level)) {
|
||||
if (param.length > 0 && param[param.length-1] instanceof Throwable)
|
||||
ClientApi.logToChat(level, msgStr + "\nat\n" + Arrays.toString(((Throwable) param[param.length - 1]).getStackTrace()));
|
||||
ClientApi.logToChat(level, msgStr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SpamReducedLogger {
|
||||
|
||||
public void log(Level level, String str, Object... param) {
|
||||
if (logTries.get() >= maxLogCount) return;
|
||||
ApiShared.LOGGER.log(level, str, param);
|
||||
ApiShared.LOGGER.log(level.isLessSpecificThan(Level.INFO) ? Level.INFO : level, str, param);
|
||||
}
|
||||
|
||||
public void error(String str, Object... param) {
|
||||
@@ -57,7 +57,7 @@ public class SpamReducedLogger {
|
||||
|
||||
public void logInc(Level level, String str, Object... param) {
|
||||
if (logTries.getAndIncrement() >= maxLogCount) return;
|
||||
ApiShared.LOGGER.log(level, str, param);
|
||||
ApiShared.LOGGER.log(level.isLessSpecificThan(Level.INFO) ? Level.INFO : level, str, param);
|
||||
}
|
||||
|
||||
public void errorInc(String str, Object... param) {
|
||||
|
||||
@@ -77,10 +77,12 @@ public class LodVertexBuffer implements AutoCloseable
|
||||
|
||||
private void _uploadBufferStorage(ByteBuffer bb) {
|
||||
if (!isBufferStorage) throw new IllegalStateException("Buffer is not bufferStorage but its trying to use bufferStorage upload method!");
|
||||
int bbSize = bb.limit() - bb.position();
|
||||
GL32.glDeleteBuffers(id);
|
||||
id = GL32.glGenBuffers();
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, id);
|
||||
GL44.glBufferStorage(GL32.GL_ARRAY_BUFFER, bb, 0);
|
||||
size = bbSize;
|
||||
}
|
||||
|
||||
// bufferData
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.seibel.lod.core.util.LodUtil;
|
||||
import com.seibel.lod.core.util.StatsMap;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
|
||||
import static com.seibel.lod.core.render.GLProxy.GL_LOGGER;
|
||||
|
||||
public class SimpleRenderBuffer extends RenderBuffer
|
||||
{
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
@@ -75,6 +77,7 @@ public class SimpleRenderBuffer extends RenderBuffer
|
||||
if (b.size == FULL_SIZED_BUFFERS) {
|
||||
statsMap.incStat("FullsizedVBOs");
|
||||
}
|
||||
if (b.size == 0) GL_LOGGER.warn("VBO with size 0");
|
||||
statsMap.incBytesStat("TotalUsage", b.size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ public class StatsMap
|
||||
longMap.put(key, longMap.getOrDefault(key, 0L)+value);
|
||||
}
|
||||
public void incBytesStat(String key, long bytes) {
|
||||
bytesMap.put(key, new UnitBytes(bytesMap.getOrDefault(key, new UnitBytes(0)).value()+bytes));
|
||||
long b = bytesMap.getOrDefault(key, new UnitBytes(0)).value;
|
||||
bytesMap.put(key, new UnitBytes(b+bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.seibel.lod.core.util;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class UnitBytes
|
||||
{
|
||||
public final long value;
|
||||
@@ -43,4 +45,17 @@ public class UnitBytes
|
||||
str.append(v).append("B");
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
UnitBytes unitBytes = (UnitBytes) o;
|
||||
return value == unitBytes.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user