~ScoreComparerTestFixture()    //TearDown fixture
 {
     m_msg.str("");
     m_msg << endl;
 }
bool cScreenGirlDetails::check_keys()
{
	if (g_LeftArrow)
	{
		g_LeftArrow = false;
		PrevGirl();
		return true;
	}
	if (g_RightArrow)
	{
		g_RightArrow = false;
		NextGirl();
		return true;
	}

	if (g_AltKeys)
	{
		if (g_A_Key)
		{
			g_A_Key = false;
			PrevGirl();
			return true;
		}
		if (g_D_Key)
		{
			g_D_Key = false;
			NextGirl();
			return true;
		}
		if (g_H_Key || g_J_Key)
		{
			int mod = 1; if (g_H_Key) mod = -1;
			g_Girls.UpdateStat(selected_girl, STAT_HOUSE, mod);
			g_H_Key = g_J_Key = false;
			SliderValue(houseperc_id, g_Girls.GetStat(selected_girl, STAT_HOUSE));
			ss.str("");
			ss << gettext("House Percentage: ") << g_Girls.GetStat(selected_girl, STAT_HOUSE) << gettext("%");
			EditTextItem(ss.str(), housepercval_id);
			// Rebelliousness might have changed, so update details
			if (DetailLevel == 0)
			{
				string detail = g_Girls.GetDetailsString(selected_girl);
				EditTextItem(detail, girldesc_id);
			}

			return true;
		}
		if (g_S_Key)
		{
			g_S_Key = false;
			if (g_ShiftDown)
			{
				DetailLevel = 2;
				EditTextItem(g_Girls.GetThirdDetailsString(selected_girl), girldesc_id);
			}
			else
			{
				if (DetailLevel == 0)		{ DetailLevel = 1; EditTextItem(g_Girls.GetMoreDetailsString(selected_girl), girldesc_id); }
				else						{ DetailLevel = 0; EditTextItem(g_Girls.GetDetailsString(selected_girl), girldesc_id); }
			}
			return true;
		}
		if (g_SpaceKey)
		{
			g_SpaceKey = false;
			g_WinManager.push("Gallery");
			g_InitWin = true;
			return true;
		}
	}
	return false;
}
Example #3
0
File: main.cpp Project: Fissh21/AI
DLLEXP void h3dutShowFrameStats( H3DRes fontMaterialRes, H3DRes boxMaterialRes, int mode )
{
	static stringstream text;
	static float curFPS = 30;
	static float timer = 100;
	static float fps = 30;
	static float frameTime = 0;
	static float animTime = 0;
	static float geoUpdateTime = 0;
	static float particleSimTime = 0;
	static float fwdLightsGPUTime = 0;
	static float defLightsGPUTime = 0;
	static float shadowsGPUTime = 0;
	static float particleGPUTime = 0;

	// Calculate FPS
	float curFrameTime = h3dGetStat( H3DStats::FrameTime, true );
	curFPS = 1000.0f / curFrameTime;
	
	timer += curFrameTime / 1000.0f;
	if( timer > 0.7f )
	{	
		fps = curFPS;
		frameTime = curFrameTime;
		animTime = h3dGetStat( H3DStats::AnimationTime, true );
		geoUpdateTime = h3dGetStat( H3DStats::GeoUpdateTime, true );
		particleSimTime = h3dGetStat( H3DStats::ParticleSimTime, true );
		fwdLightsGPUTime = h3dGetStat( H3DStats::FwdLightsGPUTime, true );
		defLightsGPUTime = h3dGetStat( H3DStats::DefLightsGPUTime, true );
		shadowsGPUTime = h3dGetStat( H3DStats::ShadowsGPUTime, true );
		particleGPUTime = h3dGetStat( H3DStats::ParticleGPUTime, true );
		timer = 0;
	}
	else
	{
		// Reset accumulative counters
		h3dGetStat( H3DStats::AnimationTime, true );
		h3dGetStat( H3DStats::GeoUpdateTime, true );
		h3dGetStat( H3DStats::ParticleSimTime, true );
	}
	
	if( mode > 0 )
	{
		// InfoBox
		beginInfoBox( 0.03f, 0.03f, 0.32f, 4, "Frame Stats", fontMaterialRes, boxMaterialRes );
		
		// FPS
		text.str( "" );
		text << fixed << setprecision( 2 ) << fps;
		addInfoBoxRow( "FPS", text.str().c_str() );
		
		// Triangle count
		text.str( "" );
		text << (int)h3dGetStat( H3DStats::TriCount, true );
		addInfoBoxRow( "Tris", text.str().c_str() );
		
		// Number of batches
		text.str( "" );
		text << (int)h3dGetStat( H3DStats::BatchCount, true );
		addInfoBoxRow( "Batches", text.str().c_str() );
		
		// Number of lighting passes
		text.str( "" );
		text << (int)h3dGetStat( H3DStats::LightPassCount, true );
		addInfoBoxRow( "Lights", text.str().c_str() );
	}

	if( mode > 1 )
	{
		// Video memory
		beginInfoBox( 0.03f, 0.30f, 0.32f, 2, "VMem", fontMaterialRes, boxMaterialRes );
		
		// Textures
		text.str( "" );
		text << h3dGetStat( H3DStats::TextureVMem, false ) << "mb";
		addInfoBoxRow( "Textures", text.str().c_str() );
		
		// Geometry
		text.str( "" );
		text << h3dGetStat( H3DStats::GeometryVMem, false ) << "mb";
		addInfoBoxRow( "Geometry", text.str().c_str() );
		
		// CPU time
		beginInfoBox( 0.03f, 0.44f, 0.32f, 4, "CPU Time", fontMaterialRes, boxMaterialRes );
		
		// Frame time
		text.str( "" );
		text << frameTime << "ms";
		addInfoBoxRow( "Frame Total", text.str().c_str() );
		
		// Animation
		text.str( "" );
		text << animTime << "ms";
		addInfoBoxRow( "Animation", text.str().c_str() );

		// Geometry updates
		text.str( "" );
		text << geoUpdateTime << "ms";
		addInfoBoxRow( "Geo Updates", text.str().c_str() );

		// Particle simulation
		text.str( "" );
		text << particleSimTime << "ms";
		addInfoBoxRow( "Particles", text.str().c_str() );

		// GPU time
		beginInfoBox( 0.03f, 0.65f, 0.32f, 3, "GPU Time", fontMaterialRes, boxMaterialRes );

		// Forward and deferred lights
		text.str( "" );
		text << (fwdLightsGPUTime + defLightsGPUTime) << "ms";
		addInfoBoxRow( "Lights", text.str().c_str() );
		
		// Shadows
		text.str( "" );
		text << shadowsGPUTime << "ms";
		addInfoBoxRow( "Shadows", text.str().c_str() );

		// Particles
		text.str( "" );
		text << particleGPUTime << "ms";
		addInfoBoxRow( "Particles", text.str().c_str() );
	}
}
Example #4
0
int main(int argc, char* argv[]) 
{
	heartbeats=256;                 
	ecgsample=256;               
	internalsample=256;
	amplitudenoise=0.0;          
	heart_rate_mean=60.0;        
	heart_rate_std=1.0;          
	lowfreq=0.1;             
	highfreq=0.25;           
	lowfreqstd=0.01;         
	highfreqstd=0.01;        
	lfhfradio=0.5; 

	if (!parse_args_pub_ecg(argc,argv,hostip,port,domainid,deviceid,loginfo,logdata,logconfpath,heartbeats,ecgsample,internalsample,
amplitudenoise,heart_rate_mean,heart_rate_std,lowfreq,highfreq,lowfreqstd,highfreqstd,lfhfradio))
    	return 1;
	
	/*Importing log4cpp configuration and Creating category*/
	log4cpp::Category &log_root = log4cpp::Category::getRoot();
    	log4cpp::Category &bloodInfo = log4cpp::Category::getInstance( std::string(loginfo));
    	log4cpp::Category &bloodData = log4cpp::Category::getInstance( std::string(logdata));
	log4cpp::PropertyConfigurator::configure(logconfpath);
	bloodInfo.notice(" ecg Publisher Started "+deviceid);
	
	/*Initializing SimpleDDS library*/
	SimpleDDS *simpledds;
	ECGTypeSupport_var typesupport;
	DataWriter_ptr writer;
	ECGDataWriter_var ecgWriter;


	simpledds = new SimpleDDS();
	typesupport = new ECGTypeSupport();
	writer = simpledds->publish(typesupport);
	ecgWriter = ECGDataWriter::_narrow(writer);
	hostInfo = gethostbyname(hostip.c_str());

	/*Initializing Socket Data*/
	if (hostInfo == NULL) 
	{
		bloodInfo.error(" Problem interpreting By HostInfo");
		bloodInfo.notice(" ecg Publisher Ends");	
		//exit(1);
	}
	serverPort=port;
	cin.get(c); 
	socketDescriptor = socket(AF_INET, SOCK_STREAM, 0);
	if (socketDescriptor < 0) 
	{
		bloodInfo.error(" Not able create the Socket");
		bloodInfo.notice(" ecg Publisher Ends");	
		//exit(1);
	}
	serverAddress.sin_family = hostInfo->h_addrtype;
	memcpy((char *) &serverAddress.sin_addr.s_addr,hostInfo->h_addr_list[0], hostInfo->h_length);
	serverAddress.sin_port = htons(serverPort);

	/*Binding Socket with Server Data Generator*/
	if (connect(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress)) < 0) 
	{
		bloodInfo.error(" cannot connect with server");
		bloodInfo.notice(" ecg Publisher Ends at ");
		//exit(1);
	}

	/*Sending Commmand to The Data Generator*/
	datacommand<<"ECG"<<SEMI<<heartbeats<<SEMI<<ecgsample<<SEMI<<internalsample<<SEMI<<amplitudenoise;
	datacommand<<SEMI<<heart_rate_mean<<SEMI<<heart_rate_std<<SEMI<<lowfreq<<SEMI<<highfreq<<SEMI<<lowfreqstd<<SEMI<<highfreqstd<<SEMI<<lfhfradio;
	strcpy(buf,datacommand.str().c_str());
	if (send(socketDescriptor, buf, strlen(buf) + 1, 0) < 0)
	{
		bloodInfo.error(" Not able to send data");
		close(socketDescriptor);
		bloodInfo.notice(" ecg Publisher Ends");
		//exit(1);
	}

	flag=0;
	ECG data;

	/*Storing Domain and Device ID*/
	data.deviceID = DDS::string_dup(deviceid.c_str());
	data.deviceDomain = DDS::string_dup(domainid.c_str());
	bloodInfo.notice("ecg Started Publishing Data In DDS");
	bloodInfo.notice("Format: DOMAIN, DEVICEID, TIMEOFMEASURED, TimeInSeconds, AmplitudeMillivolts, WaveformPeak, StandardDeviation, Signal");	
	long count=0;
	while (1) 
	{
		
		if ((sizebuf=recv(socketDescriptor, buf, 1024,  MSG_NOSIGNAL)) > 0) 
		{
			cout<<"\n"<<buf;
			buf[sizebuf]='\0';
			string datasplit[7];
			datasplit[0] = strtok (buf,SEMI);
			datasplit[1] = strtok (NULL,SEMI);
			datasplit[2] = strtok (NULL,SEMI);
			datasplit[3] = strtok (NULL,SEMI);
			datasplit[4] = strtok (NULL,SEMI);
			datasplit[5] = strtok (NULL,SEMI);

			prtemp<<domainid<<COMMA<<deviceid<<COMMA;

			data.timeOfMeasurement = atol(datasplit[0].c_str());
			prtemp<<data.timeOfMeasurement<<COMMA;

			data.timeInSeconds = (double)atof(datasplit[1].c_str());		
			prtemp<<data.timeInSeconds<<COMMA;

                        data.amplitudeMillivolts = (double)atof(datasplit[2].c_str());   
                        prtemp<<data.amplitudeMillivolts<<COMMA;
			
			data.waveformPeak = (short)atoi(datasplit[3].c_str());   
                        prtemp<<data.waveformPeak<<COMMA;
					
			data.standardDeviation = (double)atof(datasplit[4].c_str());
			prtemp<<data.standardDeviation<<COMMA;


			data.signalECG = (double)atof(datasplit[5].c_str());
			prtemp<<data.signalECG;

			//bloodData.info(prtemp.str().c_str());
			if (RETCODE_OUT_OF_RESOURCES  == ecgWriter->write(data, NULL))
			{ cout << "\n Out of Resource ";}

			cout<<"\n"<<prtemp.str().c_str()<<count++;
			int newflag=-1;
			while(newflag <= 0)
			{
				newflag=send(socketDescriptor,prtemp.str().c_str(),1024,  MSG_NOSIGNAL);
				
				
			}
			prtemp.str(CLEAN);
			fflush(stdout);
						
		}
		
		
	

	}
	
	/*Deleting SimpleDDS Instance*/
	bloodInfo.notice(" ecg Publisher Ends");
	simpledds->deleteWriter(writer);
	delete simpledds;
	return 0;
}
void forwardpacket(string response) {
	// It's going to either be a linkstatepacket, tracepacket, or ackpacket
	vector<string> packParts = explode(" ", response);
	string type = packParts[0];
	Socket sock = Socket();
	if(type.compare("T") == 0) {
		// trace packet
		
	} else if(type.compare("A") == 0) {
		// ack packet - we know one of our neighbors is online. Should only occur when we run createroutes.
		HSPacket ack = HSPacket(response);
		
		// Debugging information
		stringstream write;
		write << "Recieved ack packet from: " << ack.sourceIP() << " on port: " << ack.sourcePort();
		cout << colorize(write.str(), "green");
		
		string destIP = ack.sourceIP();
		int destPort = ack.sourcePort();
		
		HSPacket response = HSPacket().type('R').sourceIP(host).sourcePort(port).destinationIP(destIP).destinationPort(destPort);
		
		sock.send(destIP, destPort, response.toString());
		
		// Used to create reliable transfer
		sequenceNumber++;
		
	} else if(type.compare("R") == 0) {
		// Here's we're getting responses from acks
		HSPacket r = HSPacket(response);
		
		// Debugging information
		debug << "Recieved response packet from: " << r.sourceIP() << " on port: " << r.sourcePort();
		cout << colorize(debug.str(), "red");
		debug.str("");
		
		// Always enable in topology if we got a response packet.
		topology.enable(r.sourceIP(), r.sourcePort());
		
		string ackFromIP = r.sourceIP();
		int ackWithPort = r.sourcePort();
		
		stringstream ss;
		// Remove them from acksNeededFromNeighbors

		for(unsigned int i = 0; i < acksNeededFromNeighbors.size(); i++) {
			Node n = acksNeededFromNeighbors.at(i);
			if(ackFromIP.compare(n.host()) == 0 && ackWithPort == n.port()) {
				acksNeededFromNeighbors.erase(acksNeededFromNeighbors.begin()+i);
				ss.str("");
				ss << "A|" << n.host() << ":" << n.port();
				ackTimer.remove(ss.str());
			}
		}
		
		if(acksNeededFromNeighbors.empty()) {
			ackTimer = Timer();
			// cout << "No more acks needed from neighbors! " << endl;
			// We got all our acks no need to disable a node in our topology. or send in the fire squad (ie. run createroutes)
		}
	} 
	else {
		// Should be a linkstatepacket - forward it on to all neighbors EXCEPT the one we recieved it from
		// After its sent out we should start receiving ack packets from our neighbors
		LSPacket LSP = LSPacket(response);
		
		// Check to see if we should update our topology and send out LSPs and whatnot, by comparing sequence numbers
		// Also will not forward on packets when TTL reaches 0 - this will prevent a buildup of packets in the network.
		if(!shouldUpdate(LSP)) return;
		
		stringstream write;
		write << "Recieved an LSP Packet from " << LSP.id() << " with a TTL of " << LSP.TTL() << " and a seqNo of " << LSP.sequenceNumber();
		
		cout << colorize(write.str(), "pink");
		
		vector<Node> neighbors = topology.neighborsFromString(LSP.neighbors());
		
		// cout << "Disabled: " << disabled.at(0).host() << " Port: " << disabled.at(0).port() << endl;
		
		// Update the topology
		for(unsigned int i = 0; i < neighbors.size(); i++) {
			Node neighbor = neighbors.at(i);
			neighbor = topology.get(neighbor);
			if(neighbor.online()) {
				topology.enable(neighbor.host(), neighbor.port());
			} else {
				topology.disable(neighbor.host(), neighbor.port());
			}
		}
		
		// Decrement the TTL;
		int TTL = LSP.TTL();
		TTL--;
		
		// Forward LSP packet to all neighbors except the one we just received from
		string ID = LSP.id();
		map<string, string> IDInfo = fromID(ID);
		string host = IDInfo["host"];
		int port = atoi(IDInfo["port"].c_str());
		
		
		vector<Node> sendTo;
		for(unsigned int i = 0; i < me.neighbors().size(); i++) {
			Node n = me.neighbors().at(i);
			if(host.compare(n.host()) != 0 && port != n.port()) {
				sendTo.push_back(n);
			}
		}
		
		createroutes(sendTo, TTL);

	}
}
Example #6
0
 BSONObj ClearRawMongoProgramOutput( const BSONObj &args ) {
     mongo::mutex::scoped_lock lk( mongoProgramOutputMutex );
     mongoProgramOutput_.str( "" );
     return undefined_;
 }
