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
3df667a9
Commit
3df667a9
authored
Jun 03, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Fluorohydride/ygopro-core into develop
parents
15b26798
2c754979
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
60 deletions
+58
-60
ocgapi.cpp
ocgapi.cpp
+27
-27
ocgapi.h
ocgapi.h
+31
-31
premake5.lua
premake5.lua
+0
-2
No files found.
ocgapi.cpp
View file @
3df667a9
...
...
@@ -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,20 +62,14 @@ 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
);
pduel
->
lua
->
preloaded
=
FALSE
;
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
;
if
(
!
pd
->
lua
->
preloaded
)
{
pd
->
lua
->
preloaded
=
TRUE
;
...
...
@@ -118,14 +118,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
;
...
...
@@ -136,17 +136,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
{
...
...
@@ -154,7 +154,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
;
...
...
@@ -176,7 +176,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
;
...
...
@@ -205,7 +205,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
;
...
...
@@ -239,7 +239,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
;
...
...
@@ -270,7 +270,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
;
...
...
@@ -317,7 +317,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
;
...
...
@@ -361,12 +361,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 @
3df667a9
...
...
@@ -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 @
3df667a9
...
...
@@ -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