Opened 8 years ago
Last modified 7 years ago
#4326 closed enhancement
[PATCH] Random function cleanup — at Initial Version
Reported by: | bb | Owned by: | bb |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 22 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
- In current code there exist some duplicate function generating random numbers, it would be good to merge those into one globalscripts file.
- Also it would be good to have a randomPick function to randomly pick an element from an array, so we don't need to do shuffle array and then pick array[0], and thus save some performance.
- And last occurrences of
Math.round(Math.Random())
and similar expressions should be nuked into some RandInt() calls.
The attached patch is a rebase from #3102 and this ticket is necessary for the final implementation of that ticket.
Note:
See TracTickets
for help on using tickets.
Rabse form #3102, I would be glad to split the nuked function from the pickRandom(), but as the calls to pickRandom are mainly old calls to GetRandom and that last function got nuked, it seems better to merge it. So we don't change lines twice and the patch isn't *that* big. Also didn't add a messy "-1" in UnitAI because adding 1 ms to the random feed/walk time doesn't seem to matter.