MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / EditVariable

Method EditVariable

src/Ext/TAction/Body.cpp:111–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111bool TActionExt::EditVariable(TActionClass* pThis, HouseClass* pHouse, ObjectClass* pObject, TriggerClass* pTrigger, CellStruct const& location)
112{
113 // Variable Index
114 // holds by pThis->Value
115
116 // Operations:
117 // 0 : set value - operator=
118 // 1 : add value - operator+
119 // 2 : minus value - operator-
120 // 3 : multiply value - operator*
121 // 4 : divide value - operator/
122 // 5 : mod value - operator%
123 // 6 : <<
124 // 7 : >>
125 // 8 : ~ (no second param being used)
126 // 9 : ^
127 // 10 : |
128 // 11 : &
129 // holds by pThis->Param3
130
131 // Params:
132 // The second value
133 // holds by pThis->Param4
134
135 // Global Variable or Local
136 // 0 for local and 1 for global
137 // holds by pThis->Param5
138
139 // uses !pThis->Param5 to ensure Param5 is 0 or 1
140 auto& variables = ScenarioExt::Global()->Variables[pThis->Param5 != 0];
141 auto itr = variables.find(pThis->Value);
142 if (itr != variables.end())
143 {
144 auto& nCurrentValue = itr->second.Value;
145 // variable being found
146 switch (pThis->Param3)
147 {
148 case 0: { nCurrentValue = pThis->Param4; break; }
149 case 1: { nCurrentValue += pThis->Param4; break; }
150 case 2: { nCurrentValue -= pThis->Param4; break; }
151 case 3: { nCurrentValue *= pThis->Param4; break; }
152 case 4: { nCurrentValue /= pThis->Param4; break; }
153 case 5: { nCurrentValue %= pThis->Param4; break; }
154 case 6: { nCurrentValue <<= pThis->Param4; break; }
155 case 7: { nCurrentValue >>= pThis->Param4; break; }
156 case 8: { nCurrentValue = ~nCurrentValue; break; }
157 case 9: { nCurrentValue ^= pThis->Param4; break; }
158 case 10: { nCurrentValue |= pThis->Param4; break; }
159 case 11: { nCurrentValue &= pThis->Param4; break; }
160 default:
161 return true;
162 }
163
164 if (!pThis->Param5)
165 TagClass::NotifyLocalChanged(pThis->Value);
166 else
167 TagClass::NotifyGlobalChanged(pThis->Value);
168 }

Callers

nothing calls this directly

Calls 2

findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected