mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
substitution statements conformed to standard class:mVar standard
This commit is contained in:
parent
1c62080f7f
commit
3c97471630
2 changed files with 26 additions and 26 deletions
|
|
@ -62,20 +62,20 @@ SimDataBlock::SimDataBlock()
|
|||
|
||||
SimDataBlock::SubstitutionStatement::SubstitutionStatement(StringTableEntry slot, S32 idx, const char* value)
|
||||
{
|
||||
this->slot = slot;
|
||||
this->idx = idx;
|
||||
this->value = dStrdup(value);
|
||||
this->mSlot = slot;
|
||||
this->mIdx = idx;
|
||||
this->mValue = dStrdup(value);
|
||||
}
|
||||
|
||||
SimDataBlock::SubstitutionStatement::~SubstitutionStatement()
|
||||
{
|
||||
dFree(value);
|
||||
dFree(mValue);
|
||||
}
|
||||
|
||||
void SimDataBlock::SubstitutionStatement::replaceValue(const char* value)
|
||||
{
|
||||
dFree(this->value);
|
||||
this->value = dStrdup(value);
|
||||
dFree(this->mValue);
|
||||
this->mValue = dStrdup(value);
|
||||
}
|
||||
|
||||
// this is the copy-constructor for creating temp-clones.
|
||||
|
|
@ -109,7 +109,7 @@ void SimDataBlock::addSubstitution(StringTableEntry slot, S32 idx, const char* s
|
|||
|
||||
for (S32 i = 0; i < substitutions.size(); i++)
|
||||
{
|
||||
if (substitutions[i] && substitutions[i]->slot == slot && substitutions[i]->idx == idx)
|
||||
if (substitutions[i] && substitutions[i]->mSlot == slot && substitutions[i]->mIdx == idx)
|
||||
{
|
||||
if (empty_subs)
|
||||
{
|
||||
|
|
@ -137,8 +137,8 @@ const char* SimDataBlock::getSubstitution(StringTableEntry slot, S32 idx)
|
|||
{
|
||||
for (S32 i = 0; i < substitutions.size(); i++)
|
||||
{
|
||||
if (substitutions[i] && substitutions[i]->slot == slot && substitutions[i]->idx == idx)
|
||||
return substitutions[i]->value;
|
||||
if (substitutions[i] && substitutions[i]->mSlot == slot && substitutions[i]->mIdx == idx)
|
||||
return substitutions[i]->mValue;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -147,7 +147,7 @@ const char* SimDataBlock::getSubstitution(StringTableEntry slot, S32 idx)
|
|||
bool SimDataBlock::fieldHasSubstitution(StringTableEntry slot)
|
||||
{
|
||||
for (S32 i = 0; i < substitutions.size(); i++)
|
||||
if (substitutions[i] && substitutions[i]->slot == slot)
|
||||
if (substitutions[i] && substitutions[i]->mSlot == slot)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ void SimDataBlock::printSubstitutions()
|
|||
{
|
||||
for (S32 i = 0; i < substitutions.size(); i++)
|
||||
if (substitutions[i])
|
||||
Con::errorf("SubstitutionStatement[%s] = \"%s\" -- %d", substitutions[i]->slot, substitutions[i]->value, i);
|
||||
Con::errorf("SubstitutionStatement[%s] = \"%s\" -- %d", substitutions[i]->mSlot, substitutions[i]->mValue, i);
|
||||
}
|
||||
|
||||
void SimDataBlock::copySubstitutionsFrom(SimDataBlock* other)
|
||||
|
|
@ -170,7 +170,7 @@ void SimDataBlock::copySubstitutionsFrom(SimDataBlock* other)
|
|||
if (other->substitutions[i])
|
||||
{
|
||||
SubstitutionStatement* subs = other->substitutions[i];
|
||||
substitutions.push_back(new SubstitutionStatement(subs->slot, subs->idx, subs->value));
|
||||
substitutions.push_back(new SubstitutionStatement(subs->mSlot, subs->mIdx, subs->mValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
|||
char* b = buffer;
|
||||
|
||||
// perform special token expansion (%% and ##)
|
||||
const char* v = substitutions[i]->value;
|
||||
const char* v = substitutions[i]->mValue;
|
||||
while (*v != '\0')
|
||||
{
|
||||
// identify "%%" tokens and replace with <obj> id
|
||||
|
|
@ -258,7 +258,7 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
|||
if (Compiler::gSyntaxError)
|
||||
{
|
||||
Con::errorf("Field Substitution Failed: field=\"%s\" substitution=\"%s\" -- syntax error",
|
||||
substitutions[i]->slot, substitutions[i]->value);
|
||||
substitutions[i]->mSlot, substitutions[i]->mValue);
|
||||
Compiler::gSyntaxError = false;
|
||||
return;
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
|||
if (result == 0 || result[0] == '\0')
|
||||
{
|
||||
Con::errorf("Field Substitution Failed: field=\"%s\" substitution=\"%s\" -- empty result",
|
||||
substitutions[i]->slot, substitutions[i]->value);
|
||||
substitutions[i]->mSlot, substitutions[i]->mValue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -282,29 +282,29 @@ void SimDataBlock::performSubstitutions(SimDataBlock* dblock, const SimObject* o
|
|||
result = "";
|
||||
}
|
||||
|
||||
const AbstractClassRep::Field* field = dblock->getClassRep()->findField(substitutions[i]->slot);
|
||||
const AbstractClassRep::Field* field = dblock->getClassRep()->findField(substitutions[i]->mSlot);
|
||||
if (!field)
|
||||
{
|
||||
// this should be very unlikely...
|
||||
Con::errorf("Field Substitution Failed: unknown field, \"%s\".", substitutions[i]->slot);
|
||||
Con::errorf("Field Substitution Failed: unknown field, \"%s\".", substitutions[i]->mSlot);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (field->keepClearSubsOnly && result[0] != '\0')
|
||||
{
|
||||
Con::errorf("Field Substitution Failed: field \"%s\" of datablock %s only allows \"$$ ~~\" (keep) and \"$$ ~0\" (clear) field substitutions. [%s]",
|
||||
substitutions[i]->slot, this->getClassName(), this->getName());
|
||||
substitutions[i]->mSlot, this->getClassName(), this->getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
// substitute the field value with its replacement
|
||||
Con::setData(field->type, (void*)(((const char*)(dblock)) + field->offset), substitutions[i]->idx, 1, &result, field->table, field->flag);
|
||||
Con::setData(field->type, (void*)(((const char*)(dblock)) + field->offset), substitutions[i]->mIdx, 1, &result, field->table, field->flag);
|
||||
|
||||
//dStrncpy(buffer, result, 255);
|
||||
//Con::errorf("SUBSTITUTION %s.%s[%d] = %s idx=%s", Con::getIntArg(getId()), substitutions[i]->slot, substitutions[i]->idx, buffer, index_str);
|
||||
|
||||
// notify subclasses of a field modification
|
||||
dblock->onStaticModified(substitutions[i]->slot);
|
||||
dblock->onStaticModified(substitutions[i]->mSlot);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -366,9 +366,9 @@ void SimDataBlock::packData(BitStream* stream)
|
|||
if (substitutions[i])
|
||||
{
|
||||
stream->writeFlag(true);
|
||||
stream->writeString(substitutions[i]->slot);
|
||||
stream->write(substitutions[i]->idx);
|
||||
stream->writeString(substitutions[i]->value);
|
||||
stream->writeString(substitutions[i]->mSlot);
|
||||
stream->write(substitutions[i]->mIdx);
|
||||
stream->writeString(substitutions[i]->mValue);
|
||||
}
|
||||
}
|
||||
stream->writeFlag(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue