예제 #1
0
파일: intif.cpp 프로젝트: cinderweb/tmwa
//-----------------------------------------------------------------
// inter serverからの通信
// エラーがあれば0(false)を返すこと
// パケットが処理できれば1,パケット長が足りなければ2を返すこと
int intif_parse(int fd)
{
    int packet_len;
    int cmd = RFIFOW(fd, 0);
    // パケットのID確認
    if (cmd < 0x3800
        || cmd >=
        0x3800 + (sizeof(packet_len_table) / sizeof(packet_len_table[0]))
        || packet_len_table[cmd - 0x3800] == 0)
    {
        return 0;
    }
    // パケットの長さ確認
    packet_len = packet_len_table[cmd - 0x3800];
    if (packet_len == -1)
    {
        if (RFIFOREST(fd) < 4)
            return 2;
        packet_len = RFIFOW(fd, 2);
    }
//  if(battle_config.etc_log)
//      PRINTF("intif_parse %d %x %d %d\n",fd,cmd,packet_len,RFIFOREST(fd));
    if (RFIFOREST(fd) < packet_len)
    {
        return 2;
    }
    // 処理分岐
    switch (cmd)
    {
        case 0x3800:
        {
            FString mes = RFIFO_STRING(fd, 4, packet_len - 4);
            clif_GMmessage(NULL, mes, 0);
        }
            break;
        case 0x3801:
            intif_parse_WisMessage(fd);
            break;
        case 0x3802:
            intif_parse_WisEnd(fd);
            break;
        case 0x3803:
            mapif_parse_WisToGM(fd);
            break;
        case 0x3804:
            intif_parse_AccountReg(fd);
            break;
        case 0x3810:
            intif_parse_LoadStorage(fd);
            break;
        case 0x3811:
            intif_parse_SaveStorage(fd);
            break;
        case 0x3820:
            intif_parse_PartyCreated(fd);
            break;
        case 0x3821:
            intif_parse_PartyInfo(fd);
            break;
        case 0x3822:
            intif_parse_PartyMemberAdded(fd);
            break;
        case 0x3823:
            intif_parse_PartyOptionChanged(fd);
            break;
        case 0x3824:
            intif_parse_PartyMemberLeaved(fd);
            break;
        case 0x3825:
            intif_parse_PartyMove(fd);
            break;
        case 0x3826:
            intif_parse_PartyBroken(fd);
            break;
        case 0x3827:
            intif_parse_PartyMessage(fd);
            break;
        default:
            if (battle_config.error_log)
                PRINTF("intif_parse : unknown packet %d %x\n", fd,
                        RFIFOW(fd, 0));
            return 0;
    }
    // パケット読み飛ばし
    RFIFOSKIP(fd, packet_len);
    return 1;
}
예제 #2
0
파일: intif.cpp 프로젝트: Cloudxtreme/tmwa
//-----------------------------------------------------------------
// inter serverからの通信
// エラーがあれば0(false)を返すこと
// パケットが処理できれば1,パケット長が足りなければ2を返すこと
int intif_parse (int fd)
{
    int  packet_len;
    int  cmd = RFIFOW (fd, 0);
    // パケットのID確認
    if (cmd < 0x3800
        || cmd >=
        0x3800 + (sizeof (packet_len_table) / sizeof (packet_len_table[0]))
        || packet_len_table[cmd - 0x3800] == 0)
    {
        return 0;
    }
    // パケットの長さ確認
    packet_len = packet_len_table[cmd - 0x3800];
    if (packet_len == -1)
    {
        if (RFIFOREST (fd) < 4)
            return 2;
        packet_len = RFIFOW (fd, 2);
    }
//  if(battle_config.etc_log)
//      printf("intif_parse %d %x %d %d\n",fd,cmd,packet_len,RFIFOREST(fd));
    if (RFIFOREST (fd) < packet_len)
    {
        return 2;
    }
    // 処理分岐
    switch (cmd)
    {
        case 0x3800:
            clif_GMmessage (NULL, (const char *)RFIFOP (fd, 4), packet_len - 4, 0);
            break;
        case 0x3801:
            intif_parse_WisMessage (fd);
            break;
        case 0x3802:
            intif_parse_WisEnd (fd);
            break;
        case 0x3803:
            mapif_parse_WisToGM (fd);
            break;
        case 0x3804:
            intif_parse_AccountReg (fd);
            break;
        case 0x3810:
            intif_parse_LoadStorage (fd);
            break;
        case 0x3811:
            intif_parse_SaveStorage (fd);
            break;
        case 0x3818:
            intif_parse_LoadGuildStorage (fd);
            break;
        case 0x3819:
            intif_parse_SaveGuildStorage (fd);
            break;
        case 0x3820:
            intif_parse_PartyCreated (fd);
            break;
        case 0x3821:
            intif_parse_PartyInfo (fd);
            break;
        case 0x3822:
            intif_parse_PartyMemberAdded (fd);
            break;
        case 0x3823:
            intif_parse_PartyOptionChanged (fd);
            break;
        case 0x3824:
            intif_parse_PartyMemberLeaved (fd);
            break;
        case 0x3825:
            intif_parse_PartyMove (fd);
            break;
        case 0x3826:
            intif_parse_PartyBroken (fd);
            break;
        case 0x3827:
            intif_parse_PartyMessage (fd);
            break;
        case 0x3830:
            intif_parse_GuildCreated (fd);
            break;
        case 0x3831:
            intif_parse_GuildInfo (fd);
            break;
        case 0x3832:
            intif_parse_GuildMemberAdded (fd);
            break;
        case 0x3834:
            intif_parse_GuildMemberLeaved (fd);
            break;
        case 0x3835:
            intif_parse_GuildMemberInfoShort (fd);
            break;
        case 0x3836:
            intif_parse_GuildBroken (fd);
            break;
        case 0x3837:
            intif_parse_GuildMessage (fd);
            break;
        case 0x3839:
            intif_parse_GuildBasicInfoChanged (fd);
            break;
        case 0x383a:
            intif_parse_GuildMemberInfoChanged (fd);
            break;
        case 0x383b:
            intif_parse_GuildPosition (fd);
            break;
        case 0x383c:
            intif_parse_GuildSkillUp (fd);
            break;
        case 0x383d:
            intif_parse_GuildAlliance (fd);
            break;
        case 0x383e:
            intif_parse_GuildNotice (fd);
            break;
        case 0x383f:
            intif_parse_GuildEmblem (fd);
            break;
        case 0x3840:
            intif_parse_GuildCastleDataLoad (fd);
            break;
        case 0x3841:
            intif_parse_GuildCastleDataSave (fd);
            break;
        case 0x3842:
            intif_parse_GuildCastleAllDataLoad (fd);
            break;
            //case 0x3880:  intif_parse_CreateP.et(fd); break;
            //case 0x3881:  intif_parse_RecvP.etData(fd); break;
            //case 0x3882:  intif_parse_SaveP.etOk(fd); break;
            //case 0x3883:  intif_parse_DeleteP.etOk(fd); break;
        default:
            if (battle_config.error_log)
                printf ("intif_parse : unknown packet %d %x\n", fd,
                        RFIFOW (fd, 0));
            return 0;
    }
    // パケット読み飛ばし
    RFIFOSKIP (fd, packet_len);
    return 1;
}
예제 #3
0
파일: intif.cpp 프로젝트: themanaworld/tmwa
//-----------------------------------------------------------------
// inter serverからの通信
// エラーがあれば0(false)を返すこと
// パケットが処理できれば1,パケット長が足りなければ2を返すこと
RecvResult intif_parse(Session *s, uint16_t packet_id)
{
    RecvResult rv;

    switch (packet_id)
    {
        case 0x3800:
        {
            AString mes;
            rv = recv_packet_repeatonly<0x3800, 4, 1>(s, mes);
            if (rv != RecvResult::Complete)
                return rv;

            clif_GMmessage(nullptr, mes, 0);
            break;
        }
        case 0x3801:
        {
            Packet_Head<0x3801> head;
            AString repeat;
            rv = recv_vpacket<0x3801, 56, 1>(s, head, repeat);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_WisMessage(s, head, repeat);
            break;
        }
        case 0x3802:
        {
            Packet_Fixed<0x3802> fixed;
            rv = recv_fpacket<0x3802, 27>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_WisEnd(s, fixed);
            break;
        }
        case 0x3803:
        {
            Packet_Head<0x3803> head;
            AString repeat;
            rv = recv_vpacket<0x3803, 30, 1>(s, head, repeat);
            if (rv != RecvResult::Complete)
                return rv;

            mapif_parse_WisToGM(s, head, repeat);
            break;
        }
        case 0x3804:
        {
            Packet_Head<0x3804> head;
            std::vector<Packet_Repeat<0x3804>> repeat;
            rv = recv_vpacket<0x3804, 8, 36>(s, head, repeat);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_AccountReg(s, head, repeat);
            break;
        }
        case 0x3810:
        {
            Packet_Payload<0x3810> payload;
            rv = recv_ppacket<0x3810>(s, payload);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_LoadStorage(s, payload);
            break;
        }
        case 0x3811:
        {
            Packet_Fixed<0x3811> fixed;
            rv = recv_fpacket<0x3811, 7>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_SaveStorage(s, fixed);
            break;
        }
        case 0x3820:
        {
            Packet_Fixed<0x3820> fixed;
            rv = recv_fpacket<0x3820, 35>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyCreated(s, fixed);
            break;
        }
        case 0x3821:
        {
            Packet_Head<0x3821> head;
            bool has_opt;
            Packet_Option<0x3821> option;
            rv = recv_opacket<0x3821, 8, sizeof(NetPacket_Option<0x3821>)>(s, head, &has_opt, option);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyInfo(s, head, has_opt, option);
            break;
        }
        case 0x3822:
        {
            Packet_Fixed<0x3822> fixed;
            rv = recv_fpacket<0x3822, 11>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyMemberAdded(s, fixed);
            break;
        }
        case 0x3823:
        {
            Packet_Fixed<0x3823> fixed;
            rv = recv_fpacket<0x3823, 15>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyOptionChanged(s, fixed);
            break;
        }
        case 0x3824:
        {
            Packet_Fixed<0x3824> fixed;
            rv = recv_fpacket<0x3824, 34>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyMemberLeaved(s, fixed);
            break;
        }
        case 0x3825:
        {
            Packet_Fixed<0x3825> fixed;
            rv = recv_fpacket<0x3825, 29>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyMove(s, fixed);
            break;
        }
        case 0x3826:
        {
            Packet_Fixed<0x3826> fixed;
            rv = recv_fpacket<0x3826, 7>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyBroken(s, fixed);
            break;
        }
        case 0x3827:
        {
            Packet_Head<0x3827> head;
            AString repeat;
            rv = recv_vpacket<0x3827, 12, 1>(s, head, repeat);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyMessage(s, head, repeat);
            break;
        }
        case 0x3828:
        {
            Packet_Fixed<0x3828> fixed;
            rv = recv_fpacket<0x3828, 11>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            intif_parse_PartyLeaderChanged(s, fixed);
            break;
        }
        case 0x3829:
        {
            Packet_Fixed<0x3829> fixed;
            rv = recv_fpacket<0x3829, 22>(s, fixed);
            if (rv != RecvResult::Complete)
                return rv;

            chrif_parse_preauth(s, fixed);
            break;
        }
        default:
            return RecvResult::Error;
    }
    return rv;
}