Example #7
0
void KsLcsReader::error(const stringstream &msg)
{
	cout<<msg.str()<<endl;
}
Example #8
0
void drawSquare(int pos, board_2048& b) {
	/* Initialize colors for nCurses use */
	init_pair(1, COLOR_WHITE, COLOR_BLACK);
	init_pair(2, COLOR_CYAN, COLOR_RED);
	init_pair(3, COLOR_MAGENTA, COLOR_GREEN);
	init_pair(4, COLOR_BLUE, COLOR_YELLOW);
	init_pair(5, COLOR_YELLOW, COLOR_BLUE);
	init_pair(6, COLOR_GREEN, COLOR_MAGENTA);
	init_pair(7, COLOR_RED, COLOR_CYAN);
	init_pair(8, COLOR_BLACK, COLOR_WHITE);
	init_pair(9, COLOR_CYAN, COLOR_MAGENTA);
	init_pair(10, COLOR_MAGENTA, COLOR_BLUE);
	init_pair(11, COLOR_BLUE, COLOR_GREEN);
	init_pair(12, COLOR_GREEN, COLOR_RED);
	init_pair(13, COLOR_RED, COLOR_BLACK);
	init_pair(14, COLOR_MAGENTA, COLOR_CYAN);
	init_pair(15, COLOR_BLUE, COLOR_MAGENTA);
	init_pair(16, COLOR_GREEN, COLOR_BLUE);


	// Find upper left corner
	int y = y_0 + squareHeight * (pos / 4) + 1;
	int x = x_0 + squareWidth * (pos % 4);

	ss.str("");
	if (b.getVal(pos) == 0) {	// Draw empty square
		move(y,x + 1);
		addstr( EMPTY_STRING );
		move(y + 1, x + 1);
		addstr( EMPTY_STRING );
		move(y - 1, x + 1);
		addstr( EMPTY_STRING );
	}
	else{	// Not empty
		int colorPairValue = (int) (log(b.getVal(pos)) / log(2));
		if (colorPairValue < 0 || colorPairValue > 16) colorPairValue = 0;
		if (b.getVal(pos) > 0 ) {
			attron(COLOR_PAIR( (colorPairValue % 16) + 1) );
		}
		ss << b.getVal(pos);
		int length = ss.str().length();
		int diff = (squareWidth - length)/2;

		// Clear square to color
		move(y,x + 1);
		addstr( EMPTY_STRING );
		move(y + 1, x + 1);
		addstr( EMPTY_STRING );
		move(y - 1, x + 1);
		addstr( EMPTY_STRING );
		move(y, x + 1);
		for (int i = 0; i < diff - 1; i++)
		addch(' ');

		addstr( (ss.str()).c_str() );

		for (int i = 0; i < diff - 1; i++)
		addch(' ');
		if (b.getVal(pos) > 0 ) {
			attroff(COLOR_PAIR( (colorPairValue % 16) + 1) );
		}
	}
}
Example #9
0
int main()
{	
	LUT(relationLUT);

	keepcolors("SegmentColors.txt");
	createHash("ColorQuantas.txt");

	myData.getTrainData("train.txt");
	myData.getTestData("test.txt");

	char choice;
	cout << "want to train svm? (Y//N)" << endl;
	cin >> choice;

	if (choice == 'y' || choice == 'Y'){

		int trainnumber;
		cout << "enter number for saving:" << endl;
		cin >> trainnumber;
	
		cout << "Number of train samples:" << endl;
		cin >> train_sample_number;
		do{
			hesapla(myData.trainArr[index][0], myData.trainArr[index][1], myData.labelsArr[index]);
			index = index + 1;


		} while (index<train_sample_number);

		
		Mat labelsMat(train_sample_number, 1, CV_32FC1, labels_array);
		Mat trainingDataMat(train_sample_number, numberofbins, CV_32FC1, trainingData);


		// Set up SVM's parameters
		CvSVMParams params;
		params.svm_type = CvSVM::C_SVC;
		params.kernel_type = CvSVM::LINEAR;
		params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);

		// Train the SVM
		CvSVM SVM;
		SVM.train(trainingDataMat, labelsMat, Mat(), Mat(), params);
		//SVM.train_auto(trainingDataMat,labelsMat,Mat(),Mat(),params);

		mysvmstream << svmfile << trainnumber << xmltype;
		string mysvmfilename = mysvmstream.str();
		const char *cstrs = mysvmfilename.c_str();
		SVM.save(cstrs);
		
		cout << "Number of test samples:" << endl;
		cin >> test_sample_number;
		do{
			testyapilk(myData.testArr[sindex][0], myData.testArr[sindex][1]);
			sindex = sindex + 1;

		} while (sindex<test_sample_number);

		Mat testing_data = Mat(test_sample_number, numberofbins, CV_32FC1, samples);
		Mat testing_classifications = Mat(test_sample_number, 1, CV_32FC1);
		SVM.predict(testing_data, testing_classifications);
		cout << testing_classifications << endl;

	
	}
Example #10
0
void PrintLatexStats(ImageBuffer *imgbuf, Scene *scene)
{

	int numleaves = 0;

	for(int i=0; i < scene->nkdjobs; i++)
	{
		numleaves += scene->kdjob[i].curleaf;
	}

	unsigned opt_rendertime =  scene->transform_time +  scene->kdbuild_time;
	opt_rendertime += scene->raygen_time + scene->kdtravers_time;
	opt_rendertime += scene->polypartition_time + scene->polytest_time + scene->raster_time;

	if(args.printstats && (firstframe || GetScene()->animate) && frame < 25 && frame > 0)
	{
		int apt; 
		
		if(scene->nleafhits > 0)
			apt = (scene->npolytests)/scene->nleafhits;
		else
			apt = 0;

		int als = KDGetNumLeafPolys()/numleaves;

		int fhp;

		if(scene->nfrustums > 0)
			fhp = (scene->nfrustumhits*100) / scene->nfrustums;
		else
			fhp = 0;

		float aep;

		if(scene->nfrustumhits > 0)
			aep = (float)scene->total_frustum_dep / (float)scene->nfrustumhits;
		else
			aep = 0;

		if(frame == 1)
		{
			file.open("stats.tex", ios::trunc);

			file << "\\documentclass{article}" << endl;
			file << "\\usepackage{multirow}" << endl;
			file << "\\usepackage{a4}" << endl;
			file << "\\usepackage[danish]{babel}" << endl;
			file << "\\usepackage[utf8]{inputenc}" << endl;
			file << "\\usepackage{verbatim}" << endl;
			file << "\\begin{document}" << endl;

			file << "\\subsection{" << args.luascript << " " << ARCH_STR << " " << (args.renderer == R_GENERIC ? "Generic" : "Cell") << "}" << endl;
			file << "\\scriptsize" << endl;
			file << "\\subsubsection{Parametre}" << endl;

			file << "\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline" << endl;
			file << "NT & NRJ & SR & RR & MLS & ED & NEP & NEA & FD & FSS & FNS \\\\ \\hline" << endl;
			file << args.nthreads << " & " << args.njobs << " & ";
			file << (scene->shadowrays ? "On" : "Off") << " & ";
			file << (scene->secondrays ? "On" : "Off") << " & ";
			file << scene->kdtree_mls << " & " << scene->kdtree_etd << " & ";
			file << KDGetNumberOfSplits() << " & " << KDGetNumberOfAxises() << " & ";
			file << scene->frustumdim << " & " << scene->frustumstepsize << " & " << scene->frustumstep;

		
			file << "\\\\ \\hline" << endl;
			file << endl;

			file << "\\hline" << endl;
			file << "\\end{tabular}" << endl;

			file << "\\subsubsection{MÃ¥linger}" << endl;
			file << "\\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline " << endl;
			file << " & FPS & MPT & TUP & ALS & LHP & LPR & APT & FHP & DEP & AEP \\\\ \\hline" << endl;


			kernel_stats << "\\begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline \n";
			kernel_stats << " & Transform & KDBuild & RayGen & Travers & PolyPartition & PolyTest & Total \\\\ \\hline \n";


		}

		file.precision(2);

		file << "Frame " << frame << " & "; 
		file << (float)(1000.0f) / (float)(rendertime) << " & ";
		file << (scene->npolytests)/ 1000000.0f << " & ";
		file << opt_rendertime*100 / rendertime << "\\% & ";
		file << als << " & ";
		file << (scene->nleafhits*100)/ ( imgbuf->GetWidth() * imgbuf->GetHeight()) << "\\% & ";
		file << (float)apt/(float)als << " & ";
		file << apt << " & ";
		file << fhp << "\\% & ";
		file << scene->frustum_dep << " & ";printf("Total\n");
		printf("\tThreads: %i\n", args.nthreads); 
		printf("\tJobs   : %i\n\n", args.njobs);  
		printf("\tFPS    : %.2f - %.2f\n", stats.min_fps, stats.max_fps);
		printf("\tMPT    : %.2f - %.2f\n", stats.min_mpt, stats.max_mpt);
		printf("\tTUP    : %g%% - %g%%\n", stats.min_tup, stats.max_tup);
		printf("\tALS    : %i - %i\n", stats.min_als, stats.max_als);
		printf("\tLHP    : %i%% - %i%%\n", stats.min_lhp, stats.max_lhp);
		printf("\tLPR    : %.2g - %.2g\n", stats.min_lpr, stats.max_lpr);
		printf("\tAPT    : %i - %i\n", stats.min_apt, stats.max_apt);
		printf("\tFHP    : %i%% - %i%%\n", stats.min_fhp, stats.max_fhp);
		printf("\tDEP    : %i - %i\n", stats.min_dep, stats.max_dep);
		printf("\tAEP    : %.2g - %.2g\n\n", stats.min_aep, stats.max_aep);

		printf("\tTT     : %i - %i ms\n", stats.min_tt, stats.max_tt);
		printf("\tKDB    : %i - %i ms\n", stats.min_kdb, stats.max_kdb);
		printf("\tRG     : %i - %i ms\n", stats.min_rg, stats.max_rg);
		printf("\tKDT    : %i - %i ms\n", stats.min_kdt, stats.max_kdt);
		printf("\tPP     : %i - %i ms\n", stats.min_pp, stats.max_pp);
		printf("\tPT     : %i - %i ms\n", stats.min_pt, stats.max_pt);
		file << aep;
		file << "\\\\ \\hline" << endl;

	

		if(frame > 0)
		{
			kernel_stats.precision(2);

			kernel_stats << "Frame " << frame << " & ";
			kernel_stats << scene->transform_time << " ms & ";
			kernel_stats << scene->kdbuild_time << " ms & ";
			kernel_stats << scene->raygen_time << " ms & ";
			kernel_stats << scene->kdtravers_time << " ms & ";
			kernel_stats << scene->polypartition_time << " ms & ";
			kernel_stats << scene->polytest_time << " ms & ";
			kernel_stats << (scene->transform_time + scene->kdbuild_time + scene->raygen_time + scene->kdtravers_time + scene->polypartition_time + scene->polytest_time) << " ms "; 
			kernel_stats << " \\\\ \\hline\n";


		}
	}

	
	if(args.printstats && frame == 25)
	{

		file << "\\end{tabular}" << endl;

		kernel_stats << "\\end{tabular} \n";


		file << "\\\\ \\ \\\\ \\ \\\\ \\ \\\\\n" << kernel_stats.str();

		file << "\\normalsize" << endl;

		file << "\\end{document}" << endl;
		
		file.close();

		cout << "Done writing stats.tex" << endl;
	}





}
Example #11
0
/* draw the board. Appeals to global variables to determine manner to do this
 * (ncurses or otherwise) */
