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
3e613479
Commit
3e613479
authored
Jun 14, 2025
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro-core
into develop
parents
5b74daf0
7e1ef833
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
67 deletions
+68
-67
common.h
common.h
+6
-3
libdebug.cpp
libdebug.cpp
+4
-4
ocgapi.cpp
ocgapi.cpp
+27
-27
ocgapi.h
ocgapi.h
+31
-31
premake5.lua
premake5.lua
+0
-2
No files found.
common.h
View file @
3e613479
...
...
@@ -26,8 +26,11 @@ inline bool check_playerid(int32_t playerid) {
#define OPERATION_CANCELED -1
#define TRUE 1
#define FALSE 0
#define SIZE_MESSAGE_BUFFER 0x2000
#define SIZE_RETURN_VALUE 512
#define SIZE_AI_NAME 128
#define SIZE_HINT_MSG 1024
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_FLAG 0xf0000000
...
...
@@ -337,9 +340,9 @@ inline bool check_playerid(int32_t playerid) {
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162 // Debug.ReloadFieldEnd()
#define MSG_AI_NAME 163
#define MSG_SHOW_HINT 164
#define MSG_RELOAD_FIELD 162 // Debug.ReloadFieldEnd()
or query_field_info()
#define MSG_AI_NAME 163
// Debug.AIName()
#define MSG_SHOW_HINT 164
// Debug.ShowHint()
#define MSG_PLAYER_HINT 165
#define MSG_MATCH_KILL 170
#define MSG_CUSTOM_MSG 180
...
...
libdebug.cpp
View file @
3e613479
...
...
@@ -167,8 +167,8 @@ int32_t scriptlib::debug_set_ai_name(lua_State *L) {
pduel
->
write_buffer8
(
MSG_AI_NAME
);
const
char
*
pstr
=
lua_tostring
(
L
,
1
);
int
len
=
(
int
)
std
::
strlen
(
pstr
);
if
(
len
>
100
)
len
=
100
;
if
(
len
>
SIZE_AI_NAME
-
1
)
len
=
SIZE_AI_NAME
-
1
;
pduel
->
write_buffer16
(
len
);
pduel
->
write_buffer
(
pstr
,
len
);
pduel
->
write_buffer8
(
0
);
...
...
@@ -181,8 +181,8 @@ int32_t scriptlib::debug_show_hint(lua_State *L) {
pduel
->
write_buffer8
(
MSG_SHOW_HINT
);
const
char
*
pstr
=
lua_tostring
(
L
,
1
);
int
len
=
(
int
)
std
::
strlen
(
pstr
);
if
(
len
>
1024
)
len
=
1024
;
if
(
len
>
SIZE_HINT_MSG
-
1
)
len
=
SIZE_HINT_MSG
-
1
;
pduel
->
write_buffer16
(
len
);
pduel
->
write_buffer
(
pstr
,
len
);
pduel
->
write_buffer8
(
0
);
...
...
ocgapi.cpp
View file @
3e613479
...
...
@@ -16,19 +16,25 @@
#include "interpreter.h"
#include "buffer.h"
static
uint32_t
default_card_reader
(
uint32_t
code
,
card_data
*
data
)
{
return
0
;
}
static
uint32_t
default_message_handler
(
intptr_t
pduel
,
uint32_t
message_type
)
{
return
0
;
}
static
script_reader
sreader
=
default_script_reader
;
static
card_reader
creader
=
default_card_reader
;
static
message_handler
mhandler
=
default_message_handler
;
static
byte
buffer
[
0x
2
0000
];
static
byte
buffer
[
0x
10
0000
];
static
std
::
set
<
duel
*>
duel_set
;
extern
"C"
DECL_DLLEXPORT
void
set_script_reader
(
script_reader
f
)
{
OCGCORE_API
void
set_script_reader
(
script_reader
f
)
{
sreader
=
f
;
}
extern
"C"
DECL_DLLEXPORT
void
set_card_reader
(
card_reader
f
)
{
OCGCORE_API
void
set_card_reader
(
card_reader
f
)
{
creader
=
f
;
}
extern
"C"
DECL_DLLEXPORT
void
set_message_handler
(
message_handler
f
)
{
OCGCORE_API
void
set_message_handler
(
message_handler
f
)
{
mhandler
=
f
;
}
byte
*
read_script
(
const
char
*
script_name
,
int
*
len
)
{
...
...
@@ -44,7 +50,7 @@ uint32_t read_card(uint32_t code, card_data* data) {
uint32_t
handle_message
(
void
*
pduel
,
uint32_t
message_type
)
{
return
mhandler
((
intptr_t
)
pduel
,
message_type
);
}
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
slen
)
{
OCGCORE_API
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
slen
)
{
FILE
*
fp
;
fp
=
std
::
fopen
(
script_name
,
"rb"
);
if
(
!
fp
)
...
...
@@ -56,19 +62,13 @@ byte* default_script_reader(const char* script_name, int* slen) {
*
slen
=
(
int
)
len
;
return
buffer
;
}
uint32_t
default_card_reader
(
uint32_t
code
,
card_data
*
data
)
{
return
0
;
}
uint32_t
default_message_handler
(
intptr_t
pduel
,
uint32_t
message_type
)
{
return
0
;
}
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint_fast32_t
seed
)
{
OCGCORE_API
intptr_t
create_duel
(
uint_fast32_t
seed
)
{
duel
*
pduel
=
new
duel
();
duel_set
.
insert
(
pduel
);
pduel
->
random
.
reset
(
seed
);
return
(
intptr_t
)
pduel
;
}
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
intptr_t
pduel
,
uint32_t
options
)
{
OCGCORE_API
void
start_duel
(
intptr_t
pduel
,
uint32_t
options
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
uint16_t
duel_rule
=
options
>>
16
;
uint16_t
duel_options
=
options
&
0xffff
;
...
...
@@ -113,14 +113,14 @@ extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, uint32_t options) {
}
pd
->
game_field
->
add_process
(
PROCESSOR_TURN
,
0
,
0
,
0
,
0
,
0
);
}
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
intptr_t
pduel
)
{
OCGCORE_API
void
end_duel
(
intptr_t
pduel
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
if
(
duel_set
.
count
(
pd
))
{
duel_set
.
erase
(
pd
);
delete
pd
;
}
}
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
intptr_t
pduel
,
int32_t
playerid
,
int32_t
lp
,
int32_t
startcount
,
int32_t
drawcount
)
{
OCGCORE_API
void
set_player_info
(
intptr_t
pduel
,
int32_t
playerid
,
int32_t
lp
,
int32_t
startcount
,
int32_t
drawcount
)
{
if
(
!
check_playerid
(
playerid
))
return
;
duel
*
pd
=
(
duel
*
)
pduel
;
...
...
@@ -131,17 +131,17 @@ extern "C" DECL_DLLEXPORT void set_player_info(intptr_t pduel, int32_t playerid,
if
(
drawcount
>=
0
)
pd
->
game_field
->
player
[
playerid
].
draw_count
=
drawcount
;
}
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
intptr_t
pduel
,
char
*
buf
)
{
OCGCORE_API
void
get_log_message
(
intptr_t
pduel
,
char
*
buf
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
buf
[
0
]
=
'\0'
;
std
::
strncat
(
buf
,
pd
->
strbuffer
,
sizeof
pd
->
strbuffer
-
1
);
}
extern
"C"
DECL_DLLEXPORT
int32_t
get_message
(
intptr_t
pduel
,
byte
*
buf
)
{
OCGCORE_API
int32_t
get_message
(
intptr_t
pduel
,
byte
*
buf
)
{
int32_t
len
=
((
duel
*
)
pduel
)
->
read_buffer
(
buf
);
((
duel
*
)
pduel
)
->
clear_buffer
();
return
len
;
}
extern
"C"
DECL_DLLEXPORT
uint32_t
process
(
intptr_t
pduel
)
{
OCGCORE_API
uint32_t
process
(
intptr_t
pduel
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
uint32_t
result
=
0
;
do
{
...
...
@@ -149,7 +149,7 @@ extern "C" DECL_DLLEXPORT uint32_t process(intptr_t pduel) {
}
while
((
result
&
PROCESSOR_BUFFER_LEN
)
==
0
&&
(
result
&
PROCESSOR_FLAG
)
==
0
);
return
result
;
}
extern
"C"
DECL_DLLEXPORT
void
new_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
uint8_t
position
)
{
OCGCORE_API
void
new_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
uint8_t
position
)
{
if
(
!
check_playerid
(
owner
)
||
!
check_playerid
(
playerid
))
return
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
...
...
@@ -167,7 +167,7 @@ extern "C" DECL_DLLEXPORT void new_card(intptr_t pduel, uint32_t code, uint8_t o
}
}
}
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
location
)
{
OCGCORE_API
void
new_tag_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
location
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
if
(
owner
>
1
||
!
(
location
&
(
LOCATION_DECK
|
LOCATION_EXTRA
)))
return
;
...
...
@@ -196,7 +196,7 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32_t code, uint8
* @param buf int32_t array
* @return buffer length in bytes
*/
extern
"C"
DECL_DLLEXPORT
int32_t
query_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
int32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
)
{
OCGCORE_API
int32_t
query_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
int32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
)
{
if
(
!
check_playerid
(
playerid
))
return
LEN_FAIL
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
...
...
@@ -230,7 +230,7 @@ extern "C" DECL_DLLEXPORT int32_t query_card(intptr_t pduel, uint8_t playerid, u
return
LEN_EMPTY
;
}
}
extern
"C"
DECL_DLLEXPORT
int32_t
query_field_count
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
)
{
OCGCORE_API
int32_t
query_field_count
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
if
(
!
check_playerid
(
playerid
))
return
0
;
...
...
@@ -261,7 +261,7 @@ extern "C" DECL_DLLEXPORT int32_t query_field_count(intptr_t pduel, uint8_t play
}
return
0
;
}
extern
"C"
DECL_DLLEXPORT
int32_t
query_field_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
)
{
OCGCORE_API
int32_t
query_field_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
)
{
if
(
!
check_playerid
(
playerid
))
return
LEN_FAIL
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
...
...
@@ -308,7 +308,7 @@ extern "C" DECL_DLLEXPORT int32_t query_field_card(intptr_t pduel, uint8_t playe
}
return
(
int32_t
)(
p
-
buf
);
}
extern
"C"
DECL_DLLEXPORT
int32_t
query_field_info
(
intptr_t
pduel
,
byte
*
buf
)
{
OCGCORE_API
int32_t
query_field_info
(
intptr_t
pduel
,
byte
*
buf
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
byte
*
p
=
buf
;
*
p
++
=
MSG_RELOAD_FIELD
;
...
...
@@ -352,12 +352,12 @@ extern "C" DECL_DLLEXPORT int32_t query_field_info(intptr_t pduel, byte* buf) {
}
return
(
int32_t
)(
p
-
buf
);
}
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
intptr_t
pduel
,
int32_t
value
)
{
OCGCORE_API
void
set_responsei
(
intptr_t
pduel
,
int32_t
value
)
{
((
duel
*
)
pduel
)
->
set_responsei
(
value
);
}
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
intptr_t
pduel
,
byte
*
buf
)
{
OCGCORE_API
void
set_responseb
(
intptr_t
pduel
,
byte
*
buf
)
{
((
duel
*
)
pduel
)
->
set_responseb
(
buf
);
}
extern
"C"
DECL_DLLEXPORT
int32_t
preload_script
(
intptr_t
pduel
,
const
char
*
script_name
)
{
OCGCORE_API
int32_t
preload_script
(
intptr_t
pduel
,
const
char
*
script_name
)
{
return
((
duel
*
)
pduel
)
->
lua
->
load_script
(
script_name
);
}
ocgapi.h
View file @
3e613479
...
...
@@ -10,10 +10,16 @@
#include "common.h"
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
#ifdef _WIN32
#define
DECL_DLLEXPORT
__declspec(dllexport)
#define
OCGCORE_API EXTERN_C
__declspec(dllexport)
#else
#define
DECL_DLLEXPORT
#define
OCGCORE_API EXTERN_C __attribute__ ((visibility ("default")))
#endif
#define LEN_FAIL 0
...
...
@@ -21,42 +27,36 @@
#define LEN_HEADER 8
#define TEMP_CARD_ID 0
class
card
;
struct
card_data
;
class
group
;
class
effect
;
class
interpreter
;
typedef
byte
*
(
*
script_reader
)(
const
char
*
,
int
*
);
typedef
uint32_t
(
*
card_reader
)(
uint32_t
,
card_data
*
);
typedef
uint32_t
(
*
message_handler
)(
intptr_t
,
uint32_t
);
typedef
byte
*
(
*
script_reader
)(
const
char
*
script_name
,
int
*
len
);
typedef
uint32_t
(
*
card_reader
)(
uint32_t
code
,
card_data
*
data
);
typedef
uint32_t
(
*
message_handler
)(
intptr_t
pduel
,
uint32_t
msg_type
);
extern
"C"
DECL_DLLEXPORT
void
set_script_reader
(
script_reader
f
);
extern
"C"
DECL_DLLEXPORT
void
set_card_reader
(
card_reader
f
);
extern
"C"
DECL_DLLEXPORT
void
set_message_handler
(
message_handler
f
);
OCGCORE_API
void
set_script_reader
(
script_reader
f
);
OCGCORE_API
void
set_card_reader
(
card_reader
f
);
OCGCORE_API
void
set_message_handler
(
message_handler
f
);
byte
*
read_script
(
const
char
*
script_name
,
int
*
len
);
uint32_t
read_card
(
uint32_t
code
,
card_data
*
data
);
uint32_t
handle_message
(
void
*
pduel
,
uint32_t
message_type
);
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint_fast32_t
seed
);
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
intptr_t
pduel
,
uint32_t
options
);
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
intptr_t
pduel
,
int32_t
playerid
,
int32_t
lp
,
int32_t
startcount
,
int32_t
drawcount
);
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
intptr_t
pduel
,
char
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32_t
get_message
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
uint32_t
process
(
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
void
new_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
uint8_t
position
);
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
location
);
extern
"C"
DECL_DLLEXPORT
int32_t
query_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
int32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32_t
query_field_count
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
);
extern
"C"
DECL_DLLEXPORT
int32_t
query_field_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32_t
query_field_info
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
intptr_t
pduel
,
int32_t
value
);
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32_t
preload_script
(
intptr_t
pduel
,
const
char
*
script_name
);
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
len
);
uint32_t
default_card_reader
(
uint32_t
code
,
card_data
*
data
);
uint32_t
default_message_handler
(
intptr_t
pduel
,
uint32_t
msg_type
);
OCGCORE_API
intptr_t
create_duel
(
uint_fast32_t
seed
);
OCGCORE_API
void
start_duel
(
intptr_t
pduel
,
uint32_t
options
);
OCGCORE_API
void
end_duel
(
intptr_t
pduel
);
OCGCORE_API
void
set_player_info
(
intptr_t
pduel
,
int32_t
playerid
,
int32_t
lp
,
int32_t
startcount
,
int32_t
drawcount
);
OCGCORE_API
void
get_log_message
(
intptr_t
pduel
,
char
*
buf
);
OCGCORE_API
int32_t
get_message
(
intptr_t
pduel
,
byte
*
buf
);
OCGCORE_API
uint32_t
process
(
intptr_t
pduel
);
OCGCORE_API
void
new_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
uint8_t
position
);
OCGCORE_API
void
new_tag_card
(
intptr_t
pduel
,
uint32_t
code
,
uint8_t
owner
,
uint8_t
location
);
OCGCORE_API
int32_t
query_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint8_t
sequence
,
int32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
);
OCGCORE_API
int32_t
query_field_count
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
);
OCGCORE_API
int32_t
query_field_card
(
intptr_t
pduel
,
uint8_t
playerid
,
uint8_t
location
,
uint32_t
query_flag
,
byte
*
buf
,
int32_t
use_cache
);
OCGCORE_API
int32_t
query_field_info
(
intptr_t
pduel
,
byte
*
buf
);
OCGCORE_API
void
set_responsei
(
intptr_t
pduel
,
int32_t
value
);
OCGCORE_API
void
set_responseb
(
intptr_t
pduel
,
byte
*
buf
);
OCGCORE_API
int32_t
preload_script
(
intptr_t
pduel
,
const
char
*
script_name
);
OCGCORE_API
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
len
);
#endif
/* OCGAPI_H_ */
premake5.lua
View file @
3e613479
...
...
@@ -3,13 +3,11 @@ project "ocgcore"
cppdialect
"C++14"
files
{
"*.cpp"
,
"*.h"
}
links
{
LUA_LIB_NAME
}
if
BUILD_LUA
then
includedirs
{
"../lua/src"
}
else
includedirs
{
LUA_INCLUDE_DIR
}
libdirs
{
LUA_LIB_DIR
}
end
filter
"system:bsd"
...
...
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