Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
fallenstardust
YGOMobile
Commits
e51e41c9
Commit
e51e41c9
authored
Dec 18, 2023
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync ocgcore
parent
6741fa48
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
89 deletions
+95
-89
Classes/ocgcore/card.cpp
Classes/ocgcore/card.cpp
+21
-5
Classes/ocgcore/card.h
Classes/ocgcore/card.h
+20
-34
Classes/ocgcore/common.h
Classes/ocgcore/common.h
+2
-2
Classes/ocgcore/duel.cpp
Classes/ocgcore/duel.cpp
+1
-3
Classes/ocgcore/field.cpp
Classes/ocgcore/field.cpp
+27
-27
Classes/ocgcore/ocgapi.cpp
Classes/ocgcore/ocgapi.cpp
+20
-18
Classes/ocgcore/ocgapi.h
Classes/ocgcore/ocgapi.h
+4
-0
No files found.
Classes/ocgcore/card.cpp
View file @
e51e41c9
...
...
@@ -50,6 +50,25 @@ void card_state::init_state() {
reason
=
0xffffffff
;
reason_player
=
0xff
;
}
void
query_cache
::
clear_cache
()
{
info_location
=
UINT32_MAX
;
current_code
=
UINT32_MAX
;
type
=
UINT32_MAX
;
level
=
UINT32_MAX
;
rank
=
UINT32_MAX
;
link
=
UINT32_MAX
;
attribute
=
UINT32_MAX
;
race
=
UINT32_MAX
;
attack
=
-
1
;
defense
=
-
1
;
base_attack
=
-
1
;
base_defense
=
-
1
;
reason
=
UINT32_MAX
;
status
=
UINT32_MAX
;
lscale
=
UINT32_MAX
;
rscale
=
UINT32_MAX
;
link_marker
=
UINT32_MAX
;
}
bool
card
::
card_operation_sort
(
card
*
c1
,
card
*
c2
)
{
duel
*
pduel
=
c1
->
pduel
;
int32
cp1
=
c1
->
overlay_target
?
c1
->
overlay_target
->
current
.
controler
:
c1
->
current
.
controler
;
...
...
@@ -89,9 +108,6 @@ uint32 card::attacker_map::findcard(card* pcard) {
else
return
it
->
second
.
second
;
}
void
card_data
::
clear
()
{
std
::
memset
(
this
,
0
,
sizeof
(
card_data
));
}
card
::
card
(
duel
*
pd
)
{
ref_handle
=
0
;
pduel
=
pd
;
...
...
@@ -105,7 +121,6 @@ card::card(duel* pd) {
direct_attackable
=
0
;
summon_info
=
0
;
status
=
0
;
std
::
memset
(
&
q_cache
,
0xff
,
sizeof
(
query_cache
));
equiping_target
=
0
;
pre_equip_target
=
0
;
overlay_target
=
0
;
...
...
@@ -141,6 +156,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
if
((
query_flag
&
QUERY_BASE_ATTACK
)
||
(
query_flag
&
QUERY_BASE_DEFENSE
))
{
base_atk_def
=
get_base_atk_def
();
}
//first 8 bytes: data length, query flag
p
+=
2
;
if
(
query_flag
&
QUERY_CODE
)
{
*
p
=
data
.
code
;
...
...
@@ -151,7 +167,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
*
p
=
tdata
;
++
p
;
if
(
q_cache
.
info_location
!=
tdata
)
{
std
::
memset
(
&
q_cache
,
0xff
,
sizeof
(
query_cache
)
);
q_cache
.
clear_cache
(
);
q_cache
.
info_location
=
tdata
;
use_cache
=
0
;
}
...
...
Classes/ocgcore/card.h
View file @
e51e41c9
...
...
@@ -10,6 +10,7 @@
#include "common.h"
#include "effectset.h"
#include "card_data.h"
#include <set>
#include <map>
#include <unordered_set>
...
...
@@ -22,23 +23,6 @@ class effect;
class
group
;
struct
chain
;
struct
card_data
{
uint32
code
{
0
};
uint32
alias
{
0
};
uint64
setcode
{
0
};
uint32
type
{
0
};
uint32
level
{
0
};
uint32
attribute
{
0
};
uint32
race
{
0
};
int32
attack
{
0
};
int32
defense
{
0
};
uint32
lscale
{
0
};
uint32
rscale
{
0
};
uint32
link_marker
{
0
};
void
clear
();
};
struct
card_state
{
uint32
code
{
0
};
uint32
code2
{
0
};
...
...
@@ -76,23 +60,25 @@ struct card_state {
};
struct
query_cache
{
uint32
info_location
;
uint32
current_code
;
uint32
type
;
uint32
level
;
uint32
rank
;
uint32
link
;
uint32
attribute
;
uint32
race
;
int32
attack
;
int32
defense
;
int32
base_attack
;
int32
base_defense
;
uint32
reason
;
int32
status
;
uint32
lscale
;
uint32
rscale
;
uint32
link_marker
;
uint32
info_location
{
UINT32_MAX
};
uint32
current_code
{
UINT32_MAX
};
uint32
type
{
UINT32_MAX
};
uint32
level
{
UINT32_MAX
};
uint32
rank
{
UINT32_MAX
};
uint32
link
{
UINT32_MAX
};
uint32
attribute
{
UINT32_MAX
};
uint32
race
{
UINT32_MAX
};
int32
attack
{
-
1
};
int32
defense
{
-
1
};
int32
base_attack
{
-
1
};
int32
base_defense
{
-
1
};
uint32
reason
{
UINT32_MAX
};
uint32
status
{
UINT32_MAX
};
uint32
lscale
{
UINT32_MAX
};
uint32
rscale
{
UINT32_MAX
};
uint32
link_marker
{
UINT32_MAX
};
void
clear_cache
();
};
struct
material_info
{
...
...
Classes/ocgcore/common.h
View file @
e51e41c9
...
...
@@ -29,8 +29,8 @@ typedef signed char int8;
#define OPERATION_CANCELED -1
#define TRUE 1
#define FALSE 0
#define
MESSAGE_BUFFER_SIZE
0x2000
#define
QUERY_BUFFER_SIZE
0x4000
#define
SIZE_MESSAGE_BUFFER
0x2000
#define
SIZE_QUERY_BUFFER
0x4000
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_FLAG 0xf0000000
...
...
Classes/ocgcore/duel.cpp
View file @
e51e41c9
...
...
@@ -17,7 +17,7 @@ duel::duel() {
lua
=
new
interpreter
(
this
);
game_field
=
new
field
(
this
);
game_field
->
temp_card
=
new_card
(
0
);
message_buffer
.
reserve
(
MESSAGE_BUFFER_SIZE
);
message_buffer
.
reserve
(
SIZE_MESSAGE_BUFFER
);
}
duel
::~
duel
()
{
for
(
auto
&
pcard
:
cards
)
...
...
@@ -48,8 +48,6 @@ card* duel::new_card(uint32 code) {
cards
.
insert
(
pcard
);
if
(
code
)
::
read_card
(
code
,
&
(
pcard
->
data
));
else
pcard
->
data
.
clear
();
pcard
->
data
.
code
=
code
;
lua
->
register_card
(
pcard
);
return
pcard
;
...
...
Classes/ocgcore/field.cpp
View file @
e51e41c9
...
...
@@ -66,11 +66,11 @@ field::field(duel* pduel) {
player
[
i
].
tag_extra_p_count
=
0
;
player
[
i
].
list_mzone
.
resize
(
7
,
0
);
player
[
i
].
list_szone
.
resize
(
8
,
0
);
player
[
i
].
list_main
.
reserve
(
45
);
player
[
i
].
list_hand
.
reserve
(
1
0
);
player
[
i
].
list_grave
.
reserve
(
30
);
player
[
i
].
list_remove
.
reserve
(
30
);
player
[
i
].
list_extra
.
reserve
(
15
);
player
[
i
].
list_main
.
reserve
(
60
);
player
[
i
].
list_hand
.
reserve
(
6
0
);
player
[
i
].
list_grave
.
reserve
(
75
);
player
[
i
].
list_remove
.
reserve
(
75
);
player
[
i
].
list_extra
.
reserve
(
30
);
}
returns
=
{
0
};
temp_card
=
nullptr
;
...
...
@@ -200,9 +200,9 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence
pcard
->
unique_fieldid
=
UINT_MAX
;
pcard
->
turnid
=
infos
.
turn_id
;
if
(
location
==
LOCATION_MZONE
)
player
[
playerid
].
used_location
|=
1
<<
sequence
;
player
[
playerid
].
used_location
|=
0x
1
<<
sequence
;
if
(
location
==
LOCATION_SZONE
)
player
[
playerid
].
used_location
|=
256
<<
sequence
;
player
[
playerid
].
used_location
|=
0x100
<<
sequence
;
}
void
field
::
remove_card
(
card
*
pcard
)
{
if
(
pcard
->
current
.
controler
==
PLAYER_NONE
||
pcard
->
current
.
location
==
0
)
...
...
@@ -243,9 +243,9 @@ void field::remove_card(card* pcard) {
}
pcard
->
cancel_field_effect
();
if
(
pcard
->
current
.
location
==
LOCATION_MZONE
)
player
[
playerid
].
used_location
&=
~
(
1
<<
pcard
->
current
.
sequence
);
player
[
playerid
].
used_location
&=
~
(
0x
1
<<
pcard
->
current
.
sequence
);
if
(
pcard
->
current
.
location
==
LOCATION_SZONE
)
player
[
playerid
].
used_location
&=
~
(
256
<<
pcard
->
current
.
sequence
);
player
[
playerid
].
used_location
&=
~
(
0x100
<<
pcard
->
current
.
sequence
);
pcard
->
previous
.
controler
=
pcard
->
current
.
controler
;
pcard
->
previous
.
location
=
pcard
->
current
.
location
;
pcard
->
previous
.
sequence
=
pcard
->
current
.
sequence
;
...
...
@@ -321,9 +321,9 @@ void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequenc
pcard
->
current
.
sequence
=
sequence
;
}
else
{
player
[
preplayer
].
list_szone
[
presequence
]
=
0
;
player
[
preplayer
].
used_location
&=
~
(
256
<<
presequence
);
player
[
preplayer
].
used_location
&=
~
(
0x100
<<
presequence
);
player
[
playerid
].
list_szone
[
sequence
]
=
pcard
;
player
[
playerid
].
used_location
|=
256
<<
sequence
;
player
[
playerid
].
used_location
|=
0x100
<<
sequence
;
pcard
->
current
.
controler
=
playerid
;
pcard
->
current
.
sequence
=
sequence
;
}
...
...
@@ -436,13 +436,13 @@ void field::swap_card(card* pcard1, card* pcard2, uint8 new_sequence1, uint8 new
player
[
p1
].
used_location
|=
1
<<
new_sequence1
;
}
else
if
(
l1
==
LOCATION_SZONE
)
{
player
[
p1
].
list_szone
[
s1
]
=
0
;
player
[
p1
].
used_location
&=
~
(
256
<<
s1
);
player
[
p1
].
used_location
&=
~
(
0x100
<<
s1
);
player
[
p2
].
list_szone
[
s2
]
=
0
;
player
[
p2
].
used_location
&=
~
(
256
<<
s2
);
player
[
p2
].
used_location
&=
~
(
0x100
<<
s2
);
player
[
p2
].
list_szone
[
new_sequence2
]
=
pcard1
;
player
[
p2
].
used_location
|=
256
<<
new_sequence2
;
player
[
p2
].
used_location
|=
0x100
<<
new_sequence2
;
player
[
p1
].
list_szone
[
new_sequence1
]
=
pcard2
;
player
[
p1
].
used_location
|=
256
<<
new_sequence1
;
player
[
p1
].
used_location
|=
0x100
<<
new_sequence1
;
}
}
else
{
remove_card
(
pcard1
);
...
...
@@ -513,21 +513,21 @@ card* field::get_field_card(uint32 playerid, uint32 location, uint32 sequence) {
if
(
sequence
<
player
[
playerid
].
list_mzone
.
size
())
return
player
[
playerid
].
list_mzone
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_SZONE
:
{
if
(
sequence
<
player
[
playerid
].
list_szone
.
size
())
return
player
[
playerid
].
list_szone
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_FZONE
:
{
if
(
sequence
==
0
)
return
player
[
playerid
].
list_szone
[
5
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_PZONE
:
{
...
...
@@ -538,46 +538,46 @@ card* field::get_field_card(uint32 playerid, uint32 location, uint32 sequence) {
card
*
pcard
=
player
[
playerid
].
list_szone
[
core
.
duel_rule
>=
4
?
4
:
7
];
return
pcard
&&
pcard
->
current
.
pzone
?
pcard
:
0
;
}
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_DECK
:
{
if
(
sequence
<
player
[
playerid
].
list_main
.
size
())
return
player
[
playerid
].
list_main
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_HAND
:
{
if
(
sequence
<
player
[
playerid
].
list_hand
.
size
())
return
player
[
playerid
].
list_hand
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_GRAVE
:
{
if
(
sequence
<
player
[
playerid
].
list_grave
.
size
())
return
player
[
playerid
].
list_grave
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_REMOVED
:
{
if
(
sequence
<
player
[
playerid
].
list_remove
.
size
())
return
player
[
playerid
].
list_remove
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
case
LOCATION_EXTRA
:
{
if
(
sequence
<
player
[
playerid
].
list_extra
.
size
())
return
player
[
playerid
].
list_extra
[
sequence
];
else
return
0
;
return
nullptr
;
break
;
}
}
return
0
;
return
nullptr
;
}
int32
field
::
is_location_useable
(
uint32
playerid
,
uint32
location
,
uint32
sequence
)
{
uint32
flag
=
player
[
playerid
].
disabled_location
|
player
[
playerid
].
used_location
;
...
...
@@ -1694,7 +1694,7 @@ effect* field::is_player_affected_by_effect(uint8 playerid, uint32 code) {
if
(
peffect
->
is_target_player
(
playerid
)
&&
peffect
->
is_available
())
return
peffect
;
}
return
0
;
return
nullptr
;
}
int32
field
::
get_release_list
(
uint8
playerid
,
card_set
*
release_list
,
card_set
*
ex_list
,
card_set
*
ex_list_oneof
,
int32
use_con
,
int32
use_hand
,
int32
fun
,
int32
exarg
,
card
*
exc
,
group
*
exg
)
{
uint32
rcount
=
0
;
...
...
@@ -2195,7 +2195,7 @@ effect* field::check_unique_onfield(card* pcard, uint8 controler, uint8 location
cset
.
insert
(
pcard
);
if
(
cset
.
size
()
>=
2
)
return
pcard
->
unique_effect
;
return
0
;
return
nullptr
;
}
int32
field
::
check_spsummon_once
(
card
*
pcard
,
uint8
playerid
)
{
if
(
pcard
->
spsummon_code
==
0
)
...
...
Classes/ocgcore/ocgapi.cpp
View file @
e51e41c9
...
...
@@ -177,26 +177,28 @@ extern "C" DECL_DLLEXPORT void new_tag_card(intptr_t pduel, uint32 code, uint8 o
}
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
intptr_t
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
)
{
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
LEN_FAIL
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
card
*
pcard
=
0
;
card
*
pcard
=
nullptr
;
location
&=
0x7f
;
if
(
location
&
LOCATION_ONFIELD
)
pcard
=
ptduel
->
game_field
->
get_field_card
(
playerid
,
location
,
sequence
);
else
{
field
::
card_vector
*
lst
=
0
;
if
(
location
==
LOCATION_HAND
)
field
::
card_vector
*
lst
=
nullptr
;
if
(
location
==
LOCATION_HAND
)
lst
=
&
ptduel
->
game_field
->
player
[
playerid
].
list_hand
;
else
if
(
location
==
LOCATION_GRAVE
)
else
if
(
location
==
LOCATION_GRAVE
)
lst
=
&
ptduel
->
game_field
->
player
[
playerid
].
list_grave
;
else
if
(
location
==
LOCATION_REMOVED
)
else
if
(
location
==
LOCATION_REMOVED
)
lst
=
&
ptduel
->
game_field
->
player
[
playerid
].
list_remove
;
else
if
(
location
==
LOCATION_EXTRA
)
else
if
(
location
==
LOCATION_EXTRA
)
lst
=
&
ptduel
->
game_field
->
player
[
playerid
].
list_extra
;
else
if
(
location
==
LOCATION_DECK
)
else
if
(
location
==
LOCATION_DECK
)
lst
=
&
ptduel
->
game_field
->
player
[
playerid
].
list_main
;
if
(
!
lst
||
sequence
>=
lst
->
size
())
pcard
=
0
;
else
return
LEN_FAIL
;
if
(
sequence
>=
(
int32
)
lst
->
size
())
pcard
=
nullptr
;
else
pcard
=
(
*
lst
)[
sequence
];
}
...
...
@@ -204,8 +206,8 @@ 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
)
=
4
;
return
4
;
*
((
int32
*
)
buf
)
=
LEN_EMPTY
;
return
LEN_EMPTY
;
}
}
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
intptr_t
pduel
,
uint8
playerid
,
uint8
location
)
{
...
...
@@ -241,7 +243,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(intptr_t pduel, uint8 playerid
}
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
intptr_t
pduel
,
uint8
playerid
,
uint8
location
,
uint32
query_flag
,
byte
*
buf
,
int32
use_cache
)
{
if
(
playerid
!=
0
&&
playerid
!=
1
)
return
0
;
return
LEN_FAIL
;
duel
*
ptduel
=
(
duel
*
)
pduel
;
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
byte
*
p
=
buf
;
...
...
@@ -251,8 +253,8 @@ 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
)
=
4
;
p
+=
4
;
*
((
int32
*
)
p
)
=
LEN_EMPTY
;
p
+=
LEN_EMPTY
;
}
}
}
...
...
@@ -262,8 +264,8 @@ 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
)
=
4
;
p
+=
4
;
*
((
int32
*
)
p
)
=
LEN_EMPTY
;
p
+=
LEN_EMPTY
;
}
}
}
...
...
@@ -280,7 +282,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
else
if
(
location
==
LOCATION_DECK
)
lst
=
&
player
.
list_main
;
else
return
0
;
return
LEN_FAIL
;
for
(
auto
&
pcard
:
*
lst
)
{
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
...
...
Classes/ocgcore/ocgapi.h
View file @
e51e41c9
...
...
@@ -16,6 +16,10 @@
#define DECL_DLLEXPORT
#endif
#define LEN_FAIL 0
#define LEN_EMPTY 4
#define LEN_HEADER 8
class
card
;
struct
card_data
;
struct
card_info
;
...
...
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