Discussion:
Rom2.4b Cores on obj_to_char
(too old to reply)
Alex Tarsha
2004-03-07 01:34:37 UTC
Permalink
I have a heavily modified Rom2.4b mud im developing. I added a
function multi_obj_to_char(object, ch, number)
This will do obj_to_char 'number' times. I know the code is good
because if i replace the call for obj_to_char() in my code with
send_to_char() it works fine. However if I leave it obj_to_char, it
will do it, the correct amount of times but the MUD freezes after
completion. If I type anything as any character there is no response
and I have to manually restart the MUD. obj_to_char() has not been
modified, nor have the variables it uses. Any ideas what could cause
this?

Thanks
Thomas Arp
2004-03-07 10:55:09 UTC
Permalink
Post by Alex Tarsha
I have a heavily modified Rom2.4b mud im developing. I added a
How much is heavily, really ?
Post by Alex Tarsha
function multi_obj_to_char(object, ch, number)
This will do obj_to_char 'number' times. I know the code is good
because if i replace the call for obj_to_char() in my code with
send_to_char() it works fine. However if I leave it obj_to_char, it
will do it, the correct amount of times but the MUD freezes after
completion. If I type anything as any character there is no response
and I have to manually restart the MUD. obj_to_char() has not been
modified, nor have the variables it uses. Any ideas what could cause
this?
Well, for starters you're making an infinite loop:

obj_to_char:
void obj_to_char( OBJ_DATA *obj, CHAR_DATA *ch )
{
obj->next_content = ch->carrying;
ch->carrying = obj;
obj->carried_by = ch;
obj->in_room = NULL;
obj->in_obj = NULL;
ch->carry_number += get_obj_number( obj );
ch->carry_weight += get_obj_weight( obj );
}

called twice, you'll get obj->next_content == obj

Which will give you infinite loop problems on anything
that traverses the inventory (like typing 'inventory'..).

obj_to_char is a utility function to be called on objects
not otherwise assigned. If you wish to give more than one
object to a person, you must CREATE EACH ONE SPECIFICALLY
(is that loud enough for you). Simply calling obj_to_char
just sets some pointers.

If you don't know what you're doing, read what other parts
of the code does before calls to obj_to_char().

Welcor
Thomas Arp
2004-03-07 13:13:18 UTC
Permalink
Post by Thomas Arp
If you don't know what you're doing, read what other parts
of the code does before calls to obj_to_char().
Hmm.. That should probably have been phrased like this instead:

"If you don't know how to do it, read what other parts
of the code does before calls to obj_to_char()."


Welcor
Alex Tarsha
2004-03-07 17:46:18 UTC
Permalink
Post by Thomas Arp
Post by Alex Tarsha
I have a heavily modified Rom2.4b mud im developing. I added a
How much is heavily, really ?
Post by Alex Tarsha
function multi_obj_to_char(object, ch, number)
This will do obj_to_char 'number' times. I know the code is good
because if i replace the call for obj_to_char() in my code with
send_to_char() it works fine. However if I leave it obj_to_char, it
will do it, the correct amount of times but the MUD freezes after
completion. If I type anything as any character there is no response
and I have to manually restart the MUD. obj_to_char() has not been
modified, nor have the variables it uses. Any ideas what could cause
this?
void obj_to_char( OBJ_DATA *obj, CHAR_DATA *ch )
{
obj->next_content = ch->carrying;
ch->carrying = obj;
obj->carried_by = ch;
obj->in_room = NULL;
obj->in_obj = NULL;
ch->carry_number += get_obj_number( obj );
ch->carry_weight += get_obj_weight( obj );
}
called twice, you'll get obj->next_content == obj
Which will give you infinite loop problems on anything
that traverses the inventory (like typing 'inventory'..).
obj_to_char is a utility function to be called on objects
not otherwise assigned. If you wish to give more than one
object to a person, you must CREATE EACH ONE SPECIFICALLY
(is that loud enough for you). Simply calling obj_to_char
just sets some pointers.
If you don't know what you're doing, read what other parts
of the code does before calls to obj_to_char().
Welcor
Thanks for your help Welcor, I finally found the create_obj() function
and that solved the problem.

Loading...