Пример #1
0
char *
obj2devname(uint32_t tag, set_t setno, md_dev64_t dev)
{
	char		*setname;
	char		*uname;
	char		name[MD_MAX_CTDLEN];
	mdsetname_t	*sp;
	md_error_t	status = mdnullerror;
	md_set_record	*md_sr;
	minor_t		mnum = meta_getminor(dev);
	int		rtn = 0;

	setname = NULL;
	if ((setno != MD_SET_BAD) &&
		((sp = metasetnosetname(setno, &status)) != NULL)) {
		setname = sp->setname;
	}

	name[0] = '\0';
	switch (tag) {
	case SVM_TAG_HS:
	case SVM_TAG_METADEVICE:
	case SVM_TAG_MIRROR:
	case SVM_TAG_RAID5:
	case SVM_TAG_STRIPE:
	case SVM_TAG_TRANS:
		uname = get_mdname(sp, mnum);
		if (uname == NULL)
			return (NULL);

		(void) strcpy(name, uname);
		break;
	case SVM_TAG_HSP:
		uname = get_hspname(sp, mnum);
		if (uname == NULL)
			return (NULL);

		(void) strcpy(name, uname);
		break;
	case SVM_TAG_DRIVE:
		(void) sprintf(name, "drive");
		break;
	case SVM_TAG_HOST:
		md_sr = NULL;
		if (setname != NULL) {
			md_sr = getsetbyname(setname, &status);
		}
		if ((md_sr != NULL) && (md_sr->sr_nodes[mnum] != NULL)) {
			/*
			 * Get the host data from the node array.
			 */
			rtn = snprintf(name, sizeof (name), "%s",
			    md_sr->sr_nodes[mnum]);
		}
		if ((name[0] == '\0') || (rtn >= sizeof (name))) {
			(void) sprintf(name, "host");
			rtn = 0;
		}
		break;
	case SVM_TAG_SET:
		if (setname == NULL) {
			(void) sprintf(name, "diskset");
		} else {
			rtn = snprintf(name, sizeof (name), "%s", setname);
		}
		break;
	default:
		if ((setname = get_devname(setno, dev)) != NULL) {
			rtn = snprintf(name, sizeof (name), "%s", setname);
		}
		break;
	}
	mdclrerror(&status);

	/* Check if we got any rubbish for any of the snprintf's */
	if ((name[0] == '\0') || (rtn >= sizeof (name))) {
		return (NULL);
	}

	return (strdup(name));
}
Пример #2
0
int main( int argc, char* argv[] )
{
  //Initialisieren
    ZWattribute=ZWgetattribute();
    load_options();
    ZWinitparameter();
    ZWattribute->strech=stretched;
    if (fullscreen)
    {
      ZWattribute->width=resolutionx;
      ZWattribute->height=resolutiony;
      ZWattribute->sdlflags|=SDL_FULLSCREEN;
    }
    else
    {
      ZWattribute->width=windowx;
      ZWattribute->height=windowy;
    }
    ZWattribute->quit_function=quit_function;
    ZWattribute->initflags|=SDL_INIT_AUDIO;
		
		load_mapping();
		
    ZWinitsdl();
    
    int audio_rate = 44100;
    Uint16 audio_format = AUDIO_S16SYS; 
    int audio_channels = 2;
    int audio_buffers = 2048;
    if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers))
    {
      printf("Unable to open audio!\n");
      exit(1);
   }
    
    if ((ZWattribute->sdlflags & SDL_FULLSCREEN)==0) //SDL_FULLSCREEN nicht mehr gesetzt? AAAAHHHH!
    {
      fullscreen=0;
      windowx=ZWattribute->width;
      windowy=ZWattribute->height;
      resolutionx=ZWattribute->resolution[0].x;
      resolutiony=ZWattribute->resolution[0].y;
    }
    ZWinitopengl();    
    setup_opengl();
    glHint(GL_POLYGON_SMOOTH_HINT,GL_FASTEST);
    init_var();
        
  //Level laden
    if (argc<2)
    {
      printf("Not enough arguments\n");
      printf("testboard file.opxml [player]\n");
      ZWquitfont();
      ZWquitsdl();      
      return 1;
    }
    if (loadlevel(argv[1])==1)
    {
      printf("File %s not found\n",argv[1]);
      ZWquitfont();
      ZWquitsdl();   
      return 1;
    }  
    refreshsetlist();

  //Minispielliste laden
	  load_minigames();
		save_minigames();

  /*//zu Debugzwecken Set 0 bis 60 ausgeben:
  for (int a=0;a<61;a++)
  {
    if (setbynr[a]==NULL)
      printf("Set %i: NULL\n",a);
    else
      printf("Set %i: \"%s\"\n",a,setbynr[a]->type);  
  }*/

  //Debug
    if (argc>3 && argv[3][0]=='c')
      all_are_cpu=1;

  //Spielvorbereitungen
    if (argc>2)
      playernum=atoi(argv[2]);
    playernum=(playernum-1)%8+1;

		
		if (argc>3 && argv[3][1]=='2')
		{
			playernum=((playernum+1)/2)*2;
			if (playernum<4)
			  playernum=4;
			teamsize=2;
		}
		if (argc>3 && argv[3][1]=='3')
		{
			playernum=6;
			teamsize=3;
		}
		if (argc>3 && argv[3][1]=='4')
		{
			playernum=8;
			teamsize=4;
		}		

    pset startset=getsetbyname((char*)"start");
    if (startset==NULL) startset=firstset;
		prepare_game(startset,1);
		
    
  ZWreset_virtuell_joytick();
  //Controller festlegen:
  for (int a=0;a<playernum;a++)
  {
		if (all_are_cpu)
		  maindata.player[a].joystick_nr=-1;
		else		  
		  maindata.player[a].joystick_nr=a%ZWattribute->realjoystickcount;
  }
	calib_all_controllers();
  //Spiel starten
    Mix_FadeInMusic(backgroundmusic, -1,FADE_IN_TIME);
    ZWattribute->newticks=SDL_GetTicks();
    ZWschleifeex((void(*)(void*))draw_main,(int(*)(void*))calc_main_thread,(int(*)(void*))calc_main,
                 (void*)(&maindata),sizeof(tmaindata));    
    Mix_HaltMusic();
  //alles wieder freigeben
    reset_after_game();
    del_objects();
    del_sounds();
    Mix_CloseAudio();
    ZWquitfont();
    ZWquitsdl();
  return 0;
}