Process NZP Beta waypoints

This commit is contained in:
BCDeshiG 2022-09-08 20:58:58 +01:00
parent 18f80d2758
commit 1d2e7a5756
2 changed files with 79 additions and 0 deletions

40
testBETA Normal file
View file

@ -0,0 +1,40 @@
'-112.3 -494.4 8.0'
1
2
3
4
0
2
3
4
0
'-119.8 -115.7 8.0'
2
1
3
4
0
1
3
4
0
' 41.6 87.6 8.0'
3
1
0
0
0
1
0
0
0
'-115.0 152.3 120.0'
4
1
2
0
0
1
2
0
0

View file

@ -41,8 +41,14 @@ def startConversion(inputFile, outputFile, wayFormat):
header = oldWayFile[0].strip("\n")
if header == "Waypoint": # PSP
print("PSP format detected")
if wayFormat.upper() == "PSP":
raise ValueError("Already in PSP format!")
wayArray = parsePSP(oldWayFile)
elif header == "waypoint": # PC
print("PC format detected")
if wayFormat.upper() == "PC":
raise ValueError("Already in PC format!")
wayArray = parsePC(oldWayFile)
else: # Check if BETA or just random crap
where = header.strip("'").split() # Split xyz
# Should look something like [-40.5, 12.2, 8.0]
@ -53,7 +59,40 @@ def startConversion(inputFile, outputFile, wayFormat):
for i in range(len(where)):
float(where[i])
print("BETA format detected")
if wayFormat.upper() == "BETA":
raise ValueError("Already in BETA format!")
wayArray = parseBETA(oldWayFile)
except ValueError:
print("Invalid waypoint co-ords")
# Print out waypoint for now I guess
for waypoint in wayArray:
print(waypoint)
def parsePSP(oldWayFile):
return ["This", "is", "a", "test"]
def parsePC(oldWayFile):
return ["Notsee", "Zombies", "Portable", "2"]
def parseBETA(oldWayFile):
tempArray = [] # Temporarily stores waypoint fields
wayArray = [] # Array of waypoints
for i, line in enumerate(oldWayFile):
relativeLineNum = (i+1)%10
# Ignore 'owner' fields as they don't apply to modern format
if relativeLineNum < 7 and relativeLineNum != 0:
tempArray.append(line.strip()) # Add field to temporary array
if (i+1)%10 == 0: # Reached end of that waypoint
# Store waypoint fields in dictionary
waydict = {
"origin": tempArray[0],
"id": tempArray[1],
# Remove empty targets
"targets": [value for value in tempArray[2:] if value != "0"]
}
tempArray.clear() # Clear temporary array for next waypoint
wayArray.append(waydict) # Add waypoint to array
return wayArray
parseArgs()