MCPcopy Create free account
hub / github.com/Norbyte/bg3se / LoadTarget

Method LoadTarget

CoreLib/SymbolMapper.cpp:488–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488bool SymbolMappingLoader::LoadTarget(tinyxml2::XMLElement* ele, Pattern const& pattern, SymbolMappings::Target& target)
489{
490 auto name = ele->Attribute("Name");
491 if (name) target.Name = name;
492
493 if (!LoadReference(ele, pattern, target.Ref)) return false;
494
495 auto staticSymbol = ele->Attribute("Symbol");
496 if (staticSymbol) {
497 auto symIt = mappings_.StaticSymbols.find(staticSymbol);
498 if (symIt != mappings_.StaticSymbols.end()) {
499 target.TargetRef = StaticSymbolRef(symIt->second.Offset);
500 symIt->second.Bound = true;
501 } else {
502 ERR("Mapping target references nonexistent engine symbol: '%s'", staticSymbol);
503 return false;
504 }
505 }
506
507 auto nextSymbol = ele->Attribute("NextSymbol");
508 if (nextSymbol) {
509 target.NextSymbol = nextSymbol;
510 auto nextIt = mappings_.Mappings.find(nextSymbol);
511 if (nextIt == mappings_.Mappings.end()) {
512 ERR("Mapping target references nonexistent symbol mapping: '%s'", nextSymbol);
513 return false;
514 }
515
516 if (nextIt->second.Scope != SymbolMappings::MatchScope::kCustom) {
517 ERR("Mapping target references symbol '%s' that has a non-custom scope", nextSymbol);
518 return false;
519 }
520
521 auto nextSymbolSeekSize = GetIntAttribute(ele, "NextSymbolSeekSize");
522 if (!nextSymbolSeekSize) {
523 ERR("Mapping target has invalid NextSymbolSeekSize value.");
524 return false;
525 }
526
527 target.NextSymbolSeekSize = *nextSymbolSeekSize;
528 if (target.NextSymbolSeekSize <= 0) {
529 ERR("Mapping NextSymbolSeekSize must be greater than 0");
530 return false;
531 }
532 }
533
534 auto engineCallback = ele->Attribute("EngineCallback");
535 if (engineCallback) {
536 target.EngineCallback = engineCallback;
537 }
538
539 if (target.Name.empty()) {
540 if (staticSymbol) {
541 target.Name = staticSymbol;
542 } else {
543 target.Name = "(Unnamed)";
544 }
545 }

Callers

nothing calls this directly

Calls 6

StaticSymbolRefClass · 0.85
GetIntAttributeFunction · 0.85
AttributeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected