MCPcopy Create free account
hub / github.com/EasyRPG/Player / GetSignificantState

Function GetSignificantState

src/state.cpp:158–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156
157}
158const lcf::rpg::State* GetSignificantState(const StateVec& states) {
159 int priority = 0;
160 const lcf::rpg::State* sig_state = NULL;
161
162 for (int i = 0; i < (int)states.size(); ++i) {
163 auto state_id = i + 1;
164
165 if (!Has(state_id, states)) {
166 continue;
167 }
168
169 auto* state = lcf::ReaderUtil::GetElement(lcf::Data::states, state_id);
170 if (state == nullptr) {
171 Output::Warning("State::GetSignificantState: Can't remove state with invalid ID {}", state_id);
172 continue;
173 }
174
175 // Death has highest priority
176 if (state->ID == lcf::rpg::State::kDeathID) {
177 return state;
178 }
179
180 if (state->priority >= priority) {
181 sig_state = state;
182 priority = state->priority;
183 }
184 };
185
186 return sig_state;
187
188}
189
190int GetStateRate(int state_id, int rate) {
191 const lcf::rpg::State* state = lcf::ReaderUtil::GetElement(lcf::Data::states, state_id);

Callers 2

AddFunction · 0.85
GetSignificantStateMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected