game_server/src/block.cpp
/* sync_with modified this with values from other's region.
 */
sync_with modified this with values from other's region.
sync_with modified this with values from other ' s region .
void Block::sync_with(Block *other, int region)
{
  int i, j;
  if(region == P_REGION_NW)
  {
    for(i = BLOCK_PADDING; i < 2 * BLOCK_PADDING; i++)
    {
      for(j = BLOCK_PADDING; j < 2 * BLOCK_PADDING; j++)
      {
        this -> map[BLOCK_SIZE + i][BLOCK_SIZE + j] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_N)
  {
    for(i = BLOCK_PADDING; i < 2 * BLOCK_PADDING; i++)
    {
      for(j = BLOCK_PADDING; j < BLOCK_SIZE + BLOCK_PADDING; j++)
      {
        this -> map[BLOCK_SIZE + i][j] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_NE)
  {
    for(i = BLOCK_PADDING; i < 2 * BLOCK_PADDING; i++)
    {
      for(j = BLOCK_SIZE; j < BLOCK_SIZE + BLOCK_PADDING; j++)
      {
        this -> map[BLOCK_SIZE + i][j - BLOCK_SIZE] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_W)
  {
    for(i = BLOCK_PADDING; i < BLOCK_SIZE + BLOCK_PADDING; i++)
    {
      for(j = BLOCK_PADDING; j < 2 * BLOCK_PADDING; j++)
      {
        this -> map[i][BLOCK_SIZE + j] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_E)
  {
    for(i = BLOCK_PADDING; i < BLOCK_SIZE + BLOCK_PADDING; i++)
    {
      for(j = BLOCK_SIZE; j < BLOCK_SIZE + BLOCK_PADDING; j++)
      {
        this -> map[i][j - BLOCK_SIZE] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_SW)
  {
    for(i = BLOCK_SIZE; i < BLOCK_SIZE + BLOCK_PADDING; i++)
    {
      for(j = BLOCK_PADDING; j < 2 * BLOCK_PADDING; j++)
      {
        this -> map[i - BLOCK_SIZE][BLOCK_SIZE + j] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_S)
  {
    for(i = BLOCK_SIZE; i < BLOCK_SIZE + BLOCK_PADDING; i++)
    {
      for(j = BLOCK_PADDING; j < BLOCK_SIZE + BLOCK_PADDING; j++)
      {
        this -> map[i - BLOCK_SIZE][j] = other -> map[i][j];
      }
    }
  }
  if(region == P_REGION_SE)
  {
    for(i = BLOCK_SIZE; i < BLOCK_SIZE + BLOCK_PADDING; i++)
    {
      for(j = BLOCK_SIZE; j < BLOCK_SIZE + BLOCK_PADDING; j++)
      {
        this -> map[i - BLOCK_SIZE][j - BLOCK_SIZE] = other -> map[i][j];
      }
    }
  }
}
void Block :: sync_with ( Block * other , int region ) { int i , j ; if ( region == P_REGION_NW ) { for ( i = BLOCK_PADDING ; i < 2 * BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_PADDING ; j < 2 * BLOCK_PADDING ; j ++ ) { this -> map [ BLOCK_SIZE + i ] [ BLOCK_SIZE + j ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_N ) { for ( i = BLOCK_PADDING ; i < 2 * BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_PADDING ; j < BLOCK_SIZE + BLOCK_PADDING ; j ++ ) { this -> map [ BLOCK_SIZE + i ] [ j ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_NE ) { for ( i = BLOCK_PADDING ; i < 2 * BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_SIZE ; j < BLOCK_SIZE + BLOCK_PADDING ; j ++ ) { this -> map [ BLOCK_SIZE + i ] [ j - BLOCK_SIZE ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_W ) { for ( i = BLOCK_PADDING ; i < BLOCK_SIZE + BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_PADDING ; j < 2 * BLOCK_PADDING ; j ++ ) { this -> map [ i ] [ BLOCK_SIZE + j ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_E ) { for ( i = BLOCK_PADDING ; i < BLOCK_SIZE + BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_SIZE ; j < BLOCK_SIZE + BLOCK_PADDING ; j ++ ) { this -> map [ i ] [ j - BLOCK_SIZE ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_SW ) { for ( i = BLOCK_SIZE ; i < BLOCK_SIZE + BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_PADDING ; j < 2 * BLOCK_PADDING ; j ++ ) { this -> map [ i - BLOCK_SIZE ] [ BLOCK_SIZE + j ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_S ) { for ( i = BLOCK_SIZE ; i < BLOCK_SIZE + BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_PADDING ; j < BLOCK_SIZE + BLOCK_PADDING ; j ++ ) { this -> map [ i - BLOCK_SIZE ] [ j ] = other -> map [ i ] [ j ] ; } } } if ( region == P_REGION_SE ) { for ( i = BLOCK_SIZE ; i < BLOCK_SIZE + BLOCK_PADDING ; i ++ ) { for ( j = BLOCK_SIZE ; j < BLOCK_SIZE + BLOCK_PADDING ; j ++ ) { this -> map [ i - BLOCK_SIZE ] [ j - BLOCK_SIZE ] = other -> map [ i ] [ j ] ; } } } }
sync_with modified this with values from other's region.
sync_with modified this with values from other ' s region .