diff --git a/Engine/source/afx/afxEffectGroup.cpp b/Engine/source/afx/afxEffectGroup.cpp index b26550f6e..d16ec4a81 100644 --- a/Engine/source/afx/afxEffectGroup.cpp +++ b/Engine/source/afx/afxEffectGroup.cpp @@ -35,7 +35,7 @@ // When an effect is added using "addEffect", this validator intercepts the value // and adds it to the dynamic effects list. // -void afxEffectGroupData::egValidator::validateType(SimObject* object, void* typePtr) +void afxEffectGroupData::egValidator::validateType(SimObject* object, StringTableEntry varname, void* typePtr) { afxEffectGroupData* eff_data = dynamic_cast(object); afxEffectBaseData** ew = (afxEffectBaseData**)(typePtr); diff --git a/Engine/source/afx/afxEffectGroup.h b/Engine/source/afx/afxEffectGroup.h index 125cb7889..2c3ad480b 100644 --- a/Engine/source/afx/afxEffectGroup.h +++ b/Engine/source/afx/afxEffectGroup.h @@ -60,7 +60,7 @@ class afxEffectGroupData : public afxEffectBaseData U32 id; public: egValidator(U32 id) { this->id = id; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; }; bool do_id_convert; diff --git a/Engine/source/afx/afxEffectron.cpp b/Engine/source/afx/afxEffectron.cpp index c46f626be..43e0fa13b 100644 --- a/Engine/source/afx/afxEffectron.cpp +++ b/Engine/source/afx/afxEffectron.cpp @@ -39,7 +39,7 @@ // When an effect is added using "addEffect", this validator intercepts the value // and adds it to the dynamic effects list. // -void afxEffectronData::ewValidator::validateType(SimObject* object, void* typePtr) +void afxEffectronData::ewValidator::validateType(SimObject* object, StringTableEntry varname, void* typePtr) { afxEffectronData* eff_data = dynamic_cast(object); afxEffectBaseData** ew = (afxEffectBaseData**)(typePtr); diff --git a/Engine/source/afx/afxEffectron.h b/Engine/source/afx/afxEffectron.h index ec0921652..6391dd5dc 100644 --- a/Engine/source/afx/afxEffectron.h +++ b/Engine/source/afx/afxEffectron.h @@ -46,7 +46,7 @@ class afxEffectronData : public afxChoreographerData U32 id; public: ewValidator(U32 id) { this->id = id; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; }; bool do_id_convert; diff --git a/Engine/source/afx/afxMagicSpell.cpp b/Engine/source/afx/afxMagicSpell.cpp index e8c4a9d44..1d86f5303 100644 --- a/Engine/source/afx/afxMagicSpell.cpp +++ b/Engine/source/afx/afxMagicSpell.cpp @@ -43,7 +43,7 @@ // created for each effect list and an id is used to identify which list to add the effect // to. // -void afxMagicSpellData::ewValidator::validateType(SimObject* object, void* typePtr) +void afxMagicSpellData::ewValidator::validateType(SimObject* object, StringTableEntry varname, void* typePtr) { afxMagicSpellData* spelldata = dynamic_cast(object); afxEffectBaseData** ew = (afxEffectBaseData**)(typePtr); diff --git a/Engine/source/afx/afxMagicSpell.h b/Engine/source/afx/afxMagicSpell.h index a978303e0..7967ce1b3 100644 --- a/Engine/source/afx/afxMagicSpell.h +++ b/Engine/source/afx/afxMagicSpell.h @@ -65,7 +65,7 @@ class afxMagicSpellData : public afxChoreographerData, public afxMagicSpellDefs U32 id; public: ewValidator(U32 id) { this->id = id; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; }; bool mDo_id_convert; diff --git a/Engine/source/afx/afxSelectron.cpp b/Engine/source/afx/afxSelectron.cpp index fcc65ccb1..a7eb1d704 100644 --- a/Engine/source/afx/afxSelectron.cpp +++ b/Engine/source/afx/afxSelectron.cpp @@ -38,7 +38,7 @@ // When an effect is added using "addEffect", this validator intercepts the value // and adds it to the dynamic effects list. // -void afxSelectronData::ewValidator::validateType(SimObject* object, void* typePtr) +void afxSelectronData::ewValidator::validateType(SimObject* object, StringTableEntry varname, void* typePtr) { afxSelectronData* sele_data = dynamic_cast(object); afxEffectBaseData** ew = (afxEffectBaseData**)(typePtr); diff --git a/Engine/source/afx/afxSelectron.h b/Engine/source/afx/afxSelectron.h index 780322282..afd68124b 100644 --- a/Engine/source/afx/afxSelectron.h +++ b/Engine/source/afx/afxSelectron.h @@ -57,7 +57,7 @@ class afxSelectronData : public afxChoreographerData, public afxSelectronDefs U32 id; public: ewValidator(U32 id) { this->id = id; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; }; bool do_id_convert; diff --git a/Engine/source/afx/ce/afxPhraseEffect.cpp b/Engine/source/afx/ce/afxPhraseEffect.cpp index 00cda7df3..74228aef8 100644 --- a/Engine/source/afx/ce/afxPhraseEffect.cpp +++ b/Engine/source/afx/ce/afxPhraseEffect.cpp @@ -36,7 +36,7 @@ // When an effect is added using "addEffect", this validator intercepts the value // and adds it to the dynamic effects list. // -void afxPhraseEffectData::ewValidator::validateType(SimObject* object, void* typePtr) +void afxPhraseEffectData::ewValidator::validateType(SimObject* object, StringTableEntry varname, void* typePtr) { afxPhraseEffectData* eff_data = dynamic_cast(object); afxEffectBaseData** ew = (afxEffectBaseData**)(typePtr); diff --git a/Engine/source/afx/ce/afxPhraseEffect.h b/Engine/source/afx/ce/afxPhraseEffect.h index 5fd4c6ab6..bac8bf27a 100644 --- a/Engine/source/afx/ce/afxPhraseEffect.h +++ b/Engine/source/afx/ce/afxPhraseEffect.h @@ -42,7 +42,7 @@ class afxPhraseEffectData : public GameBaseData, public afxEffectDefs, public af U32 id; public: ewValidator(U32 id) { this->id = id; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; }; bool do_id_convert; diff --git a/Engine/source/console/consoleObject.cpp b/Engine/source/console/consoleObject.cpp index 1db5f14a3..9156c1da7 100644 --- a/Engine/source/console/consoleObject.cpp +++ b/Engine/source/console/consoleObject.cpp @@ -646,7 +646,6 @@ void ConsoleObject::addProtectedFieldV(const char* in_pFieldname, f.offset = in_fieldOffset; f.elementCount = in_elementCount; f.validator = v; - f.validator->fieldIndex = sg_tempFieldList.size(); f.flag = flags; f.setDataFn = in_setDataFn; @@ -722,7 +721,6 @@ void ConsoleObject::addFieldV(const char* in_pFieldname, f.writeDataFn = &defaultProtectedWriteFn; f.elementCount = in_elementCount; f.validator = v; - f.validator->fieldIndex = sg_tempFieldList.size(); f.networkMask = 0; sg_tempFieldList.push_back(f); diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index e607fbcfa..fdbc13d72 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -1097,7 +1097,7 @@ void SimObject::setDataField(StringTableEntry slotName, const char *array, const Con::setData(fld->type, (void *) (((const char *)this) + fld->offset), array1, 1, &value, fld->table); if(fld->validator) - fld->validator->validateType(this, (void *) (((const char *)this) + fld->offset)); + fld->validator->validateType(this, fld->pFieldname, (void *) (((const char *)this) + fld->offset)); if (fld->networkMask != 0) { @@ -1111,7 +1111,7 @@ void SimObject::setDataField(StringTableEntry slotName, const char *array, const } if(fld->validator) - fld->validator->validateType(this, (void *) (((const char *)this) + fld->offset)); + fld->validator->validateType(this, fld->pFieldname, (void *) (((const char *)this) + fld->offset)); onStaticModified( slotName, value ); return; diff --git a/Engine/source/console/typeValidators.cpp b/Engine/source/console/typeValidators.cpp index 237055845..0a8402461 100644 --- a/Engine/source/console/typeValidators.cpp +++ b/Engine/source/console/typeValidators.cpp @@ -28,7 +28,7 @@ #include "math/mPoint3.h" #include -void TypeValidator::consoleError(SimObject *object, const char *format, ...) +void TypeValidator::consoleError(SimObject *object, StringTableEntry varname, const char *format, ...) { char buffer[1024]; va_list argptr; @@ -37,22 +37,21 @@ void TypeValidator::consoleError(SimObject *object, const char *format, ...) va_end(argptr); AbstractClassRep *rep = object->getClassRep(); - AbstractClassRep::Field &fld = rep->mFieldList[fieldIndex]; const char *objectName = object->getName(); if(!objectName) objectName = "unnamed"; Con::warnf("%s - %s(%d) - invalid value for %s: %s", - rep->getClassName(), objectName, object->getId(), fld.pFieldname, buffer); + rep->getClassName(), objectName, object->getId(), varname, buffer); } -void FRangeValidator::validateType(SimObject *object, void *typePtr) +void FRangeValidator::validateType(SimObject *object, StringTableEntry varname, void *typePtr) { F32 *v = (F32 *) typePtr; if(*v < minV || *v > maxV) { - consoleError(object, "=(%g). Must be between %g and %g", *v, minV, maxV); + consoleError(object, varname, "=(%g). Must be between %g and %g", *v, minV, maxV); if(*v < minV) *v = minV; else if(*v > maxV) @@ -60,12 +59,12 @@ void FRangeValidator::validateType(SimObject *object, void *typePtr) } } -void IRangeValidator::validateType(SimObject *object, void *typePtr) +void IRangeValidator::validateType(SimObject *object, StringTableEntry varname, void *typePtr) { S32 *v = (S32 *) typePtr; if(*v < minV || *v > maxV) { - consoleError(object, "=(%d). Must be between %d and %d", *v, minV, maxV); + consoleError(object, varname, "=(%d). Must be between %d and %d", *v, minV, maxV); if(*v < minV) *v = minV; else if(*v > maxV) @@ -73,13 +72,13 @@ void IRangeValidator::validateType(SimObject *object, void *typePtr) } } -void IRangeValidatorScaled::validateType(SimObject *object, void *typePtr) +void IRangeValidatorScaled::validateType(SimObject *object, StringTableEntry varname, void *typePtr) { S32 *v = (S32 *) typePtr; *v /= factor; if(*v < minV || *v > maxV) { - consoleError(object, "=(%d). Scaled value must be between %d and %d", *v, minV, maxV); + consoleError(object, varname, "=(%d). Scaled value must be between %d and %d", *v, minV, maxV); if(*v < minV) *v = minV; else if(*v > maxV) @@ -87,13 +86,13 @@ void IRangeValidatorScaled::validateType(SimObject *object, void *typePtr) } } -void Point3NormalizeValidator::validateType(SimObject *object, void *typePtr) +void Point3NormalizeValidator::validateType(SimObject *object, StringTableEntry varname, void *typePtr) { Point3F *v = (Point3F *) typePtr; const F32 len = v->len(); if(!mIsEqual(len, 1.0f)) { - consoleError(object, "=(%g). Vector length must be %g", len, length); + consoleError(object, varname, "=(%g). Vector length must be %g", len, length); *v *= length / len; } } diff --git a/Engine/source/console/typeValidators.h b/Engine/source/console/typeValidators.h index 0a5cd338c..1b0920bce 100644 --- a/Engine/source/console/typeValidators.h +++ b/Engine/source/console/typeValidators.h @@ -30,8 +30,7 @@ class TypeValidator { public: - S32 fieldIndex; - TypeValidator() : fieldIndex(0) {} + TypeValidator() {} ~TypeValidator() {} /// Prints a console error message for the validator. /// @@ -39,11 +38,11 @@ class TypeValidator /// @code /// className objectName (objectId) - invalid value for fieldName: msg /// @endcode - void consoleError(SimObject *object, const char *format, ...); + void consoleError(SimObject *object, StringTableEntry varname, const char *format, ...); /// validateType is called for each assigned value on the field this /// validator is attached to. - virtual void validateType(SimObject *object, void *typePtr) = 0; + virtual void validateType(SimObject *object, StringTableEntry varname, void *typePtr) = 0; }; @@ -58,7 +57,7 @@ public: maxV = mFabs(maxValue) > F32_MIN ? maxValue : 0.0f; mFidelity = fidelity; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; F32 getMin() { return minV; }; F32 getMax() { return maxV; }; F32 getFidelity() { return mFidelity; }; @@ -75,7 +74,7 @@ public: maxV = maxValue; mFidelity = fidelity; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; S32 getMin() { return minV; }; S32 getMax() { return maxV; }; S32 getFidelity() { return mFidelity; }; @@ -96,7 +95,7 @@ public: maxV = maxValueScaled; factor = scaleFactor; } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; S32 getMin() { return minV; }; S32 getMax() { return maxV; }; S32 getScaleFactor() { return factor; }; @@ -108,7 +107,7 @@ class Point3NormalizeValidator : public TypeValidator F32 length; public: Point3NormalizeValidator(F32 normalizeLength = 1.0f) : length(normalizeLength) { } - void validateType(SimObject *object, void *typePtr) override; + void validateType(SimObject *object, StringTableEntry varname, void *typePtr) override; F32 getLength() { return length; }; };