From 55c8264cd795f859e5a22932bc2ac056051efe0e Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 24 Apr 2015 20:46:49 +0200 Subject: [PATCH] Fixes #129. --- nas_server.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/nas_server.py b/nas_server.py index 391808d..1f87689 100644 --- a/nas_server.py +++ b/nas_server.py @@ -239,17 +239,18 @@ class NasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler): # Look for a list file first. # If the list file exists, send the entire thing back to the client. if os.path.isfile(os.path.join(dlcpath, "_list.txt")): - ret = self.filter_list(safeloadfi("_list.txt"), attr1, attr2, attr3, num, offset) - - # Don't try to filter any further if the list is empty. - if ret.strip() != "": - # this is super game-specific, but we need to handle gen 5 mystery gifts properly somehow - if post["gamecd"].startswith("IRA") and attr1.startswith("MYSTERY"): - ret = self.filter_list_g5_mystery_gift(ret, post["rhgamecd"]) - ret = self.filter_list_by_date(ret, post["token"]) - - if post["gamecd"] in gamecodes_return_random_file: - ret = self.filter_list_by_date(ret, post["token"]) + if post["gamecd"].startswith("IRA") and attr1.startswith("MYSTERY"): + # Pokemon BW Mystery Gifts, until we have a better solution for that + ret = self.filter_list(safeloadfi("_list.txt"), attr1, attr2, attr3) + ret = self.filter_list_g5_mystery_gift(ret, post["rhgamecd"]) + ret = self.filter_list_by_date(ret, post["token"]) + elif post["gamecd"] in gamecodes_return_random_file: + # Pokemon Gen 4 Mystery Gifts, same here + ret = self.filter_list(safeloadfi("_list.txt"), attr1, attr2, attr3) + ret = self.filter_list_by_date(ret, post["token"]) + else: + # default case for most games + ret = self.filter_list(safeloadfi("_list.txt"), attr1, attr2, attr3, num, offset) if action == "contents": # Get only the base filename just in case there is a path involved somewhere in the filename string.