Пример #1
0
bool BitmapText::LoadFromTextureAndChars( const RString& sTexturePath, const RString& sChars )
{
	CHECKPOINT_M( ssprintf("BitmapText::LoadFromTextureAndChars(\"%s\",\"%s\")", sTexturePath.c_str(), sChars.c_str()) );

	if( m_pFont )
	{
		FONT->UnloadFont( m_pFont );
		m_pFont = NULL;
	}

	m_pFont = FONT->LoadFont( sTexturePath, sChars );

	BuildChars();

	return true;
}
Пример #2
0
void CryptManager::SignFileToFile( RString sPath, RString sSignatureFile )
{
	RString sPrivFilename = PRIVATE_KEY_PATH;
	if( sSignatureFile.empty() )
		sSignatureFile = sPath + SIGNATURE_APPEND;

	RString sPrivKey;
	if( !GetFileContents(sPrivFilename, sPrivKey) )
		return;

	RString sSignature;
	if( !Sign(sPath, sSignature, sPrivKey) )
		return;

	WriteFile( sSignatureFile, sSignature );
}
Пример #3
0
RString CryptManager::GetMD5ForFile( RString fn )
{
	RageFile file;
	if( !file.Open( fn, RageFile::READ ) )
	{
		LOG->Warn( "GetMD5: Failed to open file '%s'", fn.c_str() );
		return RString();
	}
	int iHash = register_hash( &md5_desc );
	ASSERT( iHash >= 0 );

	unsigned char digest[16];
	HashFile( file, digest, iHash );

	return RString( (const char *) digest, sizeof(digest) );
}
Пример #4
0
	virtual void PopulateFileSet( FileSet &fs, const RString &sPath )
	{
		if( sPath != "." )
			return;
		if( g_TestFile == "" )
			return;

		fs.files.clear();

		File f;
		f.SetName( g_TestFilename );
		f.dir = false;
		f.size = g_TestFile.size();
		f.hash = GetHashForString( g_TestFile );
		fs.files.insert(f);
	}
