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
3876300f
Commit
3876300f
authored
Dec 18, 2023
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update gframe
parent
e51e41c9
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
125 additions
and
96 deletions
+125
-96
Classes/gframe/client_card.h
Classes/gframe/client_card.h
+2
-14
Classes/gframe/client_field.h
Classes/gframe/client_field.h
+0
-1
Classes/gframe/data_manager.cpp
Classes/gframe/data_manager.cpp
+19
-6
Classes/gframe/data_manager.h
Classes/gframe/data_manager.h
+3
-3
Classes/gframe/duelclient.cpp
Classes/gframe/duelclient.cpp
+7
-6
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+4
-4
Classes/gframe/game.h
Classes/gframe/game.h
+28
-28
Classes/gframe/replay.h
Classes/gframe/replay.h
+0
-2
Classes/gframe/replay_mode.cpp
Classes/gframe/replay_mode.cpp
+4
-4
Classes/gframe/replay_mode.h
Classes/gframe/replay_mode.h
+1
-5
Classes/gframe/single_duel.cpp
Classes/gframe/single_duel.cpp
+4
-4
Classes/gframe/single_duel.h
Classes/gframe/single_duel.h
+1
-1
Classes/gframe/single_mode.cpp
Classes/gframe/single_mode.cpp
+4
-4
Classes/gframe/single_mode.h
Classes/gframe/single_mode.h
+1
-1
Classes/gframe/tag_duel.cpp
Classes/gframe/tag_duel.cpp
+4
-4
Classes/gframe/tag_duel.h
Classes/gframe/tag_duel.h
+1
-1
Classes/ocgcore/card_data.h
Classes/ocgcore/card_data.h
+34
-0
libcore/android/YGOGameOptions.cpp
libcore/android/YGOGameOptions.cpp
+1
-1
libcore/android/bufferio_android.h
libcore/android/bufferio_android.h
+7
-7
No files found.
Classes/gframe/client_card.h
View file @
3876300f
...
...
@@ -2,6 +2,7 @@
#define CLIENT_CARD_H
#include "config.h"
#include "../ocgcore/card_data.h"
#include <vector>
#include <set>
#include <map>
...
...
@@ -9,20 +10,7 @@
namespace
ygo
{
struct
CardData
{
unsigned
int
code
;
unsigned
int
alias
;
unsigned
long
long
setcode
;
unsigned
int
type
;
unsigned
int
level
;
unsigned
int
attribute
;
unsigned
int
race
;
int
attack
;
int
defense
;
unsigned
int
lscale
;
unsigned
int
rscale
;
unsigned
int
link_marker
;
};
using
CardData
=
card_data
;
struct
CardDataC
{
unsigned
int
code
;
unsigned
int
alias
;
...
...
Classes/gframe/client_field.h
View file @
3876300f
...
...
@@ -3,7 +3,6 @@
#include "config.h"
#include "../ocgcore/mtrandom.h"
#include "../ocgcore/ocgapi.h"
#include <vector>
#include <set>
#include <map>
...
...
Classes/gframe/data_manager.cpp
View file @
3876300f
...
...
@@ -150,12 +150,25 @@ bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt, int errNo) {
spmemvfs_env_fini
();
return
false
;
}
bool
DataManager
::
GetData
(
int
code
,
CardData
*
pData
)
{
bool
DataManager
::
GetData
(
unsigned
int
code
,
CardData
*
pData
)
{
auto
cdit
=
_datas
.
find
(
code
);
if
(
cdit
==
_datas
.
end
())
return
false
;
if
(
pData
)
*
pData
=
*
((
CardData
*
)
&
cdit
->
second
);
auto
data
=
cdit
->
second
;
if
(
pData
)
{
pData
->
code
=
data
.
code
;
pData
->
alias
=
data
.
alias
;
pData
->
setcode
=
data
.
setcode
;
pData
->
type
=
data
.
type
;
pData
->
level
=
data
.
level
;
pData
->
attribute
=
data
.
attribute
;
pData
->
race
=
data
.
race
;
pData
->
attack
=
data
.
attack
;
pData
->
defense
=
data
.
defense
;
pData
->
lscale
=
data
.
lscale
;
pData
->
rscale
=
data
.
rscale
;
pData
->
link_marker
=
data
.
link_marker
;
}
return
true
;
}
code_pointer
DataManager
::
GetCodePointer
(
int
code
)
{
...
...
@@ -349,9 +362,9 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) {
BufferIO
::
CopyWStrRef
(
L"[\u2198]"
,
p
,
4
);
return
lmBuffer
;
}
int
DataManager
::
CardReader
(
int
code
,
void
*
pData
)
{
if
(
!
dataManager
.
GetData
(
code
,
(
CardData
*
)
pData
))
memset
(
pData
,
0
,
sizeof
(
CardData
)
);
uint32
DataManager
::
CardReader
(
uint32
code
,
card_data
*
pData
)
{
if
(
!
dataManager
.
GetData
(
code
,
pData
))
pData
->
clear
(
);
return
0
;
}
byte
*
DataManager
::
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
)
{
...
...
Classes/gframe/data_manager.h
View file @
3876300f
...
...
@@ -15,13 +15,13 @@ namespace ygo {
class
DataManager
{
public:
DataManager
()
:
_datas
(
8192
),
_strings
(
8192
)
{}
DataManager
()
:
_datas
(
16384
),
_strings
(
16384
)
{}
bool
LoadDB
(
const
wchar_t
*
wfile
);
bool
LoadStrings
(
const
char
*
file
);
bool
LoadStrings
(
IReadFile
*
reader
);
void
ReadStringConfLine
(
const
char
*
linebuf
);
bool
Error
(
spmemvfs_db_t
*
pDB
,
sqlite3_stmt
*
pStmt
=
0
,
int
err
=
0
);
bool
GetData
(
int
code
,
CardData
*
pData
);
bool
GetData
(
unsigned
int
code
,
CardData
*
pData
);
code_pointer
GetCodePointer
(
int
code
);
bool
GetString
(
int
code
,
CardString
*
pStr
);
const
wchar_t
*
GetName
(
int
code
);
...
...
@@ -57,7 +57,7 @@ public:
static
byte
scriptBuffer
[
0x20000
];
static
const
wchar_t
*
unknown_string
;
static
int
CardReader
(
int
,
void
*
);
static
uint32
CardReader
(
uint32
,
card_data
*
);
static
byte
*
ScriptReaderEx
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReader
(
const
char
*
script_name
,
int
*
slen
);
static
byte
*
ScriptReaderZip
(
const
char
*
script_name
,
int
*
slen
);
...
...
Classes/gframe/duelclient.cpp
View file @
3876300f
...
...
@@ -235,8 +235,8 @@ int DuelClient::ClientThread() {
connect_state
=
0
;
return
0
;
}
void
DuelClient
::
HandleSTOCPacketLan
(
char
*
data
,
unsigned
int
len
)
{
char
*
pdata
=
data
;
void
DuelClient
::
HandleSTOCPacketLan
(
unsigned
char
*
data
,
unsigned
int
len
)
{
unsigned
char
*
pdata
=
data
;
unsigned
char
pktType
=
BufferIO
::
ReadUInt8
(
pdata
);
switch
(
pktType
)
{
case
STOC_GAME_MSG
:
{
...
...
@@ -696,7 +696,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
if
(
mainGame
->
dInfo
.
player_type
<
7
)
mainGame
->
btnLeaveGame
->
setVisible
(
false
);
mainGame
->
CloseGameButtons
();
char
*
prep
=
pdata
;
auto
prep
=
pdata
;
Replay
new_replay
;
memcpy
(
&
new_replay
.
pheader
,
prep
,
sizeof
(
ReplayHeader
));
time_t
starttime
;
...
...
@@ -894,8 +894,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
}
int
DuelClient
::
ClientAnalyze
(
char
*
msg
,
unsigned
int
len
)
{
char
*
pbuf
=
msg
;
// Analyze STOC_GAME_MSG packet
int
DuelClient
::
ClientAnalyze
(
unsigned
char
*
msg
,
unsigned
int
len
)
{
unsigned
char
*
pbuf
=
msg
;
wchar_t
textBuffer
[
256
];
mainGame
->
dInfo
.
curMsg
=
BufferIO
::
ReadUInt8
(
pbuf
);
if
(
mainGame
->
dInfo
.
curMsg
!=
MSG_RETRY
)
{
...
...
@@ -930,7 +931,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
switch
(
mainGame
->
dInfo
.
curMsg
)
{
case
MSG_RETRY
:
{
if
(
last_successful_msg_length
)
{
char
*
p
=
last_successful_msg
;
auto
p
=
last_successful_msg
;
auto
last_msg
=
BufferIO
::
ReadUInt8
(
p
);
int
err_desc
=
1421
;
switch
(
last_msg
)
{
...
...
Classes/gframe/game.cpp
View file @
3876300f
...
...
@@ -181,8 +181,9 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
is_building
=
false
;
menuHandler
.
prev_operation
=
0
;
menuHandler
.
prev_sel
=
-
1
;
memset
(
&
dInfo
,
0
,
sizeof
(
DuelInfo
));
memset
(
chatTiming
,
0
,
sizeof
(
chatTiming
));
for
(
auto
i
:
chatTiming
)
{
i
=
0
;
}
deckManager
.
LoadLFList
(
options
);
driver
=
device
->
getVideoDriver
();
#ifdef _IRR_ANDROID_PLATFORM_
...
...
@@ -1822,8 +1823,7 @@ void Game::SaveConfig() {
void
Game
::
ShowCardInfo
(
int
code
)
{
CardData
cd
;
wchar_t
formatBuffer
[
256
];
if
(
!
dataManager
.
GetData
(
code
,
&
cd
))
memset
(
&
cd
,
0
,
sizeof
(
CardData
));
dataManager
.
GetData
(
code
,
&
cd
);
imgCard
->
setImage
(
imageManager
.
GetTexture
(
code
));
imgCard
->
setScaleImage
(
true
);
if
(
cd
.
alias
!=
0
&&
(
cd
.
alias
-
code
<
CARD_ARTWORK_VERSIONS_OFFSET
||
code
-
cd
.
alias
<
CARD_ARTWORK_VERSIONS_OFFSET
))
...
...
Classes/gframe/game.h
View file @
3876300f
...
...
@@ -73,39 +73,39 @@ struct Config {
};
struct
DuelInfo
{
bool
isStarted
;
bool
isFinished
;
bool
isReplay
;
bool
isReplaySkiping
;
bool
isFirst
;
bool
isTag
;
bool
isSingleMode
;
bool
is_shuffling
;
bool
tag_player
[
2
];
int
lp
[
2
];
int
start_lp
;
bool
isStarted
{
false
};
bool
isFinished
{
false
};
bool
isReplay
{
false
};
bool
isReplaySkiping
{
false
};
bool
isFirst
{
false
};
bool
isTag
{
false
};
bool
isSingleMode
{
false
};
bool
is_shuffling
{
false
};
bool
tag_player
[
2
]{
false
};
bool
isReplaySwapped
{
false
};
int
lp
[
2
]{
0
};
int
start_lp
{
0
};
int
duel_rule
{
0
};
int
turn
{
0
};
short
curMsg
{
0
};
wchar_t
hostname
[
20
]{
0
};
wchar_t
clientname
[
20
]{
0
};
wchar_t
hostname_tag
[
20
]{
0
};
wchar_t
clientname_tag
[
20
]{
0
};
wchar_t
strLP
[
2
][
16
]{
0
};
wchar_t
*
vic_string
{
0
};
unsigned
char
player_type
{
0
};
unsigned
char
time_player
{
0
};
unsigned
short
time_limit
{
0
};
unsigned
short
time_left
[
2
]{
0
};
int
card_count
[
2
];
int
total_attack
[
2
];
int
duel_rule
;
int
turn
;
short
curMsg
;
wchar_t
hostname
[
20
];
wchar_t
clientname
[
20
];
wchar_t
hostname_tag
[
20
];
wchar_t
clientname_tag
[
20
];
wchar_t
strLP
[
2
][
16
];
wchar_t
*
vic_string
;
unsigned
char
player_type
;
unsigned
char
time_player
;
unsigned
short
time_limit
;
unsigned
short
time_left
[
2
];
wchar_t
str_time_left
[
2
][
16
];
video
::
SColor
time_color
[
2
];
wchar_t
str_card_count
[
2
][
16
];
wchar_t
str_total_attack
[
2
][
16
];
video
::
SColor
card_count_color
[
2
];
video
::
SColor
total_attack_color
[
2
];
bool
isReplaySwapped
;
};
struct
BotInfo
{
...
...
Classes/gframe/replay.h
View file @
3876300f
...
...
@@ -2,8 +2,6 @@
#define REPLAY_H
#include "config.h"
#include "../ocgcore/ocgapi.h"
#include <time.h>
namespace
ygo
{
...
...
Classes/gframe/replay_mode.cpp
View file @
3876300f
...
...
@@ -62,9 +62,9 @@ int ReplayMode::ReplayThread() {
mainGame
->
dInfo
.
isSingleMode
=
!!
(
rh
.
flag
&
REPLAY_SINGLE_MODE
);
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
set_script_reader
(
(
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
(
(
card_reader
)
DataManager
::
CardReader
);
set_message_handler
(
(
message_handler
)
MessageHandler
);
set_script_reader
(
DataManager
::
ScriptReaderEx
);
set_card_reader
(
DataManager
::
CardReader
);
set_message_handler
(
ReplayMode
::
MessageHandler
);
if
(
!
StartDuel
())
{
EndDuel
();
return
0
;
...
...
@@ -929,7 +929,7 @@ void ReplayMode::ReplayReload() {
ReloadLocation
(
0
,
LOCATION_REMOVED
,
flag
,
queryBuffer
);
ReloadLocation
(
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
);
}
int
ReplayMode
::
MessageHandler
(
intptr_t
fduel
,
int
type
)
{
uint32
ReplayMode
::
MessageHandler
(
intptr_t
fduel
,
uint32
type
)
{
if
(
!
enable_log
)
return
0
;
char
msgbuf
[
1024
];
...
...
Classes/gframe/replay_mode.h
View file @
3876300f
...
...
@@ -3,11 +3,7 @@
#include <stdint.h>
#include <vector>
#include "config.h"
#include "data_manager.h"
#include "deck_manager.h"
#include "replay.h"
#include "../ocgcore/mtrandom.h"
namespace
ygo
{
...
...
@@ -51,7 +47,7 @@ public:
static
void
ReplayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
ReplayReload
();
static
int
MessageHandler
(
intptr_t
fduel
,
int
type
);
static
uint32
MessageHandler
(
intptr_t
fduel
,
uint32
type
);
};
}
...
...
Classes/gframe/single_duel.cpp
View file @
3876300f
...
...
@@ -428,9 +428,9 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
host_info
.
time_limit
;
set_script_reader
(
(
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
(
(
card_reader
)
DataManager
::
CardReader
);
set_message_handler
(
(
message_handler
)
SingleDuel
::
MessageHandler
);
set_script_reader
(
DataManager
::
ScriptReaderEx
);
set_card_reader
(
DataManager
::
CardReader
);
set_message_handler
(
SingleDuel
::
MessageHandler
);
pduel
=
create_duel
(
duel_seed
);
set_player_info
(
pduel
,
0
,
host_info
.
start_lp
,
host_info
.
start_hand
,
host_info
.
draw_count
);
set_player_info
(
pduel
,
1
,
host_info
.
start_lp
,
host_info
.
start_hand
,
host_info
.
draw_count
);
...
...
@@ -1577,7 +1577,7 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer
::
ReSendToPlayer
(
*
pit
);
}
}
int
SingleDuel
::
MessageHandler
(
intptr_t
fduel
,
int
type
)
{
uint32
SingleDuel
::
MessageHandler
(
intptr_t
fduel
,
uint32
type
)
{
if
(
!
enable_log
)
return
0
;
char
msgbuf
[
1024
];
...
...
Classes/gframe/single_duel.h
View file @
3876300f
...
...
@@ -38,7 +38,7 @@ public:
void
RefreshExtra
(
int
player
,
int
flag
=
0xe81fff
,
int
use_cache
=
1
);
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
int
MessageHandler
(
intptr_t
fduel
,
int
type
);
static
uint32
MessageHandler
(
intptr_t
fduel
,
uint32
type
);
static
void
SingleTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
private:
...
...
Classes/gframe/single_mode.cpp
View file @
3876300f
...
...
@@ -36,9 +36,9 @@ int SingleMode::SinglePlayThread() {
std
::
random_device
rd
;
unsigned
int
seed
=
rd
();
mt19937
rnd
((
uint_fast32_t
)
seed
);
set_script_reader
(
(
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
(
(
card_reader
)
DataManager
::
CardReader
);
set_message_handler
(
(
message_handler
)
MessageHandler
);
set_script_reader
(
DataManager
::
ScriptReaderEx
);
set_card_reader
(
DataManager
::
CardReader
);
set_message_handler
(
SingleMode
::
MessageHandler
);
pduel
=
create_duel
(
rnd
.
rand
());
set_player_info
(
pduel
,
0
,
start_lp
,
start_hand
,
draw_count
);
set_player_info
(
pduel
,
1
,
start_lp
,
start_hand
,
draw_count
);
...
...
@@ -820,7 +820,7 @@ void SingleMode::SinglePlayReload() {
ReloadLocation
(
0
,
LOCATION_REMOVED
,
flag
,
queryBuffer
);
ReloadLocation
(
1
,
LOCATION_REMOVED
,
flag
,
queryBuffer
);
}
int
SingleMode
::
MessageHandler
(
intptr_t
fduel
,
int
type
)
{
uint32
SingleMode
::
MessageHandler
(
intptr_t
fduel
,
uint32
type
)
{
if
(
!
enable_log
)
return
0
;
char
msgbuf
[
1024
];
...
...
Classes/gframe/single_mode.h
View file @
3876300f
...
...
@@ -30,7 +30,7 @@ public:
static
void
SinglePlayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
void
SinglePlayReload
();
static
int
MessageHandler
(
intptr_t
fduel
,
int
type
);
static
uint32
MessageHandler
(
intptr_t
fduel
,
uint32
type
);
protected:
static
Replay
last_replay
;
...
...
Classes/gframe/tag_duel.cpp
View file @
3876300f
...
...
@@ -397,9 +397,9 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
host_info
.
time_limit
;
set_script_reader
(
(
script_reader
)
DataManager
::
ScriptReaderEx
);
set_card_reader
(
(
card_reader
)
DataManager
::
CardReader
);
set_message_handler
(
(
message_handler
)
TagDuel
::
MessageHandler
);
set_script_reader
(
DataManager
::
ScriptReaderEx
);
set_card_reader
(
DataManager
::
CardReader
);
set_message_handler
(
TagDuel
::
MessageHandler
);
pduel
=
create_duel
(
duel_seed
);
set_player_info
(
pduel
,
0
,
host_info
.
start_lp
,
host_info
.
start_hand
,
host_info
.
draw_count
);
set_player_info
(
pduel
,
1
,
host_info
.
start_lp
,
host_info
.
start_hand
,
host_info
.
draw_count
);
...
...
@@ -1690,7 +1690,7 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
}
}
}
int
TagDuel
::
MessageHandler
(
intptr_t
fduel
,
int
type
)
{
uint32
TagDuel
::
MessageHandler
(
intptr_t
fduel
,
uint32
type
)
{
if
(
!
enable_log
)
return
0
;
char
msgbuf
[
1024
];
...
...
Classes/gframe/tag_duel.h
View file @
3876300f
...
...
@@ -38,7 +38,7 @@ public:
void
RefreshExtra
(
int
player
,
int
flag
=
0xe81fff
,
int
use_cache
=
1
);
void
RefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
=
0xf81fff
);
static
int
MessageHandler
(
intptr_t
fduel
,
int
type
);
static
uint32
MessageHandler
(
intptr_t
fduel
,
uint32
type
);
static
void
TagTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
private:
...
...
Classes/ocgcore/card_data.h
0 → 100644
View file @
3876300f
#ifndef CARD_DATA_H_
#define CARD_DATA_H_
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
()
{
code
=
0
;
alias
=
0
;
setcode
=
0
;
type
=
0
;
level
=
0
;
attribute
=
0
;
race
=
0
;
attack
=
0
;
defense
=
0
;
lscale
=
0
;
rscale
=
0
;
link_marker
=
0
;
}
};
#endif
/* CARD_DATA_H_ */
libcore/android/YGOGameOptions.cpp
View file @
3876300f
...
...
@@ -17,7 +17,7 @@ YGOGameOptions::YGOGameOptions(void* data): m_pipAddr(NULL), m_puserName(NULL),
m_phostInfo
(
NULL
){
//read ip addr
char
log
[
128
];
char
*
rawdata
=
(
char
*
)
data
;
unsigned
char
*
rawdata
=
(
unsigned
char
*
)
data
;
int
tmplength
=
::
BufferIO
::
ReadInt32
(
rawdata
);
if
(
tmplength
!=
0
)
{
m_pipAddr
=
new
char
[
tmplength
+
1
];
...
...
libcore/android/bufferio_android.h
View file @
3876300f
...
...
@@ -6,37 +6,37 @@
class
BufferIO
{
public:
inline
static
int
ReadInt32
(
char
*&
p
)
{
inline
static
int
ReadInt32
(
unsigned
char
*&
p
)
{
int
ret
;
memcpy
(
&
ret
,
(
void
*
)
p
,
sizeof
(
int
));
p
+=
4
;
return
ret
;
}
inline
static
short
ReadInt16
(
char
*&
p
)
{
inline
static
short
ReadInt16
(
unsigned
char
*&
p
)
{
short
ret
;
memcpy
(
&
ret
,
(
void
*
)
p
,
sizeof
(
short
));
p
+=
2
;
return
ret
;
}
inline
static
char
ReadInt8
(
char
*&
p
)
{
inline
static
char
ReadInt8
(
unsigned
char
*&
p
)
{
char
*
pRet
=
(
char
*
)
p
;
p
++
;
return
*
pRet
;
}
inline
static
unsigned
char
ReadUInt8
(
char
*&
p
)
{
inline
static
unsigned
char
ReadUInt8
(
unsigned
char
*&
p
)
{
unsigned
char
ret
=
*
(
unsigned
char
*
)
p
;
p
++
;
return
ret
;
}
inline
static
void
WriteInt32
(
char
*&
p
,
int
val
)
{
inline
static
void
WriteInt32
(
unsigned
char
*&
p
,
int
val
)
{
memcpy
((
void
*
)
p
,
&
val
,
sizeof
(
int
));
p
+=
4
;
}
inline
static
void
WriteInt16
(
char
*&
p
,
short
val
)
{
inline
static
void
WriteInt16
(
unsigned
char
*&
p
,
short
val
)
{
memcpy
((
void
*
)
p
,
&
val
,
sizeof
(
short
));
p
+=
2
;
}
inline
static
void
WriteInt8
(
char
*&
p
,
char
val
)
{
inline
static
void
WriteInt8
(
unsigned
char
*&
p
,
char
val
)
{
memcpy
((
void
*
)
p
,
&
val
,
sizeof
(
char
));
p
++
;
}
...
...
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