- 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:
parent
929affa3cb
commit
cd180d29c7
68 changed files with 384 additions and 341 deletions
|
|
@ -1873,7 +1873,7 @@ void FParser::SF_FadeLight(void)
|
|||
FSectorTagIterator it(sectag);
|
||||
while ((i = it.Next()) >= 0)
|
||||
{
|
||||
if (!level.sectors[i].lightingdata) new DLightLevel(&level.sectors[i],destlevel,speed);
|
||||
if (!level.sectors[i].lightingdata) Create<DLightLevel>(&level.sectors[i],destlevel,speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4036,7 +4036,7 @@ DRunningScript *FParser::SaveCurrentScript()
|
|||
DFraggleThinker *th = DFraggleThinker::ActiveThinker;
|
||||
if (th)
|
||||
{
|
||||
DRunningScript *runscr = new DRunningScript(Script->trigger, Script, Script->MakeIndex(Rover));
|
||||
DRunningScript *runscr = Create<DRunningScript>(Script->trigger, Script, Script->MakeIndex(Rover));
|
||||
|
||||
// hook into chain at start
|
||||
th->AddRunningScript(runscr);
|
||||
|
|
@ -4170,7 +4170,7 @@ void FParser::SF_StartScript()
|
|||
script_error("script %i not defined\n", snum);
|
||||
}
|
||||
|
||||
DRunningScript *runscr = new DRunningScript(Script->trigger, script, 0);
|
||||
DRunningScript *runscr = Create<DRunningScript>(Script->trigger, script, 0);
|
||||
// hook into chain at start
|
||||
th->AddRunningScript(runscr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ bool FScriptLoader::ParseInfo(MapData * map)
|
|||
}
|
||||
if (HasScripts)
|
||||
{
|
||||
new DFraggleThinker;
|
||||
Create<DFraggleThinker>();
|
||||
DFraggleThinker::ActiveThinker->LevelScript->data = copystring(scriptsrc.GetChars());
|
||||
|
||||
if (drownflag==-1) drownflag = (level.maptype != MAPTYPE_DOOM || fsglobal);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ void DFsScript::ClearSections()
|
|||
DFsSection *DFsScript::NewSection(const char *brace)
|
||||
{
|
||||
int n = section_hash(brace);
|
||||
DFsSection *newsec = new DFsSection;
|
||||
DFsSection *newsec = Create<DFsSection>();
|
||||
|
||||
newsec->start_index = MakeIndex(brace);
|
||||
newsec->next = sections[n];
|
||||
|
|
|
|||
|
|
@ -406,8 +406,8 @@ DFraggleThinker::DFraggleThinker()
|
|||
else
|
||||
{
|
||||
ActiveThinker = this;
|
||||
RunningScripts = new DRunningScript;
|
||||
LevelScript = new DFsScript;
|
||||
RunningScripts = Create<DRunningScript>();
|
||||
LevelScript = Create<DFsScript>();
|
||||
LevelScript->parent = global_script;
|
||||
GC::WriteBarrier(this, RunningScripts);
|
||||
GC::WriteBarrier(this, LevelScript);
|
||||
|
|
@ -669,7 +669,7 @@ bool T_RunScript(int snum, AActor * t_trigger)
|
|||
DFsScript *script = th->LevelScript->children[snum];
|
||||
if(!script) return false;
|
||||
|
||||
DRunningScript *runscr = new DRunningScript(t_trigger, script, 0);
|
||||
DRunningScript *runscr = Create<DRunningScript>(t_trigger, script, 0);
|
||||
// hook into chain at start
|
||||
th->AddRunningScript(runscr);
|
||||
return true;
|
||||
|
|
@ -699,7 +699,7 @@ void T_Init()
|
|||
|
||||
if (global_script == NULL)
|
||||
{
|
||||
global_script = new DFsScript;
|
||||
global_script = Create<DFsScript>();
|
||||
GC::AddSoftRoot(global_script);
|
||||
init_functions();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ void FParser::spec_script()
|
|||
return;
|
||||
}
|
||||
|
||||
newscript = new DFsScript;
|
||||
newscript = Create<DFsScript>();
|
||||
|
||||
// add to scripts list of parent
|
||||
Script->children[scriptnum] = newscript;
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ void DFsVariable::Serialize(FSerializer & ar)
|
|||
|
||||
DFsVariable *DFsScript::NewVariable(const char *name, int vtype)
|
||||
{
|
||||
DFsVariable *newvar = new DFsVariable(name);
|
||||
DFsVariable *newvar = Create<DFsVariable>(name);
|
||||
newvar->type = vtype;
|
||||
|
||||
int n = variable_hash(name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue