blob: f302dc856af73c034ab447fa640a24274c50a681 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
From 17831b78d407a5abfc9389b35202b807ce5df8c4 Mon Sep 17 00:00:00 2001
From: joveeater <joveasarus@gmail.com>
Date: Wed, 8 Nov 2023 00:18:59 +0000
Subject: [PATCH 065/318] fix: npc splints and clean up iterator errors (#3592)
* Fix splints and clean up iterator errors
* style(autofix.ci): automated formatting
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
---
src/item.cpp | 1 +
src/npcmove.cpp | 13 ++++++++++++-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/item.cpp b/src/item.cpp
index 3674560e548..d772312c36a 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -483,6 +483,7 @@ item &item::operator=( const item &source )
invlet = source.invlet;
active = source.active;
activated_by = source.activated_by;
+ is_favorite = source.is_favorite;
contents.clear_items();
diff --git a/src/npcmove.cpp b/src/npcmove.cpp
index c3470703e8a..3a0cd430288 100644
--- a/src/npcmove.cpp
+++ b/src/npcmove.cpp
@@ -4736,6 +4736,7 @@ bool npc::adjust_worn()
return false;
};
+ item *splint = nullptr;
for( auto &elem : worn ) {
if( !elem->has_flag( flag_SPLINT ) ) {
continue;
@@ -4744,11 +4745,21 @@ bool npc::adjust_worn()
if( !covers_broken( *elem, elem->get_side() ) ) {
const bool needs_change = covers_broken( *elem, opposite_side( elem->get_side() ) );
// Try to change side (if it makes sense), or take off.
- if( ( needs_change && change_side( *elem ) ) || takeoff( *elem ) ) {
+ if( needs_change && change_side( *elem ) ) {
return true;
}
+
+ if( can_takeoff( *elem ).success() ) {
+ splint = elem;
+ break;
+ }
+
}
}
+ if( splint ) {
+ takeoff( *splint );
+ return true;
+ }
return false;
}
--
2.42.0
|