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
REIKAI
ygopro
Commits
545f42bf
Commit
545f42bf
authored
Sep 28, 2022
by
mercury233
Committed by
GitHub
Sep 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update time limit handling (#2296)
parent
7f1e1135
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
14 deletions
+30
-14
gframe/single_duel.cpp
gframe/single_duel.cpp
+13
-5
gframe/single_duel.h
gframe/single_duel.h
+2
-2
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+13
-5
gframe/tag_duel.h
gframe/tag_duel.h
+2
-2
No files found.
gframe/single_duel.cpp
View file @
545f42bf
...
...
@@ -484,6 +484,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra
(
0
);
RefreshExtra
(
1
);
start_duel
(
pduel
,
opt
);
if
(
host_info
.
time_limit
)
{
time_elapsed
=
0
;
timeval
timeout
=
{
1
,
0
};
event_add
(
etimer
,
&
timeout
);
}
Process
();
}
void
SingleDuel
::
Process
()
{
...
...
@@ -1410,7 +1415,7 @@ void SingleDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if
(
time_limit
[
dp
->
type
]
>=
time_elapsed
)
time_limit
[
dp
->
type
]
-=
time_elapsed
;
else
time_limit
[
dp
->
type
]
=
0
;
event_del
(
etimer
)
;
time_elapsed
=
0
;
}
Process
();
}
...
...
@@ -1427,6 +1432,7 @@ void SingleDuel::EndDuel() {
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
NetServer
::
ReSendToPlayer
(
*
oit
);
end_duel
(
pduel
);
event_del
(
etimer
);
pduel
=
0
;
}
void
SingleDuel
::
WaitforResponse
(
int
playerid
)
{
...
...
@@ -1449,9 +1455,8 @@ void SingleDuel::TimeConfirm(DuelPlayer* dp) {
if
(
dp
->
type
!=
last_response
)
return
;
players
[
last_response
]
->
state
=
CTOS_RESPONSE
;
time_elapsed
=
0
;
timeval
timeout
=
{
1
,
0
};
event_add
(
etimer
,
&
timeout
);
if
(
time_elapsed
<
10
)
time_elapsed
=
0
;
}
void
SingleDuel
::
RefreshMzone
(
int
player
,
int
flag
,
int
use_cache
)
{
char
query_buffer
[
0x2000
];
...
...
@@ -1571,7 +1576,7 @@ int SingleDuel::MessageHandler(long fduel, int type) {
void
SingleDuel
::
SingleTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
)
{
SingleDuel
*
sd
=
static_cast
<
SingleDuel
*>
(
arg
);
sd
->
time_elapsed
++
;
if
(
sd
->
time_elapsed
>=
sd
->
time_limit
[
sd
->
last_response
])
{
if
(
sd
->
time_elapsed
>=
sd
->
time_limit
[
sd
->
last_response
]
||
sd
->
time_limit
[
sd
->
last_response
]
<=
0
)
{
unsigned
char
wbuf
[
3
];
uint32
player
=
sd
->
last_response
;
wbuf
[
0
]
=
MSG_WIN
;
...
...
@@ -1591,7 +1596,10 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
sd
->
EndDuel
();
sd
->
DuelEndProc
();
event_del
(
sd
->
etimer
);
return
;
}
timeval
timeout
=
{
1
,
0
};
event_add
(
sd
->
etimer
,
&
timeout
);
}
}
gframe/single_duel.h
View file @
545f42bf
...
...
@@ -56,8 +56,8 @@ protected:
unsigned
char
duel_count
;
unsigned
char
tp_player
;
unsigned
char
match_result
[
3
];
unsigned
short
time_limit
[
2
];
unsigned
short
time_elapsed
;
short
time_limit
[
2
];
short
time_elapsed
;
};
}
...
...
gframe/tag_duel.cpp
View file @
545f42bf
...
...
@@ -480,6 +480,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra
(
0
);
RefreshExtra
(
1
);
start_duel
(
pduel
,
opt
);
if
(
host_info
.
time_limit
)
{
time_elapsed
=
0
;
timeval
timeout
=
{
1
,
0
};
event_add
(
etimer
,
&
timeout
);
}
Process
();
}
void
TagDuel
::
Process
()
{
...
...
@@ -1491,7 +1496,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if
(
time_limit
[
resp_type
]
>=
time_elapsed
)
time_limit
[
resp_type
]
-=
time_elapsed
;
else
time_limit
[
resp_type
]
=
0
;
event_del
(
etimer
)
;
time_elapsed
=
0
;
}
Process
();
}
...
...
@@ -1510,6 +1515,7 @@ void TagDuel::EndDuel() {
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
NetServer
::
ReSendToPlayer
(
*
oit
);
end_duel
(
pduel
);
event_del
(
etimer
);
pduel
=
0
;
}
void
TagDuel
::
WaitforResponse
(
int
playerid
)
{
...
...
@@ -1536,9 +1542,8 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) {
if
(
dp
!=
cur_player
[
last_response
])
return
;
cur_player
[
last_response
]
->
state
=
CTOS_RESPONSE
;
time_elapsed
=
0
;
timeval
timeout
=
{
1
,
0
};
event_add
(
etimer
,
&
timeout
);
if
(
time_elapsed
<
10
)
time_elapsed
=
0
;
}
void
TagDuel
::
RefreshMzone
(
int
player
,
int
flag
,
int
use_cache
)
{
char
query_buffer
[
0x4000
];
...
...
@@ -1687,7 +1692,7 @@ int TagDuel::MessageHandler(long fduel, int type) {
void
TagDuel
::
TagTimer
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
)
{
TagDuel
*
sd
=
static_cast
<
TagDuel
*>
(
arg
);
sd
->
time_elapsed
++
;
if
(
sd
->
time_elapsed
>=
sd
->
time_limit
[
sd
->
last_response
])
{
if
(
sd
->
time_elapsed
>=
sd
->
time_limit
[
sd
->
last_response
]
||
sd
->
time_limit
[
sd
->
last_response
]
<=
0
)
{
unsigned
char
wbuf
[
3
];
uint32
player
=
sd
->
last_response
;
wbuf
[
0
]
=
MSG_WIN
;
...
...
@@ -1700,7 +1705,10 @@ void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
sd
->
EndDuel
();
sd
->
DuelEndProc
();
event_del
(
sd
->
etimer
);
return
;
}
timeval
timeout
=
{
1
,
0
};
event_add
(
sd
->
etimer
,
&
timeout
);
}
}
gframe/tag_duel.h
View file @
545f42bf
...
...
@@ -53,8 +53,8 @@ protected:
unsigned
char
last_response
;
Replay
last_replay
;
unsigned
char
turn_count
;
unsigned
short
time_limit
[
2
];
unsigned
short
time_elapsed
;
short
time_limit
[
2
];
short
time_elapsed
;
};
}
...
...
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