Skip to content

Commit

Permalink
Merge pull request #1 from ShannonAAEmu/cryengine_3.1.2
Browse files Browse the repository at this point in the history
New read system
  • Loading branch information
ShannonAAEmu authored Nov 27, 2022
2 parents 77221c0 + fae43fd commit 681a9cf
Show file tree
Hide file tree
Showing 47 changed files with 3,095 additions and 1,081 deletions.
11 changes: 11 additions & 0 deletions .gitignore
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
16 changes: 14 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<groupId>info.aaemu</groupId>
<artifactId>ArcheAgeAiExporter</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -30,13 +42,13 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<version>2.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20201115</version>
<version>20220924</version>
</dependency>
</dependencies>

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/META-INF/MANIFEST.MF

This file was deleted.

177 changes: 131 additions & 46 deletions src/main/java/Main.java
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());
}
}
}
141 changes: 0 additions & 141 deletions src/main/java/entities/AreasMissionBai.java

This file was deleted.

Loading

0 comments on commit 681a9cf

Please sign in to comment.