diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 33658dba..9bbec2f0 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -498,6 +498,16 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } + case SV_NEWMAP: + { + int size = getint(p); + if(size>=0) empty_world(size, true); + else empty_world(-1, true); + if(d && d!=player1) + conoutf(size>=0 ? "%s started a new map of size %d" : "%s enlarged the map to size %d", colorname(d), sfactor); + break; + } + case SV_EDITENT: // coop edit of ent { uint i = getint(p); diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index a262d884..8120be85 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -139,7 +139,7 @@ char msgsizesl[] = // size inclusive message token, 0 for variable SV_TIMEUP, 2, SV_EDITENT, 10, SV_MAPRELOAD, 2, SV_NEXTMAP, 0, SV_ITEMACC, 2, SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 2, SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2, - SV_EDITMODE, 2, SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, SV_EDITD, 6, SV_EDITE, 6, + SV_EDITMODE, 2, SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, SV_EDITD, 6, SV_EDITE, 6, SV_NEWMAP, 2, SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2, SV_PRIMARYWEAP, 2, SV_MODELSKIN, 2, SV_FLAGACTION, 3, SV_FLAGINFO, 0, SV_FLAGMSG, 0, SV_FLAGCNT, 3, diff --git a/source/src/protocol.h b/source/src/protocol.h index 2324c4a4..e55a5ab1 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -21,7 +21,7 @@ enum SV_TIMEUP, SV_EDITENT, SV_MAPRELOAD, SV_NEXTMAP, SV_ITEMACC, SV_MAPCHANGE, SV_ITEMSPAWN, SV_ITEMPICKUP, SV_PING, SV_PONG, SV_CLIENTPING, SV_GAMEMODE, - SV_EDITMODE, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, + SV_EDITMODE, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, SV_NEWMAP, SV_SENDMAP, SV_RECVMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE, SV_PRIMARYWEAP, SV_MODELSKIN, SV_FLAGACTION, SV_FLAGINFO, SV_FLAGMSG, SV_FLAGCNT, @@ -51,7 +51,7 @@ const static char *messagenames[] = "SV_TIMEUP", "SV_EDITENT", "SV_MAPRELOAD", "SV_NEXTMAP", "SV_ITEMACC", "SV_MAPCHANGE", "SV_ITEMSPAWN", "SV_ITEMPICKUP", "SV_PING", "SV_PONG", "SV_CLIENTPING", "SV_GAMEMODE", - "SV_EDITMODE", "SV_EDITH", "SV_EDITT", "SV_EDITS", "SV_EDITD", "SV_EDITE", + "SV_EDITMODE", "SV_EDITH", "SV_EDITT", "SV_EDITS", "SV_EDITD", "SV_EDITE", "SV_NEWMAP", "SV_SENDMAP", "SV_RECVMAP", "SV_SERVMSG", "SV_ITEMLIST", "SV_WEAPCHANGE", "SV_PRIMARYWEAP", "SV_MODELSKIN", "SV_FLAGACTION", "SV_FLAGINFO", "SV_FLAGMSG", "SV_FLAGCNT", diff --git a/source/src/protos.h b/source/src/protos.h index 3fda54ac..5b5779eb 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -373,7 +373,7 @@ extern void consolescores(); // world extern void setupworld(int factor); -extern void empty_world(int factor, bool force); +extern bool empty_world(int factor, bool force); extern void remip(const block &b, int level = 0); extern void remipmore(const block &b, int level = 0); extern int closestent(); diff --git a/source/src/server.cpp b/source/src/server.cpp index 77af6264..1400a595 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -2325,7 +2325,7 @@ int checktype(int type, client *cl) { if(cl && cl->type==ST_LOCAL) return type; // only allow edit messages in coop-edit mode - static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE }; + static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, SV_NEWMAP }; if(cl && smode!=1) loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return -1; // server only messages static int servtypes[] = { SV_INITS2C, SV_MAPRELOAD, SV_SERVMSG, SV_GIBDAMAGE, SV_DAMAGE, diff --git a/source/src/world.cpp b/source/src/world.cpp index 8276d75e..39ef231b 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -286,9 +286,9 @@ void setupworld(int factor) loopi(LARGEST_FACTOR*2) { wmip[i] = w; w += cubicsize>>(i*2); } } -void empty_world(int factor, bool force) // main empty world creation routine, if passed factor -1 will enlarge old world by 1 +bool empty_world(int factor, bool force) // main empty world creation routine, if passed factor -1 will enlarge old world by 1 { - if(!force && noteditmode()) return; + if(!force && noteditmode()) return false; sqr *oldworld = world; bool copy = false; if(oldworld && factor<0) { factor = sfactor+1; copy = true; } @@ -360,10 +360,11 @@ void empty_world(int factor, bool force) // main empty world creation routine findplayerstart(player1, true); startmap(""); } + return true; } -void mapenlarge() { empty_world(-1, false); } -void newmap(int i) { empty_world(i, false); } +void mapenlarge() { if(empty_world(-1, false)) addmsg(SV_NEWMAP, "ri", -1); } +void newmap(int i) { if(empty_world(i, false)) addmsg(SV_NEWMAP, "ri", max(i, 0)); } COMMAND(mapenlarge, ARG_NONE); COMMAND(newmap, ARG_1INT);