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
wind2009
ygopro
Commits
82c273f8
Commit
82c273f8
authored
Jun 11, 2012
by
argon.sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
single
parent
a1619691
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
834 additions
and
21 deletions
+834
-21
gframe/drawing.cpp
gframe/drawing.cpp
+2
-2
gframe/duelclient.cpp
gframe/duelclient.cpp
+85
-11
gframe/event_handler.cpp
gframe/event_handler.cpp
+1
-1
gframe/game.h
gframe/game.h
+3
-1
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+5
-1
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+1
-1
gframe/single_duel.cpp
gframe/single_duel.cpp
+1
-0
gframe/single_mode.cpp
gframe/single_mode.cpp
+637
-0
gframe/single_mode.h
gframe/single_mode.h
+2
-2
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+1
-0
ocgcore/duel.cpp
ocgcore/duel.cpp
+15
-0
ocgcore/duel.h
ocgcore/duel.h
+2
-1
ocgcore/field.cpp
ocgcore/field.cpp
+31
-0
ocgcore/field.h
ocgcore/field.h
+3
-1
ocgcore/libdebug.cpp
ocgcore/libdebug.cpp
+5
-0
ocgcore/ocgapi.cpp
ocgcore/ocgapi.cpp
+31
-0
ocgcore/ocgapi.h
ocgcore/ocgapi.h
+1
-0
script/constant.lua
script/constant.lua
+8
-0
No files found.
gframe/drawing.cpp
View file @
82c273f8
...
@@ -326,11 +326,11 @@ void Game::DrawMisc() {
...
@@ -326,11 +326,11 @@ void Game::DrawMisc() {
numFont
->
draw
(
dInfo
.
strLP
[
1
],
recti
(
691
,
11
,
990
,
30
),
0xff000000
,
true
,
false
,
0
);
numFont
->
draw
(
dInfo
.
strLP
[
1
],
recti
(
691
,
11
,
990
,
30
),
0xff000000
,
true
,
false
,
0
);
numFont
->
draw
(
dInfo
.
strLP
[
1
],
recti
(
691
,
12
,
992
,
30
),
0xffffff00
,
true
,
false
,
0
);
numFont
->
draw
(
dInfo
.
strLP
[
1
],
recti
(
691
,
12
,
992
,
30
),
0xffffff00
,
true
,
false
,
0
);
if
(
!
dInfo
.
is
_t
ag
||
!
dInfo
.
tag_player
[
0
])
if
(
!
dInfo
.
is
T
ag
||
!
dInfo
.
tag_player
[
0
])
textFont
->
draw
(
dInfo
.
hostname
,
recti
(
335
,
31
,
629
,
50
),
0xffffffff
,
false
,
false
,
0
);
textFont
->
draw
(
dInfo
.
hostname
,
recti
(
335
,
31
,
629
,
50
),
0xffffffff
,
false
,
false
,
0
);
else
else
textFont
->
draw
(
dInfo
.
hostname_tag
,
recti
(
335
,
31
,
629
,
50
),
0xffffffff
,
false
,
false
,
0
);
textFont
->
draw
(
dInfo
.
hostname_tag
,
recti
(
335
,
31
,
629
,
50
),
0xffffffff
,
false
,
false
,
0
);
if
(
!
dInfo
.
is
_t
ag
||
!
dInfo
.
tag_player
[
1
])
{
if
(
!
dInfo
.
is
T
ag
||
!
dInfo
.
tag_player
[
1
])
{
auto
cld
=
textFont
->
getDimension
(
dInfo
.
clientname
);
auto
cld
=
textFont
->
getDimension
(
dInfo
.
clientname
);
textFont
->
draw
(
dInfo
.
clientname
,
recti
(
986
-
cld
.
Width
,
31
,
986
,
50
),
0xffffffff
,
false
,
false
,
0
);
textFont
->
draw
(
dInfo
.
clientname
,
recti
(
986
-
cld
.
Width
,
31
,
986
,
50
),
0xffffffff
,
false
,
false
,
0
);
}
else
{
}
else
{
...
...
gframe/duelclient.cpp
View file @
82c273f8
...
@@ -326,13 +326,13 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
...
@@ -326,13 +326,13 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
if
(
pkt
->
info
.
mode
==
2
)
{
if
(
pkt
->
info
.
mode
==
2
)
{
mainGame
->
dInfo
.
is
_t
ag
=
true
;
mainGame
->
dInfo
.
is
T
ag
=
true
;
mainGame
->
chkHostPrepReady
[
2
]
->
setVisible
(
true
);
mainGame
->
chkHostPrepReady
[
2
]
->
setVisible
(
true
);
mainGame
->
chkHostPrepReady
[
3
]
->
setVisible
(
true
);
mainGame
->
chkHostPrepReady
[
3
]
->
setVisible
(
true
);
mainGame
->
stHostPrepDuelist
[
2
]
->
setVisible
(
true
);
mainGame
->
stHostPrepDuelist
[
2
]
->
setVisible
(
true
);
mainGame
->
stHostPrepDuelist
[
3
]
->
setVisible
(
true
);
mainGame
->
stHostPrepDuelist
[
3
]
->
setVisible
(
true
);
}
else
{
}
else
{
mainGame
->
dInfo
.
is
_t
ag
=
false
;
mainGame
->
dInfo
.
is
T
ag
=
false
;
mainGame
->
chkHostPrepReady
[
2
]
->
setVisible
(
false
);
mainGame
->
chkHostPrepReady
[
2
]
->
setVisible
(
false
);
mainGame
->
chkHostPrepReady
[
3
]
->
setVisible
(
false
);
mainGame
->
chkHostPrepReady
[
3
]
->
setVisible
(
false
);
mainGame
->
stHostPrepDuelist
[
2
]
->
setVisible
(
false
);
mainGame
->
stHostPrepDuelist
[
2
]
->
setVisible
(
false
);
...
@@ -368,7 +368,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
...
@@ -368,7 +368,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
case
STOC_TYPE_CHANGE
:
{
case
STOC_TYPE_CHANGE
:
{
STOC_TypeChange
*
pkt
=
(
STOC_TypeChange
*
)
pdata
;
STOC_TypeChange
*
pkt
=
(
STOC_TypeChange
*
)
pdata
;
if
(
!
mainGame
->
dInfo
.
is
_t
ag
)
{
if
(
!
mainGame
->
dInfo
.
is
T
ag
)
{
selftype
=
pkt
->
type
&
0xf
;
selftype
=
pkt
->
type
&
0xf
;
is_host
=
(
pkt
->
type
>>
4
)
&
0xf
;
is_host
=
(
pkt
->
type
>>
4
)
&
0xf
;
mainGame
->
btnHostPrepKick
[
2
]
->
setVisible
(
false
);
mainGame
->
btnHostPrepKick
[
2
]
->
setVisible
(
false
);
...
@@ -449,7 +449,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
...
@@ -449,7 +449,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
wChat
->
setVisible
(
true
);
mainGame
->
wChat
->
setVisible
(
true
);
mainGame
->
imgCard
->
setImage
(
imageManager
.
tCover
);
mainGame
->
imgCard
->
setImage
(
imageManager
.
tCover
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
dField
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
dField
);
if
(
!
mainGame
->
dInfo
.
is
_t
ag
)
{
if
(
!
mainGame
->
dInfo
.
is
T
ag
)
{
if
(
selftype
>
1
)
{
if
(
selftype
>
1
)
{
mainGame
->
dInfo
.
player_type
=
7
;
mainGame
->
dInfo
.
player_type
=
7
;
mainGame
->
btnLeaveGame
->
setText
(
dataManager
.
GetSysString
(
1350
));
mainGame
->
btnLeaveGame
->
setText
(
dataManager
.
GetSysString
(
1350
));
...
@@ -544,7 +544,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
...
@@ -544,7 +544,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
BufferIO
::
CopyWStr
(
pkt
->
msg
,
msg
,
256
);
BufferIO
::
CopyWStr
(
pkt
->
msg
,
msg
,
256
);
msg
[(
len
-
3
)
/
2
]
=
0
;
msg
[(
len
-
3
)
/
2
]
=
0
;
mainGame
->
gMutex
.
Lock
();
mainGame
->
gMutex
.
Lock
();
if
(
!
mainGame
->
dInfo
.
is
_t
ag
)
{
if
(
!
mainGame
->
dInfo
.
is
T
ag
)
{
if
(
mainGame
->
dInfo
.
isStarted
)
if
(
mainGame
->
dInfo
.
isStarted
)
mainGame
->
AddChatMsg
(
msg
,
mainGame
->
LocalPlayer
(
pkt
->
player
));
mainGame
->
AddChatMsg
(
msg
,
mainGame
->
LocalPlayer
(
pkt
->
player
));
else
else
...
@@ -600,7 +600,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
...
@@ -600,7 +600,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break
;
break
;
wchar_t
name
[
20
];
wchar_t
name
[
20
];
BufferIO
::
CopyWStr
(
pkt
->
name
,
name
,
20
);
BufferIO
::
CopyWStr
(
pkt
->
name
,
name
,
20
);
if
(
mainGame
->
dInfo
.
is
_t
ag
)
{
if
(
mainGame
->
dInfo
.
is
T
ag
)
{
if
(
pkt
->
pos
==
0
)
if
(
pkt
->
pos
==
0
)
BufferIO
::
CopyWStr
(
pkt
->
name
,
mainGame
->
dInfo
.
hostname
,
20
);
BufferIO
::
CopyWStr
(
pkt
->
name
,
mainGame
->
dInfo
.
hostname
,
20
);
else
if
(
pkt
->
pos
==
1
)
else
if
(
pkt
->
pos
==
1
)
...
@@ -853,7 +853,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
...
@@ -853,7 +853,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
dInfo
.
isFirst
=
(
playertype
&
0xf
)
?
false
:
true
;
mainGame
->
dInfo
.
isFirst
=
(
playertype
&
0xf
)
?
false
:
true
;
if
(
playertype
&
0xf0
)
if
(
playertype
&
0xf0
)
mainGame
->
dInfo
.
player_type
=
7
;
mainGame
->
dInfo
.
player_type
=
7
;
if
(
mainGame
->
dInfo
.
is
_t
ag
)
{
if
(
mainGame
->
dInfo
.
is
T
ag
)
{
if
(
mainGame
->
dInfo
.
isFirst
)
if
(
mainGame
->
dInfo
.
isFirst
)
mainGame
->
dInfo
.
tag_player
[
1
]
=
true
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
true
;
else
else
...
@@ -1675,11 +1675,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
...
@@ -1675,11 +1675,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
case
MSG_NEW_TURN
:
{
case
MSG_NEW_TURN
:
{
int
player
=
mainGame
->
LocalPlayer
(
BufferIO
::
ReadInt8
(
pbuf
));
int
player
=
mainGame
->
LocalPlayer
(
BufferIO
::
ReadInt8
(
pbuf
));
mainGame
->
dInfo
.
turn
++
;
mainGame
->
dInfo
.
turn
++
;
if
(
!
mainGame
->
dInfo
.
is
_t
ag
&&
mainGame
->
dInfo
.
turn
==
5
&&
!
mainGame
->
dInfo
.
isReplay
&&
mainGame
->
dInfo
.
player_type
<
7
)
{
if
(
!
mainGame
->
dInfo
.
is
T
ag
&&
mainGame
->
dInfo
.
turn
==
5
&&
!
mainGame
->
dInfo
.
isReplay
&&
mainGame
->
dInfo
.
player_type
<
7
)
{
mainGame
->
btnLeaveGame
->
setText
(
dataManager
.
GetSysString
(
1351
));
mainGame
->
btnLeaveGame
->
setText
(
dataManager
.
GetSysString
(
1351
));
mainGame
->
btnLeaveGame
->
setVisible
(
true
);
mainGame
->
btnLeaveGame
->
setVisible
(
true
);
}
}
if
(
mainGame
->
dInfo
.
is
_t
ag
&&
mainGame
->
dInfo
.
turn
!=
1
)
{
if
(
mainGame
->
dInfo
.
is
T
ag
&&
mainGame
->
dInfo
.
turn
!=
1
)
{
if
(
player
==
0
)
if
(
player
==
0
)
mainGame
->
dInfo
.
tag_player
[
0
]
=
!
mainGame
->
dInfo
.
tag_player
[
0
];
mainGame
->
dInfo
.
tag_player
[
0
]
=
!
mainGame
->
dInfo
.
tag_player
[
0
];
else
else
...
@@ -2719,6 +2719,76 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
...
@@ -2719,6 +2719,76 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
WaitFrameSignal
(
5
);
mainGame
->
WaitFrameSignal
(
5
);
break
;
break
;
}
}
case
MSG_RELOAD_FIELD
:
{
mainGame
->
gMutex
.
Lock
();
mainGame
->
dField
.
Clear
();
int
val
=
0
;
for
(
int
p
=
0
;
p
<
2
;
++
p
)
{
for
(
int
seq
=
0
;
seq
<
5
;
++
seq
)
{
val
=
BufferIO
::
ReadInt8
(
pbuf
);
if
(
val
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_MZONE
,
0
);
ccard
->
position
=
BufferIO
::
ReadInt8
(
pbuf
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
val
=
BufferIO
::
ReadInt8
(
pbuf
);
if
(
val
)
{
for
(
int
xyz
=
0
;
xyz
<
val
;
++
xyz
)
{
ClientCard
*
xcard
=
new
ClientCard
;
ccard
->
overlayed
.
push_back
(
xcard
);
mainGame
->
dField
.
overlay_cards
.
insert
(
xcard
);
mainGame
->
gMutex
.
Unlock
();
xcard
->
overlayTarget
=
ccard
;
xcard
->
location
=
0x80
;
xcard
->
sequence
=
ccard
->
overlayed
.
size
()
-
1
;
mainGame
->
dField
.
GetCardLocation
(
xcard
,
&
xcard
->
curPos
,
&
xcard
->
curRot
);
}
}
}
}
for
(
int
seq
=
0
;
seq
<
6
;
++
seq
)
{
val
=
BufferIO
::
ReadInt8
(
pbuf
);
if
(
val
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_SZONE
,
seq
);
ccard
->
position
=
BufferIO
::
ReadInt8
(
pbuf
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
}
}
val
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
seq
=
0
;
seq
<
val
;
++
seq
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_DECK
,
seq
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
}
val
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
seq
=
0
;
seq
<
val
;
++
seq
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_HAND
,
seq
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
}
val
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
seq
=
0
;
seq
<
val
;
++
seq
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_EXTRA
,
seq
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
}
val
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
seq
=
0
;
seq
<
val
;
++
seq
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_GRAVE
,
seq
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
}
val
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
seq
=
0
;
seq
<
val
;
++
seq
)
{
ClientCard
*
ccard
=
new
ClientCard
;
mainGame
->
dField
.
AddCard
(
ccard
,
p
,
LOCATION_REMOVED
,
seq
);
mainGame
->
dField
.
GetCardLocation
(
ccard
,
&
ccard
->
curPos
,
&
ccard
->
curRot
);
}
}
mainGame
->
gMutex
.
Unlock
();
break
;
}
}
}
return
true
;
return
true
;
}
}
...
@@ -2768,8 +2838,12 @@ void DuelClient::SendResponse() {
...
@@ -2768,8 +2838,12 @@ void DuelClient::SendResponse() {
break
;
break
;
}
}
}
}
mainGame
->
dInfo
.
time_player
=
2
;
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
SendBufferToServer
(
CTOS_RESPONSE
,
response_buf
,
response_len
);
mainGame
->
singleSignal
.
Set
();
}
else
{
mainGame
->
dInfo
.
time_player
=
2
;
SendBufferToServer
(
CTOS_RESPONSE
,
response_buf
,
response_len
);
}
}
}
void
DuelClient
::
BeginRefreshHost
()
{
void
DuelClient
::
BeginRefreshHost
()
{
if
(
is_refreshing
)
if
(
is_refreshing
)
...
...
gframe/event_handler.cpp
View file @
82c273f8
...
@@ -776,7 +776,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -776,7 +776,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
unsigned
short
msgbuf
[
256
];
unsigned
short
msgbuf
[
256
];
if
(
mainGame
->
dInfo
.
isStarted
)
{
if
(
mainGame
->
dInfo
.
isStarted
)
{
if
(
mainGame
->
dInfo
.
player_type
<
7
)
{
if
(
mainGame
->
dInfo
.
player_type
<
7
)
{
if
(
mainGame
->
dInfo
.
is
_t
ag
&&
(
mainGame
->
dInfo
.
player_type
%
2
))
if
(
mainGame
->
dInfo
.
is
T
ag
&&
(
mainGame
->
dInfo
.
player_type
%
2
))
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
2
);
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
2
);
else
else
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
0
);
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
0
);
...
...
gframe/game.h
View file @
82c273f8
...
@@ -30,8 +30,9 @@ struct DuelInfo {
...
@@ -30,8 +30,9 @@ struct DuelInfo {
bool
isStarted
;
bool
isStarted
;
bool
isReplay
;
bool
isReplay
;
bool
isFirst
;
bool
isFirst
;
bool
isTag
;
bool
isSingleMode
;
bool
is_shuffling
;
bool
is_shuffling
;
bool
is_tag
;
bool
tag_player
[
2
];
bool
tag_player
[
2
];
int
lp
[
2
];
int
lp
[
2
];
int
turn
;
int
turn
;
...
@@ -99,6 +100,7 @@ public:
...
@@ -99,6 +100,7 @@ public:
Signal
frameSignal
;
Signal
frameSignal
;
Signal
actionSignal
;
Signal
actionSignal
;
Signal
replaySignal
;
Signal
replaySignal
;
Signal
singleSignal
;
Config
gameConf
;
Config
gameConf
;
DuelInfo
dInfo
;
DuelInfo
dInfo
;
...
...
gframe/menu_handler.cpp
View file @
82c273f8
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "duelclient.h"
#include "duelclient.h"
#include "deck_manager.h"
#include "deck_manager.h"
#include "replay_mode.h"
#include "replay_mode.h"
#include "single_mode.h"
#include "image_manager.h"
#include "image_manager.h"
#include "game.h"
#include "game.h"
...
@@ -168,6 +169,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -168,6 +169,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_LOAD_SINGLEPLAY
:
{
case
BUTTON_LOAD_SINGLEPLAY
:
{
if
(
mainGame
->
lstSinglePlayList
->
getSelected
()
==
-
1
)
break
;
SingleMode
::
StartPlay
();
break
;
break
;
}
}
case
BUTTON_CANCEL_SINGLEPLAY
:
{
case
BUTTON_CANCEL_SINGLEPLAY
:
{
...
@@ -300,7 +304,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -300,7 +304,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
unsigned
short
msgbuf
[
256
];
unsigned
short
msgbuf
[
256
];
if
(
mainGame
->
dInfo
.
isStarted
)
{
if
(
mainGame
->
dInfo
.
isStarted
)
{
if
(
mainGame
->
dInfo
.
player_type
<
7
)
{
if
(
mainGame
->
dInfo
.
player_type
<
7
)
{
if
(
mainGame
->
dInfo
.
is
_t
ag
&&
(
mainGame
->
dInfo
.
player_type
%
2
))
if
(
mainGame
->
dInfo
.
is
T
ag
&&
(
mainGame
->
dInfo
.
player_type
%
2
))
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
2
);
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
2
);
else
else
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
0
);
mainGame
->
AddChatMsg
((
wchar_t
*
)
input
,
0
);
...
...
gframe/replay_mode.cpp
View file @
82c273f8
...
@@ -61,7 +61,7 @@ int ReplayMode::ReplayThread(void* param) {
...
@@ -61,7 +61,7 @@ int ReplayMode::ReplayThread(void* param) {
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
hostname_tag
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
hostname_tag
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
clientname_tag
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
clientname_tag
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
clientname
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
clientname
,
40
);
mainGame
->
dInfo
.
is
_t
ag
=
true
;
mainGame
->
dInfo
.
is
T
ag
=
true
;
}
else
{
}
else
{
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
hostname
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
hostname
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
clientname
,
40
);
cur_replay
.
ReadData
(
mainGame
->
dInfo
.
clientname
,
40
);
...
...
gframe/single_duel.cpp
View file @
82c273f8
...
@@ -296,6 +296,7 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
...
@@ -296,6 +296,7 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
if
(
!
ready
[
0
]
||
!
ready
[
1
])
if
(
!
ready
[
0
]
||
!
ready
[
1
])
return
;
return
;
NetServer
::
StopListen
();
NetServer
::
StopListen
();
//NetServer::StopBroadcast();
NetServer
::
SendPacketToPlayer
(
players
[
0
],
STOC_DUEL_START
);
NetServer
::
SendPacketToPlayer
(
players
[
0
],
STOC_DUEL_START
);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
{
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
{
...
...
gframe/single_mode.cpp
View file @
82c273f8
#include "single_mode.h"
#include "duelclient.h"
#include "game.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h"
namespace
ygo
{
long
SingleMode
::
pduel
=
0
;
bool
SingleMode
::
is_closing
=
false
;
wchar_t
SingleMode
::
event_string
[
256
];
bool
SingleMode
::
StartPlay
()
{
Thread
::
NewThread
(
SinglePlayThread
,
0
);
return
true
;
}
void
SingleMode
::
StopPlay
(
bool
is_exiting
)
{
is_closing
=
is_exiting
;
mainGame
->
actionSignal
.
Set
();
}
int
SingleMode
::
SinglePlayThread
(
void
*
param
)
{
const
wchar_t
*
name
=
mainGame
->
lstReplayList
->
getListItem
(
mainGame
->
lstReplayList
->
getSelected
());
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
char
fname2
[
256
];
size_t
slen
=
BufferIO
::
EncodeUTF8
(
fname
,
fname2
);
mtrandom
rnd
;
time_t
seed
=
time
(
0
);
rnd
.
reset
(
seed
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
pduel
=
create_duel
(
rnd
.
rand
());
set_player_info
(
pduel
,
0
,
8000
,
5
,
1
);
set_player_info
(
pduel
,
1
,
8000
,
5
,
1
);
mainGame
->
dInfo
.
lp
[
0
]
=
8000
;
mainGame
->
dInfo
.
lp
[
1
]
=
8000
;
myswprintf
(
mainGame
->
dInfo
.
strLP
[
0
],
L"%d"
,
mainGame
->
dInfo
.
lp
[
0
]);
myswprintf
(
mainGame
->
dInfo
.
strLP
[
1
],
L"%d"
,
mainGame
->
dInfo
.
lp
[
1
]);
mainGame
->
dInfo
.
turn
=
0
;
mainGame
->
dInfo
.
strTurn
[
0
]
=
0
;
if
(
!
preload_script
(
pduel
,
fname2
,
slen
))
{
end_duel
(
pduel
);
return
0
;
}
mainGame
->
gMutex
.
Lock
();
mainGame
->
wCardImg
->
setVisible
(
true
);
mainGame
->
wInfos
->
setVisible
(
true
);
mainGame
->
stName
->
setText
(
L""
);
mainGame
->
stInfo
->
setText
(
L""
);
mainGame
->
stDataInfo
->
setText
(
L""
);
mainGame
->
stText
->
setText
(
L""
);
mainGame
->
wPhase
->
setVisible
(
true
);
mainGame
->
dField
.
panel
=
0
;
mainGame
->
dField
.
hovered_card
=
0
;
mainGame
->
dField
.
clicked_card
=
0
;
mainGame
->
dField
.
Clear
();
mainGame
->
dInfo
.
isStarted
=
true
;
mainGame
->
dInfo
.
isSingleMode
=
true
;
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
dField
);
mainGame
->
gMutex
.
Unlock
();
start_duel
(
pduel
,
0
);
char
engineBuffer
[
0x1000
];
is_closing
=
false
;
bool
is_continuing
=
true
;
int
len
=
0
,
flag
=
0
;
while
(
is_continuing
)
{
int
result
=
process
(
pduel
);
len
=
result
&
0xffff
;
flag
=
result
>>
16
;
if
(
len
>
0
)
{
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
is_continuing
=
SinglePlayAnalyze
(
engineBuffer
,
len
);
}
}
end_duel
(
pduel
);
if
(
!
is_closing
)
{
mainGame
->
actionSignal
.
Reset
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
stMessage
->
setText
(
dataManager
.
GetSysString
(
1501
));
if
(
mainGame
->
wCardSelect
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCardSelect
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isSingleMode
=
false
;
mainGame
->
CloseDuelWindow
();
mainGame
->
ClearTextures
();
mainGame
->
gMutex
.
Unlock
();
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
}
return
0
;
}
bool
SingleMode
::
SinglePlayAnalyze
(
char
*
msg
,
unsigned
int
len
)
{
char
*
offset
,
*
pbufw
,
*
pbuf
=
msg
;
int
player
,
count
;
while
(
pbuf
-
msg
<
len
)
{
if
(
is_closing
)
return
false
;
offset
=
pbuf
;
mainGame
->
dInfo
.
curMsg
=
BufferIO
::
ReadUInt8
(
pbuf
);
switch
(
mainGame
->
dInfo
.
curMsg
)
{
case
MSG_RETRY
:
{
mainGame
->
gMutex
.
Lock
();
mainGame
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
return
false
;
}
case
MSG_HINT
:
{
pbuf
+=
6
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_WIN
:
{
pbuf
+=
2
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
return
false
;
}
case
MSG_SELECT_BATTLECMD
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
11
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
8
+
2
;
SinglePlayRefresh
();
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_IDLECMD
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
11
+
2
;
SinglePlayRefresh
();
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_EFFECTYN
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_YESNO
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_OPTION
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_CARD
:
case
MSG_SELECT_TRIBUTE
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
3
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_CHAIN
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
10
+
count
*
11
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_PLACE
:
case
MSG_SELECT_DISFIELD
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_POSITION
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_COUNTER
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
3
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SELECT_SUM
:
{
pbuf
++
;
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
6
;
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
11
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_SORT_CARD
:
case
MSG_SORT_CHAIN
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_CONFIRM_DECKTOP
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CONFIRM_CARDS
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
7
;
break
;
}
case
MSG_SHUFFLE_DECK
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefreshDeck
(
player
);
break
;
}
case
MSG_SHUFFLE_HAND
:
{
int
oplayer
=
BufferIO
::
ReadInt8
(
pbuf
);
int
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_REFRESH_DECK
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SWAP_GRAVE_DECK
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefreshGrave
(
player
);
break
;
}
case
MSG_REVERSE_DECK
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_DECK_TOP
:
{
pbuf
+=
6
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SHUFFLE_SET_CARD
:
{
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_NEW_TURN
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_NEW_PHASE
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_MOVE
:
{
int
pc
=
pbuf
[
4
];
int
pl
=
pbuf
[
5
];
int
ps
=
pbuf
[
6
];
int
pp
=
pbuf
[
7
];
int
cc
=
pbuf
[
8
];
int
cl
=
pbuf
[
9
];
int
cs
=
pbuf
[
10
];
int
cp
=
pbuf
[
11
];
pbuf
+=
16
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
if
(
pl
!=
cl
||
pc
!=
cc
)
SinglePlayRefreshSingle
(
cc
,
cl
,
cs
);
break
;
}
case
MSG_POS_CHANGE
:
{
pbuf
+=
9
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SET
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SWAP
:
{
pbuf
+=
16
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_FIELD_DISABLED
:
{
pbuf
+=
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SUMMONING
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SUMMONED
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_SPSUMMONING
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_SPSUMMONED
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_FLIPSUMMONING
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_FLIPSUMMONED
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_CHAINING
:
{
pbuf
+=
16
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CHAINED
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_CHAIN_SOLVING
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CHAIN_SOLVED
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_CHAIN_END
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_CHAIN_NEGATED
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CHAIN_DISABLED
:
{
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CARD_SELECTED
:
case
MSG_RANDOM_SELECTED
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_BECOME_TARGET
:
{
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
*
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_DRAW
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbufw
=
pbuf
;
pbuf
+=
count
*
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_DAMAGE
:
{
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_RECOVER
:
{
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_EQUIP
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_LPUPDATE
:
{
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_UNEQUIP
:
{
pbuf
+=
4
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CARD_TARGET
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_CANCEL_TARGET
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_PAY_LPCOST
:
{
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_ADD_COUNTER
:
{
pbuf
+=
6
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_REMOVE_COUNTER
:
{
pbuf
+=
6
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_ATTACK
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_BATTLE
:
{
pbuf
+=
18
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_ATTACK_DISABLED
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_DAMAGE_STEP_START
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_DAMAGE_STEP_END
:
{
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefresh
();
break
;
}
case
MSG_MISSED_EFFECT
:
{
pbuf
+=
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_TOSS_COIN
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_TOSS_DICE
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
count
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_ANNOUNCE_RACE
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_ANNOUNCE_ATTRIB
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
5
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_ANNOUNCE_CARD
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_ANNOUNCE_NUMBER
:
{
player
=
BufferIO
::
ReadInt8
(
pbuf
);
count
=
BufferIO
::
ReadInt8
(
pbuf
);
pbuf
+=
4
*
count
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
mainGame
->
singleSignal
.
Reset
();
mainGame
->
singleSignal
.
Wait
();
break
;
}
case
MSG_CARD_HINT
:
{
pbuf
+=
9
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
break
;
}
case
MSG_TAG_SWAP
:
{
player
=
pbuf
[
0
];
pbuf
+=
pbuf
[
3
]
*
4
+
8
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayRefreshDeck
(
player
);
SinglePlayRefreshExtra
(
player
);
break
;
}
}
}
return
true
;
}
void
SingleMode
::
SinglePlayRefresh
(
int
flag
)
{
unsigned
char
queryBuffer
[
0x1000
];
int
len
=
query_field_card
(
pduel
,
0
,
LOCATION_MZONE
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
0
),
LOCATION_MZONE
,
(
char
*
)
queryBuffer
);
len
=
query_field_card
(
pduel
,
1
,
LOCATION_MZONE
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_MZONE
,
(
char
*
)
queryBuffer
);
len
=
query_field_card
(
pduel
,
0
,
LOCATION_SZONE
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
0
),
LOCATION_SZONE
,
(
char
*
)
queryBuffer
);
len
=
query_field_card
(
pduel
,
1
,
LOCATION_SZONE
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_SZONE
,
(
char
*
)
queryBuffer
);
len
=
query_field_card
(
pduel
,
0
,
LOCATION_HAND
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
0
),
LOCATION_HAND
,
(
char
*
)
queryBuffer
);
len
=
query_field_card
(
pduel
,
1
,
LOCATION_HAND
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_HAND
,
(
char
*
)
queryBuffer
);
}
void
SingleMode
::
SinglePlayRefreshHand
(
int
player
,
int
flag
)
{
unsigned
char
queryBuffer
[
0x1000
];
int
len
=
query_field_card
(
pduel
,
player
,
LOCATION_HAND
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
player
),
LOCATION_HAND
,
(
char
*
)
queryBuffer
);
}
void
SingleMode
::
SinglePlayRefreshGrave
(
int
player
,
int
flag
)
{
unsigned
char
queryBuffer
[
0x1000
];
int
len
=
query_field_card
(
pduel
,
player
,
LOCATION_GRAVE
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
player
),
LOCATION_GRAVE
,
(
char
*
)
queryBuffer
);
}
void
SingleMode
::
SinglePlayRefreshDeck
(
int
player
,
int
flag
)
{
unsigned
char
queryBuffer
[
0x1000
];
int
len
=
query_field_card
(
pduel
,
player
,
LOCATION_DECK
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
player
),
LOCATION_DECK
,
(
char
*
)
queryBuffer
);
}
void
SingleMode
::
SinglePlayRefreshExtra
(
int
player
,
int
flag
)
{
unsigned
char
queryBuffer
[
0x1000
];
int
len
=
query_field_card
(
pduel
,
player
,
LOCATION_EXTRA
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
player
),
LOCATION_EXTRA
,
(
char
*
)
queryBuffer
);
}
void
SingleMode
::
SinglePlayRefreshSingle
(
int
player
,
int
location
,
int
sequence
,
int
flag
)
{
unsigned
char
queryBuffer
[
0x1000
];
int
len
=
query_card
(
pduel
,
player
,
location
,
sequence
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateCard
(
mainGame
->
LocalPlayer
(
player
),
location
,
sequence
,
(
char
*
)
queryBuffer
);
}
int
SingleMode
::
MessageHandler
(
long
fduel
,
int
type
)
{
if
(
!
enable_log
)
return
0
;
char
msgbuf
[
1024
];
get_log_message
(
fduel
,
(
byte
*
)
msgbuf
);
if
(
enable_log
==
1
)
{
wchar_t
wbuf
[
1024
];
BufferIO
::
DecodeUTF8
(
msgbuf
,
wbuf
);
mainGame
->
AddChatMsg
(
wbuf
,
9
);
}
else
if
(
enable_log
==
2
)
{
FILE
*
fp
=
fopen
(
"error.log"
,
"at"
);
if
(
!
fp
)
return
0
;
fprintf
(
fp
,
"[Script error:] %s
\n
"
,
msgbuf
);
fclose
(
fp
);
}
return
0
;
}
}
gframe/single_mode.h
View file @
82c273f8
...
@@ -11,12 +11,12 @@ namespace ygo {
...
@@ -11,12 +11,12 @@ namespace ygo {
class
SingleMode
{
class
SingleMode
{
private:
private:
static
long
pduel
;
static
long
pduel
;
static
bool
is_closing
;
static
wchar_t
event_string
[
256
];
static
wchar_t
event_string
[
256
];
public:
public:
static
bool
StartPlay
();
static
bool
StartPlay
();
static
void
StopReplay
(
bool
is_exiting
=
false
);
static
void
StopPlay
(
bool
is_exiting
=
false
);
static
bool
ReadReplayResponse
();
static
int
SinglePlayThread
(
void
*
param
);
static
int
SinglePlayThread
(
void
*
param
);
static
bool
SinglePlayAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
bool
SinglePlayAnalyze
(
char
*
msg
,
unsigned
int
len
);
...
...
gframe/tag_duel.cpp
View file @
82c273f8
...
@@ -262,6 +262,7 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
...
@@ -262,6 +262,7 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
if
(
!
ready
[
0
]
||
!
ready
[
1
]
||
!
ready
[
2
]
||
!
ready
[
3
])
if
(
!
ready
[
0
]
||
!
ready
[
1
]
||
!
ready
[
2
]
||
!
ready
[
3
])
return
;
return
;
NetServer
::
StopListen
();
NetServer
::
StopListen
();
//NetServer::StopBroadcast();
for
(
int
i
=
0
;
i
<
4
;
++
i
)
for
(
int
i
=
0
;
i
<
4
;
++
i
)
NetServer
::
SendPacketToPlayer
(
players
[
i
],
STOC_DUEL_START
);
NetServer
::
SendPacketToPlayer
(
players
[
i
],
STOC_DUEL_START
);
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
{
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
{
...
...
ocgcore/duel.cpp
View file @
82c273f8
...
@@ -31,6 +31,21 @@ duel::~duel() {
...
@@ -31,6 +31,21 @@ duel::~duel() {
delete
lua
;
delete
lua
;
delete
game_field
;
delete
game_field
;
}
}
void
duel
::
clear
()
{
for
(
std
::
set
<
card
*>::
iterator
cit
=
cards
.
begin
();
cit
!=
cards
.
end
();
++
cit
)
delete
*
cit
;
for
(
std
::
set
<
group
*>::
iterator
git
=
groups
.
begin
();
git
!=
groups
.
end
();
++
git
)
delete
*
git
;
for
(
std
::
set
<
effect
*>::
iterator
eit
=
effects
.
begin
();
eit
!=
effects
.
end
();
++
eit
)
delete
*
eit
;
delete
lua
;
delete
game_field
;
lua
=
new
interpreter
(
this
);
game_field
=
new
field
(
this
);
game_field
->
temp_card
=
new_card
(
0
);
bufferlen
=
0
;
bufferp
=
buffer
;
}
card
*
duel
::
new_card
(
uint32
code
)
{
card
*
duel
::
new_card
(
uint32
code
)
{
card
*
pcard
=
new
card
();
card
*
pcard
=
new
card
();
cards
.
insert
(
pcard
);
cards
.
insert
(
pcard
);
...
...
ocgcore/duel.h
View file @
82c273f8
...
@@ -39,7 +39,8 @@ public:
...
@@ -39,7 +39,8 @@ public:
std
::
set
<
effect
*>
uncopy
;
std
::
set
<
effect
*>
uncopy
;
duel
();
duel
();
~
duel
();
~
duel
();
void
clear
();
card
*
new_card
(
uint32
code
);
card
*
new_card
(
uint32
code
);
group
*
new_group
(
card
*
pcard
=
0
);
group
*
new_group
(
card
*
pcard
=
0
);
effect
*
new_effect
();
effect
*
new_effect
();
...
...
ocgcore/field.cpp
View file @
82c273f8
...
@@ -84,6 +84,37 @@ field::field(duel* pduel) {
...
@@ -84,6 +84,37 @@ field::field(duel* pduel) {
field
::~
field
()
{
field
::~
field
()
{
}
}
void
field
::
reload_field_info
()
{
pduel
->
write_buffer8
(
MSG_RELOAD_FIELD
);
card
*
pcard
;
for
(
int
playerid
=
0
;
playerid
<
2
;
++
playerid
)
{
for
(
uint32
i
=
0
;
i
<
5
;
++
i
)
{
pcard
=
player
[
playerid
].
list_mzone
[
i
];
if
(
pcard
)
{
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer8
(
pcard
->
current
.
position
);
pduel
->
write_buffer8
(
pcard
->
xyz_materials
.
size
());
}
else
{
pduel
->
write_buffer8
(
0
);
}
}
for
(
uint32
i
=
0
;
i
<
6
;
++
i
)
{
pcard
=
player
[
playerid
].
list_szone
[
i
];
if
(
pcard
)
{
pduel
->
write_buffer8
(
1
);
pduel
->
write_buffer8
(
pcard
->
current
.
position
);
}
else
{
pduel
->
write_buffer8
(
0
);
}
}
pduel
->
write_buffer8
(
player
[
playerid
].
list_main
.
size
());
pduel
->
write_buffer8
(
player
[
playerid
].
list_hand
.
size
());
pduel
->
write_buffer8
(
player
[
playerid
].
list_grave
.
size
());
pduel
->
write_buffer8
(
player
[
playerid
].
list_remove
.
size
());
pduel
->
write_buffer8
(
player
[
playerid
].
list_extra
.
size
());
}
}
void
field
::
add_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
)
{
void
field
::
add_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
)
{
if
(
pcard
->
current
.
location
!=
0
)
if
(
pcard
->
current
.
location
!=
0
)
return
;
return
;
...
...
ocgcore/field.h
View file @
82c273f8
...
@@ -284,7 +284,8 @@ public:
...
@@ -284,7 +284,8 @@ public:
static
int32
field_used_count
[
32
];
static
int32
field_used_count
[
32
];
field
(
duel
*
pduel
);
field
(
duel
*
pduel
);
~
field
();
~
field
();
void
reload_field_info
();
void
add_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
);
void
add_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
);
void
remove_card
(
card
*
pcard
);
void
remove_card
(
card
*
pcard
);
void
move_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
);
void
move_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
);
...
@@ -728,4 +729,5 @@ public:
...
@@ -728,4 +729,5 @@ public:
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_CARD_HINT 160
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162
#endif
/* FIELD_H_ */
#endif
/* FIELD_H_ */
ocgcore/libdebug.cpp
View file @
82c273f8
...
@@ -83,6 +83,11 @@ int32 scriptlib::debug_set_duel_info(lua_State *L) {
...
@@ -83,6 +83,11 @@ int32 scriptlib::debug_set_duel_info(lua_State *L) {
return
0
;
return
0
;
}
}
int32
scriptlib
::
debug_reload_field_begin
(
lua_State
*
L
)
{
int32
scriptlib
::
debug_reload_field_begin
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
pduel
->
clear
();
}
}
int32
scriptlib
::
debug_reload_field_end
(
lua_State
*
L
)
{
int32
scriptlib
::
debug_reload_field_end
(
lua_State
*
L
)
{
duel
*
pduel
=
interpreter
::
get_duel_info
(
L
);
pduel
->
game_field
->
reload_field_info
();
return
0
;
}
}
ocgcore/ocgapi.cpp
View file @
82c273f8
...
@@ -282,6 +282,37 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
...
@@ -282,6 +282,37 @@ extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint
}
}
return
ct
;
return
ct
;
}
}
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
ptr
pduel
,
byte
*
buf
)
{
duel
*
ptduel
=
(
duel
*
)
pduel
;
*
buf
++
=
MSG_RELOAD_FIELD
;
card
*
pcard
;
for
(
int
playerid
=
0
;
playerid
<
2
;
++
playerid
)
{
for
(
uint32
i
=
0
;
i
<
5
;
++
i
)
{
pcard
=
ptduel
->
game_field
->
player
[
playerid
].
list_mzone
[
i
];
if
(
pcard
)
{
*
buf
++
=
1
;
*
buf
++
=
pcard
->
current
.
position
;
*
buf
++
=
pcard
->
xyz_materials
.
size
();
}
else
{
*
buf
++
=
0
;
}
}
for
(
uint32
i
=
0
;
i
<
6
;
++
i
)
{
pcard
=
ptduel
->
game_field
->
player
[
playerid
].
list_szone
[
i
];
if
(
pcard
)
{
*
buf
++
=
1
;
*
buf
++
=
pcard
->
current
.
position
;
}
else
{
*
buf
++
=
0
;
}
}
*
buf
++
=
ptduel
->
game_field
->
player
[
playerid
].
list_main
.
size
();
*
buf
++
=
ptduel
->
game_field
->
player
[
playerid
].
list_hand
.
size
();
*
buf
++
=
ptduel
->
game_field
->
player
[
playerid
].
list_grave
.
size
();
*
buf
++
=
ptduel
->
game_field
->
player
[
playerid
].
list_remove
.
size
();
*
buf
++
=
ptduel
->
game_field
->
player
[
playerid
].
list_extra
.
size
();
}
}
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
ptr
pduel
,
int32
value
)
{
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
ptr
pduel
,
int32
value
)
{
((
duel
*
)
pduel
)
->
set_responsei
(
value
);
((
duel
*
)
pduel
)
->
set_responsei
(
value
);
}
}
...
...
ocgcore/ocgapi.h
View file @
82c273f8
...
@@ -47,6 +47,7 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner,
...
@@ -47,6 +47,7 @@ extern "C" DECL_DLLEXPORT void new_tag_card(ptr pduel, uint32 code, uint8 owner,
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
ptr
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_card
(
ptr
pduel
,
uint8
playerid
,
uint8
location
,
uint8
sequence
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
ptr
pduel
,
uint8
playerid
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_count
(
ptr
pduel
,
uint8
playerid
,
uint8
location
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
ptr
pduel
,
uint8
playerid
,
uint8
location
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_card
(
ptr
pduel
,
uint8
playerid
,
uint8
location
,
int32
query_flag
,
byte
*
buf
,
int32
use_cache
);
extern
"C"
DECL_DLLEXPORT
int32
query_field_info
(
ptr
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
ptr
pduel
,
int32
value
);
extern
"C"
DECL_DLLEXPORT
void
set_responsei
(
ptr
pduel
,
int32
value
);
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
ptr
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
void
set_responseb
(
ptr
pduel
,
byte
*
buf
);
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
ptr
pduel
,
char
*
script
,
int32
len
);
extern
"C"
DECL_DLLEXPORT
int32
preload_script
(
ptr
pduel
,
char
*
script
,
int32
len
);
...
...
script/constant.lua
View file @
82c273f8
...
@@ -594,3 +594,11 @@ TIMING_TODECK =0x400000
...
@@ -594,3 +594,11 @@ TIMING_TODECK =0x400000
TIMING_TOGRAVE
=
0x800000
TIMING_TOGRAVE
=
0x800000
TIMING_BATTLE_PHASE
=
0x1000000
TIMING_BATTLE_PHASE
=
0x1000000
TIMING_EQUIP
=
0x2000000
TIMING_EQUIP
=
0x2000000
--
DUEL_TEST_MODE
=
0x01
DUEL_ATTACK_FIRST_TURN
=
0x02
DUEL_NO_CHAIN_HINT
=
0x04
DUEL_ENABLE_PRIORITY
=
0x08
DUEL_PSEUDO_SHUFFLE
=
0x10
DUEL_TAG_MODE
=
0x20
DUEL_SIMPLE_AI
=
0x40
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