[CODE] SSE Guns and Ammo Bug

From: Tristan Haynes (natsirt86@yahoo.com)
Date: 10/17/02


I'm currently writing some new code to implement a better fireweapon/missile code for more futuristic MUD's. Instead of using the object values of the fireweapon to store how much ammo is currently loaded into it, the fireweapons will act as a sort of "container" so it actually stores the ammo into the weapon. This allows you to load/unload your weapon, and use the values of the ammo whenever needed. I have a bug with loading/unloading the ammo into weapon though. I don't have any experience with storing items into objects, and the code is extracting the completely wrong item from the weapon when I go to unload the ammo from it. Here is how I am loading/unloading the ammo into the weapon.

  ammo = get_obj_in_list_vis(ch, arg1, NULL, ch->carrying);
  weapon = get_obj_in_list_vis(ch, arg2, NULL, ch->carrying);
  obj_from_char(ammo);
  obj_to_obj(ammo, weapon);

That is the code that handles loading the ammo into the gun, next is the code for unloading.

  weapon = get_obj_in_list_vis(ch, arg, NULL, ch->carrying);
  ammo = weapon->next;
  obj_from_obj(ammo);
  obj_to_char(ammo, ch);

Here is an example of the bug, the object it unloads is random though, not always being a corpse, sometimes a fountain, another weapon...etc...

<Room#26514> reload ammo gun
You load test ammo into a test gun.

<Room#26514> unload gun
You unload the corpse of a slimy blob from a test gun.

If anyone could help me figure out a solution to this problem it would be greatly appreciated, I plan to create a snippet of this code when done so that other can download it from the circlemud ftp.



---------------------------------
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos, & more
faith.yahoo.com

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT