Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2011
    Location
    Romania, Bucharest
    Posts
    5

    EvilMonkeys crashed after I shoot one of the enemies

    If someone can help me I would appreciate very much.

    After I finished coding the EvilMonkeys game, I debug it, and there I got a fatal error “Debug Assertion” Failed ! > Expression list iterator not decrementable” (please see screenshot file for further details).
    And I only get an attention (or warning) message in the error list:
    1>------ Build started: Project: evilMonkeys, Configuration: Debug Win32 ------
    1> game.cpp
    1>d:\diverse\lucru\visual studio 2010\projects\evilmonkeys\evilmonkeys\game.cpp(19) : warning C4309: 'argument' : truncation of constant value
    1> evilMonkeys.vcxproj -> D:\Diverse\Lucru\visual studio 2010\Projects\evilMonkeys\Debug\evilMonkeys.exe
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

    The warning C4309 gives me the following line of code in the "game.cpp" file:
    drawArea.createBackgroundTile(TILE_WALL, 219);


    And with the help I get this message:

    Compiler Warning (level 2) C4309
    Visual Studio 2010
    'conversion' : truncation of constant value
    The type conversion causes a constant to exceed the space allocated for it. You may need to use a larger type for the constant.
    The following sample generates C4309:
    // C4309.cpp
    // compile with: /W2
    int main()
    {
    char c = 128; // C4309
    }



    I understand something from this error, because conversion causes a constant to exceed the space allocated for it, but I don’t know how to fix it and I am afraid if I go and try to correct something, I will mess up the code even worse.

    It doesn't matter when I shoot the one that gives the error and crash. It will crash when I shoot the fireball in to it, regardless if it dies first or after the other two enemies. And the other two are working normal, I can kill them and the game works fine, but with this one I get this annoying crash. I think it is something with the memory.

    If more info is need it, please, just let me know and I will update the thread. The code is exactly like in the EvilMonkeys Tutorial, nothing is changed.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	ferror.jpg 
Views:	73 
Size:	257.9 KB 
ID:	72556  
    Last edited by GCosmin; 03-19-2012 at 08:16 AM.

  2. #2
    Join Date
    Mar 2011
    Posts
    9
    Did u read this? I don't remember but i had the same problem and fixed with this. Good luck, hope this work for u 2.

    http://www.3dbuzz.com/vbforum/showthread.php?122895-The-Thread-of-Information


  3. #3
    Join Date
    Aug 2011
    Location
    Romania, Bucharest
    Posts
    5
    Thanks mate, I'll see what I can do, but I appreciate your help.

  4. #4
    Join Date
    Aug 2011
    Location
    Romania, Bucharest
    Posts
    5
    @phantom23
    Ok, the link you gave me, helped me a lot. So before I say more, thank you very much phantom for your help.
    So for anyone who’s having this problem (details about the warning can be seen above, but I give some details again) here is the solution:
    a) - The warning message wich if ignored your game will run but it will crash when you kill the specific enemy:
    1>------ Build started: Project: evilMonkeys, Configuration: Debug Win32 ------
    1> game.cpp
    1>d:\diverse\lucru\visual studio 2010\projects\evilmonkeys\evilmonkeys\game.cpp(19) : warning C4309: 'argument' : truncation of constant value
    1> evilMonkeys.vcxproj -> D:\Diverse\Lucru\visual studio 2010\Projects\evilMonkeys\Debug\evilMonkeys.exe
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

    b) The given region of the code, were the warning occurs, is found in the file “game.cpp”:
    bool Game::run(void)
    {
    level = new Level(&drawArea, 30, 20);

    drawArea.createBackgroundTile(TILE_EMPTY, ' ');
    drawArea.createBackgroundTile(TILE_WALL, 219); /*this line starts the warning and gives link to a few more down in the code*/

    drawArea.createSprite(SPRITE_PLAYER, 1);
    drawArea.createSprite(SPRITE_ENEMY, '$');
    drawArea.createSprite(SPRITE_FIREBALL, '*');

    player = new Mage(level, &drawArea, 0);

    level->draw();
    level->addPlayer(player);
    level->addEnemies(3);

    C) Go in the file “level.cpp”:
    - find the original code from VTM 3, wich is:
    /*
    void Level::update(void)
    {
    for(Iter = npc.begin(); Iter != npc.end(); Iter++)
    {
    (*Iter)->idleUpdate();

    if ((*Iter)->isAlive() == false)
    {
    Sprite *temp = *Iter;

    Iter--;
    delete temp;
    npc.remove(temp);
    }
    }
    }
    */

    Whit this one:
    /*
    void Level::update()
    {
    for(Iter = npc.begin(); Iter != npc.end()
    {
    (*Iter)->idleUpdate();

    if((*Iter)->isAlive() == false)
    {
    Sprite *temp = *Iter;

    delete temp;
    Iter = npc.erase(Iter);
    }
    else
    Iter++;
    }
    }
    */

    This fixed my problem and now the little EvilMonkeys game is working fine, just as it should.

    If still this will not fix your problem then go to this link and search carefully for what you need and what might fix your issue:
    http://www.3dbuzz.com/vbforum/showth...of-Information

    GOOD LUCK !
    Last edited by GCosmin; 03-19-2012 at 01:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •