From 77b7e9bb87bb6adba747e7925535ed91ae9754af Mon Sep 17 00:00:00 2001 From: ac-stef Date: Thu, 25 Aug 2016 17:06:43 +0200 Subject: [PATCH] new entity type "dummy" Adds a new entity type for use in scripts. The entity does not affect rendering or physics and is not saved to map files. --- source/src/entity.h | 1 + source/src/server.h | 8 +++++--- source/src/worldio.cpp | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/src/entity.h b/source/src/entity.h index ae75f5c6..379f8f3c 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -12,6 +12,7 @@ enum // static entity types SOUND, // attr1 = idx, attr2 = radius, attr3 = size, attr4 = volume CLIP, // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height, attr6 = slope, attr7 = shape PLCLIP, // attr1 = elevation, attr2 = xradius, attr3 = yradius, attr4 = height, attr6 = slope, attr7 = shape + DUMMYENT, // temporary entity without any function - will not be saved to map files, used to mark positions and for scripting MAXENTTYPES }; diff --git a/source/src/server.h b/source/src/server.h index 5495789d..f37a0e68 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -448,7 +448,7 @@ const char *entnames[] = "none?", "light", "playerstart", "pistol", "ammobox","grenades", "health", "helmet", "armour", "akimbo", - "mapmodel", "trigger", "ladder", "ctf-flag", "sound", "clip", "plclip", "" + "mapmodel", "trigger", "ladder", "ctf-flag", "sound", "clip", "plclip", "dummy", "" }; // entity attribute scaling and wraparound definitions for mapformat 10 @@ -470,7 +470,8 @@ short entwraparound[MAXENTTYPES][7] = { -3600, 0, 0, 0, 0, 0, 0 }, // ctf-flag { 256, 0, 0, 0, 0, 0, 0 }, // sound { 0, 0, 0, 0, 0, 0, 4 }, // clip - { 0, 0, 0, 0, 0, 0, 4 } // plclip + { 0, 0, 0, 0, 0, 0, 4 }, // plclip + { 0, 0, 0, 0, 0, 0, 0 } // dummy }; uchar entscale[MAXENTTYPES][7] = @@ -491,7 +492,8 @@ uchar entscale[MAXENTTYPES][7] = { 10, 1, 1, 1, 1, 1, 1 }, // ctf-flag { 1, 1, 1, 1, 1, 1, 1 }, // sound { 10, 5, 5, 5, 1, 10, 1 }, // clip - { 10, 5, 5, 5, 1, 10, 1 } // plclip + { 10, 5, 5, 5, 1, 10, 1 }, // plclip + { 1, 1, 1, 1, 1, 1, 1 } // dummy }; // see entity.h:61: struct itemstat { int add, start, max, sound; }; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index c80c9600..f286f913 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -613,7 +613,7 @@ void save_world(char *mname, bool skipoptimise, bool addcomfort) hdr.numents = 0; ASSERT(MAXENTITIES < (1 << 16)); numbered_persistent_entity npe; - loopv(ents) if(ents[i].type != NOTUSED) // omit deleted entities + loopv(ents) if(ents[i].type != NOTUSED && ents[i].type!=DUMMYENT) // omit deleted entities and dummies { hdr.numents++; npe.e = ents[i]; @@ -701,7 +701,7 @@ void save_world9(char *mname) hdr.headersize = sizeof(header); hdr.timestamp = (int) time(NULL); // non-zero timestamps in format 9 can be used to identify "exported" maps hdr.numents = 0; - loopv(ents) if(ents[i].type!=NOTUSED) hdr.numents++; + loopv(ents) if(ents[i].type!=NOTUSED && ents[i].type!=DUMMYENT) hdr.numents++; if(hdr.numents > MAXENTITIES) { conoutf("too many map entities (%d), only %d will be written to file", hdr.numents, MAXENTITIES); @@ -718,7 +718,7 @@ void save_world9(char *mname) int ne = hdr.numents, ec = 0; loopv(ents) { - if(ents[i].type!=NOTUSED) + if(ents[i].type!=NOTUSED && ents[i].type!=DUMMYENT) { if(!ne--) break; persistent_entity tmp = ents[i];