Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
4507f074
Commit
4507f074
authored
Sep 04, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync ocgcore
parent
2abe7790
Changes
18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
959 additions
and
1115 deletions
+959
-1115
Classes/ocgcore/card.cpp
Classes/ocgcore/card.cpp
+88
-91
Classes/ocgcore/card.h
Classes/ocgcore/card.h
+2
-2
Classes/ocgcore/duel.cpp
Classes/ocgcore/duel.cpp
+15
-16
Classes/ocgcore/effect.cpp
Classes/ocgcore/effect.cpp
+6
-6
Classes/ocgcore/effect.h
Classes/ocgcore/effect.h
+1
-1
Classes/ocgcore/field.cpp
Classes/ocgcore/field.cpp
+191
-238
Classes/ocgcore/field.h
Classes/ocgcore/field.h
+8
-8
Classes/ocgcore/interpreter.cpp
Classes/ocgcore/interpreter.cpp
+25
-30
Classes/ocgcore/interpreter.h
Classes/ocgcore/interpreter.h
+5
-5
Classes/ocgcore/libcard.cpp
Classes/ocgcore/libcard.cpp
+12
-12
Classes/ocgcore/libdebug.cpp
Classes/ocgcore/libdebug.cpp
+2
-2
Classes/ocgcore/libduel.cpp
Classes/ocgcore/libduel.cpp
+34
-43
Classes/ocgcore/libgroup.cpp
Classes/ocgcore/libgroup.cpp
+53
-53
Classes/ocgcore/ocgapi.cpp
Classes/ocgcore/ocgapi.cpp
+41
-45
Classes/ocgcore/ocgapi.h
Classes/ocgcore/ocgapi.h
+1
-2
Classes/ocgcore/operations.cpp
Classes/ocgcore/operations.cpp
+253
-280
Classes/ocgcore/playerop.cpp
Classes/ocgcore/playerop.cpp
+35
-53
Classes/ocgcore/processor.cpp
Classes/ocgcore/processor.cpp
+187
-228
No files found.
Classes/ocgcore/card.cpp
View file @
4507f074
This diff is collapsed.
Click to expand it.
Classes/ocgcore/card.h
View file @
4507f074
...
...
@@ -100,9 +100,9 @@ public:
typedef
std
::
unordered_map
<
effect
*
,
effect_container
::
iterator
>
effect_indexer
;
typedef
std
::
unordered_set
<
std
::
pair
<
effect
*
,
uint16
>
,
effect_relation_hash
>
effect_relation
;
typedef
std
::
unordered_map
<
card
*
,
uint32
>
relation_map
;
typedef
std
::
map
<
uint16
,
std
::
array
<
uint16
,
2
>
>
counter_map
;
typedef
std
::
map
<
uint16
,
std
::
array
<
uint16
,
2
>>
counter_map
;
typedef
std
::
map
<
uint32
,
int32
>
effect_count
;
class
attacker_map
:
public
std
::
unordered_map
<
uint16
,
std
::
pair
<
card
*
,
uint32
>
>
{
class
attacker_map
:
public
std
::
unordered_map
<
uint16
,
std
::
pair
<
card
*
,
uint32
>>
{
public:
void
addcard
(
card
*
pcard
);
uint32
findcard
(
card
*
pcard
);
...
...
Classes/ocgcore/duel.cpp
View file @
4507f074
...
...
@@ -20,22 +20,22 @@ duel::duel() {
clear_buffer
();
}
duel
::~
duel
()
{
for
(
auto
cit
=
cards
.
begin
();
cit
!=
cards
.
end
();
++
cit
)
delete
*
cit
;
for
(
auto
git
=
groups
.
begin
();
git
!=
groups
.
end
();
++
git
)
delete
*
git
;
for
(
auto
eit
=
effects
.
begin
();
eit
!=
effects
.
end
();
++
eit
)
delete
*
ei
t
;
for
(
auto
&
pcard
:
cards
)
delete
pcard
;
for
(
auto
&
pgroup
:
groups
)
delete
pgroup
;
for
(
auto
&
peffect
:
effects
)
delete
peffec
t
;
delete
lua
;
delete
game_field
;
}
void
duel
::
clear
()
{
for
(
auto
cit
=
cards
.
begin
();
cit
!=
cards
.
end
();
++
cit
)
delete
*
cit
;
for
(
auto
git
=
groups
.
begin
();
git
!=
groups
.
end
();
++
git
)
delete
*
git
;
for
(
auto
eit
=
effects
.
begin
();
eit
!=
effects
.
end
();
++
eit
)
delete
*
ei
t
;
for
(
auto
&
pcard
:
cards
)
delete
pcard
;
for
(
auto
&
pgroup
:
groups
)
delete
pgroup
;
for
(
auto
&
peffect
:
effects
)
delete
peffec
t
;
delete
game_field
;
cards
.
clear
();
groups
.
clear
();
...
...
@@ -99,8 +99,7 @@ int32 duel::read_buffer(byte* buf) {
return
bufferlen
;
}
void
duel
::
release_script_group
()
{
for
(
auto
sit
=
sgroups
.
begin
();
sit
!=
sgroups
.
end
();
++
sit
)
{
group
*
pgroup
=
*
sit
;
for
(
auto
&
pgroup
:
sgroups
)
{
if
(
pgroup
->
is_readonly
==
0
)
{
lua
->
unregister_group
(
pgroup
);
groups
.
erase
(
pgroup
);
...
...
@@ -110,8 +109,8 @@ void duel::release_script_group() {
sgroups
.
clear
();
}
void
duel
::
restore_assumes
()
{
for
(
auto
sit
=
assumes
.
begin
();
sit
!=
assumes
.
end
();
++
sit
)
(
*
sit
)
->
assume_type
=
0
;
for
(
auto
&
pcard
:
assumes
)
pcard
->
assume_type
=
0
;
assumes
.
clear
();
}
void
duel
::
write_buffer32
(
uint32
value
)
{
...
...
Classes/ocgcore/effect.cpp
View file @
4507f074
...
...
@@ -520,18 +520,18 @@ int32 effect::is_chainable(uint8 tp) {
}
else
if
(
sp
<
pduel
->
game_field
->
core
.
current_chain
.
rbegin
()
->
triggering_effect
->
get_speed
())
return
FALSE
;
}
for
(
auto
it
=
pduel
->
game_field
->
core
.
chain_limit
.
begin
();
it
!=
pduel
->
game_field
->
core
.
chain_limit
.
end
();
++
it
)
{
for
(
const
auto
&
ch_lim
:
pduel
->
game_field
->
core
.
chain_lim
it
)
{
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
);
pduel
->
lua
->
add_param
(
it
->
player
,
PARAM_TYPE_INT
);
pduel
->
lua
->
add_param
(
ch_lim
.
player
,
PARAM_TYPE_INT
);
pduel
->
lua
->
add_param
(
tp
,
PARAM_TYPE_INT
);
if
(
!
pduel
->
lua
->
check_condition
(
it
->
function
,
3
))
if
(
!
pduel
->
lua
->
check_condition
(
ch_lim
.
function
,
3
))
return
FALSE
;
}
for
(
auto
it
=
pduel
->
game_field
->
core
.
chain_limit_p
.
begin
();
it
!=
pduel
->
game_field
->
core
.
chain_limit_p
.
end
();
++
it
)
{
for
(
const
auto
&
ch_lim_p
:
pduel
->
game_field
->
core
.
chain_limit_p
)
{
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
);
pduel
->
lua
->
add_param
(
it
->
player
,
PARAM_TYPE_INT
);
pduel
->
lua
->
add_param
(
ch_lim_p
.
player
,
PARAM_TYPE_INT
);
pduel
->
lua
->
add_param
(
tp
,
PARAM_TYPE_INT
);
if
(
!
pduel
->
lua
->
check_condition
(
it
->
function
,
3
))
if
(
!
pduel
->
lua
->
check_condition
(
ch_lim_p
.
function
,
3
))
return
FALSE
;
}
return
TRUE
;
...
...
Classes/ocgcore/effect.h
View file @
4507f074
...
...
@@ -484,7 +484,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_BATTLE_START 1132
#define EVENT_BATTLE_CONFIRM 1133
#define EVENT_PRE_DAMAGE_CALCULATE 1134
#define EVENT_DAMAGE_CALCULATING 1135
//
#define EVENT_DAMAGE_CALCULATING 1135
#define EVENT_PRE_BATTLE_DAMAGE 1136
//#define EVENT_BATTLE_END 1137
#define EVENT_BATTLED 1138
...
...
Classes/ocgcore/field.cpp
View file @
4507f074
This diff is collapsed.
Click to expand it.
Classes/ocgcore/field.h
View file @
4507f074
...
...
@@ -158,7 +158,7 @@ struct processor {
typedef
std
::
vector
<
chain
>
chain_array
;
typedef
std
::
list
<
processor_unit
>
processor_list
;
typedef
std
::
set
<
card
*
,
card_sort
>
card_set
;
typedef
std
::
set
<
std
::
pair
<
effect
*
,
tevent
>
>
delayed_effect_collection
;
typedef
std
::
set
<
std
::
pair
<
effect
*
,
tevent
>>
delayed_effect_collection
;
struct
chain_limit_t
{
chain_limit_t
(
int32
f
,
int32
p
)
:
function
(
f
),
player
(
p
)
{}
int32
function
;
...
...
@@ -238,7 +238,7 @@ struct processor {
std
::
unordered_map
<
uint32
,
uint32
>
effect_count_code_duel
;
std
::
unordered_map
<
uint32
,
uint32
>
spsummon_once_map
[
2
];
std
::
unordered_map
<
uint32
,
uint32
>
spsummon_once_map_rst
[
2
];
std
::
multimap
<
int32
,
card
*
,
std
::
greater
<
int32
>
>
xmaterial_lst
;
std
::
multimap
<
int32
,
card
*
,
std
::
greater
<
int32
>>
xmaterial_lst
;
ptr
temp_var
[
4
];
uint32
global_flag
;
uint16
pre_field
[
2
];
...
...
@@ -311,12 +311,12 @@ struct processor {
uint32
hint_timing
[
2
];
uint8
current_player
;
uint8
conti_player
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
summon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
normalsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
spsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
flipsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
attack_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
chain_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>>
summon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>>
normalsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>>
spsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>>
flipsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>>
attack_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>>
chain_counter
;
processor_list
recover_damage_reserve
;
effect_vector
dec_count_reserve
;
};
...
...
Classes/ocgcore/interpreter.cpp
View file @
4507f074
...
...
@@ -629,8 +629,8 @@ interpreter::interpreter(duel* pd): coroutines(256) {
luaL_newlib
(
lua_state
,
debuglib
);
lua_setglobal
(
lua_state
,
"Debug"
);
//extra scripts
load_script
(
(
char
*
)
"./script/constant.lua"
);
load_script
(
(
char
*
)
"./script/utility.lua"
);
load_script
(
"./script/constant.lua"
);
load_script
(
"./script/utility.lua"
);
}
interpreter
::~
interpreter
()
{
lua_close
(
lua_state
);
...
...
@@ -654,7 +654,7 @@ int32 interpreter::register_card(card *pcard) {
if
(
pcard
->
data
.
code
&&
(
!
(
pcard
->
data
.
type
&
TYPE_NORMAL
)
||
(
pcard
->
data
.
type
&
TYPE_PENDULUM
)))
{
pcard
->
set_status
(
STATUS_INITIALIZING
,
TRUE
);
add_param
(
pcard
,
PARAM_TYPE_CARD
);
call_card_function
(
pcard
,
(
char
*
)
"initial_effect"
,
1
,
0
);
call_card_function
(
pcard
,
"initial_effect"
,
1
,
0
);
pcard
->
set_status
(
STATUS_INITIALIZING
,
FALSE
);
}
pcard
->
cardid
=
pduel
->
game_field
->
infos
.
card_id
++
;
...
...
@@ -708,14 +708,13 @@ void interpreter::unregister_group(group *pgroup) {
luaL_unref
(
lua_state
,
LUA_REGISTRYINDEX
,
pgroup
->
ref_handle
);
pgroup
->
ref_handle
=
0
;
}
int32
interpreter
::
load_script
(
char
*
script_name
)
{
int32
error
;
int32
interpreter
::
load_script
(
const
char
*
script_name
)
{
int32
len
=
0
;
byte
*
buffer
=
read_script
(
script_name
,
&
len
);
if
(
!
buffer
)
return
OPERATION_FAIL
;
no_action
++
;
error
=
luaL_loadbuffer
(
current_state
,
(
const
char
*
)
buffer
,
len
,
(
const
char
*
)
script_name
)
||
lua_pcall
(
current_state
,
0
,
0
,
0
);
int32
error
=
luaL_loadbuffer
(
current_state
,
(
char
*
)
buffer
,
len
,
script_name
)
||
lua_pcall
(
current_state
,
0
,
0
,
0
);
if
(
error
)
{
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
...
...
@@ -728,7 +727,6 @@ int32 interpreter::load_script(char* script_name) {
}
int32
interpreter
::
load_card_script
(
uint32
code
)
{
char
class_name
[
20
];
char
script_name
[
64
];
sprintf
(
class_name
,
"c%d"
,
code
);
lua_getglobal
(
current_state
,
class_name
);
//if script is not loaded, create and load it
...
...
@@ -743,6 +741,7 @@ int32 interpreter::load_card_script(uint32 code) {
lua_pushstring
(
current_state
,
"__index"
);
lua_pushvalue
(
current_state
,
-
2
);
lua_rawset
(
current_state
,
-
3
);
char
script_name
[
64
];
sprintf
(
script_name
,
"./script/c%d.lua"
,
code
);
if
(
!
load_script
(
script_name
))
{
return
OPERATION_FAIL
;
...
...
@@ -763,47 +762,46 @@ void interpreter::add_param(ptr param, int32 type, bool front) {
params
.
emplace_back
((
void
*
)
param
,
type
);
}
void
interpreter
::
push_param
(
lua_State
*
L
,
bool
is_coroutine
)
{
uint32
type
;
int32
pushed
=
0
;
for
(
auto
it
=
params
.
begin
();
it
!=
params
.
end
();
++
it
)
{
type
=
it
->
second
;
for
(
const
auto
&
it
:
params
)
{
uint32
type
=
it
.
second
;
switch
(
type
)
{
case
PARAM_TYPE_INT
:
lua_pushinteger
(
L
,
(
ptr
)
it
->
first
);
lua_pushinteger
(
L
,
(
ptr
)
it
.
first
);
break
;
case
PARAM_TYPE_STRING
:
lua_pushstring
(
L
,
(
const
char
*
)
it
->
first
);
lua_pushstring
(
L
,
(
const
char
*
)
it
.
first
);
break
;
case
PARAM_TYPE_BOOLEAN
:
lua_pushboolean
(
L
,
(
ptr
)
it
->
first
);
lua_pushboolean
(
L
,
(
ptr
)
it
.
first
);
break
;
case
PARAM_TYPE_CARD
:
{
if
(
it
->
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
card
*
)
it
->
first
)
->
ref_handle
);
if
(
it
.
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
card
*
)
it
.
first
)
->
ref_handle
);
else
lua_pushnil
(
L
);
break
;
}
case
PARAM_TYPE_EFFECT
:
{
if
(
it
->
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
effect
*
)
it
->
first
)
->
ref_handle
);
if
(
it
.
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
effect
*
)
it
.
first
)
->
ref_handle
);
else
lua_pushnil
(
L
);
break
;
}
case
PARAM_TYPE_GROUP
:
{
if
(
it
->
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
group
*
)
it
->
first
)
->
ref_handle
);
if
(
it
.
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
group
*
)
it
.
first
)
->
ref_handle
);
else
lua_pushnil
(
L
);
break
;
}
case
PARAM_TYPE_FUNCTION
:
{
function2value
(
L
,
(
ptr
)
it
->
first
);
function2value
(
L
,
(
ptr
)
it
.
first
);
break
;
}
case
PARAM_TYPE_INDEX
:
{
int32
index
=
(
int32
)(
ptr
)
it
->
first
;
int32
index
=
(
int32
)(
ptr
)
it
.
first
;
if
(
index
>
0
)
lua_pushvalue
(
L
,
index
);
else
if
(
is_coroutine
)
{
...
...
@@ -867,7 +865,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) {
}
return
OPERATION_SUCCESS
;
}
int32
interpreter
::
call_card_function
(
card
*
pcard
,
char
*
f
,
uint32
param_count
,
int32
ret_count
)
{
int32
interpreter
::
call_card_function
(
card
*
pcard
,
c
onst
c
har
*
f
,
uint32
param_count
,
int32
ret_count
)
{
if
(
param_count
!=
params
.
size
())
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCardFunction
\"
(c%d.%s): incorrect parameter count"
,
pcard
->
data
.
code
,
f
);
handle_message
(
pduel
,
1
);
...
...
@@ -907,7 +905,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
}
return
OPERATION_SUCCESS
;
}
int32
interpreter
::
call_code_function
(
uint32
code
,
char
*
f
,
uint32
param_count
,
int32
ret_count
)
{
int32
interpreter
::
call_code_function
(
uint32
code
,
c
onst
c
har
*
f
,
uint32
param_count
,
int32
ret_count
)
{
if
(
param_count
!=
params
.
size
())
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCodeFunction
\"
: incorrect parameter count"
);
handle_message
(
pduel
,
1
);
...
...
@@ -948,7 +946,6 @@ int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count,
return
OPERATION_SUCCESS
;
}
int32
interpreter
::
check_condition
(
int32
f
,
uint32
param_count
)
{
int32
result
;
if
(
!
f
)
{
params
.
clear
();
return
TRUE
;
...
...
@@ -956,7 +953,7 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
no_action
++
;
call_depth
++
;
if
(
call_function
(
f
,
param_count
,
1
))
{
result
=
lua_toboolean
(
current_state
,
-
1
);
int32
result
=
lua_toboolean
(
current_state
,
-
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
call_depth
--
;
...
...
@@ -975,7 +972,6 @@ int32 interpreter::check_condition(int32 f, uint32 param_count) {
return
OPERATION_FAIL
;
}
int32
interpreter
::
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
)
{
int32
result
;
if
(
!
findex
||
lua_isnil
(
current_state
,
findex
))
return
TRUE
;
no_action
++
;
...
...
@@ -996,7 +992,7 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
}
return
OPERATION_FAIL
;
}
result
=
lua_toboolean
(
current_state
,
-
1
);
int32
result
=
lua_toboolean
(
current_state
,
-
1
);
lua_pop
(
current_state
,
1
);
no_action
--
;
call_depth
--
;
...
...
@@ -1007,7 +1003,6 @@ int32 interpreter::check_matching(card* pcard, int32 findex, int32 extraargs) {
return
result
;
}
int32
interpreter
::
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
)
{
int32
result
;
if
(
!
findex
||
lua_isnil
(
current_state
,
findex
))
return
0
;
no_action
++
;
...
...
@@ -1028,7 +1023,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
}
return
OPERATION_FAIL
;
}
result
=
std
::
round
(
lua_tonumber
(
current_state
,
-
1
));
int32
result
=
std
::
round
(
lua_tonumber
(
current_state
,
-
1
));
lua_pop
(
current_state
,
1
);
no_action
--
;
call_depth
--
;
...
...
@@ -1039,7 +1034,6 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
return
result
;
}
int32
interpreter
::
get_function_value
(
int32
f
,
uint32
param_count
)
{
int32
result
;
if
(
!
f
)
{
params
.
clear
();
return
0
;
...
...
@@ -1047,6 +1041,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
no_action
++
;
call_depth
++
;
if
(
call_function
(
f
,
param_count
,
1
))
{
int32
result
=
0
;
if
(
lua_isboolean
(
current_state
,
-
1
))
result
=
lua_toboolean
(
current_state
,
-
1
);
else
...
...
Classes/ocgcore/interpreter.h
View file @
4507f074
...
...
@@ -34,7 +34,7 @@ class duel;
class
interpreter
{
public:
typedef
std
::
unordered_map
<
int32
,
lua_State
*>
coroutine_map
;
typedef
std
::
list
<
std
::
pair
<
void
*
,
uint32
>
>
param_list
;
typedef
std
::
list
<
std
::
pair
<
void
*
,
uint32
>>
param_list
;
duel
*
pduel
;
char
msgbuf
[
64
];
...
...
@@ -49,20 +49,20 @@ public:
explicit
interpreter
(
duel
*
pd
);
~
interpreter
();
int32
register_card
(
card
*
pcard
);
int32
register_card
(
card
*
pcard
);
void
register_effect
(
effect
*
peffect
);
void
unregister_effect
(
effect
*
peffect
);
void
register_group
(
group
*
pgroup
);
void
unregister_group
(
group
*
pgroup
);
int32
load_script
(
c
har
*
buffer
);
int32
load_script
(
c
onst
char
*
script_name
);
int32
load_card_script
(
uint32
code
);
void
add_param
(
void
*
param
,
int32
type
,
bool
front
=
false
);
void
add_param
(
ptr
param
,
int32
type
,
bool
front
=
false
);
void
push_param
(
lua_State
*
L
,
bool
is_coroutine
=
false
);
int32
call_function
(
int32
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_card_function
(
card
*
pcard
,
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_code_function
(
uint32
code
,
c
har
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_card_function
(
card
*
pcard
,
const
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
call_code_function
(
uint32
code
,
c
onst
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
check_condition
(
int32
f
,
uint32
param_count
);
int32
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
...
...
Classes/ocgcore/libcard.cpp
View file @
4507f074
...
...
@@ -1273,9 +1273,9 @@ int32 scriptlib::card_get_attacked_group(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
group
*
pgroup
=
pcard
->
pduel
->
new_group
();
for
(
auto
cit
=
pcard
->
attacked_cards
.
begin
();
cit
!=
pcard
->
attacked_cards
.
end
();
++
cit
)
{
if
(
cit
->
second
.
first
)
pgroup
->
container
.
insert
(
cit
->
second
.
first
);
for
(
auto
&
cit
:
pcard
->
attacked_cards
)
{
if
(
cit
.
second
.
first
)
pgroup
->
container
.
insert
(
cit
.
second
.
first
);
}
interpreter
::
group2value
(
L
,
pgroup
);
return
1
;
...
...
@@ -1299,9 +1299,9 @@ int32 scriptlib::card_get_battled_group(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
group
*
pgroup
=
pcard
->
pduel
->
new_group
();
for
(
auto
cit
=
pcard
->
battled_cards
.
begin
();
cit
!=
pcard
->
battled_cards
.
end
();
++
cit
)
{
if
(
cit
->
second
.
first
)
pgroup
->
container
.
insert
(
cit
->
second
.
first
);
for
(
auto
&
cit
:
pcard
->
battled_cards
)
{
if
(
cit
.
second
.
first
)
pgroup
->
container
.
insert
(
cit
.
second
.
first
);
}
interpreter
::
group2value
(
L
,
pgroup
);
return
1
;
...
...
@@ -1401,9 +1401,9 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
int32
count
=
0
;
for
(
auto
eit
=
pcard
->
field_effect
.
begin
();
eit
!=
pcard
->
field_effect
.
end
();
++
ei
t
)
{
if
(
eit
->
second
->
type
&
EFFECT_TYPE_ACTIVATE
)
{
interpreter
::
effect2value
(
L
,
eit
->
second
);
for
(
auto
&
eit
:
pcard
->
field_effec
t
)
{
if
(
eit
.
second
->
type
&
EFFECT_TYPE_ACTIVATE
)
{
interpreter
::
effect2value
(
L
,
eit
.
second
);
count
++
;
}
}
...
...
@@ -2471,13 +2471,13 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
uint32
reason
=
lua_tointeger
(
L
,
5
);
if
(
countertype
==
0
)
{
// c38834303: remove all counters
for
(
auto
cmit
=
pcard
->
counters
.
begin
();
cmit
!=
pcard
->
counters
.
end
();
++
cmit
)
{
for
(
const
auto
&
cmit
:
pcard
->
counters
)
{
pcard
->
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pcard
->
pduel
->
write_buffer16
(
cmit
->
first
);
pcard
->
pduel
->
write_buffer16
(
cmit
.
first
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
controler
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
pcard
->
pduel
->
write_buffer16
(
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]);
pcard
->
pduel
->
write_buffer16
(
cmit
.
second
[
0
]
+
cmit
.
second
[
1
]);
}
pcard
->
counters
.
clear
();
return
0
;
...
...
Classes/ocgcore/libdebug.cpp
View file @
4507f074
...
...
@@ -64,8 +64,8 @@ int32 scriptlib::debug_add_card(lua_State *L) {
pcard
->
current
.
controler
=
PLAYER_NONE
;
pcard
->
current
.
location
=
LOCATION_OVERLAY
;
pcard
->
current
.
sequence
=
fcard
->
xyz_materials
.
size
()
-
1
;
for
(
auto
eit
=
pcard
->
xmaterial_effect
.
begin
();
eit
!=
pcard
->
xmaterial_effect
.
end
();
++
ei
t
)
{
effect
*
peffect
=
eit
->
second
;
for
(
auto
&
eit
:
pcard
->
xmaterial_effec
t
)
{
effect
*
peffect
=
eit
.
second
;
if
(
peffect
->
type
&
EFFECT_TYPE_FIELD
)
pduel
->
game_field
->
add_effect
(
peffect
);
}
...
...
Classes/ocgcore/libduel.cpp
View file @
4507f074
...
...
@@ -881,11 +881,11 @@ int32 scriptlib::duel_confirm_cards(lua_State *L) {
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
}
else
{
pduel
->
write_buffer8
(
pgroup
->
container
.
size
());
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
pduel
->
write_buffer32
(
(
*
cit
)
->
data
.
code
);
pduel
->
write_buffer8
(
(
*
cit
)
->
current
.
controler
);
pduel
->
write_buffer8
(
(
*
cit
)
->
current
.
location
);
pduel
->
write_buffer8
(
(
*
cit
)
->
current
.
sequence
);
for
(
auto
&
pcard
:
pgroup
->
container
)
{
pduel
->
write_buffer32
(
pcard
->
data
.
code
);
pduel
->
write_buffer8
(
pcard
->
current
.
controler
);
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
}
}
pduel
->
game_field
->
add_process
(
PROCESSOR_WAIT
,
0
,
0
,
0
,
0
,
0
);
...
...
@@ -1042,15 +1042,13 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
}
if
(
!
ret
&&
(
loc
&
LOCATION_SZONE
))
{
if
(
playerid
==
0
||
playerid
==
PLAYER_ALL
)
{
for
(
auto
cit
=
pduel
->
game_field
->
player
[
0
].
list_szone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
0
].
list_szone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_szone
)
{
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
}
}
if
(
playerid
==
1
||
playerid
==
PLAYER_ALL
)
{
for
(
auto
cit
=
pduel
->
game_field
->
player
[
1
].
list_szone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
1
].
list_szone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_szone
)
{
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
}
...
...
@@ -1058,15 +1056,13 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
}
if
(
!
ret
&&
(
loc
&
LOCATION_MZONE
))
{
if
(
playerid
==
0
||
playerid
==
PLAYER_ALL
)
{
for
(
auto
cit
=
pduel
->
game_field
->
player
[
0
].
list_mzone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
0
].
list_mzone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_mzone
)
{
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
}
}
if
(
playerid
==
1
||
playerid
==
PLAYER_ALL
)
{
for
(
auto
cit
=
pduel
->
game_field
->
player
[
1
].
list_mzone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
1
].
list_mzone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_mzone
)
{
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
}
...
...
@@ -1175,15 +1171,14 @@ int32 scriptlib::duel_equip(lua_State *L) {
int32
scriptlib
::
duel_equip_complete
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
field
::
card_set
etargets
;
for
(
auto
cit
=
pduel
->
game_field
->
core
.
equiping_cards
.
begin
();
cit
!=
pduel
->
game_field
->
core
.
equiping_cards
.
end
();
++
cit
)
{
card
*
equip_card
=
*
cit
;
for
(
auto
&
equip_card
:
pduel
->
game_field
->
core
.
equiping_cards
)
{
if
(
equip_card
->
is_position
(
POS_FACEUP
))
equip_card
->
enable_field_effect
(
true
);
etargets
.
insert
(
equip_card
->
equiping_target
);
}
pduel
->
game_field
->
adjust_instant
();
for
(
auto
cit
=
etargets
.
begin
();
cit
!=
etargets
.
end
();
++
cit
)
pduel
->
game_field
->
raise_single_event
(
*
ci
t
,
&
pduel
->
game_field
->
core
.
equiping_cards
,
EVENT_EQUIP
,
for
(
auto
&
equip_target
:
etargets
)
pduel
->
game_field
->
raise_single_event
(
equip_targe
t
,
&
pduel
->
game_field
->
core
.
equiping_cards
,
EVENT_EQUIP
,
pduel
->
game_field
->
core
.
reason_effect
,
0
,
pduel
->
game_field
->
core
.
reason_player
,
PLAYER_NONE
,
0
);
pduel
->
game_field
->
raise_event
(
&
pduel
->
game_field
->
core
.
equiping_cards
,
EVENT_EQUIP
,
pduel
->
game_field
->
core
.
reason_effect
,
0
,
pduel
->
game_field
->
core
.
reason_player
,
PLAYER_NONE
,
0
);
...
...
@@ -1360,15 +1355,14 @@ int32 scriptlib::duel_shuffle_setcard(lua_State *L) {
if
(
pgroup
->
container
.
size
()
<=
1
)
return
0
;
duel
*
pduel
=
pgroup
->
pduel
;
card
*
ms
[
7
];
uint8
seq
[
7
];
card
*
ms
[
5
];
uint8
seq
[
5
];
uint8
tp
=
2
;
uint8
loc
=
0
;
uint8
ct
=
0
;
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pgroup
->
container
)
{
if
((
loc
!=
0
&&
(
pcard
->
current
.
location
!=
loc
))
||
(
pcard
->
current
.
location
!=
LOCATION_MZONE
&&
pcard
->
current
.
location
!=
LOCATION_SZONE
)
||
(
pcard
->
current
.
position
&
POS_FACEUP
)
||
(
pcard
->
current
.
location
==
LOCATION_SZONE
&&
pcard
->
current
.
sequence
>
4
)
||
(
tp
!=
2
&&
(
pcard
->
current
.
controler
!=
tp
)))
||
(
pcard
->
current
.
position
&
POS_FACEUP
)
||
(
pcard
->
current
.
sequence
>
4
)
||
(
tp
!=
2
&&
(
pcard
->
current
.
controler
!=
tp
)))
return
0
;
tp
=
pcard
->
current
.
controler
;
loc
=
pcard
->
current
.
location
;
...
...
@@ -1615,11 +1609,11 @@ int32 scriptlib::duel_disable_summon(lua_State *L) {
if
((
pcard
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
pcard
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
}
else
{
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
(
*
cit
)
->
set_status
(
STATUS_SUMMONING
,
FALSE
);
(
*
cit
)
->
set_status
(
STATUS_SUMMON_DISABLED
,
TRUE
);
if
((
(
*
cit
)
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
(
*
cit
)
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
for
(
auto
&
pcard
:
pgroup
->
container
)
{
pcard
->
set_status
(
STATUS_SUMMONING
,
FALSE
);
pcard
->
set_status
(
STATUS_SUMMON_DISABLED
,
TRUE
);
if
((
pcard
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
pcard
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
}
}
return
0
;
...
...
@@ -1695,8 +1689,7 @@ int32 scriptlib::duel_get_mzone_count(lua_State *L) {
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
or
\"
Group
\"
."
,
2
);
for
(
int32
p
=
0
;
p
<
2
;
p
++
)
{
uint32
digit
=
1
;
for
(
auto
cit
=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
p
].
list_mzone
)
{
if
(
pcard
&&
pcard
!=
mcard
&&
!
(
mgroup
&&
mgroup
->
container
.
find
(
pcard
)
!=
mgroup
->
container
.
end
()))
{
used_location
[
p
]
|=
digit
;
list_mzone
[
p
].
push_back
(
pcard
);
...
...
@@ -1753,8 +1746,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
or
\"
Group
\"
."
,
3
);
for
(
int32
p
=
0
;
p
<
2
;
p
++
)
{
uint32
digit
=
1
;
for
(
auto
cit
=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
p
].
list_mzone
)
{
if
(
pcard
&&
pcard
!=
mcard
&&
!
(
mgroup
&&
mgroup
->
container
.
find
(
pcard
)
!=
mgroup
->
container
.
end
()))
{
used_location
[
p
]
|=
digit
;
list_mzone
[
p
].
push_back
(
pcard
);
...
...
@@ -1959,8 +1951,8 @@ int32 scriptlib::duel_get_first_target(lua_State *L) {
chain
*
ch
=
pduel
->
game_field
->
get_chain
(
0
);
if
(
!
ch
||
!
ch
->
target_cards
||
ch
->
target_cards
->
container
.
size
()
==
0
)
return
0
;
for
(
auto
iter
=
ch
->
target_cards
->
container
.
begin
();
iter
!=
ch
->
target_cards
->
container
.
end
();
++
it
er
)
interpreter
::
card2value
(
L
,
*
iter
);
for
(
auto
&
pcard
:
ch
->
target_cards
->
contain
er
)
interpreter
::
card2value
(
L
,
pcard
);
return
ch
->
target_cards
->
container
.
size
();
}
int32
scriptlib
::
duel_get_current_phase
(
lua_State
*
L
)
{
...
...
@@ -2811,8 +2803,8 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
pcard
->
create_relation
(
*
ch
);
}
else
{
targets
->
container
.
insert
(
pgroup
->
container
.
begin
(),
pgroup
->
container
.
end
());
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
(
*
cit
)
->
create_relation
(
*
ch
);
for
(
auto
&
pcard
:
pgroup
->
container
)
pcard
->
create_relation
(
*
ch
);
}
if
(
peffect
->
is_flag
(
EFFECT_FLAG_CARD_TARGET
))
{
if
(
pcard
)
{
...
...
@@ -2822,12 +2814,12 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
}
else
{
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
if
(
(
*
cit
)
->
current
.
location
&
0x30
)
pduel
->
game_field
->
move_card
(
(
*
cit
)
->
current
.
controler
,
(
*
cit
),
(
*
cit
)
->
current
.
location
,
0
);
for
(
auto
&
pcard
:
pgroup
->
container
)
{
if
(
pcard
->
current
.
location
&
0x30
)
pduel
->
game_field
->
move_card
(
pcard
->
current
.
controler
,
pcard
,
pcard
->
current
.
location
,
0
);
pduel
->
write_buffer8
(
MSG_BECOME_TARGET
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer32
(
(
*
cit
)
->
get_info_location
());
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
}
}
}
...
...
@@ -3085,8 +3077,7 @@ int32 scriptlib::duel_hint_selection(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
duel
*
pduel
=
pgroup
->
pduel
;
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
pgroup
->
container
)
{
pduel
->
write_buffer8
(
MSG_BECOME_TARGET
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
...
...
@@ -3667,8 +3658,8 @@ int32 scriptlib::duel_check_chain_uniqueness(lua_State *L) {
return
1
;
}
std
::
set
<
uint32
>
er
;
for
(
auto
cait
=
pduel
->
game_field
->
core
.
current_chain
.
begin
();
cait
!=
pduel
->
game_field
->
core
.
current_chain
.
end
();
++
cait
)
er
.
insert
(
c
ait
->
triggering_effect
->
get_handler
()
->
get_code
());
for
(
const
auto
&
ch
:
pduel
->
game_field
->
core
.
current_chain
)
er
.
insert
(
c
h
.
triggering_effect
->
get_handler
()
->
get_code
());
if
(
er
.
size
()
==
pduel
->
game_field
->
core
.
current_chain
.
size
())
lua_pushboolean
(
L
,
1
);
else
...
...
Classes/ocgcore/libgroup.cpp
View file @
4507f074
This diff is collapsed.
Click to expand it.
Classes/ocgcore/ocgapi.cpp
View file @
4507f074
...
...
@@ -225,14 +225,14 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin
return
player
.
list_main
.
size
();
if
(
location
==
LOCATION_MZONE
)
{
uint32
count
=
0
;
for
(
auto
cit
=
player
.
list_mzone
.
begin
();
cit
!=
player
.
list_mzone
.
end
();
++
cit
)
if
(
*
cit
)
count
++
;
for
(
auto
&
pcard
:
player
.
list_mzone
)
if
(
pcard
)
count
++
;
return
count
;
}
if
(
location
==
LOCATION_SZONE
)
{
uint32
count
=
0
;
for
(
auto
cit
=
player
.
list_szone
.
begin
();
cit
!=
player
.
list_szone
.
end
();
++
cit
)
if
(
*
cit
)
count
++
;
for
(
auto
&
pcard
:
player
.
list_szone
)
if
(
pcard
)
count
++
;
return
count
;
}
return
0
;
...
...
@@ -244,8 +244,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
byte
*
p
=
buf
;
if
(
location
==
LOCATION_MZONE
)
{
for
(
auto
cit
=
player
.
list_mzone
.
begin
();
cit
!=
player
.
list_mzone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
if
(
pcard
)
{
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
...
...
@@ -255,8 +254,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
}
}
}
else
if
(
location
==
LOCATION_SZONE
)
{
for
(
auto
cit
=
player
.
list_szone
.
begin
();
cit
!=
player
.
list_szone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
player
.
list_szone
)
{
if
(
pcard
)
{
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
...
...
@@ -277,8 +275,8 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
lst
=
&
player
.
list_extra
;
else
if
(
location
==
LOCATION_DECK
)
lst
=
&
player
.
list_main
;
for
(
auto
cit
=
lst
->
begin
();
cit
!=
lst
->
end
();
++
ci
t
)
{
uint32
clen
=
(
*
cit
)
->
get_infos
(
p
,
query_flag
,
use_cache
);
for
(
auto
&
pcard
:
*
ls
t
)
{
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
}
}
...
...
@@ -287,52 +285,50 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
ptr
pduel
,
byte
*
buf
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
byte
*
p
=
buf
;
*
buf
++
=
MSG_RELOAD_FIELD
;
*
buf
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
*
p
++
=
MSG_RELOAD_FIELD
;
*
p
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
for
(
int
playerid
=
0
;
playerid
<
2
;
++
playerid
)
{
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
*
((
int
*
)
buf
)
=
player
.
lp
;
buf
+=
4
;
for
(
auto
cit
=
player
.
list_mzone
.
begin
();
cit
!=
player
.
list_mzone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
*
((
int
*
)
p
)
=
player
.
lp
;
p
+=
4
;
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
if
(
pcard
)
{
*
buf
++
=
1
;
*
buf
++
=
pcard
->
current
.
position
;
*
buf
++
=
pcard
->
xyz_materials
.
size
();
*
p
++
=
1
;
*
p
++
=
pcard
->
current
.
position
;
*
p
++
=
pcard
->
xyz_materials
.
size
();
}
else
{
*
buf
++
=
0
;
*
p
++
=
0
;
}
}
for
(
auto
cit
=
player
.
list_szone
.
begin
();
cit
!=
player
.
list_szone
.
end
();
++
cit
)
{
card
*
pcard
=
*
cit
;
for
(
auto
&
pcard
:
player
.
list_szone
)
{
if
(
pcard
)
{
*
buf
++
=
1
;
*
buf
++
=
pcard
->
current
.
position
;
*
p
++
=
1
;
*
p
++
=
pcard
->
current
.
position
;
}
else
{
*
buf
++
=
0
;
*
p
++
=
0
;
}
}
*
buf
++
=
player
.
list_main
.
size
();
*
buf
++
=
player
.
list_hand
.
size
();
*
buf
++
=
player
.
list_grave
.
size
();
*
buf
++
=
player
.
list_remove
.
size
();
*
buf
++
=
player
.
list_extra
.
size
();
*
buf
++
=
player
.
extra_p_count
;
*
p
++
=
player
.
list_main
.
size
();
*
p
++
=
player
.
list_hand
.
size
();
*
p
++
=
player
.
list_grave
.
size
();
*
p
++
=
player
.
list_remove
.
size
();
*
p
++
=
player
.
list_extra
.
size
();
*
p
++
=
player
.
extra_p_count
;
}
*
buf
++
=
ptduel
->
game_field
->
core
.
current_chain
.
size
();
for
(
auto
chit
=
ptduel
->
game_field
->
core
.
current_chain
.
begin
();
chit
!=
ptduel
->
game_field
->
core
.
current_chain
.
end
();
++
chit
)
{
effect
*
peffect
=
ch
it
->
triggering_effect
;
*
((
int
*
)
buf
)
=
peffect
->
get_handler
()
->
data
.
code
;
buf
+=
4
;
*
((
int
*
)
buf
)
=
peffect
->
get_handler
()
->
get_info_location
();
buf
+=
4
;
*
buf
++
=
chit
->
triggering_controler
;
*
buf
++
=
(
uint8
)
chit
->
triggering_location
;
*
buf
++
=
chit
->
triggering_sequence
;
*
((
int
*
)
buf
)
=
peffect
->
description
;
buf
+=
4
;
*
p
++
=
ptduel
->
game_field
->
core
.
current_chain
.
size
();
for
(
const
auto
&
ch
:
ptduel
->
game_field
->
core
.
current_chain
)
{
effect
*
peffect
=
ch
.
triggering_effect
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
data
.
code
;
p
+=
4
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
get_info_location
();
p
+=
4
;
*
p
++
=
ch
.
triggering_controler
;
*
p
++
=
(
uint8
)
ch
.
triggering_location
;
*
p
++
=
ch
.
triggering_sequence
;
*
((
int
*
)
p
)
=
peffect
->
description
;
p
+=
4
;
}
return
(
int32
)(
buf
-
p
);
return
(
int32
)(
p
-
buf
);
}
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
ptr
pduel
,
int32
value
)
{
((
duel
*
)
pduel
)
->
set_responsei
(
value
);
...
...
@@ -340,6 +336,6 @@ extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) {
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
ptr
pduel
,
byte
*
buf
)
{
((
duel
*
)
pduel
)
->
set_responseb
(
buf
);
}
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
ptr
pduel
,
char
*
script
,
int32
len
)
{
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
ptr
pduel
,
c
onst
c
har
*
script
,
int32
len
)
{
return
((
duel
*
)
pduel
)
->
lua
->
load_script
(
script
);
}
Classes/ocgcore/ocgapi.h
View file @
4507f074
...
...
@@ -10,7 +10,6 @@
#include "common.h"
#ifdef WIN32
#include <windows.h>
#define DECL_DLLEXPORT __declspec(dllexport)
#else
#define DECL_DLLEXPORT
...
...
@@ -50,7 +49,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
ptr
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
ptr
pduel
,
int32
value
);
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
ptr
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
ptr
pduel
,
char
*
script
,
int32
len
);
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
ptr
pduel
,
c
onst
c
har
*
script
,
int32
len
);
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
len
);
uint32
default_card_reader
(
uint32
code
,
card_data
*
data
);
uint32
default_message_handler
(
void
*
pduel
,
uint32
msg_type
);
...
...
Classes/ocgcore/operations.cpp
View file @
4507f074
This diff is collapsed.
Click to expand it.
Classes/ocgcore/playerop.cpp
View file @
4507f074
This diff is collapsed.
Click to expand it.
Classes/ocgcore/processor.cpp
View file @
4507f074
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment