mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 22:35:42 +00:00
31 lines
946 B
Swift
31 lines
946 B
Swift
//
|
|
// main.swift
|
|
// MapTerrainConverter
|
|
//
|
|
// Created by Dan Crosby on 9/22/18.
|
|
// Copyright © 2018 none. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
struct OldGameFile : Codable {
|
|
public let hexMap : OldHexMap
|
|
}
|
|
|
|
struct NewGameFile : Codable {
|
|
public let hexMap : HexMap
|
|
}
|
|
|
|
let deserializer = CroissantDeserializer()
|
|
let fileUrl = URL(fileURLWithPath: "/Users/dancrosby/CodingProjects/github/eagle0/server/installdata/usr/local/share/eagle0/startfiles/narrowWithRiver.e0g")
|
|
let data = try! Data(contentsOf: fileUrl)
|
|
|
|
let oldGameFile = CroissantDeserializer.deserialize(OldGameFile.self, from: data)!
|
|
let oldMap = oldGameFile.hexMap
|
|
let newGameFile = NewGameFile(hexMap: HexMap(oldMap: oldMap))
|
|
let newData = newGameFile.croissantEncodedData!
|
|
|
|
let newUrl = URL(fileURLWithPath: "/Users/dancrosby/CodingProjects/github/eagle0/server/installdata/usr/local/share/eagle0/startfiles/narrowWithRiver.e0g_")
|
|
try! newData.write(to: newUrl)
|
|
|