# HELP!!!!!!!!!!

This topic is 4854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I desperately need help, been working on this project for two weeks. Hit an error I can't fix so much debugging so I rewrite my code all of it. And now I've hit another error that is unexplainable. From adding some certain code, if someone could please add me to msn so I can send you the program so you can help me debug it. I really need help desperately I thank anyone who helps. tehedra@hotmail.com

##### Share on other sites
I sure don't mind helping you, but you need to let us know what it is that you need help with. It might be that your problem lies outside of my field of knowledge or experience. Anyway, explain a little more about the problem, and maybe even post some code (between [_source_] and [_/source_] tags (remove the _ chars)) and I don't mind taking a look.

F451

##### Share on other sites
Well I fixed some errors, but everytime I fix an error I get more. What we are doing is creating a small 4 player game over the network.

Right now, this is how it works.

User connects and we perform a handshake. We know the handshake is working as it has gone under some thourough testing. Now we are passing keypresses across the sockets to determine who is doing what. Ill paste my OnTimer code this is on the server side and what it does is sends out the new location to draw our buggies in. The problem is like now with the OnTimer enabled sometimes the client doesn't even render anymore. Sometimes it shows our buggie but it wont move. And sometimes it works. Never is the same.

Anyways, its much easier to talk over msn or chat or something but ill show u what we have.

void CBuggies_DedServDlg::OnTimer(UINT nIDEvent){	static __int64 iTime = 0;	iTime++;	if(iTime % 50){		/*			Okay so, we are running out timer to send out the information.			This is a dual check process to make sure the client has responded.			Is connected and has responded to the last message.			The code will do all the movement on the server side, then 			respond to the clients with the new locations.		*/		int iPlayers2(0);		for(int i(0); i < 4; i++)			if(m_bPlayersActive)				iPlayers2++;		if(iPlayers2>0){			if(((m_bResponse[0] && m_bPlayersActive[0]) || !m_bPlayers[0]) &&				((m_bResponse[1] && m_bPlayersActive[1]) || !m_bPlayers[1]) &&				((m_bResponse[2] && m_bPlayersActive[2]) || !m_bPlayers[2]) &&				((m_bResponse[3] && m_bPlayersActive[3]) || !m_bPlayers[3])){					/*						So, its time to do them movements. Build our						sending packet. Then possible do collission						detection.					*/					for(int i(0); i<4; i++){						/*							Lets do all the movements now.						*/						if(m_cbsBuggies->up)						{							m_cbsBuggies->Accel();							// The car will only turn if it is accelerating							// This is a car not a spaceship							// if the right arrow is pressed then turn right							if(m_cbsBuggies->right)								m_cbsBuggies->TurnRight();							// if the left arrow is pressed then turn left							if(m_cbsBuggies->left)								m_cbsBuggies->TurnLeft();						} else if (m_cbsBuggies->down) {							m_cbsBuggies->Decel();							if(m_cbsBuggies->right)								m_cbsBuggies->TurnRight();							if(m_cbsBuggies->left)								m_cbsBuggies->TurnLeft();						} else {							// Decelerate the car if the gas is not on							m_cbsBuggies->Slow();						}						/*							Now that we have done the movements and set 							all the values required. Its time to							do the move.						*/						m_cbsBuggies->DoMove();						m_bResponse = false;					}					/*						This is time to make our packets and get ready to send						out the car packet to everyone with the correct values.						This is the fun part of this timer.					*/					int iPlayers(0);					for(int i(0); i < 4; i++)						if(m_bPlayersActive)							iPlayers++;					// Number of players minus yourself					SocketPacket* spSend = new SocketPacket[iPlayers];					///////////////////////////////////////////////					///////////////////////////////////////////////					for(int i(0), j(0); i < iPlayers; i++){												/*							Collect the information of all the players and send it							to the new connection. Remember now that we can do this							all at once it makes it much nicer!						*/						// First Determine which is next player						while(!m_bPlayersActive[j] && j < 4)							j++;						/*							Populates array with player names currently playing.							Pointless to send your own name so that name is not							ever sent.						*/						spSend.iFlag = 0;						spSend.data.CarPacket.iPlayer = j;						spSend.data.CarPacket.x = m_cbsBuggies->GetXPos() * 10000;						spSend.data.CarPacket.y = m_cbsBuggies->GetYPos() * 10000;						spSend.data.CarPacket.iDirection = m_cbsBuggies->GetDir() * 10000;					}					//////////////////////////////////////////////					//////////////////////////////////////////////					std::list<CServer*>::iterator scan = m_plConnections.begin();					while(scan != m_plConnections.end()){						if(m_bPlayersActive[(*scan)->m_iPlayer])							(*scan)->Send(spSend, sizeof(SocketPacket) * iPlayers);						scan++;					}					// Clean Memory Up					delete spSend;				} else {					/*						A user is active and connected but not						responding. Count how long its been						if its been over three seconds boot						their ass.					*/				}			}		}	CDialog::OnTimer(nIDEvent);}

That is less complicated then it works. And too me it should work, but then again Im very stubborn and perhaps it shouldn't.

Anyways thanks for the help from anyone who is able to help me.

##### Share on other sites
ah ok. You might get more people looking at this if you posted this in the Multiplayer and Network Programming forum. As it is, this is way over my head! Good luck sorting this out though. Sounds like a cool project you have going there.

F451

##### Share on other sites
Okay, * looks for a way to switch it over without double posting* lol anyways Ill try there later. Thanks for the help.

##### Share on other sites
Moved to Multiplayer and Networking forum by request.

##### Share on other sites
Why are you doing this?:
if(iTime % 50){...}

iTime%50 will evaluate to zero the first 50 times this function is called, and will also evaluate to zero every 50th time this is called. % = modulo a.k.a. 'remainder'.

I assume you have a timer of some sort that is checked periodically to call this function.

Is your timer firing appropriately? Are you using a high resolution timer or a windows API timer - these get blocked real easy. You might want to implement a better method (high resolution timer) in your game loop - relying on the windows message pump for timing is not a particularly safe thing to do.

##### Share on other sites
Quote:
 if(iTime % 50)

Actually, this will fire the first 49 times through, but not the 50th, and then it will repeat the pattern -- remainder when dividing by 50 is only 0 (false) 1 time out of 50.

However, that's probably not your problem. If I were you, I would put in code that prints various information (time stamp, # bytes received, function you're in, etc) at various important parts of your program, and then inspect that log file. It'll be a lot of data to go through, but that's one of the best ways of knowing what's actually going on.

Other tools that can help are judicious use of assert() to validate assumptions; using Ethereal (the free network sniffer); and your regular debugger -- conditional breakpoints are teh w1n!

##### Share on other sites
Yes thanks for the help, I never noticed that it was supposed to be !(iTime%10) though that didn't fix my errors. I was able to determine that the harder errors to figure out were the computer themselves. The other ones was once I switched computers I was able to determine that the while loop to move on was incorrect. My sockets and drawing is now working correct. And I ended up sending the information every ms anyways since the network is fast enough to do that.

Now im moving onto collission detection as well as determing an algorithm to draw map tiles onto a screen. Again thanks for the help.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 28
• 15
• 39
• ### Forum Statistics

• Total Topics
634837
• Total Posts
3019545
×