MCPcopy Create free account
hub / github.com/assaultcube/AC / startgame

Function startgame

source/src/server.cpp:2357–2467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2355}
2356
2357void startgame(const char *newname, int newmode, int newtime, bool notify)
2358{
2359 if(!newname || !*newname || (newmode == GMODE_DEMO && isdedicated)) fatal("startgame() abused");
2360 if(newmode == GMODE_DEMO)
2361 {
2362 startdemoplayback(newname);
2363 }
2364 else
2365 {
2366 bool lastteammode = m_teammode;
2367 resetserver(newname, newmode, newtime); // beware: may clear *newname
2368
2369 if(sg->custom_servdesc && findcnbyaddress(&sg->servdesc_caller) < 0)
2370 {
2371 updatesdesc(NULL);
2372 if(notify)
2373 {
2374 sendservmsg("server description reset to default");
2375 mlog(ACLOG_INFO, "server description reset to '%s'", sg->servdesc_current);
2376 }
2377 }
2378
2379 servermap *sm = NULL;
2380 if(isdedicated)
2381 { // dedicated server: only use pre-loaded maps
2382 sm = getservermap(sg->smapname);
2383 }
2384#ifndef STANDALONE
2385 else
2386 { // local server: load map temporarily
2387 static servermap *localmap = NULL;
2388 DELETEP(localmap);
2389 const char *lpath = checklocalmap(sg->smapname);
2390 if(lpath) localmap = new servermap(sg->smapname, lpath);
2391 if(localmap)
2392 {
2393 localmap->load();
2394 if(localmap->isok)
2395 {
2396 sm = localmap;
2397 if(!(sm->entstats.modes_possible & 1 << sg->smode)) conoutf("\f3map %s does not support game mode %s", sm->fname, fullmodestr(sg->smode));
2398 }
2399 else conoutf("\f3local server failed to load map \"%s%s\", error: %s", lpath, sg->smapname, localmap->err);
2400 }
2401 }
2402#endif
2403 sg->curmap = sm;
2404 if(sm)
2405 {
2406 sg->layout = sm->getlayout(); // get floorplan
2407
2408 loopi(2)
2409 {
2410 sflaginfo &f = sg->sflaginfos[i];
2411 if(sg->curmap->entstats.hasflags) // don't check flag positions, if there is more than one flag per team
2412 {
2413 f.x = sg->curmap->entpos_x[sg->curmap->entstats.flagents[i]];
2414 f.y = sg->curmap->entpos_y[sg->curmap->entstats.flagents[i]];

Callers 4

nextMethod · 0.85
restartMethod · 0.85
performMethod · 0.85
serversliceFunction · 0.85

Calls 15

startdemoplaybackFunction · 0.85
resetserverFunction · 0.85
findcnbyaddressFunction · 0.85
updatesdescFunction · 0.85
sendservmsgFunction · 0.85
mlogFunction · 0.85
getservermapFunction · 0.85
checklocalmapFunction · 0.85
fullmodestrFunction · 0.85
sendfFunction · 0.85
numnonlocalclientsFunction · 0.85
send_item_listFunction · 0.85

Tested by

no test coverage detected