// File: /workspace/github_cpp_makefile_star2_O2/fieryzig[P]GameServer/LogicServer/LogicServer.cpp
// Function: fieryzig::LogicServer::SetConfig(char const*)
RS LogicServer::SetConfig(const char* configFile)
{
    string json = GetStringFromFile(configFile);
    if (json == "") {
        cout << configFile << " doesn't exist!" << endl;
        return RS::FAILED;
    }
    using rapidjson::Document;
    
    Document d;
    d.Parse(json.c_str());
    
    string type; ServerType st;
    int port = -1;
    string ip;
    
    using rapidjson::Value;
    
    Value& v = d["ServerType"];
    if (v.IsString()) {
        type = v.GetString();
        if (type == "CLIENT") {
            st = ServerType::CLIENT;
        }
        else if (type == "GATEWAY") {
            st = ServerType::GATEWAY;
        }
        else if (type == "LOGIC") {
            st = ServerType::LOGIC;
        }
        else {
            cout << "Wrong Server Type!" << endl;
            return RS::FAILED;
        }
    }
    v = d["IP"];
    if (v.IsString()) {
        ip = v.GetString();
    }
    else {
        cout << "Wrong IP Format!" << endl;
    }
    
    v = d["PORT"];
    if (v.IsInt()) {
        port = v.GetInt();
    }
    else {
        cout << "Wrong port!" << endl;
    }
    
    v = d["GATEWAY"];
    if (v.IsArray()) {
        for (int i = 0; i < v.Size(); i++) {
            Value& content = v[i];
            string ip; int port;
            if (content.HasMember("IP") && content["IP"].IsString()) {
                ip = content["IP"].GetString();
            }
            if (content.HasMember("PORT") && content["PORT"].IsInt()) {
                port = content["PORT"].GetInt();
            }
            gateway = make_pair(ip,port);
        }
    }

    config = new ServerConfig(st, ip, port);
    return RS::SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %rbx
movq %rdi, -0x38(%rbp)
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0x252c
leaq 0x724c(%rip), %rsi      # 0x9bd5
movq %r14, %rdi
callq 0x2e51
testb %al, %al
je 0x29c3
movq 0xa63c(%rip), %rdi      # 0xcfd8
movq %rbx, %rsi
callq 0x21e0
leaq 0x46ca(%rip), %rsi      # 0x7075
movq %rax, %rdi
callq 0x21e0
movq %rax, %rdi
callq 0x2130
pushq $0x1
popq %rbx
jmp 0x2ce6
leaq -0x140(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2f06
movq -0xe0(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x3b50
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x4670(%rip), %rsi      # 0x7085
leaq -0x140(%rbp), %rdi
callq 0x2f82
movq %rax, %r14
testb $0x4, 0xf(%rax)
je 0x2a8f
movq %r14, %rdi
callq 0x2fce
leaq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x2370
leaq 0x464b(%rip), %rsi      # 0x7090
leaq -0x80(%rbp), %rdi
callq 0x2e51
movl $0x0, -0x2c(%rbp)
testb %al, %al
jne 0x2a8f
leaq 0x4637(%rip), %rsi      # 0x7097
leaq -0x80(%rbp), %rdi
callq 0x2e51
testb %al, %al
je 0x2a71
pushq $0x1
jmp 0x2a8b
leaq 0x4627(%rip), %rsi      # 0x709f
leaq -0x80(%rbp), %rdi
callq 0x2e51
testb %al, %al
je 0x2d06
pushq $0x2
popq %rax
movl %eax, -0x2c(%rbp)
leaq 0x4622(%rip), %rsi      # 0x70b8
leaq -0x140(%rbp), %rdi
callq 0x2f82
movq %r14, %rdi
movq %rax, %rsi
callq 0x3012
testb $0x4, 0xf(%r14)
jne 0x2ad1
movq 0xa51d(%rip), %rdi      # 0xcfd8
leaq 0x45f9(%rip), %rsi      # 0x70bb
callq 0x21e0
movq %rax, %rdi
callq 0x2130
jmp 0x2ae8
movq %r14, %rdi
callq 0x2fce
leaq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x2370
leaq 0x45dd(%rip), %rsi      # 0x70cc
leaq -0x140(%rbp), %rdi
callq 0x2f82
movq %r14, %rdi
movq %rax, %rsi
callq 0x3012
testb $0x20, 0xe(%r14)
jne 0x2b2d
movq 0xa4c4(%rip), %rdi      # 0xcfd8
leaq 0x45b6(%rip), %rsi      # 0x70d1
callq 0x21e0
movq %rax, %rdi
callq 0x2130
pushq $-0x1
popq %rax
jmp 0x2b35
movq %r14, %rdi
callq 0x304a
movl %eax, -0x30(%rbp)
leaq 0x4558(%rip), %rsi      # 0x7097
leaq -0x140(%rbp), %rdi
callq 0x2f82
movq %r14, %rdi
movq %rax, %rsi
callq 0x3012
cmpw $0x4, 0xe(%r14)
jne 0x2c71
movq -0x38(%rbp), %rax
addq $0x170, %rax            # imm = 0x170
movq %rax, -0x40(%rbp)
xorl %r13d, %r13d
leaq -0x168(%rbp), %rbx
movq %r14, %rdi
callq 0x3076
cmpl %eax, %r13d
jae 0x2c71
movq %r14, %rdi
movl %r13d, %esi
callq 0x30a4
movq %rax, %r15
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
andq $0x0, -0x58(%rbp)
movb $0x0, -0x50(%rbp)
movq %r15, %rdi
leaq 0x4504(%rip), %rsi      # 0x70b8
callq 0x310a
testb %al, %al
je 0x2bf5
movq %r15, %rdi
leaq 0x44f1(%rip), %rsi      # 0x70b8
callq 0x2f82
testb $0x4, 0xf(%rax)
je 0x2bf5
movq %r15, %rdi
leaq 0x44dc(%rip), %rsi      # 0x70b8
callq 0x2f82
movq %rax, %rdi
callq 0x2fce
leaq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x2370
movq %r15, %rdi
leaq 0x44cd(%rip), %rsi      # 0x70cc
callq 0x310a
testb %al, %al
je 0x2c37
movq %r15, %rdi
leaq 0x44ba(%rip), %rsi      # 0x70cc
callq 0x2f82
testb $0x20, 0xe(%rax)
je 0x2c37
movq %r15, %rdi
leaq 0x44a5(%rip), %rsi      # 0x70cc
callq 0x2f82
movq %rax, %rdi
callq 0x304a
movl %eax, %r12d
movq %rbx, %rdi
leaq -0x60(%rbp), %r15
movq %r15, %rsi
callq 0x2290
movl %r12d, -0x148(%rbp)
movq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x3130
movq %rbx, %rdi
callq 0x2110
movq %r15, %rdi
callq 0x2110
incl %r13d
jmp 0x2b7a
pushq $0x30
popq %rdi
callq 0x21f0
movq %rax, %r14
leaq -0xc0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2290
movl -0x2c(%rbp), %eax
movl %eax, (%r14)
movq %r14, %rdi
addq $0x8, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x2290
movl -0x30(%rbp), %eax
movl %eax, 0x28(%r14)
movq -0x38(%rbp), %rax
movq %r14, 0x8(%rax)
leaq -0xc0(%rbp), %rdi
callq 0x2110
xorl %ebx, %ebx
leaq -0xa0(%rbp), %rdi
callq 0x2110
leaq -0x80(%rbp), %rdi
callq 0x2110
leaq -0x140(%rbp), %rdi
callq 0x3152
leaq -0xe0(%rbp), %rdi
callq 0x2110
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa2cb(%rip), %rdi      # 0xcfd8
leaq 0x4391(%rip), %rsi      # 0x70a5
callq 0x21e0
movq %rax, %rdi
callq 0x2130
pushq $0x1
popq %rbx
jmp 0x2cc5
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x2110
jmp 0x2d3a
movq %rax, %rbx
movq %r14, %rdi
callq 0x21d0
jmp 0x2d65
movq %rax, %rbx
jmp 0x2d7a
jmp 0x2d4b
movq %rax, %rbx
jmp 0x2d86
jmp 0x2d52
movq %rax, %rbx
jmp 0x2d65
jmp 0x2d59
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2110
leaq -0xa0(%rbp), %rdi
callq 0x2110
leaq -0x80(%rbp), %rdi
callq 0x2110
leaq -0x140(%rbp), %rdi
callq 0x3152
leaq -0xe0(%rbp), %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2330