// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
cmpl $0xe, %edi
jne 0xf2e2
leaq 0x911c(%rip), %r12      # 0x18204
leaq 0x9316(%rip), %rbx      # 0x18405
movq %rsp, %r14
callq 0xf89b
movq %rax, %r15
movl (%rax), %eax
cmpq $0x8, %rax
ja 0xf284
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x1296a(%rip), %rax     # 0x21a80
movslq 0x148(%rax), %rcx
testq %rcx, %rcx
jle 0xf15a
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
xorl %edx, %edx
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
cmpq %rdx, %rcx
jne 0xf12b
xorl %edi, %edi
jmp 0xf263
callq 0xcf10
callq 0xcdc7
jmp 0xf284
callq 0x7024
movl $0x2, %edi
xorl %esi, %esi
movl $0xe10, %edx            # imm = 0xE10
jmp 0xf27d
movq 0x128f3(%rip), %rdx     # 0x21a80
movslq 0x4(%r15), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
cmpl $0x0, 0x12ec(%rdx,%rax)
je 0xf284
leaq 0x1a0(%rdx), %rax
movslq 0x4(%r15), %rcx
imulq $0x26a8, %rcx, %rsi     # imm = 0x26A8
leaq (%rax,%rsi), %rcx
movl 0x1144(%rax,%rsi), %r8d
movl 0x1148(%rax,%rsi), %r9d
movl %r8d, 0x25ec(%rax,%rsi)
movl %r9d, 0x25f0(%rax,%rsi)
addq $0x100, %rdx            # imm = 0x100
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xcd1c
movq 0x12876(%rip), %rax     # 0x21a80
movslq 0x4(%r15), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movl $0x0, 0x12ec(%rax,%rcx)
jmp 0xf284
movq 0x12857(%rip), %rax     # 0x21a80
movl $0x0, 0x198(%rax)
callq 0x3764
movl $0x7, %edi
xorl %esi, %esi
movl $0x15180, %edx          # imm = 0x15180
jmp 0xf27d
callq 0xd854
movl $0x1, %edi
xorl %esi, %esi
movl $0x384, %edx            # imm = 0x384
jmp 0xf27d
callq 0x7921
movl $0x5, %edi
xorl %esi, %esi
movl $0x708, %edx            # imm = 0x708
jmp 0xf27d
callq 0x7997
movl $0x6, %edi
xorl %esi, %esi
movl $0xa8c0, %edx           # imm = 0xA8C0
xorl %ecx, %ecx
callq 0xf5b7
movq %r15, %rdi
callq 0x2240
callq 0xf8da
testl %eax, %eax
jne 0xf0f2
jmp 0xf2d3
movq 0x127de(%rip), %rax     # 0x21a80
xorps %xmm0, %xmm0
movups %xmm0, 0x188(%rax)
movups %xmm0, 0x178(%rax)
movups %xmm0, 0x168(%rax)
movups %xmm0, 0x158(%rax)
movq $0x0, 0x198(%rax)
callq 0x3764
jmp 0xf284
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x90e8(%rip), %rdi      # 0x183d1
leaq 0x90f0(%rip), %rsi      # 0x183e0
leaq 0x90f6(%rip), %rcx      # 0x183ed
movl $0xe8, %edx
callq 0x2100