Example #1
0
//  list change
void CGui::listRplChng(List* li, size_t pos)
{
	String name = getRplName();  if (name.empty())  return;
	string file = GetRplListDir() + "/" + name + ".rpl";
	valRplName->setCaption(name);
	edRplName->setCaption(name);
	
	//  load replay header, upd info text
	Replay rpl;  char stm[128];
	if (rpl.LoadFile(file,true))
	{
		String ss = String(TR("#{Track}: ")) + gcom->GetSceneryColor(rpl.header.track) +
			rpl.header.track + (rpl.header.track_user ? "  *"+TR("#{TweakUser}")+"*" : "");
		valRplName->setCaption(ss);

		ss = String(TR("#{Car}: ")) + rpl.header.car + "       "+
			(rpl.header.numPlayers == 1 ? "" : (TR("#{Players}: ") + toStr(rpl.header.numPlayers))) + "  " +
			(rpl.header.networked == 0 ? "" : "M") +  //TR("#{Multiplayer}")
			"\n#C0D8F0" + TR("#{RplTime}: ") + CHud::StrTime(rpl.GetTimeLength()) +
			"\n#90A0B0" + TR("#{Simulation}: ") + rpl.header.sim_mode;
		if (rpl.header.networked == 1)  // list nicks
			ss += String("\n#90C0E0")+rpl.header.nicks[0]+"  "+rpl.header.nicks[1]+"  "+rpl.header.nicks[2]+"  "+rpl.header.nicks[3];
		//else  // other cars, car colors ..
			//ss += String("\n#90C0E0")+rpl.header.cars[0]+"  "+rpl.header.cars[1]+"  "+rpl.header.cars[2];
		valRplInfo->setCaption(ss);

		//  file stats
		int size = fs::file_size(file);
		std::time_t ti = fs::last_write_time(file);
		if (!std::strftime(stm, 126, "%d.%b'%y  %a %H:%M", std::localtime(&ti)))  stm[0]=0;
		
		ss =/*"Time: "+*/String(stm)+"\n#A0A0A0"+
			String(TR("#{RplFileSize}: ")) + fToStr( float(size)/1000000.f, 2,5) + TR(" #{UnitMB}") + "\n#808080" +
			TR("#{RplVersion}: ") + toStr(rpl.header.ver) + "     " + toStr(rpl.header.frameSize) + "B";
		if (valRplInfo2)  valRplInfo2->setCaption(ss);
	}
	//edRplDesc
}
Example #2
0
///............................................................................................................................
///  _Tool_ convert ghosts to track's ghosts (less size and frame data)
//  put original ghosts into  data/ghosts/original/*_ES.rpl
//  (ES, normal sim, 1st lap, no boost, use rewind with _Tool_ go back time)
//  time should be like in tracks.ini or less (last T= )
///............................................................................................................................
void CGui::ToolGhostsConv()
{
	LogO("ALL ghosts Convert ---------");
	Replay ghost;  TrackGhost trg;
	bool reverse = false;  string sRev = reverse ? "_r" : "";
	//for both dir sRev..
	
	//  foreach track
	for (int i=0; i < data->tracks->trks.size(); ++i)
	{	string track = data->tracks->trks[i].name;
		if (track.substr(0,4) == "Test" && track.substr(0,5) != "TestC")  continue;
		
		//  load
		ghost.Clear();  trg.Clear();
		string file = PATHMANAGER::TrkGhosts()+"/original/"+ track + sRev + "_ES.rpl";
		if (!PATHMANAGER::FileExists(file))
		{}	//LogO("NOT found: "+file);
		else
		{	LogO("---------  "+track+"  ---------");
			ghost.LoadFile(file);
			
			//  convert
			MATHVECTOR<float,3> oldPos;  float oldTime = 0.f;
			int num = ghost.GetNumFrames(), jmp = 0;
			
			for (int i=0; i < num; ++i)
			{
				const ReplayFrame& fr = ghost.GetFrame0(i);
				TrackFrame tf;
				tf.time = fr.time;
				tf.pos = fr.pos;
				tf.rot = fr.rot;  //tf.rot[0] = fr.rot[0] * 32767.f;  //..
				tf.brake = fr.braking > 0 ? 1 : 0;
				tf.steer = fr.steer * 127.f;
				//LogO(toStr(fr.braking)+ " st " +fToStr(fr.steer,2,5));

				#define Nth 3
				if (i % Nth == Nth-1)  /// write every n-th frame only
					trg.AddFrame(tf);

				//  check for sudden pos jumps  (rewind used but not with _Tool_ go back time !)
				if (i > 10 && i < num-1)  // ignore jumps at start or end
				{	float dist = (fr.pos - oldPos).MagnitudeSquared();
					if (dist > 16.f)  //1.f small
					{	
						LogO("!Jump at "+CHud::StrTime2(fr.time)+"  d "+fToStr(sqrt(dist),0)+"m");
						++jmp;
				}	}
				//  check vel at start
				if (i==50)
				{
					float dist = (fr.pos - oldPos).Magnitude();
					float vel = 3.6f * dist / (fr.time - oldTime);
					bool bad = vel > 30;
					if (bad)
						LogO("!Vel at "+CHud::StrTime(fr.time)+" kmh "+fToStr(vel,0) + (bad ? "  BAD":""));
				}
				oldPos = fr.pos;  oldTime = fr.time;
			}
			if (jmp > 0)
				LogO("!Jumps: "+toStr(jmp));
		
			//  save
			string fsave = PATHMANAGER::TrkGhosts()+"/"+ track + sRev + ".gho";
			trg.header.ver = 1;
			trg.SaveFile(fsave);
		}
	}

	//  check missing
	for (int i=0; i < data->tracks->trks.size(); ++i)
	{	string track = data->tracks->trks[i].name;
		if (track.substr(0,4) == "Test" && track.substr(0,5) != "TestC")  continue;
		
		string fsave = PATHMANAGER::TrkGhosts()+"/"+ track + sRev + ".gho";
		if (!PATHMANAGER::FileExists(fsave))
			LogO("MISSING for track: "+track);
	}
}