forked from OpenWF/SpaceNinjaServer
create backup of original worldstate
This commit is contained in:
parent
82c0a60afa
commit
cef55a78c9
@ -1493,6 +1493,8 @@ const nightwaveTagToSeason: Record<string, number> = {
|
||||
RadioLegionSyndicate: 0 // The Wolf of Saturn Six
|
||||
};
|
||||
|
||||
type AnyObj = { [key: string]: object | Array<object> | string | number | boolean };
|
||||
const staticWorldStateBackup: AnyObj = structuredClone(staticWorldState);
|
||||
let syncWorldStateTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
export const syncWorldState = async (): Promise<void> => {
|
||||
@ -1528,7 +1530,6 @@ export const syncWorldState = async (): Promise<void> => {
|
||||
logger.error("Invalid world state sync response", { data });
|
||||
return;
|
||||
}
|
||||
type AnyObj = { [key: string]: object | Array<object> | string | number | boolean };
|
||||
const staticWorldState_ = staticWorldState as AnyObj;
|
||||
const data_ = data as AnyObj;
|
||||
|
||||
@ -1547,9 +1548,9 @@ export const syncWorldState = async (): Promise<void> => {
|
||||
case "Events":
|
||||
{
|
||||
const remoteValue = data_[name] as Array<object>;
|
||||
const localValue = staticWorldState_[name] as Array<object>;
|
||||
const localValue = staticWorldStateBackup[name] as Array<object>;
|
||||
if (Array.isArray(remoteValue) && Array.isArray(localValue)) {
|
||||
localValue.push(...remoteValue);
|
||||
staticWorldState_[name] = localValue.concat(remoteValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user