Commit 8f435ab4 authored by nanahira's avatar nanahira

sort loading lflist

parent 9d5e8b84
...@@ -8,47 +8,11 @@ namespace ygo { ...@@ -8,47 +8,11 @@ namespace ygo {
DeckManager deckManager; DeckManager deckManager;
void DeckManager::LoadLFList() { void DeckManager::LoadLFListSingle(const char* path) {
LFList* cur = NULL; LFList* cur = NULL;
FILE* fp = fopen("lflist.conf", "r"); FILE* fp = fopen(path, "r");
FILE* fp_custom = fopen("expansions/lflist.conf", "r");
char linebuf[256]; char linebuf[256];
wchar_t strBuffer[256]; wchar_t strBuffer[256];
if(fp_custom) {
while(fgets(linebuf, 256, fp_custom)) {
if(linebuf[0] == '#')
continue;
int p = 0, sa = 0, code, count;
if(linebuf[0] == '!') {
sa = BufferIO::DecodeUTF8((const char*)(&linebuf[1]), strBuffer);
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' ) sa--;
LFList newlist;
_lfList.push_back(newlist);
cur = &_lfList[_lfList.size() - 1];
memcpy(cur->listName, (const void*)strBuffer, 20 * sizeof(wchar_t));
cur->listName[sa] = 0;
cur->content = new std::unordered_map<int, int>;
cur->hash = 0x7dfcee6a;
continue;
}
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
if(linebuf[p] == 0)
continue;
linebuf[p++] = 0;
sa = p;
code = atoi(linebuf);
if(code == 0)
continue;
while(linebuf[p] == ' ' || linebuf[p] == '\t') p++;
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
linebuf[p] = 0;
count = atoi(&linebuf[sa]);
if(cur == NULL) continue;
(*cur->content)[code] = count;
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
}
fclose(fp_custom);
}
if(fp) { if(fp) {
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
...@@ -84,6 +48,10 @@ void DeckManager::LoadLFList() { ...@@ -84,6 +48,10 @@ void DeckManager::LoadLFList() {
} }
fclose(fp); fclose(fp);
} }
}
void DeckManager::LoadLFList() {
LoadLFListSingle("expansions/lflist.conf");
LoadLFListSingle("lflist.conf");
LFList nolimit; LFList nolimit;
myswprintf(nolimit.listName, L"N/A"); myswprintf(nolimit.listName, L"N/A");
nolimit.hash = 0; nolimit.hash = 0;
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
Deck current_deck; Deck current_deck;
std::vector<LFList> _lfList; std::vector<LFList> _lfList;
void LoadLFListSingle(const char* path);
void LoadLFList(); void LoadLFList();
wchar_t* GetLFListName(int lfhash); wchar_t* GetLFListName(int lfhash);
int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg); int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg);
......
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