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
d595155d
Commit
d595155d
authored
Dec 04, 2024
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
da075384
9da90b8d
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
225 additions
and
149 deletions
+225
-149
buffer.h
buffer.h
+9
-1
card.cpp
card.cpp
+45
-48
card.h
card.h
+1
-7
card_data.h
card_data.h
+17
-1
duel.cpp
duel.cpp
+1
-1
effect.cpp
effect.cpp
+10
-10
effect.h
effect.h
+52
-5
interpreter.cpp
interpreter.cpp
+13
-10
interpreter.h
interpreter.h
+3
-3
libcard.cpp
libcard.cpp
+5
-1
libduel.cpp
libduel.cpp
+1
-1
libeffect.cpp
libeffect.cpp
+2
-2
ocgapi.cpp
ocgapi.cpp
+8
-2
ocgapi.h
ocgapi.h
+1
-0
operations.cpp
operations.cpp
+54
-54
playerop.cpp
playerop.cpp
+3
-3
No files found.
buffer.h
View file @
d595155d
#ifndef CORE_BUFFER_H
#define CORE_BUFFER_H
#include <cstdio>
#include <cstring>
#include <vector>
...
...
@@ -21,7 +22,7 @@ inline void buffer_write_block(unsigned char*& p, const void* src, size_t size)
}
template
<
typename
T
>
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
)
{
...
...
@@ -34,4 +35,11 @@ inline void vector_write(std::vector<unsigned char>& buffer, T value) {
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
card.cpp
View file @
d595155d
...
...
@@ -15,14 +15,6 @@
#include "buffer.h"
#include <algorithm>
const
std
::
unordered_map
<
uint32
,
uint32
>
card
::
second_code
=
{
{
CARD_MARINE_DOLPHIN
,
17955766u
},
{
CARD_TWINKLE_MOSS
,
17732278u
},
{
CARD_TIMAEUS
,
10000050u
},
{
CARD_CRITIAS
,
10000060u
},
{
CARD_HERMOS
,
10000070u
}
};
bool
card_sort
::
operator
()(
card
*
const
&
c1
,
card
*
const
&
c2
)
const
{
return
c1
->
cardid
<
c2
->
cardid
;
}
...
...
@@ -2611,6 +2603,13 @@ void card::filter_effect_container(const effect_container& container, uint32 cod
eset
.
add_item
(
it
->
second
);
}
}
void
card
::
filter_effect_container
(
const
effect_container
&
container
,
uint32
code
,
effect_filter
f
,
effect_collection
&
eset
)
{
auto
rg
=
container
.
equal_range
(
code
);
for
(
auto
it
=
rg
.
first
;
it
!=
rg
.
second
;
++
it
)
{
if
(
f
(
this
,
it
->
second
))
eset
.
insert
(
it
->
second
);
}
}
void
card
::
filter_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
)
{
filter_effect_container
(
single_effect
,
code
,
default_single_filter
,
*
eset
);
for
(
const
auto
&
pcard
:
equiping_cards
)
...
...
@@ -2736,11 +2735,11 @@ int32 card::filter_summon_procedure(uint8 playerid, effect_set* peset, uint8 ign
effect_set
extra_count
;
filter_effect
(
EFFECT_EXTRA_SUMMON_COUNT
,
&
extra_count
);
for
(
int32
i
=
0
;
i
<
extra_count
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
extra_count
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
int32
new_min
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
std
::
vector
<
lua_Integer
>
retval
;
extra_count
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min
<
min
)
new_min
=
min
;
new_zone
&=
zone
;
...
...
@@ -2769,12 +2768,12 @@ int32 card::check_summon_procedure(effect* proc, uint8 playerid, uint8 ignore_co
effect_set
eset
;
filter_effect
(
EFFECT_EXTRA_SUMMON_COUNT
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
int32
new_min_tribute
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
if
(
new_min_tribute
<
(
int32
)
min_tribute
)
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min_tribute
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min_tribute
<
min_tribute
)
new_min_tribute
=
min_tribute
;
new_zone
&=
zone
;
if
(
is_summonable
(
proc
,
new_min_tribute
,
new_zone
,
releasable
))
...
...
@@ -2819,11 +2818,11 @@ int32 card::filter_set_procedure(uint8 playerid, effect_set* peset, uint8 ignore
effect_set
extra_count
;
filter_effect
(
EFFECT_EXTRA_SET_COUNT
,
&
extra_count
);
for
(
int32
i
=
0
;
i
<
extra_count
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
extra_count
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
int32
new_min
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
std
::
vector
<
lua_Integer
>
retval
;
extra_count
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min
<
min
)
new_min
=
min
;
new_zone
&=
zone
;
...
...
@@ -2849,12 +2848,12 @@ int32 card::check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count
effect_set
eset
;
filter_effect
(
EFFECT_EXTRA_SET_COUNT
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
std
::
vector
<
int32
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
int32
new_min_tribute
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
new_zone
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
retval
[
2
]
:
retval
[
2
]
)
:
0xff00ff
;
if
(
new_min_tribute
<
(
int32
)
min_tribute
)
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
new_min_tribute
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
uint32
new_zone
=
retval
.
size
()
>
1
?
static_cast
<
uint32
>
(
retval
[
1
])
:
0x1f
;
int32
releasable
=
retval
.
size
()
>
2
?
(
retval
[
2
]
<
0
?
0xff00ff
+
static_cast
<
int32
>
(
retval
[
2
])
:
static_cast
<
int32
>
(
retval
[
2
])
)
:
0xff00ff
;
if
(
new_min_tribute
<
min_tribute
)
new_min_tribute
=
min_tribute
;
new_zone
&=
zone
;
if
(
is_summonable
(
proc
,
new_min_tribute
,
new_zone
,
releasable
))
...
...
@@ -2865,12 +2864,11 @@ int32 card::check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count
return
FALSE
;
}
void
card
::
filter_spsummon_procedure
(
uint8
playerid
,
effect_set
*
peset
,
uint32
summon_type
,
material_info
info
)
{
auto
pr
=
field_effect
.
equal_range
(
EFFECT_SPSUMMON_PROC
);
uint8
toplayer
;
uint8
topos
;
for
(
auto
eit
=
pr
.
first
;
eit
!=
pr
.
second
;)
{
effect
*
peffect
=
eit
->
second
;
++
eit
;
effect_collection
proc_set
;
filter_effect_container
(
field_effect
,
EFFECT_SPSUMMON_PROC
,
accept_filter
,
proc_set
);
for
(
auto
&
peffect
:
proc_set
)
{
uint8
toplayer
{};
uint8
topos
{};
if
(
peffect
->
is_flag
(
EFFECT_FLAG_SPSUM_PARAM
))
{
topos
=
(
uint8
)
peffect
->
s_range
;
if
(
peffect
->
o_range
==
0
)
...
...
@@ -2894,10 +2892,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s
}
}
void
card
::
filter_spsummon_procedure_g
(
uint8
playerid
,
effect_set
*
peset
)
{
auto
pr
=
field_effect
.
equal_range
(
EFFECT_SPSUMMON_PROC_G
);
for
(
auto
eit
=
pr
.
first
;
eit
!=
pr
.
second
;)
{
effect
*
peffect
=
eit
->
second
;
++
eit
;
effect_collection
proc_set
;
filter_effect_container
(
field_effect
,
EFFECT_SPSUMMON_PROC_G
,
accept_filter
,
proc_set
);
for
(
auto
&
peffect
:
proc_set
)
{
if
(
!
peffect
->
is_available
()
||
!
peffect
->
check_count_limit
(
playerid
))
continue
;
if
(
current
.
controler
!=
playerid
&&
!
peffect
->
is_flag
(
EFFECT_FLAG_BOTH_SIDE
))
...
...
@@ -3395,10 +3392,10 @@ int32 card::get_summon_tribute_count() {
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
if
(
eset
[
i
]
->
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
)
&&
eset
[
i
]
->
count_limit
==
0
)
continue
;
std
::
vector
<
int32
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
int32
dec
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0
;
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
dec
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
static_cast
<
int32
>
(
retval
[
1
])
:
0
;
if
(
effect_code
>
0
)
{
auto
it
=
std
::
find
(
duplicate
.
begin
(),
duplicate
.
end
(),
effect_code
);
if
(
it
==
duplicate
.
end
())
...
...
@@ -3428,10 +3425,10 @@ int32 card::get_set_tribute_count() {
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
if
(
eset
[
i
]
->
is_flag
(
EFFECT_FLAG_COUNT_LIMIT
)
&&
eset
[
i
]
->
count_limit
==
0
)
continue
;
std
::
vector
<
int32
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
&
retval
);
int32
dec
=
retval
.
size
()
>
0
?
retval
[
0
]
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
retval
[
1
]
:
0
;
std
::
vector
<
lua_Integer
>
retval
;
eset
[
i
]
->
get_value
(
this
,
0
,
retval
);
int32
dec
=
retval
.
size
()
>
0
?
static_cast
<
int32
>
(
retval
[
0
])
:
0
;
int32
effect_code
=
retval
.
size
()
>
1
?
static_cast
<
int32
>
(
retval
[
1
])
:
0
;
if
(
effect_code
>
0
)
{
auto
it
=
std
::
find
(
duplicate
.
begin
(),
duplicate
.
end
(),
effect_code
);
if
(
it
==
duplicate
.
end
())
...
...
card.h
View file @
d595155d
...
...
@@ -109,12 +109,6 @@ struct material_info {
};
const
material_info
null_info
;
constexpr
uint32
CARD_MARINE_DOLPHIN
=
78734254
;
constexpr
uint32
CARD_TWINKLE_MOSS
=
13857930
;
constexpr
uint32
CARD_TIMAEUS
=
1784686
;
constexpr
uint32
CARD_CRITIAS
=
11082056
;
constexpr
uint32
CARD_HERMOS
=
46232525
;
class
card
{
public:
struct
effect_relation_hash
{
...
...
@@ -149,7 +143,6 @@ public:
uint8
location
{
0
};
uint8
sequence
{
0
};
};
static
const
std
::
unordered_map
<
uint32
,
uint32
>
second_code
;
int32
ref_handle
;
duel
*
pduel
;
...
...
@@ -327,6 +320,7 @@ public:
template
<
typename
T
>
void
filter_effect_container
(
const
effect_container
&
container
,
uint32
code
,
effect_filter
f
,
T
&
eset
);
void
filter_effect_container
(
const
effect_container
&
container
,
uint32
code
,
effect_filter
f
,
effect_collection
&
eset
);
void
filter_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_single_continuous_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
void
filter_self_effect
(
uint32
code
,
effect_set
*
eset
,
uint8
sort
=
TRUE
);
...
...
card_data.h
View file @
d595155d
#ifndef CARD_DATA_H_
#define CARD_DATA_H_
#include <unordered_map>
#include "common.h"
constexpr
int
CARD_ARTWORK_VERSIONS_OFFSET
=
20
;
constexpr
int
SIZE_SETCODE
=
16
;
constexpr
int
CARD_BLACK_LUSTER_SOLDIER2
=
5405695
;
constexpr
uint32
CARD_BLACK_LUSTER_SOLDIER2
=
5405695
;
//double name
constexpr
uint32
CARD_MARINE_DOLPHIN
=
78734254
;
constexpr
uint32
CARD_TWINKLE_MOSS
=
13857930
;
constexpr
uint32
CARD_TIMAEUS
=
1784686
;
constexpr
uint32
CARD_CRITIAS
=
11082056
;
constexpr
uint32
CARD_HERMOS
=
46232525
;
const
std
::
unordered_map
<
uint32
,
uint32
>
second_code
=
{
{
CARD_MARINE_DOLPHIN
,
17955766u
},
{
CARD_TWINKLE_MOSS
,
17732278u
},
{
CARD_TIMAEUS
,
10000050u
},
{
CARD_CRITIAS
,
10000060u
},
{
CARD_HERMOS
,
10000070u
},
};
struct
card_data
{
uint32
code
{};
...
...
duel.cpp
View file @
d595155d
...
...
@@ -51,7 +51,7 @@ void duel::clear() {
card
*
duel
::
new_card
(
uint32
code
)
{
card
*
pcard
=
new
card
(
this
);
cards
.
insert
(
pcard
);
if
(
code
)
if
(
code
!=
TEMP_CARD_ID
)
::
read_card
(
code
,
&
(
pcard
->
data
));
pcard
->
data
.
code
=
code
;
lua
->
register_card
(
pcard
);
...
...
effect.cpp
View file @
d595155d
...
...
@@ -697,7 +697,7 @@ int32 effect::get_value(uint32 extraargs) {
return
res
;
}
else
{
pduel
->
lua
->
params
.
clear
();
return
(
int32
)
value
;
return
value
;
}
}
int32
effect
::
get_value
(
card
*
pcard
,
uint32
extraargs
)
{
...
...
@@ -708,7 +708,7 @@ int32 effect::get_value(card* pcard, uint32 extraargs) {
return
res
;
}
else
{
pduel
->
lua
->
params
.
clear
();
return
(
int32
)
value
;
return
value
;
}
}
int32
effect
::
get_value
(
effect
*
peffect
,
uint32
extraargs
)
{
...
...
@@ -719,36 +719,36 @@ int32 effect::get_value(effect* peffect, uint32 extraargs) {
return
res
;
}
else
{
pduel
->
lua
->
params
.
clear
();
return
(
int32
)
value
;
return
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
))
{
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
1
+
extraargs
,
result
);
}
else
{
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
))
{
pduel
->
lua
->
add_param
(
pcard
,
PARAM_TYPE_CARD
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
}
else
{
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
))
{
pduel
->
lua
->
add_param
(
peffect
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
add_param
(
this
,
PARAM_TYPE_EFFECT
,
TRUE
);
pduel
->
lua
->
get_function_value
(
value
,
2
+
extraargs
,
result
);
}
else
{
pduel
->
lua
->
params
.
clear
();
result
->
push_back
((
int32
)
value
);
result
.
push_back
(
value
);
}
}
int32
effect
::
get_integer_value
()
{
...
...
@@ -761,7 +761,7 @@ int32 effect::check_value_condition(uint32 extraargs) {
return
res
;
}
else
{
pduel
->
lua
->
params
.
clear
();
return
(
int32
)
value
;
return
value
;
}
}
void
*
effect
::
get_label_object
()
{
...
...
effect.h
View file @
d595155d
...
...
@@ -22,6 +22,7 @@ struct effect_set;
struct
effect_set_v
;
enum
effect_flag
:
uint64
;
enum
effect_flag2
:
uint64
;
enum
effect_category
:
uint64
;
enum
code_type
:
int32
;
bool
is_continuous_event
(
uint32
code
);
...
...
@@ -98,9 +99,9 @@ public:
int32
get_value
(
uint32
extraargs
=
0
);
int32
get_value
(
card
*
pcard
,
uint32
extraargs
=
0
);
int32
get_value
(
effect
*
peffect
,
uint32
extraargs
=
0
);
void
get_value
(
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
card
*
pcard
,
uint32
extraargs
,
std
::
vector
<
int32
>*
result
);
void
get_value
(
effect
*
peffect
,
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
<
lua_Integer
>&
result
);
void
get_value
(
effect
*
peffect
,
uint32
extraargs
,
std
::
vector
<
lua_Integer
>&
result
);
int32
get_integer_value
();
int32
check_value_condition
(
uint32
extraargs
=
0
);
void
*
get_label_object
();
...
...
@@ -214,6 +215,9 @@ enum effect_flag : uint64 {
EFFECT_FLAG_ACTIVATE_CONDITION
=
0x20000000
,
// EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY
=
0x80000000
,
EFFECT_FLAG_COIN
=
0x100000000
,
EFFECT_FLAG_DICE
=
0x200000000
,
EFFECT_FLAG_FUSION_SUMMON
=
0x400000000
,
};
enum
effect_flag2
:
uint64
{
EFFECT_FLAG2_REPEAT_UPDATE
=
0x0001
,
...
...
@@ -222,9 +226,52 @@ enum effect_flag2 : uint64 {
EFFECT_FLAG2_OPTION
=
0x0008
,
};
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
uint32
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
uint64
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
enum
effect_category
:
uint64
{
CATEGORY_DESTROY
=
0x1
,
CATEGORY_RELEASE
=
0x2
,
CATEGORY_REMOVE
=
0x4
,
CATEGORY_TOHAND
=
0x8
,
CATEGORY_TODECK
=
0x10
,
CATEGORY_TOGRAVE
=
0x20
,
CATEGORY_DECKDES
=
0x40
,
CATEGORY_HANDES
=
0x80
,
CATEGORY_SUMMON
=
0x100
,
CATEGORY_SPECIAL_SUMMON
=
0x200
,
CATEGORY_TOKEN
=
0x400
,
CATEGORY_GRAVE_ACTION
=
0x800
,
CATEGORY_POSITION
=
0x1000
,
CATEGORY_CONTROL
=
0x2000
,
CATEGORY_DISABLE
=
0x4000
,
CATEGORY_DISABLE_SUMMON
=
0x8000
,
CATEGORY_DRAW
=
0x10000
,
CATEGORY_SEARCH
=
0x20000
,
CATEGORY_EQUIP
=
0x40000
,
CATEGORY_DAMAGE
=
0x80000
,
CATEGORY_RECOVER
=
0x100000
,
CATEGORY_ATKCHANGE
=
0x200000
,
CATEGORY_DEFCHANGE
=
0x400000
,
CATEGORY_COUNTER
=
0x800000
,
CATEGORY_COIN
=
0x1000000
,
CATEGORY_DICE
=
0x2000000
,
CATEGORY_LEAVE_GRAVE
=
0x4000000
,
CATEGORY_GRAVE_SPSUMMON
=
0x8000000
,
CATEGORY_NEGATE
=
0x10000000
,
CATEGORY_ANNOUNCE
=
0x20000000
,
CATEGORY_FUSION_SUMMON
=
0x40000000
,
CATEGORY_TOEXTRA
=
0x80000000
,
};
const
std
::
map
<
uint64
,
uint64
>
category_checklist
{
{
CATEGORY_COIN
,
EFFECT_FLAG_COIN
},
{
CATEGORY_DICE
,
EFFECT_FLAG_DICE
},
{
CATEGORY_FUSION_SUMMON
,
EFFECT_FLAG_FUSION_SUMMON
},
};
//========== Codes ==========
#define EFFECT_IMMUNE_EFFECT 1 //
#define EFFECT_DISABLE 2 //
...
...
interpreter.cpp
View file @
d595155d
...
...
@@ -50,7 +50,9 @@ interpreter::interpreter(duel* pd): coroutines(256) {
interpreter
::~
interpreter
()
{
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
luaL_checkstack
(
lua_state
,
1
,
nullptr
);
card
**
ppcard
=
(
card
**
)
lua_newuserdata
(
lua_state
,
sizeof
(
card
*
));
//+1 userdata
...
...
@@ -65,14 +67,13 @@ int32 interpreter::register_card(card *pcard) {
lua_setmetatable
(
current_state
,
-
2
);
//-1
lua_pop
(
current_state
,
1
);
//-1
//Initial
if
(
pcard
->
data
.
code
&&
is_load_script
(
pcard
->
data
))
{
if
(
is_load_script
(
pcard
->
data
))
{
pcard
->
set_status
(
STATUS_INITIALIZING
,
TRUE
);
add_param
(
pcard
,
PARAM_TYPE_CARD
);
call_card_function
(
pcard
,
"initial_effect"
,
1
,
0
);
pcard
->
set_status
(
STATUS_INITIALIZING
,
FALSE
);
}
pcard
->
cardid
=
pduel
->
game_field
->
infos
.
card_id
++
;
return
OPERATION_SUCCESS
;
}
void
interpreter
::
register_effect
(
effect
*
peffect
)
{
if
(
!
peffect
)
...
...
@@ -505,7 +506,7 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
}
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
;
if
(
!
f
)
{
params
.
clear
();
...
...
@@ -517,14 +518,14 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
if
(
call_function
(
f
,
param_count
,
LUA_MULTRET
))
{
int32
stack_newtop
=
lua_gettop
(
current_state
);
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
))
return_value
=
lua_toboolean
(
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
return_value
=
(
int32
)
lua_tonumber
(
current_state
,
index
);
result
->
push_back
(
return_value
);
return_value
=
static_cast
<
lua_Integer
>
(
lua_tonumber
(
current_state
,
index
)
);
result
.
push_back
(
return_value
);
}
lua_settop
(
current_state
,
stack_top
);
is_success
=
OPERATION_SUCCESS
;
...
...
@@ -672,11 +673,13 @@ int32 interpreter::get_function_handle(lua_State* L, int32 index) {
int32
ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
return
ref
;
}
duel
*
interpreter
::
get_duel_info
(
lua_State
*
L
)
{
duel
*
interpreter
::
get_duel_info
(
lua_State
*
L
)
{
duel
*
pduel
;
std
::
memcpy
(
&
pduel
,
lua_getextraspace
(
L
),
LUA_EXTRASPACE
);
return
pduel
;
}
bool
interpreter
::
is_load_script
(
card_data
data
)
{
bool
interpreter
::
is_load_script
(
const
card_data
&
data
)
{
if
(
data
.
code
==
TEMP_CARD_ID
)
return
false
;
return
!
(
data
.
type
&
TYPE_NORMAL
)
||
(
data
.
type
&
TYPE_PENDULUM
);
}
interpreter.h
View file @
d595155d
...
...
@@ -56,7 +56,7 @@ public:
explicit
interpreter
(
duel
*
pd
);
~
interpreter
();
int32
register_card
(
card
*
pcard
);
void
register_card
(
card
*
pcard
);
void
register_effect
(
effect
*
peffect
);
void
unregister_effect
(
effect
*
peffect
);
void
register_group
(
group
*
pgroup
);
...
...
@@ -74,7 +74,7 @@ public:
int32
check_filter
(
lua_State
*
L
,
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
,
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
clone_function_ref
(
int32
func_ref
);
void
*
get_ref_object
(
int32
ref_handler
);
...
...
@@ -85,7 +85,7 @@ public:
static
void
function2value
(
lua_State
*
L
,
int32
func_ref
);
static
int32
get_function_handle
(
lua_State
*
L
,
int32
index
);
static
duel
*
get_duel_info
(
lua_State
*
L
);
static
bool
is_load_script
(
c
ard_data
data
);
static
bool
is_load_script
(
c
onst
card_data
&
data
);
template
<
size_t
N
,
typename
...
TR
>
static
int
sprintf
(
char
(
&
buffer
)[
N
],
const
char
*
format
,
TR
...
args
)
{
...
...
libcard.cpp
View file @
d595155d
...
...
@@ -1828,6 +1828,10 @@ int32 scriptlib::card_register_effect(lua_State *L) {
pduel
->
game_field
->
core
.
reseted_effects
.
insert
(
peffect
);
return
0
;
}
for
(
auto
&
entry
:
category_checklist
)
{
if
(
peffect
->
category
&
entry
.
first
)
peffect
->
flag
[
0
]
|=
entry
.
second
;
}
int32
id
;
if
(
peffect
->
handler
)
id
=
-
1
;
...
...
@@ -1891,7 +1895,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
1
);
int32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
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
);
lua_Integer
lab
=
0
;
int32
desc
=
0
;
...
...
libduel.cpp
View file @
d595155d
...
...
@@ -97,7 +97,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
return
0
;
int32
code
=
(
lua_tointeger
(
L
,
2
)
&
MAX_CARD_ID
)
|
EFFECT_FLAG_EFFECT
;
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
);
lua_Integer
lab
=
0
;
if
(
lua_gettop
(
L
)
>=
6
)
...
...
libeffect.cpp
View file @
d595155d
...
...
@@ -226,8 +226,8 @@ int32 scriptlib::effect_set_property(lua_State *L) {
check_param_count
(
L
,
2
);
check_param
(
L
,
PARAM_TYPE_EFFECT
,
1
);
effect
*
peffect
=
*
(
effect
**
)
lua_touserdata
(
L
,
1
);
uint
32
v1
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint
32
v2
=
(
uint32
)
lua_tointeger
(
L
,
3
);
uint
64
v1
=
lua_tointeger
(
L
,
2
);
uint
64
v2
=
lua_tointeger
(
L
,
3
);
peffect
->
flag
[
0
]
=
(
peffect
->
flag
[
0
]
&
INTERNAL_FLAGS
)
|
(
v1
&
~
INTERNAL_FLAGS
);
peffect
->
flag
[
1
]
=
v2
;
return
0
;
...
...
ocgapi.cpp
View file @
d595155d
...
...
@@ -6,6 +6,7 @@
*/
#include <cstdio>
#include <cstring>
#include <set>
#include "ocgapi.h"
#include "duel.h"
#include "card.h"
...
...
@@ -14,7 +15,6 @@
#include "field.h"
#include "interpreter.h"
#include "buffer.h"
#include <set>
static
script_reader
sreader
=
default_script_reader
;
static
card_reader
creader
=
default_card_reader
;
...
...
@@ -35,6 +35,10 @@ byte* read_script(const char* script_name, int* len) {
return
sreader
(
script_name
,
len
);
}
uint32
read_card
(
uint32
code
,
card_data
*
data
)
{
if
(
code
==
TEMP_CARD_ID
)
{
data
->
clear
();
return
0
;
}
return
creader
(
code
,
data
);
}
uint32
handle_message
(
void
*
pduel
,
uint32
msg_type
)
{
...
...
@@ -127,7 +131,9 @@ extern "C" DECL_DLLEXPORT void set_player_info(intptr_t pduel, int32 playerid, i
pd
->
game_field
->
player
[
playerid
].
draw_count
=
drawcount
;
}
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
intptr_t
pduel
,
char
*
buf
)
{
std
::
strcpy
(
buf
,
((
duel
*
)
pduel
)
->
strbuffer
);
duel
*
pd
=
(
duel
*
)
pduel
;
buf
[
0
]
=
'\0'
;
std
::
strncat
(
buf
,
pd
->
strbuffer
,
sizeof
pd
->
strbuffer
-
1
);
}
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
intptr_t
pduel
,
byte
*
buf
)
{
int32
len
=
((
duel
*
)
pduel
)
->
read_buffer
(
buf
);
...
...
ocgapi.h
View file @
d595155d
...
...
@@ -19,6 +19,7 @@
#define LEN_FAIL 0
#define LEN_EMPTY 4
#define LEN_HEADER 8
#define TEMP_CARD_ID 0
class
card
;
struct
card_data
;
...
...
operations.cpp
View file @
d595155d
This diff is collapsed.
Click to expand it.
playerop.cpp
View file @
d595155d
...
...
@@ -913,7 +913,7 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod
stack
.
pop
();
int32
lhs
=
stack
.
top
();
stack
.
pop
();
stack
.
push
(
lhs
&&
rhs
);
stack
.
push
(
static_cast
<
int32
>
(
lhs
&&
rhs
)
);
}
break
;
}
...
...
@@ -923,7 +923,7 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod
stack
.
pop
();
int32
lhs
=
stack
.
top
();
stack
.
pop
();
stack
.
push
(
lhs
||
rhs
);
stack
.
push
(
static_cast
<
int32
>
(
lhs
||
rhs
)
);
}
break
;
}
...
...
@@ -939,7 +939,7 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod
if
(
stack
.
size
()
>=
1
)
{
int32
val
=
stack
.
top
();
stack
.
pop
();
stack
.
push
(
!
val
);
stack
.
push
(
static_cast
<
int32
>
(
!
val
)
);
}
break
;
}
...
...
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