summaryrefslogtreecommitdiff
path: root/src/KingSystem/Quest/qstStep.cpp
blob: 367a7a2cbe495eb0440c079a0ea6d1e6dfbfbd15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "KingSystem/Quest/qstStep.h"
#include <memory>
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Quest/qstActorData.h"
#include "KingSystem/Quest/qstIndicator.h"

namespace ksys::qst {

// NON_MATCHING: regalloc
Step::Step(const u8** iter_data, sead::Heap* heap) : heap(heap) {
    if (*iter_data != nullptr) {
        iter = new (heap, std::nothrow_t()) al::ByamlIter(*iter_data);
    }
}

bool Step::sub_7100FDB89C(act::Actor* actor) const {
    for (int i = 0; i < links.size(); ++i) {
        if (!links[i]->link.hasProc())
            continue;
        if (links[i]->link.hasProcById(actor))
            return true;
    }
    return false;
}

bool Step::sub_7100FDB538(act::Actor* actor, const sead::SafeString& name) const {
    if (actor == nullptr)
        return false;
    if (!_28)
        return true;

    for (int i = 0; i < links.size(); ++i) {
        sead::SafeString actName(actor->getName());
        sead::SafeString uniqName(actor->getUniqueName());
        if (actName != links[i]->name)
            continue;

        if (uniqName != links[i]->unique_name)
            continue;

        if (links[i]->sub_71012B43D0(actor, name)) {
            return true;
        }
    }
    return false;
}

bool Step::initActorData([[maybe_unused]] u32 unused, sead::BufferedSafeString* out_message) {
    if (actor_data != nullptr) {
        // The photo object has already been created.
        out_message->format("写真対象は既に作成されています。");
        return false;
    }

    actor_data = new (heap, std::nothrow_t()) ActorData(heap);
    if (actor_data == nullptr) {
        // Due to insufficient memory, photo data could not be created.
        out_message->format("メモリ不足のため、写真情報を作成できませんでした。");
        return false;
    }
    return actor_data->init(iter, out_message);
}

bool Step::initIndicator([[maybe_unused]] u32 unused, sead::BufferedSafeString* out_message) {
    if (indicator_info != nullptr) {
        // The indicator information has already been created.
        out_message->format("光点情報は既に作成されています。");
        return false;
    }

    indicator_info = new (heap, std::nothrow_t()) Indicator(this, heap);
    if (indicator_info == nullptr) {
        // Due to insufficient memory, indicator information could not be created.
        out_message->format("メモリ不足のため、光点情報を作成できませんでした。");
        return false;
    }
    return indicator_info->init(iter, out_message);
}

bool Step::sub_7100FDC2A4(al::ByamlIter* iter) {
    al::ByamlIter evt_iter;
    al::ByamlIter trg_iter;
    const char* value;

    if (!iter->tryGetIterByKey(&evt_iter, "TriggerEvents"))
        return false;

    for (int i = 0; i < evt_iter.getSize(); ++i) {
        if (evt_iter.tryGetIterByIndex(&trg_iter, i) && trg_iter.isValid() &&
            trg_iter.tryGetStringByKey(&value, "Trigger")) {
            if (sead::SafeString("StepStart") == value)
                return true;
        }
    }
    return false;
}

}  // namespace ksys::qst