Skip to content

Commit f659466

Browse files
committed
Report implicit ModReputation usage
1 parent ceced54 commit f659466

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "StandardsValidator"
3-
version = "2.15.0"
3+
version = "2.16.0"
44
edition = "2021"
55

66
[dependencies]

WARNINGS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ A book matching the detected marker ID exists, but it's not using the correct me
303303
### Refers to marker which has no references
304304
No instances of the detected marker exist in this file.
305305

306+
### Uses ModReputation without an explicit target
307+
This script is probably changing an NPC's reputation instead of the player's.
308+
306309
## Magic
307310

308311
### Uses effect

src/validators/scripts.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct ScriptValidator {
3737
aifollow: Regex,
3838
needs_marker: Regex,
3939
marker_id: Regex,
40+
mod_reputation: Regex,
4041
}
4142

4243
struct ScriptInfo {
@@ -170,6 +171,19 @@ impl Handler<'_> for ScriptValidator {
170171
}
171172
}
172173
}
174+
if self.mod_reputation.is_match(code) {
175+
if let TES3Object::DialogueInfo(info) = record {
176+
println!(
177+
"Info {} in topic {} uses ModReputation without an explicit target",
178+
info.id, topic.id
179+
);
180+
} else if let TES3Object::Script(script) = record {
181+
println!(
182+
"Script {} uses ModReputation without an explicit target",
183+
script.id
184+
);
185+
}
186+
}
173187
}
174188

175189
fn on_cellref(
@@ -286,6 +300,7 @@ impl ScriptValidator {
286300
let marker_id = RegexBuilder::new(&marker_id_pattern)
287301
.case_insensitive(true)
288302
.build()?;
303+
let mod_reputation = Regex::new(r"^[,\s]*modreputation[,\s]")?;
289304
Ok(Self {
290305
unique_heads,
291306
scripts: HashMap::new(),
@@ -303,6 +318,7 @@ impl ScriptValidator {
303318
aifollow,
304319
marker_id,
305320
markers: HashMap::new(),
321+
mod_reputation,
306322
})
307323
}
308324

0 commit comments

Comments
 (0)