Skip to content

Commit ae163bc

Browse files
committed
fixed bugs in the source
1 parent 5c45074 commit ae163bc

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lib/Narsil/Frontend.pm

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,18 @@ get '/match/:id' => sub {
256256
my $userid = user()->{username};
257257

258258
my $matchid = param('id');
259-
my $match = get_match($matchid) or do {
260-
flash error => no_match => $matchid;
261-
return redirect request.uri_for('/');
262-
};
263-
264-
my $game = get_game($match->{game}) or do {
265-
flash error => no_game => $match->{game};
266-
return redirect request.uri_for('/');
259+
my ($match, $game);
260+
try {
261+
$match = get_match($matchid) or do {
262+
flash error => no_match => $matchid;
263+
die {};
264+
};
265+
$game = get_game($match->{game}) or do {
266+
flash error => no_game => $match->{game};
267+
die {};
268+
};
267269
};
270+
return redirect request()->uri_for('/') unless defined $game;
268271

269272
my $gameid = $game->{id};
270273
my $template = "games/$gameid";
@@ -304,7 +307,7 @@ post '/match' => sub {
304307
catch {
305308
warning "caught error during forward: $_";
306309
};
307-
return redirect request . uri_for('/');
310+
return redirect request()->uri_for('/');
308311
};
309312

310313
post '/match/joins/:id' => sub {
@@ -323,7 +326,7 @@ post '/match/joins/:id' => sub {
323326
else {
324327
flash warning => 'join_pending';
325328
}
326-
return redirect '/';
329+
return redirect request()->uri_for('/');
327330
};
328331

329332
post '/move' => sub {
@@ -357,7 +360,7 @@ post '/move' => sub {
357360
};
358361

359362
#flash info => debug => to_json($move);
360-
return redirect "/match/$matchid";
363+
return redirect request()->uri_for("/match/$matchid");
361364
};
362365

363366
get '/game/:id' => sub {

views/layouts/main_/flash/no_match.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Match <% report.2 | html > does not exist
1+
Match <% report.2 | html %> does not exist

0 commit comments

Comments
 (0)