Commit bfa930df authored by wind2009's avatar wind2009

Merge remote-tracking branch 'upstream/master' into develop

parents 0bd1cfab 836bacd5
...@@ -23,44 +23,44 @@ These functions create the game itself and then manipulate it. ...@@ -23,44 +23,44 @@ These functions create the game itself and then manipulate it.
- `intptr_t create_duel(uint_fast32_t seed);` - `intptr_t create_duel(uint_fast32_t seed);`
Create a the instance of the duel with a PRNG seed. Create a the instance of the duel with a PRNG seed.
- `void start_duel(intptr_t pduel, uint32 options);` - `void start_duel(intptr_t pduel, uint32_t options);`
Start the duel. Start the duel.
- `void end_duel(intptr_t pduel);` - `void end_duel(intptr_t pduel);`
End the duel. End the duel.
- `void set_player_info(intptr_t pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount);` - `void set_player_info(intptr_t pduel, int32_t playerid, int32_t lp, int32_t startcount, int32_t drawcount);`
Set up the duel information. Set up the duel information.
- `void get_log_message(intptr_t pduel, char* buf);` - `void get_log_message(intptr_t pduel, char* buf);`
- `int32 get_message(intptr_t pduel, byte* buf);` - `int32_t get_message(intptr_t pduel, byte* buf);`
- `int32 process(intptr_t pduel);` - `int32_t process(intptr_t pduel);`
Do a game tick. Do a game tick.
- `void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);` - `void new_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position);`
Add a card to the duel state. Add a card to the duel state.
- `void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location);` - `void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t location);`
Add a new card to the tag pool. Add a new card to the tag pool.
- `int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache);` - `int32_t query_field_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint32_t query_flag, byte* buf, int32_t use_cache);`
Get a card in a specific location. Get a card in a specific location.
- `int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location);` - `int32_t query_field_count(intptr_t pduel, uint8_t playerid, uint8_t location);`
Get the number of cards in a specific location. Get the number of cards in a specific location.
- `int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache);` - `int32_t query_field_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint32_t query_flag, byte* buf, int32_t use_cache);`
Get all cards in some location. Get all cards in some location.
- `int32 query_field_info(intptr_t pduel, byte* buf);` - `int32_t query_field_info(intptr_t pduel, byte* buf);`
- `void set_responsei(intptr_t pduel, int32 value);` - `void set_responsei(intptr_t pduel, int32_t value);`
- `void set_responseb(intptr_t pduel, byte* buf);` - `void set_responseb(intptr_t pduel, byte* buf);`
- `int32 preload_script(intptr_t pduel, const char* script_name);` - `int32_t preload_script(intptr_t pduel, const char* script_name);`
# Lua functions # Lua functions
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
constexpr int CARD_ARTWORK_VERSIONS_OFFSET = 20; constexpr int CARD_ARTWORK_VERSIONS_OFFSET = 20;
constexpr int SIZE_SETCODE = 16; constexpr int SIZE_SETCODE = 16;
constexpr uint32 CARD_BLACK_LUSTER_SOLDIER2 = 5405695; constexpr uint32_t CARD_BLACK_LUSTER_SOLDIER2 = 5405695;
//double name //double name
constexpr uint32 CARD_MARINE_DOLPHIN = 78734254; constexpr uint32_t CARD_MARINE_DOLPHIN = 78734254;
constexpr uint32 CARD_TWINKLE_MOSS = 13857930; constexpr uint32_t CARD_TWINKLE_MOSS = 13857930;
constexpr uint32 CARD_TIMAEUS = 1784686; constexpr uint32_t CARD_TIMAEUS = 1784686;
constexpr uint32 CARD_CRITIAS = 11082056; constexpr uint32_t CARD_CRITIAS = 11082056;
constexpr uint32 CARD_HERMOS = 46232525; constexpr uint32_t CARD_HERMOS = 46232525;
const std::unordered_map<uint32, uint32> second_code = { const std::unordered_map<uint32_t, uint32_t> second_code = {
{CARD_MARINE_DOLPHIN, 17955766u}, {CARD_MARINE_DOLPHIN, 17955766u},
{CARD_TWINKLE_MOSS, 17732278u}, {CARD_TWINKLE_MOSS, 17732278u},
{CARD_TIMAEUS, 10000050u}, {CARD_TIMAEUS, 10000050u},
...@@ -24,18 +24,18 @@ const std::unordered_map<uint32, uint32> second_code = { ...@@ -24,18 +24,18 @@ const std::unordered_map<uint32, uint32> second_code = {
}; };
struct card_data { struct card_data {
uint32 code{}; uint32_t code{};
uint32 alias{}; uint32_t alias{};
uint16_t setcode[SIZE_SETCODE]{}; uint16_t setcode[SIZE_SETCODE]{};
uint32 type{}; uint32_t type{};
uint32 level{}; uint32_t level{};
uint32 attribute{}; uint32_t attribute{};
uint32 race{}; uint32_t race{};
int32 attack{}; int32_t attack{};
int32 defense{}; int32_t defense{};
uint32 lscale{}; uint32_t lscale{};
uint32 rscale{}; uint32_t rscale{};
uint32 link_marker{}; uint32_t link_marker{};
void clear() { void clear() {
code = 0; code = 0;
...@@ -53,7 +53,7 @@ struct card_data { ...@@ -53,7 +53,7 @@ struct card_data {
link_marker = 0; link_marker = 0;
} }
bool is_setcode(uint32 value) const { bool is_setcode(uint32_t value) const {
uint16_t settype = value & 0x0fff; uint16_t settype = value & 0x0fff;
uint16_t setsubtype = value & 0xf000; uint16_t setsubtype = value & 0xf000;
for (auto& x : setcode) { for (auto& x : setcode) {
...@@ -71,7 +71,7 @@ struct card_data { ...@@ -71,7 +71,7 @@ struct card_data {
return alias && (alias < code + CARD_ARTWORK_VERSIONS_OFFSET) && (code < alias + CARD_ARTWORK_VERSIONS_OFFSET); return alias && (alias < code + CARD_ARTWORK_VERSIONS_OFFSET) && (code < alias + CARD_ARTWORK_VERSIONS_OFFSET);
} }
void set_setcode(uint64 value) { void set_setcode(uint64_t value) {
int ctr = 0; int ctr = 0;
while (value) { while (value) {
if (value & 0xffff) { if (value & 0xffff) {
...@@ -84,7 +84,7 @@ struct card_data { ...@@ -84,7 +84,7 @@ struct card_data {
setcode[i] = 0; setcode[i] = 0;
} }
uint32 get_original_code() const { uint32_t get_original_code() const {
return is_alternative() ? alias : code; return is_alternative() ? alias : code;
} }
}; };
......
...@@ -10,15 +10,11 @@ ...@@ -10,15 +10,11 @@
#include <stdint.h> #include <stdint.h>
#include <assert.h> #include <assert.h>
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
typedef unsigned char byte; typedef unsigned char byte;
typedef long long int64;
typedef int int32; inline bool check_playerid(int32_t playerid) {
typedef short int16; return playerid >= 0 && playerid <= 1;
typedef signed char int8; }
#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))
...@@ -39,10 +35,6 @@ typedef signed char int8; ...@@ -39,10 +35,6 @@ typedef signed char int8;
#define PROCESSOR_WAITING 0x10000000 #define PROCESSOR_WAITING 0x10000000
#define PROCESSOR_END 0x20000000 #define PROCESSOR_END 0x20000000
#ifndef NULL
#define NULL 0
#endif
#define MASTER_RULE3 3 //Master Rule 3 (2014) #define MASTER_RULE3 3 //Master Rule 3 (2014)
#define NEW_MASTER_RULE 4 //New Master Rule (2017) #define NEW_MASTER_RULE 4 //New Master Rule (2017)
#define MASTER_RULE_2020 5 //Master Rule 2020 #define MASTER_RULE_2020 5 //Master Rule 2020
......
...@@ -48,7 +48,7 @@ void duel::clear() { ...@@ -48,7 +48,7 @@ void duel::clear() {
game_field = new field(this); game_field = new field(this);
game_field->temp_card = new_card(0); game_field->temp_card = new_card(0);
} }
card* duel::new_card(uint32 code) { card* duel::new_card(uint32_t code) {
card* pcard = new card(this); card* pcard = new card(this);
cards.insert(pcard); cards.insert(pcard);
if (code != TEMP_CARD_ID) if (code != TEMP_CARD_ID)
...@@ -97,11 +97,11 @@ void duel::delete_effect(effect* peffect) { ...@@ -97,11 +97,11 @@ void duel::delete_effect(effect* peffect) {
effects.erase(peffect); effects.erase(peffect);
delete peffect; delete peffect;
} }
int32 duel::read_buffer(byte* buf) { int32_t duel::read_buffer(byte* buf) {
auto size = buffer_size(); auto size = buffer_size();
if (size) if (size)
std::memcpy(buf, message_buffer.data(), size); std::memcpy(buf, message_buffer.data(), size);
return (int32)size; return (int32_t)size;
} }
void duel::release_script_group() { void duel::release_script_group() {
for(auto& pgroup : sgroups) { for(auto& pgroup : sgroups) {
...@@ -121,25 +121,25 @@ void duel::restore_assumes() { ...@@ -121,25 +121,25 @@ void duel::restore_assumes() {
void duel::write_buffer(const void* data, int size) { void duel::write_buffer(const void* data, int size) {
vector_write_block(message_buffer, data, size); vector_write_block(message_buffer, data, size);
} }
void duel::write_buffer32(uint32 value) { void duel::write_buffer32(uint32_t value) {
vector_write<uint32_t>(message_buffer, value); vector_write<uint32_t>(message_buffer, value);
} }
void duel::write_buffer16(uint16 value) { void duel::write_buffer16(uint16_t value) {
vector_write<uint16_t>(message_buffer, value); vector_write<uint16_t>(message_buffer, value);
} }
void duel::write_buffer8(uint8 value) { void duel::write_buffer8(uint8_t value) {
vector_write<unsigned char>(message_buffer, value); vector_write<unsigned char>(message_buffer, value);
} }
void duel::clear_buffer() { void duel::clear_buffer() {
message_buffer.clear(); message_buffer.clear();
} }
void duel::set_responsei(uint32 resp) { void duel::set_responsei(uint32_t resp) {
game_field->returns.ivalue[0] = resp; game_field->returns.ivalue[0] = resp;
} }
void duel::set_responseb(byte* resp) { void duel::set_responseb(byte* resp) {
std::memcpy(game_field->returns.bvalue, resp, SIZE_RETURN_VALUE); std::memcpy(game_field->returns.bvalue, resp, SIZE_RETURN_VALUE);
} }
int32 duel::get_next_integer(int32 l, int32 h) { int32_t duel::get_next_integer(int32_t l, int32_t h) {
if (game_field->core.duel_options & DUEL_OLD_REPLAY) { if (game_field->core.duel_options & DUEL_OLD_REPLAY) {
return random.get_random_integer_old(l, h); return random.get_random_integer_old(l, h);
} }
......
...@@ -41,10 +41,10 @@ public: ...@@ -41,10 +41,10 @@ public:
~duel(); ~duel();
void clear(); void clear();
uint32 buffer_size() const { uint32_t buffer_size() const {
return (uint32)message_buffer.size() & PROCESSOR_BUFFER_LEN; return (uint32_t)message_buffer.size() & PROCESSOR_BUFFER_LEN;
} }
card* new_card(uint32 code); card* new_card(uint32_t code);
group* new_group(); group* new_group();
group* new_group(card* pcard); group* new_group(card* pcard);
group* new_group(const card_set& cset); group* new_group(const card_set& cset);
...@@ -54,15 +54,15 @@ public: ...@@ -54,15 +54,15 @@ public:
void delete_effect(effect* peffect); void delete_effect(effect* peffect);
void release_script_group(); void release_script_group();
void restore_assumes(); void restore_assumes();
int32 read_buffer(byte* buf); int32_t read_buffer(byte* buf);
void write_buffer(const void* data, int size); void write_buffer(const void* data, int size);
void write_buffer32(uint32 value); void write_buffer32(uint32_t value);
void write_buffer16(uint16 value); void write_buffer16(uint16_t value);
void write_buffer8(uint8 value); void write_buffer8(uint8_t value);
void clear_buffer(); void clear_buffer();
void set_responsei(uint32 resp); void set_responsei(uint32_t resp);
void set_responseb(byte* resp); void set_responseb(byte* resp);
int32 get_next_integer(int32 l, int32 h); int32_t get_next_integer(int32_t l, int32_t h);
private: private:
group* register_group(group* pgroup); group* register_group(group* pgroup);
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -27,8 +27,8 @@ public: ...@@ -27,8 +27,8 @@ public:
duel* pduel; duel* pduel;
card_set container; card_set container;
card_set::iterator it; card_set::iterator it;
int32 ref_handle{ 0 }; int32_t ref_handle{ 0 };
uint32 is_readonly{ GTYPE_DEFAULT }; uint32_t is_readonly{ GTYPE_DEFAULT };
bool is_iterator_dirty{ true }; bool is_iterator_dirty{ true };
bool has_card(card* c) { bool has_card(card* c) {
......
This diff is collapsed.
...@@ -23,7 +23,7 @@ class effect; ...@@ -23,7 +23,7 @@ class effect;
class group; class group;
class duel; class duel;
enum LuaParamType : int32 { enum LuaParamType : int32_t {
PARAM_TYPE_INT = 0x01, PARAM_TYPE_INT = 0x01,
PARAM_TYPE_STRING = 0x02, PARAM_TYPE_STRING = 0x02,
PARAM_TYPE_CARD = 0x04, PARAM_TYPE_CARD = 0x04,
...@@ -38,9 +38,9 @@ class interpreter { ...@@ -38,9 +38,9 @@ class interpreter {
public: public:
union lua_param { union lua_param {
void* ptr; void* ptr;
int32 integer; int32_t integer;
}; };
using coroutine_map = std::unordered_map<int32, std::pair<lua_State*, int32>>; using coroutine_map = std::unordered_map<int32_t, std::pair<lua_State*, int32_t>>;
using param_list = std::list<std::pair<lua_param, LuaParamType>>; using param_list = std::list<std::pair<lua_param, LuaParamType>>;
duel* pduel; duel* pduel;
...@@ -50,8 +50,8 @@ public: ...@@ -50,8 +50,8 @@ public:
param_list params; param_list params;
param_list resumes; param_list resumes;
coroutine_map coroutines; coroutine_map coroutines;
int32 no_action; int32_t no_action;
int32 call_depth; int32_t call_depth;
explicit interpreter(duel* pd); explicit interpreter(duel* pd);
~interpreter(); ~interpreter();
...@@ -62,28 +62,28 @@ public: ...@@ -62,28 +62,28 @@ public:
void register_group(group* pgroup); void register_group(group* pgroup);
void unregister_group(group* pgroup); void unregister_group(group* pgroup);
int32 load_script(const char* script_name); int32_t load_script(const char* script_name);
int32 load_card_script(uint32 code); int32_t load_card_script(uint32_t code);
void add_param(void* param, LuaParamType type, bool front = false); void add_param(void* param, LuaParamType type, bool front = false);
void add_param(int32 param, LuaParamType type, bool front = false); void add_param(int32_t param, LuaParamType type, bool front = false);
void push_param(lua_State* L, bool is_coroutine = false); void push_param(lua_State* L, bool is_coroutine = false);
int32 call_function(int32 f, uint32 param_count, int32 ret_count); int32_t call_function(int32_t f, uint32_t param_count, int32_t ret_count);
int32 call_card_function(card* pcard, const char* f, uint32 param_count, int32 ret_count); int32_t call_card_function(card* pcard, const char* f, uint32_t param_count, int32_t ret_count);
int32 call_code_function(uint32 code, const char* f, uint32 param_count, int32 ret_count); int32_t call_code_function(uint32_t code, const char* f, uint32_t param_count, int32_t ret_count);
int32 check_condition(int32 f, uint32 param_count); int32_t check_condition(int32_t f, uint32_t param_count);
int32 check_filter(lua_State* L, card* pcard, int32 findex, int32 extraargs); int32_t check_filter(lua_State* L, card* pcard, int32_t findex, int32_t extraargs);
int32 get_operation_value(card* pcard, int32 findex, int32 extraargs); int32_t get_operation_value(card* pcard, int32_t findex, int32_t extraargs);
int32 get_function_value(int32 f, uint32 param_count); int32_t get_function_value(int32_t f, uint32_t param_count);
int32 get_function_value(int32 f, uint32 param_count, std::vector<lua_Integer>& result); int32_t get_function_value(int32_t f, uint32_t param_count, std::vector<lua_Integer>& result);
int32 call_coroutine(int32 f, uint32 param_count, int32* yield_value, uint16 step); int32_t call_coroutine(int32_t f, uint32_t param_count, int32_t* yield_value, uint16_t step);
int32 clone_function_ref(int32 func_ref); int32_t clone_function_ref(int32_t func_ref);
void* get_ref_object(int32 ref_handler); void* get_ref_object(int32_t ref_handler);
static void card2value(lua_State* L, card* pcard); static void card2value(lua_State* L, card* pcard);
static void group2value(lua_State* L, group* pgroup); static void group2value(lua_State* L, group* pgroup);
static void effect2value(lua_State* L, effect* peffect); static void effect2value(lua_State* L, effect* peffect);
static void function2value(lua_State* L, int32 func_ref); static void function2value(lua_State* L, int32_t func_ref);
static int32 get_function_handle(lua_State* L, int32 index); static int32_t get_function_handle(lua_State* L, int32_t index);
static duel* get_duel_info(lua_State* L); static duel* get_duel_info(lua_State* L);
static bool is_load_script(const card_data& data); static bool is_load_script(const card_data& data);
......
This diff is collapsed.
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "effect.h" #include "effect.h"
#include "ocgapi.h" #include "ocgapi.h"
int32 scriptlib::debug_message(lua_State *L) { int32_t scriptlib::debug_message(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
lua_getglobal(L, "tostring"); lua_getglobal(L, "tostring");
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
...@@ -22,16 +22,16 @@ int32 scriptlib::debug_message(lua_State *L) { ...@@ -22,16 +22,16 @@ int32 scriptlib::debug_message(lua_State *L) {
handle_message(pduel, 2); handle_message(pduel, 2);
return 0; return 0;
} }
int32 scriptlib::debug_add_card(lua_State *L) { int32_t scriptlib::debug_add_card(lua_State *L) {
check_param_count(L, 6); check_param_count(L, 6);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 code = (int32)lua_tointeger(L, 1); int32_t code = (int32_t)lua_tointeger(L, 1);
int32 owner = (int32)lua_tointeger(L, 2); int32_t owner = (int32_t)lua_tointeger(L, 2);
int32 playerid = (int32)lua_tointeger(L, 3); int32_t playerid = (int32_t)lua_tointeger(L, 3);
int32 location = (int32)lua_tointeger(L, 4); int32_t location = (int32_t)lua_tointeger(L, 4);
int32 sequence = (int32)lua_tointeger(L, 5); int32_t sequence = (int32_t)lua_tointeger(L, 5);
int32 position = (int32)lua_tointeger(L, 6); int32_t position = (int32_t)lua_tointeger(L, 6);
int32 proc = lua_toboolean(L, 7); int32_t proc = lua_toboolean(L, 7);
if (!check_playerid(owner)) if (!check_playerid(owner))
return 0; return 0;
if (!check_playerid(playerid)) if (!check_playerid(playerid))
...@@ -43,7 +43,7 @@ int32 scriptlib::debug_add_card(lua_State *L) { ...@@ -43,7 +43,7 @@ int32 scriptlib::debug_add_card(lua_State *L) {
position = POS_FACEDOWN_DEFENSE; position = POS_FACEDOWN_DEFENSE;
pcard->sendto_param.position = position; pcard->sendto_param.position = position;
if(location == LOCATION_PZONE) { if(location == LOCATION_PZONE) {
int32 seq = pduel->game_field->get_pzone_sequence(sequence); int32_t seq = pduel->game_field->get_pzone_sequence(sequence);
pduel->game_field->add_card(playerid, pcard, LOCATION_SZONE, seq, TRUE); pduel->game_field->add_card(playerid, pcard, LOCATION_SZONE, seq, TRUE);
} else { } else {
pduel->game_field->add_card(playerid, pcard, location, sequence); pduel->game_field->add_card(playerid, pcard, location, sequence);
...@@ -71,13 +71,13 @@ int32 scriptlib::debug_add_card(lua_State *L) { ...@@ -71,13 +71,13 @@ int32 scriptlib::debug_add_card(lua_State *L) {
} }
return 0; return 0;
} }
int32 scriptlib::debug_set_player_info(lua_State *L) { int32_t scriptlib::debug_set_player_info(lua_State *L) {
check_param_count(L, 4); check_param_count(L, 4);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 playerid = (int32)lua_tointeger(L, 1); int32_t playerid = (int32_t)lua_tointeger(L, 1);
int32 lp = (int32)lua_tointeger(L, 2); int32_t lp = (int32_t)lua_tointeger(L, 2);
int32 startcount = (int32)lua_tointeger(L, 3); int32_t startcount = (int32_t)lua_tointeger(L, 3);
int32 drawcount = (int32)lua_tointeger(L, 4); int32_t drawcount = (int32_t)lua_tointeger(L, 4);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
pduel->game_field->player[playerid].lp = lp; pduel->game_field->player[playerid].lp = lp;
...@@ -85,18 +85,18 @@ int32 scriptlib::debug_set_player_info(lua_State *L) { ...@@ -85,18 +85,18 @@ int32 scriptlib::debug_set_player_info(lua_State *L) {
pduel->game_field->player[playerid].draw_count = drawcount; pduel->game_field->player[playerid].draw_count = drawcount;
return 0; return 0;
} }
int32 scriptlib::debug_pre_summon(lua_State *L) { int32_t scriptlib::debug_pre_summon(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 summon_type = (uint32)lua_tointeger(L, 2); uint32_t summon_type = (uint32_t)lua_tointeger(L, 2);
uint8 summon_location = 0; uint8_t summon_location = 0;
if(lua_gettop(L) > 2) if(lua_gettop(L) > 2)
summon_location = (uint8)lua_tointeger(L, 3); summon_location = (uint8_t)lua_tointeger(L, 3);
pcard->summon_info = summon_type | (summon_location << 16); pcard->summon_info = summon_type | (summon_location << 16);
return 0; return 0;
} }
int32 scriptlib::debug_pre_equip(lua_State *L) { int32_t scriptlib::debug_pre_equip(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
...@@ -114,7 +114,7 @@ int32 scriptlib::debug_pre_equip(lua_State *L) { ...@@ -114,7 +114,7 @@ int32 scriptlib::debug_pre_equip(lua_State *L) {
} }
return 1; return 1;
} }
int32 scriptlib::debug_pre_set_target(lua_State *L) { int32_t scriptlib::debug_pre_set_target(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_CARD, 2); check_param(L, PARAM_TYPE_CARD, 2);
...@@ -123,23 +123,23 @@ int32 scriptlib::debug_pre_set_target(lua_State *L) { ...@@ -123,23 +123,23 @@ int32 scriptlib::debug_pre_set_target(lua_State *L) {
t_card->add_card_target(target); t_card->add_card_target(target);
return 0; return 0;
} }
int32 scriptlib::debug_pre_add_counter(lua_State *L) { int32_t scriptlib::debug_pre_add_counter(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 countertype = (uint32)lua_tointeger(L, 2); uint32_t countertype = (uint32_t)lua_tointeger(L, 2);
uint16 count = (uint16)lua_tointeger(L, 3); uint16_t count = (uint16_t)lua_tointeger(L, 3);
uint16 cttype = countertype; uint16_t cttype = countertype;
auto pr = pcard->counters.emplace(cttype, 0); auto pr = pcard->counters.emplace(cttype, 0);
auto cmit = pr.first; auto cmit = pr.first;
cmit->second += count; cmit->second += count;
return 0; return 0;
} }
int32 scriptlib::debug_reload_field_begin(lua_State *L) { int32_t scriptlib::debug_reload_field_begin(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 flag = (uint32)lua_tointeger(L, 1); uint32_t flag = (uint32_t)lua_tointeger(L, 1);
int32 rule = (int32)lua_tointeger(L, 2); int32_t rule = (int32_t)lua_tointeger(L, 2);
pduel->clear(); pduel->clear();
pduel->game_field->core.duel_options |= flag; pduel->game_field->core.duel_options |= flag;
if (rule) if (rule)
...@@ -154,7 +154,7 @@ int32 scriptlib::debug_reload_field_begin(lua_State *L) { ...@@ -154,7 +154,7 @@ int32 scriptlib::debug_reload_field_begin(lua_State *L) {
} }
return 0; return 0;
} }
int32 scriptlib::debug_reload_field_end(lua_State *L) { int32_t scriptlib::debug_reload_field_end(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->core.shuffle_hand_check[0] = FALSE; pduel->game_field->core.shuffle_hand_check[0] = FALSE;
pduel->game_field->core.shuffle_hand_check[1] = FALSE; pduel->game_field->core.shuffle_hand_check[1] = FALSE;
...@@ -163,7 +163,7 @@ int32 scriptlib::debug_reload_field_end(lua_State *L) { ...@@ -163,7 +163,7 @@ int32 scriptlib::debug_reload_field_end(lua_State *L) {
pduel->game_field->reload_field_info(); pduel->game_field->reload_field_info();
return 0; return 0;
} }
int32 scriptlib::debug_set_ai_name(lua_State *L) { int32_t scriptlib::debug_set_ai_name(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_STRING, 1); check_param(L, PARAM_TYPE_STRING, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
...@@ -177,7 +177,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) { ...@@ -177,7 +177,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) {
pduel->write_buffer8(0); pduel->write_buffer8(0);
return 0; return 0;
} }
int32 scriptlib::debug_show_hint(lua_State *L) { int32_t scriptlib::debug_show_hint(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_STRING, 1); check_param(L, PARAM_TYPE_STRING, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
...@@ -204,7 +204,7 @@ static const struct luaL_Reg debuglib[] = { ...@@ -204,7 +204,7 @@ static const struct luaL_Reg debuglib[] = {
{ "ReloadFieldEnd", scriptlib::debug_reload_field_end }, { "ReloadFieldEnd", scriptlib::debug_reload_field_end },
{ "SetAIName", scriptlib::debug_set_ai_name }, { "SetAIName", scriptlib::debug_set_ai_name },
{ "ShowHint", scriptlib::debug_show_hint }, { "ShowHint", scriptlib::debug_show_hint },
{ NULL, NULL } { nullptr, nullptr }
}; };
void scriptlib::open_debuglib(lua_State *L) { void scriptlib::open_debuglib(lua_State *L) {
luaL_newlib(L, debuglib); luaL_newlib(L, debuglib);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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