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

Function sendmap

source/src/client.cpp:608–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608void sendmap(char *mapname)
609{
610 if(!*mapname) mapname = getclientmap();
611 if(securemapcheck(mapname)) return;
612 if(gamemode == GMODE_COOPEDIT && !strcmp(getclientmap(), mapname)) save_world(mapname, true, false); // skip optimisations, don't add undos
613
614 int mapsize, cfgsize, cfgsizegz, revision;
615 uchar *mapdata = readmap(path(mapname), &mapsize, &revision);
616 if(!mapdata) return;
617 uchar *cfgdata = readmcfggz(path(mapname), &cfgsize, &cfgsizegz);
618 if(!cfgdata) { cfgsize = 0; cfgsizegz = 0; }
619
620 packetbuf p(MAXTRANS + mapsize + cfgsizegz, ENET_PACKET_FLAG_RELIABLE);
621
622 putint(p, SV_SENDMAP);
623 sendstring(mapname, p);
624 putint(p, mapsize);
625 putint(p, cfgsize);
626 putint(p, cfgsizegz);
627 putint(p, revision);
628 if(MAXMAPSENDSIZE - p.length() < mapsize + cfgsizegz || cfgsize > MAXCFGFILESIZE)
629 {
630 conoutf("map %s is too large to send", mapname);
631 delete[] mapdata;
632 if(cfgsize) delete[] cfgdata;
633 return;
634 }
635 p.put(mapdata, mapsize);
636 delete[] mapdata;
637 if(cfgsizegz)
638 {
639 p.put(cfgdata, cfgsizegz);
640 delete[] cfgdata;
641 }
642
643 sendpackettoserv(2, p.finalize());
644 conoutf("sending map %s to server...", mapname);
645}
646COMMAND(sendmap, "s");
647
648void getmap(char *name, char *callback)

Callers

nothing calls this directly

Calls 13

getclientmapFunction · 0.85
securemapcheckFunction · 0.85
save_worldFunction · 0.85
readmapFunction · 0.85
pathFunction · 0.85
readmcfggzFunction · 0.85
putintFunction · 0.85
sendstringFunction · 0.85
sendpackettoservFunction · 0.85
finalizeMethod · 0.80
conoutfFunction · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected