| 606 | } |
| 607 | |
| 608 | void 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 | } |
| 646 | COMMAND(sendmap, "s"); |
| 647 | |
| 648 | void getmap(char *name, char *callback) |
nothing calls this directly
no test coverage detected