| 1149 | //----------------------------------------------------------------------------- |
| 1150 | |
| 1151 | void SimObject::setPrefixedDynamicDataField(StringTableEntry fieldName, const char *array, const char *value, const S32 fieldType) |
| 1152 | { |
| 1153 | // Sanity! |
| 1154 | AssertFatal(fieldName != NULL, "Cannot set object field value with NULL field name."); |
| 1155 | AssertFatal(value != NULL, "Field value cannot be NULL."); |
| 1156 | |
| 1157 | // Set value without prefix if no field type was specified. |
| 1158 | if (fieldType == -1) |
| 1159 | { |
| 1160 | setDataField(fieldName, NULL, value); |
| 1161 | return; |
| 1162 | } |
| 1163 | |
| 1164 | // Fetch the console base type. |
| 1165 | ConsoleBaseType* pConsoleBaseType = ConsoleBaseType::getType(fieldType); |
| 1166 | |
| 1167 | // Did we find the console base type? |
| 1168 | if (pConsoleBaseType == NULL) |
| 1169 | { |
| 1170 | // No, so warn. |
| 1171 | Con::warnf("setPrefixedDynamicDataField() - Invalid field type '%d' specified for field '%s' with value '%s'.", |
| 1172 | fieldType, fieldName, value); |
| 1173 | } |
| 1174 | |
| 1175 | // Set value without prefix if there's no value or we didn't find the console base type. |
| 1176 | if (*value == 0 || pConsoleBaseType == NULL) |
| 1177 | { |
| 1178 | setDataField(fieldName, NULL, value); |
| 1179 | return; |
| 1180 | } |
| 1181 | |
| 1182 | // Fetch the field prefix. |
| 1183 | StringTableEntry fieldPrefix = pConsoleBaseType->getTypePrefix(); |
| 1184 | |
| 1185 | // Sanity. |
| 1186 | AssertFatal(fieldPrefix != NULL, "Field prefix cannot be NULL."); |
| 1187 | |
| 1188 | // Do we have a field prefix? |
| 1189 | if (fieldPrefix == StringTable->EmptyString()) |
| 1190 | { |
| 1191 | // No, so set the data field in the usual way. |
| 1192 | setDataField(fieldName, NULL, value); |
| 1193 | return; |
| 1194 | } |
| 1195 | |
| 1196 | // Yes, so fetch the length of the field prefix. |
| 1197 | const U32 fieldPrefixLength = dStrlen(fieldPrefix); |
| 1198 | |
| 1199 | // Yes, so does it start with the object field prefix? |
| 1200 | if (dStrnicmp(value, fieldPrefix, fieldPrefixLength) != 0) |
| 1201 | { |
| 1202 | // No, so set the data field in the usual way. |
| 1203 | setDataField(fieldName, NULL, value); |
| 1204 | return; |
| 1205 | } |
| 1206 | |
| 1207 | // Yes, so set the data excluding the prefix. |
| 1208 | setDataField(fieldName, NULL, value + fieldPrefixLength); |
nothing calls this directly
no test coverage detected