Thread: Cant edit my game anymore :(

  1. #1
    Codigious FingerPrint's Avatar
    Join Date
    Mar 2006
    Posts
    60

    Cant edit my game anymore :(

    I finished my first text based game not to long ago. The original copy worked just fine. As in, it compiled, ran, played and did everything it was supposed to do...just fine. Then I went through it making minor changes, fixing small bugs and such. It kept working fine for about 4 or 5 updates. Then, one time it just didn't work. I don't know why either. I have retyped it several times only to et the same result. When I run it I just get an "Error Report"(from windows) and it closes.

    I cant figure out what I did, or if its just my computer, that is messing it up. Basically, I would like to know if anyone can think of a reason that its not working, just off the top of your head. Below is the source file for it. So you can look it over if need be.
    Code:
    /* ------------------------------------------------------------------*/
                               // INSERT CODE HERE
    /* ------------------------------------------------------------------*/

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Which IDE do you use? The debugger will probably flag the error

  3. #3
    Codigious FingerPrint's Avatar
    Join Date
    Mar 2006
    Posts
    60
    I honestly dont know what an IDE is heh. But I just did a debug and noticed something I never noticed before. Apparently there was a little popup, I guess I didnt notice it because it came up behind the console. I just saw the bottom of it this time.

    The popup said "An Access Violation(Segmentation Fault) raised in your program."

    Does that help any?
    Code:
    /* ------------------------------------------------------------------*/
                               // INSERT CODE HERE
    /* ------------------------------------------------------------------*/

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    (I don't have a compiler right now so I can't help much)

    IDE: http://en.wikipedia.org/wiki/Integra...nt_environment
    Seg Fault: http://web.mit.edu/10.001/Web/Tips/t...mentation.html

    You know the error is somewhere close after intro(), did you check the area? Also the strcmp looks fishy

  5. #5
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    I compiled your game using visual studio and this is what it found:

    main.cpp(182): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data

    main.cpp(304): error C4716: 'getMonster' : must return a value

    main.cpp(343): error C4716: 'paintFight' : must return a value

    main.cpp(646): error C4716: 'vpaintFight' : must return a value

    main.cpp(651): warning C4101: 'vyes' : unreferenced local variable

    main.cpp(1597): warning C4101: 'helpExp' : unreferenced local variable

    main.cpp(1748): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data

    Your unreferenced loca variable would cause the seg fault, which DevC++ did pick up on. If you can sort these out, you should be able to run the game. But also eradicate the errors I found too, as they could cause problems later.

  6. #6
    Codigious FingerPrint's Avatar
    Join Date
    Mar 2006
    Posts
    60
    What exactly does it mean by "conversion from 'time_t' to 'unsigned int'"? Does 'time_t' have something to do with Sleep()?


    EDIT: I looked up time_t, but I still dont get exactly what the error means.
    Last edited by FingerPrint; 10-12-2006 at 01:44 PM.
    Code:
    /* ------------------------------------------------------------------*/
                               // INSERT CODE HERE
    /* ------------------------------------------------------------------*/

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    srand(time(NULL));
    time() returns a time_t, but srand is expecting an unsigned int. The common solution is to cast the return value of time():
    Code:
    srand((unsigned)time(NULL));
    (unsigned is the same as unsigned int.)
    Last edited by dwks; 10-12-2006 at 04:15 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Codigious FingerPrint's Avatar
    Join Date
    Mar 2006
    Posts
    60
    Thanks for telling me how to fix that part dwks. But I dont have a way of telling if I have fixed the rest of the problems. It still opens the game for me, so I cant tell whats still wrong. I dd edit it a bit, hopefulyl fixing at least some problems.

    I downloaded GDB because I thought it was a debugger, but I cant figure out how to work it. I went to its folder just to see a bunch of soruce files, headers and the likes. Is it not a debugger? If it is, how do you open and use it?
    Code:
    /* ------------------------------------------------------------------*/
                               // INSERT CODE HERE
    /* ------------------------------------------------------------------*/

  9. #9
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,071
    Compile the source files?
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Try my game
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-15-2004, 11:58 AM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. Game Programmer's AIM Circle: Join Today
    By KingZoolerius66 in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 12-20-2003, 12:12 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM