Script: Remove unused category parameter from GetDefinition

While at it, also remove it from the internal function and a bunch of dead
code from C4IDList.
floating-point
Günther Brammer 2011-03-07 21:26:56 +01:00
parent 98757cb488
commit c009851ce2
9 changed files with 54 additions and 152 deletions

View File

@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenClonk documentation\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-02-18 21:42+0100\n"
"POT-Creation-Date: 2011-03-07 21:09+0100\n"
"PO-Revision-Date: 2010-11-24 22:17+0100\n"
"Last-Translator: Günther Brammer <gbrammer@gmx.de>\n"
"Language-Team: German <>\n"
@ -7557,18 +7557,11 @@ msgstr "Hinweis: <placeholder-1/> = 0 / <placeholder-2/> = 1"
msgid "Index of the definition."
msgstr "Index der gesuchten Definition."
#: sdk/script/fn/GetDefinition.xml:21(desc)
msgid "Category of the definition."
msgstr "Die Kategorie, in der die gesuchte Definition ist."
#: sdk/script/fn/GetDefinition.xml:26(desc)
msgid "Returns the id of the indicated definition from the list of definitions of the specified category as currently loaded by the engine (category 0 for all categories)."
#: sdk/script/fn/GetDefinition.xml:20(desc)
#, fuzzy
msgid "Returns the id of the indicated definition from the list of definitions as currently loaded by the engine."
msgstr "Liefert das ID der indizierten von der Engine in dieser Runde geladenen Objektdefinition der angegebenen Kategorie (category 0 für alle Objektkategorien)."
#: sdk/script/fn/GetDefinition.xml:29(text)
msgid "see <placeholder-1/>."
msgstr "siehe <placeholder-1/>."
#: sdk/script/fn/GetDefCoreVal.xml:32(desc)
msgid "Returns the property value of an object definition by its name in the <emlink href=\"definition/defcore.html\">DefCore.txt</emlink>."
msgstr "Gibt einen Eigenschaftswert der aufrufenden Objektdefinition nach seinem Namen in der <emlink href=\"definition/defcore.html\">DefCore.txt</emlink> zurück."
@ -16292,12 +16285,31 @@ msgstr "Über das Condition-Feld kann bestimmt werden, dass die Funktion nur dan
msgid "Every object has a number of properties that are handled by the engine. Typically, these are inherited from the object's Prototype, an <emlink href=\"definition/index.html#Objektdefinitionen\">Object Definition</emlink>. A Property of an Object Definition is defined with the <code>local</code> keyword in the <emlink href=\"definition/script.html#Objektscripte\">Definition's script</emlink>:"
msgstr ""
#: sdk/definition/properties.xml:120(col)
#: sdk/definition/properties.xml:30(col)
#: sdk/definition/properties.xml:50(col)
#: sdk/definition/properties.xml:90(col)
#, fuzzy
msgid "proplist"
msgstr "Proplisten"
#: sdk/definition/properties.xml:35(col)
#, fuzzy
msgid "string"
msgstr "Zeichenkette"
#: sdk/definition/properties.xml:105(col)
#: sdk/definition/properties.xml:110(col)
#: sdk/definition/properties.xml:115(col)
#: sdk/definition/properties.xml:125(col)
#, fuzzy
msgid "int"
msgstr "Bit"
#: sdk/definition/properties.xml:120(col)
#, fuzzy
msgid "[int, int]"
msgstr "int, int"
#: sdk/definition/properties.xml:121(col)
#, fuzzy
msgid "The Objects's major Z-Position. See <placeholder-1/>."
@ -16832,10 +16844,6 @@ msgstr "Lokale Objektdefinitionen, die nur als Teil eines Szenarios verbreitet w
msgid "Object definitions created by community players but publicly released should use the format AB3C of which the first two characters should identify the object and the second two (one digit and one character) should identify the developer. This is to avoid id conflicts with other developers."
msgstr "Von Spielern erstellte Objektdefinitionen, die auch einzeln veröffentlicht werden, sollten das Format AB3C nutzen, wobei nur die ersten beiden Zeichen frei vergeben werden können und die letzten beiden Zeichen (1 Ziffer und 1 Buchstabe) das Entwickler-ID des Spielers darstellen, welches frei wählbar ist, wobei allerdings Überschneidungen mit bereits von anderen Entwicklern benutzten IDs vermieden werden sollten."
#: sdk/definition/index.xml:96(script)
msgid "if (netscape.security.PrivilegeManager.enablePrivilege) window.onload = tr; function tr() { try { netscape.security.PrivilegeManager.enablePrivilege(\"UniversalBrowserRead\"); } catch (e) { return; } var xhr = new XMLHttpRequest(); xhr.open(\"GET\", \"../../clonk.xsl\", false); xhr.send(null); var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xhr.responseXML); document.replaceChild(xsltProcessor.transformToDocument(document).documentElement, document.documentElement); };"
msgstr ""
#: sdk/definition/defcore.xml:9(text)
msgid "The component DefCore.txt defines the basic characteristics of an object. This includes the object category (whether it is a building or a living being), graphics, entrance and collection areas, value, mass, and so on. Here also the object id is defined which is used to identify the object type in script calls or other components. Every object definition must have a unique object id. Also see <emlink href=\"definition/index.html#ObjektundEntwicklerIdentifikation\">object and developer identification</emlink>."
msgstr "In der Komponente DefCore.txt eines Objekts lässt sich das Basisverhalten eines Objekts einrichten. Dazu gehören zum Beispiel die Kategorie, also ob es sich um ein Gebäude oder ein Lebewesen handelt, die Grafik, Eingangs- und Einsammelbereiche, Brennbarkeit, Wert, Masse, und so weiter. Außerdem wird hier das Objekt-ID angegeben, mit dem dieser Objekttyp später in Scripten referenziert wird - es ist wichtig, dass jedes Objekt ein eigenes ID hat. Hierzu siehe auch <emlink href=\"definition/index.html#ObjektundEntwicklerIdentifikation\">Objekt- und Entwickleridentifikation</emlink>."
@ -17981,6 +17989,12 @@ msgstr "c4group.exe (Windows) c4group (Linux) c4group (Mac)"
msgid "This command line program is used for processing group files. A list of command line options is available by starting the program without parameters via command line (<i>not</i> by double clicking)."
msgstr "Dieses Kommandozeilen-Programm dient zum Bearbeiten von Gruppendateien. Es kann nicht per Doppelklick, sondern nur per Kommandozeile (Eingabeaufforderung) gestartet werden. Auskunft über alle verfügbaren Kommandozeilenparameter erhält man, indem man das Programm ohne weitere Parameter über die Kommandozeile startet."
#~ msgid "Category of the definition."
#~ msgstr "Die Kategorie, in der die gesuchte Definition ist."
#~ msgid "see <placeholder-1/>."
#~ msgstr "siehe <placeholder-1/>."
#~ msgid "LineConnect"
#~ msgstr "LineConnect"

