I've been reading the source codes for several days and I briefly understand the flows and the subs.
However, I'm struggling with the Global variables. I simply cant track where it has been called and more importantly, what are the hash members. Things getting worse to me with the autovivification feature because it can be set anywhere...
So, would be glad if you guys can share your experience/tips on how you remember or work with the Global variables.
This is exactly the reason why Global vars are frowned upon, not just in perl but in _any_ other language.
Unfortunately there really is no way to track them except for being intimately familiar with the flow of the routines.
I suggest you put some dump or debug statements on the lines you think would be interesting. You might also try your luck on a debugger (not sure if there's one for perl though).
It's a pain, admittedly, but do remember that OpenKore started out as a single perl file and through the years have mutated into what it is today. We've tried stamping out some globs by encapsulating them into classes, but alas not everything has been done. Plus, with numerous devs coming and going (both core code and plugins) we're not totally sure if they're adding in yet another hash to $char as a temp var.
Got your topic trashed by a mod?
Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.
I personally think, that things might get changed in future.
Because another big update after Release of 2.1 is total cleaning of Globals.pm and Replacing current Object/Actor system with more advanced one (as was designed for AI 2008 I guess.). Plus Implementation of SmartHook system with all it's dependency.
Ah, that's what I am thinking also.. But it's amazing that you guys because you manage enhance it,providing plugins and all -- that's why I am looking for tips.
Anyway, is it still good if I spend time to create the plugins for the current code? I know that the 2.1 release is just around the corner. I just afraid that it does not worth spending time with the current release and I'm also concern with the portability of the current plugins to the V2.1.
kLabMouse wrote:I personally think, that things might get changed in future.
Because another big update after Release of 2.1 is total cleaning of Globals.pm and Replacing current Object/Actor system with more advanced one (as was designed for AI 2008 I guess.). Plus Implementation of SmartHook system with all it's dependency.
You said "total cleaning of Globals.pm".
Indeed, it runs fine, even removing the Globals.pm file.
But why I can not remove the line "use Globals;" in the other .pm files ?
Where is the "Globals" package ?
The error message is:
Global symbol "$syncXKoreSync" requires explicit package name at src/functions.pl line 712.
BEGIN not safe after errors--compilation aborted at src/functions.pl line 988.
Compilation failed in require at /u/ro/ok/openkore.pl line 52.
Press ENTER to exit this program.