- Joined
- May 15, 2013
- Messages
- 2,248
- Reaction score
- 2,158
- First Language
- English
- Primarily Uses
- N/A
This is related to the following and later / some earlier posts on this topic in the original Yanfly plugin's thread: http://forums.rpgmakerweb.com/index.php?/topic/48860-yep-yanfly-engine-plugins-newest-armor-scaling-plugin-count-33/?p=511130
Long story short, I'd like to see data reading logic moved out of DataManager.isDatabaseLoaded() because this function is designed to be used only to read the status of the loading of the database objects (the $data* objects). This function can and is called repeatedly by the core scripts to wait for the startup scene (Scene_Boot) to be done loading these data objects before proceeding. Other plugins may also need to check this to ensure that these objects are available before they run their own logic, especially if it's logic to be run at startup.
The current implementation in the YEP series of plugins means that notetags are read and processed over and over when this function is called, which is both unnecessary and breaking with the design behind the function.
I propose changing this code starting on line 576 of latest YEP_CoreEngine.js (it's also used in other plugins, but I use this for the example):
Yanfly.Core.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;DataManager.isDatabaseLoaded = function() { if (!Yanfly.Core.DataManager_isDatabaseLoaded.call(this)) return false; this.processCORENotetags1($dataItems); this.processCORENotetags1($dataWeapons); this.processCORENotetags1($dataArmors); this.processCORENotetags2($dataEnemies); this.processCORENotetags3($dataActors); this.processCORENotetags4($dataClasses); return true;};Into this:
Yanfly.Core.DataManager_onLoad = DataManager.onLoad;DataManager.onLoad = function(object) { Yanfly.Core.DataManager_onLoad.call(this); if (this.isDatabaseLoaded()) this._processYanflyNotetags();};DataManager._processYanflyNotetags = function() { this.processCORENotetags1($dataItems); this.processCORENotetags1($dataWeapons); this.processCORENotetags1($dataArmors); this.processCORENotetags2($dataEnemies); this.processCORENotetags3($dataActors); this.processCORENotetags4($dataClasses);}The benefits of this change are:
I created this topic to discuss this change. If there are problems with it we can discuss it and find the best solution that solves the issues that may exist with it. I'm not here saying one way is better than all others, just that the current implementation is something I find very problematic for reasons I have already described ad nauseam.
Let's find the best solution together
Long story short, I'd like to see data reading logic moved out of DataManager.isDatabaseLoaded() because this function is designed to be used only to read the status of the loading of the database objects (the $data* objects). This function can and is called repeatedly by the core scripts to wait for the startup scene (Scene_Boot) to be done loading these data objects before proceeding. Other plugins may also need to check this to ensure that these objects are available before they run their own logic, especially if it's logic to be run at startup.
The current implementation in the YEP series of plugins means that notetags are read and processed over and over when this function is called, which is both unnecessary and breaking with the design behind the function.
I propose changing this code starting on line 576 of latest YEP_CoreEngine.js (it's also used in other plugins, but I use this for the example):
Yanfly.Core.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;DataManager.isDatabaseLoaded = function() { if (!Yanfly.Core.DataManager_isDatabaseLoaded.call(this)) return false; this.processCORENotetags1($dataItems); this.processCORENotetags1($dataWeapons); this.processCORENotetags1($dataArmors); this.processCORENotetags2($dataEnemies); this.processCORENotetags3($dataActors); this.processCORENotetags4($dataClasses); return true;};Into this:
Yanfly.Core.DataManager_onLoad = DataManager.onLoad;DataManager.onLoad = function(object) { Yanfly.Core.DataManager_onLoad.call(this); if (this.isDatabaseLoaded()) this._processYanflyNotetags();};DataManager._processYanflyNotetags = function() { this.processCORENotetags1($dataItems); this.processCORENotetags1($dataWeapons); this.processCORENotetags1($dataArmors); this.processCORENotetags2($dataEnemies); this.processCORENotetags3($dataActors); this.processCORENotetags4($dataClasses);}The benefits of this change are:
- DataManager.isDatabaseLoaded() contains only the function of checking whether the database objects have been loaded, its original and only logical role to have.
- Notetags are only read once, but they are just as guaranteed to load correctly now as before this change.
- The tentatively named DataManager._processYanflyNotetags function can easily be extended by other Yanfly plugins to read additional data, while encapsulating this logic in a clearly defined and separate function space.
- We do not extend Scene_Boot, which Yanfly explicitly said he did not want to touch.
I created this topic to discuss this change. If there are problems with it we can discuss it and find the best solution that solves the issues that may exist with it. I'm not here saying one way is better than all others, just that the current implementation is something I find very problematic for reasons I have already described ad nauseam.
Let's find the best solution together
