| 1099 | //----------------------------------------------------------------------------- |
| 1100 | |
| 1101 | const char *SimObject::getPrefixedDynamicDataField(StringTableEntry fieldName, const char *array, const S32 fieldType) |
| 1102 | { |
| 1103 | // Sanity! |
| 1104 | AssertFatal(fieldName != NULL, "Cannot get field value with NULL field name."); |
| 1105 | |
| 1106 | // Fetch field value. |
| 1107 | const char* pFieldValue = getDataField(fieldName, array); |
| 1108 | |
| 1109 | // Sanity. |
| 1110 | AssertFatal(pFieldValue != NULL, "Field value cannot be NULL."); |
| 1111 | |
| 1112 | // Return the field if no field type is specified. |
| 1113 | if (fieldType == -1) |
| 1114 | return pFieldValue; |
| 1115 | |
| 1116 | // Return without the prefix if there's no value. |
| 1117 | if (*pFieldValue == 0) |
| 1118 | return StringTable->EmptyString(); |
| 1119 | |
| 1120 | // Fetch the console base type. |
| 1121 | ConsoleBaseType* pConsoleBaseType = ConsoleBaseType::getType(fieldType); |
| 1122 | |
| 1123 | // Did we find the console base type? |
| 1124 | if (pConsoleBaseType == NULL) |
| 1125 | { |
| 1126 | // No, so warn. |
| 1127 | Con::warnf("getPrefixedDynamicDataField() - Invalid field type '%d' specified for field '%s' with value '%s'.", |
| 1128 | fieldType, fieldName, pFieldValue); |
| 1129 | } |
| 1130 | |
| 1131 | // Fetch the field prefix. |
| 1132 | StringTableEntry fieldPrefix = pConsoleBaseType->getTypePrefix(); |
| 1133 | |
| 1134 | // Sanity! |
| 1135 | AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL."); |
| 1136 | |
| 1137 | // Calculate a buffer size including prefix. |
| 1138 | const U32 valueBufferSize = dStrlen(fieldPrefix) + dStrlen(pFieldValue) + 1; |
| 1139 | |
| 1140 | // Fetch a buffer. |
| 1141 | char* pValueBuffer = Con::getReturnBuffer(valueBufferSize); |
| 1142 | |
| 1143 | // Format the value buffer. |
| 1144 | dSprintf(pValueBuffer, valueBufferSize, "%s%s", fieldPrefix, pFieldValue); |
| 1145 | |
| 1146 | return pValueBuffer; |
| 1147 | } |
| 1148 | |
| 1149 | //----------------------------------------------------------------------------- |
| 1150 |
nothing calls this directly
no test coverage detected