-
Code:
if(head == 0)
{
head->name = name;
head->value = value;
head->locked = lock;
return;
}
Code:
if(head == 0)
{
head = new rCVar;
head->name = name;
head->value = value;
head->locked = lock;
return;
}
You could make a constructor for your struct/class to make it easier;
Code:
if(head == 0)
{
head = new rCVar(name, value, lock);
return;
}
-
Ok I updated it, after thinking it over last night. Found a few extra stuff that wasn't needed.
Code:
//setNew: Sets a new cvar if an existing one of the same
// name doesn't exist.
void rCVarEngine::set(const char *name, const char *value,bool lock)
{
// If we don't have a cvar in our head
// then set it
if(head == 0)
{
head = new rCVar(name,value,lock);
return;
}
// If our current cvarList value hasn't been set
// then set it...yo
else if(cvarList == 0)
{
cvarList = new rCVar(name,value,lock);
head->next = cvarList;
return;
}
while(cvarList)
{
// If we found an existing CVar
// then set its value and lock
// mode
if(strcmp(cvarList->name, name))
{
cvarList->value = value;
cvarList->locked = lock;
return;
}
// Else if the next in the list is empty
// Set its new values
else if(cvarList->next == 0)
{
// Add it to the end
cvarList->next = new rCVar(name,value,lock);
return;
}
// If we havn't found the end of the
// list or if we havn't found a pre-
// existing cvar, then move to the
// next in the list
else
{
cvarList = cvarList->next;
}
}
}
But it still crashes.
Code:
struct rCVar
{
const char *name;
const char *value;
bool locked;
rCVar *next;
// Constructor
rCVar(const char *cName, const char *cValue, bool cLock)
{
name = cName;
value = cValue;
locked = cLock;
next = 0;
}
};