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
6a61bc16
You need to sign in or sign up before continuing.
Commit
6a61bc16
authored
May 14, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Fluorohydride/ygopro-core
parents
c5d72671
476c8892
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
126 deletions
+140
-126
buffer.h
buffer.h
+37
-0
card.cpp
card.cpp
+80
-101
duel.cpp
duel.cpp
+5
-12
effect.cpp
effect.cpp
+10
-0
ocgapi.cpp
ocgapi.cpp
+8
-13
No files found.
buffer.h
0 → 100644
View file @
6a61bc16
#ifndef BUFFER_H
#define BUFFER_H
#include <cstring>
#include <vector>
inline
void
buffer_read_block
(
unsigned
char
*&
p
,
void
*
dest
,
size_t
size
)
{
std
::
memcpy
(
dest
,
p
,
size
);
p
+=
size
;
}
template
<
typename
T
>
inline
T
buffer_read
(
unsigned
char
*&
p
)
{
T
ret
{};
buffer_read_block
(
p
,
&
ret
,
sizeof
(
T
));
return
ret
;
}
inline
void
buffer_write_block
(
unsigned
char
*&
p
,
const
void
*
src
,
size_t
size
)
{
std
::
memcpy
(
p
,
src
,
size
);
p
+=
size
;
}
template
<
typename
T
>
inline
void
buffer_write
(
unsigned
char
*&
p
,
T
value
)
{
buffer_write_block
(
p
,
&
value
,
sizeof
(
T
));
}
inline
void
vector_write_block
(
std
::
vector
<
unsigned
char
>&
buffer
,
const
void
*
src
,
size_t
size
)
{
const
auto
len
=
buffer
.
size
();
buffer
.
resize
(
len
+
size
);
std
::
memcpy
(
&
buffer
[
len
],
src
,
size
);
}
template
<
typename
T
>
inline
void
vector_write
(
std
::
vector
<
unsigned
char
>&
buffer
,
T
value
)
{
vector_write_block
(
buffer
,
&
value
,
sizeof
(
T
));
}
#endif //BUFFER_H
card.cpp
View file @
6a61bc16
This diff is collapsed.
Click to expand it.
duel.cpp
View file @
6a61bc16
...
...
@@ -13,14 +13,7 @@
#include "effect.h"
#include "group.h"
#include "ocgapi.h"
inline
void
write_buffer_vector
(
std
::
vector
<
byte
>&
buffer
,
const
void
*
data
,
int
size
)
{
if
(
size
>
0
)
{
const
auto
len
=
buffer
.
size
();
buffer
.
resize
(
len
+
size
);
std
::
memcpy
(
&
buffer
[
len
],
data
,
size
);
}
}
#include "buffer.h"
duel
::
duel
()
{
lua
=
new
interpreter
(
this
);
...
...
@@ -125,16 +118,16 @@ void duel::restore_assumes() {
assumes
.
clear
();
}
void
duel
::
write_buffer
(
const
void
*
data
,
int
size
)
{
write_buffer_vector
(
message_buffer
,
data
,
size
);
vector_write_block
(
message_buffer
,
data
,
size
);
}
void
duel
::
write_buffer32
(
uint32
value
)
{
write_buffer
(
&
value
,
sizeof
(
value
)
);
vector_write
<
uint32_t
>
(
message_buffer
,
value
);
}
void
duel
::
write_buffer16
(
uint16
value
)
{
write_buffer
(
&
value
,
sizeof
(
value
)
);
vector_write
<
uint16_t
>
(
message_buffer
,
value
);
}
void
duel
::
write_buffer8
(
uint8
value
)
{
write_buffer
(
&
value
,
sizeof
(
value
)
);
vector_write
<
unsigned
char
>
(
message_buffer
,
value
);
}
void
duel
::
clear_buffer
()
{
message_buffer
.
clear
();
...
...
effect.cpp
View file @
6a61bc16
...
...
@@ -206,9 +206,16 @@ int32 effect::get_required_handorset_effects(effect_set* eset, uint8 playerid, c
int32
available
=
0
;
effect_set
tmp_eset
;
handler
->
filter_effect
(
ecode
,
&
tmp_eset
);
if
(
!
tmp_eset
.
size
())
return
available
;
effect
*
oreason
=
pduel
->
game_field
->
core
.
reason_effect
;
uint8
op
=
pduel
->
game_field
->
core
.
reason_player
;
pduel
->
game_field
->
core
.
reason_player
=
playerid
;
pduel
->
game_field
->
save_lp_cost
();
for
(
int32
i
=
0
;
i
<
tmp_eset
.
size
();
++
i
)
{
auto
peffect
=
tmp_eset
[
i
];
if
(
peffect
->
check_count_limit
(
playerid
))
{
pduel
->
game_field
->
core
.
reason_effect
=
peffect
;
pduel
->
lua
->
add_param
(
peffect
,
PARAM_TYPE_EFFECT
);
pduel
->
lua
->
add_param
(
playerid
,
PARAM_TYPE_INT
);
pduel
->
lua
->
add_param
(
e
.
event_cards
,
PARAM_TYPE_GROUP
);
...
...
@@ -225,6 +232,9 @@ int32 effect::get_required_handorset_effects(effect_set* eset, uint8 playerid, c
}
}
}
pduel
->
game_field
->
core
.
reason_effect
=
oreason
;
pduel
->
game_field
->
core
.
reason_player
=
op
;
pduel
->
game_field
->
restore_lp_cost
();
return
available
;
}
// check if an EFFECT_TYPE_ACTIONS effect can be activated
...
...
ocgapi.cpp
View file @
6a61bc16
...
...
@@ -13,6 +13,7 @@
#include "effect.h"
#include "field.h"
#include "interpreter.h"
#include "buffer.h"
#include <set>
static
script_reader
sreader
=
default_script_reader
;
...
...
@@ -206,7 +207,7 @@ extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8
return
pcard
->
get_infos
(
buf
,
query_flag
,
use_cache
);
}
else
{
*
((
int32
*
)
buf
)
=
LEN_EMPTY
;
buffer_write
<
int32_t
>
(
buf
,
LEN_EMPTY
)
;
return
LEN_EMPTY
;
}
}
...
...
@@ -253,8 +254,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
}
else
{
*
((
int32
*
)
p
)
=
LEN_EMPTY
;
p
+=
LEN_EMPTY
;
buffer_write
<
int32_t
>
(
p
,
LEN_EMPTY
);
}
}
}
...
...
@@ -264,8 +264,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
}
else
{
*
((
int32
*
)
p
)
=
LEN_EMPTY
;
p
+=
LEN_EMPTY
;
buffer_write
<
int32_t
>
(
p
,
LEN_EMPTY
);
}
}
}
...
...
@@ -297,8 +296,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
*
p
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
for
(
int
playerid
=
0
;
playerid
<
2
;
++
playerid
)
{
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
*
((
int
*
)
p
)
=
player
.
lp
;
p
+=
4
;
buffer_write
<
int32_t
>
(
p
,
player
.
lp
);
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
if
(
pcard
)
{
*
p
++
=
1
;
...
...
@@ -326,15 +324,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
*
p
++
=
(
uint8
)
ptduel
->
game_field
->
core
.
current_chain
.
size
();
for
(
const
auto
&
ch
:
ptduel
->
game_field
->
core
.
current_chain
)
{
effect
*
peffect
=
ch
.
triggering_effect
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
data
.
code
;
p
+=
4
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
get_info_location
();
p
+=
4
;
buffer_write
<
uint32_t
>
(
p
,
peffect
->
get_handler
()
->
data
.
code
);
buffer_write
<
uint32_t
>
(
p
,
peffect
->
get_handler
()
->
get_info_location
());
*
p
++
=
ch
.
triggering_controler
;
*
p
++
=
(
uint8
)
ch
.
triggering_location
;
*
p
++
=
ch
.
triggering_sequence
;
*
((
int
*
)
p
)
=
peffect
->
description
;
p
+=
4
;
buffer_write
<
uint32_t
>
(
p
,
peffect
->
description
);
}
return
(
int32
)(
p
-
buf
);
}
...
...
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