diff --git a/doc/Database.odt b/doc/Database.odt new file mode 100644 index 0000000..1fdd9a3 Binary files /dev/null and b/doc/Database.odt differ diff --git a/doc/Database.pdf b/doc/Database.pdf new file mode 100644 index 0000000..7aec758 Binary files /dev/null and b/doc/Database.pdf differ diff --git a/utils/README b/utils/README index af0246c..c5034b2 100644 --- a/utils/README +++ b/utils/README @@ -4,7 +4,9 @@ Only the ones that I can play through without getting stuck because of a bug will stay in the database. You can access the files here like this ~/.local/share/TombRaiderLinuxLauncher/5.TRLE If the directory 5.TRLE would be missing it will attempt to try -installing it. +installing it. If you use you own database you can update it +with updateDB_1.0.0.py. + 1.The Infada Cult https://www.trle.net/sc/levelfeatures.php?lid=3573 @@ -52,4 +54,14 @@ installing it. https://www.trle.net/sc/levelfeatures.php?lid=3557 have not played through all of the game no problems + I manage to port this one to Linux native thru TR1X + I got the fist level, sound and video working + but start menu is now different from original + If i do this is should be exactly like the original + but with restored braid, better graphics, but most important no lags. + And it should be dark. I will put a patch for TR1X and a bash script + that will install all the game data into to built game or something + like that. +9.The Experiment 3/1 - Under the Moonlight + https://www.trle.net/sc/levelfeatures.php?lid=1388 diff --git a/utils/addData.py b/utils/addData.py index 83c48ab..7732d8d 100644 --- a/utils/addData.py +++ b/utils/addData.py @@ -91,11 +91,19 @@ def download_file(url, cert, file_name): info_difficulty = file_info.get('difficulty') info_duration = file_info.get('duration') -c.execute("SELECT InfoDifficultyID FROM InfoDifficulty WHERE value = ?", (info_difficulty,)) -difficulty_id = c.fetchone()[0] - -c.execute("SELECT InfoDurationID FROM InfoDuration WHERE value = ?", (info_duration,)) -duration_id = c.fetchone()[0] +difficulty_id = None +if info_difficulty != "missing": + c.execute("SELECT InfoDifficultyID FROM InfoDifficulty WHERE value = ?", (info_difficulty,)) + result = c.fetchone() + if result: + difficulty_id = result[0] + +duration_id = None +if info_duration != "missing": + c.execute("SELECT InfoDurationID FROM InfoDuration WHERE value = ?", (info_duration,)) + result = c.fetchone() + if result: + duration_id = result[0] c.execute("SELECT InfoTypeID FROM InfoType WHERE value = ?", (info_type,)) type_id = c.fetchone()[0] diff --git a/utils/getData.py b/utils/getData.py index cd93b97..c0aa1cd 100644 --- a/utils/getData.py +++ b/utils/getData.py @@ -61,8 +61,24 @@ type = soup.find('td', string='file type:').find_next('td').get_text(strip=True) or "missing" class_ = soup.find('td', string='class:').find_next('td').get_text(strip=True) or "missing" releaseDate = soup.find('td', string='release date:').find_next('td').get_text(strip=True) or "missing" - difficulty = soup.find('td', string='difficulty:').find_next('td').get_text(strip=True) or "missing" - duration = soup.find('td', string='duration:').find_next('td').get_text(strip=True) or "missing" + difficulty_td = soup.find('td', string='difficulty:') + if difficulty_td: + next_td = difficulty_td.find_next('td') + if next_td: + difficulty = next_td.get_text(strip=True) + else: + difficulty = "missing" + else: + difficulty = "missing" + duration_td = soup.find('td', string='duration:') + if duration_td: + next_td = duration_td.find_next('td') + if next_td: + duration = next_td.get_text(strip=True) + else: + duration = "missing" + else: + duration = "missing" specific_tags = soup.find_all('td', class_='medGText', align='left', valign='top') body = specific_tags[1] if len(specific_tags) >= 2 else "missing" diff --git a/utils/makeDatabase.py b/utils/makeDatabase.py index 9c9651a..07c95a3 100644 --- a/utils/makeDatabase.py +++ b/utils/makeDatabase.py @@ -41,8 +41,8 @@ title TEXT NOT NULL, author TEXT NOT NULL, release DATE NOT NULL, - difficulty INT NOT NULL, - duration INT NOT NULL, + difficulty INT, + duration INT, type INT NOT NULL, class INT NOT NULL, FOREIGN KEY (difficulty) REFERENCES InfoDifficulty(InfoDifficultyID), @@ -117,7 +117,7 @@ class INT NOT NULL, FOREIGN KEY (levelID) REFERENCES Level(LevelID) )''') -c.execute("INSERT INTO InfoClass (value) VALUES (?)", ('Alien/Space',)) +c.execute("INSERT INTO infoclass (value) VALUES (?)", ('Alien/Space',)) c.execute("INSERT INTO InfoClass (value) VALUES (?)", ('Atlantis',)) c.execute("INSERT INTO InfoClass (value) VALUES (?)", ('Base/Lab',)) c.execute("INSERT INTO InfoClass (value) VALUES (?)", ('Cambodia',)) diff --git a/utils/tombll.db b/utils/tombll.db index 24b965b..1d2eda8 100644 Binary files a/utils/tombll.db and b/utils/tombll.db differ diff --git a/utils/updateDB_1.0.0.py b/utils/updateDB_1.0.0.py new file mode 100644 index 0000000..6fe0f25 --- /dev/null +++ b/utils/updateDB_1.0.0.py @@ -0,0 +1,70 @@ +import sys +import logging +import sqlite3 + +if __name__ == "__main__": + if len(sys.argv) != 2: + logging.error("Usage: python3 updateDB_1.0.0.py path/to/tombll.db") + sys.exit(1) + else: + arg_path = sys.argv[1] + +def update_table_schema_and_data(db_path): + conn = sqlite3.connect(db_path) + cursor = conn.cursor() + + # Begin a transaction + cursor.execute('BEGIN TRANSACTION;') + + try: + # Step 1: Rename the existing Info table + cursor.execute('ALTER TABLE Info RENAME TO Info_old;') + + # Step 2: Create the new Info table with the updated schema + cursor.execute(''' + CREATE TABLE Info ( + InfoID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + title TEXT NOT NULL, + author TEXT NOT NULL, + release DATE NOT NULL, + difficulty INT, + duration INT, + type INT NOT NULL, + class INT NOT NULL, + FOREIGN KEY (difficulty) REFERENCES InfoDifficulty(InfoDifficultyID), + FOREIGN KEY (duration) REFERENCES InfoDuration(InfoDurationID), + FOREIGN KEY (type) REFERENCES InfoType(InfoTypeID), + FOREIGN KEY (class) REFERENCES InfoClass(InfoClassID) + ); + ''') + + # Step 3: Copy data from the old Info table to the new Info table + cursor.execute(''' + INSERT INTO Info (InfoID, title, author, release, difficulty, duration, type, class) + SELECT InfoID, title, author, release, difficulty, duration, type, class FROM Info_old; + ''') + + # Step 4: Drop the old Info table + cursor.execute('DROP TABLE Info_old;') + + # Step 5: Update the value in the InfoClass table + cursor.execute(''' + UPDATE InfoClass + SET value = 'Alien/Space' + WHERE value = 'alien/space'; + ''') + + # Commit the transaction + conn.commit() + + except Exception as e: + # If there is any error, rollback the transaction + conn.rollback() + print(f"An error occurred: {e}") + + finally: + # Close the connection + conn.close() + +# Usage +update_table_schema_and_data(arg_path)