diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/WstringLookup.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/WstringLookup.cpp')
| -rw-r--r-- | Minecraft.Client/WstringLookup.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Minecraft.Client/WstringLookup.cpp b/Minecraft.Client/WstringLookup.cpp new file mode 100644 index 00000000..93b189f7 --- /dev/null +++ b/Minecraft.Client/WstringLookup.cpp @@ -0,0 +1,54 @@ + +#include "stdafx.h" + +#include "WstringLookup.h" + +WstringLookup::WstringLookup() +{ + numIDs = 0; +} + +wstring WstringLookup::lookup(UINT id) +{ + // TODO + //if (id > currentMaxID) + // throw error + + return int2str.at(id); +} + +UINT WstringLookup::lookup(wstring str) +{ + if (str2int.find(str) == str2int.end()) + { + pair<wstring,UINT> p = + pair<wstring,UINT>(str, numIDs); + + str2int.insert( p ); + int2str.push_back( str ); + + return numIDs++; + } + else + { + return str2int.at(str); + } +} + +VOID WstringLookup::getTable(wstring **lookup, UINT *len) +{ + // Outputs + wstring *out_lookup; UINT out_len; + + // Fill lookup. + out_lookup = new wstring[int2str.size()]; + for (UINT i = 0; i < numIDs; i++) + out_lookup[i] = int2str.at(i); + + out_len = numIDs; + + // Return. + *lookup = out_lookup; + *len = out_len; + return; +}
\ No newline at end of file |
