// File: /workspace/github_c_makefile_star2_O2/Ziddykins[P]Dawn/src/status.c
// Function: event_handler
void event_handler(int sig) {
    assert(sig == SIGALRM);
    struct event * e;
    do {
        e = retr_event(); //handle event
        switch (e->event) {
            case MSGSEND:
            {
                pop_hist_msg();
                process_messages();
                break;
            }
            case HEALING:
            {
                int j;
                for (j=0; j < dawn->player_count; j++) {
                    if ((dawn->players[j].health + 5) <= dawn->players[j].max_health) {
                        dawn->players[j].health += 5;
                    } else {
                        dawn->players[j].health = dawn->players[j].max_health;
                    }
                }
                add_event(HEALING, 0, HEALING_INTERVAL, NORMAL);
                break;
            }
            case SAVING:
            {
                persistent_save();
                add_event(SAVING, 0, SAVING_INTERVAL, NORMAL);
                break;
            }
            case HOURLY:
            {
                hourly_events();
                add_event(HOURLY, 0, 3600, NORMAL);
                break;
            }
            case TRAVEL:
            {
                if(dawn->players[e->data].travel_timer.active) {
                    char out[MAX_MESSAGE_BUFFER];
                    dawn->players[e->data].pos_x = dawn->players[e->data].travel_timer.pos.x;
                    dawn->players[e->data].pos_y = dawn->players[e->data].travel_timer.pos.y;
                    sprintf(out, "PRIVMSG %s :%s has arrived at %d,%d\r\n", dawn->active_room, dawn->players[e->data].username,
                            dawn->players[e->data].pos_x, dawn->players[e->data].pos_y);
                    add_msg(out, strlen(out));
                    dawn->players[e->data].travel_timer.active = 0;
                    //check_special_location(dawn, e->data); DEPRECATED
                }
                break;
            }
            case LOTTERY_COLLECT:
            {
                lottery_collect();
                add_event(LOTTERY_COLLECT, 0, LOTTERY_COLLECT_INTERVAL, NORMAL);
                break;
            }
            case LOTTERY_REWARD:
            {
                lottery_reward();
                add_event(LOTTERY_REWARD, 0, LOTTERY_REWARD_INTERVAL, NORMAL);
                break;
            }
            case BOUNTY_RESET:
            {
                dawn->gbounty.amount = 0;
                gen_global_bounty();
                add_event(BOUNTY_RESET, 0, BOUNTY_RESET_INTERVAL, NORMAL);
                break;
            }
            case BOUNTY_INIT:
            {

                memset(&dawn->gbounty, 0, sizeof(dawn->gbounty));
                gen_global_bounty();
                break;
            }
        }
        free(e);
    } while(is_next_due());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
cmpl $0xe, %edi
jne 0xe2b7
leaq 0x916d(%rip), %rbp      # 0x17234
movq %rsp, %r15
pushq $0x5
popq %r12
pushq $0x6
popq %r13
pushq $0x7
popq %r14
callq 0xe8ab
movq %rax, %rbx
movl (%rax), %eax
cmpq $0x8, %rax
ja 0xe259
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x11985(%rip), %rax     # 0x1fa80
movl 0x148(%rax), %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
xorl %edx, %edx
cmpq %rdx, %rcx
je 0xe22e
movq 0x27f0(%rax,%rdx), %rsi
addq $0x5, %rsi
movslq 0x2810(%rax,%rdx), %rdi
cmpq %rdi, %rsi
cmovgeq %rdi, %rsi
movq %rsi, 0x27f0(%rax,%rdx)
addq $0x26a8, %rdx           # imm = 0x26A8
jmp 0xe114
callq 0xbef1
callq 0xbdd7
jmp 0xe259
callq 0x62dc
pushq $0x2
popq %rdi
xorl %esi, %esi
movl $0xe10, %edx            # imm = 0xE10
jmp 0xe252
movq 0x1190d(%rip), %rdx     # 0x1fa80
movslq 0x4(%rbx), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
cmpl $0x0, 0x12ec(%rdx,%rax)
je 0xe259
leaq 0x1a0(%rdx), %rsi
leaq (%rsi,%rax), %rcx
movl 0x1144(%rsi,%rax), %r8d
movl 0x1148(%rsi,%rax), %r9d
movl %r8d, 0x25ec(%rsi,%rax)
movl %r9d, 0x25f0(%rsi,%rax)
addq $0x100, %rdx            # imm = 0x100
movq %r15, %rdi
leaq 0x926d(%rip), %rsi      # 0x17435
xorl %eax, %eax
callq 0x2050
movq %r15, %rdi
callq 0x20c0
movq %r15, %rdi
movq %rax, %rsi
callq 0xbd04
movq 0x11897(%rip), %rax     # 0x1fa80
movslq 0x4(%rbx), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
andl $0x0, 0x12ec(%rax,%rcx)
jmp 0xe259
movq 0x1187b(%rip), %rax     # 0x1fa80
andl $0x0, 0x198(%rax)
callq 0x2af4
movl %r14d, %edi
xorl %esi, %esi
movl $0x15180, %edx          # imm = 0x15180
jmp 0xe252
callq 0xc818
pushq $0x1
popq %rdi
xorl %esi, %esi
movl $0x384, %edx            # imm = 0x384
jmp 0xe252
xorl %edi, %edi
jmp 0xe23a
callq 0x6b1b
movl %r12d, %edi
xorl %esi, %esi
movl $0x708, %edx            # imm = 0x708
jmp 0xe252
callq 0x6b79
movl %r13d, %edi
xorl %esi, %esi
movl $0xa8c0, %edx           # imm = 0xA8C0
xorl %ecx, %ecx
callq 0xe5c7
movq %rbx, %rdi
callq 0x2250
callq 0xe8ea
testl %eax, %eax
jne 0xe0d6
jmp 0xe2a5
movq 0x11809(%rip), %rax     # 0x1fa80
xorps %xmm0, %xmm0
movups %xmm0, 0x188(%rax)
movups %xmm0, 0x178(%rax)
movups %xmm0, 0x168(%rax)
movups %xmm0, 0x158(%rax)
andq $0x0, 0x198(%rax)
callq 0x2af4
jmp 0xe259
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9143(%rip), %rdi      # 0x17401
leaq 0x914b(%rip), %rsi      # 0x17410
leaq 0x9151(%rip), %rcx      # 0x1741d
movl $0xe8, %edx
callq 0x2100