Skip to content

Commit

Permalink
Merge branch 'master' into Playerbot
Browse files Browse the repository at this point in the history
  • Loading branch information
liyunfan1223 committed Feb 4, 2025
2 parents e5c67bd + 8af593b commit de3c2b5
Show file tree
Hide file tree
Showing 81 changed files with 3,116 additions and 583 deletions.
44 changes: 39 additions & 5 deletions apps/codestyle/codestyle-sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"Multiple blank lines check": "Passed",
"Trailing whitespace check": "Passed",
"SQL codestyle check": "Passed",
"INSERT safety usage check": "Passed",
"Missing semicolon check": "Passed"
"INSERT & DELETE safety usage check": "Passed",
"Missing semicolon check": "Passed",
"Backtick check": "Passed"
}

# Collect all files in all directories
Expand Down Expand Up @@ -44,8 +45,9 @@ def parsing_file(files: list) -> None:
multiple_blank_lines_check(file, file_path)
trailing_whitespace_check(file, file_path)
sql_check(file, file_path)
insert_safety_check(file, file_path)
insert_delete_safety_check(file, file_path)
semicolon_check(file, file_path)
backtick_check(file, file_path)
except UnicodeDecodeError:
print(f"\nCould not decode file {file_path}")
sys.exit(1)
Expand Down Expand Up @@ -134,9 +136,10 @@ def sql_check(file: io, file_path: str) -> None:
error_handler = True
results["SQL codestyle check"] = "Failed"

def insert_safety_check(file: io, file_path: str) -> None:
def insert_delete_safety_check(file: io, file_path: str) -> None:
global error_handler, results
file.seek(0) # Reset file pointer to the beginning
not_delete = ["creature_template", "gameobject_template", "item_template", "quest_template"]
check_failed = False
previous_line = ""

Expand All @@ -148,11 +151,18 @@ def insert_safety_check(file: io, file_path: str) -> None:
print(f"No DELETE keyword found after the INSERT in {file_path} at line {line_number}\nIf this error is intended, please advert a maintainer")
check_failed = True
previous_line = line
match = re.match(r"DELETE FROM\s+`([^`]+)`", line, re.IGNORECASE)
if match:
table_name = match.group(1)
if table_name in not_delete:
print(
f"Entries from {table} should not be deleted! {file_path} at line {line_number}")
check_failed = True

# Handle the script error and update the result output
if check_failed:
error_handler = True
results["INSERT safety usage check"] = "Failed"
results["INSERT & DELETE safety usage check"] = "Failed"

def semicolon_check(file: io, file_path: str) -> None:
global error_handler, results
Expand Down Expand Up @@ -192,6 +202,30 @@ def semicolon_check(file: io, file_path: str) -> None:
error_handler = True
results["Missing semicolon check"] = "Failed"

def backtick_check(file: io, file_path: str) -> None:
global error_handler, results
file.seek(0)
check_failed = False
pattern = re.compile(
r'\b(SELECT|FROM|JOIN|WHERE|GROUP BY|ORDER BY|DELETE FROM|UPDATE|INSERT INTO|SET)\s+([^;]+)',
re.IGNORECASE)

for line_number, line in enumerate(file, start=1):
matches = pattern.findall(line)
for clause, content in matches:
words = re.findall(r'\b[a-zA-Z_][a-zA-Z0-9_]*\b', content)
for word in words:
if word.upper() in {"SELECT", "FROM", "JOIN", "WHERE", "GROUP", "BY", "ORDER",
"DELETE", "UPDATE", "INSERT", "INTO", "SET", "VALUES"}:
continue
if not re.search(rf'`{re.escape(word)}`', content):
print(f"Missing backticks around ({word}). {file_path} at line {line_number}")
check_failed = True

if check_failed:
error_handler = True
results["Backtick check"] = "Failed"

# Collect all files from matching directories
all_files = collect_files_from_directories(src_directory)

Expand Down
8 changes: 4 additions & 4 deletions apps/installer/includes/os_configs/windows.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# install chocolatey before

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# powershell.exe -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

# install automatically following packages:
# cmake
Expand All @@ -24,7 +24,7 @@ fi

choco install -y --skip-checksums $INSTALL_ARGS cmake.install -y --installargs 'ADD_CMAKE_TO_PATH=System'
choco install -y --skip-checksums $INSTALL_ARGS visualstudio2022-workload-nativedesktop
choco install -y --skip-checksums $INSTALL_ARGS openssl --version=3.1.1
choco install -y --skip-checksums $INSTALL_ARGS boost-msvc-14.3 --version=1.82.0
choco install -y --skip-checksums $INSTALL_ARGS mysql --version=8.0.31
choco install -y --skip-checksums $INSTALL_ARGS openssl --force --version=3.3.2
choco install -y --skip-checksums $INSTALL_ARGS boost-msvc-14.3 --force --version=1.87.0
choco install -y --skip-checksums $INSTALL_ARGS mysql --force --version=8.4.4

13 changes: 13 additions & 0 deletions data/sql/updates/db_characters/2025_01_31_00.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- DB update 2024_11_15_00 -> 2025_01_31_00
--
DROP TABLE IF EXISTS `world_state`;
CREATE TABLE IF NOT EXISTS `world_state` (
`Id` INT UNSIGNED NOT NULL COMMENT 'Internal save ID',
`Data` longtext,
PRIMARY KEY(`Id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 COMMENT='WorldState save system';

-- Isle of Quel'danas is in its final stage with all subphases completed
-- open all Sunwell Plateau gates
DELETE FROM `world_state` WHERE `Id` = 20;
INSERT INTO `world_state` (`Id`, `Data`) VALUES(20, '3 15 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 3 80 80 80');
Loading

0 comments on commit de3c2b5

Please sign in to comment.