Well, what I can see is that your are passing an obj into a function that is
returning a new obj for all practical purposes.

The function should be a 'void' and use the obj that is passed and return
nothing.

Also, if you are changing the short_descr of the obj, make sure that you
'free_string( obj->short_descr )' first to make sure that you don't have
goofy memory problems.

- Valnir

----- Original Message ----- 
From: "Cyhawk" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, March 04, 2004 5:05 AM
Subject: Function causing Loop


> Hello all, i have a small question.. I found a bug in a OBJ_DATA function
i
> wrote for my item generator. It seems, whenever this function is called,
> it causes a loop. (sometimes later though.. its very odd, inside the shop
> generator, the mud loops on startup, but no errors, when i use a function
> that calls on it, it works.. but anytime i try to save_char it loops,
> copyover/save/quit) and im wondering.. What logic error am i missing?
> (while writing this.. i thought about something and re-wrote the function
> and it ended up working flawlessly.. though still... what mistake did
> i do here?)
> The function is below
>
> As always, help is much appreciated =)
>
> -Thri
>
> OBJ_DATA * weapon_plus_five (OBJ_DATA * obj)
> {
> AFFECT_DATA *af = new_affect ();
> char prefix_full[MSL];
>
>
> sprintf (prefix_full, "(+5) %s", obj->short_descr);
> obj->short_descr = str_dup (prefix_full);
>
> af->location = APPLY_HITROLL;
> af->modifier = 5;
> af->where = TO_OBJECT;
> af->type = 10;
> af->duration = -1;
> af->bitvector = 0;
> af->level = 1;
> af->next = obj->affected;
> obj->affected = af;
>
> af->location = APPLY_HITROLL;
> af->next = obj->affected;
> obj->affected = af;
>
> obj->cost += 15000;
> return (obj);
> }
>
>
>
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>


Reply via email to