View File

@ -15,18 +15,20 @@
<name>index</name>
<desc>Index of the definition.</desc>
</param>
<param>
<type>int</type>
<name>category</name>
<desc>Category of the definition.</desc>
<optional />
</param>
</params>
</syntax>
<desc>Returns the id of the indicated definition from the list of definitions of the specified category as currently loaded by the engine (category 0 for all categories).</desc>
<desc>Returns the id of the indicated definition from the list of definitions as currently loaded by the engine.</desc>
<examples>
<example>
<text>see <funclink>C4D_Goal</funclink>.</text>
<code>
var index = 0, weapon_def, weapon_list = [];
while (weapon_def = GetDefinition(index))
{
if (weapon_def->~IsPlaneWeapon())
weapon_list[GetLength(weapon_list)] = weapon_def;
index++;
}
spawn_weapon = weapon_list[Random(GetLength(weapon_list))];</code>
</example>
</examples>
<related>

View File

@ -302,25 +302,23 @@ int32_t C4DefList::GetIndex(C4ID id)
return -1;
}
int32_t C4DefList::GetDefCount(DWORD dwCategory)
int32_t C4DefList::GetDefCount()
{
C4Def *cdef; int32_t ccount=0;
for (cdef=FirstDef; cdef; cdef=cdef->Next)
if (cdef->Category & dwCategory)
ccount++;
ccount++;
return ccount;
}
C4Def* C4DefList::GetDef(int32_t iIndex, DWORD dwCategory)
C4Def* C4DefList::GetDef(int32_t iIndex)
{
C4Def *pDef; int32_t iCurrentIndex;
if (iIndex<0) return NULL;
for (pDef=FirstDef,iCurrentIndex=-1; pDef; pDef=pDef->Next)
if (pDef->Category & dwCategory)
{
iCurrentIndex++;
if (iCurrentIndex==iIndex) return pDef;
}
{
iCurrentIndex++;
if (iCurrentIndex==iIndex) return pDef;
}
return NULL;
}

