forked from Mirrors/openclonk
C4Object: Visibility made a property
Accordingly, SetVisibility and GetVisibility have been removed. Specify visibility like obj->SetProperty("Visibility", VIS_Allies). VIS_Local has been renamed VIS_Select and uses an array: obj->SetProperty("Visibility", [VIS_Select, Plr0Visible, Plr1Visible, ...]) where Plr*Visible are of type bool.stable-5.2
parent
0efc4bd8df
commit
c511615376
|
@ -68,7 +68,7 @@
|
|||
#define VIS_Owner 2
|
||||
#define VIS_Allies 4
|
||||
#define VIS_Enemies 8
|
||||
#define VIS_Local 16
|
||||
#define VIS_Select 16
|
||||
#define VIS_God 32
|
||||
#define VIS_LayerToggle 64
|
||||
#define VIS_OverlayOnly 128
|
||||
|
@ -148,7 +148,6 @@ class C4Object: public C4PropList
|
|||
bool NeedEnergy;
|
||||
uint32_t t_contact; // SyncClearance-NoSave //
|
||||
uint32_t OCF;
|
||||
int32_t Visibility;
|
||||
unsigned int Marker; // state var used by Objects::CrossCheck and C4FindObject - NoSave
|
||||
union
|
||||
{
|
||||
|
|
|
@ -167,6 +167,7 @@ P_Name,
|
|||
P_Collectible,
|
||||
P_ActMap,
|
||||
P_Attach,
|
||||
P_Visibility,
|
||||
P_Procedure,
|
||||
P_Directions,
|
||||
P_FlipDir,
|
||||
|
|
|
@ -1399,7 +1399,7 @@ C4Object *C4Game::FindVisObject(float tx, float ty, int32_t iPlr, const C4Facet
|
|||
// Owner
|
||||
if ((iOwner==ANY_OWNER) || (cObj->Owner==iOwner))
|
||||
// Visibility
|
||||
if (!cObj->Visibility || cObj->IsVisible(iPlr, false))
|
||||
if (cObj->IsVisible(iPlr, false))
|
||||
// Area
|
||||
{
|
||||
// Layer check: Layered objects are invisible to players whose cursor is in another layer
|
||||
|
|
|
@ -147,7 +147,6 @@ void C4Object::Default()
|
|||
PhysicalTemporary=false;
|
||||
TemporaryPhysical.Default();
|
||||
MaterialContents=NULL;
|
||||
Visibility=VIS_All;
|
||||
LocalNamed.Reset();
|
||||
Marker=0;
|
||||
ColorMod=BlitMode=0;
|
||||
|
@ -2218,7 +2217,7 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
|
|||
if (!Status || !Def) return;
|
||||
|
||||
// visible?
|
||||
if (Visibility || pLayer) if(!IsVisible(iByPlayer, !!eDrawMode)) return;
|
||||
if(!IsVisible(iByPlayer, !!eDrawMode)) return;
|
||||
|
||||
// Line
|
||||
if (Def->Line) { DrawLine(cgo); return; }
|
||||
|
@ -2493,7 +2492,7 @@ void C4Object::DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDraw
|
|||
// Status
|
||||
if (!Status || !Def) return;
|
||||
// visible?
|
||||
if (Visibility) if(!IsVisible(iByPlayer, eDrawMode==ODM_Overlay)) return;
|
||||
if(!IsVisible(iByPlayer, eDrawMode==ODM_Overlay)) return;
|
||||
// target pos (parallax)
|
||||
float cotx = cgo.TargetX, coty = cgo.TargetY; if (eDrawMode!=ODM_Overlay) TargetPos(cotx, coty, cgo);
|
||||
// Clonk name
|
||||
|
@ -2738,7 +2737,6 @@ void C4Object::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt( Component, "Component" ));
|
||||
pComp->Value(mkNamingAdapt( Contents, "Contents" ));
|
||||
pComp->Value(mkNamingAdapt( PlrViewRange, "PlrViewRange", 0 ));
|
||||
pComp->Value(mkNamingAdapt( Visibility, "Visibility", VIS_All ));
|
||||
pComp->Value(mkNamingAdapt( LocalNamed, "LocalNamed" ));
|
||||
pComp->Value(mkNamingAdapt( ColorMod, "ColorMod", 0u ));
|
||||
pComp->Value(mkNamingAdapt( BlitMode, "BlitMode", 0u ));
|
||||
|
@ -5421,34 +5419,48 @@ void C4Object::SetAudibilityAt(C4TargetFacet &cgo, int32_t iX, int32_t iY)
|
|||
bool C4Object::IsVisible(int32_t iForPlr, bool fAsOverlay)
|
||||
{
|
||||
bool fDraw;
|
||||
C4Value vis;
|
||||
if (!GetProperty(Strings.P[P_Visibility], vis))
|
||||
return true;
|
||||
|
||||
int32_t Visibility;
|
||||
C4ValueArray *parameters = vis.getArray();
|
||||
if (parameters && parameters->GetSize())
|
||||
{
|
||||
Visibility = parameters->GetItem(0).getInt();
|
||||
} else {
|
||||
Visibility = vis.getInt();
|
||||
}
|
||||
// check overlay
|
||||
if (Visibility & VIS_OverlayOnly)
|
||||
{
|
||||
{
|
||||
if (!fAsOverlay) return false;
|
||||
if (Visibility == VIS_OverlayOnly) return true;
|
||||
}
|
||||
}
|
||||
// check layer
|
||||
if (pLayer && pLayer != this && !fAsOverlay)
|
||||
{
|
||||
{
|
||||
fDraw = pLayer->IsVisible(iForPlr, false);
|
||||
if (pLayer->Visibility & VIS_LayerToggle) fDraw = !fDraw;
|
||||
if (pLayer->GetPropertyInt(P_Visibility) & VIS_LayerToggle) fDraw = !fDraw;
|
||||
if (!fDraw) return false;
|
||||
}
|
||||
}
|
||||
// no flags set?
|
||||
if (!Visibility) return true;
|
||||
// check visibility
|
||||
fDraw=false;
|
||||
if (Visibility & VIS_Owner) fDraw = fDraw || (iForPlr==Owner);
|
||||
if (iForPlr!=NO_OWNER)
|
||||
{
|
||||
{
|
||||
// check all
|
||||
if (Visibility & VIS_Allies) fDraw = fDraw || (iForPlr!=Owner && !Hostile(iForPlr, Owner));
|
||||
if (Visibility & VIS_Enemies) fDraw = fDraw || (iForPlr!=Owner && Hostile(iForPlr, Owner));
|
||||
if (Visibility & VIS_Local) fDraw = fDraw || (Local[iForPlr/32].getInt() & (1<<(iForPlr%32)));
|
||||
if (parameters) {
|
||||
if (Visibility & VIS_Select) fDraw = fDraw || parameters->GetItem(1+iForPlr).getBool();
|
||||
}
|
||||
}
|
||||
else fDraw = fDraw || (Visibility & VIS_God);
|
||||
return fDraw;
|
||||
}
|
||||
}
|
||||
|
||||
bool C4Object::IsInLiquidCheck()
|
||||
{
|
||||
|
|
|
@ -3606,25 +3606,6 @@ static C4Value FnSetLength(C4AulContext *cthr, C4Value *pPars)
|
|||
return C4VBool(true);
|
||||
}
|
||||
|
||||
static bool FnSetVisibility(C4AulContext *cthr, long iVisibility, C4Object *pObj)
|
||||
{
|
||||
// local call/safety
|
||||
if(!pObj) pObj = cthr->Obj;
|
||||
if(!pObj) return FALSE;
|
||||
|
||||
pObj->Visibility=iVisibility;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static long FnGetVisibility(C4AulContext *cthr, C4Object *pObj)
|
||||
{
|
||||
if(!pObj) pObj = cthr->Obj;
|
||||
if(!pObj) return 0;
|
||||
|
||||
return pObj->Visibility;
|
||||
}
|
||||
|
||||
static bool FnSetClrModulation(C4AulContext *cthr, long dwClr, C4Object *pObj, long iOverlayID)
|
||||
{
|
||||
// local call/safety
|
||||
|
@ -6167,8 +6148,6 @@ void InitFunctionMap(C4AulScriptEngine *pEngine)
|
|||
AddFunc(pEngine, "ShowInfo", FnShowInfo);
|
||||
AddFunc(pEngine, "GetTime", FnGetTime);
|
||||
AddFunc(pEngine, "GetSystemTime", FnGetSystemTime, false);
|
||||
AddFunc(pEngine, "SetVisibility", FnSetVisibility);
|
||||
AddFunc(pEngine, "GetVisibility", FnGetVisibility);
|
||||
AddFunc(pEngine, "SetClrModulation", FnSetClrModulation);
|
||||
AddFunc(pEngine, "GetClrModulation", FnGetClrModulation);
|
||||
AddFunc(pEngine, "GetMissionAccess", FnGetMissionAccess);
|
||||
|
@ -6384,7 +6363,7 @@ C4ScriptConstDef C4ScriptConstMap[]={
|
|||
{ "VIS_Owner" ,C4V_Int, VIS_Owner},
|
||||
{ "VIS_Allies" ,C4V_Int, VIS_Allies},
|
||||
{ "VIS_Enemies" ,C4V_Int, VIS_Enemies},
|
||||
{ "VIS_Local" ,C4V_Int, VIS_Local},
|
||||
{ "VIS_Select" ,C4V_Int, VIS_Select},
|
||||
{ "VIS_God" ,C4V_Int, VIS_God},
|
||||
{ "VIS_LayerToggle" ,C4V_Int, VIS_LayerToggle},
|
||||
{ "VIS_OverlayOnly" ,C4V_Int, VIS_OverlayOnly},
|
||||
|
|
|
@ -114,6 +114,7 @@ C4StringTable::C4StringTable()
|
|||
P[P_TurnAction] = RegString("TurnAction");
|
||||
P[P_Reverse] = RegString("Reverse");
|
||||
P[P_Step] = RegString("Step");
|
||||
P[P_Visibility] = RegString("Visibility");
|
||||
for (unsigned int i = 0; i < P_LAST; ++i) P[i]->IncRef();
|
||||
}
|
||||
|
||||
|
@ -150,6 +151,7 @@ C4String *C4StringTable::FindString(C4String *pString)
|
|||
for (C4String * const * i = Set.First(); i; i = Set.Next(i))
|
||||
if (*i == pString)
|
||||
return pString;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
C4String *C4StringTable::FindString(int iEnumID)
|
||||
|
|
Loading…
Reference in New Issue