forked from otland/forgottenserver
-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: migrate outfits and mounts to Lua #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ranisalt
wants to merge
56
commits into
dev
Choose a base branch
from
refactor/lua-outfits-mounts
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
988b140
refactor: migrate outfits and mounts to Lua
ranisalt 02ccd8f
chore(mounts): remove legacyId
ranisalt f9ceebb
refactor(podium): validate item type before processing podium window
ranisalt f99fb33
refactor(players): remove unused currentmount column from players table
ranisalt 065de9f
refactor(network_message): fix incorrect reference to 'msg' in addIte…
ranisalt 6174228
refactor(database): switch to synchronous queries for outfit and moun…
ranisalt 904aa8a
refactor(mounts): rename parameter in setWasMounted to prevent shadowing
ranisalt 0c5f17f
refactor(outfits): simplify hasOutfit and hasOutfitAddon methods for …
ranisalt b060383
refactor(events): streamline zone change logic for player mounting
ranisalt c437bc6
refactor(set_outfit): ensure player can wear outfit before setting
ranisalt 8d4111a
refactor(iologindata): update SQL queries to remove currentmount
ranisalt e4c49bf
refactor(mounts): rename parameter in setWasMounted for clarity
ranisalt 0ec07e4
refactor(mounts): update toggleMount logic to fix cooldown condition
ranisalt 5d03ec1
refactor(podium): fix mount checkbox logic to use lookMount instead o…
ranisalt 2a1124c
refactor(general): remove reload, code style and checks
ramon-bernardo a18614b
fix(events): self creature and linter
ramon-bernardo 645b99d
feat(events): add creature zone change and logout handling for mounts…
ranisalt da786a8
Update data/scripts/systems/outfits/events/logout.lua
ranisalt 4fb0414
feat(commands): add outfit and mount management commands for gamemasters
ranisalt 5ac3404
refactor(mounts): fix mount storage checks and add mount riding valid…
ranisalt c071c6b
feat(events): implement creature removal event handling and cleanup
ranisalt 36f5f39
refactor(mounts): rename and reorganize mount storage keys for clarity
ranisalt 8fbf676
refactor(outfits): fix mounted state checks in outfit window and chan…
ranisalt 8d5fb83
refactor(outfits): fix outfit ownership checks in add and remove addo…
ranisalt 7cedd31
refactor(mounts): add mount ownership check in setCurrentMount and va…
ranisalt 9479f64
refactor(outfits): enhance item validation in set outfit handling
ranisalt 4b164f8
refactor(outfits): fix mount color assignment logic in set outfit han…
ranisalt f7af96b
refactor(outfits): fix outfit addon check logic in hasOutfitAddon and…
ranisalt c878520
refactor(outfits): remove unused addons parameter in addOutfit function
ranisalt 0d4ea27
refactor(podium): fix mount ownership check in onPodiumEdit function
ranisalt e46e0aa
refactor(outfits, mounts): move more outfit and mount management func…
ranisalt bab1558
refactor(mounts): enhance mount validation to include speed check
ranisalt 3b561db
fix(mounts): move network, toggle and group bypass
ramon-bernardo 22e09e2
fix(mounts): current mount storage
ramon-bernardo cdff977
refactor(events): remove onCreatureRemoved and add onPlayerLogout eve…
ranisalt 77fd03b
refactor(mounts, outfits): revert bad changes
ranisalt c43e9b8
refactor(game): remove onRemoved event call from removeCreature function
ranisalt d9d11bf
refactor(outfits, mounts): enhance command documentation and clarify …
ranisalt 9351896
refactor(outfits): streamline outfit and mount data handling in netwo…
ranisalt 2ab053b
refactor(migrations): add migration for currentmount and randomizemou…
ranisalt b0c238a
refactor(mounts): improve toggleMount logic to enforce cooldown only …
ranisalt da5ab24
refactor(migrations): add batch insertion and transaction handling in…
ranisalt 8df1e87
refactor(migrations): fix query execution logic in database update fu…
ranisalt 1a1fef0
refactor(migrations): fix shadowing in database update logic for outf…
ranisalt f7be825
refactor(migrations): enhance transaction handling and batch insertio…
ranisalt d6dc2cd
refactor(commands): enhance feedback for outfit and mount management …
ranisalt 86f0450
refactor(outfits): standardize indentation and formatting in outfit h…
ranisalt 2714970
refactor(outfits, mounts): optimize outfit and mount retrieval with c…
ranisalt 7065921
refactor(outfits): add TODO for implementing store outfit preview window
ranisalt cf87b0d
refactor(outfits): improve item position verification in outfit handling
ranisalt 66cc1a1
refactor(outfits): add type check for outfit name in getOutfitByName …
ranisalt 4249763
refactor(storages, migrations): update storage key definitions for ou…
ranisalt dcfa9d6
refactor(migrations): simplify storage collection in onUpdateDatabase
ranisalt e757a4d
refactor(migrations): ensure transaction rollback on query failures i…
ranisalt 661e6c5
refactor(migrations): update query condition for migrating current an…
ranisalt 892aabe
Merge branch 'dev' into refactor/lua-outfits-mounts
ranisalt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,89 @@ | ||
| -- must match PlayerStorageKeys in storages.lua, change accordingly if modified | ||
| local CURRENT_MOUNT = 60000 | ||
| local RANDOMIZE_MOUNT = 60001 | ||
| local OUTFITS_BASE = 600000 | ||
| local MOUNTS_BASE = 610000 | ||
|
|
||
| function onUpdateDatabase() | ||
| return false | ||
| print("> Updating database to version 38 (revert outfits/mounts to storages)") | ||
|
|
||
| local tx = DBTransaction() | ||
| if not tx.begin() then | ||
| return false | ||
| end | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| local query = DBInsert("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ") | ||
|
|
||
| do | ||
| local resultId = db.storeQuery("SELECT `player_id`, `outfit_id`, `addons` FROM `player_outfits`") | ||
| if resultId then | ||
| repeat | ||
| local playerId = result.getNumber(resultId, "player_id") | ||
| local outfitId = result.getNumber(resultId, "outfit_id") | ||
| local addons = result.getNumber(resultId, "addons") | ||
|
|
||
| local storageKey = OUTFITS_BASE + outfitId | ||
| query:addRow(string.format("%d, %d, %d", playerId, storageKey, addons)) | ||
| until not result.next(resultId) | ||
| result.free(resultId) | ||
| end | ||
| end | ||
|
|
||
| do | ||
| local resultId = db.storeQuery("SELECT `player_id`, `mount_id` FROM `player_mounts`") | ||
| if resultId then | ||
| repeat | ||
| local playerId = result.getNumber(resultId, "player_id") | ||
| local mountId = result.getNumber(resultId, "mount_id") | ||
|
|
||
| local storageKey = MOUNTS_BASE + mountId | ||
| query:addRow(string.format("%d, %d, %d", playerId, storageKey, 1)) | ||
| until not result.next(resultId) | ||
| result.free(resultId) | ||
| end | ||
| end | ||
|
|
||
| -- Migrate currentmount and randomizemount from players table | ||
| do | ||
| local resultId = db.storeQuery( | ||
| "SELECT `id`, `currentmount`, `randomizemount` FROM `players` WHERE `currentmount` > 0 OR `randomizemount` > 0") | ||
| if resultId then | ||
| repeat | ||
| local playerId = result.getNumber(resultId, "id") | ||
| local currentMount = result.getNumber(resultId, "currentmount") | ||
| local randomizeMount = result.getNumber(resultId, "randomizemount") | ||
|
|
||
| if currentMount > 0 then | ||
| query:addRow(string.format("%d, %d, %d", playerId, CURRENT_MOUNT, currentMount)) | ||
| end | ||
|
|
||
| if randomizeMount > 0 then | ||
| query:addRow(string.format("%d, %d, %d", playerId, RANDOMIZE_MOUNT, randomizeMount)) | ||
| end | ||
| until not result.next(resultId) | ||
| result.free(resultId) | ||
| end | ||
| end | ||
|
|
||
| if not query:execute() then | ||
| tx.rollback() | ||
| return false | ||
| end | ||
|
|
||
| if not db.query("DROP TABLE IF EXISTS `player_outfits`") then | ||
| tx.rollback() | ||
| return false | ||
| end | ||
|
|
||
| if not db.query("DROP TABLE IF EXISTS `player_mounts`") then | ||
| tx.rollback() | ||
| return false | ||
| end | ||
|
|
||
| if not db.query("ALTER TABLE `players` DROP COLUMN `currentmount`, DROP COLUMN `randomizemount`") then | ||
| tx.rollback() | ||
| return false | ||
| end | ||
|
|
||
| return tx.commit() | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| function onUpdateDatabase() | ||
| return false | ||
| end | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.