- block direct use of 'new' for DObjects.

This is to ensure that the Class pointer can be set right on creation. ZDoom had always depended on handling this lazily which poses some problems for the VM.
So now there is a variadic Create<classtype> function taking care of that, but to ensure that it gets used, direct access to the new operator has been blocked.

This also neccessitated making DArgs a regular object because they get created before the type system is up. Since the few uses of DArgs are easily controllable this wasn't a big issue.

- did a bit of optimization on the bots' decision making whether to pick up a health item or not.
This commit is contained in:
Christoph Oelckers 2017-04-14 13:31:58 +02:00
commit cd180d29c7
68 changed files with 384 additions and 341 deletions

View file

@ -282,7 +282,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
// new floor thinker
rtn = true;
floor = new DFloor(sec);
floor = Create<DFloor>(sec);
floor->m_Type = floortype;
floor->m_Crush = crush;
floor->m_Hexencrush = hexencrush;
@ -631,7 +631,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
// new floor thinker
rtn = true;
floor = new DFloor (sec);
floor = Create<DFloor> (sec);
floor->m_Direction = (type == DFloor::buildUp) ? 1 : -1;
stairstep = stairsize * floor->m_Direction;
floor->m_Type = DFloor::buildStair; //jff 3/31/98 do not leave uninited
@ -734,7 +734,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
secnum = newsecnum;
// create and initialize a thinker for the next step
floor = new DFloor (sec);
floor = Create<DFloor> (sec);
floor->StartFloorSound ();
floor->m_Direction = (type == DFloor::buildUp) ? 1 : -1;
floor->m_FloorDestDist = sec->floorplane.PointToDist (DVector2(0, 0), height);
@ -813,7 +813,7 @@ bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed)
s3 = ln->backsector;
// Spawn rising slime
floor = new DFloor (s2);
floor = Create<DFloor> (s2);
floor->m_Type = DFloor::donutRaise;
floor->m_Crush = -1;
floor->m_Hexencrush = false;
@ -828,7 +828,7 @@ bool EV_DoDonut (int tag, line_t *line, double pillarspeed, double slimespeed)
floor->StartFloorSound ();
// Spawn lowering donut-hole
floor = new DFloor (s1);
floor = Create<DFloor> (s1);
floor->m_Type = DFloor::floorLowerToNearest;
floor->m_Crush = -1;
floor->m_Hexencrush = false;
@ -1017,7 +1017,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
// create and initialize new elevator thinker
rtn = true;
elevator = new DElevator (sec);
elevator = Create<DElevator> (sec);
elevator->m_Type = elevtype;
elevator->m_Speed = speed;
elevator->StartFloorSound ();
@ -1327,12 +1327,12 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset,
retCode = true;
if (ceiling)
{
waggle = new DCeilingWaggle (sector);
waggle = Create<DCeilingWaggle> (sector);
waggle->m_OriginalDist = sector->ceilingplane.fD();
}
else
{
waggle = new DFloorWaggle (sector);
waggle = Create<DFloorWaggle> (sector);
waggle->m_OriginalDist = sector->floorplane.fD();
}
waggle->m_Accumulator = offset;