From 67129480a46cb7e121450ec5cd4d74f56ad02bbe Mon Sep 17 00:00:00 2001 From: Vatiken Date: Sat, 11 Aug 2012 04:44:23 +0000 Subject: [PATCH] Room=name size increased to allow larger colour codes. --- src/oasis.h | 7 ++++--- src/redit.c | 4 ++++ src/utils.c | 32 ++++++++++++++++++++++++++++++++ src/utils.h | 1 + 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/oasis.h b/src/oasis.h index 6eef39c..37bbafb 100644 --- a/src/oasis.h +++ b/src/oasis.h @@ -34,9 +34,10 @@ #define MAX_PEOPLE 10 /* Max # of people you want to sit in furniture. */ /* Limit information. */ -#define MAX_ROOM_NAME 75 -#define MAX_MOB_NAME 50 -#define MAX_OBJ_NAME 50 +/* Name size increased due to larger colour/mxp codes. -Vatiken */ +#define MAX_ROOM_NAME 150 +#define MAX_MOB_NAME 100 +#define MAX_OBJ_NAME 100 #define MAX_ROOM_DESC 2048 #define MAX_EXIT_DESC 256 #define MAX_EXTRA_DESC 512 diff --git a/src/redit.c b/src/redit.c index da631d0..1cdf2b4 100644 --- a/src/redit.c +++ b/src/redit.c @@ -680,6 +680,10 @@ void redit_parse(struct descriptor_data *d, char *arg) case REDIT_NAME: if (!genolc_checkstring(d, arg)) break; + if (count_non_protocol_chars(arg) > MAX_ROOM_NAME / 2) { + write_to_output(d, "Size limited to %d non-protocol characters.\r\n", MAX_ROOM_NAME / 2); + break; + } if (OLC_ROOM(d)->name) free(OLC_ROOM(d)->name); arg[MAX_ROOM_NAME - 1] = '\0'; diff --git a/src/utils.c b/src/utils.c index 0122608..8d93523 100644 --- a/src/utils.c +++ b/src/utils.c @@ -820,6 +820,38 @@ int count_color_chars(char *string) return num; } +/* Not the prettiest thing I've ever written but it does the task which + * is counting all characters in a string which are not part of the + * protocol system. This is with the exception of detailed MXP codes. */ +int count_non_protocol_chars(char * str) +{ + int count = 0; + char *string = str; + + while (*string) { + if (*string == '\r' || *string == '\n') { + string++; + continue; + } + if (*string == '@' || *string == '\t') { + string++; + if (*string != '[' && *string != '<' && *string != '>' && *string != '(' && *string != ')') + string++; + else if (*string == '[') { + while (*string && *string != ']') + string++; + string++; + } else + string++; + continue; + } + count++; + string++; + } + + return count; +} + /** Tests to see if a room is dark. Rules (unless overridden by ROOM_DARK): * Inside and City rooms are always lit. Outside rooms are dark at sunset and * night. diff --git a/src/utils.h b/src/utils.h index d68fccd..6dd2af2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -69,6 +69,7 @@ char *strpaste(char *str1, char *str2, char *joiner); void new_affect(struct affected_type *af); int get_class_by_name(char *classname); char * convert_from_tabs(char * string); +int count_non_protocol_chars(char * str); /* Public functions made available form weather.c */ void weather_and_time(int mode);