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
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
nanahira
ygopro-core
Commits
3dcd4627
Commit
3dcd4627
authored
Dec 02, 2024
by
Nanahira
Committed by
GitHub
Dec 02, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25 from mycard/develop-8888
Develop 8888
parents
d57237d1
797238d7
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
119 additions
and
110 deletions
+119
-110
buffer.h
buffer.h
+9
-1
card.cpp
card.cpp
+30
-30
effect.cpp
effect.cpp
+6
-6
effect.h
effect.h
+6
-6
interpreter.cpp
interpreter.cpp
+8
-7
interpreter.h
interpreter.h
+2
-2
libcard.cpp
libcard.cpp
+1
-1
libduel.cpp
libduel.cpp
+1
-1
libeffect.cpp
libeffect.cpp
+2
-2
operations.cpp
operations.cpp
+54
-54
No files found.
buffer.h
View file @
3dcd4627
#ifndef CORE_BUFFER_H
#ifndef CORE_BUFFER_H
#define CORE_BUFFER_H
#define CORE_BUFFER_H
#include <cstdio>
#include <cstring>
#include <cstring>
#include <vector>
#include <vector>
...
@@ -21,7 +22,7 @@ inline void buffer_write_block(unsigned char*& p, const void* src, size_t size)
...
@@ -21,7 +22,7 @@ inline void buffer_write_block(unsigned char*& p, const void* src, size_t size)
}
}
template
<
typename
T
>
template
<
typename
T
>
inline
void
buffer_write
(
unsigned
char
*&
p
,
T
value
)
{
inline
void
buffer_write
(
unsigned
char
*&
p
,
T
value
)
{
buffer_write_block
(
p
,
&
value
,
sizeof
(
T
));
buffer_write_block
(
p
,
&
value
,
sizeof
(
T
));
}
}
inline
void
vector_write_block
(
std
::
vector
<
unsigned
char
>&
buffer
,
const
void
*
src
,
size_t
size
)
{
inline
void
vector_write_block
(
std
::
vector
<
unsigned
char
>&
buffer
,
const
void
*
src
,
size_t
size
)
{
...
@@ -34,4 +35,11 @@ inline void vector_write(std::vector<unsigned char>& buffer, T value) {
...
@@ -34,4 +35,11 @@ inline void vector_write(std::vector<unsigned char>& buffer, T value) {
vector_write_block
(
buffer
,
&
value
,
sizeof
(
T
));
vector_write_block
(
buffer
,
&
value
,
sizeof
(
T
));
}
}
inline
void
vector_fread
(
std
::
vector
<
unsigned
char
>&
buffer
,
FILE
*
fp
)
{
unsigned
char
temp
[
4096
]{};
while
(
size_t
len
=
std
::
fread
(
temp
,
1
,
sizeof
temp
,
fp
))
vector_write_block
(
buffer
,
temp
,
len
);
std
::
fclose
(
fp
);
}
#endif // !CORE_BUFFER_H
#endif // !CORE_BUFFER_H
card.cpp
View file @
3dcd4627
...
@@ -2848,11 +2848,11 @@ int32 card::filter_summon_procedure(uint8 playerid, effect_set* peset, uint8 ign
...
@@ -2848,11 +2848,11 @@ int32 card::filter_summon_procedure(uint8 playerid, effect_set* peset, uint8 ign
effect_set
extra_count
;
effect_set
extra_count
;
filter_effect
(
EFFECT_EXTRA_SUMMON_COUNT
,
&
extra_count
);
filter_effect
(
EFFECT_EXTRA_SUMMON_COUNT
,
&
extra_count
);
for
(
int32
i
=
0
;
i
<
extra_count
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
extra_count
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
std
::
vector
<
lua_Integer
>
retval
;
extra_count
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
extra_count
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_min
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min
<
min
)
if
(
new_min
<
min
)
new_min
=
min
;
new_min
=
min
;
new_zone
&=
zone
;
new_zone
&=
zone
;
...
@@ -2881,12 +2881,12 @@ int32 card::check_summon_procedure(effect* proc, uint8 playerid, uint8 ignore_co
...
@@ -2881,12 +2881,12 @@ int32 card::check_summon_procedure(effect* proc, uint8 playerid, uint8 ignore_co
effect_set
eset
;
effect_set
eset
;
filter_effect
(
EFFECT_EXTRA_SUMMON_COUNT
,
&
eset
);
filter_effect
(
EFFECT_EXTRA_SUMMON_COUNT
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min_tribute
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_min_tribute
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min_tribute
<
(
int32
)
min_tribute
)
if
(
new_min_tribute
<
min_tribute
)
new_min_tribute
=
min_tribute
;
new_min_tribute
=
min_tribute
;
new_zone
&=
zone
;
new_zone
&=
zone
;
if
(
is_summonable
(
proc
,
new_min_tribute
,
new_zone
,
releasable
))
if
(
is_summonable
(
proc
,
new_min_tribute
,
new_zone
,
releasable
))
...
@@ -2931,11 +2931,11 @@ int32 card::filter_set_procedure(uint8 playerid, effect_set* peset, uint8 ignore
...
@@ -2931,11 +2931,11 @@ int32 card::filter_set_procedure(uint8 playerid, effect_set* peset, uint8 ignore
effect_set
extra_count
;
effect_set
extra_count
;
filter_effect
(
EFFECT_EXTRA_SET_COUNT
,
&
extra_count
);
filter_effect
(
EFFECT_EXTRA_SET_COUNT
,
&
extra_count
);
for
(
int32
i
=
0
;
i
<
extra_count
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
extra_count
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
std
::
vector
<
lua_Integer
>
retval
;
extra_count
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
extra_count
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_min
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min
<
min
)
if
(
new_min
<
min
)
new_min
=
min
;
new_min
=
min
;
new_zone
&=
zone
;
new_zone
&=
zone
;
...
@@ -2961,12 +2961,12 @@ int32 card::check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count
...
@@ -2961,12 +2961,12 @@ int32 card::check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count
effect_set
eset
;
effect_set
eset
;
filter_effect
(
EFFECT_EXTRA_SET_COUNT
,
&
eset
);
filter_effect
(
EFFECT_EXTRA_SET_COUNT
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min_tribute
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_min_tribute
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min_tribute
<
(
int32
)
min_tribute
)
if
(
new_min_tribute
<
min_tribute
)
new_min_tribute
=
min_tribute
;
new_min_tribute
=
min_tribute
;
new_zone
&=
zone
;
new_zone
&=
zone
;
if
(
is_summonable
(
proc
,
new_min_tribute
,
new_zone
,
releasable
))
if
(
is_summonable
(
proc
,
new_min_tribute
,
new_zone
,
releasable
))
...
@@ -3507,10 +3507,10 @@ int32 card::get_summon_tribute_count() {
...
@@ -3507,10 +3507,10 @@ int32 card::get_summon_tribute_count() {
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
if
(
eset
[
i
]
->
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
)
&&
eset
[
i
]
->
count_limit
==
0
)
if
(
eset
[
i
]
->
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
)
&&
eset
[
i
]
->
count_limit
==
0
)
continue
;
continue
;
std
::
vector
<
int32
>
retval
;
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
dec
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
dec
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
static_cast
<
int32
>
(
retval
[
1
])
:
0
;
if
(
effect_code
>
0
)
{
if
(
effect_code
>
0
)
{
auto
it
=
std
::
find
(
duplicate
.
begin
(),
duplicate
.
end
(),
effect_code
);
auto
it
=
std
::
find
(
duplicate
.
begin
(),
duplicate
.
end
(),
effect_code
);
if
(
it
==
duplicate
.
end
())
if
(
it
==
duplicate
.
end
())
...
@@ -3540,10 +3540,10 @@ int32 card::get_set_tribute_count() {
...
@@ -3540,10 +3540,10 @@ int32 card::get_set_tribute_count() {
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
if
(
eset
[
i
]
->
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
)
&&
eset
[
i
]
->
count_limit
==
0
)
if
(
eset
[
i
]
->
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
)
&&
eset
[
i
]
->
count_limit
==
0
)
continue
;
continue
;
std
::
vector
<
int32
>
retval
;
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
dec
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
dec
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
static_cast
<
int32
>
(
retval
[
1
])
:
0
;
if
(
effect_code
>
0
)
{
if
(
effect_code
>
0
)
{
auto
it
=
std
::
find
(
duplicate
.
begin
(),
duplicate
.
end
(),
effect_code
);
auto
it
=
std
::
find
(
duplicate
.
begin
(),
duplicate
.
end
(),
effect_code
);
if
(
it
==
duplicate
.
end
())
if
(
it
==
duplicate
.
end
())
...
...
effect.cpp
View file @
3dcd4627
...
@@ -725,33 +725,33 @@ int32 effect::get_value(effect* peffect, uint32 extraargs) {
...
@@ -725,33 +725,33 @@ int32 effect::get_value(effect* peffect, uint32 extraargs) {
return
(
int32
)
value
;
return
(
int32
)
value
;
}
}
}
}
void
effect
::
get_value
(
uint32
extraargs
,
std
::
vector
<
int32
>*
result
)
{
void
effect
::
get_value
(
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
1
+
extraargs
,
result
);
pduel
->
lua
->
get_function_value
(
value
,
1
+
extraargs
,
result
);
}
else
{
}
else
{
pduel
->
lua
->
params
.
clear
();
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
result
.
push_back
(
value
);
}
}
}
}
void
effect
::
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
)
{
void
effect
::
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
pcard
,
PARAM_TYPE_CARD
,
TRUE
);
pduel
->
lua
->
add_param
(
pcard
,
PARAM_TYPE_CARD
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
}
else
{
}
else
{
pduel
->
lua
->
params
.
clear
();
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
result
.
push_back
(
value
);
}
}
}
}
void
effect
::
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
)
{
void
effect
::
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
)
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
if
(
is_flag
(
EFFECT_FLAG_FUNC_VALUE
))
{
pduel
->
lua
->
add_param
(
peffect
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
peffect
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
}
else
{
}
else
{
pduel
->
lua
->
params
.
clear
();
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
result
.
push_back
((
int32
)
value
);
}
}
}
}
int32
effect
::
get_integer_value
()
{
int32
effect
::
get_integer_value
()
{
...
...
effect.h
View file @
3dcd4627
...
@@ -99,9 +99,9 @@ public:
...
@@ -99,9 +99,9 @@ public:
int32
get_value
(
uint32
extraargs
=
0
);
int32
get_value
(
uint32
extraargs
=
0
);
int32
get_value
(
card
*
pcard
,
uint32
extraargs
=
0
);
int32
get_value
(
card
*
pcard
,
uint32
extraargs
=
0
);
int32
get_value
(
effect
*
peffect
,
uint32
extraargs
=
0
);
int32
get_value
(
effect
*
peffect
,
uint32
extraargs
=
0
);
void
get_value
(
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
);
void
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
);
void
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
);
int32
get_integer_value
();
int32
get_integer_value
();
int32
check_value_condition
(
uint32
extraargs
=
0
);
int32
check_value_condition
(
uint32
extraargs
=
0
);
void
*
get_label_object
();
void
*
get_label_object
();
...
@@ -246,12 +246,12 @@ enum effect_flag2 : uint64 {
...
@@ -246,12 +246,12 @@ enum effect_flag2 : uint64 {
EFFECT_FLAG2_ACTIVATE_MONSTER_SZONE
=
0x0400
,
EFFECT_FLAG2_ACTIVATE_MONSTER_SZONE
=
0x0400
,
};
};
constexpr
effect_flag
operator
|
(
effect_flag
flag1
,
effect_flag
flag2
)
{
constexpr
effect_flag
operator
|
(
effect_flag
flag1
,
effect_flag
flag2
)
{
return
static_cast
<
effect_flag
>
(
static_cast
<
uint
32
>
(
flag1
)
|
static_cast
<
uint32
>
(
flag2
));
return
static_cast
<
effect_flag
>
(
static_cast
<
uint
64
>
(
flag1
)
|
static_cast
<
uint64
>
(
flag2
));
}
}
constexpr
uint
32
INTERNAL_FLAGS
=
EFFECT_FLAG_INITIAL
|
EFFECT_FLAG_COPY
|
EFFECT_FLAG_FUNC_VALUE
|
EFFECT_FLAG_COUNT_LIMIT
|
EFFECT_FLAG_FIELD_ONLY
|
EFFECT_FLAG_ABSOLUTE_TARGET
;
constexpr
uint
64
INTERNAL_FLAGS
=
EFFECT_FLAG_INITIAL
|
EFFECT_FLAG_COPY
|
EFFECT_FLAG_FUNC_VALUE
|
EFFECT_FLAG_COUNT_LIMIT
|
EFFECT_FLAG_FIELD_ONLY
|
EFFECT_FLAG_ABSOLUTE_TARGET
;
//Category
//Category
enum
effect_category
:
uint64
{
enum
effect_category
:
uint64
{
CATEGORY_DESTROY
=
0x1
,
CATEGORY_DESTROY
=
0x1
,
CATEGORY_RELEASE
=
0x2
,
CATEGORY_RELEASE
=
0x2
,
CATEGORY_REMOVE
=
0x4
,
CATEGORY_REMOVE
=
0x4
,
...
...
interpreter.cpp
View file @
3dcd4627
...
@@ -134,7 +134,9 @@ interpreter::interpreter(duel* pd): coroutines(256) {
...
@@ -134,7 +134,9 @@ interpreter::interpreter(duel* pd): coroutines(256) {
interpreter
::~
interpreter
()
{
interpreter
::~
interpreter
()
{
lua_close
(
lua_state
);
lua_close
(
lua_state
);
}
}
int32
interpreter
::
register_card
(
card
*
pcard
)
{
void
interpreter
::
register_card
(
card
*
pcard
)
{
if
(
!
pcard
)
return
;
//create a card in by userdata
//create a card in by userdata
luaL_checkstack
(
lua_state
,
1
,
nullptr
);
luaL_checkstack
(
lua_state
,
1
,
nullptr
);
card
**
ppcard
=
(
card
**
)
lua_newuserdata
(
lua_state
,
sizeof
(
card
*
));
//+1 userdata
card
**
ppcard
=
(
card
**
)
lua_newuserdata
(
lua_state
,
sizeof
(
card
*
));
//+1 userdata
...
@@ -156,7 +158,6 @@ int32 interpreter::register_card(card *pcard) {
...
@@ -156,7 +158,6 @@ int32 interpreter::register_card(card *pcard) {
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
++
;
return
OPERATION_SUCCESS
;
}
}
void
interpreter
::
register_effect
(
effect
*
peffect
)
{
void
interpreter
::
register_effect
(
effect
*
peffect
)
{
if
(
!
peffect
)
if
(
!
peffect
)
...
@@ -596,7 +597,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
...
@@ -596,7 +597,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
}
}
return
OPERATION_FAIL
;
return
OPERATION_FAIL
;
}
}
int32
interpreter
::
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
int32
>*
result
)
{
int32
interpreter
::
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
lua_Integer
>&
result
)
{
int32
is_success
=
OPERATION_FAIL
;
int32
is_success
=
OPERATION_FAIL
;
if
(
!
f
)
{
if
(
!
f
)
{
params
.
clear
();
params
.
clear
();
...
@@ -608,14 +609,14 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
...
@@ -608,14 +609,14 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
if
(
call_function
(
f
,
param_count
,
LUA_MULTRET
))
{
if
(
call_function
(
f
,
param_count
,
LUA_MULTRET
))
{
int32
stack_newtop
=
lua_gettop
(
current_state
);
int32
stack_newtop
=
lua_gettop
(
current_state
);
for
(
int32
index
=
stack_top
+
1
;
index
<=
stack_newtop
;
++
index
)
{
for
(
int32
index
=
stack_top
+
1
;
index
<=
stack_newtop
;
++
index
)
{
int32
return_value
=
0
;
lua_Integer
return_value
=
0
;
if
(
lua_isboolean
(
current_state
,
index
))
if
(
lua_isboolean
(
current_state
,
index
))
return_value
=
lua_toboolean
(
current_state
,
index
);
return_value
=
lua_toboolean
(
current_state
,
index
);
else
if
(
lua_isinteger
(
current_state
,
index
))
else
if
(
lua_isinteger
(
current_state
,
index
))
return_value
=
(
int32
)
lua_tointeger
(
current_state
,
index
);
return_value
=
lua_tointeger
(
current_state
,
index
);
else
else
return_value
=
(
int32
)
lua_tonumber
(
current_state
,
index
);
return_value
=
static_cast
<
lua_Integer
>
(
lua_tonumber
(
current_state
,
index
)
);
result
->
push_back
(
return_value
);
result
.
push_back
(
return_value
);
}
}
lua_settop
(
current_state
,
stack_top
);
lua_settop
(
current_state
,
stack_top
);
is_success
=
OPERATION_SUCCESS
;
is_success
=
OPERATION_SUCCESS
;
...
...
interpreter.h
View file @
3dcd4627
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
explicit
interpreter
(
duel
*
pd
);
explicit
interpreter
(
duel
*
pd
);
~
interpreter
();
~
interpreter
();
int32
register_card
(
card
*
pcard
);
void
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
);
...
@@ -76,7 +76,7 @@ public:
...
@@ -76,7 +76,7 @@ public:
int32
check_filter
(
lua_State
*
L
,
card
*
pcard
,
int32
findex
,
int32
extraargs
);
int32
check_filter
(
lua_State
*
L
,
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
);
int32
get_function_value
(
int32
f
,
uint32
param_count
);
int32
get_function_value
(
int32
f
,
uint32
param_count
);
int32
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
int32
>*
result
);
int32
get_function_value
(
int32
f
,
uint32
param_count
,
std
::
vector
<
lua_Integer
>&
result
);
int32
call_coroutine
(
int32
f
,
uint32
param_count
,
int32
*
yield_value
,
uint16
step
);
int32
call_coroutine
(
int32
f
,
uint32
param_count
,
int32
*
yield_value
,
uint16
step
);
int32
clone_function_ref
(
int32
func_ref
);
int32
clone_function_ref
(
int32
func_ref
);
void
*
get_ref_object
(
int32
ref_handler
);
void
*
get_ref_object
(
int32
ref_handler
);
...
...
libcard.cpp
View file @
3dcd4627
...
@@ -2026,7 +2026,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
...
@@ -2026,7 +2026,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
int32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
int32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
int32
reset
=
(
int32
)
lua_tointeger
(
L
,
3
);
int32
reset
=
(
int32
)
lua_tointeger
(
L
,
3
);
uint
32
flag
=
(
uint32
)
lua_tointeger
(
L
,
4
);
uint
64
flag
=
lua_tointeger
(
L
,
4
);
int32
count
=
(
int32
)
lua_tointeger
(
L
,
5
);
int32
count
=
(
int32
)
lua_tointeger
(
L
,
5
);
lua_Integer
lab
=
0
;
lua_Integer
lab
=
0
;
int32
desc
=
0
;
int32
desc
=
0
;
...
...
libduel.cpp
View file @
3dcd4627
...
@@ -313,7 +313,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
...
@@ -313,7 +313,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
return
0
;
return
0
;
int32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
int32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
int32
reset
=
(
int32
)
lua_tointeger
(
L
,
3
);
int32
reset
=
(
int32
)
lua_tointeger
(
L
,
3
);
uint
32
flag
=
(
uint32
)
lua_tointeger
(
L
,
4
);
uint
64
flag
=
lua_tointeger
(
L
,
4
);
int32
count
=
(
int32
)
lua_tointeger
(
L
,
5
);
int32
count
=
(
int32
)
lua_tointeger
(
L
,
5
);
lua_Integer
lab
=
0
;
lua_Integer
lab
=
0
;
if
(
lua_gettop
(
L
)
>=
6
)
if
(
lua_gettop
(
L
)
>=
6
)
...
...
libeffect.cpp
View file @
3dcd4627
...
@@ -250,8 +250,8 @@ int32 scriptlib::effect_set_property(lua_State *L) {
...
@@ -250,8 +250,8 @@ int32 scriptlib::effect_set_property(lua_State *L) {
check_param_count
(
L
,
2
);
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint
32
v1
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint
64
v1
=
lua_tointeger
(
L
,
2
);
uint
32
v2
=
(
uint32
)
lua_tointeger
(
L
,
3
);
uint
64
v2
=
lua_tointeger
(
L
,
3
);
peffect
->
flag
[
0
]
=
(
peffect
->
flag
[
0
]
&
INTERNAL_FLAGS
)
|
(
v1
&
~
INTERNAL_FLAGS
);
peffect
->
flag
[
0
]
=
(
peffect
->
flag
[
0
]
&
INTERNAL_FLAGS
)
|
(
v1
&
~
INTERNAL_FLAGS
);
peffect
->
flag
[
1
]
=
v2
;
peffect
->
flag
[
1
]
=
v2
;
return
0
;
return
0
;
...
...
operations.cpp
View file @
3dcd4627
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