summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-03-20 20:19:23 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-03-20 20:19:23 +0000
commit1a18fb9893df4d3cb40910d41acf875c7c6ea773 (patch)
treeedff894a35b9019f85be7890bcf3ab12d216244e /src/map/atcommand.c
parentd6d6653b47488b9ad96b153d546639d52bcc0aba (diff)
downloadhercules-1a18fb9893df4d3cb40910d41acf875c7c6ea773.tar.gz
hercules-1a18fb9893df4d3cb40910d41acf875c7c6ea773.tar.bz2
hercules-1a18fb9893df4d3cb40910d41acf875c7c6ea773.tar.xz
hercules-1a18fb9893df4d3cb40910d41acf875c7c6ea773.zip
* Random accumulated tweaks and fixes.
- Added a error message to npc_enable, to spot disablenpc/enablenpc/hideoffnpc/hideonnpc on non-existing NPCs (related r14750). - Replaced inlined npc_name2id code with calls to npc_name2id. - Open Buying Store skill is now exempted from noskill mapflag like Vending as well (bugreport:4815, follow up to r14713). - Fixed signed constant being returned as unsigned value in get_percentage (bugreport:4765, since r12679). - Replaced strlen checks, which checked whether or not a string is empty, with first-byte checks. - Fixed enabling 'fakename' not clearing party and guild name and cleaned up atcommand 'fakename' code. - Cleaned up party/guild name code in clif_charnameack (follow up to r14737). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14751 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b44eae946..b6304349e 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2377,7 +2377,7 @@ ACMD_FUNC(monster)
if (number <= 0)
number = 1;
- if (strlen(name) < 1)
+ if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
@@ -2458,7 +2458,7 @@ ACMD_FUNC(monstersmall)
if (number <= 0)
number = 1;
- if (strlen(name) < 1)
+ if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
@@ -2534,7 +2534,7 @@ ACMD_FUNC(monsterbig)
if (number <= 0)
number = 1;
- if (strlen(name) < 1)
+ if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
@@ -5983,7 +5983,7 @@ ACMD_FUNC(changegm)
return -1;
}
- if (strlen(message)==0)
+ if( !message[0] )
{
clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
return -1;
@@ -6006,7 +6006,7 @@ ACMD_FUNC(changeleader)
{
nullpo_retr(-1, sd);
- if (strlen(message)==0)
+ if( !message[0] )
{
clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
return -1;
@@ -7744,31 +7744,32 @@ ACMD_FUNC(monsterignore)
*------------------------------------------*/
ACMD_FUNC(fakename)
{
- char name[NAME_LENGTH];
nullpo_retr(-1, sd);
-
- if((!message || !*message) && strlen(sd->fakename) > 1) {
- sd->fakename[0]='\0';
- clif_charnameack(0, &sd->bl);
- clif_displaymessage(sd->fd,"Returned to real name.");
- return 0;
- }
- if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
- clif_displaymessage(sd->fd,"You must enter a name.");
+ if( !message || !*message )
+ {
+ if( sd->fakename[0] )
+ {
+ sd->fakename[0] = '\0';
+ clif_charnameack(0, &sd->bl);
+ clif_displaymessage(sd->fd, "Returned to real name.");
+ return 0;
+ }
+
+ clif_displaymessage(sd->fd, "You must enter a name.");
return -1;
}
- if(strlen(name) < 2) {
- clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
+ if( strlen(message) < 2 )
+ {
+ clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
return -1;
}
- memcpy(sd->fakename,name,NAME_LENGTH);
- sd->fakename[NAME_LENGTH-1] = '\0';
+ safestrncpy(sd->fakename, message, sizeof(sd->fakename));
clif_charnameack(0, &sd->bl);
- clif_displaymessage(sd->fd,"Fake name enabled.");
-
+ clif_displaymessage(sd->fd, "Fake name enabled.");
+
return 0;
}
@@ -7902,7 +7903,7 @@ ACMD_FUNC(duel)
return 0;
}
- if(strlen(message) > 0) {
+ if( message[0] ) {
if(sscanf(message, "%d", &maxpl) >= 1) {
if(maxpl < 2 || maxpl > 65535) {
clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
@@ -8078,7 +8079,7 @@ ACMD_FUNC(clone)
*-----------------------------------*/
ACMD_FUNC(main)
{
- if(strlen(message) > 0) {
+ if( message[0] ) {
if(strcmpi(message, "on") == 0) {
if(!sd->state.mainchat) {
@@ -9164,7 +9165,7 @@ ACMD_FUNC(commands)
if( gm_lvl < atcommand_info[i].level2 && stristr(command,"charcommands") )
continue;
- slen = (unsigned int)strlen(atcommand_info[i].command);
+ slen = strlen(atcommand_info[i].command);
// flush the text buffer if this command won't fit into it
if( slen + cur - line_buff >= CHATBOX_SIZE )