mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Prevent server crash if DB is down and game is attempted to be created (#5600)
This commit is contained in:
parent
80bd783d54
commit
cb060f43b5
2 changed files with 17 additions and 13 deletions
|
|
@ -790,9 +790,6 @@ Server_ProtocolHandler::cmdCreateGame(const Command_CreateGame &cmd, Server_Room
|
|||
{
|
||||
if (authState == NotLoggedIn)
|
||||
return Response::RespLoginNeeded;
|
||||
const int gameId = databaseInterface->getNextGameId();
|
||||
if (gameId == -1)
|
||||
return Response::RespInternalError;
|
||||
if (cmd.password().length() > MAX_NAME_LENGTH)
|
||||
return Response::RespContextError;
|
||||
|
||||
|
|
@ -821,6 +818,11 @@ Server_ProtocolHandler::cmdCreateGame(const Command_CreateGame &cmd, Server_Room
|
|||
QString description = nameFromStdString(cmd.description());
|
||||
int startingLifeTotal = cmd.has_starting_life_total() ? cmd.starting_life_total() : 20;
|
||||
|
||||
const int gameId = databaseInterface->getNextGameId();
|
||||
if (gameId == -1) {
|
||||
return Response::RespInternalError;
|
||||
}
|
||||
|
||||
// When server doesn't permit registered users to exist, do not honor only-reg setting
|
||||
bool onlyRegisteredUsers = cmd.only_registered() && (server->permitUnregisteredUsers());
|
||||
Server_Game *game = new Server_Game(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue