diff --git a/code/defines/procs/helpers.dm b/code/defines/procs/helpers.dm
index fa32abb74a4..feccba947d1 100644
--- a/code/defines/procs/helpers.dm
+++ b/code/defines/procs/helpers.dm
@@ -146,7 +146,7 @@
//removes doublespaces and double apostrophes
//lowercases everything and capitalises the first letter of each word (or characters following an apostrophe)
//prevents names which are too short, have too many space, or not enough normal letters
-/proc/reject_bad_name(var/t_in, var/allow_numbers=0, var/max_length=MAX_NAME_LEN)
+/proc/reject_bad_name(var/t_in, var/minimum_words=2, var/allow_numbers=0, var/max_length=MAX_NAME_LEN)
if(length(t_in) > max_length) return //name too long
var/number_of_alphanumeric = 0
var/number_of_spaces = 0
@@ -187,7 +187,7 @@
return
if(last_char_group == 3) number_of_spaces--
if(number_of_alphanumeric < 4) return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '"
- if(number_of_spaces > 4 || number_of_spaces < 1) return //protects against single-word names like "Unknown" and names like "I ' M A D E R P Spaces Lul"
+ if(number_of_spaces > 4 || number_of_spaces < minimum_words-1) return //protects against single-word names like "Unknown" and names like "I ' M A D E R P Spaces Lul"
return t_out
/proc/strip_html_simple(var/t,var/limit=MAX_MESSAGE_LEN)
@@ -733,22 +733,29 @@ Turf and target are seperate in case you want to teleport some distance from a t
/proc/ainame(var/mob/M as mob)
var/randomname = M.name
var/time_passed = world.time//Pretty basic but it'll do. It's still possible to bypass this by return ainame().
- var/newname = copytext(sanitize(input(M,"You are the AI. Would you like to change your name to something else?", "Name change",randomname)),1,MAX_NAME_LEN)
- if((world.time-time_passed)>200)//If more than 20 game seconds passed.
+
+ var/newname
+ var/iterations = 0
+ while(!newname)
+ switch(iterations)
+ if(0)
+ if(1 to 5) M << "Invalid name. Your name should be at least 4 alphanumeric characters but under [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, 0-9, -, ' and ."
+ else break
+ newname = reject_bad_name(input(M,"You are the AI. Would you like to change your name to something else?", "Name change",randomname),1,1)
+ iterations++
+
+ if((world.time-time_passed)>300)//If more than 20 game seconds passed.
M << "You took too long to decide. Default name selected."
return
- if (!newname)
- newname = randomname
-
- else
- if (newname == "Inactive AI")//Keeping this here to prevent dumb.
+ if(newname)
+ if( newname == "Inactive AI" || findtext(newname,"cyborg") ) //To prevent common meta-gaming name-choices
M << "That name is reserved."
- return ainame(M)
+ return
for (var/mob/living/silicon/ai/A in world)
- if (A.real_name == newname&&newname!=randomname)
+ if (A.real_name == newname && newname!=randomname)
M << "There's already an AI with that name."
- return ainame(M)
+ return
M.real_name = newname
M.name = newname
M.original_name = newname
diff --git a/code/modules/mob/new_player/preferences.dm b/code/modules/mob/new_player/preferences.dm
index 04abe6e2308..3ad87a1dc7b 100644
--- a/code/modules/mob/new_player/preferences.dm
+++ b/code/modules/mob/new_player/preferences.dm
@@ -445,7 +445,7 @@ datum/preferences
switch(link_tags["real_name"])
if("input")
- new_name = reject_bad_name( input(user, "Please select a name:", "Character Generation") as text|null )
+ new_name = reject_bad_name( input(user, "Please select a name:", "Character Generation") as text|null, 2 )
if("random")
randomize_name()
@@ -453,7 +453,7 @@ datum/preferences
if(new_name)
real_name = new_name
else
- user << "Invalid name. Your name should be at least ten letters and two words. It should be under [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and ."
+ user << "Invalid name. Your name should be at least 4 letters and two words but it should be under [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and ."
if(link_tags["age"])
switch(link_tags["age"])