View File

@ -60,9 +60,9 @@ public:
C4SoundSystem *pSoundSystem = NULL,
bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0);
C4Def *ID2Def(C4ID id);
C4Def *GetDef(int32_t Index, DWORD dwCategory = C4D_All);
C4Def *GetDef(int32_t Index);
C4Def *GetByPath(const char *szPath);
int32_t GetDefCount(DWORD dwCategory = C4D_All);
int32_t GetDefCount();
int32_t GetIndex(C4ID id);
int32_t RemoveTemporary();
int32_t CheckEngineVersion(int32_t ver1, int32_t ver2, int32_t ver3, int32_t ver4);

View File

@ -368,14 +368,6 @@ bool C4IDList::Add(C4IDList &rList)
return true;
}
// Removes all empty id gaps from the list.
bool C4IDList::Consolidate()
{
// however, there ain't be any of those crappy gaps!
return false;
}
bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
{
bool fIDsRemoved=false;
@ -403,53 +395,6 @@ bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
return fIDsRemoved;
}
void C4IDList::SortByValue(C4DefList &rDefs)
{
bool fBubble;
size_t cnt;
C4Def *cdef1,*cdef2;
do
{
fBubble=false;
for (cnt=0; cnt+1<Count; cnt++)
if ((cdef1=rDefs.ID2Def(GetID(cnt))) && (cdef2=rDefs.ID2Def(GetID(cnt+1))))
// FIXME: Should call GetValue here
if (cdef1->Value > cdef2->Value)
{
SwapItems(cnt, cnt+1);
fBubble=true;
}
}
while (fBubble);
}
void C4IDList::Load(C4DefList &rDefs, int32_t dwCategory)
{
// (deprecated, use StdCompiler instead)
C4Def *cdef; size_t cntl=0,cnt=0;
// clear list
Clear();
// add all IDs of def list
C4IDListChunk *pChunk=this;
while ((cdef=rDefs.GetDef(cnt++,dwCategory)))
{
// add new chunk if necessary
if (cntl==C4IDListChunkSize)
{
C4IDListChunk *pLast=this;
while (pLast->pNext) pLast=pLast->pNext;
pChunk=new C4IDListChunk();
pLast->pNext=pChunk;
cntl=0;
}
// set def
pChunk->id[cntl]=cdef->id;
pChunk->Count[cntl]=0;
// advance in own list
++cntl; ++Count;
}
}
void C4IDList::Draw(C4Facet &cgo, int32_t iSelection,
C4DefList &rDefs, DWORD dwCategory,
bool fCounts, int32_t iAlign) const
@ -477,52 +422,6 @@ void C4IDList::Default()
Clear();
}
bool C4IDList::ConsolidateCounts()
{
bool fIDsRemoved=false;
C4IDListChunk *pQueryChunk=this;
size_t cnt=Count,cntl=0;
while (cnt--)
{
if (!pQueryChunk->Count[cntl])
{
// delete it
DeleteItem(Count-cnt-1);
// handle this list index again!
--cntl;
// something was done
fIDsRemoved=true;
}
if (++cntl==C4IDListChunkSize)
{
pQueryChunk=pQueryChunk->pNext;
cntl=0;
}
}
return fIDsRemoved;
}
bool C4IDList::SwapItems(size_t iIndex1, size_t iIndex2)
{
// Invalid index
if (!Inside<size_t>(iIndex1+1,1u,Count)) return false;
if (!Inside<size_t>(iIndex2+1,1u,Count)) return false;
// get first+second chunk and index
C4IDListChunk *pChunk1=this;
while (iIndex1>=C4IDListChunkSize) { pChunk1=pChunk1->pNext; iIndex1-=C4IDListChunkSize; }
C4IDListChunk *pChunk2=this;
while (iIndex2>=C4IDListChunkSize) { pChunk2=pChunk2->pNext; iIndex2-=C4IDListChunkSize; }
// swap id & count
int32_t iTemp = pChunk1->Count[iIndex1];
C4ID idTemp = pChunk1->id[iIndex1];
pChunk1->Count[iIndex1] = pChunk2->Count[iIndex2];
pChunk1->id [iIndex1] = pChunk2->id [iIndex2];
pChunk2->Count[iIndex2] = iTemp;
pChunk2->id [iIndex2] = idTemp;
// done
return true;
}
// Clear index entry and shift all entries behind down by one.
bool C4IDList::DeleteItem(size_t iIndex)

