|
|
@ -60,8 +60,9 @@ def create_game(): |
|
|
|
cur.execute("SELECT * FROM games WHERE port=?", (port,)) |
|
|
|
rows = cur.fetchall() |
|
|
|
|
|
|
|
if game_count == MAX_GAMES: |
|
|
|
if game_count >= MAX_GAMES: |
|
|
|
abort(401) |
|
|
|
return |
|
|
|
|
|
|
|
# check duplicate name |
|
|
|
base_name = name |
|
|
@ -84,13 +85,18 @@ def create_game(): |
|
|
|
result = cur.fetchone() |
|
|
|
if result[0]: |
|
|
|
games[result[0]] = subprocess.Popen([GAME_EXEC, |
|
|
|
GAME_EXEC_ARG_PACK,GAME_EXEC_ARG_PACK_PATH, |
|
|
|
GAME_EXEC_ARG_ID.format(int(result[0])), |
|
|
|
GAME_EXEC_ARG_PORT.format(port), |
|
|
|
GAME_EXEC_ARG_SECRET.format(secret), |
|
|
|
GAME_EXEC_ARG_BOTS.format(int(bots)), |
|
|
|
GAME_EXEC_ARG_SERVER_ADDR.format('127.0.0.1'), # localhost |
|
|
|
GAME_EXEC_ARG_API_ADDR.format('http://127.0.0.1:5000/')]) |
|
|
|
GAME_EXEC_ARG_PACK, GAME_EXEC_ARG_PACK_PATH, |
|
|
|
GAME_EXEC_ARG_ID.format( |
|
|
|
int(result[0])), |
|
|
|
GAME_EXEC_ARG_PORT.format( |
|
|
|
port), |
|
|
|
GAME_EXEC_ARG_SECRET.format( |
|
|
|
secret), |
|
|
|
GAME_EXEC_ARG_BOTS.format( |
|
|
|
int(bots)), |
|
|
|
GAME_EXEC_ARG_SERVER_ADDR.format( |
|
|
|
'127.0.0.1'), # localhost |
|
|
|
GAME_EXEC_ARG_API_ADDR.format('http://127.0.0.1:5000/')]) |
|
|
|
except: |
|
|
|
con.rollback() |
|
|
|
abort(500) |
|
|
@ -184,4 +190,4 @@ def close_game(): |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
app.run(debug=True,host='0.0.0.0',port=5000) |
|
|
|
app.run(debug=True, host='0.0.0.0', port=5000) |