Fix ValheimPlus type (#451)

This commit is contained in:
Michael
2021-09-21 20:18:36 -07:00
committed by GitHub
parent 98c3f34243
commit 903ba6252f
4 changed files with 1454 additions and 35 deletions

8
Cargo.lock generated
View File

@@ -555,9 +555,9 @@ dependencies = [
[[package]]
name = "http"
version = "0.2.4"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11"
checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b"
dependencies = [
"bytes",
"fnv",
@@ -1506,9 +1506,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.11.0"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce"
checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc"
dependencies = [
"autocfg",
"bytes",

View File

@@ -203,10 +203,6 @@ If you would like to have release notifications tied into your Discord server, c
**Note**: The discord is PURELY for release notifications and any + all permissions involving sending chat messages has been disabled.
[Any support for this repository must take place on the Discussions.](https://github.com/mbround18/valheim-docker/discussions)
# Contributions
- @some_guy - design, doc
## Versions
- latest (Stable): Mod support! and cleaned up the code base.

1425
THIRDPARTY.yml Normal file

File diff suppressed because one or more lines are too long

View File

@@ -14,7 +14,6 @@ use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::process::exit;
use zip::{
read::ZipFile,
result::{ZipError, ZipResult},
ZipArchive,
};
@@ -102,15 +101,9 @@ impl ValheimMod {
fn try_parse_manifest(&self, archive: &mut ZipArchive<File>) -> Result<Manifest, ZipError> {
debug!("Parsing 'manifest.json' ...");
let mut manifest: ZipFile = match archive.by_name("manifest.json") {
Ok(value) => value,
Err(error) => {
error!("Failed to deserialize manifest file: {:?}", error);
// TODO: Remove Exit Code and provide an Ok or Err.
exit(1);
}
};
match archive.by_name("manifest.json") {
Ok(mut manifest) => {
debug!("'manifest.json' successfully loaded");
let mut json_data = String::new();
manifest.read_to_string(&mut json_data).unwrap();
@@ -120,6 +113,12 @@ impl ValheimMod {
Ok(serde_json::from_str(&json_data).expect("Failed to deserialize manifest file."))
}
Err(error) => {
error!("Failed to deserialize manifest file: {:?}", error);
Err(error)
}
}
}
fn remove_byte_order_mark(&self, value: String) -> String {
if value.contains('\u{feff}') {
@@ -155,9 +154,8 @@ impl ValheimMod {
}
fn is_mod_framework(&self, archive: &mut ZipArchive<File>) -> bool {
let maybe_manifest = self.try_parse_manifest(archive).ok();
match maybe_manifest {
Some(Manifest { name }) => {
if let Ok(maybe_manifest) = self.try_parse_manifest(archive) {
let name = maybe_manifest.name;
let mod_dir = format!("{}/", name);
let mod_dir_exists = archive.file_names().any(|file_name| file_name == mod_dir);
@@ -165,11 +163,11 @@ impl ValheimMod {
// archive
debug!("Validating if file is a framework");
mod_dir_exists && (name == "BepInExPack_Valheim" || name == "BepInEx_Valheim_Full")
}
None => archive
} else {
archive
// If there is no manifest, fall back to checking for winhttp.dll as a heuristic
.file_names()
.any(|file_name| file_name.eq_ignore_ascii_case("winhttp.dll")),
.any(|file_name| file_name.eq_ignore_ascii_case("winhttp.dll"))
}
}