Skip to content

Commit 86fee18

Browse files
committed
Remove support for the "LOOT" alias
1 parent 2b95f26 commit 86fee18

File tree

5 files changed

+34
-107
lines changed

5 files changed

+34
-107
lines changed

Diff for: ffi/src/state.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ pub unsafe extern "C" fn lci_state_create(
3232
state: *mut *mut lci_state,
3333
game_type: c_int,
3434
data_path: *const c_char,
35-
loot_path: *const c_char,
3635
) -> c_int {
3736
catch_unwind(|| {
38-
if state.is_null() || data_path.is_null() || loot_path.is_null() {
37+
if state.is_null() || data_path.is_null() {
3938
error(LCI_ERROR_INVALID_ARGS, "Null pointer passed")
4039
} else {
4140
let game_type = match map_game_type(game_type) {
@@ -48,13 +47,8 @@ pub unsafe extern "C" fn lci_state_create(
4847
Err(e) => return e,
4948
};
5049

51-
let loot_path = match to_str(loot_path) {
52-
Ok(x) => PathBuf::from(x),
53-
Err(e) => return e,
54-
};
55-
5650
*state = Box::into_raw(Box::new(lci_state(RwLock::new(State::new(
57-
game_type, data_path, loot_path,
51+
game_type, data_path,
5852
)))));
5953

6054
LCI_OK

Diff for: ffi/tests/ffi.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void test_lci_state_create() {
5454
printf("testing lci_state_create()...\n");
5555

5656
lci_state * state = nullptr;
57-
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, ".", ".");
57+
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, ".");
5858

5959
assert(return_code == LCI_OK);
6060
assert(state != nullptr);
@@ -66,7 +66,7 @@ void test_lci_condition_eval() {
6666
printf("testing lci_condition_eval()...\n");
6767

6868
lci_state * state = nullptr;
69-
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
69+
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data");
7070

7171
assert(return_code == LCI_OK);
7272
assert(state != nullptr);
@@ -86,7 +86,7 @@ void test_lci_state_set_active_plugins() {
8686
printf("testing lci_state_set_active_plugins()...\n");
8787

8888
lci_state * state = nullptr;
89-
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
89+
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data");
9090

9191
assert(return_code == LCI_OK);
9292
assert(state != nullptr);
@@ -118,7 +118,7 @@ void test_lci_state_set_plugin_versions() {
118118
printf("testing lci_state_set_plugin_versions()...\n");
119119

120120
lci_state * state = nullptr;
121-
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
121+
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data");
122122

123123
assert(return_code == LCI_OK);
124124
assert(state != nullptr);
@@ -153,7 +153,7 @@ void test_lci_state_set_crc_cache() {
153153
printf("testing lci_state_set_crc_cache()...\n");
154154

155155
lci_state * state = nullptr;
156-
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data", ".");
156+
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, "../../tests/testing-plugins/Oblivion/Data");
157157

158158
assert(return_code == LCI_OK);
159159
assert(state != nullptr);
@@ -185,7 +185,7 @@ void test_lci_state_set_additional_data_paths() {
185185
printf("testing lci_state_set_additional_data_paths()...\n");
186186

187187
lci_state * state = nullptr;
188-
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, ".", ".");
188+
int return_code = lci_state_create(&state, LCI_GAME_OBLIVION, ".");
189189

190190
assert(return_code == LCI_OK);
191191
assert(state != nullptr);

Diff for: src/function/eval.rs

+3-52
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,19 @@ mod tests {
329329
}
330330

331331
fn state_with_active_plugins<T: Into<PathBuf>>(data_path: T, active_plugins: &[&str]) -> State {
332-
state_with_data(data_path, Vec::default(), "", active_plugins, &[])
333-
}
334-
335-
fn state_with_loot_path<T: Into<PathBuf>>(data_path: T, loot_path: &str) -> State {
336-
state_with_data(data_path, Vec::default(), loot_path, &[], &[])
332+
state_with_data(data_path, Vec::default(), active_plugins, &[])
337333
}
338334

339335
fn state_with_versions<T: Into<PathBuf>>(
340336
data_path: T,
341337
plugin_versions: &[(&str, &str)],
342338
) -> State {
343-
state_with_data(data_path, Vec::default(), "", &[], plugin_versions)
339+
state_with_data(data_path, Vec::default(), &[], plugin_versions)
344340
}
345341

346342
fn state_with_data<T: Into<PathBuf>>(
347343
data_path: T,
348344
additional_data_paths: Vec<T>,
349-
loot_path: &str,
350345
active_plugins: &[&str],
351346
plugin_versions: &[(&str, &str)],
352347
) -> State {
@@ -370,7 +365,6 @@ mod tests {
370365
game_type: GameType::Oblivion,
371366
data_path,
372367
additional_data_paths,
373-
loot_path: loot_path.into(),
374368
active_plugins: active_plugins
375369
.into_iter()
376370
.map(|s| s.to_lowercase())
@@ -425,24 +419,6 @@ mod tests {
425419
assert!(function.eval(&state).unwrap());
426420
}
427421

428-
#[test]
429-
#[allow(non_snake_case)]
430-
fn function_file_path_eval_should_be_true_if_given_LOOT_and_loot_path_exists() {
431-
let function = Function::FilePath(PathBuf::from("LOOT"));
432-
let state = state_with_loot_path(".", "Cargo.toml");
433-
434-
assert!(function.eval(&state).unwrap());
435-
}
436-
437-
#[test]
438-
#[allow(non_snake_case)]
439-
fn function_file_path_eval_should_be_false_if_given_LOOT_and_loot_path_does_not_exist() {
440-
let function = Function::FilePath(PathBuf::from("LOOT"));
441-
let state = state_with_loot_path(".", "missing");
442-
443-
assert!(!function.eval(&state).unwrap());
444-
}
445-
446422
#[test]
447423
fn function_file_path_eval_should_not_check_for_ghosted_non_plugin_file() {
448424
let tmp_dir = tempdir().unwrap();
@@ -515,13 +491,7 @@ mod tests {
515491
#[test]
516492
fn function_file_regex_eval_should_check_all_configured_data_paths() {
517493
let function = Function::FileRegex(PathBuf::from("Data"), regex("Blank\\.esp"));
518-
let state = state_with_data(
519-
"./src",
520-
vec!["./tests/testing-plugins/Oblivion"],
521-
".",
522-
&[],
523-
&[],
524-
);
494+
let state = state_with_data("./src", vec!["./tests/testing-plugins/Oblivion"], &[], &[]);
525495

526496
assert!(function.eval(&state).unwrap());
527497
}
@@ -781,7 +751,6 @@ mod tests {
781751
let state = state_with_data(
782752
"./tests/testing-plugins/Skyrim",
783753
vec!["./tests/testing-plugins/Oblivion"],
784-
".",
785754
&[],
786755
&[],
787756
);
@@ -878,24 +847,6 @@ mod tests {
878847
assert!(!function.eval(&state).unwrap());
879848
}
880849

881-
#[test]
882-
#[allow(non_snake_case)]
883-
fn function_checksum_eval_should_be_true_if_given_LOOT_crc_matches() {
884-
let function = Function::Checksum(PathBuf::from("LOOT"), 0x374E2A6F);
885-
let state = state_with_loot_path(".", "tests/testing-plugins/Oblivion/Data/Blank.esm");
886-
887-
assert!(function.eval(&state).unwrap());
888-
}
889-
890-
#[test]
891-
#[allow(non_snake_case)]
892-
fn function_checksum_eval_should_be_false_if_given_LOOT_crc_does_not_match() {
893-
let function = Function::Checksum(PathBuf::from("LOOT"), 0xDEADBEEF);
894-
let state = state_with_loot_path(".", "tests/testing-plugins/Oblivion/Data/Blank.esm");
895-
896-
assert!(!function.eval(&state).unwrap());
897-
}
898-
899850
#[test]
900851
fn function_checksum_eval_should_be_false_if_given_a_directory_path() {
901852
// The given CRC is the CRC-32 of the directory as calculated by 7-zip.

Diff for: src/function/path.rs

+22-36
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,30 @@ pub fn normalise_file_name(game_type: GameType, name: &str) -> &str {
5656
}
5757

5858
pub fn resolve_path(state: &State, path: &Path) -> PathBuf {
59-
if path == Path::new("LOOT") {
60-
state.loot_path.clone()
61-
} else {
62-
// First check external data paths, as files there may override files in the main data path.
63-
for data_path in &state.additional_data_paths {
64-
let mut path = data_path.join(path);
59+
// First check external data paths, as files there may override files in the main data path.
60+
for data_path in &state.additional_data_paths {
61+
let mut path = data_path.join(path);
6562

66-
if path.exists() {
67-
return path;
68-
}
63+
if path.exists() {
64+
return path;
65+
}
6966

70-
if has_unghosted_plugin_file_extension(state.game_type, &path) {
71-
path = add_ghost_extension(path);
72-
}
67+
if has_unghosted_plugin_file_extension(state.game_type, &path) {
68+
path = add_ghost_extension(path);
69+
}
7370

74-
if path.exists() {
75-
return path;
76-
}
71+
if path.exists() {
72+
return path;
7773
}
74+
}
7875

79-
// Now check the main data path.
80-
let path = state.data_path.join(path);
76+
// Now check the main data path.
77+
let path = state.data_path.join(path);
8178

82-
if !path.exists() && has_unghosted_plugin_file_extension(state.game_type, &path) {
83-
add_ghost_extension(path)
84-
} else {
85-
path
86-
}
79+
if !path.exists() && has_unghosted_plugin_file_extension(state.game_type, &path) {
80+
add_ghost_extension(path)
81+
} else {
82+
path
8783
}
8884
}
8985

@@ -404,20 +400,10 @@ mod tests {
404400
assert_eq!(PathBuf::from("plugin.ghost"), path);
405401
}
406402

407-
#[test]
408-
#[allow(non_snake_case)]
409-
fn resolve_path_should_return_loot_path_if_given_LOOT() {
410-
let loot_path = PathBuf::from("loot.exe");
411-
let state = State::new(GameType::Skyrim, "data".into(), loot_path.clone());
412-
let path = resolve_path(&state, Path::new("LOOT"));
413-
414-
assert_eq!(loot_path, path);
415-
}
416-
417403
#[test]
418404
fn resolve_path_should_return_the_data_path_prefixed_path_if_it_exists() {
419405
let data_path = PathBuf::from(".");
420-
let state = State::new(GameType::Skyrim, data_path.clone(), "loot.exe".into());
406+
let state = State::new(GameType::Skyrim, data_path.clone());
421407
let input_path = Path::new("README.md");
422408
let resolved_path = resolve_path(&state, input_path);
423409

@@ -428,7 +414,7 @@ mod tests {
428414
fn resolve_path_should_return_the_data_path_prefixed_path_if_it_does_not_exist_and_is_not_an_unghosted_plugin_filename(
429415
) {
430416
let data_path = PathBuf::from(".");
431-
let state = State::new(GameType::Skyrim, data_path.clone(), "loot.exe".into());
417+
let state = State::new(GameType::Skyrim, data_path.clone());
432418
let input_path = Path::new("plugin.esp.ghost");
433419
let resolved_path = resolve_path(&state, input_path);
434420

@@ -444,7 +430,7 @@ mod tests {
444430
fn resolve_path_should_return_the_given_data_relative_path_plus_a_ghost_extension_if_the_plugin_path_does_not_exist(
445431
) {
446432
let data_path = PathBuf::from(".");
447-
let state = State::new(GameType::Skyrim, data_path.clone(), "loot.exe".into());
433+
let state = State::new(GameType::Skyrim, data_path.clone());
448434
let input_path = Path::new("plugin.esp");
449435
let resolved_path = resolve_path(&state, input_path);
450436

@@ -474,7 +460,7 @@ mod tests {
474460
.unwrap();
475461
copy(Path::new("Cargo.toml"), data_path.join("Cargo.toml")).unwrap();
476462

477-
let mut state = State::new(GameType::Skyrim, data_path, "loot.exe".into());
463+
let mut state = State::new(GameType::Skyrim, data_path);
478464
state.set_additional_data_paths(vec![external_data_path_1, external_data_path_2.clone()]);
479465

480466
let input_path = Path::new("Cargo.toml");

Diff for: src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ pub struct State {
5454
/// Other directories that may contain plugins and other game files, used before data_path and
5555
/// in the order they're listed.
5656
additional_data_paths: Vec<PathBuf>,
57-
/// Path to the LOOT executable, used to resolve conditions that use the "LOOT" path.
58-
loot_path: PathBuf,
5957
/// Lowercased plugin filenames.
6058
active_plugins: HashSet<String>,
6159
/// Lowercased paths.
@@ -67,12 +65,11 @@ pub struct State {
6765
}
6866

6967
impl State {
70-
pub fn new(game_type: GameType, data_path: PathBuf, loot_path: PathBuf) -> Self {
68+
pub fn new(game_type: GameType, data_path: PathBuf) -> Self {
7169
State {
7270
game_type,
7371
data_path,
7472
additional_data_paths: Vec::default(),
75-
loot_path,
7673
active_plugins: HashSet::default(),
7774
crc_cache: RwLock::default(),
7875
plugin_versions: HashMap::default(),
@@ -296,7 +293,6 @@ mod tests {
296293
game_type: GameType::Oblivion,
297294
data_path,
298295
additional_data_paths: Vec::default(),
299-
loot_path: PathBuf::new(),
300296
active_plugins: HashSet::new(),
301297
crc_cache: RwLock::default(),
302298
plugin_versions: HashMap::default(),

0 commit comments

Comments
 (0)