MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / onTamlCustomRead

Method onTamlCustomRead

Engine/source/console/simObject.cpp:492–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490
491
492void 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

Callers 1

tamlCustomReadMethod · 0.45

Calls 12

dToupperFunction · 0.85
dSprintfFunction · 0.85
getNodeNameMethod · 0.80
StringClass · 0.70
warnfFunction · 0.70
sizeMethod · 0.45
findNodeMethod · 0.45
getChildrenMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getFieldNameMethod · 0.45
getFieldValueMethod · 0.45

Tested by

no test coverage detected