| 1018 | |
| 1019 | |
| 1020 | const char *SimObject::getPrefixedDataField(StringTableEntry fieldName, const char *array) |
| 1021 | { |
| 1022 | // Sanity! |
| 1023 | AssertFatal(fieldName != NULL, "Cannot get field value with NULL field name."); |
| 1024 | |
| 1025 | // Fetch field value. |
| 1026 | const char* pFieldValue = getDataField(fieldName, array); |
| 1027 | |
| 1028 | // Sanity. |
| 1029 | //AssertFatal(pFieldValue != NULL, "Field value cannot be NULL."); |
| 1030 | if (!pFieldValue) |
| 1031 | return NULL; |
| 1032 | |
| 1033 | // Return without the prefix if there's no value. |
| 1034 | if (*pFieldValue == 0) |
| 1035 | return StringTable->EmptyString(); |
| 1036 | |
| 1037 | // Fetch the field prefix. |
| 1038 | StringTableEntry fieldPrefix = getDataFieldPrefix(fieldName); |
| 1039 | |
| 1040 | // Sanity! |
| 1041 | AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL."); |
| 1042 | |
| 1043 | // Calculate a buffer size including prefix. |
| 1044 | const U32 valueBufferSize = dStrlen(fieldPrefix) + dStrlen(pFieldValue) + 1; |
| 1045 | |
| 1046 | // Fetch a buffer. |
| 1047 | char* pValueBuffer = Con::getReturnBuffer(valueBufferSize); |
| 1048 | |
| 1049 | // Format the value buffer. |
| 1050 | dSprintf(pValueBuffer, valueBufferSize, "%s%s", fieldPrefix, pFieldValue); |
| 1051 | |
| 1052 | return pValueBuffer; |
| 1053 | } |
| 1054 | |
| 1055 | //----------------------------------------------------------------------------- |
| 1056 |
no test coverage detected