Esempio n. 1
0
void Cell::rotate(int a)
{
    if((ddirs == Free) || (ddirs == None))
        return;

    rotationProgress += a;
    changed = true;
    while(rotationProgress >= 45)
    {
	rotationProgress -= 90;
	int newdirs = Free;
	if(ddirs & U) newdirs |= R;
	if(ddirs & R) newdirs |= D;
	if(ddirs & D) newdirs |= L;
	if(ddirs & L) newdirs |= U;
	setDirs(Dirs(newdirs));
    }
    while(rotationProgress < -45)
    {
	rotationProgress += 90;
	int newdirs = Free;
	if(ddirs & U) newdirs |= L;
	if(ddirs & R) newdirs |= U;
	if(ddirs & D) newdirs |= R;
	if(ddirs & L) newdirs |= D;
	setDirs(Dirs(newdirs));
    }
    update();
}
Esempio n. 2
0
void Cell::rotate(int a)
{
  angle += a;
  changed = true;
  while(angle >= 45)
  {
    angle -= 90;
    int newdirs = Free;
    if(ddirs & U)
      newdirs |= R;
    if(ddirs & R)
      newdirs |= D;
    if(ddirs & D)
      newdirs |= L;
    if(ddirs & L)
      newdirs |= U;
    setDirs(Dirs(newdirs));
  }
  while(angle < -45)
  {
    angle += 90;
    int newdirs = Free;
    if(ddirs & U)
      newdirs |= L;
    if(ddirs & R)
      newdirs |= U;
    if(ddirs & D)
      newdirs |= R;
    if(ddirs & L)
      newdirs |= D;
    setDirs(Dirs(newdirs));
  }
  update();
}
Esempio n. 3
0
void BaseFileModel::deleteSelected()
{
	emit layoutAboutToBeChanged ();

	foreach(const QModelIndex& index, selected_) {
		const QString fileName = filePass(index);
		if(fileName.isEmpty())
			continue;

		QFile file(fileName);
		if(file.open(QIODevice::ReadWrite)) {
			file.remove();
		}
	}

	setDirs(dirs_);

	emit updateLabel(0);
}
Esempio n. 4
0
void loadGame(string sav = savename) {
  gameExists = false;
  savefile = fopen(sav.c_str(), "rb");

  if(!savefile) { error = true; return; }
  error = false;
  
  load(P);

  if(P.saveformat < 103) {
    printf("Savefile format incompatible\n");
    return;
    }
  
  loadStats(stats, P.saveformat);
  if(P.geometry == 0) P.geometry = 8; setDirs();
  load(playerpos); load(topx); load(topy);
  pinfo.charname = loadString();
  pinfo.username = loadString();  

  if(P.twinsNamed)
    pinfo.twin[0] = loadString(),
    pinfo.twin[1] = loadString();
  
  if(P.version != VERSION) P.vchanged = true;
  
  int set; load(set); for(int i=0; i<MAXARMS; i++) if((set>>i) & 1) wpn[i] = (weapon*) loadS();

  if(P.race == R_TROLL || (P.version >= 1030)) {
    int trollsize;
    load(trollsize);
    pinfo.trollwpn.clear(); pinfo.trollkey.resize(trollsize);
    for(int i=0; i<trollsize; i++) load(pinfo.trollkey[i]);
    for(int i=0; i<trollsize; i++) pinfo.trollwpn.push_back((weapon*) loadS());;
    }

  for(int i=0; i<P.stairqueue; i++) stairqueue.push_back((hydra*) loadS());
  
  pinfo.whistAt.resize(stats.whistSize);
  for(int i=0; i<stats.whistSize; i++) 
    load(pinfo.whistAt[i]), pinfo.whist.push_back((weapon*) loadS());
  
  for(int y=0; y<SY; y++) for(int x=0; x<SX; x++) {
    cell& c(M.m[y][x]);
    c.it = NULL;
    load(c.type), load(c.mushrooms), load(c.dead), load(c.explored);
    if(c.mushrooms & ITEMMASK) {
      c.mushrooms &= ~ITEMMASK;
      c.it = loadS();
      }
    if(c.type == CT_STAIRUP)
      stairpos = vec2(x,y);
    }
  M.out.clear(); M.out.type = CT_WALL;
  
  int32_t i; load(i); hydras.resize(i);
  for(int i=0; i<size(hydras); i++) {
    hydra *h = (hydra*) loadS();
    hydras[i] = h;
    M[h->pos].h = h;
    if(h->color == HC_TWIN) twin = h;
    }
  
  char x; if(error || fread(&x, 1, 1, savefile) != 0) error = true;
  
  fclose(savefile);
  stats.savecount++;
  
  if(error) { 
    printf("Error while loading savegame - file deleted\n"); 
    deleteGame();
    exit(0);
    }
  else gameExists = true;
  }