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
16c4d4b2
Commit
16c4d4b2
authored
Dec 14, 2023
by
salix5
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update class duel, API process()
parent
8799b7a1
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
131 additions
and
126 deletions
+131
-126
common.h
common.h
+9
-0
duel.cpp
duel.cpp
+11
-14
duel.h
duel.h
+10
-5
field.h
field.h
+1
-4
libdebug.cpp
libdebug.cpp
+2
-6
ocgapi.cpp
ocgapi.cpp
+4
-3
ocgapi.h
ocgapi.h
+1
-1
processor.cpp
processor.cpp
+93
-93
No files found.
common.h
View file @
16c4d4b2
...
@@ -29,6 +29,15 @@ typedef signed char int8;
...
@@ -29,6 +29,15 @@ typedef signed char int8;
#define OPERATION_CANCELED -1
#define OPERATION_CANCELED -1
#define TRUE 1
#define TRUE 1
#define FALSE 0
#define FALSE 0
#define MESSAGE_BUFFER_SIZE 0x2000
#define QUERY_BUFFER_SIZE 0x4000
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_FLAG 0xf0000000
#define PROCESSOR_NONE 0
#define PROCESSOR_WAITING 0x10000000
#define PROCESSOR_END 0x20000000
#ifndef NULL
#ifndef NULL
#define NULL 0
#define NULL 0
#endif
#endif
...
...
duel.cpp
View file @
16c4d4b2
...
@@ -17,7 +17,7 @@ duel::duel() {
...
@@ -17,7 +17,7 @@ duel::duel() {
lua
=
new
interpreter
(
this
);
lua
=
new
interpreter
(
this
);
game_field
=
new
field
(
this
);
game_field
=
new
field
(
this
);
game_field
->
temp_card
=
new_card
(
0
);
game_field
->
temp_card
=
new_card
(
0
);
clear_buffer
(
);
message_buffer
.
reserve
(
MESSAGE_BUFFER_SIZE
);
}
}
duel
::~
duel
()
{
duel
::~
duel
()
{
for
(
auto
&
pcard
:
cards
)
for
(
auto
&
pcard
:
cards
)
...
@@ -95,8 +95,9 @@ void duel::delete_effect(effect* peffect) {
...
@@ -95,8 +95,9 @@ void duel::delete_effect(effect* peffect) {
delete
peffect
;
delete
peffect
;
}
}
int32
duel
::
read_buffer
(
byte
*
buf
)
{
int32
duel
::
read_buffer
(
byte
*
buf
)
{
std
::
memcpy
(
buf
,
message_buffer
,
bufferlen
);
if
(
message_buffer
.
size
())
return
bufferlen
;
std
::
memcpy
(
buf
,
message_buffer
.
data
(),
message_buffer
.
size
());
return
(
int32
)
message_buffer
.
size
();
}
}
void
duel
::
release_script_group
()
{
void
duel
::
release_script_group
()
{
for
(
auto
&
pgroup
:
sgroups
)
{
for
(
auto
&
pgroup
:
sgroups
)
{
...
@@ -113,24 +114,20 @@ void duel::restore_assumes() {
...
@@ -113,24 +114,20 @@ void duel::restore_assumes() {
pcard
->
assume_type
=
0
;
pcard
->
assume_type
=
0
;
assumes
.
clear
();
assumes
.
clear
();
}
}
void
duel
::
write_buffer
(
const
void
*
data
,
int
size
)
{
write_buffer_vector
(
message_buffer
,
data
,
size
);
}
void
duel
::
write_buffer32
(
uint32
value
)
{
void
duel
::
write_buffer32
(
uint32
value
)
{
std
::
memcpy
(
bufferp
,
&
value
,
sizeof
(
value
));
write_buffer
(
&
value
,
sizeof
(
value
));
bufferp
+=
4
;
bufferlen
+=
4
;
}
}
void
duel
::
write_buffer16
(
uint16
value
)
{
void
duel
::
write_buffer16
(
uint16
value
)
{
std
::
memcpy
(
bufferp
,
&
value
,
sizeof
(
value
));
write_buffer
(
&
value
,
sizeof
(
value
));
bufferp
+=
2
;
bufferlen
+=
2
;
}
}
void
duel
::
write_buffer8
(
uint8
value
)
{
void
duel
::
write_buffer8
(
uint8
value
)
{
std
::
memcpy
(
bufferp
,
&
value
,
sizeof
(
value
));
write_buffer
(
&
value
,
sizeof
(
value
));
bufferp
+=
1
;
bufferlen
+=
1
;
}
}
void
duel
::
clear_buffer
()
{
void
duel
::
clear_buffer
()
{
bufferlen
=
0
;
message_buffer
.
clear
();
bufferp
=
message_buffer
;
}
}
void
duel
::
set_responsei
(
uint32
resp
)
{
void
duel
::
set_responsei
(
uint32
resp
)
{
game_field
->
returns
.
ivalue
[
0
]
=
resp
;
game_field
->
returns
.
ivalue
[
0
]
=
resp
;
...
...
duel.h
View file @
16c4d4b2
...
@@ -13,21 +13,25 @@
...
@@ -13,21 +13,25 @@
#include <set>
#include <set>
#include <unordered_set>
#include <unordered_set>
#define BUFFER_SIZE 4096
class
card
;
class
card
;
class
group
;
class
group
;
class
effect
;
class
effect
;
class
field
;
class
field
;
class
interpreter
;
class
interpreter
;
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
);
}
}
class
duel
{
class
duel
{
public:
public:
using
card_set
=
std
::
set
<
card
*
,
card_sort
>
;
using
card_set
=
std
::
set
<
card
*
,
card_sort
>
;
char
strbuffer
[
256
];
char
strbuffer
[
256
];
byte
message_buffer
[
BUFFER_SIZE
];
std
::
vector
<
byte
>
message_buffer
;
int32
bufferlen
;
byte
*
bufferp
;
interpreter
*
lua
;
interpreter
*
lua
;
field
*
game_field
;
field
*
game_field
;
mt19937
random
;
mt19937
random
;
...
@@ -53,6 +57,7 @@ public:
...
@@ -53,6 +57,7 @@ public:
void
release_script_group
();
void
release_script_group
();
void
restore_assumes
();
void
restore_assumes
();
int32
read_buffer
(
byte
*
buf
);
int32
read_buffer
(
byte
*
buf
);
void
write_buffer
(
const
void
*
data
,
int
size
);
void
write_buffer32
(
uint32
value
);
void
write_buffer32
(
uint32
value
);
void
write_buffer16
(
uint16
value
);
void
write_buffer16
(
uint16
value
);
void
write_buffer8
(
uint8
value
);
void
write_buffer8
(
uint8
value
);
...
...
field.h
View file @
16c4d4b2
...
@@ -501,7 +501,7 @@ public:
...
@@ -501,7 +501,7 @@ public:
int32
is_able_to_enter_bp
();
int32
is_able_to_enter_bp
();
void
add_process
(
uint16
type
,
uint16
step
,
effect
*
peffect
,
group
*
target
,
int32
arg1
,
int32
arg2
,
int32
arg3
=
0
,
int32
arg4
=
0
,
void
*
ptr1
=
nullptr
,
void
*
ptr2
=
nullptr
);
void
add_process
(
uint16
type
,
uint16
step
,
effect
*
peffect
,
group
*
target
,
int32
arg1
,
int32
arg2
,
int32
arg3
=
0
,
int32
arg4
=
0
,
void
*
ptr1
=
nullptr
,
void
*
ptr2
=
nullptr
);
int32
process
();
u
int32
process
();
int32
execute_cost
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
int32
execute_cost
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
int32
execute_operation
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
int32
execute_operation
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
int32
execute_target
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
int32
execute_target
(
uint16
step
,
effect
*
peffect
,
uint8
triggering_player
);
...
@@ -704,9 +704,6 @@ public:
...
@@ -704,9 +704,6 @@ public:
#define GLOBALFLAG_TUNE_MAGICIAN 0x400
#define GLOBALFLAG_TUNE_MAGICIAN 0x400
#define GLOBALFLAG_ACTIVATION_COUNT 0x800
#define GLOBALFLAG_ACTIVATION_COUNT 0x800
//
//
#define PROCESSOR_NONE 0
#define PROCESSOR_WAITING 0x10000
#define PROCESSOR_END 0x20000
#define PROCESSOR_ADJUST 1
#define PROCESSOR_ADJUST 1
#define PROCESSOR_HINT 2
#define PROCESSOR_HINT 2
...
...
libdebug.cpp
View file @
16c4d4b2
...
@@ -174,9 +174,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) {
...
@@ -174,9 +174,7 @@ int32 scriptlib::debug_set_ai_name(lua_State *L) {
if
(
len
>
100
)
if
(
len
>
100
)
len
=
100
;
len
=
100
;
pduel
->
write_buffer16
(
len
);
pduel
->
write_buffer16
(
len
);
for
(
int
i
=
0
;
i
<
len
;
++
i
)
{
pduel
->
write_buffer
(
pstr
,
len
);
pduel
->
write_buffer8
(
pstr
[
i
]);
}
pduel
->
write_buffer8
(
0
);
pduel
->
write_buffer8
(
0
);
return
0
;
return
0
;
}
}
...
@@ -190,9 +188,7 @@ int32 scriptlib::debug_show_hint(lua_State *L) {
...
@@ -190,9 +188,7 @@ int32 scriptlib::debug_show_hint(lua_State *L) {
if
(
len
>
1024
)
if
(
len
>
1024
)
len
=
1024
;
len
=
1024
;
pduel
->
write_buffer16
(
len
);
pduel
->
write_buffer16
(
len
);
for
(
int
i
=
0
;
i
<
len
;
++
i
)
{
pduel
->
write_buffer
(
pstr
,
len
);
pduel
->
write_buffer8
(
pstr
[
i
]);
}
pduel
->
write_buffer8
(
0
);
pduel
->
write_buffer8
(
0
);
return
0
;
return
0
;
}
}
...
...
ocgapi.cpp
View file @
16c4d4b2
...
@@ -127,11 +127,12 @@ extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf) {
...
@@ -127,11 +127,12 @@ extern "C" DECL_DLLEXPORT int32 get_message(intptr_t pduel, byte* buf) {
((
duel
*
)
pduel
)
->
clear_buffer
();
((
duel
*
)
pduel
)
->
clear_buffer
();
return
len
;
return
len
;
}
}
extern
"C"
DECL_DLLEXPORT
int32
process
(
intptr_t
pduel
)
{
extern
"C"
DECL_DLLEXPORT
u
int32
process
(
intptr_t
pduel
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
duel
*
pd
=
(
duel
*
)
pduel
;
int
result
=
pd
->
game_field
->
process
();
uint32
result
=
0
;
while
((
result
&
0xffff
)
==
0
&&
(
result
&
0xf0000
)
==
0
)
do
{
result
=
pd
->
game_field
->
process
();
result
=
pd
->
game_field
->
process
();
}
while
((
result
&
PROCESSOR_BUFFER_LEN
)
==
0
&&
(
result
&
PROCESSOR_FLAG
)
==
0
);
return
result
;
return
result
;
}
}
extern
"C"
DECL_DLLEXPORT
void
new_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
uint8
position
)
{
extern
"C"
DECL_DLLEXPORT
void
new_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
uint8
position
)
{
...
...
ocgapi.h
View file @
16c4d4b2
...
@@ -41,7 +41,7 @@ extern "C" DECL_DLLEXPORT void end_duel(intptr_t pduel);
...
@@ -41,7 +41,7 @@ extern "C" DECL_DLLEXPORT void end_duel(intptr_t pduel);
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
intptr_t
pduel
,
int32
playerid
,
int32
lp
,
int32
startcount
,
int32
drawcount
);
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
intptr_t
pduel
,
int32
playerid
,
int32
lp
,
int32
startcount
,
int32
drawcount
);
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
process
(
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
u
int32
process
(
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
void
new_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
uint8
position
);
extern
"C"
DECL_DLLEXPORT
void
new_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
uint8
position
);
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
intptr_t
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
intptr_t
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
...
...
processor.cpp
View file @
16c4d4b2
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