forked from Mirrors/openclonk
C4Value does not store C4IDs anymore
Instead, C4IDs are converted from/to C4PropLists. This will have to change, of course. Objects can be created from prototypes which only inherit from C4Defstable-5.2
parent
b9f398b111
commit
c420a3bf3b
|
@ -294,6 +294,7 @@ class C4Def: public C4PropList
|
|||
void Synchronize();
|
||||
#endif
|
||||
const char *GetDesc() { return Desc.GetData(); }
|
||||
virtual C4Def* GetDef() { return this; }
|
||||
protected:
|
||||
bool LoadPortraits(C4Group &hGroup);
|
||||
BOOL ColorizeByMaterial(class C4MaterialMap &rMats, BYTE bGBM);
|
||||
|
|
|
@ -237,10 +237,13 @@ class C4Game
|
|||
BOOL ReloadParticle(const char *szName);
|
||||
// Object functions
|
||||
void ClearPointers(C4PropList *cobj);
|
||||
C4Object *CreateObject(C4PropList * type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
int32_t x=50, int32_t y=50, int32_t r=0,
|
||||
FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER);
|
||||
C4Object *CreateObject(C4ID type, C4Object *pCreator, int32_t owner=NO_OWNER,
|
||||
int32_t x=50, int32_t y=50, int32_t r=0,
|
||||
FIXED xdir=Fix0, FIXED ydir=Fix0, FIXED rdir=Fix0, int32_t iController=NO_OWNER);
|
||||
C4Object *CreateObjectConstruction(C4ID type,
|
||||
C4Object *CreateObjectConstruction(C4PropList * type,
|
||||
C4Object *pCreator,
|
||||
int32_t owner,
|
||||
int32_t ctx=0, int32_t bty=0,
|
||||
|
@ -341,7 +344,7 @@ class C4Game
|
|||
BOOL RecreatePlayerFiles();
|
||||
|
||||
// Object function internals
|
||||
C4Object *NewObject( C4Def *ndef, C4Object *pCreator,
|
||||
C4Object *NewObject( C4PropList *ndef, C4Object *pCreator,
|
||||
int32_t owner, C4ObjectInfo *info,
|
||||
int32_t tx, int32_t ty, int32_t tr,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir,
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
|
||||
#include <StdAdaptors.h>
|
||||
|
||||
// Use 64 Bit for C4ID (on x86_64) to pass 64 bit for each script function
|
||||
// parameter
|
||||
|
||||
class C4ID
|
||||
{
|
||||
uint32_t v;
|
||||
|
|
|
@ -246,6 +246,6 @@ BOOL FindThrowingPosition(int32_t iTx, int32_t iTy, FIXED fXDir, FIXED fYDir, in
|
|||
BOOL PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix=NULL, int32_t *iy=NULL);
|
||||
BOOL PathFreeIgnoreVehicle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix=NULL, int32_t *iy=NULL);
|
||||
BOOL FindClosestFree(int32_t &rX, int32_t &rY, int32_t iAngle1, int32_t iAngle2, int32_t iExcludeAngle1, int32_t iExcludeAngle2);
|
||||
BOOL ConstructionCheck(C4ID id, int32_t iX, int32_t iY, C4Object *pByObj=NULL);
|
||||
BOOL ConstructionCheck(C4PropList *, int32_t iX, int32_t iY, C4Object *pByObj=NULL);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -231,7 +231,7 @@ class C4Object: public C4PropList
|
|||
void DenumeratePointers();
|
||||
void EnumeratePointers();
|
||||
void Default();
|
||||
BOOL Init(C4Def *ndef, C4Object *pCreator,
|
||||
BOOL Init(C4PropList *ndef, C4Object *pCreator,
|
||||
int32_t owner, C4ObjectInfo *info,
|
||||
int32_t nx, int32_t ny, int32_t nr,
|
||||
FIXED nxdir, FIXED nydir, FIXED nrdir, int32_t iController);
|
||||
|
@ -316,7 +316,7 @@ class C4Object: public C4PropList
|
|||
BOOL Push(FIXED txdir, FIXED dforce, BOOL fStraighten);
|
||||
BOOL Lift(FIXED tydir, FIXED dforce);
|
||||
void Fling(FIXED txdir, FIXED tydir, bool fAddSpeed); // set/add given speed to current, setting jump/tumble-actions
|
||||
C4Object* CreateContents(C4ID n_id);
|
||||
C4Object* CreateContents(C4PropList *);
|
||||
BOOL CreateContentsByList(C4IDList &idlist);
|
||||
BYTE GetArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt);
|
||||
inline int32_t addtop() { return Max<int32_t>(18-Shape.Hgt,0); } // Minimum top action size for build check
|
||||
|
|
|
@ -24,6 +24,9 @@ class C4PropList {
|
|||
const char *GetName();
|
||||
virtual void SetName (const char *NewName = 0);
|
||||
|
||||
virtual C4Def * GetDef();
|
||||
C4PropList * GetPrototype() { return prototype; }
|
||||
|
||||
bool GetProperty(C4String * k, C4Value & to);
|
||||
C4String * GetPropertyStr(C4PropertyName k);
|
||||
int32_t GetPropertyInt(C4PropertyName k);
|
||||
|
|
|
@ -34,14 +34,13 @@ enum C4V_Type
|
|||
C4V_Any=0, // unknown / no type
|
||||
C4V_Int=1, // Integer
|
||||
C4V_Bool=2, // Boolean
|
||||
C4V_C4ID=3, // C4ID
|
||||
C4V_PropList=3,
|
||||
C4V_C4Object=4, // Pointer on Object
|
||||
C4V_String=5, // String
|
||||
C4V_Array=6, // pointer on array of values
|
||||
C4V_PropList=7,
|
||||
C4V_pC4Value=8, // reference on a value (variable)
|
||||
C4V_pC4Value=7, // reference on a value (variable)
|
||||
|
||||
C4V_C4ObjectEnum=9, // enumerated object
|
||||
C4V_C4ObjectEnum=8, // enumerated object
|
||||
};
|
||||
|
||||
#define C4V_Last (int) C4V_pC4Value
|
||||
|
@ -102,9 +101,9 @@ public:
|
|||
|
||||
// Checked getters
|
||||
int32_t getInt() { return ConvertTo(C4V_Int) ? Data.Int : 0; }
|
||||
int32_t getIntOrID() { Deref(); if (Type == C4V_Int || Type == C4V_Bool || Type == C4V_C4ID) return Data.Int; else return 0; }
|
||||
int32_t getIntOrID() { Deref(); if (Type == C4V_Int || Type == C4V_Bool /* FIXME || Type == C4V_C4ID*/) return Data.Int; else return 0; }
|
||||
bool getBool() { return ConvertTo(C4V_Bool) ? !! Data : 0; }
|
||||
C4ID getC4ID() { return ConvertTo(C4V_C4ID) ? Data.Int : 0; }
|
||||
C4ID getC4ID();
|
||||
C4Object * getObj() { return ConvertTo(C4V_C4Object) ? Data.Obj : NULL; }
|
||||
C4PropList * getPropList() { return ConvertTo(C4V_PropList) ? Data.PropList : NULL; }
|
||||
C4String * getStr() { return ConvertTo(C4V_String) ? Data.Str : NULL; }
|
||||
|
@ -114,7 +113,6 @@ public:
|
|||
// Unchecked getters
|
||||
int32_t _getInt() const { return Data.Int; }
|
||||
bool _getBool() const { return !! Data.Int; }
|
||||
C4ID _getC4ID() const { return Data.Int; }
|
||||
C4Object *_getObj() const { return Data.Obj; }
|
||||
C4String *_getStr() const { return Data.Str; }
|
||||
C4ValueArray *_getArray() const { return Data.Array; }
|
||||
|
@ -134,8 +132,6 @@ public:
|
|||
|
||||
void SetBool(bool b) { C4V_Data d; d.Int = b; Set(d, C4V_Bool); }
|
||||
|
||||
void SetC4ID(C4ID id) { C4V_Data d; d.Int = id; Set(d, C4V_C4ID); }
|
||||
|
||||
void SetObject(C4Object * Obj) { C4V_Data d; d.Obj = Obj; Set(d, C4V_C4Object); }
|
||||
|
||||
void SetString(C4String * Str) { C4V_Data d; d.Str = Str; Set(d, C4V_String); }
|
||||
|
@ -241,7 +237,7 @@ protected:
|
|||
// converter
|
||||
inline C4Value C4VInt(int32_t iVal) { C4V_Data d; d.Int = iVal; return C4Value(d, C4V_Int); }
|
||||
inline C4Value C4VBool(bool fVal) { C4V_Data d; d.Int = fVal; return C4Value(d, C4V_Bool); }
|
||||
inline C4Value C4VID(C4ID iVal) { C4V_Data d; d.Int = iVal; return C4Value(d, C4V_C4ID); }
|
||||
C4Value C4VID(C4ID iVal);
|
||||
inline C4Value C4VObj(C4Object *pObj) { return C4Value(pObj); }
|
||||
inline C4Value C4VPropList(C4PropList * p) { return C4Value(p); }
|
||||
inline C4Value C4VString(C4String *pStr) { return C4Value(pStr); }
|
||||
|
@ -268,9 +264,9 @@ template <> struct C4ValueConv<bool>
|
|||
};
|
||||
template <> struct C4ValueConv<C4ID>
|
||||
{
|
||||
inline static C4V_Type Type() { return C4V_C4ID; }
|
||||
inline static C4V_Type Type() { return C4V_PropList; }
|
||||
inline static C4ID FromC4V(C4Value &v) { return v.getC4ID(); }
|
||||
inline static C4ID _FromC4V(C4Value &v) { return v._getC4ID(); }
|
||||
inline static C4ID _FromC4V(C4Value &v) { return FromC4V(v); }
|
||||
inline static C4Value ToC4V(C4ID v) { return C4VID(v); }
|
||||
};
|
||||
template <> struct C4ValueConv<C4Object *>
|
||||
|
|
|
@ -343,7 +343,7 @@ C4Value C4AulExec::Exec(C4AulBCC *pCPos, bool fPassErrors)
|
|||
break;
|
||||
|
||||
case AB_C4ID:
|
||||
PushValue(C4VID(pCPos->Par.i));
|
||||
PushValue(C4VPropList(C4Id2Def(pCPos->Par.i)));
|
||||
break;
|
||||
|
||||
case AB_EOFN:
|
||||
|
@ -980,15 +980,15 @@ C4Value C4AulExec::Exec(C4AulBCC *pCPos, bool fPassErrors)
|
|||
pDestObj = pTargetVal->_getObj();
|
||||
pDestDef = pDestObj->Def;
|
||||
}
|
||||
else if(pTargetVal->ConvertTo(C4V_C4ID))
|
||||
else if(pTargetVal->ConvertTo(C4V_PropList) && pTargetVal->_getPropList())
|
||||
{
|
||||
// definition call
|
||||
pDestObj = NULL;
|
||||
pDestDef = C4Id2Def(pTargetVal->_getC4ID());
|
||||
pDestDef = pTargetVal->_getPropList()->GetDef();
|
||||
// definition must be known
|
||||
if(!pDestDef)
|
||||
throw new C4AulExecError(pCurCtx->Obj,
|
||||
FormatString("Definition call: Definition for id %s not found!", C4IdText(pTargetVal->_getC4ID())).getData());
|
||||
FormatString("Definition call: Definition for %s not found!", pTargetVal->_getPropList()->GetName()).getData());
|
||||
}
|
||||
else
|
||||
throw new C4AulExecError(pCurCtx->Obj,
|
||||
|
|
|
@ -1574,7 +1574,7 @@ void C4AulParseState::Parse_FuncHead()
|
|||
// type identifier?
|
||||
if (SEqual(Idtf, C4AUL_TypeInt)) { Fn->ParType[cpar] = C4V_Int; Shift(Discard,false); }
|
||||
else if (SEqual(Idtf, C4AUL_TypeBool)) { Fn->ParType[cpar] = C4V_Bool; Shift(Discard,false); }
|
||||
else if (SEqual(Idtf, C4AUL_TypeC4ID)) { Fn->ParType[cpar] = C4V_C4ID; Shift(Discard,false); }
|
||||
else if (SEqual(Idtf, C4AUL_TypeC4ID)) { Fn->ParType[cpar] = C4V_PropList; Shift(Discard,false); }
|
||||
else if (SEqual(Idtf, C4AUL_TypeC4Object)) { Fn->ParType[cpar] = C4V_C4Object; Shift(Discard,false); }
|
||||
else if (SEqual(Idtf, C4AUL_TypePropList)) { Fn->ParType[cpar] = C4V_PropList; Shift(Discard,false); }
|
||||
else if (SEqual(Idtf, C4AUL_TypeString)) { Fn->ParType[cpar] = C4V_String; Shift(Discard,false); }
|
||||
|
@ -2687,7 +2687,7 @@ void C4AulParseState::Parse_Expression(int iParentPrio)
|
|||
case C4V_String:
|
||||
AddBCC(AB_STRING, reinterpret_cast<intptr_t>(val._getStr()));
|
||||
break;
|
||||
case C4V_C4ID: AddBCC(AB_C4ID, val.GetData().Int); break;
|
||||
case C4V_PropList: AddBCC(AB_C4ID, C4ValueConv<C4ID>::FromC4V(val)); break;
|
||||
case C4V_Any:
|
||||
// any: allow zero; add it as int
|
||||
if (!val.GetData())
|
||||
|
@ -3130,7 +3130,7 @@ void C4AulParseState::Parse_Const()
|
|||
case ATT_INT: vGlobalValue.SetInt(cInt); break;
|
||||
case ATT_BOOL: vGlobalValue.SetBool(!!cInt); break;
|
||||
case ATT_STRING: vGlobalValue.SetString(reinterpret_cast<C4String *>(cInt)); break; // increases ref count of C4String in cInt to 1
|
||||
case ATT_C4ID: vGlobalValue.SetC4ID(cInt); break;
|
||||
//FIXME case ATT_C4ID: vGlobalValue.SetC4ID(cInt); break;
|
||||
case ATT_IDTF:
|
||||
// identifier is only OK if it's another constant
|
||||
if (!a->Engine->GetGlobalConstant(Idtf, &vGlobalValue))
|
||||
|
|
|
@ -1667,12 +1667,12 @@ void C4Command::Construct()
|
|||
{ cObj->AddCommand(C4CMD_MoveTo,NULL,Tx,Ty,50); return; }
|
||||
|
||||
// Check construction site
|
||||
if (!ConstructionCheck(Data,Tx._getInt(),Ty,cObj))
|
||||
if (!ConstructionCheck(C4Id2Def(Data),Tx._getInt(),Ty,cObj))
|
||||
// Site no good: fail
|
||||
{ Finish(); return; }
|
||||
|
||||
// Create construction
|
||||
C4Object *pConstruction = Game.CreateObjectConstruction(Data,NULL,cObj->Owner,Tx._getInt(),Ty,1,TRUE);
|
||||
C4Object *pConstruction = Game.CreateObjectConstruction(C4Id2Def(Data),NULL,cObj->Owner,Tx._getInt(),Ty,1,TRUE);
|
||||
|
||||
// Remove conkit
|
||||
pKit->AssignRemoval();
|
||||
|
|
|
@ -883,7 +883,7 @@ void C4ControlEMMoveObject::Execute() const
|
|||
for (int i=0; i<iObjectNum; ++i)
|
||||
if (pObj = Game.Objects.SafeObjectPointer(pObjects[i]))
|
||||
{
|
||||
pObj = Game.CreateObject(pObj->id, pObj, pObj->Owner, pObj->GetX(), pObj->GetY());
|
||||
pObj = Game.CreateObject(pObj->GetPrototype(), pObj, pObj->Owner, pObj->GetX(), pObj->GetY());
|
||||
if (pObj && fLocalCall) Console.EditCursor.GetSelection().Add(pObj, C4ObjectList::stNone);
|
||||
}
|
||||
// update status
|
||||
|
|
|
@ -842,7 +842,7 @@ void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr)
|
|||
// Create smoke
|
||||
level=BoundBy<int32_t>(level,3,32);
|
||||
C4Object *pObj;
|
||||
if (pObj = Game.CreateObjectConstruction(C4Id("FXS1"),NULL,NO_OWNER,tx,ty,FullCon*level/32))
|
||||
if (pObj = Game.CreateObjectConstruction(C4Id2Def(C4Id("FXS1")),NULL,NO_OWNER,tx,ty,FullCon*level/32))
|
||||
pObj->Call(PSF_Activate);
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ void Explosion(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t i
|
|||
Game.Particles.Cast(Game.Particles.pFSpark, level/5+1, (float) tx, (float) ty, level, level/2+1.0f, 0x00ef0000, level+1.0f, 0xffff1010);
|
||||
}
|
||||
else
|
||||
if (pBlast = Game.CreateObjectConstruction(idEffect ? idEffect : C4Id("FXB1"),pByObj,iCausedBy,tx,ty+level,FullCon*level/20))
|
||||
if (pBlast = Game.CreateObjectConstruction(C4Id2Def(idEffect ? idEffect : C4Id("FXB1")),pByObj,iCausedBy,tx,ty+level,FullCon*level/20))
|
||||
pBlast->Call(PSF_Activate);
|
||||
}
|
||||
// Blast objects
|
||||
|
|
|
@ -1012,7 +1012,7 @@ bool C4Game::IsPaused()
|
|||
}
|
||||
|
||||
|
||||
C4Object* C4Game::NewObject( C4Def *pDef, C4Object *pCreator,
|
||||
C4Object* C4Game::NewObject( C4PropList *pDef, C4Object *pCreator,
|
||||
int32_t iOwner, C4ObjectInfo *pInfo,
|
||||
int32_t iX, int32_t iY, int32_t iR,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir,
|
||||
|
@ -1076,7 +1076,22 @@ C4Object* C4Game::CreateObject(C4ID id, C4Object *pCreator, int32_t iOwner,
|
|||
FullCon, iController);
|
||||
}
|
||||
|
||||
C4Object* C4Game::CreateInfoObject(C4ObjectInfo *cinf, int32_t iOwner,
|
||||
C4Object* C4Game::CreateObject(C4PropList * PropList, C4Object *pCreator, int32_t iOwner,
|
||||
int32_t x, int32_t y, int32_t r,
|
||||
FIXED xdir, FIXED ydir, FIXED rdir, int32_t iController)
|
||||
{
|
||||
C4Def *pDef;
|
||||
// Get pDef
|
||||
if (!PropList || !(pDef=PropList->GetDef())) return NULL;
|
||||
// Create object
|
||||
return NewObject(pDef,pCreator,
|
||||
iOwner,NULL,
|
||||
x,y,r,
|
||||
xdir,ydir,rdir,
|
||||
FullCon, iController);
|
||||
}
|
||||
|
||||
C4Object* C4Game::CreateInfoObject(C4ObjectInfo *cinf, int32_t iOwner,
|
||||
int32_t tx, int32_t ty)
|
||||
{
|
||||
C4Def *def;
|
||||
|
@ -1092,18 +1107,19 @@ C4Object* C4Game::CreateInfoObject(C4ObjectInfo *cinf, int32_t iOwner,
|
|||
FullCon, NO_OWNER );
|
||||
}
|
||||
|
||||
C4Object* C4Game::CreateObjectConstruction(C4ID id,
|
||||
C4Object *pCreator,
|
||||
C4Object* C4Game::CreateObjectConstruction(C4PropList * PropList,
|
||||
C4Object *pCreator,
|
||||
int32_t iOwner,
|
||||
int32_t iX, int32_t iBY,
|
||||
int32_t iCon,
|
||||
BOOL fTerrain)
|
||||
BOOL fTerrain)
|
||||
{
|
||||
C4Def *pDef;
|
||||
C4Object *pObj;
|
||||
|
||||
// Get def
|
||||
if (!(pDef=C4Id2Def(id))) return NULL;
|
||||
if (!PropList) return NULL;
|
||||
if (!(pDef=PropList->GetDef())) return NULL;
|
||||
|
||||
int32_t dx,dy,dwdt,dhgt;
|
||||
dwdt=pDef->Shape.Wdt; dhgt=pDef->Shape.Hgt;
|
||||
|
@ -2695,7 +2711,7 @@ C4Object* C4Game::PlaceVegetation(C4ID id, int32_t iX, int32_t iY, int32_t iWdt,
|
|||
{
|
||||
if (!pDef->Growth) iGrowth=FullCon;
|
||||
iTy+=5;
|
||||
return CreateObjectConstruction(id,NULL,NO_OWNER,iTx,iTy,iGrowth);
|
||||
return CreateObjectConstruction(C4Id2Def(id),NULL,NO_OWNER,iTx,iTy,iGrowth);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2712,7 +2728,7 @@ C4Object* C4Game::PlaceVegetation(C4ID id, int32_t iX, int32_t iY, int32_t iWdt,
|
|||
if (!SemiAboveSolid(iTx,iTy)) return NULL;
|
||||
iTy+=3;
|
||||
// Create object
|
||||
return CreateObjectConstruction(id,NULL,NO_OWNER,iTx,iTy,iGrowth);
|
||||
return CreateObjectConstruction(C4Id2Def(id),NULL,NO_OWNER,iTx,iTy,iGrowth);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2063,51 +2063,44 @@ BOOL FindClosestFree(int32_t &rX, int32_t &rY, int32_t iAngle1, int32_t iAngle2,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL ConstructionCheck(C4ID id, int32_t iX, int32_t iY, C4Object *pByObj)
|
||||
{
|
||||
C4Def *ndef;
|
||||
char idostr[5];
|
||||
|
||||
// Check def
|
||||
if (!(ndef=C4Id2Def(id)))
|
||||
{
|
||||
GetC4IdText(id,idostr);
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_UNDEF"),idostr).getData(),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Constructable?
|
||||
if (!ndef->Constructable)
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCON"),ndef->GetName()).getData(),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check area
|
||||
int32_t rtx,rty,wdt,hgt;
|
||||
wdt=ndef->Shape.Wdt; hgt=ndef->Shape.Hgt-ndef->ConSizeOff;
|
||||
rtx=iX-wdt/2; rty=iY-hgt;
|
||||
if (Game.Landscape.AreaSolidCount(rtx,rty,wdt,hgt)>(wdt*hgt/20))
|
||||
{
|
||||
if (pByObj) GameMsgObject(LoadResStr("IDS_OBJ_NOROOM"),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
if (Game.Landscape.AreaSolidCount(rtx,rty+hgt,wdt,5)<(wdt*2))
|
||||
{
|
||||
if (pByObj) GameMsgObject(LoadResStr("IDS_OBJ_NOLEVEL"),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check other structures
|
||||
C4Object *other;
|
||||
if (other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->Category))
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL ConstructionCheck(C4PropList * PropList, int32_t iX, int32_t iY, C4Object *pByObj)
|
||||
{
|
||||
C4Def *ndef;
|
||||
// Check def
|
||||
if (!(ndef=PropList->GetDef()))
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_UNDEF"), PropList->GetName()).getData(),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
// Constructable?
|
||||
if (!ndef->Constructable)
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCON"),ndef->GetName()).getData(),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
// Check area
|
||||
int32_t rtx,rty,wdt,hgt;
|
||||
wdt=ndef->Shape.Wdt; hgt=ndef->Shape.Hgt-ndef->ConSizeOff;
|
||||
rtx=iX-wdt/2; rty=iY-hgt;
|
||||
if (Game.Landscape.AreaSolidCount(rtx,rty,wdt,hgt)>(wdt*hgt/20))
|
||||
{
|
||||
if (pByObj) GameMsgObject(LoadResStr("IDS_OBJ_NOROOM"),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
if (Game.Landscape.AreaSolidCount(rtx,rty+hgt,wdt,5)<(wdt*2))
|
||||
{
|
||||
if (pByObj) GameMsgObject(LoadResStr("IDS_OBJ_NOLEVEL"),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
// Check other structures
|
||||
C4Object *other;
|
||||
if (other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->Category))
|
||||
{
|
||||
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj,FRed);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void C4Landscape::ClearRect(int32_t iTx, int32_t iTy, int32_t iWdt, int32_t iHgt)
|
||||
|
|
|
@ -1133,7 +1133,7 @@ void C4MouseControl::DragConstruct()
|
|||
Cursor=C4MC_Cursor_Construct;
|
||||
// Check site
|
||||
DragImagePhase=1;
|
||||
if (!FogOfWar && ConstructionCheck(DragID,int32_t(GameX),int32_t(GameY))) DragImagePhase=0;
|
||||
if (!FogOfWar && ConstructionCheck(C4Id2Def(DragID),int32_t(GameX),int32_t(GameY))) DragImagePhase=0;
|
||||
}
|
||||
|
||||
void C4MouseControl::LeftUpDragNone()
|
||||
|
|
|
@ -145,7 +145,7 @@ void C4Object::Default()
|
|||
iLastAttachMovementFrame=-1;
|
||||
}
|
||||
|
||||
BOOL C4Object::Init(C4Def *pDef, C4Object *pCreator,
|
||||
BOOL C4Object::Init(C4PropList *pDef, C4Object *pCreator,
|
||||
int32_t iOwner, C4ObjectInfo *pInfo,
|
||||
int32_t nx, int32_t ny, int32_t nr,
|
||||
FIXED nxdir, FIXED nydir, FIXED nrdir, int32_t iController)
|
||||
|
@ -154,13 +154,13 @@ BOOL C4Object::Init(C4Def *pDef, C4Object *pCreator,
|
|||
Initializing=TRUE;
|
||||
|
||||
// Def & basics
|
||||
id=pDef->id;
|
||||
Owner=iOwner;
|
||||
if (iController > NO_OWNER) Controller = iController; else Controller=iOwner;
|
||||
LastEnergyLossCausePlayer=NO_OWNER;
|
||||
Info=pInfo;
|
||||
Def=pDef;
|
||||
Def=pDef->GetDef();assert(Def);
|
||||
prototype = pDef;
|
||||
id=Def->id;
|
||||
if (Info) SetName(pInfo->Name);
|
||||
Category=Def->Category;
|
||||
Def->Count++;
|
||||
|
@ -214,7 +214,7 @@ BOOL C4Object::Init(C4Def *pDef, C4Object *pCreator,
|
|||
SetOCF();
|
||||
|
||||
// local named vars
|
||||
LocalNamed.SetNameList(&pDef->Script.LocalNamed);
|
||||
LocalNamed.SetNameList(&Def->Script.LocalNamed);
|
||||
|
||||
// finished initializing
|
||||
Initializing=FALSE;
|
||||
|
@ -1820,10 +1820,10 @@ BOOL C4Object::Lift(FIXED tydir, FIXED dforce)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
C4Object* C4Object::CreateContents(C4ID n_id)
|
||||
C4Object* C4Object::CreateContents(C4PropList * PropList)
|
||||
{
|
||||
C4Object *nobj;
|
||||
if (!(nobj=Game.CreateObject(n_id,this,Owner))) return NULL;
|
||||
if (!(nobj=Game.CreateObject(PropList,this,Owner))) return NULL;
|
||||
if (!nobj->Enter(this)) { nobj->AssignRemoval(); return NULL; }
|
||||
return nobj;
|
||||
}
|
||||
|
@ -1833,7 +1833,7 @@ BOOL C4Object::CreateContentsByList(C4IDList &idlist)
|
|||
int32_t cnt,cnt2;
|
||||
for (cnt=0; idlist.GetID(cnt); cnt++)
|
||||
for (cnt2=0; cnt2<idlist.GetCount(cnt); cnt2++)
|
||||
if (!CreateContents(idlist.GetID(cnt)))
|
||||
if (!CreateContents(C4Id2Def(idlist.GetID(cnt))))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -3716,7 +3716,7 @@ C4Object *C4Object::ComposeContents(C4ID id)
|
|||
// Create composed object
|
||||
// the object is created with default components instead of builder components
|
||||
// this is done because some objects (e.g. arrow packs) will set custom components during initialization, which should not be overriden
|
||||
return CreateContents(id);
|
||||
return CreateContents(C4Id2Def(id));
|
||||
}
|
||||
|
||||
void C4Object::SetSolidMask(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iTX, int32_t iTY)
|
||||
|
|
|
@ -578,7 +578,7 @@ void C4Player::PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
|
|||
ctx=tx; cty=ty;
|
||||
if (Game.C4S.PlrStart[PlrStartIndex].EnforcePosition
|
||||
|| FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,def->Category,20))
|
||||
if (cbase=Game.CreateObjectConstruction(cid,NULL,Number,ctx,cty,FullCon,TRUE))
|
||||
if (cbase=Game.CreateObjectConstruction(C4Id2Def(cid),NULL,Number,ctx,cty,FullCon,TRUE))
|
||||
{
|
||||
// FirstBase
|
||||
if (!(*pFirstBase)) if (cbase->Def->CanBeBase)
|
||||
|
|
|
@ -67,6 +67,14 @@ void C4PropList::SetName(const char* NewName)
|
|||
|
||||
|
||||
|
||||
C4Def * C4PropList::GetDef()
|
||||
{
|
||||
if (prototype) return prototype->GetDef();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<> template<>
|
||||
unsigned int C4Set<C4Property>::Hash<C4String *>(C4String * e)
|
||||
{
|
||||
|
|
|
@ -1547,9 +1547,6 @@ static C4Value FnAddMenuItem(C4AulContext *cthr, C4Value *pPars)
|
|||
case C4V_Bool:
|
||||
SCopy(Parameter.getBool() ? "true" : "false", parameter);
|
||||
break;
|
||||
case C4V_C4ID:
|
||||
sprintf(parameter, "%s", C4IdText(Parameter.getC4ID()));
|
||||
break;
|
||||
case C4V_C4Object:
|
||||
case C4V_PropList:
|
||||
sprintf(parameter, "Object(%d)", Parameter.getPropList()->Number);
|
||||
|
@ -1913,7 +1910,7 @@ static bool FnComponentAll(C4AulContext *cthr, C4Object *pObj, C4ID c_id)
|
|||
}
|
||||
|
||||
static C4Object *FnCreateObject(C4AulContext *cthr,
|
||||
C4ID id, long iXOffset, long iYOffset, long iOwner)
|
||||
C4PropList * PropList, long iXOffset, long iYOffset, long iOwner)
|
||||
{
|
||||
if (cthr->Obj) // Local object calls override
|
||||
{
|
||||
|
@ -1923,16 +1920,16 @@ static C4Object *FnCreateObject(C4AulContext *cthr,
|
|||
iOwner=cthr->Obj->Owner;
|
||||
}
|
||||
|
||||
C4Object *pNewObj = Game.CreateObject(id,cthr->Obj,iOwner,iXOffset,iYOffset);
|
||||
C4Object *pNewObj = Game.CreateObject(PropList,cthr->Obj,iOwner,iXOffset,iYOffset);
|
||||
|
||||
// Set initial controller to creating controller, so more complicated cause-effect-chains can be traced back to the causing player
|
||||
if (pNewObj && cthr->Obj && cthr->Obj->Controller>NO_OWNER) pNewObj->Controller = cthr->Obj->Controller;
|
||||
if (pNewObj && cthr->Obj && cthr->Obj->Controller > NO_OWNER) pNewObj->Controller = cthr->Obj->Controller;
|
||||
|
||||
return pNewObj;
|
||||
}
|
||||
|
||||
static C4Object *FnCreateConstruction(C4AulContext *cthr,
|
||||
C4ID id, long iXOffset, long iYOffset, long iOwner,
|
||||
C4PropList * PropList, long iXOffset, long iYOffset, long iOwner,
|
||||
long iCompletion, bool fTerrain, bool fCheckSite)
|
||||
{
|
||||
// Local object calls override position offset, owner
|
||||
|
@ -1946,11 +1943,11 @@ static C4Object *FnCreateConstruction(C4AulContext *cthr,
|
|||
|
||||
// Check site
|
||||
if (fCheckSite)
|
||||
if (!ConstructionCheck(id,iXOffset,iYOffset,cthr->Obj))
|
||||
if (!ConstructionCheck(PropList,iXOffset,iYOffset,cthr->Obj))
|
||||
return NULL;
|
||||
|
||||
// Create site object
|
||||
C4Object *pNewObj = Game.CreateObjectConstruction(id,cthr->Obj,iOwner,iXOffset,iYOffset,iCompletion*FullCon/100,fTerrain);
|
||||
C4Object *pNewObj = Game.CreateObjectConstruction(PropList,cthr->Obj,iOwner,iXOffset,iYOffset,iCompletion*FullCon/100,fTerrain);
|
||||
|
||||
// Set initial controller to creating controller, so more complicated cause-effect-chains can be traced back to the causing player
|
||||
if (pNewObj && cthr->Obj && cthr->Obj->Controller>NO_OWNER) pNewObj->Controller = cthr->Obj->Controller;
|
||||
|
@ -1958,7 +1955,7 @@ static C4Object *FnCreateConstruction(C4AulContext *cthr,
|
|||
return pNewObj;
|
||||
}
|
||||
|
||||
static C4Object *FnCreateContents(C4AulContext *cthr, C4ID c_id, C4Object *pObj, long iCount)
|
||||
static C4Object *FnCreateContents(C4AulContext *cthr, C4PropList * PropList, C4Object *pObj, long iCount)
|
||||
{
|
||||
// local call / safety
|
||||
if (!pObj) pObj=cthr->Obj; if (!pObj) return NULL;
|
||||
|
@ -1966,7 +1963,7 @@ static C4Object *FnCreateContents(C4AulContext *cthr, C4ID c_id, C4Object *pObj,
|
|||
if (!iCount) ++iCount;
|
||||
// create objects
|
||||
C4Object *pNewObj = NULL;
|
||||
while (iCount-- > 0) pNewObj = pObj->CreateContents(c_id);
|
||||
while (iCount-- > 0) pNewObj = pObj->CreateContents(PropList);
|
||||
// controller will automatically be set upon entrance
|
||||
// return last created
|
||||
return pNewObj;
|
||||
|
@ -2022,11 +2019,11 @@ static C4Object *FnComposeContents(C4AulContext *cthr, C4ID c_id, C4Object *pObj
|
|||
return C4VBool(!!fSuccess);
|
||||
}*/
|
||||
|
||||
static bool FnFindConstructionSite(C4AulContext *cthr, C4ID id, long iVarX, long iVarY)
|
||||
static bool FnFindConstructionSite(C4AulContext *cthr, C4PropList * PropList, long iVarX, long iVarY)
|
||||
{
|
||||
// Get def Old-style implementation (fixed)...
|
||||
C4Def *pDef;
|
||||
if (!(pDef=C4Id2Def(id))) return FALSE;
|
||||
if (!(pDef=PropList->GetDef())) return FALSE;
|
||||
// Var indices out of range
|
||||
if (!Inside<long>(iVarX,0,C4AUL_MAX_Par-1) || !Inside<long>(iVarY,0,C4AUL_MAX_Par-1)) return FALSE;
|
||||
// Get thread vars
|
||||
|
@ -2034,7 +2031,7 @@ static bool FnFindConstructionSite(C4AulContext *cthr, C4ID id, long iVarX, long
|
|||
C4Value& V1 = cthr->Caller->NumVars[iVarX];
|
||||
C4Value& V2 = cthr->Caller->NumVars[iVarY];
|
||||
// Construction check at starting position
|
||||
if (ConstructionCheck(id,V1.getInt(),V2.getInt()))
|
||||
if (ConstructionCheck(PropList,V1.getInt(),V2.getInt()))
|
||||
return TRUE;
|
||||
// Search for real
|
||||
int32_t v1 = V1.getInt(), v2 = V2.getInt();
|
||||
|
@ -4181,71 +4178,6 @@ protected:
|
|||
{ Res = (fIsID ? C4VID(C4Id(*pszString)) : C4VString(*pszString)); }
|
||||
};
|
||||
|
||||
class C4ValueSetCompiler : public C4ValueCompiler
|
||||
{
|
||||
private:
|
||||
C4Value Val; // value to which the setting should be set
|
||||
bool fSuccess; // set if the value could be set successfully
|
||||
int32_t iRuntimeWriteAllowed; // if >0, runtime writing of values is allowed
|
||||
|
||||
public:
|
||||
C4ValueSetCompiler(const char **pszNames, int iNameCnt, int iEntryNr, const C4Value &rSetVal)
|
||||
: C4ValueCompiler(pszNames, iNameCnt, iEntryNr), Val(rSetVal), fSuccess(false), iRuntimeWriteAllowed(0)
|
||||
{ }
|
||||
|
||||
// Query successful setting
|
||||
bool getSuccess() const { return fSuccess; }
|
||||
|
||||
virtual void setRuntimeWritesAllowed(int32_t iChange) { iRuntimeWriteAllowed += iChange; }
|
||||
|
||||
protected:
|
||||
// set values as C4Value, only if type matches or is convertible
|
||||
virtual void ProcessInt(int32_t &rInt) { if (iRuntimeWriteAllowed > 0 && Val.ConvertTo(C4V_Int)) { rInt = Val.getInt(); fSuccess=true; } }
|
||||
virtual void ProcessBool(bool &rBool) { if (iRuntimeWriteAllowed > 0 && Val.ConvertTo(C4V_Bool)) { rBool = Val.getBool(); fSuccess=true; } }
|
||||
virtual void ProcessChar(char &rChar) { C4String *s; if (iRuntimeWriteAllowed > 0 && (s = Val.getStr())) { rChar = s->GetCStr() ? *s->GetCStr() : 0; fSuccess=true; } }
|
||||
|
||||
virtual void ProcessString(char *szString, size_t iMaxLength, bool fIsID)
|
||||
{
|
||||
if (iRuntimeWriteAllowed <= 0 || !Val.ConvertTo(fIsID ? C4V_C4ID : C4V_String)) return;
|
||||
if (fIsID)
|
||||
{
|
||||
assert(iMaxLength >= 4); // fields that should carry an ID are guaranteed to have a buffer that's large enough
|
||||
GetC4IdText(Val.getC4ID(), szString);
|
||||
}
|
||||
else
|
||||
{
|
||||
C4String *s = Val.getStr(); if (!s) return;
|
||||
if (s->GetCStr()) SCopy(s->GetCStr(), szString, iMaxLength); else *szString = 0;
|
||||
}
|
||||
fSuccess = true;
|
||||
}
|
||||
|
||||
virtual void ProcessString(char **pszString, bool fIsID)
|
||||
{
|
||||
if (iRuntimeWriteAllowed <= 0 || !Val.ConvertTo(fIsID ? C4V_C4ID : C4V_String)) return;
|
||||
// This cannot be allowed, because it is run during decompilation and wouldn't update assiciated length fields in StdStrBuf!
|
||||
/*
|
||||
assert(pszString);
|
||||
if (fIsID)
|
||||
{
|
||||
*pszString = new char[5];
|
||||
GetC4IdText(Val.getC4ID(), *pszString);
|
||||
}
|
||||
else
|
||||
{
|
||||
C4String *s = Val.getStr(); if (!s) return;
|
||||
StdStrBuf &rsBuf = s->Data;
|
||||
if (rsBuf.getData() && rsBuf.getSize())
|
||||
{
|
||||
*pszString = new char[rsBuf.getSize()];
|
||||
SCopy(rsBuf.getData(), *pszString);
|
||||
}
|
||||
else
|
||||
pszString = NULL;
|
||||
}*/
|
||||
}
|
||||
};
|
||||
|
||||
// Use the compiler to find a named value in a structure
|
||||
template <class T>
|
||||
C4Value GetValByStdCompiler(const char *strEntry, const char *strSection, int iEntryNr, const T &rFrom)
|
||||
|
@ -4267,27 +4199,6 @@ template <class T>
|
|||
}
|
||||
}
|
||||
|
||||
// Use the compiler to set a named value in a structure
|
||||
template <class T>
|
||||
bool SetValByStdCompiler(const char *strEntry, const char *strSection, int iEntryNr, const T &rTo, const C4Value &rvNewVal)
|
||||
{
|
||||
// Set up name array, create compiler
|
||||
const char *szNames[2] = { strSection ? strSection : strEntry, strSection ? strEntry : NULL };
|
||||
C4ValueSetCompiler Comp(szNames, strSection ? 2 : 1, iEntryNr, rvNewVal);
|
||||
|
||||
// Compile
|
||||
try
|
||||
{
|
||||
Comp.Decompile(rTo);
|
||||
return Comp.getSuccess();
|
||||
}
|
||||
// Should not happen, catch it anyway.
|
||||
catch(StdCompiler::Exception *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static C4Value FnGetDefCoreVal(C4AulContext* cthr, C4Value* strEntry_C4V, C4Value* strSection_C4V, C4Value* idDef_C4V, C4Value *iEntryNr_C4V)
|
||||
{
|
||||
const char *strEntry = FnStringPar(strEntry_C4V->getStr());
|
||||
|
@ -4355,21 +4266,6 @@ static C4Value FnGetScenarioVal(C4AulContext* cthr, C4Value* strEntry_C4V, C4Val
|
|||
return GetValByStdCompiler(strEntry, strSection, iEntryNr, mkParAdapt(Game.C4S, false));
|
||||
}
|
||||
|
||||
static C4Value FnSetScenarioVal(C4AulContext* cthr, C4Value* strEntry_C4V, C4Value* strSection_C4V, C4Value *iEntryNr_C4V, C4Value *setVal_C4V)
|
||||
{
|
||||
const char *strEntry = FnStringPar(strEntry_C4V->getStr());
|
||||
const char *strSection = FnStringPar(strSection_C4V->getStr());
|
||||
long iEntryNr = iEntryNr_C4V->getInt();
|
||||
|
||||
if(strSection && !*strSection) strSection = NULL;
|
||||
|
||||
// only set dereferenced values
|
||||
C4Value setVal(*setVal_C4V);
|
||||
setVal.Deref();
|
||||
|
||||
return C4VBool(SetValByStdCompiler(strEntry, strSection, iEntryNr, mkParAdapt(Game.C4S, false), setVal));
|
||||
}
|
||||
|
||||
static C4Value FnGetPlayerVal(C4AulContext* cthr, C4Value* strEntry_C4V, C4Value* strSection_C4V, C4Value* iPlayer_C4V, C4Value *iEntryNr_C4V)
|
||||
{
|
||||
const char *strEntry = FnStringPar(strEntry_C4V->getStr());
|
||||
|
@ -4814,8 +4710,7 @@ static C4Value FnSetPlrExtraData(C4AulContext *cthr, C4Value *iPlayer_C4V, C4Val
|
|||
// do not allow data type C4V_String or C4V_C4Object
|
||||
if(Data->GetType() != C4V_Any &&
|
||||
Data->GetType() != C4V_Int &&
|
||||
Data->GetType() != C4V_Bool &&
|
||||
Data->GetType() != C4V_C4ID) return C4VNull;
|
||||
Data->GetType() != C4V_Bool) return C4VNull;
|
||||
// get pointer on player...
|
||||
C4Player* pPlayer = Game.Players.Get(iPlayer);
|
||||
// no name list created yet?
|
||||
|
@ -4864,8 +4759,7 @@ static C4Value FnSetCrewExtraData(C4AulContext *cthr, C4Value *pCrew_C4V, C4Valu
|
|||
// do not allow data type C4V_String or C4V_C4Object
|
||||
if(Data->GetType() != C4V_Any &&
|
||||
Data->GetType() != C4V_Int &&
|
||||
Data->GetType() != C4V_Bool &&
|
||||
Data->GetType() != C4V_C4ID) return C4VNull;
|
||||
Data->GetType() != C4V_Bool) return C4VNull;
|
||||
// get pointer on info...
|
||||
C4ObjectInfo *pInfo = pCrew->Info;
|
||||
// no name list created yet?
|
||||
|
@ -6813,10 +6707,9 @@ void InitFunctionMap(C4AulScriptEngine *pEngine)
|
|||
AddFunc(pEngine, "LocateFunc", FnLocateFunc);
|
||||
AddFunc(pEngine, "PathFree", FnPathFree);
|
||||
AddFunc(pEngine, "SetNextMission", FnSetNextMission);
|
||||
new C4AulDefCastFunc(pEngine, "ScoreboardCol", C4V_C4ID, C4V_Int);
|
||||
//FIXME new C4AulDefCastFunc(pEngine, "ScoreboardCol", C4V_C4ID, C4V_Int);
|
||||
new C4AulDefCastFunc(pEngine, "CastInt", C4V_Any, C4V_Int);
|
||||
new C4AulDefCastFunc(pEngine, "CastBool", C4V_Any, C4V_Bool);
|
||||
new C4AulDefCastFunc(pEngine, "CastC4ID", C4V_Any, C4V_C4ID);
|
||||
new C4AulDefCastFunc(pEngine, "CastAny", C4V_Any, C4V_Any);
|
||||
}
|
||||
|
||||
|
@ -6864,7 +6757,6 @@ C4ScriptConstDef C4ScriptConstMap[]={
|
|||
{ "C4V_Any" ,C4V_Int, C4V_Any},
|
||||
{ "C4V_Int" ,C4V_Int, C4V_Int},
|
||||
{ "C4V_Bool" ,C4V_Int, C4V_Bool},
|
||||
{ "C4V_C4ID" ,C4V_Int, C4V_C4ID},
|
||||
{ "C4V_C4Object" ,C4V_Int, C4V_C4Object},
|
||||
{ "C4V_String" ,C4V_Int, C4V_String},
|
||||
{ "C4V_Array" ,C4V_Int, C4V_Array},
|
||||
|
@ -7168,7 +7060,7 @@ C4ScriptFnDef C4ScriptFnMap[]={
|
|||
{ "Local", 1 ,C4V_Any ,{ C4V_Int ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnLocal_C4V , 0 },
|
||||
{ "SetProperty", 1 ,C4V_Any ,{ C4V_String ,C4V_Any ,C4V_PropList,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnSetProperty_C4V , 0 },
|
||||
{ "GetProperty", 1 ,C4V_Any ,{ C4V_String ,C4V_PropList,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetProperty_C4V , 0 },
|
||||
{ "Explode", 1 ,C4V_Bool ,{ C4V_Int ,C4V_C4Object,C4V_C4ID ,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnExplode },
|
||||
{ "Explode", 1 ,C4V_Bool ,{ C4V_Int ,C4V_C4Object,C4V_PropList,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnExplode },
|
||||
{ "Incinerate", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnIncinerate },
|
||||
{ "IncinerateLandscape", 1 ,C4V_Bool ,{ C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnIncinerateLandscape },
|
||||
{ "Extinguish", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnExtinguish },
|
||||
|
@ -7177,7 +7069,7 @@ C4ScriptFnDef C4ScriptFnMap[]={
|
|||
{ "Kill", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_Bool ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnKill },
|
||||
{ "Fling", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnFling },
|
||||
{ "Jump", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnJump },
|
||||
{ "ChangeDef", 1 ,C4V_Bool ,{ C4V_C4ID ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnChangeDef },
|
||||
{ "ChangeDef", 1 ,C4V_Bool ,{ C4V_PropList,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnChangeDef },
|
||||
{ "Exit", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnExit },
|
||||
{ "Enter", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnEnter },
|
||||
{ "Collect", 1 ,C4V_Bool ,{ C4V_C4Object,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnCollect },
|
||||
|
@ -7190,21 +7082,21 @@ C4ScriptFnDef C4ScriptFnMap[]={
|
|||
//{ "FindConstructionSite", 0 ,C4V_Bool ,{ C4V_C4ID ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnFindConstructionSite , 0 },
|
||||
{ "PathFree2", 1 ,C4V_Bool ,{ C4V_pC4Value,C4V_pC4Value,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnPathFree2_C4V , 0 },
|
||||
{ "DeathAnnounce", 1 ,C4V_Bool ,{ C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnDeathAnnounce },
|
||||
{ "FindObject", 1 ,C4V_C4Object ,{ C4V_C4ID ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_C4Object} ,0 , FnFindObject },
|
||||
{ "FindObject", 1 ,C4V_C4Object ,{ C4V_PropList,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_C4Object} ,0 , FnFindObject },
|
||||
{ "FindObject2", 1 ,C4V_C4Object ,{ C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array},0 , FnFindObject2 },
|
||||
{ "FindObjects", 1 ,C4V_Array ,{ C4V_Array ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnFindObjects },
|
||||
{ "ObjectCount", 1 ,C4V_Int ,{ C4V_C4ID ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_Int},0 , FnObjectCount },
|
||||
{ "ObjectCount", 1 ,C4V_Int ,{ C4V_PropList,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_Int},0 , FnObjectCount },
|
||||
{ "ObjectCount2", 1 ,C4V_Int ,{ C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array ,C4V_Array},0 , FnObjectCount2 },
|
||||
{ "ObjectCall", 1 ,C4V_Any ,{ C4V_C4Object,C4V_String,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnObjectCall_C4V , 0 },
|
||||
{ "ProtectedCall", 1 ,C4V_Any ,{ C4V_C4Object,C4V_String,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnProtectedCall_C4V , 0 },
|
||||
{ "PrivateCall", 1 ,C4V_Any ,{ C4V_C4Object,C4V_String,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnPrivateCall_C4V , 0 },
|
||||
{ "GameCall", 1 ,C4V_Any ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGameCall_C4V , 0 },
|
||||
{ "GameCallEx", 1 ,C4V_Any ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGameCallEx_C4V , 0 },
|
||||
{ "DefinitionCall", 1 ,C4V_Any ,{ C4V_C4ID ,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnDefinitionCall_C4V , 0 },
|
||||
{ "DefinitionCall", 1 ,C4V_Any ,{ C4V_PropList,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnDefinitionCall_C4V , 0 },
|
||||
{ "Call", 0 ,C4V_Any ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnCall_C4V , 0 },
|
||||
{ "GetPlrKnowledge", 1 ,C4V_Int ,{ C4V_Int ,C4V_C4ID ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetPlrKnowledge_C4V , 0 },
|
||||
{ "GetPlrMagic", 1 ,C4V_Int ,{ C4V_Int ,C4V_C4ID ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetPlrMagic_C4V , 0 },
|
||||
{ "GetComponent", 1 ,C4V_Int ,{ C4V_C4ID ,C4V_Int ,C4V_C4Object,C4V_C4ID ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetComponent_C4V , 0 },
|
||||
{ "GetPlrKnowledge", 1 ,C4V_Int ,{ C4V_Int ,C4V_PropList,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetPlrKnowledge_C4V , 0 },
|
||||
{ "GetPlrMagic", 1 ,C4V_Int ,{ C4V_Int ,C4V_PropList,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetPlrMagic_C4V , 0 },
|
||||
{ "GetComponent", 1 ,C4V_Int ,{ C4V_PropList,C4V_Int ,C4V_C4Object,C4V_PropList,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetComponent_C4V , 0 },
|
||||
{ "PlayerMessage", 1 ,C4V_Int ,{ C4V_Int ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V &FnPlayerMessage_C4V, 0 },
|
||||
{ "Message", 1 ,C4V_Bool ,{ C4V_String ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V &FnMessage_C4V, 0 },
|
||||
{ "AddMessage", 1 ,C4V_Bool ,{ C4V_String ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V &FnAddMessage_C4V, 0 },
|
||||
|
@ -7213,12 +7105,12 @@ C4ScriptFnDef C4ScriptFnMap[]={
|
|||
{ "DebugLog", 1 ,C4V_Bool ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V &FnDebugLog_C4V, 0 },
|
||||
{ "Format", 1 ,C4V_String ,{ C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V &FnFormat_C4V, 0 },
|
||||
{ "EditCursor", 1 ,C4V_C4Object ,{ C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnEditCursor },
|
||||
{ "AddMenuItem", 1 ,C4V_Bool ,{ C4V_String ,C4V_String ,C4V_C4ID ,C4V_C4Object,C4V_Int ,C4V_Any ,C4V_String ,C4V_Int ,C4V_Any ,C4V_Any} ,0 , FnAddMenuItem },
|
||||
{ "AddMenuItem", 1 ,C4V_Bool ,{ C4V_String ,C4V_String ,C4V_PropList,C4V_C4Object,C4V_Int ,C4V_Any ,C4V_String ,C4V_Int ,C4V_Any ,C4V_Any} ,0 , FnAddMenuItem },
|
||||
{ "SetSolidMask", 1 ,C4V_Bool ,{ C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Int ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnSetSolidMask },
|
||||
{ "SetGravity", 1 ,C4V_Bool ,{ C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnSetGravity },
|
||||
{ "GetGravity", 1 ,C4V_Int ,{ C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0 , FnGetGravity },
|
||||
{ "GetHomebaseMaterial", 1 ,C4V_Int ,{ C4V_Int ,C4V_C4ID ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetHomebaseMaterial_C4V , 0 },
|
||||
{ "GetHomebaseProduction", 1 ,C4V_Int ,{ C4V_Int ,C4V_C4ID ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetHomebaseProduction_C4V , 0 },
|
||||
{ "GetHomebaseMaterial", 1 ,C4V_Int ,{ C4V_Int ,C4V_PropList,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetHomebaseMaterial_C4V , 0 },
|
||||
{ "GetHomebaseProduction", 1 ,C4V_Int ,{ C4V_Int ,C4V_PropList,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetHomebaseProduction_C4V , 0 },
|
||||
|
||||
{ "Set", 1 ,C4V_Any ,{ C4V_pC4Value,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnSet, 0 },
|
||||
{ "Inc", 1 ,C4V_Any ,{ C4V_pC4Value,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnInc, 0 },
|
||||
|
@ -7232,7 +7124,7 @@ C4ScriptFnDef C4ScriptFnMap[]={
|
|||
{ "SetLength", 1 ,C4V_Bool ,{ C4V_pC4Value,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,0, FnSetLength },
|
||||
|
||||
|
||||
{ "GetDefCoreVal", 1 ,C4V_Any ,{ C4V_String ,C4V_String ,C4V_C4ID ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetDefCoreVal, 0 },
|
||||
{ "GetDefCoreVal", 1 ,C4V_Any ,{ C4V_String ,C4V_String ,C4V_PropList,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetDefCoreVal, 0 },
|
||||
{ "GetObjectVal", 1 ,C4V_Any ,{ C4V_String ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetObjectVal, 0 },
|
||||
{ "GetObjectInfoCoreVal", 1 ,C4V_Any ,{ C4V_String ,C4V_String ,C4V_C4Object,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetObjectInfoCoreVal, 0 },
|
||||
{ "GetScenarioVal", 1 ,C4V_Any ,{ C4V_String ,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetScenarioVal, 0 },
|
||||
|
@ -7247,7 +7139,7 @@ C4ScriptFnDef C4ScriptFnMap[]={
|
|||
{ "GetCrewExtraData", 1 ,C4V_Any ,{ C4V_C4Object,C4V_String,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetCrewExtraData, 0 },
|
||||
{ "SimFlight", 1 ,C4V_Bool ,{ C4V_pC4Value,C4V_pC4Value,C4V_pC4Value,C4V_pC4Value,C4V_Int,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any} ,MkFnC4V FnSimFlight, 0 },
|
||||
{ "GetPortrait", 1 ,C4V_Any ,{ C4V_C4Object,C4V_Bool ,C4V_Bool ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetPortrait, 0 },
|
||||
{ "AddEffect", 1 ,C4V_Int ,{ C4V_String ,C4V_C4Object,C4V_Int ,C4V_Int ,C4V_C4Object,C4V_C4ID ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnAddEffect_C4V, 0 },
|
||||
{ "AddEffect", 1 ,C4V_Int ,{ C4V_String ,C4V_C4Object,C4V_Int ,C4V_Int ,C4V_C4Object,C4V_PropList,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnAddEffect_C4V, 0 },
|
||||
{ "GetEffect", 1 ,C4V_Any ,{ C4V_String ,C4V_C4Object,C4V_Int ,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnGetEffect_C4V, 0 },
|
||||
{ "CheckEffect", 1 ,C4V_Int ,{ C4V_String ,C4V_C4Object,C4V_Int ,C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnCheckEffect_C4V, 0 },
|
||||
{ "EffectCall", 1 ,C4V_Any ,{ C4V_C4Object,C4V_Int ,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any} ,MkFnC4V FnEffectCall_C4V, 0 },
|
||||
|
|
|
@ -254,10 +254,6 @@ C4V_Type C4Value::GuessType()
|
|||
|
||||
if (Type != C4V_Any) return Type;
|
||||
|
||||
// C4ID?
|
||||
if (LooksLikeID(Data.Int) && Data.Int >= 10000)
|
||||
return Type = C4V_C4ID;
|
||||
|
||||
#ifdef C4ENGINE
|
||||
// object?
|
||||
if (Game.Objects.ObjectNumber(Data.Obj))
|
||||
|
@ -297,8 +293,6 @@ const char* GetC4VName(const C4V_Type Type)
|
|||
return "bool";
|
||||
case C4V_C4Object:
|
||||
return "object";
|
||||
case C4V_C4ID:
|
||||
return "id";
|
||||
case C4V_String:
|
||||
return "string";
|
||||
case C4V_Array:
|
||||
|
@ -324,8 +318,6 @@ char GetC4VID(const C4V_Type Type)
|
|||
return 'b';
|
||||
case C4V_C4Object:
|
||||
return 'o';
|
||||
case C4V_C4ID:
|
||||
return 'I';
|
||||
case C4V_String:
|
||||
return 's';
|
||||
case C4V_pC4Value:
|
||||
|
@ -352,8 +344,6 @@ C4V_Type GetC4VFromID(const char C4VID)
|
|||
return C4V_Bool;
|
||||
case 'o':
|
||||
return C4V_C4Object;
|
||||
case 'I':
|
||||
return C4V_C4ID;
|
||||
case 's':
|
||||
return C4V_String;
|
||||
case 'V':
|
||||
|
@ -420,20 +410,10 @@ bool C4Value::FnCnvGuess(C4Value *Val, C4V_Type toType, BOOL fStrict)
|
|||
}
|
||||
}
|
||||
|
||||
bool C4Value::FnCnvInt2Id(C4Value *Val, C4V_Type toType, BOOL fStrict)
|
||||
{
|
||||
// inside range?
|
||||
if (!Inside<long>(Val->Data.Int, 0, 9999)) return FALSE;
|
||||
// convert
|
||||
Val->Type = C4V_C4ID;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Type conversion table
|
||||
#define CnvOK 0, false // allow conversion by same value
|
||||
#define CnvError FnCnvError, true
|
||||
#define CnvGuess C4Value::FnCnvGuess, false
|
||||
#define CnvInt2Id C4Value::FnCnvInt2Id, false
|
||||
#define CnvDirectOld FnCnvDirectOld, true
|
||||
#define CnvDeref FnCnvDeref, false
|
||||
#define CnvObject FnCnvObject, false
|
||||
|
@ -443,98 +423,79 @@ C4VCnvFn C4Value::C4ScriptCnvMap[C4V_Last+1][C4V_Last+1] = {
|
|||
{ CnvOK }, // any same
|
||||
{ CnvGuess }, // int
|
||||
{ CnvGuess }, // Bool
|
||||
{ CnvGuess }, // C4ID
|
||||
{ CnvGuess }, // PropList
|
||||
{ CnvGuess }, // C4Object
|
||||
{ CnvGuess }, // String
|
||||
{ CnvGuess }, // Array
|
||||
{ CnvGuess }, // PropList
|
||||
{ CnvError }, // pC4Value
|
||||
},
|
||||
{ // C4V_Int
|
||||
{ CnvOK }, // any
|
||||
{ CnvOK }, // int same
|
||||
{ CnvOK }, // Bool
|
||||
{ CnvInt2Id }, // C4ID numerical ID?
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // C4Object NEVER!
|
||||
{ CnvError }, // String NEVER!
|
||||
{ CnvError }, // Array NEVER!
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // pC4Value
|
||||
},
|
||||
{ // C4V_Bool
|
||||
{ CnvOK }, // any
|
||||
{ CnvOK }, // int might be used
|
||||
{ CnvOK }, // Bool same
|
||||
{ CnvDirectOld }, // C4ID #strict forbid
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // C4Object NEVER!
|
||||
{ CnvError }, // String NEVER!
|
||||
{ CnvError }, // Array NEVER!
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // pC4Value
|
||||
},
|
||||
{ // C4V_C4ID
|
||||
{ // C4V_PropList
|
||||
{ CnvOK }, // any
|
||||
{ CnvDirectOld }, // int #strict forbid
|
||||
{ CnvError }, // int NEVER!
|
||||
{ CnvOK }, // Bool
|
||||
{ CnvOK }, // C4ID same
|
||||
{ CnvError }, // C4Object NEVER!
|
||||
{ CnvOK }, // PropList same
|
||||
{ CnvObject }, // C4Object
|
||||
{ CnvError }, // String NEVER!
|
||||
{ CnvError }, // Array NEVER!
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // pC4Value
|
||||
{ CnvError }, // pC4Value NEVER!
|
||||
},
|
||||
{ // C4V_Object
|
||||
{ CnvOK }, // any
|
||||
{ CnvDirectOld }, // int #strict forbid
|
||||
{ CnvOK }, // Bool
|
||||
{ CnvError }, // C4ID Senseless, thus error
|
||||
{ CnvOK }, // PropList
|
||||
{ CnvOK }, // C4Object same
|
||||
{ CnvError }, // String NEVER!
|
||||
{ CnvError }, // Array NEVER!
|
||||
{ CnvOK }, // PropList
|
||||
{ CnvError }, // pC4Value
|
||||
},
|
||||
{ // C4V_String
|
||||
{ CnvOK }, // any
|
||||
{ CnvDirectOld }, // int #strict forbid
|
||||
{ CnvOK }, // Bool
|
||||
{ CnvError }, // C4ID Sensless, thus error
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // C4Object NEVER!
|
||||
{ CnvOK }, // String same
|
||||
{ CnvError }, // Array NEVER!
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // pC4Value
|
||||
},
|
||||
{ // C4V_Array
|
||||
{ CnvOK }, // any
|
||||
{ CnvError }, // int NEVER!
|
||||
{ CnvOK }, // Bool
|
||||
{ CnvError }, // C4ID NEVER!
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // C4Object NEVER!
|
||||
{ CnvError }, // String NEVER!
|
||||
{ CnvOK }, // Array same
|
||||
{ CnvError }, // PropList NEVER!
|
||||
{ CnvError }, // pC4Value NEVER!
|
||||
},
|
||||
{ // C4V_PropList
|
||||
{ CnvOK }, // any
|
||||
{ CnvError }, // int NEVER!
|
||||
{ CnvOK }, // Bool
|
||||
{ CnvError }, // C4ID NEVER!
|
||||
{ CnvObject }, // C4Object NEVER!
|
||||
{ CnvError }, // String NEVER!
|
||||
{ CnvError }, // Array NEVER!
|
||||
{ CnvOK }, // PropList same
|
||||
{ CnvError }, // pC4Value NEVER!
|
||||
},
|
||||
{ // C4V_pC4Value - resolve reference and retry type check
|
||||
{ CnvDeref }, // any
|
||||
{ CnvDeref }, // int
|
||||
{ CnvDeref }, // Bool
|
||||
{ CnvDeref }, // C4ID
|
||||
{ CnvDeref }, // PropList
|
||||
{ CnvDeref }, // C4Object
|
||||
{ CnvDeref }, // String
|
||||
{ CnvDeref }, // PropList
|
||||
{ CnvDeref }, // Array
|
||||
{ CnvOK }, // pC4Value same
|
||||
},
|
||||
|
@ -561,8 +522,6 @@ StdStrBuf C4Value::GetDataString()
|
|||
return FormatString("%ld", Data.Int);
|
||||
case C4V_Bool:
|
||||
return StdStrBuf(Data ? "true" : "false");
|
||||
case C4V_C4ID:
|
||||
return StdCopyStrBuf(C4IdText(Data.Int));
|
||||
#ifdef C4ENGINE
|
||||
case C4V_C4Object:
|
||||
{
|
||||
|
@ -714,7 +673,6 @@ void C4Value::CompileFunc(StdCompiler *pComp)
|
|||
case C4V_Any:
|
||||
case C4V_Int:
|
||||
case C4V_Bool:
|
||||
case C4V_C4ID:
|
||||
|
||||
// these are 32-bit integers
|
||||
iTmp = Data.Int;
|
||||
|
@ -798,10 +756,6 @@ bool C4Value::operator == (const C4Value& Value2) const
|
|||
case C4V_Int:
|
||||
case C4V_Bool:
|
||||
return Data == Value2.Data;
|
||||
case C4V_C4ID:
|
||||
if (Inside<long>(Value2.Data.Int, 0, 9999))
|
||||
return Data == Value2.Data;
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -817,21 +771,6 @@ bool C4Value::operator == (const C4Value& Value2) const
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
case C4V_C4ID:
|
||||
switch (Value2.Type)
|
||||
{
|
||||
case C4V_Any:
|
||||
assert(!Value2.Data);
|
||||
return Data == Value2.Data;
|
||||
case C4V_C4ID:
|
||||
return Data == Value2.Data;
|
||||
case C4V_Int:
|
||||
if (Inside<long>(Value2.Data.Int, 0, 9999))
|
||||
return Data == Value2.Data;
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case C4V_C4Object: case C4V_PropList:
|
||||
return Data == Value2.Data && Type == Value2.Type;
|
||||
case C4V_String:
|
||||
|
@ -850,3 +789,13 @@ bool C4Value::operator != (const C4Value& Value2) const
|
|||
// Fixme: implement faster
|
||||
return !(*this == Value2);
|
||||
}
|
||||
|
||||
C4Value C4VID(C4ID iVal) { return C4Value(Game.Defs.ID2Def(iVal)); }
|
||||
C4ID C4Value::getC4ID()
|
||||
{
|
||||
C4PropList * p = getPropList();
|
||||
if(!p) return 0;
|
||||
C4Def * d = p->GetDef();
|
||||
if (!d) return 0;
|
||||
return d->id;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ global func GetActMapVal(string strEntry, string strAction, id idDef, int iEntry
|
|||
return GetProperty(strEntry, GetProperty(strAction, idDef));
|
||||
}
|
||||
|
||||
global func CastC4ID(x) { return x; }
|
||||
|
||||
// Abgelöst durch SetPosition
|
||||
global func ForcePosition(object obj, int x, int y) { return SetPosition(x, y, obj); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue