// File: fieryzig[P]GameServer/GateServer/GateServer.cpp
// Function: fieryzig::GateServer::Dispatch(fieryzig::Client*, fieryzig::PacketInfo*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void GateServer::Dispatch(Client* cli, PacketInfo *ppi, string content) {
	switch(ppi->srcType) {
		case ServerType::CLIENT:
        {
		    PacketInfo pi;
		    if (ppi->uid == -1 && content == "Login") {

		        int uid = Login();
		        pi.srcType = config->type;
		        pi.time = time(NULL);
		        pi.uid = uid;
		        pi.svrid = ppi->svrid;
		        pi.clifd = cli->fd;
		        pi.contentLen = 5;
		        
                cli->Send(pi,"Login");
                Logics[pi.svrid]->Send(pi,"Login");
		    }
		    else {
                Logics[ppi->svrid]->Send(*ppi,content);
                if (content == "Logout") {
                    Clients.erase(cli);
                    close(cli->fd);
                }
		    }
		    break;
        }
		case ServerType::GATEWAY:
        {
		    break;
        }
		case ServerType::LOGIC:
        {
		    break;
        }
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rcx, -0x128(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x114(%rbp)
testl %eax, %eax
je 0x2b24
jmp 0x2aff
movl -0x114(%rbp), %eax
subl $0x1, %eax
je 0x2e48
jmp 0x2b10
movl -0x114(%rbp), %eax
subl $0x2, %eax
je 0x2e4a
jmp 0x2e4c
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x2d52
movq -0x128(%rbp), %rdi
leaq 0xb510(%rip), %rsi      # 0xe050
callq 0x3b50
testb $0x1, %al
jne 0x2b4e
jmp 0x2d52
movq -0x120(%rbp), %rdi
callq 0x3b80
movl %eax, %ecx
movq -0x120(%rbp), %rax
movl %ecx, -0x3c(%rbp)
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x2220
movl %eax, -0x34(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x2020(%rax), %eax
movl %eax, -0x28(%rbp)
movl $0x5, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movups -0x38(%rbp), %xmm0
movaps %xmm0, -0x60(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x23e0
movq -0x130(%rbp), %rdx
leaq 0xb475(%rip), %rsi      # 0xe050
leaq -0x80(%rbp), %rdi
callq 0x2320
jmp 0x2be6
movq -0x138(%rbp), %rdi
movq -0x50(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0x60(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x80(%rbp), %rsi
callq 0xc990
jmp 0x2c0a
leaq -0x80(%rbp), %rdi
callq 0x21a0
leaq -0x81(%rbp), %rdi
callq 0x2290
movq -0x120(%rbp), %rdi
addq $0x138, %rdi            # imm = 0x138
movslq -0x2c(%rbp), %rsi
callq 0x3bb0
movq (%rax), %rax
movq %rax, -0x148(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movups -0x38(%rbp), %xmm0
movaps %xmm0, -0xb0(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x23e0
movq -0x140(%rbp), %rdx
leaq 0xb3d9(%rip), %rsi      # 0xe050
leaq -0xd0(%rbp), %rdi
callq 0x2320
jmp 0x2c85
movq -0x148(%rbp), %rdi
movq -0xa0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0xb0(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0xd0(%rbp), %rsi
callq 0xc990
jmp 0x2cb2
leaq -0xd0(%rbp), %rdi
callq 0x21a0
leaq -0xd1(%rbp), %rdi
callq 0x2290
jmp 0x2e46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2cfe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x21a0
leaq -0x81(%rbp), %rdi
callq 0x2290
jmp 0x2e55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2d41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x21a0
leaq -0xd1(%rbp), %rdi
callq 0x2290
jmp 0x2e55
movq -0x120(%rbp), %rdi
addq $0x138, %rdi            # imm = 0x138
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rsi
callq 0x3bb0
movq -0x128(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x158(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0xe0(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0xf0(%rbp)
leaq -0x110(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x2120
movq -0x158(%rbp), %rdi
movq -0x150(%rbp), %rsi
movq -0xe0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0xf0(%rbp), %xmm0
movups %xmm0, (%rax)
callq 0xc990
jmp 0x2dd7
leaq -0x110(%rbp), %rdi
callq 0x21a0
movq -0x128(%rbp), %rdi
leaq 0xb265(%rip), %rsi      # 0xe056
callq 0x3b50
testb $0x1, %al
jne 0x2dfc
jmp 0x2e44
movq -0x120(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
leaq -0x10(%rbp), %rsi
callq 0x3bd0
movq -0x10(%rbp), %rax
movl 0x2020(%rax), %edi
callq 0x2440
jmp 0x2e44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x21a0
jmp 0x2e55
jmp 0x2e46
jmp 0x2e4c
jmp 0x2e4c
jmp 0x2e4c
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x23d0
nopw %cs:(%rax,%rax)