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

Method ValidateMappedComponentSize

BG3Extender/GameDefinitions/EntitySystem.cpp:1455–1500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1453}
1454
1455bool EntitySystemHelpersBase::ValidateMappedComponentSize(ecs::EntityWorld* world, ComponentTypeIndex typeId, ExtComponentType extType)
1456{
1457 auto mapped = world->ComponentRegistry_.Get(typeId);
1458 auto const& local = components_[(unsigned)extType];
1459 auto name = ecsComponentData_.Get(typeId).Name;
1460 if (mapped != nullptr) {
1461 if (!local.Properties) {
1462 WARN("[ECS INTEGRITY CHECK] '%s' has no property map", name->c_str());
1463 return false;
1464 }
1465
1466 if (local.IsProxy) {
1467 if (mapped->InlineSize != sizeof(void*)) {
1468 ERR("[ECS INTEGRITY CHECK] '%s' marked as proxy, but entity only has inline data (%d)",
1469 name->c_str(), mapped->InlineSize);
1470 return false;
1471 }
1472
1473 if (mapped->InlineSize != sizeof(void*) || mapped->ComponentSize != local.Size) {
1474 ERR("[ECS INTEGRITY CHECK] '%s' OOB size mismatch: local %d, ECS %d",
1475 name->c_str(), local.Size, mapped->ComponentSize);
1476 // Don't unmap since OOB mismatch doesn't invalidate component store layout
1477 return true;
1478 }
1479 } else {
1480 if (mapped->InlineSize != mapped->ComponentSize) {
1481 ERR("[ECS INTEGRITY CHECK] '%s' marked as non-proxy, but entity has OOB data (inline %d, OOB %d)",
1482 name->c_str(), mapped->InlineSize, mapped->ComponentSize);
1483 return false;
1484 }
1485
1486 if (mapped->ComponentSize != local.Size) {
1487 ERR("[ECS INTEGRITY CHECK] '%s' size mismatch: local %d, ECS %d",
1488 name->c_str(), local.Size, mapped->ComponentSize);
1489 return false;
1490 }
1491 }
1492
1493 if (mapped->OneFrame != local.OneFrame) {
1494 ERR("[ECS INTEGRITY CHECK] '%s' one-frame type mismatch", name->c_str());
1495 return false;
1496 }
1497 }
1498
1499 return true;
1500}
1501
1502void EntitySystemHelpersBase::ValidateECBFlushChanges()
1503{

Callers

nothing calls this directly

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected