ID:148606
 
I'm getting some really weird in-game problems with my login/char saving code. Here is my code:

#if !defined(SUPER_NEW)
#define SUPER_NEW "New"
#endif
#if !defined(SUPER_LOAD)
#define SUPER_LOAD "Load"
#endif
#if !defined(SUPER_QUIT)
#define SUPER_QUIT "Quit"
#endif

var/list/HTML_TAGS = list ("<",">")
mob/proc/Check_For_Tags(T as text,var/list/L)
for(var/V in L)
if(findtext(T,V))
return TRUE

client
proc
Load()
var/savefile/load
load = new ("Save Files/[src.mob.ckey]")
load["mob"] >> src.mob
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z
Save()
var/savefile/save
save = new ("Save Files/[src.mob.ckey]")
save["mob"] << src.mob
save["x"] << src.mob.x
save["y"] << src.mob.y
save["z"] << src.mob.z
New()
..()
world << "[mob] has entered."
Del()
world << "[mob] has left."
src.mob.client.Save()
del src.mob


mob/player
Login()
var/list/L = newlist()
if(fexists("Save Files/[src.client.ckey]"))
L.Add(SUPER_NEW,SUPER_LOAD,SUPER_QUIT)
var/menu = input("Character File Found.","[world.name]") in L
switch(menu)
if(SUPER_NEW)
Create()
if(SUPER_LOAD)
src.client.Load()
if(SUPER_QUIT)
del(src)
else
L.Add(SUPER_NEW,SUPER_QUIT)
var/newmenu = input("Character File Not Found.","[world.name], \"New Player\"") in L
switch(newmenu)
if(SUPER_NEW)
Create()
if(SUPER_QUIT)
del(src)
..()
proc
Create()
var/mob/mobcreation
var/newname = input("What is your name?","Name",src.key)
if(lentext(src.name) > 20)
src << "Your name can not exceed 20 characters."
Create()
if(isnull(newname) | newname == "" | !newname)
src << "Your name may not be nothing."
Create()
if(Check_For_Tags(newname,HTML_TAGS) == TRUE)
src << "Your name may not have html tags in your name."
Create()

else
newname = html_encode(newname)
var/c = input("Choose a class.") in list("Warrior", "Mage", "Cleric", "Ranger", "Theif")
switch(c)
if("Warrior")
var/k = input("Choose a complextion.") in list("Pale", "Tan", "Dark")
switch(k)
if("Pale")
var/h = input("Choose a hair color.") in list("Blonde", "Brown", "Black")
switch(h)
if("Blonde")
usr.overlays += /obj/overlay/hair1
world << "[usr] has entered the world."
icon = 'player.dmi'
icon_state = "1"
usr.hair = 1
Move(locate(/area/start))
if("Brown")
usr.overlays += /obj/overlay/hair2
world << "[usr] has entered the world."
icon = 'player.dmi'
icon_state = "1"
usr.hair = 2
Move(locate(/area/start))
if("Black")
usr.overlays += /obj/overlay/hair3
world << "[usr] has entered the world."
icon = 'player.dmi'
icon_state = "1"
usr.hair = 3
Move(locate(/area/start))
mobcreation.name = newname
src.client.mob = mobcreation
del(src)

The problem I'm having is that you can't change your name. It asks you what you want your name to be, then it gives me an error message and makes your name the same as your byond key. This is the error message I get:

runtime error: Cannot modify null.name.
proc name: Create (/mob/player/proc/Create)
source file: Login2.dm,312
usr: SSTrunks7 (/mob/player)
src: SSTrunks7 (/mob/player)
call stack:
SSTrunks7 (/mob/player): Create()
SSTrunks7 (/mob/player): Login()

Also, when you load a character, it loads fine then the popup asking you to load or create a char pops up again. Please help me, i have absolutely no idea what to do. Thanks in advance.</<></<></<></<>
I know the error has something to do with the newname and name variables but have no idea how to fix it. Does anyone know?
"Cannot modify null.name" is the key. That should point, I believe, to this line:
mobcreation.name = newname
Which means mobcreation is null. Simple inspection of the code reveals that this mob was never created; the var is declared, but new() is never called:
var/mob/mobcreation
Since the mob wasn't created, the mobcreation var is null by default, and thus when you try to modify its vars you get an error.

Lummox JR