diff --git a/conf/battle/gm.conf b/conf/battle/gm.conf index 564fdc914b..d7b4302f86 100644 --- a/conf/battle/gm.conf +++ b/conf/battle/gm.conf @@ -16,6 +16,8 @@ atcommand_slave_clone_limit: 25 // If 'no', commands require exact player name. If 'yes', entering a partial // name will work, as long as there's only one match from all players in the // current map server. +// Some critical atcommands like jail, ban and a few others will still require you to enter the full name. +// It will always work for charcommands when the setting is enabled. partial_name_scan: yes // Ban people that try trade dupe. diff --git a/src/map/atcommand.c b/src/map/atcommand.c index fbbd5700ab..2afb0069aa 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -507,7 +507,7 @@ ACMD_FUNC(where) return -1; } - 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)) @@ -536,7 +536,7 @@ ACMD_FUNC(jumpto) return -1; } - if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) + if((pl_sd=map_nick2sd((char *)message,true)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -2892,7 +2892,7 @@ ACMD_FUNC(recall) { return -1; } - if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) + if((pl_sd=map_nick2sd((char *)message,true)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -3228,7 +3228,7 @@ ACMD_FUNC(kick) return -1; } - if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) + if((pl_sd=map_nick2sd((char *)message,false)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -4487,7 +4487,7 @@ ACMD_FUNC(nuke) return -1; } - if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) { + if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != 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, gettick(), 0); clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked! @@ -4760,7 +4760,7 @@ ACMD_FUNC(jail) return -1; } - if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } @@ -4810,7 +4810,7 @@ ACMD_FUNC(unjail) return -1; } - if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } @@ -4858,7 +4858,7 @@ ACMD_FUNC(jailfor) { return -1; } - if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } @@ -5416,7 +5416,7 @@ ACMD_FUNC(follow) return 0; } - if ( (pl_sd = map_nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map_nick2sd((char *)message,true)) == NULL ) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -5674,7 +5674,7 @@ ACMD_FUNC(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_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } @@ -5743,7 +5743,7 @@ ACMD_FUNC(skilltree) return -1; } - if ( (pl_sd = map_nick2sd(target)) == NULL ) + if ( (pl_sd = map_nick2sd(target,true)) == NULL ) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -5820,7 +5820,7 @@ ACMD_FUNC(marry) return -1; } - if ((pl_sd = map_nick2sd(player_name)) == NULL) { + if ((pl_sd = map_nick2sd(player_name,false)) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); return -1; } @@ -5958,7 +5958,7 @@ ACMD_FUNC(changegm) return -1; } - if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { + if((pl_sd=map_nick2sd((char *) message,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member. return -1; } @@ -5981,7 +5981,7 @@ ACMD_FUNC(changeleader) return -1; } - if (party_changeleader(sd, map_nick2sd((char *) message),NULL)) + if (party_changeleader(sd, map_nick2sd((char *) message,false),NULL)) return 0; return -1; } @@ -6808,7 +6808,7 @@ ACMD_FUNC(trade) return -1; } - if ( (pl_sd = map_nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map_nick2sd((char *)message,true)) == NULL ) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -6856,7 +6856,7 @@ ACMD_FUNC(unmute) return -1; } - if ( (pl_sd = map_nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map_nick2sd((char *)message,false)) == NULL ) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -6953,7 +6953,7 @@ ACMD_FUNC(mute) return -1; } - if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL ) + if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL ) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; @@ -8204,7 +8204,7 @@ ACMD_FUNC(showdelay) ACMD_FUNC(invite) { unsigned int did = sd->duel_group; - struct map_session_data *target_sd = map_nick2sd((char *)message); + struct map_session_data *target_sd = map_nick2sd((char *)message,true); if(did == 0) { // "Duel: @invite without @duel." @@ -8277,7 +8277,7 @@ ACMD_FUNC(duel) duel_create(sd, maxpl); } else { struct map_session_data *target_sd; - target_sd = map_nick2sd((char *)message); + target_sd = map_nick2sd((char *)message,true); if(target_sd != NULL) { unsigned int newduel; if((newduel = duel_create(sd, 2)) != -1) { @@ -8429,7 +8429,7 @@ ACMD_FUNC(clone) return 0; } - if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) { + if((pl_sd=map_nick2sd((char *)message,true)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return 0; } @@ -9554,7 +9554,7 @@ ACMD_FUNC(vip) { return -1; } - if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } @@ -9617,7 +9617,7 @@ ACMD_FUNC(fullstrip) { return -1; } - if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){ + if((tsd=map_nick2sd((char *)message,false)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){ clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } @@ -9708,7 +9708,7 @@ ACMD_FUNC(cloneequip) { if (char_id) pl_sd = map_charid2sd(char_id); else - pl_sd = map_nick2sd(atcmd_output); + pl_sd = map_nick2sd(atcmd_output,true); if (!pl_sd) { clif_displaymessage(fd, msg_txt(sd, 3)); @@ -9784,7 +9784,7 @@ ACMD_FUNC(clonestat) { if (char_id) pl_sd = map_charid2sd(char_id); else - pl_sd = map_nick2sd(atcmd_output); + pl_sd = map_nick2sd(atcmd_output,true); if (!pl_sd) { clif_displaymessage(fd, msg_txt(sd, 3)); @@ -9874,7 +9874,7 @@ ACMD_FUNC(adopt) return -1; } - if ((b_sd = map_nick2sd((char *)atcmd_player_name)) == NULL) { + if ((b_sd = map_nick2sd((char *)atcmd_player_name,false)) == NULL) { clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found. return -1; } @@ -10360,10 +10360,10 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if (*message == charcommand_symbol) is_atcommand = false; - if (is_atcommand) { // #command + if (is_atcommand) { // @command sprintf(atcmd_msg, "%s", message); ssd = sd; - } else { // @command + } else { // #command char charname[NAME_LENGTH]; int n; @@ -10385,7 +10385,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message return true; } - ssd = map_nick2sd(charname); + ssd = map_nick2sd(charname,true); if (ssd == NULL) { sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found. clif_displaymessage(fd, output); diff --git a/src/map/channel.c b/src/map/channel.c index 3451d02c8d..04c81ef2a2 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -813,7 +813,7 @@ int channel_pcunbind(struct map_session_data *sd){ int channel_pcban(struct map_session_data *sd, char *chname, char *pname, int flag){ struct Channel *channel; char output[128]; - struct map_session_data *tsd = map_nick2sd(pname); + struct map_session_data *tsd = map_nick2sd(pname,false); if( channel_chk(chname,NULL,1) ) { clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'. diff --git a/src/map/clif.c b/src/map/clif.c index 91a853520d..7363b5b8b8 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6390,7 +6390,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) safestrncpy(WFIFOCP(fd,28), mes, mes_len); WFIFOSET(fd,WFIFOW(fd,2)); #else - struct map_session_data *ssd = map_nick2sd(nick); + struct map_session_data *ssd = map_nick2sd(nick,false); WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8); WFIFOW(fd,0) = 0x97; @@ -11071,7 +11071,7 @@ 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) { // player is not on this map-server @@ -12732,7 +12732,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd){ return; } - t_sd = map_nick2sd(name); + t_sd = map_nick2sd(name,false); if(t_sd && t_sd->state.noask) {// @noask [LuzZza] clif_noask_sub(sd, t_sd, 1); @@ -13360,7 +13360,7 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd){ /// 0916 .24B (CZ_REQ_JOIN_GUILD2) void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) { - struct map_session_data *t_sd = map_nick2sd(RFIFOCP(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); + struct map_session_data *t_sd = map_nick2sd(RFIFOCP(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),false); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -14212,15 +14212,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) struct map_session_data *f_sd; int i; - f_sd = map_nick2sd(RFIFOCP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); - - // ensure that the request player's friend list is not full - ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0); - - if( i == MAX_FRIENDS ) { - clif_friendslist_reqack(sd, f_sd, 2); - return; - } + f_sd = map_nick2sd(RFIFOCP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),false); // Friend doesn't exist (no player with this name) if (f_sd == NULL) { @@ -14232,6 +14224,14 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) return; } + // ensure that the request player's friend list is not full + ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0); + + if( i == MAX_FRIENDS ){ + clif_friendslist_reqack(sd, f_sd, 2); + return; + } + // @noask [LuzZza] if(f_sd->state.noask) { clif_noask_sub(sd, f_sd, 5); @@ -14633,7 +14633,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd) safestrncpy(charname, RFIFOCP(fd,packet_db[sd->packet_ver][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,false) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { return; } diff --git a/src/map/guild.c b/src/map/guild.c index 8ae67e2247..d334162591 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -496,7 +496,7 @@ int guild_recv_info(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 ) diff --git a/src/map/intif.c b/src/map/intif.c index b2ee13dce8..5b1f7a35c3 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1234,7 +1234,7 @@ int intif_parse_WisMessage(int fd) id=RFIFOL(fd,4); safestrncpy(name, RFIFOCP(fd,32), NAME_LENGTH); - sd = map_nick2sd(name); + sd = map_nick2sd(name,false); if(sd == NULL || strcmp(sd->status.name, name) != 0) { //Not found intif_wis_replay(id,1); @@ -1272,7 +1272,7 @@ int intif_parse_WisEnd(int fd) if (battle_config.etc_log) ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - sd = (struct map_session_data *)map_nick2sd(RFIFOCP(fd,2)); + sd = (struct map_session_data *)map_nick2sd(RFIFOCP(fd,2),false); if (sd != NULL) clif_wis_end(sd->fd, RFIFOB(fd,26)); diff --git a/src/map/map.c b/src/map/map.c index 2dfa0d093b..9a8bd13ef8 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2185,7 +2185,7 @@ struct map_session_data* map_charid2sd(int charid) * (without sensitive case if necessary) * return map_session_data pointer or NULL *------------------------------------------*/ -struct map_session_data * map_nick2sd(const char *nick) +struct map_session_data * map_nick2sd(const char *nick, bool allow_partial) { struct map_session_data* sd; struct map_session_data* found_sd; @@ -2202,7 +2202,7 @@ struct map_session_data * map_nick2sd(const char *nick) found_sd = NULL; for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) ) { - if( battle_config.partial_name_scan ) + if( allow_partial && battle_config.partial_name_scan ) {// partial name search if( strnicmp(sd->status.name, nick, nicklen) == 0 ) { diff --git a/src/map/map.h b/src/map/map.h index e449cc5813..c9bfc6d8a8 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -854,7 +854,7 @@ void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...); void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...); void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...); void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...); -struct map_session_data * map_nick2sd(const char*); +struct map_session_data * map_nick2sd(const char* nick, bool allow_partial); struct mob_data * map_getmob_boss(int16 m); struct mob_data * map_id2boss(int id); diff --git a/src/map/script.c b/src/map/script.c index 1702bb5d8e..522d68fee2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -106,7 +106,7 @@ static bool script_charid2sd_(struct script_state *st, uint8 loc, struct map_ses static bool script_nick2sd_(struct script_state *st, uint8 loc, struct map_session_data **sd, const char *func) { if (script_hasdata(st, loc)) { const char *name_ = script_getstr(st, loc); - if (!(*sd = map_nick2sd(name_))) + if (!(*sd = map_nick2sd(name_,false))) ShowError("%s: Player with nick '%s' is not found.\n", func, name_); } else @@ -7219,7 +7219,7 @@ BUILDIN_FUNC(getnameditem) data=script_getdata(st,3); get_val(st,data); if( data_isstring(data) ) //Char Name - tsd=map_nick2sd(conv_str(st,data)); + tsd=map_nick2sd(conv_str(st,data),false); else //Char Id was given tsd=map_charid2sd(conv_num(st,data)); @@ -7880,12 +7880,8 @@ BUILDIN_FUNC(getcharid) TBL_PC *sd; num = script_getnum(st,2); - if( script_hasdata(st,3) ) - sd=map_nick2sd(script_getstr(st,3)); - else - sd=script_rid2sd(st); - if(sd==NULL){ + if( !script_nick2sd(3,sd) ){ script_pushint(st,0); //return 0, according docs return SCRIPT_CMD_SUCCESS; } @@ -9838,7 +9834,7 @@ BUILDIN_FUNC(guildchangegm) guild_id = script_getnum(st,2); name = script_getstr(st,3); - sd=map_nick2sd(name); + sd=map_nick2sd(name,false); if (!sd) script_pushint(st,0); @@ -10484,13 +10480,7 @@ BUILDIN_FUNC(attachnpctimer) return SCRIPT_CMD_FAILURE; } - if( script_hasdata(st,2) ) - sd = map_nick2sd(script_getstr(st,2)); - else - sd = script_rid2sd(st); - - if( !sd ) - { + if( !script_nick2sd(2,sd) ){ script_pushint(st,1); ShowWarning("attachnpctimer: Invalid player.\n"); return SCRIPT_CMD_FAILURE; @@ -12363,12 +12353,10 @@ BUILDIN_FUNC(emotion) if (player) { TBL_PC *sd = NULL; - if( script_hasdata(st,4) ) - sd = map_nick2sd(script_getstr(st,4)); - else - sd = script_rid2sd(st); - if (sd) - clif_emotion(&sd->bl,type); + + if( script_nick2sd(4,sd) ){ + clif_emotion(&sd->bl, type); + } } else if( script_hasdata(st,4) ) { @@ -12950,7 +12938,7 @@ BUILDIN_FUNC(marriage) { const char *partner=script_getstr(st,2); TBL_PC *sd=script_rid2sd(st); - TBL_PC *p_sd=map_nick2sd(partner); + TBL_PC *p_sd=map_nick2sd(partner,false); if(!sd || !p_sd || !pc_marriage(sd,p_sd)){ script_pushint(st,0); @@ -14011,10 +13999,7 @@ BUILDIN_FUNC(specialeffect2) int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; - if( script_hasdata(st,4) ) - sd = map_nick2sd(script_getstr(st,4)); - - if (sd) + if( script_nick2sd(4,sd) ) clif_specialeffect(&sd->bl, type, target); return SCRIPT_CMD_SUCCESS; } @@ -14467,7 +14452,7 @@ BUILDIN_FUNC(message) player = script_getstr(st,2); msg = script_getstr(st,3); - if((pl_sd=map_nick2sd((char *) player)) == NULL) + if((pl_sd=map_nick2sd((char *) player,false)) == NULL) return SCRIPT_CMD_SUCCESS; clif_displaymessage(pl_sd->fd, msg); @@ -14669,12 +14654,7 @@ BUILDIN_FUNC(getmapxy) switch (type) { case UNITTYPE_PC: //Get Character Position - if( script_hasdata(st,6) ) - sd=map_nick2sd(script_getstr(st,6)); - else - sd=script_rid2sd(st); - - if (sd) + if( script_nick2sd(6,sd) ) bl = &sd->bl; break; case UNITTYPE_NPC: //Get NPC Position @@ -14688,39 +14668,19 @@ BUILDIN_FUNC(getmapxy) bl=map_id2bl(st->oid); break; case UNITTYPE_PET: //Get Pet Position - if(script_hasdata(st,6)) - sd=map_nick2sd(script_getstr(st,6)); - else - sd=script_rid2sd(st); - - if (sd && sd->pd) + if( script_nick2sd(6, sd) && sd->pd ) bl = &sd->pd->bl; break; case UNITTYPE_HOM: //Get Homun Position - if(script_hasdata(st,6)) - sd=map_nick2sd(script_getstr(st,6)); - else - sd=script_rid2sd(st); - - if (sd && sd->hd) + if( script_nick2sd(6, sd) && sd->hd ) bl = &sd->hd->bl; break; case UNITTYPE_MER: //Get Mercenary Position - if(script_hasdata(st,6)) - sd=map_nick2sd(script_getstr(st,6)); - else - sd=script_rid2sd(st); - - if (sd && sd->md) + if( script_nick2sd(6, sd) && sd->md ) bl = &sd->md->bl; break; case UNITTYPE_ELEM: //Get Elemental Position - if(script_hasdata(st,6)) - sd=map_nick2sd(script_getstr(st,6)); - else - sd=script_rid2sd(st); - - if (sd && sd->ed) + if( script_nick2sd(6, sd) && sd->ed ) bl = &sd->ed->bl; break; default: @@ -16744,16 +16704,7 @@ BUILDIN_FUNC(getmonsterinfo) BUILDIN_FUNC(checkvending) { TBL_PC *sd = NULL; - if (script_hasdata(st,2)) { - if (!(sd = map_nick2sd(script_getstr(st,2)))) { - ShowError("buildin_checkvending: Player '%s' is not online!\n", script_getstr(st,2)); - return SCRIPT_CMD_FAILURE; - } - } - else - sd = script_rid2sd(st); - - if (!sd) { + if (!script_nick2sd(2,sd) ) { script_pushint(st,0); return SCRIPT_CMD_SUCCESS; } @@ -16776,12 +16727,7 @@ BUILDIN_FUNC(checkchatting) // check chatting [Marka] { TBL_PC *sd = NULL; - if(script_hasdata(st,2)) - sd = map_nick2sd(script_getstr(st,2)); - else - sd = script_rid2sd(st); - - if(sd) + if( script_nick2sd(2,sd) ) script_pushint(st,(sd->chatID != 0)); else script_pushint(st,0); @@ -16792,12 +16738,7 @@ BUILDIN_FUNC(checkidle) { TBL_PC *sd = NULL; - if (script_hasdata(st, 2)) - sd = map_nick2sd(script_getstr(st, 2)); - else - sd = script_rid2sd(st); - - if (sd) + if( script_nick2sd(2,sd) ) script_pushint(st, DIFF_TICK(last_tick, sd->idletime)); else script_pushint(st, 0); @@ -17906,7 +17847,7 @@ BUILDIN_FUNC(unitattack) get_val(st, data); if (data_isstring(data)) { - TBL_PC* sd = map_nick2sd(conv_str(st, data)); + TBL_PC* sd = map_nick2sd(conv_str(st, data),false); if( sd != NULL ) target_bl = &sd->bl; } else @@ -19992,7 +19933,7 @@ BUILDIN_FUNC(getcharip) data = script_getdata(st, 2); get_val(st, data); // Convert into value in case of a variable if (data_isstring(data)) - sd = map_nick2sd(script_getstr(st, 2)); + sd = map_nick2sd(script_getstr(st, 2),false); else if (data_isint(data) || script_getnum(st, 2)) { int id = 0; @@ -20435,12 +20376,7 @@ BUILDIN_FUNC(sit) { TBL_PC *sd; - if( script_hasdata(st, 2) ) - sd = map_nick2sd(script_getstr(st, 2)); - else - sd = script_rid2sd(st); - - if( sd == NULL) + if( !script_nick2sd(2,sd) ) return SCRIPT_CMD_FAILURE; if( !pc_issit(sd) ) { @@ -20458,12 +20394,7 @@ BUILDIN_FUNC(stand) { TBL_PC *sd; - if( script_hasdata(st, 2) ) - sd = map_nick2sd(script_getstr(st, 2)); - else - sd = script_rid2sd(st); - - if( sd == NULL) + if( !script_nick2sd(2,sd) ) return SCRIPT_CMD_FAILURE; if( pc_issit(sd) && pc_setstand(sd, false)) { @@ -20767,12 +20698,7 @@ BUILDIN_FUNC(vip_status) { time_t now = time(NULL); int type = script_getnum(st, 2); - if (script_hasdata(st, 3)) - sd = map_nick2sd(script_getstr(st, 3)); - else - sd = script_rid2sd(st); - - if (sd == NULL) + if( !script_nick2sd(3,sd) ) return SCRIPT_CMD_FAILURE; switch(type) { @@ -20816,12 +20742,7 @@ BUILDIN_FUNC(vip_time) { TBL_PC *sd; int viptime = script_getnum(st, 2) * 60; // Convert since it's given in minutes. - if (script_hasdata(st, 3)) - sd = map_nick2sd(script_getstr(st, 3)); - else - sd = script_rid2sd(st); - - if (sd == NULL) + if( !script_nick2sd(3,sd) ) return SCRIPT_CMD_FAILURE; chrif_req_login_operation(sd->status.account_id, sd->status.name, CHRIF_OP_LOGIN_VIP, viptime, 7, 0); @@ -21115,7 +21036,7 @@ BUILDIN_FUNC(addspiritball) { if (!script_isstring(st,4)) sd = map_charid2sd(script_getnum(st,4)); else - sd = map_nick2sd(script_getstr(st,4)); + sd = map_nick2sd(script_getstr(st,4),false); } else sd = script_rid2sd(st); @@ -21144,7 +21065,7 @@ BUILDIN_FUNC(delspiritball) { if (!script_isstring(st,3)) sd = map_charid2sd(script_getnum(st,3)); else - sd = map_nick2sd(script_getstr(st,3)); + sd = map_nick2sd(script_getstr(st,3),false); } else sd = script_rid2sd(st); @@ -21167,7 +21088,7 @@ BUILDIN_FUNC(countspiritball) { if (!script_isstring(st,2)) sd = map_charid2sd(script_getnum(st,2)); else - sd = map_nick2sd(script_getstr(st,2)); + sd = map_nick2sd(script_getstr(st,2),false); } else sd = script_rid2sd(st); @@ -21458,7 +21379,7 @@ BUILDIN_FUNC(ignoretimeout) if (!script_isstring(st,3)) sd = map_charid2sd(script_getnum(st,3)); else - sd = map_nick2sd(script_getstr(st,3)); + sd = map_nick2sd(script_getstr(st,3),false); } else sd = script_rid2sd(st); @@ -21667,7 +21588,7 @@ BUILDIN_FUNC(adopt) if (data_isstring(data)) { const char *name = conv_str(st, data); - sd = map_nick2sd(name); + sd = map_nick2sd(name,false); if (sd == NULL) { ShowError("buildin_adopt: Non-existant parent character %s requested.\n", name); return SCRIPT_CMD_FAILURE; @@ -21691,7 +21612,7 @@ BUILDIN_FUNC(adopt) if (data_isstring(data)) { const char *name = conv_str(st, data); - b_sd = map_nick2sd(name); + b_sd = map_nick2sd(name,false); if (b_sd == NULL) { ShowError("buildin_adopt: Non-existant baby character %s requested.\n", name); return SCRIPT_CMD_FAILURE;