(svn r3192) Split the surname list into two lists (non-toyland/toyland) and use lengthof() to get the number of names instead of using magic numbers
This commit is contained in:
		
							
								
								
									
										38
									
								
								strings.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								strings.c
									
									
									
									
									
								
							@@ -793,7 +793,7 @@ static const char * const _silly_company_names[] = {
 | 
				
			|||||||
	"Lightning International",
 | 
						"Lightning International",
 | 
				
			||||||
	"Pannik & Loozit Ltd.",
 | 
						"Pannik & Loozit Ltd.",
 | 
				
			||||||
	"Inter-City Transport",
 | 
						"Inter-City Transport",
 | 
				
			||||||
	"Getout & Pushit Ltd.",
 | 
						"Getout & Pushit Ltd."
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char* const _surname_list[] = {
 | 
					static const char* const _surname_list[] = {
 | 
				
			||||||
@@ -825,7 +825,10 @@ static const char * const _surname_list[] = {
 | 
				
			|||||||
	"Quigley",
 | 
						"Quigley",
 | 
				
			||||||
	"Sharkey",
 | 
						"Sharkey",
 | 
				
			||||||
	"Thomson",
 | 
						"Thomson",
 | 
				
			||||||
	"Watkins",
 | 
						"Watkins"
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char* const _silly_surname_list[] = {
 | 
				
			||||||
	"Grumpy",
 | 
						"Grumpy",
 | 
				
			||||||
	"Dozy",
 | 
						"Dozy",
 | 
				
			||||||
	"Speedy",
 | 
						"Speedy",
 | 
				
			||||||
@@ -837,7 +840,7 @@ static const char * const _surname_list[] = {
 | 
				
			|||||||
	"Fishy",
 | 
						"Fishy",
 | 
				
			||||||
	"Swindle",
 | 
						"Swindle",
 | 
				
			||||||
	"Sneaky",
 | 
						"Sneaky",
 | 
				
			||||||
	"Nutkins",
 | 
						"Nutkins"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char _initial_name_letters[] = {
 | 
					static const char _initial_name_letters[] = {
 | 
				
			||||||
@@ -847,16 +850,18 @@ static const char _initial_name_letters[] = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static char *GenAndCoName(char *buff, uint32 arg)
 | 
					static char *GenAndCoName(char *buff, uint32 arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint base,num;
 | 
						const char* const* base;
 | 
				
			||||||
 | 
						uint num;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	base = 0;
 | 
					 | 
				
			||||||
	num = 29;
 | 
					 | 
				
			||||||
	if (_opt_ptr->landscape == LT_CANDY) {
 | 
						if (_opt_ptr->landscape == LT_CANDY) {
 | 
				
			||||||
		base = num;
 | 
							base = _silly_surname_list;
 | 
				
			||||||
		num = 12;
 | 
							num  = lengthof(_silly_surname_list);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							base = _surname_list;
 | 
				
			||||||
 | 
							num  = lengthof(_surname_list);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buff = strecpy(buff, _surname_list[base + (num * GB(arg, 16, 8) >> 8)], NULL);
 | 
						buff = strecpy(buff, base[num * GB(arg, 16, 8) >> 8], NULL);
 | 
				
			||||||
	buff = strecpy(buff, " & Co.", NULL);
 | 
						buff = strecpy(buff, " & Co.", NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return buff;
 | 
						return buff;
 | 
				
			||||||
@@ -864,7 +869,9 @@ static char *GenAndCoName(char *buff, uint32 arg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static char *GenPresidentName(char *buff, uint32 x)
 | 
					static char *GenPresidentName(char *buff, uint32 x)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint i, base, num;
 | 
						const char* const* base;
 | 
				
			||||||
 | 
						uint num;
 | 
				
			||||||
 | 
						uint i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buff[0] = _initial_name_letters[sizeof(_initial_name_letters) * GB(x, 0, 8) >> 8];
 | 
						buff[0] = _initial_name_letters[sizeof(_initial_name_letters) * GB(x, 0, 8) >> 8];
 | 
				
			||||||
	buff[1] = '.';
 | 
						buff[1] = '.';
 | 
				
			||||||
@@ -879,14 +886,15 @@ static char *GenPresidentName(char *buff, uint32 x)
 | 
				
			|||||||
		buff += 3;
 | 
							buff += 3;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	base = 0;
 | 
					 | 
				
			||||||
	num = 29;
 | 
					 | 
				
			||||||
	if (_opt_ptr->landscape == LT_CANDY) {
 | 
						if (_opt_ptr->landscape == LT_CANDY) {
 | 
				
			||||||
		base = num;
 | 
							base = _silly_surname_list;
 | 
				
			||||||
		num = 12;
 | 
							num  = lengthof(_silly_surname_list);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							base = _surname_list;
 | 
				
			||||||
 | 
							num  = lengthof(_surname_list);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buff = strecpy(buff, _surname_list[base + (num * GB(x, 16, 8) >> 8)], NULL);
 | 
						buff = strecpy(buff, base[num * GB(x, 16, 8) >> 8], NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return buff;
 | 
						return buff;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user