Skip to content

Commit

Permalink
Fixed @go \n problem.
Browse files Browse the repository at this point in the history
Special Thanks to Yommy, Fatalis.
http://hercules.ws/board/topic/570-problem-on-go-text/

Signed-off-by: shennetsind <ind@henn.et>
  • Loading branch information
shennetsind committed May 9, 2013
1 parent cbda33c commit ac3caf5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
24 changes: 10 additions & 14 deletions src/map/atcommand.c
Expand Up @@ -876,9 +876,8 @@ ACMD(option)
// notify the user of the requirement to enter an option
clif->message(fd, msg_txt(921)); // Please enter at least one option.

if( text )
{// send the help text associated with this command
clif->message( fd, text );
if( text ) {// send the help text associated with this command
clif->messageln( fd, text );
}

return false;
Expand Down Expand Up @@ -969,7 +968,7 @@ ACMD(jobchange)
if (!found) {
text = atcommand_help_string(info);
if (text)
clif->message(fd, text);
clif->messageln(fd, text);
return false;
}
}
Expand All @@ -992,7 +991,7 @@ ACMD(jobchange)
} else {
text = atcommand_help_string(info);
if (text)
clif->message(fd, text);
clif->messageln(fd, text);
return false;
}

Expand Down Expand Up @@ -1767,9 +1766,8 @@ ACMD(go)

clif->message(fd, msg_txt(38)); // Invalid location number, or name.

if( text )
{// send the text to the client
clif->message( fd, text );
if( text ) {// send the text to the client
clif->messageln( fd, text );
}

return false;
Expand Down Expand Up @@ -3122,9 +3120,8 @@ ACMD(questskill)
// send the error message as always
clif->message(fd, msg_txt(1027)); // Please enter a quest skill number.

if( text )
{// send the skill ID list associated with this command
clif->message( fd, text );
if( text ) {// send the skill ID list associated with this command
clif->messageln( fd, text );
}

return false;
Expand Down Expand Up @@ -3166,9 +3163,8 @@ ACMD(lostskill)
// send the error message as always
clif->message(fd, msg_txt(1027)); // Please enter a quest skill number.

if( text )
{// send the skill ID list associated with this command
clif->message( fd, text );
if( text ) {// send the skill ID list associated with this command
clif->messageln( fd, text );
}

return false;
Expand Down
36 changes: 34 additions & 2 deletions src/map/clif.c
Expand Up @@ -5657,6 +5657,39 @@ void clif_displaymessage(const int fd, const char* mes) {
}
}
}
void clif_displaymessage2(const int fd, const char* mes) {
// invalid pointer?
nullpo_retv(mes);

//Scrapped, as these are shared by disconnected players =X [Skotlex]
if (fd == 0)
;
else {
// Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client)
char *message, *line;

message = aStrdup(mes);
line = strtok(message, "\n");
while(line != NULL) {
// Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client)
int len = strnlen(line, 255);

if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
if( fd == -2 ) {
ShowInfo("HCP: %s\n",line);
} else {
WFIFOHEAD(fd, 5 + len);
WFIFOW(fd,0) = 0x8e;
WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate
safestrncpy((char *)WFIFOP(fd,4), line, len + 1);
WFIFOSET(fd, 5 + len);
}
}
line = strtok(NULL, "\n");
}
aFree(message);
}
}

/// Send broadcast message in yellow or blue without font formatting (ZC_BROADCAST).
/// 009a <packet len>.W <message>.?B
Expand Down Expand Up @@ -9838,11 +9871,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
} else if ( sd->fontcolor && !sd->chatID ) {
char mout[200];
unsigned char mylen = 1;
ShowDebug("Hi1:%d\n",sd->disguise);

if( sd->disguise == -1 ) {
pc_disguise(sd,sd->status.class_);
ShowDebug("Hi2:%d\n",sd->disguise);
sd->fontcolor_tid = add_timer(gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
} else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) {
const struct TimerData *timer;
Expand Down Expand Up @@ -17369,6 +17400,7 @@ void clif_defaults(void) {
clif->msgtable = clif_msgtable;
clif->msgtable_num = clif_msgtable_num;
clif->message = clif_displaymessage;
clif->messageln = clif_displaymessage2;
clif->colormes = clif_colormes;
clif->process_message = clif_process_message;
clif->wisexin = clif_wisexin;
Expand Down
1 change: 1 addition & 0 deletions src/map/clif.h
Expand Up @@ -677,6 +677,7 @@ struct clif_interface {
void (*msgtable) (int fd, int line);
void (*msgtable_num) (int fd, int line, int num);
void (*message) (const int fd, const char* mes);
void (*messageln) (const int fd, const char* mes);
int (*colormes) (int fd, enum clif_colors color, const char* msg);
bool (*process_message) (struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_);
void (*wisexin) (struct map_session_data *sd,int type,int flag);
Expand Down

0 comments on commit ac3caf5

Please sign in to comment.