Commit 9494a7f8 authored by nanahira's avatar nanahira

use latest ocgcore

parent bc1e5eee
Pipeline #5207 failed with stages
in 20 minutes and 51 seconds
project (ocgcore)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$")
if (MSVC)
include_directories ( ../lua )
else ()
include_directories ( ${LUA_INCLUDE_DIR} )
endif ()
add_library (ocgcore STATIC ${AUTO_FILES_RESULT})
if (MSVC)
target_link_libraries (ocgcore lua)
else ()
target_link_libraries (ocgcore ${LUA_LIBRARIES})
endif ()
......@@ -8,13 +8,11 @@
#ifndef COMMON_H_
#define COMMON_H_
typedef void* uptr;
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
typedef unsigned char byte;
typedef void* ptr;
typedef long long int64;
typedef int int32;
typedef short int16;
......
......@@ -401,7 +401,7 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev
pduel->lua->add_param(e.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(e.reason, PARAM_TYPE_INT);
pduel->lua->add_param(e.reason_player, PARAM_TYPE_INT);
pduel->lua->add_param((ptr)0, PARAM_TYPE_INT);
pduel->lua->add_param(0, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(cost, 9)) {
return FALSE;
}
......@@ -415,7 +415,7 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev
pduel->lua->add_param(e.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(e.reason, PARAM_TYPE_INT);
pduel->lua->add_param(e.reason_player, PARAM_TYPE_INT);
pduel->lua->add_param((ptr)0, PARAM_TYPE_INT);
pduel->lua->add_param(0, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(target, 9)) {
return FALSE;
}
......
......@@ -70,50 +70,47 @@ private:
};
struct effect_set_v {
effect_set_v(): count(0) {}
effect_set_v() {}
void add_item(effect* peffect) {
container.push_back(peffect);
count++;
}
void remove_item(int index) {
if(index >= count)
if(index >= (int)container.size())
return;
container.erase(container.begin() + index);
count--;
}
void clear() {
container.clear();
count = 0;
}
int size() const {
return count;
return (int)container.size();
}
void sort() {
int count = (int)container.size();
if(count < 2)
return;
std::sort(container.begin(), container.begin() + count, effect_sort_id);
}
effect* const& get_last() const {
return container[count - 1];
return container.back();
}
effect*& get_last() {
return container[count - 1];
return container.back();
}
effect* const& operator[] (int index) const {
return container[index];
return container.at(index);
}
effect*& operator[] (int index) {
return container[index];
return container.at(index);
}
effect* const& at(int index) const {
return container[index];
return container.at(index);
}
effect*& at(int index) {
return container[index];
return container.at(index);
}
private:
std::vector<effect*> container;
int count;
};
#endif //EFFECTSET_H_
......@@ -3323,7 +3323,7 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) {
pduel->lua->add_param(pchain->evt.reason_effect , PARAM_TYPE_EFFECT);
pduel->lua->add_param(pchain->evt.reason, PARAM_TYPE_INT);
pduel->lua->add_param(pchain->evt.reason_player, PARAM_TYPE_INT);
pduel->lua->add_param((ptr)0, PARAM_TYPE_INT);
pduel->lua->add_param(0, PARAM_TYPE_INT);
pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
return pduel->lua->check_condition(peffect->target, 10);
}
......
......@@ -184,13 +184,13 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
uint32 type = it.second;
switch(type) {
case PARAM_TYPE_INT:
lua_pushinteger(L, (int32) it.first);
lua_pushinteger(L, (size_t) it.first);
break;
case PARAM_TYPE_STRING:
lua_pushstring(L, (const char *) it.first);
break;
case PARAM_TYPE_BOOLEAN:
lua_pushboolean(L, (int32)(ptr)it.first);
lua_pushboolean(L, (size_t)it.first);
break;
case PARAM_TYPE_CARD: {
if (it.first)
......@@ -214,11 +214,11 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
break;
}
case PARAM_TYPE_FUNCTION: {
function2value(L, (int32)(ptr)it.first);
function2value(L, (size_t)it.first);
break;
}
case PARAM_TYPE_INDEX: {
int32 index = (int32)(ptr)it.first;
int32 index = (size_t)it.first;
if(index > 0)
lua_pushvalue(L, index);
else if(is_coroutine) {
......
......@@ -57,13 +57,13 @@ uint32 default_card_reader(uint32 code, card_data* data) {
uint32 default_message_handler(void* pduel, uint32 message_type) {
return 0;
}
extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed) {
extern "C" DECL_DLLEXPORT intptr_t create_duel(uint32 seed) {
duel* pduel = new duel();
duel_set.insert(pduel);
pduel->random.reset(seed);
return (ptr)pduel;
return (intptr_t)pduel;
}
extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options) {
extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options) {
duel* pd = (duel*)pduel;
pd->game_field->core.duel_options |= options & 0xffff;
int32 duel_rule = options >> 16;
......@@ -103,14 +103,14 @@ extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options) {
}
pd->game_field->add_process(PROCESSOR_TURN, 0, 0, 0, 0, 0);
}
extern "C" DECL_DLLEXPORT void end_duel(ptr pduel) {
extern "C" DECL_DLLEXPORT void end_duel(intptr_t pduel) {
duel* pd = (duel*)pduel;
if(duel_set.count(pd)) {
duel_set.erase(pd);
delete pd;
}
}
extern "C" DECL_DLLEXPORT void set_player_info(ptr pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount) {
extern "C" DECL_DLLEXPORT void set_player_info(intptr_t pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount) {
duel* pd = (duel*)pduel;
if(lp > 0)
pd->game_field->player[playerid].lp = lp;
......@@ -119,22 +119,22 @@ extern "C" DECL_DLLEXPORT void set_player_info(ptr pduel, int32 playerid, int32
if(drawcount >= 0)
pd->game_field->player[playerid].draw_count = drawcount;
}
extern "C" DECL_DLLEXPORT void get_log_message(ptr pduel, byte* buf) {
extern "C" DECL_DLLEXPORT void get_log_message(intptr_t pduel, byte* buf) {
strcpy((char*)buf, ((duel*)pduel)->strbuffer);
}
extern "C" DECL_DLLEXPORT int32 get_message(ptr pduel, byte* buf) {
extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf) {
int32 len = ((duel*)pduel)->read_buffer(buf);
((duel*)pduel)->clear_buffer();
return len;
}
extern "C" DECL_DLLEXPORT int32 process(ptr pduel) {
extern "C" DECL_DLLEXPORT int32 process(intptr_t pduel) {
duel* pd = (duel*)pduel;
int result = pd->game_field->process();
while((result & 0xffff) == 0 && (result & 0xf0000) == 0)
result = pd->game_field->process();
return result;
}
extern "C" DECL_DLLEXPORT void new_card(ptr pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position) {
extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position) {
duel* ptduel = (duel*)pduel;
if(ptduel->game_field->is_location_useable(playerid, location, sequence)) {
card* pcard = ptduel->new_card(code);
......@@ -151,7 +151,7 @@ extern "C" DECL_DLLEXPORT void new_card(ptr pduel, uint32 code, uint8 owner, uin
}
}
}
extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner, uint8 location) {
extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location) {
duel* ptduel = (duel*)pduel;
if(owner > 1 || !(location & (LOCATION_DECK | LOCATION_EXTRA)))
return;
......@@ -175,7 +175,7 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner,
break;
}
}
extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache) {
extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache) {
if(playerid != 0 && playerid != 1)
return 0;
duel* ptduel = (duel*)pduel;
......@@ -208,7 +208,7 @@ extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 loca
return 4;
}
}
extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uint8 location) {
extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location) {
duel* ptduel = (duel*)pduel;
if(playerid != 0 && playerid != 1)
return 0;
......@@ -237,7 +237,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin
}
return 0;
}
extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache) {
extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache) {
if(playerid != 0 && playerid != 1)
return 0;
duel* ptduel = (duel*)pduel;
......@@ -284,7 +284,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
}
return (int32)(p - buf);
}
extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
duel* ptduel = (duel*)pduel;
byte* p = buf;
*p++ = MSG_RELOAD_FIELD;
......@@ -332,12 +332,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
}
return (int32)(p - buf);
}
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) {
extern "C" DECL_DLLEXPORT void set_responsei(intptr_t pduel, int32 value) {
((duel*)pduel)->set_responsei(value);
}
extern "C" DECL_DLLEXPORT void set_responseb(ptr pduel, byte* buf) {
extern "C" DECL_DLLEXPORT void set_responseb(intptr_t pduel, byte* buf) {
((duel*)pduel)->set_responseb(buf);
}
extern "C" DECL_DLLEXPORT int32 preload_script(ptr pduel, const char* script, int32 len) {
extern "C" DECL_DLLEXPORT int32 preload_script(intptr_t pduel, const char* script, int32 len) {
return ((duel*)pduel)->lua->load_script(script);
}
......@@ -9,6 +9,8 @@
#define OCGAPI_H_
#include "common.h"
#include <cstdint>
#ifdef WIN32
#define DECL_DLLEXPORT __declspec(dllexport)
#else
......@@ -34,22 +36,22 @@ byte* read_script(const char* script_name, int* len);
uint32 read_card(uint32 code, card_data* data);
uint32 handle_message(void* pduel, uint32 message_type);
extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed);
extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options);
extern "C" DECL_DLLEXPORT void end_duel(ptr pduel);
extern "C" DECL_DLLEXPORT void set_player_info(ptr pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount);
extern "C" DECL_DLLEXPORT void get_log_message(ptr pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 get_message(ptr pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 process(ptr pduel);
extern "C" DECL_DLLEXPORT void new_card(ptr pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);
extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf);
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value);
extern "C" DECL_DLLEXPORT void set_responseb(ptr pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 preload_script(ptr pduel, const char* script, int32 len);
extern "C" DECL_DLLEXPORT std::intptr_t create_duel(uint32 seed);
extern "C" DECL_DLLEXPORT void start_duel(std::intptr_t pduel, int32 options);
extern "C" DECL_DLLEXPORT void end_duel(std::intptr_t pduel);
extern "C" DECL_DLLEXPORT void set_player_info(std::intptr_t pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount);
extern "C" DECL_DLLEXPORT void get_log_message(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 get_message(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 process(std::intptr_t pduel);
extern "C" DECL_DLLEXPORT void new_card(std::intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);
extern "C" DECL_DLLEXPORT void new_tag_card(std::intptr_t pduel, uint32 code, uint8 owner, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_card(std::intptr_t pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_count(std::intptr_t pduel, uint8 playerid, uint8 location);
extern "C" DECL_DLLEXPORT int32 query_field_card(std::intptr_t pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT int32 query_field_info(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT void set_responsei(std::intptr_t pduel, int32 value);
extern "C" DECL_DLLEXPORT void set_responseb(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 preload_script(std::intptr_t pduel, const char* script, int32 len);
byte* default_script_reader(const char* script_name, int* len);
uint32 default_card_reader(uint32 code, card_data* data);
uint32 default_message_handler(void* pduel, uint32 msg_type);
......
......@@ -194,6 +194,7 @@ void field::special_summon_complete(effect* reason_effect, uint8 reason_player)
group* ng = pduel->new_group();
ng->container.swap(core.special_summoning);
ng->is_readonly = TRUE;
core.hint_timing[reason_player] |= TIMING_SPSUMMON;
add_process(PROCESSOR_SPSUMMON, 1, reason_effect, ng, reason_player, 0);
}
void field::destroy(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence) {
......
project "ocgcore"
kind "StaticLib"
files { "**.cc", "**.cpp", "**.c", "**.h" }
configuration "windows"
includedirs { "../lua" }
configuration "not vs*"
buildoptions { "-std=c++14" }
configuration "not windows"
includedirs { "/usr/include/lua5.3" }
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