mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Add delete handler
This commit is contained in:
parent
d59d0b73be
commit
06092dfea4
@ -474,6 +474,15 @@ LegoWorld* LegoOmni::FindWorld(const MxAtomId& p_atom, MxS32 p_entityid)
|
||||
// STUB: BETA10 0x1008e93e
|
||||
void LegoOmni::DeleteObject(MxDSAction& p_dsAction)
|
||||
{
|
||||
auto result = Extension<SiLoader>::Call(
|
||||
HandleDelete,
|
||||
SiLoader::StreamObject{p_dsAction.GetAtomId(), p_dsAction.GetObjectId()}
|
||||
)
|
||||
.value_or(std::nullopt);
|
||||
if (result && result.value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_dsAction.GetAtomId().GetInternal() != NULL) {
|
||||
LegoWorld* world = FindWorld(p_dsAction.GetAtomId(), p_dsAction.GetObjectId());
|
||||
if (world) {
|
||||
|
||||
@ -19,6 +19,7 @@ class SiLoader {
|
||||
static std::optional<MxCore*> HandleFind(StreamObject p_object, LegoWorld* world);
|
||||
static std::optional<MxResult> HandleStart(StreamObject p_object);
|
||||
static std::optional<MxBool> HandleRemove(StreamObject p_object, LegoWorld* world);
|
||||
static std::optional<MxBool> HandleDelete(StreamObject p_object);
|
||||
|
||||
static std::map<std::string, std::string> options;
|
||||
static std::vector<std::string> files;
|
||||
@ -38,10 +39,12 @@ constexpr auto Load = &SiLoader::Load;
|
||||
constexpr auto HandleFind = &SiLoader::HandleFind;
|
||||
constexpr auto HandleStart = &SiLoader::HandleStart;
|
||||
constexpr auto HandleRemove = &SiLoader::HandleRemove;
|
||||
constexpr auto HandleDelete = &SiLoader::HandleDelete;
|
||||
#else
|
||||
constexpr decltype(&SiLoader::Load) Load = nullptr;
|
||||
constexpr decltype(&SiLoader::HandleFind) HandleFind = nullptr;
|
||||
constexpr decltype(&SiLoader::HandleStart) HandleStart = nullptr;
|
||||
constexpr decltype(&SiLoader::HandleRemove) HandleRemove = nullptr;
|
||||
constexpr decltype(&SiLoader::HandleDelete) HandleDelete = nullptr;
|
||||
#endif
|
||||
}; // namespace Extensions
|
||||
|
||||
@ -87,6 +87,30 @@ std::optional<MxBool> SiLoader::HandleRemove(StreamObject p_object, LegoWorld* w
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<MxBool> SiLoader::HandleDelete(StreamObject p_object)
|
||||
{
|
||||
for (const auto& key : removeWith) {
|
||||
if (key.first == p_object) {
|
||||
MxDSAction action;
|
||||
action.SetAtomId(key.second.first);
|
||||
action.SetObjectId(key.second.second);
|
||||
DeleteObject(&action);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& key : replace) {
|
||||
if (key.first == p_object) {
|
||||
MxDSAction action;
|
||||
action.SetAtomId(key.second.first);
|
||||
action.SetObjectId(key.second.second);
|
||||
DeleteObject(&action);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool SiLoader::LoadFile(const char* p_file)
|
||||
{
|
||||
si::Interleaf si;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user