Создание приложений с использованием многопоточности при обработки запросов клиентов, страница 4

                                 matrix[pos->y+i][pos->x][k]=0;

                          }

                    if((pos->y)>=0&&(pos->y)<7&&(pos->x+i)>=0&&(pos->x+i)<13)

                          if(matrix[pos->y][pos->x+i][k]>0)

                          {

                                 if(matrix[pos->y][pos->x+i][k]>0&&matrix[pos->y][pos->x+i][k]<bombCode)

                                       deadCount++;

                                 //Map.mtr[pos->y][pos->x+i][k]=0;

                                 matrix[pos->y][pos->x+i][k]=0;

                          }

             }

       SendInfoGlobal();

       ReleaseSemaphore(semaphore,1,NULL);

}

void ProcessEnterKey(int key,position &point,int code)

{

       //position* bombPos = new position;

       if(matrix[point.y][point.x][code])

       switch(key)

       {

             //d

             case 275:

                    if ((point.x + 1)<13 && matrix[point.y][point.x + 1][0] != 1 && matrix[point.y][point.x + 1][bombCode] != bombCode)

                    {

                          matrix[point.y][point.x][code]=0;

                          matrix[point.y][point.x+1][code]=code;

                          point.x=point.x+1;

                    }

                    break;

             //a

             case 276:

             {

                    if ((point.x - 1) >= 0 && matrix[point.y][point.x - 1][0] != 1 && matrix[point.y][point.x - 1][bombCode]!=bombCode)

                    {

                          matrix[point.y][point.x][code]=0;

                          matrix[point.y][point.x-1][code]=code;

                          point.x=point.x-1;

                    }

             }

             break;

             //s

             case 274:

             {

                    if ((point.y + 1)<7 && matrix[point.y + 1][point.x][0] != 1 && matrix[point.y + 1][point.x][bombCode] != bombCode)

                    {

                          matrix[point.y][point.x][code]=0;

                          matrix[point.y+1][point.x][code]=code;

                          point.y=point.y+1;

                    }

             }

             break;

             //w

             case 273:

                    if ((point.y - 1) >= 0 && matrix[point.y - 1][point.x][0] != 1 && matrix[point.y - 1][point.x][bombCode] != bombCode)

                    {

                          matrix[point.y][point.x][code]=0;

                          matrix[point.y-1][point.x][code]=code;

                          point.y=point.y-1;

                    }

             break;

             //space

             /*case 32:

                    matrix[point.y][point.x][bombCode]=bombCode;

                    bombPos->x=point.x;

                    bombPos->y=point.y;

                    CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Badabum,(LPVOID)bombPos,NULL,NULL);

                    break;*/

             default:

                    matrix[point.y][point.x][bombCode] = bombCode;

                    position* bombPos = new position;

                    bombPos->x = point.x;

                    bombPos->y = point.y;

                    CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Badabum, (LPVOID)bombPos, NULL, NULL);

                    break;

       }

}

bool isDead(int code)

{

       for(int i=0;i<7;i++)

             for(int j=0;j<13;j++)

                    if(matrix[i][j][code]==code)

                          return false;

       return true;

}

position GetPosition(int code)

{

       position pos;

       switch(code)

       {

             case 1:

                    pos.x=0;

                    pos.y=0;

                    break;

             case 2:

                    pos.x=12;

                    pos.y=0;

                    break;

             case 3:

                    pos.x=0;

                    pos.y=6;

                    break;

             case 4:

                    pos.x=12;

                    pos.y=6;