void drawBoard(board_2048& b) {
	if (usingCurses){
		move(score_y, score_x);
		/* Draw the scoreboard */
		ss.str("");
		ss << b.getScore() << "   WINS: " << wins << "     ";
		init_pair(1, COLOR_RED, COLOR_BLACK);
		attron(COLOR_PAIR(1));
		addstr( "SCORE: " );
		addstr( (ss.str()).c_str());
		// Add High Score
		ss.str("");
		ss << "HIGHSCORE: "<<  highScore << "   " << "AVERAGE: ";
		if (gameNumber > 1) ss <<  cummulativeScore/(gameNumber - 1);
		else ss << 0;
		ss << "        ";
		move(score_y + 1, score_x);
		addstr( ss.str().c_str());

		// Add GAme Number
		ss.str("");

		ss << "GAME " << gameNumber << " OF " << numberOfGames << "  ";
		move(score_y + 2, score_x);
		addstr(ss.str().c_str());

		// Draw Border
		// Horizontal Lines
		attroff(COLOR_PAIR(1));
		for (int j = 0; j < 5; j++) {
			move(y_0 - 1 + squareHeight*j, x_0);
			for (int i = 0; i < 4 * squareWidth; i++ )
			if ( i % squareWidth == 0) {
				if (j == 0) addch(ACS_TTEE);
				else if (j == 4) addch(ACS_BTEE);
				else addch(ACS_HLINE);
			}
			else
			addch(ACS_HLINE);
		}
		// Vertical Lines
		for (int j = 0; j < 4*squareHeight; j++) {
			for (int i = 0; i < 5; i++){
				move(y_0 + j, x_0 + i * squareWidth);
				if (j % squareHeight == squareHeight - 1) {
					if (i == 0) addch(ACS_LTEE);
					else if (i == 4) addch(ACS_RTEE);
					else addch(ACS_PLUS);
				}
				else
				addch(ACS_VLINE);
			}
		}
		// Draw Corners
		move(y_0 - 1, x_0);
		addch(ACS_ULCORNER);
		move(y_0 - 1, x_0 + 4*squareWidth);
		addch(ACS_URCORNER);
		move(y_0 + 4*squareHeight - 1, x_0);
		addch(ACS_LLCORNER);
		move(y_0 + 4*squareHeight - 1, x_0 + 4 * squareWidth);
		addch(ACS_LRCORNER);

		for (int i = 0; i < 16; i++) {
			drawSquare(i, b);
		}
		move(HEIGHT, WIDTH);
	} // if using curses
	else { // no curses
		for (int i = 0; i < 16; i++) {
			cout.width(7);
			cout << b.getVal(i);
			cout.width(1);
			cout << " | ";
			if (i % 4 == 3)
			cout << '\n';
		}
	} // no curses
}
				case 5: mySR = "Bt"; break;
				case 6: mySR = "Cm"; break;
				case 7: mySR = "Ct"; break;
				case 8: mySR = "Dm"; break;
				case 9: mySR = "Dt"; break;
				case 10: mySR = "El"; break;
				case 11: mySR = "Em"; break;
				case 12: mySR = "Et"; break;
				default: mySR = ; break;
				}
			}	
		}
		else if (opti == 2) {
			stringstream sfID;
			sfID << fID;
			mySR = "E" + sfID.str();
		}
		else if (opti == 3) {
			stringstream sfID;
			sfID << fID;
			mySR = "D" + sfID.str();
		}

		int label = 1; // 0 - no label, 1 - SR, 2 - CLsexp, 3 - PAPER SR + CLs for new SR
		if (label == 0) {
			cout << "No label!" << endl;
		} else if (label == 1) {
			lat.DrawLatex(mH1sq,m12,mySR.Data());
			//cout << mH1sq << " " << m12 << " " << mySR.Data() << endl;
		} else if (label == 2) {
			stringstream sCLsexp;
Example #13
0
void ScanFile(string path)
{
    cout << path << endl;
    //system("pause");
    //cout << path << endl;
    //cin.get();

    string line_read;
    stringstream line_write_ss;
    string line_write;
    string Quote_author;
    bool duplicate;
    unsigned long tempfile_size;

    string line;
    string feld;
    unsigned int line_pos=0;
    unsigned short feld_pos=0;

    vector<int> Pos(7);
    int i;

    char infile_char;

    infile_ScanFile.open(path, ios::in|ios::binary);
    if (infile_ScanFile.is_open()) {

        unsigned int aaa=0;
        unsigned int bbb=0;

        /*
        while (infile_ScanFile.get(infile_char))
        {
            aaa++;
            if(aaa==1)
            {
                aaa=0;
                bbb++;
                cout << infile_char;
            }
        }
        system("pause");
        */

        while (infile_ScanFile.get(infile_char))
        {
            if(infile_char==Find[0][Pos[0]])
            {
                Pos[0]++;
            } else {
                Pos[0]=0;
            }
            if(Pos[0]==Find_length[0]) break;
        }

            //
        //}

        while(1)
        {
            //cout << line << endl;
            //memset(line,0,sizeof(line));
            feld_pos=0;
            line.clear();
            feld.clear();
            //infile_ScanFile.get(infile_char);
            while(infile_ScanFile.get(infile_char))
            {
                //cout << aaa++ << endl;
                //continue;
                //cout << "#";
                //cout << infile_char;
                line.push_back(infile_char);
                if(infile_char=='\n') break;
                //new_feld:;
                if(infile_char==' ')
                {
                    infile_ScanFile.get(infile_char);
                    line.push_back(infile_char);
                    if(infile_char=='\'')
                    {
                        infile_ScanFile.get(infile_char);
                        line.push_back(infile_char);
                        if(infile_char=='\'') continue;

                        //memset(hash_char,0,sizeof(hash_char));
                        if(feld_pos==1)
                        {
                            while(1)
                        {
                            //cout << infile_char;
                            //cout << "#";
                            if(infile_char=='\'')
                            {
                                infile_char_finchar_1:;
                                infile_ScanFile.get(infile_char);
                                line.push_back(infile_char);
                                if(infile_char==',')
                                {
                                    //infile_ScanFile.get(infile_char);
                                    line.push_back(infile_char);
                                    break;
                                } else if (infile_char=='\'') {
                                    goto infile_char_finchar_1; //for the rare but possible ''', case!
                                } else {
                                    //break;
                                    feld.push_back('\'');
                                    i++;
                                    feld.push_back(infile_char);
                                }


                            }
                            feld.push_back(infile_char);
                            infile_ScanFile.get(infile_char);
                            line.push_back(infile_char);
                        }
                        }

                        //cout << line << endl;
                        feld_pos++;

                        /*
                        if(feld_pos==2)
                        {
                            aaa++;
                            if(aaa==10000)
                            {
                                aaa=0;
                                bbb++;
                                for(i=0;i<40;i++)
                                {
                                    cout << feld[i];
                                }
                                cout << endl;
                            //system("pause");
                            }
                        }
                        */

                    } else {
                        if(infile_char=='\n') break;
                    }
                } else {
                    if(infile_char=='\n') break;
                }
            }

            //cout << endl;// << endl << endl;
            //system("pause");

            //cout << line << endl;
            /*
            for(i=0;i<2000;i++)
            {
                cout << line[i];
            }
            system("pause");
            */
            /*
                                        aaa++;
                            if(aaa==10000)
                            {
                                aaa=0;
                                bbb++;
                                for(i=0;i<40;i++)
                                {
                                    cout << feld[i];
                                }
                                cout << endl;
                            //system("pause");
                            }

            continue;
            */
            cout << feld << endl;

            if(feld.length()<40) continue;

    for(c.at(0)=48;c.at(0)<58;c.at(0)++)
    for(c.at(0)=97;c.at(0)<123;c.at(0)++)

            outfile_ss << "./temp/" << feld[0] << "/" << feld[1] << feld[2] << feld[3];

            //cout << feld << endl;

            tempfile.open(outfile_ss.str(), ios::in|ios::out|ios::binary|ios::app);
            duplicate=false;
            tempfile.seekg(0, tempfile.end);
            //cout << tempfile.tellg() << endl;
            tempfile_size=tempfile.tellg();
            if(tempfile_size>0)
            {
                tempfile.seekg(0, tempfile.beg);
                while(tempfile_size>tempfile.tellg()+7)
                {
                    getline(tempfile, line_read);
                    //cout << line << endl;
                    if(line==line_read)
                    {
                        duplicate=true;
                        torrent_duplication_cont_temp++;
                        //cout << "Duplicate!" << endl;
                        break;
                    }
                }
            }

            torrent_count_temp++;
            if(torrent_count_temp==1000)
            {
                torrent_count+=torrent_count_temp;
                torrent_count_temp=0;
                torrent_duplication_cont+=torrent_duplication_cont_temp;

                        clock_duration = (clock()-torrent_clock) / (double) CLOCKS_PER_SEC;
                        cout << torrent_count << " Torrents in " << clock()/(double)CLOCKS_PER_SEC
                             << "s and " << clock_duration << "s/part avg="
                             << (clock()/(double)CLOCKS_PER_SEC/torrent_count*1000) << "s/l D/p="
                             << torrent_duplication_cont_temp << " Dubl=" << torrent_duplication_cont
                             << "\nFile:" << path << '\n' << endl;
                        torrent_duplication_cont_temp=0;
                        torrent_clock = clock();
            }
            if(duplicate==false)
            {
                //cout << line << endl;
                tempfile << line;
            }

            tempfile.close();

            outfile_ss.str("");
            outfile_ss.clear();
            //memset(line,0,sizeof(line));
            //system("pause");

        }
    }
    infile_ScanFile.close();

}
 void write_msg()
 {
     m_msg << endl;
     CHECK_MESSAGE( m_msg.str() );
 }
void cScreenGangs::check_events()
{
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home
	if (g_InterfaceEvents.CheckButton(back_id))			// if it's the back button, pop the window off the stack and we're done
	{
		g_InitWin = true;
		g_WinManager.Pop();
		return;
	}
	if (g_InterfaceEvents.CheckButton(ganghire_id))
	{
		hire_recruitable();
		return;
	}
	if (g_InterfaceEvents.CheckButton(weaponup_id))
	{
		int cost = 0;
		int *wlev = g_Gangs.GetWeaponLevel();
		cost = tariff.goon_weapon_upgrade(*wlev);
		if (g_Gold.item_cost(cost) == true)
		{
			*wlev += 1;
			g_InitWin = true;
		}
		wlev = 0;
		return;
	}

	int buynets = 0;
	if (g_InterfaceEvents.CheckButton(netbuy_id))	buynets = 1;
	if (g_InterfaceEvents.CheckButton(netbuy10_id))	buynets = 10;
	if (g_InterfaceEvents.CheckButton(netbuy20_id))	buynets = 20;
	if (buynets > 0)
	{
		int cost = 0;
		int amount = buynets;
		int *nets = g_Gangs.GetNets();
		if (((*nets) + buynets) > 60) amount = 60 - (*nets);
		cost = tariff.nets_price(amount);
		if (g_Gold.item_cost(cost) == true)
		{
			*nets += amount;
			if (IsCheckboxOn(netautobuy_id)) g_Gangs.KeepNetStocked(*nets);
			g_InitWin = true;
		}
		nets = 0;
		buynets = 0;
		return;
	}

	int buypots = 0;
	if (g_InterfaceEvents.CheckButton(healbuy_id))		buypots = 1;
	if (g_InterfaceEvents.CheckButton(healbuy10_id))	buypots = 10;
	if (g_InterfaceEvents.CheckButton(healbuy20_id))	buypots = 20;
	if (buypots > 0)
	{
		int cost = 0;
		int amount = buypots;
		int *potions = g_Gangs.GetHealingPotions();
		if (((*potions) + buypots) > 200)	amount = 200 - (*potions);
		cost = tariff.healing_price(amount);
		if (g_Gold.item_cost(cost) == true)
		{
			*potions += amount;
			if (IsCheckboxOn(healautobuy_id)) g_Gangs.KeepHealStocked(*potions);
			g_InitWin = true;
		}
		potions = 0;
		buypots = 0;
		return;
	}
	if (g_InterfaceEvents.CheckCheckbox(netautobuy_id))
	{
		int *nets = g_Gangs.GetNets();
		g_Gangs.KeepNetStocked(IsCheckboxOn(netautobuy_id) ? *nets : 0);
	}
	if (g_InterfaceEvents.CheckCheckbox(healautobuy_id))
	{
		int *potions = g_Gangs.GetHealingPotions();
		g_Gangs.KeepHealStocked(IsCheckboxOn(healautobuy_id) ? *potions : 0);
	}
	if (g_InterfaceEvents.CheckButton(gangfire_id))
	{
		selection = GetLastSelectedItemFromList(ganglist_id);
		if (selection != -1)
		{
			g_Gangs.FireGang(selection);
			g_InitWin = true;
		}
		return;
	}
	if (g_InterfaceEvents.CheckListbox(recruitlist_id))
	{
		string ClickedHeader = HeaderClicked(recruitlist_id);
		if (ClickedHeader != "")
		{
			g_LogFile.ss() << "User clicked \"" << ClickedHeader << "\" column header on Recruit listbox" << endl; g_LogFile.ssend();
			return;
		}

		g_LogFile.ss() << "selected recruitable gang changed" << endl; g_LogFile.ssend();
		sel_recruit = GetLastSelectedItemFromList(recruitlist_id);

		if (ListDoubleClicked(recruitlist_id))
		{
			g_LogFile.ss() << "User double-clicked recruitable gang! Hiring if possible." << endl; g_LogFile.ssend();
			hire_recruitable();
			return;
		}
		//		g_InitWin = true;
	}

	// this is what gets called it you change the selected gang
	if (g_InterfaceEvents.CheckListbox(ganglist_id))
	{
		string ClickedHeader = HeaderClicked(ganglist_id);
		if (ClickedHeader != "")
		{
			g_LogFile.ss() << "User clicked \"" << ClickedHeader << "\" column header on Gangs listbox" << endl; g_LogFile.ssend();
			return;
		}

		g_LogFile.write("selected gang changed");
		selection = GetLastSelectedItemFromList(ganglist_id);
		if (selection != -1)
		{
			sGang* gang = g_Gangs.GetGang(selection);
			ss.str(""); ss << "Name: " << gang->m_Name << "\n" << "Number: " << gang->m_Num << "\n" << "Combat: " << gang->m_Skills[SKILL_COMBAT] << "%\n" << "Magic: " << gang->m_Skills[SKILL_MAGIC] << "%\n" << "Intelligence: " << gang->m_Stats[STAT_INTELLIGENCE] << "%\n";
			EditTextItem(ss.str(), gangdesc_id);
			SetSelectedItemInList(missionlist_id, gang->m_MissionID, false);
			set_mission_desc(gang->m_MissionID);		// set the long description for the mission
		}
	}
	if (g_InterfaceEvents.CheckListbox(missionlist_id))
	{
		// get the index into the missions list
		int mission_id = GetLastSelectedItemFromList(missionlist_id);
		g_LogFile.ss() << "selchange: mid = " << mission_id << endl; g_LogFile.ssend();
		set_mission_desc(mission_id);		// set the textfield with the long description and price for this mission
		g_LogFile.ss() << "selection change: rebuilding gang list box" << endl; g_LogFile.ssend();
		for (int selection = multi_first(); selection != -1; selection = multi_next())
		{
			sGang* gang = g_Gangs.GetGang(selection);
			/*
			*				make sure we found the gang - pretty catastrophic
			*				if not, so log it if we do
			*/
			if (gang == 0)
			{
				g_LogFile.ss() << "Error: No gang for index " << selection; g_LogFile.ssend();
				continue;
			}
			/*
			*				if the mission id is -1, nothing else to do
			*				(moving this to before the recruitment check
			*				since -1 most likely means nothing selected in
			*				the missions list)
			*/
			if (mission_id == -1) { continue; }
			/*
			*				if the gang is already doing <whatever>
			*				then let them get on with it
			*/
			if (gang->m_MissionID == u_int(mission_id)) { continue; }
			/*
			*				if they were recruiting, turn off the
			*				auto-recruit flag
			*/
			if (gang->m_MissionID == MISS_RECRUIT && gang->m_AutoRecruit)
			{
				gang->m_AutoRecruit = false;
				gang->m_LastMissID = -1;
			}
			gang->m_MissionID = mission_id;
			/*
			*				format the display line
			*/
			g_InitWin = true;
		}

		int cost = 0;
		if (g_Gangs.GetNumGangs() > 0)
		{
			for (int i = 0; i < g_Gangs.GetNumGangs(); i++)
			{
				sGang* g = g_Gangs.GetGang(i);
				cost += tariff.goon_mission_cost(g->m_MissionID);
			}
		}
		ss.str(""); ss << "Weekly Cost: " << cost;
		EditTextItem(ss.str(), totalcost_id);
		if (gold_id >= 0)
		{
			ss.str(""); ss << "Gold: " << g_Gold.ival();
			EditTextItem(ss.str(), gold_id);
		}

	}

	if (g_InterfaceEvents.CheckCheckbox(controlcatacombs_id))
	{
		g_Gangs.Control_Gangs(IsCheckboxOn(controlcatacombs_id));
	}
	bool dosliders = false;
	if (g_InterfaceEvents.CheckSlider(girlspercslider_id))
	{
		int s1 = SliderValue(girlspercslider_id);
		int s2 = SliderValue(itemspercslider_id);
		if (s2 < s1)
		{
			s2 = s1;
			SliderRange(itemspercslider_id, 0, 100, s2, 1);
		}
		dosliders = true;
	}
	if (g_InterfaceEvents.CheckSlider(itemspercslider_id))
	{
		int s1 = SliderValue(itemspercslider_id);
		int s2 = SliderValue(girlspercslider_id);
		if (s1 < s2)
		{
			s2 = s1;
			SliderRange(girlspercslider_id, 0, 100, s2, 1);
		}
		dosliders = true;
	}
	if (dosliders)
	{
		int s1 = SliderValue(girlspercslider_id);
		int s2 = SliderValue(itemspercslider_id);
		g_Gangs.Gang_Gets_Girls(s1);
		g_Gangs.Gang_Gets_Items(s2 - s1);
		g_Gangs.Gang_Gets_Beast(100 - s2);
		ss.str("");	ss << "Girls : " << g_Gangs.Gang_Gets_Girls() << "%";	EditTextItem(ss.str(), ganggetsgirls_id);
		ss.str("");	ss << "Items : " << g_Gangs.Gang_Gets_Items() << "%";	EditTextItem(ss.str(), ganggetsitems_id);
		ss.str("");	ss << "Beasts : " << g_Gangs.Gang_Gets_Beast() << "%";	EditTextItem(ss.str(), ganggetsbeast_id);
		return;
	}
}
Example #16
0
int DoModeRun(stringstream &ssArg)
{

    if(ssArg.str().empty())
        return -1;

    vector<string> vectArg;
    string strArg;

    while(ssArg >> strArg)
    {
        vectArg.push_back(strArg);
    }

    string strScriptAbsName;
    string strScriptArg;

    for(size_t i=0; i<vectArg.size(); i++)
    {
        if(i==0)
        {
            strScriptAbsName = vectArg.at(i);
        }
        else
        {
            strScriptArg.append(vectArg.at(i));
            strScriptArg.append(" ");
        }
    }

    size_t posSplit = strScriptAbsName.find_last_of("/");
    string strScriptPath = strScriptAbsName.substr(0, posSplit);
    string strScriptName = strScriptAbsName.substr(posSplit+1);

    //check script file extension
    stringstream ss;
    string strScriptProcFile;
    string strScriptOnlyName;

    int iExtPos;

    if((iExtPos = CheckScriptExt(strScriptName.c_str(), TEST_SCRIPT_ORI_EXT)) > 0)
    {
        strScriptOnlyName = strScriptName.substr(0, iExtPos-1);

        ss << SYS_WORK_PATH <<  "/" << strScriptOnlyName << "." << TEST_SCRIPT_RUN_EXT;
        strScriptProcFile = ss.str();
    }
    else if((iExtPos = CheckScriptExt(strScriptName.c_str(), TEST_SCRIPT_RUN_EXT)) > 0)
    {
        strScriptOnlyName = strScriptName.substr(0, iExtPos-1);

        ss << SYS_WORK_PATH <<  "/" << strScriptName;
        strScriptProcFile = ss.str();
    }
    else
    {
        printf(">> '%s, %s' file is not eixst\n", TEST_SCRIPT_ORI_EXT, TEST_SCRIPT_RUN_EXT);
        return -2;
    }

    //copy script to work folder
    ss.str("");
    ss << "cp -f " << strScriptAbsName << " " << strScriptProcFile;
    string strCmd = ss.str();
    int ret = system(strCmd.c_str());

    //compile script
    ss.str("");
    ss << SYS_WORK_PATH << "/exec/" << strScriptOnlyName << " ";
    string strRunFile = ss.str();
    unlink(strRunFile.c_str());

    ss.str("");
    ss << SYS_LOG_PATH << "/" << "compile.txt";
    string strCompileLog;
    strCompileLog = ss.str();

    ss.str("");
    ss << COMPILE_PROG << " "
       << COMPILE_INCPATH << " "
       << strScriptProcFile << " "
       << " -include sctbasic.h "
       << "-o " << strRunFile << " "
       << COMPILE_LIBPATH << " "
       << COMPILE_LIB << " "
       << "2> " << strCompileLog;
    strCmd = ss.str();

    ret = system(strCmd.c_str());
    if(ret != 0)
    {
        printf(">> compile error is happened!!\n");
        char buf[256];
        sprintf(buf, "cat %s > /dev/stdout", strCompileLog.c_str());
        system(buf);
        return -3;
    }

    //delete script file
    unlink(strScriptProcFile.c_str());

    //run script
    string strRunCmd;
    strRunCmd.append(strRunFile);
    strRunCmd.append(" ");
    strRunCmd.append(strScriptArg);
    system(strRunCmd.c_str());

    return 0;
}
Example #17
0
void writeToLog(stringstream& ss, int stamp ){
    writeToLog(ss.str(),stamp);
	 ss.str(""); // clears the string steam...
	 ss.clear();
}
Example #18
0
void Logger::logErr(stringstream& stream) {
	if(DEBUG) {
		cerr << prefix << ": " << stream.str() << endl;
	}
}
Example #19
0
void Add(stringstream& sstr, int x, int y){
  sstr.str("");
  sstr << x << " + " << y << " = " << (x + y) << flush;
}
 //--------------------------------------------------------------
 void setup() {
     tester();
     cout << outputStream.str();
 }
Example #21
0
    sb->SetX2NDC(1.);
    sb->SetY1NDC(1.);
    sb->SetY2NDC(1.);
    
    leg = new TLegend(0.22,0.7,0.85,0.8);
    
    double datamean = ptdata->GetMean(); datamean=datamean*10; int idatamean = datamean+0.5; datamean = (double)idatamean/10;
    double mcmean = ptmc->GetMean(); mcmean = mcmean*10; int imcmean = mcmean+0.5; mcmean = (double)imcmean/10;
    
    cout << datamean << " " << datamean << " " << endl;
    stringstream s, t;
    
    s<<datamean;
    t<<mcmean;
	
	leg->AddEntry(ptdata,("Data (<p_{T}>_{jets}="+s.str()+"GeV/c)").c_str(),"p");
	leg->AddEntry(ptmc,("Simulation (<p_{T}>_{jets}="+t.str()+"GeV/c)").c_str(),"l");
	
	leg->Draw();
    
    c2->Draw();

    
    c2->cd(2);
    
    gPad->SetGrid();
    
    ptdata->SetMarkerColor(kRed);
    ptdata->SetLineColor(kRed);
    ptdata->GetYaxis()->SetTitle("a.u.");
    ptdata->SetTitle("");
 //--------------------------------------------------------------
 void draw() {
     ofBackground(0);
     ofDrawBitmapString(outputStream.str(), 20, 30);
 }
Example #23
0
    void ReplSetImpl::_summarizeAsHtml(stringstream& s) const {
        s << table(0, false);
        s << tr("Set name:", _name);
        s << tr("Majority up:", elect.aMajoritySeemsToBeUp()?"yes":"no" );
        s << _table();

        const char *h[] = {"Member",
                           "<a title=\"member id in the replset config\">id</a>",
                           "Up",
                           "<a title=\"length of time we have been continuously connected to the other member with no reconnects (for self, shows uptime)\">cctime</a>",
                           "<a title=\"when this server last received a heartbeat response - includes error code responses\">Last heartbeat</a>",
                           "Votes", "Priority", "State", "Messages",
                           "<a title=\"how up to date this server is.  this value polled every few seconds so actually lag is typically much lower than value shown here.\">optime</a>",
                           "<a title=\"Clock skew in seconds relative to this server. Informational; server clock variances will make the diagnostics hard to read, but otherwise are benign..\">skew</a>",
                           0
                          };
        s << table(h);

        /* this is to sort the member rows by their ordinal _id, so they show up in the same
           order on all the different web ui's; that is less confusing for the operator. */
        map<int,string> mp;

        string myMinValid;
        try {
            readlocktry lk("local.replset.minvalid", 300);
            if( lk.got() ) {
                BSONObj mv;
                if( Helpers::getSingleton("local.replset.minvalid", mv) ) {
                    myMinValid = "minvalid:" + mv["ts"]._opTime().toString();
                }
            }
            else myMinValid = ".";
        }
        catch(...) {
            myMinValid = "exception fetching minvalid";
        }

        const Member *_self = this->_self;
        assert(_self);
        {
            stringstream s;
            /* self row */
            s << tr() << td(_self->fullName() + " (me)") <<
              td(_self->id()) <<
              td("1") <<  //up
              td(ago(started)) <<
              td("") << // last heartbeat
              td(ToString(_self->config().votes)) <<
              td(ToString(_self->config().priority)) <<
              td( stateAsHtml(box.getState()) + (_self->config().hidden?" (hidden)":"") );
            s << td( _hbmsg );
            stringstream q;
            q << "/_replSetOplog?_id=" << _self->id();
            s << td( a(q.str(), myMinValid, theReplSet->lastOpTimeWritten.toString()) );
            s << td(""); // skew
            s << _tr();
            mp[_self->hbinfo().id()] = s.str();
        }
        Member *m = head();
        while( m ) {
            stringstream s;
            m->summarizeMember(s);
            mp[m->hbinfo().id()] = s.str();
            m = m->next();
        }

        for( map<int,string>::const_iterator i = mp.begin(); i != mp.end(); i++ )
            s << i->second;
        s << _table();
    }
Example #24
0
		virtual std::string getToolSpecificName(ColorObject *color_object, const Color *color)
		{
			m_stream.str("");
			m_stream << color_names_get(m_gs->getColorNames(), color, false) << " " << _("brightness darkness") << " " << m_ident;
			return m_stream.str();
		}
void cScreenGirlDetails::init()
{
	if (selected_girl == 0)
	{
		g_WinManager.Pop();
		g_InitWin = true;
		g_LogFile.write("ERROR - girl details screen, selected_girl is null");
		/*
		*		adding this because the game will crash if we
		*		go past this point with a null girl
		*
		*		Now as to why it was null in the first place ...
		*		-- doc
		*/
		return;
	}

	g_CurrentScreen = SCREEN_GIRLDETAILS;
	if (!g_InitWin) return;

	Focused();
	g_InitWin = false;

	////////////////////
	if (selected_girl->health() <= 0)
	{
		// `J` instead of removing dead girls from the list which breaks the game, just skip past her in the list.
		NextGirl();								// `J` currently this prevents scrolling backwards past her - need to fix that.
//		selected_girl = remove_selected_girl();
		if (selected_girl == 0)
		{
			g_WinManager.Pop();
			g_InitWin = true;
			return;
		}
	}

	u_int job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
	SetJob = true;

	EditTextItem(selected_girl->m_Realname, girlname_id);

	string detail;
	if (DetailLevel == 0)		detail = g_Girls.GetDetailsString(selected_girl);
	else if (DetailLevel == 1)	detail = g_Girls.GetMoreDetailsString(selected_girl);
	else						detail = g_Girls.GetThirdDetailsString(selected_girl);
	EditTextItem(detail, girldesc_id);

	if (selected_girl)
	{
		if (lastsexact != -1)
		{
			PrepareImage(girlimage_id, selected_girl, lastsexact, true, ImageNum);
			lastsexact = -1;
		}
		else
		{
			if (selected_girl->m_newRandomFixed >= 0)
			{
				PrepareImage(girlimage_id, selected_girl, IMGTYPE_PROFILE, false, selected_girl->m_newRandomFixed);
			}
			else
			{
				PrepareImage(girlimage_id, selected_girl, IMGTYPE_PROFILE, true, ImageNum);
			}
		}
	}

	SliderRange(houseperc_id, 0, 100, g_Girls.GetStat(selected_girl, STAT_HOUSE), 10);
	ss.str("");
	ss << gettext("House Percentage: ") << SliderValue(houseperc_id) << gettext("%");
	EditTextItem(ss.str(), housepercval_id);

	ClearListBox(jobtypelist_id);

	// `J` Replacing accom buttons with slider
	if (accomdown_id != -1)	DisableButton(accomdown_id, selected_girl->m_AccLevel < 1);
	if (accomup_id != -1)	DisableButton(accomup_id, selected_girl->m_AccLevel > 9);
	if (accom_id != -1)
	{
		SliderRange(accom_id, 0, 9, selected_girl->m_AccLevel, 1);
		SliderMarker(accom_id, g_Girls.PreferredAccom(selected_girl));
	}
	if (accomval_id != -1)
	{
		stringstream acc;
		acc << "Accommodation: " << g_Girls.Accommodation(SliderValue(accom_id));
		if (cfg.debug.log_extradetails())
		{
			int val = SliderValue(accom_id) - g_Girls.PreferredAccom(selected_girl);
			if (val != 0) acc << "  ( " << (val > 0 ? "+" : "") << val << " )";
		}
		EditTextItem(acc.str(), accomval_id);
	}
	DisableButton(interact_id, (g_TalkCount <= 0));
	DisableButton(takegold_id, (selected_girl->m_Money <= 0));
	SetCheckBox(antipreg_id, (selected_girl->m_UseAntiPreg));

	bool InMovieStudio = (selected_girl->m_InStudio);
	bool InArena = (selected_girl->m_InArena);
	bool InCentre = (selected_girl->m_InCentre);
	bool InClinic = (selected_girl->m_InClinic);
	bool InHouse = (selected_girl->m_InHouse);
	bool InFarm = (selected_girl->m_InFarm);
	bool InDungeon = (selected_girl->m_DayJob == JOB_INDUNGEON);
	DisableButton(reldungeon_id, !InDungeon);
	DisableButton(senddungeon_id, InDungeon);

	// Disable dungeon if selected girl is in a non-brothel building
//	if (InMovieStudio || InArena || InCentre || InClinic || InFarm || InHouse) 
//	{
//		DisableButton(senddungeon_id, true);
//	}

	if (InArena)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_ARENASTAFF, g_Arena.m_JobManager.JobFilterName[JOBFILTER_ARENASTAFF]);
		AddToListBox(jobtypelist_id, JOBFILTER_ARENA, g_Arena.m_JobManager.JobFilterName[JOBFILTER_ARENA]);
		RefreshJobList();
		if (job >= g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENA] && job < g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENA + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_ARENA);
		else // if (job >= g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENASTAFF] && job < g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENASTAFF + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_ARENASTAFF);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InClinic)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_CLINIC, g_Clinic.m_JobManager.JobFilterName[JOBFILTER_CLINIC]);
		AddToListBox(jobtypelist_id, JOBFILTER_CLINICSTAFF, g_Clinic.m_JobManager.JobFilterName[JOBFILTER_CLINICSTAFF]);
		RefreshJobList();
		if (job >= g_Clinic.m_JobManager.JobFilterIndex[JOBFILTER_CLINIC] && job < g_Clinic.m_JobManager.JobFilterIndex[JOBFILTER_CLINIC + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_CLINIC);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_CLINICSTAFF);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InCentre)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_COMMUNITYCENTRE, g_Centre.m_JobManager.JobFilterName[JOBFILTER_COMMUNITYCENTRE]);
		AddToListBox(jobtypelist_id, JOBFILTER_COUNSELINGCENTRE, g_Centre.m_JobManager.JobFilterName[JOBFILTER_COUNSELINGCENTRE]);
		RefreshJobList();
		if (job >= g_Centre.m_JobManager.JobFilterIndex[JOBFILTER_COUNSELINGCENTRE] && job < g_Centre.m_JobManager.JobFilterIndex[JOBFILTER_COUNSELINGCENTRE + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_COUNSELINGCENTRE);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_COMMUNITYCENTRE);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InHouse)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_HOUSE, g_House.m_JobManager.JobFilterName[JOBFILTER_HOUSE]);
		SetSelectedItemInList(jobtypelist_id, JOBFILTER_HOUSE);
		RefreshJobList();
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InMovieStudio)
	{
		Day0Night1 = SHIFT_NIGHT;
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_STUDIOCREW, g_Studios.m_JobManager.JobFilterName[JOBFILTER_STUDIOCREW]);
		AddToListBox(jobtypelist_id, JOBFILTER_MOVIESTUDIO, g_Studios.m_JobManager.JobFilterName[JOBFILTER_MOVIESTUDIO]);
		RefreshJobList();
		if (job >= g_Studios.m_JobManager.JobFilterIndex[JOBFILTER_MOVIESTUDIO] && job < g_Studios.m_JobManager.JobFilterIndex[JOBFILTER_MOVIESTUDIO + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_MOVIESTUDIO);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_STUDIOCREW);
		HideButton(day_id, true);
		HideButton(night_id, true);

	}
	else if (InFarm)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_FARMSTAFF, g_Farm.m_JobManager.JobFilterName[JOBFILTER_FARMSTAFF]);
		AddToListBox(jobtypelist_id, JOBFILTER_LABORERS, g_Farm.m_JobManager.JobFilterName[JOBFILTER_LABORERS]);
		AddToListBox(jobtypelist_id, JOBFILTER_PRODUCERS, g_Farm.m_JobManager.JobFilterName[JOBFILTER_PRODUCERS]);
		RefreshJobList();
		if (job >= g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_LABORERS] && job < g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_LABORERS + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_LABORERS);
		else if (job >= g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_PRODUCERS] && job < g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_PRODUCERS + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_PRODUCERS);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_FARMSTAFF);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));

	}
	else if (!InDungeon)
	{  // if not in dungeon, set up job lists
		// add the job filters
		//	for(int i=0; i<NUMJOBTYPES; i++)  // loop through all job types
		for (unsigned int i = 0; i <= JOBFILTER_BROTHEL; i++)  // temporary limit to job types shown
		{
			AddToListBox(jobtypelist_id, i, g_Brothels.m_JobManager.JobFilterName[i]);
		}

		// set the job filter
		int jobtype = 0;
		for (unsigned int i = 0; i < NUMJOBTYPES; i++)
		{
			if (job >= g_Brothels.m_JobManager.JobFilterIndex[i] && job < g_Brothels.m_JobManager.JobFilterIndex[i + 1])
			{
				jobtype = i;
				break;
			}
		}
		SetSelectedItemInList(jobtypelist_id, jobtype);
		RefreshJobList();

		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else
	{  // if in dungeon, effectively disable job lists
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, -1, gettext("Languish in dungeon"));
		HideButton(day_id, true);
		HideButton(night_id, true);
	}

	ClearListBox(traitlist_id);
	for (int i = 0; i < MAXNUM_TRAITS; i++)
	{
		if (selected_girl->m_Traits[i])
		{
			stringstream st;
			st << selected_girl->m_Traits[i]->m_Name;
			if (selected_girl->m_TempTrait[i] > 0) st << "   (" << selected_girl->m_TempTrait[i] << ")";
			AddToListBox(traitlist_id, i, g_Traits.GetTranslateName(st.str()));
		}
	}
	EditTextItem("", traitdesc_id);
}
Example #26
0
    filename = argv[1];
  }

  // Salt-and-pepper noise parameters
  int black_proba = 2;
  int white_proba = 2;
  if (argc > 3) {
    stringstream ss;
    ss << argv[2] << " " << argv[3];
    ss >> black_proba >> white_proba;
  }

  Mat img = load_binary_image(filename);
  Mat noisy_img = add_salt_and_pepper_noise(img, black_proba, white_proba);

  auto start = std::chrono::steady_clock::now();
  Mat denoised_img = denoise(noisy_img, 1);
  auto end = std::chrono::steady_clock::now();
  std::cout << "Time: "
            << chrono::duration_cast<chrono::milliseconds>(end - start).count() 
            << " ms"
            << std::endl;

  Mat comparison = make_comparison(img, noisy_img, denoised_img);

  stringstream ss;
  ss << "denoised_" << black_proba << "_" << white_proba << "_" << filename;
  imwrite(ss.str(), comparison);
  show_image(comparison);
}
void cScreenGirlDetails::check_events()
{
	// no events means we can go home
	if (g_InterfaceEvents.GetNumEvents() == 0) return;

	// if it's the back button, pop the window off the stack and we're done
	if (g_InterfaceEvents.CheckButton(back_id))
	{
		g_InitWin = true;
		g_WinManager.Pop();
		return;
	}
	if (g_InterfaceEvents.CheckSlider(houseperc_id))
	{
		g_Girls.SetStat(selected_girl, STAT_HOUSE, SliderValue(houseperc_id));
		ss.str("");
		ss << gettext("House Percentage: ") << SliderValue(houseperc_id) << gettext("%");
		EditTextItem(ss.str(), housepercval_id);
		// Rebelliousness might have changed, so update details
		if (DetailLevel == 0)
		{
			string detail = g_Girls.GetDetailsString(selected_girl);
			EditTextItem(detail, girldesc_id);
		}
		return;
	}
	if (g_InterfaceEvents.CheckButton(more_id))
	{
		if (DetailLevel == 0)		{ DetailLevel = 1; EditTextItem(g_Girls.GetMoreDetailsString(selected_girl), girldesc_id); }
		else if (DetailLevel == 1)	{ DetailLevel = 2; EditTextItem(g_Girls.GetThirdDetailsString(selected_girl), girldesc_id); }
		else						{ DetailLevel = 0; EditTextItem(g_Girls.GetDetailsString(selected_girl), girldesc_id); }
	}
	if (g_InterfaceEvents.CheckButton(day_id))
	{
		DisableButton(day_id, true);
		DisableButton(night_id, false);
		g_InitWin = true;
		Day0Night1 = SHIFT_DAY;
	}
	if (g_InterfaceEvents.CheckButton(night_id))
	{
		DisableButton(day_id, false);
		DisableButton(night_id, true);
		g_InitWin = true;
		Day0Night1 = SHIFT_NIGHT;
	}
	if (g_InterfaceEvents.CheckCheckbox(antipreg_id))
	{
		selected_girl->m_UseAntiPreg = (IsCheckboxOn(antipreg_id));
	}
	if (g_InterfaceEvents.CheckListbox(traitlist_id))
	{
		int selection = GetLastSelectedItemFromList(traitlist_id);
		if (selection != -1)
			EditTextItem(selected_girl->m_Traits[selection]->m_Desc, traitdesc_id);
		else
			EditTextItem("", traitdesc_id);
	}
	if (g_InterfaceEvents.CheckListbox(jobtypelist_id))
	{
		SetJob = true;
		RefreshJobList();
	}
	if (g_InterfaceEvents.CheckListbox(joblist_id))
	{
		bool fulltime = g_CTRLDown;

		int selection = GetSelectedItemFromList(joblist_id);
		if (selection != -1)
		{
			int old_job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
			// handle special job requirements and assign - if HandleSpecialJobs returns true, the job assignment was modified or cancelled
			if (g_Brothels.m_JobManager.HandleSpecialJobs(g_CurrBrothel, selected_girl, selection, old_job, Day0Night1, fulltime))
			{
				selection = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
				SetSelectedItemInList(joblist_id, selection, false);
			}
			// refresh job worker counts for former job and current job
			if (old_job != selection)
			{
				SetSelectedItemText(joblist_id, old_job, g_Brothels.m_JobManager.JobDescriptionCount(old_job, g_CurrBrothel, Day0Night1));
				SetSelectedItemText(joblist_id, selection, g_Brothels.m_JobManager.JobDescriptionCount(selection, g_CurrBrothel, Day0Night1));
			}
			RefreshJobList();
		}
	}
	if (g_InterfaceEvents.CheckButton(inventory_id))
	{
		if (selected_girl)
		{
			if (GirlDead(selected_girl)) return;
			g_InitWin = true;
			g_AllTogle = true;
			g_WinManager.push("Item Management");
			return;
		}
	}
	if (g_InterfaceEvents.CheckButton(gallery_id))
	{
		g_WinManager.push("Gallery");
		g_InitWin = true;
		return;
	}


	if (g_InterfaceEvents.CheckSlider(accom_id))
	{
		selected_girl->m_AccLevel = SliderValue(accom_id);
		SliderRange(accom_id, 0, 9, selected_girl->m_AccLevel, 1);
		if (accomval_id != -1)
		{
			stringstream acc;
			acc << "Accommodation: " << g_Girls.Accommodation(SliderValue(accom_id));
			if (cfg.debug.log_extradetails())
			{
				int val = SliderValue(accom_id) - g_Girls.PreferredAccom(selected_girl);
				if (val != 0) acc << "  ( " << (val > 0 ? "+" : "") << val << " )";
			}
			EditTextItem(acc.str(), accomval_id);
		}
		g_InitWin = true;
		return;
	}
	if (g_InterfaceEvents.CheckButton(accomup_id))
	{
		if (selected_girl->m_AccLevel + 1 > 9)
			selected_girl->m_AccLevel = 9;
		else
			selected_girl->m_AccLevel++;
		if (accomval_id != -1) EditTextItem("Accommodation: " + g_Girls.Accommodation(selected_girl->m_AccLevel), accomval_id);

		g_InitWin = true;
		return;
	}
	if (g_InterfaceEvents.CheckButton(accomdown_id))
	{
		if (selected_girl->m_AccLevel - 1 < 0)	selected_girl->m_AccLevel = 0;
		else									selected_girl->m_AccLevel--;
		if (accomval_id != -1) EditTextItem("Accommodation: " + g_Girls.Accommodation(selected_girl->m_AccLevel), accomval_id);

		g_InitWin = true;
		return;
	}
	if (g_InterfaceEvents.CheckButton(takegold_id))
	{
		take_gold(selected_girl);
	}
	if (g_InterfaceEvents.CheckButton(reldungeon_id))
	{
		g_Brothels.GetDungeon()->GetDungeonPos(selected_girl);
		if ((g_Brothels.GetBrothel(g_CurrBrothel)->m_NumRooms - g_Brothels.GetBrothel(g_CurrBrothel)->m_NumGirls) == 0)
		{
			g_MessageQue.AddToQue(gettext("The current brothel has no more room.\nBuy a new one, get rid of some girls, or change the brothel you are currently managing."), 0);
		}
		else
		{
			sGirl* nextGirl = remove_selected_girl();
			sGirl* tempGirl = g_Brothels.GetDungeon()->RemoveGirl(g_Brothels.GetDungeon()->GetGirl(g_Brothels.GetDungeon()->GetGirlPos(selected_girl)));
			g_Brothels.AddGirl(g_CurrBrothel, tempGirl);

			if (g_Brothels.GetDungeon()->GetNumGirls() == 0)
			{
				selected_girl = 0;
				g_WinManager.Pop();
			}
			else
				selected_girl = nextGirl;
		}
		g_InitWin = true;
		return;
	}
	if (g_InterfaceEvents.CheckButton(senddungeon_id))
	{
		ss.str("");
		g_Brothels.GetGirlPos(g_CurrBrothel, selected_girl);

		// does she decide to fight back
		if (g_Brothels.FightsBack(selected_girl))
		{
			bool win = true;
			sGang* gang = g_Gangs.GetGangOnMission(MISS_GUARDING);
			int count = 8;
			while (gang && win && count >= 0)
			{
				win = (g_Gangs.GangCombat(selected_girl, gang));
				if (gang->m_Num == 0) gang = g_Gangs.GetGangOnMission(MISS_GUARDING);
				count--;
				if (count<0) win = true;
			}
			// Calculate combat between goons and girl if she decides to fight back
			if (win)
			{
				ss << gettext("She puts up a fight");
				if (gang && gang->m_Num == 0) ss << gettext(", and the gang is completely wiped out");
				ss << ". ";

				if (g_Brothels.PlayerCombat(selected_girl))				// fight with the player
				{
					// If girl wins she escapes and leaves the brothel
					ss << gettext("After defeating you as well, she escapes to the outside.\n");
					ss << gettext("She will escape for good in 6 weeks if you don't send someone after her.");

					sGirl* nextGirl = remove_selected_girl();
					sGirl* temp = selected_girl;
					if (selected_girl->m_DayJob == JOB_INDUNGEON)	temp = g_Brothels.GetDungeon()->RemoveGirl(selected_girl);
					else if (selected_girl->m_InHouse)	g_House.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InFarm)	g_Farm.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InClinic)	g_Clinic.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InCentre)	g_Centre.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InArena)	g_Arena.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InStudio)	g_Studios.RemoveGirl(0, selected_girl, false);
					else g_Brothels.RemoveGirl(selected_girl->where_is_she, selected_girl, false);

					temp->m_RunAway = 6;
					temp->m_NightJob = temp->m_DayJob = JOB_RUNAWAY;
					g_Brothels.AddGirlToRunaways(temp);

					stringstream smess;
					smess << temp->m_Realname << gettext(" has run away");
					g_MessageQue.AddToQue(smess.str(), 1);

					selected_girl = nextGirl;
					if (selected_girl == 0) g_WinManager.Pop();
				}
				else	// otherwise put her in the dungeon
				{
					int reason = (selected_girl->m_Spotted ? DUNGEON_GIRLSTEAL : DUNGEON_GIRLWHIM);
					sGirl* nextGirl = remove_selected_girl();
					selected_girl->m_DayJob = selected_girl->m_NightJob = JOB_INDUNGEON;

					/* */if (selected_girl->m_InHouse)	g_House.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InFarm)	g_Farm.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InClinic)	g_Clinic.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InCentre)	g_Centre.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InArena)	g_Arena.RemoveGirl(0, selected_girl, false);
					else if (selected_girl->m_InStudio)	g_Studios.RemoveGirl(0, selected_girl, false);
					else g_Brothels.RemoveGirl(selected_girl->where_is_she, selected_girl, false);

					g_Brothels.GetDungeon()->AddGirl(selected_girl, reason);
					ss << gettext("However, you manage to defeat her yourself and place her unconscious body in the dungeon.");

					bool pop = false;
					/* */if (selected_girl->m_InHouse)	if (g_House.GetNumGirls(0) == 0)	pop = true;
					else if (selected_girl->m_InFarm)	if (g_Farm.GetNumGirls(0) == 0)		pop = true;
					else if (selected_girl->m_InClinic)	if (g_Clinic.GetNumGirls(0) == 0)	pop = true;
					else if (selected_girl->m_InCentre)	if (g_Centre.GetNumGirls(0) == 0)	pop = true;
					else if (selected_girl->m_InArena)	if (g_Arena.GetNumGirls(0) == 0)	pop = true;
					else if (selected_girl->m_InStudio)	if (g_Studios.GetNumGirls(0) == 0)	pop = true;
					else if (g_Brothels.GetNumGirls(selected_girl->where_is_she) == 0)		pop = true;

					if (pop)	{ selected_girl = 0; g_WinManager.Pop(); }
					else		selected_girl = nextGirl;
				}
			}
			else	// otherwise put her in the dungeon
			{
				ss << gettext("She puts up a fight ");
				if (gang && gang->m_Num == 0)	ss << gettext("and the gang is wiped out, ");

				ss << gettext("but your goons manage to drag her unconscious to the dungeon.");
				int reason = (selected_girl->m_Spotted ? DUNGEON_GIRLSTEAL : DUNGEON_GIRLWHIM);
				sGirl* nextGirl = remove_selected_girl();

				/* */if (selected_girl->m_InHouse)	g_House.RemoveGirl(0, selected_girl, false);
				else if (selected_girl->m_InFarm)	g_Farm.RemoveGirl(0, selected_girl, false);
				else if (selected_girl->m_InClinic)	g_Clinic.RemoveGirl(0, selected_girl, false);
				else if (selected_girl->m_InCentre)	g_Centre.RemoveGirl(0, selected_girl, false);
				else if (selected_girl->m_InArena)	g_Arena.RemoveGirl(0, selected_girl, false);
				else if (selected_girl->m_InStudio)	g_Studios.RemoveGirl(0, selected_girl, false);
				else g_Brothels.RemoveGirl(selected_girl->where_is_she, selected_girl, false);
				g_Brothels.GetDungeon()->AddGirl(selected_girl, reason);

				bool pop = false;
				/* */if (selected_girl->m_InHouse)	if (g_House.GetNumGirls(0) == 0)	pop = true;
				else if (selected_girl->m_InFarm)	if (g_Farm.GetNumGirls(0) == 0)		pop = true;
				else if (selected_girl->m_InClinic)	if (g_Clinic.GetNumGirls(0) == 0)	pop = true;
				else if (selected_girl->m_InCentre)	if (g_Centre.GetNumGirls(0) == 0)	pop = true;
				else if (selected_girl->m_InArena)	if (g_Arena.GetNumGirls(0) == 0)	pop = true;
				else if (selected_girl->m_InStudio)	if (g_Studios.GetNumGirls(0) == 0)	pop = true;
				else if (g_Brothels.GetNumGirls(selected_girl->where_is_she) == 0)		pop = true;

				if (pop)	{ selected_girl = 0; g_WinManager.Pop(); }
				else		selected_girl = nextGirl;
			}
		}
		else
		{
			int reason = (selected_girl->m_Spotted ? DUNGEON_GIRLSTEAL : DUNGEON_GIRLWHIM);
			sGirl* nextGirl = remove_selected_girl();

			/* */if (selected_girl->m_InHouse)	g_House.RemoveGirl(0, selected_girl, false);
			else if (selected_girl->m_InFarm)	g_Farm.RemoveGirl(0, selected_girl, false);
			else if (selected_girl->m_InClinic)	g_Clinic.RemoveGirl(0, selected_girl, false);
			else if (selected_girl->m_InCentre)	g_Centre.RemoveGirl(0, selected_girl, false);
			else if (selected_girl->m_InArena)	g_Arena.RemoveGirl(0, selected_girl, false);
			else if (selected_girl->m_InStudio)	g_Studios.RemoveGirl(0, selected_girl, false);
			else g_Brothels.RemoveGirl(selected_girl->where_is_she, selected_girl, false);

			g_Brothels.GetDungeon()->AddGirl(selected_girl, reason);
			ss << gettext("She goes quietly with a sullen look on her face.");

			bool pop = false;
			/* */if (selected_girl->m_InHouse)	if (g_House.GetNumGirls(0) == 0)	pop = true;
			else if (selected_girl->m_InFarm)	if (g_Farm.GetNumGirls(0) == 0)		pop = true;
			else if (selected_girl->m_InClinic)	if (g_Clinic.GetNumGirls(0) == 0)	pop = true;
			else if (selected_girl->m_InCentre)	if (g_Centre.GetNumGirls(0) == 0)	pop = true;
			else if (selected_girl->m_InArena)	if (g_Arena.GetNumGirls(0) == 0)	pop = true;
			else if (selected_girl->m_InStudio)	if (g_Studios.GetNumGirls(0) == 0)	pop = true;
			else if (g_Brothels.GetNumGirls(g_CurrBrothel) == 0) /*              */	pop = true;

			if (pop)	{ selected_girl = 0; g_WinManager.Pop(); }
			else		selected_girl = nextGirl;
		}
		g_InitWin = true;
		g_MessageQue.AddToQue(ss.str(), 0);
		return;
	}
	if (g_InterfaceEvents.CheckButton(interact_id))
	{
		if (g_TalkCount > 0)
		{
			DirPath dp;
			eventrunning = true;
			if (selected_girl->m_DayJob != JOB_INDUNGEON)
			{
				int v[2] = { 1, -1 };
				cTrigger* trig = 0;
				if (!(trig = selected_girl->m_Triggers.CheckForScript(TRIGGER_TALK, false, v)))	// trigger any girl specific talk script
				{
					// no, so trigger the default one
					dp = dp << "Resources" << "Scripts" << "DefaultInteractDetails.script";
				}
				else
				{
					// yes, so use that instead
					dp = DirPath(cfg.folders.characters().c_str()) << selected_girl->m_Name << trig->m_Script;
				}
			}
			else
			{
				int v[2] = { 0, -1 };
				cTrigger* trig = 0;
				if (!(trig = selected_girl->m_Triggers.CheckForScript(TRIGGER_TALK, false, v)))	// trigger any girl specific talk script
				{
					// no, so trigger the default one
					dp = dp << "Resources" << "Scripts" << "DefaultInteractDungeon.script";
				}
				else
				{
						dp = DirPath(cfg.folders.characters().c_str()) << selected_girl->m_Name << trig->m_Script;
				}
			}
			cScriptManager script_manager;
			script_manager.Load(dp, selected_girl);
			if (!g_Cheats)
				g_TalkCount--;
		}
		g_InitWin = true;
		return;
	}
	if (g_InterfaceEvents.CheckButton(next_id))
	{
		NextGirl();
	}
	if (g_InterfaceEvents.CheckButton(prev_id))
	{
		PrevGirl();
	}
}
void cScreenGangs::init()
{
	g_CurrentScreen = SCREEN_GANGMANAGEMENT;
	if (!g_InitWin) return;
	Focused();
	g_InitWin = false;

	selection = GetLastSelectedItemFromList(ganglist_id);
	sel_recruit = GetLastSelectedItemFromList(recruitlist_id);

	ClearListBox(missionlist_id);
	AddToListBox(missionlist_id, 0, "GUARDING");
	AddToListBox(missionlist_id, 1, "SABOTAGE");
	AddToListBox(missionlist_id, 2, "SPY ON GIRLS");
	AddToListBox(missionlist_id, 3, "RECAPTURE");
	AddToListBox(missionlist_id, 4, "ACQUIRE TERRITORY");
	AddToListBox(missionlist_id, 5, "PETTY THEFT");
	AddToListBox(missionlist_id, 6, "GRAND THEFT");
	AddToListBox(missionlist_id, 7, "KIDNAPPING");
	AddToListBox(missionlist_id, 8, "CATACOMBS");
	AddToListBox(missionlist_id, 9, "TRAINING");
	AddToListBox(missionlist_id, 10, "RECRUITING");
	AddToListBox(missionlist_id, 11, "SERVICE");

	SetCheckBox(controlcatacombs_id, (g_Gangs.Control_Gangs()));
	SliderRange(girlspercslider_id, 0, 100, g_Gangs.Gang_Gets_Girls(), 1);
	SliderRange(itemspercslider_id, 0, 100, g_Gangs.Gang_Gets_Girls() + g_Gangs.Gang_Gets_Items(), 1);
	ss.str("");	ss << "Girls : " << g_Gangs.Gang_Gets_Girls() << "%";	EditTextItem(ss.str(), ganggetsgirls_id);
	ss.str("");	ss << "Items : " << g_Gangs.Gang_Gets_Items() << "%";	EditTextItem(ss.str(), ganggetsitems_id);
	ss.str("");	ss << "Beasts : " << g_Gangs.Gang_Gets_Beast() << "%";	EditTextItem(ss.str(), ganggetsbeast_id);

	SetCheckBox(netautobuy_id, (g_Gangs.GetNetRestock() > 0));
	SetCheckBox(healautobuy_id, (g_Gangs.GetHealingRestock() > 0));

	// weapon upgrades
	int *wlev = g_Gangs.GetWeaponLevel();
	ss.str("");	ss << "Weapon Level: " << *wlev;
	if ((*wlev) < 4)
	{
		EnableButton(weaponup_id);
		ss << " Next: " << tariff.goon_weapon_upgrade(*wlev) << "g";
	}
	else DisableButton(weaponup_id);
	g_LogFile.ss() << "weapon text = '" << ss.str() << "'" << endl; g_LogFile.ssend();
	EditTextItem(ss.str(), weaponlevel_id);

	int *nets = g_Gangs.GetNets();
	ss.str(""); ss << "Nets (" << tariff.nets_price(1) << "g each): " << *nets;
	EditTextItem(ss.str(), netdesc_id);
	DisableButton(netbuy_id, *nets >= 60);
	DisableButton(netbuy10_id, *nets >= 60);
	DisableButton(netbuy20_id, *nets >= 60);
	DisableCheckBox(netautobuy_id, *nets < 1);

	int *potions = g_Gangs.GetHealingPotions();
	ss.str(""); ss << "Heal Potions (" << tariff.healing_price(1) << "g each): " << *potions;
	EditTextItem(ss.str(), healdesc_id);
	DisableButton(healbuy_id, *potions >= 200);
	DisableButton(healbuy10_id, *potions >= 200);
	DisableButton(healbuy20_id, *potions >= 200);
	DisableCheckBox(healautobuy_id, *potions < 1);

	int cost = 0;
	if (g_Gangs.GetNumGangs() > 0)
	{
		for (int i = 0; i < g_Gangs.GetNumGangs(); i++)
		{
			sGang* g = g_Gangs.GetGang(i);
			if (g == 0) g = g_Gangs.GetGang(i - 1);
			cost += tariff.goon_mission_cost(g->m_MissionID);
		}
	}
	ss.str(""); ss << "Weekly Cost: " << cost;
	EditTextItem(ss.str(), totalcost_id);
	if (gold_id >= 0)
	{
		ss.str(""); ss << "Gold: " << g_Gold.ival();
		EditTextItem(ss.str(), gold_id);
	}

	ClearListBox(ganglist_id);
	int num = 0;
	sGang* current = g_Gangs.GetGang(0);

	// loop through the gangs, populating the list box
	g_LogFile.write("Setting gang mission descriptions\n");
	for (current = g_Gangs.GetGang(0); current; current = current->m_Next)
	{
		// format the string with the gang name, mission and number of men
		string Data[11];
		ss.str("");	ss << current->m_Name;								Data[0] = ss.str();
		ss.str("");	ss << current->m_Num;								Data[1] = ss.str();
		ss.str("");	ss << short_mission_desc(current->m_MissionID);		Data[2] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_COMBAT] << "%";		Data[3] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_MAGIC] << "%";		Data[4] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_INTELLIGENCE] << "%";	Data[5] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_AGILITY] << "%";		Data[6] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CONSTITUTION] << "%";	Data[7] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CHARISMA] << "%";		Data[8] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_STRENGTH] << "%";		Data[9] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_SERVICE] << "%";		Data[10] = ss.str();

		//		cerr << "Gang:\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2]
		//			<< "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << "\t" << Data[6] << endl;

		/*
		*			add the box to the list; red highlight gangs that are low on numbers
		*/
		int color = (current->m_Num < 6 ? COLOR_RED : COLOR_BLUE);
		if (current->m_Num < 6 && (current->m_MissionID == MISS_SERVICE || current->m_MissionID == MISS_TRAINING)) color = COLOR_YELLOW;
		AddToListBox(ganglist_id, num++, Data, 11, color);
	}

	ClearListBox(recruitlist_id);
	num = 0;
	current = g_Gangs.GetHireableGang(0);

	// loop through the gangs, populating the list box
	g_LogFile.write("Setting recruitable gang info\n");
	for (current = g_Gangs.GetHireableGang(0); current; current = current->m_Next)
	{
		// format the string with the gang name, mission and number of men
		string Data[10];
		ss.str("");	ss << current->m_Name;								Data[0] = ss.str();
		ss.str("");	ss << current->m_Num;								Data[1] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_COMBAT] << "%";		Data[2] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_MAGIC] << "%";		Data[3] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_INTELLIGENCE] << "%";	Data[4] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_AGILITY] << "%";		Data[5] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CONSTITUTION] << "%";	Data[6] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CHARISMA] << "%";		Data[7] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_STRENGTH] << "%";		Data[8] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_SERVICE] << "%";		Data[9] = ss.str();

		//		cerr << "Recruitable\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2]
		//			<< "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << endl;

		/*
		*			add the box to the list
		*/
		int color = (current->m_Num < 6 ? COLOR_RED : COLOR_BLUE);
		AddToListBox(recruitlist_id, num++, Data, 10, color);
	}

	if (selection == -1 && GetListBoxSize(ganglist_id) >= 1) selection = 0;

	if (selection >= 0)
	{
		while (selection > GetListBoxSize(ganglist_id) && selection != -1) selection--;
	}
	if (selection >= 0) SetSelectedItemInList(ganglist_id, selection);
	if (sel_recruit == -1 && GetListBoxSize(recruitlist_id) >= 1) sel_recruit = 0;
	if (sel_recruit >= 0) SetSelectedItemInList(recruitlist_id, sel_recruit);

	DisableButton(ganghire_id, (g_Gangs.GetNumHireableGangs() <= 0) || (g_Gangs.GetNumGangs() >= g_Gangs.GetMaxNumGangs()) || (sel_recruit == -1));
	DisableButton(gangfire_id, (g_Gangs.GetNumGangs() <= 0) || (selection == -1));

	potions = wlev = nets = 0;
}
Example #29
0
	static void outputErrorPosition(int pos, stringstream & ss){
		const string & s = ss.str();
		cerr << "Configuration error " << endl << s.substr(0, pos) << "!!!!ERROR IS HERE!!!!" << s.substr(pos) << endl;
	}
