In addition, here is a small function to get the flag code from either the bz_PlayerRecord or the bz_BasePlayerRecord. The PlayerRecord::currentFlag string is formatted with the full name, the flag code, and a plus or minus sign indicating a good or bad flag respectively. For example, the wings flag has this formatting: "WinGs (+WG)." However, not all functions or data members use this same formatting.
Code: Select all
// A hack to get the flag code from a bz_BasePlayerRecord
inline std::string extractFlagCode(const std::string& flag)
{
std::size_t begin = flag.find_last_of('(');
std::size_t end = flag.find_last_of(')');
if(begin == std::string::npos || end == std::string::npos)
return std::string("");
return std::string(flag.begin() + begin + 2,
flag.begin() + end);
}