// 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); } } }
// Wisp/page transmission to all map-server static void mapif_wis_message(struct WisData *wd) { size_t str_size = wd->msg.size() + 1; uint8_t buf[56 + str_size]; WBUFW(buf, 0) = 0x3801; WBUFW(buf, 2) = 56 + str_size; WBUFL(buf, 4) = wd->id; WBUF_STRING(buf, 8, wd->src.to__actual(), 24); WBUF_STRING(buf, 32, wd->dst.to__actual(), 24); WBUF_STRING(buf, 56, wd->msg, str_size); wd->count = mapif_sendall(buf, WBUFW(buf, 2)); }
// Wisp/page transmission result to map-server static void mapif_wis_end(struct WisData *wd, int flag) { uint8_t buf[27]; WBUFW(buf, 0) = 0x3802; WBUF_STRING(buf, 2, wd->src.to__actual(), 24); WBUFB(buf, 26) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target mapif_send(wd->fd, buf, 27); }
// GMメッセージ送信 static void mapif_GMmessage(XString mes) { size_t str_len = mes.size() + 1; size_t msg_len = str_len + 4; uint8_t buf[msg_len]; WBUFW(buf, 0) = 0x3800; WBUFW(buf, 2) = msg_len; WBUF_STRING(buf, 4, mes, str_len); mapif_sendall(buf, msg_len); }
// パーティ脱退通知 static void mapif_party_leaved(int party_id, int account_id, CharName name) { unsigned char buf[34]; WBUFW(buf, 0) = 0x3824; WBUFL(buf, 2) = party_id; WBUFL(buf, 6) = account_id; WBUF_STRING(buf, 10, name.to__actual(), 24); mapif_sendall(buf, 34); PRINTF("int_party: party leaved %d %d %s\n", party_id, account_id, name); }
// パーティ内発言 static void mapif_party_message(int party_id, int account_id, XString mes) { size_t len = mes.size() + 1; unsigned char buf[len + 12]; WBUFW(buf, 0) = 0x3827; WBUFW(buf, 2) = len + 12; WBUFL(buf, 4) = party_id; WBUFL(buf, 8) = account_id; WBUF_STRING(buf, 12, mes, len); mapif_sendall(buf, len + 12); }
// パーティマップ更新通知 static void mapif_party_membermoved(struct party *p, int idx) { unsigned char buf[29]; WBUFW(buf, 0) = 0x3825; WBUFL(buf, 2) = p->party_id; WBUFL(buf, 6) = p->member[idx].account_id; WBUF_STRING(buf, 10, p->member[idx].map, 16); WBUFB(buf, 26) = p->member[idx].online; WBUFW(buf, 27) = p->member[idx].lv; mapif_sendall(buf, 29); }