Commit 497b364a authored by Chen Bill's avatar Chen Bill Committed by GitHub

add constant MAX_STRING_ID, MIN_CARD_ID (#2538)

MAX_STRING_ID=2047, MIN_CARD_ID=128
parent 41d0ed07
...@@ -224,7 +224,7 @@ const wchar_t* DataManager::GetText(unsigned int code) { ...@@ -224,7 +224,7 @@ const wchar_t* DataManager::GetText(unsigned int code) {
return unknown_string; return unknown_string;
} }
const wchar_t* DataManager::GetDesc(unsigned int strCode) { const wchar_t* DataManager::GetDesc(unsigned int strCode) {
if(strCode < 10000u) if (strCode < (MIN_CARD_ID << 4))
return GetSysString(strCode); return GetSysString(strCode);
unsigned int code = (strCode >> 4) & 0x0fffffff; unsigned int code = (strCode >> 4) & 0x0fffffff;
unsigned int offset = strCode & 0xf; unsigned int offset = strCode & 0xf;
...@@ -236,7 +236,7 @@ const wchar_t* DataManager::GetDesc(unsigned int strCode) { ...@@ -236,7 +236,7 @@ const wchar_t* DataManager::GetDesc(unsigned int strCode) {
return unknown_string; return unknown_string;
} }
const wchar_t* DataManager::GetSysString(int code) { const wchar_t* DataManager::GetSysString(int code) {
if(code < 0 || code >= 2048) if (code < 0 || code > MAX_STRING_ID)
return unknown_string; return unknown_string;
auto csit = _sysStrings.find(code); auto csit = _sysStrings.find(code);
if(csit == _sysStrings.end()) if(csit == _sysStrings.end())
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <unordered_map> #include <unordered_map>
namespace ygo { namespace ygo {
constexpr int MAX_STRING_ID = 0x7ff;
constexpr unsigned int MIN_CARD_ID = (unsigned int)(MAX_STRING_ID + 1) >> 4;
class DataManager { class DataManager {
public: public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment