| 1 | #include "System/UniqObjInfo.h" |
| 2 | |
| 3 | #include "Library/Math/MathUtil.h" |
| 4 | #include "Library/Placement/PlacementFunction.h" |
| 5 | #include "Library/Placement/PlacementId.h" |
| 6 | |
| 7 | void UniqObjInfo::set(const char* stage_name, const char* obj_id) { |
| 8 | mStageName.format(formatStr: "%s" , stage_name); |
| 9 | mObjId.format(formatStr: "%s" , obj_id); |
| 10 | } |
| 11 | |
| 12 | void UniqObjInfo::set(const sead::BufferedSafeString& stage_name, |
| 13 | const sead::BufferedSafeString& obj_id) { |
| 14 | set(stage_name: stage_name.cstr(), obj_id: obj_id.cstr()); |
| 15 | } |
| 16 | |
| 17 | void UniqObjInfo::set(const char* stage_name, const al::PlacementInfo* placement_info) { |
| 18 | al::PlacementId placement_id; |
| 19 | al::getPlacementId(placementId: &placement_id, placementInfo: *placement_info); |
| 20 | set(stage_name, obj_id: al::makeStringPlacementId(placementId: &placement_id).cstr()); |
| 21 | } |
| 22 | |
| 23 | void UniqObjInfo::clear() { |
| 24 | mStageName.clear(); |
| 25 | mObjId.clear(); |
| 26 | } |
| 27 | |
| 28 | bool UniqObjInfo::isEmpty() const { |
| 29 | return mStageName.isEmpty(); |
| 30 | } |
| 31 | |
| 32 | bool UniqObjInfo::isEqual(const char* stage_name, const char* obj_id) const { |
| 33 | return al::isEqualString(str1: stage_name, str2: mStageName.cstr()) && |
| 34 | al::isEqualString(str1: obj_id, str2: mObjId.cstr()); |
| 35 | } |
| 36 | |
| 37 | bool UniqObjInfo::isEqual(const sead::BufferedSafeString& stage_name, |
| 38 | const sead::BufferedSafeString& obj_id) const { |
| 39 | return isEqual(stage_name: stage_name.cstr(), obj_id: obj_id.cstr()); |
| 40 | } |
| 41 | |
| 42 | bool UniqObjInfo::isEqual(const UniqObjInfo& other) const { |
| 43 | return isEqual(stage_name: other.mStageName, obj_id: other.mObjId); |
| 44 | } |
| 45 | |
| 46 | void UniqObjInfo::print() const {} |
| 47 | |
| 48 | void UniqObjInfo::fillDummyData() { |
| 49 | clear(); |
| 50 | for (s32 i = 0; i < mStageName.getBufferSize(); i++) |
| 51 | mStageName.append(c: al::getRandom(max: 1)); |
| 52 | for (s32 i = 0; i < mObjId.getBufferSize(); i++) |
| 53 | mObjId.append(c: al::getRandom(max: 1)); |
| 54 | } |
| 55 | |