Ejemplo n.º 1
0
bool ReplayList::GetReplayInfos(const std::string& ReplayPath, StoredGame& ret) const
{
	const std::string FileName = LSL::Util::AfterLast(ReplayPath, SEP); // strips file path
	ret.type = StoredGame::REPLAY;
	ret.Filename = ReplayPath;
	ret.battle.SetPlayBackFilePath(ReplayPath);
	ret.SpringVersion = LSL::Util::BeforeLast(LSL::Util::AfterLast(FileName, "_"), ".");
	ret.MapName = LSL::Util::BeforeLast(FileName, "_");

	if (!wxFileExists(TowxString(ReplayPath))) {
		wxLogWarning(wxString::Format(_T("File %s does not exist!"), ReplayPath.c_str()));
		MarkBroken(ret);
		return false;
	}
	wxFile replay(TowxString(ReplayPath), wxFile::read);
	if (!replay.IsOpened()) {
		wxLogWarning(wxString::Format(_T("Could not open file %s for reading!"), ReplayPath.c_str()));
		MarkBroken(ret);
		return false;
	}

	if (replay.Length() == 0) {
		replay.Close();
		MarkBroken(ret);
		return false;
	}

	const int replay_version = replayVersion(replay);
	ret.battle.SetScript(GetScriptFromReplay(replay, replay_version));

	if (ret.battle.GetScript().empty()) {
		wxLogWarning(wxString::Format(_T("File %s have incompatible version!"), ReplayPath.c_str()));
		MarkBroken(ret);
		return false;
	}

	GetHeaderInfo(replay, ret, replay_version);
	ret.battle.GetBattleFromScript(false);
	ret.ModName = ret.battle.GetHostModName();
	ret.battle.SetBattleType(BT_Replay);
	ret.battle.SetEngineName("spring");
	ret.battle.SetEngineVersion(ret.SpringVersion);
	ret.battle.SetPlayBackFilePath(ReplayPath);

	//getting this from filename seems more reliable than from demoheader
	wxDateTime rdate;

	if (rdate.ParseFormat(TowxString(FileName), _T("%Y%m%d_%H%M%S")) == 0) {
		wxLogWarning(wxString::Format(_T("Name of the file %s could not be parsed!"), ReplayPath.c_str()));
		MarkBroken(ret);
		return false;
	}
	ret.date = rdate.GetTicks(); // now it is sorted properly
	ret.date_string = STD_STRING(rdate.FormatISODate() + _T(" ") + rdate.FormatISOTime());

	return true;
}
Ejemplo n.º 2
0
GDALDataset *NGSGEOIDDataset::Open( GDALOpenInfo * poOpenInfo )

