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

Method handle

plugins/koth/koth.cpp:205–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203KOTHZone kothzone;
204
205bool KOTHMapHandler::handle(bz_ApiString object, bz_CustomMapObjectInfo* data) {
206 if (object != "KOTH" || !data) {
207 return false;
208 }
209
210 // parse all the chunks
211 for (unsigned int i = 0; i < data->data.size(); i++) {
212 std::string line = data->data.get(i).c_str();
213
214 bz_APIStringList* nubs = bz_newStringList();
215 nubs->tokenize(line.c_str(), " ", 0, true);
216
217 if (nubs->size() > 0) {
218 std::string key = bz_toupper(nubs->get(0).c_str());
219
220 if (key == "BBOX" && nubs->size() > 6) {
221 kothzone.box = true;
222 kothzone.xMin = (float) atof(nubs->get(1).c_str());
223 kothzone.xMax = (float) atof(nubs->get(2).c_str());
224 kothzone.yMin = (float) atof(nubs->get(3).c_str());
225 kothzone.yMax = (float) atof(nubs->get(4).c_str());
226 kothzone.zMin = (float) atof(nubs->get(5).c_str());
227 kothzone.zMax = (float) atof(nubs->get(6).c_str());
228 }
229 else if (key == "CYLINDER" && nubs->size() > 5) {
230 kothzone.box = false;
231 kothzone.rad = (float) atof(nubs->get(5).c_str());
232 kothzone.xMax = (float) atof(nubs->get(1).c_str());
233 kothzone.yMax = (float) atof(nubs->get(2).c_str());
234 kothzone.zMin = (float) atof(nubs->get(3).c_str());
235 kothzone.zMax = (float) atof(nubs->get(4).c_str());
236 }
237 else if (key == "TEAMPLAY") {
238 koth.teamPlay = true;
239 }
240 else if (key == "NOSOUND") {
241 koth.soundEnabled = false;
242 }
243 else if (key == "AUTOTIME" && nubs->size() == 1) {
244 koth.autoTimeOn = true;
245 }
246 else if (key == "AUTOTIME" && nubs->size() > 2) {
247 double temp1 = (double) atof(nubs->get(1).c_str());
248 double temp2 = (double) atof(nubs->get(2).c_str());
249 if (temp1 >= 1 && temp1 <= 99) {
250 koth.timeMult = temp1 / 100;
251 }
252 if (temp2 >= 1 && temp2 <= 99) {
253 koth.timeMultMin = temp2 / 100;
254 }
255 koth.autoTimeOn = true;
256 }
257 else if (key == "HOLDTIME" && nubs->size() > 1) {
258 double temp = (double) atof(nubs->get(1).c_str());
259 if (temp >= 1 && temp <= 7200) {
260 koth.TTH = temp;
261 }
262 }

Callers

nothing calls this directly

Calls 12

bz_toupperFunction · 0.85
bz_deleteStringListFunction · 0.85
bz_setMaxWaitTimeFunction · 0.85
bz_sendTextMessageFunction · 0.85
bz_freePlayerRecordFunction · 0.85
bz_sendTextMessagefFunction · 0.85
c_strMethod · 0.80
tokenizeMethod · 0.80
ConvertToNumFunction · 0.70
autoTimeFunction · 0.70
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected