Replace some usages of C4ID with C4Def*

In particular those that made the c4script shell depend on C4Id.cpp.
heavy-resources
Günther Brammer 2013-03-03 19:25:18 +01:00
parent 88e5608298
commit 22016e075f
32 changed files with 94 additions and 135 deletions

View File

@ -407,6 +407,8 @@ set(OC_CLONK_SOURCES
src/object/C4DefList.h
src/object/C4GameObjects.cpp
src/object/C4GameObjects.h
src/object/C4Id.cpp
src/object/C4Id.h
src/object/C4IDList.cpp
src/object/C4IDList.h
src/object/C4InfoCore.cpp
@ -485,6 +487,8 @@ set(MAPE_BASE_SOURCES
src/lib/C4NameList.h
src/lib/C4Rect.cpp
src/lib/C4Rect.h
src/object/C4Id.cpp
src/object/C4Id.h
)
set(MAPE_SOURCES
@ -1060,8 +1064,6 @@ src/lib/C4Real.cpp
src/lib/C4Real.h
src/lib/C4Random.cpp
src/lib/C4Random.h
src/object/C4Id.cpp
src/object/C4Id.h
src/script/C4Aul.cpp
src/script/C4AulDefFunc.h
src/script/C4AulExec.cpp

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>C4Id</title>
<category>Script</category>
<subcat>Strings</subcat>
<version>5.1 OC</version>
<syntax>
<rtype>id</rtype>
<params>
<param>
<type>string</type>
<name>id_string</name>
<desc>String to be converted into an id.</desc>
</param>
</params>
</syntax>
<desc>Converts a string into an id.</desc>
<examples>
<example>
<code>C4Id(&quot;Rock&quot;)</code>
<text>Returns the id 'Rock'.</text>
</example>
</examples>
</func>
<author>jwk</author><date>2002-04</date>
</funcs>

View File

@ -209,7 +209,7 @@ func OpenBuyMenu(object pClonk, id idDef, int iSelection)
var aBuy = [0,0,0];
var iIndex, iSelection;
AddClonkBuyList(pClonk);
pClonk->CreateMenu (Library_Base, this, C4MN_Extra_Value, "$TxtNothingToBuy$", 0, C4MN_Style_Normal, 0, C4Id("BuyMenu"));
pClonk->CreateMenu (Library_Base, this, C4MN_Extra_Value, "$TxtNothingToBuy$", 0, C4MN_Style_Normal);
for(aBuy in GetBuyObjects())
{
if(aBuy[0] == idDef) iSelection = iIndex;

View File

@ -24,6 +24,7 @@
#include <C4Object.h>
#include <C4PlayerList.h>
#include <C4GameObjects.h>
#include <C4DefList.h>
// *** C4RoundResultsPlayer
@ -282,8 +283,8 @@ void C4RoundResults::EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalLi
{
// determine if the goal is fulfilled - do the calls even if the menu is not to be opened to ensure synchronization
bool fFulfilled = false;;
C4Object *pObj;
if ((pObj = ::Objects.Find(idGoal)))
C4Object *pObj = C4Id2Def(idGoal) ? ::Objects.Find(::Definitions.ID2Def(idGoal)) : NULL;
if (pObj)
{
// Check fulfilled per player, this enables the possibility of rivalry.
C4AulParSet pars(C4VInt(iPlayerNumber));

View File

@ -153,7 +153,7 @@ bool C4EditCursor::Move(float iX, float iY, DWORD dwKeyState)
Target = ((dwKeyState & MK_SHIFT) && Selection.Last) ? Selection.Last->Obj : NULL;
do
{
Target = Game.FindObject(C4ID::None,X,Y,0,0,OCF_NotContained, Target);
Target = Game.FindObject(NULL,X,Y,0,0,OCF_NotContained, Target);
}
while ((dwKeyState & MK_SHIFT) && Target && Selection.GetLink(Target));
}

View File

@ -1126,7 +1126,7 @@ C4Object* C4Game::OverlapObject(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt
return NULL;
}
C4Object* C4Game::FindObject(C4ID id,
C4Object* C4Game::FindObject(C4Def * pDef,
int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt,
DWORD ocf,
C4Object *pFindNext)
@ -1136,15 +1136,10 @@ C4Object* C4Game::FindObject(C4ID id,
int32_t iClosest = 0,iDistance,iFartherThan=-1;
C4Object *cObj;
C4ObjectLink *cLnk;
C4Def *pDef;
C4Object *pFindNextCpy=pFindNext;
// check the easy cases first
if (id!=C4ID::None)
{
if (!(pDef=C4Id2Def(id))) return NULL; // no valid def
if (!pDef->Count) return NULL; // no instances at all
}
// check the easy case first: no instances at all?
if (pDef && !pDef->Count) return NULL;
// Finding next closest: find closest but further away than last closest
if (pFindNext && (iWdt==-1) && (iHgt==-1))
@ -1161,7 +1156,7 @@ C4Object* C4Game::FindObject(C4ID id,
// Status
if (cObj->Status)
// ID
if ((id==C4ID::None) || (cObj->Def->id==id))
if (!pDef || (cObj->Def == pDef))
// OCF (match any specified)
if (cObj->OCF & ocf)
// Area

View File

@ -189,7 +189,7 @@ public:
C4Object *CreateInfoObject(C4ObjectInfo *cinf, int32_t owner,
int32_t tx=50, int32_t ty=50);
C4Object *OverlapObject(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t Plane);
C4Object *FindObject(C4ID id,
C4Object *FindObject(C4Def * pDef,
int32_t iX=0, int32_t iY=0, int32_t iWdt=0, int32_t iHgt=0,
DWORD ocf=OCF_All,
C4Object *pFindNext=NULL);

View File

@ -87,7 +87,7 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject *
return new C4FindObjectExclude(Data[1].getObj());
case C4FO_ID:
return new C4FindObjectID(Data[1].getC4ID());
return new C4FindObjectDef(Data[1].getPropList());
// #973: For all criteria using coordinates: If FindObject et al. are called in object context, offset by object center
@ -606,15 +606,14 @@ bool C4FindObjectExclude::Check(C4Object *pObj)
return pObj != pExclude;
}
bool C4FindObjectID::Check(C4Object *pObj)
bool C4FindObjectDef::Check(C4Object *pObj)
{
return pObj->id == id;
return pObj->GetPrototype() == def;
}
bool C4FindObjectID::IsImpossible()
bool C4FindObjectDef::IsImpossible()
{
C4Def * pDef = C4Id2Def(id);
return !pDef || !pDef->Count;
return !def || !def->GetDef() || !def->GetDef()->Count;
}
bool C4FindObjectInRect::Check(C4Object *pObj)

View File

@ -169,13 +169,13 @@ protected:
virtual bool Check(C4Object *pObj);
};
class C4FindObjectID : public C4FindObject
class C4FindObjectDef : public C4FindObject
{
public:
C4FindObjectID(C4ID id)
: id(id) { }
C4FindObjectDef(C4PropList * def)
: def(def) { }
private:
C4ID id;
C4PropList * def;
protected:
virtual bool Check(C4Object *pObj);
virtual bool IsImpossible();

View File

@ -61,7 +61,7 @@ C4GoalDisplay::GoalPicture::GoalPicture(const C4Rect &rcBounds, C4ID idGoal, boo
{
Picture.Create(C4PictureSize, C4PictureSize);
// get an object instance to draw (optional; may be zero)
C4Object *pGoalObj = ::Objects.Find(idGoal);
C4Object *pGoalObj = ::Objects.Find(pDrawDef);
// draw goal def!
pDrawDef->Draw(Picture, false, 0, pGoalObj);
}

View File

@ -804,8 +804,8 @@ bool C4MainMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
{
if (!ValidPlr(Player)) return false; // observers may not look at goal/rule info, because it requires queue activation
Close(true);
C4Object *pObj; C4ID idItem(szCommand+12);
if ((pObj = ::Objects.Find(idItem)))
C4Object *pObj; C4ID idItem(szCommand+12); C4Def * pDef = C4Id2Def(idItem);
if (pDef && (pObj = ::Objects.Find(pDef)))
::Control.DoInput(CID_PlrAction, C4ControlPlayerAction::ActivateGoal(::Players.Get(Player), pObj), CDT_Queue);
else
return false;

View File

@ -638,16 +638,16 @@ void C4MouseControl::DragNone()
// check if target object allows scripted dragging
if (fAllowDrag && DownTarget && (!FogOfWar || (DownTarget->Category & C4D_IgnoreFoW)))
{
C4Object *drag_image_obj; C4ID drag_image_id;
C4Object *drag_image_obj; C4Def * drag_image_def;
// Drag only if MD_SOURCE is set and drag image is present
if ( (DownTarget->GetPropertyInt(P_MouseDrag) & C4MC_MD_DragSource) &&
DownTarget->GetDragImage(&drag_image_obj, &drag_image_id))
DownTarget->GetDragImage(&drag_image_obj, &drag_image_def))
{
Drag=C4MC_Drag_Script;
if(drag_image_obj) DragImageObject = drag_image_obj;
else DragImageDef = C4Id2Def(drag_image_id);
else DragImageDef = drag_image_def;
DragObject = DownTarget;
}

View File

@ -20,6 +20,7 @@
#include <C4Include.h>
#include <C4Landscape.h>
#include <C4DefList.h>
#include <C4SolidMask.h>
#include <C4Game.h>
#include <C4Group.h>
@ -929,7 +930,7 @@ bool C4Landscape::Incinerate(int32_t x, int32_t y)
if (MatValid(mat))
if (::MaterialMap.Map[mat].Inflammable)
// Not too much FLAMs
if (!Game.FindObject (C4ID::Flame, x - 4, y - 1, 8, 20))
if (!Game.FindObject (C4Id2Def(C4ID::Flame), x - 4, y - 1, 8, 20))
if (Game.CreateObject(C4ID::Flame,NULL,NO_OWNER,x,y))
return true;
return false;

View File

@ -102,7 +102,7 @@ void C4Def::IncludeDefinition(C4Def*) {}
C4DefList::C4DefList() {}
C4DefList::~C4DefList() {}
C4Def* C4DefList::ID2Def(C4ID) {return NULL;}
C4Def* C4DefList::GetByName(const StdStrBuf &) {return NULL;}
void C4DefList::Draw(C4ID, C4Facet &, bool, int32_t) {}
C4Def * C4DefList::GetDef(int) {return 0;}
int C4DefList::GetDefCount() {return 0;}

View File

@ -940,7 +940,7 @@ void C4Command::Get()
// Get target specified by container and type
if (!Target && Target2 && Data)
if (!(Target = Target2->Contents.Find(Data.getC4ID())))
if (!(Target = Target2->Contents.Find(Data.getDef())))
{ Finish(); return; }
// No target: failure
@ -1116,7 +1116,7 @@ void C4Command::Activate()
C4Object *pObj; C4ObjectLink *cLnk;
if (!Target)
for (cLnk=Target2->Contents.First; cLnk && (pObj=cLnk->Obj); cLnk=cLnk->Next)
if (pObj->Status && (pObj->Def->id==Data.getC4ID()))
if (pObj->Status && (pObj->Def==Data.getDef()))
if (!pObj->Command || (pObj->Command->Command!=C4CMD_Exit))
{ Target=pObj; break; }
// No target
@ -1155,7 +1155,7 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna
// Thing to put specified by type
if (!Target2 && Data)
if (!(Target2 = cObj->Contents.Find(Data.getC4ID())))
if (!(Target2 = cObj->Contents.Find(Data.getDef())))
{ Finish(); return; }
// No thing to put specified
@ -1623,7 +1623,7 @@ void C4Command::Acquire()
if (!Data) { Finish(); return; }
// Target material in inventory: done
if (cObj->Contents.Find(Data.getC4ID()))
if (cObj->Contents.Find(Data.getDef()))
{ Finish(true); return; }
// script overload
@ -1640,7 +1640,7 @@ void C4Command::Acquire()
// Find available material
C4Object *pMaterial=NULL;
// Next closest
while ((pMaterial = Game.FindObject(Data.getC4ID(),cObj->GetX(),cObj->GetY(),-1,-1,OCF_Available,pMaterial)))
while ((pMaterial = Game.FindObject(Data.getDef(),cObj->GetX(),cObj->GetY(),-1,-1,OCF_Available,pMaterial)))
// Object is not in container to be ignored
if (!Target2 || pMaterial->Contained!=Target2)
// Object is near enough
@ -1733,7 +1733,7 @@ void C4Command::Fail(const char *szFailMessage)
if (szFailMessage) break;
// Fail message with name of target type
SCopy(LoadResStr(CommandNameID(Command)), szCommandName);
C4Def *pDef; pDef = ::Definitions.ID2Def(Data.getC4ID());
C4Def *pDef; pDef = Data.getDef();
SCopy(pDef ? pDef->GetName() : LoadResStr("IDS_OBJ_UNKNOWN"), szObjectName);
str.Format(LoadResStr("IDS_CON_FAILUREOF"), szCommandName, szObjectName);
break;

View File

@ -211,6 +211,11 @@ C4Def* C4DefList::ID2Def(C4ID id)
return NULL;
}
C4Def * C4DefList::GetByName(const StdStrBuf & name)
{
return ID2Def(C4ID(name));
}
int32_t C4DefList::GetIndex(C4ID id)
{
C4Def *cdef;

View File

@ -48,6 +48,7 @@ public:
C4Def *ID2Def(C4ID id);
C4Def *GetDef(int32_t Index);
C4Def *GetByPath(const char *szPath);
C4Def *GetByName(const StdStrBuf &);
int32_t GetDefCount();
int32_t GetIndex(C4ID id);
int32_t RemoveTemporary();

View File

@ -1960,13 +1960,13 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode, f
//sprintf(szCommand,"%s %d/%d",CommandName(pCom->Command),pCom->Tx,pCom->Ty,iAngle);
break;
case C4CMD_Put:
sprintf(szCommand,"%s %s to %s",CommandName(pCom->Command),pCom->Target2 ? pCom->Target2->GetName() : pCom->Data ? pCom->Data.getC4ID().ToString() : "Content",pCom->Target ? pCom->Target->GetName() : "");
sprintf(szCommand,"%s %s to %s",CommandName(pCom->Command),pCom->Target2 ? pCom->Target2->GetName() : pCom->Data ? pCom->Data.GetDataString().getData() : "Content",pCom->Target ? pCom->Target->GetName() : "");
break;
case C4CMD_Buy: case C4CMD_Sell:
sprintf(szCommand,"%s %s at %s",CommandName(pCom->Command),pCom->Data.getC4ID().ToString(),pCom->Target ? pCom->Target->GetName() : "closest base");
sprintf(szCommand,"%s %s at %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData(),pCom->Target ? pCom->Target->GetName() : "closest base");
break;
case C4CMD_Acquire:
sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Data.getC4ID().ToString());
sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData());
break;
case C4CMD_Call:
sprintf(szCommand,"%s %s in %s",CommandName(pCom->Command),pCom->Text->GetCStr(),pCom->Target ? pCom->Target->GetName() : "(null)");
@ -2628,7 +2628,7 @@ C4Object *C4Object::ComposeContents(C4ID id)
// Remove components
for (cnt=0; (c_id=NeededComponents.GetID(cnt)); cnt++)
for (cnt2=0; cnt2<NeededComponents.GetCount(cnt); cnt2++)
if (!( pObj = Contents.Find(c_id) ))
if (!( pObj = Contents.Find(C4Id2Def(c_id)) ))
return NULL;
else
pObj->AssignRemoval();
@ -4460,17 +4460,17 @@ void C4Object::GetParallaxity(int32_t *parX, int32_t *parY) const
*parY = par->GetItem(1).getInt();
}
bool C4Object::GetDragImage(C4Object **drag_object, C4ID *drag_id) const
bool C4Object::GetDragImage(C4Object **drag_object, C4Def **drag_def) const
{
// drag is possible if MouseDragImage is assigned
C4Value parV; GetProperty(P_MouseDragImage, &parV);
if (!parV) return false;
// determine drag object/id
C4Object *obj=NULL; C4ID id;
if (parV.CheckConversion(C4V_Object)) obj = parV.getObj();
else if (parV.CheckConversion(C4V_Def)) id = parV.getC4ID();
C4Object *obj = parV.getObj();
C4Def * def = NULL;
if (!obj) def = parV.getDef();
if (drag_object) *drag_object = obj;
if (drag_id) *drag_id = id;
if (drag_def) *drag_def = def;
// drag possible, even w./o image
return true;
}

View File

@ -339,7 +339,7 @@ public:
bool IsInLiquidCheck() const; // returns whether the Clonk is within liquid material
void UpdateInLiquid(); // makes splash when a liquid is entered
void GrabContents(C4Object *pFrom); // grab all contents that don't reject it
bool GetDragImage(C4Object **drag_object, C4ID *drag_id) const; // return true if object is draggable; assign drag_object/drag_id to gfx to be used for dragging
bool GetDragImage(C4Object **drag_object, C4Def **drag_id) const; // return true if object is draggable; assign drag_object/drag_id to gfx to be used for dragging
protected:
void SideBounds(C4Real &ctcox); // apply bounds at side; regarding bourder bound and pLayer

View File

@ -270,13 +270,13 @@ bool C4ObjectList::Remove(C4Object *pObj)
return true;
}
C4Object* C4ObjectList::Find(C4ID id, int owner, DWORD dwOCF)
C4Object* C4ObjectList::Find(C4Def * def, int owner, DWORD dwOCF)
{
C4ObjectLink *cLnk;
// Find link and object
for (cLnk=First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status)
if (cLnk->Obj->Def->id==id)
if (cLnk->Obj->Def==def)
if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner))
if (dwOCF & cLnk->Obj->OCF)
return cLnk->Obj;

View File

@ -116,7 +116,7 @@ public:
const C4Object* GetObject(int Index=0) const;
C4Object* GetObject(int Index=0)
{ return const_cast<C4Object*>(const_cast<const C4ObjectList*>(this)->GetObject(Index)); }
C4Object* Find(C4ID id, int iOwner=ANY_OWNER, DWORD dwOCF=OCF_All);
C4Object* Find(C4Def * def, int iOwner=ANY_OWNER, DWORD dwOCF=OCF_All);
C4Object* FindOther(C4ID id, int iOwner=ANY_OWNER);
const C4ObjectLink* GetLink(const C4Object *pObj) const;

View File

@ -162,7 +162,7 @@ bool C4ObjectMenu::DoRefillInternal(bool &rfRefilled)
{
// easy way: only if first concat check matches
// this doesn't catch all possibilities, but that will rarely matter
C4Object *pObj2=pTarget->Contents.Find(pDef->id, ANY_OWNER, OCF_FullCon);
C4Object *pObj2=pTarget->Contents.Find(pDef, ANY_OWNER, OCF_FullCon);
if (pObj2) if (pObj2->CanConcatPictureWith(pObj)) pObj = pObj2;
}
// Caption
@ -199,7 +199,7 @@ bool C4ObjectMenu::DoRefillInternal(bool &rfRefilled)
{
// easy way: only if first concat check matches
// this doesn't catch all possibilities, but that will rarely matter
C4Object *pObj2 = pTarget->Contents.Find(pDef->id, ANY_OWNER, OCF_FullCon);
C4Object *pObj2 = pTarget->Contents.Find(pDef, ANY_OWNER, OCF_FullCon);
if (pObj2) if (pObj2->CanConcatPictureWith(pObj)) pObj = pObj2;
}
// Determine whether to get or activate

View File

@ -1156,7 +1156,7 @@ static C4Object *FnContents(C4Object *Obj, long index)
return NULL;
}
static bool FnShiftContents(C4Object *Obj, bool fShiftBack, C4ID idTarget, bool fDoCalls)
static bool FnShiftContents(C4Object *Obj, bool fShiftBack, C4Def * idTarget, bool fDoCalls)
{
// regular shift
if (!idTarget) return !!Obj->ShiftContents(fShiftBack, fDoCalls);
@ -1186,7 +1186,7 @@ static long FnContentsCount(C4Object *Obj, C4ID id)
return Obj->Contents.ObjectCount(id);
}
static C4Object *FnFindContents(C4Object *Obj, C4ID c_id)
static C4Object *FnFindContents(C4Object *Obj, C4Def * c_id)
{
return Obj->Contents.Find(c_id);
}

View File

@ -137,7 +137,7 @@ template <> struct C4ValueConv<bool>
template <> struct C4ValueConv<C4ID>
{
inline static C4V_Type Type() { return C4V_PropList; }
inline static C4ID FromC4V(C4Value &v) { return v.getC4ID(); }
inline static C4ID FromC4V(C4Value &v) { C4Def * def = v.getDef(); return def ? def->id : C4ID::None; }
inline static C4ID _FromC4V(C4Value &v) { return FromC4V(v); }
inline static C4Value ToC4V(C4ID v) { return C4VPropList(C4Id2Def(v)); }
};
@ -186,8 +186,8 @@ template <> struct C4ValueConv<C4Effect *>
template <> struct C4ValueConv<C4Def *>
{
inline static C4V_Type Type() { return C4V_Def; }
inline static C4Def *FromC4V(C4Value &v) { C4PropList * p = v.getPropList(); return p ? p->GetDef() : 0; }
inline static C4Def *_FromC4V(C4Value &v) { C4PropList * p = v._getPropList(); return p ? p->GetDef() : 0; }
inline static C4Def *FromC4V(C4Value &v) { return v.getDef(); }
inline static C4Def *_FromC4V(C4Value &v) { return v._getDef(); }
inline static C4Value ToC4V(C4Def *v) { return C4VPropList(v); }
};
template <> struct C4ValueConv<const C4Value &>

View File

@ -40,11 +40,11 @@ bool C4ScriptHost::ResolveAppends(C4DefList *rDefs)
{
// resolve local appends
if (State != ASS_PREPARSED) return false;
for (std::list<C4ID>::iterator a = Appends.begin(); a != Appends.end(); ++a)
for (std::list<StdCopyStrBuf>::iterator a = Appends.begin(); a != Appends.end(); ++a)
{
if (*a)
if (*a != "*")
{
C4Def *Def = rDefs->ID2Def(*a);
C4Def *Def = rDefs->GetByName(*a);
if (Def)
{
if (std::find(Def->Script.SourceScripts.begin(), Def->Script.SourceScripts.end(), GetScriptHost()) == Def->Script.SourceScripts.end())
@ -55,7 +55,7 @@ bool C4ScriptHost::ResolveAppends(C4DefList *rDefs)
// save id in buffer because AulWarn will use the buffer of C4IdText
// to get the id of the object in which the error occurs...
// (stupid static buffers...)
Warn("#appendto %s not found", a->ToString());
Warn("#appendto %s not found", a->getData());
}
}
else
@ -91,9 +91,9 @@ bool C4ScriptHost::ResolveIncludes(C4DefList *rDefs)
}
Resolving=true;
// append all includes to local script
for (std::list<C4ID>::reverse_iterator i = Includes.rbegin(); i != Includes.rend(); ++i)
for (std::list<StdCopyStrBuf>::reverse_iterator i = Includes.rbegin(); i != Includes.rend(); ++i)
{
C4Def *Def = rDefs->ID2Def(*i);
C4Def *Def = rDefs->GetByName(*i);
if (Def)
{
// resolve #includes in included script first (#include-chains :( )
@ -112,7 +112,7 @@ bool C4ScriptHost::ResolveIncludes(C4DefList *rDefs)
// save id in buffer because AulWarn will use the buffer of C4IdText
// to get the id of the object in which the error occurs...
// (stupid static buffers...)
Warn("#include %s not found", i->ToString());
Warn("#include %s not found", i->getData());
}
}
IncludesResolved = true;

View File

@ -1249,7 +1249,7 @@ void C4AulParse::Parse_Script(C4ScriptHost * scripthost)
if (Type == PREPARSER)
{
// add to include list
Host->Includes.push_back(C4ID(StdStrBuf(Idtf)));
Host->Includes.push_back(StdCopyStrBuf(Idtf));
}
Shift();
}
@ -1262,14 +1262,14 @@ void C4AulParse::Parse_Script(C4ScriptHost * scripthost)
if (Type == PREPARSER)
{
// get id of script to include/append
C4ID Id;
StdCopyStrBuf Id;
switch (TokenType)
{
case ATT_IDTF:
Id = C4ID(StdStrBuf(Idtf));
Id = StdCopyStrBuf(Idtf);
break;
case ATT_STAR: // "*"
Id = C4ID::None;
Id = StdCopyStrBuf("*");
break;
default:
// -> ID expected

View File

@ -67,13 +67,6 @@ StdStrBuf FnStringFormat(C4PropList * _this, C4String *szFormatPar, C4Value * Pa
}
// C4ID
case 'i':
{
if (cPar >= ParCount) throw new C4AulExecError("format placeholder without parameter");
C4ID id = Pars[cPar++].getC4ID();
StringBuf.Append(id.ToString());
cpFormat+=SLen(szField);
break;
}
// C4Value
case 'v':
{
@ -251,11 +244,6 @@ static C4Value FnFormat(C4PropList * _this, C4Value * Pars)
return C4VString(FnStringFormat(_this, Pars[0].getStr(), &Pars[1], 9));
}
static C4ID FnC4Id(C4PropList * _this, C4String *szID)
{
return(C4ID(FnStringPar(szID)));
}
static long FnAbs(C4PropList * _this, long iVal)
{
return Abs(iVal);
@ -532,16 +520,12 @@ static bool FnStartCallTrace(C4PropList * _this)
return true;
}
static bool FnStartScriptProfiler(C4PropList * _this, C4ID idScript)
static bool FnStartScriptProfiler(C4PropList * _this, C4Def * pDef)
{
// get script to profile
C4AulScript *pScript;
if (idScript)
{
C4Def *pDef = C4Id2Def(idScript);
if (!pDef) return false;
if (pDef)
pScript = &pDef->Script;
}
else
pScript = &::ScriptEngine;
// profile it
@ -676,7 +660,6 @@ void InitCoreFunctionMap(C4AulScriptEngine *pEngine)
F(GetProperty);
F(SetProperty);
F(ResetProperty);
F(C4Id);
F(Distance);
F(Angle);
F(GetChar);

View File

@ -167,7 +167,7 @@ bool C4DefScriptHost::Parse()
case C4D_Living | C4D_Foreground: Plane = 1400; break;
case C4D_Object | C4D_Foreground: Plane = 1500; break;
default:
Warn("Def %s (%s) has invalid category", Def->GetName(), Def->id.ToString());
Warn("Def %s (%s) has invalid category", Def->GetName(), Def->GetDataString().getData());
gotplane = false;
break;
}
@ -175,7 +175,7 @@ bool C4DefScriptHost::Parse()
}
if (!Def->GetPlane())
{
Warn("Def %s (%s) has invalid Plane", Def->GetName(), Def->id.ToString());
Warn("Def %s (%s) has invalid Plane", Def->GetName(), Def->GetDataString().getData());
Def->SetProperty(P_Plane, C4VInt(1));
}
return r;

View File

@ -48,8 +48,8 @@ protected:
virtual void UnLink(); // reset to unlinked state
std::list<C4ID> Includes; // include list
std::list<C4ID> Appends; // append list
std::list<StdCopyStrBuf> Includes; // include list
std::list<StdCopyStrBuf> Appends; // append list
virtual void AddEngineFunctions() {}; // add any engine functions specific to this script host
void CopyPropList(C4Set<C4Property> & from, C4PropListStatic * to);

View File

@ -47,7 +47,7 @@ const char * C4Config::AtRelativePath(char const*s) {return s;}
C4DefList Definitions;
C4DefList::C4DefList() {}
C4DefList::~C4DefList() {}
C4Def* C4DefList::ID2Def(C4ID id) {return NULL;}
C4Def* C4DefList::GetByName(const StdStrBuf &) {return NULL;}
C4Def * C4DefList::GetDef(int) {return 0;}
int C4DefList::GetDefCount() {return 0;}
void C4DefList::CallEveryDefinition() {}

View File

@ -74,6 +74,16 @@ C4Object * C4Value::_getObj() const
return Data.PropList ? Data.PropList->GetObject() : NULL;
}
C4Def * C4Value::getDef() const
{
return CheckConversion(C4V_Object) ? Data.PropList->GetDef() : NULL;
}
C4Def * C4Value::_getDef() const
{
return Data.PropList ? Data.PropList->GetDef() : NULL;
}
C4Value C4VObj(C4Object *pObj) { return C4Value(static_cast<C4PropList*>(pObj)); }
bool C4Value::FnCnvObject() const
@ -564,15 +574,6 @@ bool C4Value::operator != (const C4Value& Value2) const
return !(*this == Value2);
}
C4ID C4Value::getC4ID() const
{
C4PropList * p = getPropList();
if (!p) return C4ID::None;
C4Def * d = p->GetDef();
if (!d) return C4ID::None;
return d->id;
}
void C4Value::LogDeletedObjectWarning(C4PropList * p)
{
if (p->GetPropListNumbered())

View File

@ -90,8 +90,8 @@ public:
// Checked getters
int32_t getInt() const { return CheckConversion(C4V_Int) ? Data.Int : 0; }
bool getBool() const { return CheckConversion(C4V_Bool) ? !! Data : 0; }
C4ID getC4ID() const;
C4Object * getObj() const;
C4Def * getDef() const;
C4PropList * getPropList() const { return CheckConversion(C4V_PropList) ? Data.PropList : NULL; }
C4String * getStr() const { return CheckConversion(C4V_String) ? Data.Str : NULL; }
C4ValueArray * getArray() const { return CheckConversion(C4V_Array) ? Data.Array : NULL; }
@ -101,6 +101,7 @@ public:
int32_t _getInt() const { return Data.Int; }
bool _getBool() const { return !! Data.Int; }
C4Object *_getObj() const;
C4Def *_getDef() const;
C4String *_getStr() const { return Data.Str; }
C4ValueArray *_getArray() const { return Data.Array; }
C4AulFunc *_getFunction() const { return Data.Fn; }