bool GAMESSUKFormat::ReadGeometry(OBMol &mol, vector<string> &geomList)
{
	
	/* Read a geometry from a list. Any variables that appear in the geometry need
	 * to be in the variables map that should have been populated before this is called.
	 */
	
	if (geomList.size()==0){
		obErrorLog.ThrowError(__FUNCTION__, 
				"Problems reading a GAMESS-UK Input file: ReadGeometry got empty list",
				obWarning);
		return false;
	}

	vector<string> tokens; // list of lines and list of tokens on a line
	string line; // For convenience so we can refer to lines from the iterator as 'line'
	double factor=BOHR_TO_ANGSTROM; // The coordinate conversion factor for handling bohr/angstrom issues

	mol.BeginModify();	
	// Clear out any existing information
	mol.Clear();
	vic.clear();
	
	ReadMode=SKIP;
	bool ContainsZmatrix=false;
	int zmatLineCount=0;

	/*	
	cerr << "ReadGeometry got geometry list: \n";
	for (vector<string>::iterator i=geomList.begin(); i !=geomList.end(); i++) {
		
		// Alias the line
		line = *i; 
		cerr << "line: " << line << endl;
	}
	*/
	
	for (vector<string>::iterator i=geomList.begin(); i !=geomList.end(); i++) {
		
		// Alias the line
		line = *i; 
		
		//cerr << "ReadGeometry line is: " << line << endl;

		// Check for commas & split with that as the separator if necessary
		if (line.find(',')!=string::npos) {
			tokenize(tokens, line, ",");
		} else {
			tokenize(tokens, line, " \t\n");
		}


		// Set the mode
		if (line.compare(0, 4, "zmat")==0 || line.compare(0, 4, "inte")==0) {
			ReadMode=ZMATRIX;
			//cout << "ZMATRIX mode " << ReadMode << endl;
			//cout << "tokens.size()" << tokens.size() << endl;
			if (tokens.size()>1) if (IsUnits(tokens[1])) factor=Rescale(tokens[1]);
			ContainsZmatrix=true;
			vic.push_back((OBInternalCoord*)NULL); // OBMol indexed from 1 -- potential atom index problem
		} else if (line.compare(0, 4, "coor")==0 || line.compare(0, 4, "cart")==0 ||line.compare(0, 4, "geom")==0) {
			ReadMode=CARTESIAN;
			//cout << "CARTESIAN mode " << ReadMode << endl;
			if (tokens.size()>1) if (IsUnits(tokens[1])) factor=Rescale(tokens[1]);
			
		/*
		 We need to have read the variables first
		} else if (line.compare(0, 4, "vari")==0) {
			ReadMode=VARIABLES;
			//cout << "VARIABLES mode "<< ReadMode << endl;
			if (tokens.size() == 2) factor=Rescale(tokens[1]);
			//cout << "Factor now " << factor << endl;
		} else if (line.compare(0, 4, "cons")==0) {
			ReadMode=CONSTANTS;
			//cout << "CONSTANTS mode\n";
			if (tokens.size() == 2)
				factor=Rescale(tokens[1]);
			//cout << "Factor now " << factor << endl;
	    */
			
		} else if (line.compare(0, 3, "end")==0) {
			ReadMode=SKIP;
			//cout << "SKIP mode " << ReadMode << endl;
		} else {
			if (ReadMode==SKIP) continue;
			if (ReadMode==ZMATRIX) {
				// Create an atom
				OBAtom *atom = mol.NewAtom();
				// Read the ZMatrix definition line
				if (! ReadLineZmatrix(mol,atom,tokens,factor,&zmatLineCount) )
				{
					errorMsg << "Problems reading a GAMESS-UK Input file: "
							<< "Could not read zmat line: " << line;
					obErrorLog.ThrowError(__FUNCTION__, errorMsg.str() ,
							obWarning);
					return (false);
				}	
				
			} // End ReadMode ZMATRIX

			if (ReadMode==CARTESIAN) {
				OBAtom *atom = mol.NewAtom();
				if (! ReadLineCartesian(atom,tokens,factor) )
				{
					errorMsg << "Problems reading a GAMESS-UK Input file: "
							<< "Could not read xyz line: " << line;
					obErrorLog.ThrowError(__FUNCTION__, errorMsg.str() ,
							obWarning);
					return (false);
				}
				
			} // End ReadMode CARTESIAN


		} // End Test for first chars on line
	} // End loop over lines
	
	if (ContainsZmatrix)InternalToCartesian(vic,mol);
	mol.EndModify();
	
	return true;	
}