| 08-18-2008, 05:57 PM | #1 |
Hi guys I am doing my map, and one of the coders of the team likes using waits some times. I don't like them, but I don't know enough to prove to him they are really evil. This are the reasons I think Waits are evil, can some one tell me if they are correct or add more reasons about why shouldn't use waits please ? : 1 - waits are not accurate 2 - waits can cause memory corruption due bad use of CPU and thus a game crash 3 - waits diminish code's efficiency greatly because they use an assembly instruction "nop" which means "do nothing on the cycle", thus although the CPU could be working on something else for the machine it is wasting precious cycles in a stupid way 4 - waits can cause threads to crash 5 - waits ca not be used in ForGroup and in Boolexpr 6 - waits produce weird effects if used in filters Why are waits better: 1 - waits are more efficient than timers ( is this truth !?) 2 - waits are easier to use Why are timers better: 1 - they are more accurate then waits 2 - they don't do all evil stuff waits do Can some one help me out this please ? |
| 08-18-2008, 06:06 PM | #2 |
It's mainly an issue of accuracy and stability (timers) vs. ease of use. I also doubt that waits are more efficient - even if they are, the difference is marginal, practicaly insignificant. As an example: I was making a TD with spawning using waits. Trigger 1: Turn on (spawn) Wait 20 Turn off (spawn) Spawn: Time - every 0.75 Unit - Spawn (unit) Technically, this should always spawn (20)/(0.75), with a slight variation due to logic. However, during one spawning session, I Alt-Tab'd out of warcraft, and on my return I noticed that it spawned less that usual. This is because waits are not as efficient/stable as timers. If your coder likes to use waits, first look at the trigger he is using it in to determine if it's bad or not. In most cases (spells, advanced triggers, etc), timers are better. However, in simple time intervals (like next round in 30 seconds or such), waits are practically no different from timers. |
| 08-18-2008, 06:08 PM | #3 |
The main advantage of waits is that you keep access to local variables, and don't need to cleanup. The main disadvantage is accuracy and killing ForGroup/conditions/etc. I think as long as the functions doing waits aren't being called from elsewhere, it's fine. So you can use them in isolation, but functions that other triggers and systems call should never be waiting. Maybe get him to try Decal? It hides all the timer and attaching stuff behind a function. http://wc3campaigns.net/showthread.php?t=101403 |
| 08-18-2008, 06:45 PM | #4 |
I don't consider waits evil, they are just lame, there is also the detail that their durations get very unpredictable when they are used in quantity and there are many players in the game, or that they really can't use short times. I think timers (without attaching or anything) are more efficient than waits. |
| 08-18-2008, 08:18 PM | #5 |
With the help of Deaod, I made some testing to confirm Anitarf's predictions. Never use waits in multiplayer. The "Waiting for players"-window won't prevent waits from ticking. In other words, when the player has dropped, all your waits will have gone through 45 seconds (at max). |
| 08-18-2008, 09:36 PM | #6 |
JASS:local timer t=CreateTimer() call TimerStart(t, 8192., false, null) call TriggerSleepAction(0.) call BJDebugMsg("min TriggerSleepAction period - "+R2S(TimerGetElapsed(t))) hm... i use only timers) |
| 08-18-2008, 09:44 PM | #7 |
the main feature of sleep is what it does need to be synchronized between players. well it does mess alot with it. + sleep in dead trigger = omfg evil =) it does put the last destroyed object to the handle stack. (or does it require 2+ sleeps) but well anyway. the main reason is what it's unprecise and makes algorithm logic weird. |
| 08-18-2008, 10:22 PM | #8 | |
Quote:
|
| 08-18-2008, 10:33 PM | #9 | |
Quote:
He meant the lag screen, not normal dialogs. |
| 08-18-2008, 10:34 PM | #10 |
I use waits in my map. Is there something wrong with that? Waits is my favorite action. I only use timer on my demon cage though, cuz i need those spines at perfect height, otherwise I use waits on not so critical spells. |
| 08-18-2008, 10:53 PM | #11 |
Waits are for sissies and GUI users. |
| 08-18-2008, 11:10 PM | #12 | |
Quote:
Waits shorten code considerably. They also allow for functions to lock the current running thread (as used by Vexorian in the Caster System). Waits should be for everyone, since they are really nifty. Waits are for nobody. They are unsafe. |
| 08-18-2008, 11:30 PM | #13 | ||
Quote:
Quote:
|
| 08-18-2008, 11:35 PM | #14 |
It's still easier. |
| 08-19-2008, 12:11 AM | #15 |
or u all can try out my crazy macro abuse timing system for the old fashion way of making waits, just now more accurate and same simplicity |
