owner123 wrote:Very nice! Looks much cleaner even with just a quick glance over it. No more dynamic triggers and WaitForString calls.
Small efficiency comment: I'd make these commands use elseif rather than "endif/then" like this:
Code: Select all
if command == "debuff" then
call UnitRemoveBuffs( jjUnit, true, true )
endif
if command == "heal" then
call UnitRestoreLife( jjUnit, UnitMaxLife( jjUnit ) )
endif
That way we can save computation on evaluating these ifs
Well, WC3 has a limit of about 50 elseifs or maybe a bit higher, I have actually run into a limit, when I was rewriting VIP system for NRPG, so I would actually suggest avoid using it, instead it's better to add return in the if statement to exit from the thread upon completion, or just leave it as is. Aka in WC3 elseif is still read as a separate if, and the lower you go the more "paths" it generates.
haxorico wrote:Not talking about leaks, more about general coding.
For example, if I have a program with many different functions and loops (as many big projects have).
That is not really correct, every time a CreateGroup or DestroyGroup is called, WC3 is re-allocating memory, aka trying to free whatever was occupied and shifts it, to the changes. That also includes the shifting of arrays and so on, which is not really ideal.
Don't forget JASS only stores pointers, not the "objects" themselves. A Group is simply a dynamic array, that doesn't accept repeating entries, so there is no real point in destroying it, if it is used as a temporary group, which we can see in:
https://www.hiveworkshop.com/threads/ja ... st-2458284The point is, you don't need to destroy a group that will be used frequently, but you should destroy a group that probably will never be used again, if it is used in something like MUI spells. The same reasoning applies even to C++, you generally want to avoid re-creating variables if they don't really serve any purpose (although C++ has a much better garbage collector than what Warcraft 3 has, but oh well).
And now for the natives, I am using 1.26a offsets, CreateGroup ( GameDll + 0x3D2900 ) and DestroyGroup ( GameDll + 0x3C3FA0 ):
[spoiler=CreateGroup]
CreateGroup.png
[/spoiler]
[spoiler=DestroyGroup]
DestroyGroup_2.png
DestroyGroup.png
[/spoiler]
haxorico wrote:I will not use a single global integer called "i" or "index" that will be set to a starting value (like 0) at the beginning of each loop. As while no loop is using it, it is just some data that is sitting waiting and taking space.
When I need to use some data, I create it and when it is finished, destroy it.
You are comparing completely different types of variables, however, yes, with this example it is indeed better to get rid of unused variables, which I have stated above
haxorico wrote:Example for a cheatpack, is aslong as the game is running, even if I am not using the cheat-pack (as I am a user who is unaware), there is data taking space (the group is still being created, an empty group is still taking some space).
Well, same goes for any of the code, right? User will never be aware of what is happening "under the hood" until he takes a peek.
You do not have the required permissions to view the files attached to this post.