Call Definition in every definition at start

This is mainly intended to fill the proplist of the definition and replace
the defcore, but other one time initialisation could also be done at that
point.
Günther Brammer 2009-05-20 00:30:49 +02:00
parent 1964e442f1
commit bf839b9a66
7 changed files with 57 additions and 8 deletions

View File

@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Clonk Doku\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-05-20 00:11+0200\n"
"POT-Creation-Date: 2009-05-20 00:30+0200\n"
"PO-Revision-Date: 2008-05-30 14:30+0100\n"
"Last-Translator: matthes <matthes@clonk.de>\n"
"Language-Team: English\n"
@ -9863,6 +9863,25 @@ msgstr "Calls a function in a script without object context. <placeholder-1/> re
msgid "Gibt Spieler 0 die Pläne für die Burgteile."
msgstr "Gives castle construction plans to player 0."
#: sdk/script/fn/Definition.xml:7(category)
#: sdk/script/fn/Construction.xml:7(category)
#: sdk/script/fn/Activate.xml:7(category)
msgid "Callbacks"
msgstr "Callbacks"
#: sdk/script/fn/Definition.xml:8(subcat)
#, fuzzy
msgid "Definition"
msgstr "definition id"
#: sdk/script/fn/Definition.xml:12(desc)
msgid "Definition, die initialisiert wird."
msgstr ""
#: sdk/script/fn/Definition.xml:15(desc)
msgid "Wird nach dem Laden der Definitionen aufgerufen. Sollte nur die aktuelle Definiton ändern."
msgstr ""
#: sdk/script/fn/DeathAnnounce.xml:12(desc)
msgid "Gibt eine Botschaft a la \"[name] ist von uns gegangen\" über dem aufrufenden Objekt aus."
msgstr "Displays a death message above the calling object."
@ -10331,11 +10350,6 @@ msgstr "Object to examine. Can be 0 in local calls."
msgid "Liefert das Objekt, in dem sich pObj befindet. Rückgabewert Null, wenn pObj sich im Freien befindet."
msgstr "Returns the container object in which this object is contained. Returns 0 if this object is not contained."
#: sdk/script/fn/Construction.xml:7(category)
#: sdk/script/fn/Activate.xml:7(category)
msgid "Callbacks"
msgstr "Callbacks"
#: sdk/script/fn/Construction.xml:12(desc)
msgid "Objekt welches das neu erstellte Objekt erzeugt hat. 0 wenn es global (Szenarioscript,...) erstellt wurde."
msgstr "Object that created the new object. 0 if createt global (Scenarioscript,...)."

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE funcs SYSTEM "../../../clonk.dtd">
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>Definition</title>
<category>Callbacks</category>
<subcat>Definition</subcat>
<version>4.10.0.0</version>
<syntax>
<params>
<param><type>proplist</type><name>def</name><desc>Definition, die initialisiert wird.</desc></param>
</params>
</syntax>
<desc>Wird nach dem Laden der Definitionen aufgerufen. Sollte nur die aktuelle Definiton ändern.</desc>
</func>
<author>Günther</author><date>Mai 2009</date>
</funcs>

View File

@ -414,6 +414,7 @@ class C4DefList
BOOL Add(C4Def *ndef, BOOL fOverload);
void BuildTable(); // build quick access table
void ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains
void CallEveryDefinition();
#ifdef C4ENGINE
void Synchronize();
#endif

View File

@ -150,6 +150,7 @@ void InitFunctionMap(C4AulScriptEngine *pEngine); // add functions to engine
#define PSF_OnHostilityChange "~OnHostilityChange" // int iPlr1, int iPlr2, bool fNewHostility, bool fOldHostility
#define PSF_OnTeamSwitch "~OnTeamSwitch" // int iPlr1, int idNewTeam, int idOldTeam
#define PSF_OnOwnerRemoved "~OnOwnerRemoved"
#define PSF_Definition "~Definition" // proplist definition
// Fx%s is automatically prefixed
#define PSFS_FxAdd "Add" // C4Object *pTarget, int iEffectNumber, C4String *szNewEffect, int iNewTimer, C4Value vNewEffectVar1, C4Value vNewEffectVar2, C4Value vNewEffectVar3, C4Value vNewEffectVar4

View File

@ -265,6 +265,7 @@ void C4AulScriptEngine::Link(C4DefList *rDefs)
// update material pointers
Game.Material.UpdateScriptPointers();
rDefs->CallEveryDefinition();
// display state
LogF("C4AulScriptEngine linked - %d line%s, %d warning%s, %d error%s",
lineCnt, (lineCnt != 1 ? "s" : ""), warnCnt, (warnCnt != 1 ? "s" : ""), errCnt, (errCnt != 1 ? "s" : ""));

View File

@ -1755,3 +1755,13 @@ void C4DefList::ResetIncludeDependencies()
for (pDef=FirstDef; pDef; pDef=pDef->Next)
pDef->ResetIncludeDependencies();
}
void C4DefList::CallEveryDefinition()
{
C4Def *pDef;
for (pDef=FirstDef; pDef; pDef=pDef->Next)
{
C4AulParSet Pars(C4VPropList(pDef));
pDef->Script.Call(PSF_Definition, 0, &Pars, true);
}
}

View File

@ -967,7 +967,9 @@ static C4String *FnGetAction(C4AulContext *cthr, C4Object *pObj)
static C4Value FnGetProperty_C4V(C4AulContext *cthr, C4Value * key_C4V, C4Value * pObj_C4V)
{
C4PropList * pObj = pObj_C4V->_getPropList();
if (!pObj) pObj=cthr->Obj; if (!pObj) return C4VFalse;
if (!pObj) pObj=cthr->Obj;
if (!pObj) pObj=cthr->Def;
if (!pObj) return C4VFalse;
C4String * key = key_C4V->_getStr();
if(!key) return C4VFalse;
C4Value r;
@ -978,7 +980,9 @@ static C4Value FnGetProperty_C4V(C4AulContext *cthr, C4Value * key_C4V, C4Value
static C4Value FnSetProperty_C4V(C4AulContext *cthr, C4Value * key_C4V, C4Value * to, C4Value * pObj_C4V)
{
C4PropList * pObj = pObj_C4V->_getPropList();
if (!pObj) pObj=cthr->Obj; if (!pObj) return C4VFalse;
if (!pObj) pObj=cthr->Obj;
if (!pObj) pObj=cthr->Def;
if (!pObj) return C4VFalse;
C4String * key = key_C4V->_getStr();
if(!key) return C4VFalse;
pObj->SetProperty(key, *to);