summaryrefslogtreecommitdiff
path: root/src/KingSystem/Resource/resResourceAttClient.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-06-15 17:47:03 +0200
committerLéo Lam <leo@leolam.fr>2021-06-15 18:04:39 +0200
commitdd0cc52ce99b9d78f1c7022c1bf13349149f263a (patch)
tree2eb5acd7d704d612181399bd8ab2be7b84fe450f /src/KingSystem/Resource/resResourceAttClient.cpp
parent38e5e47b07696a0954145bf68148cb0301cf133c (diff)
ksys: Move ActorParam classes into separate folder to declutter Resource/
Diffstat (limited to 'src/KingSystem/Resource/resResourceAttClient.cpp')
-rw-r--r--src/KingSystem/Resource/resResourceAttClient.cpp185
1 files changed, 0 insertions, 185 deletions
diff --git a/src/KingSystem/Resource/resResourceAttClient.cpp b/src/KingSystem/Resource/resResourceAttClient.cpp
deleted file mode 100644
index dc00b1a7..00000000
--- a/src/KingSystem/Resource/resResourceAttClient.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-#include "KingSystem/Resource/resResourceAttClient.h"
-#include <container/seadSafeArray.h>
-#include "KingSystem/Resource/resResourceAttCheck.h"
-
-namespace ksys::res {
-
-AttClientList::~AttClientList() {
- mClients.freeBuffer();
-}
-
-void AttClientList::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {}
-
-bool AttClientList::parse_(u8* data, size_t size, sead::Heap* heap) {
- if (!data)
- return false;
-
- agl::utl::ResParameterArchive archive{data};
- const auto root = archive.getRootList();
-
- mAttPos.init(&mAttPosObj);
- mForceEdit.init(false, "ForceEdit", "強制編集", "", &mAttPosObj);
- addObj(&mAttPosObj, "AttPos");
-
- const auto AttClients = agl::utl::getResParameterList(root, "AttClients");
- if (int num; AttClients && (num = AttClients.getResParameterObjNum()) != 0) {
- mClients.allocBufferAssert(num, heap);
- for (auto it = mClients.begin(), end = mClients.end(); it != end; ++it) {
- it->client = nullptr;
- it->name.init("", "Name", "クライアントのキー名", "", &it->obj);
- it->file_name.init("", "FileName", "クライアントのデータファイル名", "", &it->obj);
- it->is_valid.init(true, "IsValid", "デフォルトの有効・無効状態", "", &it->obj);
-
- mAttClientsList.addObj(
- &it->obj, sead::FormatFixedSafeString<32>("%s%d", "AttClient_", it.getIndex()));
- }
- }
-
- addList(&mAttClientsList, "AttClients");
-
- applyResParameterArchive(archive);
- return true;
-}
-
-bool AttClientList::finishParsing_() {
- return true;
-}
-
-bool AttClientList::m7_() {
- for (auto& client : mClients)
- client.client = nullptr;
- return true;
-}
-
-bool AttClientList::isForceEdit() const {
- return mForceEdit.ref();
-}
-
-AttClient::~AttClient() {
- for (int i = 0; i < mChecks.size(); ++i) {
- if (mChecks[i]) {
- delete mChecks[i];
- mChecks[i] = nullptr;
- }
- }
- mChecks.freeBuffer();
-}
-
-void AttClient::doCreate_(u8*, u32, sead::Heap*) {}
-
-namespace {
-
-// Keep this in sync with ksys::act::AttType!
-sead::SafeArray<const char*, 8> sAttTypes = {{
- "Action",
- "Lock",
- "SwordSearch",
- "Attack",
- "Appeal",
- "JumpRide",
- "NameBalloon",
- "LookOnly",
-}};
-
-void parseAttType(const agl::utl::ResParameterObj& AttClientParams, act::AttType* type) {
- const sead::SafeString AttType =
- agl::utl::getResParameter(AttClientParams, "AttType").getData<char>();
-
- *type = act::AttType::Invalid;
-
- for (int i = 0; i < sAttTypes.size(); ++i) {
- if (AttType == sAttTypes[i]) {
- *type = static_cast<act::AttType>(i);
- break;
- }
- }
-
- if (*type == act::AttType::Invalid)
- *type = act::AttType::Action;
-}
-
-void parseActionType(const agl::utl::ResParameterObj& AttClientParams, act::AttActionCode* code) {
- const sead::SafeString ActionType =
- agl::utl::getResParameter(AttClientParams, "ActionType").getData<char>();
-
- *code = act::AttActionCode::Dummy;
-
- for (int i = int(act::AttActionCode::None); i < int(act::AttActionCode::Dummy); ++i) {
- if (ActionType == act::AttActionType::text(i - int(act::AttActionCode::None))) {
- *code = static_cast<act::AttActionCode>(i);
- break;
- }
- }
-
- if (*code == act::AttActionCode::Dummy)
- *code = act::AttActionCode::None;
-}
-
-} // namespace
-
-bool AttClient::parse_(u8* data, size_t size, sead::Heap* heap) {
- if (!data)
- return false;
-
- agl::utl::ResParameterArchive archive{data};
- const auto root = archive.getRootList();
- const auto AttClientParams = root.getResParameterObj(0);
-
- parseAttType(AttClientParams, &mAttType);
- parseActionType(AttClientParams, &mActionCode);
- addObj(&mAttClientParamsObj, "AttClientParams");
-
- mAttTypeParam.init({sAttTypes[0]}, "AttType", "", &mAttClientParamsObj);
- mActionTypeParam.init({act::AttActionType(act::AttActionType::None).text()}, "ActionType", "",
- &mAttClientParamsObj);
- mPriorityTypeParam.init({act::AttPriorityType(act::AttPriorityType::Obj).text()},
- "PriorityType", "", &mAttClientParamsObj);
-
- const int num_checks = root.getResParameterListNum();
- if (num_checks != 0) {
- mChecks.allocBufferAssert(num_checks, heap);
- for (int i = 0; i < num_checks; ++i)
- mChecks[i] = nullptr;
-
- AttCheck::CreateArg arg{};
- arg.heap = heap;
- arg.client = this;
-
- auto it = mChecks.begin(), end = mChecks.end();
- auto res_it = root.listBegin(), res_end = root.listEnd();
- for (; it != end && res_it != res_end; ++res_it, ++it) {
- arg.res_list = res_it.getList();
-
- auto* check = *it = AttCheck::make(arg);
- if (check == nullptr)
- return false;
-
- addList(&check->getList_(),
- sead::FormatFixedSafeString<32>("%s%d", "Check_", it.getIndex()));
- }
- }
-
- applyResParameterArchive(archive);
-
- const sead::SafeString PriorityType = mPriorityTypeParam.ref();
- for (auto priority : act::AttPriorityType{}) {
- if (PriorityType == priority.text()) {
- mPriorityType = priority;
- mPriorityTypeStr = PriorityType;
- return true;
- }
- }
- mPriorityType = act::AttPriorityType::Obj;
- mPriorityTypeStr = mPriorityType.text();
- return true;
-}
-
-int AttClient::getNumChecks() const {
- return mChecks.size();
-}
-
-void AttClient::appendPriority(sead::BufferedSafeString* str) {
- str->append(mPriorityTypeStr);
-}
-
-} // namespace ksys::res