MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / findColor

Method findColor

src/game/DynamicColor.cpp:114–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112
113
114int DynamicColorManager::findColor(const std::string& name) const {
115 if (name.empty()) {
116 return -1;
117 }
118 else if ((name[0] >= '0') && (name[0] <= '9')) {
119 int index = atoi(name.c_str());
120 if ((index < 0) || (index >= (int)colors.size())) {
121 return -1;
122 }
123 else {
124 return index;
125 }
126 }
127 else {
128 for (int i = 0; i < (int)colors.size(); i++) {
129 if (colors[i]->getName() == name) {
130 return i;
131 }
132 }
133 return -1;
134 }
135}
136
137
138const DynamicColor* DynamicColorManager::getColor(int id) const {

Callers 3

writeToManagerMethod · 0.80
parseMaterialsFunction · 0.80
getLinkMaterialMethod · 0.80

Calls 4

c_strMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected