title: SDL event loop quitting?
body: <p>I am making an RTS in C++ using SDL for graphics.</p>
  
  <p>Every time I run the game, it crashes without errors or anything in the compiler debug window.  It doesn't crash immediately or consistently, sometimes taking 10 seconds to crash and other times taking 2 minutes to crash.  </p>
  
  <p>When I played around with return values (at the end of the main function) it turned out it wasn't crashing, but rather quitting as the return values were consistent with what I changed it to.  </p>
  
  <p>The only theory that I have is that my poll event loop is glitching and telling the program to quit when it isn't supposed to.  </p>
  
  <p>Here is my event loop, contained within my game loop:</p>
  
  <pre><code>    if( SDL_PollEvent( &amp;event ) )
      {
          if( event.type == SDL_MOUSEMOTION )
          {
              mx = event.motion.x;
              my = event.motion.y;
          }
  
          if( event.type == SDL_MOUSEBUTTONDOWN )
          {
              if( hut.getselected() &amp;&amp; hut.getplacable() )
              {
                  hut.place( map );
              }
          }
  
          if( event.type == SDL_QUIT )
          {
              quit = true;
          }
  
          switch( event.key.keysym.sym )
          {
          case SDLK_ESCAPE: quit = true; break;
          }
      }
  </code></pre>
  
  <p>Is it possible that when the mouse moves or clicks, that it is confusing it for exiting?  I don't think the ram is overloading either because it only displays what it needs to tile-wise.  </p>
  
  <p>Is it also possible that my compiler, VisualC++, is screwing up?</p>