Пример #5
0
void ScreenTestLights::Update( float fDeltaTime )
{
    Screen::Update( fDeltaTime );


    if( m_timerBackToAutoCycle.Ago() > 20 )
    {
        m_timerBackToAutoCycle.Touch();
        LIGHTSMAN->SetLightsMode( LIGHTSMODE_TEST_AUTO_CYCLE );
    }


    CabinetLight cl = LIGHTSMAN->GetFirstLitCabinetLight();
    GameInput gi = LIGHTSMAN->GetFirstLitGameButtonLight();

    RString s;

    switch( LIGHTSMAN->GetLightsMode() )
    {
    case LIGHTSMODE_TEST_AUTO_CYCLE:
        s += AUTO_CYCLE.GetValue()+"\n";
        break;
    case LIGHTSMODE_TEST_MANUAL_CYCLE:
        s += MANUAL_CYCLE.GetValue()+"\n";
        break;
    default:
        break;
    }

    if( cl == CabinetLight_Invalid )
        s += CABINET_LIGHT.GetValue()+": -----\n";
    else
        s += ssprintf( "%s: %d %s\n", CABINET_LIGHT.GetValue().c_str(), cl, CabinetLightToString(cl).c_str() );

    if( !gi.IsValid() )
    {
        s += CONTROLLER_LIGHT.GetValue()+": -----\n";
    }
    else
    {
        RString sGameButton = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), gi.button );
        PlayerNumber pn = (PlayerNumber)(gi.controller);
        s += ssprintf( "%s: %s %d %s\n", CONTROLLER_LIGHT.GetValue().c_str(), PlayerNumberToString(pn).c_str(), gi.button, sGameButton.c_str() );
    }

    m_textInputs.SetText( s );
}
Пример #6
0
bool KSFLoader::LoadFromDir( const RString &sDir, Song &out )
{
	LOG->Trace( "KSFLoader::LoadFromDir(%s)", sDir.c_str() );

	vector<RString> arrayKSFFileNames;
	GetDirListing( sDir + RString("*.ksf"), arrayKSFFileNames );

	// We shouldn't have been called to begin with if there were no KSFs.
	ASSERT( arrayKSFFileNames.size() != 0 );

	bool bKIUCompliant = false;
	/* With Split Timing, there has to be a backup Song Timing in case
	 * anything goes wrong. As these files are kept in alphabetical
	 * order (hopefully), it is best to use the LAST file for timing 
	 * purposes, for that is the "normal", or easiest difficulty.
	 * Usually. */
	// Nevermind, kiu compilancy is screwing things up:
	// IE, I have two simfiles, oh wich each have four ksf files, the first one has
	// the first ksf with directmove timing changes, and the rest are not, everything
	// goes fine. In the other hand I have my second simfile with the first ksf file
	// without directmove timing changes and the rest have changes, changes are not
	// loaded due to kiucompilancy in the first ksf file.
	// About the "normal" thing, my simfiles' ksfs uses non-standard naming so
	// the last chart is usually nightmare or normal, I use easy and normal
	// indistinctly for SM so it shouldn't matter, I use piu fiesta/ex naming
	// for directmove though, and we're just gathering basic info anyway, and
	// most of the time all the KSF files have the same info in the #TITLE:; section
	unsigned files = arrayKSFFileNames.size();
	RString dir = out.GetSongDir();
	if( !LoadGlobalData(dir + arrayKSFFileNames[files - 1], out, bKIUCompliant) )
		return false;

	out.m_sSongFileName = dir + arrayKSFFileNames[files - 1];
	// load the Steps from the rest of the KSF files
	for( unsigned i=0; i<files; i++ ) 
	{
		Steps* pNewNotes = out.CreateSteps();
		if( !LoadFromKSFFile(dir + arrayKSFFileNames[i], *pNewNotes, out, bKIUCompliant) )
		{
			delete pNewNotes;
			continue;
		}
		pNewNotes->SetFilename(dir + arrayKSFFileNames[i]);
		out.AddSteps( pNewNotes );
	}
	return true;
}
Пример #7
0
void ScreenOptionsMaster::Init()
{
	vector<RString> asLineNames;
	split( LINE_NAMES, ",", asLineNames );
	if( asLineNames.empty() )
	{
		LuaHelpers::ReportScriptErrorFmt("\"%s:LineNames\" is empty.", m_sName.c_str());
	}

	if( FORCE_ALL_PLAYERS )
	{
		FOREACH_PlayerNumber( pn )
			GAMESTATE->JoinPlayer( pn );
	}

	if( NAVIGATION_MODE == "toggle" )
		SetNavigation( PREFSMAN->m_iArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
	else if( NAVIGATION_MODE == "menu" )
		SetNavigation( NAV_THREE_KEY_MENU );

	SetInputMode( StringToInputMode(INPUT_MODE) );

	// Call this after enabling players, if any.
	ScreenOptions::Init();

	vector<OptionRowHandler*> OptionRowHandlers;
	for( unsigned i = 0; i < asLineNames.size(); ++i )
	{
		RString sLineName = asLineNames[i];
		RString sRowCommands = LINE(sLineName);
		
		Commands cmds;
		ParseCommands( sRowCommands, cmds, false );

		OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds );
		if( pHand == NULL )
		{
			LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler \"%s\" in \"%s:Line:%s\".", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str());
		}
		else
		{
			OptionRowHandlers.push_back( pHand );
		}
	}
	InitMenu( OptionRowHandlers );
}
Пример #8
0
bool
RealFileDriver::ReadFile(const RString &path, void* buffer, const unsigned int start, const unsigned int length)
{
    FILE* file = fopen(RString(mRoot + "/" + path).c_str(), "rb");

    if (file == NULL)
    {
        LOGGER->Log(LOGGER_ERROR, "Can't open file %s", path.c_str());
        return false;
    }

    fseek(file, start, SEEK_SET);
    fread(buffer, sizeof(char), length, file);
    fclose(file);

    return true;
}
Пример #9
0
bool BitmapText::LoadFromFont( const RString& sFontFilePath )
{
	CHECKPOINT_M( ssprintf("BitmapText::LoadFromFont(%s)", sFontFilePath.c_str()) );

	if( m_pFont )
	{
		FONT->UnloadFont( m_pFont );
		m_pFont = NULL;
	}

	m_pFont = FONT->LoadFont( sFontFilePath );

	this->SetStrokeColor( m_pFont->GetDefaultStrokeColor() );

	BuildChars();

	return true;
}
Пример #10
0
void BackgroundUtil::GetSongBGAnimations( const Song *pSong, const RString &sMatch, vector<RString> &vsPathsOut, vector<RString> &vsNamesOut )
{
	vsPathsOut.clear();
	if( sMatch.empty() )
	{
		GetDirListing( pSong->GetSongDir()+"*",    vsPathsOut, true, true );
	}
	else
	{
		GetDirListing( pSong->GetSongDir()+sMatch, vsPathsOut, true, true );
	}
	
	vsNamesOut.clear();
	FOREACH_CONST( RString, vsPathsOut, s )
		vsNamesOut.push_back( Basename(*s) );

	StripCvsAndSvn( vsPathsOut, vsNamesOut );
}
Пример #11
0
bool BitmapText::StringWillUseAlternate( const RString& sText, const RString& sAlternateText ) const
{
	ASSERT( m_pFont != NULL );

	// Can't use the alternate if there isn't one.
	if( !sAlternateText.size() )
		return false;

	// False if the alternate isn't needed.
	if( m_pFont->FontCompleteForString(RStringToWstring(sText)) )
		return false;

	// False if the alternate is also incomplete.
	if( !m_pFont->FontCompleteForString(RStringToWstring(sAlternateText)) )
		return false;

	return true;
}
Пример #12
0
void SongUtil::GetSteps(
    const Song *pSong,
    vector<Steps*>& arrayAddTo,
    StepsType st,
    Difficulty dc,
    int iMeterLow,
    int iMeterHigh,
    const RString &sDescription,
    bool bIncludeAutoGen,
    unsigned uHash,
    int iMaxToGet
)
{
    if( !iMaxToGet )
        return;

    const vector<Steps*> &vpSteps = st == StepsType_Invalid ? pSong->GetAllSteps() : pSong->GetStepsByStepsType(st);
    for( unsigned i=0; i<vpSteps.size(); i++ )	// for each of the Song's Steps
    {
        Steps* pSteps = vpSteps[i];

        if( dc != Difficulty_Invalid && dc != pSteps->GetDifficulty() )
            continue;
        if( iMeterLow != -1 && iMeterLow > pSteps->GetMeter() )
            continue;
        if( iMeterHigh != -1 && iMeterHigh < pSteps->GetMeter() )
            continue;
        if( sDescription.size() && sDescription != pSteps->GetDescription() )
            continue;
        if( uHash != 0 && uHash != pSteps->GetHash() )
            continue;
        if( !bIncludeAutoGen && pSteps->IsAutogen() )
            continue;

        arrayAddTo.push_back( pSteps );

        if( iMaxToGet != -1 )
        {
            --iMaxToGet;
            if( !iMaxToGet )
                break;
        }
    }
}
Пример #13
0
void BackgroundUtil::GetSongBitmaps( const Song *pSong, const RString &sMatch, vector<RString> &vsPathsOut, vector<RString> &vsNamesOut )
{
	vsPathsOut.clear();
	if( sMatch.empty() )
	{
		FILEMAN->GetDirListingWithMultipleExtensions(pSong->GetSongDir()+sMatch,
			ActorUtil::GetTypeExtensionList(FT_Bitmap), vsPathsOut, false, true);
	}
	else
	{
		GetDirListing( pSong->GetSongDir()+sMatch,			vsPathsOut, false, true );
	}

	vsNamesOut.clear();
	FOREACH_CONST( RString, vsPathsOut, s )
		vsNamesOut.push_back( Basename(*s) );

	StripCvsAndSvn( vsPathsOut, vsNamesOut );
}
static bool ExecuteCommand( const RString &sCommand )
{
	LOG->Trace( "executing '%s'", sCommand.c_str() );
	int ret = system(sCommand);
	LOG->Trace( "done executing '%s'", sCommand.c_str() );
	if( ret != 0 )
	{
		RString sError = ssprintf("failed to execute '%s' with error %d", sCommand.c_str(), ret);
		if( ret == -1 )
			sError += ssprintf(": %s", sCommand.c_str());
		LOG->Warn( "%s", sError.c_str() );
	}
	return ret == 0;
}
Пример #15
0
void RageLog::AddToInfo( const RString &str )
{
	static bool limit_reached = false;
	if( limit_reached )
		return;
	
	unsigned len = str.size() + strlen( NEWLINE );
	if( staticlog_size + len > sizeof(staticlog) )
	{
		const RString txt( NEWLINE "Staticlog limit reached" NEWLINE );
		
		const unsigned pos = min( staticlog_size, sizeof(staticlog) - txt.size() );
		memcpy( staticlog+pos, txt.data(), txt.size() );
		limit_reached = true;
		return;
	}

	memcpy( staticlog+staticlog_size, str.data(), str.size() );
	staticlog_size += str.size();
	memcpy( staticlog+staticlog_size, NEWLINE, strlen(NEWLINE) );
	staticlog_size += strlen( NEWLINE );
}
Пример #16
0
    u64 enoFile::readLine(RString& str, const c8 *delimiter, bool joinDelimiter)
    {
        RString out;
        s64 readCount = 0;
        u64 availBufSize;
        s64 derimsearchoffset = 0;
        const s64 delimLength = strlen(delimiter);
        
        while (true) {
            availBufSize = read_end-read_offset;
            
            if (availBufSize == 0) {
                if (FillBuffer() == 0) {
                    break;
                }
                continue;
            }
            
            out.append(read_offset, availBufSize);

            const c8 *delimoff = mystrnstr(out.c_str()+derimsearchoffset,
                          delimiter,
                          out.size()-derimsearchoffset);
            
            if (delimoff != nullptr) {
                s64 noff = (delimoff-out.c_str());
                noff+=delimLength-readCount;
                read_offset += noff;
                readCount = (delimoff-out.c_str())+(joinDelimiter?delimLength:0);
                break;
            }
            
            readCount += availBufSize;
            derimsearchoffset = readCount-delimLength;
            read_offset = read_end;
        }
        
        if (readCount != 0) {
            str = out.substr(0, readCount);
        }

        return readCount;
    }
