From 1606653546958fd6d621809ab3cfdc8c5e7b8494 Mon Sep 17 00:00:00 2001 From: Philip Paquette Date: Mon, 9 Sep 2019 17:57:09 -0400 Subject: Added ability to load a custom map by specifying the path to a '.map' file --- diplomacy/utils/convoy_paths.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'diplomacy/utils') diff --git a/diplomacy/utils/convoy_paths.py b/diplomacy/utils/convoy_paths.py index 5929d51..27b6836 100644 --- a/diplomacy/utils/convoy_paths.py +++ b/diplomacy/utils/convoy_paths.py @@ -188,7 +188,10 @@ def add_to_cache(map_name): pass # Getting map MD5 hash - map_path = os.path.join(settings.PACKAGE_DIR, 'maps', map_name + '.map') + if os.path.exists(map_name): + map_path = map_name + else: + map_path = os.path.join(settings.PACKAGE_DIR, 'maps', map_name + '.map') if not os.path.exists(map_path): return None map_hash = get_file_md5(map_path) @@ -227,6 +230,7 @@ def get_convoy_paths_cache(): map_hash = get_file_md5(file_path) if map_hash in disk_convoy_paths: cache_convoy_paths[map_name] = disk_convoy_paths[map_hash] + cache_convoy_paths[file_path] = disk_convoy_paths[map_hash] # Returning return cache_convoy_paths -- cgit v1.2.3