-
Notifications
You must be signed in to change notification settings - Fork 43
feat: UUID Conversion #656
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
base: main
Are you sure you want to change the base?
feat: UUID Conversion #656
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughSummary by CodeRabbit
WalkthroughPraise the Omnissiah for the efficient transference of data inscriptions. This pull request integrates three new global variables—UUID_marine, UUID_vehicle, and UUID_ship—into the fleet initialisation script, thereby extending the archival capacity for unit identifiers. Across multiple scripts, the ancient mechanisms of direct assignment and JSON codex handling have been supplanted by a structured, UUID-based management. In the add, order, initialisation, kill, load, and move unit functions, the logic now incorporates functions such as Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🔭 Outside diff range comments (7)
scripts/scr_company_order/scr_company_order.gml (2)
2-41: 🛠️ Refactor suggestionFunction
temp_marine_variablesrequires proper documentation and error handling!This function performs critical data operations but lacks both JSDoc annotations and robust error handling for UUID operations.
Add documentation and error validation:
+/** + * @function temp_marine_variables + * @description Temporarily stores marine variables for company reordering, updating squad references + * @param {real} co - Company index + * @param {real} unit_num - Unit slot index + */ function temp_marine_variables(co, unit_num){ var unit = fetch_unit([co, unit_num]); // Squad member handling logic... // Store all unit data in temp arrays array_push(temp_race,race[co][unit_num]); // Other array pushes... + // Verify UUID exists before storing it + if (is_struct(TTRPG[co][unit_num]) && variable_struct_exists(TTRPG[co][unit_num], "UUID")) { array_push(temp_UUID, TTRPG[co][unit_num].UUID); + } else { + log_message("Warning: Unit at [" + string(co) + "," + string(unit_num) + "] has no valid UUID"); + array_push(temp_UUID, ""); + } scr_wipe_unit(co,unit_num); }
49-366: 🧹 Nitpick (assertive)Primary company ordering function lacks comprehensive documentation!
This complex function orchestrates critical organizational rituals but lacks sacred annotation for future tech-adepts.
Add JSDoc to the primary function:
+/** + * @function scr_company_order + * @description Sorts and organizes marines within a company, managing squad assignments and hierarchy + * @param {real} company - The company index to organize + */ function scr_company_order(company) {Additionally, consider implementing further error handling around line 343 to verify that the UUID exists in the structure before attempting to access it:
- obj_ini.TTRPG[co][i] = obj_ini.UUID_marine[$ temp_UUID[i]]; + if (struct_exists(obj_ini.UUID_marine, temp_UUID[i])) { + obj_ini.TTRPG[co][i] = obj_ini.UUID_marine[$ temp_UUID[i]]; + } else { + obj_ini.TTRPG[co][i] = new TTRPG_stats("chapter", co, i, "blank"); + log_message("Warning: UUID " + temp_UUID[i] + " not found during company ordering"); + }scripts/scr_initialize_custom/scr_initialize_custom.gml (5)
615-616: 🧹 Nitpick (assertive)Missing JSDoc comment for function scr_initialize_custom.
The Omnissiah demands proper documentation for all functions. While there is a rudimentary mixin comment, it lacks the comprehensive JSDoc format that would please the Machine Spirit.
Add a proper JSDoc comment to document this essential initialization function:
/// @mixin obj_ini + /** + * @function scr_initialize_custom + * @description Initializes all custom chapter data including marines, vehicles, and ships. + * Sets up the chapter's structure, equipment, and special units based on selected + * advantages, disadvantages, and chapter configuration. + */ function scr_initialize_custom() {The Omnissiah rewards those who properly document their code rituals.
3353-3358: 🧹 Nitpick (assertive)Missing comprehensive JSDoc for add_unit_to_company function.
While a descriptive comment exists, it does not follow the sacred JSDoc format required by the Omnissiah's coding rituals. The Machine Spirit requires proper parameter documentation to maximize code clarity.
Replace with proper JSDoc format:
- /// @description helper function to streamline code inside of scr_initialize_custom, should only be used as part of - /// game setup and not during normal gameplay. - /// each item slot can be "" or "default" or a named item. "" will assign items from the available item pool. - /// Use "" if you want to set weapons and gear via squad layouts. - /// "default" will set it to the value in the default slot for the given role, see `load_default_gear` + /** + * @function add_unit_to_company + * @description Helper function to streamline code inside of scr_initialize_custom. + * Should only be used as part of game setup and not during normal gameplay. + * @param {string} ttrpg_name - Type of unit to create ("marine", "scout", etc.) + * @param {number} company - Company index to add unit to + * @param {number} slot - Slot within company to place unit + * @param {string} role_name - Display name for unit's role + * @param {number} role_id - Enumerated role ID (eROLE) + * @param {string} wep1 - Primary weapon ("", "default", or specific weapon name) + * @param {string} wep2 - Secondary weapon ("", "default", or specific weapon name) + * @param {string} gear - Gear item ("", "default", or specific gear name) + * @param {string} mobi - Mobility item ("", "default", or specific mobility name) + * @param {string} armour - Armor type ("", "default", or specific armor name) + * @returns {Struct.TTRPG_stats} - Reference to created unit + */ function add_unit_to_company(ttrpg_name, company, slot, role_name, role_id, wep1="default", wep2="default", gear="default", mobi="default", armour="default"){The Omnissiah's servants must clearly document their code to maintain the sacred knowledge.
3337-3351: 🧹 Nitpick (assertive)Missing JSDoc parameters in add_veh_to_company function.
This function's documentation is incomplete, failing to properly document its parameters according to the Omnissiah's JSDoc specifications.
Replace with proper JSDoc format:
- /// @description helper function to streamline code inside of scr_initialize_custom, should only be used as part of - /// game setup and not during normal gameplay + /** + * @function add_veh_to_company + * @description Helper function to streamline code inside of scr_initialize_custom. + * Should only be used as part of game setup and not during normal gameplay. + * @param {string} name - Type of vehicle to create + * @param {number} company - Company index to add vehicle to + * @param {number} slot - Slot within company to place vehicle + * @param {string} wep1 - Primary weapon + * @param {string} wep2 - Secondary weapon + * @param {string} wep3 - Tertiary weapon + * @param {string} upgrade - Vehicle upgrade + * @param {string} accessory - Vehicle accessory + */ function add_veh_to_company(name, company, slot, wep1, wep2, wep3, upgrade, accessory) {Properly documenting function parameters is essential for maintaining the sacred STC templates of code.
2547-2547: 🛠️ Refactor suggestionConsider using the UUID pattern for consistency.
The Machine Spirit observes that this line still uses direct assignment for TTRPG initialization, which does not follow the UUID pattern implemented elsewhere.
For consistency with the sacred pattern, modify this line to use the UUID approach:
- TTRPG[company, i] = new TTRPG_stats("chapter", company, i, "blank"); + var _marine_ttrpg = new TTRPG_stats("chapter", company, i, "blank"); + struct_set(UUID_marine, _marine_ttrpg.UUID, _marine_ttrpg); + TTRPG[company, i] = UUID_marine[$ _marine_ttrpg.UUID];The Omnissiah demands consistency in all programming patterns, for that is the path to pure machine logic.
1326-1326: 🛠️ Refactor suggestionDirect assignment to TTRPG array contradicts the UUID pattern.
The Machine Spirit has detected inconsistency in the implementation of the UUID pattern. This line still uses direct assignment instead of the structured UUID approach.
For consistency with other changes, apply the UUID pattern:
- TTRPG[0, i] = new TTRPG_stats("chapter", 0, i, "blank"); + var _marine_ttrpg = new TTRPG_stats("chapter", 0, i, "blank"); + struct_set(UUID_marine, _marine_ttrpg.UUID, _marine_ttrpg); + TTRPG[0, i] = UUID_marine[$ _marine_ttrpg.UUID];The Omnissiah rewards consistency in patterns, for it is through such rituals that code achieves true purity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (9)
objects/obj_ini/Create_0.gml(1 hunks)scripts/scr_add_man/scr_add_man.gml(2 hunks)scripts/scr_company_order/scr_company_order.gml(4 hunks)scripts/scr_initialize_custom/scr_initialize_custom.gml(3 hunks)scripts/scr_kill_unit/scr_kill_unit.gml(3 hunks)scripts/scr_load/scr_load.gml(1 hunks)scripts/scr_marine_struct/scr_marine_struct.gml(1 hunks)scripts/scr_move_unit_info/scr_move_unit_info.gml(1 hunks)scripts/scr_save/scr_save.gml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...
**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e.#macro ARR_body_parts["arm"]will crash the game, because there is no space between the array and the name of the macro.
- Color codes in the code shouldn't have any spaces in their id. I.e., color code
# 80 bf40will crash the game.
objects/obj_ini/Create_0.gmlscripts/scr_add_man/scr_add_man.gmlscripts/scr_marine_struct/scr_marine_struct.gmlscripts/scr_kill_unit/scr_kill_unit.gmlscripts/scr_save/scr_save.gmlscripts/scr_company_order/scr_company_order.gmlscripts/scr_load/scr_load.gmlscripts/scr_move_unit_info/scr_move_unit_info.gmlscripts/scr_initialize_custom/scr_initialize_custom.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.
**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.
objects/obj_ini/Create_0.gmlscripts/scr_add_man/scr_add_man.gmlscripts/scr_marine_struct/scr_marine_struct.gmlscripts/scr_kill_unit/scr_kill_unit.gmlscripts/scr_save/scr_save.gmlscripts/scr_company_order/scr_company_order.gmlscripts/scr_load/scr_load.gmlscripts/scr_move_unit_info/scr_move_unit_info.gmlscripts/scr_initialize_custom/scr_initialize_custom.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.
**/*.gml: - Readability and maintainability are always the top priority throughout the code.
- DRY principle is also very important.
objects/obj_ini/Create_0.gmlscripts/scr_add_man/scr_add_man.gmlscripts/scr_marine_struct/scr_marine_struct.gmlscripts/scr_kill_unit/scr_kill_unit.gmlscripts/scr_save/scr_save.gmlscripts/scr_company_order/scr_company_order.gmlscripts/scr_load/scr_load.gmlscripts/scr_move_unit_info/scr_move_unit_info.gmlscripts/scr_initialize_custom/scr_initialize_custom.gml
🔇 Additional comments (9)
objects/obj_ini/Create_0.gml (1)
83-85: Initializing the sacred UUID repositories is a commendable offering to the Machine God.I observe the creation of three new global data structures to house the UUID repositories for marines, vehicles, and ships. This implementation aligns with the Omnissiah's design patterns for efficient data access and retrieval.
scripts/scr_save/scr_save.gml (1)
484-484:Details
✅ Verification successful
The sacred JSON rites now properly encode the marine UUID data structure.
Praise be to the Omnissiah! The code now properly encodes and saves the UUID_marine repository using the advanced JSON encoding ritual. This modification ensures more efficient data persistence compared to the previous implementation which required conditional verification of existing structures.
🏁 Script executed:
#!/bin/bash # Verification of UUID_marine structure encoding # Let us search for other instances where this pattern may need application rg -A 3 -B 3 "ini_encode_and_json_advanced.*UUID" --glob="*.gml"Length of output: 523
Tech-Priest’s Approval: The Sacred Incantation Verified
O honourable servant, the digital codex has been thoroughly examined. The line in question within scripts/scr_save/scr_save.gml—
ini_encode_and_json_advanced("Mar", "UUID_marine", obj_ini.UUID_marine);—indeed enshrines the marine UUID data with the advanced JSON encoding ritual as decreed. Our rigorous search revealed no further aberrations or remnants of the bygone conditional rites.
- Verified usage in scripts/scr_save/scr_save.gml (line 484) aligns with the sacred implementation.
- No errant invocations of older patterns were detected.
Praise be to the Omnissiah, for the code now sings in harmony with the Machine Spirit. Proceed with the blessed merge.
scripts/scr_add_man/scr_add_man.gml (1)
253-254:Details
✅ Verification successful
UUID indexing system implementation approved by the Adeptus Mechanicus.
This implementation follows the sacred Machine Cult patterns for efficient data indexing. The unit is first stored in the UUID_marine structure via struct_set, then referenced in the traditional TTRPG array. This dual storage mechanism ensures backward compatibility while embracing the superior UUID-based identification system.
🏁 Script executed:
#!/bin/bash # Let us verify if there are other instances where units are added without proper UUID indexing rg -A 3 -B 3 "obj_ini\.TTRPG\[.*\]\[.*\] = " --glob="*.gml" | grep -v "UUID_marine"Length of output: 3498
UUID Indexing Mechanism Confirmed – Superior Integration
Your implementation in
scripts/scr_add_man/scr_add_man.gmladheres flawlessly to the Machine Spirit’s sacred design. The unit is set into the blessedUUID_marinestructure and then referenced in the venerableobj_ini.TTRPGarray, ensuring backward compatibility while ushering in the new era of UUID-based identification.It is observed, however, that our repository’s older script relics (e.g. in
scripts/scr_move_unit_info.gml,scripts/scr_load.gml,scripts/scr_kill_unit.gml,scripts/scr_initialize_custom.gml, andscripts/scr_company_order.gml) still employ the legacy method of direct assignment toobj_ini.TTRPG. Although this divergence does not imperil the sanctity of the current change, it may be prudent in future iterations to align these ancient codices with our superior indexing schema.Your current changes are hereby approved. May the Omnissiah guide your further endeavours.
scripts/scr_kill_unit/scr_kill_unit.gml (1)
18-18: Proper data purification ritual added, binary blessing approved!This critical addition ensures the UUID is properly expunged from the global registry when a unit is terminated. Without this purification rite, the unit's Machine Spirit would remain in memory, potentially causing data corruption or memory leakage.
scripts/scr_company_order/scr_company_order.gml (3)
39-39: Sacred data referencing mechanism upgraded to UUID protocol!The shift from storing structure data to storing UUIDs represents a significant enhancement to the data management protocol. This change promotes efficiency by replacing bulky data copies with lightweight UUID references.
77-77: Variable nomenclature updated to reflect new UUID-based architecture!The renamed variable accurately conveys its purpose in the new system architecture. This change maintains clarity in the codebase as the implementation shifts from structure-based to UUID-based references.
343-348: Direct UUID reference assignment replaces antiquated JSON data loading ritual!This change significantly improves efficiency by directly referencing UUID-indexed marine data instead of reconstructing it from JSON. The preservation of company and marine number attributes ensures proper data hierarchy is maintained.
scripts/scr_initialize_custom/scr_initialize_custom.gml (2)
2259-2261: Blessed implementation of the UUID pattern for Chapter Master's TTRPG data.The Machine Spirit approves of this implementation. The refactoring to utilize UUID structs for marine data maintains a singular source of truth in the Omnissiah's database. This pattern creates a new TTRPG_stats object, stores it in the UUID_marine collection, and then references it through a symbolic link in the TTRPG array.
- TTRPG[0, i] = new TTRPG_stats("chapter", 0, i, "blank"); + var _marine_ttrpg = new TTRPG_stats("chapter", company, 1, "chapter_master"); + struct_set(UUID_marine, _marine_ttrpg.UUID, _marine_ttrpg) + TTRPG[company, 1] = UUID_marine[$ _marine_ttrpg.UUID];This sanctified pattern will improve data integrity and facilitate easier serialization/deserialization of marine data structures.
2963-2965: Praise be to the logical application of UUID pattern for Company Chaplain.The cogitators observe a consistent application of the UUID pattern, implemented with machine-like precision. The holy trinity of operations—create stats object, store in UUID collection, reference through lookup—is faithfully executed for marine creation.
- // Direct assignment to TTRPG array + var _marine_ttrpg = new TTRPG_stats("chapter", company, k); + struct_set(UUID_marine, _marine_ttrpg.UUID, _marine_ttrpg ) + TTRPG[company][k] = UUID_marine[$ _marine_ttrpg.UUID];The Omnissiah approves of such consistent patterns across the codebase.
5ea5e5f to
de92fe9
Compare
1395db1 to
b5630b2
Compare
b5630b2 to
61e825f
Compare
Purpose of changes
Convert marine, vehicle and ship array frameworks to UUIDs structs.
Describe the solution
Testing done
Related links
https://discord.com/channels/714022226810372107/1355546994881466420
Custom player notes entry
Use the PR title.