Пример #17
0
RString LoadALSA()
{
    /* If /proc/asound/ doesn't exist, chances are we're on an OSS system.  We shouldn't
     * touch ALSA at all, since many OSS systems have old, broken versions of ALSA lying
     * around; we're likely to crash if we go near it.  Do this first, before loading
     * the ALSA library, since making any ALSA calls may load ALSA core modules.
     *
     * It's vaguely possible that a module autoloader would load the entire ALSA module set
     * on use, and this would prevent that from happening.  I don't know if anyone actually
     * does that, though: they're often configured to load snd (the core module) if ALSA
     * devices are accessed, but hardware drivers are typically loaded on boot. */
    if( !IsADirectory("/rootfs/proc/asound/") )
        return "/proc/asound/ does not exist";

    ASSERT( Handle == NULL );

    Handle = dlopen( lib, RTLD_NOW );
    if( Handle == NULL )
        return ssprintf("dlopen(%s): %s", lib.c_str(), dlerror());

    RString error;
    /* Eww.  The "new" HW and SW API functions are really prefixed by __,
     * eg. __snd_pcm_hw_params_set_rate_near. */
#define FUNC(ret, name, proto) \
	d##name = (name##_f) dlsym(Handle, "__" #name); \
	if( !d##name ) { \
		d##name = (name##_f) dlsym(Handle, #name); \
		if( !d##name ) { \
			error="Couldn't load symbol " #name; \
			goto error; \
		} \
	}
#include "ALSA9Functions.h"
#undef FUNC

    return "";
error:
    UnloadALSA();
    return error;
}
Пример #18
0
void CrashHandler::InformUserOfCrash( const RString& sPath )
{
	CFBundleRef bundle = CFBundleGetMainBundle();
	CFStringRef sAlternate = LSTRING( bundle, "Quit " PRODUCT_FAMILY );
	/* XXX Translate these and remove the redefine of LSTRING. Another way to do this
	 * would be to pass bundle's URL to CFUserNotificationDisplayAlert's localizationURL
	 * parameter and let it do it. This wouldn't work for sBody though. */
#undef LSTRING
#define LSTRING(b,x) CFSTR(x)
	CFStringRef sDefault = LSTRING( bundle, "File Bug Report" );
	CFStringRef sOther = LSTRING( bundle, "Open crashinfo.txt" );
	CFStringRef sTitle = LSTRING( bundle, PRODUCT_FAMILY " has crashed" );
	CFStringRef sFormat = LSTRING( bundle, PRODUCT_FAMILY " has crashed. "
				       "Debugging information has been output to\n\n%s\n\n"
				       "Please file a bug report at\n\n%s" );
	CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, NULL, sFormat,
						      sPath.c_str(), REPORT_BUG_URL );
	CFOptionFlags response = kCFUserNotificationCancelResponse;
	CFTimeInterval timeout = 0.0; // Should we ever time out?
	
	CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
					sTitle, sBody, sDefault, sAlternate, sOther, &response );
	
	switch( response )
	{
	case kCFUserNotificationDefaultResponse:
		HOOKS->GoToURL( REPORT_BUG_URL );
		// Fall through.
	case kCFUserNotificationOtherResponse:
		// Open the file with the default application (probably TextEdit).
		HOOKS->GoToURL( "file://" + sPath );
		break;
	}
	CFRelease( sBody );
	CFRelease( sFormat );
	CFRelease( sTitle );
	CFRelease( sOther );
	CFRelease( sDefault );
	CFRelease( sAlternate );
}
Пример #19
0
void InputHandler::Create( const RString &drivers_, vector<InputHandler *> &Add )
{
	const RString drivers = drivers_.empty()? RString(DEFAULT_INPUT_DRIVER_LIST):drivers_;
	vector<RString> DriversToTry;
	split( drivers, ",", DriversToTry, true );
	
	if( DriversToTry.empty() )
		RageException::Throw( "%s", INPUT_HANDLERS_EMPTY.GetValue().c_str() );
	
	FOREACH_CONST( RString, DriversToTry, s )
	{
		RageDriver *pDriver = InputHandler::m_pDriverList.Create( *s );
		if( pDriver == NULL )
		{
			LOG->Trace( "Unknown Input Handler name: %s", s->c_str() );
			continue;
		}

		InputHandler *ret = dynamic_cast<InputHandler *>( pDriver );
		DEBUG_ASSERT( ret );
		Add.push_back( ret );
	}
Пример #20
0
void OptionListRow::SetTextFromHandler( const OptionRowHandler *pHandler )
{
	ASSERT( pHandler != NULL );
	for( unsigned i = 0; i < pHandler->m_Def.m_vsChoices.size(); ++i )
	{
		// init text
		RString sText = pHandler->GetThemedItemText( i );

		RString sDest = pHandler->GetScreen( i );
		if( m_pOptions->m_setDirectRows.find(sDest) != m_pOptions->m_setDirectRows.end() && sDest.size() )
		{
			const OptionRowHandler *pTarget = m_pOptions->m_Rows[sDest];
			if( pTarget->m_Def.m_selectType == SELECT_ONE )
			{
				int iSelection = m_pOptions->GetOneSelection(sDest);
				sText += ": " + pTarget->GetThemedItemText( iSelection );
			}
		}

		m_Text[i].SetText( sText );
	}
}
		inline void GetNewState(uint8_t * buffer, RString& line)
		{
			size_t lineLen = line.length();
			size_t i, cursor;
			cursor = 0;
			memset(buffer, 0, STATE_BUFFER_SIZE);

			// Copy from line to buffer until either it is full or we've run out
			// of characters. Characters outside the sextet code range
			// (0x30..0x6F) are skipped; the remaining characters have their two
			// high bits cleared.
			for(i = 0; i < lineLen; ++i) {
				char b = line[i];
				if((b >= 0x30) && (b <= 0x6F)) {
					buffer[cursor] = b & 0x3F;
					++cursor;
					if(cursor >= STATE_BUFFER_SIZE) {
						break;
					}
				}
			}
		}
Пример #22
0
void LightsDriver::Create( const RString &sDrivers, vector<LightsDriver *> &Add )
{
	LOG->Trace( "Initializing lights drivers: %s", sDrivers.c_str() );

	vector<RString> asDriversToTry;
	split( sDrivers, ",", asDriversToTry, true );
	
	FOREACH_CONST( RString, asDriversToTry, Driver )
	{
		RageDriver *pRet = m_pDriverList.Create( *Driver );
		if( pRet == NULL )
		{
			LOG->Trace( "Unknown lights driver: %s", Driver->c_str() );
			continue;
		}

		LightsDriver *pDriver = dynamic_cast<LightsDriver *>( pRet );
		ASSERT( pDriver != NULL );

		LOG->Info( "Lights driver: %s", Driver->c_str() );
		Add.push_back( pDriver );
	}
Пример #23
0
bool ArchHooks_Unix::GoToURL( RString sUrl )
{
	int status;
	pid_t p = fork();
	if ( p == -1 )
	{
		// Call to fork failed
		return false;
	}
	else if ( p == 0 )
	{
		// Child
		const char * const argv[] = { "xdg-open", sUrl.c_str(), NULL };
		execv( "/usr/bin/xdg-open", const_cast<char * const *>( argv ));
		// If we reach here, the call to execvp failed
		exit( 1 );
	}
	else
	{
		// Parent
		waitpid( p, &status, 0 );
		return WEXITSTATUS( status ) == 0;
	}
}
Пример #24
0
void C_RBASE::save_string(unsigned char *data, int &pos, RString &text)
{
  if (text.get() && text.get()[0])
	{
    char *p=text.get();
    int x=32768;
    while (x-- && *p) p++;
    if (*p)
    {
      MessageBox(NULL,"Yo, this is some long ass shit","F**K!",MB_OK);
      //FUCKO
    }
    int l=(strlen(text.get())+1);
	  PUT_INT(l); pos+=4;
	  memcpy(data+pos, text.get(), strlen(text.get())+1);
	  pos+=strlen(text.get())+1;
	}
  else
  { 
    PUT_INT(0); 
    pos+=4;
  }
}
Пример #25
0
bool Steps::GetNoteDataFromSimfile()
{
	// Replace the line below with the Steps' cache file.
	RString stepFile = this->GetFilename();
	RString extension = GetExtension(stepFile);
	extension.MakeLower(); // must do this because the code is expecting lowercase

	if (extension.empty() || extension == "ssc"
		|| extension == "ats") // remember cache files.
	{
		SSCLoader loader;
		if ( ! loader.LoadNoteDataFromSimfile(stepFile, *this) )
		{
			/*
			HACK: 7/20/12 -- see bugzilla #740
			users who edit songs using the ever popular .sm file
			that remove or tamper with the .ssc file later on 
			complain of blank steps in the editor after reloading.
			Despite the blank steps being well justified since 
			the cache files contain only the SSC step file,
			give the user some leeway and search for a .sm replacement
			*/
			SMLoader backup_loader;
			RString transformedStepFile = stepFile;
			transformedStepFile.Replace(".ssc", ".sm");
			
			return backup_loader.LoadNoteDataFromSimfile(transformedStepFile, *this);
		}
		else
		{
			return true;
		}
	}
	else if (extension == "sm")
	{
		SMLoader loader;
		return loader.LoadNoteDataFromSimfile(stepFile, *this);
	}
	else if (extension == "sma")
	{
		SMALoader loader;
		return loader.LoadNoteDataFromSimfile(stepFile, *this);
	}
	else if (extension == "dwi")
	{
		return DWILoader::LoadNoteDataFromSimfile(stepFile, *this);
	}
	else if (extension == "ksf")
	{
		return KSFLoader::LoadNoteDataFromSimfile(stepFile, *this);
	}
	else if (extension == "bms" || extension == "bml" || extension == "bme" || extension == "pms")
	{
		return BMSLoader::LoadNoteDataFromSimfile(stepFile, *this);
	}
	else if (extension == "edit")
	{
		// Try SSC, then fallback to SM.
		SSCLoader ldSSC;
		if(ldSSC.LoadNoteDataFromSimfile(stepFile, *this) != true)
		{
			SMLoader ldSM;
			return ldSM.LoadNoteDataFromSimfile(stepFile, *this);
		}
		else return true;
	}
	return false;
}
Пример #26
0
void SMLoader::ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam )
{
	BackgroundLayer iLayer = BACKGROUND_LAYER_1;
	if( sscanf(sValueName, "BGCHANGES%d", &*ConvertValue<int>(&iLayer)) == 1 )
		enum_add(iLayer, -1);	// #BGCHANGES2 = BACKGROUND_LAYER_2
	
	bool bValid = iLayer>=0 && iLayer<NUM_BackgroundLayer;
	if( !bValid )
	{
		LOG->UserLog( "Song file", sPath, "has a #BGCHANGES tag \"%s\" that is out of range.", sValueName.c_str() );
	}
	else
	{
		vector<RString> aBGChangeExpressions;
		split( sParam, ",", aBGChangeExpressions );
		
		for( unsigned b=0; b<aBGChangeExpressions.size(); b++ )
		{
			BackgroundChange change;
			if( LoadFromBGChangesString( change, aBGChangeExpressions[b] ) )
				out.AddBackgroundChange( iLayer, change );
		}
	}
}
Пример #27
0
void SMLoader::LoadFromTokens( 
			     RString sStepsType, 
			     RString sDescription,
			     RString sDifficulty,
			     RString sMeter,
			     RString sRadarValues,
			     RString sNoteData,
			     Steps &out
			     )
{
	// we're loading from disk, so this is by definition already saved:
	out.SetSavedToDisk( true );

	Trim( sStepsType );
	Trim( sDescription );
	Trim( sDifficulty );
	Trim( sNoteData );

	// LOG->Trace( "Steps::LoadFromTokens(), %s", sStepsType.c_str() );

	// backwards compatibility hacks:
	// HACK: We eliminated "ez2-single-hard", but we should still handle it.
	if( sStepsType == "ez2-single-hard" )
		sStepsType = "ez2-single";

	// HACK: "para-single" used to be called just "para"
	if( sStepsType == "para" )
		sStepsType = "para-single";

	out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType );
	out.m_StepsTypeStr = sStepsType;
	out.SetDescription( sDescription );
	out.SetCredit( sDescription ); // this is often used for both.
	out.SetChartName(sDescription); // yeah, one more for good measure.
	out.SetDifficulty( OldStyleStringToDifficulty(sDifficulty) );

	// Handle hacks that originated back when StepMania didn't have
	// Difficulty_Challenge. (At least v1.64, possibly v3.0 final...)
	if( out.GetDifficulty() == Difficulty_Hard )
	{
		// HACK: SMANIAC used to be Difficulty_Hard with a special description.
		if( sDescription.CompareNoCase("smaniac") == 0 ) 
			out.SetDifficulty( Difficulty_Challenge );

		// HACK: CHALLENGE used to be Difficulty_Hard with a special description.
		if( sDescription.CompareNoCase("challenge") == 0 ) 
			out.SetDifficulty( Difficulty_Challenge );
	}

	if( sMeter.empty() )
	{
		// some simfiles (e.g. X-SPECIALs from Zenius-I-Vanisher) don't
		// have a meter on certain steps. Make the meter 1 in these instances.
		sMeter = "1";
	}
	out.SetMeter( StringToInt(sMeter) );

	out.SetSMNoteData( sNoteData );

	out.TidyUpData();
}
//virtual 
void 
ASCIIDataWriter::writeFloat(float b)
{
  RString tstr = Float::toString(b);
  _out->write((const byte*)tstr->byte_begin(), 0, tstr->length());
}
//virtual 
void 
ASCIIDataWriter::writeLong(jlong b) 
{
  RString tstr = Long::toString(b);
  _out->write((const byte*)tstr->byte_begin(), 0, tstr->length());
}
//virtual 
void 
ASCIIDataWriter::writeInt(int b)
{
  RString tstr = Integer::toString(b);
  _out->write((const byte*)tstr->byte_begin(), 0, tstr->length());
}