mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Update naming within exchange string lib
This commit is contained in:
1 file changed
+11
-10
@@ -4,9 +4,10 @@ class MapReaderState {
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
last_position = { x: 0, y: 0 };
|
last_position = { x: 0, y: 0 };
|
||||||
/** True when a version greater than 2.0.0 is detected */
|
/** True when a version greater than 2.0.0 is detected */
|
||||||
v2 = false;
|
gt_v2_0 = false;
|
||||||
/** True when a version greater than 2.1.0 is detected */
|
/** True when a version greater than 2.1.0 is detected */
|
||||||
v2_1 = false;
|
gt_v2_1 = false;
|
||||||
|
// If more versions are required then we should expose version directly
|
||||||
constructor(
|
constructor(
|
||||||
public buf: Buffer
|
public buf: Buffer
|
||||||
) { }
|
) { }
|
||||||
@@ -163,7 +164,7 @@ function readBoundingBox(state: MapReaderState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readCliffSettings(state: MapReaderState) {
|
function readCliffSettings(state: MapReaderState) {
|
||||||
return state.v2 ? {
|
return state.gt_v2_0 ? {
|
||||||
name: readString(state),
|
name: readString(state),
|
||||||
control: readString(state), // v2
|
control: readString(state), // v2
|
||||||
cliff_elevation_0: readFloat(state),
|
cliff_elevation_0: readFloat(state),
|
||||||
@@ -188,7 +189,7 @@ function readTerritorySettings(state: MapReaderState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readMapGenSettings(state: MapReaderState) {
|
function readMapGenSettings(state: MapReaderState) {
|
||||||
return state.v2 ? {
|
return state.gt_v2_0 ? {
|
||||||
autoplace_controls: Object.fromEntries(readDict(state, readString, readFrequencySizeRichness)),
|
autoplace_controls: Object.fromEntries(readDict(state, readString, readFrequencySizeRichness)),
|
||||||
autoplace_settings: Object.fromEntries(readDict(state, readString, readAutoplaceSetting)),
|
autoplace_settings: Object.fromEntries(readDict(state, readString, readAutoplaceSetting)),
|
||||||
default_enable_all_autoplace_controls: readBool(state),
|
default_enable_all_autoplace_controls: readBool(state),
|
||||||
@@ -264,7 +265,7 @@ function readEnemyEvolution(state: MapReaderState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readEnemyExpansion(state: MapReaderState) {
|
function readEnemyExpansion(state: MapReaderState) {
|
||||||
return state.v2_1 ? {
|
return state.gt_v2_1 ? {
|
||||||
enabled: readOptional(state, readBool),
|
enabled: readOptional(state, readBool),
|
||||||
max_expansion_distance: readOptional(state, readUInt32),
|
max_expansion_distance: readOptional(state, readUInt32),
|
||||||
min_expansion_distance: readOptional(state, readUInt32), // v2.1
|
min_expansion_distance: readOptional(state, readUInt32), // v2.1
|
||||||
@@ -354,7 +355,7 @@ function readPathFinder(state: MapReaderState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readDifficultySettings(state: MapReaderState) {
|
function readDifficultySettings(state: MapReaderState) {
|
||||||
return state.v2 ? {
|
return state.gt_v2_0 ? {
|
||||||
technology_price_multiplier: readDouble(state),
|
technology_price_multiplier: readDouble(state),
|
||||||
spoil_time_modifier: readDouble(state), // v2
|
spoil_time_modifier: readDouble(state), // v2
|
||||||
} : {
|
} : {
|
||||||
@@ -373,7 +374,7 @@ function readAsteroids(state: MapReaderState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readMapSettings(state: MapReaderState) {
|
function readMapSettings(state: MapReaderState) {
|
||||||
if (state.v2_1) {
|
if (state.gt_v2_1) {
|
||||||
return {
|
return {
|
||||||
pollution: readPollution(state),
|
pollution: readPollution(state),
|
||||||
// steering removed v2.1
|
// steering removed v2.1
|
||||||
@@ -385,7 +386,7 @@ function readMapSettings(state: MapReaderState) {
|
|||||||
difficulty_settings: readDifficultySettings(state),
|
difficulty_settings: readDifficultySettings(state),
|
||||||
asteroids: readAsteroids(state), // v2
|
asteroids: readAsteroids(state), // v2
|
||||||
};
|
};
|
||||||
} else if (state.v2) {
|
} else if (state.gt_v2_0) {
|
||||||
return {
|
return {
|
||||||
pollution: readPollution(state),
|
pollution: readPollution(state),
|
||||||
steering: readSteering(state),
|
steering: readSteering(state),
|
||||||
@@ -459,8 +460,8 @@ export function readMapExchangeString(exchangeString: string) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const version = readVersion(state);
|
const version = readVersion(state);
|
||||||
state.v2 = version[0] >= 2;
|
state.gt_v2_0 = version[0] >= 2;
|
||||||
state.v2_1 = version[0] >= 2 && version[1] >= 1;
|
state.gt_v2_1 = version[0] >= 2 && version[1] >= 1;
|
||||||
data = {
|
data = {
|
||||||
version: version,
|
version: version,
|
||||||
unknown: readUInt8(state),
|
unknown: readUInt8(state),
|
||||||
|
|||||||
Reference in new issue
Block a user