Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ ACMD(where)
return false;
}

pl_sd = map->nick2sd(atcmd_player_name);
pl_sd = map->nick2sd(atcmd_player_name, true);
if (pl_sd == NULL ||
strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
(pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
Expand Down Expand Up @@ -548,7 +548,7 @@ ACMD(jumpto)
return false;
}

if ((pl_sd=map->nick2sd(message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
if ((pl_sd=map->nick2sd(message, true)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -2904,7 +2904,7 @@ ACMD(recall)
return false;
}

if ((pl_sd=map->nick2sd(message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
if ((pl_sd=map->nick2sd(message, true)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -3229,7 +3229,7 @@ ACMD(kick)
return false;
}

if ((pl_sd=map->nick2sd(message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
if ((pl_sd=map->nick2sd(message, true)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -4364,7 +4364,7 @@ ACMD(nuke)
return false;
}

if ((pl_sd = map->nick2sd(atcmd_player_name)) != NULL) {
if ((pl_sd = map->nick2sd(atcmd_player_name, true)) != NULL) {
if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0);
clif->message(fd, msg_fd(fd,109)); // Player has been nuked!
Expand Down Expand Up @@ -4684,7 +4684,7 @@ ACMD(jail)
return false;
}

if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
if ((pl_sd = map->nick2sd(atcmd_player_name, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -4736,7 +4736,7 @@ ACMD(unjail)
return false;
}

if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
if ((pl_sd = map->nick2sd(atcmd_player_name, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -4815,7 +4815,7 @@ ACMD(jailfor)
return false;
}

if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
if ((pl_sd = map->nick2sd(atcmd_player_name, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -5346,7 +5346,7 @@ ACMD(follow)
return true;
}

if ((pl_sd = map->nick2sd(message)) == NULL) {
if ((pl_sd = map->nick2sd(message, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -5596,7 +5596,7 @@ ACMD(useskill)

if (!strcmp(target,"self"))
pl_sd = sd; //quick keyword
else if ((pl_sd = map->nick2sd(target)) == NULL) {
else if ((pl_sd = map->nick2sd(target, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -5664,7 +5664,7 @@ ACMD(skilltree)
return false;
}

if ( (pl_sd = map->nick2sd(target)) == NULL ) {
if ( (pl_sd = map->nick2sd(target, true)) == NULL ) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -5734,7 +5734,7 @@ ACMD(marry)
return false;
}

if ((pl_sd = map->nick2sd(player_name)) == NULL) {
if ((pl_sd = map->nick2sd(player_name, true)) == NULL) {
clif->message(fd, msg_fd(fd,3));
return false;
}
Expand Down Expand Up @@ -5864,7 +5864,7 @@ ACMD(changegm)
return false;
}

if ((pl_sd=map->nick2sd(message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
if ((pl_sd=map->nick2sd(message, true)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
clif->message(fd, msg_fd(fd,1184)); // Target character must be online and be a guild member.
return false;
}
Expand All @@ -5885,7 +5885,7 @@ ACMD(changeleader)
return false;
}

if (party->changeleader(sd, map->nick2sd(message)))
if (party->changeleader(sd, map->nick2sd(message, true)))
return true;
return false;
}
Expand Down Expand Up @@ -6349,7 +6349,7 @@ ACMD(mobsearch)
}
if (mob_id == atoi(mob_name)) {
strcpy(mob_name,mob->db(mob_id)->jname); // DEFAULT_MOB_JNAME
//strcpy(mob_name,mob_db(mob_id)->name); // DEFAULT_MOB_NAME
//strcpy(mob_name,mob->db(mob_id)->name); // DEFAULT_MOB_NAME
}

snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
Expand Down Expand Up @@ -6651,7 +6651,7 @@ ACMD(trade)
return false;
}

if ((pl_sd = map->nick2sd(message)) == NULL) {
if ((pl_sd = map->nick2sd(message, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -6695,7 +6695,7 @@ ACMD(unmute)
return false;
}

if ((pl_sd = map->nick2sd(message)) == NULL) {
if ((pl_sd = map->nick2sd(message, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -6775,7 +6775,7 @@ ACMD(mute)
return false;
}

if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
if ((pl_sd = map->nick2sd(atcmd_player_name, true)) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -7072,7 +7072,7 @@ ACMD(showmobs)

if (mob_id == atoi(mob_name)) {
strcpy(mob_name,mob->db(mob_id)->jname); // DEFAULT_MOB_JNAME
//strcpy(mob_name,mob_db(mob_id)->name); // DEFAULT_MOB_NAME
//strcpy(mob_name,mob->db(mob_id)->name); // DEFAULT_MOB_NAME
}

snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1252), // Mob Search... %s %s
Expand Down Expand Up @@ -7985,7 +7985,7 @@ ACMD(showdelay)
ACMD(invite)
{
unsigned int did = sd->duel_group;
struct map_session_data *target_sd = map->nick2sd(message);
struct map_session_data *target_sd = map->nick2sd(message, true);

if (did == 0)
{
Expand Down Expand Up @@ -8058,7 +8058,7 @@ ACMD(duel)
}
duel->create(sd, maxpl);
} else {
struct map_session_data *target_sd = map->nick2sd(message);
struct map_session_data *target_sd = map->nick2sd(message, true);
if (target_sd != NULL) {
unsigned int newduel;
if ((newduel = duel->create(sd, 2)) != -1) {
Expand Down Expand Up @@ -8203,7 +8203,7 @@ ACMD(clone)
return false;
}

if ((pl_sd=map->nick2sd(message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
if ((pl_sd=map->nick2sd(message, true)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_fd(fd,3)); // Character not found.
return false;
}
Expand Down Expand Up @@ -9321,7 +9321,7 @@ ACMD(channel)
return false;
}

if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4, true)) == NULL) {
safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
Expand Down Expand Up @@ -9368,7 +9368,7 @@ ACMD(channel)
clif->message(fd, atcmd_output);
return false;
}
if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4, true)) == NULL) {
safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
Expand Down Expand Up @@ -10463,7 +10463,7 @@ static bool atcommand_exec(const int fd, struct map_session_data *sd, const char
return true;
}

ssd = map->nick2sd(charname);
ssd = map->nick2sd(charname, true);
if (ssd == NULL) {
sprintf(output, msg_fd(fd,1389), command); // %s failed. Player not found.
clif->message(fd, output);
Expand Down
14 changes: 7 additions & 7 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -6458,7 +6458,7 @@ static void clif_wis_message(int fd, const char *nick, const char *mes, int mes_
safestrncpy(WFIFOP(fd,28), mes, mes_len + 1);
WFIFOSET(fd,WFIFOW(fd,2));
#else
ssd = map->nick2sd(nick);
ssd = map->nick2sd(nick, false);

WFIFOHEAD(fd, mes_len + NAME_LENGTH + 9);
WFIFOW(fd,0) = 0x97;
Expand Down Expand Up @@ -11644,9 +11644,9 @@ static void clif_parse_WisMessage(int fd, struct map_session_data *sd)
}

// searching destination character
dstsd = map->nick2sd(target);
dstsd = map->nick2sd(target, false);

if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) {
if (dstsd == NULL) {
// Character not found (or found through partial match).
clif->wis_end(sd->fd, 1);
return;
Expand Down Expand Up @@ -13492,7 +13492,7 @@ static void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
return;
}

t_sd = map->nick2sd(name);
t_sd = map->nick2sd(name, true);

if(t_sd && t_sd->state.noask) { // @noask [LuzZza]
clif->noask_sub(sd, t_sd, 1);
Expand Down Expand Up @@ -14766,7 +14766,7 @@ static void clif_parse_GuildInvite2(int fd, struct map_session_data *sd)
struct map_session_data *t_sd = NULL;

safestrncpy(nick, RFIFOP(fd, 2), NAME_LENGTH);
t_sd = map->nick2sd(nick);
t_sd = map->nick2sd(nick, true);

clif_sub_guild_invite(fd, sd, t_sd);
}
Expand Down Expand Up @@ -15807,7 +15807,7 @@ static void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd)

safestrncpy(nick, RFIFOP(fd,2), NAME_LENGTH);

f_sd = map->nick2sd(nick);
f_sd = map->nick2sd(nick, true);

// ensure that the request player's friend list is not full
ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0);
Expand Down Expand Up @@ -16539,7 +16539,7 @@ static void clif_parse_Check(int fd, struct map_session_data *sd)

safestrncpy(charname, RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname));

if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) {
if ((pl_sd = map->nick2sd(charname, true)) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/map/guild.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ static int guild_recv_info(const struct guild *sg)
before=*sg;
//Perform the check on the user because the first load
guild->check_member(sg);
if ((sd = map->nick2sd(sg->master)) != NULL) {
if ((sd = map->nick2sd(sg->master, false)) != NULL) {
//If the guild master is online the first time the guild_info is received,
//that means he was the first to join, so apply guild skill blocking here.
if( battle_config.guild_skill_relog_delay == 1)
Expand Down
48 changes: 23 additions & 25 deletions src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,48 +2268,46 @@ static struct map_session_data *map_charid2sd(int charid)
* (without sensitive case if necessary)
* return map_session_data pointer or NULL
*------------------------------------------*/
static struct map_session_data *map_nick2sd(const char *nick)
static struct map_session_data *map_nick2sd(const char *nick, bool allow_partial)
{
struct map_session_data* sd;
struct map_session_data* found_sd;
struct s_mapiterator* iter;
size_t nicklen;
int qty = 0;

if( nick == NULL )
if (nick == NULL)
return NULL;

nicklen = strlen(nick);
iter = mapit_getallusers();
struct s_mapiterator *iter = mapit_getallusers();
struct map_session_data *found_sd = NULL;

if (battle_config.partial_name_scan && allow_partial) {
int nicklen = (int)strlen(nick);
int qty = 0;

found_sd = NULL;
for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) {
if( battle_config.partial_name_scan )
{// partial name search
if( strnicmp(sd->status.name, nick, nicklen) == 0 )
{
// partial name search
for (struct map_session_data *sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) {
if (strnicmp(sd->status.name, nick, nicklen) == 0) {
found_sd = sd;

if( strcmp(sd->status.name, nick) == 0 )
{// Perfect Match
if (strcmp(sd->status.name, nick) == 0) {
// Perfect Match
qty = 1;
break;
}

qty++;
}
}
else if( strcasecmp(sd->status.name, nick) == 0 )
{// exact search only
found_sd = sd;
break;

if (qty != 1)
found_sd = NULL;
} else {
// exact search only
for (struct map_session_data *sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) {
if (strcasecmp(sd->status.name, nick) == 0) {
found_sd = sd;
break;
}
}
}
mapit->free(iter);

if( battle_config.partial_name_scan && qty != 1 )
found_sd = NULL;

return found_sd;
}

Expand Down
2 changes: 1 addition & 1 deletion src/map/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ END_ZEROED_BLOCK;
void (*addiddb) (struct block_list *bl);
void (*deliddb) (struct block_list *bl);
/* */
struct map_session_data * (*nick2sd) (const char *nick);
struct map_session_data * (*nick2sd) (const char *nick, bool allow_partial);
struct mob_data * (*getmob_boss) (int16 m);
struct mob_data * (*id2boss) (int id);
uint32 (*race_id2mask) (int race);
Expand Down
Loading