Commit 7874592b authored by salix5's avatar salix5 Committed by GitHub

move check_playerid to common.h (#698)

* move check_playerid to common.h

* update card::get_infos
parent 5c582863
...@@ -167,7 +167,7 @@ int32_t card::get_infos(byte* buf, uint32_t query_flag, int32_t use_cache) { ...@@ -167,7 +167,7 @@ int32_t card::get_infos(byte* buf, uint32_t query_flag, int32_t use_cache) {
base_atk_def = get_base_atk_def(); base_atk_def = get_base_atk_def();
} }
//first 8 bytes: data length, query flag //first 8 bytes: data length, query flag
p += 8; p += 2 * sizeof(uint32_t);
if (query_flag & QUERY_CODE) { if (query_flag & QUERY_CODE) {
buffer_write<uint32_t>(p, data.code); buffer_write<uint32_t>(p, data.code);
} }
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
#include <assert.h> #include <assert.h>
typedef unsigned char byte; typedef unsigned char byte;
inline bool check_playerid(int32_t playerid) {
return playerid >= 0 && playerid <= 1;
}
#define MATCH_ALL(x,y) (((x)&(y))==(y)) #define MATCH_ALL(x,y) (((x)&(y))==(y))
#define MATCH_ANY(x,y) ((x)&(y)) #define MATCH_ANY(x,y) ((x)&(y))
#define ADD_BIT(x,y) ((x)|=(y)) #define ADD_BIT(x,y) ((x)|=(y))
......
...@@ -13,10 +13,6 @@ ...@@ -13,10 +13,6 @@
#include "interpreter.h" #include "interpreter.h"
#include <cstring> #include <cstring>
bool check_playerid(int32_t playerid) {
return playerid >= 0 && playerid <= 1;
}
int32_t field::field_used_count[32] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5}; int32_t field::field_used_count[32] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5};
bool chain::chain_operation_sort(const chain& c1, const chain& c2) { bool chain::chain_operation_sort(const chain& c1, const chain& c2) {
......
...@@ -33,8 +33,6 @@ class effect; ...@@ -33,8 +33,6 @@ class effect;
using effect_vector = std::vector<effect*>; using effect_vector = std::vector<effect*>;
bool check_playerid(int32_t playerid);
struct tevent { struct tevent {
card* trigger_card{ nullptr }; card* trigger_card{ nullptr };
group* event_cards{ nullptr }; group* event_cards{ nullptr };
......
...@@ -190,6 +190,11 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32_t code, uint8 ...@@ -190,6 +190,11 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32_t code, uint8
break; break;
} }
} }
/**
* @brief Get card information.
* @param buf uint32_t array
* @return buffer length in bytes
*/
extern "C" DECL_DLLEXPORT int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, int32_t query_flag, byte* buf, int32_t use_cache) { extern "C" DECL_DLLEXPORT int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, int32_t query_flag, byte* buf, int32_t use_cache) {
if (!check_playerid(playerid)) if (!check_playerid(playerid))
return LEN_FAIL; return LEN_FAIL;
......
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