- scriptified PowerProtection and PowerDamage.
- made ModifyDamage calls iterative instead of recursive. With going through the VM they'd be too costly otherwise. - small optimization: Detect empty VM functions right when entering the VM and shortcut them. This is to reduce the overhead of virtual placeholders, which in a few cases (e.g. CanCollideWith and ModifyDamage) can be called quite frequently.
This commit is contained in:
parent
1d3afce59b
commit
9948189193
10 changed files with 204 additions and 177 deletions
|
|
@ -467,15 +467,30 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
|
|||
}
|
||||
else
|
||||
{
|
||||
VMCycles[0].Clock();
|
||||
VMCalls[0]++;
|
||||
AllocFrame(static_cast<VMScriptFunction *>(func));
|
||||
allocated = true;
|
||||
VMFillParams(params, TopFrame(), numparams);
|
||||
int numret = VMExec(this, static_cast<VMScriptFunction *>(func)->Code, results, numresults);
|
||||
PopFrame();
|
||||
VMCycles[0].Unclock();
|
||||
return numret;
|
||||
auto code = static_cast<VMScriptFunction *>(func)->Code;
|
||||
// handle empty functions consisting of a single return explicitly so that empty virtual callbacks do not need to set up an entire VM frame.
|
||||
if (code->word == 0x0080804e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (code->word == 0x0004804e)
|
||||
{
|
||||
if (numresults == 0) return 0;
|
||||
results[0].SetInt(static_cast<VMScriptFunction *>(func)->KonstD[0]);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
VMCycles[0].Clock();
|
||||
VMCalls[0]++;
|
||||
AllocFrame(static_cast<VMScriptFunction *>(func));
|
||||
allocated = true;
|
||||
VMFillParams(params, TopFrame(), numparams);
|
||||
int numret = VMExec(this, code, results, numresults);
|
||||
PopFrame();
|
||||
VMCycles[0].Unclock();
|
||||
return numret;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (VMException *exception)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue