diff --git a/.gitignore b/.gitignore index fcee6fe..3a8d460 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ storage/* !storage/force_dir_in_git.txt example-requests/* zoffline.log -migrate_auth.sql \ No newline at end of file +migrate_auth.sql +bots \ No newline at end of file diff --git a/cdn/static/web/launcher/user_home.html b/cdn/static/web/launcher/user_home.html index f2ea73f..c1bea00 100644 --- a/cdn/static/web/launcher/user_home.html +++ b/cdn/static/web/launcher/user_home.html @@ -20,6 +20,9 @@ {% elif is_admin %} Cancel restart {% endif %} + {% if is_admin %} + Reload bots + {% endif %} {% endif %} diff --git a/standalone.py b/standalone.py index 6bc2803..8015117 100755 --- a/standalone.py +++ b/standalone.py @@ -402,7 +402,12 @@ def load_bots(): bot.position = 0 def play_bots(): + global global_bots while True: + if zwift_offline.reload_pacer_bots: + zwift_offline.reload_pacer_bots = False + global_bots.clear() + load_bots() for bot_id in global_bots.keys(): bot = global_bots[bot_id] if bot.position < len(bot.route.states) - 1: bot.position += 1 diff --git a/zwift_offline.py b/zwift_offline.py index 2689bb7..ab0c730 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -99,6 +99,7 @@ app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 db = SQLAlchemy(app) online = {} global_pace_partners = {} +global_bots = {} ghosts_enabled = {} player_update_queue = {} player_ids = {} @@ -106,6 +107,7 @@ player_partial_profiles = {} save_ghost = None restarting = False restarting_in_minutes = 0 +reload_pacer_bots = False class User(UserMixin, db.Model): player_id = db.Column(db.Integer, primary_key=True) @@ -384,6 +386,14 @@ def cancel_restart_server(): send_message_to_all_online('Restart of the server has been cancelled. Ride on!') return redirect('/user/%s/' % current_user.username) +@app.route("/reloadbots") +@login_required +def reload_bots(): + global reload_pacer_bots + if bool(current_user.is_admin): + reload_pacer_bots = True + return redirect('/user/%s/' % current_user.username) + @app.route("/upload//", methods=["GET", "POST"]) @login_required def upload(username):