Program ending too soon?

Hey, I've got a code that looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
while (End==false)					
    {		

		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
		{
		    if (msg.message==WM_QUIT)
				break;
			TranslateMessage (&msg);							
			DispatchMessage (&msg);
		}

		else
		{
	         game loop stuff
                }
        releaseResources();
	return msg.wParam ;										
   }


The problem is, my game ends after about 30 seconds and I cant fix it. It's obviously because the peekmessage if loop becomes true but if I delete that then the game doesnt work. Any help?
1
2
releaseResources();
return msg.wParam;

These statements are being executed unconditionally at the end of the first iteration of the loop. Other than that I don't see any major problem with this code.
It doesnt do it the first loop, my game plays perfectly for around 30 seconds. I deleted those two lines and it still ends somehow. I put this line in my game

1
2
3
4
if(keys[VK_ESCAPE]) 
	{
		End=true;
	}


That works without everything except

1
2
3
4
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
  DispatchMessage (&msg);
}


Which, if I delete or change, makes the game unplayable.
Topic archived. No new replies allowed.