Commit b2d1a11d authored by nanahira's avatar nanahira

Merge branch 'develop'

parents bebba9f0 1d7398c7
...@@ -7,7 +7,7 @@ on: ...@@ -7,7 +7,7 @@ on:
branches: [ "master" ] branches: [ "master" ]
jobs: jobs:
build: build-windows:
runs-on: windows-2022 runs-on: windows-2022
steps: steps:
...@@ -16,16 +16,27 @@ jobs: ...@@ -16,16 +16,27 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Install lua - name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Lua
run: | run: |
bash -c "curl -Z --retry 5 --connect-timeout 30 --location --create-dirs --output-dir temp --remote-name-all https://www.lua.org/ftp/lua-5.4.7.tar.gz https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-windows.zip ; exit 0" tar -xzf ${{ steps.lua.outputs.filepath }}
tar -xzf temp/lua-5.4.7.tar.gz
move lua-5.4.7 lua move lua-5.4.7 lua
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-windows.zip
- name: Premake - name: Premake
run: | run: |
mkdir premake-5 mkdir premake-5
tar -C premake-5 -xzf temp/premake-5.0.0-beta2-windows.zip tar -C premake-5 -xzf ${{ steps.premake.outputs.filepath }}
copy premake\lua.lua lua\premake5.lua copy premake\lua.lua lua\premake5.lua
copy premake\dll.lua dll.lua copy premake\dll.lua dll.lua
.\premake-5\premake5.exe vs2022 --file=dll.lua .\premake-5\premake5.exe vs2022 --file=dll.lua
...@@ -33,14 +44,18 @@ jobs: ...@@ -33,14 +44,18 @@ jobs:
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2 uses: microsoft/setup-msbuild@v2
- name: Build - name: Build x32
run: | run: |
msbuild build\ocgcoredll.sln /t:Build /p:"Configuration=Release;Platform=Win32" msbuild build\ocgcoredll.sln /t:Build /p:"Configuration=Release;Platform=Win32"
- name: Build x64
run: |
msbuild build\ocgcoredll.sln /t:Build /p:"Configuration=Release;Platform=x64" msbuild build\ocgcoredll.sln /t:Build /p:"Configuration=Release;Platform=x64"
- name: Upload build artifacts - name: Upload build artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ocgcore-windows
path: | path: |
build\bin\x32\Release\ocgcore.dll build\bin\x32\Release\ocgcore.dll
build\bin\x64\Release\ocgcore.dll build\bin\x64\Release\ocgcore.dll
...@@ -55,3 +70,63 @@ jobs: ...@@ -55,3 +70,63 @@ jobs:
title: "Development Build" title: "Development Build"
files: | files: |
build/bin/x64/Release/ocgcore.dll build/bin/x64/Release/ocgcore.dll
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib
- name: Download lua
id: lua
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
- name: Lua
run: |
tar -xzf ${{ steps.lua.outputs.filepath }}
mv lua-5.4.7 lua
- name: Download premake
id: premake
uses: mercury233/action-cache-download-file@v1.0.0
with:
url: https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-linux.tar.gz
- name: Premake
run: |
mkdir premake-5
tar -C premake-5 -xzf ${{ steps.premake.outputs.filepath }}
cp premake/lua.lua lua/premake5.lua
cp premake/dll.lua dll.lua
chmod +x premake-5/premake5
./premake-5/premake5 gmake --file=dll.lua
- name: Build x32
run: |
cd build
make -j 4 config=release_x32
cd ..
- name: Build x64
run: |
cd build
make -j 4 config=release_x64
cd ..
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ocgcore-linux
path: |
build/bin/x32/Release/libocgcore.so
build/bin/x64/Release/libocgcore.so
This diff is collapsed.
...@@ -178,7 +178,8 @@ public: ...@@ -178,7 +178,8 @@ public:
uint8_t attack_controler{}; uint8_t attack_controler{};
uint64_t cardid{}; uint64_t cardid{};
uint32_t fieldid{}; uint32_t fieldid{};
uint32_t fieldid_r{}; uint32_t fieldid_r{}; //real field id, updated when moving to new location
uint32_t activate_count_id{}; //updated when moving to new location or flipping
uint16_t turnid{}; uint16_t turnid{};
uint16_t turn_counter{}; uint16_t turn_counter{};
uint8_t unique_pos[2]{}; uint8_t unique_pos[2]{};
...@@ -253,6 +254,8 @@ public: ...@@ -253,6 +254,8 @@ public:
uint32_t get_level(); uint32_t get_level();
uint32_t get_rank(); uint32_t get_rank();
uint32_t get_link(); uint32_t get_link();
uint32_t get_mat_level_from_effect(card* pcard, uint32_t effect_code);
uint32_t get_mat_level(card* pcard, uint32_t level_effect_code, uint32_t allow_effect_code = 0);
uint32_t get_synchro_level(card* pcard); uint32_t get_synchro_level(card* pcard);
uint32_t get_ritual_level(card* pcard); uint32_t get_ritual_level(card* pcard);
uint32_t check_xyz_level(card* pcard, uint32_t lv); uint32_t check_xyz_level(card* pcard, uint32_t lv);
......
...@@ -442,4 +442,11 @@ inline bool check_playerid(int32_t playerid) { ...@@ -442,4 +442,11 @@ inline bool check_playerid(int32_t playerid) {
#define CARDDATA_RSCALE 11 #define CARDDATA_RSCALE 11
#define CARDDATA_LINK_MARKER 12 #define CARDDATA_LINK_MARKER 12
//get effects for Card.GetCardRegistered
#define GETEFFECT_INITIAL 0x1
#define GETEFFECT_GAIN 0x2
#define GETEFFECT_COPY 0x4
#define GETEFFECT_GRANT 0x8
#define GETEFFECT_ALL 0xf
#endif /* COMMON_H_ */ #endif /* COMMON_H_ */
...@@ -159,9 +159,6 @@ int32_t effect::is_single_ready() { ...@@ -159,9 +159,6 @@ int32_t effect::is_single_ready() {
int32_t res = pduel->lua->check_condition(condition, 1); int32_t res = pduel->lua->check_condition(condition, 1);
return res; return res;
} }
// reset_count: count of effect reset
// count_limit: left count of activation
// count_limit_max: max count of activation
int32_t effect::check_count_limit(uint8_t playerid) { int32_t effect::check_count_limit(uint8_t playerid) {
if(is_flag(EFFECT_FLAG_COUNT_LIMIT)) { if(is_flag(EFFECT_FLAG_COUNT_LIMIT)) {
if(count_limit == 0) if(count_limit == 0)
...@@ -171,7 +168,7 @@ int32_t effect::check_count_limit(uint8_t playerid) { ...@@ -171,7 +168,7 @@ int32_t effect::check_count_limit(uint8_t playerid) {
uint32_t limit_type = count_code & 0xf0000000U; uint32_t limit_type = count_code & 0xf0000000U;
int32_t count = count_limit_max; int32_t count = count_limit_max;
if(limit_code == EFFECT_COUNT_CODE_SINGLE) { if(limit_code == EFFECT_COUNT_CODE_SINGLE) {
if(pduel->game_field->get_effect_code(limit_type | get_handler()->fieldid, PLAYER_NONE) >= count) if(pduel->game_field->get_effect_code(limit_type | get_handler()->activate_count_id, PLAYER_NONE) >= count)
return FALSE; return FALSE;
} else { } else {
if(pduel->game_field->get_effect_code(count_code, playerid) >= count) if(pduel->game_field->get_effect_code(count_code, playerid) >= count)
...@@ -219,7 +216,7 @@ int32_t effect::get_required_handorset_effects(effect_set* eset, uint8_t playeri ...@@ -219,7 +216,7 @@ int32_t effect::get_required_handorset_effects(effect_set* eset, uint8_t playeri
uint8_t op = pduel->game_field->core.reason_player; uint8_t op = pduel->game_field->core.reason_player;
pduel->game_field->core.reason_player = playerid; pduel->game_field->core.reason_player = playerid;
pduel->game_field->save_lp_cost(); pduel->game_field->save_lp_cost();
for(int32_t i = 0; i < tmp_eset.size(); ++i) { for(effect_set::size_type i = 0; i < tmp_eset.size(); ++i) {
auto peffect = tmp_eset[i]; auto peffect = tmp_eset[i];
if(peffect->check_count_limit(playerid)) { if(peffect->check_count_limit(playerid)) {
pduel->game_field->core.reason_effect = peffect; pduel->game_field->core.reason_effect = peffect;
...@@ -235,7 +232,7 @@ int32_t effect::get_required_handorset_effects(effect_set* eset, uint8_t playeri ...@@ -235,7 +232,7 @@ int32_t effect::get_required_handorset_effects(effect_set* eset, uint8_t playeri
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
if(pduel->lua->check_condition(peffect->cost, 10)) { if(pduel->lua->check_condition(peffect->cost, 10)) {
available = 2; available = 2;
eset->add_item(peffect); eset->push_back(peffect);
} }
} }
} }
...@@ -381,7 +378,7 @@ int32_t effect::is_activateable(uint8_t playerid, const tevent& e, int32_t negle ...@@ -381,7 +378,7 @@ int32_t effect::is_activateable(uint8_t playerid, const tevent& e, int32_t negle
int32_t effect::is_action_check(uint8_t playerid) { int32_t effect::is_action_check(uint8_t playerid) {
effect_set eset; effect_set eset;
pduel->game_field->filter_player_effect(playerid, EFFECT_CANNOT_ACTIVATE, &eset); pduel->game_field->filter_player_effect(playerid, EFFECT_CANNOT_ACTIVATE, &eset);
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT); pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(eset[i]->check_value_condition(2)) if(eset[i]->check_value_condition(2))
...@@ -389,7 +386,7 @@ int32_t effect::is_action_check(uint8_t playerid) { ...@@ -389,7 +386,7 @@ int32_t effect::is_action_check(uint8_t playerid) {
} }
eset.clear(); eset.clear();
pduel->game_field->filter_player_effect(playerid, EFFECT_ACTIVATE_COST, &eset); pduel->game_field->filter_player_effect(playerid, EFFECT_ACTIVATE_COST, &eset);
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT); pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT); pduel->lua->add_param(playerid, PARAM_TYPE_INT);
...@@ -577,7 +574,7 @@ int32_t effect::is_player_effect_target(card* pcard) { ...@@ -577,7 +574,7 @@ int32_t effect::is_player_effect_target(card* pcard) {
} }
int32_t effect::is_immuned(card* pcard) { int32_t effect::is_immuned(card* pcard) {
const effect_set_v& effects = pcard->immune_effect; const effect_set_v& effects = pcard->immune_effect;
for (int32_t i = 0; i < effects.size(); ++i) { for (effect_set::size_type i = 0; i < effects.size(); ++i) {
effect* peffect = effects[i]; effect* peffect = effects[i];
if(peffect->is_available() && peffect->value) { if(peffect->is_available() && peffect->value) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
...@@ -683,7 +680,7 @@ void effect::dec_count(uint8_t playerid) { ...@@ -683,7 +680,7 @@ void effect::dec_count(uint8_t playerid) {
uint32_t limit_code = count_code & MAX_CARD_ID; uint32_t limit_code = count_code & MAX_CARD_ID;
uint32_t limit_type = count_code & 0xf0000000; uint32_t limit_type = count_code & 0xf0000000;
if(limit_code == EFFECT_COUNT_CODE_SINGLE) if(limit_code == EFFECT_COUNT_CODE_SINGLE)
pduel->game_field->add_effect_code(limit_type | get_handler()->fieldid, PLAYER_NONE); pduel->game_field->add_effect_code(limit_type | get_handler()->activate_count_id, PLAYER_NONE);
else else
pduel->game_field->add_effect_code(count_code, playerid); pduel->game_field->add_effect_code(count_code, playerid);
} }
......
...@@ -18,8 +18,6 @@ class duel; ...@@ -18,8 +18,6 @@ class duel;
class group; class group;
class effect; class effect;
struct tevent; struct tevent;
struct effect_set;
struct effect_set_v;
enum effect_flag : uint64_t; enum effect_flag : uint64_t;
enum effect_flag2 : uint64_t; enum effect_flag2 : uint64_t;
enum effect_category :uint64_t; enum effect_category :uint64_t;
...@@ -42,8 +40,8 @@ public: ...@@ -42,8 +40,8 @@ public:
uint16_t range{ 0 }; uint16_t range{ 0 };
uint16_t s_range{ 0 }; uint16_t s_range{ 0 };
uint16_t o_range{ 0 }; uint16_t o_range{ 0 };
uint8_t count_limit{ 0 }; uint8_t count_limit{ 0 }; //left count of activation
uint8_t count_limit_max{ 0 }; uint8_t count_limit_max{ 0 }; //max count of activation
uint16_t status{ 0 }; uint16_t status{ 0 };
int32_t reset_count{ 0 }; int32_t reset_count{ 0 };
uint32_t reset_flag{ 0 }; uint32_t reset_flag{ 0 };
...@@ -64,6 +62,8 @@ public: ...@@ -64,6 +62,8 @@ public:
int32_t value{ 0 }; int32_t value{ 0 };
int32_t operation{ 0 }; int32_t operation{ 0 };
uint8_t cost_checked{ FALSE }; uint8_t cost_checked{ FALSE };
uint8_t is_granted{ 0 };
effect_set required_handorset_effects; effect_set required_handorset_effects;
LuaParamType object_type{ PARAM_TYPE_INT }; LuaParamType object_type{ PARAM_TYPE_INT };
...@@ -133,14 +133,11 @@ public: ...@@ -133,14 +133,11 @@ public:
#define EFFECT_CANNOT_LOSE_KOISHI 37564153 #define EFFECT_CANNOT_LOSE_KOISHI 37564153
#define EFFECT_EXTRA_TOMAIN_KOISHI 37564154 #define EFFECT_EXTRA_TOMAIN_KOISHI 37564154
#define EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI 37564155 #define EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI 37564155
#define EFFECT_ALLOW_SYNCHRO_KOISHI 37564156
#define EFFECT_MINIATURE_GARDEN_GIRL 37564157
#define EFFECT_ADD_SUMMON_TYPE_KOISHI 37564158 #define EFFECT_ADD_SUMMON_TYPE_KOISHI 37564158
#define EFFECT_REMOVE_SUMMON_TYPE_KOISHI 37564159 #define EFFECT_REMOVE_SUMMON_TYPE_KOISHI 37564159
#define EFFECT_CHANGE_SUMMON_TYPE_KOISHI 37564160 #define EFFECT_CHANGE_SUMMON_TYPE_KOISHI 37564160
#define EFFECT_CHANGE_SUMMON_LOCATION_KOISHI 37564161 #define EFFECT_CHANGE_SUMMON_LOCATION_KOISHI 37564161
#define EFFECT_LINK_SPELL_KOISHI 37564162 #define EFFECT_LINK_SPELL_KOISHI 37564162
#define EFFECT_SEA_PULSE 37564163
#define EFFECT_MAP_OF_HEAVEN 77702007 #define EFFECT_MAP_OF_HEAVEN 77702007
//status //status
...@@ -550,6 +547,8 @@ const std::map<uint64_t, uint64_t> category_checklist{ ...@@ -550,6 +547,8 @@ const std::map<uint64_t, uint64_t> category_checklist{
#define EFFECT_KAISER_COLOSSEUM 370 #define EFFECT_KAISER_COLOSSEUM 370
#define EFFECT_REPLACE_DAMAGE 371 #define EFFECT_REPLACE_DAMAGE 371
#define EFFECT_XYZ_MIN_COUNT 372 #define EFFECT_XYZ_MIN_COUNT 372
#define EFFECT_SYNCHRO_LEVEL_EX 373
#define EFFECT_RITUAL_LEVEL_EX 374
//#define EVENT_STARTUP 1000 //#define EVENT_STARTUP 1000
#define EVENT_FLIP 1001 #define EVENT_FLIP 1001
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#ifndef EFFECTSET_H_ #ifndef EFFECTSET_H_
#define EFFECTSET_H_ #define EFFECTSET_H_
#include <array>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
...@@ -16,96 +15,7 @@ class effect; ...@@ -16,96 +15,7 @@ class effect;
bool effect_sort_id(const effect* e1, const effect* e2); bool effect_sort_id(const effect* e1, const effect* e2);
// std::array<effect*, 64> using effect_set = std::vector<effect*>;
struct effect_set { using effect_set_v = effect_set;
void add_item(effect* peffect) {
if (count >= 64)
return;
container[count++] = peffect;
}
void remove_item(int index) {
if (index < 0 || index >= count)
return;
for(int i = index; i < count - 1; ++i)
container[i] = container[i + 1];
--count;
}
void clear() {
count = 0;
}
int size() const {
return count;
}
void sort() {
if(count < 2)
return;
std::sort(container.begin(), container.begin() + count, effect_sort_id);
}
effect* const& get_last() const {
assert(count);
return container[count - 1];
}
effect*& get_last() {
assert(count);
return container[count - 1];
}
effect* const& operator[] (int index) const {
return container[index];
}
effect*& operator[] (int index) {
return container[index];
}
effect* const& at(int index) const {
return container[index];
}
effect*& at(int index) {
return container[index];
}
private:
std::array<effect*, 64> container{ nullptr };
int count{ 0 };
};
struct effect_set_v {
void add_item(effect* peffect) {
container.push_back(peffect);
}
void remove_item(int index) {
if (index < 0 || index >= (int)container.size())
return;
container.erase(container.begin() + index);
}
void clear() {
container.clear();
}
int size() const {
return (int)container.size();
}
void sort() {
std::sort(container.begin(), container.end(), effect_sort_id);
}
effect* const& get_last() const {
assert(container.size());
return container.back();
}
effect*& get_last() {
assert(container.size());
return container.back();
}
effect* const& operator[] (int index) const {
return container[index];
}
effect*& operator[] (int index) {
return container[index];
}
effect* const& at(int index) const {
return container[index];
}
effect*& at(int index) {
return container[index];
}
private:
std::vector<effect*> container;
};
#endif //EFFECTSET_H_ #endif //EFFECTSET_H_
This diff is collapsed.
...@@ -36,11 +36,10 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -36,11 +36,10 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
luaL_requiref(lua_state, "math", luaopen_math, 1); luaL_requiref(lua_state, "math", luaopen_math, 1);
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
luaL_requiref(lua_state, "coroutine", luaopen_coroutine, 1);
lua_pop(lua_state, 1);
#endif #endif
//add bit lib back
lua_getglobal(lua_state, "bit32");
lua_setglobal(lua_state, "bit");
//open all libs //open all libs
scriptlib::open_cardlib(lua_state); scriptlib::open_cardlib(lua_state);
scriptlib::open_effectlib(lua_state); scriptlib::open_effectlib(lua_state);
...@@ -99,10 +98,10 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -99,10 +98,10 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_setglobal(lua_state, "EFFECT_EXTRA_TOMAIN_KOISHI"); lua_setglobal(lua_state, "EFFECT_EXTRA_TOMAIN_KOISHI");
lua_pushinteger(lua_state, EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI); lua_pushinteger(lua_state, EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI);
lua_setglobal(lua_state, "EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI"); lua_setglobal(lua_state, "EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI");
lua_pushinteger(lua_state, EFFECT_ALLOW_SYNCHRO_KOISHI); lua_pushinteger(lua_state, EFFECT_SYNCHRO_LEVEL_EX);
lua_setglobal(lua_state, "EFFECT_ALLOW_SYNCHRO_KOISHI"); lua_setglobal(lua_state, "EFFECT_ALLOW_SYNCHRO_KOISHI"); // for compat only
lua_pushinteger(lua_state, EFFECT_MINIATURE_GARDEN_GIRL); // lua_pushinteger(lua_state, EFFECT_MINIATURE_GARDEN_GIRL);
lua_setglobal(lua_state, "EFFECT_MINIATURE_GARDEN_GIRL"); // lua_setglobal(lua_state, "EFFECT_MINIATURE_GARDEN_GIRL");
lua_pushinteger(lua_state, EFFECT_ADD_SUMMON_TYPE_KOISHI); lua_pushinteger(lua_state, EFFECT_ADD_SUMMON_TYPE_KOISHI);
lua_setglobal(lua_state, "EFFECT_ADD_SUMMON_TYPE_KOISHI"); lua_setglobal(lua_state, "EFFECT_ADD_SUMMON_TYPE_KOISHI");
lua_pushinteger(lua_state, EFFECT_REMOVE_SUMMON_TYPE_KOISHI); lua_pushinteger(lua_state, EFFECT_REMOVE_SUMMON_TYPE_KOISHI);
...@@ -113,8 +112,20 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -113,8 +112,20 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_setglobal(lua_state, "EFFECT_CHANGE_SUMMON_LOCATION_KOISHI"); lua_setglobal(lua_state, "EFFECT_CHANGE_SUMMON_LOCATION_KOISHI");
lua_pushinteger(lua_state, EFFECT_LINK_SPELL_KOISHI); lua_pushinteger(lua_state, EFFECT_LINK_SPELL_KOISHI);
lua_setglobal(lua_state, "EFFECT_LINK_SPELL_KOISHI"); lua_setglobal(lua_state, "EFFECT_LINK_SPELL_KOISHI");
lua_pushinteger(lua_state, EFFECT_SEA_PULSE);
lua_setglobal(lua_state, "EFFECT_SEA_PULSE"); lua_pushinteger(lua_state, GETEFFECT_ALL);
lua_setglobal(lua_state, "GETEFFECT_ALL");
lua_pushinteger(lua_state, GETEFFECT_INITIAL);
lua_setglobal(lua_state, "GETEFFECT_INITIAL");
lua_pushinteger(lua_state, GETEFFECT_COPY);
lua_setglobal(lua_state, "GETEFFECT_COPY");
lua_pushinteger(lua_state, GETEFFECT_GAIN);
lua_setglobal(lua_state, "GETEFFECT_GAIN");
lua_pushinteger(lua_state, GETEFFECT_GRANT);
lua_setglobal(lua_state, "GETEFFECT_GRANT");
// lua_pushinteger(lua_state, EFFECT_SEA_PULSE);
// lua_setglobal(lua_state, "EFFECT_SEA_PULSE");
lua_pushinteger(lua_state, EFFECT_MAP_OF_HEAVEN); lua_pushinteger(lua_state, EFFECT_MAP_OF_HEAVEN);
lua_setglobal(lua_state, "EFFECT_MAP_OF_HEAVEN"); lua_setglobal(lua_state, "EFFECT_MAP_OF_HEAVEN");
...@@ -209,6 +220,24 @@ void interpreter::unregister_group(group *pgroup) { ...@@ -209,6 +220,24 @@ void interpreter::unregister_group(group *pgroup) {
luaL_unref(lua_state, LUA_REGISTRYINDEX, pgroup->ref_handle); luaL_unref(lua_state, LUA_REGISTRYINDEX, pgroup->ref_handle);
pgroup->ref_handle = 0; pgroup->ref_handle = 0;
} }
int32_t interpreter::is_effect_check(lua_State* L, effect* peffect, int32_t findex, int32_t extraargs) {
if (!findex || lua_isnil(L, findex))
return TRUE;
luaL_checkstack(L, 1 + extraargs, nullptr);
lua_pushvalue(L, findex);
interpreter::effect2value(L, peffect);
for (int32_t i = 0; i < extraargs; ++i)
lua_pushvalue(L, (int32_t)(-extraargs - 2));
if (lua_pcall(L, 1 + extraargs, 1, 0)) {
sprintf(pduel->strbuffer, "%s", lua_tostring(L, -1));
handle_message(pduel, 1);
lua_pop(L, 1);
return OPERATION_FAIL;
}
int32_t result = lua_toboolean(L, -1);
lua_pop(L, 1);
return result;
}
int32_t interpreter::load_script(const char* script_name) { int32_t interpreter::load_script(const char* script_name) {
int len = 0; int len = 0;
byte* buffer = ::read_script(script_name, &len); byte* buffer = ::read_script(script_name, &len);
......
...@@ -64,6 +64,7 @@ public: ...@@ -64,6 +64,7 @@ public:
void register_group(group* pgroup); void register_group(group* pgroup);
void unregister_group(group* pgroup); void unregister_group(group* pgroup);
int32_t is_effect_check(lua_State *L, effect *peffect, int32_t findex, int32_t extraargs);
int32_t load_script(const char* script_name); int32_t load_script(const char* script_name);
int32_t load_card_script(uint32_t 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);
......
...@@ -12,6 +12,55 @@ ...@@ -12,6 +12,55 @@
#include "effect.h" #include "effect.h"
#include "group.h" #include "group.h"
int32_t scriptlib::card_get_card_registered(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
if(!lua_isnil(L, 2))
check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pcard = *(card**) lua_touserdata(L, 1);
int type = GETEFFECT_ALL;
if (!pcard) {
lua_pushnil(L);
return 1;
}
if (lua_gettop(L) > 2) {
check_param(L, PARAM_TYPE_INT, 3);
type = lua_tointeger(L, 3);
}
effect_set eset;
duel* pduel = pcard->pduel;
int32_t extraargs = lua_gettop(L) - 3;
for(auto& eit : pcard->single_effect) {
if(pduel->lua->is_effect_check(L, eit.second, 2, extraargs)) {
eset.push_back(eit.second);
}
}
for(auto& eit : pcard->field_effect) {
if(pduel->lua->is_effect_check(L, eit.second, 2, extraargs)) {
eset.push_back(eit.second);
}
}
int size = 0;
for (int32_t i = 0; i < eset.size(); ++i) {
if (eset[i]->is_granted) {
if (type & GETEFFECT_GRANT) {
interpreter::effect2value(L, eset[i]);
++size;
}
} else if ((type & GETEFFECT_COPY && eset[i]->copy_id != 0)
|| (type & GETEFFECT_INITIAL && eset[i]->reset_flag == 0 && eset[i]->copy_id == 0)
|| (type & GETEFFECT_GAIN && eset[i]->reset_flag != 0 && eset[i]->copy_id == 0)) {
interpreter::effect2value(L, eset[i]);
++size;
}
}
if (!size) {
lua_pushnil(L);
return 1;
}
return size;
}
int32_t scriptlib::card_is_ritual_type(lua_State *L) { int32_t scriptlib::card_is_ritual_type(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);
...@@ -87,11 +136,13 @@ int32_t scriptlib::card_set_card_data(lua_State *L) { ...@@ -87,11 +136,13 @@ int32_t scriptlib::card_set_card_data(lua_State *L) {
pcard->data.link_marker = lua_tointeger(L, 3); pcard->data.link_marker = lua_tointeger(L, 3);
break; break;
} }
pduel->write_buffer8(MSG_MOVE); pduel->write_buffer8(MSG_UPDATE_CARD);
pduel->write_buffer32(pcard->data.code); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer32(pcard->get_info_location()); pduel->write_buffer8(pcard->current.location);
pduel->write_buffer32(pcard->get_info_location()); pduel->write_buffer8(pcard->current.sequence);
pduel->write_buffer32(0); unsigned char query_buffer[0x1000];
auto query_len = pcard->get_infos(query_buffer, 0xe81fff, 0);
pduel->write_buffer(query_buffer, query_len);
return 0; return 0;
} }
int32_t scriptlib::card_get_link_marker(lua_State *L) { int32_t scriptlib::card_get_link_marker(lua_State *L) {
...@@ -194,7 +245,7 @@ int32_t scriptlib::card_get_fusion_code(lua_State *L) { ...@@ -194,7 +245,7 @@ int32_t scriptlib::card_get_fusion_code(lua_State *L) {
return count; return count;
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_FUSION_CODE, &eset); pcard->filter_effect(EFFECT_ADD_FUSION_CODE, &eset);
for(int32_t i = 0; i < eset.size(); ++i) for(effect_set::size_type i = 0; i < eset.size(); ++i)
lua_pushinteger(L, eset[i]->get_value(pcard)); lua_pushinteger(L, eset[i]->get_value(pcard));
return count + eset.size(); return count + eset.size();
} }
...@@ -211,7 +262,7 @@ int32_t scriptlib::card_get_link_code(lua_State *L) { ...@@ -211,7 +262,7 @@ int32_t scriptlib::card_get_link_code(lua_State *L) {
} }
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_LINK_CODE, &eset); pcard->filter_effect(EFFECT_ADD_LINK_CODE, &eset);
for(int32_t i = 0; i < eset.size(); ++i) for(effect_set::size_type i = 0; i < eset.size(); ++i)
lua_pushinteger(L, eset[i]->get_value(pcard)); lua_pushinteger(L, eset[i]->get_value(pcard));
return count + eset.size(); return count + eset.size();
} }
...@@ -229,7 +280,7 @@ int32_t scriptlib::card_is_fusion_code(lua_State *L) { ...@@ -229,7 +280,7 @@ int32_t scriptlib::card_is_fusion_code(lua_State *L) {
fcode.insert(code1); fcode.insert(code1);
if(code2) if(code2)
fcode.insert(code2); fcode.insert(code2);
for(int32_t i = 0; i < eset.size(); ++i) for(effect_set::size_type i = 0; i < eset.size(); ++i)
fcode.insert(eset[i]->get_value(pcard)); fcode.insert(eset[i]->get_value(pcard));
uint32_t count = lua_gettop(L) - 1; uint32_t count = lua_gettop(L) - 1;
uint32_t result = FALSE; uint32_t result = FALSE;
...@@ -259,7 +310,7 @@ int32_t scriptlib::card_is_link_code(lua_State *L) { ...@@ -259,7 +310,7 @@ int32_t scriptlib::card_is_link_code(lua_State *L) {
fcode.insert(code1); fcode.insert(code1);
if(code2) if(code2)
fcode.insert(code2); fcode.insert(code2);
for(int32_t i = 0; i < eset.size(); ++i) for(effect_set::size_type i = 0; i < eset.size(); ++i)
fcode.insert(eset[i]->get_value(pcard)); fcode.insert(eset[i]->get_value(pcard));
uint32_t count = lua_gettop(L) - 1; uint32_t count = lua_gettop(L) - 1;
uint32_t result = FALSE; uint32_t result = FALSE;
...@@ -1989,7 +2040,7 @@ int32_t scriptlib::card_is_has_effect(lua_State *L) { ...@@ -1989,7 +2040,7 @@ int32_t scriptlib::card_is_has_effect(lua_State *L) {
check_player = PLAYER_NONE; check_player = PLAYER_NONE;
} }
int32_t size = 0; int32_t size = 0;
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) { if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) {
interpreter::effect2value(L, eset[i]); interpreter::effect2value(L, eset[i]);
++size; ++size;
...@@ -3586,6 +3637,7 @@ int32_t scriptlib::card_set_spsummon_once(lua_State *L) { ...@@ -3586,6 +3637,7 @@ int32_t scriptlib::card_set_spsummon_once(lua_State *L) {
static const struct luaL_Reg cardlib[] = { static const struct luaL_Reg cardlib[] = {
//millux //millux
{ "GetCardRegistered", scriptlib::card_get_card_registered },
{ "IsRitualType", scriptlib::card_is_ritual_type }, { "IsRitualType", scriptlib::card_is_ritual_type },
{ "SetEntityCode", scriptlib::card_set_entity_code }, { "SetEntityCode", scriptlib::card_set_entity_code },
{ "SetCardData", scriptlib::card_set_card_data }, { "SetCardData", scriptlib::card_set_card_data },
......
...@@ -399,7 +399,7 @@ int32_t scriptlib::duel_get_flag_effect_label(lua_State *L) { ...@@ -399,7 +399,7 @@ int32_t scriptlib::duel_get_flag_effect_label(lua_State *L) {
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
for(int32_t i = 0; i < eset.size(); ++i) for(effect_set::size_type i = 0; i < eset.size(); ++i)
lua_pushinteger(L, eset[i]->label.size() ? eset[i]->label[0] : 0); lua_pushinteger(L, eset[i]->label.size() ? eset[i]->label[0] : 0);
return eset.size(); return eset.size();
} }
...@@ -1475,7 +1475,7 @@ int32_t scriptlib::duel_is_environment(lua_State *L) { ...@@ -1475,7 +1475,7 @@ int32_t scriptlib::duel_is_environment(lua_State *L) {
effect_set eset; effect_set eset;
pduel->game_field->filter_field_effect(EFFECT_CHANGE_ENVIRONMENT, &eset); pduel->game_field->filter_field_effect(EFFECT_CHANGE_ENVIRONMENT, &eset);
if(eset.size()) { if(eset.size()) {
effect* peffect = eset.get_last(); effect* peffect = eset.back();
if(code == (uint32_t)peffect->get_value() && (playerid == peffect->get_handler_player() || playerid == PLAYER_ALL)) if(code == (uint32_t)peffect->get_value() && (playerid == peffect->get_handler_player() || playerid == PLAYER_ALL))
ret = 1; ret = 1;
} }
...@@ -4533,7 +4533,7 @@ int32_t scriptlib::duel_is_player_affected_by_effect(lua_State *L) { ...@@ -4533,7 +4533,7 @@ int32_t scriptlib::duel_is_player_affected_by_effect(lua_State *L) {
effect_set eset; effect_set eset;
pduel->game_field->filter_player_effect(playerid, code, &eset); pduel->game_field->filter_player_effect(playerid, code, &eset);
int32_t size = 0; int32_t size = 0;
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
if(eset[i]->check_count_limit(playerid)) { if(eset[i]->check_count_limit(playerid)) {
interpreter::effect2value(L, eset[i]); interpreter::effect2value(L, eset[i]);
++size; ++size;
......
This diff is collapsed.
...@@ -12,6 +12,7 @@ end ...@@ -12,6 +12,7 @@ end
workspace "ocgcoredll" workspace "ocgcoredll"
location "build" location "build"
language "C++" language "C++"
cppdialect "C++14"
configurations { "Release", "Debug" } configurations { "Release", "Debug" }
platforms { "x32", "x64" } platforms { "x32", "x64" }
...@@ -35,7 +36,11 @@ workspace "ocgcoredll" ...@@ -35,7 +36,11 @@ workspace "ocgcoredll"
startproject "ocgcore" startproject "ocgcore"
filter { "configurations:Release", "action:vs*" } filter { "configurations:Release", "action:vs*" }
flags { "LinkTimeOptimization" } if linktimeoptimization then
linktimeoptimization "On"
else
flags { "LinkTimeOptimization" }
end
staticruntime "On" staticruntime "On"
disablewarnings { "4334" } disablewarnings { "4334" }
...@@ -43,6 +48,19 @@ workspace "ocgcoredll" ...@@ -43,6 +48,19 @@ workspace "ocgcoredll"
buildoptions { "/utf-8" } buildoptions { "/utf-8" }
defines { "_CRT_SECURE_NO_WARNINGS" } defines { "_CRT_SECURE_NO_WARNINGS" }
filter "not action:vs*"
buildoptions { }
filter "system:bsd"
defines { "LUA_USE_POSIX" }
filter "system:macosx"
defines { "LUA_USE_MACOSX" }
filter "system:linux"
defines { "LUA_USE_LINUX" }
buildoptions { "-fPIC" }
filter {} filter {}
include(LUA_DIR) include(LUA_DIR)
...@@ -50,6 +68,7 @@ include(LUA_DIR) ...@@ -50,6 +68,7 @@ include(LUA_DIR)
project "ocgcore" project "ocgcore"
kind "SharedLib" kind "SharedLib"
cppdialect "C++14"
files { "*.cpp", "*.h" } files { "*.cpp", "*.h" }
links { "lua" } links { "lua" }
......
project "lua" project "lua"
kind "StaticLib" kind "StaticLib"
compileas "C++"
files { "src/*.c", "src/*.h", "src/*.hpp" } files { "src/*.c", "src/*.h" }
removefiles { "src/lua.c", "src/luac.c" } removefiles { "src/lua.c", "src/luac.c", "src/linit.c", "src/onelua.c" }
filter "action:vs*"
buildoptions { "/TP" }
filter "not action:vs*"
buildoptions { "-x c++" }
filter "configurations:Debug" filter "configurations:Debug"
defines { "LUA_USE_APICHECK" } defines { "LUA_USE_APICHECK" }
...@@ -21,3 +16,4 @@ project "lua" ...@@ -21,3 +16,4 @@ project "lua"
filter "system:linux" filter "system:linux"
defines { "LUA_USE_LINUX" } defines { "LUA_USE_LINUX" }
buildoptions { "-fPIC" }
project "ocgcore" project "ocgcore"
kind "StaticLib" kind "StaticLib"
cppdialect "C++14"
files { "*.cpp", "*.h" } files { "*.cpp", "*.h" }
links { LUA_LIB_NAME } links { LUA_LIB_NAME }
...@@ -12,7 +13,7 @@ project "ocgcore" ...@@ -12,7 +13,7 @@ project "ocgcore"
end end
filter "not action:vs*" filter "not action:vs*"
buildoptions { "-std=c++14" } buildoptions { }
filter "system:bsd" filter "system:bsd"
defines { "LUA_USE_POSIX" } defines { "LUA_USE_POSIX" }
......
...@@ -1233,7 +1233,7 @@ int32_t field::process_phase_event(int16_t step, int32_t phase) { ...@@ -1233,7 +1233,7 @@ int32_t field::process_phase_event(int16_t step, int32_t phase) {
effect_set eset; effect_set eset;
filter_player_effect(infos.turn_player, EFFECT_HAND_LIMIT, &eset); filter_player_effect(infos.turn_player, EFFECT_HAND_LIMIT, &eset);
if(eset.size()) if(eset.size())
limit = eset.get_last()->get_value(); limit = eset.back()->get_value();
int32_t hd = (int32_t)player[infos.turn_player].list_hand.size(); int32_t hd = (int32_t)player[infos.turn_player].list_hand.size();
if(hd <= limit) { if(hd <= limit) {
core.units.begin()->step = 24; core.units.begin()->step = 24;
...@@ -2148,7 +2148,7 @@ int32_t field::process_idle_command(uint16_t step) { ...@@ -2148,7 +2148,7 @@ int32_t field::process_idle_command(uint16_t step) {
core.spsummonable_cards.clear(); core.spsummonable_cards.clear();
effect_set eset; effect_set eset;
filter_field_effect(EFFECT_SPSUMMON_PROC, &eset); filter_field_effect(EFFECT_SPSUMMON_PROC, &eset);
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
card* pcard = eset[i]->get_handler(); card* pcard = eset[i]->get_handler();
if(!eset[i]->check_count_limit(pcard->current.controler)) if(!eset[i]->check_count_limit(pcard->current.controler))
continue; continue;
...@@ -2157,7 +2157,7 @@ int32_t field::process_idle_command(uint16_t step) { ...@@ -2157,7 +2157,7 @@ int32_t field::process_idle_command(uint16_t step) {
} }
eset.clear(); eset.clear();
filter_field_effect(EFFECT_SPSUMMON_PROC_G, &eset); filter_field_effect(EFFECT_SPSUMMON_PROC_G, &eset);
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
card* pcard = eset[i]->get_handler(); card* pcard = eset[i]->get_handler();
if(!eset[i]->check_count_limit(infos.turn_player)) if(!eset[i]->check_count_limit(infos.turn_player))
continue; continue;
...@@ -2526,7 +2526,7 @@ int32_t field::process_battle_command(uint16_t step) { ...@@ -2526,7 +2526,7 @@ int32_t field::process_battle_command(uint16_t step) {
effect_set eset; effect_set eset;
filter_player_effect(infos.turn_player, EFFECT_ATTACK_COST, &eset, FALSE); filter_player_effect(infos.turn_player, EFFECT_ATTACK_COST, &eset, FALSE);
core.attacker->filter_effect(EFFECT_ATTACK_COST, &eset); core.attacker->filter_effect(EFFECT_ATTACK_COST, &eset);
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
if(eset[i]->operation) { if(eset[i]->operation) {
core.attack_cancelable = FALSE; core.attack_cancelable = FALSE;
core.sub_solving_event.push_back(nil_event); core.sub_solving_event.push_back(nil_event);
...@@ -3398,7 +3398,7 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui ...@@ -3398,7 +3398,7 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui
if(eset.size()) { if(eset.size()) {
pierce = true; pierce = true;
uint8_t dp[2] = {}; uint8_t dp[2] = {};
for(int32_t i = 0; i < eset.size(); ++i) for(effect_set::size_type i = 0; i < eset.size(); ++i)
dp[1 - eset[i]->get_handler_player()] = 1; dp[1 - eset[i]->get_handler_player()] = 1;
if(dp[0]) if(dp[0])
core.battle_damage[0] = attacker_value - defender_value; core.battle_damage[0] = attacker_value - defender_value;
...@@ -3406,7 +3406,7 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui ...@@ -3406,7 +3406,7 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui
core.battle_damage[1] = attacker_value - defender_value; core.battle_damage[1] = attacker_value - defender_value;
bool double_damage = false; bool double_damage = false;
//bool half_damage = false; //bool half_damage = false;
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
if(eset[i]->get_value() == DOUBLE_DAMAGE) if(eset[i]->get_value() == DOUBLE_DAMAGE)
double_damage = true; double_damage = true;
//if(eset[i]->get_value() == HALF_DAMAGE) //if(eset[i]->get_value() == HALF_DAMAGE)
...@@ -3491,12 +3491,12 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui ...@@ -3491,12 +3491,12 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui
core.attack_target->filter_effect(EFFECT_CHANGE_INVOLVING_BATTLE_DAMAGE, &change_effects, FALSE); core.attack_target->filter_effect(EFFECT_CHANGE_INVOLVING_BATTLE_DAMAGE, &change_effects, FALSE);
filter_player_effect(pa, EFFECT_CHANGE_BATTLE_DAMAGE, &change_effects, FALSE); filter_player_effect(pa, EFFECT_CHANGE_BATTLE_DAMAGE, &change_effects, FALSE);
filter_player_effect(1 - pa, EFFECT_CHANGE_BATTLE_DAMAGE, &change_effects, FALSE); filter_player_effect(1 - pa, EFFECT_CHANGE_BATTLE_DAMAGE, &change_effects, FALSE);
change_effects.sort(); std::sort(change_effects.begin(), change_effects.end(), effect_sort_id);
for(uint8_t p = 0; p < 2; ++p) { for(uint8_t p = 0; p < 2; ++p) {
bool double_dam = false; bool double_dam = false;
bool half_dam = false; bool half_dam = false;
int32_t dam_value = -1; int32_t dam_value = -1;
for(int32_t i = 0; i < change_effects.size(); ++i) { for(effect_set::size_type i = 0; i < change_effects.size(); ++i) {
int32_t val = -1; int32_t val = -1;
if(!change_effects[i]->is_flag(EFFECT_FLAG_PLAYER_TARGET)) { if(!change_effects[i]->is_flag(EFFECT_FLAG_PLAYER_TARGET)) {
pduel->lua->add_param(p, PARAM_TYPE_INT); pduel->lua->add_param(p, PARAM_TYPE_INT);
...@@ -3612,13 +3612,13 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui ...@@ -3612,13 +3612,13 @@ void field::calculate_battle_damage(effect** pdamchange, card** preason_card, ui
dam_card->filter_effect(EFFECT_CHANGE_INVOLVING_BATTLE_DAMAGE, &eset, FALSE); dam_card->filter_effect(EFFECT_CHANGE_INVOLVING_BATTLE_DAMAGE, &eset, FALSE);
filter_player_effect(damaged_player, EFFECT_CHANGE_BATTLE_DAMAGE, &eset, FALSE); filter_player_effect(damaged_player, EFFECT_CHANGE_BATTLE_DAMAGE, &eset, FALSE);
filter_player_effect(1 - damaged_player, EFFECT_CHANGE_BATTLE_DAMAGE, &eset, FALSE); filter_player_effect(1 - damaged_player, EFFECT_CHANGE_BATTLE_DAMAGE, &eset, FALSE);
eset.sort(); std::sort(eset.begin(), eset.end(), effect_sort_id);
for(uint8_t p = 0; p < 2; ++p) { for(uint8_t p = 0; p < 2; ++p) {
bool double_dam = false; bool double_dam = false;
bool half_dam = false; bool half_dam = false;
int32_t dam_value = -1; int32_t dam_value = -1;
int32_t current_min = INT32_MAX; int32_t current_min = INT32_MAX;
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
int32_t val = -1; int32_t val = -1;
if(!eset[i]->is_flag(EFFECT_FLAG_PLAYER_TARGET)) { if(!eset[i]->is_flag(EFFECT_FLAG_PLAYER_TARGET)) {
pduel->lua->add_param(p, PARAM_TYPE_INT); pduel->lua->add_param(p, PARAM_TYPE_INT);
...@@ -4006,7 +4006,7 @@ int32_t field::add_chain(uint16_t step) { ...@@ -4006,7 +4006,7 @@ int32_t field::add_chain(uint16_t step) {
card* phandler = peffect->get_handler(); card* phandler = peffect->get_handler();
effect_set eset; effect_set eset;
filter_player_effect(clit.triggering_player, EFFECT_ACTIVATE_COST, &eset); filter_player_effect(clit.triggering_player, EFFECT_ACTIVATE_COST, &eset);
for(int32_t i = 0; i < eset.size(); ++i) { for(effect_set::size_type i = 0; i < eset.size(); ++i) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT); pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(clit.triggering_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(clit.triggering_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(clit.triggering_player, PARAM_TYPE_INT); pduel->lua->add_param(clit.triggering_player, PARAM_TYPE_INT);
...@@ -4177,7 +4177,7 @@ int32_t field::add_chain(uint16_t step) { ...@@ -4177,7 +4177,7 @@ int32_t field::add_chain(uint16_t step) {
auto peffect = clit.triggering_effect; auto peffect = clit.triggering_effect;
auto playerid = clit.triggering_player; auto playerid = clit.triggering_player;
int32_t ceffect_unique_id = 0; int32_t ceffect_unique_id = 0;
for(int32_t i = 0; i < clit.required_handorset_effects.size(); ++i) { for(effect_set::size_type i = 0; i < clit.required_handorset_effects.size(); ++i) {
pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT); pduel->lua->add_param(peffect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT); pduel->lua->add_param(playerid, PARAM_TYPE_INT);
auto id = clit.required_handorset_effects[i]->get_value(2); auto id = clit.required_handorset_effects[i]->get_value(2);
...@@ -4196,7 +4196,7 @@ int32_t field::add_chain(uint16_t step) { ...@@ -4196,7 +4196,7 @@ int32_t field::add_chain(uint16_t step) {
} }
} }
core.select_options.clear(); core.select_options.clear();
for(int32_t i = 0; i < clit.required_handorset_effects.size(); ++i) { for(effect_set::size_type i = 0; i < clit.required_handorset_effects.size(); ++i) {
core.select_options.push_back(clit.required_handorset_effects[i]->description); core.select_options.push_back(clit.required_handorset_effects[i]->description);
} }
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, clit.triggering_player, 0); add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, clit.triggering_player, 0);
...@@ -4623,21 +4623,21 @@ void field::refresh_location_info_instant() { ...@@ -4623,21 +4623,21 @@ void field::refresh_location_info_instant() {
player[0].disabled_location = 0; player[0].disabled_location = 0;
player[1].disabled_location = 0; player[1].disabled_location = 0;
filter_field_effect(EFFECT_DISABLE_FIELD, &eset); filter_field_effect(EFFECT_DISABLE_FIELD, &eset);
for (int32_t i = 0; i < eset.size(); ++i) { for (effect_set::size_type i = 0; i < eset.size(); ++i) {
uint32_t value = eset[i]->get_value(); uint32_t value = eset[i]->get_value();
player[0].disabled_location |= value & 0x1f7f; player[0].disabled_location |= value & 0x1f7f;
player[1].disabled_location |= (value >> 16) & 0x1f7f; player[1].disabled_location |= (value >> 16) & 0x1f7f;
} }
eset.clear(); eset.clear();
filter_field_effect(EFFECT_USE_EXTRA_MZONE, &eset); filter_field_effect(EFFECT_USE_EXTRA_MZONE, &eset);
for (int32_t i = 0; i < eset.size(); ++i) { for (effect_set::size_type i = 0; i < eset.size(); ++i) {
uint8_t p = eset[i]->get_handler_player(); uint8_t p = eset[i]->get_handler_player();
uint32_t value = eset[i]->get_value(); uint32_t value = eset[i]->get_value();
player[p].disabled_location |= (value >> 16) & 0x1f; player[p].disabled_location |= (value >> 16) & 0x1f;
} }
eset.clear(); eset.clear();
filter_field_effect(EFFECT_USE_EXTRA_SZONE, &eset); filter_field_effect(EFFECT_USE_EXTRA_SZONE, &eset);
for (int32_t i = 0; i < eset.size(); ++i) { for (effect_set::size_type i = 0; i < eset.size(); ++i) {
uint8_t p = eset[i]->get_handler_player(); uint8_t p = eset[i]->get_handler_player();
uint32_t value = eset[i]->get_value(); uint32_t value = eset[i]->get_value();
player[p].disabled_location |= (value >> 8) & 0x1f00; player[p].disabled_location |= (value >> 8) & 0x1f00;
...@@ -4661,31 +4661,31 @@ int32_t field::refresh_location_info(uint16_t step) { ...@@ -4661,31 +4661,31 @@ int32_t field::refresh_location_info(uint16_t step) {
core.extra_mzone_effects.clear(); core.extra_mzone_effects.clear();
core.extra_szone_effects.clear(); core.extra_szone_effects.clear();
filter_field_effect(EFFECT_DISABLE_FIELD, &eset); filter_field_effect(EFFECT_DISABLE_FIELD, &eset);
for (int32_t i = 0; i < eset.size(); ++i) { for (effect_set::size_type i = 0; i < eset.size(); ++i) {
uint32_t value = eset[i]->get_value(); uint32_t value = eset[i]->get_value();
if(value) { if(value) {
player[0].disabled_location |= value & 0x1f7f; player[0].disabled_location |= value & 0x1f7f;
player[1].disabled_location |= (value >> 16) & 0x1f7f; player[1].disabled_location |= (value >> 16) & 0x1f7f;
} else } else
core.disfield_effects.add_item(eset[i]); core.disfield_effects.push_back(eset[i]);
} }
eset.clear(); eset.clear();
filter_field_effect(EFFECT_USE_EXTRA_MZONE, &eset); filter_field_effect(EFFECT_USE_EXTRA_MZONE, &eset);
for (int32_t i = 0; i < eset.size(); ++i) { for (effect_set::size_type i = 0; i < eset.size(); ++i) {
uint8_t p = eset[i]->get_handler_player(); uint8_t p = eset[i]->get_handler_player();
uint32_t value = eset[i]->get_value(); uint32_t value = eset[i]->get_value();
player[p].disabled_location |= (value >> 16) & 0x1f; player[p].disabled_location |= (value >> 16) & 0x1f;
if((uint32_t)field_used_count[(value >> 16) & 0x1f] < (value & 0xffff)) if((uint32_t)field_used_count[(value >> 16) & 0x1f] < (value & 0xffff))
core.extra_mzone_effects.add_item(eset[i]); core.extra_mzone_effects.push_back(eset[i]);
} }
eset.clear(); eset.clear();
filter_field_effect(EFFECT_USE_EXTRA_SZONE, &eset); filter_field_effect(EFFECT_USE_EXTRA_SZONE, &eset);
for (int32_t i = 0; i < eset.size(); ++i) { for (effect_set::size_type i = 0; i < eset.size(); ++i) {
uint8_t p = eset[i]->get_handler_player(); uint8_t p = eset[i]->get_handler_player();
uint32_t value = eset[i]->get_value(); uint32_t value = eset[i]->get_value();
player[p].disabled_location |= (value >> 8) & 0x1f00; player[p].disabled_location |= (value >> 8) & 0x1f00;
if((uint32_t)field_used_count[(value >> 16) & 0x1f] < (value & 0xffff)) if((uint32_t)field_used_count[(value >> 16) & 0x1f] < (value & 0xffff))
core.extra_szone_effects.add_item(eset[i]); core.extra_szone_effects.push_back(eset[i]);
} }
return FALSE; return FALSE;
} }
...@@ -4696,7 +4696,7 @@ int32_t field::refresh_location_info(uint16_t step) { ...@@ -4696,7 +4696,7 @@ int32_t field::refresh_location_info(uint16_t step) {
} }
effect* peffect = core.disfield_effects[0]; effect* peffect = core.disfield_effects[0];
core.units.begin()->peffect = peffect; core.units.begin()->peffect = peffect;
core.disfield_effects.remove_item(0); core.disfield_effects.erase(core.disfield_effects.begin());
if(!peffect->operation) { if(!peffect->operation) {
peffect->value = 0x80; peffect->value = 0x80;
core.units.begin()->step = 0; core.units.begin()->step = 0;
...@@ -4729,7 +4729,7 @@ int32_t field::refresh_location_info(uint16_t step) { ...@@ -4729,7 +4729,7 @@ int32_t field::refresh_location_info(uint16_t step) {
} }
effect* peffect = core.extra_mzone_effects[0]; effect* peffect = core.extra_mzone_effects[0];
core.units.begin()->peffect = peffect; core.units.begin()->peffect = peffect;
core.extra_mzone_effects.remove_item(0); core.extra_mzone_effects.erase(core.extra_mzone_effects.begin());
uint32_t p = peffect->get_handler_player(); uint32_t p = peffect->get_handler_player();
uint32_t mzone_flag = (player[p].disabled_location | player[p].used_location) & 0x1f; uint32_t mzone_flag = (player[p].disabled_location | player[p].used_location) & 0x1f;
if(mzone_flag == 0x1f) { if(mzone_flag == 0x1f) {
...@@ -4768,7 +4768,7 @@ int32_t field::refresh_location_info(uint16_t step) { ...@@ -4768,7 +4768,7 @@ int32_t field::refresh_location_info(uint16_t step) {
} }
effect* peffect = core.extra_szone_effects[0]; effect* peffect = core.extra_szone_effects[0];
core.units.begin()->peffect = peffect; core.units.begin()->peffect = peffect;
core.extra_szone_effects.remove_item(0); core.extra_szone_effects.erase(core.extra_szone_effects.begin());
uint32_t p = peffect->get_handler_player(); uint32_t p = peffect->get_handler_player();
uint32_t szone_flag = ((player[p].disabled_location | player[p].used_location) >> 8) & 0x1f; uint32_t szone_flag = ((player[p].disabled_location | player[p].used_location) >> 8) & 0x1f;
if(szone_flag == 0x1f) { if(szone_flag == 0x1f) {
...@@ -5018,7 +5018,7 @@ int32_t field::adjust_step(uint16_t step) { ...@@ -5018,7 +5018,7 @@ int32_t field::adjust_step(uint16_t step) {
eset.clear(); eset.clear();
pcard->filter_effect(EFFECT_SET_POSITION, &eset); pcard->filter_effect(EFFECT_SET_POSITION, &eset);
if(eset.size()) { if(eset.size()) {
pos = eset.get_last()->get_value(); pos = eset.back()->get_value();
if((pos & 0xff) != pcard->current.position) { if((pos & 0xff) != pcard->current.position) {
pos_adjust.insert(pcard); pos_adjust.insert(pcard);
pcard->position_param = pos; pcard->position_param = pos;
......
...@@ -29,6 +29,7 @@ public: ...@@ -29,6 +29,7 @@ public:
static int32_t check_param_count(lua_State* L, int32_t count); static int32_t check_param_count(lua_State* L, int32_t count);
static int32_t check_action_permission(lua_State* L); static int32_t check_action_permission(lua_State* L);
//millux //millux
static int32_t card_get_card_registered(lua_State *L);
static int32_t card_is_ritual_type(lua_State *L); static int32_t card_is_ritual_type(lua_State *L);
static int32_t card_set_entity_code(lua_State *L); static int32_t card_set_entity_code(lua_State *L);
static int32_t card_set_card_data(lua_State *L); static int32_t card_set_card_data(lua_State *L);
......
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