spawn ents right after adding them in editmode

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1858 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-05-04 10:32:18 +00:00
parent 479d81bb38
commit 03f608c346
3 changed files with 12 additions and 5 deletions
+4
View File
@@ -21,12 +21,16 @@ struct persistent_entity // map entity
short attr1;
uchar type; // type is one of the above
uchar attr2, attr3, attr4;
persistent_entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : x(x), y(y), z(z), type(type), attr1(attr1), attr2(attr2), attr3(attr3), attr4(attr4) {};
persistent_entity(){};
};
struct entity : public persistent_entity
{
bool spawned; //the only dynamic state of a map entity
bool soundinuse;
entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : persistent_entity(x, y, z, type, attr1, attr2, attr3, attr4), spawned(false), soundinuse(false) {};
entity(){};
};
struct itemstat { int add, start, max, sound; };
+7 -3
View File
@@ -173,11 +173,14 @@ int findtype(char *what)
entity *newentity(int x, int y, int z, char *what, int v1, int v2, int v3, int v4)
{
int type = findtype(what);
persistent_entity e = { x, y, z, v1, type, v2, v3, v4 };
if(type==NOTUSED) return NULL;
entity e(x, y, z, type, v1, v2, v3, v4);
switch(type)
{
case LIGHT:
if(v1>64) v1 = 64;//if(v1>32) v1=32;
if(v1>64) v1 = 64;
if(!v1) e.attr1 = 16;
if(!v2 && !v3 && !v4) e.attr2 = 255;
break;
@@ -193,7 +196,8 @@ entity *newentity(int x, int y, int z, char *what, int v1, int v2, int v3, int v
break;
}
addmsg(SV_EDITENT, "ri9", ents.length(), type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4);
ents.add(*((entity *)&e)); // unsafe!
e.spawned = true;
ents.add(e);
if(type==LIGHT) calclight();
return &ents.last();
}
+1 -2
View File
@@ -184,8 +184,7 @@ void dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner)
if(b.ys+b.y>ssize-2) b.ys = ssize-2-b.y;
dlights.add(blockcopy(b)); // backup area before rendering in dynlight
persistent_entity l = { (int)v.x, (int)v.y, (int)v.z, reach, LIGHT, strength, 0, 0 };
persistent_entity l((int)v.x, (int)v.y, (int)v.z, LIGHT, reach, strength, 0, 0);
calclightsource(l);
postlightarea(b);
}