Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Google, Bing, Yahoo!

Members: 0
Guests: 11
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » First game breaking error
Forum Rules | Mark all | Recent Posts

First game breaking error
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Apr 12, 2012, 9:31 pm
Go to the top of the page
Go to the bottom of the page

Disgaeamud
Fledgling
GroupMembers
Posts23
JoinedApr 11, 2012

Well tonight I got adventurous and I wanted to try and mess with the combat.

I changed this code.

 /*
    * The moment of excitement!
    */
   while( ( diceroll = number_bits( 5 ) ) >= 20 )
      ;

  /*  if( diceroll == 0 || ( diceroll != 19 && diceroll < thac0 - victim_ac ) ) commented out in case I needed to add it back in  */
      if ((ch->level + wield->value[2]) != (victim->perm_dex + victim_ac + victim->level) )

      /*
       * Miss.
       */
      if( prof_gsn != -1 )
         learn_from_failure( ch, prof_gsn );
      damage( ch, victim, 0, dt );
      tail_chain(  );
      return rNONE;


It compiles fine and everything but when one attacks the mud crashes. I went into GDB and typed list and this is what came up X_X

Reading symbols from /home/dmud/smaugfuss19/src/smaug...done.
/home/dmud/smaugfuss19/src/core.20893: No such file or directory.
(gdb) list
388 }  /* cleanup memory */
389
390 #ifdef WIN32
391 int mainthread( int argc, char **argv )
392 #else
393 int main( int argc, char **argv )
394 #endif
395 {
396    struct timeval now_time;
397    bool fCopyOver = FALSE;
(gdb)


I'm kind of confused as seeing how this isn't even the same code I messed with and it hotboots up just fine...

Any advice, I'd love to learn from my mistake and know what I did so I don't do it again!
       
Post is unread #2 Apr 13, 2012, 1:07 am
Go to the top of the page
Go to the bottom of the page

Disgaeamud
Fledgling
GroupMembers
Posts23
JoinedApr 11, 2012

Okay after doing some C tutorials I noticed It has to be an endless loop. I just wanted to change combat just to do it. I'm not sure how I would write the code to resemble what I have down already and keep the loop from not going bananas...
       
Post is unread #3 Apr 13, 2012, 8:19 am
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Use bt (backtrace) in gdb for a look at how things were stepped through. This should give you a line number of where the problem was.
       
Post is unread #4 Apr 13, 2012, 2:56 pm   Last edited Apr 13, 2012, 2:56 pm by Remcon
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

   if( diceroll == 0 || ( diceroll != 19 && diceroll < thac0 - victim_ac ) )
   {
      /*
       * Miss. 
       */
      if( prof_gsn != -1 )
         learn_from_failure( ch, prof_gsn );
      damage( ch, victim, 0, dt );
      tail_chain(  );
      return rNONE;
   }

I assume this is the part your speaking of. I don't see the { after the if check your using and after the return though which will likely cause some issues. This part of the code isn't a loop of any kind so it won't cause a loop. My guess is that the wield->value[2] is causing the issue so change it to this
if( ( ch->level + ( wield ? wield->value[2] : 0 ) ) != ( victim->perm_dex + victim_ac + victim->level ) )

You do know that though this is going to make it miss unless the first part is equal to the second part right? meaning there will be a whole lot more missing then hitting most the time.
       
Post is unread #5 Apr 13, 2012, 11:09 pm
Go to the top of the page
Go to the bottom of the page

Disgaeamud
Fledgling
GroupMembers
Posts23
JoinedApr 11, 2012

Awesome that did the trick and I got to learn a little bit about the ? operator :D Is there any reason it was crashing like that? Like the technical reason so I can avoid something like that in the future?

The value 2 of the weapon is going to be the weapons hit, which in Disgaea can get into some huge numbers. I noticed that if I set it over anything 1000 the stat craps out and everything ends up being a miss. I'm not sure where I could go in the code to look at it to find the value so that I can alter it to accept higher numbers. Also I need to throw in some kind of randomness so there is a fair mix of numbers? I guess I could number range out the characters levels to make it randomish...

Thanks again guys you are awesome!
       
Post is unread #6 Apr 14, 2012, 6:15 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005


Awesome that did the trick and I got to learn a little bit about the ? operator :D Is there any reason it was crashing like that? Like the technical reason so I can avoid something like that in the future?

The reason it was crashing is sometimes wield is able to be NULL and trying to access wield->value[2] when wield is NULL will cause a crash.


The value 2 of the weapon is going to be the weapons hit, which in Disgaea can get into some huge numbers. I noticed that if I set it over anything 1000 the stat craps out and everything ends up being a miss. I'm not sure where I could go in the code to look at it to find the value so that I can alter it to accept higher numbers. Also I need to throw in some kind of randomness so there is a fair mix of numbers? I guess I could number range out the characters levels to make it randomish...

Well it depends on what it uses on how big the numbers can get. You also have to take into consideration if your doing math with the numbers that the math being done could make the numbers roll over (max out) and cause it to have issues. On most where huge numbers will be used they use a double for the numbers. That can be a fairly massive change depending on how all the parts to the numbers are used.
       
Post is unread #7 Apr 14, 2012, 8:19 pm
Go to the top of the page
Go to the bottom of the page

Disgaeamud
Fledgling
GroupMembers
Posts23
JoinedApr 11, 2012

The numbers can go up into the billions and the max level is 9999 you can also "store" your levels and revert back to level one. You can store around 186,000 levels.

If you never played the game check it out :D It's really great and it has yet to be MUD-ified. I really hope I can do this for Disgaeas sake!
       
Post is unread #8 Apr 15, 2012, 8:07 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

Again depends on what is used, short only handles so big of a number and next higher one is int etc... Doubles can handle some large numbers
       
Pages:<< prev 1 next >>