Skip to content

Commit

Permalink
Add new CNames to the pool
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Oct 2, 2021
1 parent 0a6fdeb commit 07e51c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/reverse/BasicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ bool CName::operator==(const CName& acRhs) const noexcept
return hash == acRhs.hash;
}

void CName::Add(const std::string& aName)
{
RED4ext::CNamePool::Add(aName.c_str());
}

std::string TweakDBID::ToString() const noexcept
{
return fmt::format("ToTweakDBID{{ hash = 0x{0:08X}, length = {1:d} }}", name_hash, name_length);
Expand Down
2 changes: 2 additions & 0 deletions src/reverse/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ struct CName
std::string ToString() const noexcept;

bool operator==(const CName& acRhs) const noexcept;

static void Add(const std::string& aName);
};

#pragma pack(push, 1)
Expand Down
3 changes: 2 additions & 1 deletion src/scripting/Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ void Scripting::PostInitialize()
sol::meta_function::equal_to, &CName::operator==,
"hash_lo", &CName::hash_lo,
"hash_hi", &CName::hash_hi,
"value", sol::property(&CName::AsString));
"value", sol::property(&CName::AsString),
"add", &CName::Add);

luaGlobal["CName"] = luaVm["CName"];
luaGlobal["ToCName"] = [](sol::table table) -> CName
Expand Down

0 comments on commit 07e51c7

Please sign in to comment.