Пример #1
0
// ----------------------------------------------------------------------------
// Load
// ----------------------------------------------------------------------------
bool database_Load(std::string digest) {
  if(database_enabled) {
	logger_LogInfo("Accessing database " + database_filename + ".", DATABASE_SOURCE);
    
    FILE* file = fopen(database_filename.c_str( ), "r");
    if(file == NULL) {
      logger_LogError("Failed to open the database for reading.", DATABASE_SOURCE);
      return false;  
    }

    char buffer[256];
    while(fgets(buffer, 256, file) != NULL) {
      std::string line = buffer;
      if(line.compare(1, 32, digest.c_str( )) == 0) {
        std::string entry[11];
        for(int index = 0; index < 11; index++) {
          fgets(buffer, 256, file);
          entry[index] = common_Remove(buffer, '\n');  
          entry[index] = common_Remove(entry[index], '\r');
        }
        
        cartridge_title = database_GetValue(entry[0]);
        cartridge_type = common_ParseByte(database_GetValue(entry[1]));
        cartridge_pokey = common_ParseBool(database_GetValue(entry[2]));
        cartridge_controller[0] = common_ParseByte(database_GetValue(entry[3]));
        cartridge_controller[1] = common_ParseByte(database_GetValue(entry[4]));
        cartridge_region = common_ParseByte(database_GetValue(entry[5]));
        cartridge_flags = common_ParseUint(database_GetValue(entry[6]));

        // Optionally load the lightgun crosshair offsets, hblank, dual analog
        for(int index = 7; index < 11; index++)
        {
          if(entry[index].find("crossx") != std::string::npos)
          {
              cartridge_crosshair_x = common_ParseInt(database_GetValue(entry[index]));
          }         
          if(entry[index].find("crossy") != std::string::npos)
          {
              cartridge_crosshair_y = common_ParseInt(database_GetValue(entry[index]));
          }         
          if(entry[index].find("hblank") != std::string::npos)
          {
              cartridge_hblank = common_ParseInt(database_GetValue(entry[index]));
          }         
          if(entry[index].find("dualanalog") != std::string::npos)
          {
              cartridge_dualanalog = common_ParseBool(database_GetValue(entry[index]));
          }         
        }

        break;
      }
    }    
    
    fclose(file);  
  }
  return true;
}
Пример #2
0
// ----------------------------------------------------------------------------
// ParseDefaultPath
// ----------------------------------------------------------------------------
void main_ParseDefaultPath( ) {
  std::string commandLine = GetCommandLine( );
  if(commandLine[0] == '"') {
    common_defaultPath = common_Remove(commandLine.substr(0, commandLine.find('"', 1)), '"');
    common_defaultPath = common_defaultPath.substr(0, common_defaultPath.rfind("\\") + 1);
  }
  else {
    common_defaultPath = commandLine.substr(0, commandLine.find(' '));
    common_defaultPath = common_defaultPath.substr(0, common_defaultPath.rfind("\\") + 1);
  }

//Leonis - screenshot directory
  common_screenshotsPath = common_defaultPath + "snap";
  std::string tmp2X;
  tmp2X=common_screenshotsPath;
  tmp2X=common_ReplaceString(tmp2X, "\\", "!");
  tmp2X=common_ReplaceString(tmp2X, "!", "\\\\");
  
  CreateDirectory(tmp2X.c_str(), NULL);
//Leonis

}