Commit dde64688 authored by salix5's avatar salix5

card_data: add is_alternative()

parent a517fad9
...@@ -421,7 +421,7 @@ uint32 card::get_info_location() { ...@@ -421,7 +421,7 @@ uint32 card::get_info_location() {
} }
// get the printed code on card // get the printed code on card
uint32 card::get_original_code() const { uint32 card::get_original_code() const {
if (data.alias && (data.alias < data.code + CARD_ARTWORK_VERSIONS_OFFSET) && (data.code < data.alias + CARD_ARTWORK_VERSIONS_OFFSET)) if (data.is_alternative())
return data.alias; return data.alias;
else else
return data.code; return data.code;
......
...@@ -429,6 +429,4 @@ public: ...@@ -429,6 +429,4 @@ public:
#define SUMMON_INFO_REASON_EFFECT 0x200 #define SUMMON_INFO_REASON_EFFECT 0x200
#define SUMMON_INFO_REASON_PLAYER 0x400 #define SUMMON_INFO_REASON_PLAYER 0x400
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif /* CARD_H_ */ #endif /* CARD_H_ */
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "common.h" #include "common.h"
#include <vector> #include <vector>
constexpr int CARD_ARTWORK_VERSIONS_OFFSET = 10;
struct card_data { struct card_data {
uint32 code{}; uint32 code{};
uint32 alias{}; uint32 alias{};
...@@ -43,6 +45,10 @@ struct card_data { ...@@ -43,6 +45,10 @@ struct card_data {
return false; return false;
} }
bool is_alternative() const {
return alias && (alias < code + CARD_ARTWORK_VERSIONS_OFFSET) && (code < alias + CARD_ARTWORK_VERSIONS_OFFSET);
}
void set_setcode(uint64 value) { void set_setcode(uint64 value) {
setcode.clear(); setcode.clear();
while (value) { while (value) {
......
...@@ -56,7 +56,7 @@ int32 interpreter::register_card(card *pcard) { ...@@ -56,7 +56,7 @@ int32 interpreter::register_card(card *pcard) {
//some userdata may be created in script like token so use current_state //some userdata may be created in script like token so use current_state
lua_rawgeti(current_state, LUA_REGISTRYINDEX, pcard->ref_handle); lua_rawgeti(current_state, LUA_REGISTRYINDEX, pcard->ref_handle);
//load script //load script
if(pcard->data.alias && (pcard->data.alias < pcard->data.code + CARD_ARTWORK_VERSIONS_OFFSET) && (pcard->data.code < pcard->data.alias + CARD_ARTWORK_VERSIONS_OFFSET)) if(pcard->data.is_alternative())
load_card_script(pcard->data.alias); load_card_script(pcard->data.alias);
else else
load_card_script(pcard->data.code); load_card_script(pcard->data.code);
......
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