local ServerCfg = {
normal        = 0,
classic        = 1,    -- 怀旧版本服务器
notrade        = 2,    -- 不可交易版本服务器
gold        = 4,    -- 金币服务器
new            = 8,    -- 新服
passion        = 16,    -- 激情服
oldsoldier        = 256,    -- 老兵服
coinsserver        = 512,    -- 掉钱服
}

local T_UserData = {
}

local function GetServerType()
    return T_UserData.serverType
end

local function ResetDynamicData()
    T_UserData = {}

    -- 服务器类型
    T_UserData.serverType = 0
    T_UserData.isNewServer = false
    T_UserData.isPassion = false
	T_UserData.isOldSoldier = false
	T_UserData.isCoinsServer = false
end

local function SetServerType(server_type)
	ResetDynamicData()
	
	T_UserData.serverType = server_type

    if (Cpp_And(server_type, ServerCfg.new) > 0) then
        T_UserData.isNewServer = true
    end

    if (Cpp_And(server_type, ServerCfg.passion) > 0) then
        T_UserData.isPassion = true
    end

    if (Cpp_And(server_type, ServerCfg.oldsoldier) > 0) then
        T_UserData.isOldSoldier = true
    end
	
	if (Cpp_And(server_type, ServerCfg.coinsserver) > 0) then
        T_UserData.isCoinsServer = true
    end
end

-- 是否新服
local function IsNewServer()
    return T_UserData.isNewServer
end

-- 是否激情服
local function IsPassionServer()
    return T_UserData.isPassion
end

-- 是否老兵服
local function IsOldSoldierServer()
    return T_UserData.isOldSoldier
end

--是否掉钱服，请根据实际配置
local function IsCoinsServer()
	return T_UserData.isCoinsServer
end

local function Unload()
    ResetDynamicData()
end

local UserData = {
	IsCoinsServer = IsCoinsServer,
    GetServerType = GetServerType,
    IsNewServer = IsNewServer,
    IsPassionServer = IsPassionServer,
    ResetDynamicData = ResetDynamicData,
    SetServerType = SetServerType,
	IsOldSoldierServer = IsOldSoldierServer,
    Unload = Unload,
}

UserData_GetServerType = UserData.GetServerType
UserData_IsNewServer = UserData.IsNewServer
UserData_IsPassionServer = UserData.IsPassionServer
UserData_ResetDynamicData = UserData.ResetDynamicData
UserData_SetServerType = UserData.SetServerType
UserData_IsOldSoldierServer = UserData.IsOldSoldierServer
UserData_IsCoinsServer = UserData.IsCoinsServer
UserData_Unload = UserData.Unload
return UserData
