Commit 55679708 authored by salix5's avatar salix5

use array

parent dde64688
......@@ -5,11 +5,12 @@
#include <vector>
constexpr int CARD_ARTWORK_VERSIONS_OFFSET = 10;
constexpr int SIZE_SETCODE = 16;
struct card_data {
uint32 code{};
uint32 alias{};
std::vector<uint16_t> setcode;
uint16_t setcode[SIZE_SETCODE]{};
uint32 type{};
uint32 level{};
uint32 attribute{};
......@@ -23,7 +24,8 @@ struct card_data {
void clear() {
code = 0;
alias = 0;
setcode.clear();
for (auto& x : setcode)
x = 0;
type = 0;
level = 0;
attribute = 0;
......@@ -41,6 +43,8 @@ struct card_data {
for (auto& x : setcode) {
if ((x & 0x0fff) == settype && (x & 0xf000 & setsubtype) == setsubtype)
return true;
if (!x)
return false;
}
return false;
}
......@@ -50,12 +54,16 @@ struct card_data {
}
void set_setcode(uint64 value) {
setcode.clear();
int ctr = 0;
while (value) {
if (value & 0xffff)
setcode.push_back(value & 0xffff);
if (value & 0xffff) {
setcode[ctr] = value & 0xffff;
++ctr;
}
value >>= 16;
}
for (int i = ctr; i < SIZE_SETCODE; ++i)
setcode[i] = 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