-module(pt_400).
-include("common.hrl").
-export([
        read/2,
        write/2
    ]).

read(40001, Bin0) ->
    {GuildName, Bin1} = pt:read_string(Bin0), 
    <<Filter:8, Bin2/binary>> = Bin1, 
    <<PageSize:16, Bin3/binary>> = Bin2, 
    <<PageNo:16, _Bin4/binary>> = Bin3, 
    {ok, [GuildName, Filter, PageSize, PageNo]};
read(40002, Bin0) ->
    <<GuildId:64, _Bin1/binary>> = Bin0, 
    {ok, [GuildId]};
read(40003, _) ->
    {ok, []};
read(40004, Bin0) ->
    <<Opty:8, Bin1/binary>> = Bin0, 
    {GuildName, Bin2} = pt:read_string(Bin1), 
    <<GuildFlag:32, _Bin3/binary>> = Bin2, 
    {ok, [Opty, GuildName, GuildFlag]};
read(40005, _) ->
    {ok, []};
read(40006, Bin0) ->
    <<PageSize:16, Bin1/binary>> = Bin0, 
    <<PageNo:16, _Bin2/binary>> = Bin1, 
    {ok, [PageSize, PageNo]};
read(40007, _) ->
    {ok, []};
read(40008, _) ->
    {ok, []};
read(40009, Bin0) ->
    <<RoleId:64, Bin1/binary>> = Bin0, 
    <<Type:8, _Bin2/binary>> = Bin1, 
    {ok, [RoleId, Type]};
read(40010, _) ->
    {ok, []};
read(40011, Bin0) ->
    <<ApproveType:8, Bin1/binary>> = Bin0, 
    <<AutoApproveLv:16, Bin2/binary>> = Bin1, 
    <<AutoApprovePower:64, _Bin3/binary>> = Bin2, 
    {ok, [ApproveType, AutoApproveLv, AutoApprovePower]};
read(40012, Bin0) ->
    {Announce, Bin1} = pt:read_string(Bin0), 
    <<Type:8, _Bin2/binary>> = Bin1, 
    {ok, [Announce, Type]};
read(40013, Bin0) ->
    <<RoleId:64, Bin1/binary>> = Bin0, 
    <<Position:8, _Bin2/binary>> = Bin1, 
    {ok, [RoleId, Position]};
read(40014, Bin0) ->
    <<RoleId:64, _Bin1/binary>> = Bin0, 
    {ok, [RoleId]};
read(40015, _) ->
    {ok, []};
read(40016, Bin0) ->
    <<Type:8, _Bin1/binary>> = Bin0, 
    {ok, [Type]};
read(40018, Bin0) ->
    <<Position:8, _Bin1/binary>> = Bin0, 
    {ok, [Position]};
read(40019, _) ->
    {ok, []};
read(40020, _) ->
    {ok, []};
read(40021, _) ->
    {ok, []};
read(40022, Bin0) ->
    <<PageSize:16, Bin1/binary>> = Bin0, 
    <<PageNo:16, _Bin2/binary>> = Bin1, 
    {ok, [PageSize, PageNo]};
read(40023, _) ->
    {ok, []};
read(40024, Bin0) ->
    <<Position:8, Bin1/binary>> = Bin0, 
    FunArray0 = fun(<<RestBin0/binary>>) -> 
        <<RoleId:64, _Args01/binary>> = RestBin0, 
        {RoleId,_Args01}
        end,
    {RoleIdList, _Bin2} = pt:read_array(FunArray0, Bin1),

    {ok, [Position, RoleIdList]};
read(40025, Bin0) ->
    <<Opty:8, Bin1/binary>> = Bin0, 
    {GuildName, Bin2} = pt:read_string(Bin1), 
    <<GuildFlag:32, _Bin3/binary>> = Bin2, 
    {ok, [Opty, GuildName, GuildFlag]};
read(40026, _) ->
    {ok, []};
read(40027, _) ->
    {ok, []};
read(40028, Bin0) ->
    <<Id:32, Bin1/binary>> = Bin0, 
    <<Num:16, _Bin2/binary>> = Bin1, 
    {ok, [Id, Num]};
read(40031, Bin0) ->
    <<GuildId:64, _Bin1/binary>> = Bin0, 
    {ok, [GuildId]};
read(40032, _) ->
    {ok, []};
read(40033, Bin0) ->
    <<Opty:8, Bin1/binary>> = Bin0, 
    <<Target:64, _Bin2/binary>> = Bin1, 
    {ok, [Opty, Target]};
read(40034, _) ->
    {ok, []};
read(40035, _) ->
    {ok, []};
read(40066, _) ->
    {ok, []};
read(40036, Bin0) ->
    <<Opty:8, Bin1/binary>> = Bin0, 
    <<Order:8, _Bin2/binary>> = Bin1, 
    {ok, [Opty, Order]};
