Jump to content
  • Advertisement
Sign in to follow this  
levijgraham

i really need some help

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have attached a picture of the error i get it when i send my map between the server and the client.
theres my main
#include <iostream>
#include <string>
#include "GameState.h"
#include "Socket.h"
#include "Level.h"

using namespace std;

GameState CurrentGameState;
const int STRLEN = 256;
const int MAPLENGTH = 250;
Level CurrentLevel;

int main()
{
CurrentLevel.init();
int port = 666;
char *ipAddress = "127.0.0.1";
char recMessage[STRLEN];
char sendMessage[STRLEN];
bool run = true;
while (true)
{
int a = CurrentGameState.run();
if(a == 1)
{
bool run2 = true;
ServerSocket sockServer;
cout << "HOSTING..."<<endl;
sockServer.StartHosting(port);
sockServer.Listen();
while (run2)
{
char sendMap[MAPLENGTH];
CurrentLevel.draw();
CurrentLevel.Edit(true);
int id = 0;
for(int y = 0;y < 10;y++)
{
for(int x = 0;x < 25;x++)
{
sendMap[id] = CurrentLevel.map[x][y];
id++;
}
}
sockServer.SendData( sendMap );

sockServer.ReceiveData(sendMap,MAPLENGTH);
id = 0;
for(int y = 0;y < 10;y++)
{
for(int x = 0;x < 25;x++)
{
CurrentLevel.map[x][y] = sendMap[id];
id++;
}
}

if (strcmp(recMessage,"end") == 0 || strcmp(sendMessage,"end") == 0)
{
run2 = false;
}
}
}
else if(a == 2)
{
ClientSocket sockClient;
cout << "ATTEMPTING TO CONNECT" << endl;
sockClient.ConnectToServer(ipAddress,port);
bool run2 = true;
while (run2)
{
char sendMap[MAPLENGTH];
CurrentLevel.draw();
sockClient.ReceiveData(sendMap,MAPLENGTH);
int id = 0;
for(int y = 0;y < 10;y++)
{
for(int x = 0;x < 25;x++)
{
CurrentLevel.map[x][y] = sendMap[id];
id++;
}
}
CurrentLevel.Edit(false);

id = 0;
for(int y = 0;y < 10;y++)
{
for(int x = 0;x < 25;x++)
{
sendMap[id] = CurrentLevel.map[x][y];
id++;
}
}
sockClient.SendData( sendMap );

if (strcmp(recMessage,"end") == 0 || strcmp(sendMessage,"end") == 0)
{
run2 = false;
}
}
sockClient.CloseConnection();
}
else if(a == 3)
{
exit(0);
}
}
return 0;}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!