User Name:


Forgot your password?
Vote for Us!
Nov 28, 2018, 10:10 am
By Keirath
First Immortal
Oct 12, 2018, 12:02 pm
By GatewaySysop
Bug in do_climb( )
Jun 5, 2018, 5:31 pm
By joeyfogas
question on overland code
May 31, 2018, 10:03 am
By joeyfogas
KaVir's Protocol Snip
May 15, 2018, 7:57 pm
By joeyfogas
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Bing, Sogou

Members: 0
Guests: 12
Newest Member
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SWR FUSS Bugfix List » [Bug] Spell dice forumlas ret...
Forum Rules | Mark all | Recent Posts

[Bug] Spell dice forumlas return incorrect results when parsed
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 12, 2005, 6:19 pm
Go to the top of the page
Go to the bottom of the page

Black Hand
JoinedJan 1, 2002

Bug: Spell dice forumlas return incorrect results when parsed. Damage caps do not work.
Danger: Medium - Returns values outside expected ranges, making some spells far too powerful.
Found by: Too many people to count
Fixed by: Remcon


magic.c, rd_parse

    * get rid of brackets if they surround the entire expresion
   if( ( *texp == '(' ) && !index( texp + 1, '(' ) && texp[strlen( texp ) - 1] == ')' )
      texp[strlen( texp ) - 1] = '\0';

Change to:
    * get rid of brackets if they surround the entire expresion
   if( ( *texp == '(' ) && texp[strlen( texp ) - 1] == ')' )
      texp[strlen( texp ) - 1] = '\0';

At the root of a number of problems in spell/skill dice formulas is the rd_parse function. What it does is take a spell formula, parse the variables, and return a value within the range specified by that formula. Something similar to this:

ld6+(l/2) { 500

A seemingly simple formula, it takes the caster's level, rolls it as that many 6 sided dice. The value of that is then added to half of the caster's level. The left brace indicates this formula wants a cap, and the cap is set to 500, so the most this spell should do in damage is 500 points. The bug in rd_parse would outright ignore any caps, minimums or maximums, so this spell in reality could have become quite devastating and thus provide a huge advantage to the classes that could cast it. Once fixed, the formula does need to be rewritten in proper syntax to acheive the desired result, and should now look like:

(ld6+(l/2)) { 500

Notice that the expression on the left side of the brace is entirely surrounded in parentheses. If this is not done then the cap would only apply to the expression closest to it on the right of an operator, such as +, -, * or /

This bug has been long-standing, very persistant, and dozens of coders have attempted in some way or another to fix it. Often with comically large 100-200+ line rewrites of various portions and whole new wrapper functions around those. Our own coding staff on Alsherok spent months trying to fix this, and it became so frustrating we began jokingly referring to it as "The function whose name shall not be spoken". It was basically treated as evil incarnate. A cancer upon the code. It has quite a history behind it. How ironic that the fix for it would literally be a single line, and only a portion of that single line.
Pages:<< prev 1 next >>