mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 05:23:28 +00:00
Move map metadata to map manifest (#1262)
## Description: To simply the map binary data, remove height & width data to the manifest ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"map": {
|
||||
"height": 200,
|
||||
"num_land_tiles": 40000,
|
||||
"width": 200
|
||||
},
|
||||
"mini_map": {
|
||||
"height": 100,
|
||||
"num_land_tiles": 10000,
|
||||
"width": 100
|
||||
},
|
||||
"name": "Big Plains"
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"map": {
|
||||
"height": 16,
|
||||
"num_land_tiles": 160,
|
||||
"width": 16
|
||||
},
|
||||
"mini_map": {
|
||||
"height": 8,
|
||||
"num_land_tiles": 48,
|
||||
"width": 8
|
||||
},
|
||||
"name": "Half Land Half Ocean"
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"map": {
|
||||
"height": 16,
|
||||
"num_land_tiles": 178,
|
||||
"width": 16
|
||||
},
|
||||
"mini_map": {
|
||||
"height": 8,
|
||||
"num_land_tiles": 50,
|
||||
"width": 8
|
||||
},
|
||||
"name": "Ocean and Land"
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"map": {
|
||||
"height": 100,
|
||||
"num_land_tiles": 10000,
|
||||
"width": 100
|
||||
},
|
||||
"mini_map": {
|
||||
"height": 50,
|
||||
"num_land_tiles": 2500,
|
||||
"width": 50
|
||||
},
|
||||
"name": "Plains"
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
+16
-3
@@ -10,7 +10,10 @@ import {
|
||||
PlayerType,
|
||||
} from "../../src/core/game/Game";
|
||||
import { createGame } from "../../src/core/game/GameImpl";
|
||||
import { genTerrainFromBin } from "../../src/core/game/TerrainMapLoader";
|
||||
import {
|
||||
genTerrainFromBin,
|
||||
MapManifest,
|
||||
} from "../../src/core/game/TerrainMapLoader";
|
||||
import { UserSettings } from "../../src/core/game/UserSettings";
|
||||
import { GameConfig } from "../../src/core/Schemas";
|
||||
import { TestConfig } from "./TestConfig";
|
||||
@@ -33,16 +36,26 @@ export async function setup(
|
||||
__dirname,
|
||||
`../testdata/maps/${mapName}/mini_map.bin`,
|
||||
);
|
||||
const manifestPath = path.join(
|
||||
__dirname,
|
||||
`../testdata/maps/${mapName}/manifest.json`,
|
||||
);
|
||||
|
||||
const mapBinBuffer = fs.readFileSync(mapBinPath);
|
||||
const miniMapBinBuffer = fs.readFileSync(miniMapBinPath);
|
||||
const manifest = JSON.parse(
|
||||
fs.readFileSync(manifestPath, "utf8"),
|
||||
) satisfies MapManifest;
|
||||
|
||||
// Convert Buffer to string (binary encoding)
|
||||
const mapBinString = mapBinBuffer.toString("binary");
|
||||
const miniMapBinString = miniMapBinBuffer.toString("binary");
|
||||
|
||||
const gameMap = await genTerrainFromBin(mapBinString);
|
||||
const miniGameMap = await genTerrainFromBin(miniMapBinString);
|
||||
const gameMap = await genTerrainFromBin(manifest.map, mapBinString);
|
||||
const miniGameMap = await genTerrainFromBin(
|
||||
manifest.mini_map,
|
||||
miniMapBinString,
|
||||
);
|
||||
|
||||
// Configure the game
|
||||
const serverConfig = new TestServerConfig();
|
||||
|
||||
Reference in New Issue
Block a user