Exemplo n.º 1
0
// Wisp/page request to send
static
void mapif_parse_WisRequest(int fd)
{
    static int wisid = 0;

    if (RFIFOW(fd, 2) - 52 <= 0)
    {                           // normaly, impossible, but who knows...
        PRINTF("inter: Wis message doesn't exist.\n");
        return;
    }

    CharName from = stringish<CharName>(RFIFO_STRING<24>(fd, 4));
    CharName to = stringish<CharName>(RFIFO_STRING<24>(fd, 28));

    // search if character exists before to ask all map-servers
    const mmo_charstatus *mcs = search_character(to);
    if (!mcs)
    {
        uint8_t buf[27];
        WBUFW(buf, 0) = 0x3802;
        WBUF_STRING(buf, 2, from.to__actual(), 24);
        WBUFB(buf, 26) = 1;    // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
        mapif_send(fd, buf, 27);
        // Character exists. So, ask all map-servers
    }
    else
    {
        // to be sure of the correct name, rewrite it
        to = mcs->name;
        // if source is destination, don't ask other servers.
        if (from == to)
        {
            uint8_t buf[27];
            WBUFW(buf, 0) = 0x3802;
            WBUF_STRING(buf, 2, from.to__actual(), 24);
            WBUFB(buf, 26) = 1;    // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
            mapif_send(fd, buf, 27);
        }
        else
        {
            struct WisData wd {};

            // Whether the failure of previous wisp/page transmission (timeout)
            check_ttl_wisdata();

            wd.id = ++wisid;
            wd.fd = fd;
            size_t len = RFIFOW(fd, 2) - 52;
            wd.src = from;
            wd.dst = to;
            wd.msg = RFIFO_STRING(fd, 52, len);
            wd.tick = gettick();
            wis_db.insert(wd.id, wd);
            mapif_wis_message(&wd);
        }
    }
}
Exemplo n.º 2
0
Arquivo: inter.cpp Projeto: mrktj/tmwa
// Wisp/page transmission to correct map-server
static
void mapif_wis_message(Session *tms, CharName src, CharName dst, XString msg)
{
    const CharPair *mcs = search_character(src);
    assert (mcs);

    Packet_Head<0x3801> head_01;
    head_01.whisper_id = mcs->key.char_id;
    head_01.src_char_name = src;
    head_01.dst_char_name = dst;
    send_vpacket<0x3801, 56, 1>(tms, head_01, msg);
}
Exemplo n.º 3
0
// パ?ティデ?タの文字列からの?換
int inter_party_fromstr(char *str, struct party *p) {
	int i, j;
	int tmp_int[16];
	char tmp_str[256];
#ifndef TXT_SQL_CONVERT
	struct mmo_charstatus* status;
#endif
	
	memset(p, 0, sizeof(struct party));

//	printf("sscanf party main info\n");
	if (sscanf(str, "%d\t%255[^\t]\t%d,%d\t", &tmp_int[0], tmp_str, &tmp_int[1], &tmp_int[2]) != 4)
		return 1;

	p->party_id = tmp_int[0];
	memcpy(p->name, tmp_str, NAME_LENGTH);
	p->exp = tmp_int[1]?1:0;
	p->item = tmp_int[2];
//	printf("%d [%s] %d %d\n", tmp_int[0], tmp_str[0], tmp_int[1], tmp_int[2]);

	for(j = 0; j < 3 && str != NULL; j++)
		str = strchr(str + 1, '\t');

	for(i = 0; i < MAX_PARTY; i++) {
		struct party_member *m = &p->member[i];
		if (str == NULL)
			return 1;
//		printf("sscanf party member info %d\n", i);

		if (sscanf(str + 1, "%d,%d,%d\t", &tmp_int[0], &tmp_int[1], &tmp_int[2]) != 3)
			return 1;

		m->account_id = tmp_int[0];
		m->char_id = tmp_int[1]; 
		m->leader = tmp_int[2]?1:0;

		str = strchr(str + 1, '\t');
#ifndef TXT_SQL_CONVERT
		if (!m->account_id) continue;
		//Lookup player for rest of data.
		status = search_character(m->account_id, m->char_id);
		if (!status) continue;
		
		memcpy(m->name, status->name, NAME_LENGTH);
		m->class_ = status->class_;
		m->map = status->last_point.map;
		m->lv = status->base_level;
#endif //TXT_SQL_CONVERT
	}

	return 0;
}
Exemplo n.º 4
0
Arquivo: inter.cpp Projeto: mrktj/tmwa
RecvResult mapif_parse_WisRequest(Session *sms)
{
    Packet_Head<0x3001> head;
    AString repeat;
    RecvResult rv = recv_vpacket<0x3001, 52, 1>(sms, head, repeat);
    if (rv != RecvResult::Complete)
        return rv;

    CharName from = head.from_char_name;
    CharName to = head.to_char_name;

    // search if character exists before to ask all map-servers
    const CharPair *mcs = search_character(to);
    if (!mcs)
    {
        Packet_Fixed<0x3802> fixed_02;
        fixed_02.sender_char_name = from;
        fixed_02.flag = 1;    // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
        send_fpacket<0x3802, 27>(sms, fixed_02);
        // Character exists. So, ask all map-servers
    }
    else
    {
        // to be sure of the correct name, rewrite it
        to = mcs->key.name;
        // if source is destination, don't ask other servers.
        if (from == to)
        {
            Packet_Fixed<0x3802> fixed_02;
            fixed_02.sender_char_name = from;
            fixed_02.flag = 1;    // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
            send_fpacket<0x3802, 27>(sms, fixed_02);
        }
        else
        {
            Session *tms = server_for(mcs); // for to
            AString& msg = repeat;
            if (tms)
            {
                mapif_wis_message(tms, from, to, msg);
            }
            else
            {
                mapif_wis_end(sms, from, 1);
            }
        }
    }

    return rv;
}
Exemplo n.º 5
0
static
void party_check_deleted_init(PartyPair p)
{
    for (int i = 0; i < MAX_PARTY; i++)
    {
        if (!p->member[i].account_id)
            continue;
        const CharPair *c = search_character(p->member[i].name);
        if (!c || c->key.account_id != p->member[i].account_id)
        {
            CHAR_LOG("WARNING: deleting obsolete party member %d %s of %d %s\n"_fmt,
                    p->member[i].account_id, p->member[i].name,
                    p.party_id, p->name);
            PRINTF("WARNING: deleting obsolete party member %d %s of %d %s\n"_fmt,
                    p->member[i].account_id, p->member[i].name,
                    p.party_id, p->name);
            p->member[i] = PartyMember{};
        }
    }
}