@divinevoxel/vlox 0.0.73 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Contexts/Base/Remote/InitDataSync.js +4 -0
- package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -0
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -0
- package/Init/StartConstructor.js +2 -0
- package/Math/index.d.ts +5 -1
- package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
- package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +15 -22
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +118 -197
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +8 -70
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +18 -183
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/VoxelMeshBuffers.js +2 -2
- package/Mesher/InitTask.js +5 -1
- package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
- package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +7 -7
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +22 -25
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +3 -3
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -9
- package/Mesher/Models/VoxelModelBuilder.js +1 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelModels.js +16 -39
- package/Models/Defaults/LiquidVoxelModel.js +3 -3
- package/Models/Defaults/PanelVoxelModels.js +10 -36
- package/Models/Defaults/StairVoxelModel.js +6 -21
- package/Models/Examples.js +23 -44
- package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
- package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
- package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +13 -13
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +8 -8
- package/Models/VoxelModel.types.d.ts +3 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/InitTasks.js +1 -9
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +24 -23
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +2 -2
- package/Settings/EngineSettings.d.ts +1 -0
- package/Settings/EngineSettings.js +6 -3
- package/Settings/EngineSettings.types.d.ts +7 -21
- package/Settings/EngineSettings.types.js +6 -14
- package/Tasks/Logic/InitTasks.d.ts +1 -0
- package/Tasks/Logic/InitTasks.js +10 -0
- package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
- package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
- package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
- package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
- package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
- package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
- package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
- package/Tasks/Propagation/InitTasks.js +4 -4
- package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
- package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
- package/Tasks/Tasks.types.d.ts +2 -2
- package/Tasks/TasksIds.d.ts +2 -1
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/Update/Common.d.ts +3 -0
- package/Tasks/Update/Common.js +41 -0
- package/Tasks/Update/EreaseUpdate.d.ts +3 -0
- package/Tasks/Update/EreaseUpdate.js +66 -0
- package/Tasks/Update/InitTasks.d.ts +2 -2
- package/Tasks/Update/InitTasks.js +3 -1
- package/Tasks/Update/PaintUpdate.d.ts +3 -0
- package/Tasks/Update/PaintUpdate.js +89 -0
- package/Tasks/Update/VoxelUpdate.d.ts +2 -5
- package/Tasks/Update/VoxelUpdate.js +5 -147
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +15 -7
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +20 -7
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -2
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- package/Tools/Brush/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +2 -2
- package/Tools/Brush/Brush.js +1 -1
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryBuffer.d.ts +17 -11
- package/Util/Binary/BinaryBuffer.js +65 -59
- package/Util/Binary/BinaryTree.d.ts +46 -0
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +7 -2
- package/Voxels/Cursor/VoxelCursor.interface.js +46 -2
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +5 -0
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +31 -31
- package/Voxels/Functions/BuildTagAndPaletteData.js +5 -0
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +12 -8
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
- package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
- package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
- package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
- package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
- package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
- package/Voxels/Logic/VoxelLogic.types.js +1 -0
- package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
- package/Voxels/Logic/VoxelLogicRegister.js +15 -0
- package/Voxels/State/SchemaRegister.js +10 -5
- package/Voxels/State/State.types.d.ts +1 -1
- package/Voxels/State/StateTreeReader.d.ts +1 -1
- package/Voxels/State/StateTreeReader.js +2 -3
- package/Voxels/Types/Voxel.types.d.ts +3 -0
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +31 -12
- package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
- package/World/Archive/Classes/ArchiveClasses.js +78 -0
- package/World/Archive/Classes/ImportedSection.d.ts +40 -0
- package/World/Archive/Classes/ImportedSection.js +307 -0
- package/World/Archive/Classes/ImportedSector.d.ts +23 -0
- package/World/Archive/Classes/ImportedSector.js +97 -0
- package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
- package/World/Archive/Functions/ArchiveArea.js +39 -36
- package/World/Archive/Functions/ArchiveSector.js +210 -404
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +1 -3
- package/World/Archive/Functions/ImportSector.js +13 -244
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +2 -2
- package/World/Archive/Functions/Shared.js +15 -40
- package/World/Archive/InitTasks.js +7 -10
- package/World/Cursor/SectionCursor.d.ts +1 -1
- package/World/Cursor/SectorCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.d.ts +4 -3
- package/World/Cursor/WorldCursor.js +16 -13
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +23 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/Section/Section.d.ts +17 -4
- package/World/Section/Section.js +68 -6
- package/World/Section/SectionState.d.ts +4 -2
- package/World/Section/SectionState.js +4 -2
- package/World/Sector/Sector.d.ts +7 -1
- package/World/Sector/Sector.js +37 -4
- package/World/Sector/SectorState.d.ts +3 -2
- package/World/Sector/SectorState.js +3 -2
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/WorldRegister.d.ts +9 -9
- package/World/WorldRegister.js +9 -6
- package/World/WorldSpaces.js +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +6 -4
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +9 -5
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
- package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
- package/{Tasks/IWG/Internal/Classes/BuildQueue.js → WorldSimulation/Internal/Classes/TickQueue.js} +16 -7
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +6 -6
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
- package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
- package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +29 -19
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
- package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
- package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
- package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
- package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -14
- package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
- package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
- package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +5 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +5 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +21 -21
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- package/package.json +1 -1
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +0 -11
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
- package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -30
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
|
@@ -1,337 +1,25 @@
|
|
|
1
|
-
import { StringPalette } from "../../../Util/StringPalette";
|
|
2
|
-
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
3
1
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
4
2
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
5
3
|
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
6
4
|
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
7
5
|
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
8
6
|
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
9
|
-
import { setNibbleArrayIndex } from "../../../Util/Binary/BinaryArrays";
|
|
10
7
|
import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
isPaletted: false,
|
|
17
|
-
remapped: false,
|
|
18
|
-
value: 0,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const getProcessedSection = (section) => {
|
|
22
|
-
return {
|
|
23
|
-
original: section,
|
|
24
|
-
palettes: getSectionPalettes(),
|
|
25
|
-
isBuriedAllTheSame: false,
|
|
26
|
-
buriedValue: 0,
|
|
27
|
-
isVoxelMapAllTheSame: false,
|
|
28
|
-
voxelMapValue: 0,
|
|
29
|
-
isDirtyMapAllTheSame: false,
|
|
30
|
-
dirtyMapValue: 0,
|
|
31
|
-
// ids
|
|
32
|
-
ids: getProcessedData(new Uint16Array(section.ids.length)),
|
|
33
|
-
// light
|
|
34
|
-
light: {
|
|
35
|
-
sun: getProcessedData(new Uint8Array(section.light.length)),
|
|
36
|
-
red: getProcessedData(new Uint8Array(section.light.length)),
|
|
37
|
-
green: getProcessedData(new Uint8Array(section.light.length)),
|
|
38
|
-
blue: getProcessedData(new Uint8Array(section.light.length)),
|
|
39
|
-
},
|
|
40
|
-
// level
|
|
41
|
-
level: getProcessedData(new Uint8Array(section.level.length)),
|
|
42
|
-
// state
|
|
43
|
-
state: getProcessedData(new Uint16Array(section.level.length)),
|
|
44
|
-
// mod
|
|
45
|
-
mod: getProcessedData(new Uint16Array(section.mod.length)),
|
|
46
|
-
// secondary
|
|
47
|
-
secondary: getProcessedData(new Uint16Array(section.mod.length)),
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
function getLightPalette() {
|
|
51
|
-
return {
|
|
52
|
-
sun: new NumberPalette(),
|
|
53
|
-
red: new NumberPalette(),
|
|
54
|
-
green: new NumberPalette(),
|
|
55
|
-
blue: new NumberPalette(),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function getSectionPalettes() {
|
|
59
|
-
return {
|
|
60
|
-
ids: new NumberPalette(),
|
|
61
|
-
level: new NumberPalette(),
|
|
62
|
-
light: getLightPalette(),
|
|
63
|
-
state: new NumberPalette(),
|
|
64
|
-
mod: new NumberPalette(),
|
|
65
|
-
secondaryId: new NumberPalette(),
|
|
66
|
-
secondaryState: new NumberPalette(),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function getColumnPalettes() {
|
|
70
|
-
return {
|
|
71
|
-
ids: new StringPalette(),
|
|
72
|
-
level: new NumberPalette(),
|
|
73
|
-
light: getLightPalette(),
|
|
74
|
-
stateIdMap: [],
|
|
75
|
-
state: new NumberPalette(),
|
|
76
|
-
modIdMap: [],
|
|
77
|
-
mod: new NumberPalette(),
|
|
78
|
-
secondaryId: new StringPalette(),
|
|
79
|
-
secondaryState: new NumberPalette(),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function getLightBuffer(light, buffer) {
|
|
83
|
-
const array = new Uint8Array(buffer.length / 2);
|
|
84
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
85
|
-
let l = 0;
|
|
86
|
-
if (light == "sun")
|
|
87
|
-
l = lightData.getS(buffer[i]);
|
|
88
|
-
if (light == "red")
|
|
89
|
-
l = lightData.getR(buffer[i]);
|
|
90
|
-
if (light == "green")
|
|
91
|
-
l = lightData.getG(buffer[i]);
|
|
92
|
-
if (light == "blue")
|
|
93
|
-
l = lightData.getB(buffer[i]);
|
|
94
|
-
setNibbleArrayIndex(array, i, l);
|
|
95
|
-
}
|
|
96
|
-
return array;
|
|
97
|
-
}
|
|
98
|
-
function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
99
|
-
const palettes = {};
|
|
100
|
-
if (archiveSection.ids.remapped)
|
|
101
|
-
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
102
|
-
if (archiveSection.level.remapped)
|
|
103
|
-
palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
|
|
104
|
-
if (archiveSection.light.sun.remapped) {
|
|
105
|
-
palettes.light ??= {};
|
|
106
|
-
palettes.light.sun = Uint8Array.from(archiveSection.palettes.light.sun._palette);
|
|
107
|
-
}
|
|
108
|
-
if (archiveSection.light.red.remapped) {
|
|
109
|
-
palettes.light ??= {};
|
|
110
|
-
palettes.light.red = Uint8Array.from(archiveSection.palettes.light.red._palette);
|
|
111
|
-
}
|
|
112
|
-
if (archiveSection.light.green.remapped) {
|
|
113
|
-
palettes.light ??= {};
|
|
114
|
-
palettes.light.green = Uint8Array.from(archiveSection.palettes.light.green._palette);
|
|
115
|
-
}
|
|
116
|
-
if (archiveSection.light.blue.remapped) {
|
|
117
|
-
palettes.light ??= {};
|
|
118
|
-
palettes.light.blue = Uint8Array.from(archiveSection.palettes.light.blue._palette);
|
|
119
|
-
}
|
|
120
|
-
if (archiveSection.state.remapped)
|
|
121
|
-
palettes.state = Uint16Array.from(archiveSection.palettes.state._palette);
|
|
122
|
-
if (archiveSection.mod.remapped)
|
|
123
|
-
palettes.mod = Uint16Array.from(archiveSection.palettes.mod._palette);
|
|
124
|
-
if (archiveSection.secondary.remapped) {
|
|
125
|
-
palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
|
|
126
|
-
palettes.secondaryState = Uint16Array.from(archiveSection.palettes.secondaryState._palette);
|
|
127
|
-
}
|
|
128
|
-
const buffers = {};
|
|
129
|
-
//id
|
|
130
|
-
if (archiveSection.ids.allTheSame) {
|
|
131
|
-
if (archiveSection.ids.buffer[0] !== 0) {
|
|
132
|
-
buffers.id = archiveSection.ids.buffer[0];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else if (archiveSection.ids.isPaletted) {
|
|
136
|
-
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.ids.remapped
|
|
137
|
-
? archiveSection.palettes.ids.size
|
|
138
|
-
: sectorPalettes.ids.size);
|
|
139
|
-
buffers.id = BinaryBuffer.Create({
|
|
140
|
-
buffer: BinaryBuffer.Convert(archiveSection.ids.buffer, "16-bit", type),
|
|
141
|
-
type,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
buffers.id = BinaryBuffer.Create({
|
|
146
|
-
buffer: archiveSection.ids.buffer,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
//level
|
|
150
|
-
if (archiveSection.level.allTheSame) {
|
|
151
|
-
if (archiveSection.level.buffer[0] !== 0) {
|
|
152
|
-
buffers.level = archiveSection.level.buffer[0];
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else if (archiveSection.level.isPaletted) {
|
|
156
|
-
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.level.remapped
|
|
157
|
-
? archiveSection.palettes.level.size
|
|
158
|
-
: sectorPalettes.level.size);
|
|
159
|
-
buffers.level = BinaryBuffer.Create({
|
|
160
|
-
buffer: BinaryBuffer.Convert(archiveSection.level.buffer, "8-bit", type),
|
|
161
|
-
type,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
buffers.level = BinaryBuffer.Create({
|
|
166
|
-
buffer: archiveSection.original.level.slice(),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
for (const semgnet of lightSegments) {
|
|
170
|
-
if (archiveSection.light[semgnet].allTheSame) {
|
|
171
|
-
if (archiveSection.light[semgnet].value !== 0) {
|
|
172
|
-
buffers.light ??= {};
|
|
173
|
-
buffers.light[semgnet] = archiveSection.light[semgnet].value;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else if (archiveSection.light[semgnet].isPaletted) {
|
|
177
|
-
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.light[semgnet].remapped
|
|
178
|
-
? archiveSection.palettes.light[semgnet].size
|
|
179
|
-
: sectorPalettes.light[semgnet].size);
|
|
180
|
-
buffers.light ??= {};
|
|
181
|
-
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
182
|
-
buffer: BinaryBuffer.Convert(archiveSection.light[semgnet].buffer, "8-bit", type),
|
|
183
|
-
type,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
buffers.light ??= {};
|
|
188
|
-
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
189
|
-
buffer: getLightBuffer(semgnet, archiveSection.original.light),
|
|
190
|
-
type: "4-bit",
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (archiveSection.state.allTheSame) {
|
|
195
|
-
if (archiveSection.state.buffer[0] !== 0) {
|
|
196
|
-
buffers.state = archiveSection.state.buffer[0];
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
else if (archiveSection.state.isPaletted) {
|
|
200
|
-
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.state.remapped
|
|
201
|
-
? archiveSection.palettes.state.size
|
|
202
|
-
: sectorPalettes.state.size);
|
|
203
|
-
buffers.state = BinaryBuffer.Create({
|
|
204
|
-
buffer: BinaryBuffer.Convert(archiveSection.state.buffer, "16-bit", type),
|
|
205
|
-
type,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
buffers.state = BinaryBuffer.Create({
|
|
210
|
-
buffer: archiveSection.state.buffer,
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
if (archiveSection.mod.allTheSame) {
|
|
214
|
-
if (archiveSection.mod.buffer[0] !== 0) {
|
|
215
|
-
buffers.mod = archiveSection.mod.buffer[0];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (archiveSection.mod.isPaletted) {
|
|
219
|
-
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.mod.remapped
|
|
220
|
-
? archiveSection.palettes.mod.size
|
|
221
|
-
: sectorPalettes.mod.size);
|
|
222
|
-
buffers.mod = BinaryBuffer.Create({
|
|
223
|
-
buffer: BinaryBuffer.Convert(archiveSection.mod.buffer, "16-bit", type),
|
|
224
|
-
type,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
buffers.mod = BinaryBuffer.Create({
|
|
229
|
-
buffer: archiveSection.mod.buffer,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
if (archiveSection.secondary.allTheSame) {
|
|
233
|
-
if (archiveSection.secondary.buffer[0] !== 0) {
|
|
234
|
-
buffers.secondary = archiveSection.secondary.buffer[0];
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
else if (archiveSection.secondary.isPaletted) {
|
|
238
|
-
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.secondary.remapped
|
|
239
|
-
? Math.max(archiveSection.palettes.secondaryState.size, archiveSection.palettes.secondaryId.size)
|
|
240
|
-
: Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size));
|
|
241
|
-
buffers.secondary = BinaryBuffer.Create({
|
|
242
|
-
buffer: BinaryBuffer.Convert(archiveSection.secondary.buffer, "16-bit", type),
|
|
243
|
-
type,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
buffers.secondary = BinaryBuffer.Create({
|
|
248
|
-
buffer: archiveSection.secondary.buffer,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
if (archiveSection.isBuriedAllTheSame) {
|
|
252
|
-
if (archiveSection.buriedValue !== 0) {
|
|
253
|
-
buffers.buried = archiveSection.buriedValue;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
buffers.buried = archiveSection.original.buried.slice();
|
|
258
|
-
}
|
|
259
|
-
if (archiveSection.isVoxelMapAllTheSame) {
|
|
260
|
-
if (archiveSection.voxelMapValue !== 0) {
|
|
261
|
-
buffers.voxelMap = archiveSection.voxelMapValue;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
buffers.voxelMap = archiveSection.original.voxelMap.slice();
|
|
266
|
-
}
|
|
267
|
-
if (archiveSection.isDirtyMapAllTheSame) {
|
|
268
|
-
if (archiveSection.dirtyMapValue !== 0) {
|
|
269
|
-
buffers.dirtyMap = archiveSection.dirtyMapValue;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
buffers.dirtyMap = archiveSection.original.dirtyMap.slice();
|
|
274
|
-
}
|
|
275
|
-
const flags = archiveSection.original.storeFlags();
|
|
276
|
-
return {
|
|
277
|
-
...(Object.keys(flags).length ? { flags } : {}),
|
|
278
|
-
...(Object.keys(palettes).length ? { palettes } : {}),
|
|
279
|
-
buffers,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
function RemoveDuplicates(data) {
|
|
283
|
-
const duplicateSectionMap = new Map();
|
|
284
|
-
let duplicateSections = [];
|
|
285
|
-
for (let i = 0; i < data.sections.length; i++) {
|
|
286
|
-
for (let j = 0; j < data.sections.length; j++) {
|
|
287
|
-
const section1 = data.sections[i];
|
|
288
|
-
const section2 = data.sections[j];
|
|
289
|
-
if (i == j)
|
|
290
|
-
continue;
|
|
291
|
-
if (typeof section1 == "string" || typeof section2 == "string")
|
|
292
|
-
continue;
|
|
293
|
-
let index = -1;
|
|
294
|
-
if (compareSection(section1, section2)) {
|
|
295
|
-
if (duplicateSectionMap.has(section2)) {
|
|
296
|
-
index = duplicateSectionMap.get(section2)[1];
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
let found = false;
|
|
300
|
-
for (let k = 0; k < duplicateSections.length; k++) {
|
|
301
|
-
if (compareSection(section1, duplicateSections[k])) {
|
|
302
|
-
index = k;
|
|
303
|
-
found = true;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (!found) {
|
|
307
|
-
duplicateSections.push(section1);
|
|
308
|
-
index = duplicateSections.length - 1;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
duplicateSectionMap.set(section1, [i, index]);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
const sections = {};
|
|
316
|
-
for (const [object, [sectionIndex, index]] of duplicateSectionMap) {
|
|
317
|
-
const id = uint16To4CharString(index);
|
|
318
|
-
if (!sections[id])
|
|
319
|
-
sections[id] = object;
|
|
320
|
-
data.sections[sectionIndex] = id;
|
|
321
|
-
}
|
|
322
|
-
data.duplicates = {
|
|
323
|
-
sections,
|
|
324
|
-
};
|
|
325
|
-
}
|
|
8
|
+
import { lightSegments, lightSemgnetGet } from "./Shared";
|
|
9
|
+
import { ProcessedSection, SectorPalette, VoxelStateObjectMap, } from "../Classes/ArchiveClasses";
|
|
10
|
+
import { CreateArchivedSection } from "./CreateArchivedSection";
|
|
11
|
+
import { RemoveDuplicates } from "./RemoveDuplicates";
|
|
12
|
+
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
326
13
|
const lightData = new VoxelLightData();
|
|
327
14
|
export default function ArchiveSector(archiveData) {
|
|
328
15
|
const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
329
16
|
if (!sector)
|
|
330
|
-
throw new Error(`
|
|
331
|
-
const sectorPalettes =
|
|
17
|
+
throw new Error(`Sector at location ${location} does not exist when trying to arhicve it.`);
|
|
18
|
+
const sectorPalettes = new SectorPalette();
|
|
332
19
|
const processedSections = [];
|
|
333
|
-
for (
|
|
334
|
-
const
|
|
20
|
+
for (let sectionIndex = 0; sectionIndex < sector.sections.length; sectionIndex++) {
|
|
21
|
+
const section = sector.sections[sectionIndex];
|
|
22
|
+
const processedSection = new ProcessedSection(section);
|
|
335
23
|
{
|
|
336
24
|
let value = section.buried[0];
|
|
337
25
|
processedSection.isBuriedAllTheSame = true;
|
|
@@ -392,46 +80,84 @@ export default function ArchiveSector(archiveData) {
|
|
|
392
80
|
? !sectorPalettes.secondaryId.isRegistered(secondaryId)
|
|
393
81
|
? sectorPalettes.secondaryId.register(secondaryId)
|
|
394
82
|
: sectorPalettes.secondaryId.getNumberId(secondaryId)
|
|
395
|
-
: !sectorPalettes.
|
|
396
|
-
? sectorPalettes.
|
|
397
|
-
: sectorPalettes.
|
|
83
|
+
: !sectorPalettes.secondaryValue.isRegistered(section.secondary[i])
|
|
84
|
+
? sectorPalettes.secondaryValue.register(section.secondary[i])
|
|
85
|
+
: sectorPalettes.secondaryValue.getId(section.secondary[i]);
|
|
398
86
|
if (VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]) {
|
|
399
87
|
if (!processedSection.palettes.secondaryId.isRegistered(voxelSecondary))
|
|
400
88
|
processedSection.palettes.secondaryId.register(voxelSecondary);
|
|
401
89
|
}
|
|
402
90
|
else {
|
|
403
|
-
if (!processedSection.palettes.
|
|
404
|
-
processedSection.palettes.
|
|
91
|
+
if (!processedSection.palettes.secondaryValue.isRegistered(voxelSecondary))
|
|
92
|
+
processedSection.palettes.secondaryValue.register(voxelSecondary);
|
|
405
93
|
}
|
|
406
94
|
const voxelLevel = !sectorPalettes.level.isRegistered(section.level[i])
|
|
407
95
|
? sectorPalettes.level.register(section.level[i])
|
|
408
96
|
: sectorPalettes.level.getId(section.level[i]);
|
|
409
97
|
if (!processedSection.palettes.level.isRegistered(section.level[i]))
|
|
410
98
|
processedSection.palettes.level.register(section.level[i]);
|
|
99
|
+
let stateMap;
|
|
100
|
+
if (secondaryId) {
|
|
101
|
+
if (!sectorPalettes.secondaryStateMap[voxelSecondary]) {
|
|
102
|
+
stateMap = new VoxelStateObjectMap();
|
|
103
|
+
sectorPalettes.secondaryStateMap[voxelId] = stateMap;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
stateMap = sectorPalettes.secondaryStateMap[voxelSecondary];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (!sectorPalettes.stateMap[voxelId]) {
|
|
111
|
+
stateMap = new VoxelStateObjectMap();
|
|
112
|
+
sectorPalettes.stateMap[voxelId] = stateMap;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
stateMap = sectorPalettes.stateMap[voxelId];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
411
118
|
let voxelState = -1;
|
|
412
|
-
if (!
|
|
413
|
-
voxelState =
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
119
|
+
if (!stateMap.palette.isRegistered(section.state[i])) {
|
|
120
|
+
voxelState = stateMap.palette.register(section.state[i]);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
voxelState = stateMap.palette.getId(section.state[i]);
|
|
124
|
+
}
|
|
125
|
+
if (!processedSection.palettes.state[voxelId]) {
|
|
126
|
+
processedSection.palettes.state[voxelId] = new NumberPalette();
|
|
127
|
+
}
|
|
128
|
+
if (!processedSection.palettes.state[voxelId].isRegistered(voxelState))
|
|
129
|
+
processedSection.palettes.state[voxelId].register(voxelState);
|
|
130
|
+
let modMap;
|
|
131
|
+
if (secondaryId) {
|
|
132
|
+
if (!sectorPalettes.secondaryModMap[voxelSecondary]) {
|
|
133
|
+
modMap = new VoxelStateObjectMap();
|
|
134
|
+
sectorPalettes.secondaryModMap[voxelSecondary] = modMap;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
modMap = sectorPalettes.secondaryModMap[voxelSecondary];
|
|
138
|
+
}
|
|
417
139
|
}
|
|
418
140
|
else {
|
|
419
|
-
|
|
141
|
+
if (!sectorPalettes.modMap[voxelId]) {
|
|
142
|
+
modMap = new VoxelStateObjectMap();
|
|
143
|
+
sectorPalettes.modMap[voxelSecondary] = modMap;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
modMap = sectorPalettes.modMap[voxelId];
|
|
147
|
+
}
|
|
420
148
|
}
|
|
421
|
-
if (!processedSection.palettes.state.isRegistered(voxelState))
|
|
422
|
-
processedSection.palettes.state.register(voxelState);
|
|
423
149
|
let voxelMod = -1;
|
|
424
|
-
if (!
|
|
425
|
-
voxelMod =
|
|
426
|
-
sectorPalettes.modIdMap[voxelMod] = secondaryId
|
|
427
|
-
? section.secondary[i]
|
|
428
|
-
: section.ids[i];
|
|
150
|
+
if (!modMap.palette.isRegistered(section.mod[i])) {
|
|
151
|
+
voxelMod = modMap.palette.register(section.mod[i]);
|
|
429
152
|
}
|
|
430
153
|
else {
|
|
431
|
-
voxelMod =
|
|
154
|
+
voxelMod = modMap.palette.getId(section.mod[i]);
|
|
155
|
+
}
|
|
156
|
+
if (!processedSection.palettes.mod[voxelId]) {
|
|
157
|
+
processedSection.palettes.mod[voxelId] = new NumberPalette();
|
|
432
158
|
}
|
|
433
|
-
if (!processedSection.palettes.mod.isRegistered(voxelMod))
|
|
434
|
-
processedSection.palettes.mod.register(voxelMod);
|
|
159
|
+
if (!processedSection.palettes.mod[voxelId].isRegistered(voxelMod))
|
|
160
|
+
processedSection.palettes.mod[voxelId].register(voxelMod);
|
|
435
161
|
for (let l = 0; l < lightSegments.length; l++) {
|
|
436
162
|
const segment = lightSegments[l];
|
|
437
163
|
const light = lightSemgnetGet[segment](section.light[i]);
|
|
@@ -461,7 +187,7 @@ export default function ArchiveSector(archiveData) {
|
|
|
461
187
|
processedSection.mod.buffer[i] = voxelMod;
|
|
462
188
|
processedSection.secondary.buffer[i] = voxelSecondary;
|
|
463
189
|
}
|
|
464
|
-
processedSections
|
|
190
|
+
processedSections[sectionIndex] = processedSection;
|
|
465
191
|
}
|
|
466
192
|
let neededPalettes = {
|
|
467
193
|
level: false,
|
|
@@ -472,53 +198,78 @@ export default function ArchiveSector(archiveData) {
|
|
|
472
198
|
blue: false,
|
|
473
199
|
},
|
|
474
200
|
};
|
|
201
|
+
for (const state of sectorPalettes.stateMap) {
|
|
202
|
+
if (!state)
|
|
203
|
+
continue;
|
|
204
|
+
if (state.palette.size > sectorPalettes.maxStatePaletteSize)
|
|
205
|
+
sectorPalettes.maxStatePaletteSize = state.palette.size;
|
|
206
|
+
}
|
|
207
|
+
for (const mod of sectorPalettes.modMap) {
|
|
208
|
+
if (!mod)
|
|
209
|
+
continue;
|
|
210
|
+
if (mod.palette.size > sectorPalettes.maxModPaletteSize)
|
|
211
|
+
sectorPalettes.maxModPaletteSize = mod.palette.size;
|
|
212
|
+
}
|
|
475
213
|
for (const archivedSection of processedSections) {
|
|
214
|
+
for (const stateId in archivedSection.palettes.state) {
|
|
215
|
+
const state = archivedSection.palettes.state[stateId];
|
|
216
|
+
if (!state)
|
|
217
|
+
continue;
|
|
218
|
+
if (state.size > archivedSection.palettes.maxStatePaletteSize)
|
|
219
|
+
archivedSection.palettes.maxStatePaletteSize = state.size;
|
|
220
|
+
}
|
|
221
|
+
for (const modId in archivedSection.palettes.mod) {
|
|
222
|
+
const mod = archivedSection.palettes.state[modId];
|
|
223
|
+
if (!mod)
|
|
224
|
+
continue;
|
|
225
|
+
if (mod.size > archivedSection.palettes.maxModPaletteSize)
|
|
226
|
+
archivedSection.palettes.maxModPaletteSize = mod.size;
|
|
227
|
+
}
|
|
476
228
|
//ids
|
|
477
229
|
archivedSection.ids.isPaletted =
|
|
478
|
-
sectorPalettes.ids.size <= BinaryBuffer.
|
|
479
|
-
archivedSection.palettes.ids.size <= BinaryBuffer.
|
|
230
|
+
sectorPalettes.ids.size <= BinaryBuffer.ByteArrayMax ||
|
|
231
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.ByteArrayMax;
|
|
480
232
|
archivedSection.ids.remapped =
|
|
481
|
-
sectorPalettes.ids.size > BinaryBuffer.
|
|
482
|
-
archivedSection.palettes.ids.size <= BinaryBuffer.
|
|
233
|
+
sectorPalettes.ids.size > BinaryBuffer.ByteArrayMax &&
|
|
234
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.ByteArrayMax &&
|
|
483
235
|
!archivedSection.ids.allTheSame;
|
|
484
236
|
//level
|
|
485
237
|
archivedSection.level.isPaletted =
|
|
486
|
-
sectorPalettes.level.size <= BinaryBuffer.
|
|
487
|
-
archivedSection.palettes.level.size <= BinaryBuffer.
|
|
238
|
+
sectorPalettes.level.size <= BinaryBuffer.NibbleArrayMax &&
|
|
239
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibbleArrayMax;
|
|
488
240
|
archivedSection.level.remapped =
|
|
489
|
-
sectorPalettes.level.size > BinaryBuffer.
|
|
490
|
-
archivedSection.palettes.level.size <= BinaryBuffer.
|
|
241
|
+
sectorPalettes.level.size > BinaryBuffer.NibbleArrayMax &&
|
|
242
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibbleArrayMax &&
|
|
491
243
|
!archivedSection.level.allTheSame;
|
|
492
244
|
if (archivedSection.level.isPaletted && !archivedSection.level.remapped) {
|
|
493
245
|
neededPalettes.level = true;
|
|
494
246
|
}
|
|
495
247
|
//state
|
|
496
248
|
archivedSection.state.isPaletted =
|
|
497
|
-
sectorPalettes.
|
|
498
|
-
archivedSection.palettes.
|
|
249
|
+
sectorPalettes.maxStatePaletteSize <= BinaryBuffer.ByteArrayMax ||
|
|
250
|
+
archivedSection.palettes.maxStatePaletteSize <= BinaryBuffer.ByteArrayMax;
|
|
499
251
|
archivedSection.state.remapped =
|
|
500
|
-
sectorPalettes.
|
|
501
|
-
archivedSection.palettes.
|
|
252
|
+
sectorPalettes.maxStatePaletteSize > BinaryBuffer.ByteArrayMax &&
|
|
253
|
+
archivedSection.palettes.maxStatePaletteSize <=
|
|
254
|
+
BinaryBuffer.ByteArrayMax &&
|
|
502
255
|
!archivedSection.state.allTheSame;
|
|
503
256
|
//mod
|
|
504
257
|
archivedSection.mod.isPaletted =
|
|
505
|
-
sectorPalettes.
|
|
506
|
-
archivedSection.palettes.
|
|
258
|
+
sectorPalettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax ||
|
|
259
|
+
archivedSection.palettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax;
|
|
507
260
|
archivedSection.mod.remapped =
|
|
508
|
-
sectorPalettes.
|
|
509
|
-
archivedSection.palettes.
|
|
261
|
+
sectorPalettes.maxModPaletteSize > BinaryBuffer.ByteArrayMax &&
|
|
262
|
+
archivedSection.palettes.maxModPaletteSize <= BinaryBuffer.ByteArrayMax &&
|
|
510
263
|
!archivedSection.mod.allTheSame;
|
|
511
264
|
for (const semgnet of lightSegments) {
|
|
512
265
|
archivedSection.light[semgnet].isPaletted =
|
|
513
|
-
sectorPalettes.light[semgnet].size <=
|
|
514
|
-
BinaryBuffer.HalfNibblePaletteMax ||
|
|
266
|
+
sectorPalettes.light[semgnet].size <= BinaryBuffer.HalfNibbleArrayMax ||
|
|
515
267
|
archivedSection.palettes.light[semgnet].size <=
|
|
516
|
-
BinaryBuffer.
|
|
268
|
+
BinaryBuffer.HalfNibbleArrayMax;
|
|
517
269
|
archivedSection.light[semgnet].remapped =
|
|
518
|
-
sectorPalettes.light[semgnet].size >
|
|
519
|
-
BinaryBuffer.HalfNibblePaletteMax &&
|
|
270
|
+
sectorPalettes.light[semgnet].size > BinaryBuffer.HalfNibbleArrayMax &&
|
|
520
271
|
archivedSection.palettes.light[semgnet].size <=
|
|
521
|
-
BinaryBuffer.
|
|
272
|
+
BinaryBuffer.HalfNibbleArrayMax &&
|
|
522
273
|
!archivedSection.light[semgnet].allTheSame;
|
|
523
274
|
if (archivedSection.light[semgnet].isPaletted &&
|
|
524
275
|
!archivedSection.light[semgnet].remapped) {
|
|
@@ -527,15 +278,14 @@ export default function ArchiveSector(archiveData) {
|
|
|
527
278
|
}
|
|
528
279
|
//secondary
|
|
529
280
|
archivedSection.secondary.isPaletted =
|
|
530
|
-
(sectorPalettes.
|
|
531
|
-
sectorPalettes.secondaryId.size <= BinaryBuffer.
|
|
532
|
-
(archivedSection.palettes.
|
|
533
|
-
BinaryBuffer.
|
|
534
|
-
archivedSection.palettes.secondaryId.size <=
|
|
535
|
-
BinaryBuffer.BytePaletteMax);
|
|
281
|
+
(sectorPalettes.secondaryValue.size <= BinaryBuffer.ByteArrayMax &&
|
|
282
|
+
sectorPalettes.secondaryId.size <= BinaryBuffer.ByteArrayMax) ||
|
|
283
|
+
(archivedSection.palettes.secondaryValue.size <=
|
|
284
|
+
BinaryBuffer.ByteArrayMax &&
|
|
285
|
+
archivedSection.palettes.secondaryId.size <= BinaryBuffer.ByteArrayMax);
|
|
536
286
|
archivedSection.secondary.remapped =
|
|
537
|
-
Math.max(sectorPalettes.
|
|
538
|
-
Math.max(archivedSection.palettes.secondaryId.size, archivedSection.palettes.
|
|
287
|
+
Math.max(sectorPalettes.secondaryValue.size, sectorPalettes.secondaryId.size) > BinaryBuffer.ByteArrayMax &&
|
|
288
|
+
Math.max(archivedSection.palettes.secondaryId.size, archivedSection.palettes.secondaryValue.size) <= BinaryBuffer.ByteArrayMax &&
|
|
539
289
|
!archivedSection.secondary.allTheSame;
|
|
540
290
|
if (!archivedSection.ids.remapped &&
|
|
541
291
|
!archivedSection.light.sun.remapped &&
|
|
@@ -548,8 +298,21 @@ export default function ArchiveSector(archiveData) {
|
|
|
548
298
|
continue;
|
|
549
299
|
const length = archivedSection.original.ids.length;
|
|
550
300
|
for (let i = 0; i < length; i++) {
|
|
301
|
+
let secondary = false;
|
|
302
|
+
if (VoxelTagsRegister.VoxelTags[archivedSection.original.ids[i]]["dve_can_have_secondary"] &&
|
|
303
|
+
archivedSection.original.secondary[i] !== 0) {
|
|
304
|
+
secondary = true;
|
|
305
|
+
}
|
|
306
|
+
let stateId = !secondary
|
|
307
|
+
? archivedSection.ids.buffer[i]
|
|
308
|
+
: archivedSection.secondary.buffer[i];
|
|
309
|
+
if (archivedSection.state.remapped)
|
|
310
|
+
archivedSection.state.buffer[i] = archivedSection.palettes.state[stateId].getId(sectorPalettes.stateMap[stateId].palette.getId(archivedSection.state.buffer[i]));
|
|
311
|
+
if (archivedSection.mod.remapped)
|
|
312
|
+
archivedSection.mod.buffer[i] = archivedSection.palettes.mod[stateId].getId(sectorPalettes.modMap[archivedSection.ids.buffer[i]].palette.getId(stateId));
|
|
551
313
|
if (archivedSection.ids.remapped)
|
|
552
|
-
archivedSection.ids.buffer[i] =
|
|
314
|
+
archivedSection.ids.buffer[i] =
|
|
315
|
+
archivedSection.palettes.ids.getId(stateId);
|
|
553
316
|
for (let l = 0; l < lightSegments.length; l++) {
|
|
554
317
|
const segment = lightSegments[l];
|
|
555
318
|
if (archivedSection.light[segment].remapped) {
|
|
@@ -559,48 +322,86 @@ export default function ArchiveSector(archiveData) {
|
|
|
559
322
|
}
|
|
560
323
|
if (archivedSection.level.remapped)
|
|
561
324
|
archivedSection.level.buffer[i] = archivedSection.palettes.level.getId(archivedSection.original.level[i]);
|
|
562
|
-
if (archivedSection.state.remapped)
|
|
563
|
-
archivedSection.state.buffer[i] = archivedSection.palettes.state.getId(sectorPalettes.state.getId(archivedSection.state.buffer[i]));
|
|
564
|
-
if (archivedSection.mod.remapped)
|
|
565
|
-
archivedSection.mod.buffer[i] = archivedSection.palettes.mod.getId(sectorPalettes.mod.getId(archivedSection.mod.buffer[i]));
|
|
566
325
|
if (archivedSection.secondary.remapped)
|
|
567
|
-
archivedSection.secondary.buffer[i] =
|
|
326
|
+
archivedSection.secondary.buffer[i] = secondary
|
|
568
327
|
? archivedSection.palettes.secondaryId.getId(archivedSection.secondary.buffer[i])
|
|
569
|
-
: archivedSection.palettes.
|
|
328
|
+
: archivedSection.palettes.secondaryValue.getId(archivedSection.secondary.buffer[i]);
|
|
570
329
|
}
|
|
571
330
|
}
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
331
|
+
const palettes = {
|
|
332
|
+
id: sectorPalettes.ids._palette,
|
|
333
|
+
stateMap: [],
|
|
334
|
+
secondaryStateMap: [],
|
|
335
|
+
modMap: [],
|
|
336
|
+
secondaryModMap: [],
|
|
337
|
+
light: {},
|
|
338
|
+
secondaryId: sectorPalettes.secondaryId._palette,
|
|
339
|
+
secondaryValue: new Uint16Array(sectorPalettes.secondaryValue._palette),
|
|
340
|
+
};
|
|
341
|
+
const stateMap = palettes.stateMap;
|
|
342
|
+
for (let i = 0; i < sectorPalettes.stateMap.length; i++) {
|
|
343
|
+
const states = sectorPalettes.stateMap[i]?.palette;
|
|
344
|
+
if (!states)
|
|
345
|
+
continue;
|
|
346
|
+
const voxelId = sectorPalettes.ids._palette[i];
|
|
576
347
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
577
348
|
continue;
|
|
578
349
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
579
|
-
|
|
350
|
+
const voxelStates = [];
|
|
351
|
+
stateMap[i] = voxelStates;
|
|
352
|
+
for (let k = 0; k < states._palette.length; k++) {
|
|
353
|
+
voxelStates[k] = schema.state.getStateObject(states._palette[k]);
|
|
354
|
+
}
|
|
580
355
|
}
|
|
581
|
-
const
|
|
582
|
-
for (let i = 0; i < sectorPalettes.
|
|
583
|
-
const
|
|
584
|
-
|
|
356
|
+
const secondaryStateMap = palettes.secondaryStateMap;
|
|
357
|
+
for (let i = 0; i < sectorPalettes.secondaryStateMap.length; i++) {
|
|
358
|
+
const states = sectorPalettes.secondaryStateMap[i]?.palette;
|
|
359
|
+
if (!states)
|
|
360
|
+
continue;
|
|
361
|
+
const voxelId = sectorPalettes.secondaryId._palette[i];
|
|
585
362
|
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
586
363
|
continue;
|
|
587
364
|
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
588
|
-
|
|
365
|
+
const voxelStates = [];
|
|
366
|
+
secondaryStateMap[i] = voxelStates;
|
|
367
|
+
for (let k = 0; k < states._palette.length; k++) {
|
|
368
|
+
voxelStates[k] = schema.state.getStateObject(states._palette[k]);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const modMap = palettes.modMap;
|
|
372
|
+
for (let i = 0; i < sectorPalettes.modMap.length; i++) {
|
|
373
|
+
const mods = sectorPalettes.modMap[i]?.palette;
|
|
374
|
+
if (!mods)
|
|
375
|
+
continue;
|
|
376
|
+
const voxelId = sectorPalettes.ids._palette[i];
|
|
377
|
+
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
378
|
+
continue;
|
|
379
|
+
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
380
|
+
const voxelMods = [];
|
|
381
|
+
modMap[i] = voxelMods;
|
|
382
|
+
for (let k = 0; k < mods._palette.length; k++) {
|
|
383
|
+
voxelMods[k] = schema.mod.getStateObject(mods._palette[k]);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const secondaryModMap = palettes.modMap;
|
|
387
|
+
for (let i = 0; i < sectorPalettes.secondaryModMap.length; i++) {
|
|
388
|
+
const mods = sectorPalettes.secondaryModMap[i]?.palette;
|
|
389
|
+
if (!mods)
|
|
390
|
+
continue;
|
|
391
|
+
const voxelId = sectorPalettes.secondaryId._palette[i];
|
|
392
|
+
if (!SchemaRegister.hasVoxelSchema(voxelId))
|
|
393
|
+
continue;
|
|
394
|
+
const schema = SchemaRegister.getVoxelSchemas(voxelId);
|
|
395
|
+
const voxelMods = [];
|
|
396
|
+
secondaryModMap[i] = voxelMods;
|
|
397
|
+
for (let k = 0; k < mods._palette.length; k++) {
|
|
398
|
+
voxelMods[k] = schema.mod.getStateObject(mods._palette[k]);
|
|
399
|
+
}
|
|
589
400
|
}
|
|
590
401
|
const sections = [];
|
|
591
|
-
for (
|
|
592
|
-
sections
|
|
402
|
+
for (let sectionIndex = 0; sectionIndex < processedSections.length; sectionIndex++) {
|
|
403
|
+
sections[sectionIndex] = CreateArchivedSection(processedSections[sectionIndex], sectorPalettes);
|
|
593
404
|
}
|
|
594
|
-
const palettes = {
|
|
595
|
-
id: sectorPalettes.ids._palette,
|
|
596
|
-
stateMap,
|
|
597
|
-
modMap,
|
|
598
|
-
state: new Uint16Array(sectorPalettes.state._palette),
|
|
599
|
-
mod: new Uint16Array(sectorPalettes.mod._palette),
|
|
600
|
-
light: {},
|
|
601
|
-
secondaryId: sectorPalettes.secondaryId._palette,
|
|
602
|
-
secondaryState: new Uint16Array(sectorPalettes.secondaryState._palette),
|
|
603
|
-
};
|
|
604
405
|
if (neededPalettes.level) {
|
|
605
406
|
palettes.level = new Uint8Array(sectorPalettes.level._palette);
|
|
606
407
|
}
|
|
@@ -612,7 +413,12 @@ export default function ArchiveSector(archiveData) {
|
|
|
612
413
|
const archivedSector = {
|
|
613
414
|
version: "",
|
|
614
415
|
vloxVersion: EngineSettings.version,
|
|
615
|
-
|
|
416
|
+
dimension: WorldRegister.dimensions.get(archiveData.location[0]).id,
|
|
417
|
+
location: [
|
|
418
|
+
archiveData.location[1],
|
|
419
|
+
archiveData.location[2],
|
|
420
|
+
archiveData.location[3],
|
|
421
|
+
],
|
|
616
422
|
flags: sector.storeFlags(),
|
|
617
423
|
timestamps: sector.storeTimestamps(),
|
|
618
424
|
buffers: {},
|