//=========================================================================== // // FindState (multiple names version) // // Finds a state that matches as many of the supplied names as possible. // A state with more names than those provided does not match. // A state with fewer names can match if there are no states with the exact // same number of names. // // The search proceeds like this. For the current class, keeping matching // names until there are no more. If both the argument list and the state // are out of names, it's an exact match, so return it. If the state still // has names, ignore it. If the argument list still has names, remember it. // //=========================================================================== FState *PClassActor::FindState(int numnames, FName *names, bool exact) const { FStateLabels *labels = StateList; FState *best = NULL; if (labels != NULL) { int count = 0; FStateLabel *slabel = NULL; FName label; // Find the best-matching label for this class. while (labels != NULL && count < numnames) { label = *names++; slabel = labels->FindLabel(label); if (slabel != NULL) { count++; labels = slabel->Children; best = slabel->State; } else { break; } } if (count < numnames && exact) { return NULL; } } return best; }
static void CheckStateLabels(PClassActor *obj, ENamedName *test, int useflag, const char *descript) { FStateLabels *labels = obj->StateList; for (; *test != NAME_None; test++) { auto label = labels->FindLabel(*test); if (label != nullptr) { CheckLabel(obj, label, useflag, *test, descript); } } }