read(40037, Bin0) ->
    <<Order:8, Bin1/binary>> = Bin0, 
    <<Rid:64, _Bin2/binary>> = Bin1, 
    {ok, [Order, Rid]};
read(40039, Bin0) ->
    <<Order:8, Bin1/binary>> = Bin0, 
    <<Rid:64, _Bin2/binary>> = Bin1, 
    {ok, [Order, Rid]};
read(40041, Bin0) ->
    <<Order:8, _Bin1/binary>> = Bin0, 
    {ok, [Order]};
read(40044, _) ->
    {ok, []};
read(40045, _) ->
    {ok, []};
read(40046, _) ->
    {ok, []};
read(40047, _) ->
    {ok, []};
read(40048, _) ->
    {ok, []};
read(40049, Bin0) ->
    <<SupportId:64, _Bin1/binary>> = Bin0, 
    {ok, [SupportId]};
read(40050, Bin0) ->
    <<Type:8, Bin1/binary>> = Bin0, 
    <<SupportId:64, Bin2/binary>> = Bin1, 
    {ChatMsg, _Bin3} = pt:read_string(Bin2), 
    {ok, [Type, SupportId, ChatMsg]};
read(40051, Bin0) ->
    <<Module:16, Bin1/binary>> = Bin0, 
    <<SubModule:16, Bin2/binary>> = Bin1, 
    <<GameValue1:16, Bin3/binary>> = Bin2, 
    <<GameValue2:64, _Bin4/binary>> = Bin3, 
    {ok, [Module, SubModule, GameValue1, GameValue2]};
read(40052, Bin0) ->
    <<SupportSid:64, _Bin1/binary>> = Bin0, 
    {ok, [SupportSid]};
read(40053, _) ->
    {ok, []};
read(40054, _) ->
    {ok, []};
read(40055, _) ->
    {ok, []};
read(40056, _) ->
    {ok, []};
read(40057, _) ->
    {ok, []};
read(40058, _) ->
    {ok, []};
read(40060, _) ->
    {ok, []};
read(40061, _) ->
    {ok, []};
read(40063, _) ->
    {ok, []};
read(40064, Bin0) ->
    <<ModId:16, _Bin1/binary>> = Bin0, 
    {ok, [ModId]};
read(40068, _) ->
    {ok, []};
read(40069, _) ->
    {ok, []};
read(40070, Bin0) ->
    <<Type:8, Bin1/binary>> = Bin0, 
    <<SupportId:64, _Bin2/binary>> = Bin1, 
    {ok, [Type, SupportId]};
read(40071, _) ->
    {ok, []};
read(_Cmd, _R) -> {error, no_match}.

write (40000,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40000, Data, Src_Data)};

write (40001,[
    Filter,
    PageTotal,
    PageNo,
    GuildList,
    HistoryGuildNum
] = Src_Data) ->
    BinList_GuildList = [
        item_to_bin_0(GuildList_Item) || GuildList_Item <- GuildList
    ], 

    GuildList_Len = length(GuildList), 
    Bin_GuildList = list_to_binary(BinList_GuildList),

    Data = <<
        Filter:8,
        PageTotal:16,
        PageNo:16,
        GuildList_Len:16, Bin_GuildList/binary,
        HistoryGuildNum:16
    >>,
    {ok, pt:encode(40001, Data, Src_Data)};

write (40002,[
    Result,
    GuildId,
    ApplyType
] = Src_Data) ->
    Data = <<
        Result:32,
        GuildId:64,
        ApplyType:8
    >>,
    {ok, pt:encode(40002, Data, Src_Data)};

write (40003,[
    Result,
    GuildId,
    ApplyType
] = Src_Data) ->
    Data = <<
        Result:32,
        GuildId:64,
        ApplyType:8
    >>,
    {ok, pt:encode(40003, Data, Src_Data)};

write (40004,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40004, Data, Src_Data)};

write (40005,[
    GuildId,
    GuildName,
    GuildFlag,
    ChiefName,
    Announce,
    PositionList,
    GuildLv,
    GuildExp,
    Division,
    GuildFunds,
    MemberNum,
    WeekLaborLast,
    CombatPower,
    OnlineNum,
    DisbandWarnningTime,
    DisbandStatus,
    CreateTime,
    Badges,
    AddMemNum
] = Src_Data) ->
    Bin_GuildName = pt:write_string(GuildName), 

    Bin_ChiefName = pt:write_string(ChiefName), 

    Bin_Announce = pt:write_string(Announce), 

    BinList_PositionList = [
        item_to_bin_2(PositionList_Item) || PositionList_Item <- PositionList
    ], 

    PositionList_Len = length(PositionList), 
    Bin_PositionList = list_to_binary(BinList_PositionList),

    BinList_Badges = [
        item_to_bin_3(Badges_Item) || Badges_Item <- Badges
    ], 

    Badges_Len = length(Badges), 
    Bin_Badges = list_to_binary(BinList_Badges),

    Data = <<
        GuildId:64,
        Bin_GuildName/binary,
        GuildFlag:32,
        Bin_ChiefName/binary,
        Bin_Announce/binary,
        PositionList_Len:16, Bin_PositionList/binary,
        GuildLv:16,
        GuildExp:32,
        Division:16,
        GuildFunds:32,
        MemberNum:16,
        WeekLaborLast:32,
        CombatPower:64,
        OnlineNum:16,
        DisbandWarnningTime:32,
        DisbandStatus:8,
        CreateTime:32,
        Badges_Len:16, Bin_Badges/binary,
        AddMemNum:8
    >>,
    {ok, pt:encode(40005, Data, Src_Data)};

write (40006,[
    PageTotal,
    PageNo,
    MemberList
] = Src_Data) ->
    BinList_MemberList = [
        item_to_bin_4(MemberList_Item) || MemberList_Item <- MemberList
    ], 

    MemberList_Len = length(MemberList), 
    Bin_MemberList = list_to_binary(BinList_MemberList),

    Data = <<
        PageTotal:16,
        PageNo:16,
        MemberList_Len:16, Bin_MemberList/binary
    >>,
    {ok, pt:encode(40006, Data, Src_Data)};

write (40007,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40007, Data, Src_Data)};

write (40008,[
    ApplyList
] = Src_Data) ->
    BinList_ApplyList = [
        item_to_bin_5(ApplyList_Item) || ApplyList_Item <- ApplyList
    ], 

    ApplyList_Len = length(ApplyList), 
    Bin_ApplyList = list_to_binary(BinList_ApplyList),

    Data = <<
        ApplyList_Len:16, Bin_ApplyList/binary
    >>,
    {ok, pt:encode(40008, Data, Src_Data)};

write (40009,[
    Result,
    Type,
    RoleId
] = Src_Data) ->
    Data = <<
        Result:32,
        Type:8,
        RoleId:64
    >>,
    {ok, pt:encode(40009, Data, Src_Data)};

write (40010,[
    ApproveType,
    AutoApproveLv,
    AutoApprovePower
] = Src_Data) ->
    Data = <<
        ApproveType:8,
        AutoApproveLv:16,
        AutoApprovePower:64
    >>,
    {ok, pt:encode(40010, Data, Src_Data)};

write (40011,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40011, Data, Src_Data)};

write (40012,[
    Result,
    LeftNum
] = Src_Data) ->
    Data = <<
        Result:32,
        LeftNum:16
    >>,
    {ok, pt:encode(40012, Data, Src_Data)};

write (40013,[
    Result,
    RoleId,
    Position
] = Src_Data) ->
    Data = <<
        Result:32,
        RoleId:64,
        Position:8
    >>,
    {ok, pt:encode(40013, Data, Src_Data)};

write (40014,[
    Result,
    RoleId
] = Src_Data) ->
    Data = <<
        Result:32,
        RoleId:64
    >>,
    {ok, pt:encode(40014, Data, Src_Data)};

write (40015,[
    GuildId,
    GuildName,
    GuildLv,
    Position,
    PositionName
] = Src_Data) ->
    Bin_GuildName = pt:write_string(GuildName), 

    Bin_PositionName = pt:write_string(PositionName), 

    Data = <<
        GuildId:64,
        Bin_GuildName/binary,
        GuildLv:16,
        Position:8,
        Bin_PositionName/binary
    >>,
    {ok, pt:encode(40015, Data, Src_Data)};

write (40016,[
    Result,
    Type
] = Src_Data) ->
    Data = <<
        Result:32,
        Type:8
    >>,
    {ok, pt:encode(40016, Data, Src_Data)};

write (40017,[
    RoleId,
    GuildId,
    GuildName,
    Position,
    PositionName
] = Src_Data) ->
    Bin_GuildName = pt:write_string(GuildName), 

    Bin_PositionName = pt:write_string(PositionName), 

    Data = <<
        RoleId:64,
        GuildId:64,
        Bin_GuildName/binary,
        Position:8,
        Bin_PositionName/binary
    >>,
    {ok, pt:encode(40017, Data, Src_Data)};

write (40018,[
    Position,
    Result
] = Src_Data) ->
    Data = <<
        Position:8,
        Result:32
    >>,
    {ok, pt:encode(40018, Data, Src_Data)};

write (40019,[
    RemainTimes,
    FreeTimes
] = Src_Data) ->
    Data = <<
        RemainTimes:8,
        FreeTimes:8
    >>,
    {ok, pt:encode(40019, Data, Src_Data)};

write (40020,[
    State,
    Flags
] = Src_Data) ->
    BinList_Flags = [
        item_to_bin_6(Flags_Item) || Flags_Item <- Flags
    ], 

    Flags_Len = length(Flags), 
    Bin_Flags = list_to_binary(BinList_Flags),

    Data = <<
        State:8,
        Flags_Len:16, Bin_Flags/binary
    >>,
    {ok, pt:encode(40020, Data, Src_Data)};

write (40021,[
    PermissionTypeList
] = Src_Data) ->
    BinList_PermissionTypeList = [
        item_to_bin_7(PermissionTypeList_Item) || PermissionTypeList_Item <- PermissionTypeList
    ], 

    PermissionTypeList_Len = length(PermissionTypeList), 
    Bin_PermissionTypeList = list_to_binary(BinList_PermissionTypeList),

    Data = <<
        PermissionTypeList_Len:16, Bin_PermissionTypeList/binary
    >>,
    {ok, pt:encode(40021, Data, Src_Data)};

write (40022,[
    PageTotal,
    PageNo,
    MemberList
] = Src_Data) ->
    BinList_MemberList = [
        item_to_bin_8(MemberList_Item) || MemberList_Item <- MemberList
    ], 

    MemberList_Len = length(MemberList), 
    Bin_MemberList = list_to_binary(BinList_MemberList),

    Data = <<
        PageTotal:16,
        PageNo:16,
        MemberList_Len:16, Bin_MemberList/binary
    >>,
    {ok, pt:encode(40022, Data, Src_Data)};

write (40023,[
    PositionNumList
] = Src_Data) ->
    BinList_PositionNumList = [
        item_to_bin_9(PositionNumList_Item) || PositionNumList_Item <- PositionNumList
    ], 

    PositionNumList_Len = length(PositionNumList), 
    Bin_PositionNumList = list_to_binary(BinList_PositionNumList),

    Data = <<
        PositionNumList_Len:16, Bin_PositionNumList/binary
    >>,
    {ok, pt:encode(40023, Data, Src_Data)};

write (40024,[
    ErrorCode,
    Position,
    ChangeList
] = Src_Data) ->
    BinList_ChangeList = [
        item_to_bin_10(ChangeList_Item) || ChangeList_Item <- ChangeList
    ], 

    ChangeList_Len = length(ChangeList), 
    Bin_ChangeList = list_to_binary(BinList_ChangeList),

    Data = <<
        ErrorCode:32,
        Position:8,
        ChangeList_Len:16, Bin_ChangeList/binary
    >>,
    {ok, pt:encode(40024, Data, Src_Data)};

write (40025,[
    ErrorCode,
    GuildName,
    GuildFlag
] = Src_Data) ->
    Bin_GuildName = pt:write_string(GuildName), 

    Data = <<
        ErrorCode:32,
        Bin_GuildName/binary,
        GuildFlag:32
    >>,
    {ok, pt:encode(40025, Data, Src_Data)};

write (40026,[
    ErrorCode
] = Src_Data) ->
    Data = <<
        ErrorCode:32
    >>,
    {ok, pt:encode(40026, Data, Src_Data)};

write (40027,[
    Cargos
] = Src_Data) ->
    BinList_Cargos = [
        item_to_bin_11(Cargos_Item) || Cargos_Item <- Cargos
    ], 

    Cargos_Len = length(Cargos), 
    Bin_Cargos = list_to_binary(BinList_Cargos),

    Data = <<
        Cargos_Len:16, Bin_Cargos/binary
    >>,
    {ok, pt:encode(40027, Data, Src_Data)};

write (40028,[
    Result,
    Id,
    Num
] = Src_Data) ->
    Data = <<
        Result:32,
        Id:32,
        Num:16
    >>,
    {ok, pt:encode(40028, Data, Src_Data)};

write (40029,[
    GuildLv,
    GuildExp
] = Src_Data) ->
    Data = <<
        GuildLv:16,
        GuildExp:32
    >>,
    {ok, pt:encode(40029, Data, Src_Data)};

write (40030,[
    RoleId,
    Name
] = Src_Data) ->
    Bin_Name = pt:write_string(Name), 

    Data = <<
        RoleId:64,
        Bin_Name/binary
    >>,
    {ok, pt:encode(40030, Data, Src_Data)};

write (40031,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40031, Data, Src_Data)};

write (40032,[
    TGuildId,
    TGuildName,
    TGuildFlag,
    TGuildLv,
    TWeekLaborLast,
    TCombatPower,
    TPicture,
    TMemberNum,
    TAddMemberNum,
    Fapplys
] = Src_Data) ->
    Bin_TGuildName = pt:write_string(TGuildName), 

    Bin_TPicture = pt:write_picture(TPicture), 

    BinList_Fapplys = [
        item_to_bin_12(Fapplys_Item) || Fapplys_Item <- Fapplys
    ], 

    Fapplys_Len = length(Fapplys), 
    Bin_Fapplys = list_to_binary(BinList_Fapplys),

    Data = <<
        TGuildId:64,
        Bin_TGuildName/binary,
        TGuildFlag:32,
        TGuildLv:16,
        TWeekLaborLast:32,
        TCombatPower:64,
        Bin_TPicture/binary,
        TMemberNum:16,
        TAddMemberNum:16,
        Fapplys_Len:16, Bin_Fapplys/binary
    >>,
    {ok, pt:encode(40032, Data, Src_Data)};

write (40033,[
    Result,
    Target,
    Type,
    Opty
] = Src_Data) ->
    Data = <<
        Result:32,
        Target:64,
        Type:8,
        Opty:8
    >>,
    {ok, pt:encode(40033, Data, Src_Data)};

write (40034,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40034, Data, Src_Data)};

write (40035,[
    Ordered,
    Refreshed,
    GuildOrders
] = Src_Data) ->
    BinList_GuildOrders = [
        item_to_bin_13(GuildOrders_Item) || GuildOrders_Item <- GuildOrders
    ], 

    GuildOrders_Len = length(GuildOrders), 
    Bin_GuildOrders = list_to_binary(BinList_GuildOrders),

    Data = <<
        Ordered:8,
        Refreshed:8,
        GuildOrders_Len:16, Bin_GuildOrders/binary
    >>,
    {ok, pt:encode(40035, Data, Src_Data)};

write (40065,[
    Order,
    Cfg,
    State,
    Process,
    Limit,
    Teams,
    Ftime
] = Src_Data) ->
    BinList_Teams = [
        item_to_bin_15(Teams_Item) || Teams_Item <- Teams
    ], 

    Teams_Len = length(Teams), 
    Bin_Teams = list_to_binary(BinList_Teams),

    Data = <<
        Order:8,
        Cfg:8,
        State:8,
        Process:16,
        Limit:16,
        Teams_Len:16, Bin_Teams/binary,
        Ftime:32
    >>,
    {ok, pt:encode(40065, Data, Src_Data)};

write (40066,[
    Res
] = Src_Data) ->
    Data = <<
        Res:32
    >>,
    {ok, pt:encode(40066, Data, Src_Data)};

write (40036,[
    Result,
    Opty,
    Order
] = Src_Data) ->
    Data = <<
        Result:32,
        Opty:8,
        Order:8
    >>,
    {ok, pt:encode(40036, Data, Src_Data)};

write (40037,[
    Result,
    Order,
    Rid
] = Src_Data) ->
    Data = <<
        Result:32,
        Order:8,
        Rid:64
    >>,
    {ok, pt:encode(40037, Data, Src_Data)};

write (40038,[
    Rid,
    Lv,
    Vip,
    Svip,
    Name,
    Cfg,
    Order
] = Src_Data) ->
    Bin_Name = pt:write_string(Name), 

    Data = <<
        Rid:64,
        Lv:16,
        Vip:8,
        Svip:8,
        Bin_Name/binary,
        Cfg:8,
        Order:8
    >>,
    {ok, pt:encode(40038, Data, Src_Data)};

write (40039,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40039, Data, Src_Data)};

write (40040,[
    Order,
    Num,
    Cfg
] = Src_Data) ->
    Data = <<
        Order:8,
        Num:8,
        Cfg:8
    >>,
    {ok, pt:encode(40040, Data, Src_Data)};

write (40041,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40041, Data, Src_Data)};

write (40042,[
    Head,
    Cfg
] = Src_Data) ->
    Bin_Head = pt:write_picture(Head), 

    Data = <<
        Bin_Head/binary,
        Cfg:8
    >>,
    {ok, pt:encode(40042, Data, Src_Data)};

write (40043,[
    Value
] = Src_Data) ->
    Data = <<
        Value:32
    >>,
    {ok, pt:encode(40043, Data, Src_Data)};

write (40044,[
    Errcode
] = Src_Data) ->
    Data = <<
        Errcode:32
    >>,
    {ok, pt:encode(40044, Data, Src_Data)};

write (40045,[
    Errcode
] = Src_Data) ->
    Data = <<
        Errcode:32
    >>,
    {ok, pt:encode(40045, Data, Src_Data)};

write (40046,[
    SupportList,
    SelfSupportSid,
    SelfSupportStatus,
    SelfCollectSupportSid
] = Src_Data) ->
    BinList_SupportList = [
        item_to_bin_16(SupportList_Item) || SupportList_Item <- SupportList
    ], 

    SupportList_Len = length(SupportList), 
    Bin_SupportList = list_to_binary(BinList_SupportList),

    Data = <<
        SupportList_Len:16, Bin_SupportList/binary,
        SelfSupportSid:64,
        SelfSupportStatus:8,
        SelfCollectSupportSid:64
    >>,
    {ok, pt:encode(40046, Data, Src_Data)};

write (40047,[
    Type,
    SupportCfgId,
    Figure,
    ChatMsg,
    BossId,
    RewardList
] = Src_Data) ->
    Bin_Figure = pt:write_figure(Figure), 

    Bin_ChatMsg = pt:write_string(ChatMsg), 

    BinList_RewardList = [
        item_to_bin_17(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        Type:8,
        SupportCfgId:16,
        Bin_Figure/binary,
        Bin_ChatMsg/binary,
        BossId:32,
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    {ok, pt:encode(40047, Data, Src_Data)};

write (40048,[
    Type,
    OptionType,
    SupportId
] = Src_Data) ->
    Data = <<
        Type:8,
        OptionType:8,
        SupportId:64
    >>,
    {ok, pt:encode(40048, Data, Src_Data)};

write (40049,[
    Type,
    SupportCfgId,
    BossId,
    RoleList
] = Src_Data) ->
    BinList_RoleList = [
        item_to_bin_18(RoleList_Item) || RoleList_Item <- RoleList
    ], 

    RoleList_Len = length(RoleList), 
    Bin_RoleList = list_to_binary(BinList_RoleList),

    Data = <<
        Type:8,
        SupportCfgId:16,
        BossId:32,
        RoleList_Len:16, Bin_RoleList/binary
    >>,
    {ok, pt:encode(40049, Data, Src_Data)};

write (40050,[
    ErrCode
] = Src_Data) ->
    Data = <<
        ErrCode:32
    >>,
    {ok, pt:encode(40050, Data, Src_Data)};

write (40051,[
    Errcode,
    Module,
    SubModule,
    SupportSid
] = Src_Data) ->
    Data = <<
        Errcode:32,
        Module:16,
        SubModule:16,
        SupportSid:64
    >>,
    {ok, pt:encode(40051, Data, Src_Data)};

write (40052,[
    Errcode,
    SupportSid,
    SupportCfgId
] = Src_Data) ->
    Data = <<
        Errcode:32,
        SupportSid:64,
        SupportCfgId:16
    >>,
    {ok, pt:encode(40052, Data, Src_Data)};

write (40053,[
    Errcode,
    SupportSid,
    SupportCfgId
] = Src_Data) ->
    Data = <<
        Errcode:32,
        SupportSid:64,
        SupportCfgId:16
    >>,
    {ok, pt:encode(40053, Data, Src_Data)};

write (40054,[
    Errcode,
    SupportCfgId,
    Figure,
    Value
] = Src_Data) ->
    Bin_Figure = pt:write_figure(Figure), 

    Data = <<
        Errcode:32,
        SupportCfgId:16,
        Bin_Figure/binary,
        Value:32
    >>,
    {ok, pt:encode(40054, Data, Src_Data)};

write (40055,[
    Errcode,
    IsInSupport,
    SupportId
] = Src_Data) ->
    Data = <<
        Errcode:32,
        IsInSupport:8,
        SupportId:64
    >>,
    {ok, pt:encode(40055, Data, Src_Data)};

write (40056,[
    Type,
    Length
] = Src_Data) ->
    Data = <<
        Type:8,
        Length:16
    >>,
    {ok, pt:encode(40056, Data, Src_Data)};

write (40057,[
    Stime,
    Etime,
    Ltime
] = Src_Data) ->
    Data = <<
        Stime:32,
        Etime:32,
        Ltime:32
    >>,
    {ok, pt:encode(40057, Data, Src_Data)};

write (40058,[
    Exp
] = Src_Data) ->
    Data = <<
        Exp:32
    >>,
    {ok, pt:encode(40058, Data, Src_Data)};

write (40059,[
    Exp,
    Ltime
] = Src_Data) ->
    Data = <<
        Exp:32,
        Ltime:32
    >>,
    {ok, pt:encode(40059, Data, Src_Data)};

write (40060,[
    Pos
] = Src_Data) ->
    Data = <<
        Pos:8
    >>,
    {ok, pt:encode(40060, Data, Src_Data)};

write (40061,[
    RoleId
] = Src_Data) ->
    Data = <<
        RoleId:64
    >>,
    {ok, pt:encode(40061, Data, Src_Data)};

write (40063,[
    Num
] = Src_Data) ->
    Data = <<
        Num:32
    >>,
    {ok, pt:encode(40063, Data, Src_Data)};

write (40064,[
    Res,
    ModId
] = Src_Data) ->
    Data = <<
        Res:32,
        ModId:16
    >>,
    {ok, pt:encode(40064, Data, Src_Data)};

write (40067,[
    RoleId,
    OnlineFlag
] = Src_Data) ->
    Data = <<
        RoleId:64,
        OnlineFlag:8
    >>,
    {ok, pt:encode(40067, Data, Src_Data)};

write (40068,[
    InfoList
] = Src_Data) ->
    BinList_InfoList = [
        item_to_bin_19(InfoList_Item) || InfoList_Item <- InfoList
    ], 

    InfoList_Len = length(InfoList), 
    Bin_InfoList = list_to_binary(BinList_InfoList),

    Data = <<
        InfoList_Len:16, Bin_InfoList/binary
    >>,
    {ok, pt:encode(40068, Data, Src_Data)};

write (40069,[
    InfoList
] = Src_Data) ->
    BinList_InfoList = [
        item_to_bin_22(InfoList_Item) || InfoList_Item <- InfoList
    ], 

    InfoList_Len = length(InfoList), 
    Bin_InfoList = list_to_binary(BinList_InfoList),

    Data = <<
        InfoList_Len:16, Bin_InfoList/binary
    >>,
    {ok, pt:encode(40069, Data, Src_Data)};

write (40070,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40070, Data, Src_Data)};

write (40071,[
    HistoryGuildNum
] = Src_Data) ->
    Data = <<
        HistoryGuildNum:16
    >>,
    {ok, pt:encode(40071, Data, Src_Data)};

write (40072,[
    Result
] = Src_Data) ->
    Data = <<
        Result:32
    >>,
    {ok, pt:encode(40072, Data, Src_Data)};

write(_Cmd, _R) -> ?DEBUG("no_match:~p,~p~n", [_Cmd, _R]), {ok, pt:pack(0, <<>>)}.


item_to_bin_0 ({
    GuildId,
    GuildName,
    GuildFlag,
    GuildLv,
    Division,
    WeekLaborLast,
    CombatPower,
    Picture,
    MemberNum,
    IsApply,
    AppType,
    Announce,
    RequireLv,
    RequirePow,
    Badges,
    AddMemNum
}) ->
    Bin_GuildName = pt:write_string(GuildName), 

    Bin_Picture = pt:write_picture(Picture), 

    Bin_Announce = pt:write_string(Announce), 

    BinList_Badges = [
        item_to_bin_1(Badges_Item) || Badges_Item <- Badges
    ], 

    Badges_Len = length(Badges), 
    Bin_Badges = list_to_binary(BinList_Badges),

    Data = <<
        GuildId:64,
        Bin_GuildName/binary,
        GuildFlag:32,
        GuildLv:16,
        Division:16,
        WeekLaborLast:32,
        CombatPower:64,
        Bin_Picture/binary,
        MemberNum:16,
        IsApply:8,
        AppType:8,
        Bin_Announce/binary,
        RequireLv:32,
        RequirePow:64,
        Badges_Len:16, Bin_Badges/binary,
        AddMemNum:8
    >>,
    Data.
item_to_bin_1 ({
    Id,
    StartTime,
    EndTime
}) ->
    Data = <<
        Id:32,
        StartTime:32,
        EndTime:32
    >>,
    Data.
item_to_bin_2 ({
    Position,
    RoleId,
    Figure
}) ->
    Bin_Figure = pt:write_picture(Figure), 

    Data = <<
        Position:8,
        RoleId:64,
        Bin_Figure/binary
    >>,
    Data.
item_to_bin_3 ({
    Id,
    StartTime,
    EndTime
}) ->
    Data = <<
        Id:32,
        StartTime:32,
        EndTime:32
    >>,
    Data.
item_to_bin_4 ({
    RoleId,
    Figure,
    Position,
    CombatPower,
    WeekLabor,
    TotalLabor,
    OnlineFlag,
    OfflineTime,
    CreateTime
}) ->
    Bin_Figure = pt:write_figure(Figure), 

    Data = <<
        RoleId:64,
        Bin_Figure/binary,
        Position:8,
        CombatPower:32,
        WeekLabor:32,
        TotalLabor:32,
        OnlineFlag:8,
        OfflineTime:32,
        CreateTime:32
    >>,
    Data.
item_to_bin_5 ({
    RoleId,
    Figure,
    CombatPower,
    Position,
    Time
}) ->
    Bin_Figure = pt:write_figure(Figure), 

    Data = <<
        RoleId:64,
        Bin_Figure/binary,
        CombatPower:32,
        Position:8,
        Time:32
    >>,
    Data.
item_to_bin_6 (
    GuildFlag
) ->
    Data = <<
        GuildFlag:32
    >>,
    Data.
item_to_bin_7 (
    PermissionType
) ->
    Data = <<
        PermissionType:8
    >>,
    Data.
item_to_bin_8 ({
    RoleId,
    Figure,
    Position,
    Labors,
    LastLogoutTime
}) ->
    Bin_Figure = pt:write_figure(Figure), 

    Data = <<
        RoleId:64,
        Bin_Figure/binary,
        Position:8,
        Labors:32,
        LastLogoutTime:32
    >>,
    Data.
item_to_bin_9 ({
    Position,
    Num
}) ->
    Data = <<
        Position:8,
        Num:8
    >>,
    Data.
item_to_bin_10 ({
    RoleId,
    NowPositoin
}) ->
    Data = <<
        RoleId:64,
        NowPositoin:8
    >>,
    Data.
item_to_bin_11 ({
    Id,
    Buyed
}) ->
    Data = <<
        Id:32,
        Buyed:32
    >>,
    Data.
item_to_bin_12 ({
    GuildId,
    GuildName,
    GuildFlag,
    GuildLv,
    WeekLaborLast,
    CombatPower,
    Picture,
    MemberNum,
    AddMemberNum
}) ->
    Bin_GuildName = pt:write_string(GuildName), 

    Bin_Picture = pt:write_picture(Picture), 

    Data = <<
        GuildId:64,
        Bin_GuildName/binary,
        GuildFlag:32,
        GuildLv:16,
        WeekLaborLast:32,
        CombatPower:64,
        Bin_Picture/binary,
        MemberNum:16,
        AddMemberNum:16
    >>,
    Data.
item_to_bin_13 ({
    Order,
    Cfg,
    State,
    Process,
    Limit,
    Teams,
    Ftime
}) ->
    BinList_Teams = [
        item_to_bin_14(Teams_Item) || Teams_Item <- Teams
    ], 

    Teams_Len = length(Teams), 
    Bin_Teams = list_to_binary(BinList_Teams),

    Data = <<
        Order:8,
        Cfg:8,
        State:8,
        Process:16,
        Limit:16,
        Teams_Len:16, Bin_Teams/binary,
        Ftime:32
    >>,
    Data.
item_to_bin_14 (
    Head
) ->
    Bin_Head = pt:write_picture(Head), 

    Data = <<
        Bin_Head/binary
    >>,
    Data.
item_to_bin_15 (
    Head
) ->
    Bin_Head = pt:write_picture(Head), 

    Data = <<
        Bin_Head/binary
    >>,
    Data.
item_to_bin_16 ({
    SupportSid,
    SupportCfgId,
    Figure,
    Status,
    BossId,
    ShowTime,
    KvData
}) ->
    Bin_Figure = pt:write_figure(Figure), 

    Bin_KvData = pt:write_string(KvData), 

    Data = <<
        SupportSid:64,
        SupportCfgId:16,
        Bin_Figure/binary,
        Status:8,
        BossId:32,
        ShowTime:32,
        Bin_KvData/binary
    >>,
    Data.
item_to_bin_17 ({
    GoodsTypeId,
    GoodsId,
    Num
}) ->
    Data = <<
        GoodsTypeId:8,
        GoodsId:32,
        Num:16
    >>,
    Data.
item_to_bin_18 (
    Figure
) ->
    Bin_Figure = pt:write_figure(Figure), 

    Data = <<
        Bin_Figure/binary
    >>,
    Data.
item_to_bin_19 ({
    Type,
    SupportId,
    SupportCfgId,
    ExtraValue,
    RoleList,
    IsSend
}) ->
    BinList_ExtraValue = [
        item_to_bin_20(ExtraValue_Item) || ExtraValue_Item <- ExtraValue
    ], 

    ExtraValue_Len = length(ExtraValue), 
    Bin_ExtraValue = list_to_binary(BinList_ExtraValue),

    BinList_RoleList = [
        item_to_bin_21(RoleList_Item) || RoleList_Item <- RoleList
    ], 

    RoleList_Len = length(RoleList), 
    Bin_RoleList = list_to_binary(BinList_RoleList),

    Data = <<
        Type:8,
        SupportId:64,
        SupportCfgId:16,
        ExtraValue_Len:16, Bin_ExtraValue/binary,
        RoleList_Len:16, Bin_RoleList/binary,
        IsSend:8
    >>,
    Data.
item_to_bin_20 ({
    Key,
    Value
}) ->
    Data = <<
        Key:8,
        Value:32
    >>,
    Data.
item_to_bin_21 ({
    RoleId,
    Name,
    Sex,
    ProfilePhotoId,
    DressBoardId,
    VipFlag,
    SupVipType
}) ->
    Bin_Name = pt:write_string(Name), 

    Data = <<
        RoleId:64,
        Bin_Name/binary,
        Sex:8,
        ProfilePhotoId:32,
        DressBoardId:32,
        VipFlag:32,
        SupVipType:16
    >>,
    Data.
item_to_bin_22 ({
    Type,
    SupportId,
    SupportCfgId,
    ExtraValue,
    ChatMsg,
    RoleId,
    Name,
    Sex,
    ProfilePhotoId,
    DressBoardId,
    VipFlag,
    SupVipType,
    IsGet
}) ->
    BinList_ExtraValue = [
        item_to_bin_23(ExtraValue_Item) || ExtraValue_Item <- ExtraValue
    ], 

    ExtraValue_Len = length(ExtraValue), 
    Bin_ExtraValue = list_to_binary(BinList_ExtraValue),

    Bin_ChatMsg = pt:write_string(ChatMsg), 

    Bin_Name = pt:write_string(Name), 

    Data = <<
        Type:8,
        SupportId:64,
        SupportCfgId:16,
        ExtraValue_Len:16, Bin_ExtraValue/binary,
        Bin_ChatMsg/binary,
        RoleId:64,
        Bin_Name/binary,
        Sex:8,
        ProfilePhotoId:32,
        DressBoardId:32,
        VipFlag:32,
        SupVipType:16,
        IsGet:8
    >>,
    Data.
item_to_bin_23 ({
    Key,
    Value
}) ->
    Data = <<
        Key:8,
        Value:32
    >>,
    Data.
