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
03b59cd0
Commit
03b59cd0
authored
Aug 31, 2021
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use intptr_t
parent
1f6e9845
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
40 deletions
+51
-40
ocgapi.cpp
ocgapi.cpp
+33
-23
ocgapi.h
ocgapi.h
+18
-17
No files found.
ocgapi.cpp
View file @
03b59cd0
...
@@ -57,13 +57,14 @@ uint32 default_card_reader(uint32 code, card_data* data) {
...
@@ -57,13 +57,14 @@ uint32 default_card_reader(uint32 code, card_data* data) {
uint32
default_message_handler
(
void
*
pduel
,
uint32
message_type
)
{
uint32
default_message_handler
(
void
*
pduel
,
uint32
message_type
)
{
return
0
;
return
0
;
}
}
extern
"C"
DECL_DLLEXPORT
duel
*
create_duel
(
uint32
seed
)
{
extern
"C"
DECL_DLLEXPORT
intptr_t
create_duel
(
uint32
seed
)
{
duel
*
pduel
=
new
duel
();
duel
*
pduel
=
new
duel
();
duel_set
.
insert
(
pduel
);
duel_set
.
insert
(
pduel
);
pduel
->
random
.
reset
(
seed
);
pduel
->
random
.
reset
(
seed
);
return
pduel
;
return
(
intptr_t
)
pduel
;
}
}
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
duel
*
pd
,
int32
options
)
{
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
intptr_t
pduel
,
int32
options
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
pd
->
game_field
->
core
.
duel_options
|=
options
&
0xffff
;
pd
->
game_field
->
core
.
duel_options
|=
options
&
0xffff
;
int32
duel_rule
=
options
>>
16
;
int32
duel_rule
=
options
>>
16
;
if
(
duel_rule
)
if
(
duel_rule
)
...
@@ -102,13 +103,15 @@ extern "C" DECL_DLLEXPORT void start_duel(duel* pd, int32 options) {
...
@@ -102,13 +103,15 @@ extern "C" DECL_DLLEXPORT void start_duel(duel* pd, int32 options) {
}
}
pd
->
game_field
->
add_process
(
PROCESSOR_TURN
,
0
,
0
,
0
,
0
,
0
);
pd
->
game_field
->
add_process
(
PROCESSOR_TURN
,
0
,
0
,
0
,
0
,
0
);
}
}
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
duel
*
pd
)
{
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
intptr_t
pduel
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
if
(
duel_set
.
count
(
pd
))
{
if
(
duel_set
.
count
(
pd
))
{
duel_set
.
erase
(
pd
);
duel_set
.
erase
(
pd
);
delete
pd
;
delete
pd
;
}
}
}
}
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
duel
*
pd
,
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
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
if
(
lp
>
0
)
if
(
lp
>
0
)
pd
->
game_field
->
player
[
playerid
].
lp
=
lp
;
pd
->
game_field
->
player
[
playerid
].
lp
=
lp
;
if
(
startcount
>=
0
)
if
(
startcount
>=
0
)
...
@@ -116,21 +119,23 @@ extern "C" DECL_DLLEXPORT void set_player_info(duel* pd, int32 playerid, int32 l
...
@@ -116,21 +119,23 @@ extern "C" DECL_DLLEXPORT void set_player_info(duel* pd, int32 playerid, int32 l
if
(
drawcount
>=
0
)
if
(
drawcount
>=
0
)
pd
->
game_field
->
player
[
playerid
].
draw_count
=
drawcount
;
pd
->
game_field
->
player
[
playerid
].
draw_count
=
drawcount
;
}
}
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
duel
*
pduel
,
byte
*
buf
)
{
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
intptr_t
pduel
,
byte
*
buf
)
{
strcpy
((
char
*
)
buf
,
pduel
->
strbuffer
);
strcpy
((
char
*
)
buf
,
((
duel
*
)
pduel
)
->
strbuffer
);
}
}
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
duel
*
pduel
,
byte
*
buf
)
{
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
intptr_t
pduel
,
byte
*
buf
)
{
int32
len
=
pduel
->
read_buffer
(
buf
);
int32
len
=
((
duel
*
)
pduel
)
->
read_buffer
(
buf
);
pduel
->
clear_buffer
();
((
duel
*
)
pduel
)
->
clear_buffer
();
return
len
;
return
len
;
}
}
extern
"C"
DECL_DLLEXPORT
int32
process
(
duel
*
pd
)
{
extern
"C"
DECL_DLLEXPORT
int32
process
(
intptr_t
pduel
)
{
duel
*
pd
=
(
duel
*
)
pduel
;
int
result
=
pd
->
game_field
->
process
();
int
result
=
pd
->
game_field
->
process
();
while
((
result
&
0xffff
)
==
0
&&
(
result
&
0xf0000
)
==
0
)
while
((
result
&
0xffff
)
==
0
&&
(
result
&
0xf0000
)
==
0
)
result
=
pd
->
game_field
->
process
();
result
=
pd
->
game_field
->
process
();
return
result
;
return
result
;
}
}
extern
"C"
DECL_DLLEXPORT
void
new_card
(
duel
*
ptduel
,
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
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
if
(
ptduel
->
game_field
->
is_location_useable
(
playerid
,
location
,
sequence
))
{
if
(
ptduel
->
game_field
->
is_location_useable
(
playerid
,
location
,
sequence
))
{
card
*
pcard
=
ptduel
->
new_card
(
code
);
card
*
pcard
=
ptduel
->
new_card
(
code
);
pcard
->
owner
=
owner
;
pcard
->
owner
=
owner
;
...
@@ -146,7 +151,8 @@ extern "C" DECL_DLLEXPORT void new_card(duel* ptduel, uint32 code, uint8 owner,
...
@@ -146,7 +151,8 @@ extern "C" DECL_DLLEXPORT void new_card(duel* ptduel, uint32 code, uint8 owner,
}
}
}
}
}
}
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
duel
*
ptduel
,
uint32
code
,
uint8
owner
,
uint8
location
)
{
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
location
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
if
(
owner
>
1
||
!
(
location
&
(
LOCATION_DECK
|
LOCATION_EXTRA
)))
if
(
owner
>
1
||
!
(
location
&
(
LOCATION_DECK
|
LOCATION_EXTRA
)))
return
;
return
;
card
*
pcard
=
ptduel
->
new_card
(
code
);
card
*
pcard
=
ptduel
->
new_card
(
code
);
...
@@ -169,9 +175,10 @@ extern "C" DECL_DLLEXPORT void new_tag_card(duel* ptduel, uint32 code, uint8 own
...
@@ -169,9 +175,10 @@ extern "C" DECL_DLLEXPORT void new_tag_card(duel* ptduel, uint32 code, uint8 own
break
;
break
;
}
}
}
}
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
duel
*
pt
duel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
)
{
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
intptr_t
p
duel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
)
{
if
(
playerid
!=
0
&&
playerid
!=
1
)
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
0
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
card
*
pcard
=
0
;
card
*
pcard
=
0
;
location
&=
0x7f
;
location
&=
0x7f
;
if
(
location
&
LOCATION_ONFIELD
)
if
(
location
&
LOCATION_ONFIELD
)
...
@@ -201,7 +208,8 @@ extern "C" DECL_DLLEXPORT int32 query_card(duel* ptduel, uint8 playerid, uint8 l
...
@@ -201,7 +208,8 @@ extern "C" DECL_DLLEXPORT int32 query_card(duel* ptduel, uint8 playerid, uint8 l
return
4
;
return
4
;
}
}
}
}
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
duel
*
ptduel
,
uint8
playerid
,
uint8
location
)
{
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
intptr_t
pduel
,
uint8
playerid
,
uint8
location
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
if
(
playerid
!=
0
&&
playerid
!=
1
)
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
0
;
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
...
@@ -229,9 +237,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(duel* ptduel, uint8 playerid,
...
@@ -229,9 +237,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(duel* ptduel, uint8 playerid,
}
}
return
0
;
return
0
;
}
}
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
duel
*
pt
duel
,
uint8
playerid
,
uint8
location
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
)
{
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
intptr_t
p
duel
,
uint8
playerid
,
uint8
location
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
)
{
if
(
playerid
!=
0
&&
playerid
!=
1
)
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
0
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
byte
*
p
=
buf
;
byte
*
p
=
buf
;
if
(
location
==
LOCATION_MZONE
)
{
if
(
location
==
LOCATION_MZONE
)
{
...
@@ -275,7 +284,8 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(duel* ptduel, uint8 playerid, u
...
@@ -275,7 +284,8 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(duel* ptduel, uint8 playerid, u
}
}
return
(
int32
)(
p
-
buf
);
return
(
int32
)(
p
-
buf
);
}
}
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
duel
*
ptduel
,
byte
*
buf
)
{
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
intptr_t
pduel
,
byte
*
buf
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
byte
*
p
=
buf
;
byte
*
p
=
buf
;
*
p
++
=
MSG_RELOAD_FIELD
;
*
p
++
=
MSG_RELOAD_FIELD
;
*
p
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
*
p
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
...
@@ -322,12 +332,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(duel* ptduel, byte* buf) {
...
@@ -322,12 +332,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(duel* ptduel, byte* buf) {
}
}
return
(
int32
)(
p
-
buf
);
return
(
int32
)(
p
-
buf
);
}
}
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
duel
*
pduel
,
int32
value
)
{
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
intptr_t
pduel
,
int32
value
)
{
pduel
->
set_responsei
(
value
);
((
duel
*
)
pduel
)
->
set_responsei
(
value
);
}
}
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
duel
*
pduel
,
byte
*
buf
)
{
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
intptr_t
pduel
,
byte
*
buf
)
{
pduel
->
set_responseb
(
buf
);
((
duel
*
)
pduel
)
->
set_responseb
(
buf
);
}
}
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
duel
*
pduel
,
const
char
*
script
,
int32
len
)
{
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
intptr_t
pduel
,
const
char
*
script
,
int32
len
)
{
return
pduel
->
lua
->
load_script
(
script
);
return
((
duel
*
)
pduel
)
->
lua
->
load_script
(
script
);
}
}
ocgapi.h
View file @
03b59cd0
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#define OCGAPI_H_
#define OCGAPI_H_
#include "common.h"
#include "common.h"
#include <cstdint>
#ifdef WIN32
#ifdef WIN32
#define DECL_DLLEXPORT __declspec(dllexport)
#define DECL_DLLEXPORT __declspec(dllexport)
#else
#else
...
@@ -21,7 +23,6 @@ struct card_info;
...
@@ -21,7 +23,6 @@ struct card_info;
class
group
;
class
group
;
class
effect
;
class
effect
;
class
interpreter
;
class
interpreter
;
class
duel
;
typedef
byte
*
(
*
script_reader
)(
const
char
*
,
int
*
);
typedef
byte
*
(
*
script_reader
)(
const
char
*
,
int
*
);
typedef
uint32
(
*
card_reader
)(
uint32
,
card_data
*
);
typedef
uint32
(
*
card_reader
)(
uint32
,
card_data
*
);
...
@@ -35,22 +36,22 @@ byte* read_script(const char* script_name, int* len);
...
@@ -35,22 +36,22 @@ byte* read_script(const char* script_name, int* len);
uint32
read_card
(
uint32
code
,
card_data
*
data
);
uint32
read_card
(
uint32
code
,
card_data
*
data
);
uint32
handle_message
(
void
*
pduel
,
uint32
message_type
);
uint32
handle_message
(
void
*
pduel
,
uint32
message_type
);
extern
"C"
DECL_DLLEXPORT
duel
*
create_duel
(
uint32
seed
);
extern
"C"
DECL_DLLEXPORT
std
::
intptr_t
create_duel
(
uint32
seed
);
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
duel
*
pduel
,
int32
options
);
extern
"C"
DECL_DLLEXPORT
void
start_duel
(
std
::
intptr_t
pduel
,
int32
options
);
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
duel
*
pduel
);
extern
"C"
DECL_DLLEXPORT
void
end_duel
(
std
::
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
duel
*
pduel
,
int32
playerid
,
int32
lp
,
int32
startcount
,
int32
drawcount
);
extern
"C"
DECL_DLLEXPORT
void
set_player_info
(
std
::
intptr_t
pduel
,
int32
playerid
,
int32
lp
,
int32
startcount
,
int32
drawcount
);
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
duel
*
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
get_log_message
(
std
::
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
duel
*
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
get_message
(
std
::
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
process
(
duel
*
pduel
);
extern
"C"
DECL_DLLEXPORT
int32
process
(
std
::
intptr_t
pduel
);
extern
"C"
DECL_DLLEXPORT
void
new_card
(
duel
*
pduel
,
uint32
code
,
uint8
owner
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
uint8
position
);
extern
"C"
DECL_DLLEXPORT
void
new_card
(
std
::
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
uint8
position
);
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
duel
*
pduel
,
uint32
code
,
uint8
owner
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
void
new_tag_card
(
std
::
intptr_t
pduel
,
uint32
code
,
uint8
owner
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
duel
*
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
std
::
intptr_t
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
duel
*
pduel
,
uint8
playerid
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
std
::
intptr_t
pduel
,
uint8
playerid
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
duel
*
pduel
,
uint8
playerid
,
uint8
location
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
std
::
intptr_t
pduel
,
uint8
playerid
,
uint8
location
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
duel
*
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
std
::
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
duel
*
pduel
,
int32
value
);
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
std
::
intptr_t
pduel
,
int32
value
);
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
duel
*
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
std
::
intptr_t
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
duel
*
pduel
,
const
char
*
script
,
int32
len
);
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
std
::
intptr_t
pduel
,
const
char
*
script
,
int32
len
);
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
len
);
byte
*
default_script_reader
(
const
char
*
script_name
,
int
*
len
);
uint32
default_card_reader
(
uint32
code
,
card_data
*
data
);
uint32
default_card_reader
(
uint32
code
,
card_data
*
data
);
uint32
default_message_handler
(
void
*
pduel
,
uint32
msg_type
);
uint32
default_message_handler
(
void
*
pduel
,
uint32
msg_type
);
...
...
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