diff --git a/src/ctf_gameserver/checker/database.py b/src/ctf_gameserver/checker/database.py index a493a0e..8cb7926 100644 --- a/src/ctf_gameserver/checker/database.py +++ b/src/ctf_gameserver/checker/database.py @@ -67,8 +67,8 @@ def get_check_duration(db_conn, service_id, std_dev_count, prohibit_changes=Fals """ with transaction_cursor(db_conn, prohibit_changes) as cursor: - cursor.execute('SELECT avg(extract(epoch from (placement_end - placement_start))) + %s *' - ' stddev_pop(extract(epoch from (placement_end - placement_start)))' + cursor.execute('SELECT (avg(extract(epoch from (placement_end - placement_start))) + %s *' + ' stddev_pop(extract(epoch from (placement_end - placement_start))))::float' ' FROM scoring_flag, scoring_gamecontrol' ' WHERE service_id = %s AND tick < current_tick', (std_dev_count, service_id)) result = cursor.fetchone() diff --git a/src/ctf_gameserver/checkerlib/lib.py b/src/ctf_gameserver/checkerlib/lib.py index 934143b..b66b7f8 100644 --- a/src/ctf_gameserver/checkerlib/lib.py +++ b/src/ctf_gameserver/checkerlib/lib.py @@ -120,6 +120,9 @@ def get_flag(tick: int) -> str: current run. The returned flag can be used for both placement and checks. """ + if not isinstance(tick, int): + raise TypeError('tick must be of type int') + # Return dummy flag when launched locally if _launched_without_runner(): try: @@ -140,6 +143,9 @@ def set_flagid(data: str) -> None: Stores the Flag ID for the current team and tick. """ + if not isinstance(data, str): + raise TypeError('data must be of type str') + if not _launched_without_runner(): _send_ctrl_message({'action': 'FLAGID', 'param': data}) # Wait for acknowledgement @@ -154,6 +160,9 @@ def store_state(key: str, data: Any) -> None: service and team with the given key as an additional identifier. """ + if not isinstance(key, str): + raise TypeError('key must be of type str') + serialized_data = base64.b64encode(pickle.dumps(data)).decode('ascii') if not _launched_without_runner(): @@ -178,6 +187,9 @@ def load_state(key: str) -> Any: current service and team), None is returned. """ + if not isinstance(key, str): + raise TypeError('key must be of type str') + if not _launched_without_runner(): _send_ctrl_message({'action': 'LOAD', 'param': key}) result = _recv_ctrl_message() diff --git a/src/ctf_gameserver/controller/database.py b/src/ctf_gameserver/controller/database.py index 239ce06..f501749 100644 --- a/src/ctf_gameserver/controller/database.py +++ b/src/ctf_gameserver/controller/database.py @@ -27,7 +27,8 @@ def get_control_info(db_conn, prohibit_changes=False): def increase_tick(db_conn, prohibit_changes=False): with transaction_cursor(db_conn, prohibit_changes) as cursor: - cursor.execute('UPDATE scoring_gamecontrol SET current_tick = current_tick + 1, cancel_checks = 0') + cursor.execute('UPDATE scoring_gamecontrol SET current_tick = current_tick + 1,' + ' cancel_checks = false') # Create flags for every service and team in the new tick cursor.execute('INSERT INTO scoring_flag (service_id, protecting_team_id, tick)' ' SELECT service.id, team.user_id, control.current_tick' @@ -39,7 +40,7 @@ def increase_tick(db_conn, prohibit_changes=False): def cancel_checks(db_conn, prohibit_changes=False): with transaction_cursor(db_conn, prohibit_changes) as cursor: - cursor.execute('UPDATE scoring_gamecontrol SET cancel_checks = 1') + cursor.execute('UPDATE scoring_gamecontrol SET cancel_checks = true') def update_scoring(db_conn): diff --git a/src/ctf_gameserver/web/templates/base-common.html b/src/ctf_gameserver/web/templates/base-common.html index bd8975d..501e188 100644 --- a/src/ctf_gameserver/web/templates/base-common.html +++ b/src/ctf_gameserver/web/templates/base-common.html @@ -22,7 +22,7 @@