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
4b25a3bf
Commit
4b25a3bf
authored
May 13, 2024
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update bufferio.h
parent
063d80ec
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
155 additions
and
176 deletions
+155
-176
Classes/gframe/bufferio.h
Classes/gframe/bufferio.h
+9
-18
Classes/gframe/drawing.cpp
Classes/gframe/drawing.cpp
+1
-3
Classes/gframe/replay.cpp
Classes/gframe/replay.cpp
+10
-16
Classes/ocgcore/buffer.h
Classes/ocgcore/buffer.h
+37
-0
Classes/ocgcore/card.cpp
Classes/ocgcore/card.cpp
+67
-87
Classes/ocgcore/duel.cpp
Classes/ocgcore/duel.cpp
+5
-12
Classes/ocgcore/ocgapi.cpp
Classes/ocgcore/ocgapi.cpp
+8
-13
Classes/ocgcore/operations.cpp
Classes/ocgcore/operations.cpp
+2
-2
libcore/android/bufferio_android.h
libcore/android/bufferio_android.h
+16
-25
No files found.
Classes/gframe/bufferio.h
View file @
4b25a3bf
#ifndef BUFFERIO_H
#ifndef BUFFERIO_H
#define BUFFERIO_H
#define BUFFERIO_H
#include <cstdint>
#include "../ocgcore/buffer.h"
class
BufferIO
{
class
BufferIO
{
public:
public:
inline
static
int
ReadInt32
(
unsigned
char
*&
p
)
{
inline
static
int
ReadInt32
(
unsigned
char
*&
p
)
{
int
ret
=
*
(
int
*
)
p
;
return
buffer_read
<
int32_t
>
(
p
);
p
+=
4
;
return
ret
;
}
}
inline
static
short
ReadInt16
(
unsigned
char
*&
p
)
{
inline
static
short
ReadInt16
(
unsigned
char
*&
p
)
{
short
ret
=
*
(
short
*
)
p
;
return
buffer_read
<
int16_t
>
(
p
);
p
+=
2
;
return
ret
;
}
}
inline
static
char
ReadInt8
(
unsigned
char
*&
p
)
{
inline
static
char
ReadInt8
(
unsigned
char
*&
p
)
{
char
ret
=
*
(
char
*
)
p
;
return
buffer_read
<
char
>
(
p
);
p
++
;
return
ret
;
}
}
inline
static
unsigned
char
ReadUInt8
(
unsigned
char
*&
p
)
{
inline
static
unsigned
char
ReadUInt8
(
unsigned
char
*&
p
)
{
unsigned
char
ret
=
*
(
unsigned
char
*
)
p
;
return
buffer_read
<
unsigned
char
>
(
p
);
p
++
;
return
ret
;
}
}
inline
static
void
WriteInt32
(
unsigned
char
*&
p
,
int
val
)
{
inline
static
void
WriteInt32
(
unsigned
char
*&
p
,
int
val
)
{
(
*
(
int
*
)
p
)
=
val
;
buffer_write
<
int32_t
>
(
p
,
val
);
p
+=
4
;
}
}
inline
static
void
WriteInt16
(
unsigned
char
*&
p
,
short
val
)
{
inline
static
void
WriteInt16
(
unsigned
char
*&
p
,
short
val
)
{
(
*
(
short
*
)
p
)
=
val
;
buffer_write
<
int16_t
>
(
p
,
val
);
p
+=
2
;
}
}
inline
static
void
WriteInt8
(
unsigned
char
*&
p
,
char
val
)
{
inline
static
void
WriteInt8
(
unsigned
char
*&
p
,
char
val
)
{
*
p
=
val
;
buffer_write
<
char
>
(
p
,
val
);
p
++
;
}
}
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
inline
static
int
CopyWStr
(
T1
*
src
,
T2
*
pstr
,
int
bufsize
)
{
inline
static
int
CopyWStr
(
T1
*
src
,
T2
*
pstr
,
int
bufsize
)
{
...
...
Classes/gframe/drawing.cpp
View file @
4b25a3bf
...
@@ -1389,9 +1389,7 @@ void Game::DrawDeckBd() {
...
@@ -1389,9 +1389,7 @@ void Game::DrawDeckBd() {
}
}
#endif
#endif
if
(
deckBuilder
.
is_draging
)
{
if
(
deckBuilder
.
is_draging
)
{
DrawThumb
(
deckBuilder
.
draging_pointer
,
DrawThumb
(
deckBuilder
.
draging_pointer
,
position2di
(
deckBuilder
.
dragx
-
22
,
deckBuilder
.
dragy
-
32
),
deckBuilder
.
filterList
);
position2di
(
deckBuilder
.
dragx
-
22
,
deckBuilder
.
dragy
-
32
),
deckBuilder
.
filterList
);
}
}
}
}
}
}
...
...
Classes/gframe/replay.cpp
View file @
4b25a3bf
#include "replay.h"
#include "replay.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
#include "lzma/LzmaLib.h"
#include "lzma/LzmaLib.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -54,7 +52,7 @@ void Replay::WriteData(const void* data, int length, bool flush) {
...
@@ -54,7 +52,7 @@ void Replay::WriteData(const void* data, int length, bool flush) {
return
;
return
;
if
(
length
<
0
||
(
pdata
-
replay_data
)
+
length
>
MAX_REPLAY_SIZE
)
if
(
length
<
0
||
(
pdata
-
replay_data
)
+
length
>
MAX_REPLAY_SIZE
)
return
;
return
;
memcpy
(
pdata
,
data
,
length
);
std
::
memcpy
(
pdata
,
data
,
length
);
pdata
+=
length
;
pdata
+=
length
;
#ifdef _WIN32
#ifdef _WIN32
DWORD
size
;
DWORD
size
;
...
@@ -70,8 +68,7 @@ void Replay::WriteInt32(int data, bool flush) {
...
@@ -70,8 +68,7 @@ void Replay::WriteInt32(int data, bool flush) {
return
;
return
;
if
((
pdata
-
replay_data
)
+
4
>
MAX_REPLAY_SIZE
)
if
((
pdata
-
replay_data
)
+
4
>
MAX_REPLAY_SIZE
)
return
;
return
;
*
((
int
*
)(
pdata
))
=
data
;
BufferIO
::
WriteInt32
(
pdata
,
data
);
pdata
+=
4
;
#ifdef _WIN32
#ifdef _WIN32
DWORD
size
;
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
int
),
&
size
,
NULL
);
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
int
),
&
size
,
NULL
);
...
@@ -86,8 +83,7 @@ void Replay::WriteInt16(short data, bool flush) {
...
@@ -86,8 +83,7 @@ void Replay::WriteInt16(short data, bool flush) {
return
;
return
;
if
((
pdata
-
replay_data
)
+
2
>
MAX_REPLAY_SIZE
)
if
((
pdata
-
replay_data
)
+
2
>
MAX_REPLAY_SIZE
)
return
;
return
;
*
((
short
*
)(
pdata
))
=
data
;
BufferIO
::
WriteInt16
(
pdata
,
data
);
pdata
+=
2
;
#ifdef _WIN32
#ifdef _WIN32
DWORD
size
;
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
short
),
&
size
,
NULL
);
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
short
),
&
size
,
NULL
);
...
@@ -102,8 +98,7 @@ void Replay::WriteInt8(char data, bool flush) {
...
@@ -102,8 +98,7 @@ void Replay::WriteInt8(char data, bool flush) {
return
;
return
;
if
((
pdata
-
replay_data
)
+
1
>
MAX_REPLAY_SIZE
)
if
((
pdata
-
replay_data
)
+
1
>
MAX_REPLAY_SIZE
)
return
;
return
;
*
pdata
=
data
;
BufferIO
::
WriteInt8
(
pdata
,
data
);
pdata
++
;
#ifdef _WIN32
#ifdef _WIN32
DWORD
size
;
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
char
),
&
size
,
NULL
);
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
char
),
&
size
,
NULL
);
...
@@ -266,7 +261,7 @@ bool Replay::ReadNextResponse(unsigned char resp[]) {
...
@@ -266,7 +261,7 @@ bool Replay::ReadNextResponse(unsigned char resp[]) {
int
len
=
*
pdata
++
;
int
len
=
*
pdata
++
;
if
(
len
>
SIZE_RETURN_VALUE
)
if
(
len
>
SIZE_RETURN_VALUE
)
return
false
;
return
false
;
memcpy
(
resp
,
pdata
,
len
);
std
::
memcpy
(
resp
,
pdata
,
len
);
pdata
+=
len
;
pdata
+=
len
;
return
true
;
return
true
;
}
}
...
@@ -280,27 +275,26 @@ void Replay::ReadName(wchar_t* data) {
...
@@ -280,27 +275,26 @@ void Replay::ReadName(wchar_t* data) {
void
Replay
::
ReadData
(
void
*
data
,
int
length
)
{
void
Replay
::
ReadData
(
void
*
data
,
int
length
)
{
if
(
!
is_replaying
)
if
(
!
is_replaying
)
return
;
return
;
memcpy
(
data
,
pdata
,
length
);
std
::
memcpy
(
data
,
pdata
,
length
);
pdata
+=
length
;
pdata
+=
length
;
}
}
int
Replay
::
ReadInt32
()
{
int
Replay
::
ReadInt32
()
{
if
(
!
is_replaying
)
if
(
!
is_replaying
)
return
-
1
;
return
-
1
;
int
ret
=
*
((
int
*
)
pdata
);
int
ret
=
BufferIO
::
ReadInt32
(
pdata
);
pdata
+=
4
;
return
ret
;
return
ret
;
}
}
short
Replay
::
ReadInt16
()
{
short
Replay
::
ReadInt16
()
{
if
(
!
is_replaying
)
if
(
!
is_replaying
)
return
-
1
;
return
-
1
;
short
ret
=
*
((
short
*
)
pdata
);
short
ret
=
BufferIO
::
ReadInt16
(
pdata
);
pdata
+=
2
;
return
ret
;
return
ret
;
}
}
char
Replay
::
ReadInt8
()
{
char
Replay
::
ReadInt8
()
{
if
(
!
is_replaying
)
if
(
!
is_replaying
)
return
-
1
;
return
-
1
;
return
*
pdata
++
;
char
ret
=
BufferIO
::
ReadInt8
(
pdata
);
return
ret
;
}
}
void
Replay
::
Rewind
()
{
void
Replay
::
Rewind
()
{
pdata
=
replay_data
;
pdata
=
replay_data
;
...
...
Classes/ocgcore/buffer.h
0 → 100644
View file @
4b25a3bf
#ifndef BUFFER_H
#define BUFFER_H
#include <cstring>
#include <vector>
inline
void
buffer_read_block
(
unsigned
char
*&
p
,
void
*
dest
,
size_t
size
)
{
std
::
memcpy
(
dest
,
p
,
size
);
p
+=
size
;
}
template
<
typename
T
>
inline
T
buffer_read
(
unsigned
char
*&
p
)
{
T
ret
{};
buffer_read_block
(
p
,
&
ret
,
sizeof
(
T
));
return
ret
;
}
inline
void
buffer_write_block
(
unsigned
char
*&
p
,
const
void
*
src
,
size_t
size
)
{
std
::
memcpy
(
p
,
src
,
size
);
p
+=
size
;
}
template
<
typename
T
>
inline
void
buffer_write
(
unsigned
char
*&
p
,
T
value
)
{
buffer_write_block
(
p
,
&
value
,
sizeof
(
T
));
}
inline
void
vector_write_block
(
std
::
vector
<
unsigned
char
>&
buffer
,
const
void
*
src
,
size_t
size
)
{
const
auto
len
=
buffer
.
size
();
buffer
.
resize
(
len
+
size
);
std
::
memcpy
(
&
buffer
[
len
],
src
,
size
);
}
template
<
typename
T
>
inline
void
vector_write
(
std
::
vector
<
unsigned
char
>&
buffer
,
T
value
)
{
vector_write_block
(
buffer
,
&
value
,
sizeof
(
T
));
}
#endif //BUFFER_H
Classes/ocgcore/card.cpp
View file @
4b25a3bf
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#include "group.h"
#include "group.h"
#include "interpreter.h"
#include "interpreter.h"
#include "ocgapi.h"
#include "ocgapi.h"
#include "buffer.h"
#include <algorithm>
#include <algorithm>
const
std
::
unordered_map
<
uint32
,
uint32
>
card
::
second_code
=
{
const
std
::
unordered_map
<
uint32
,
uint32
>
card
::
second_code
=
{
...
@@ -176,17 +177,16 @@ card::card(duel* pd) {
...
@@ -176,17 +177,16 @@ card::card(duel* pd) {
xyz_materials_previous_count_onfield
=
0
;
xyz_materials_previous_count_onfield
=
0
;
current
.
controler
=
PLAYER_NONE
;
current
.
controler
=
PLAYER_NONE
;
}
}
inline
void
update_cache
(
uint32
&
tdata
,
uint32
&
cache
,
int32
*&
p
,
uint32
&
query_flag
,
const
uint32
flag
)
{
inline
void
update_cache
(
uint32
&
tdata
,
uint32
&
cache
,
byte
*&
p
,
uint32
&
query_flag
,
const
uint32
flag
)
{
if
(
tdata
!=
cache
)
{
if
(
tdata
!=
cache
)
{
cache
=
tdata
;
cache
=
tdata
;
*
p
=
tdata
;
buffer_write
<
uint32_t
>
(
p
,
tdata
);
++
p
;
}
}
else
else
query_flag
&=
~
flag
;
query_flag
&=
~
flag
;
}
}
int32
card
::
get_infos
(
byte
*
buf
,
uint32
query_flag
,
int32
use_cache
)
{
int32
card
::
get_infos
(
byte
*
buf
,
uint32
query_flag
,
int32
use_cache
)
{
int32
*
p
=
(
int32
*
)
buf
;
byte
*
p
=
buf
;
std
::
pair
<
int32
,
int32
>
atk_def
(
-
10
,
-
10
);
std
::
pair
<
int32
,
int32
>
atk_def
(
-
10
,
-
10
);
std
::
pair
<
int32
,
int32
>
base_atk_def
(
-
10
,
-
10
);
std
::
pair
<
int32
,
int32
>
base_atk_def
(
-
10
,
-
10
);
if
((
query_flag
&
QUERY_ATTACK
)
||
(
query_flag
&
QUERY_DEFENSE
))
{
if
((
query_flag
&
QUERY_ATTACK
)
||
(
query_flag
&
QUERY_DEFENSE
))
{
...
@@ -196,15 +196,13 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -196,15 +196,13 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
base_atk_def
=
get_base_atk_def
();
base_atk_def
=
get_base_atk_def
();
}
}
//first 8 bytes: data length, query flag
//first 8 bytes: data length, query flag
p
+=
2
;
p
+=
8
;
if
(
query_flag
&
QUERY_CODE
)
{
if
(
query_flag
&
QUERY_CODE
)
{
*
p
=
data
.
code
;
buffer_write
<
uint32_t
>
(
p
,
data
.
code
);
++
p
;
}
}
if
(
query_flag
&
QUERY_POSITION
)
{
if
(
query_flag
&
QUERY_POSITION
)
{
uint32
tdata
=
get_info_location
();
uint32
tdata
=
get_info_location
();
*
p
=
tdata
;
buffer_write
<
uint32_t
>
(
p
,
tdata
);
++
p
;
if
(
q_cache
.
info_location
!=
tdata
)
{
if
(
q_cache
.
info_location
!=
tdata
)
{
q_cache
.
clear_cache
();
q_cache
.
clear_cache
();
q_cache
.
info_location
=
tdata
;
q_cache
.
info_location
=
tdata
;
...
@@ -213,59 +211,54 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -213,59 +211,54 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
}
}
if
(
!
use_cache
)
{
if
(
!
use_cache
)
{
if
(
query_flag
&
QUERY_ALIAS
)
{
if
(
query_flag
&
QUERY_ALIAS
)
{
*
p
=
get_code
();
uint32
tdata
=
get_code
();
q_cache
.
current_code
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
current_code
=
tdata
;
}
}
if
(
query_flag
&
QUERY_TYPE
)
{
if
(
query_flag
&
QUERY_TYPE
)
{
*
p
=
get_type
();
uint32
tdata
=
get_type
();
q_cache
.
type
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
type
=
tdata
;
}
}
if
(
query_flag
&
QUERY_LEVEL
)
{
if
(
query_flag
&
QUERY_LEVEL
)
{
*
p
=
get_level
();
uint32
tdata
=
get_level
();
q_cache
.
level
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
level
=
tdata
;
}
}
if
(
query_flag
&
QUERY_RANK
)
{
if
(
query_flag
&
QUERY_RANK
)
{
*
p
=
get_rank
();
uint32
tdata
=
get_rank
();
q_cache
.
rank
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
rank
=
tdata
;
}
}
if
(
query_flag
&
QUERY_ATTRIBUTE
)
{
if
(
query_flag
&
QUERY_ATTRIBUTE
)
{
*
p
=
get_attribute
();
uint32
tdata
=
get_attribute
();
q_cache
.
attribute
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
attribute
=
tdata
;
}
}
if
(
query_flag
&
QUERY_RACE
)
{
if
(
query_flag
&
QUERY_RACE
)
{
*
p
=
get_race
();
uint32
tdata
=
get_race
();
q_cache
.
race
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
race
=
tdata
;
}
}
if
(
query_flag
&
QUERY_ATTACK
)
{
if
(
query_flag
&
QUERY_ATTACK
)
{
*
p
=
atk_def
.
first
;
buffer_write
<
int32_t
>
(
p
,
atk_def
.
first
)
;
q_cache
.
attack
=
atk_def
.
first
;
q_cache
.
attack
=
atk_def
.
first
;
++
p
;
}
}
if
(
query_flag
&
QUERY_DEFENSE
)
{
if
(
query_flag
&
QUERY_DEFENSE
)
{
*
p
=
atk_def
.
second
;
buffer_write
<
int32_t
>
(
p
,
atk_def
.
second
)
;
q_cache
.
defense
=
atk_def
.
second
;
q_cache
.
defense
=
atk_def
.
second
;
++
p
;
}
}
if
(
query_flag
&
QUERY_BASE_ATTACK
)
{
if
(
query_flag
&
QUERY_BASE_ATTACK
)
{
*
p
=
base_atk_def
.
first
;
buffer_write
<
int32_t
>
(
p
,
base_atk_def
.
first
)
;
q_cache
.
base_attack
=
base_atk_def
.
first
;
q_cache
.
base_attack
=
base_atk_def
.
first
;
++
p
;
}
}
if
(
query_flag
&
QUERY_BASE_DEFENSE
)
{
if
(
query_flag
&
QUERY_BASE_DEFENSE
)
{
*
p
=
base_atk_def
.
second
;
buffer_write
<
int32_t
>
(
p
,
base_atk_def
.
second
)
;
q_cache
.
base_defense
=
base_atk_def
.
second
;
q_cache
.
base_defense
=
base_atk_def
.
second
;
++
p
;
}
}
if
(
query_flag
&
QUERY_REASON
)
{
if
(
query_flag
&
QUERY_REASON
)
{
*
p
=
current
.
reason
;
buffer_write
<
uint32_t
>
(
p
,
current
.
reason
)
;
q_cache
.
reason
=
current
.
reason
;
q_cache
.
reason
=
current
.
reason
;
++
p
;
}
}
}
}
else
{
else
{
...
@@ -296,8 +289,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -296,8 +289,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
if
((
query_flag
&
QUERY_ATTACK
))
{
if
((
query_flag
&
QUERY_ATTACK
))
{
if
(
atk_def
.
first
!=
q_cache
.
attack
)
{
if
(
atk_def
.
first
!=
q_cache
.
attack
)
{
q_cache
.
attack
=
atk_def
.
first
;
q_cache
.
attack
=
atk_def
.
first
;
*
p
=
atk_def
.
first
;
buffer_write
<
int32_t
>
(
p
,
atk_def
.
first
);
++
p
;
}
}
else
else
query_flag
&=
~
QUERY_ATTACK
;
query_flag
&=
~
QUERY_ATTACK
;
...
@@ -305,8 +297,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -305,8 +297,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
if
((
query_flag
&
QUERY_DEFENSE
))
{
if
((
query_flag
&
QUERY_DEFENSE
))
{
if
(
atk_def
.
second
!=
q_cache
.
defense
)
{
if
(
atk_def
.
second
!=
q_cache
.
defense
)
{
q_cache
.
defense
=
atk_def
.
second
;
q_cache
.
defense
=
atk_def
.
second
;
*
p
=
atk_def
.
second
;
buffer_write
<
int32_t
>
(
p
,
atk_def
.
second
);
++
p
;
}
}
else
else
query_flag
&=
~
QUERY_DEFENSE
;
query_flag
&=
~
QUERY_DEFENSE
;
...
@@ -314,8 +305,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -314,8 +305,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
if
((
query_flag
&
QUERY_BASE_ATTACK
))
{
if
((
query_flag
&
QUERY_BASE_ATTACK
))
{
if
(
base_atk_def
.
first
!=
q_cache
.
base_attack
)
{
if
(
base_atk_def
.
first
!=
q_cache
.
base_attack
)
{
q_cache
.
base_attack
=
base_atk_def
.
first
;
q_cache
.
base_attack
=
base_atk_def
.
first
;
*
p
=
base_atk_def
.
first
;
buffer_write
<
int32_t
>
(
p
,
base_atk_def
.
first
);
++
p
;
}
}
else
else
query_flag
&=
~
QUERY_BASE_ATTACK
;
query_flag
&=
~
QUERY_BASE_ATTACK
;
...
@@ -323,8 +313,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -323,8 +313,7 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
if
((
query_flag
&
QUERY_BASE_DEFENSE
))
{
if
((
query_flag
&
QUERY_BASE_DEFENSE
))
{
if
(
base_atk_def
.
second
!=
q_cache
.
base_defense
)
{
if
(
base_atk_def
.
second
!=
q_cache
.
base_defense
)
{
q_cache
.
base_defense
=
base_atk_def
.
second
;
q_cache
.
base_defense
=
base_atk_def
.
second
;
*
p
=
base_atk_def
.
second
;
buffer_write
<
int32_t
>
(
p
,
base_atk_def
.
second
);
++
p
;
}
}
else
else
query_flag
&=
~
QUERY_BASE_DEFENSE
;
query_flag
&=
~
QUERY_BASE_DEFENSE
;
...
@@ -335,73 +324,68 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -335,73 +324,68 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
}
}
}
}
if
(
query_flag
&
QUERY_REASON_CARD
)
{
if
(
query_flag
&
QUERY_REASON_CARD
)
{
*
p
=
current
.
reason_card
?
current
.
reason_card
->
get_info_location
()
:
0
;
uint32
tdata
=
current
.
reason_card
?
current
.
reason_card
->
get_info_location
()
:
0
;
++
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
}
}
if
(
query_flag
&
QUERY_EQUIP_CARD
)
{
if
(
query_flag
&
QUERY_EQUIP_CARD
)
{
if
(
equiping_target
)
{
if
(
equiping_target
)
{
*
p
=
equiping_target
->
get_info_location
();
uint32
tdata
=
equiping_target
->
get_info_location
();
++
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
}
}
else
else
query_flag
&=
~
QUERY_EQUIP_CARD
;
query_flag
&=
~
QUERY_EQUIP_CARD
;
}
}
if
(
query_flag
&
QUERY_TARGET_CARD
)
{
if
(
query_flag
&
QUERY_TARGET_CARD
)
{
*
p
=
(
int32
)
effect_target_cards
.
size
();
buffer_write
<
int32_t
>
(
p
,
(
int32_t
)
effect_target_cards
.
size
());
++
p
;
for
(
auto
&
pcard
:
effect_target_cards
)
{
for
(
auto
&
pcard
:
effect_target_cards
)
{
*
p
=
pcard
->
get_info_location
();
uint32
tdata
=
pcard
->
get_info_location
();
++
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
}
}
}
}
if
(
query_flag
&
QUERY_OVERLAY_CARD
)
{
if
(
query_flag
&
QUERY_OVERLAY_CARD
)
{
*
p
=
(
int32
)
xyz_materials
.
size
();
buffer_write
<
int32_t
>
(
p
,
(
int32_t
)
xyz_materials
.
size
());
++
p
;
for
(
auto
&
xcard
:
xyz_materials
)
{
for
(
auto
&
xcard
:
xyz_materials
)
{
*
p
=
xcard
->
data
.
code
;
buffer_write
<
uint32_t
>
(
p
,
xcard
->
data
.
code
);
++
p
;
}
}
}
}
if
(
query_flag
&
QUERY_COUNTERS
)
{
if
(
query_flag
&
QUERY_COUNTERS
)
{
*
p
=
(
int32
)
counters
.
size
();
buffer_write
<
int32_t
>
(
p
,
(
int32_t
)
counters
.
size
());
++
p
;
for
(
const
auto
&
cmit
:
counters
)
{
for
(
const
auto
&
cmit
:
counters
)
{
*
p
=
cmit
.
first
+
((
cmit
.
second
[
0
]
+
cmit
.
second
[
1
])
<<
16
);
int32
tdata
=
cmit
.
first
+
((
cmit
.
second
[
0
]
+
cmit
.
second
[
1
])
<<
16
);
++
p
;
buffer_write
<
int32_t
>
(
p
,
tdata
)
;
}
}
}
}
if
(
query_flag
&
QUERY_OWNER
)
{
if
(
query_flag
&
QUERY_OWNER
)
{
*
p
=
owner
;
int32
tdata
=
owner
;
++
p
;
buffer_write
<
int32_t
>
(
p
,
tdata
)
;
}
}
if
(
query_flag
&
QUERY_STATUS
)
{
if
(
query_flag
&
QUERY_STATUS
)
{
uint32
tdata
=
status
&
(
STATUS_DISABLED
|
STATUS_FORBIDDEN
|
STATUS_PROC_COMPLETE
);
uint32
tdata
=
status
&
(
STATUS_DISABLED
|
STATUS_FORBIDDEN
|
STATUS_PROC_COMPLETE
);
if
(
!
use_cache
||
(
tdata
!=
q_cache
.
status
))
{
if
(
!
use_cache
||
(
tdata
!=
q_cache
.
status
))
{
q_cache
.
status
=
tdata
;
q_cache
.
status
=
tdata
;
*
p
=
tdata
;
buffer_write
<
uint32_t
>
(
p
,
tdata
);
++
p
;
}
}
else
else
query_flag
&=
~
QUERY_STATUS
;
query_flag
&=
~
QUERY_STATUS
;
}
}
if
(
!
use_cache
)
{
if
(
!
use_cache
)
{
if
(
query_flag
&
QUERY_LSCALE
)
{
if
(
query_flag
&
QUERY_LSCALE
)
{
*
p
=
get_lscale
();
uint32
tdata
=
get_lscale
();
q_cache
.
lscale
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
lscale
=
tdata
;
}
}
if
(
query_flag
&
QUERY_RSCALE
)
{
if
(
query_flag
&
QUERY_RSCALE
)
{
*
p
=
get_rscale
();
uint32
tdata
=
get_rscale
();
q_cache
.
rscale
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
rscale
=
tdata
;
}
}
if
(
query_flag
&
QUERY_LINK
)
{
if
(
query_flag
&
QUERY_LINK
)
{
*
p
=
get_link
();
uint32
tdata
=
get_link
();
q_cache
.
link
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
link
=
tdata
;
*
p
=
get_link_marker
();
tdata
=
get_link_marker
();
q_cache
.
link_marker
=
*
p
;
buffer_write
<
uint32_t
>
(
p
,
tdata
)
;
++
p
;
q_cache
.
link_marker
=
tdata
;
}
}
}
}
else
{
else
{
...
@@ -418,22 +402,18 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -418,22 +402,18 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
uint32
link_marker
=
get_link_marker
();
uint32
link_marker
=
get_link_marker
();
if
((
link
!=
q_cache
.
link
)
||
(
link_marker
!=
q_cache
.
link_marker
))
{
if
((
link
!=
q_cache
.
link
)
||
(
link_marker
!=
q_cache
.
link_marker
))
{
q_cache
.
link
=
link
;
q_cache
.
link
=
link
;
*
p
=
(
int32
)
link
;
buffer_write
<
uint32_t
>
(
p
,
link
);
++
p
;
q_cache
.
link_marker
=
link_marker
;
q_cache
.
link_marker
=
link_marker
;
*
p
=
(
int32
)
link_marker
;
buffer_write
<
uint32_t
>
(
p
,
link_marker
);
++
p
;
}
}
else
else
query_flag
&=
~
QUERY_LINK
;
query_flag
&=
~
QUERY_LINK
;
}
}
}
}
int32
*
finalize
=
(
int32
*
)
buf
;
byte
*
finalize
=
buf
;
*
finalize
=
(
byte
*
)
p
-
buf
;
buffer_write
<
int32_t
>
(
finalize
,
p
-
buf
);
++
finalize
;
buffer_write
<
uint32_t
>
(
finalize
,
query_flag
);
*
finalize
=
query_flag
;
return
(
int32
)(
p
-
buf
);
++
finalize
;
return
(
byte
*
)
p
-
buf
;
}
}
uint32
card
::
get_info_location
()
{
uint32
card
::
get_info_location
()
{
if
(
overlay_target
)
{
if
(
overlay_target
)
{
...
...
Classes/ocgcore/duel.cpp
View file @
4b25a3bf
...
@@ -13,14 +13,7 @@
...
@@ -13,14 +13,7 @@
#include "effect.h"
#include "effect.h"
#include "group.h"
#include "group.h"
#include "ocgapi.h"
#include "ocgapi.h"
#include "buffer.h"
inline
void
write_buffer_vector
(
std
::
vector
<
byte
>&
buffer
,
const
void
*
data
,
int
size
)
{
if
(
size
>
0
)
{
const
auto
len
=
buffer
.
size
();
buffer
.
resize
(
len
+
size
);
std
::
memcpy
(
&
buffer
[
len
],
data
,
size
);
}
}
duel
::
duel
()
{
duel
::
duel
()
{
lua
=
new
interpreter
(
this
);
lua
=
new
interpreter
(
this
);
...
@@ -125,16 +118,16 @@ void duel::restore_assumes() {
...
@@ -125,16 +118,16 @@ void duel::restore_assumes() {
assumes
.
clear
();
assumes
.
clear
();
}
}
void
duel
::
write_buffer
(
const
void
*
data
,
int
size
)
{
void
duel
::
write_buffer
(
const
void
*
data
,
int
size
)
{
write_buffer_vector
(
message_buffer
,
data
,
size
);
vector_write_block
(
message_buffer
,
data
,
size
);
}
}
void
duel
::
write_buffer32
(
uint32
value
)
{
void
duel
::
write_buffer32
(
uint32
value
)
{
write_buffer
(
&
value
,
sizeof
(
value
)
);
vector_write
<
uint32_t
>
(
message_buffer
,
value
);
}
}
void
duel
::
write_buffer16
(
uint16
value
)
{
void
duel
::
write_buffer16
(
uint16
value
)
{
write_buffer
(
&
value
,
sizeof
(
value
)
);
vector_write
<
uint16_t
>
(
message_buffer
,
value
);
}
}
void
duel
::
write_buffer8
(
uint8
value
)
{
void
duel
::
write_buffer8
(
uint8
value
)
{
write_buffer
(
&
value
,
sizeof
(
value
)
);
vector_write
<
unsigned
char
>
(
message_buffer
,
value
);
}
}
void
duel
::
clear_buffer
()
{
void
duel
::
clear_buffer
()
{
message_buffer
.
clear
();
message_buffer
.
clear
();
...
...
Classes/ocgcore/ocgapi.cpp
View file @
4b25a3bf
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "effect.h"
#include "effect.h"
#include "field.h"
#include "field.h"
#include "interpreter.h"
#include "interpreter.h"
#include "buffer.h"
#include <set>
#include <set>
static
script_reader
sreader
=
default_script_reader
;
static
script_reader
sreader
=
default_script_reader
;
...
@@ -206,7 +207,7 @@ extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8
...
@@ -206,7 +207,7 @@ extern "C" DECL_DLLEXPORT int32 query_card(intptr_t pduel, uint8 playerid, uint8
return
pcard
->
get_infos
(
buf
,
query_flag
,
use_cache
);
return
pcard
->
get_infos
(
buf
,
query_flag
,
use_cache
);
}
}
else
{
else
{
*
((
int32
*
)
buf
)
=
LEN_EMPTY
;
buffer_write
<
int32_t
>
(
buf
,
LEN_EMPTY
)
;
return
LEN_EMPTY
;
return
LEN_EMPTY
;
}
}
}
}
...
@@ -253,8 +254,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
...
@@ -253,8 +254,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
p
+=
clen
;
}
else
{
}
else
{
*
((
int32
*
)
p
)
=
LEN_EMPTY
;
buffer_write
<
int32_t
>
(
p
,
LEN_EMPTY
);
p
+=
LEN_EMPTY
;
}
}
}
}
}
}
...
@@ -264,8 +264,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
...
@@ -264,8 +264,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(intptr_t pduel, uint8 playerid,
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
int32
clen
=
pcard
->
get_infos
(
p
,
query_flag
,
use_cache
);
p
+=
clen
;
p
+=
clen
;
}
else
{
}
else
{
*
((
int32
*
)
p
)
=
LEN_EMPTY
;
buffer_write
<
int32_t
>
(
p
,
LEN_EMPTY
);
p
+=
LEN_EMPTY
;
}
}
}
}
}
}
...
@@ -297,8 +296,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
...
@@ -297,8 +296,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
*
p
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
*
p
++
=
ptduel
->
game_field
->
core
.
duel_rule
;
for
(
int
playerid
=
0
;
playerid
<
2
;
++
playerid
)
{
for
(
int
playerid
=
0
;
playerid
<
2
;
++
playerid
)
{
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
auto
&
player
=
ptduel
->
game_field
->
player
[
playerid
];
*
((
int
*
)
p
)
=
player
.
lp
;
buffer_write
<
int32_t
>
(
p
,
player
.
lp
);
p
+=
4
;
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
for
(
auto
&
pcard
:
player
.
list_mzone
)
{
if
(
pcard
)
{
if
(
pcard
)
{
*
p
++
=
1
;
*
p
++
=
1
;
...
@@ -326,15 +324,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
...
@@ -326,15 +324,12 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(intptr_t pduel, byte* buf) {
*
p
++
=
(
uint8
)
ptduel
->
game_field
->
core
.
current_chain
.
size
();
*
p
++
=
(
uint8
)
ptduel
->
game_field
->
core
.
current_chain
.
size
();
for
(
const
auto
&
ch
:
ptduel
->
game_field
->
core
.
current_chain
)
{
for
(
const
auto
&
ch
:
ptduel
->
game_field
->
core
.
current_chain
)
{
effect
*
peffect
=
ch
.
triggering_effect
;
effect
*
peffect
=
ch
.
triggering_effect
;
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
data
.
code
;
buffer_write
<
uint32_t
>
(
p
,
peffect
->
get_handler
()
->
data
.
code
);
p
+=
4
;
buffer_write
<
uint32_t
>
(
p
,
peffect
->
get_handler
()
->
get_info_location
());
*
((
int
*
)
p
)
=
peffect
->
get_handler
()
->
get_info_location
();
p
+=
4
;
*
p
++
=
ch
.
triggering_controler
;
*
p
++
=
ch
.
triggering_controler
;
*
p
++
=
(
uint8
)
ch
.
triggering_location
;
*
p
++
=
(
uint8
)
ch
.
triggering_location
;
*
p
++
=
ch
.
triggering_sequence
;
*
p
++
=
ch
.
triggering_sequence
;
*
((
int
*
)
p
)
=
peffect
->
description
;
buffer_write
<
uint32_t
>
(
p
,
peffect
->
description
);
p
+=
4
;
}
}
return
(
int32
)(
p
-
buf
);
return
(
int32
)(
p
-
buf
);
}
}
...
...
Classes/ocgcore/operations.cpp
View file @
4b25a3bf
...
@@ -4646,9 +4646,9 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
...
@@ -4646,9 +4646,9 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
target
->
reset
(
resetflag
,
RESET_EVENT
);
target
->
reset
(
resetflag
,
RESET_EVENT
);
target
->
clear_card_target
();
target
->
clear_card_target
();
}
}
if
(
!
(
target
->
current
.
location
&
LOCATION_ONFIELD
))
target
->
clear_relate_effect
();
}
}
if
(
!
(
target
->
current
.
location
&
LOCATION_ONFIELD
))
target
->
clear_relate_effect
();
if
(
ret
==
1
)
if
(
ret
==
1
)
target
->
current
.
reason
&=
~
REASON_TEMPORARY
;
target
->
current
.
reason
&=
~
REASON_TEMPORARY
;
if
(
ret
==
0
&&
location
!=
target
->
current
.
location
if
(
ret
==
0
&&
location
!=
target
->
current
.
location
...
...
libcore/android/bufferio_android.h
View file @
4b25a3bf
#ifndef BUFFERIO_H
#ifndef BUFFERIO_H
#define BUFFERIO_H
#define BUFFERIO_H
#include <
wchar.h
>
#include <
cstdint
>
#include
<string.h>
#include
"../ocgcore/buffer.h"
class
BufferIO
{
class
BufferIO
{
public:
public:
inline
static
int
ReadInt32
(
unsigned
char
*&
p
)
{
inline
static
int
ReadInt32
(
unsigned
char
*&
p
)
{
int
ret
=
*
(
int
*
)
p
;
return
buffer_read
<
int32_t
>
(
p
);
p
+=
4
;
return
ret
;
}
}
inline
static
short
ReadInt16
(
unsigned
char
*&
p
)
{
inline
static
short
ReadInt16
(
unsigned
char
*&
p
)
{
short
ret
=
*
(
short
*
)
p
;
return
buffer_read
<
int16_t
>
(
p
);
p
+=
2
;
return
ret
;
}
}
inline
static
char
ReadInt8
(
unsigned
char
*&
p
)
{
inline
static
char
ReadInt8
(
unsigned
char
*&
p
)
{
char
ret
=
*
(
char
*
)
p
;
return
buffer_read
<
char
>
(
p
);
p
++
;
return
ret
;
}
}
inline
static
unsigned
char
ReadUInt8
(
unsigned
char
*&
p
)
{
inline
static
unsigned
char
ReadUInt8
(
unsigned
char
*&
p
)
{
unsigned
char
ret
=
*
(
unsigned
char
*
)
p
;
return
buffer_read
<
unsigned
char
>
(
p
);
p
++
;
return
ret
;
}
}
inline
static
void
WriteInt32
(
unsigned
char
*&
p
,
int
val
)
{
inline
static
void
WriteInt32
(
unsigned
char
*&
p
,
int
val
)
{
(
*
(
int
*
)
p
)
=
val
;
buffer_write
<
int32_t
>
(
p
,
val
);
p
+=
4
;
}
}
inline
static
void
WriteInt16
(
unsigned
char
*&
p
,
short
val
)
{
inline
static
void
WriteInt16
(
unsigned
char
*&
p
,
short
val
)
{
(
*
(
short
*
)
p
)
=
val
;
buffer_write
<
int16_t
>
(
p
,
val
);
p
+=
2
;
}
}
inline
static
void
WriteInt8
(
unsigned
char
*&
p
,
char
val
)
{
inline
static
void
WriteInt8
(
unsigned
char
*&
p
,
char
val
)
{
*
p
=
val
;
buffer_write
<
char
>
(
p
,
val
);
p
++
;
}
}
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
inline
static
int
CopyWStr
(
T1
*
src
,
T2
*
pstr
,
int
bufsize
)
{
inline
static
int
CopyWStr
(
T1
*
src
,
T2
*
pstr
,
int
bufsize
)
{
int
l
=
0
;
int
l
=
0
;
while
(
src
[
l
]
&&
l
<
bufsize
-
1
)
{
while
(
src
[
l
]
&&
l
<
bufsize
-
1
)
{
pstr
[
l
]
=
src
[
l
];
pstr
[
l
]
=
(
T2
)
src
[
l
];
l
++
;
l
++
;
}
}
pstr
[
l
]
=
0
;
pstr
[
l
]
=
0
;
...
@@ -52,7 +41,7 @@ public:
...
@@ -52,7 +41,7 @@ public:
inline
static
int
CopyWStrRef
(
T1
*
src
,
T2
*&
pstr
,
int
bufsize
)
{
inline
static
int
CopyWStrRef
(
T1
*
src
,
T2
*&
pstr
,
int
bufsize
)
{
int
l
=
0
;
int
l
=
0
;
while
(
src
[
l
]
&&
l
<
bufsize
-
1
)
{
while
(
src
[
l
]
&&
l
<
bufsize
-
1
)
{
pstr
[
l
]
=
src
[
l
];
pstr
[
l
]
=
(
T2
)
src
[
l
];
l
++
;
l
++
;
}
}
pstr
+=
l
;
pstr
+=
l
;
...
@@ -64,7 +53,7 @@ public:
...
@@ -64,7 +53,7 @@ public:
char
*
pstr
=
str
;
char
*
pstr
=
str
;
while
(
*
wsrc
!=
0
)
{
while
(
*
wsrc
!=
0
)
{
if
(
*
wsrc
<
0x80
)
{
if
(
*
wsrc
<
0x80
)
{
*
str
=
*
wsrc
;
*
str
=
(
char
)
*
wsrc
;
++
str
;
++
str
;
}
else
if
(
*
wsrc
<
0x800
)
{
}
else
if
(
*
wsrc
<
0x800
)
{
str
[
0
]
=
((
*
wsrc
>>
6
)
&
0x1f
)
|
0xc0
;
str
[
0
]
=
((
*
wsrc
>>
6
)
&
0x1f
)
|
0xc0
;
...
@@ -112,12 +101,14 @@ public:
...
@@ -112,12 +101,14 @@ public:
return
wp
-
wstr
;
return
wp
-
wstr
;
}
}
static
int
GetVal
(
const
wchar_t
*
pstr
)
{
static
int
GetVal
(
const
wchar_t
*
pstr
)
{
int
ret
=
0
;
unsigned
int
ret
=
0
;
while
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
while
(
*
pstr
>=
L'0'
&&
*
pstr
<=
L'9'
)
{
ret
=
ret
*
10
+
(
*
pstr
-
L'0'
);
ret
=
ret
*
10
+
(
*
pstr
-
L'0'
);
pstr
++
;
pstr
++
;
}
}
return
ret
;
if
(
*
pstr
==
0
)
return
(
int
)
ret
;
return
0
;
}
}
};
};
...
...
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