Exemplo n.º 1
0
void CMapScene::setMap(CMap *map, int startType)
{
    if(!map)
    {
        clearMap();
        removeItem(Pixmap);
        return;
    }
    //Shaman dance.
    //Map will not change if map == Map
    //and map wasn't removed from scene (i.e. map wasn't destroyed in CBattle::changeMap();
    if((Map == map) && (items().contains(Pixmap)))
        return;

    QGraphicsView *View;

    if((Map != map) && (items().contains(Pixmap)))
        removeItem(Pixmap);

    Map = map;
    connect(Map, SIGNAL(destroyed()), this, SLOT(mapDestroyed()));

    clearMap();
    Pixmap->resetTransform();
    Pixmap->setPixmap(Map->getBigMinimap());
    Pixmap->setTransform(QTransform::fromScale((Map->width() / 1024.0), (Map->height() / 1024.0)));
    setSceneRect(Pixmap->mapRectToScene(Pixmap->boundingRect()));
    addItem(Pixmap);

    SceneScale = qMax(Map->width() / 1024.0, Map->height() / 1024.0);

    foreach(View, views())
    {
        View->fitInView(Pixmap, Qt::KeepAspectRatio);
    }
void Actions::clear()
{
	clearMap(useItemMap);
	clearMap(uniqueItemMap);
	clearMap(actionItemMap);

	m_interface.reInitState();
}
Exemplo n.º 3
0
void GlobalEvents::clear()
{
	clearMap(thinkMap);
	clearMap(serverMap);
	clearMap(timerMap);

	m_interface.reInitState();
}
Exemplo n.º 4
0
void Actions::clear(bool fromLua)
{
	clearMap(useItemMap, fromLua);
	clearMap(uniqueItemMap, fromLua);
	clearMap(actionItemMap, fromLua);

	reInitState(fromLua);
}
Exemplo n.º 5
0
void Actions::clear()
{
	clearMap(useItemMap);
	clearMap(uniqueItemMap);
	clearMap(actionItemMap);

	m_interface.reInitState();
	delete defaultAction;
	defaultAction = NULL;
}
Exemplo n.º 6
0
void GlobalEvents::clear()
{
	g_scheduler.stopEvent(thinkEventId);
	thinkEventId = 0;
	g_scheduler.stopEvent(timerEventId);
	timerEventId = 0;

	clearMap(thinkMap);
	clearMap(serverMap);
	clearMap(timerMap);

	scriptInterface.reInitState();
}
Exemplo n.º 7
0
//Right Click Menu.
void menu(int value)
{
	if(value == 0)
	{
		clearMap();
	}
	else if(value == 1)
	{
		paused = !paused;
	}
	else if(value == 2)
	{
		incrementSpeed();
	}
	else if(value ==3)
	{
		decrementSpeed();
	}
	else if(value == 4)
	{
		buildMap();
	}
	else if(value == 5)
	{
    	exit(0);
	}
}
Exemplo n.º 8
0
void								Landscape::init(void)
{
	Parser		p(_filename);

	_waterHeight = 0.0f;
	clearMap();
	if (p.fail())
	{
		std::cout << "Parsing:\tERROR" << std::endl;
		_fail = true;
		return ;
	}
	std::cout << "Parsing:\tDONE" << std::endl;
	lexer(p);
	std::cout << "Lexing:\t\tDONE" << std::endl;
	smoothMap();
	useMap();
	initBuffers();
	_rain.init();
	_sea.init();
	for (size_t i = 0; i < MAX_RAIN_PARTICLE; ++i)
	{
		_rain.addDrop(_vBufferData, i, true);
	}
}
Exemplo n.º 9
0
VOID Astar::Initialize( TileMap::LPINFO a_MapInfo )
{
	m_iWidth = a_MapInfo->iGraphWidth;
	m_iHeight = a_MapInfo->iGraphHeight;

	m_Map = new PathMap*[m_iWidth];

	for( INT i=0; i<m_iWidth; i++ )
	{
		m_Map[i] = new PathMap[m_iHeight];
	}

	m_pOpen = new TreeRoot;
	m_pOpen->root = NULL;

	// 탐색 방법 - 12시 부터 시계방향
	m_Dir[0][0] = 0;	m_Dir[0][1] = -1;
	m_Dir[1][0] = 1;	m_Dir[1][1] = -1;
	m_Dir[2][0] = 1;	m_Dir[2][1] = 0;
	m_Dir[3][0] = 1;	m_Dir[3][1] = 1;
	m_Dir[4][0] = 0;	m_Dir[4][1] = 1;
	m_Dir[5][0] = -1;	m_Dir[5][1] = -1;
	m_Dir[6][0] = -1;	m_Dir[6][1] = 0;
	m_Dir[7][0] = -1;	m_Dir[7][1] = 1;

	createMap( a_MapInfo->pNavGraphNode );
	clearMap();
}
void MapRoom::buildMap( int map )
{
    clearMap();
    m_mapCode = map;
    
    switch (map)
    {
        case MAP_START_ZONE:
            buildMap_StartRoom( false );
            break;
            
        case MAP_START_OPEN:
            buildMap_StartRoom( true );
            break;
            
            
        case MAP_CAVE_COLD:
        case MAP_CAVE_DANCE:
        case MAP_CAVE_SWORD:
            buildMap_Cave( map);
            break;
            
        default:
            break;
    }
}
Exemplo n.º 11
0
bool
Map::push (int _x, int _y) {
  assert (!badCoords (xpos_, ypos_));
  assert (empty (xpos_, ypos_));

  int xd=0, yd=0;
  if (_x < xpos_) xd = -1;
  if (_x > xpos_) xd =  1;
  if (_y < ypos_) yd = -1;
  if (_y > ypos_) yd =  1;
  if (badDelta (xd, yd) || badCoords (_x+xd, _y+yd)) return false;

  int x=xpos_+xd, y=ypos_+yd;
  if (!object (x, y)) return false;
  if (!empty (_x+xd, _y+yd)) return false;

  while (!(x==_x && y==_y)) {
    x += xd;
    y += yd;
    if (!empty (x, y)) return false;
  }

  clearMap (xpos_+xd, ypos_+yd, OBJECT);
  setMap (_x+xd, _y+yd, OBJECT);

  xpos_ = _x;
  ypos_ = _y;

  return true;
}
Exemplo n.º 12
0
void MoveEvents::clear()
{
    clearMap(itemIdMap);
    clearMap(actionIdMap);
    clearMap(uniqueIdMap);

    for (const auto& it : positionMap) {
        const MoveEventList& moveEventList = it.second;
        for (const auto& i : moveEventList.moveEvent) {
            for (MoveEvent* moveEvent : i) {
                delete moveEvent;
            }
        }
    }
    positionMap.clear();

    scriptInterface.reInitState();
}
Exemplo n.º 13
0
void MoveEvents::clear()
{
	clearMap(m_itemIdMap);
	clearMap(m_actionIdMap);
	clearMap(m_uniqueIdMap);

	for (const auto& it : m_positionMap) {
		const MoveEventList& moveEventList = it.second;
		for (int32_t i = 0; i < MOVE_EVENT_LAST; ++i) {
			for (MoveEvent* moveEvent : moveEventList.moveEvent[i]) {
				delete moveEvent;
			}
		}
	}
	m_positionMap.clear();

	m_scriptInterface.reInitState();
}
Exemplo n.º 14
0
void MapView::displayMap()
{
    clearMap();
    if (displayStrategy != NULL)
        displayStrategy->display();
    if (gridStrategy != NULL)
        gridStrategy->execute();
    this->setSceneRect(0,0,map->getSize().width()*BLOCSIZE,map->getSize().height()*BLOCSIZE);
}
Exemplo n.º 15
0
SDLWrapper::~SDLWrapper() {
    destroyWindow();
    destroyRenderer();
    clearTextures();
    clearMap();
    freeDrawableObjects();
    freeTextObjects();
    SDL_Quit();
    TTF_Quit();
}
void FrameBuffer::draw(std::vector<Polygon*> &polygons){
    std::vector<Polygon*>::iterator it;
    std::sort(polygons.begin(), polygons.end(), Polygon::isFront);

    for (it = polygons.begin(); it != polygons.end(); it++) {
        oosMap = (int**) malloc(((*it)->getNLine())*sizeof(int*));
        drawPolygon(*it);
        clearMap(*it);
    }
}
Exemplo n.º 17
0
GeoHelper::~GeoHelper()
{
    clearMap();

    if (provider)
    {
        delete provider;
        provider = NULL;
    }
}
  int  findCorners(ImageGradient *grd, float thr=0.1) {
    // Find corners using Harris corner detector, assumming 
    //   gradient images 'grd->gx' and 'grd->gy' are ready (by getGradient()).
    if (!grd || grd->gx.w == 0 || grd->gx.h == 0 || !grd->gx.sameSize( &grd->gy )) return 0;
    this->grd = grd;
    this->w  = grd->gx.w;  this->h = grd->gx.h;  this->total = w * h;
    int   x, y, idx, margin=4;
    clearMap();
    cmap.setImage( w, h, PIXEL_VOIDP );
    smap.setImage( w, h, PIXEL_FLOAT );
    // Average intensity change in direction (u,v) can be expressed as a linear form:
    //   E(u,v) = [u v] M [u],  where M =  SUM  W(x,y) [ Ix^2 IxIy ]
    //                    [v]             (x,y)        [ IxIy Iy^2 ]
    // Describe a point in terms of eigenvalues of M (measurement of corner response):
    //   R = Lambda1 * Lambda2 - kappa * (Lambda1 + Lambda2),  where kappa=0.04~0.06
    //     = det(M) - kappa * tr(M)^2               (OpenCV : icvCalcHarris() in icvCornerEigenValsVecs())
    //     = (Ix2 Iy2 - IxIy IxIy) - k (Ix2+Iy2)^2  (Gandalf: calc_strength() in gan_harris_corner_q())
    //   R = Ix2 Iyy + Iy2 Ixx - 2 Ix Iy IxIy       (OpenCV : PreCornerDetect())
    // A good corner point should have a large intensity change in all directions,
    //   i.e. R should be large positive. (Lambda_min should be large.)
    float *gxp = (float*)(grd->gx.data), *gyp = (float*)(grd->gy.data);
    float gx, gy, gx2, gy2, gxy, value, *curr, *prev, *next;
    // calculate corner strength for each pixel
    for (max_strength = idx = 0; idx < total; idx++) {
      gx  = gxp[idx];  gy  = gyp[idx];  
      gx2 = gx * gx;   gy2 = gy * gy;   gxy = gx * gy;
      value = (float)(fabs((gx2 * gy2 - gxy * gxy) - 0.04 * (gx2 + gy2) * (gx2 + gy2)));  //////
      if (value < 0.0) value = 0.0;
      smap.setFloat( idx, value );
      if (value > max_strength) max_strength = value;
    }
    // decide threshold values (default : 10% of maximum strength)
    if (thr <= 0.01) thr = 0.01;
    if (thr >= 0.99) thr = 0.99;
    // low_strength = (float)pow(pow((double)max_strength,0.25) * thr, 2.0);
    low_strength = max_strength * thr;
    // search for peaks in corner strength
    for (y = margin, corner_count=0; y < h-margin; y++) {
      curr = (float*)(smap.data) + y * w + margin;
      prev = curr - w;
      next = curr + w;
      for (x = margin; x < w-margin; x++, curr++,  prev++,  next++) {
	if (curr[0] < low_strength) continue;
	// non-maximum suppression
	if ( curr[0] < prev[-1] || curr[0] < prev[0] || curr[0] < prev[+1] ||
	     curr[0] < curr[-1] ||                      curr[0] < curr[+1] ||
	     curr[0] < next[-1] || curr[0] < next[0] || curr[0] < next[+1] ) continue;
	//// quadratic fitting for subpixel accuracy
	cmap.setPointer( x, y, new CornerPoint(x, y, curr[0]) );
	corner_count++;
      }
    }
    return corner_count;
  }
Exemplo n.º 19
0
void QSqlForm::sync()
{
    if ( d->dirty ) {
	clearMap();
	if ( d->buf ) {
	    for ( uint i = 0; i < d->fld.count(); ++i )
		insert( d->wgt[ d->fld[ i ] ], d->buf->field( d->fld[ i ] ) );
	}
    }
    d->dirty = FALSE;
}
Exemplo n.º 20
0
void hrAdventureScreen::loadMap(hrH3MReader *reader)
{
    Q_ASSERT(reader);
    clearMap();
    size.setSize(QSize(reader->getSize(), reader->getSize()));

    hasUnderground = reader->hasUnderground();

    hrCache& cache = hrCache::Get();

    for (int i = 0; i < size.width() * size.height(); i++)
    {
        hrTile tile = reader->getTile(i);
        tilesGround.append(tile);
        loadTile(tile);
        if (hasUnderground)
        {
            tile = reader->getTile(i, true);
            tilesUnderground.append(tile);
            loadTile(tile);
        }
    }
    for (int i = 0; i < reader->getObjectsCount(); i++)
    {
        hrSceneObject object = reader->getObject(i);

        hrGraphicsItem item;
        if (!itemsObject.contains(object.getId()))
        {
            QString name = reader->getObjectName(object.getId());
            item = cache.loadItem(name);
            itemsObject[object.getId()] = item;
        }
        else
        {
            item = itemsObject[object.getId()];
        }
        object.setFrames(item.countFrames);
        object.setSize(coord::toCell(item.getSize()));

        if (!object.isUnderground())
            objectsGround.append(object);
        else
            objectsUnderground.append(object);
    }
    std::sort(objectsGround.begin(), objectsGround.end());
    std::sort(objectsUnderground.begin(), objectsUnderground.end());

    loadCursor("cradvntr.def");
    setCursor(CURSOR_POINTER);

    animateTimer.start(200);
}
Exemplo n.º 21
0
void
LevelMap::random (void) {
  printf ("start!\n");

  minX_ = 0;
  minY_ = 0;
  maxX_ = MAX_X;
  maxY_ = MAX_Y;
  totalMoves_ = totalPushes_ = 0;
  clearMap ();

  xpos_ = 13;
  ypos_ = 9;

  KRandomSequence random(0);

  for (int i=0; i<200; i++) {
    map (xpos_, ypos_, FLOOR);

    switch (random.getLong(4)) {
    case 0:
      if (ypos_ > 1) ypos_--; else i--;
      break;

    case 1:
      if (ypos_ < MAX_Y-1) ypos_++; else i--;
      break;

    case 2:
      if (xpos_ > 1) xpos_--; else i--;
      break;

    case 3:
      if (xpos_ < MAX_X-1) xpos_++; else i--;
      break;
    }
  }

  for (int y=1; y<MAX_Y; y++) {
    for (int x=1; x<MAX_X; x++) {
      if (map (x, y) & FLOOR) {
	if (!(map (x, y-1) & FLOOR)) map (x, y-1, WALL);
	if (!(map (x, y+1) & FLOOR)) map (x, y+1, WALL);
	if (!(map (x-1, y) & FLOOR)) map (x-1, y, WALL);
	if (!(map (x+1, y) & FLOOR)) map (x+1, y, WALL);
      }
    }
  }

  printf ("klar!\n");
  printMap ();
}
Exemplo n.º 22
0
PhotonGrid::PhotonGrid(BVH &sceneGraph, LightList &lights, EmitterList &emitters, MaterialList &materials) {
	m_pSceneGraph = &sceneGraph;
	m_pLightList = &lights;
	m_pEmitterList = &emitters;
	m_pMaterialList = &materials;

#ifndef _GRID_HASH
	m_pGrid = NULL;
#endif
	m_pGridMask = NULL;

	clearMap();
}
Exemplo n.º 23
0
void Q3SqlForm::sync()
{
    if (d->dirty) {
        clearMap();
        if (d->buf) {
            for (int i = 0; i < d->fld.count(); ++i) {
                const QSqlField *field = d->buf->fieldPtr(d->fld.at(i));
                insert(d->wgt.value(d->fld.at(i)), const_cast<QSqlField *>(field));
            }
        }
    }
    d->dirty = false;
}
Exemplo n.º 24
0
void ProtoMessage::clear()
{
	if (m_protoMsg == nullptr)
	{
		return;
	}
	m_protoMsg->Clear();
	clearMap();
	clearList();
	clearTable();
	m_key = -1;
	m_dataKey = -1;
}
Exemplo n.º 25
0
bool verifyOrigin(){
	if( current_x == origin_x ){
		if( current_y == origin_y ){
			if( current_direction == UP ){
				nextDeep();
				clearMap();
				turnAntiClockWise();
				return true;
			}
		}
	}
	return false;
}
Exemplo n.º 26
0
//Generates a map with random cells.
void buildMap()
{
	clearMap();

	int i, j;
 
	for ( i = 0; i < 30; i++ )
	{
    	for ( j = 0; j < 30; j++ )
    	{
        	currentMap[i][j] = myRand(2);
    	}
   }
}
Exemplo n.º 27
0
void MoveEvents::clear()
{
    clearMap(m_itemIdMap);
    clearMap(m_actionIdMap);
    clearMap(m_uniqueIdMap);

    for(MovePosListMap::iterator it = m_positionMap.begin(); it != m_positionMap.end(); ++it)
    {
        for(int32_t i = MOVE_EVENT_FIRST; i <= MOVE_EVENT_LAST; ++i)
        {
            EventList& moveEventList = it->second.moveEvent[i];
            for(EventList::iterator it = moveEventList.begin(); it != moveEventList.end(); ++it)
                delete (*it);

            moveEventList.clear();
        }
    }

    m_positionMap.clear();
    m_scriptInterface.reInitState();

    m_lastCacheTile = NULL;
    m_lastCacheItemVector.clear();
}
Exemplo n.º 28
0
void SpawnShell::clear(void)
{
#ifdef SPAWNSHELL_DIAG
   printf("SpawnShell::clear()\n");
#endif

   emit clearItems();

   clearMap(m_spawns);
   clearMap(m_coins);
   clearMap(m_doors);
   clearMap(m_drops);

   // clear the players list, reinsert the player
   m_players.clear();
   m_players.insert(0, m_player);

   // emit an changeItem for the player
   emit changeItem(m_player, tSpawnChangedALL);

   m_cntDeadSpawnIDs = 0;
   m_posDeadSpawnIDs = 0;
   memset((void*)&m_deadSpawnID[0], 0, sizeof(m_deadSpawnID));
} // end clear
Exemplo n.º 29
0
void Game::startUpdate()
{
    areDelayTimer->reset();
    
    clearMap();
    show->mapShow(mapData);
    
    createBlock();
    show->previewShow(randomQueue->begin(), randomQueue->begin() + 4);
    
    calGhostPosY();

    show->ghostShow(getLockPos(),
		    shape,
		    direction);
    
    gameStatus = AREDELAY;
}
Exemplo n.º 30
0
/**
 * Initializes and memory-maps the newly-created file that will contain the
 * product-index map for reading and writing.
 *
 * @param[in]  max          Maximum number of data-product signatures for the
 *                          map.
 * @retval     0            Success.
 * @retval     LDM7_SYSTEM  System error. `log_add()` called.
 */
static Ldm7Status
initNewMapAndMap(
        const size_t max)
{
    const size_t size = fileSizeFromNumSigs(max);
    int          status = truncateMap(size);

    if (0 == status) {
        fileSize = size;
        status = mapMap();

        if (0 == status) {
            clearMap();
            maxSigs = max;
        }
    }

    return status;
}