Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
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
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
MyCard
ygopro-core
Commits
5bacddd6
Commit
5bacddd6
authored
Sep 04, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
b9f8e1bd
40f63398
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
938 additions
and
1074 deletions
+938
-1074
card.cpp
card.cpp
+85
-88
card.h
card.h
+2
-2
duel.cpp
duel.cpp
+15
-16
effect.cpp
effect.cpp
+6
-6
field.cpp
field.cpp
+191
-238
field.h
field.h
+8
-8
interpreter.cpp
interpreter.cpp
+30
-30
interpreter.h
interpreter.h
+5
-5
libcard.cpp
libcard.cpp
+12
-12
libdebug.cpp
libdebug.cpp
+2
-2
libduel.cpp
libduel.cpp
+35
-44
libgroup.cpp
libgroup.cpp
+53
-53
ocgapi.cpp
ocgapi.cpp
+15
-19
ocgapi.h
ocgapi.h
+0
-1
operations.cpp
operations.cpp
+255
-282
playerop.cpp
playerop.cpp
+35
-53
processor.cpp
processor.cpp
+189
-215
No files found.
card.cpp
View file @
5bacddd6
This diff is collapsed.
Click to expand it.
card.h
View file @
5bacddd6
...
@@ -100,9 +100,9 @@ public:
...
@@ -100,9 +100,9 @@ public:
typedef
std
::
unordered_map
<
effect
*
,
effect_container
::
iterator
>
effect_indexer
;
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_set
<
std
::
pair
<
effect
*
,
uint16
>
,
effect_relation_hash
>
effect_relation
;
typedef
std
::
unordered_map
<
card
*
,
uint32
>
relation_map
;
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
;
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:
public:
void
addcard
(
card
*
pcard
);
void
addcard
(
card
*
pcard
);
uint32
findcard
(
card
*
pcard
);
uint32
findcard
(
card
*
pcard
);
...
...
duel.cpp
View file @
5bacddd6
...
@@ -22,22 +22,22 @@ duel::duel() {
...
@@ -22,22 +22,22 @@ duel::duel() {
clear_buffer
();
clear_buffer
();
}
}
duel
::~
duel
()
{
duel
::~
duel
()
{
for
(
auto
cit
=
cards
.
begin
();
cit
!=
cards
.
end
();
++
cit
)
for
(
auto
&
pcard
:
cards
)
delete
*
cit
;
delete
pcard
;
for
(
auto
git
=
groups
.
begin
();
git
!=
groups
.
end
();
++
git
)
for
(
auto
&
pgroup
:
groups
)
delete
*
git
;
delete
pgroup
;
for
(
auto
eit
=
effects
.
begin
();
eit
!=
effects
.
end
();
++
eit
)
for
(
auto
&
peffect
:
effects
)
delete
*
ei
t
;
delete
peffec
t
;
delete
lua
;
delete
lua
;
delete
game_field
;
delete
game_field
;
}
}
void
duel
::
clear
()
{
void
duel
::
clear
()
{
for
(
auto
cit
=
cards
.
begin
();
cit
!=
cards
.
end
();
++
cit
)
for
(
auto
&
pcard
:
cards
)
delete
*
cit
;
delete
pcard
;
for
(
auto
git
=
groups
.
begin
();
git
!=
groups
.
end
();
++
git
)
for
(
auto
&
pgroup
:
groups
)
delete
*
git
;
delete
pgroup
;
for
(
auto
eit
=
effects
.
begin
();
eit
!=
effects
.
end
();
++
eit
)
for
(
auto
&
peffect
:
effects
)
delete
*
ei
t
;
delete
peffec
t
;
delete
game_field
;
delete
game_field
;
cards
.
clear
();
cards
.
clear
();
groups
.
clear
();
groups
.
clear
();
...
@@ -103,8 +103,7 @@ int32 duel::read_buffer(byte* buf) {
...
@@ -103,8 +103,7 @@ int32 duel::read_buffer(byte* buf) {
return
bufferlen
;
return
bufferlen
;
}
}
void
duel
::
release_script_group
()
{
void
duel
::
release_script_group
()
{
for
(
auto
sit
=
sgroups
.
begin
();
sit
!=
sgroups
.
end
();
++
sit
)
{
for
(
auto
&
pgroup
:
sgroups
)
{
group
*
pgroup
=
*
sit
;
if
(
pgroup
->
is_readonly
==
0
)
{
if
(
pgroup
->
is_readonly
==
0
)
{
lua
->
unregister_group
(
pgroup
);
lua
->
unregister_group
(
pgroup
);
groups
.
erase
(
pgroup
);
groups
.
erase
(
pgroup
);
...
@@ -114,8 +113,8 @@ void duel::release_script_group() {
...
@@ -114,8 +113,8 @@ void duel::release_script_group() {
sgroups
.
clear
();
sgroups
.
clear
();
}
}
void
duel
::
restore_assumes
()
{
void
duel
::
restore_assumes
()
{
for
(
auto
sit
=
assumes
.
begin
();
sit
!=
assumes
.
end
();
++
sit
)
for
(
auto
&
pcard
:
assumes
)
(
*
sit
)
->
assume_type
=
0
;
pcard
->
assume_type
=
0
;
assumes
.
clear
();
assumes
.
clear
();
}
}
void
duel
::
write_buffer32
(
uint32
value
)
{
void
duel
::
write_buffer32
(
uint32
value
)
{
...
...
effect.cpp
View file @
5bacddd6
...
@@ -523,18 +523,18 @@ int32 effect::is_chainable(uint8 tp) {
...
@@ -523,18 +523,18 @@ int32 effect::is_chainable(uint8 tp) {
}
else
if
(
sp
<
pduel
->
game_field
->
core
.
current_chain
.
rbegin
()
->
triggering_effect
->
get_speed
())
}
else
if
(
sp
<
pduel
->
game_field
->
core
.
current_chain
.
rbegin
()
->
triggering_effect
->
get_speed
())
return
FALSE
;
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
(
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
);
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
;
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
(
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
);
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
FALSE
;
}
}
return
TRUE
;
return
TRUE
;
...
...
field.cpp
View file @
5bacddd6
This diff is collapsed.
Click to expand it.
field.h
View file @
5bacddd6
...
@@ -158,7 +158,7 @@ struct processor {
...
@@ -158,7 +158,7 @@ struct processor {
typedef
std
::
vector
<
chain
>
chain_array
;
typedef
std
::
vector
<
chain
>
chain_array
;
typedef
std
::
list
<
processor_unit
>
processor_list
;
typedef
std
::
list
<
processor_unit
>
processor_list
;
typedef
std
::
set
<
card
*
,
card_sort
>
card_set
;
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
{
struct
chain_limit_t
{
chain_limit_t
(
int32
f
,
int32
p
)
:
function
(
f
),
player
(
p
)
{}
chain_limit_t
(
int32
f
,
int32
p
)
:
function
(
f
),
player
(
p
)
{}
int32
function
;
int32
function
;
...
@@ -238,7 +238,7 @@ struct processor {
...
@@ -238,7 +238,7 @@ struct processor {
std
::
unordered_map
<
uint32
,
uint32
>
effect_count_code_duel
;
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
[
2
];
std
::
unordered_map
<
uint32
,
uint32
>
spsummon_once_map_rst
[
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
];
ptr
temp_var
[
4
];
uint32
global_flag
;
uint32
global_flag
;
uint16
pre_field
[
2
];
uint16
pre_field
[
2
];
...
@@ -311,12 +311,12 @@ struct processor {
...
@@ -311,12 +311,12 @@ struct processor {
uint32
hint_timing
[
2
];
uint32
hint_timing
[
2
];
uint8
current_player
;
uint8
current_player
;
uint8
conti_player
;
uint8
conti_player
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
summon_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
>>
normalsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
spsummon_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
>>
flipsummon_counter
;
std
::
unordered_map
<
uint32
,
std
::
pair
<
uint32
,
uint32
>
>
attack_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
>>
chain_counter
;
processor_list
recover_damage_reserve
;
processor_list
recover_damage_reserve
;
effect_vector
dec_count_reserve
;
effect_vector
dec_count_reserve
;
};
};
...
...
interpreter.cpp
View file @
5bacddd6
...
@@ -663,9 +663,9 @@ interpreter::interpreter(duel* pd): coroutines(256) {
...
@@ -663,9 +663,9 @@ interpreter::interpreter(duel* pd): coroutines(256) {
luaL_newlib
(
lua_state
,
debuglib
);
luaL_newlib
(
lua_state
,
debuglib
);
lua_setglobal
(
lua_state
,
"Debug"
);
lua_setglobal
(
lua_state
,
"Debug"
);
//extra scripts
//extra scripts
load_script
(
(
char
*
)
"./script/constant.lua"
);
load_script
(
"./script/constant.lua"
);
load_script
(
(
char
*
)
"./script/utility.lua"
);
load_script
(
"./script/utility.lua"
);
load_script
(
(
char
*
)
"./script/special.lua"
);
load_script
(
"./script/special.lua"
);
//load kpro constant
//load kpro constant
//card data constants
//card data constants
lua_pushinteger
(
lua_state
,
CARDDATA_CODE
);
lua_pushinteger
(
lua_state
,
CARDDATA_CODE
);
...
@@ -735,17 +735,17 @@ interpreter::interpreter(duel* pd): coroutines(256) {
...
@@ -735,17 +735,17 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_setglobal
(
lua_state
,
"_WIN32"
);
lua_setglobal
(
lua_state
,
"_WIN32"
);
#endif
#endif
//load init.lua by MLD
//load init.lua by MLD
load_script
(
(
char
*
)
"./script/init.lua"
);
load_script
(
"./script/init.lua"
);
//nef
//nef
/*
/*
load_script(
(char*)
"./script/nef/afi.lua");
load_script("./script/nef/afi.lua");
load_script(
(char*)
"./script/nef/cardList.lua");
load_script("./script/nef/cardList.lua");
load_script(
(char*)
"./script/nef/nef.lua");
load_script("./script/nef/nef.lua");
load_script(
(char*)
"./script/nef/elf.lua");
load_script("./script/nef/elf.lua");
load_script(
(char*)
"./script/nef/ets.lua");
load_script("./script/nef/ets.lua");
load_script(
(char*)
"./script/nef/fus.lua");
load_script("./script/nef/fus.lua");
load_script(
(char*)
"./script/nef/msc.lua");
load_script("./script/nef/msc.lua");
load_script(
(char*)
"./script/nef/uds.lua");
load_script("./script/nef/uds.lua");
*/
*/
}
}
interpreter
::~
interpreter
()
{
interpreter
::~
interpreter
()
{
...
@@ -770,7 +770,7 @@ int32 interpreter::register_card(card *pcard) {
...
@@ -770,7 +770,7 @@ int32 interpreter::register_card(card *pcard) {
if
(
pcard
->
data
.
code
&&
(
!
(
pcard
->
data
.
type
&
TYPE_NORMAL
)
||
(
pcard
->
data
.
type
&
TYPE_PENDULUM
)))
{
if
(
pcard
->
data
.
code
&&
(
!
(
pcard
->
data
.
type
&
TYPE_NORMAL
)
||
(
pcard
->
data
.
type
&
TYPE_PENDULUM
)))
{
pcard
->
set_status
(
STATUS_INITIALIZING
,
TRUE
);
pcard
->
set_status
(
STATUS_INITIALIZING
,
TRUE
);
add_param
(
pcard
,
PARAM_TYPE_CARD
);
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
->
set_status
(
STATUS_INITIALIZING
,
FALSE
);
}
}
pcard
->
cardid
=
pduel
->
game_field
->
infos
.
card_id
++
;
pcard
->
cardid
=
pduel
->
game_field
->
infos
.
card_id
++
;
...
@@ -824,14 +824,14 @@ void interpreter::unregister_group(group *pgroup) {
...
@@ -824,14 +824,14 @@ 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
interpreter
::
load_script
(
char
*
script_name
)
{
int32
interpreter
::
load_script
(
c
onst
c
har
*
script_name
)
{
int32
error
;
int32
error
;
int32
len
=
0
;
int32
len
=
0
;
byte
*
buffer
=
read_script
(
script_name
,
&
len
);
byte
*
buffer
=
read_script
(
script_name
,
&
len
);
if
(
!
buffer
)
if
(
!
buffer
)
return
OPERATION_FAIL
;
return
OPERATION_FAIL
;
no_action
++
;
no_action
++
;
error
=
luaL_loadbuffer
(
current_state
,
(
c
onst
char
*
)
buffer
,
len
,
(
const
char
*
)
script_name
)
||
lua_pcall
(
current_state
,
0
,
0
,
0
);
error
=
luaL_loadbuffer
(
current_state
,
(
c
har
*
)
buffer
,
len
,
script_name
)
||
lua_pcall
(
current_state
,
0
,
0
,
0
);
if
(
error
)
{
if
(
error
)
{
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
interpreter
::
strcpy
(
pduel
->
strbuffer
,
lua_tostring
(
current_state
,
-
1
));
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
...
@@ -881,45 +881,45 @@ void interpreter::add_param(ptr param, int32 type, bool front) {
...
@@ -881,45 +881,45 @@ void interpreter::add_param(ptr param, int32 type, bool front) {
void
interpreter
::
push_param
(
lua_State
*
L
,
bool
is_coroutine
)
{
void
interpreter
::
push_param
(
lua_State
*
L
,
bool
is_coroutine
)
{
uint32
type
;
uint32
type
;
int32
pushed
=
0
;
int32
pushed
=
0
;
for
(
auto
it
=
params
.
begin
();
it
!=
params
.
end
();
++
it
)
{
for
(
const
auto
&
it
:
params
)
{
type
=
it
->
second
;
type
=
it
.
second
;
switch
(
type
)
{
switch
(
type
)
{
case
PARAM_TYPE_INT
:
case
PARAM_TYPE_INT
:
lua_pushinteger
(
L
,
(
ptr
)
it
->
first
);
lua_pushinteger
(
L
,
(
ptr
)
it
.
first
);
break
;
break
;
case
PARAM_TYPE_STRING
:
case
PARAM_TYPE_STRING
:
lua_pushstring
(
L
,
(
const
char
*
)
it
->
first
);
lua_pushstring
(
L
,
(
const
char
*
)
it
.
first
);
break
;
break
;
case
PARAM_TYPE_BOOLEAN
:
case
PARAM_TYPE_BOOLEAN
:
lua_pushboolean
(
L
,
(
ptr
)
it
->
first
);
lua_pushboolean
(
L
,
(
ptr
)
it
.
first
);
break
;
break
;
case
PARAM_TYPE_CARD
:
{
case
PARAM_TYPE_CARD
:
{
if
(
it
->
first
)
if
(
it
.
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
card
*
)
it
->
first
)
->
ref_handle
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
card
*
)
it
.
first
)
->
ref_handle
);
else
else
lua_pushnil
(
L
);
lua_pushnil
(
L
);
break
;
break
;
}
}
case
PARAM_TYPE_EFFECT
:
{
case
PARAM_TYPE_EFFECT
:
{
if
(
it
->
first
)
if
(
it
.
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
effect
*
)
it
->
first
)
->
ref_handle
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
effect
*
)
it
.
first
)
->
ref_handle
);
else
else
lua_pushnil
(
L
);
lua_pushnil
(
L
);
break
;
break
;
}
}
case
PARAM_TYPE_GROUP
:
{
case
PARAM_TYPE_GROUP
:
{
if
(
it
->
first
)
if
(
it
.
first
)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
group
*
)
it
->
first
)
->
ref_handle
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
((
group
*
)
it
.
first
)
->
ref_handle
);
else
else
lua_pushnil
(
L
);
lua_pushnil
(
L
);
break
;
break
;
}
}
case
PARAM_TYPE_FUNCTION
:
{
case
PARAM_TYPE_FUNCTION
:
{
function2value
(
L
,
(
ptr
)
it
->
first
);
function2value
(
L
,
(
ptr
)
it
.
first
);
break
;
break
;
}
}
case
PARAM_TYPE_INDEX
:
{
case
PARAM_TYPE_INDEX
:
{
int32
index
=
(
int32
)(
ptr
)
it
->
first
;
int32
index
=
(
int32
)(
ptr
)
it
.
first
;
if
(
index
>
0
)
if
(
index
>
0
)
lua_pushvalue
(
L
,
index
);
lua_pushvalue
(
L
,
index
);
else
if
(
is_coroutine
)
{
else
if
(
is_coroutine
)
{
...
@@ -983,7 +983,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) {
...
@@ -983,7 +983,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) {
}
}
return
OPERATION_SUCCESS
;
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
())
{
if
(
param_count
!=
params
.
size
())
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCardFunction
\"
(c%d.%s): incorrect parameter count"
,
pcard
->
data
.
code
,
f
);
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCardFunction
\"
(c%d.%s): incorrect parameter count"
,
pcard
->
data
.
code
,
f
);
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
...
@@ -1023,7 +1023,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
...
@@ -1023,7 +1023,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
}
}
return
OPERATION_SUCCESS
;
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
())
{
if
(
param_count
!=
params
.
size
())
{
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCodeFunction
\"
: incorrect parameter count"
);
sprintf
(
pduel
->
strbuffer
,
"
\"
CallCodeFunction
\"
: incorrect parameter count"
);
handle_message
(
pduel
,
1
);
handle_message
(
pduel
,
1
);
...
...
interpreter.h
View file @
5bacddd6
...
@@ -34,7 +34,7 @@ class duel;
...
@@ -34,7 +34,7 @@ class duel;
class
interpreter
{
class
interpreter
{
public:
public:
typedef
std
::
unordered_map
<
int32
,
lua_State
*>
coroutine_map
;
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
;
duel
*
pduel
;
char
msgbuf
[
64
];
char
msgbuf
[
64
];
...
@@ -50,20 +50,20 @@ public:
...
@@ -50,20 +50,20 @@ public:
explicit
interpreter
(
duel
*
pd
);
explicit
interpreter
(
duel
*
pd
);
~
interpreter
();
~
interpreter
();
int32
register_card
(
card
*
pcard
);
int32
register_card
(
card
*
pcard
);
void
register_effect
(
effect
*
peffect
);
void
register_effect
(
effect
*
peffect
);
void
unregister_effect
(
effect
*
peffect
);
void
unregister_effect
(
effect
*
peffect
);
void
register_group
(
group
*
pgroup
);
void
register_group
(
group
*
pgroup
);
void
unregister_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
);
int32
load_card_script
(
uint32
code
);
void
add_param
(
void
*
param
,
int32
type
,
bool
front
=
false
);
void
add_param
(
void
*
param
,
int32
type
,
bool
front
=
false
);
void
add_param
(
ptr
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
);
void
push_param
(
lua_State
*
L
,
bool
is_coroutine
=
false
);
int32
call_function
(
int32
f
,
uint32
param_count
,
int32
ret_count
);
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_card_function
(
card
*
pcard
,
const
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_code_function
(
uint32
code
,
c
onst
char
*
f
,
uint32
param_count
,
int32
ret_count
);
int32
check_condition
(
int32
f
,
uint32
param_count
);
int32
check_condition
(
int32
f
,
uint32
param_count
);
int32
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
check_matching
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
get_operation_value
(
card
*
pcard
,
int32
findex
,
int32
extraargs
);
...
...
libcard.cpp
View file @
5bacddd6
...
@@ -1396,9 +1396,9 @@ int32 scriptlib::card_get_attacked_group(lua_State *L) {
...
@@ -1396,9 +1396,9 @@ int32 scriptlib::card_get_attacked_group(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
group
*
pgroup
=
pcard
->
pduel
->
new_group
();
group
*
pgroup
=
pcard
->
pduel
->
new_group
();
for
(
auto
cit
=
pcard
->
attacked_cards
.
begin
();
cit
!=
pcard
->
attacked_cards
.
end
();
++
cit
)
{
for
(
auto
&
cit
:
pcard
->
attacked_cards
)
{
if
(
cit
->
second
.
first
)
if
(
cit
.
second
.
first
)
pgroup
->
container
.
insert
(
cit
->
second
.
first
);
pgroup
->
container
.
insert
(
cit
.
second
.
first
);
}
}
interpreter
::
group2value
(
L
,
pgroup
);
interpreter
::
group2value
(
L
,
pgroup
);
return
1
;
return
1
;
...
@@ -1422,9 +1422,9 @@ int32 scriptlib::card_get_battled_group(lua_State *L) {
...
@@ -1422,9 +1422,9 @@ int32 scriptlib::card_get_battled_group(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
group
*
pgroup
=
pcard
->
pduel
->
new_group
();
group
*
pgroup
=
pcard
->
pduel
->
new_group
();
for
(
auto
cit
=
pcard
->
battled_cards
.
begin
();
cit
!=
pcard
->
battled_cards
.
end
();
++
cit
)
{
for
(
auto
&
cit
:
pcard
->
battled_cards
)
{
if
(
cit
->
second
.
first
)
if
(
cit
.
second
.
first
)
pgroup
->
container
.
insert
(
cit
->
second
.
first
);
pgroup
->
container
.
insert
(
cit
.
second
.
first
);
}
}
interpreter
::
group2value
(
L
,
pgroup
);
interpreter
::
group2value
(
L
,
pgroup
);
return
1
;
return
1
;
...
@@ -1524,9 +1524,9 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) {
...
@@ -1524,9 +1524,9 @@ int32 scriptlib::card_get_activate_effect(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
check_param
(
L
,
PARAM_TYPE_CARD
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
int32
count
=
0
;
int32
count
=
0
;
for
(
auto
eit
=
pcard
->
field_effect
.
begin
();
eit
!=
pcard
->
field_effect
.
end
();
++
ei
t
)
{
for
(
auto
&
eit
:
pcard
->
field_effec
t
)
{
if
(
eit
->
second
->
type
&
EFFECT_TYPE_ACTIVATE
)
{
if
(
eit
.
second
->
type
&
EFFECT_TYPE_ACTIVATE
)
{
interpreter
::
effect2value
(
L
,
eit
->
second
);
interpreter
::
effect2value
(
L
,
eit
.
second
);
count
++
;
count
++
;
}
}
}
}
...
@@ -2622,13 +2622,13 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
...
@@ -2622,13 +2622,13 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
uint32
reason
=
lua_tointeger
(
L
,
5
);
uint32
reason
=
lua_tointeger
(
L
,
5
);
if
(
countertype
==
0
)
{
if
(
countertype
==
0
)
{
// c38834303: remove all counters
// 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_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
.
controler
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pcard
->
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
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
();
pcard
->
counters
.
clear
();
return
0
;
return
0
;
...
...
libdebug.cpp
View file @
5bacddd6
...
@@ -64,8 +64,8 @@ int32 scriptlib::debug_add_card(lua_State *L) {
...
@@ -64,8 +64,8 @@ int32 scriptlib::debug_add_card(lua_State *L) {
pcard
->
current
.
controler
=
PLAYER_NONE
;
pcard
->
current
.
controler
=
PLAYER_NONE
;
pcard
->
current
.
location
=
LOCATION_OVERLAY
;
pcard
->
current
.
location
=
LOCATION_OVERLAY
;
pcard
->
current
.
sequence
=
fcard
->
xyz_materials
.
size
()
-
1
;
pcard
->
current
.
sequence
=
fcard
->
xyz_materials
.
size
()
-
1
;
for
(
auto
eit
=
pcard
->
xmaterial_effect
.
begin
();
eit
!=
pcard
->
xmaterial_effect
.
end
();
++
ei
t
)
{
for
(
auto
&
eit
:
pcard
->
xmaterial_effec
t
)
{
effect
*
peffect
=
eit
->
second
;
effect
*
peffect
=
eit
.
second
;
if
(
peffect
->
type
&
EFFECT_TYPE_FIELD
)
if
(
peffect
->
type
&
EFFECT_TYPE_FIELD
)
pduel
->
game_field
->
add_effect
(
peffect
);
pduel
->
game_field
->
add_effect
(
peffect
);
}
}
...
...
libduel.cpp
View file @
5bacddd6
...
@@ -204,7 +204,7 @@ int32 scriptlib::duel_load_script(lua_State *L) {
...
@@ -204,7 +204,7 @@ int32 scriptlib::duel_load_script(lua_State *L) {
const
char
*
pstr
=
lua_tostring
(
L
,
1
);
const
char
*
pstr
=
lua_tostring
(
L
,
1
);
char
filename
[
64
];
char
filename
[
64
];
sprintf
(
filename
,
"./script/%s"
,
pstr
);
sprintf
(
filename
,
"./script/%s"
,
pstr
);
lua_pushboolean
(
L
,
pduel
->
lua
->
load_script
(
(
char
*
)
filename
));
lua_pushboolean
(
L
,
pduel
->
lua
->
load_script
(
filename
));
return
1
;
return
1
;
}
}
...
@@ -1083,11 +1083,11 @@ int32 scriptlib::duel_confirm_cards(lua_State *L) {
...
@@ -1083,11 +1083,11 @@ int32 scriptlib::duel_confirm_cards(lua_State *L) {
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
}
else
{
}
else
{
pduel
->
write_buffer8
(
pgroup
->
container
.
size
());
pduel
->
write_buffer8
(
pgroup
->
container
.
size
());
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pgroup
->
container
)
{
pduel
->
write_buffer32
(
(
*
cit
)
->
data
.
code
);
pduel
->
write_buffer32
(
pcard
->
data
.
code
);
pduel
->
write_buffer8
(
(
*
cit
)
->
current
.
controler
);
pduel
->
write_buffer8
(
pcard
->
current
.
controler
);
pduel
->
write_buffer8
(
(
*
cit
)
->
current
.
location
);
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pduel
->
write_buffer8
(
(
*
cit
)
->
current
.
sequence
);
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
}
}
}
}
pduel
->
game_field
->
add_process
(
PROCESSOR_WAIT
,
0
,
0
,
0
,
0
,
0
);
pduel
->
game_field
->
add_process
(
PROCESSOR_WAIT
,
0
,
0
,
0
,
0
,
0
);
...
@@ -1244,15 +1244,13 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
...
@@ -1244,15 +1244,13 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
}
}
if
(
!
ret
&&
(
loc
&
LOCATION_SZONE
))
{
if
(
!
ret
&&
(
loc
&
LOCATION_SZONE
))
{
if
(
playerid
==
0
||
playerid
==
PLAYER_ALL
)
{
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
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_szone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
ret
=
1
;
}
}
}
}
if
(
playerid
==
1
||
playerid
==
PLAYER_ALL
)
{
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
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_szone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
ret
=
1
;
}
}
...
@@ -1260,15 +1258,13 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
...
@@ -1260,15 +1258,13 @@ int32 scriptlib::duel_is_environment(lua_State *L) {
}
}
if
(
!
ret
&&
(
loc
&
LOCATION_MZONE
))
{
if
(
!
ret
&&
(
loc
&
LOCATION_MZONE
))
{
if
(
playerid
==
0
||
playerid
==
PLAYER_ALL
)
{
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
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_mzone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
ret
=
1
;
}
}
}
}
if
(
playerid
==
1
||
playerid
==
PLAYER_ALL
)
{
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
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
0
].
list_mzone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
if
(
pcard
&&
pcard
->
is_position
(
POS_FACEUP
)
&&
pcard
->
get_status
(
STATUS_EFFECT_ENABLED
)
&&
code
==
pcard
->
get_code
())
ret
=
1
;
ret
=
1
;
}
}
...
@@ -1377,15 +1373,14 @@ int32 scriptlib::duel_equip(lua_State *L) {
...
@@ -1377,15 +1373,14 @@ int32 scriptlib::duel_equip(lua_State *L) {
int32
scriptlib
::
duel_equip_complete
(
lua_State
*
L
)
{
int32
scriptlib
::
duel_equip_complete
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
field
::
card_set
etargets
;
field
::
card_set
etargets
;
for
(
auto
cit
=
pduel
->
game_field
->
core
.
equiping_cards
.
begin
();
cit
!=
pduel
->
game_field
->
core
.
equiping_cards
.
end
();
++
cit
)
{
for
(
auto
&
equip_card
:
pduel
->
game_field
->
core
.
equiping_cards
)
{
card
*
equip_card
=
*
cit
;
if
(
equip_card
->
is_position
(
POS_FACEUP
))
if
(
equip_card
->
is_position
(
POS_FACEUP
))
equip_card
->
enable_field_effect
(
true
);
equip_card
->
enable_field_effect
(
true
);
etargets
.
insert
(
equip_card
->
equiping_target
);
etargets
.
insert
(
equip_card
->
equiping_target
);
}
}
pduel
->
game_field
->
adjust_instant
();
pduel
->
game_field
->
adjust_instant
();
for
(
auto
cit
=
etargets
.
begin
();
cit
!=
etargets
.
end
();
++
cit
)
for
(
auto
&
equip_target
:
etargets
)
pduel
->
game_field
->
raise_single_event
(
*
ci
t
,
&
pduel
->
game_field
->
core
.
equiping_cards
,
EVENT_EQUIP
,
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
->
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
->
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
);
pduel
->
game_field
->
core
.
reason_effect
,
0
,
pduel
->
game_field
->
core
.
reason_player
,
PLAYER_NONE
,
0
);
...
@@ -1562,15 +1557,14 @@ int32 scriptlib::duel_shuffle_setcard(lua_State *L) {
...
@@ -1562,15 +1557,14 @@ int32 scriptlib::duel_shuffle_setcard(lua_State *L) {
if
(
pgroup
->
container
.
size
()
<=
1
)
if
(
pgroup
->
container
.
size
()
<=
1
)
return
0
;
return
0
;
duel
*
pduel
=
pgroup
->
pduel
;
duel
*
pduel
=
pgroup
->
pduel
;
card
*
ms
[
7
];
card
*
ms
[
5
];
uint8
seq
[
7
];
uint8
seq
[
5
];
uint8
tp
=
2
;
uint8
tp
=
2
;
uint8
loc
=
0
;
uint8
loc
=
0
;
uint8
ct
=
0
;
uint8
ct
=
0
;
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pgroup
->
container
)
{
card
*
pcard
=
*
cit
;
if
((
loc
!=
0
&&
(
pcard
->
current
.
location
!=
loc
))
||
(
pcard
->
current
.
location
!=
LOCATION_MZONE
&&
pcard
->
current
.
location
!=
LOCATION_SZONE
)
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
;
return
0
;
tp
=
pcard
->
current
.
controler
;
tp
=
pcard
->
current
.
controler
;
loc
=
pcard
->
current
.
location
;
loc
=
pcard
->
current
.
location
;
...
@@ -1817,11 +1811,11 @@ int32 scriptlib::duel_disable_summon(lua_State *L) {
...
@@ -1817,11 +1811,11 @@ int32 scriptlib::duel_disable_summon(lua_State *L) {
if
((
pcard
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
if
((
pcard
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
pcard
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
pcard
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
}
else
{
}
else
{
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pgroup
->
container
)
{
(
*
cit
)
->
set_status
(
STATUS_SUMMONING
,
FALSE
);
pcard
->
set_status
(
STATUS_SUMMONING
,
FALSE
);
(
*
cit
)
->
set_status
(
STATUS_SUMMON_DISABLED
,
TRUE
);
pcard
->
set_status
(
STATUS_SUMMON_DISABLED
,
TRUE
);
if
((
(
*
cit
)
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
if
((
pcard
->
summon_info
&
SUMMON_TYPE_PENDULUM
)
!=
SUMMON_TYPE_PENDULUM
)
(
*
cit
)
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
pcard
->
set_status
(
STATUS_PROC_COMPLETE
,
FALSE
);
}
}
}
}
return
0
;
return
0
;
...
@@ -1897,8 +1891,7 @@ int32 scriptlib::duel_get_mzone_count(lua_State *L) {
...
@@ -1897,8 +1891,7 @@ int32 scriptlib::duel_get_mzone_count(lua_State *L) {
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
or
\"
Group
\"
."
,
2
);
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
or
\"
Group
\"
."
,
2
);
for
(
int32
p
=
0
;
p
<
2
;
p
++
)
{
for
(
int32
p
=
0
;
p
<
2
;
p
++
)
{
uint32
digit
=
1
;
uint32
digit
=
1
;
for
(
auto
cit
=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
p
].
list_mzone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
&&
pcard
!=
mcard
&&
!
(
mgroup
&&
mgroup
->
container
.
find
(
pcard
)
!=
mgroup
->
container
.
end
()))
{
if
(
pcard
&&
pcard
!=
mcard
&&
!
(
mgroup
&&
mgroup
->
container
.
find
(
pcard
)
!=
mgroup
->
container
.
end
()))
{
used_location
[
p
]
|=
digit
;
used_location
[
p
]
|=
digit
;
list_mzone
[
p
].
push_back
(
pcard
);
list_mzone
[
p
].
push_back
(
pcard
);
...
@@ -1960,8 +1953,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
...
@@ -1960,8 +1953,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
or
\"
Group
\"
."
,
3
);
luaL_error
(
L
,
"Parameter %d should be
\"
Card
\"
or
\"
Group
\"
."
,
3
);
for
(
int32
p
=
0
;
p
<
2
;
p
++
)
{
for
(
int32
p
=
0
;
p
<
2
;
p
++
)
{
uint32
digit
=
1
;
uint32
digit
=
1
;
for
(
auto
cit
=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
begin
();
cit
!=
pduel
->
game_field
->
player
[
p
].
list_mzone
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
player
[
p
].
list_mzone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
&&
pcard
!=
mcard
&&
!
(
mgroup
&&
mgroup
->
container
.
find
(
pcard
)
!=
mgroup
->
container
.
end
()))
{
if
(
pcard
&&
pcard
!=
mcard
&&
!
(
mgroup
&&
mgroup
->
container
.
find
(
pcard
)
!=
mgroup
->
container
.
end
()))
{
used_location
[
p
]
|=
digit
;
used_location
[
p
]
|=
digit
;
list_mzone
[
p
].
push_back
(
pcard
);
list_mzone
[
p
].
push_back
(
pcard
);
...
@@ -2174,8 +2166,8 @@ int32 scriptlib::duel_get_first_target(lua_State *L) {
...
@@ -2174,8 +2166,8 @@ int32 scriptlib::duel_get_first_target(lua_State *L) {
chain
*
ch
=
pduel
->
game_field
->
get_chain
(
0
);
chain
*
ch
=
pduel
->
game_field
->
get_chain
(
0
);
if
(
!
ch
||
!
ch
->
target_cards
||
ch
->
target_cards
->
container
.
size
()
==
0
)
if
(
!
ch
||
!
ch
->
target_cards
||
ch
->
target_cards
->
container
.
size
()
==
0
)
return
0
;
return
0
;
for
(
auto
iter
=
ch
->
target_cards
->
container
.
begin
();
iter
!=
ch
->
target_cards
->
container
.
end
();
++
it
er
)
for
(
auto
&
pcard
:
ch
->
target_cards
->
contain
er
)
interpreter
::
card2value
(
L
,
*
iter
);
interpreter
::
card2value
(
L
,
pcard
);
return
ch
->
target_cards
->
container
.
size
();
return
ch
->
target_cards
->
container
.
size
();
}
}
int32
scriptlib
::
duel_get_current_phase
(
lua_State
*
L
)
{
int32
scriptlib
::
duel_get_current_phase
(
lua_State
*
L
)
{
...
@@ -3026,8 +3018,8 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
...
@@ -3026,8 +3018,8 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
pcard
->
create_relation
(
*
ch
);
pcard
->
create_relation
(
*
ch
);
}
else
{
}
else
{
targets
->
container
.
insert
(
pgroup
->
container
.
begin
(),
pgroup
->
container
.
end
());
targets
->
container
.
insert
(
pgroup
->
container
.
begin
(),
pgroup
->
container
.
end
());
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
for
(
auto
&
pcard
:
pgroup
->
container
)
(
*
cit
)
->
create_relation
(
*
ch
);
pcard
->
create_relation
(
*
ch
);
}
}
if
(
peffect
->
is_flag
(
EFFECT_FLAG_CARD_TARGET
))
{
if
(
peffect
->
is_flag
(
EFFECT_FLAG_CARD_TARGET
))
{
if
(
pcard
)
{
if
(
pcard
)
{
...
@@ -3037,12 +3029,12 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
...
@@ -3037,12 +3029,12 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
}
else
{
}
else
{
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pgroup
->
container
)
{
if
(
(
*
cit
)
->
current
.
location
&
0x30
)
if
(
pcard
->
current
.
location
&
0x30
)
pduel
->
game_field
->
move_card
(
(
*
cit
)
->
current
.
controler
,
(
*
cit
),
(
*
cit
)
->
current
.
location
,
0
);
pduel
->
game_field
->
move_card
(
pcard
->
current
.
controler
,
pcard
,
pcard
->
current
.
location
,
0
);
pduel
->
write_buffer8
(
MSG_BECOME_TARGET
);
pduel
->
write_buffer8
(
MSG_BECOME_TARGET
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer32
(
(
*
cit
)
->
get_info_location
());
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
}
}
}
}
}
}
...
@@ -3300,8 +3292,7 @@ int32 scriptlib::duel_hint_selection(lua_State *L) {
...
@@ -3300,8 +3292,7 @@ int32 scriptlib::duel_hint_selection(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
);
duel
*
pduel
=
pgroup
->
pduel
;
duel
*
pduel
=
pgroup
->
pduel
;
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
pgroup
->
container
)
{
card
*
pcard
=
*
cit
;
pduel
->
write_buffer8
(
MSG_BECOME_TARGET
);
pduel
->
write_buffer8
(
MSG_BECOME_TARGET
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
pduel
->
write_buffer32
(
pcard
->
get_info_location
());
...
@@ -3898,8 +3889,8 @@ int32 scriptlib::duel_check_chain_uniqueness(lua_State *L) {
...
@@ -3898,8 +3889,8 @@ int32 scriptlib::duel_check_chain_uniqueness(lua_State *L) {
return
1
;
return
1
;
}
}
std
::
set
<
uint32
>
er
;
std
::
set
<
uint32
>
er
;
for
(
auto
cait
=
pduel
->
game_field
->
core
.
current_chain
.
begin
();
cait
!=
pduel
->
game_field
->
core
.
current_chain
.
end
();
++
cait
)
for
(
const
auto
&
ch
:
pduel
->
game_field
->
core
.
current_chain
)
er
.
insert
(
c
ait
->
triggering_effect
->
get_handler
()
->
get_code
());
er
.
insert
(
c
h
.
triggering_effect
->
get_handler
()
->
get_code
());
if
(
er
.
size
()
==
pduel
->
game_field
->
core
.
current_chain
.
size
())
if
(
er
.
size
()
==
pduel
->
game_field
->
core
.
current_chain
.
size
())
lua_pushboolean
(
L
,
1
);
lua_pushboolean
(
L
,
1
);
else
else
...
...
libgroup.cpp
View file @
5bacddd6
This diff is collapsed.
Click to expand it.
ocgapi.cpp
View file @
5bacddd6
...
@@ -226,14 +226,14 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin
...
@@ -226,14 +226,14 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin
return
player
.
list_main
.
size
();
return
player
.
list_main
.
size
();
if
(
location
==
LOCATION_MZONE
)
{
if
(
location
==
LOCATION_MZONE
)
{
uint32
count
=
0
;
uint32
count
=
0
;
for
(
auto
cit
=
player
.
list_mzone
.
begin
();
cit
!=
player
.
list_mzone
.
end
();
++
cit
)
for
(
auto
&
pcard
:
player
.
list_mzone
)
if
(
*
cit
)
count
++
;
if
(
pcard
)
count
++
;
return
count
;
return
count
;
}
}
if
(
location
==
LOCATION_SZONE
)
{
if
(
location
==
LOCATION_SZONE
)
{
uint32
count
=
0
;
uint32
count
=
0
;
for
(
auto
cit
=
player
.
list_szone
.
begin
();
cit
!=
player
.
list_szone
.
end
();
++
cit
)
for
(
auto
&
pcard
:
player
.
list_szone
)
if
(
*
cit
)
count
++
;
if
(
pcard
)
count
++
;
return
count
;
return
count
;
}
}
return
0
;
return
0
;
...
@@ -245,8 +245,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
...
@@ -245,8 +245,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
byte
*
p
=
buf
;
byte
*
p
=
buf
;
if
(
location
==
LOCATION_MZONE
)
{
if
(
location
==
LOCATION_MZONE
)
{
for
(
auto
cit
=
player
.
list_mzone
.
begin
();
cit
!=
player
.
list_mzone
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
)
{
if
(
pcard
)
{
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
p
+=
clen
;
...
@@ -256,8 +255,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
...
@@ -256,8 +255,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
}
}
}
}
}
else
if
(
location
==
LOCATION_SZONE
)
{
}
else
if
(
location
==
LOCATION_SZONE
)
{
for
(
auto
cit
=
player
.
list_szone
.
begin
();
cit
!=
player
.
list_szone
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
player
.
list_szone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
)
{
if
(
pcard
)
{
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
p
+=
clen
;
...
@@ -278,8 +276,8 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
...
@@ -278,8 +276,8 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
lst
=
&
player
.
list_extra
;
lst
=
&
player
.
list_extra
;
else
if
(
location
==
LOCATION_DECK
)
else
if
(
location
==
LOCATION_DECK
)
lst
=
&
player
.
list_main
;
lst
=
&
player
.
list_main
;
for
(
auto
cit
=
lst
->
begin
();
cit
!=
lst
->
end
();
++
ci
t
)
{
for
(
auto
&
pcard
:
*
ls
t
)
{
uint32
clen
=
(
*
cit
)
->
get_infos
(
p
,
query_flag
,
use_cache
);
uint32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
p
+=
clen
;
}
}
}
}
...
@@ -294,8 +292,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
...
@@ -294,8 +292,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
*
((
int
*
)
p
)
=
player
.
lp
;
*
((
int
*
)
p
)
=
player
.
lp
;
p
+=
4
;
p
+=
4
;
for
(
auto
cit
=
player
.
list_mzone
.
begin
();
cit
!=
player
.
list_mzone
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
)
{
if
(
pcard
)
{
*
p
++
=
1
;
*
p
++
=
1
;
*
p
++
=
pcard
->
current
.
position
;
*
p
++
=
pcard
->
current
.
position
;
...
@@ -304,8 +301,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
...
@@ -304,8 +301,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*
p
++
=
0
;
*
p
++
=
0
;
}
}
}
}
for
(
auto
cit
=
player
.
list_szone
.
begin
();
cit
!=
player
.
list_szone
.
end
();
++
cit
)
{
for
(
auto
&
pcard
:
player
.
list_szone
)
{
card
*
pcard
=
*
cit
;
if
(
pcard
)
{
if
(
pcard
)
{
*
p
++
=
1
;
*
p
++
=
1
;
*
p
++
=
pcard
->
current
.
position
;
*
p
++
=
pcard
->
current
.
position
;
...
@@ -321,15 +317,15 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
...
@@ -321,15 +317,15 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*
p
++
=
player
.
extra_p_count
;
*
p
++
=
player
.
extra_p_count
;
}
}
*
p
++
=
ptduel
->
game_field
->
core
.
current_chain
.
size
();
*
p
++
=
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
)
{
for
(
const
auto
&
ch
:
ptduel
->
game_field
->
core
.
current_chain
)
{
effect
*
peffect
=
ch
it
->
triggering_effect
;
effect
*
peffect
=
ch
.
triggering_effect
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
data
.
code
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
data
.
code
;
p
+=
4
;
p
+=
4
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
get_info_location
();
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
get_info_location
();
p
+=
4
;
p
+=
4
;
*
p
++
=
ch
it
->
triggering_controler
;
*
p
++
=
ch
.
triggering_controler
;
*
p
++
=
(
uint8
)
ch
it
->
triggering_location
;
*
p
++
=
(
uint8
)
ch
.
triggering_location
;
*
p
++
=
ch
it
->
triggering_sequence
;
*
p
++
=
ch
.
triggering_sequence
;
*
((
int
*
)
p
)
=
peffect
->
description
;
*
((
int
*
)
p
)
=
peffect
->
description
;
p
+=
4
;
p
+=
4
;
}
}
...
...
ocgapi.h
View file @
5bacddd6
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
#include "common.h"
#include "common.h"
#ifdef WIN32
#ifdef WIN32
#include <windows.h>
#define DECL_DLLEXPORT __declspec(dllexport)
#define DECL_DLLEXPORT __declspec(dllexport)
#else
#else
#define DECL_DLLEXPORT
#define DECL_DLLEXPORT
...
...
operations.cpp
View file @
5bacddd6
This diff is collapsed.
Click to expand it.
playerop.cpp
View file @
5bacddd6
This diff is collapsed.
Click to expand it.
processor.cpp
View file @
5bacddd6
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