{
    if (!Identify(poOpenInfo))
        return NULL;

    if (poOpenInfo->eAccess == GA_Update)
    {
        CPLError( CE_Failure, CPLE_NotSupported,
                  "The NGSGEOID driver does not support update access to existing"
                  " datasets.\n" );
        return NULL;
    }

    VSILFILE* fp = VSIFOpenL( poOpenInfo->pszFilename, "rb" );
    if (fp == NULL)
        return NULL;

/* -------------------------------------------------------------------- */
/*      Create a corresponding GDALDataset.                             */
/* -------------------------------------------------------------------- */
    NGSGEOIDDataset         *poDS;

    poDS = new NGSGEOIDDataset();
    poDS->fp = fp;

    int nRows, nCols;
    GetHeaderInfo( poOpenInfo->pabyHeader,
                   poDS->adfGeoTransform,
                   &nRows,
                   &nCols,
                   &poDS->bIsLittleEndian );
    poDS->nRasterXSize = nCols;
    poDS->nRasterYSize = nRows;

/* -------------------------------------------------------------------- */
/*      Create band information objects.                                */
/* -------------------------------------------------------------------- */
    poDS->nBands = 1;
    poDS->SetBand( 1, new NGSGEOIDRasterBand( poDS ) );

/* -------------------------------------------------------------------- */
/*      Initialize any PAM information.                                 */
/* -------------------------------------------------------------------- */
    poDS->SetDescription( poOpenInfo->pszFilename );
    poDS->TryLoadXML();

/* -------------------------------------------------------------------- */
/*      Support overviews.                                              */
/* -------------------------------------------------------------------- */
    poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename );
    return( poDS );
}
Ejemplo n.º 3
0
bool VGMMultiSectionSeq::LoadMain()
{
	readMode = READMODE_ADD_TO_UI;

	if (!GetHeaderInfo())
		return false;

	if (!LoadTracks(readMode))
		return false;

	return true;
}
Ejemplo n.º 4
0
int NGSGEOIDDataset::Identify( GDALOpenInfo * poOpenInfo )
{
    if (poOpenInfo->nHeaderBytes < HEADER_SIZE)
        return FALSE;

    double adfGeoTransform[6];
    int nRows, nCols;
    int bIsLittleEndian;
    if ( !GetHeaderInfo( poOpenInfo->pabyHeader,
                         adfGeoTransform,
                         &nRows, &nCols, &bIsLittleEndian ) )
        return FALSE;

    return TRUE;
}
Ejemplo n.º 5
0
bool ReplayList::GetReplayInfos(const wxString& ReplayPath, Replay& ret ) const
{
	const wxString FileName = ReplayPath.AfterLast( wxFileName::GetPathSeparator() ); // strips file path
	ret.Filename = ReplayPath;
	ret.battle.SetPlayBackFilePath(STD_STRING(ReplayPath));
	ret.SpringVersion = FileName.AfterLast(_T('_')).BeforeLast(_T('.'));
	ret.MapName = FileName.BeforeLast(_T('_'));


	if (!wxFileExists(ReplayPath)) {
		return false;
	}
	wxFile replay(ReplayPath, wxFile::read );
	if (!replay.IsOpened()) {
		return false;
	}

	const int replay_version = replayVersion( replay );
	ret.battle.SetScript(STD_STRING(GetScriptFromReplay( replay, replay_version )));

	if ( ret.battle.GetScript().empty() ) {
		return false;
	}

	GetHeaderInfo(replay, ret, replay_version );
	ret.battle.GetBattleFromScript( false );
	ret.ModName = TowxString(ret.battle.GetHostModName());
	ret.battle.SetBattleType( BT_Replay );
	ret.battle.SetEngineName("spring");
	ret.battle.SetEngineVersion(STD_STRING(ret.SpringVersion));
	ret.battle.SetPlayBackFilePath(STD_STRING(ReplayPath));

	//getting this from filename seems more reliable than from demoheader
	wxDateTime rdate;

	if (rdate.ParseFormat(FileName, _T("%Y%m%d_%H%M%S")) == 0) {
		wxLogError(_T("Parsing %s failed"), FileName.c_str());
		return false;
	}
	ret.date=rdate.GetTicks(); // now it is sorted properly
	ret.date_string=rdate.FormatISODate()+_T(" ")+rdate.FormatISOTime();

	return true;
}
Ejemplo n.º 6
0
bool ReplayList::GetReplayInfos (const wxString& ReplayPath, Replay& ret ) const
{
    //wxLogMessage(_T("GetReplayInfos %s"), ReplayPath.c_str());
    //wxLOG_Info  ( STD_STRING( ReplayPath ) );
    //TODO extract moar info
    ret.Filename = ReplayPath;
    ret.battle.SetPlayBackFilePath( ReplayPath );

	wxString FileName = ReplayPath.AfterLast( wxFileName::GetPathSeparator() ); // strips file path
    FileName = FileName.BeforeLast( _T('.') ); //strips the file extension;

    wxString date_string = FileName.BeforeFirst(_T('_'));
    FileName = FileName.AfterFirst(_T('_'));

    FileName = FileName.AfterFirst(_T('_')); // strips hours minutes seconds informatiom

    ret.SpringVersion = FileName.AfterLast(_T('_'));

    ret.MapName = FileName.BeforeLast(_T('_'));

    const int replay_version = replayVersion( ReplayPath );
    ret.battle.SetScript( GetScriptFromReplay( ReplayPath, replay_version ) );
    //wxLogMessage(_T("Script: %s"), script.c_str());

    if ( ret.battle.GetScript().IsEmpty() ) return false;

    GetHeaderInfo( ret, ReplayPath, replay_version );
    ret.battle.GetBattleFromScript( false );
    ret.ModName = ret.battle.GetHostModName();
    ret.battle.SetBattleType( BT_Replay );

    //getting this from filename seems more reliable than from demoheader
    wxFormat date_format(_T("%s-%s-%s"));
    ret.date_string = date_format % date_string.SubString(0,3)
            % date_string.SubString(4,5) % date_string.SubString(6,7);
    return true;
}
Ejemplo n.º 7
0
void CSaveLoadInfoBase::ReadHeader(void)
{
	int nNo;
	PBYTE pData, pDataBack;
	DWORD i, j, dwCountElement, dwDataCount, dwSize;
	PHEADERINFO pInfoElement, pInfoTmp;
	PCInfoBase pInfo;

	pData			= m_pData;
	pInfoTmp		= new HEADERINFO;
	pInfoElement	= NULL;

	/* カラム数を読み込み */
	CopyMemoryDataSrc ((PBYTE)&dwCountElement, pData, sizeof (dwCountElement));
	/* データ数を読み込み */
	CopyMemoryDataSrc ((PBYTE)&dwDataCount, pData, sizeof (dwDataCount));
	/* ヘッダ情報を読み込み */
	for (i = 0; i < dwCountElement; i ++) {
		ZeroMemory (pInfoTmp, sizeof (HEADERINFO));
		strcpy (pInfoTmp->szName, (LPCSTR)pData);
		pData += (strlen (pInfoTmp->szName) + 1);

		CopyMemoryDataSrc ((PBYTE)&pInfoTmp->dwOffset, pData, sizeof (pInfoTmp->dwOffset));
		pInfoElement = GetHeaderInfo (pInfoTmp->szName);
		if (pInfoElement == NULL) {
			continue;
		}
		pInfoElement->dwOffset = pInfoTmp->dwOffset;
	}

	/* 空のデータを作成 */
	for (i = 0; i < dwDataCount; i ++) {
		pInfo = m_pLibInfoBase->GetNew ();
		m_pLibInfoBase->Add (pInfo);
	}

	/* データ先頭部分のアドレスを保存 */
	pDataBack = m_pData;


	/***********************
		データを読み込み
	***********************/

	dwCountElement = m_pHeaderInfo->GetSize ();
	for (i = 0; i < dwCountElement; i ++) {
		pInfoElement = m_pHeaderInfo->GetAt (i);
		if (pInfoElement->dwOffset == 0) {
			continue;
		}
		pData = pDataBack + pInfoElement->dwOffset;

		for (j = 0; j < dwDataCount; j ++) {
			pInfo	= m_pLibInfoBase->RenewInfo (j);
			nNo		= pInfo->GetElementNo (pInfoElement->szName);
			dwSize	= pInfo->ReadElementData (pData, nNo);
			pData	+= dwSize;
			if ((DWORD)(pData - m_pData) >= m_dwDataSize) {
				break;
			}
		}
		if ((DWORD)(pData - m_pData) >= m_dwDataSize) {
			break;
		}
	}
	m_pLibInfoBase->RenewIDPtr ();

	SAFE_DELETE (pInfoTmp);
}