Server Help

Bot Questions - _linkedlist.kill() function

tikiman - Wed Jan 29, 2003 4:36 pm
Post subject: _linkedlist.kill() function
Whenever I use this function I get either an assertion failure or Catid's command-crash bug error. The funny thing is I can use the append() function to add a node, then use a find() function and it will return the correct node. But if I try to kill() the same node within the same block of code I get errors. The code essentially looks like this:

Code: Show/Hide
captlist.append(name_ptr);
captlist.kill(name_ptr);


Where name_ptr is a String*. This is within a command definition in command.cpp of course. Anyone know whats going wrong here?
SOS - Wed Jan 29, 2003 11:39 pm
Post subject:
So the captlist is a _linkedlist<String*>? Hmm...
Well, I can't think of anything that can cause this :/
Did you run it through a debugger?
Anonymous - Thu Jan 30, 2003 5:54 pm
Post subject: linkedlist
_linkedlist <String> MyList;

MyList.append(new String("Hello"));

_listnode <String> *parse = MyList.head;

while (parse)
{
String *s = parse->item;

if (*s == "blah")
MyList.kill(parse);

parse = parse->next;
}

etc...
SOS - Fri Jan 31, 2003 1:03 am
Post subject:
Actually caid, that would crash, lol sa_tongue.gif
parse = parse->next; before the kill icon_smile.gif
tikiman - Sat Feb 01, 2003 4:58 pm
Post subject:
Thanks catid, I wouldn't have thought to put the (new String("Hello")) as a parameter to the append function:)

I actually ended up using <PlayerTag> instead and just copied some of your code to do the kill(). But the post you made would have worked as well.
Anonymous - Sat Feb 22, 2003 8:26 pm
Post subject: oops!
oops! Sorry =)
Anonymous - Mon Feb 24, 2003 2:44 pm
Post subject:
wouldn't that crash too?

I'd think you would have to do:

_listnode tempNode = parse->next;
MyList.kill(parse);
parse = tempNode;
Anonymous - Mon Feb 24, 2003 2:49 pm
Post subject:
err... and make sure you declare _listnode tempNode outside of the loop to prevent duplicate declarations of course.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group