mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- allow 'const' on class functions. This is preferable to 'clearscope' so that the UI code can call getter functions without having to declare things as 'clearscope'.
Clearscope is a dangerous context and should be limited to the minimum extent possible and preferably be blocked in user code. This may still need some work on const functions but better have it in now.
This commit is contained in:
parent
5551f3a8c5
commit
b3ba5bfe2c
5 changed files with 14 additions and 10 deletions
|
@ -2141,10 +2141,14 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
|
||||
// [ZZ] supporting const self for actors is quite a cumbersome task because there's no concept of a const pointer (?)
|
||||
// either way, it doesn't make sense, because you can call any method on a readonly class instance.
|
||||
|
||||
// The above is nonsense. This needs to work and needs to be implemented properly.
|
||||
/*
|
||||
if ((f->Flags & ZCC_FuncConst) && (c->Type()->IsKindOf(RUNTIME_CLASS(PClass))))
|
||||
{
|
||||
Error(f, "'Const' on a method can only be used in structs");
|
||||
}
|
||||
*/
|
||||
|
||||
if ((f->Flags & ZCC_VarArg) && !(f->Flags & ZCC_Native))
|
||||
{
|
||||
|
|
|
@ -425,7 +425,7 @@ class Actor : Thinker native
|
|||
}
|
||||
}
|
||||
|
||||
clearscope virtual String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
|
||||
virtual String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) const
|
||||
{
|
||||
if (mod == 'Telefrag')
|
||||
{
|
||||
|
@ -450,13 +450,13 @@ class Actor : Thinker native
|
|||
native static int FindUniqueTid(int start = 0, int limit = 0);
|
||||
native void SetShade(color col);
|
||||
|
||||
clearscope native string GetTag(string defstr = "");
|
||||
native string GetTag(string defstr = "") const;
|
||||
native void SetTag(string defstr = "");
|
||||
native double GetBobOffset(double frac = 0);
|
||||
native void ClearCounters();
|
||||
native bool GiveBody (int num, int max=0);
|
||||
native bool HitFloor();
|
||||
clearscope native bool isTeammate(Actor other);
|
||||
native bool isTeammate(Actor other) const;
|
||||
native int PlayerNumber();
|
||||
native void SetFriendPlayer(PlayerInfo player);
|
||||
native void SoundAlert(Actor target, bool splash = false, double maxdist = 0);
|
||||
|
@ -597,7 +597,7 @@ class Actor : Thinker native
|
|||
native void ClearInventory();
|
||||
native bool GiveInventory(class<Inventory> type, int amount, bool givecheat = false);
|
||||
native bool TakeInventory(class<Inventory> itemclass, int amount, bool fromdecorate = false, bool notakeinfinite = false);
|
||||
clearscope native Inventory FindInventory(class<Inventory> itemtype, bool subclass = false);
|
||||
native Inventory FindInventory(class<Inventory> itemtype, bool subclass = false) const;
|
||||
native Inventory GiveInventoryType(class<Inventory> itemtype);
|
||||
native Inventory DropInventory (Inventory item, int amt = -1);
|
||||
native bool UseInventory(Inventory item);
|
||||
|
|
|
@ -285,7 +285,7 @@ class Powerup : Inventory
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
virtual clearscope bool isBlinking()
|
||||
virtual bool isBlinking() const
|
||||
{
|
||||
return (EffectTics <= BLINKTHRESHOLD && (EffectTics & 8) && !bNoScreenBlink);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class Weapon : StateProvider native
|
|||
return s;
|
||||
}
|
||||
|
||||
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
|
||||
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) const
|
||||
{
|
||||
// Weapons may never return HitObituary by default. Override this if it is needed.
|
||||
return Obituary;
|
||||
|
|
|
@ -119,7 +119,7 @@ class PlayerPawn : Actor native
|
|||
}
|
||||
}
|
||||
|
||||
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
|
||||
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) const
|
||||
{
|
||||
if (victim.player != player && victim.IsTeammate(self))
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ class PlayerPawn : Actor native
|
|||
}
|
||||
|
||||
// This is for SBARINFO.
|
||||
clearscope int, int GetEffectTicsForItem(class<Inventory> item)
|
||||
int, int GetEffectTicsForItem(class<Inventory> item) const
|
||||
{
|
||||
let pg = (class<PowerupGiver>)(item);
|
||||
if (pg != null)
|
||||
|
@ -167,10 +167,10 @@ class PlayerPawn : Actor native
|
|||
return -1, -1;
|
||||
}
|
||||
|
||||
clearscope native int GetMaxHealth(bool withupgrades = false);
|
||||
native int GetMaxHealth(bool withupgrades = false) const;
|
||||
native bool ResetAirSupply (bool playgasp = false);
|
||||
native void CheckWeaponSwitch(class<Inventory> item);
|
||||
clearscope native static String GetPrintableDisplayName(Class<Actor> cls);
|
||||
native clearscope static String GetPrintableDisplayName(Class<Actor> cls);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue