Random Window Close

This is a discussion on Random Window Close within the Game Programming forums, part of the General Programming Boards category; Hey guys, ok whats going on here is, that my game when it is in the actual game play screen, ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29

    Random Window Close

    Hey guys, ok whats going on here is, that my game when it is in the actual game play screen, when it has the map and stuff drawn, it loads everything fine, connects to the MySQL server and draws all my pretty little squares and triangles I am using for testing, but after a few seconds it closes with this error

    The thread 'Win32 Thread' (0x1498) has exited with code 1 (0x1).
    The program '[4988] TD4.exe: Native' has exited with code 1 (0x1).

    Now it only happens when it is in the game play screen, in the menu it will run fine, does anyone have any ideas why or how I can fix this, I am doing Windows progamming and using OpenGL

    Thanks in advance guys

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Search for "exit(1)" in your code - if you have several, you may want to change them so that they have different values for different exit reasons.

    If it's not in your code, then you'll have to try to track down where the exit is called - you can perhaps set a breakpoint on the function exit, and look the the call-stack.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    Thanks, I found where it is exiting, now I just need to work out why :P

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That is, however, usually the easy part - but it can still be a challeng in some cases (particularly data corruption & other such "stuff ain't doin' what it should do" cases).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    Hehe, yes it can be quite annoying sometimes, it's in my MySQL code and I do not have a clue why it's exiting so I am going to have to go through it all and see whats going on

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You may find that writing to a log-file for each SQL contact makes sense. Not just this time, but having a way to enabl/disable logging of SQL will probably help you with other problems in the future too.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    maybe you could help me, it's a completely different problem but you seem to know what your talking about, I think my code is generating a MySQL error, thats the only reason for the line that is exiting my program to have been called. Does MySQL complain if you try to connect and disconnect to it very very fast, because everytime my screen refreshs I connect to MySQL to get screen data, building locations and unit locations and the like. And if that would cause an error is there a way I can limit that connect to say once every second, cause thats what I want for my game

    Thanks in advance

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If there are even pairs (that is, there exactly one disconnect for exactly one connect) then I don't see how that should cause a problem. You may want to consider a different approach if you plan on doing this with a remote server, but there's (as far as I know) no problem with it. Try adding a bit of debug output to your connect & disconnect sections of code if you suspect that they aren't doing the right thing.

    I haven't used MySQL in C/C++ (or a game environment), but I have used MySQL with PHP for web-site use, so I have some clue what you are talking about.

    You may want to try to add a function call that shows where in your code the call came from when you make a MySQL query.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    You dont want to do it that way.

    What you want to do is read everything you need from the database once and then as you move stuff or whatever in game you update the values in memory. Then when you exit you write to the database with the new values.

    Now this creates extra problems...like what happends at a crash and such but one thing is clear....you dont want to extract the data from the database every frame...that you do once and that is at program launch.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  10. #10
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    I also don't want to do it that way, cause the game, once it's finished it going to be a multiplayer online game, I will be connecting to a remote server and what i need is a way to connect once every few seconds say, can anyone help me out in limiting my connection to MySQL, I assume the easiest way would be to use a timer, but my knowledge of Windows programming (in that sense) is limited

    Thanks in advance

  11. #11
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    Then you have the server connect to the database once at launch...collect all the data, and as the game is progressing does all the calculations on the values in memory while feeding the info needed to the clients. Once the data is retrieved IMO the only thing that should involve the database is writing new/overwriting values. And to do timers look up this page: http://msdn2.microsoft.com/en-us/library/ms644901.aspx
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  12. #12
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    What Shakti is referring to is very similar to replicating the database on the client computer. However replication can take a long time if the database is large. Instead of always accessing the server you access the local database and modify it. Then when you are done you send the new data to the database on the server.

    The point is you don't want to tie up network traffic for every single piece of data you need. Also when it is inevitable that you must communicate with the server you want to make your request as simple as possible. This is, of course, speaking from a game programming perspective as to how you should use your database.

    If you tie up the server or the network (in a LAN game) you will cause lag both on the client systems and on the server. This could bring the game to a standstill very quickly.

    I recommend buying a book on multiplayer game programming.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Over Rideing close message when closing window
    By Rune Hunter in forum Windows Programming
    Replies: 8
    Last Post: 12-04-2005, 01:57 PM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 07:23 AM
  4. Problem with creating new window, from another window
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-11-2004, 01:10 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21