From debf92811f517f0780ac72d9ba6a6f868ec3c3d2 Mon Sep 17 00:00:00 2001 From: Vatiken Date: Wed, 27 Jun 2012 02:14:22 +0000 Subject: [PATCH] Fixed a client issue that was causing duplicate new lines --- src/db.c | 11 ++++++++++- src/oasis_list.c | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/db.c b/src/db.c index a05a843..f7693c2 100644 --- a/src/db.c +++ b/src/db.c @@ -156,6 +156,7 @@ char *fread_action(FILE *fl, int nr) { char buf[MAX_STRING_LENGTH]; char *buf1; + int i; buf1 = fgets(buf, MAX_STRING_LENGTH, fl); if (feof(fl)) { @@ -169,7 +170,15 @@ char *fread_action(FILE *fl, int nr) return (NULL); parse_at(buf); - buf[strlen(buf) - 1] = '\0'; + + /* Some clients interpret '\r' the same as { '\r' '\n' }, so the original way of just + replacing '\n' with '\0' would appear as 2 new lines following the action */ + for (i = 0; buf[i] != '\0'; i++) + if (buf[i] == '\r' || buf[i] == '\n') { + buf[i] = '\0'; + break; + } + return (strdup(buf)); } diff --git a/src/oasis_list.c b/src/oasis_list.c index 6e771ad..f249567 100644 --- a/src/oasis_list.c +++ b/src/oasis_list.c @@ -263,7 +263,10 @@ void perform_obj_aff_list(struct char_data * ch, char *arg) if ((apply == APPLY_CLASS && obj_proto[num].obj_flags.type_flag == ITEM_WEAPON) || (apply == APPLY_LEVEL && obj_proto[num].obj_flags.type_flag == ITEM_ARMOR) ) { ov = obj_index[num].vnum; - v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[num].obj_flags.value[1])/2); + if (apply == APPLY_CLASS) + v1 = ((obj_proto[num].obj_flags.value[2]+1)*(obj_proto[num].obj_flags.value[1])/2); + else + v1 = (obj_proto[num].obj_flags.value[0]); if ((r_num = real_object(ov)) != NOTHING) add_to_obj_list(lst, MAX_OBJ_LIST, ov, v1);