Commit 1536e0a7 authored by nanahira's avatar nanahira

Merge branch 'server-develop' of git.mycard.moe:nanahira/ygopro into server-develop

parents f9145460 f592c9cc
Pipeline #42988 failed with stages
in 13 minutes and 4 seconds
......@@ -13,6 +13,17 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
auto cur = loadedLists.rend();
char linebuf[256]{};
wchar_t strBuffer[256]{};
auto credit_hash = [](const char* s) -> uint32_t {
uint32_t h = 2166136261u;
for(const unsigned char* p = reinterpret_cast<const unsigned char*>(s); *p; ++p) {
h ^= *p;
h *= 16777619u;
}
return h;
};
auto credit_update_hash = [](uint32_t& h, uint32_t a, uint32_t b, uint32_t c) {
h = h ^ ((a << 18) | (a >> 14)) ^ ((b << 9) | (b >> 23)) ^ ((c << 27) | (c >> 5));
};
if(true) {
while(getLine(linebuf, sizeof linebuf)) {
if(linebuf[0] == '#')
......@@ -50,6 +61,7 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
continue;
BufferIO::DecodeUTF8(keybuf, strBuffer);
cur->credit_limits[strBuffer] = static_cast<uint32_t>(limitValue);
credit_update_hash(cur->hash, credit_hash(keybuf), static_cast<uint32_t>(limitValue), 0x43524544u);
continue;
}
char* pos = linebuf;
......@@ -82,6 +94,7 @@ void DeckManager::LoadLFListFromLineProvider(const std::function<bool(char*, siz
continue;
BufferIO::DecodeUTF8(keybuf, strBuffer);
cur->credits[code][strBuffer] = static_cast<uint32_t>(creditValue);
credit_update_hash(cur->hash, code, credit_hash(keybuf), static_cast<uint32_t>(creditValue));
continue;
}
errno = 0;
......
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