Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
Improved the object getters
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed May 14, 2022
1 parent 2369c9d commit d9ab718
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Code/Lib/BuildVersion.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#pragma once
#define SMBC_BUILD_VERSION 863
#define SMBC_BUILD_VERSION 864
18 changes: 12 additions & 6 deletions Code/ObjectDatabase/ModData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,26 @@ namespace SMBC

const PartData* Mod::GetPart(const SMBC::Uuid& uuid)
{
const ObjectData* current_obj = GetObject(uuid);
if (!current_obj || current_obj->Type() != ObjectType::Part)
if (Mod::AllObjects.find(uuid) == Mod::AllObjects.end())
return nullptr;

return static_cast<const PartData*>(current_obj);
const ObjectData* p_cur_obj = Mod::AllObjects.at(uuid);
if (p_cur_obj->Type() != ObjectType::Part)
return nullptr;

return static_cast<const PartData*>(p_cur_obj);
}

const BlockData* Mod::GetBlock(const SMBC::Uuid& uuid)
{
const ObjectData* current_obj = GetObject(uuid);
if (!current_obj || current_obj->Type() != ObjectType::Block)
if (Mod::AllObjects.find(uuid) == Mod::AllObjects.end())
return nullptr;

const ObjectData* p_cur_obj = Mod::AllObjects.at(uuid);
if (p_cur_obj->Type() != ObjectType::Block)
return nullptr;

return static_cast<const BlockData*>(current_obj);
return static_cast<const BlockData*>(p_cur_obj);
}

Mod* Mod::CreateModFromDirectory(const std::wstring& dir)
Expand Down

0 comments on commit d9ab718

Please sign in to comment.