Commit 90674109 authored by nanahira's avatar nanahira

Merge branch 'master' into szonedl

parents 80c420d2 2d486e69
...@@ -7,6 +7,10 @@ stages: ...@@ -7,6 +7,10 @@ stages:
variables: variables:
GIT_DEPTH: "1" GIT_DEPTH: "1"
.no_888:
except:
- '888'
mat_common: mat_common:
stage: prepare stage: prepare
tags: tags:
...@@ -24,6 +28,7 @@ mat_common: ...@@ -24,6 +28,7 @@ mat_common:
- sqlite3 - sqlite3
mat_windows: mat_windows:
extends: .no_888
stage: prepare stage: prepare
tags: tags:
- linux - linux
...@@ -36,6 +41,7 @@ mat_windows: ...@@ -36,6 +41,7 @@ mat_windows:
- premake5.exe - premake5.exe
mat_macos: mat_macos:
extends: .no_888
stage: prepare stage: prepare
tags: tags:
- linux - linux
...@@ -46,13 +52,20 @@ mat_macos: ...@@ -46,13 +52,20 @@ mat_macos:
paths: paths:
- premake5 - premake5
.build_unix: .build:
extends: .no_888
stage: build stage: build
dependencies:
- mat_common
artifacts:
paths:
- dist
.build_unix:
extends: .build
tags: tags:
- noavx2 - noavx2
image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian11 image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian11
dependencies:
- mat_common
variables: variables:
PREMAKE_OS: linux PREMAKE_OS: linux
BUILD_TYPE: x64 BUILD_TYPE: x64
...@@ -66,13 +79,18 @@ mat_macos: ...@@ -66,13 +79,18 @@ mat_macos:
- mkdir -p dist/$BUILD_TYPE - mkdir -p dist/$BUILD_TYPE
- cp build/bin/$BUILD_TYPE/Release/libocgcore.* dist/$BUILD_TYPE/ - cp build/bin/$BUILD_TYPE/Release/libocgcore.* dist/$BUILD_TYPE/
- cp build/bin/$BUILD_TYPE/Release/libsqlite3.* dist/$BUILD_TYPE/ || true - cp build/bin/$BUILD_TYPE/Release/libsqlite3.* dist/$BUILD_TYPE/ || true
artifacts:
paths:
- dist
build_linux_x64: build_linux_x64:
extends: .build_unix extends: .build_unix
build_linux_x64_no_longjmp:
extends: .build_unix
except: []
only:
- '888'
variables:
NO_LONGJMP: '1'
build_linux_x32: build_linux_x32:
extends: .build_unix extends: .build_unix
variables: variables:
...@@ -88,7 +106,7 @@ build_wasm: ...@@ -88,7 +106,7 @@ build_wasm:
image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian12 image: git-registry.moenext.com/mycard/docker-ygopro-builder:debian12
.build_windows: .build_windows:
stage: build extends: .build
dependencies: dependencies:
- mat_common - mat_common
- mat_windows - mat_windows
...@@ -98,9 +116,6 @@ build_wasm: ...@@ -98,9 +116,6 @@ build_wasm:
- copy premake\dll.lua dll.lua - copy premake\dll.lua dll.lua
- '.\premake5.exe vs2019 --file=dll.lua --sqlite3-dir=sqlite3' - '.\premake5.exe vs2019 --file=dll.lua --sqlite3-dir=sqlite3'
- mkdir dist - mkdir dist
artifacts:
paths:
- dist
build_windows_x32: build_windows_x32:
extends: .build_windows extends: .build_windows
...@@ -144,6 +159,7 @@ build_macos_m1: ...@@ -144,6 +159,7 @@ build_macos_m1:
BUILD_TYPE: arm64 BUILD_TYPE: arm64
build_macos: build_macos:
extends: .no_888
stage: combine stage: combine
dependencies: dependencies:
- build_macos_x64 - build_macos_x64
...@@ -174,3 +190,30 @@ upload_to_minio: ...@@ -174,3 +190,30 @@ upload_to_minio:
- aws s3 --endpoint=https://minio.moenext.com:9000 sync --delete dist/ s3://mycard/libocgcore-koishi - aws s3 --endpoint=https://minio.moenext.com:9000 sync --delete dist/ s3://mycard/libocgcore-koishi
only: only:
- master - master
.deploy_to_server:
stage: deploy
tags:
- linux
dependencies:
- build_linux_x64_no_longjmp
variables:
SERVER_USER: nanahira
SERVER_HOST: koishi.momobako.com
FROM_PATH: 'dist/x64/libocgcore.so'
SERVER_PATH: ''
script:
- apt update && apt -y install openssh-client rsync coreutils
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $SERVER_HOST >> ~/.ssh/known_hosts
- echo $NANAHIRA_SSH_KEY | base64 --decode > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/*
- rsync -4cavzP $FROM_PATH $SERVER_USER@$SERVER_HOST:$SERVER_PATH
deploy_888:
extends: .deploy_to_server
variables:
SERVER_PATH: '~/ygopro-super-pre/bin/release/'
only:
- '888'
...@@ -3425,69 +3425,32 @@ int32_t scriptlib::card_add_monster_attribute(lua_State *L) { ...@@ -3425,69 +3425,32 @@ int32_t scriptlib::card_add_monster_attribute(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
pcard->set_status(STATUS_NO_LEVEL, FALSE); pcard->set_status(STATUS_NO_LEVEL, FALSE);
// pre-monster effect* peffect;
effect* peffect = pduel->new_effect(); auto add_temp_effect = [&](uint32_t code, int32_t value, uint32_t extra_reset_flag = 0) {
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_PRE_MONSTER;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_CHAIN + RESET_EVENT + 0x47e0000;
peffect->value = type;
pcard->add_effect(peffect);
//attribute
if(attribute) {
peffect = pduel->new_effect(); peffect = pduel->new_effect();
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_ATTRIBUTE; peffect->code = code;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT | 0x47e0000 | extra_reset_flag;
peffect->value = attribute; peffect->value = value;
pcard->add_effect(peffect); pcard->add_effect(peffect);
};
add_temp_effect(EFFECT_PRE_MONSTER, type, RESET_CHAIN);
if(attribute) {
add_temp_effect(EFFECT_CHANGE_ATTRIBUTE, attribute);
} }
//race
if(race) { if(race) {
peffect = pduel->new_effect(); add_temp_effect(EFFECT_CHANGE_RACE, race);
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_RACE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = race;
pcard->add_effect(peffect);
} }
//level
if(level) { if(level) {
peffect = pduel->new_effect(); add_temp_effect(EFFECT_CHANGE_LEVEL, level);
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_CHANGE_LEVEL;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = level;
pcard->add_effect(peffect);
} }
//atk
if(atk) { if(atk) {
peffect = pduel->new_effect(); add_temp_effect(EFFECT_SET_BASE_ATTACK, atk);
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_ATTACK;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = atk;
pcard->add_effect(peffect);
} }
//def
if(def) { if(def) {
peffect = pduel->new_effect(); add_temp_effect(EFFECT_SET_BASE_DEFENSE, def);
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_DEFENSE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = def;
pcard->add_effect(peffect);
} }
return 0; return 0;
} }
......
...@@ -1465,14 +1465,14 @@ int32_t scriptlib::duel_confirm_cards(lua_State *L) { ...@@ -1465,14 +1465,14 @@ int32_t scriptlib::duel_confirm_cards(lua_State *L) {
int32_t scriptlib::duel_sort_decktop(lua_State *L) { int32_t scriptlib::duel_sort_decktop(lua_State *L) {
check_action_permission(L); check_action_permission(L);
check_param_count(L, 3); check_param_count(L, 3);
uint32_t sort_player = (uint32_t)lua_tointeger(L, 1); int32_t sort_player = (int32_t)lua_tointeger(L, 1);
uint32_t target_player = (uint32_t)lua_tointeger(L, 2); int32_t target_player = (int32_t)lua_tointeger(L, 2);
uint32_t count = (uint32_t)lua_tointeger(L, 3); int32_t count = (int32_t)lua_tointeger(L, 3);
if(sort_player != 0 && sort_player != 1) if (!check_playerid(sort_player))
return 0; return 0;
if(target_player != 0 && target_player != 1) if (!check_playerid(target_player))
return 0; return 0;
if(count < 1 || count > 16) if (count < 1)
return 0; return 0;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->add_process(PROCESSOR_SORT_DECK, 0, 0, 0, sort_player + (target_player << 16), count); pduel->game_field->add_process(PROCESSOR_SORT_DECK, 0, 0, 0, sort_player + (target_player << 16), count);
......
...@@ -368,12 +368,12 @@ int32_t scriptlib::group_random_select(lua_State *L) { ...@@ -368,12 +368,12 @@ int32_t scriptlib::group_random_select(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
int32_t playerid = (int32_t)lua_tointeger(L, 2); int32_t playerid = (int32_t)lua_tointeger(L, 2);
uint32_t count = (uint32_t)lua_tointeger(L, 3); int32_t count = (int32_t)lua_tointeger(L, 3);
int32_t no_hint = lua_toboolean(L, 4); int32_t no_hint = lua_toboolean(L, 4);
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
group* newgroup = pduel->new_group(); group* newgroup = pduel->new_group();
if(count > pgroup->container.size()) if (count > (int32_t)pgroup->container.size())
count = (uint32_t)pgroup->container.size(); count = (int32_t)pgroup->container.size();
if(count == 0) { if(count == 0) {
interpreter::group2value(L, newgroup); interpreter::group2value(L, newgroup);
return 1; return 1;
...@@ -381,12 +381,13 @@ int32_t scriptlib::group_random_select(lua_State *L) { ...@@ -381,12 +381,13 @@ int32_t scriptlib::group_random_select(lua_State *L) {
if(count == pgroup->container.size()) if(count == pgroup->container.size())
newgroup->container = pgroup->container; newgroup->container = pgroup->container;
else { else {
while(newgroup->container.size() < count) { card_vector cv(pgroup->container.begin(), pgroup->container.end());
int32_t i = pduel->get_next_integer(0, (int32_t)pgroup->container.size() - 1); int32_t back = (int32_t)cv.size() - 1;
auto cit = pgroup->container.begin(); for (int32_t i = 0; i < count; ++i) {
std::advance(cit, i); int32_t r = pduel->get_next_integer(i, back);
newgroup->container.insert(*cit); std::swap(cv[i], cv[r]);
} }
newgroup->container.insert(cv.begin(), cv.begin() + count);
} }
if(no_hint) { if(no_hint) {
interpreter::group2value(L, newgroup); interpreter::group2value(L, newgroup);
......
newoption { trigger = "lua-dir", description = "", value = "PATH", default = "./lua" } newoption { trigger = "lua-dir", description = "", value = "PATH", default = "./lua" }
newoption { trigger = "sqlite3-dir", description = "", value = "PATH" } newoption { trigger = "sqlite3-dir", description = "", value = "PATH" }
newoption { trigger = "no-longjmp", description = "Disable use of longjmp for error handling in Lua" }
boolOptions = {
"no-lua-safe",
}
for _, boolOption in ipairs(boolOptions) do
newoption { trigger = boolOption, category = "YGOPro - options", description = "" }
end
function GetParam(param) function GetParam(param)
return _OPTIONS[param] or os.getenv(string.upper(string.gsub(param,"-","_"))) return _OPTIONS[param] or os.getenv(string.upper(string.gsub(param,"-","_")))
...@@ -11,6 +20,13 @@ if not os.isdir(LUA_DIR) then ...@@ -11,6 +20,13 @@ if not os.isdir(LUA_DIR) then
end end
SQLITE3_DIR=GetParam("sqlite3-dir") SQLITE3_DIR=GetParam("sqlite3-dir")
USE_LONGJMP=not GetParam("no-longjmp")
function ApplyBoolean(param)
if GetParam(param) then
defines { "YGOPRO_" .. string.upper(string.gsub(param,"-","_")) }
end
end
workspace "ocgcoredll" workspace "ocgcoredll"
location "build" location "build"
...@@ -19,6 +35,14 @@ workspace "ocgcoredll" ...@@ -19,6 +35,14 @@ workspace "ocgcoredll"
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
platforms { "x64", "x32", "arm64", "wasm" } platforms { "x64", "x32", "arm64", "wasm" }
if USE_LONGJMP then
defines { "LUA_USE_LONGJMP" }
end
for _, boolOption in ipairs(boolOptions) do
ApplyBoolean(boolOption)
end
filter "platforms:x32" filter "platforms:x32"
architecture "x32" architecture "x32"
...@@ -59,11 +83,13 @@ workspace "ocgcoredll" ...@@ -59,11 +83,13 @@ workspace "ocgcoredll"
filter "system:linux" filter "system:linux"
defines { "LUA_USE_LINUX" } defines { "LUA_USE_LINUX" }
pic "On" pic "On"
if USE_LONGJMP then
linkoptions { "-static-libstdc++", "-static-libgcc" } linkoptions { "-static-libstdc++", "-static-libgcc" }
end
filter "platforms:wasm" filter "platforms:wasm"
toolset "emcc" toolset "emcc"
defines { "LUA_USE_C89", "LUA_USE_LONGJMP" } defines { "LUA_USE_C89" }
pic "On" pic "On"
filter {} filter {}
......
...@@ -5,8 +5,6 @@ project "lua" ...@@ -5,8 +5,6 @@ project "lua"
files { "src/*.c", "src/*.h" } files { "src/*.c", "src/*.h" }
removefiles { "src/lua.c", "src/luac.c", "src/onelua.c" } removefiles { "src/lua.c", "src/luac.c", "src/onelua.c" }
defines { "LUA_USE_LONGJMP" }
if not GetParam("no-lua-safe") then if not GetParam("no-lua-safe") then
removefiles { "src/linit.c" } removefiles { "src/linit.c" }
end end
......
project "ocgcore" project "ocgcore"
if OCGCORE_DYNAMIC then
kind "SharedLib"
links { LUA_LIB_NAME }
libdirs { LUA_LIB_DIR }
else
kind "StaticLib" kind "StaticLib"
end
files { "*.cpp", "*.h" } files { "*.cpp", "*.h" }
...@@ -20,3 +26,7 @@ project "ocgcore" ...@@ -20,3 +26,7 @@ project "ocgcore"
filter "system:linux" filter "system:linux"
defines { "LUA_USE_LINUX" } defines { "LUA_USE_LINUX" }
if OCGCORE_DYNAMIC then
pic "On"
-- linkoptions { "-static-libstdc++", "-static-libgcc" }
end
...@@ -675,15 +675,15 @@ uint32_t field::process() { ...@@ -675,15 +675,15 @@ uint32_t field::process() {
++it->step; ++it->step;
} else { } else {
if(returns.bvalue[0] != 0xff) { if(returns.bvalue[0] != 0xff) {
card* tc[16]; card* tc[256];
for(i = 0; i < count; ++i) for(i = 0; i < count; ++i)
player[target_player].list_main.pop_back(); player[target_player].list_main.pop_back();
for(i = 0; i < count; ++i) for(i = 0; i < count; ++i)
tc[returns.bvalue[i]] = core.select_cards[i]; tc[returns.bvalue[i]] = core.select_cards[i];
for(i = 0; i < count; ++i) { for(i = 0; i < count; ++i) {
player[target_player].list_main.push_back(tc[count - i - 1]); player[target_player].list_main.push_back(tc[count - 1 - i]);
tc[count - i - 1]->current.sequence = (uint8_t)player[target_player].list_main.size() - 1;
} }
reset_sequence(target_player, LOCATION_DECK);
auto clit = player[target_player].list_main.rbegin(); auto clit = player[target_player].list_main.rbegin();
for(i = 0; i < count; ++i, ++clit) { for(i = 0; i < count; ++i, ++clit) {
card* pcard = *clit; card* pcard = *clit;
......
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