int
building_create(int type, int x, int y)
{
  Building* building;

  if (type == 1)
    {
      building = 0;
    }
  else
    {
      AList props;
      props.set_int("x-pos", x);
      props.set_int("y-pos", y);
      building = BuildingTypeManager::current()->create_building(type, props);
    }

  if (building)
    {
      BuildingManager::current()->add_building(building, x, y);
      return building->get_id();
    }
  else
    {
      std::cout << "BuildingCommands: Unhandled building type: " << type << std::endl;
      return 0;
    }
}
Esempio n. 2
0
ADVBConfig::ADVBConfig() : config(AString(DEFAULTCONFDIR).CatPath("dvb"), false),
						   defaults(20, &AString::DeleteString),
						   webresponse(false)
{
	static const struct {
		const char *name;
		const char *value;
	} __defaults[] = {
		{"prehandle",  		 	"2"},
		{"posthandle", 		 	"3"},
		{"pri", 	   		 	"0"},
		{"dir",              	""},
		{"h264crf",      	 	"17"},
		{"maxvideorate", 	 	"2000k"},
		{"aacbitrate", 	 	 	"160k"},
		{"mp3bitrate", 	 	 	"160k"},
		{"copyvideo", 	 	 	"-vcodec copy"},
		{"copyaudio", 	 	 	"-acodec copy"},
		{"mp3audio",  	 	 	"-acodec mp3 -b:a {conf:mp3bitrate}"},
		{"h264preset",   	 	"veryfast"},
		{"h264bufsize",  	 	"3000k"},
		{"videodeinterlace", 	"yadif"},
		{"videofilter",  	 	"-filter:v {conf:videodeinterlace}"},
		{"filters",		 	 	"{conf:videofilter} {conf:audiofilter}"},
		{"encodeflags",	 	 	"-movflags +faststart"},
		{"h264video", 	 	 	"-vcodec libx264 -preset {conf:h264preset} -crf {conf:h264crf} -maxrate {conf:maxvideorate} -bufsize {conf:h264bufsize} {conf:encodeflags} {conf:filters}"},
		{"aacaudio",  	 	 	"-acodec libfdk_aac -b:a {conf:aacbitrate}"},
		{"encodecopy",   	 	"{conf:copyvideo} {conf:mp3audio}"},
		{"encodeh264",   	 	"{conf:h264video} {conf:aacaudio}"},
		{"encodeargs",   	 	"{conf:encodeh264}"},
		{"encodeaudioonlyargs", "{conf:mp3audio}"},
	};
	uint_t i;

	for (i = 0; i < NUMBEROF(__defaults); i++) {
		defaults.Insert(__defaults[i].name, (uptr_t)new AString(__defaults[i].value));
	}

	CreateDirectory(GetConfigDir());
	CreateDirectory(GetDataDir());
	CreateDirectory(GetLogDir());
	CreateDirectory(GetRecordingsStorageDir());
	CreateDirectory(GetRecordingsDir());
	CreateDirectory(GetTempDir());

	if (CommitScheduling()) {
		AList   users;
		AString dir;

		ListUsers(users);

		const AString *user = AString::Cast(users.First());
		while (user) {
			if (((dir = GetRecordingsDir(*user)).Valid())        && (dir.Pos("{") < 0)) CreateDirectory(dir);
			if (((dir = GetRecordingsArchiveDir(*user)).Valid()) && (dir.Pos("{") < 0)) CreateDirectory(dir);

			user = user->Next();
		}
	}
}
Esempio n. 3
0
Tower::Tower(const AList& lst) :
  Building(lst),
  towerbase(resources->get_sprite("feuerkraft/tower/base")),
  towerdamaged (resources->get_sprite("feuerkraft/tower/damaged")),
  towerdestroyed (resources->get_sprite("feuerkraft/tower/destroyed")),
  turret (resources->get_sprite("feuerkraft/tower/turret")),
  steering(),
  orientation(),
  energie (lst.get_int("start-energie", 100)),
  destroyed (false),
  pos()
{  
  //int energie;
  //std::cout << lst.retrieve_int("start-energie", energie) << std::endl;
  //std::cout << lst << std::endl;
  //std::cout << "Tower Energie: " << lst.get_int("start-energie", 100) << std::endl;
  //std::cout << "--Tower Energie: " << lst.get_int("sta-energie", 100) << std::endl;

  orientation = lst.get_float("orientation");
  pos.x = x_pos * 40 + 40;
  pos.y = y_pos * 40 + 40;

  steering = 0;

  Building::properties->register_float("orientation", &orientation);
}
Esempio n. 4
0
int main(int argc, char** argv) {
  cout << "Starting ListTest" << endl;
  fstream successfile;
  AList AL;
  // LList LL = new LList();

  test(AL);
  // test(LL);
  AL.clear();
  //LL.clear();
  testAppend(AL);
  // testAppend(LL);

  if (SUCCESS) {
    successfile.open("success", ios::out);
    if (!successfile) {
      cout << "Unable to open SUCCESS file :";
      exit(-1);
    }
    successfile << "Success";
  }

  if (testsize == 0) {
    exit(-1);
    return 0;
  }
  /*
  println("Do the timing test");
  LList LT = new LList();
  time1 = millis();
  for (int i = 0; i < testsize; i++) {
    LL.insert(10);
    LL.insert(15);
    LL.insert(20);
    LL.insert(25);
    LL.clear();
  }
  time2 = millis();
  long totaltime = (time2-time1);
  println("Timing test on " + testsize + " iterations: " + totaltime);

  time1 = millis();
  for (int i = 0; i < testsize; i++) {
    Link temp = new Link(null, null);
    temp = new Link(null, null);
    temp = new Link(null, null);
    temp = new Link(null, null);
    temp = new Link(null, null);
  }
  time2 = millis();
  totaltime = (time2-time1);
  println("Timing test2 on " + testsize + " iterations: " + totaltime);
  */

  exit(-1);
  return 0;
} //end main
Esempio n. 5
0
void mlrVoiceManager::Exec(Tpoint *campos, Trotation *camrot, Tpoint *camvel){
	static const Tpoint upv = { 0, 0, 1 };
	static const Tpoint fwd = { 1, 0, 0 };

	MatrixMult(camrot, &upv, &listenerUp);
	MatrixMult(camrot, &fwd, &listenerFront);
	listenerPosition = *campos;
	listenerVelocity = *camvel;

	Lock();

	mlrVoice *n;
	int channels;
	channels=g_nDynamicVoices;
	// sort the PlayList, store in temp
	AList temp;
	while (n=(mlrVoice *)PlayList.RemHead()){
		n->PreExec();
		temp.AddSorted((ANode *)n);
	}

	// filter out what will be played
	while (n=(mlrVoice *)temp.RemHead()){
		if(( n->status==mlrVoice::VSSTART || n->status==mlrVoice::VSPLAYING ) && channels > 0){
			PlayList.AddTail(n); // maintain sortedness
			channels--;
		}
		else {
			n->ReleaseBuffers();
			HoldList.AddTail(n);		
		}
	}

	channels=g_nDynamicVoices;
	// make these allocate their sound buffers
	// then exec()
	if (SimDriver.MotionOn()){
		n=(mlrVoice *)PlayList.GetHead();
		while (n){
			//COUNT_PROFILE("VOICEMAN_COUNT");
			n->AllocateBuffers();
			n->Exec();
			n=(mlrVoice *)n->GetSucc();
		} 
	}
	else{
		n=(mlrVoice *)PlayList.GetHead();
		while (n){
			n->Pause();
			n=(mlrVoice *)n->GetSucc();
		} 

	}

	Unlock();
}
Esempio n. 6
0
int ARegion::CanBeStartingCity( ARegionArray *pRA )
{
	if(type == R_OCEAN) return 0;
    if (!IsCoastal()) return 0;
    if (town && town->pop == 5000) return 0;

    int regs = 0;
    AList inlist;
    AList donelist;

    ARegionPtr * temp = new ARegionPtr;
    temp->ptr = this;
    inlist.Add(temp);

    while(inlist.Num()) {
        ARegionPtr * reg = (ARegionPtr *) inlist.First();
        for (int i=0; i<NDIRS; i++) {
            ARegion * r2 = reg->ptr->neighbors[i];
            if (!r2) continue;
            if (r2->type == R_OCEAN) continue;
            if (GetRegion(&inlist,r2->num)) continue;
            if (GetRegion(&donelist,r2->num)) continue;
            regs++;
            if (regs>20) return 1;
            ARegionPtr * temp = new ARegionPtr;
            temp->ptr = r2;
            inlist.Add(temp);
        }
        inlist.Remove(reg);
        donelist.Add(reg);
    }
    return 0;
}
Esempio n. 7
0
File: main.cpp Progetto: palmerc/lab
int main()
{
   AList L;
       
   cout << "insert test" << endl;
   for (int i=1; i <= 10; i++)
   {
      L.insert(i);
   }
   
   L.printAList();
   
   cout << "finding a value" << endl;
   L.find(5);   
   L.printAList();
      
   return 0;
}
Soldier::Soldier(const AList& lst) :
  ai(0),
  sur(resources->get_sprite("feuerkraft/soldier")),
  sur_light(resources->get_sprite("feuerkraft/soldier-light")),
  acceleration(),
  steering()
{
  pos.x = lst.get_float("x-pos");
  pos.y = lst.get_float("y-pos");
}
Esempio n. 9
0
Marker::Marker(const AList& lst)
{
  passed_time = 0;
  properties->register_float("x-pos", &pos.x);
  properties->register_float("y-pos", &pos.y);

  pos.x = lst.get_float("x-pos");
  pos.y = lst.get_float("y-pos");

  sprite = resources->get_sprite("feuerkraft/marker");
  sprite.set_blend_func(blend_src_alpha, blend_one);
}
CustomBuilding::CustomBuilding(const AList& type, const AList& lst) :
  Building(lst),
  sprite(),
  energie(),
  width(),
  height()
{
  std::string sprite_str = "feuerkraft/nobuilding";
  int         i_energie = 100;
  width   = 2;
  height  = 2;

  type.retrieve_string("sprite",  sprite_str);
  type.retrieve_int   ("energie", i_energie);
  type.retrieve_int   ("width",   width);
  type.retrieve_int   ("height",  height);

  energie.set_max_energie(i_energie);

  sprite = resources->get_sprite(sprite_str);
}
int
building_create_type(const char* name, SCM lst)
{
  AList alist;
  
  while(!gh_null_p(lst))
    {
      SCM key   = gh_car(lst);

      if (gh_null_p(gh_cdr(lst)))
        {
          std::cout << "Missing argument to keyword!" << std::endl;
        }

      SCM value = gh_cadr(lst);

      if (gh_boolean_p(value))
        {
          alist.set_bool(Guile::keyword2string(key), gh_scm2bool(value));
        }
      else if (gh_number_p(value))
        {
          alist.set_int(Guile::keyword2string(key), gh_scm2int(value));
        }
      else if (gh_string_p(value))
        {
          alist.set_string(Guile::keyword2string(key), Guile::scm2string(value));
        }
      else
        {
          std::cout << "BuildingCommands: unknown argumnent type" << std::endl;
        }

      lst = gh_cddr(lst);
    }

  return BuildingTypeManager::current()->register_factory(new CustomBuildingFactory(name, alist));
}
void
OutputWorldBuilder::print_alist(const AList& alist)
{
  for(AList::const_iterator i = alist.begin(); i != alist.end(); ++i)
    {
      std::cout << "  " << i->first << " -> ";
      switch(i->second.type)
        {
        case AList::AL_INT:
          std::cout << i->second.v_int << std::endl;
          break;
        case AList::AL_FLOAT:
          std::cout << i->second.v_float << std::endl;
          break;
        case AList::AL_BOOL:
          std::cout << i->second.v_bool << std::endl;
          break;
        case AList::AL_STRING:
          std::cout << *i->second.v_string << std::endl;
          break;
        case AList::AL_INTVECTOR2D:
          std::cout << "[" << (*i).second.v_int_vector2d.x
                    << ", " << (*i).second.v_int_vector2d.y
                    << "]"
                    << std::endl;
          break;
          /*case AList::AL_FLOATVECTOR2D:
          std::cout << "[" << (*i).second.v_float_vector2d.x
                    << ", " << (*i).second.v_float_vector2d.y
                    << "]"
                    << std::endl;
                    break;*/
        default:
          std::cout << "<unhandled>" << std::endl;
          break;
        }
    }
}
Esempio n. 13
0
bool TraverseFiles(const AList& list, bool (*fn)(const AFileNode& file, void *context), void *context)
{
	const AListNode *node = list.First();
	const AFileNode *file;
	bool  success = true;

	while (node && success) {
		if ((file = AFileNode::Cast(node)) != NULL) {
			success = (*fn)(*file, context);
		}

		node = node->Next();
	}

	return success;
}
Esempio n. 14
0
bool TraverseFiles(const AList& list, bool (*fn)(const FILE_INFO *file, void *context), void *context)
{
	FILE_INFO file;
	const AListNode *node = list.First();
	const AString *str;
	bool  success = true;

	while (node && success) {
		if ((str = AString::Cast(node)) != NULL) {
			success = ::GetFileInfo(*str, &file);
			if (success) success = (*fn)(&file, context);
		}

		node = node->Next();
	}

	return success;
}
WallDoor::WallDoor(const AList& lst) :
  Building(lst),
  sprite(),
  map_width(),
  map_height(),
  status(),
  pos()
{
  if (lst.get_string("orientation") == "vertical")
    {
      sprite = resources->get_sprite("feuerkraft/vdoor");
      pos = FloatVector2d(x_pos * 40 + 20, y_pos * 40 + 60);
      map_width = 1;
      map_height = 3;
    }
  else 
    {
      sprite = resources->get_sprite("feuerkraft/hdoor");
      pos = FloatVector2d(x_pos * 40 + 60, y_pos * 40 + 20);
      map_width = 3;
      map_height = 1;
    }
}
Esempio n. 16
0
void ADVBConfig::ListUsers(AList& list) const
{
	AHash 	 users(10);
	AList 	 userpatterns;
	AString  filepattern 	   = GetUserPatternsPattern();
	AString  filepattern_parsed = ParseRegex(filepattern);
	AString  _users             = GetConfigItem("users");
	AStdFile fp;
	uint_t   i, n = _users.CountColumns();

	//debug("Reading users from config %s\n", config.GetFilename().str());

	for (i = 0; i < n; i++) {
		AString user = _users.Column(i).Words(0);

		if (!users.Exists(user)) {
			users.Insert(user, 0);
			list.Add(new AString(user));
		}
	}

	if (fp.open(GetPatternsFile())) {
		AString line;

		while (line.ReadLn(fp) >= 0) {
			AString user;
			int p;

			if		((p = line.PosNoCase(" user:="******"user:=") == 0)        user = line.Mid(6).Word(0).DeQuotify();

			if (user.Valid() && !users.Exists(user)) {
				users.Insert(user, 0);
				list.Add(new AString(user));
			}
		}

		fp.close();
	}

	::CollectFiles(filepattern.PathPart(), filepattern.FilePart(), 0, userpatterns);

	const AString *file = AString::Cast(userpatterns.First());
	while (file) {
		AString   user;
		ADataList regions;

		if (MatchRegex(*file, filepattern_parsed, regions)) {
			const REGEXREGION *region = (const REGEXREGION *)regions[0];

			if (region) {
				user = file->Mid(region->pos, region->len);
				if (!users.Exists(user)) {
					users.Insert(user, 0);
					list.Add(new AString(user));
				}
			}
		}

		file = file->Next();
	}

	list.Sort(&AString::AlphaCompareCase);
}
Esempio n. 17
0
void KeyPressed(unsigned char ch, int x, int y)
{

  if(ch == ' ')
  {

    	Point3 p(Xpos,Ypos,Zpos);
    	Vector d(Xrot,Yrot,Zrot);
		Agent a(p,2.0,2.0,1.0,1.0,d,1,NULL);
        //a.xrot=Xrot; a.yrot=Yrot; a.zrot=Zrot;
		Agents.push_back(a);
		nAgents++;

	}

  switch (ch)
  {
  // ESC key to exit program
 	case 27:             /* ESC */
	 	//delete Env; //->CloseOutFile();
        exit(0);
	break;

	case 'y' :
    		Ypos +=0.5;
	        if(Ypos > bb->center.y+bb->height/2)
            	Ypos =bb->center.y+bb->height/2;

 	break;
	case 'b' :
    		Ypos -=0.5;
   	        if(Ypos < bb->center.y-bb->height/2)
            	Ypos =bb->center.y-bb->height/2;

    break;

	case 'h' :
    		Xpos +=0.5;
	        if(Xpos > bb->center.x+bb->width/2)
            	Xpos =bb->center.x+bb->width/2;

    break;
	case 'g' :
    		Xpos -=0.5;
    		if(Xpos < bb->center.x-bb->width/2)
            	Xpos =bb->center.x-bb->width/2;

    break;

    case 'j' :
    		Zpos +=0.5;
			if(Zpos > bb->center.z+bb->depth/2)
            	Zpos =bb->center.z+bb->depth/2;
    break;

    case 'u' : Zpos -=0.5;
   			if(Zpos < bb->center.z-bb->depth/2)
            	Zpos =bb->center.z-bb->depth/2;



    break;

    case 'z' : Zrot +=0.5; break;
	case 'Z' : Zrot -=0.5; break;
    case 'x' : Xrot +=0.5; break;
	case 'X' : Xrot -=0.5; break;
	case 'c' : Yrot +=0.5; break;
	case 'C' : Yrot -=0.5; break;
	case 's' :

    if ((stream = fopen(fname, "wt")) == NULL)
	{
        cout << "Failed to open file for writing : "<< fname<<endl;
        exit(0);
    }
	fprintf(stream,"%ld\n",nAgents);
    for(unsigned long int i=0; i<nAgents; i++)
    	{
        fprintf(stream,"%f %f %f %f %f %f\n",Agents[i].Pos.x,Agents[i].Pos.y,Agents[i].Pos.z,
        				Agents[i].Dir.x,Agents[i].Dir.y,Agents[i].Dir.z);


        }
	fclose(stream);

    default :
  break;
  }
  // tell the system we need to redisplay
 glutPostRedisplay();
}
Esempio n. 18
0
void process(type t){
    AList<type> alist;
    type data;
    int size;
    cin >> size;
    for(int i=0; i<size; i++){
        cin >> data;
        alist.append(data);
    }
    alist.traverse();
    alist.insert(1,100);
    alist.traverse();
    alist.remove(6);
    alist.traverse();
    alist.append(88);
    alist.traverse();
    alist.append(90);
    alist.traverse();
    alist.clear();
    alist.traverse();
}
Esempio n. 19
0
int AGetName(int town, ARegion *reg)
{
	int unique, rnd, syllables, i, trail, port, similar;
	unsigned int u;
	char temp[80];
	AString *name;

	port = 0;
	if (town) {
		for (i = 0; i < NDIRS; i++)
			if (reg->neighbors[i] &&
					TerrainDefs[reg->neighbors[i]->type].similar_type == R_OCEAN)
				port = 1;
	}

	unique = 0;
	while (!unique) {
		rnd = getrandom(tSyll);
		for (syllables = 0; rnd >= syllprob[syllables]; syllables++)
			rnd -= syllprob[syllables];
		syllables++;
		temp[0] = 0;
		trail = 0;
		while (syllables-- > 0) {
			if (!syllables) {
				// Might replace the last syllable with a
				// terrain specific suffix
				rnd = getrandom(400);
				similar = TerrainDefs[reg->type].similar_type;
				// Use forest names for underforest
				if (similar == R_UFOREST)
					similar = R_FOREST;
				// ocean (water) names for lakes
				if (similar == R_LAKE)
					similar = R_OCEAN;
				// and plains names for cavern
				if (similar == R_CAVERN)
					similar = R_PLAIN;
				for (u = 0; u < sizeof(ts) / sizeof(ts[0]); u++) {
					if (ts[u].terrain == similar ||
							ts[u].terrain == -1 ||
							(ts[u].town && town) ||
							(ts[u].port && port)) {
						if (rnd >= ts[u].prob)
							rnd -= ts[u].prob;
						else {
							if (trail) {
								switch(ts[u].word[0]) {
									case 'a':
									case 'e':
									case 'i':
									case 'o':
									case 'u':
										strcat(temp, "'");
										break;
									default:
										break;
								}
							}
							strcat(temp, ts[u].word);
							break;
						}
					}
				}
				if (u < sizeof(ts) / sizeof(ts[0]))
					break;
			}
			if (getrandom(5) > 0) {
				// 4 out of 5 syllables start with a consonant sequence
				rnd = getrandom(tIC);
				for (i = 0; rnd >= ic[i].prob; i++)
					rnd -= ic[i].prob;
				strcat(temp, ic[i].word);
			} else if (trail) {
				// separate adjacent vowels
				strcat(temp, "'");
			}
			// All syllables have a vowel sequence
			rnd = getrandom(tV);
			for (i = 0; rnd >= v[i].prob; i++)
				rnd -= v[i].prob;
			strcat(temp, v[i].word);
			if (getrandom(5) > 1) {
				// 3 out of 5 syllables end with a consonant sequence
				rnd = getrandom(tFC);
				for (i = 0; rnd >= fc[i].prob; i++)
					rnd -= fc[i].prob;
				strcat(temp, fc[i].word);
				trail = 0;
			} else {
				trail = 1;
			}
		}
		temp[0] = toupper(temp[0]);
		unique = 1;
		forlist(&regionnames) {
			name = (AString *) elem;
			if (*name == temp) {
				unique = 0;
				break;
			}
		}
		if (strlen(temp) > 12)
			unique = 0;
	}

	nnames++;
	if (town)
		ntowns++;
	else
		nregions++;

	name = new AString(temp);
	regionnames.Add(name);

	return regionnames.Num();
}