ctd help


Questions, Explanations, Howtos

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Tuesday, 26th February 2013, 01:57

ctd help

My modded game crashes to desktop for unknown reasons.
Is there some way to get an error log?

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Tuesday, 26th February 2013, 02:40

Re: ctd help

Crash logs are created in the morgue folder, but you won't get a stack trace on Windows, so they probably won't be much help. If your crash continues after a make clean and full recompile, you can also try clearing out your des cache. (Delete all files in your saves/des folder)

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Tuesday, 26th February 2013, 23:30

Re: ctd help

That didn't work. I think it might be a problem with my code.
  Code:
            case SP_MUMMY:
                if (you.experience_level == 13 || you.experience_level == 26)
                {
                    mpr("You feel more in touch with the powers of death.",
                        MSGCH_INTRINSIC_GAIN);
                }
      
      if (you.experience_level == mummyspacing*journal){
       
      if (journal == 1){mpr("Allthough much has been lost to the sands of time you still see glimpses of a fleeting past.",
                        MSGCH_INTRINSIC_GAIN);mummyskills();journal = journal + 1;

}
      else if (journal == 2){mpr("You begin to remember more of your hidden past, regaining skills once thought lost.",
                        MSGCH_INTRINSIC_GAIN);mummyskills();journal = journal + 1;}
      else if (journal == 3){mpr("Through flashes and short glimpses, you now know secrets lost to the ages.",
                        MSGCH_INTRINSIC_GAIN);mummyskills();journal = journal + 1;}
      else if (journal == 4){mpr("The ghosts of amnesia are no match for your vast intellect. You know who you are. More importantly, you know who you were.",
                        MSGCH_INTRINSIC_GAIN);mummyskills();journal = journal + 1;}
      else if (journal < 7){mpr("Allthough you allready remember your past, you still gain a flash of insight on your road to ultimate power.",
                        MSGCH_INTRINSIC_GAIN);mummyskills();journal = journal + 1;}
      

}


                if (you.experience_level == 13)  // level 13 for now -- bwr
                {
                    mpr("You can now infuse your body with magic to restore "
                        "decomposition.", MSGCH_INTRINSIC_GAIN);
                }
                break;

And here's the function it's calling:
  Code:
static void mummyskills(){
    int totalweight = 0;

      int c = random2(10) + 1;
    skill_type result = SK_NONE;
    for (int i = SK_FIRST_SKILL; i < NUM_SKILLS; ++i)
    {
        skill_type s = static_cast<skill_type>(i);
        if (skill_name(s) == NULL || is_useless_skill(s))
            continue;

        if (you.skills[s] < MAX_SKILL_LEVEL)
        {
            // Choosing a skill is likelier if you are somewhat skilled in it.
            const int curweight = 1 + you.skills[s] * (40 - you.skills[s]) * c;
            totalweight += curweight;
            if (x_chance_in_y(curweight, totalweight))
                result = s;
        }
    }
   if (you.skills[result] + 4 < 28){
you.skills[result] = you.skills[result] +4;
}
else{
you.skills[result] = 27;
}
   
}

Any clue as to what the problem is?

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 27th February 2013, 01:15

Re: ctd help

Are you sure you're showing all the code you've changed? It would also help if we could see where in what files those changes are. (This will be easier if you properly generate a patch file from git)

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Wednesday, 27th February 2013, 10:58

Re: ctd help

This is the only changed file. It's in player.cc
There's also a declaration for journal and spacing at the start that sets them to 1 and 3 respectively.

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 27th February 2013, 11:44

Re: ctd help

Ok can you provide more information on the crash, does it happen at specific points, e.g. when your character is gaining experience? Is it when the game starts? You're not providing enough info for anyone to help really. (Although one guess might be that result could still equal SK_NONE at the end of the loop in mummyskills...)

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Wednesday, 27th February 2013, 16:09

Re: ctd help

It happens every time I reach the level specifified in mummyspacing. Furthermore, when mummyspacing is set to 0, there is no crash. That's all I know.

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Wednesday, 27th February 2013, 17:51

Re: ctd help

Well, right away I can see that you're comparing skill levels to 28 instead of 27. It's doubtful that you're raising a skill past 27 the first time you reach your mummy threshold, but it's something you'll want to fix.

Edit: Rather, you should be comparing you.skills[result] + 4 to MAX_SKILL_LEVEL

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Wednesday, 27th February 2013, 18:44

Re: ctd help

Also try starting Crawl from the command line, that way you will see any messages it writes after the crash (this may or may not help).

Ziggurat Zagger

Posts: 3163

Joined: Friday, 6th January 2012, 18:45

Post Wednesday, 27th February 2013, 19:16

Re: ctd help

I tried out your code. The crash message is:
  Code:
ASSERT(prog >= 0) in 'skills2.cc' at line 154 failed.


Skill levels are tied to the amount of skill points (xp, basically) devoted to them. If you raise a skill level without raising the amount of skill points, your skill progress to reach the next level becomes negative. I think you need to change your implementation to increase skills differently. You might want to look into how a potion of experience increases skills.

For this message the author BlackSheep has received thanks:
khalil

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Wednesday, 27th February 2013, 22:01

Re: ctd help

Thank you.

Spider Stomper

Posts: 243

Joined: Sunday, 28th August 2011, 14:04

Post Wednesday, 27th February 2013, 22:21

Re: ctd help

I have seen three mistakes in your code:

1) The value stored in journal is not saved. The best solution is to remove that variable and mummyspacing. Do something like this:

  Code:
switch(you.experience_level) {
  case 4:
  ...
  break;
  case 8:
  ...
  break;
...
}


2) You should increment your skills using the function set_skill_level which can be found in skills.cc. In wiz-you.cc, there is a good example which shows how to call this function.

3) As mumra said, result can be SK_NONE after leaving the for loop.

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Wednesday, 27th February 2013, 23:39

Re: ctd help

And thank you to you too! I've got it working now.

Dungeon Master

Posts: 1531

Joined: Saturday, 5th March 2011, 06:29

Post Thursday, 28th February 2013, 00:10

Re: ctd help

CommanderC wrote:3) As mumra said, result can be SK_NONE after leaving the for loop.


Actually I was wrong about this; the first call to x_chance_in_y will always be a 100% chance so you'll at least get SK_FIRST_SKILL (there are similar weighted selection loops elsewhere in the code and I assume it was copied from those examples).

Tomb Titivator

Posts: 799

Joined: Saturday, 23rd February 2013, 22:25

Post Thursday, 28th February 2013, 01:55

Re: ctd help

Yeah, this is based off the sage code.
Either way, it defaults to spellcasting now.

Return to Coding

Who is online

Users browsing this forum: No registered users and 6 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.