Exemplo n.º 1
0
// Received wisp message from map-server via char-server for ALL gm
static
void mapif_parse_WisToGM(int fd)
{
    // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
    int min_gm_level, len;

    if (RFIFOW(fd, 2) - 30 <= 0)
        return;

    len = RFIFOW(fd, 2) - 30;

    min_gm_level = RFIFOW(fd, 28);
    CharName Wisp_name = stringish<CharName>(RFIFO_STRING<24>(fd, 4));
    FString message = RFIFO_STRING(fd, 30, len);
    // information is sended to all online GM
    for (int i = 0; i < fd_max; i++)
    {
        if (!session[i])
            continue;
        dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
        if (pl_sd && pl_sd->state.auth)
            if (pc_isGM(pl_sd) >= min_gm_level)
                clif_wis_message(i, Wisp_name, message);
    }
}
Exemplo n.º 2
0
// Received wisp message from map-server via char-server for ALL gm
static
int mapif_parse_WisToGM (int fd)
{                               // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
    int  i, min_gm_level, len;
    struct map_session_data *pl_sd;
    char Wisp_name[24];
    char mbuf[255];

    if (RFIFOW (fd, 2) - 30 <= 0)
        return 0;

    len = RFIFOW (fd, 2) - 30;
    char *message = ((len) >= 255) ? (char *) malloc (len) : mbuf;

    min_gm_level = (int) RFIFOW (fd, 28);
    memcpy (Wisp_name, RFIFOP (fd, 4), 24);
    Wisp_name[23] = '\0';
    memcpy (message, RFIFOP (fd, 30), len);
    message[len - 1] = '\0';
    // information is sended to all online GM
    for (i = 0; i < fd_max; i++)
        if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data)
            && pl_sd->state.auth)
            if (pc_isGM (pl_sd) >= min_gm_level)
                clif_wis_message (i, Wisp_name, message,
                                  strlen (message) + 1);

    if (message != mbuf)
        free (message);

    return 0;
}
Exemplo n.º 3
0
// Wisp/Page reception
static
int intif_parse_WisMessage(Session *, const Packet_Head<0x3801>& head, AString& buf)
{
    // rewritten by [Yor]
    dumb_ptr<map_session_data> sd;

    CharName from = head.src_char_name;
    CharName to = head.dst_char_name;

    if (battle_config.etc_log)
    {
        PRINTF("intif_parse_wismessage: id: %d, from: %s, to: %s\n"_fmt,
                head.whisper_id,
                from,
                to);
    }
    sd = map_nick2sd(to); // Searching destination player
    if (sd != nullptr && sd->status_key.name == to)
    {
        // exactly same name (inter-server have checked the name before)
        {
            // if source player not found in ignore list
            {
                clif_wis_message(sd->sess, from, buf);
                intif_wis_replay(head.whisper_id, 0);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
            }
        }
    }
    else
        intif_wis_replay(head.whisper_id, 1);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
    return 0;
}
Exemplo n.º 4
0
// Received wisp message from map-server via char-server for ALL gm
static
void mapif_parse_WisToGM(Session *, const Packet_Head<0x3803>& head, AString& message)
{
    // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
    GmLevel min_gm_level = head.min_gm_level;
    CharName Wisp_name = head.char_name;
    // information is sended to all online GM
    for (io::FD i : iter_fds())
    {
        Session *s2 = get_session(i);
        if (!s2)
            continue;
        dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
        if (pl_sd && pl_sd->state.auth && !pl_sd->state.connect_new)
        {
            if (pc_isGM(pl_sd).satisfies(min_gm_level))
                clif_wis_message(s2, Wisp_name, message);
        }
    }
}
Exemplo n.º 5
0
// Wisp/Page reception
static
int intif_parse_WisMessage (int fd)
{                               // rewritten by [Yor]
    struct map_session_data *sd;
    int  i;

    if (battle_config.etc_log)
        printf
            ("intif_parse_wismessage: id: %d, from: %s, to: %s, message: '%s'\n",
             RFIFOL (fd, 4), RFIFOP (fd, 8), RFIFOP (fd, 32), RFIFOP (fd,
                                                                      56));
    sd = map_nick2sd ((const char *)RFIFOP (fd, 32)); // Searching destination player
    if (sd != NULL && strcmp (sd->status.name, (const char *)RFIFOP (fd, 32)) == 0)
    {                           // exactly same name (inter-server have checked the name before)
        // if player ignore all
        if (sd->ignoreAll == 1)
            intif_wis_replay (RFIFOL (fd, 4), 2);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
        else
        {
            const char *wisp_source = (const char *)RFIFOP (fd, 8);   // speed up
            // if player ignore the source character
            for (i = 0; i < (sizeof (sd->ignore) / sizeof (sd->ignore[0]));
                 i++)
                if (strcmp (sd->ignore[i].name, wisp_source) == 0)
                {
                    intif_wis_replay (RFIFOL (fd, 4), 2);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
                    break;
                }
            // if source player not found in ignore list
            if (i == (sizeof (sd->ignore) / sizeof (sd->ignore[0])))
            {
                clif_wis_message (sd->fd, (const char *)RFIFOP (fd, 8), (const char *)RFIFOP (fd, 56),
                                  RFIFOW (fd, 2) - 56);
                intif_wis_replay (RFIFOL (fd, 4), 0);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
            }
        }
    }
    else
        intif_wis_replay (RFIFOL (fd, 4), 1);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
    return 0;
}
Exemplo n.º 6
0
// Wisp/Page reception
static
int intif_parse_WisMessage(int fd)
{
    // rewritten by [Yor]
    dumb_ptr<map_session_data> sd;

    CharName from = stringish<CharName>(RFIFO_STRING<24>(fd, 8));
    CharName to = stringish<CharName>(RFIFO_STRING<24>(fd, 32));

    size_t len = RFIFOW(fd, 2) - 56;
    FString buf = RFIFO_STRING(fd, 56, len);

    if (battle_config.etc_log)
    {
        PRINTF("intif_parse_wismessage: id: %d, from: %s, to: %s, message: '%s'\n",
             RFIFOL(fd, 4),
             from,
             to,
             buf);
    }
    sd = map_nick2sd(to); // Searching destination player
    if (sd != NULL && sd->status.name == to)
    {
        // exactly same name (inter-server have checked the name before)
        {
            // if source player not found in ignore list
            {
                clif_wis_message(sd->fd, from, buf);
                intif_wis_replay(RFIFOL(fd, 4), 0);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
            }
        }
    }
    else
        intif_wis_replay(RFIFOL(fd, 4), 1);   // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
    return 0;
}
Exemplo n.º 7
0
void channel_join(struct map_session_data *sd, const char* name, const char* pass, bool invite)
{
	char output[256];
	struct channel_data *cd;
	int i = 0;
	
	if( !name || strlen(name) < 2 || strlen(name) >= NAME_LENGTH || name[0] != '#' )
	{
		clif_displaymessage(sd->fd, msg_txt(801));
		return;
	}

	if( (cd = (struct channel_data *)strdb_get(channel_db, name)) == NULL )
	{
		clif_displaymessage(sd->fd, msg_txt(805));
		return;
	}

	if( channel_slot_get(sd, cd) != -1 )
	{
		clif_displaymessage(sd->fd, msg_txt(806));
		return;
	}

	if( (i = channel_slot_free(sd)) < 0 )
	{
		clif_displaymessage(sd->fd, msg_txt(800));
		return;
	}

	if( !invite )
	{
		if( cd->pass[0] && strcmp(cd->pass, pass) != 0 )
		{ // Check password only if not invited
			clif_displaymessage(sd->fd, msg_txt(808));
			return;
		}
		if( cd->type == CHN_GAMEMASTER && pc_has_permission(sd,PC_PERM_CHANNEL_OPERATOR) )
		{
			clif_displaymessage(sd->fd, msg_txt(703));
			return;
		}
	}

	if( battle_config.channel_announce_join )
	{
		sprintf(output, msg_txt(803), cd->name, sd->status.name);
		clif_channel_message(cd, output, -1);
	}

	sprintf(output, msg_txt(710), sd->status.name, cd->name);
	clif_wis_message(sd->fd, cd->name, output, strlen(output) + 1);

	// Joining Channel
	sd->cd[i] = cd;
	sd->canjoinchn_tick = gettick() + 10000;
	idb_put(cd->users_db, sd->bl.id, sd);
	cd->users++;

	if( sd->channel_invite_timer != INVALID_TIMER )
	{
		const struct TimerData * td = get_timer(sd->channel_invite_timer);
		char *name = td ? (char *)td->data : NULL;

		if( strcmp(name, cd->name) == 0 )
			channel_invite_clear(sd); // Invitation removed as the user joined the channel
	}

	if( cd->type != CHN_USER )
	{
		switch( cd->type )
		{
			case CHN_MAIN: sd->channels |= 1; break;
			case CHN_VENDING: sd->channels |= 2; break;
			case CHN_BATTLEGROUND: sd->channels |= 4; break;
			case CHN_GAMEMASTER: sd->channels |= 8; break;
		}
		pc_setaccountreg(sd, "#CHANNEL_CONF", sd->channels);
	}
}