mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-29 06:01:37 +00:00
don't allow changing out-ness of parameters in virtual overrides
This commit is contained in:
parent
645dbcfa51
commit
d9c224439d
1 changed files with 23 additions and 2 deletions
|
@ -672,15 +672,36 @@ bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PTyp
|
|||
int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType, bool ignorePointerReadOnly)
|
||||
{
|
||||
auto proto = variant->Proto;
|
||||
auto &flags = variant->ArgFlags;
|
||||
for (unsigned i = 0; i < Virtuals.Size(); i++)
|
||||
{
|
||||
if (Virtuals[i]->Name == name)
|
||||
{
|
||||
auto vproto = Virtuals[i]->Proto;
|
||||
if (vproto->ReturnTypes.Size() != proto->ReturnTypes.Size() ||
|
||||
auto &vflags = Virtuals[i]->ArgFlags;
|
||||
|
||||
int n = flags.size();
|
||||
|
||||
bool flagsOk = true;
|
||||
|
||||
for(int i = 0; i < n; i++)
|
||||
{
|
||||
int argA = i >= vflags.size() ? 0 : vflags[i];
|
||||
int argB = i >= flags.size() ? 0 : flags[i];
|
||||
|
||||
bool AisRef = argA & (VARF_Out | VARF_Ref);
|
||||
bool BisRef = argB & (VARF_Out | VARF_Ref);
|
||||
|
||||
if(AisRef != BisRef)
|
||||
{
|
||||
flagsOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flagsOk || vproto->ReturnTypes.Size() != proto->ReturnTypes.Size() ||
|
||||
vproto->ArgumentTypes.Size() < proto->ArgumentTypes.Size())
|
||||
{
|
||||
|
||||
continue; // number of parameters does not match, so it's incompatible
|
||||
}
|
||||
bool fail = false;
|
||||
|
|
Loading…
Reference in a new issue