Room=name size increased to allow larger colour codes.

This commit is contained in:
Vatiken 2012-08-11 04:44:23 +00:00
parent 60a2f0ff7b
commit 67129480a4
4 changed files with 41 additions and 3 deletions

View file

@ -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

View file

@ -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';

View file

@ -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.

View file

@ -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);