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
9810e1b2
Commit
9810e1b2
authored
Aug 22, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync ocgcore
parent
6b911e9d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
80 additions
and
114 deletions
+80
-114
Classes/ocgcore/card.cpp
Classes/ocgcore/card.cpp
+3
-0
Classes/ocgcore/common.h
Classes/ocgcore/common.h
+8
-8
Classes/ocgcore/duel.cpp
Classes/ocgcore/duel.cpp
+6
-1
Classes/ocgcore/duel.h
Classes/ocgcore/duel.h
+1
-1
Classes/ocgcore/effectset.h
Classes/ocgcore/effectset.h
+10
-13
Classes/ocgcore/field.cpp
Classes/ocgcore/field.cpp
+4
-7
Classes/ocgcore/mtrandom.h
Classes/ocgcore/mtrandom.h
+47
-84
Classes/ocgcore/operations.cpp
Classes/ocgcore/operations.cpp
+1
-0
No files found.
Classes/ocgcore/card.cpp
View file @
9810e1b2
...
...
@@ -1641,6 +1641,9 @@ int32 card::add_effect(effect* peffect) {
}
if
(
indexer
.
find
(
peffect
)
!=
indexer
.
end
())
return
0
;
if
(
peffect
->
type
&
EFFECT_TYPE_SINGLE
&&
!
peffect
->
is_flag
(
EFFECT_FLAG_SINGLE_RANGE
)
&&
peffect
->
owner
==
this
&&
get_status
(
STATUS_DISABLED
)
&&
(
peffect
->
reset_flag
&
RESET_DISABLE
))
return
0
;
card_set
check_target
=
{
this
};
effect_container
::
iterator
eit
;
if
(
peffect
->
type
&
EFFECT_TYPE_SINGLE
)
{
...
...
Classes/ocgcore/common.h
View file @
9810e1b2
...
...
@@ -218,14 +218,14 @@ struct card_sort {
#define QUERY_LINK 0x800000
//Link markers
#define LINK_MARKER_BOTTOM_LEFT 0001
#define LINK_MARKER_BOTTOM 0002
#define LINK_MARKER_BOTTOM_RIGHT 0004
#define LINK_MARKER_LEFT 0
010
#define LINK_MARKER_RIGHT 0
04
0
#define LINK_MARKER_TOP_LEFT 0
10
0
#define LINK_MARKER_TOP 0
20
0
#define LINK_MARKER_TOP_RIGHT 0
4
00
#define LINK_MARKER_BOTTOM_LEFT 0
x
001
#define LINK_MARKER_BOTTOM 0
x
002
#define LINK_MARKER_BOTTOM_RIGHT 0
x
004
#define LINK_MARKER_LEFT 0
x008
#define LINK_MARKER_RIGHT 0
x02
0
#define LINK_MARKER_TOP_LEFT 0
x04
0
#define LINK_MARKER_TOP 0
x08
0
#define LINK_MARKER_TOP_RIGHT 0
x1
00
//Messages
#define MSG_RETRY 1
...
...
Classes/ocgcore/duel.cpp
View file @
9810e1b2
...
...
@@ -139,5 +139,10 @@ void duel::set_responseb(byte* resp) {
std
::
memcpy
(
game_field
->
returns
.
bvalue
,
resp
,
64
);
}
int32
duel
::
get_next_integer
(
int32
l
,
int32
h
)
{
return
(
int32
)
(
random
.
real
()
*
(
h
-
l
+
1
))
+
l
;
if
(
game_field
->
core
.
duel_options
&
DUEL_OLD_REPLAY
)
{
return
random
.
get_random_integer_old
(
l
,
h
);
}
else
{
return
random
.
get_random_integer
(
l
,
h
);
}
}
Classes/ocgcore/duel.h
View file @
9810e1b2
...
...
@@ -28,7 +28,7 @@ public:
byte
*
bufferp
;
interpreter
*
lua
;
field
*
game_field
;
mt
random
random
;
mt
19937
random
;
std
::
unordered_set
<
card
*>
cards
;
std
::
unordered_set
<
card
*>
assumes
;
std
::
unordered_set
<
group
*>
groups
;
...
...
Classes/ocgcore/effectset.h
View file @
9810e1b2
...
...
@@ -70,50 +70,47 @@ private:
};
struct
effect_set_v
{
effect_set_v
()
:
count
(
0
)
{}
effect_set_v
()
{}
void
add_item
(
effect
*
peffect
)
{
container
.
push_back
(
peffect
);
count
++
;
}
void
remove_item
(
int
index
)
{
if
(
index
>=
count
)
if
(
index
>=
(
int
)
container
.
size
()
)
return
;
container
.
erase
(
container
.
begin
()
+
index
);
count
--
;
}
void
clear
()
{
container
.
clear
();
count
=
0
;
}
int
size
()
const
{
return
count
;
return
(
int
)
container
.
size
()
;
}
void
sort
()
{
int
count
=
(
int
)
container
.
size
();
if
(
count
<
2
)
return
;
std
::
sort
(
container
.
begin
(),
container
.
begin
()
+
count
,
effect_sort_id
);
}
effect
*
const
&
get_last
()
const
{
return
container
[
count
-
1
]
;
return
container
.
back
()
;
}
effect
*&
get_last
()
{
return
container
[
count
-
1
]
;
return
container
.
back
()
;
}
effect
*
const
&
operator
[]
(
int
index
)
const
{
return
container
[
index
]
;
return
container
.
at
(
index
)
;
}
effect
*&
operator
[]
(
int
index
)
{
return
container
[
index
]
;
return
container
.
at
(
index
)
;
}
effect
*
const
&
at
(
int
index
)
const
{
return
container
[
index
]
;
return
container
.
at
(
index
)
;
}
effect
*&
at
(
int
index
)
{
return
container
[
index
]
;
return
container
.
at
(
index
)
;
}
private:
std
::
vector
<
effect
*>
container
;
int
count
;
};
#endif //EFFECTSET_H_
Classes/ocgcore/field.cpp
View file @
9810e1b2
...
...
@@ -950,13 +950,10 @@ void field::shuffle(uint8 playerid, uint8 location) {
if
(
location
==
LOCATION_EXTRA
)
s
=
s
-
player
[
playerid
].
extra_p_count
;
if
(
s
>
1
)
{
uint32
i
=
0
,
r
;
for
(
i
=
0
;
i
<
s
-
1
;
++
i
)
{
r
=
pduel
->
get_next_integer
(
i
,
s
-
1
);
card
*
t
=
svector
[
i
];
svector
[
i
]
=
svector
[
r
];
svector
[
r
]
=
t
;
}
if
(
core
.
duel_options
&
DUEL_OLD_REPLAY
)
pduel
->
random
.
shuffle_vector_old
(
svector
);
else
pduel
->
random
.
shuffle_vector
(
svector
);
reset_sequence
(
playerid
,
location
);
}
}
...
...
Classes/ocgcore/mtrandom.h
View file @
9810e1b2
...
...
@@ -8,99 +8,62 @@
#ifndef MTRANDOM_H_
#define MTRANDOM_H_
//Mersenne Twister
class
mtrandom
{
#include <random>
class
mt19937
{
public:
mtrandom
()
:
left
(
1
)
{
init
();
}
explicit
mtrandom
(
unsigned
int
seed
)
:
left
(
1
)
{
init
(
seed
);
}
mtrandom
(
unsigned
int
*
init_key
,
int
key_length
)
:
left
(
1
)
{
int
i
=
1
,
j
=
0
;
int
k
=
N
>
key_length
?
N
:
key_length
;
init
();
for
(;
k
;
--
k
)
{
state
[
i
]
=
(
state
[
i
]
^
((
state
[
i
-
1
]
^
(
state
[
i
-
1
]
>>
30
))
*
1664525UL
))
+
init_key
[
j
]
+
j
;
// non linear
state
[
i
]
&=
4294967295UL
;
++
i
;
++
j
;
if
(
i
>=
N
)
{
state
[
0
]
=
state
[
N
-
1
];
i
=
1
;
}
if
(
j
>=
key_length
)
j
=
0
;
}
for
(
k
=
N
-
1
;
k
;
--
k
)
{
state
[
i
]
=
(
state
[
i
]
^
((
state
[
i
-
1
]
^
(
state
[
i
-
1
]
>>
30
))
*
1566083941UL
))
-
i
;
state
[
i
]
&=
4294967295UL
;
++
i
;
if
(
i
>=
N
)
{
state
[
0
]
=
state
[
N
-
1
];
i
=
1
;
}
}
state
[
0
]
=
2147483648UL
;
}
void
reset
(
unsigned
int
rs
)
{
init
(
rs
);
next_state
();
mt19937
()
:
rng
(),
rand_max
((
rng
.
max
)())
{}
explicit
mt19937
(
unsigned
int
seed
)
:
rng
(
seed
),
rand_max
((
rng
.
max
)())
{}
// mersenne_twister_engine
void
reset
(
unsigned
int
seed
)
{
rng
.
seed
(
seed
);
}
unsigned
int
rand
()
{
unsigned
int
y
;
if
(
0
==
--
left
)
next_state
();
y
=
*
next
++
;
y
^=
(
y
>>
11
);
y
^=
(
y
<<
7
)
&
0x9d2c5680UL
;
y
^=
(
y
<<
15
)
&
0xefc60000UL
;
y
^=
(
y
>>
18
);
return
y
;
return
rng
();
}
double
real
()
{
return
(
double
)
rand
()
/
0xffffffffUL
;
}
double
res53
()
{
unsigned
int
a
=
rand
()
>>
5
,
b
=
rand
()
>>
6
;
return
(
a
*
67108864.0
+
b
)
/
9007199254740992.0
;
}
void
init
(
unsigned
int
seed
=
19650218UL
)
{
state
[
0
]
=
seed
&
4294967295UL
;
for
(
int
j
=
1
;
j
<
N
;
++
j
)
{
state
[
j
]
=
(
1812433253UL
*
(
state
[
j
-
1
]
^
(
state
[
j
-
1
]
>>
30
))
+
j
);
state
[
j
]
&=
4294967295UL
;
// for >32 bit machines
// uniform_int_distribution
int
get_random_integer
(
int
l
,
int
h
)
{
unsigned
int
range
=
(
unsigned
int
)(
h
-
l
+
1
);
unsigned
int
secureMax
=
rand_max
-
rand_max
%
range
;
unsigned
int
x
;
do
{
x
=
rng
();
}
while
(
x
>=
secureMax
);
return
(
int
)(
l
+
x
%
range
);
}
int
get_random_integer_old
(
int
l
,
int
h
)
{
int
result
=
(
int
)((
double
)
rng
()
/
rand_max
*
(
h
-
l
+
1
))
+
l
;
if
(
result
>
h
)
result
=
h
;
return
result
;
}
// Fisher-Yates shuffle
template
<
typename
T
>
void
shuffle_vector
(
std
::
vector
<
T
>&
v
)
{
int
n
=
(
int
)
v
.
size
();
for
(
int
i
=
0
;
i
<
n
-
1
;
++
i
)
{
int
r
=
get_random_integer
(
i
,
n
-
1
);
std
::
swap
(
v
[
i
],
v
[
r
]);
}
private:
void
next_state
()
{
unsigned
int
*
p
=
state
;
int
i
;
for
(
i
=
N
-
M
+
1
;
--
i
;
++
p
)
*
p
=
(
p
[
M
]
^
twist
(
p
[
0
],
p
[
1
]));
for
(
i
=
M
;
--
i
;
++
p
)
*
p
=
(
p
[
M
-
N
]
^
twist
(
p
[
0
],
p
[
1
]));
*
p
=
p
[
M
-
N
]
^
twist
(
p
[
0
],
state
[
0
]);
left
=
N
;
next
=
state
;
}
unsigned
int
mixbits
(
unsigned
int
u
,
unsigned
int
v
)
const
{
return
(
u
&
2147483648UL
)
|
(
v
&
2147483647UL
);
template
<
typename
T
>
void
shuffle_vector_old
(
std
::
vector
<
T
>&
v
)
{
int
n
=
(
int
)
v
.
size
();
for
(
int
i
=
0
;
i
<
n
-
1
;
++
i
)
{
int
r
=
get_random_integer_old
(
i
,
n
-
1
);
std
::
swap
(
v
[
i
],
v
[
r
]);
}
unsigned
int
twist
(
unsigned
int
u
,
unsigned
int
v
)
const
{
return
((
mixbits
(
u
,
v
)
>>
1
)
^
(
v
&
1UL
?
2567483615UL
:
0UL
));
}
static
const
int
N
=
624
,
M
=
397
;
unsigned
int
state
[
N
];
unsigned
int
left
;
unsigned
int
*
next
;
private:
std
::
mt19937
rng
;
const
unsigned
int
rand_max
;
};
#endif
/* MTRANDOM_H_ */
Classes/ocgcore/operations.cpp
View file @
9810e1b2
...
...
@@ -194,6 +194,7 @@ void field::special_summon_complete(effect* reason_effect, uint8 reason_player)
group
*
ng
=
pduel
->
new_group
();
ng
->
container
.
swap
(
core
.
special_summoning
);
ng
->
is_readonly
=
TRUE
;
core
.
hint_timing
[
reason_player
]
|=
TIMING_SPSUMMON
;
add_process
(
PROCESSOR_SPSUMMON
,
1
,
reason_effect
,
ng
,
reason_player
,
0
);
}
void
field
::
destroy
(
card_set
*
targets
,
effect
*
reason_effect
,
uint32
reason
,
uint32
reason_player
,
uint32
playerid
,
uint32
destination
,
uint32
sequence
)
{
...
...
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