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
YGOPRO-520DIY
ygopro
Commits
1b3cbe32
Commit
1b3cbe32
authored
Aug 30, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add backup time
parent
48347267
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
2 deletions
+53
-2
gframe/netserver.cpp
gframe/netserver.cpp
+21
-0
gframe/netserver.h
gframe/netserver.h
+1
-0
gframe/single_duel.cpp
gframe/single_duel.cpp
+15
-0
gframe/single_duel.h
gframe/single_duel.h
+2
-1
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+12
-0
gframe/tag_duel.h
gframe/tag_duel.h
+2
-1
No files found.
gframe/netserver.cpp
View file @
1b3cbe32
...
...
@@ -55,6 +55,27 @@ void NetServer::InitDuel()
BufferIO
::
CopyWStr
(
pkt
->
pass
,
duel_mode
->
pass
,
20
);
}
bool
NetServer
::
IsCanIncreaseTime
(
unsigned
short
gameMsg
,
void
*
pdata
,
unsigned
int
len
)
{
int32
*
ivalue
=
(
int32
*
)
pdata
;
switch
(
gameMsg
)
{
case
MSG_RETRY
:
case
MSG_SELECT_UNSELECT_CARD
:
return
false
;
case
MSG_SELECT_CHAIN
:
return
ivalue
[
0
]
!=
-
1
;
case
MSG_SELECT_IDLECMD
:
{
int32
idleChoice
=
ivalue
[
0
]
&
0xffff
;
return
idleChoice
<=
5
;
// no shuffle hand, enter other phases
}
case
MSG_SELECT_BATTLECMD
:
{
int32
battleChoice
=
ivalue
[
0
]
&
0xffff
;
return
battleChoice
<=
1
;
// attack only
}
default:
return
true
;
}
}
unsigned
short
NetServer
::
StartServer
(
unsigned
short
port
)
{
#else
bool
NetServer
::
StartServer
(
unsigned
short
port
)
{
...
...
gframe/netserver.h
View file @
1b3cbe32
...
...
@@ -29,6 +29,7 @@ public:
static
event_base
*
net_evbase
;
static
void
InitDuel
();
static
unsigned
short
StartServer
(
unsigned
short
port
);
static
bool
IsCanIncreaseTime
(
unsigned
short
gameMsg
,
void
*
pdata
,
unsigned
int
len
);
#else
static
bool
StartServer
(
unsigned
short
port
);
#endif //YGOPRO_SERVER_MODE
...
...
gframe/single_duel.cpp
View file @
1b3cbe32
...
...
@@ -627,6 +627,9 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
#ifdef YGOPRO_SERVER_MODE
time_compensator
[
0
]
=
host_info
.
time_limit
;
time_compensator
[
1
]
=
host_info
.
time_limit
;
time_backed
[
0
]
=
host_info
.
time_limit
;
time_backed
[
1
]
=
host_info
.
time_limit
;
last_game_msg
=
0
;
#endif
timeval
timeout
=
{
1
,
0
};
event_add
(
etimer
,
&
timeout
);
...
...
@@ -741,6 +744,9 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
while
(
pbuf
-
msgbuffer
<
(
int
)
len
)
{
offset
=
pbuf
;
unsigned
char
engType
=
BufferIO
::
ReadUInt8
(
pbuf
);
#ifdef YGOPRO_SERVER_MODE
last_game_msg
=
engType
;
#endif
switch
(
engType
)
{
case
MSG_RETRY
:
{
WaitforResponse
(
last_response
);
...
...
@@ -1143,6 +1149,8 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
#ifdef YGOPRO_SERVER_MODE
time_compensator
[
0
]
=
host_info
.
time_limit
;
time_compensator
[
1
]
=
host_info
.
time_limit
;
time_backed
[
0
]
=
host_info
.
time_limit
;
time_backed
[
1
]
=
host_info
.
time_limit
;
#endif
NetServer
::
SendBufferToPlayer
(
players
[
0
],
STOC_GAME_MSG
,
offset
,
pbuf
-
offset
);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
...
...
@@ -1769,6 +1777,13 @@ void SingleDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
time_limit
[
dp
->
type
]
-=
time_elapsed
;
else
time_limit
[
dp
->
type
]
=
0
;
time_elapsed
=
0
;
#ifdef YGOPRO_SERVER_MODE
if
(
time_backed
[
dp
->
type
]
>
0
&&
time_limit
[
dp
->
type
]
<
host_info
.
time_limit
&&
NetServer
::
IsCanIncreaseTime
(
last_game_msg
,
pdata
,
len
))
{
++
time_limit
[
dp
->
type
];
++
time_compensator
[
dp
->
type
];
--
time_backed
[
dp
->
type
];
}
#endif
}
Process
();
}
...
...
gframe/single_duel.h
View file @
1b3cbe32
...
...
@@ -78,10 +78,11 @@ protected:
short
time_elapsed
;
#ifdef YGOPRO_SERVER_MODE
short
time_compensator
[
2
];
short
time_backed
[
2
];
unsigned
char
last_game_msg
;
#endif
};
}
#endif //SINGLE_DUEL_H
gframe/tag_duel.cpp
View file @
1b3cbe32
...
...
@@ -626,6 +626,9 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
#ifdef YGOPRO_SERVER_MODE
time_compensator
[
0
]
=
host_info
.
time_limit
;
time_compensator
[
1
]
=
host_info
.
time_limit
;
time_backed
[
0
]
=
host_info
.
time_limit
;
time_backed
[
1
]
=
host_info
.
time_limit
;
last_game_msg
=
0
;
#endif
timeval
timeout
=
{
1
,
0
};
event_add
(
etimer
,
&
timeout
);
...
...
@@ -1081,6 +1084,8 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
#ifdef YGOPRO_SERVER_MODE
time_compensator
[
0
]
=
host_info
.
time_limit
;
time_compensator
[
1
]
=
host_info
.
time_limit
;
time_backed
[
0
]
=
host_info
.
time_limit
;
time_backed
[
1
]
=
host_info
.
time_limit
;
#endif
NetServer
::
SendBufferToPlayer
(
players
[
0
],
STOC_GAME_MSG
,
offset
,
pbuf
-
offset
);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
...
...
@@ -1836,6 +1841,13 @@ void TagDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
time_limit
[
resp_type
]
-=
time_elapsed
;
else
time_limit
[
resp_type
]
=
0
;
time_elapsed
=
0
;
#ifdef YGOPRO_SERVER_MODE
if
(
time_backed
[
resp_type
]
>
0
&&
time_limit
[
resp_type
]
<
host_info
.
time_limit
&&
NetServer
::
IsCanIncreaseTime
(
last_game_msg
,
pdata
,
len
))
{
++
time_limit
[
resp_type
];
++
time_compensator
[
resp_type
];
--
time_backed
[
resp_type
];
}
#endif
}
Process
();
}
...
...
gframe/tag_duel.h
View file @
1b3cbe32
...
...
@@ -75,10 +75,11 @@ protected:
short
time_elapsed
;
#ifdef YGOPRO_SERVER_MODE
short
time_compensator
[
2
];
short
time_backed
[
2
];
unsigned
char
last_game_msg
;
#endif
};
}
#endif //TAG_DUEL_H
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