Moved region implementation to .server.world.io.region

This commit is contained in:
OLEGSHA 2021-09-10 23:59:03 +03:00
parent e2308b825d
commit 6b33f231b4
6 changed files with 15 additions and 15 deletions

View File

@ -25,8 +25,8 @@ import java.util.function.Function;
import ru.windcorp.progressia.common.world.DefaultWorldData; import ru.windcorp.progressia.common.world.DefaultWorldData;
import ru.windcorp.progressia.server.world.generation.WorldGenerator; import ru.windcorp.progressia.server.world.generation.WorldGenerator;
import ru.windcorp.progressia.server.world.io.WorldContainer; import ru.windcorp.progressia.server.world.io.WorldContainer;
import ru.windcorp.progressia.server.world.io.region.RegionFormat;
import ru.windcorp.progressia.test.gen.TestGenerationConfig; import ru.windcorp.progressia.test.gen.TestGenerationConfig;
import ru.windcorp.progressia.test.region.RegionFormat;
public class ServerState { public class ServerState {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package ru.windcorp.progressia.test.region; package ru.windcorp.progressia.server.world.io.region;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
@ -59,7 +59,7 @@ public class Region {
this.file.confirmHeaderHealth(offsets); this.file.confirmHeaderHealth(offsets);
} catch (IOException e) { } catch (IOException e) {
TestWorldDiskIO.LOG.debug("Uh the file broke"); RegionWorldContainer.LOG.debug("Uh the file broke");
if (RESET_CORRUPTED) { if (RESET_CORRUPTED) {
this.file.makeHeader(); this.file.makeHeader();
} }
@ -98,7 +98,7 @@ public class Region {
public void save(DefaultChunkData chunk, Server server) throws IOException { public void save(DefaultChunkData chunk, Server server) throws IOException {
isUsing.set(true); isUsing.set(true);
Vec3i pos = TestWorldDiskIO.getInRegionCoords(chunk.getPosition()); Vec3i pos = RegionWorldContainer.getInRegionCoords(chunk.getPosition());
if (!hasOffset(pos)) { if (!hasOffset(pos)) {
putOffset(pos, file.allocateChunk(pos)); putOffset(pos, file.allocateChunk(pos));
@ -121,7 +121,7 @@ public class Region {
) )
) { ) {
ChunkIO.save(chunk, dataStream, IOContext.SAVE); ChunkIO.save(chunk, dataStream, IOContext.SAVE);
TestWorldDiskIO.writeGenerationHint(chunk, dataStream, server); RegionWorldContainer.writeGenerationHint(chunk, dataStream, server);
} }
return arrayStream.toByteArray(); return arrayStream.toByteArray();
@ -133,7 +133,7 @@ public class Region {
isUsing.set(true); isUsing.set(true);
int dataOffset = 0; int dataOffset = 0;
Vec3i pos = TestWorldDiskIO.getInRegionCoords(chunkPos); Vec3i pos = RegionWorldContainer.getInRegionCoords(chunkPos);
if (hasOffset(pos)) { if (hasOffset(pos)) {
dataOffset = getOffset(pos); dataOffset = getOffset(pos);
@ -160,7 +160,7 @@ public class Region {
); );
DefaultChunkData result = ChunkIO.load(world, chunkPos, dataStream, IOContext.SAVE); DefaultChunkData result = ChunkIO.load(world, chunkPos, dataStream, IOContext.SAVE);
TestWorldDiskIO.readGenerationHint(result, dataStream, server); RegionWorldContainer.readGenerationHint(result, dataStream, server);
return result; return result;
} }
} }

View File

@ -1,6 +1,6 @@
package ru.windcorp.progressia.test.region; package ru.windcorp.progressia.server.world.io.region;
import static ru.windcorp.progressia.test.region.TestWorldDiskIO.REGION_DIAMETER; import static ru.windcorp.progressia.server.world.io.region.RegionWorldContainer.REGION_DIAMETER;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package ru.windcorp.progressia.test.region; package ru.windcorp.progressia.server.world.io.region;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
@ -31,7 +31,7 @@ public class RegionFormat extends WorldContainerFormat {
@Override @Override
public WorldContainer create(Path directory) throws IOException { public WorldContainer create(Path directory) throws IOException {
return new TestWorldDiskIO(directory); return new RegionWorldContainer(directory);
} }
} }

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package ru.windcorp.progressia.test.region; package ru.windcorp.progressia.server.world.io.region;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -43,7 +43,7 @@ import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
public class TestWorldDiskIO implements WorldContainer { public class RegionWorldContainer implements WorldContainer {
private static final boolean ENABLE = true; private static final boolean ENABLE = true;
@ -68,7 +68,7 @@ public class TestWorldDiskIO implements WorldContainer {
private final Path path; private final Path path;
private final ChunkMap<Region> regions = ChunkMaps.newHashMap(); private final ChunkMap<Region> regions = ChunkMaps.newHashMap();
public TestWorldDiskIO(Path path) throws IOException { public RegionWorldContainer(Path path) throws IOException {
this.path = path; this.path = path;
Files.createDirectories(getPath()); Files.createDirectories(getPath());