| 455 | |
| 456 | |
| 457 | bool OsirisPropertyMapSetRaw(PropertyMapBase const & propertyMap, void * obj, |
| 458 | OsiArgumentDesc const & args, uint32_t firstArg, OsiPropertyMapType type, bool throwError) |
| 459 | { |
| 460 | auto propertyName = args.Get(firstArg).String; |
| 461 | if (obj == nullptr) { |
| 462 | OsiError("Attempted to set property '" << propertyName << "' of null object!"); |
| 463 | return false; |
| 464 | } |
| 465 | |
| 466 | switch (type) { |
| 467 | case OsiPropertyMapType::Integer: |
| 468 | { |
| 469 | auto val = args.Get(firstArg + 1).Int32; |
| 470 | |
| 471 | if (!propertyMap.setFlag(obj, propertyName, val != 0, false, false)) { |
| 472 | return propertyMap.setInt(obj, propertyName, val, false, throwError); |
| 473 | } else { |
| 474 | return true; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | case OsiPropertyMapType::Integer64: |
| 479 | { |
| 480 | auto val = args.Get(firstArg + 1).Int64; |
| 481 | return propertyMap.setInt(obj, propertyName, val, false, throwError); |
| 482 | } |
| 483 | |
| 484 | case OsiPropertyMapType::Real: |
| 485 | { |
| 486 | auto val = args.Get(firstArg + 1).Float; |
| 487 | return propertyMap.setFloat(obj, propertyName, val, false, throwError); |
| 488 | } |
| 489 | |
| 490 | case OsiPropertyMapType::String: |
| 491 | { |
| 492 | auto val = args.Get(firstArg + 1).String; |
| 493 | return propertyMap.setString(obj, propertyName, val, false, throwError); |
| 494 | } |
| 495 | |
| 496 | case OsiPropertyMapType::GuidStringHandle: |
| 497 | { |
| 498 | auto guid = args.Get(firstArg + 1).String; |
| 499 | if (guid == nullptr |
| 500 | || !strlen(guid) |
| 501 | || NameGuidToFixedString(guid) == ToFixedString("00000000-0000-0000-0000-000000000000").Str) { |
| 502 | return propertyMap.setHandle(obj, propertyName, ObjectHandle{}, false, throwError); |
| 503 | } |
| 504 | |
| 505 | auto gameObject = FindGameObjectByNameGuid(guid); |
| 506 | if (gameObject != nullptr) { |
| 507 | ObjectHandle handle; |
| 508 | gameObject->GetObjectHandle(&handle); |
| 509 | return propertyMap.setHandle(obj, propertyName, handle, false, throwError); |
| 510 | } |
| 511 | |
| 512 | OsiError("Failed to set property '" << propertyName << "': Could not map GUID to game object: " << guid); |
| 513 | return false; |
| 514 | } |
no test coverage detected