Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
xiaoye
ygopro
Commits
58a947b2
Commit
58a947b2
authored
Jun 16, 2025
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro
into server
parents
3d49930e
97af9bb3
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
62 additions
and
61 deletions
+62
-61
.github/workflows/build.yml
.github/workflows/build.yml
+6
-6
gframe/CGUITTFont.cpp
gframe/CGUITTFont.cpp
+1
-0
gframe/client_field.cpp
gframe/client_field.cpp
+2
-3
gframe/client_field.h
gframe/client_field.h
+2
-2
gframe/data_manager.cpp
gframe/data_manager.cpp
+1
-2
gframe/deck_con.cpp
gframe/deck_con.cpp
+10
-4
gframe/deck_con.h
gframe/deck_con.h
+3
-2
gframe/drawing.cpp
gframe/drawing.cpp
+0
-1
gframe/duelclient.cpp
gframe/duelclient.cpp
+14
-8
gframe/duelclient.h
gframe/duelclient.h
+4
-4
gframe/event_handler.cpp
gframe/event_handler.cpp
+0
-2
gframe/netserver.cpp
gframe/netserver.cpp
+5
-3
gframe/netserver.h
gframe/netserver.h
+1
-2
gframe/network.h
gframe/network.h
+0
-11
gframe/premake5.lua
gframe/premake5.lua
+3
-3
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+1
-1
gframe/single_mode.cpp
gframe/single_mode.cpp
+3
-3
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+4
-2
gframe/sound_manager.h
gframe/sound_manager.h
+2
-2
No files found.
.github/workflows/build.yml
View file @
58a947b2
...
@@ -110,12 +110,12 @@ jobs:
...
@@ -110,12 +110,12 @@ jobs:
id
:
sqlite
id
:
sqlite
uses
:
mercury233/action-cache-download-file@v1.0.0
uses
:
mercury233/action-cache-download-file@v1.0.0
with
:
with
:
url
:
https://www.sqlite.org/2025/sqlite-amalgamation-3
49
0100.zip
url
:
https://www.sqlite.org/2025/sqlite-amalgamation-3
50
0100.zip
-
name
:
Extract sqlite
-
name
:
Extract sqlite
run
:
|
run
:
|
7z x ${{ steps.sqlite.outputs.filepath }}
7z x ${{ steps.sqlite.outputs.filepath }}
move sqlite-amalgamation-3
49
0100 sqlite3
move sqlite-amalgamation-3
50
0100 sqlite3
-
name
:
Download miniaudio
-
name
:
Download miniaudio
if
:
matrix.audiolib == 'miniaudio'
if
:
matrix.audiolib == 'miniaudio'
...
@@ -357,13 +357,13 @@ jobs:
...
@@ -357,13 +357,13 @@ jobs:
id
:
sqlite
id
:
sqlite
uses
:
mercury233/action-cache-download-file@v1.0.0
uses
:
mercury233/action-cache-download-file@v1.0.0
with
:
with
:
url
:
https://www.sqlite.org/2025/sqlite-amalgamation-3
49
0100.zip
url
:
https://www.sqlite.org/2025/sqlite-amalgamation-3
50
0100.zip
-
name
:
Extract sqlite
-
name
:
Extract sqlite
if
:
matrix.static-link ==
true
if
:
matrix.static-link ==
true
run
:
|
run
:
|
7z x ${{ steps.sqlite.outputs.filepath }}
7z x ${{ steps.sqlite.outputs.filepath }}
mv sqlite-amalgamation-3
49
0100 sqlite3
mv sqlite-amalgamation-3
50
0100 sqlite3
-
name
:
Download miniaudio
-
name
:
Download miniaudio
run
:
|
run
:
|
...
@@ -583,13 +583,13 @@ jobs:
...
@@ -583,13 +583,13 @@ jobs:
id
:
sqlite
id
:
sqlite
uses
:
mercury233/action-cache-download-file@v1.0.0
uses
:
mercury233/action-cache-download-file@v1.0.0
with
:
with
:
url
:
https://www.sqlite.org/2025/sqlite-amalgamation-3
49
0100.zip
url
:
https://www.sqlite.org/2025/sqlite-amalgamation-3
50
0100.zip
-
name
:
Extract sqlite
-
name
:
Extract sqlite
if
:
matrix.static-link ==
true
if
:
matrix.static-link ==
true
run
:
|
run
:
|
7z x ${{ steps.sqlite.outputs.filepath }}
7z x ${{ steps.sqlite.outputs.filepath }}
mv sqlite-amalgamation-3
49
0100 sqlite3
mv sqlite-amalgamation-3
50
0100 sqlite3
-
name
:
Download miniaudio
-
name
:
Download miniaudio
run
:
|
run
:
|
...
...
gframe/CGUITTFont.cpp
View file @
58a947b2
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
john@suckerfreegames.com
john@suckerfreegames.com
*/
*/
#define _IRR_STATIC_LIB_
#include <irrlicht.h>
#include <irrlicht.h>
#include "CGUITTFont.h"
#include "CGUITTFont.h"
...
...
gframe/client_field.cpp
View file @
58a947b2
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
#include "image_manager.h"
#include "image_manager.h"
#include "game.h"
#include "game.h"
#include "materials.h"
#include "materials.h"
#include "../ocgcore/common.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -15,7 +14,7 @@ ClientField::ClientField() {
...
@@ -15,7 +14,7 @@ ClientField::ClientField() {
mzone
[
p
].
resize
(
7
,
0
);
mzone
[
p
].
resize
(
7
,
0
);
szone
[
p
].
resize
(
8
,
0
);
szone
[
p
].
resize
(
8
,
0
);
}
}
rnd
.
reset
((
uint_fast32_t
)
std
::
random_device
()());
rnd
.
seed
(
std
::
random_device
()());
}
}
ClientField
::~
ClientField
()
{
ClientField
::~
ClientField
()
{
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
...
@@ -413,7 +412,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
...
@@ -413,7 +412,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
}
}
}
}
if
(
has_card_in_grave
)
{
if
(
has_card_in_grave
)
{
rnd
.
shuffle_vector
(
selectable_cards
);
std
::
shuffle
(
selectable_cards
.
begin
(),
selectable_cards
.
end
(),
rnd
);
}
}
}
}
int
startpos
;
int
startpos
;
...
...
gframe/client_field.h
View file @
58a947b2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#define CLIENT_FIELD_H
#define CLIENT_FIELD_H
#include "config.h"
#include "config.h"
#include
"../ocgcore/mtrandom.h"
#include
<random>
#include <vector>
#include <vector>
#include <set>
#include <set>
#include <map>
#include <map>
...
@@ -90,7 +90,7 @@ public:
...
@@ -90,7 +90,7 @@ public:
bool
cant_check_grave
{
false
};
bool
cant_check_grave
{
false
};
bool
tag_surrender
{
false
};
bool
tag_surrender
{
false
};
bool
tag_teammate_surrender
{
false
};
bool
tag_teammate_surrender
{
false
};
mt19937
rnd
;
std
::
mt19937
rnd
;
ClientField
();
ClientField
();
~
ClientField
();
~
ClientField
();
...
...
gframe/data_manager.cpp
View file @
58a947b2
...
@@ -189,8 +189,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
...
@@ -189,8 +189,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
}
}
#endif //YGOPRO_SERVER_MODE
#endif //YGOPRO_SERVER_MODE
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
errmsg
[
0
]
=
'\0'
;
std
::
snprintf
(
errmsg
,
sizeof
errmsg
,
"%s"
,
sqlite3_errmsg
(
pDB
));
std
::
strncat
(
errmsg
,
sqlite3_errmsg
(
pDB
),
sizeof
errmsg
-
1
);
if
(
pStmt
)
if
(
pStmt
)
sqlite3_finalize
(
pStmt
);
sqlite3_finalize
(
pStmt
);
return
false
;
return
false
;
...
...
gframe/deck_con.cpp
View file @
58a947b2
#include <array>
#include "config.h"
#include "config.h"
#include "deck_con.h"
#include "deck_con.h"
#include "myfilesystem.h"
#include "myfilesystem.h"
#include "data_manager.h"
#include "deck_manager.h"
#include "image_manager.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "sound_manager.h"
#include "game.h"
#include "game.h"
...
@@ -54,6 +53,14 @@ static inline void load_current_deck(irr::gui::IGUIComboBox* cbCategory, irr::gu
...
@@ -54,6 +53,14 @@ static inline void load_current_deck(irr::gui::IGUIComboBox* cbCategory, irr::gu
deckManager
.
LoadCurrentDeck
(
cbCategory
->
getSelected
(),
cbCategory
->
getText
(),
cbDeck
->
getText
());
deckManager
.
LoadCurrentDeck
(
cbCategory
->
getSelected
(),
cbCategory
->
getText
(),
cbDeck
->
getText
());
}
}
DeckBuilder
::
DeckBuilder
()
{
std
::
random_device
rd
;
std
::
array
<
uint32_t
,
8
>
seed
{};
for
(
auto
&
x
:
seed
)
x
=
rd
();
std
::
seed_seq
seq
(
seed
.
begin
(),
seed
.
end
());
rnd
.
seed
(
seq
);
}
void
DeckBuilder
::
Initialize
()
{
void
DeckBuilder
::
Initialize
()
{
mainGame
->
is_building
=
true
;
mainGame
->
is_building
=
true
;
mainGame
->
is_siding
=
false
;
mainGame
->
is_siding
=
false
;
...
@@ -82,7 +89,6 @@ void DeckBuilder::Initialize() {
...
@@ -82,7 +89,6 @@ void DeckBuilder::Initialize() {
filterList
=
&
deckManager
.
_lfList
.
back
();
filterList
=
&
deckManager
.
_lfList
.
back
();
}
}
ClearSearch
();
ClearSearch
();
rnd
.
reset
((
uint_fast32_t
)
std
::
time
(
nullptr
));
mouse_pos
.
set
(
0
,
0
);
mouse_pos
.
set
(
0
,
0
);
hovered_code
=
0
;
hovered_code
=
0
;
hovered_pos
=
0
;
hovered_pos
=
0
;
...
@@ -175,7 +181,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -175,7 +181,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_SHUFFLE_DECK
:
{
case
BUTTON_SHUFFLE_DECK
:
{
rnd
.
shuffle_vector
(
deckManager
.
current_deck
.
main
);
std
::
shuffle
(
deckManager
.
current_deck
.
main
.
begin
(),
deckManager
.
current_deck
.
main
.
end
(),
rnd
);
break
;
break
;
}
}
case
BUTTON_SAVE_DECK
:
{
case
BUTTON_SAVE_DECK
:
{
...
...
gframe/deck_con.h
View file @
58a947b2
...
@@ -3,15 +3,16 @@
...
@@ -3,15 +3,16 @@
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <random>
#include <irrlicht.h>
#include <irrlicht.h>
#include "data_manager.h"
#include "data_manager.h"
#include "deck_manager.h"
#include "deck_manager.h"
#include "../ocgcore/mtrandom.h"
namespace
ygo
{
namespace
ygo
{
class
DeckBuilder
:
public
irr
::
IEventReceiver
{
class
DeckBuilder
:
public
irr
::
IEventReceiver
{
public:
public:
DeckBuilder
();
bool
OnEvent
(
const
irr
::
SEvent
&
event
)
override
;
bool
OnEvent
(
const
irr
::
SEvent
&
event
)
override
;
void
Initialize
();
void
Initialize
();
void
Terminate
();
void
Terminate
();
...
@@ -80,7 +81,7 @@ public:
...
@@ -80,7 +81,7 @@ public:
bool
is_modified
{};
bool
is_modified
{};
bool
readonly
{};
bool
readonly
{};
bool
showing_pack
{};
bool
showing_pack
{};
mt19937
rnd
;
std
::
mt19937
rnd
;
const
LFList
*
filterList
{};
const
LFList
*
filterList
{};
std
::
vector
<
code_pointer
>
results
;
std
::
vector
<
code_pointer
>
results
;
...
...
gframe/drawing.cpp
View file @
58a947b2
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#include "deck_manager.h"
#include "deck_manager.h"
#include "sound_manager.h"
#include "sound_manager.h"
#include "duelclient.h"
#include "duelclient.h"
#include "../ocgcore/common.h"
namespace
ygo
{
namespace
ygo
{
...
...
gframe/duelclient.cpp
View file @
58a947b2
...
@@ -29,7 +29,8 @@ int DuelClient::last_select_hint = 0;
...
@@ -29,7 +29,8 @@ int DuelClient::last_select_hint = 0;
unsigned
char
DuelClient
::
last_successful_msg
[
SIZE_NETWORK_BUFFER
];
unsigned
char
DuelClient
::
last_successful_msg
[
SIZE_NETWORK_BUFFER
];
size_t
DuelClient
::
last_successful_msg_length
=
0
;
size_t
DuelClient
::
last_successful_msg_length
=
0
;
wchar_t
DuelClient
::
event_string
[
256
];
wchar_t
DuelClient
::
event_string
[
256
];
mt19937
DuelClient
::
rnd
;
std
::
mt19937
DuelClient
::
rnd
;
std
::
uniform_real_distribution
<
float
>
DuelClient
::
real_dist
;
bool
DuelClient
::
is_refreshing
=
false
;
bool
DuelClient
::
is_refreshing
=
false
;
int
DuelClient
::
match_kill
=
0
;
int
DuelClient
::
match_kill
=
0
;
...
@@ -58,7 +59,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
...
@@ -58,7 +59,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
return
false
;
return
false
;
}
}
connect_state
=
0x1
;
connect_state
=
0x1
;
rnd
.
reset
((
uint_fast32_t
)
std
::
random_device
()());
rnd
.
seed
(
std
::
random_device
()());
if
(
!
create_game
)
{
if
(
!
create_game
)
{
timeval
timeout
=
{
5
,
0
};
timeval
timeout
=
{
5
,
0
};
event
*
timeout_event
=
event_new
(
client_base
,
0
,
EV_TIMEOUT
,
ConnectTimeout
,
0
);
event
*
timeout_event
=
event_new
(
client_base
,
0
,
EV_TIMEOUT
,
ConnectTimeout
,
0
);
...
@@ -774,8 +775,12 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
...
@@ -774,8 +775,12 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break
;
break
;
}
}
case
STOC_CHAT
:
{
case
STOC_CHAT
:
{
if
(
len
<
1
+
sizeof
(
uint16_t
)
+
sizeof
(
uint16_t
)
*
1
)
return
;
if
(
len
>
1
+
sizeof
(
uint16_t
)
+
sizeof
(
uint16_t
)
*
LEN_CHAT_MSG
)
return
;
const
int
chat_msg_size
=
len
-
1
-
sizeof
(
uint16_t
);
const
int
chat_msg_size
=
len
-
1
-
sizeof
(
uint16_t
);
if
(
!
check_msg_size
(
chat_msg_size
))
if
(
chat_msg_size
%
sizeof
(
uint16_t
))
return
;
return
;
uint16_t
chat_player_type
=
buffer_read
<
uint16_t
>
(
pdata
);
uint16_t
chat_player_type
=
buffer_read
<
uint16_t
>
(
pdata
);
uint16_t
chat_msg
[
LEN_CHAT_MSG
];
uint16_t
chat_msg
[
LEN_CHAT_MSG
];
...
@@ -1753,7 +1758,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
...
@@ -1753,7 +1758,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
SetResponseI
(
-
1
);
SetResponseI
(
-
1
);
mainGame
->
dField
.
ClearChainSelect
();
mainGame
->
dField
.
ClearChainSelect
();
if
(
mainGame
->
chkWaitChain
->
isChecked
()
&&
!
mainGame
->
ignore_chain
)
{
if
(
mainGame
->
chkWaitChain
->
isChecked
()
&&
!
mainGame
->
ignore_chain
)
{
mainGame
->
WaitFrameSignal
(
rnd
.
get_random_integer
(
20
,
40
));
mainGame
->
WaitFrameSignal
(
std
::
uniform_int_distribution
<>
(
20
,
40
)(
rnd
));
}
}
DuelClient
::
SendResponse
();
DuelClient
::
SendResponse
();
return
true
;
return
true
;
...
@@ -1852,9 +1857,10 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
...
@@ -1852,9 +1857,10 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
}
}
if
(
!
pzone
)
{
if
(
!
pzone
)
{
if
(
mainGame
->
chkRandomPos
->
isChecked
())
{
if
(
mainGame
->
chkRandomPos
->
isChecked
())
{
std
::
uniform_int_distribution
<>
dist
(
0
,
6
);
do
{
do
{
respbuf
[
2
]
=
rnd
.
get_random_integer
(
0
,
6
);
respbuf
[
2
]
=
dist
(
rnd
);
}
while
(
!
(
filter
&
(
1
<<
respbuf
[
2
])));
}
while
(
!
(
filter
&
(
0x1U
<<
respbuf
[
2
])));
}
else
{
}
else
{
if
(
filter
&
0x40
)
respbuf
[
2
]
=
6
;
if
(
filter
&
0x40
)
respbuf
[
2
]
=
6
;
else
if
(
filter
&
0x20
)
respbuf
[
2
]
=
5
;
else
if
(
filter
&
0x20
)
respbuf
[
2
]
=
5
;
...
@@ -2259,7 +2265,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
...
@@ -2259,7 +2265,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
soundManager
.
PlaySoundEffect
(
SOUND_SHUFFLE
);
soundManager
.
PlaySoundEffect
(
SOUND_SHUFFLE
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
auto
cit
=
mainGame
->
dField
.
deck
[
player
].
begin
();
cit
!=
mainGame
->
dField
.
deck
[
player
].
end
();
++
cit
)
{
for
(
auto
cit
=
mainGame
->
dField
.
deck
[
player
].
begin
();
cit
!=
mainGame
->
dField
.
deck
[
player
].
end
();
++
cit
)
{
(
*
cit
)
->
dPos
=
irr
::
core
::
vector3df
(
r
nd
.
rand
()
*
0.4
f
/
rnd
.
rand_max
-
0.2
f
,
0
,
0
);
(
*
cit
)
->
dPos
=
irr
::
core
::
vector3df
(
r
eal_dist
(
rnd
)
*
0.4
f
-
0.2
f
,
0
,
0
);
(
*
cit
)
->
dRot
=
irr
::
core
::
vector3df
(
0
,
0
,
0
);
(
*
cit
)
->
dRot
=
irr
::
core
::
vector3df
(
0
,
0
,
0
);
(
*
cit
)
->
is_moving
=
true
;
(
*
cit
)
->
is_moving
=
true
;
(
*
cit
)
->
aniFrame
=
3
;
(
*
cit
)
->
aniFrame
=
3
;
...
@@ -2331,7 +2337,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
...
@@ -2331,7 +2337,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
auto
cit
=
mainGame
->
dField
.
extra
[
player
].
begin
();
cit
!=
mainGame
->
dField
.
extra
[
player
].
end
();
++
cit
)
{
for
(
auto
cit
=
mainGame
->
dField
.
extra
[
player
].
begin
();
cit
!=
mainGame
->
dField
.
extra
[
player
].
end
();
++
cit
)
{
if
(
!
((
*
cit
)
->
position
&
POS_FACEUP
))
{
if
(
!
((
*
cit
)
->
position
&
POS_FACEUP
))
{
(
*
cit
)
->
dPos
=
irr
::
core
::
vector3df
(
r
nd
.
rand
()
*
0.4
f
/
rnd
.
rand_max
-
0.2
f
,
0
,
0
);
(
*
cit
)
->
dPos
=
irr
::
core
::
vector3df
(
r
eal_dist
(
rnd
)
*
0.4
f
-
0.2
f
,
0
,
0
);
(
*
cit
)
->
dRot
=
irr
::
core
::
vector3df
(
0
,
0
,
0
);
(
*
cit
)
->
dRot
=
irr
::
core
::
vector3df
(
0
,
0
,
0
);
(
*
cit
)
->
is_moving
=
true
;
(
*
cit
)
->
is_moving
=
true
;
(
*
cit
)
->
aniFrame
=
3
;
(
*
cit
)
->
aniFrame
=
3
;
...
...
gframe/duelclient.h
View file @
58a947b2
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
#include <vector>
#include <vector>
#include <set>
#include <set>
#include <random>
#include "network.h"
#include "network.h"
#include "../ocgcore/mtrandom.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -26,7 +26,8 @@ private:
...
@@ -26,7 +26,8 @@ private:
static
unsigned
char
last_successful_msg
[
SIZE_NETWORK_BUFFER
];
static
unsigned
char
last_successful_msg
[
SIZE_NETWORK_BUFFER
];
static
size_t
last_successful_msg_length
;
static
size_t
last_successful_msg_length
;
static
wchar_t
event_string
[
256
];
static
wchar_t
event_string
[
256
];
static
mt19937
rnd
;
static
std
::
mt19937
rnd
;
static
std
::
uniform_real_distribution
<
float
>
real_dist
;
static
bool
is_refreshing
;
static
bool
is_refreshing
;
static
int
match_kill
;
static
int
match_kill
;
static
event
*
resp_event
;
static
event
*
resp_event
;
...
@@ -55,8 +56,7 @@ public:
...
@@ -55,8 +56,7 @@ public:
template
<
typename
ST
>
template
<
typename
ST
>
static
void
SendPacketToServer
(
unsigned
char
proto
,
const
ST
&
st
)
{
static
void
SendPacketToServer
(
unsigned
char
proto
,
const
ST
&
st
)
{
auto
p
=
duel_client_write
;
auto
p
=
duel_client_write
;
if
(
sizeof
(
ST
)
>
MAX_DATA_SIZE
)
static_assert
(
sizeof
(
ST
)
<=
MAX_DATA_SIZE
,
"Packet size is too large."
);
return
;
buffer_write
<
uint16_t
>
(
p
,
(
uint16_t
)(
1
+
sizeof
(
ST
)));
buffer_write
<
uint16_t
>
(
p
,
(
uint16_t
)(
1
+
sizeof
(
ST
)));
buffer_write
<
uint8_t
>
(
p
,
proto
);
buffer_write
<
uint8_t
>
(
p
,
proto
);
std
::
memcpy
(
p
,
&
st
,
sizeof
(
ST
));
std
::
memcpy
(
p
,
&
st
,
sizeof
(
ST
));
...
...
gframe/event_handler.cpp
View file @
58a947b2
#include "event_handler.h"
#include "event_handler.h"
#include "client_field.h"
#include "client_field.h"
#include "math.h"
#include "network.h"
#include "network.h"
#include "game.h"
#include "game.h"
#include "duelclient.h"
#include "duelclient.h"
...
@@ -11,7 +10,6 @@
...
@@ -11,7 +10,6 @@
#include "replay_mode.h"
#include "replay_mode.h"
#include "single_mode.h"
#include "single_mode.h"
#include "materials.h"
#include "materials.h"
#include "../ocgcore/common.h"
namespace
ygo
{
namespace
ygo
{
...
...
gframe/netserver.cpp
View file @
58a947b2
...
@@ -293,7 +293,11 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
...
@@ -293,7 +293,11 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case
CTOS_CHAT
:
{
case
CTOS_CHAT
:
{
if
(
!
dp
->
game
)
if
(
!
dp
->
game
)
return
;
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
unsigned
char
))
if
(
len
<
1
+
sizeof
(
uint16_t
)
*
1
)
return
;
if
(
len
>
1
+
sizeof
(
uint16_t
)
*
LEN_CHAT_MSG
)
return
;
if
((
len
-
1
)
%
sizeof
(
uint16_t
))
return
;
return
;
duel_mode
->
Chat
(
dp
,
pdata
,
len
-
1
);
duel_mode
->
Chat
(
dp
,
pdata
,
len
-
1
);
break
;
break
;
...
@@ -455,8 +459,6 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
...
@@ -455,8 +459,6 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
}
}
}
}
size_t
NetServer
::
CreateChatPacket
(
unsigned
char
*
src
,
int
src_size
,
unsigned
char
*
dst
,
uint16_t
dst_player_type
)
{
size_t
NetServer
::
CreateChatPacket
(
unsigned
char
*
src
,
int
src_size
,
unsigned
char
*
dst
,
uint16_t
dst_player_type
)
{
if
(
!
check_msg_size
(
src_size
))
return
0
;
uint16_t
src_msg
[
LEN_CHAT_MSG
];
uint16_t
src_msg
[
LEN_CHAT_MSG
];
std
::
memcpy
(
src_msg
,
src
,
src_size
);
std
::
memcpy
(
src_msg
,
src
,
src_size
);
const
int
src_len
=
src_size
/
sizeof
(
uint16_t
);
const
int
src_len
=
src_size
/
sizeof
(
uint16_t
);
...
...
gframe/netserver.h
View file @
58a947b2
...
@@ -52,8 +52,7 @@ public:
...
@@ -52,8 +52,7 @@ public:
template
<
typename
ST
>
template
<
typename
ST
>
static
void
SendPacketToPlayer
(
DuelPlayer
*
dp
,
unsigned
char
proto
,
const
ST
&
st
)
{
static
void
SendPacketToPlayer
(
DuelPlayer
*
dp
,
unsigned
char
proto
,
const
ST
&
st
)
{
auto
p
=
net_server_write
;
auto
p
=
net_server_write
;
if
(
sizeof
(
ST
)
>
MAX_DATA_SIZE
)
static_assert
(
sizeof
(
ST
)
<=
MAX_DATA_SIZE
,
"Packet size is too large."
);
return
;
buffer_write
<
uint16_t
>
(
p
,
(
uint16_t
)(
1
+
sizeof
(
ST
)));
buffer_write
<
uint16_t
>
(
p
,
(
uint16_t
)(
1
+
sizeof
(
ST
)));
buffer_write
<
uint8_t
>
(
p
,
proto
);
buffer_write
<
uint8_t
>
(
p
,
proto
);
std
::
memcpy
(
p
,
&
st
,
sizeof
(
ST
));
std
::
memcpy
(
p
,
&
st
,
sizeof
(
ST
));
...
...
gframe/network.h
View file @
58a947b2
...
@@ -196,17 +196,6 @@ struct DuelPlayer {
...
@@ -196,17 +196,6 @@ struct DuelPlayer {
bufferevent
*
bev
{};
bufferevent
*
bev
{};
};
};
inline
bool
check_msg_size
(
int
size
)
{
// empty string is not allowed
if
(
size
<
2
*
sizeof
(
uint16_t
))
return
false
;
if
(
size
>
LEN_CHAT_MSG
*
sizeof
(
uint16_t
))
return
false
;
if
(
size
%
sizeof
(
uint16_t
)
!=
0
)
return
false
;
return
true
;
}
inline
unsigned
int
GetPosition
(
unsigned
char
*
qbuf
,
size_t
offset
)
{
inline
unsigned
int
GetPosition
(
unsigned
char
*
qbuf
,
size_t
offset
)
{
unsigned
int
info
=
0
;
unsigned
int
info
=
0
;
std
::
memcpy
(
&
info
,
qbuf
+
offset
,
sizeof
info
);
std
::
memcpy
(
&
info
,
qbuf
+
offset
,
sizeof
info
);
...
...
gframe/premake5.lua
View file @
58a947b2
...
@@ -116,9 +116,9 @@ end
...
@@ -116,9 +116,9 @@ end
links
{
"irrKlang"
}
links
{
"irrKlang"
}
if
IRRKLANG_PRO
then
if
IRRKLANG_PRO
then
defines
{
"IRRKLANG_STATIC"
}
defines
{
"IRRKLANG_STATIC"
}
filter
{
"not configurations:Debug"
}
filter
{
"
system:windows"
,
"
not configurations:Debug"
}
libdirs
{
IRRKLANG_PRO_RELEASE_LIB_DIR
}
libdirs
{
IRRKLANG_PRO_RELEASE_LIB_DIR
}
filter
{
"configurations:Debug"
}
filter
{
"
system:windows"
,
"
configurations:Debug"
}
libdirs
{
IRRKLANG_PRO_DEBUG_LIB_DIR
}
libdirs
{
IRRKLANG_PRO_DEBUG_LIB_DIR
}
filter
{}
filter
{}
end
end
...
@@ -142,7 +142,7 @@ end
...
@@ -142,7 +142,7 @@ end
filter
"system:linux"
filter
"system:linux"
if
not
SERVER_MODE
then
if
not
SERVER_MODE
then
links
{
"GL"
,
"X11"
,
"Xxf86vm"
}
links
{
"GL"
,
"X11"
,
"Xxf86vm"
,
"dl"
,
"pthread"
}
linkoptions
{
"-fopenmp"
}
linkoptions
{
"-fopenmp"
}
end
end
if
SERVER_MODE
then
-- support old gcc
if
SERVER_MODE
then
-- support old gcc
...
...
gframe/replay_mode.cpp
View file @
58a947b2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include "duelclient.h"
#include "duelclient.h"
#include "game.h"
#include "game.h"
#include "data_manager.h"
#include "data_manager.h"
#include
"../ocgcore/mtrandom.h"
#include
<random>
#include <thread>
#include <thread>
namespace
ygo
{
namespace
ygo
{
...
...
gframe/single_mode.cpp
View file @
58a947b2
...
@@ -747,7 +747,7 @@ bool SingleMode::SinglePlayAnalyze(unsigned char* msg, unsigned int len) {
...
@@ -747,7 +747,7 @@ bool SingleMode::SinglePlayAnalyze(unsigned char* msg, unsigned int len) {
break
;
break
;
}
}
case
MSG_AI_NAME
:
{
case
MSG_AI_NAME
:
{
char
namebuf
[
128
]{};
char
namebuf
[
SIZE_AI_NAME
]{};
wchar_t
wname
[
20
]{};
wchar_t
wname
[
20
]{};
int
name_len
=
buffer_read
<
uint16_t
>
(
pbuf
);
int
name_len
=
buffer_read
<
uint16_t
>
(
pbuf
);
if
(
name_len
+
1
<=
(
int
)
sizeof
namebuf
)
{
if
(
name_len
+
1
<=
(
int
)
sizeof
namebuf
)
{
...
@@ -760,8 +760,8 @@ bool SingleMode::SinglePlayAnalyze(unsigned char* msg, unsigned int len) {
...
@@ -760,8 +760,8 @@ bool SingleMode::SinglePlayAnalyze(unsigned char* msg, unsigned int len) {
break
;
break
;
}
}
case
MSG_SHOW_HINT
:
{
case
MSG_SHOW_HINT
:
{
char
msgbuf
[
1024
]{};
char
msgbuf
[
SIZE_HINT_MSG
]{};
wchar_t
msg
[
1024
]{};
wchar_t
msg
[
SIZE_HINT_MSG
]{};
int
msg_len
=
buffer_read
<
uint16_t
>
(
pbuf
);
int
msg_len
=
buffer_read
<
uint16_t
>
(
pbuf
);
if
(
msg_len
+
1
<=
(
int
)
sizeof
msgbuf
)
{
if
(
msg_len
+
1
<=
(
int
)
sizeof
msgbuf
)
{
std
::
memcpy
(
msgbuf
,
pbuf
,
msg_len
);
std
::
memcpy
(
msgbuf
,
pbuf
,
msg_len
);
...
...
gframe/sound_manager.cpp
View file @
58a947b2
...
@@ -16,7 +16,7 @@ bool SoundManager::Init() {
...
@@ -16,7 +16,7 @@ bool SoundManager::Init() {
#ifdef YGOPRO_USE_AUDIO
#ifdef YGOPRO_USE_AUDIO
bgm_scene
=
-
1
;
bgm_scene
=
-
1
;
RefreshBGMList
();
RefreshBGMList
();
rnd
.
reset
((
unsigned
int
)
std
::
time
(
nullptr
));
rnd
.
seed
(
std
::
random_device
()(
));
#ifdef YGOPRO_USE_MINIAUDIO
#ifdef YGOPRO_USE_MINIAUDIO
engineConfig
=
ma_engine_config_init
();
engineConfig
=
ma_engine_config_init
();
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
...
@@ -68,6 +68,7 @@ void SoundManager::RefreshBGMList() {
...
@@ -68,6 +68,7 @@ void SoundManager::RefreshBGMList() {
#endif
#endif
}
}
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#ifdef YGOPRO_USE_AUDIO
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
(
if
(
!
isdir
&&
(
...
@@ -81,6 +82,7 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
...
@@ -81,6 +82,7 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
BGMList
[
scene
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
}
});
});
#endif // YGOPRO_USE_AUDIO
}
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_AUDIO
#ifdef YGOPRO_USE_AUDIO
...
@@ -302,7 +304,7 @@ void SoundManager::PlayBGM(int scene) {
...
@@ -302,7 +304,7 @@ void SoundManager::PlayBGM(int scene) {
if
(
count
<=
0
)
if
(
count
<=
0
)
return
;
return
;
bgm_scene
=
scene
;
bgm_scene
=
scene
;
int
bgm
=
rnd
.
get_random_integer
(
0
,
count
-
1
)
;
int
bgm
=
(
count
>
1
)
?
std
::
uniform_int_distribution
<>
(
0
,
count
-
1
)(
rnd
)
:
0
;
auto
name
=
BGMList
[
scene
][
bgm
].
c_str
();
auto
name
=
BGMList
[
scene
][
bgm
].
c_str
();
wchar_t
BGMName
[
1024
];
wchar_t
BGMName
[
1024
];
myswprintf
(
BGMName
,
L"./sound/BGM/%ls"
,
name
);
myswprintf
(
BGMName
,
L"./sound/BGM/%ls"
,
name
);
...
...
gframe/sound_manager.h
View file @
58a947b2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#define SOUNDMANAGER_H
#define SOUNDMANAGER_H
#include "game.h"
#include "game.h"
#include
"../ocgcore/mtrandom.h"
#include
<random>
#ifdef YGOPRO_USE_MINIAUDIO
#ifdef YGOPRO_USE_MINIAUDIO
#include <miniaudio.h>
#include <miniaudio.h>
#endif
#endif
...
@@ -16,7 +16,7 @@ class SoundManager {
...
@@ -16,7 +16,7 @@ class SoundManager {
private:
private:
std
::
vector
<
std
::
wstring
>
BGMList
[
8
];
std
::
vector
<
std
::
wstring
>
BGMList
[
8
];
int
bgm_scene
{};
int
bgm_scene
{};
mt19937
rnd
;
std
::
mt19937
rnd
;
#ifdef YGOPRO_USE_MINIAUDIO
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_config
engineConfig
;
ma_engine_config
engineConfig
;
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
#ifdef YGOPRO_MINIAUDIO_SUPPORT_OPUS_VORBIS
...
...
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