tool that finds the first SpellScript by searching for public SpellScriptLoader in a file and converts it to use registry macros
Project description
Spellscript Refactor Tool for AzerothCore
Python tool to convert spellscript(s) to use registry macros (see official wiki https://www.azerothcore.org/wiki/core-scripts)
The acore_spellscript_refactor tool provides modules to refactor spellscripts to use registry macros (see official wiki https://www.azerothcore.org/wiki/core-scripts).
Disclaimer: This tool is dumb. It finds the first SpellScript by searching for public SpellScriptLoader in a file and converts it. It does not add enums for magic numbers, and may remove variables; some manual work is required, but it is a good first pass
Features
- convert AuraScript
- convert SpellScript
- convert Spell- and Aurascript Pairs
- add
bool Validate...if it does not exist already - read/write to file
- create skeleton update statement
spell_script_namestoscript_name.sqlif type is_aura - fill in spell_ids skeleton update with spell_ids from table
acore_worldspell_script_names -
--skipto specify line number to search for SpellScript -
--verbose/-vto output debug info -
--sql-fileto write script_name updates to specific file -
discoverruns repeatedly on all*cppin directory - spell scripts with args
- magic numbers to Enum
Install
The acore-spellscript-refactor package is published on Test PyPI for testing and development purposes. Follow the steps below to install it.
Installation Steps
-
Clone the Repository (Optional)
If you want to work with the source code, clone the repository to your local machine:git clone https://github.com/your-username/acore-spellscript-refactor.git cd acore-spellscript-refactor pip install -e .
-
Install from Test PyPI
To install the latest version ofacore-spellscript-refactorfrom Test PyPI, use the following command:pip install acore-spellscript-refactor
This installs the package and all required dependencies from the Test PyPI repository.
-
Verify the Installation
Confirm the installation by running:python3 -m acore_spellscript_refactor.main --help
For more information, visit the acore-spellscript-refactor page on Test PyPI.
Usage
This covers basic usage, command options, and examples for the main and discover modules.
To create a rev_*.sql file, use create_sql.sh
./data/sql/updates/pending_db_world/create_sql.sh
In the sections below $REV_SQL refers to absolute path of this created rev_*.sql.
REV_SQL="/azerothcore-wotlk/data/sql/updates/pending_db_world/rev_1730477106741869456.sql"
note: for file arguments, use absolute paths
Examples
Using main
The main module refactors a single script file at a time or all scripts within a directory.
Refactoring a Single Script with Line Offset
To refactor a single script file and specify an offset (e.g., skip the first 950 lines):
python3 -m acore_spellscript_refactor.main "/azerothcore-wotlk/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp" --skip 950
python3 -m acore_spellscript_refactor.main `realpath boss_xt002.cpp` --skip 950
python3 -m acore_spellscript_refactor.main `realpath boss_xt002.cpp` --skip 950 --verbose
Refactoring All Scripts in a Directory
To refactor all .cpp files in a directory, use xargs to iterate through each file:
ls *cpp | xargs -n 1 -I {} python3 -m acore_spellscript_refactor.main `realpath {}`
Command Options
-
Specify input and output files:
- Provide an
input_fileandoutput_fileto save results to a specific file.
python3 -m acore_spellscript_refactor.main input_file output_file
- Provide an
-
Overwrite input file:
- Use the same file for both
input_fileandoutput_fileto overwrite.
python3 -m acore_spellscript_refactor.main input_file input_file
- Use the same file for both
-
Default single file refactor:
- Refactor a single file without specifying an output, defaults to overwriting the
input_file.
python3 -m acore_spellscript_refactor.main input_file
- Refactor a single file without specifying an output, defaults to overwriting the
-
Skip a specified number of lines:
- Use
--skipto ignore a set number of lines.
python3 -m acore_spellscript_refactor.main input_file output_file --skip 1200
- Use
-
Use with SQL file generation:
- Refactor with associated SQL queries stored in a specified file.
python3 -m acore_spellscript_refactor.main input_file output_file --skip 1200 --sql_file $REV_SQL
-
Commit changes:
- Add the
--commitflag to save changes with an optional SQL file for database updates.
python3 -m acore_spellscript_refactor.main input_file --commit --sql_file $REV_SQL
- Add the
Using discover
The discover module finds .cpp files and creates commits and SQL files as necessary.
Example Usage
-
Commit all discovered files:
- Specify a
.sqlfile for database changes, or allowdiscoverto auto-create one by omitting--sql_file
python3 -m acore_spellscript_refactor.discover --commit --sql_file $REV_SQL
- Specify a
-
Run on all scripts in a directory:
- Set the working directory to
azerothcore-wotlk/src/server/scripts/***/scripts_folderand recursively discover.cppfiles.
python3 -m acore_spellscript_refactor.discover --commit --recursive --sql_file $REV_SQL
- Set the working directory to
-
Run on all scripts:
- Set the working directory to
azerothcore-wotlk/src/server/scriptsand recursively discover.cppfiles.
python3 -m acore_spellscript_refactor.discover --commit --recursive --sql_file $REV_SQL
- Set the working directory to
Development
Run tests
pytest .
Development
pip install -e .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file acore_spellscript_refactor-1.8.4.tar.gz.
File metadata
- Download URL: acore_spellscript_refactor-1.8.4.tar.gz
- Upload date:
- Size: 224.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcba7194afcb1ba63543de999a368d919cedfffdf5dfa81c28d14186cc51e5a2
|
|
| MD5 |
9d42c3999b07742d383d3c175a1c1794
|
|
| BLAKE2b-256 |
749696bd307fa00841861ba7a677dfeb3daab43fac8c2c0b1037605031b1c678
|
File details
Details for the file acore_spellscript_refactor-1.8.4-py3-none-any.whl.
File metadata
- Download URL: acore_spellscript_refactor-1.8.4-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c2c7585d6ec0248a7f4e3b7302053e4de99b290152b2d119d7aab6b4025c1a
|
|
| MD5 |
6e2b9c54493186ebcadeb2ed8a506a29
|
|
| BLAKE2b-256 |
53099742e7ad6f2d5e9dccf8304315e57100bfb4fd0b9f38605a415e1b8508f0
|