Skip to content

Commit

Permalink
update database
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Jul 20, 2024
1 parent 2ebbc13 commit 5fe9bba
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 11 deletions.
Binary file added doc/Database.odt
Binary file not shown.
Binary file added doc/Database.pdf
Binary file not shown.
14 changes: 13 additions & 1 deletion utils/README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
18 changes: 13 additions & 5 deletions utils/addData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
20 changes: 18 additions & 2 deletions utils/getData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions utils/makeDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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',))
Expand Down
Binary file modified utils/tombll.db
Binary file not shown.
70 changes: 70 additions & 0 deletions utils/updateDB_1.0.0.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5fe9bba

Please sign in to comment.