0

refac: PackFileEntry -> PackFile.Entry

This commit is contained in:
2026-02-12 14:03:39 +03:00
parent bf73b91b60
commit c9a6f508fc
4 changed files with 39 additions and 41 deletions

View File

@@ -24,7 +24,6 @@ import lwjake2.game.Cmd;
import lwjake2.game.cvar_t; import lwjake2.game.cvar_t;
import lwjake2.sys.Sys; import lwjake2.sys.Sys;
import ru.di9.lwjake2.PackFile; import ru.di9.lwjake2.PackFile;
import ru.di9.lwjake2.PackFileEntry;
import ru.di9.lwjake2.PackLoader; import ru.di9.lwjake2.PackLoader;
import java.io.File; import java.io.File;
@@ -170,7 +169,7 @@ public final class FS extends Globals {
// look through all the pak file elements // look through all the pak file elements
pak = search.pack; pak = search.pack;
filename = filename.toLowerCase(); filename = filename.toLowerCase();
PackFileEntry entry = pak.getFiles().get(filename); PackFile.Entry entry = pak.getFiles().get(filename);
if (entry != null) { if (entry != null) {
// found it! // found it!
@@ -245,7 +244,7 @@ public final class FS extends Globals {
// look through all the pak file elements // look through all the pak file elements
pak = search.pack; pak = search.pack;
filename = filename.toLowerCase(); filename = filename.toLowerCase();
PackFileEntry entry = pak.getFiles().get(filename); PackFile.Entry entry = pak.getFiles().get(filename);
if (entry != null) { if (entry != null) {
// found it! // found it!
@@ -407,7 +406,7 @@ public final class FS extends Globals {
// look through all the pak file elements // look through all the pak file elements
pak = search.pack; pak = search.pack;
filename = filename.toLowerCase(); filename = filename.toLowerCase();
PackFileEntry entry = pak.getFiles().get(filename); PackFile.Entry entry = pak.getFiles().get(filename);
if (entry != null) { if (entry != null) {
// found it! // found it!

View File

@@ -8,11 +8,11 @@ public class PackFile {
private final String filename; private final String filename;
private final int numFiles; private final int numFiles;
private Map<String, PackFileEntry> files; private Map<String, Entry> files;
private RandomAccessFile handle; private RandomAccessFile handle;
private ByteBuffer backBuffer; private ByteBuffer backBuffer;
public PackFile(String filename, RandomAccessFile handle, int numFiles, Map<String, PackFileEntry> files) { public PackFile(String filename, RandomAccessFile handle, int numFiles, Map<String, Entry> files) {
this.filename = filename; this.filename = filename;
this.handle = handle; this.handle = handle;
this.numFiles = numFiles; this.numFiles = numFiles;
@@ -35,11 +35,11 @@ public class PackFile {
this.handle = handle; this.handle = handle;
} }
public Map<String, PackFileEntry> getFiles() { public Map<String, Entry> getFiles() {
return files; return files;
} }
public void setFiles(Map<String, PackFileEntry> files) { public void setFiles(Map<String, Entry> files) {
this.files = files; this.files = files;
} }
@@ -50,4 +50,33 @@ public class PackFile {
public void setBackBuffer(ByteBuffer backBuffer) { public void setBackBuffer(ByteBuffer backBuffer) {
this.backBuffer = backBuffer; this.backBuffer = backBuffer;
} }
public static class Entry {
private final String name;
private final int filePos;
private final int fileLen;
public Entry(String name, int filePos, int fileLen) {
this.name = name;
this.filePos = filePos;
this.fileLen = fileLen;
}
public String getName() {
return name;
}
public int getFilePos() {
return filePos;
}
public int getFileLen() {
return fileLen;
}
@Override
public String toString() {
return name + " [ length: " + fileLen + " pos: " + filePos + " ]";
}
}
} }

View File

@@ -1,30 +0,0 @@
package ru.di9.lwjake2;
public class PackFileEntry {
private final String name;
private final int filePos;
private final int fileLen;
public PackFileEntry(String name, int filePos, int fileLen) {
this.name = name;
this.filePos = filePos;
this.fileLen = fileLen;
}
public String getName() {
return name;
}
public int getFilePos() {
return filePos;
}
public int getFileLen() {
return fileLen;
}
@Override
public String toString() {
return name + " [ length: " + fileLen + " pos: " + filePos + " ]";
}
}

View File

@@ -53,10 +53,10 @@ public class PackLoader {
throw new IOException(file + " has " + numPackFiles + " files"); throw new IOException(file + " has " + numPackFiles + " files");
} }
Map<String, PackFileEntry> newFiles = new HashMap<>(numPackFiles); Map<String, PackFile.Entry> newFiles = new HashMap<>(numPackFiles);
packHandle.position(headerDirofs); packHandle.position(headerDirofs);
PackFileEntry entry; PackFile.Entry entry;
byte[] tmpBuff = new byte[NAME_SIZE]; byte[] tmpBuff = new byte[NAME_SIZE];
for (int i = 0; i < numPackFiles; i++) { for (int i = 0; i < numPackFiles; i++) {
packHandle.get(tmpBuff); packHandle.get(tmpBuff);
@@ -64,7 +64,7 @@ public class PackLoader {
String name = new String(tmpBuff).trim(); String name = new String(tmpBuff).trim();
int filePos = packHandle.getInt(); int filePos = packHandle.getInt();
int fileLen = packHandle.getInt(); int fileLen = packHandle.getInt();
entry = new PackFileEntry(name, filePos, fileLen); entry = new PackFile.Entry(name, filePos, fileLen);
newFiles.put(entry.getName().toLowerCase(), entry); newFiles.put(entry.getName().toLowerCase(), entry);
} }