View File

@ -86,14 +86,9 @@ public:
// IDList merge
bool Add(C4IDList &rList);
// Aux
bool Consolidate();
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory = 0);
bool ConsolidateCounts();
void SortByValue(C4DefList &rDefs);
void Load(C4DefList &rDefs, int32_t dwCategory);
// Item operation
bool DeleteItem(size_t iIndex);
bool SwapItems(size_t iIndex1, size_t iIndex2);
// Graphics
void Draw(C4Facet &cgo, int32_t iSelection,
C4DefList &rDefs, DWORD dwCategory,

View File

@ -737,15 +737,9 @@ static C4Value FnGetPlrKnowledge_C4V(C4AulContext *cthr, C4Value* iPlr_C4V, C4Va
return C4VPropList(C4Id2Def(::Players.Get(iPlr)->Knowledge.GetID( ::Definitions, dwCategory, iIndex )));
}
static C4ID FnGetDefinition(C4AulContext *cthr, long iIndex, long dwCategory)
static C4Def * FnGetDefinition(C4AulContext *cthr, long iIndex)
{
C4Def *pDef;
// Default: all categories
if (!dwCategory) dwCategory=C4D_All;
// Get def
if (!(pDef = ::Definitions.GetDef(iIndex,dwCategory))) return C4ID::None;
// Return id
return pDef->id;
return ::Definitions.GetDef(iIndex);
}
static C4Value FnGetComponent_C4V(C4AulContext *cthr, C4Value* idComponent_C4V, C4Value* iIndex_C4V, C4Value* pObj_C4V, C4Value* idDef_C4V)

View File

@ -203,7 +203,7 @@ template <> struct C4ValueConv<C4Def *>
inline static C4V_Type Type() { return C4V_PropList; }
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 C4Value ToC4V(C4Effect *v) { return C4VPropList(v); }
inline static C4Value ToC4V(C4Def *v) { return C4VPropList(v); }
};
template <> struct C4ValueConv<const C4Value &>
{

View File

@ -59,8 +59,8 @@ C4DefList Definitions;
C4DefList::C4DefList() {}
C4DefList::~C4DefList() {}
C4Def* C4DefList::ID2Def(C4ID id) {return NULL;}
C4Def * C4DefList::GetDef(int, unsigned int) {return 0;}
int C4DefList::GetDefCount(unsigned int) {return 0;}
C4Def * C4DefList::GetDef(int) {return 0;}
int C4DefList::GetDefCount() {return 0;}
void C4DefList::CallEveryDefinition() {}
void C4DefList::ResetIncludeDependencies() {}
bool C4DefList::GetFontImage(char const*, CFacet&) {return false;}