Commit 3e38ae11 authored by 神楽坂玲奈's avatar 神楽坂玲奈

Merge remote-tracking branch 'remotes/origin/ci'

parents b15c84b7 5879e358
stages: stages:
- ocgcore
- build_and_test - build_and_test
- deploy - deploy
...@@ -15,26 +16,78 @@ variables: ...@@ -15,26 +16,78 @@ variables:
image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION
.unity_before_script: &unity_before_script .unity_before_script:
before_script: before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh - chmod +x ./ci/before_script.sh && ./ci/before_script.sh
.cache: &cache .cache:
cache: cache:
key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM" key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM"
paths: paths:
- $UNITY_DIR/Library/ - $UNITY_DIR/Library/
.license: &license .license:
rules: rules:
- if: '$UNITY_LICENSE != null' - if: '$UNITY_LICENSE != null'
when: always when: always
.unity_defaults: &unity_defaults .unity_defaults:
<<: extends:
- *unity_before_script - .unity_before_script
- *cache - .cache
- *license - .license
.common_image:
image: git-registry.mycard.moe/mycard/docker-runner-base
.ocgcore:
extends: .common_image
stage: ocgcore
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- AI_core_vs2017solution/x64/Release
- AI_core_vs2017solution/Release
- AI_core_vs2017solution/bin
- AI_core_vs2017solution/obj
.ocgcore_unix:
extends: .ocgcore
script:
- cd AI_core_vs2017solution/build/gmake.$GMAKE_PLATFORM/
- make config=release -j$(nproc)
- cd ../..
- cp -rf bin/gmake.$GMAKE_PLATFORM/x64/*.so ../Assets/Plugins/$PLUGIN_PLATFORM/
ocgcore_windows:
extends:
- .ocgcore
tags:
- vs
script:
- cd AI_core_vs2017solution
- cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" core.sln /m /p:Configuration=Release /p:Platform=x86'
- cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" core.sln /m /p:Configuration=Release /p:Platform=x64'
- bash -c 'cp -rf Release/ocgcore.dll ../Assets/Plugins/x86/ ; cp -rf x64/Release/ocgcore.dll ../Assets/Plugins/x64/'
artifacts:
paths:
- Assets/Plugins/Release
- Assets/Plugins/x64/Release
ocgcore_linux:
extends:
- .ocgcore_unix
tags:
- linux
image: git-registry.mycard.moe/mycard/docker-runner-base:buster
before_script:
- apt update; apt -y install clang build-essential
variables:
GMAKE_PLATFORM: linux
PLUGIN_PLATFORM: Linux
artifacts:
paths:
- Assets/Plugins/Linux
# run this job when you need to request a license # run this job when you need to request a license
# you may need to follow activation steps from documentation # you may need to follow activation steps from documentation
...@@ -50,9 +103,9 @@ get-activation-file: ...@@ -50,9 +103,9 @@ get-activation-file:
- $UNITY_ACTIVATION_FILE - $UNITY_ACTIVATION_FILE
expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public
.test: &test .test:
stage: build_and_test stage: build_and_test
<<: *unity_defaults extends: .unity_defaults
script: script:
- chmod +x ./ci/test.sh && ./ci/test.sh - chmod +x ./ci/test.sh && ./ci/test.sh
artifacts: artifacts:
...@@ -64,15 +117,15 @@ get-activation-file: ...@@ -64,15 +117,15 @@ get-activation-file:
- linux - linux
coverage: /<Linecoverage>(.*?)</Linecoverage>/ coverage: /<Linecoverage>(.*?)</Linecoverage>/
test-playmode: #test-playmode:
<<: *test # extends: .test
variables: # variables:
TEST_PLATFORM: playmode # TEST_PLATFORM: playmode
test-editmode: #test-editmode:
<<: *test # extends: .test
variables: # variables:
TEST_PLATFORM: editmode # TEST_PLATFORM: editmode
# uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab # uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab
# We currently have the following issue which prevents it from working right now, but you can give # We currently have the following issue which prevents it from working right now, but you can give
...@@ -81,7 +134,7 @@ test-editmode: ...@@ -81,7 +134,7 @@ test-editmode:
# .test-with-junit-reports: &test-with-junit-reports # .test-with-junit-reports: &test-with-junit-reports
# stage: build_and_test # stage: build_and_test
# <<: *unity_defaults # extends: .unity_defaults
# script: # script:
# # This could be made faster by adding these packages to base image or running in a separate job (and step) # # This could be made faster by adding these packages to base image or running in a separate job (and step)
# # We could use an image with these two depencencies only and only do the saxonb-xslt command on # # We could use an image with these two depencencies only and only do the saxonb-xslt command on
...@@ -103,18 +156,18 @@ test-editmode: ...@@ -103,18 +156,18 @@ test-editmode:
# coverage: /<Linecoverage>(.*?)</Linecoverage>/ # coverage: /<Linecoverage>(.*?)</Linecoverage>/
# test-playmode-with-junit-reports: # test-playmode-with-junit-reports:
# <<: *test-with-junit-reports # extends: .test-with-junit-reports
# variables: # variables:
# TEST_PLATFORM: playmode # TEST_PLATFORM: playmode
# test-editmode-with-junit-reports: # test-editmode-with-junit-reports:
# <<: *test-with-junit-reports # extends: .test-with-junit-reports
# variables: # variables:
# TEST_PLATFORM: editmode # TEST_PLATFORM: editmode
.build: &build .build:
stage: build_and_test stage: build_and_test
<<: *unity_defaults extends: .unity_defaults
script: script:
- chmod +x ./ci/build.sh && ./ci/build.sh - chmod +x ./ci/build.sh && ./ci/build.sh
artifacts: artifacts:
...@@ -126,62 +179,67 @@ test-editmode: ...@@ -126,62 +179,67 @@ test-editmode:
- linux - linux
build-StandaloneLinux64: build-StandaloneLinux64:
<<: *build extends: .build
dependencies:
- ocgcore_linux
variables: variables:
BUILD_TARGET: StandaloneLinux64 BUILD_TARGET: StandaloneLinux64
build-StandaloneLinux64-il2cpp: #build-StandaloneLinux64-il2cpp:
<<: *build # extends: .build
image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION # image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION
variables: # variables:
BUILD_TARGET: StandaloneLinux64 # BUILD_TARGET: StandaloneLinux64
SCRIPTING_BACKEND: IL2CPP # SCRIPTING_BACKEND: IL2CPP
build-StandaloneOSX: build-StandaloneOSX:
<<: *build extends: .build
dependencies: [] # todo
image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION
variables: variables:
BUILD_TARGET: StandaloneOSX BUILD_TARGET: StandaloneOSX
#Note: build target names changed in recent versions, use this for versions < 2017.2: #Note: build target names changed in recent versions, use this for versions < 2017.2:
# build-StandaloneOSXUniversal: # build-StandaloneOSXUniversal:
# <<: *build # extends: .build
# variables: # variables:
# BUILD_TARGET: StandaloneOSXUniversal # BUILD_TARGET: StandaloneOSXUniversal
build-StandaloneWindows64: build-StandaloneWindows64:
<<: *build extends: .build
dependencies:
- ocgcore_windows
image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION
variables: variables:
BUILD_TARGET: StandaloneWindows64 BUILD_TARGET: StandaloneWindows64
# For webgl support, you need to set Compression Format to Disabled for v0.9. See https://github.com/game-ci/docker/issues/75 # For webgl support, you need to set Compression Format to Disabled for v0.9. See https://github.com/game-ci/docker/issues/75
build-WebGL: #build-WebGL:
<<: *build # extends: .build
image: $IMAGE:$UNITY_VERSION-webgl-$IMAGE_VERSION # image: $IMAGE:$UNITY_VERSION-webgl-$IMAGE_VERSION
# Temporary workaround for https://github.com/game-ci/docker/releases/tag/v0.9 and webgl support in current project to prevent errors with missing ffmpeg # Temporary workaround for https://github.com/game-ci/docker/releases/tag/v0.9 and webgl support in current project to prevent errors with missing ffmpeg
before_script: # before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh # - chmod +x ./ci/before_script.sh && ./ci/before_script.sh
- apt-get update && apt-get install ffmpeg -y # - apt-get update && apt-get install ffmpeg -y
variables: # variables:
BUILD_TARGET: WebGL # BUILD_TARGET: WebGL
build-android: #build-android:
<<: *build # extends: .build
image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION # image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
variables: # variables:
BUILD_TARGET: Android # BUILD_TARGET: Android
BUNDLE_VERSION_CODE: $CI_PIPELINE_IID # BUNDLE_VERSION_CODE: $CI_PIPELINE_IID
BUILD_APP_BUNDLE: "false" # BUILD_APP_BUNDLE: "false"
build-android-il2cpp: #build-android-il2cpp:
<<: *build # extends: .build
image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION # image: $IMAGE:$UNITY_VERSION-android-$IMAGE_VERSION
variables: # variables:
BUILD_TARGET: Android # BUILD_TARGET: Android
BUNDLE_VERSION_CODE: $CI_PIPELINE_IID # BUNDLE_VERSION_CODE: $CI_PIPELINE_IID
BUILD_APP_BUNDLE: "false" # BUILD_APP_BUNDLE: "false"
SCRIPTING_BACKEND: IL2CPP # SCRIPTING_BACKEND: IL2CPP
#deploy-android: #deploy-android:
# stage: deploy # stage: deploy
...@@ -194,11 +252,11 @@ build-android-il2cpp: ...@@ -194,11 +252,11 @@ build-android-il2cpp:
# - fastlane supply --aab $BUILD_NAME.aab --track internal --package_name com.youcompany.yourgame --json_key ./gpc_token.json # - fastlane supply --aab $BUILD_NAME.aab --track internal --package_name com.youcompany.yourgame --json_key ./gpc_token.json
# needs: ["build-android"] # needs: ["build-android"]
build-ios-xcode: #build-ios-xcode:
<<: *build # extends: .build
image: $IMAGE:$UNITY_VERSION-ios-$IMAGE_VERSION # image: $IMAGE:$UNITY_VERSION-ios-$IMAGE_VERSION
variables: # variables:
BUILD_TARGET: iOS # BUILD_TARGET: iOS
#build-and-deploy-ios: #build-and-deploy-ios:
# stage: deploy # stage: deploy
...@@ -211,22 +269,21 @@ build-ios-xcode: ...@@ -211,22 +269,21 @@ build-ios-xcode:
# - mac # - mac
# needs: ["build-ios-xcode"] # needs: ["build-ios-xcode"]
pages: #pages:
image: alpine:latest # image: alpine:latest
stage: deploy # stage: deploy
script: # script:
- mv "$UNITY_DIR/Builds/WebGL/${BUILD_NAME}" public # - mv "$UNITY_DIR/Builds/WebGL/${BUILD_NAME}" public
artifacts: # artifacts:
paths: # paths:
- public # - public
only: # only:
- master # - master
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_TAG
when: never
- when: always
#workflow:
# rules:
# - if: $CI_MERGE_REQUEST_ID
# when: never
# - if: $CI_COMMIT_TAG
# when: never
# - when: always
...@@ -27,7 +27,7 @@ endif ...@@ -27,7 +27,7 @@ endif
ifeq ($(origin AR), default) ifeq ($(origin AR), default)
AR = ar AR = ar
endif endif
OSX_FLAGS = -mmacosx-version-min=10.9 -arch i386 -arch x86_64 OSX_FLAGS = -mmacosx-version-min=10.9 -arch x86_64
DEFINES += -DLUA_COMPAT_5_2 -DLUA_USE_MACOSX DEFINES += -DLUA_COMPAT_5_2 -DLUA_USE_MACOSX
INCLUDES += INCLUDES +=
FORCE_INCLUDE += FORCE_INCLUDE +=
...@@ -294,4 +294,4 @@ $(OBJDIR)/lzio.o: ../../lua/lzio.c ...@@ -294,4 +294,4 @@ $(OBJDIR)/lzio.o: ../../lua/lzio.c
-include $(OBJECTS:%.o=%.d) -include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH)) ifneq (,$(PCH))
-include $(PCH_PLACEHOLDER).d -include $(PCH_PLACEHOLDER).d
endif endif
\ No newline at end of file
...@@ -27,7 +27,7 @@ endif ...@@ -27,7 +27,7 @@ endif
ifeq ($(origin AR), default) ifeq ($(origin AR), default)
AR = ar AR = ar
endif endif
OSX_FLAGS = -mmacosx-version-min=10.9 -arch i386 -arch x86_64 OSX_FLAGS = -mmacosx-version-min=10.9 -arch x86_64
DEFINES += -DUSE_LUA DEFINES += -DUSE_LUA
INCLUDES += -I../../lua INCLUDES += -I../../lua
FORCE_INCLUDE += FORCE_INCLUDE +=
...@@ -214,4 +214,4 @@ $(OBJDIR)/scriptlib.o: ../../ocgcore/scriptlib.cpp ...@@ -214,4 +214,4 @@ $(OBJDIR)/scriptlib.o: ../../ocgcore/scriptlib.cpp
-include $(OBJECTS:%.o=%.d) -include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH)) ifneq (,$(PCH))
-include $(PCH_PLACEHOLDER).d -include $(PCH_PLACEHOLDER).d
endif endif
\ No newline at end of file
...@@ -27,7 +27,7 @@ endif ...@@ -27,7 +27,7 @@ endif
ifeq ($(origin AR), default) ifeq ($(origin AR), default)
AR = ar AR = ar
endif endif
OSX_FLAGS = -mmacosx-version-min=10.9 -arch i386 -arch x86_64 OSX_FLAGS = -mmacosx-version-min=10.9 -arch x86_64
DEFINES += DEFINES +=
INCLUDES += INCLUDES +=
FORCE_INCLUDE += FORCE_INCLUDE +=
...@@ -134,4 +134,4 @@ $(OBJDIR)/sqlite3.o: ../../sqlite3/sqlite3.c ...@@ -134,4 +134,4 @@ $(OBJDIR)/sqlite3.o: ../../sqlite3/sqlite3.c
-include $(OBJECTS:%.o=%.d) -include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH)) ifneq (,$(PCH))
-include $(PCH_PLACEHOLDER).d -include $(PCH_PLACEHOLDER).d
endif endif
\ No newline at end of file
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 @@ ...@@ -8,13 +8,11 @@
#ifndef COMMON_H_ #ifndef COMMON_H_
#define COMMON_H_ #define COMMON_H_
typedef void* uptr;
typedef unsigned long long uint64; typedef unsigned long long uint64;
typedef unsigned int uint32; typedef unsigned int uint32;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef unsigned char uint8; typedef unsigned char uint8;
typedef unsigned char byte; typedef unsigned char byte;
typedef void* ptr;
typedef long long int64; typedef long long int64;
typedef int int32; typedef int int32;
typedef short int16; typedef short int16;
......
...@@ -401,7 +401,7 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev ...@@ -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_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(e.reason, PARAM_TYPE_INT); pduel->lua->add_param(e.reason, PARAM_TYPE_INT);
pduel->lua->add_param(e.reason_player, 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)) { if(!pduel->lua->check_condition(cost, 9)) {
return FALSE; return FALSE;
} }
...@@ -415,7 +415,7 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev ...@@ -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_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(e.reason, PARAM_TYPE_INT); pduel->lua->add_param(e.reason, PARAM_TYPE_INT);
pduel->lua->add_param(e.reason_player, 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)) { if(!pduel->lua->check_condition(target, 9)) {
return FALSE; return FALSE;
} }
......
...@@ -70,50 +70,47 @@ private: ...@@ -70,50 +70,47 @@ private:
}; };
struct effect_set_v { struct effect_set_v {
effect_set_v(): count(0) {} effect_set_v() {}
void add_item(effect* peffect) { void add_item(effect* peffect) {
container.push_back(peffect); container.push_back(peffect);
count++;
} }
void remove_item(int index) { void remove_item(int index) {
if(index >= count) if(index >= (int)container.size())
return; return;
container.erase(container.begin() + index); container.erase(container.begin() + index);
count--;
} }
void clear() { void clear() {
container.clear(); container.clear();
count = 0;
} }
int size() const { int size() const {
return count; return (int)container.size();
} }
void sort() { void sort() {
int count = (int)container.size();
if(count < 2) if(count < 2)
return; return;
std::sort(container.begin(), container.begin() + count, effect_sort_id); std::sort(container.begin(), container.begin() + count, effect_sort_id);
} }
effect* const& get_last() const { effect* const& get_last() const {
return container[count - 1]; return container.back();
} }
effect*& get_last() { effect*& get_last() {
return container[count - 1]; return container.back();
} }
effect* const& operator[] (int index) const { effect* const& operator[] (int index) const {
return container[index]; return container.at(index);
} }
effect*& operator[] (int index) { effect*& operator[] (int index) {
return container[index]; return container.at(index);
} }
effect* const& at(int index) const { effect* const& at(int index) const {
return container[index]; return container.at(index);
} }
effect*& at(int index) { effect*& at(int index) {
return container[index]; return container.at(index);
} }
private: private:
std::vector<effect*> container; std::vector<effect*> container;
int count;
}; };
#endif //EFFECTSET_H_ #endif //EFFECTSET_H_
...@@ -3323,7 +3323,7 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) { ...@@ -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_effect , PARAM_TYPE_EFFECT);
pduel->lua->add_param(pchain->evt.reason, PARAM_TYPE_INT); 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(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); pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
return pduel->lua->check_condition(peffect->target, 10); return pduel->lua->check_condition(peffect->target, 10);
} }
......
...@@ -184,13 +184,13 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) { ...@@ -184,13 +184,13 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
uint32 type = it.second; uint32 type = it.second;
switch(type) { switch(type) {
case PARAM_TYPE_INT: case PARAM_TYPE_INT:
lua_pushinteger(L, (int32) it.first); lua_pushinteger(L, (size_t) it.first);
break; break;
case PARAM_TYPE_STRING: case PARAM_TYPE_STRING:
lua_pushstring(L, (const char *) it.first); lua_pushstring(L, (const char *) it.first);
break; break;
case PARAM_TYPE_BOOLEAN: case PARAM_TYPE_BOOLEAN:
lua_pushboolean(L, (int32)(ptr)it.first); lua_pushboolean(L, (size_t)it.first);
break; break;
case PARAM_TYPE_CARD: { case PARAM_TYPE_CARD: {
if (it.first) if (it.first)
...@@ -214,11 +214,11 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) { ...@@ -214,11 +214,11 @@ void interpreter::push_param(lua_State* L, bool is_coroutine) {
break; break;
} }
case PARAM_TYPE_FUNCTION: { case PARAM_TYPE_FUNCTION: {
function2value(L, (int32)(ptr)it.first); function2value(L, (size_t)it.first);
break; break;
} }
case PARAM_TYPE_INDEX: { case PARAM_TYPE_INDEX: {
int32 index = (int32)(ptr)it.first; int32 index = (size_t)it.first;
if(index > 0) if(index > 0)
lua_pushvalue(L, index); lua_pushvalue(L, index);
else if(is_coroutine) { else if(is_coroutine) {
......
...@@ -57,13 +57,13 @@ uint32 default_card_reader(uint32 code, card_data* data) { ...@@ -57,13 +57,13 @@ uint32 default_card_reader(uint32 code, card_data* data) {
uint32 default_message_handler(void* pduel, uint32 message_type) { uint32 default_message_handler(void* pduel, uint32 message_type) {
return 0; 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* pduel = new duel();
duel_set.insert(pduel); duel_set.insert(pduel);
pduel->random.reset(seed); 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; duel* pd = (duel*)pduel;
pd->game_field->core.duel_options |= options & 0xffff; pd->game_field->core.duel_options |= options & 0xffff;
int32 duel_rule = options >> 16; int32 duel_rule = options >> 16;
...@@ -103,14 +103,14 @@ extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options) { ...@@ -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); 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; duel* pd = (duel*)pduel;
if(duel_set.count(pd)) { if(duel_set.count(pd)) {
duel_set.erase(pd); duel_set.erase(pd);
delete 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; duel* pd = (duel*)pduel;
if(lp > 0) if(lp > 0)
pd->game_field->player[playerid].lp = lp; pd->game_field->player[playerid].lp = lp;
...@@ -119,22 +119,22 @@ extern "C" DECL_DLLEXPORT void set_player_info(ptr pduel, int32 playerid, int32 ...@@ -119,22 +119,22 @@ extern "C" DECL_DLLEXPORT void set_player_info(ptr pduel, int32 playerid, int32
if(drawcount >= 0) if(drawcount >= 0)
pd->game_field->player[playerid].draw_count = drawcount; 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); 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); int32 len = ((duel*)pduel)->read_buffer(buf);
((duel*)pduel)->clear_buffer(); ((duel*)pduel)->clear_buffer();
return len; return len;
} }
extern "C" DECL_DLLEXPORT int32 process(ptr pduel) { extern "C" DECL_DLLEXPORT int32 process(intptr_t pduel) {
duel* pd = (duel*)pduel; duel* pd = (duel*)pduel;
int result = pd->game_field->process(); int result = pd->game_field->process();
while((result & 0xffff) == 0 && (result & 0xf0000) == 0) while((result & 0xffff) == 0 && (result & 0xf0000) == 0)
result = pd->game_field->process(); result = pd->game_field->process();
return result; 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; duel* ptduel = (duel*)pduel;
if(ptduel->game_field->is_location_useable(playerid, location, sequence)) { if(ptduel->game_field->is_location_useable(playerid, location, sequence)) {
card* pcard = ptduel->new_card(code); card* pcard = ptduel->new_card(code);
...@@ -151,7 +151,7 @@ extern "C" DECL_DLLEXPORT void new_card(ptr pduel, uint32 code, uint8 owner, uin ...@@ -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; duel* ptduel = (duel*)pduel;
if(owner > 1 || !(location & (LOCATION_DECK | LOCATION_EXTRA))) if(owner > 1 || !(location & (LOCATION_DECK | LOCATION_EXTRA)))
return; return;
...@@ -175,7 +175,7 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner, ...@@ -175,7 +175,7 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner,
break; 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) if(playerid != 0 && playerid != 1)
return 0; return 0;
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
...@@ -208,7 +208,7 @@ extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 loca ...@@ -208,7 +208,7 @@ extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 loca
return 4; 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; duel* ptduel = (duel*)pduel;
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
...@@ -237,7 +237,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin ...@@ -237,7 +237,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin
} }
return 0; 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) if(playerid != 0 && playerid != 1)
return 0; return 0;
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
...@@ -284,7 +284,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint ...@@ -284,7 +284,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
} }
return (int32)(p - buf); 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; duel* ptduel = (duel*)pduel;
byte* p = buf; byte* p = buf;
*p++ = MSG_RELOAD_FIELD; *p++ = MSG_RELOAD_FIELD;
...@@ -332,12 +332,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) { ...@@ -332,12 +332,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
} }
return (int32)(p - 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); ((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); ((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); return ((duel*)pduel)->lua->load_script(script);
} }
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#define OCGAPI_H_ #define OCGAPI_H_
#include "common.h" #include "common.h"
#include <cstdint>
#ifdef WIN32 #ifdef WIN32
#define DECL_DLLEXPORT __declspec(dllexport) #define DECL_DLLEXPORT __declspec(dllexport)
#else #else
...@@ -34,22 +36,22 @@ byte* read_script(const char* script_name, int* len); ...@@ -34,22 +36,22 @@ byte* read_script(const char* script_name, int* len);
uint32 read_card(uint32 code, card_data* data); uint32 read_card(uint32 code, card_data* data);
uint32 handle_message(void* pduel, uint32 message_type); uint32 handle_message(void* pduel, uint32 message_type);
extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed); extern "C" DECL_DLLEXPORT std::intptr_t create_duel(uint32 seed);
extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int32 options); extern "C" DECL_DLLEXPORT void start_duel(std::intptr_t pduel, int32 options);
extern "C" DECL_DLLEXPORT void end_duel(ptr pduel); extern "C" DECL_DLLEXPORT void end_duel(std::intptr_t pduel);
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(std::intptr_t 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 void get_log_message(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 get_message(ptr pduel, byte* buf); extern "C" DECL_DLLEXPORT int32 get_message(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 process(ptr pduel); extern "C" DECL_DLLEXPORT int32 process(std::intptr_t 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_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(ptr pduel, uint32 code, uint8 owner, uint8 location); 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(ptr pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache); 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(ptr pduel, uint8 playerid, uint8 location); extern "C" DECL_DLLEXPORT int32 query_field_count(std::intptr_t 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_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(ptr pduel, byte* buf); extern "C" DECL_DLLEXPORT int32 query_field_info(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value); extern "C" DECL_DLLEXPORT void set_responsei(std::intptr_t pduel, int32 value);
extern "C" DECL_DLLEXPORT void set_responseb(ptr pduel, byte* buf); extern "C" DECL_DLLEXPORT void set_responseb(std::intptr_t pduel, byte* buf);
extern "C" DECL_DLLEXPORT int32 preload_script(ptr pduel, const char* script, int32 len); 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); byte* default_script_reader(const char* script_name, int* len);
uint32 default_card_reader(uint32 code, card_data* data); uint32 default_card_reader(uint32 code, card_data* data);
uint32 default_message_handler(void* pduel, uint32 msg_type); uint32 default_message_handler(void* pduel, uint32 msg_type);
......
...@@ -194,6 +194,7 @@ void field::special_summon_complete(effect* reason_effect, uint8 reason_player) ...@@ -194,6 +194,7 @@ void field::special_summon_complete(effect* reason_effect, uint8 reason_player)
group* ng = pduel->new_group(); group* ng = pduel->new_group();
ng->container.swap(core.special_summoning); ng->container.swap(core.special_summoning);
ng->is_readonly = TRUE; ng->is_readonly = TRUE;
core.hint_timing[reason_player] |= TIMING_SPSUMMON;
add_process(PROCESSOR_SPSUMMON, 1, reason_effect, ng, reason_player, 0); 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) { 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