Commit 16a4f5cb authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:moecube/ygopro-core

parents 9fd65875 31785ae6
......@@ -30,7 +30,6 @@ typedef signed char int8;
#define TRUE 1
#define FALSE 0
#define SIZE_MESSAGE_BUFFER 0x2000
#define SIZE_QUERY_BUFFER 0x4000
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_FLAG 0xf0000000
......
......@@ -5,6 +5,7 @@
* Author: Argon
*/
#include <cstring>
#include "duel.h"
#include "interpreter.h"
#include "field.h"
......@@ -13,6 +14,14 @@
#include "group.h"
#include "ocgapi.h"
inline void write_buffer_vector(std::vector<byte>& buffer, const void* data, int size) {
if (size > 0) {
const auto len = buffer.size();
buffer.resize(len + size);
std::memcpy(&buffer[len], data, size);
}
}
duel::duel() {
lua = new interpreter(this);
game_field = new field(this);
......
......@@ -20,14 +20,6 @@ class effect;
class field;
class interpreter;
inline void write_buffer_vector(std::vector<byte>& buffer, const void* data, int size) {
if (size > 0) {
const auto len = buffer.size();
buffer.resize(len + size);
std::memcpy(&buffer[len], data, size);
}
}
class duel {
public:
using card_set = std::set<card*, card_sort>;
......
......@@ -27,43 +27,8 @@ bool is_continuous_event(uint32 code) {
}
effect::effect(duel* pd) {
ref_handle = 0;
pduel = pd;
owner = 0;
handler = 0;
description = 0;
effect_owner = PLAYER_NONE;
card_type = 0;
active_type = 0;
active_location = 0;
active_sequence = 0;
active_handler = 0;
id = 0;
code = 0;
type = 0;
flag[0] = 0;
flag[1] = 0;
copy_id = 0;
range = 0;
s_range = 0;
o_range = 0;
count_limit = 0;
count_limit_max = 0;
reset_count = 0;
reset_flag = 0;
count_code = 0;
category = 0;
label.reserve(4);
label_object = 0;
hint_timing[0] = 0;
hint_timing[1] = 0;
status = 0;
condition = 0;
cost = 0;
target = 0;
value = 0;
operation = 0;
cost_checked = FALSE;
}
int32 effect::is_disable_related() {
if (code == EFFECT_IMMUNE_EFFECT || code == EFFECT_DISABLE || code == EFFECT_CANNOT_DISABLE || code == EFFECT_FORBIDDEN)
......
......@@ -27,41 +27,41 @@ enum effect_flag2 : uint32;
class effect {
public:
int32 ref_handle;
duel* pduel;
card* owner;
card* handler;
uint8 effect_owner;
uint32 description;
uint32 code;
uint32 flag[2];
uint32 id;
uint16 type;
uint16 copy_id;
uint16 range;
uint16 s_range;
uint16 o_range;
uint8 count_limit;
uint8 count_limit_max;
uint16 reset_count;
uint32 reset_flag;
uint32 count_code;
uint32 category;
uint32 hint_timing[2];
uint32 card_type;
uint32 active_type;
uint16 active_location;
uint16 active_sequence;
card* active_handler;
uint16 status;
int32 ref_handle{ 0 };
duel* pduel{ nullptr };
card* owner{ nullptr };
card* handler{ nullptr };
uint8 effect_owner{ PLAYER_NONE };
uint32 description{ 0 };
uint32 code{ 0 };
uint32 flag[2]{ 0 };
uint32 id{ 0 };
uint16 type{ 0 };
uint16 copy_id{ 0 };
uint16 range{ 0 };
uint16 s_range{ 0 };
uint16 o_range{ 0 };
uint8 count_limit{ 0 };
uint8 count_limit_max{ 0 };
uint16 reset_count{ 0 };
uint32 reset_flag{ 0 };
uint32 count_code{ 0 };
uint32 category{ 0 };
uint32 hint_timing[2]{ 0 };
uint32 card_type{ 0 };
uint32 active_type{ 0 };
uint16 active_location{ 0 };
uint16 active_sequence{ 0 };
card* active_handler{ nullptr };
uint16 status{ 0 };
std::vector<uint32> label;
int32 label_object;
int32 condition;
int32 cost;
int32 target;
int32 value;
int32 operation;
uint8 cost_checked;
int32 label_object{ 0 };
int32 condition{ 0 };
int32 cost{ 0 };
int32 target{ 0 };
int32 value{ 0 };
int32 operation{ 0 };
uint8 cost_checked{ FALSE };
explicit effect(duel* pd);
~effect() = default;
......
......@@ -5,6 +5,7 @@
* Author: Argon
*/
#include <cstring>
#include "duel.h"
#include "group.h"
#include "card.h"
......@@ -17,7 +18,7 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_state = luaL_newstate();
current_state = lua_state;
pduel = pd;
memcpy(lua_getextraspace(lua_state), &pd, LUA_EXTRASPACE); //set_duel_info
std::memcpy(lua_getextraspace(lua_state), &pd, LUA_EXTRASPACE); //set_duel_info
no_action = 0;
call_depth = 0;
disable_action_check = 0;
......@@ -758,6 +759,6 @@ int32 interpreter::get_function_handle(lua_State* L, int32 index) {
}
duel* interpreter::get_duel_info(lua_State * L) {
duel* pduel;
memcpy(&pduel, lua_getextraspace(L), LUA_EXTRASPACE);
std::memcpy(&pduel, lua_getextraspace(L), LUA_EXTRASPACE);
return pduel;
}
......@@ -20,7 +20,6 @@
#include <list>
#include <vector>
#include <cstdio>
#include <cstring>
class card;
class effect;
......
......@@ -5,7 +5,7 @@
* Author: Argon
*/
#include <string.h>
#include <cstring>
#include "scriptlib.h"
#include "duel.h"
#include "field.h"
......@@ -177,7 +177,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
pduel->write_buffer8(MSG_AI_NAME);
const char* pstr = lua_tostring(L, 1);
int len = (int)strlen(pstr);
int len = (int)std::strlen(pstr);
if(len > 100)
len = 100;
pduel->write_buffer16(len);
......@@ -193,7 +193,7 @@ int32 scriptlib::debug_show_hint(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
pduel->write_buffer8(MSG_SHOW_HINT);
const char* pstr = lua_tostring(L, 1);
int len = (int)strlen(pstr);
int len = (int)std::strlen(pstr);
if(len > 1024)
len = 1024;
pduel->write_buffer16(len);
......
......@@ -8,7 +8,6 @@
#ifndef MTRANDOM_H_
#define MTRANDOM_H_
#include <cstdint>
#include <random>
class mt19937 {
......
......@@ -4,8 +4,8 @@
* Created on: 2010-5-2
* Author: Argon
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "ocgapi.h"
#include "duel.h"
#include "card.h"
......@@ -41,11 +41,11 @@ uint32 handle_message(void* pduel, uint32 msg_type) {
}
byte* default_script_reader(const char* script_name, int* slen) {
FILE *fp;
fp = fopen(script_name, "rb");
fp = std::fopen(script_name, "rb");
if (!fp)
return 0;
int len = (int)fread(buffer, 1, sizeof(buffer), fp);
fclose(fp);
std::fclose(fp);
if(len >= sizeof(buffer))
return 0;
*slen = len;
......@@ -121,7 +121,7 @@ extern "C" DECL_DLLEXPORT void set_player_info(intptr_t pduel, int32 playerid, i
pd->game_field->player[playerid].draw_count = drawcount;
}
extern "C" DECL_DLLEXPORT void get_log_message(intptr_t pduel, byte* buf) {
strcpy((char*)buf, ((duel*)pduel)->strbuffer);
std::strcpy((char*)buf, ((duel*)pduel)->strbuffer);
}
extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf) {
int32 len = ((duel*)pduel)->read_buffer(buf);
......
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