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
d3a70f2e
Commit
d3a70f2e
authored
Dec 05, 2024
by
Nanahira
Committed by
GitHub
Dec 05, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #26 from mycard/develop-8888
Develop 8888
parents
eca4db36
3f9ee2cd
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
41 deletions
+57
-41
card.cpp
card.cpp
+15
-18
card.h
card.h
+1
-7
card_data.h
card_data.h
+17
-1
duel.cpp
duel.cpp
+1
-1
effect.cpp
effect.cpp
+5
-5
interpreter.cpp
interpreter.cpp
+5
-3
interpreter.h
interpreter.h
+1
-1
ocgapi.cpp
ocgapi.cpp
+8
-2
ocgapi.h
ocgapi.h
+1
-0
playerop.cpp
playerop.cpp
+3
-3
No files found.
card.cpp
View file @
d3a70f2e
...
...
@@ -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
;
}
...
...
@@ -2723,6 +2715,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
)
...
...
@@ -2977,12 +2976,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
)
...
...
@@ -3006,10 +3004,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
))
...
...
card.h
View file @
d3a70f2e
...
...
@@ -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
{
...
...
@@ -156,7 +150,6 @@ public:
uint8
location
{
0
};
uint8
sequence
{
0
};
};
static
const
std
::
unordered_map
<
uint32
,
uint32
>
second_code
;
int32
ref_handle
;
duel
*
pduel
;
...
...
@@ -337,6 +330,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 @
d3a70f2e
#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 @
d3a70f2e
...
...
@@ -55,7 +55,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 @
d3a70f2e
...
...
@@ -700,7 +700,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
)
{
...
...
@@ -711,7 +711,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
)
{
...
...
@@ -722,7 +722,7 @@ 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
<
lua_Integer
>&
result
)
{
...
...
@@ -751,7 +751,7 @@ void effect::get_value(effect* peffect, uint32 extraargs, std::vector<lua_Intege
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
()
{
...
...
@@ -764,7 +764,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
()
{
...
...
interpreter.cpp
View file @
d3a70f2e
...
...
@@ -151,7 +151,7 @@ void 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
);
...
...
@@ -764,11 +764,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 @
d3a70f2e
...
...
@@ -87,7 +87,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
)
{
...
...
ocgapi.cpp
View file @
d3a70f2e
...
...
@@ -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
)
{
...
...
@@ -132,7 +136,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 @
d3a70f2e
...
...
@@ -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
;
...
...
playerop.cpp
View file @
d3a70f2e
...
...
@@ -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