-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter-matches-product
156 lines (145 loc) · 5.66 KB
/
filter-matches-product
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
diff --git a/gameSource/LivingLifePage.cpp b/gameSource/LivingLifePage.cpp
index 8d00bc808..980e1bc2a 100644
--- a/gameSource/LivingLifePage.cpp
+++ b/gameSource/LivingLifePage.cpp
@@ -176,6 +176,8 @@ static int clickToMoveLockToInteract = 0;
static int showLearnedTools = 0;
+static int filterMatchesProduct = 1;
+
typedef enum interactionKeyType {
IK_MOVE,
@@ -3255,6 +3257,8 @@ LivingLifePage::LivingLifePage()
showLearnedTools = SettingsManager::getIntSetting( "showLearnedTools", 0 );
+ filterMatchesProduct = SettingsManager::getIntSetting( "filterMatchesProduct", 1 );
+
interactionKeysEnabled = SettingsManager::getIntSetting( "interactionKeysEnabled", 1 );
initKeybinds();
@@ -12814,6 +12818,7 @@ int LivingLifePage::getNumHints( int inObjectID ) {
// new logic:
// show all trans leading to this target object
+ if( !filterMatchesProduct )
if( mLastHintFilterString != NULL ) {
SimpleVector<int> hitIDs = findObjectsMatchingWords(
@@ -12948,6 +12953,101 @@ int LivingLifePage::getNumHints( int inObjectID ) {
}
}
+ // mod logic
+ // show all direct trans leading to this target object
+ if( filterMatchesProduct )
+ if( mLastHintFilterString != NULL ) {
+ int remaining;
+ ObjectRecord** hitObjects = searchObjects(
+ mLastHintFilterString,
+ 0, // don't filter out what we're holding
+ 200,
+ &numFilterHits, &remaining );
+
+ if( numFilterHits > 0 ) {
+ filteredTrans.deleteAll();
+ unfilteredTrans.deleteAll();
+
+ for( int i=0; i<numFilterHits; i++ ) {
+ int oID = hitObjects[i]->id;
+ int oD = getObjectDepth( oID );
+
+ int numResults = 0;
+ int numRemain = 0;
+ TransRecord **prodTrans =
+ searchProduces( oID,
+ 0,
+ 200,
+ &numResults, &numRemain );
+
+ if( prodTrans != NULL ) {
+ TransRecord *minDepthTrans = NULL;
+ int minDepth = UNREACHABLE;
+
+ for( int r=0; r<numResults; r++ ) {
+
+ int actor = prodTrans[r]->actor;
+ int target = prodTrans[r]->target;
+
+ int actorD = 0;
+ int targetD = 0;
+
+ if( actor > 0 ) {
+ actorD = getObjectDepth( actor );
+ }
+ if( target > 0 ) {
+ targetD = getObjectDepth( target );
+ }
+
+ if( actor >= -1 &&
+ ( actor <= 0 || actorD < oD )
+ &&
+ target != 0 && targetD < oD
+ &&
+ filteredTrans.getElementIndex( prodTrans[r] )
+ == -1 ) {
+
+ if( prodTrans[r]->lastUseTarget ||
+ prodTrans[r]->lastUseActor ) {
+ // skip last use transitions
+ continue;
+ }
+
+ // skip dummy versions of transitions, too
+ if( actor > 0 &&
+ ( getObject( actor )->isUseDummy ||
+ getObject( actor )->isVariableDummy ) ) {
+ continue;
+ }
+ if( target > 0 &&
+ ( getObject( target )->isUseDummy ||
+ getObject( target )->isVariableDummy ) ) {
+ continue;
+ }
+
+
+ int maxDepth = actorD;
+ if( targetD > maxDepth ) {
+ maxDepth = targetD;
+ }
+
+ if( maxDepth < minDepth ) {
+ minDepth = maxDepth;
+ minDepthTrans = prodTrans[r];
+ }
+ }
+ }
+ if( minDepthTrans != NULL ) {
+ filteredTrans.push_back( minDepthTrans );
+ }
+
+ delete [] prodTrans;
+ }
+ }
+ unfilteredTrans.push_back_other( &filteredTrans );
+ delete [] hitObjects;
+ }
+ }
int numTrans = filteredTrans.size();
diff --git a/gameSource/settings/wonlife-plus/filterMatchesProduct.ini b/gameSource/settings/wonlife-plus/filterMatchesProduct.ini
new file mode 100644
index 000000000..56a6051ca
--- /dev/null
+++ b/gameSource/settings/wonlife-plus/filterMatchesProduct.ini
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/gameSource/settings/wonlife-vanilla/filterMatchesProduct.ini b/gameSource/settings/wonlife-vanilla/filterMatchesProduct.ini
new file mode 100644
index 000000000..c22708346
--- /dev/null
+++ b/gameSource/settings/wonlife-vanilla/filterMatchesProduct.ini
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/gameSource/settings/wonlife-wondible/filterMatchesProduct.ini b/gameSource/settings/wonlife-wondible/filterMatchesProduct.ini
new file mode 100644
index 000000000..56a6051ca
--- /dev/null
+++ b/gameSource/settings/wonlife-wondible/filterMatchesProduct.ini
@@ -0,0 +1 @@
+1
\ No newline at end of file