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
80cca853
Commit
80cca853
authored
Jun 17, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-uint8' of github.com:Fluorohydride/ygopro-core into develop
parents
df8dc6fc
d08afe0a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
84 deletions
+96
-84
common.h
common.h
+1
-1
field.h
field.h
+2
-1
libgroup.cpp
libgroup.cpp
+9
-8
operations.cpp
operations.cpp
+4
-4
playerop.cpp
playerop.cpp
+77
-67
processor.cpp
processor.cpp
+3
-3
No files found.
common.h
View file @
80cca853
...
@@ -31,7 +31,7 @@ typedef signed char int8;
...
@@ -31,7 +31,7 @@ typedef signed char int8;
#define TRUE 1
#define TRUE 1
#define FALSE 0
#define FALSE 0
#define SIZE_MESSAGE_BUFFER 0x2000
#define SIZE_MESSAGE_BUFFER 0x2000
#define SIZE_RETURN_VALUE
128
#define SIZE_RETURN_VALUE
512
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_BUFFER_LEN 0x0fffffff
#define PROCESSOR_FLAG 0xf0000000
#define PROCESSOR_FLAG 0xf0000000
...
...
field.h
View file @
80cca853
...
@@ -160,7 +160,7 @@ constexpr int SIZE_SVALUE = SIZE_RETURN_VALUE / 2;
...
@@ -160,7 +160,7 @@ constexpr int SIZE_SVALUE = SIZE_RETURN_VALUE / 2;
constexpr
int
SIZE_IVALUE
=
SIZE_RETURN_VALUE
/
4
;
constexpr
int
SIZE_IVALUE
=
SIZE_RETURN_VALUE
/
4
;
constexpr
int
SIZE_LVALUE
=
SIZE_RETURN_VALUE
/
8
;
constexpr
int
SIZE_LVALUE
=
SIZE_RETURN_VALUE
/
8
;
union
return_value
{
union
return_value
{
int8
bvalue
[
SIZE_RETURN_VALUE
];
u
int8
bvalue
[
SIZE_RETURN_VALUE
];
int16
svalue
[
SIZE_SVALUE
];
int16
svalue
[
SIZE_SVALUE
];
int32
ivalue
[
SIZE_IVALUE
];
int32
ivalue
[
SIZE_IVALUE
];
int64
lvalue
[
SIZE_LVALUE
];
int64
lvalue
[
SIZE_LVALUE
];
...
@@ -630,6 +630,7 @@ public:
...
@@ -630,6 +630,7 @@ public:
int32
toss_dice
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
uint8
playerid
,
uint8
count1
,
uint8
count2
);
int32
toss_dice
(
uint16
step
,
effect
*
reason_effect
,
uint8
reason_player
,
uint8
playerid
,
uint8
count1
,
uint8
count2
);
int32
rock_paper_scissors
(
uint16
step
,
uint8
repeat
);
int32
rock_paper_scissors
(
uint16
step
,
uint8
repeat
);
bool
check_response
(
int32
vector_size
,
int32
min_len
,
int32
max_len
)
const
;
int32
select_battle_command
(
uint16
step
,
uint8
playerid
);
int32
select_battle_command
(
uint16
step
,
uint8
playerid
);
int32
select_idle_command
(
uint16
step
,
uint8
playerid
);
int32
select_idle_command
(
uint16
step
,
uint8
playerid
);
int32
select_effect_yes_no
(
uint16
step
,
uint8
playerid
,
uint32
description
,
card
*
pcard
);
int32
select_effect_yes_no
(
uint16
step
,
uint8
playerid
,
uint32
description
,
card
*
pcard
);
...
...
libgroup.cpp
View file @
80cca853
...
@@ -328,14 +328,15 @@ int32 scriptlib::group_select_unselect(lua_State *L) {
...
@@ -328,14 +328,15 @@ int32 scriptlib::group_select_unselect(lua_State *L) {
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_UNSELECT_CARD
,
0
,
0
,
0
,
playerid
+
(
cancelable
<<
16
),
min
+
(
max
<<
16
),
finishable
);
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_UNSELECT_CARD
,
0
,
0
,
0
,
playerid
+
(
cancelable
<<
16
),
min
+
(
max
<<
16
),
finishable
);
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
duel
*
pduel
=
(
duel
*
)
ctx
;
duel
*
pduel
=
(
duel
*
)
ctx
;
if
(
pduel
->
game_field
->
returns
.
b
value
[
0
]
==
-
1
)
{
if
(
pduel
->
game_field
->
returns
.
i
value
[
0
]
==
-
1
)
{
lua_pushnil
(
L
);
lua_pushnil
(
L
);
}
else
{
}
else
{
card
*
pcard
;
card
*
pcard
;
if
((
size_t
)
pduel
->
game_field
->
returns
.
bvalue
[
1
]
<
pduel
->
game_field
->
core
.
select_cards
.
size
())
const
int32
index
=
pduel
->
game_field
->
returns
.
bvalue
[
1
];
pcard
=
pduel
->
game_field
->
core
.
select_cards
[
pduel
->
game_field
->
returns
.
bvalue
[
1
]];
if
(
index
<
(
int32
)
pduel
->
game_field
->
core
.
select_cards
.
size
())
pcard
=
pduel
->
game_field
->
core
.
select_cards
[
index
];
else
else
pcard
=
pduel
->
game_field
->
core
.
unselect_cards
[
pduel
->
game_field
->
returns
.
bvalue
[
1
]
-
pduel
->
game_field
->
core
.
select_cards
.
size
()];
pcard
=
pduel
->
game_field
->
core
.
unselect_cards
[
index
-
pduel
->
game_field
->
core
.
select_cards
.
size
()];
interpreter
::
card2value
(
L
,
pcard
);
interpreter
::
card2value
(
L
,
pcard
);
}
}
return
1
;
return
1
;
...
@@ -401,7 +402,7 @@ int32 scriptlib::group_cancelable_select(lua_State *L) {
...
@@ -401,7 +402,7 @@ int32 scriptlib::group_cancelable_select(lua_State *L) {
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_CARD
,
0
,
0
,
0
,
playerid
+
0x10000
,
min
+
(
max
<<
16
));
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_CARD
,
0
,
0
,
0
,
playerid
+
0x10000
,
min
+
(
max
<<
16
));
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
duel
*
pduel
=
(
duel
*
)
ctx
;
duel
*
pduel
=
(
duel
*
)
ctx
;
if
(
pduel
->
game_field
->
returns
.
b
value
[
0
]
==
-
1
)
{
if
(
pduel
->
game_field
->
returns
.
i
value
[
0
]
==
-
1
)
{
lua_pushnil
(
L
);
lua_pushnil
(
L
);
}
else
{
}
else
{
group
*
pgroup
=
pduel
->
new_group
();
group
*
pgroup
=
pduel
->
new_group
();
...
@@ -493,8 +494,8 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
...
@@ -493,8 +494,8 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
min
=
0
;
min
=
0
;
if
(
max
<
min
)
if
(
max
<
min
)
max
=
min
;
max
=
min
;
if
(
max
>
127
)
if
(
max
>
UINT8_MAX
)
return
luaL_error
(
L
,
"Parameter
\"
max
\"
exceeded
127
."
);
return
luaL_error
(
L
,
"Parameter
\"
max
\"
exceeded
255
."
);
int32
extraargs
=
lua_gettop
(
L
)
-
6
;
int32
extraargs
=
lua_gettop
(
L
)
-
6
;
pduel
->
game_field
->
core
.
select_cards
.
assign
(
pgroup
->
container
.
begin
(),
pgroup
->
container
.
end
());
pduel
->
game_field
->
core
.
select_cards
.
assign
(
pgroup
->
container
.
begin
(),
pgroup
->
container
.
end
());
for
(
auto
&
pcard
:
pduel
->
game_field
->
core
.
must_select_cards
)
{
for
(
auto
&
pcard
:
pduel
->
game_field
->
core
.
must_select_cards
)
{
...
@@ -512,7 +513,7 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
...
@@ -512,7 +513,7 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
interpreter
::
group2value
(
L
,
empty_group
);
interpreter
::
group2value
(
L
,
empty_group
);
return
1
;
return
1
;
}
}
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_SUM
,
0
,
0
,
0
,
acc
,
playerid
+
(
min
<<
16
)
+
(
max
<<
24
)
);
pduel
->
game_field
->
add_process
(
PROCESSOR_SELECT_SUM
,
0
,
0
,
0
,
acc
,
playerid
,
min
,
max
);
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
return
lua_yieldk
(
L
,
0
,
(
lua_KContext
)
pduel
,
[](
lua_State
*
L
,
int32
status
,
lua_KContext
ctx
)
{
duel
*
pduel
=
(
duel
*
)
ctx
;
duel
*
pduel
=
(
duel
*
)
ctx
;
group
*
pgroup
=
pduel
->
new_group
();
group
*
pgroup
=
pduel
->
new_group
();
...
...
operations.cpp
View file @
80cca853
...
@@ -5589,7 +5589,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
...
@@ -5589,7 +5589,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
pduel
->
write_buffer8
(
HINT_SELECTMSG
);
pduel
->
write_buffer8
(
HINT_SELECTMSG
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer32
(
512
);
pduel
->
write_buffer32
(
512
);
add_process
(
PROCESSOR_SELECT_SUM
,
0
,
0
,
0
,
lv
,
playerid
+
(
min
<<
16
)
+
(
max
<<
24
)
);
add_process
(
PROCESSOR_SELECT_SUM
,
0
,
0
,
0
,
lv
,
playerid
,
min
,
max
);
return
FALSE
;
return
FALSE
;
}
}
case
8
:
{
case
8
:
{
...
@@ -5644,7 +5644,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
...
@@ -5644,7 +5644,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
pduel
->
write_buffer8
(
HINT_SELECTMSG
);
pduel
->
write_buffer8
(
HINT_SELECTMSG
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer32
(
512
);
pduel
->
write_buffer32
(
512
);
add_process
(
PROCESSOR_SELECT_SUM
,
0
,
0
,
0
,
lv
,
playerid
+
(
min
<<
16
)
+
(
max
<<
24
)
);
add_process
(
PROCESSOR_SELECT_SUM
,
0
,
0
,
0
,
lv
,
playerid
,
min
,
max
);
core
.
units
.
begin
()
->
step
=
7
;
core
.
units
.
begin
()
->
step
=
7
;
return
FALSE
;
return
FALSE
;
}
}
...
@@ -6173,7 +6173,7 @@ int32 field::select_release_cards(int16 step, uint8 playerid, uint8 cancelable,
...
@@ -6173,7 +6173,7 @@ int32 field::select_release_cards(int16 step, uint8 playerid, uint8 cancelable,
}
}
case
7
:
{
case
7
:
{
core
.
select_cards
.
clear
();
core
.
select_cards
.
clear
();
returns
.
bvalue
[
0
]
=
(
int8
)
core
.
operated_set
.
size
();
returns
.
bvalue
[
0
]
=
(
u
int8
)
core
.
operated_set
.
size
();
int32
i
=
0
;
int32
i
=
0
;
for
(
auto
cit
=
core
.
operated_set
.
begin
();
cit
!=
core
.
operated_set
.
end
();
++
cit
,
++
i
)
{
for
(
auto
cit
=
core
.
operated_set
.
begin
();
cit
!=
core
.
operated_set
.
end
();
++
cit
,
++
i
)
{
core
.
select_cards
.
push_back
(
*
cit
);
core
.
select_cards
.
push_back
(
*
cit
);
...
@@ -6374,7 +6374,7 @@ int32 field::select_tribute_cards(int16 step, card* target, uint8 playerid, uint
...
@@ -6374,7 +6374,7 @@ int32 field::select_tribute_cards(int16 step, card* target, uint8 playerid, uint
}
}
case
9
:
{
case
9
:
{
core
.
select_cards
.
clear
();
core
.
select_cards
.
clear
();
returns
.
bvalue
[
0
]
=
(
int8
)
core
.
operated_set
.
size
();
returns
.
bvalue
[
0
]
=
(
u
int8
)
core
.
operated_set
.
size
();
int32
i
=
0
;
int32
i
=
0
;
for
(
auto
cit
=
core
.
operated_set
.
begin
();
cit
!=
core
.
operated_set
.
end
();
++
cit
,
++
i
)
{
for
(
auto
cit
=
core
.
operated_set
.
begin
();
cit
!=
core
.
operated_set
.
end
();
++
cit
,
++
i
)
{
core
.
select_cards
.
push_back
(
*
cit
);
core
.
select_cards
.
push_back
(
*
cit
);
...
...
playerop.cpp
View file @
80cca853
...
@@ -14,6 +14,20 @@
...
@@ -14,6 +14,20 @@
#include <algorithm>
#include <algorithm>
#include <stack>
#include <stack>
bool
field
::
check_response
(
int32
vector_size
,
int32
min_len
,
int32
max_len
)
const
{
const
int32
len
=
returns
.
bvalue
[
0
];
if
(
len
<
min_len
||
len
>
max_len
)
return
false
;
std
::
set
<
uint8
>
index_set
;
for
(
int32
i
=
0
;
i
<
len
;
++
i
)
{
uint8
index
=
returns
.
bvalue
[
1
+
i
];
if
(
index
>=
vector_size
||
index_set
.
count
(
index
))
{
return
false
;
}
index_set
.
insert
(
index
);
}
return
true
;
}
int32
field
::
select_battle_command
(
uint16
step
,
uint8
playerid
)
{
int32
field
::
select_battle_command
(
uint16
step
,
uint8
playerid
)
{
if
(
step
==
0
)
{
if
(
step
==
0
)
{
pduel
->
write_buffer8
(
MSG_SELECT_BATTLECMD
);
pduel
->
write_buffer8
(
MSG_SELECT_BATTLECMD
);
...
@@ -53,11 +67,11 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
...
@@ -53,11 +67,11 @@ int32 field::select_battle_command(uint16 step, uint8 playerid) {
pduel
->
write_buffer8
(
0
);
pduel
->
write_buffer8
(
0
);
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
uint32
t
=
returns
.
ivalue
[
0
]
&
0xffff
;
int32
t
=
(
uint32
)
returns
.
ivalue
[
0
]
&
0xffff
;
uint32
s
=
returns
.
ivalue
[
0
]
>>
16
;
int32
s
=
(
uint32
)
returns
.
ivalue
[
0
]
>>
16
;
if
(
t
<
0
||
t
>
3
||
s
<
0
if
(
t
<
0
||
t
>
3
||
s
<
0
||
(
t
==
0
&&
s
>=
core
.
select_chains
.
size
())
||
(
t
==
0
&&
s
>=
(
int32
)
core
.
select_chains
.
size
())
||
(
t
==
1
&&
s
>=
core
.
attackable_cards
.
size
())
||
(
t
==
1
&&
s
>=
(
int32
)
core
.
attackable_cards
.
size
())
||
(
t
==
2
&&
!
core
.
to_m2
)
||
(
t
==
2
&&
!
core
.
to_m2
)
||
(
t
==
3
&&
!
core
.
to_ep
))
{
||
(
t
==
3
&&
!
core
.
to_ep
))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
...
@@ -140,18 +154,18 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
...
@@ -140,18 +154,18 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel
->
write_buffer8
(
0
);
pduel
->
write_buffer8
(
0
);
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
uint32
t
=
returns
.
ivalue
[
0
]
&
0xffff
;
int32
t
=
(
uint32
)
returns
.
ivalue
[
0
]
&
0xffff
;
uint32
s
=
returns
.
ivalue
[
0
]
>>
16
;
int32
s
=
(
uint32
)
returns
.
ivalue
[
0
]
>>
16
;
if
(
t
<
0
||
t
>
8
||
s
<
0
if
(
t
<
0
||
t
>
8
||
s
<
0
||
(
t
==
0
&&
s
>=
core
.
summonable_cards
.
size
())
||
(
t
==
0
&&
s
>=
(
int32
)
core
.
summonable_cards
.
size
())
||
(
t
==
1
&&
s
>=
core
.
spsummonable_cards
.
size
())
||
(
t
==
1
&&
s
>=
(
int32
)
core
.
spsummonable_cards
.
size
())
||
(
t
==
2
&&
s
>=
core
.
repositionable_cards
.
size
())
||
(
t
==
2
&&
s
>=
(
int32
)
core
.
repositionable_cards
.
size
())
||
(
t
==
3
&&
s
>=
core
.
msetable_cards
.
size
())
||
(
t
==
3
&&
s
>=
(
int32
)
core
.
msetable_cards
.
size
())
||
(
t
==
4
&&
s
>=
core
.
ssetable_cards
.
size
())
||
(
t
==
4
&&
s
>=
(
int32
)
core
.
ssetable_cards
.
size
())
||
(
t
==
5
&&
s
>=
core
.
select_chains
.
size
())
||
(
t
==
5
&&
s
>=
(
int32
)
core
.
select_chains
.
size
())
||
(
t
==
6
&&
(
infos
.
phase
!=
PHASE_MAIN1
||
!
core
.
to_bp
))
||
(
t
==
6
&&
(
infos
.
phase
!=
PHASE_MAIN1
||
!
core
.
to_bp
))
||
(
t
==
7
&&
!
core
.
to_ep
)
||
(
t
==
7
&&
!
core
.
to_ep
)
||
(
t
==
8
&&
!
(
infos
.
can_shuffle
&&
player
[
playerid
].
list_hand
.
size
()
>
1
)))
{
||
(
t
==
8
&&
!
(
infos
.
can_shuffle
&&
(
int32
)
player
[
playerid
].
list_hand
.
size
()
>
1
)))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -230,8 +244,6 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi
...
@@ -230,8 +244,6 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi
std
::
sort
(
core
.
select_cards
.
begin
(),
core
.
select_cards
.
end
(),
card
::
card_operation_sort
);
std
::
sort
(
core
.
select_cards
.
begin
(),
core
.
select_cards
.
end
(),
card
::
card_operation_sort
);
if
(
core
.
select_cards
.
size
()
>
UINT8_MAX
)
if
(
core
.
select_cards
.
size
()
>
UINT8_MAX
)
core
.
select_cards
.
resize
(
UINT8_MAX
);
core
.
select_cards
.
resize
(
UINT8_MAX
);
if
(
max
>
SIZE_RETURN_VALUE
-
1
)
max
=
SIZE_RETURN_VALUE
-
1
;
if
(
max
>
core
.
select_cards
.
size
())
if
(
max
>
core
.
select_cards
.
size
())
max
=
(
uint8
)
core
.
select_cards
.
size
();
max
=
(
uint8
)
core
.
select_cards
.
size
();
if
(
min
>
max
)
if
(
min
>
max
)
...
@@ -256,21 +268,15 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi
...
@@ -256,21 +268,15 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi
}
}
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
if
(
cancelable
&&
returns
.
ivalue
[
0
]
==
-
1
)
if
(
returns
.
ivalue
[
0
]
==
-
1
)
{
return
TRUE
;
if
(
cancelable
)
if
(
returns
.
bvalue
[
0
]
<
min
||
returns
.
bvalue
[
0
]
>
max
)
{
return
TRUE
;
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
std
::
set
<
int8
>
c
;
if
(
!
check_response
(
core
.
select_cards
.
size
(),
min
,
max
))
{
uint8
m
=
(
uint8
)
core
.
select_cards
.
size
();
pduel
->
write_buffer8
(
MSG_RETRY
);
for
(
int32
i
=
0
;
i
<
returns
.
bvalue
[
0
];
++
i
)
{
return
FALSE
;
int8
v
=
returns
.
bvalue
[
i
+
1
];
if
(
v
<
0
||
v
>=
m
||
c
.
count
(
v
))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
}
c
.
insert
(
v
);
}
}
return
TRUE
;
return
TRUE
;
}
}
...
@@ -317,13 +323,7 @@ int32 field::select_unselect_card(uint16 step, uint8 playerid, uint8 cancelable,
...
@@ -317,13 +323,7 @@ int32 field::select_unselect_card(uint16 step, uint8 playerid, uint8 cancelable,
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
if
(
returns
.
bvalue
[
0
]
==
0
||
returns
.
bvalue
[
0
]
>
1
)
{
if
(
!
check_response
(
core
.
select_cards
.
size
()
+
core
.
unselect_cards
.
size
(),
1
,
1
))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
}
int32
m
=
core
.
select_cards
.
size
()
+
core
.
unselect_cards
.
size
();
uint8
v
=
returns
.
bvalue
[
1
];
if
(
v
<
0
||
v
>=
m
)
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -373,8 +373,12 @@ int32 field::select_chain(uint16 step, uint8 playerid, uint8 spe_count, uint8 fo
...
@@ -373,8 +373,12 @@ int32 field::select_chain(uint16 step, uint8 playerid, uint8 spe_count, uint8 fo
}
}
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
if
(
!
forced
&&
returns
.
ivalue
[
0
]
==
-
1
)
if
(
returns
.
ivalue
[
0
]
==
-
1
)
{
return
TRUE
;
if
(
!
forced
)
return
TRUE
;
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
}
if
(
returns
.
ivalue
[
0
]
<
0
||
returns
.
ivalue
[
0
]
>=
(
int32
)
core
.
select_chains
.
size
())
{
if
(
returns
.
ivalue
[
0
]
<
0
||
returns
.
ivalue
[
0
]
>=
(
int32
)
core
.
select_chains
.
size
())
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
...
@@ -386,7 +390,7 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
...
@@ -386,7 +390,7 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
if
(
step
==
0
)
{
if
(
step
==
0
)
{
if
((
playerid
==
1
)
&&
(
core
.
duel_options
&
DUEL_SIMPLE_AI
))
{
if
((
playerid
==
1
)
&&
(
core
.
duel_options
&
DUEL_SIMPLE_AI
))
{
flag
=
~
flag
;
flag
=
~
flag
;
int32
filter
;
u
int32
filter
;
int32
pzone
=
0
;
int32
pzone
=
0
;
if
(
flag
&
0x7f
)
{
if
(
flag
&
0x7f
)
{
returns
.
bvalue
[
0
]
=
1
;
returns
.
bvalue
[
0
]
=
1
;
...
@@ -441,7 +445,8 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
...
@@ -441,7 +445,8 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
}
else
{
}
else
{
uint8
pt
=
0
;
uint8
pt
=
0
;
uint32
selected
=
0
;
uint32
selected
=
0
;
for
(
int8
i
=
0
;
i
<
1
||
i
<
count
;
++
i
)
{
int32
len
=
std
::
max
(
1
,
(
int32
)
count
);
for
(
int32
i
=
0
;
i
<
len
;
++
i
)
{
uint8
p
=
returns
.
bvalue
[
pt
];
uint8
p
=
returns
.
bvalue
[
pt
];
uint8
l
=
returns
.
bvalue
[
pt
+
1
];
uint8
l
=
returns
.
bvalue
[
pt
+
1
];
uint8
s
=
returns
.
bvalue
[
pt
+
2
];
uint8
s
=
returns
.
bvalue
[
pt
+
2
];
...
@@ -453,10 +458,10 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
...
@@ -453,10 +458,10 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
if
(
sel
&
(
0x1
<<
5
))
if
(
sel
&
(
0x1
u
<<
5
))
sel
|=
0x1
<<
(
16
+
6
);
sel
|=
0x1
u
<<
(
16
+
6
);
if
(
sel
&
(
0x1
<<
6
))
if
(
sel
&
(
0x1
u
<<
6
))
sel
|=
0x1
<<
(
16
+
5
);
sel
|=
0x1
u
<<
(
16
+
5
);
selected
|=
sel
;
selected
|=
sel
;
pt
+=
3
;
pt
+=
3
;
}
}
...
@@ -475,11 +480,11 @@ int32 field::select_position(uint16 step, uint8 playerid, uint32 code, uint8 pos
...
@@ -475,11 +480,11 @@ int32 field::select_position(uint16 step, uint8 playerid, uint32 code, uint8 pos
return
TRUE
;
return
TRUE
;
}
}
if
((
playerid
==
1
)
&&
(
core
.
duel_options
&
DUEL_SIMPLE_AI
))
{
if
((
playerid
==
1
)
&&
(
core
.
duel_options
&
DUEL_SIMPLE_AI
))
{
if
(
positions
&
0x4
)
if
(
(
uint32
)
positions
&
0x4
)
returns
.
ivalue
[
0
]
=
0x4
;
returns
.
ivalue
[
0
]
=
0x4
;
else
if
(
positions
&
0x1
)
else
if
(
(
uint32
)
positions
&
0x1
)
returns
.
ivalue
[
0
]
=
0x1
;
returns
.
ivalue
[
0
]
=
0x1
;
else
if
(
positions
&
0x8
)
else
if
(
(
uint32
)
positions
&
0x8
)
returns
.
ivalue
[
0
]
=
0x8
;
returns
.
ivalue
[
0
]
=
0x8
;
else
else
returns
.
ivalue
[
0
]
=
0x2
;
returns
.
ivalue
[
0
]
=
0x2
;
...
@@ -535,17 +540,21 @@ int32 field::select_tribute(uint16 step, uint8 playerid, uint8 cancelable, uint8
...
@@ -535,17 +540,21 @@ int32 field::select_tribute(uint16 step, uint8 playerid, uint8 cancelable, uint8
}
}
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
if
(
cancelable
&&
returns
.
ivalue
[
0
]
==
-
1
)
if
(
returns
.
ivalue
[
0
]
==
-
1
)
{
return
TRUE
;
if
(
cancelable
)
return
TRUE
;
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
}
if
(
returns
.
bvalue
[
0
]
>
max
)
{
if
(
returns
.
bvalue
[
0
]
>
max
)
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
std
::
set
<
int8
>
c
;
std
::
set
<
u
int8
>
c
;
uint8
m
=
(
uint8
)
core
.
select_cards
.
size
(),
tt
=
0
;
int32
m
=
(
int32
)
core
.
select_cards
.
size
(),
tt
=
0
;
for
(
int32
i
=
0
;
i
<
returns
.
bvalue
[
0
];
++
i
)
{
for
(
int32
i
=
0
;
i
<
returns
.
bvalue
[
0
];
++
i
)
{
int8
v
=
returns
.
bvalue
[
i
+
1
];
u
int8
v
=
returns
.
bvalue
[
i
+
1
];
if
(
v
<
0
||
v
>=
m
||
c
.
count
(
v
))
{
if
(
v
>=
m
||
c
.
count
(
v
))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -621,7 +630,7 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
...
@@ -621,7 +630,7 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
}
}
return
TRUE
;
return
TRUE
;
}
}
static
int32
select_sum_check1
(
const
int32
*
oparam
,
int32
size
,
int32
index
,
int32
acc
,
int32
opmin
)
{
static
int32
select_sum_check1
(
const
u
int32
*
oparam
,
int32
size
,
int32
index
,
int32
acc
,
int32
opmin
)
{
if
(
acc
==
0
||
index
==
size
)
if
(
acc
==
0
||
index
==
size
)
return
FALSE
;
return
FALSE
;
int32
o1
=
oparam
[
index
]
&
0xffff
;
int32
o1
=
oparam
[
index
]
&
0xffff
;
...
@@ -650,7 +659,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
...
@@ -650,7 +659,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
if
(
max
<
min
)
if
(
max
<
min
)
max
=
min
;
max
=
min
;
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer8
(
playerid
);
pduel
->
write_buffer32
(
acc
&
0xffff
);
pduel
->
write_buffer32
(
(
uint32
)
acc
&
0xffff
);
pduel
->
write_buffer8
(
min
);
pduel
->
write_buffer8
(
min
);
pduel
->
write_buffer8
(
max
);
pduel
->
write_buffer8
(
max
);
pduel
->
write_buffer8
((
uint8
)
core
.
must_select_cards
.
size
());
pduel
->
write_buffer8
((
uint8
)
core
.
must_select_cards
.
size
());
...
@@ -673,9 +682,11 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
...
@@ -673,9 +682,11 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
std
::
set
<
int32
>
c
;
std
::
set
<
int32
>
c
;
int32
mcount
=
(
int32
)
core
.
must_select_cards
.
size
();
if
(
mcount
>
UINT8_MAX
)
mcount
=
UINT8_MAX
;
if
(
max
)
{
if
(
max
)
{
int32
oparam
[
16
];
uint32
oparam
[
512
]{};
int32
mcount
=
(
int32
)
core
.
must_select_cards
.
size
();
if
(
returns
.
bvalue
[
0
]
<
min
+
mcount
||
returns
.
bvalue
[
0
]
>
max
+
mcount
)
{
if
(
returns
.
bvalue
[
0
]
<
min
+
mcount
||
returns
.
bvalue
[
0
]
>
max
+
mcount
)
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
...
@@ -698,15 +709,14 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
...
@@ -698,15 +709,14 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
}
}
return
TRUE
;
return
TRUE
;
}
else
{
}
else
{
int32
mcount
=
(
int32
)
core
.
must_select_cards
.
size
();
int32
sum
=
0
,
mx
=
0
,
mn
=
0x7fffffff
;
int32
sum
=
0
,
mx
=
0
,
mn
=
0x7fffffff
;
for
(
int32
i
=
0
;
i
<
mcount
;
++
i
)
{
for
(
int32
i
=
0
;
i
<
mcount
;
++
i
)
{
int32
op
=
core
.
must_select_cards
[
i
]
->
sum_param
;
u
int32
op
=
core
.
must_select_cards
[
i
]
->
sum_param
;
int32
o1
=
op
&
0xffff
;
int32
o1
=
op
&
0xffff
;
int32
o2
=
op
>>
16
;
int32
o2
=
op
>>
16
;
int32
ms
=
(
o2
&&
o2
<
o1
)
?
o2
:
o1
;
int32
ms
=
(
o2
&&
o2
<
o1
)
?
o2
:
o1
;
sum
+=
ms
;
sum
+=
ms
;
mx
+=
(
o2
>
o1
)
?
o2
:
o1
;
mx
+=
std
::
max
(
o1
,
o2
)
;
if
(
ms
<
mn
)
if
(
ms
<
mn
)
mn
=
ms
;
mn
=
ms
;
}
}
...
@@ -718,12 +728,12 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
...
@@ -718,12 +728,12 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
return
FALSE
;
return
FALSE
;
}
}
c
.
insert
(
v
);
c
.
insert
(
v
);
int32
op
=
core
.
select_cards
[
v
]
->
sum_param
;
u
int32
op
=
core
.
select_cards
[
v
]
->
sum_param
;
int32
o1
=
op
&
0xffff
;
int32
o1
=
op
&
0xffff
;
int32
o2
=
op
>>
16
;
int32
o2
=
op
>>
16
;
int32
ms
=
(
o2
&&
o2
<
o1
)
?
o2
:
o1
;
int32
ms
=
(
o2
&&
o2
<
o1
)
?
o2
:
o1
;
sum
+=
ms
;
sum
+=
ms
;
mx
+=
(
o2
>
o1
)
?
o2
:
o1
;
mx
+=
std
::
max
(
o1
,
o2
)
;
if
(
ms
<
mn
)
if
(
ms
<
mn
)
mn
=
ms
;
mn
=
ms
;
}
}
...
@@ -740,7 +750,7 @@ int32 field::sort_card(int16 step, uint8 playerid) {
...
@@ -740,7 +750,7 @@ int32 field::sort_card(int16 step, uint8 playerid) {
if
(
step
==
0
)
{
if
(
step
==
0
)
{
returns
.
bvalue
[
0
]
=
0
;
returns
.
bvalue
[
0
]
=
0
;
if
((
playerid
==
1
)
&&
(
core
.
duel_options
&
DUEL_SIMPLE_AI
))
{
if
((
playerid
==
1
)
&&
(
core
.
duel_options
&
DUEL_SIMPLE_AI
))
{
returns
.
bvalue
[
0
]
=
-
1
;
returns
.
bvalue
[
0
]
=
0xff
;
return
TRUE
;
return
TRUE
;
}
}
if
(
core
.
select_cards
.
empty
())
if
(
core
.
select_cards
.
empty
())
...
@@ -758,13 +768,13 @@ int32 field::sort_card(int16 step, uint8 playerid) {
...
@@ -758,13 +768,13 @@ int32 field::sort_card(int16 step, uint8 playerid) {
}
}
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
if
(
returns
.
bvalue
[
0
]
==
-
1
)
if
(
returns
.
bvalue
[
0
]
==
0xff
)
return
TRUE
;
return
TRUE
;
std
::
set
<
int8
>
c
;
std
::
set
<
u
int8
>
c
;
uint8
m
=
(
uint8
)
core
.
select_cards
.
size
();
int32
m
=
(
int32
)
core
.
select_cards
.
size
();
for
(
uint8
i
=
0
;
i
<
m
;
++
i
)
{
for
(
int32
i
=
0
;
i
<
m
;
++
i
)
{
int8
v
=
returns
.
bvalue
[
i
];
u
int8
v
=
returns
.
bvalue
[
i
];
if
(
v
<
0
||
v
>=
m
||
c
.
count
(
v
))
{
if
(
v
>=
m
||
c
.
count
(
v
))
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
return
FALSE
;
return
FALSE
;
}
}
...
...
processor.cpp
View file @
80cca853
...
@@ -175,7 +175,7 @@ uint32 field::process() {
...
@@ -175,7 +175,7 @@ uint32 field::process() {
}
}
}
}
case
PROCESSOR_SELECT_SUM
:
{
case
PROCESSOR_SELECT_SUM
:
{
if
(
select_with_sum_limit
(
it
->
step
,
it
->
arg2
&
0xffff
,
it
->
arg1
,
(
it
->
arg2
>>
16
)
&
0xff
,
(
it
->
arg2
>>
24
)
&
0xff
))
{
if
(
select_with_sum_limit
(
it
->
step
,
it
->
arg2
,
it
->
arg1
,
it
->
arg3
,
it
->
arg4
))
{
core
.
units
.
pop_front
();
core
.
units
.
pop_front
();
return
pduel
->
message_buffer
.
size
();
return
pduel
->
message_buffer
.
size
();
}
else
{
}
else
{
...
@@ -674,12 +674,12 @@ uint32 field::process() {
...
@@ -674,12 +674,12 @@ uint32 field::process() {
add_process
(
PROCESSOR_SORT_CARD
,
0
,
0
,
0
,
sort_player
,
0
);
add_process
(
PROCESSOR_SORT_CARD
,
0
,
0
,
0
,
sort_player
,
0
);
++
it
->
step
;
++
it
->
step
;
}
else
{
}
else
{
if
(
returns
.
bvalue
[
0
]
!=
-
1
)
{
if
(
returns
.
bvalue
[
0
]
!=
0xff
)
{
card
*
tc
[
16
];
card
*
tc
[
16
];
for
(
i
=
0
;
i
<
count
;
++
i
)
for
(
i
=
0
;
i
<
count
;
++
i
)
player
[
target_player
].
list_main
.
pop_back
();
player
[
target_player
].
list_main
.
pop_back
();
for
(
i
=
0
;
i
<
count
;
++
i
)
for
(
i
=
0
;
i
<
count
;
++
i
)
tc
[
(
uint8
)
returns
.
bvalue
[
i
]]
=
core
.
select_cards
[
i
];
tc
[
returns
.
bvalue
[
i
]]
=
core
.
select_cards
[
i
];
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
player
[
target_player
].
list_main
.
push_back
(
tc
[
count
-
i
-
1
]);
player
[
target_player
].
list_main
.
push_back
(
tc
[
count
-
i
-
1
]);
tc
[
count
-
i
-
1
]
->
current
.
sequence
=
(
uint8
)
player
[
target_player
].
list_main
.
size
()
-
1
;
tc
[
count
-
i
-
1
]
->
current
.
sequence
=
(
uint8
)
player
[
target_player
].
list_main
.
size
()
-
1
;
...
...
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