-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom extracts fully implemented 😎 #54
base: next
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a first static review of the code, I don't have tested yet.
Tomorrow I'll test it on my current fika modpack.
const exfils = ALL_EXFILS[mapName] ?? []; | ||
const customExfils = NEW_CUSTOM_EXFILS[mapName] ?? []; | ||
exfils.push(...customExfils); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const exfils = ALL_EXFILS[mapName] ?? []; | |
const customExfils = NEW_CUSTOM_EXFILS[mapName] ?? []; | |
exfils.push(...customExfils); | |
const vanillaExfils = ALL_EXFILS[mapName] ?? []; | |
const customExfils = NEW_CUSTOM_EXFILS[mapName] ?? []; | |
const exfils = { | |
...vanillaExfils, | |
...customExfils, | |
}; |
everytime isValidExfilForMap
is called, this will mutate ALL_EXFILS
and add several time the same custom exfils.
mutations is the devil.
src/custom-extracts.ts
Outdated
public getJsonFiles(directory: string): string[] { | ||
try { | ||
return fs.readdirSync(path.resolve(__dirname, directory)) | ||
.filter(file => file.endsWith(".json")); | ||
} catch (err) { | ||
console.error(`Error reading directory ${directory}:`, err); | ||
return []; | ||
} | ||
} | ||
|
||
public loadConfigs(files: string[], directory: string): CustomExitConfig[] { | ||
const configs: CustomExitConfig[] = []; | ||
|
||
for (const file of files) { | ||
try { | ||
const filePath = path.resolve(__dirname, directory, file); | ||
const rawData = fs.readFileSync(filePath, "utf8"); | ||
configs.push(...JSON.parse(rawData)); | ||
} catch (err) { | ||
console.error(`Error reading file ${file}:`, err); | ||
} | ||
} | ||
|
||
return configs; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think reading json files should be done only once outside of this class. (the readed custom extracts can be just passed into the CustomExtracts constructor)
if (!this.config.enabled) { | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would break the current uninstall procedure.
This check is already done few lines later.
@@ -139,6 +143,12 @@ class PathToTarkov implements IPreSptLoadMod, IPostSptLoadMod { | |||
|
|||
public postSptLoad(container: DependencyContainer): void { | |||
this.container = container; | |||
this.instanceManager.postDBLoad(container); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line should be moved into a real postDBLoad
? because we are in the postSptLoad here.
configs/Default/Tooltips.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add a new configs/ExampleCustomExtracts/Tooltips.json
configs/Default/config.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add a new configs/ExampleCustomExtracts/config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add a new configs/ExampleCustomExtracts/customExtracts/exfilConfig.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add a new configs/ExampleCustomExtracts/player_spawnpoints.json
@@ -137,7 +137,28 @@ const ALL_DUMPED_EXFILS_FROM_SCRIPT = { | |||
'Nakatani_stairs_free_exit', | |||
], | |||
}; | |||
|
|||
const ALL_NEW_CUSTOM_EXFILS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can introduce a new config field enable_custom_exfils
that will bypass the validation of the exfils name.
For a first iteration it seems enough.
Server:
Client: