Beispiel #1
0
void CGameStats::SubmitServerStats()
{
	SStatsTrackHelper hlp(this);
	
	string mode;
	if(IEntity* pGRE = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem()->GetCurrentGameRulesEntity())
	{
		mode = pGRE->GetClass()->GetName();
	}
	else
		mode = gEnv->pConsole->GetCVar("sv_gamerules")->GetString();

	char strProductVersion[256];
	gEnv->pSystem->GetProductVersion().ToString(strProductVersion);
	
	string name;
	ICVar* pName = gEnv->pConsole->GetCVar("sv_servername");
	if(pName)
		name = pName->GetString();
	if(name.empty())
		name = gEnv->pNetwork->GetHostName();

	string levelname;
	GetLevelName(levelname);

	hlp.ServerValue("mapname",levelname);
	hlp.ServerValue("gametype",mode);
	hlp.ServerValue("hostname",name);
	hlp.ServerValue("gamever",strProductVersion);
}
Beispiel #2
0
void World::InitLevels()
{
	levels.clear();

	std::ifstream world(ResolveFileName(FILE_WORLD_DEF, DIR_WORLD)); 

	if (world.is_open())
	{
		std::string levelDef;
		while (std::getline(world, levelDef, ';').good())
		{
			Level newLevel;
			std::string levelName = GetLevelName(levelDef); 
			newLevel.Init(levelName + EXT_LEVEL);
			std::vector<std::string> cutscenes = GetLevelArrayOfCutscenes(levelDef);
			newLevel.InitCutscenes(cutscenes);
			levels.push_back(newLevel);
		}
	}
	else
	{
		Report::UnexpectedError("Can't open world file", __LINE__, __FILE__);
	}

	world.close();
}
Beispiel #3
0
void CGameStats::ReportGame()
{
	string mode;
	if(IEntity* pGRE = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem()->GetCurrentGameRulesEntity())
	{
		mode = pGRE->GetClass()->GetName();
	}
	else
		mode = gEnv->pConsole->GetCVar("sv_gamerules")->GetString();

	string name;
	ICVar* pName = gEnv->pConsole->GetCVar("sv_servername");
	if(pName)
		name = pName->GetString();

	string timelimit;
	static ICVar* pVar = gEnv->pConsole->GetCVar("g_timelimit");
	timelimit = pVar?pVar->GetString():"0";

	if(m_serverReport)
	{
		string levelname;
		if(GetLevelName(levelname))
			m_serverReport->SetServerValue("mapname",levelname.c_str());
		m_serverReport->SetServerValue("gametype",mode);

		m_serverReport->SetServerValue("timelimit",pVar?pVar->GetString():"0");
	}

	Report();
}
Beispiel #4
0
static Level GetLevelByName(const It begin, const It end) {
    for (u8 i = 0; i < static_cast<u8>(Level::Count); ++i) {
        const char* level_name = GetLevelName(static_cast<Level>(i));
        if (Common::ComparePartialString(begin, end, level_name)) {
            return static_cast<Level>(i);
        }
    }
    return Level::Count;
}
Beispiel #5
0
void FormatLogMessage(const Entry& entry, char* out_text, size_t text_len) {
    unsigned int time_seconds    = static_cast<unsigned int>(entry.timestamp.count() / 1000000);
    unsigned int time_fractional = static_cast<unsigned int>(entry.timestamp.count() % 1000000);

    const char* class_name = GetLogClassName(entry.log_class);
    const char* level_name = GetLevelName(entry.log_level);

    snprintf(out_text, text_len, "[%4u.%06u] %s <%s> %s: %s",
        time_seconds, time_fractional, class_name, level_name,
        TrimSourcePath(entry.location.c_str()), entry.message.c_str());
}
Beispiel #6
0
void CMapLocation::UpdateSpot(CUICustomMap* map, CMapSpot* sp )
{
	if( map->MapName() == GetLevelName() )
	{
		bool b_alife = !!ai().get_alife();

		if ( b_alife && m_flags.test(eHideInOffline) && !m_owner_se_object->m_bOnline )
		{
			return;
		}

		if ( b_alife && m_owner_se_object->m_flags.test(CSE_ALifeObject::flVisibleForMap) == FALSE )
		{
			return;
		}

		if ( IsGameTypeSingle() )
		{
			CGameTask* ml_task = Level().GameTaskManager().HasGameTask( this, true );
			if ( ml_task )
			{
				CGameTask* active_task = Level().GameTaskManager().ActiveTask();
				bool border_show = ( ml_task == active_task );
				if ( m_minimap_spot )
				{
					m_minimap_spot->show_static_border( border_show );
				}
				if ( m_level_spot )
				{
					m_level_spot->show_static_border( border_show );
				}
				if ( m_complex_spot )
				{
					m_complex_spot->show_static_border( border_show );
				}
			}
		}

		//update spot position
		Fvector2 position	= GetPosition();

		m_position_on_map	= map->ConvertRealToLocal(position, (map->Heading())?false:true); //for visibility calculating

		sp->SetWndPos		(m_position_on_map);

		Frect wnd_rect		= sp->GetWndRect();

		if ( map->IsRectVisible(wnd_rect) ) 
		{
			//update heading if needed
			if( sp->Heading() && !sp->GetConstHeading() )
			{
				Fvector2 dir_global = CalcDirection();
				float h = dir_global.getH();
				float h_ = map->GetHeading()+h;
				sp->SetHeading( h_ );
			}
			map->AttachChild	(sp);
		}

		if ( IsGameTypeSingle() )
		{
			CMapSpot* s = GetSpotBorder( sp );
			if ( s )
			{
				s->SetWndPos( sp->GetWndPos() );
				map->AttachChild( s );
			}
		}


		bool b_pointer =( GetSpotPointer(sp) && map->NeedShowPointer(wnd_rect));

		if(map->Heading())
		{
			m_position_on_map	= map->ConvertRealToLocal(position, true); //for drawing
			sp->SetWndPos		(m_position_on_map);
		}

		if(b_pointer)
			UpdateSpotPointer( map, GetSpotPointer(sp) );
	}
	else if ( Level().name() == map->MapName() && GetSpotPointer(sp) )
	{
		GameGraph::_GRAPH_ID		dest_graph_id;

		dest_graph_id		= m_owner_se_object->m_tGraphID;

		map_point_path.clear();

		VERIFY( Actor() );
		GraphEngineSpace::CGameVertexParams		params(Actor()->locations().vertex_types(),flt_max);
		bool res = ai().graph_engine().search(
			ai().game_graph(),
			Actor()->ai_location().game_vertex_id(),
			dest_graph_id,
			&map_point_path,
			params
			);

		if ( res )
		{
			xr_vector<u32>::reverse_iterator it = map_point_path.rbegin();
			xr_vector<u32>::reverse_iterator it_e = map_point_path.rend();

			xr_vector<CLevelChanger*>::iterator lit = g_lchangers.begin();
			//xr_vector<CLevelChanger*>::iterator lit_e = g_lchangers.end();
			bool bDone						= false;
			//for(; (it!=it_e)&&(!bDone) ;++it){
			//	for(lit=g_lchangers.begin();lit!=lit_e; ++lit){

			//		if((*it)==(*lit)->ai_location().game_vertex_id() )
			//		{
			//			bDone = true;
			//			break;
			//		}

			//	}
			//}
			static bool bbb = false;
			if(!bDone&&bbb)
			{
				Msg("! Error. Path from actor to selected map spot does not contain level changer :(");
				Msg("Path:");
				xr_vector<u32>::iterator it			= map_point_path.begin();
				xr_vector<u32>::iterator it_e		= map_point_path.end();
				for(; it!=it_e;++it){
					//					Msg("%d-%s",(*it),ai().game_graph().vertex(*it));
					Msg("[%d] level[%s]",(*it),*ai().game_graph().header().level(ai().game_graph().vertex(*it)->level_id()).name());
				}
				Msg("- Available LevelChangers:");
				xr_vector<CLevelChanger*>::iterator lit,lit_e;
				lit_e							= g_lchangers.end();
				for(lit=g_lchangers.begin();lit!=lit_e; ++lit){
					GameGraph::_GRAPH_ID gid = (*lit)->ai_location().game_vertex_id();
					Msg("[%d]",gid);
					Fvector p = ai().game_graph().vertex(gid)->level_point();
					Msg("lch_name=%s pos=%f %f %f",*ai().game_graph().header().level(ai().game_graph().vertex(gid)->level_id()).name(), p.x, p.y, p.z);
				}


			};
			if(bDone)
			{
				Fvector2 position;
				position.set			((*lit)->Position().x, (*lit)->Position().z);
				m_position_on_map		= map->ConvertRealToLocal(position, false);
				UpdateSpotPointer		(map, GetSpotPointer(sp));
			}
			else
			{
				xr_vector<u32>::reverse_iterator it = map_point_path.rbegin();
				xr_vector<u32>::reverse_iterator it_e = map_point_path.rend();
				for(; (it!=it_e)&&(!bDone) ;++it)
				{
					if(*ai().game_graph().header().level(ai().game_graph().vertex(*it)->level_id()).name()==Level().name())
						break;
				}
				if(it!=it_e)
				{
					Fvector p = ai().game_graph().vertex(*it)->level_point();
					if(Actor()->Position().distance_to_sqr(p)>45.0f*45.0f)
					{
						Fvector2 position;
						position.set			(p.x, p.z);
						m_position_on_map		= map->ConvertRealToLocal(position, false);
						UpdateSpotPointer		(map, GetSpotPointer(sp));
					}
				}
			}
		}
	}


}
Beispiel #7
0
		const RichBool::detail::String& GetName(size_t idx) const
		{ return idx==GetSize() ? GetLevelName(2) : g->GetName(idx); }