Merge remote-tracking branch 'origin-core/main'

This commit is contained in:
Steveplays28
2023-09-23 16:34:07 +02:00
8 changed files with 26 additions and 47 deletions
@@ -1110,8 +1110,6 @@ public class Config
// TODO write strings
public static class Debugging
{
public static ConfigCategory debugWireframeRendering = new ConfigCategory.Builder().set(DebugWireframeRendering.class).build();
public static ConfigEntry<ERendererMode> rendererMode = new ConfigEntry.Builder<ERendererMode>()
.set(ERendererMode.DEFAULT)
.comment(""
@@ -1160,44 +1158,6 @@ public class Config
+ " Mod compatibility is not guaranteed.")
.build();
public static class DebugWireframeRendering
{
public static ConfigEntry<Boolean> enableRendering = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment(""
+ "If enabled, various wireframes for debugging internal functions will be drawn. \n"
+ "\n"
+ "NOTE: There WILL be performance hit! \n"
+ " Additionally, only stuff that's loaded after you enable this \n"
+ " will render their debug wireframes.")
.build();
public static ConfigEntry<Boolean> fullDataMetaFile = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Class: FullDataMetaFile")
.build();
public static ConfigEntry<Boolean> lodRenderSection = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Class: LodRenderSection")
.build();
public static ConfigEntry<Boolean> renderDataMetaFile = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Class: RenderDataMetaFile")
.build();
public static ConfigEntry<Boolean> worldGenerationQueue = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Class: WorldGenerationQueue")
.build();
public static ConfigEntry<Boolean> worldRemoteGenerationQueue = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment("Class: WorldRemoteGenerationQueue")
.build();
}
public static ConfigEntry<Boolean> enableWhiteWorld = new ConfigEntry.Builder<Boolean>()
.set(false)
.comment(""
@@ -38,8 +38,11 @@ public class CompleteFullDataSourceLoader extends AbstractFullDataSourceLoader
/** Uses a given stream to create a temporary {@link CompleteFullDataSource}, which is not saved. */
public CompleteFullDataSource loadData(DhSectionPos pos, DhDataInputStream inputStream, IDhLevel level) throws IOException, InterruptedException
{
CompleteFullDataSource dataSource = CompleteFullDataSource.createEmpty(pos);
dataSource.populateFromStream(null, inputStream, level);
CompleteFullDataSource dataSource = (CompleteFullDataSource) this.tryGetPooledSource();
if (dataSource == null)
dataSource = CompleteFullDataSource.createEmpty(pos);
dataSource.repopulateFromStream(pos, inputStream, level);
return dataSource;
}
}
@@ -66,6 +66,22 @@ public interface IStreamableFullDataSource<SummaryDataType extends IStreamableFu
this.populateFromStream(dataFile, inputStream, level);
}
/**
* Clears and then overwrites any data in this object with the data from the given file and stream.
* This is expected to be used with an existing {@link IStreamableFullDataSource} and can be used in place of a constructor to reuse an existing {@link IStreamableFullDataSource} object.
*
* @see IStreamableFullDataSource#populateFromStream
*/
default void repopulateFromStream(DhSectionPos pos, DhDataInputStream inputStream, IDhLevel level) throws IOException, InterruptedException
{
// clear/overwrite the old data
this.resizeDataStructuresForRepopulation(pos);
this.getMapping().clear(pos);
// set the new data
this.populateFromStream(null, inputStream, level);
}
/**
* Overwrites any data in this object with the data from the given file and stream.
* This is expected to be used with an empty {@link IStreamableFullDataSource} and functions similar to a constructor.
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.core.file.fullDatafile;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.config.listeners.ConfigChangeListener;
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
import com.seibel.distanthorizons.core.dataObjects.fullData.loader.AbstractFullDataSourceLoader;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.HighDetailIncompleteFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.LowDetailIncompleteFullDataSource;
@@ -467,8 +467,6 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile implements I
@Override
public void debugRender(DebugRenderer debugRenderer)
{
if (!Config.Client.Advanced.Debugging.DebugWireframeRendering.fullDataMetaFile.get()) return;
if (this.pos.getDetailLevel() > DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL)
{
return;
@@ -188,6 +188,7 @@ public class WorldRemoteGenerationQueue implements IWorldGenerationQueue, IDebug
return entry.future.cancel(false);
fullDataSource.splitIntoChunkSizedAccessors(chunkDataConsumer);
response.getFullDataSourceLoader().returnPooledDataSource(fullDataSource);
}
catch (InvalidLevelException ignored)
{
@@ -255,13 +256,12 @@ public class WorldRemoteGenerationQueue implements IWorldGenerationQueue, IDebug
public void close()
{
f3Message.close();
DebugRenderer.unregister(this, Config.Client.Advanced.Debugging.DebugWireframe.showWorldGenQueue);
}
@Override
public void debugRender(DebugRenderer r)
{
if (!Config.Client.Advanced.Debugging.DebugWireframeRendering.worldRemoteGenerationQueue.get()) return;
for (Map.Entry<DhSectionPos, WorldGenQueueEntry> mapEntry : waitingTasks.entrySet())
{
r.renderBox(new DebugRenderer.Box(mapEntry.getKey(), -32f, 64f, 0.05f,
@@ -237,7 +237,7 @@ public class DhServerLevel extends DhLevel implements IDhServerLevel
{
for (ServerPlayerState serverPlayerState : remotePlayerConnectionHandler.getConnectedPlayers())
{
if (serverPlayerState.config.isRealTimeUpdatesEnabled()) continue;
if (!serverPlayerState.config.isRealTimeUpdatesEnabled()) continue;
if (chunk.getChunkPos().distance(new DhChunkPos(serverPlayerState.serverPlayer.getPosition())) <= serverPlayerState.config.getRenderDistance())
serverPlayerState.channelContext.writeAndFlush(new FullDataPartialUpdateMessage(chunkSizedFullDataAccessor, this));
@@ -41,6 +41,7 @@ public class FullDataSourceResponseMessage extends FutureTrackableNetworkMessage
private DhServerLevel level;
private CompleteFullDataSourceLoader fullDataSourceLoader;
public CompleteFullDataSourceLoader getFullDataSourceLoader() { return fullDataSourceLoader; }
private ByteBuf dataBuffer;
public FullDataSourceResponseMessage() {}