Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex

Members: 0
Guests: 16
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
614
BenitoVirg
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Smaug Snippets » Archery Snippet Bug
Forum Rules | Mark all | Recent Posts

Archery Snippet Bug
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Dec 2, 2007, 7:01 pm   Last edited Dec 2, 2007, 7:28 pm by Kayle
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

In the archery snippet, the code references the damage type of the projectile in two places, and it should be checking the projectile type. The code in question is in archery.c - ch_ret ranged_got_target( CHAR_DATA * ch, CHAR_DATA * victim, OBJ_DATA * weapon, OBJ_DATA * projectile, short dist, short dt, char *stxt, short color )
   /*
    * check dam type of projectile to determine value of wtype 
    * * wtype points to same "short" as the skill assigned to that
    * * range by the code and as such the proper skill will be used. 
    * * Grimm 
    */
   switch ( projectile->value[3] )
   {
      case 13:
      case 14:
         wtype = gsn_archery;
         break;
      case 15:
         wtype = gsn_blowguns;
         break;
      case 16:
         wtype = gsn_slings;
         break;
   }


should become:

   /*
    * check dam type of projectile to determine value of wtype 
    * * wtype points to same "short" as the skill assigned to that
    * * range by the code and as such the proper skill will be used. 
    * * Grimm 
    */
   switch ( projectile->value[4] )
   {
      case PROJ_BOLT:
      case PROJ_ARROW:
         wtype = gsn_archery;
         break;
      case PROJ_DART:
         wtype = gsn_blowguns;
         break;
      case PROJ_STONE:
         wtype = gsn_slings;
         break;
   }


And further down,
      switch ( projectile->value[3] )
      {
         case 13:
         case 14:
            learn_from_failure( ch, gsn_archery );
            break;

         case 15:
            learn_from_failure( ch, gsn_blowguns );
            break;

         case 16:
            learn_from_failure( ch, gsn_slings );
            break;
      }


Should become:
      switch ( projectile->value[4] )
      {
         case PROJ_BOLT:
         case PROJ_ARROW:
            learn_from_failure( ch, gsn_archery );
            break;

         case PROJ_DART:
            learn_from_failure( ch, gsn_blowguns );
            break;

         case PROJ_STONE:
            learn_from_failure( ch, gsn_slings );
            break;
      }
       
Post is unread #2 Dec 2, 2007, 7:11 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Using hardcoded values is not recommended. The values from the projectile_types enum in mud.h should be used instead. In case they ever get shifted around for some reason.
       
Post is unread #3 Dec 2, 2007, 7:22 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Using symbolic names instead of values also greatly improves code readability. The value '14' holds no meaning unless you keep going to the list and figuring out what it is; but "TYPE_ARROW" actually tells you more about what's being done.
       
Post is unread #4 Dec 2, 2007, 7:25 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Updated original post accordingly.
       
Pages:<< prev 1 next >>