- Joined
- Dec 12, 2010
- Messages
- 2,074
Whenever you create a group out of units, they're always located the same way between each player. It required for many things, including FirstOfGroup native - it have to be synced value.
Basic ordering algoritm can be seen on normal unit selection, when you select bunch of units using mouse. Selected group's representation on the HUD is the same as the JASS group would looks like. The same way game handles all other groups ordering, at least to my knowledge.
Each object in game which has a handle also has 2 miniref indexes. One can imagine those indexes being an X/Y coordinates of 2D array, a-la "10D34" and "832D". Whole game working around those miniRefs, but there are no way for mapmaker to know those IDs or manipulate them. They aren't related to any handle ID and can be re-assigned when no longer used to another object, just like handle IDs, automatically.
In case if you have no leaks, dead units/objects (which got cleared from the memory) handles & miniRefs might be re-used and your groups will start to sharking because of their miniRef most likely will be lower than miniRef of unit created later.
In case if you leak each object's handle, game can't free minRefs either, leading in continuous increase of miniRef values. Therefore, in case if we don't speak about heroes, there are big chance that units added into a group will be ordered starting from the oldest one to newest one. I say a "chance" because there are instances you can't control, like abilities usage or buildings or anything else, plenty background process are happens each second.
Obviously, if you won't clean up your leaks, soon you'll get out of memory errors, so thats not the way to go.
Practical effect:
None of unit's parameters even matter for the order they're inside the group. If first letter of his UnitTypeId is A-Z then he will be in first line, else - in second, everything else irrelevant.
Blizzard, pls give us:
native GetNthUnitFromGroup takes group g, integer n returns unit
so we can check each group's position manually. In case of bad N return null, as usual. Thats much better than slow-ass GroupPickRandomUnit. There are already a similar cycle inside GroupRemoveUnit, with a very small adjustments it can be turned into new native within 5 mins.
Basic ordering algoritm can be seen on normal unit selection, when you select bunch of units using mouse. Selected group's representation on the HUD is the same as the JASS group would looks like. The same way game handles all other groups ordering, at least to my knowledge.
- Heroes (defined by ID's first letter) are always pushed on the top of the list.
- Units with the same ID are always going in bunches, you can't have two units of the same typeID being spreaded inside the group listing, they're always nearby.
- When 2 units have the same priority on placing, first cell will be taken by the one with lowest RefMini index.
Each object in game which has a handle also has 2 miniref indexes. One can imagine those indexes being an X/Y coordinates of 2D array, a-la "10D34" and "832D". Whole game working around those miniRefs, but there are no way for mapmaker to know those IDs or manipulate them. They aren't related to any handle ID and can be re-assigned when no longer used to another object, just like handle IDs, automatically.
In case if you have no leaks, dead units/objects (which got cleared from the memory) handles & miniRefs might be re-used and your groups will start to sharking because of their miniRef most likely will be lower than miniRef of unit created later.
In case if you leak each object's handle, game can't free minRefs either, leading in continuous increase of miniRef values. Therefore, in case if we don't speak about heroes, there are big chance that units added into a group will be ordered starting from the oldest one to newest one. I say a "chance" because there are instances you can't control, like abilities usage or buildings or anything else, plenty background process are happens each second.
Obviously, if you won't clean up your leaks, soon you'll get out of memory errors, so thats not the way to go.
Practical effect:
- Adding a hero into a group with no heroes or hero illusions will definitly put him into top cell. FirstOfGroup will always return this hero.
- Adding a second hero into the same group will force game to compare miniRefs, and you have no control over that.
- Adding a non-hero will never put him above any hero/illusion in group. All of non-heroes will stack next to each other in order of their miniRefs increasing.
None of unit's parameters even matter for the order they're inside the group. If first letter of his UnitTypeId is A-Z then he will be in first line, else - in second, everything else irrelevant.
Blizzard, pls give us:
native GetNthUnitFromGroup takes group g, integer n returns unit
so we can check each group's position manually. In case of bad N return null, as usual. Thats much better than slow-ass GroupPickRandomUnit. There are already a similar cycle inside GroupRemoveUnit, with a very small adjustments it can be turned into new native within 5 mins.
Last edited: