| 490 | |
| 491 | |
| 492 | void SimObject::onTamlCustomRead(TamlCustomNodes const& customNodes) |
| 493 | { |
| 494 | // Debug Profiling. |
| 495 | //PROFILE_SCOPE(SimObject_OnTamlCustomRead); |
| 496 | |
| 497 | // Fetch field list. |
| 498 | const AbstractClassRep::FieldList& fieldList = getFieldList(); |
| 499 | const U32 fieldCount = fieldList.size(); |
| 500 | for (U32 index = 0; index < fieldCount; ++index) |
| 501 | { |
| 502 | // Fetch field. |
| 503 | const AbstractClassRep::Field* pField = &fieldList[index]; |
| 504 | |
| 505 | // Ignore if field not appropriate. |
| 506 | if (pField->type == AbstractClassRep::StartArrayFieldType || pField->elementCount > 1) |
| 507 | { |
| 508 | // Find cell custom node. |
| 509 | const TamlCustomNode* pCustomCellNodes = NULL; |
| 510 | if (pField->pGroupname != NULL) |
| 511 | pCustomCellNodes = customNodes.findNode(pField->pGroupname); |
| 512 | if (!pCustomCellNodes) |
| 513 | { |
| 514 | char* niceFieldName = const_cast<char *>(pField->pFieldname); |
| 515 | niceFieldName[0] = dToupper(niceFieldName[0]); |
| 516 | String str_niceFieldName = String(niceFieldName); |
| 517 | pCustomCellNodes = customNodes.findNode(str_niceFieldName + "s"); |
| 518 | } |
| 519 | |
| 520 | // Continue if we have explicit cells. |
| 521 | if (pCustomCellNodes != NULL) |
| 522 | { |
| 523 | // Fetch children cell nodes. |
| 524 | const TamlCustomNodeVector& cellNodes = pCustomCellNodes->getChildren(); |
| 525 | |
| 526 | U8 idx = 0; |
| 527 | // Iterate cells. |
| 528 | for (TamlCustomNodeVector::const_iterator cellNodeItr = cellNodes.begin(); cellNodeItr != cellNodes.end(); ++cellNodeItr) |
| 529 | { |
| 530 | char buf[5]; |
| 531 | dSprintf(buf, 5, "%d", idx); |
| 532 | |
| 533 | // Fetch cell node. |
| 534 | TamlCustomNode* pCellNode = *cellNodeItr; |
| 535 | |
| 536 | // Fetch node name. |
| 537 | StringTableEntry nodeName = pCellNode->getNodeName(); |
| 538 | |
| 539 | // Is this a valid alias? |
| 540 | if (nodeName != pField->pFieldname) |
| 541 | { |
| 542 | // No, so warn. |
| 543 | Con::warnf("SimObject::onTamlCustomRead() - Encountered an unknown custom name of '%s'. Only '%s' is valid.", nodeName, pField->pFieldname); |
| 544 | continue; |
| 545 | } |
| 546 | |
| 547 | // Fetch fields. |
| 548 | const TamlCustomFieldVector& fields = pCellNode->getFields(); |
| 549 |
no test coverage detected