// File: lotuskip[P]yuxtapa/server/occent.cpp
// Function: Zap::update()
void Zap::update()
{
	if(madevoid)
		return;
	if(bounces == -1) // indicates the first call to update()
		++bounces;
	else // not the first move; should vacate position:
	{
		event_set.insert(pos);
		Game::curmap->mod_tile(pos)->flags &= ~(TF_OCCUPIED);
	}

	for(char ch = 0; ch < ZAP_TILES_PER_TURN; ++ch)
	{
		if(missile_coll(this, pos.in(dir)))
		{
			// For zaps, missile_coll returns true if we (A) have been voided
			// by hitting something, or (B) hit a PC and _should_ void ourselves
			// if that was the final tile for this round.
			if(isvoid())
				return; // *this voided, possibly via a returning bounce() call
			//else
			if(ch == ZAP_TILES_PER_TURN-1) // hit something and are at the last tile
			{
				makevoid(); // occupied flag has been unset
				return;
			}
			// else we hit a PC and will pass right through her
		}
		pos = pos.in(dir);
	}
	// Travelled all the way without hitting anything.
	if(++travelled > ZAP_TRAVEL_DIST)
		makevoid();
	else
	{
		// Update for drawing:
		Game::curmap->mod_tile(pos)->flags |= TF_OCCUPIED;
		event_set.insert(pos);
		symbol = zappath_sym[dir];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
testb $0x1, 0xe(%rax)
je 0x4e71f
jmp 0x4e8b7
movq -0x48(%rbp), %rax
movsbl 0x1c(%rax), %eax
cmpl $-0x1, %eax
jne 0x4e73b
movq -0x48(%rbp), %rax
movb 0x1c(%rax), %cl
addb $0x1, %cl
movb %cl, 0x1c(%rax)
jmp 0x4e776
movq -0x48(%rbp), %rsi
addq $0x8, %rsi
leaq 0x449fe(%rip), %rdi     # 0x93148
callq 0x4a010
movq -0x48(%rbp), %rsi
movq %rax, -0x18(%rbp)
movb %dl, -0x10(%rbp)
leaq 0x43677(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
addq $0x8, %rsi
callq 0x3d2d0
movzwl (%rax), %ecx
andl $-0x41, %ecx
movw %cx, (%rax)
movb $0x0, -0x19(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x2, %eax
jge 0x4e844
movq -0x48(%rbp), %rax
movq %rax, %rsi
addq $0x8, %rsi
movl 0x18(%rax), %edx
leaq -0x1e(%rbp), %rdi
movq %rdi, -0x58(%rbp)
callq 0x60550
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x563c0
movb %al, -0x49(%rbp)
jmp 0x4e7b4
leaq -0x1e(%rbp), %rdi
callq 0x60460
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x4e7c6
jmp 0x4e80d
movq -0x48(%rbp), %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x4e7d5
jmp 0x4e7f4
jmp 0x4e8b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1e(%rbp), %rdi
callq 0x60460
jmp 0x4e8bd
movsbl -0x19(%rbp), %eax
cmpl $0x1, %eax
jne 0x4e80b
movq -0x48(%rbp), %rdi
callq 0x4d8d0
jmp 0x4e8b7
jmp 0x4e80d
movq -0x48(%rbp), %rax
movq %rax, %rsi
addq $0x8, %rsi
movl 0x18(%rax), %edx
leaq -0x30(%rbp), %rdi
callq 0x60550
movq -0x48(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, 0x8(%rax)
leaq -0x30(%rbp), %rdi
callq 0x60460
movb -0x19(%rbp), %al
addb $0x1, %al
movb %al, -0x19(%rbp)
jmp 0x4e77a
movq -0x48(%rbp), %rcx
movb 0x1d(%rcx), %al
addb $0x1, %al
movb %al, 0x1d(%rcx)
movsbl %al, %eax
cmpl $0x6, %eax
jle 0x4e863
movq -0x48(%rbp), %rdi
callq 0x4d8d0
jmp 0x4e8b7
movq -0x48(%rbp), %rsi
leaq 0x4356a(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
addq $0x8, %rsi
callq 0x3d2d0
movq -0x48(%rbp), %rsi
movzwl (%rax), %ecx
orl $0x40, %ecx
movw %cx, (%rax)
addq $0x8, %rsi
leaq 0x448b6(%rip), %rdi     # 0x93148
callq 0x4a010
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x40(%rbp)
movb %dl, -0x38(%rbp)
movl 0x18(%rax), %ecx
movl %ecx, %edx
leaq 0x199f8(%rip), %rcx     # 0x682a9
movb (%rcx,%rdx), %cl
movb %cl, 0xc(%rax)
addq $0x60, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x5920
nopw %cs:(%rax,%rax)