Cilent
while(!mainpack.endOfPacket())
{
if(mainpack >>counter1 >> counter2 >>actualx >>actualy >>temp)
input=0;
else
{
std::cout <<"An error has occured\n";
std::cout <<"Got Map Data x " <<counter1 <<" y " <<counter2<<" data " <<temp <<" actualx " <<actualx <<" actualy "<<actualy <<"\n";
counter1= -40; continue;
}
std::cout <<"Got Map Data x " <<counter1 <<" y " <<counter2<<" data " <<temp <<" actualx " <<actualx <<" actualy "<<actualy <<"\n";
if(counter1 > 0 & counter2 > 0 & counter1 <MAP_WIDTH & counter2<MAP_HEIGHT)
mainmap.block[counter1][counter2]=temp;
else
{
if(counter1 < 1 | counter2 < 1)
std::cout <<"An Error has Occured Because x " <<counter1 <<" or y " <<counter2 <<" is less than one\n";
if(counter1 >MAP_WIDTH & counter2 > MAP_HEIGHT)
std::cout <<"An Error has Occured Because x " << actualx <<" is greater than map width"
<<MAP_WIDTH <<"\n or y " <<counter2 <<" is greater than map height " <<MAP_HEIGHT <<"\n";
}
Server:
upperleftx=10;//(player_.location[counter][1]-VIEW_WIDTH)-1;
upperlefty=10;//(player_.location[counter][2]-VIEW_HEIGHT)-1;
lowerrightx=10+VIEW_WIDTH;//(player_.location[counter][1]+VIEW_WIDTH)+1;
lowerrighty=10+VIEW_HEIGHT;//(player_.location[counter][2]+VIEW_HEIGHT)+1;
int counterx = upperleftx; int countery = upperlefty;
int counter2=1; int counter1=0;
while(countery<lowerrighty)
{
receive <<mainmap.block[counterx][countery];
std::cout <<"mainmap screenx " <<counter1 <<" screeny" <<counter2 <<" " << "\nx" <<counterx <<" y" << countery <<"data" <<mainmap.block[counterx][countery] <<"\n";
counterx++;
counter1++;
if(counterx>lowerrightx)
{
counterx=upperleftx;
counter1=1;
countery++;
counter2++;
}
}
if(request.send(receive, receiveip, port) ==sf::Socket::Done)
{
std::cout <<"Sent Properly \n";
}
else
{
std::cout <<"An Error Occured While Sending Sending Map to " <<usernametemp <<"\n";
}
}