-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ShannonAAEmu/cryengine_3.1.2
New read system
- Loading branch information
Showing
47 changed files
with
3,095 additions
and
1,081 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Default ignored files | ||
/shelf/ | ||
/.idea/workspace.xml | ||
# Editor-based HTTP Client requests | ||
/httpRequests/ | ||
# Datasource local storage ignored files | ||
/dataSources/ | ||
/dataSources.local.xml | ||
### IntelliJ IDEA ### | ||
.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,157 @@ | ||
import entities.AreasMissionBai; | ||
import entities.NetHideMissionBai; | ||
import entities.VertexMissionBai; | ||
import entities.export.*; | ||
import org.apache.commons.io.FileDeleteStrategy; | ||
import org.apache.commons.io.FilenameUtils; | ||
import org.apache.commons.lang3.math.NumberUtils; | ||
import reader.BaiReader; | ||
import reader.impl.*; | ||
import utils.WriterUtil; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class Main { | ||
|
||
private static final File ROOT_FOLDER = new File(System.getProperty("user.dir")); | ||
private static final boolean IS_DEBUG = false; | ||
private static String geoType = "server"; | ||
private static HashMap<File, String> serverBaiHashMap; | ||
|
||
public static void main(String[] args) throws Exception { | ||
HashMap<File, String> serverBaiHashMap = new HashMap<>(); | ||
HashMap<File, String> clientBaiHashMap = new HashMap<>(); | ||
File worldsFolder = new File(String.valueOf(ROOT_FOLDER)); | ||
for (File world : Objects.requireNonNull(worldsFolder.listFiles())) { | ||
public static void main(String[] args) { | ||
serverBaiHashMap = new HashMap<>(); | ||
checkFolders(); | ||
try { | ||
exportNavData(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private static void checkFolders() { | ||
File worlds = new File(String.valueOf(ROOT_FOLDER)); | ||
for (File world : Objects.requireNonNull(worlds.listFiles())) { | ||
if (world.getName().startsWith("instance_") || world.getName().equals("arche_mall_world")) { | ||
if (!world.getName().endsWith("_dev")) { | ||
File zoneFolder = new File(world.getPath() + "\\zone"); | ||
for (File id : Objects.requireNonNull(zoneFolder.listFiles())) { | ||
if (NumberUtils.isDigits(id.getName())) { | ||
for (File file : Objects.requireNonNull(id.listFiles())) { | ||
if (FilenameUtils.getExtension(file.getName()).equals("bai")) { | ||
if (4 < file.length()) { | ||
serverBaiHashMap.put(file, id.getName()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
File pathsFolder = new File(world.getPath() + "\\paths"); | ||
for (File ids : Objects.requireNonNull(pathsFolder.listFiles())) { | ||
for (File file : Objects.requireNonNull(ids.listFiles())) { | ||
if (FilenameUtils.getExtension(file.getName()).equals("bai")) { | ||
if (4 < file.length()) { | ||
clientBaiHashMap.put(file, ids.getName()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
checkInstancesFolders(world); | ||
} | ||
} | ||
} | ||
|
||
private static void checkInstancesFolders(File world) { | ||
if (!world.getName().endsWith("_dev")) { | ||
checkServerFolders(world); | ||
} | ||
} | ||
|
||
private static void checkServerFolders(File world) { | ||
File zone = new File(world.getPath() + "\\zone"); | ||
for (File zoneId : Objects.requireNonNull(zone.listFiles())) { | ||
checkZoneFolders(zoneId); | ||
} | ||
} | ||
|
||
private static void checkZoneFolders(File zoneId) { | ||
if (NumberUtils.isDigits(zoneId.getName())) { | ||
for (File file : Objects.requireNonNull(zoneId.listFiles())) { | ||
loadServerBaiFiles(file, zoneId); | ||
} | ||
} | ||
System.out.println("Total server zone data: " + serverBaiHashMap.size()); | ||
readGeoData(serverBaiHashMap); | ||
//geoType = "client"; | ||
//System.out.println("Total client zone data: " + clientBaiHashMap.size()); | ||
//readGeoData(clientBaiHashMap); | ||
} | ||
|
||
private static void readGeoData(HashMap<File, String> baiHashMap) throws Exception { | ||
for (Map.Entry<File, String> map : baiHashMap.entrySet()) { | ||
private static void loadServerBaiFiles(File file, File zoneId) { | ||
if (FilenameUtils.getExtension(file.getName()).equals("bai")) { | ||
serverBaiHashMap.put(file, zoneId.getName()); | ||
} | ||
} | ||
|
||
private static void exportNavData() throws IOException { | ||
String exportFolder = ROOT_FOLDER + "\\export_server"; | ||
File path = new File(exportFolder); | ||
createExportDirectory(path); | ||
File zonePath; | ||
BaiReader baiReader; | ||
int total = serverBaiHashMap.size(); | ||
int i = 0; | ||
int prev = 0; | ||
int cur; | ||
AreasMissionExport areasMissionExport; | ||
FlightMissionExport flightMissionExport; | ||
NetMissionExport netMissionExport; | ||
RoadMissionExport roadMissionExport; | ||
VertexMissionExport vertexMissionExport; | ||
WaypointSurfaceNavigationExport waypointSurfaceNavigationExport; | ||
for (Map.Entry<File, String> map : serverBaiHashMap.entrySet()) { | ||
int zoneId = Integer.parseInt(map.getValue()); | ||
zonePath = new File(path.getPath() + "\\" + zoneId); | ||
createExportZoneDirectory(zonePath); | ||
if ("areasmission0.bai".equals(map.getKey().getName())) { | ||
new AreasMissionBai(map.getKey(), map.getValue(), ROOT_FOLDER, IS_DEBUG, geoType).readFile(); | ||
areasMissionExport = new AreasMissionExport(); | ||
baiReader = new AreasMissionReaderImpl(areasMissionExport, map.getKey(), zoneId); | ||
baiReader.readFile(); | ||
baiReader.prepareExport(); | ||
exportData(zonePath, "forbidden_areas", areasMissionExport.getForbiddenAreasList()); | ||
exportData(zonePath, "navigation_modifiers", areasMissionExport.getNavigationModifiersList()); | ||
exportData(zonePath, "designer_forbidden_areas", areasMissionExport.getDesignerForbiddenAreasList()); | ||
exportData(zonePath, "forbidden_boundaries", areasMissionExport.getForbiddenBoundariesList()); | ||
exportData(zonePath, "extra_link_costs", areasMissionExport.getExtraLinkCostsList()); | ||
exportData(zonePath, "designer_paths", areasMissionExport.getDesignerPathsList()); | ||
} | ||
if ("fnavmission0.bai".equals(map.getKey().getName())) { | ||
flightMissionExport = new FlightMissionExport(); | ||
baiReader = new FlightMissionReaderImpl(flightMissionExport, map.getKey(), zoneId); | ||
baiReader.readFile(); | ||
baiReader.prepareExport(); | ||
exportData(zonePath, "flight_navi_regions", flightMissionExport.getFlightNavRegion()); | ||
} | ||
if ("netmission0.bai".equals(map.getKey().getName()) || "hidemission0.bai".equals(map.getKey().getName())) { | ||
boolean isHide = "hidemission0.bai".equals(map.getKey().getName()); | ||
new NetHideMissionBai(isHide, map.getKey(), map.getValue(), ROOT_FOLDER, IS_DEBUG, geoType).readFile(); | ||
if ("netmission0.bai".equals(map.getKey().getName())) { | ||
netMissionExport = new NetMissionExport(); | ||
baiReader = new NetMissionReaderImpl(netMissionExport, map.getKey(), zoneId); | ||
baiReader.readFile(); | ||
baiReader.prepareExport(); | ||
exportData(zonePath, "triangulation", netMissionExport.getNavigations()); | ||
} | ||
if ("roadnavmission0.bai".equals(map.getKey().getName())) { | ||
roadMissionExport = new RoadMissionExport(); | ||
baiReader = new RoadMissionImpl(roadMissionExport, map.getKey(), zoneId); | ||
baiReader.readFile(); | ||
baiReader.prepareExport(); | ||
exportData(zonePath, "roads", roadMissionExport.getRoadList()); | ||
} | ||
// v3dmission0.bai | ||
if ("vertsmission0.bai".equals(map.getKey().getName())) { | ||
new VertexMissionBai(map.getKey(), map.getValue(), ROOT_FOLDER, IS_DEBUG, geoType).readFile(); | ||
vertexMissionExport = new VertexMissionExport(); | ||
baiReader = new VertexMissionReaderImpl(vertexMissionExport, map.getKey(), zoneId); | ||
baiReader.readFile(); | ||
baiReader.prepareExport(); | ||
exportData(zonePath, "vertex", vertexMissionExport.getObstacleDataDescriptorList()); | ||
} | ||
if ("waypt3dsfcmission0.bai".equals(map.getKey().getName())) { | ||
waypointSurfaceNavigationExport = new WaypointSurfaceNavigationExport(); | ||
baiReader = new WaypointSurfaceNavigationReaderImpl(waypointSurfaceNavigationExport, map.getKey(), zoneId); | ||
baiReader.readFile(); | ||
baiReader.prepareExport(); | ||
exportData(zonePath, "waypoint_surface_nav", waypointSurfaceNavigationExport.getWaypointSurfaceNavigationList()); | ||
} | ||
cur = i++ * 100 / total; | ||
if (prev != cur) { | ||
prev = cur; | ||
System.out.println(cur + "% "); | ||
} | ||
} | ||
} | ||
|
||
private static void exportData(File zonePath, String fileName, Object export) throws IOException { | ||
WriterUtil.writeDataToJson(zonePath, fileName + ".json", export); | ||
} | ||
|
||
private static void createExportDirectory(File exportFolder) throws IOException { | ||
FileDeleteStrategy.FORCE.delete(exportFolder); | ||
Files.createDirectory(exportFolder.toPath()); | ||
} | ||
|
||
private static void createExportZoneDirectory(File zoneFolder) throws IOException { | ||
if (!zoneFolder.exists()) { | ||
Files.createDirectory(zoneFolder.toPath()); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.