1#include "Library/Camera/CameraTicketId.h"
2
3#include "Library/Base/StringUtil.h"
4#include "Library/Placement/PlacementId.h"
5#include "Library/Yaml/ByamlUtil.h"
6
7namespace al {
8
9CameraTicketId::CameraTicketId(const PlacementId* placementId, const char* suffix)
10 : mPlacementId(placementId), mSuffix(suffix) {}
11
12bool CameraTicketId::isEqual(const CameraTicketId& other) const {
13 if (!mPlacementId && other.mPlacementId)
14 return false;
15 if (mPlacementId && !other.mPlacementId)
16 return false;
17
18 if (!mPlacementId && !other.mPlacementId)
19 return isEqualString(str1: mSuffix, str2: other.mSuffix);
20 if (!mPlacementId->isEqual(otherId: *other.mPlacementId))
21 return false;
22
23 bool noneSuffix = !mSuffix && !other.mSuffix;
24 if (mSuffix && other.mSuffix)
25 return isEqualString(str1: mSuffix, str2: other.mSuffix);
26
27 return noneSuffix;
28}
29
30bool CameraTicketId::isEqual(const CameraTicketId& ticket1, const CameraTicketId& ticket2) {
31 return ticket1.isEqual(other: ticket2);
32}
33
34// NON_MATCHING: https://decomp.me/scratch/4vdbx
35bool CameraTicketId::isEqual(const ByamlIter& iter) const {
36 const char* id = getObjId();
37 const char* otherId = tryGetByamlKeyStringOrNULL(iter, "ObjId");
38 if (id && otherId) {
39 if (!isEqualString(str1: id, str2: otherId))
40 return false;
41 } else if (id || otherId)
42 return false;
43
44 const char* suffix = mSuffix;
45 const char* otherSuffix = tryGetByamlKeyStringOrNULL(iter, "Suffix");
46 if (suffix && otherSuffix) {
47 if (!isEqualString(str1: suffix, str2: otherSuffix))
48 return false;
49 } else
50 return !suffix && !otherSuffix;
51 return true;
52}
53
54const char* CameraTicketId::tryGetObjId() const {
55 if (!mPlacementId)
56 return nullptr;
57 return mPlacementId->getId();
58}
59
60const char* CameraTicketId::getObjId() const {
61 return tryGetObjId();
62}
63
64} // namespace al
65