- Joined
- Aug 7, 2013
- Messages
- 1,338
Hi,
Suppose people enter a room in random order. After entering the room, the person cannot leave.
The first person who enters the room starts a timer for N seconds.
Everyone else who enters the room afterwards has to wait whatever time is remaining on the first person's timer.
When the first person's timer finishes, the door to the room locks, and nobody can enter.
Here is my simple implementation of this "local" global wait (local since it's only true for one room--there could be many rooms with this property). Are there any problems with my set up?
Suppose people enter a room in random order. After entering the room, the person cannot leave.
The first person who enters the room starts a timer for N seconds.
Everyone else who enters the room afterwards has to wait whatever time is remaining on the first person's timer.
When the first person's timer finishes, the door to the room locks, and nobody can enter.
Here is my simple implementation of this "local" global wait (local since it's only true for one room--there could be many rooms with this property). Are there any problems with my set up?
JASS:
local timer t
local timer globalTimer
if timerTable.timer[this] == null then
set timerTable.timer[this] = CreateTimer()
set globalTimer = timerTable.timer[this]
set eventHandleTable[GetHandleId(globalTimer)] = this
set eventHandleTable.real[GetHandleId(globalTimer)] = pid
call TimerStart(globalTimer, duration, false, function after)
else //someone's already started this global timer
set t = CreateTimer()
set eventHandleTable[GetHandleId(t)] = this
set eventHandleTable.real[GetHandleId(t)] = pid
call TimerStart(t, TimerGetRemaining(timerTable.timer[this]), false, function EventGlobalWait.afterWait)
endif