@divinevoxel/vlox 0.0.72 → 0.0.73
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/Render/DivineVoxelEngineRender.d.ts +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
- package/Init/StartConstructor.js +6 -4
- package/Init/StartWorld.d.ts +1 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +1 -1
- package/Mesher/Functions/MeshSection.js +20 -8
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
- package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +2 -2
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +1 -1
- package/Mesher/InitTask.js +4 -22
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +11 -17
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +24 -12
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
- package/Mesher/Models/RenderedMaterials.d.ts +6 -0
- package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +3 -3
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +1 -3
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +0 -23
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +11 -7
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +344 -344
- package/Models/Defaults/LiquidVoxelModel.js +2 -2
- package/Models/Defaults/PanelVoxelModels.js +432 -432
- package/Models/Defaults/StairVoxelModel.js +576 -576
- package/Models/Examples.js +469 -456
- package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +14 -5
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +6 -7
- package/Renderer/MeshManager.js +2 -2
- package/Renderer/MeshRegister.js +2 -1
- package/Settings/EngineSettings.d.ts +1 -1
- package/Settings/EngineSettings.js +3 -5
- package/Settings/EngineSettings.types.d.ts +17 -18
- package/Settings/EngineSettings.types.js +16 -15
- package/Tasks/IWG/IWG.d.ts +2 -1
- package/Tasks/IWG/IWG.js +9 -3
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
- package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
- package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
- package/Tasks/IWG/Internal/Classes/Generator.js +13 -1
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
- package/Tasks/IWG/Internal/IWGTasks.js +0 -10
- package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
- package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
- package/Tasks/Update/UpdateTask.d.ts +3 -1
- package/Tasks/Update/UpdateTask.js +28 -2
- package/Tasks/Update/VoxelUpdate.js +6 -0
- package/Tasks/WorldGeneration/WorldGenBrush.js +1 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/VoxelTemplates.types.d.ts +1 -1
- package/Textures/Classes/CompiledTexture.d.ts +18 -0
- package/Textures/Classes/CompiledTexture.js +50 -0
- package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
- package/Textures/Classes/CompiledTextureAnimation.js +27 -0
- package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
- package/Textures/Classes/TextureAnimationTexture.js +32 -0
- package/Textures/Functions/BuildTextureData.d.ts +10 -0
- package/Textures/Functions/BuildTextureData.js +205 -0
- package/Textures/Texture.types.d.ts +50 -64
- package/Textures/TextureManager.d.ts +8 -19
- package/Textures/TextureManager.js +28 -166
- package/Tools/Brush/Brush.d.ts +1 -1
- package/Tools/Brush/Brush.js +39 -7
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +29 -0
- package/Util/Binary/BinaryBuffer.js +130 -0
- package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.js +8 -11
- package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
- package/Voxels/Data/VoxelPalettesRegister.js +0 -9
- package/Voxels/Data/VoxelTagsRegister.js +7 -7
- package/Voxels/Functions/BuildStateData.js +9 -9
- package/Voxels/Functions/BuildTagAndPaletteData.js +2 -4
- package/Voxels/InitVoxelData.js +12 -13
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +18 -0
- package/Voxels/Types/Voxel.types.js +6 -2
- package/World/Archive/Archive.types.d.ts +38 -34
- package/World/Archive/Functions/ArchiveArea.js +16 -24
- package/World/Archive/Functions/ArchiveSector.js +477 -192
- package/World/Archive/Functions/ImportSector.d.ts +3 -3
- package/World/Archive/Functions/ImportSector.js +202 -141
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +75 -0
- package/World/Archive/InitTasks.js +30 -13
- package/World/Cursor/SectionCursor.d.ts +2 -2
- package/World/Cursor/SectionCursor.js +2 -3
- package/World/Cursor/SectorCursor.d.ts +2 -2
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.d.ts +2 -2
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/Cursor/WorldVoxelCursor.js +1 -0
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +12 -16
- package/World/Section/Section.js +62 -20
- package/World/Section/SectionState.d.ts +10 -0
- package/World/Section/SectionState.js +11 -0
- package/World/Sector/Sector.d.ts +14 -6
- package/World/Sector/Sector.js +67 -17
- package/World/Sector/SectorHeightMap.js +2 -2
- package/World/Sector/SectorState.d.ts +14 -6
- package/World/Sector/SectorState.js +28 -15
- package/World/Types/WorldStorage.interface.js +1 -0
- package/World/WorldRegister.d.ts +4 -0
- package/World/WorldRegister.js +15 -3
- package/World/WorldSpaces.d.ts +4 -0
- package/World/WorldSpaces.js +19 -6
- package/package.json +1 -1
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
- package/Mesher/Geomtry/GeometryNormals.js +0 -52
- package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
- package/Mesher/Geomtry/MeshData.types.js +0 -6
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
- package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
- package/Mesher/Geomtry/Tools/index.d.ts +0 -1
- package/Mesher/Geomtry/Tools/index.js +0 -1
- package/Mesher/RenderedMaterials.d.ts +0 -6
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Textures/TextureAnimations.d.ts +0 -4
- package/Textures/TextureAnimations.js +0 -35
- package/Textures/TextureArray.d.ts +0 -47
- package/Textures/TextureArray.js +0 -202
- package/Textures/TextureBuilder.d.ts +0 -13
- package/Textures/TextureBuilder.js +0 -120
- package/Textures/TextureRegister.d.ts +0 -9
- package/Textures/TextureRegister.js +0 -28
- package/Tools/DataCursor.interface.d.ts +0 -5
- package/Tools/DataCursor.interface.js +0 -2
- package/Util/Binary/BitArray.js +0 -16
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +0 -0
- /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
- /package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
|
@@ -1,50 +1,65 @@
|
|
|
1
1
|
import { StringPalette } from "../../../Util/StringPalette";
|
|
2
2
|
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
3
3
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
4
|
-
import { convertToPaletteBuffer } from "../../../Util/Binary/Palettes";
|
|
5
4
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
6
5
|
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
7
6
|
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
7
|
+
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
8
|
+
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
9
|
+
import { setNibbleArrayIndex } from "../../../Util/Binary/BinaryArrays";
|
|
10
|
+
import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
|
|
11
|
+
import { compareSection, lightSegments, lightSemgnetGet, uint16To4CharString, } from "./Shared";
|
|
12
|
+
function getProcessedData(buffer) {
|
|
13
|
+
return {
|
|
14
|
+
buffer,
|
|
15
|
+
allTheSame: true,
|
|
16
|
+
isPaletted: false,
|
|
17
|
+
remapped: false,
|
|
18
|
+
value: 0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
8
21
|
const getProcessedSection = (section) => {
|
|
9
22
|
return {
|
|
10
|
-
section,
|
|
23
|
+
original: section,
|
|
11
24
|
palettes: getSectionPalettes(),
|
|
25
|
+
isBuriedAllTheSame: false,
|
|
26
|
+
buriedValue: 0,
|
|
27
|
+
isVoxelMapAllTheSame: false,
|
|
28
|
+
voxelMapValue: 0,
|
|
29
|
+
isDirtyMapAllTheSame: false,
|
|
30
|
+
dirtyMapValue: 0,
|
|
12
31
|
// ids
|
|
13
|
-
ids: new Uint16Array(section.ids.length),
|
|
14
|
-
idsAllTheSame: true,
|
|
15
|
-
remappedIds: false,
|
|
32
|
+
ids: getProcessedData(new Uint16Array(section.ids.length)),
|
|
16
33
|
// light
|
|
17
|
-
light:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
},
|
|
21
40
|
// level
|
|
22
|
-
level: new Uint8Array(section.level.length),
|
|
23
|
-
levelAllTheSame: true,
|
|
24
|
-
isLevelPaletted: false,
|
|
25
|
-
remappedLevel: false,
|
|
41
|
+
level: getProcessedData(new Uint8Array(section.level.length)),
|
|
26
42
|
// state
|
|
27
|
-
state: new Uint16Array(section.
|
|
28
|
-
stateAllTheSame: true,
|
|
29
|
-
isStatePaletted: false,
|
|
30
|
-
remappedState: false,
|
|
43
|
+
state: getProcessedData(new Uint16Array(section.level.length)),
|
|
31
44
|
// mod
|
|
32
|
-
mod: new Uint16Array(section.mod.length),
|
|
33
|
-
modAllTheSame: true,
|
|
34
|
-
isModPaletted: false,
|
|
35
|
-
remappedMod: false,
|
|
45
|
+
mod: getProcessedData(new Uint16Array(section.mod.length)),
|
|
36
46
|
// secondary
|
|
37
|
-
secondary: new Uint16Array(section.
|
|
38
|
-
isSecondaryPaletted: false,
|
|
39
|
-
secondaryAllTheSame: true,
|
|
40
|
-
remappedSecondary: false,
|
|
47
|
+
secondary: getProcessedData(new Uint16Array(section.mod.length)),
|
|
41
48
|
};
|
|
42
49
|
};
|
|
50
|
+
function getLightPalette() {
|
|
51
|
+
return {
|
|
52
|
+
sun: new NumberPalette(),
|
|
53
|
+
red: new NumberPalette(),
|
|
54
|
+
green: new NumberPalette(),
|
|
55
|
+
blue: new NumberPalette(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
43
58
|
function getSectionPalettes() {
|
|
44
59
|
return {
|
|
45
60
|
ids: new NumberPalette(),
|
|
46
61
|
level: new NumberPalette(),
|
|
47
|
-
light:
|
|
62
|
+
light: getLightPalette(),
|
|
48
63
|
state: new NumberPalette(),
|
|
49
64
|
mod: new NumberPalette(),
|
|
50
65
|
secondaryId: new NumberPalette(),
|
|
@@ -55,7 +70,7 @@ function getColumnPalettes() {
|
|
|
55
70
|
return {
|
|
56
71
|
ids: new StringPalette(),
|
|
57
72
|
level: new NumberPalette(),
|
|
58
|
-
light:
|
|
73
|
+
light: getLightPalette(),
|
|
59
74
|
stateIdMap: [],
|
|
60
75
|
state: new NumberPalette(),
|
|
61
76
|
modIdMap: [],
|
|
@@ -64,69 +79,251 @@ function getColumnPalettes() {
|
|
|
64
79
|
secondaryState: new NumberPalette(),
|
|
65
80
|
};
|
|
66
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
|
+
}
|
|
67
98
|
function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
68
99
|
const palettes = {};
|
|
69
|
-
if (archiveSection.
|
|
100
|
+
if (archiveSection.ids.remapped)
|
|
70
101
|
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
71
|
-
if (archiveSection.
|
|
102
|
+
if (archiveSection.level.remapped)
|
|
72
103
|
palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
|
|
73
|
-
if (archiveSection.
|
|
74
|
-
palettes.light
|
|
75
|
-
|
|
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)
|
|
76
121
|
palettes.state = Uint16Array.from(archiveSection.palettes.state._palette);
|
|
77
|
-
if (archiveSection.
|
|
122
|
+
if (archiveSection.mod.remapped)
|
|
78
123
|
palettes.mod = Uint16Array.from(archiveSection.palettes.mod._palette);
|
|
79
|
-
if (archiveSection.
|
|
124
|
+
if (archiveSection.secondary.remapped) {
|
|
80
125
|
palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
|
|
81
126
|
palettes.secondaryState = Uint16Array.from(archiveSection.palettes.secondaryState._palette);
|
|
82
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();
|
|
83
276
|
return {
|
|
84
|
-
|
|
85
|
-
palettes,
|
|
86
|
-
buffers
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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,
|
|
128
324
|
};
|
|
129
325
|
}
|
|
326
|
+
const lightData = new VoxelLightData();
|
|
130
327
|
export default function ArchiveSector(archiveData) {
|
|
131
328
|
const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
132
329
|
if (!sector)
|
|
@@ -134,23 +331,61 @@ export default function ArchiveSector(archiveData) {
|
|
|
134
331
|
const sectorPalettes = getColumnPalettes();
|
|
135
332
|
const processedSections = [];
|
|
136
333
|
for (const section of sector.sections) {
|
|
137
|
-
const length = section.ids.length;
|
|
138
|
-
let firstId = -1;
|
|
139
|
-
let firstLight = -1;
|
|
140
|
-
let firstLevel = -1;
|
|
141
|
-
let firstState = -1;
|
|
142
|
-
let firstMod = -1;
|
|
143
|
-
let firstSecondary = -1;
|
|
144
334
|
const processedSection = getProcessedSection(section);
|
|
335
|
+
{
|
|
336
|
+
let value = section.buried[0];
|
|
337
|
+
processedSection.isBuriedAllTheSame = true;
|
|
338
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
339
|
+
if (value != section.buried[i]) {
|
|
340
|
+
processedSection.isBuriedAllTheSame = false;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
processedSection.buriedValue = value;
|
|
345
|
+
}
|
|
346
|
+
{
|
|
347
|
+
let value = section.voxelMap[0];
|
|
348
|
+
processedSection.isVoxelMapAllTheSame = true;
|
|
349
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
350
|
+
if (value != section.voxelMap[i]) {
|
|
351
|
+
processedSection.isVoxelMapAllTheSame = false;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
processedSection.voxelMapValue = value;
|
|
356
|
+
}
|
|
357
|
+
{
|
|
358
|
+
let value = section.dirtyMap[0];
|
|
359
|
+
processedSection.isDirtyMapAllTheSame = true;
|
|
360
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
361
|
+
if (value != section.dirtyMap[i]) {
|
|
362
|
+
processedSection.isDirtyMapAllTheSame = false;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
processedSection.dirtyMapValue = value;
|
|
367
|
+
}
|
|
368
|
+
const firstId = section.ids[0];
|
|
369
|
+
const firstLight = section.light[0];
|
|
370
|
+
const firstLevel = section.level[0];
|
|
371
|
+
const firstState = section.state[0];
|
|
372
|
+
const firstMod = section.mod[0];
|
|
373
|
+
const firstSecondary = section.secondary[0];
|
|
374
|
+
const firstLightLevels = {
|
|
375
|
+
sun: lightData.getS(firstLight),
|
|
376
|
+
red: lightData.getR(firstLight),
|
|
377
|
+
green: lightData.getG(firstLight),
|
|
378
|
+
blue: lightData.getB(firstLight),
|
|
379
|
+
};
|
|
380
|
+
const length = section.ids.length;
|
|
145
381
|
for (let i = 0; i < length; i++) {
|
|
146
382
|
const stringId = VoxelPalettesRegister.voxels.getStringId(section.ids[i]);
|
|
147
383
|
const voxelId = !sectorPalettes.ids.isRegistered(stringId)
|
|
148
384
|
? sectorPalettes.ids.register(stringId)
|
|
149
385
|
: sectorPalettes.ids.getNumberId(stringId);
|
|
386
|
+
processedSection.ids.value = voxelId;
|
|
150
387
|
if (!processedSection.palettes.ids.isRegistered(voxelId))
|
|
151
388
|
processedSection.palettes.ids.register(voxelId);
|
|
152
|
-
if (firstId == -1)
|
|
153
|
-
firstId = voxelId;
|
|
154
389
|
const secondaryId = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"] &&
|
|
155
390
|
VoxelPalettesRegister.voxels.getStringId(section.secondary[i]);
|
|
156
391
|
const voxelSecondary = secondaryId
|
|
@@ -160,20 +395,19 @@ export default function ArchiveSector(archiveData) {
|
|
|
160
395
|
: !sectorPalettes.secondaryState.isRegistered(section.secondary[i])
|
|
161
396
|
? sectorPalettes.secondaryState.register(section.secondary[i])
|
|
162
397
|
: sectorPalettes.secondaryState.getId(section.secondary[i]);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
processedSection.palettes.secondaryId.register(voxelSecondary)
|
|
166
|
-
|
|
398
|
+
if (VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"]) {
|
|
399
|
+
if (!processedSection.palettes.secondaryId.isRegistered(voxelSecondary))
|
|
400
|
+
processedSection.palettes.secondaryId.register(voxelSecondary);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
if (!processedSection.palettes.secondaryState.isRegistered(voxelSecondary))
|
|
167
404
|
processedSection.palettes.secondaryState.register(voxelSecondary);
|
|
168
|
-
|
|
169
|
-
firstSecondary = section.secondary[i];
|
|
405
|
+
}
|
|
170
406
|
const voxelLevel = !sectorPalettes.level.isRegistered(section.level[i])
|
|
171
407
|
? sectorPalettes.level.register(section.level[i])
|
|
172
408
|
: sectorPalettes.level.getId(section.level[i]);
|
|
173
409
|
if (!processedSection.palettes.level.isRegistered(section.level[i]))
|
|
174
410
|
processedSection.palettes.level.register(section.level[i]);
|
|
175
|
-
if (firstLevel == -1)
|
|
176
|
-
firstLevel = voxelLevel;
|
|
177
411
|
let voxelState = -1;
|
|
178
412
|
if (!sectorPalettes.state.isRegistered(section.state[i])) {
|
|
179
413
|
voxelState = sectorPalettes.state.register(section.state[i]);
|
|
@@ -186,12 +420,10 @@ export default function ArchiveSector(archiveData) {
|
|
|
186
420
|
}
|
|
187
421
|
if (!processedSection.palettes.state.isRegistered(voxelState))
|
|
188
422
|
processedSection.palettes.state.register(voxelState);
|
|
189
|
-
if (firstState == -1)
|
|
190
|
-
firstState = voxelState;
|
|
191
423
|
let voxelMod = -1;
|
|
192
424
|
if (!sectorPalettes.mod.isRegistered(section.mod[i])) {
|
|
193
425
|
voxelMod = sectorPalettes.mod.register(section.mod[i]);
|
|
194
|
-
sectorPalettes.
|
|
426
|
+
sectorPalettes.modIdMap[voxelMod] = secondaryId
|
|
195
427
|
? section.secondary[i]
|
|
196
428
|
: section.ids[i];
|
|
197
429
|
}
|
|
@@ -200,91 +432,141 @@ export default function ArchiveSector(archiveData) {
|
|
|
200
432
|
}
|
|
201
433
|
if (!processedSection.palettes.mod.isRegistered(voxelMod))
|
|
202
434
|
processedSection.palettes.mod.register(voxelMod);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (
|
|
217
|
-
processedSection.
|
|
218
|
-
if (
|
|
219
|
-
processedSection.
|
|
220
|
-
if (
|
|
221
|
-
processedSection.
|
|
222
|
-
if (
|
|
223
|
-
processedSection.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
processedSection.
|
|
227
|
-
processedSection.
|
|
228
|
-
processedSection.
|
|
229
|
-
processedSection.
|
|
435
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
436
|
+
const segment = lightSegments[l];
|
|
437
|
+
const light = lightSemgnetGet[segment](section.light[i]);
|
|
438
|
+
if (light != firstLightLevels[segment])
|
|
439
|
+
processedSection.light[segment].allTheSame = false;
|
|
440
|
+
processedSection.light[segment].value = light;
|
|
441
|
+
const voxelLight = !sectorPalettes.light[segment].isRegistered(light)
|
|
442
|
+
? sectorPalettes.light[segment].register(light)
|
|
443
|
+
: sectorPalettes.light[segment].getId(light);
|
|
444
|
+
if (!processedSection.palettes.light[segment].isRegistered(light))
|
|
445
|
+
processedSection.palettes.light[segment].register(light);
|
|
446
|
+
processedSection.light[segment].buffer[i] = voxelLight;
|
|
447
|
+
}
|
|
448
|
+
if (section.ids[i] != firstId)
|
|
449
|
+
processedSection.ids.allTheSame = false;
|
|
450
|
+
if (section.level[i] != firstLevel)
|
|
451
|
+
processedSection.level.allTheSame = false;
|
|
452
|
+
if (section.state[i] != firstState)
|
|
453
|
+
processedSection.state.allTheSame = false;
|
|
454
|
+
if (section.mod[i] != firstMod)
|
|
455
|
+
processedSection.mod.allTheSame = false;
|
|
456
|
+
if (section.secondary[i] != firstSecondary)
|
|
457
|
+
processedSection.secondary.allTheSame = false;
|
|
458
|
+
processedSection.ids.buffer[i] = voxelId;
|
|
459
|
+
processedSection.level.buffer[i] = voxelLevel;
|
|
460
|
+
processedSection.state.buffer[i] = voxelState;
|
|
461
|
+
processedSection.mod.buffer[i] = voxelMod;
|
|
462
|
+
processedSection.secondary.buffer[i] = voxelSecondary;
|
|
230
463
|
}
|
|
231
464
|
processedSections.push(processedSection);
|
|
232
465
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
sectorPalettes.level.size
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
466
|
+
let neededPalettes = {
|
|
467
|
+
level: false,
|
|
468
|
+
light: {
|
|
469
|
+
sun: false,
|
|
470
|
+
red: false,
|
|
471
|
+
green: false,
|
|
472
|
+
blue: false,
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
for (const archivedSection of processedSections) {
|
|
476
|
+
//ids
|
|
477
|
+
archivedSection.ids.isPaletted =
|
|
478
|
+
sectorPalettes.ids.size <= BinaryBuffer.BytePaletteMax ||
|
|
479
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.BytePaletteMax;
|
|
480
|
+
archivedSection.ids.remapped =
|
|
481
|
+
sectorPalettes.ids.size > BinaryBuffer.BytePaletteMax &&
|
|
482
|
+
archivedSection.palettes.ids.size <= BinaryBuffer.BytePaletteMax &&
|
|
483
|
+
!archivedSection.ids.allTheSame;
|
|
484
|
+
//level
|
|
485
|
+
archivedSection.level.isPaletted =
|
|
486
|
+
sectorPalettes.level.size <= BinaryBuffer.NibblePaletteMax &&
|
|
487
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibblePaletteMax;
|
|
488
|
+
archivedSection.level.remapped =
|
|
489
|
+
sectorPalettes.level.size > BinaryBuffer.NibblePaletteMax &&
|
|
490
|
+
archivedSection.palettes.level.size <= BinaryBuffer.NibblePaletteMax &&
|
|
491
|
+
!archivedSection.level.allTheSame;
|
|
492
|
+
if (archivedSection.level.isPaletted && !archivedSection.level.remapped) {
|
|
493
|
+
neededPalettes.level = true;
|
|
494
|
+
}
|
|
495
|
+
//state
|
|
496
|
+
archivedSection.state.isPaletted =
|
|
497
|
+
sectorPalettes.state.size <= BinaryBuffer.BytePaletteMax ||
|
|
498
|
+
archivedSection.palettes.state.size <= BinaryBuffer.BytePaletteMax;
|
|
499
|
+
archivedSection.state.remapped =
|
|
500
|
+
sectorPalettes.state.size > BinaryBuffer.BytePaletteMax &&
|
|
501
|
+
archivedSection.palettes.state.size <= BinaryBuffer.BytePaletteMax &&
|
|
502
|
+
!archivedSection.state.allTheSame;
|
|
503
|
+
//mod
|
|
504
|
+
archivedSection.mod.isPaletted =
|
|
505
|
+
sectorPalettes.mod.size <= BinaryBuffer.BytePaletteMax ||
|
|
506
|
+
archivedSection.palettes.mod.size <= BinaryBuffer.BytePaletteMax;
|
|
507
|
+
archivedSection.mod.remapped =
|
|
508
|
+
sectorPalettes.mod.size > BinaryBuffer.BytePaletteMax &&
|
|
509
|
+
archivedSection.palettes.mod.size <= BinaryBuffer.BytePaletteMax &&
|
|
510
|
+
!archivedSection.mod.allTheSame;
|
|
511
|
+
for (const semgnet of lightSegments) {
|
|
512
|
+
archivedSection.light[semgnet].isPaletted =
|
|
513
|
+
sectorPalettes.light[semgnet].size <=
|
|
514
|
+
BinaryBuffer.HalfNibblePaletteMax ||
|
|
515
|
+
archivedSection.palettes.light[semgnet].size <=
|
|
516
|
+
BinaryBuffer.HalfNibblePaletteMax;
|
|
517
|
+
archivedSection.light[semgnet].remapped =
|
|
518
|
+
sectorPalettes.light[semgnet].size >
|
|
519
|
+
BinaryBuffer.HalfNibblePaletteMax &&
|
|
520
|
+
archivedSection.palettes.light[semgnet].size <=
|
|
521
|
+
BinaryBuffer.HalfNibblePaletteMax &&
|
|
522
|
+
!archivedSection.light[semgnet].allTheSame;
|
|
523
|
+
if (archivedSection.light[semgnet].isPaletted &&
|
|
524
|
+
!archivedSection.light[semgnet].remapped) {
|
|
525
|
+
neededPalettes.light[semgnet] = true;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
//secondary
|
|
529
|
+
archivedSection.secondary.isPaletted =
|
|
530
|
+
(sectorPalettes.secondaryState.size <= BinaryBuffer.BytePaletteMax &&
|
|
531
|
+
sectorPalettes.secondaryId.size <= BinaryBuffer.BytePaletteMax) ||
|
|
532
|
+
(archivedSection.palettes.secondaryState.size <=
|
|
533
|
+
BinaryBuffer.BytePaletteMax &&
|
|
534
|
+
archivedSection.palettes.secondaryId.size <=
|
|
535
|
+
BinaryBuffer.BytePaletteMax);
|
|
536
|
+
archivedSection.secondary.remapped =
|
|
537
|
+
Math.max(sectorPalettes.secondaryState.size, sectorPalettes.secondaryId.size) > BinaryBuffer.BytePaletteMax &&
|
|
538
|
+
Math.max(archivedSection.palettes.secondaryId.size, archivedSection.palettes.secondaryState.size) <= BinaryBuffer.BytePaletteMax &&
|
|
539
|
+
!archivedSection.secondary.allTheSame;
|
|
540
|
+
if (!archivedSection.ids.remapped &&
|
|
541
|
+
!archivedSection.light.sun.remapped &&
|
|
542
|
+
!archivedSection.light.red.remapped &&
|
|
543
|
+
!archivedSection.light.green.remapped &&
|
|
544
|
+
!archivedSection.light.blue.remapped &&
|
|
545
|
+
!archivedSection.secondary.remapped &&
|
|
546
|
+
!archivedSection.mod.remapped &&
|
|
547
|
+
!archivedSection.level.remapped)
|
|
271
548
|
continue;
|
|
272
|
-
const length =
|
|
549
|
+
const length = archivedSection.original.ids.length;
|
|
273
550
|
for (let i = 0; i < length; i++) {
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
551
|
+
if (archivedSection.ids.remapped)
|
|
552
|
+
archivedSection.ids.buffer[i] = archivedSection.palettes.ids.getId(archivedSection.ids.buffer[i]);
|
|
553
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
554
|
+
const segment = lightSegments[l];
|
|
555
|
+
if (archivedSection.light[segment].remapped) {
|
|
556
|
+
archivedSection.light[segment].buffer[i] =
|
|
557
|
+
archivedSection.palettes.light[segment].getId(lightSemgnetGet[segment](archivedSection.original.light[i]));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (archivedSection.level.remapped)
|
|
561
|
+
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
|
+
if (archivedSection.secondary.remapped)
|
|
567
|
+
archivedSection.secondary.buffer[i] = VoxelTagsRegister.VoxelTags[archivedSection.original.ids[i]]["dve_can_have_secondary"]
|
|
568
|
+
? archivedSection.palettes.secondaryId.getId(archivedSection.secondary.buffer[i])
|
|
569
|
+
: archivedSection.palettes.secondaryState.getId(archivedSection.secondary.buffer[i]);
|
|
288
570
|
}
|
|
289
571
|
}
|
|
290
572
|
const stateMap = {};
|
|
@@ -315,26 +597,29 @@ export default function ArchiveSector(archiveData) {
|
|
|
315
597
|
modMap,
|
|
316
598
|
state: new Uint16Array(sectorPalettes.state._palette),
|
|
317
599
|
mod: new Uint16Array(sectorPalettes.mod._palette),
|
|
600
|
+
light: {},
|
|
601
|
+
secondaryId: sectorPalettes.secondaryId._palette,
|
|
602
|
+
secondaryState: new Uint16Array(sectorPalettes.secondaryState._palette),
|
|
318
603
|
};
|
|
319
|
-
if (
|
|
320
|
-
palettes.light = new Uint16Array(sectorPalettes.light._palette);
|
|
321
|
-
if (sectorPalettes.level.size < 255)
|
|
604
|
+
if (neededPalettes.level) {
|
|
322
605
|
palettes.level = new Uint8Array(sectorPalettes.level._palette);
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
606
|
+
}
|
|
607
|
+
for (const segment of lightSegments) {
|
|
608
|
+
if (neededPalettes.light[segment]) {
|
|
609
|
+
palettes.light[segment] = new Uint8Array(sectorPalettes.light[segment]._palette);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const archivedSector = {
|
|
330
613
|
version: "",
|
|
614
|
+
vloxVersion: EngineSettings.version,
|
|
331
615
|
location: [...archiveData.location],
|
|
332
|
-
|
|
616
|
+
flags: sector.storeFlags(),
|
|
617
|
+
timestamps: sector.storeTimestamps(),
|
|
333
618
|
buffers: {},
|
|
334
|
-
keys: {
|
|
335
|
-
sectionState: [],
|
|
336
|
-
},
|
|
337
619
|
palettes,
|
|
620
|
+
duplicates: {},
|
|
338
621
|
sections,
|
|
339
622
|
};
|
|
623
|
+
RemoveDuplicates(archivedSector);
|
|
624
|
+
return archivedSector;
|
|
340
625
|
}
|