}
}
}
}
ПРИЛОЖЕНИЕ Б
(Листинг программы сервера)
#ifndef CLIENT_H_INCLUDED
#define CLIENT_H_INCLUDED
//#include <winsock2.h>
#include <string>
#include <conio.h>
#include <winsock2.h>
#include <windows.h>
#include <vector>
#include <iostream>
#include <algorithm> //find_if
#include <cctype>
#define bombCode 5
int playerCode;
int playerCount=0;
int deadCount=0;
int totalCount=2;
HWND textBox;
HWND messBox;
SOCKET clientSocket;
SOCKET serverSocket;
int matrix[7][13][6]={{{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}},
{{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0}},
{{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}},
{{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0}},
{{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}},
{{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0},{1,0,0,0,0,0},{0,0,0,0,0,0}},
{{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}}};
char* str=new char[7*6*13];
char _buffer[1024];
int BUF_SIZE=1024;
std::vector<int> clientCodes(4);
std::vector<SOCKET> clientList(4);
//using namespace std;
bool sendMess=false;
int cSock;
typedef struct
{
int x;
int y;
} position;
HANDLE semaphore;
HANDLE messageBoxSemaphore;
void SendInfoGlobal();
void PrintMessage(char mess[])
{
WaitForSingleObject(messageBoxSemaphore, INFINITE);
SendMessage(messBox, EM_SETSEL, -1, -1);
SendMessage(messBox, EM_REPLACESEL, TRUE, (LPARAM)mess);
ReleaseSemaphore(messageBoxSemaphore, 1, NULL);
}
void KillPlayer(int code)
{
for (int i = 0; i < 7;i++)
for (int j = 0; j < 13;j++)
if (matrix[i][j][code] == code)
{
WaitForSingleObject(semaphore, INFINITE);
matrix[i][j][code - 1] = 0;
deadCount++;
ReleaseSemaphore(semaphore, 1, NULL);
}
SendInfoGlobal();
}
void ProcessMatrixToString()
{
int iter = 0;
WaitForSingleObject(semaphore,INFINITE);
str = new char[1024];
for(int i=0;i<7;i++)
for(int j=0;j<13;j++)
for(int k=0;k<6;k++)
{
str[iter]=(char)(matrix[i][j][k])+'0';
iter++;
}
str[iter]=0;
ReleaseSemaphore(semaphore,1,NULL);
}
void Badabum(LPCVOID param)
{
Sleep(3000);
position* pos=(position*) param;
WaitForSingleObject(semaphore,INFINITE);
for(int i=-1;i<=1;i++)
for(int k=1;k<6;k++)
{
if((pos->y+i)>=0&&(pos->y+i)<7&&(pos->x)>=0&&(pos->x)<13)
if(matrix[pos->y+i][pos->x][k]>0)
{
if(matrix[pos->y+i][pos->x][k]<bombCode&&matrix[pos->y+i][pos->x][k]>0)
deadCount++;
//Map.mtr[pos->y+i][pos->x][k]=0;
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.