the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1
2#include "stdafx.h"
3
4#include "WstringLookup.h"
5
6WstringLookup::WstringLookup()
7{
8 numIDs = 0;
9}
10
11wstring WstringLookup::lookup(UINT id)
12{
13 // TODO
14 //if (id > currentMaxID)
15 // throw error
16
17 return int2str.at(id);
18}
19
20UINT WstringLookup::lookup(wstring str)
21{
22 if (str2int.find(str) == str2int.end())
23 {
24 pair<wstring,UINT> p =
25 pair<wstring,UINT>(str, numIDs);
26
27 str2int.insert( p );
28 int2str.push_back( str );
29
30 return numIDs++;
31 }
32 else
33 {
34 return str2int.at(str);
35 }
36}
37
38VOID WstringLookup::getTable(wstring **lookup, UINT *len)
39{
40 // Outputs
41 wstring *out_lookup; UINT out_len;
42
43 // Fill lookup.
44 out_lookup = new wstring[int2str.size()];
45 for (UINT i = 0; i < numIDs; i++)
46 out_lookup[i] = int2str.at(i);
47
48 out_len = numIDs;
49
50 // Return.
51 *lookup = out_lookup;
52 *len = out_len;
53 return;
54}