Skip to content

Commit

Permalink
move check_playerid to common.h (#698)
Browse files Browse the repository at this point in the history
* move check_playerid to common.h

* update card::get_infos
  • Loading branch information
salix5 authored Dec 15, 2024
1 parent 5c58286 commit 7874592
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
//first 8 bytes: data length, query flag
p += 8;
p += 2 * sizeof(uint32_t);
if (query_flag & QUERY_CODE) {
buffer_write<uint32_t>(p, data.code);
}
Expand Down
4 changes: 4 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <assert.h>
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_ANY(x,y) ((x)&(y))
#define ADD_BIT(x,y) ((x)|=(y))
Expand Down
4 changes: 0 additions & 4 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#include "interpreter.h"
#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};

bool chain::chain_operation_sort(const chain& c1, const chain& c2) {
Expand Down
2 changes: 0 additions & 2 deletions field.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class effect;

using effect_vector = std::vector<effect*>;

bool check_playerid(int32_t playerid);

struct tevent {
card* trigger_card{ nullptr };
group* event_cards{ nullptr };
Expand Down
5 changes: 5 additions & 0 deletions ocgapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32_t code, uint8
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) {
if (!check_playerid(playerid))
return LEN_FAIL;
Expand Down

0 comments on commit 7874592

Please sign in to comment.