Bläddra i källkod

- Made the char_name_option char_athena.conf setting apply to parties and guilds as well. It cannot be applied to pets yet without adding a change-name-request interserver packet.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6897 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 år sedan
förälder
incheckning
ca917a0909

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/05/31
+	* Made the char_name_option char_athena.conf setting apply to parties and
+	  guilds as well. It cannot be applied to pets yet without adding a
+	  change-name-request interserver packet. [Skotlex]
 	* Moved the JOB_* defines from map.h to mmo.h, update char.c to use them.
 	  [Skotlex]
 	* Added function char_read_fame_list for famelist reading. Invoked it on

+ 1 - 0
conf-tmpl/char_athena.conf

@@ -150,6 +150,7 @@ char_log_filename: log/char.log
 name_ignoring_case: 0
 
 // Manage possible letters/symbol in the name of charater. Control character (0x00-0x1f) are never accepted. Possible values are:
+// NOTE: Applies to character, party and guild names.
 // 0: no restriction (default)
 // 1: only letters/symbols in 'char_name_letters' option.
 // 2: Letters/symbols in 'char_name_letters' option are forbidden. All others are possibles.

+ 3 - 0
src/char/char.h

@@ -39,6 +39,9 @@ int request_accreg2(int account_id, int char_id);
 int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int len);
 int save_accreg2(unsigned char *buf, int len);
 int char_account_reg_reply(int fd,int account_id,int char_id);
+
+extern int char_name_option;
+extern char char_name_letters[];
 extern int autosave_interval;
 extern char db_path[];
 

+ 16 - 0
src/char/int_guild.c

@@ -948,6 +948,22 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem
 		mapif_guild_created(fd, account_id, NULL);
 		return 0;
 	}
+
+	// Check Authorised letters/symbols in the name of the character
+	if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) == NULL) {
+				mapif_guild_created(fd,account_id,NULL);
+				return 0;
+			}
+	} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) != NULL) {
+				mapif_guild_created(fd,account_id,NULL);
+				return 0;
+			}
+	}
+
 	g = (struct guild *) aCalloc(sizeof(struct guild), 1);
 	if (g == NULL) {
 		ShowFatalError("int_guild: CreateGuild: out of memory !\n");

+ 16 - 0
src/char/int_party.c

@@ -430,6 +430,22 @@ int mapif_parse_CreateParty(int fd, int account_id, int char_id, char *name, cha
 		mapif_party_created(fd, account_id, char_id, NULL);
 		return 0;
 	}
+
+	// Check Authorised letters/symbols in the name of the character
+	if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) == NULL) {
+				mapif_party_created(fd, account_id, char_id, NULL);
+				return 0;
+			}
+	} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) != NULL) {
+				mapif_party_created(fd, account_id, char_id, NULL);
+				return 0;
+			}
+	}
+
 	p = (struct party *) aCalloc(sizeof(struct party), 1);
 	if (p == NULL) {
 		ShowFatalError("int_party: out of memory !\n");

+ 2 - 0
src/char_sql/char.h

@@ -59,6 +59,8 @@ int char_child(int parent_id, int child_id);
 int request_accreg2(int account_id, int char_id);
 int save_accreg2(unsigned char* buf, int len);
 
+extern int char_name_option;
+extern char char_name_letters[];
 extern bool char_gm_read;
 extern int autosave_interval;
 extern int save_log;

+ 15 - 0
src/char_sql/int_guild.c

@@ -1185,6 +1185,21 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
 		mapif_guild_created(fd,account_id,NULL);
 		return 0;
 	}
+	// Check Authorised letters/symbols in the name of the character
+	if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) == NULL) {
+				mapif_guild_created(fd,account_id,NULL);
+				return 0;
+			}
+	} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) != NULL) {
+				mapif_guild_created(fd,account_id,NULL);
+				return 0;
+			}
+	}
+
 	g = (struct guild *)aMalloc(sizeof(struct guild));
 	memset(g,0,sizeof(struct guild));
 

+ 15 - 0
src/char_sql/int_party.c

@@ -499,6 +499,21 @@ int mapif_parse_CreateParty(int fd, int account_id, int char_id, char *name, cha
 		mapif_party_created(fd,account_id,char_id,NULL);
 		return 0;
 	}
+	// Check Authorised letters/symbols in the name of the character
+	if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) == NULL) {
+				mapif_party_created(fd,account_id,char_id,NULL);
+				return 0;
+			}
+	} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
+		for (i = 0; i < NAME_LENGTH && name[i]; i++)
+			if (strchr(char_name_letters, name[i]) != NULL) {
+				mapif_party_created(fd,account_id,char_id,NULL);
+				return 0;
+			}
+	}
+
 	p= aCalloc(1, sizeof(struct party));
 	
 	memcpy(p->name,name,NAME_LENGTH);