Exemple #1
0
int main(int argc, char *argv[])
{ FILE *fpOut=NULL;
  int traceLevel;
  ATerm bottom;
  ATinit(argc,argv,&bottom);

   switch(parseArgs(argc, argv,&fpOut,&traceLevel)) {
      case ERR_ARGS:
         doHelp(argv[0]);
         exit(EXIT_ERR_ARGS);
         break;
      case ERR_FILE:
         exit(EXIT_ERR_FILE);
         break;
      case CMD_HELP:
         doHelp(argv[0]);
         exit(EXIT_OK);
         break;
      case CMD_VERSION:
         doVersion(argv[0]);
         exit(EXIT_OK);
      case CMD_CONVERT:
         exit(doConvert(fpOut, traceLevel));
         break;
      default:
         exit(EXIT_OK);
   }


} /* main */
Exemple #2
0
	UString convert(iconv_t &ctx, byte *data, size_t n, size_t growth, size_t termSize) {
		if (ctx == ((iconv_t) -1))
			return "[!!!]";

		size_t size;
		ScopedArray<byte> dataOut(doConvert(ctx, data, n, n * growth + termSize, size));
		if (!dataOut)
			return "[!?!]";

		while (termSize-- > 0)
			dataOut[size++] = '\0';

		return UString(reinterpret_cast<const char *>(dataOut.get()));
	}
Exemple #3
0
	UString convert(iconv_t &ctx, byte *data, size_t n, size_t growth, size_t termSize) {
		if (ctx == ((iconv_t) -1))
			return "[!!!]";

		size_t size;
		byte *dataOut = doConvert(ctx, data, n, n * growth + termSize, size);
		if (!dataOut)
			return "[!?!]";

		while (termSize-- > 0)
			dataOut[size++] = '\0';

		UString str((const char *) dataOut);
		delete[] dataOut;

		return str;
	}
Exemple #4
0
	MemoryReadStream *convert(iconv_t &ctx, const UString &str, size_t growth, size_t termSize) {
		if (ctx == ((iconv_t) -1))
			return 0;

		byte  *dataIn = const_cast<byte *>(reinterpret_cast<const byte *>(str.c_str()));
		size_t nIn    = std::strlen(str.c_str());
		size_t nOut   = nIn * growth + termSize;

		size_t size;
		ScopedArray<byte> dataOut(doConvert(ctx, dataIn, nIn, nOut, size));
		if (!dataOut)
			return 0;

		while (termSize-- > 0)
			dataOut[size++] = '\0';

		return new MemoryReadStream(dataOut.release(), size, true);
	}
Exemple #5
0
	MemoryReadStream *convert(iconv_t &ctx, const UString &str, size_t growth, size_t termSize) {
		if (ctx == ((iconv_t) -1))
			return 0;

		byte  *dataIn = const_cast<byte *>((const byte *) str.c_str());
		size_t nIn    = strlen(str.c_str());
		size_t nOut   = nIn * growth + termSize;

		size_t size;
		byte *dataOut = doConvert(ctx, dataIn, nIn, nOut, size);
		if (!dataOut)
			return 0;

		while (termSize-- > 0)
			dataOut[size++] = '\0';

		return new MemoryReadStream(dataOut, size, true);
	}
Exemple #6
0
uv_err_t uvmain(int argc, char **argv)
{
	uv_err_t rc = UV_ERR_GENERAL;
	UVDConfig *config = NULL;
	UVDFLIRTConfig *flirtConfig = NULL;
	uv_err_t parseMainRc = UV_ERR_GENERAL;
	
	if( strcmp(GetVersion(), UVDGetVersion()) )
	{
		printf_warn("libuvudec version mismatch (exe: %s, libuvudec: %s)\n", GetVersion(), UVDGetVersion());
		fflush(stdout);
	}
	
	//Early library initialization.  Logging and arg parsing structures
	uv_assert_err_ret(UVDInit());
	config = g_config;
	uv_assert_ret(config);
	//Early local initialization
	uv_assert_err_ret(initProgConfig());
	
	//Grab our command line options
	parseMainRc = config->parseMain(argc, argv);
	uv_assert_err_ret(parseMainRc);
	if( parseMainRc == UV_ERR_DONE )
	{
		rc = UV_ERR_OK;
		goto error;
	}


	//Create a doConvertr engine active on that input
	printf_debug_level(UVD_DEBUG_SUMMARY, "doConvert: initializing FLIRT engine...\n");
	if( UV_FAILED(UVDFLIRT::getFLIRT(&g_flirt)) )
	{
		printf_error("Failed to initialize FLIRT engine\n");
		rc = UV_ERR_OK;
		goto error;
	}
	uv_assert_ret(g_flirt);

	flirtConfig = g_UVDFLIRTConfig;
	uv_assert_ret(flirtConfig);

	//Source .pat files
	if( flirtConfig->m_targetFiles.empty() )
	{
		printf_error("Target file(s) not specified\n");
		config->printHelp();
		uv_assert_err(UV_ERR_GENERAL);
	}
	
	if( UV_FAILED(doConvert()) )
	{
		printf_error("Top level doConvert failed\n");
		uv_assert(UV_ERR_GENERAL);
	}	

	rc = UV_ERR_OK;

error:
	uv_assert_err_ret(UVDDeinit());
		
	return UV_DEBUG(rc);
}
Exemple #7
0
int main(int argc,char **argv)
{
    QCoreApplication app(argc,argv);
    if(app.arguments().size()<2) {
        showSupportedBinTypes();
        return -1;
    }
    BinType bin_type = getLoader(app.arguments()[1]);
    if(bin_type==eInvalid) {
        qCritical() << "Unhandled bin file type";
        showSupportedBinTypes();
        return -1;
    }
    BinStore binfile;
    binfile.open(argv[1],0);
    QString target_basename=QFileInfo(argv[1]).baseName();
    bool json_output=true;

    try // handle possible cereal::RapidJSONException
    {
      if(app.arguments().size()>2)
          json_output = app.arguments()[2].toInt()!=0;

      switch(bin_type)
      {
          case eLevelsDebts:    doConvert(doLoadRef<LevelExpAndDebt>(&binfile),target_basename,json_output); break;
          case eCombineChances: doConvert(doLoadRef<Parse_Combining>(&binfile),target_basename,json_output); break;
          case eBoostEffectiveness: doConvert(doLoadRef<Parse_Effectiveness>(&binfile),target_basename,json_output); break;
          case eParticleSystems:doConvert(doLoad<Parse_AllPSystems>(&binfile),target_basename,json_output); break;
          case eShops:        doConvert(doLoadRef<AllShops_Data>(&binfile),target_basename,json_output); break;
          case eShopItems:    doConvert(doLoad<AllShopItems_Data>(&binfile),target_basename,json_output); break;
          case eShopDepts:    doConvert(doLoad<AllShopDepts_Data>(&binfile),target_basename,json_output); break;
//        case eSequencers:   doConvert(doLoad<SequencerList>(&binfile),target_basename,json_output); break;
          case eTailorCosts:  doConvert(doLoad<AllTailorCosts_Data>(&binfile),target_basename,json_output); break;
          case eCostumeSets:  doConvert(doLoad<CostumeSet_Data>(&binfile),target_basename,json_output); break;
          case eBodyParts:    doConvert(doLoad<AllBodyParts_Data>(&binfile),target_basename,json_output); break;
          case eGroupEmblems: doConvert(doLoad<GeoSet_Data>(&binfile),target_basename,json_output); break;
          case ePaletteSets:  doConvert(doLoad<Pallette_Data>(&binfile),target_basename,json_output); break;
          case eZones:        doConvert(doLoadRef<AllMaps_Data>(&binfile),target_basename,json_output); break;
          case eAttribNames:  doConvert(doLoadRef<AttribNames_Data>(&binfile),target_basename,json_output); break;
          case eSceneGraph:   doConvert(doLoadRef<SceneGraph_Data>(&binfile),target_basename,json_output); break;
          case eTrickDefinitions: doConvert(doLoadRef<SceneModifiers>(&binfile),target_basename,json_output); break;
          case eEntityClasses: doConvert(doLoadRef<Parse_AllCharClasses>(&binfile),target_basename,json_output); break;
          case eEntityOrigins: doConvert(doLoadRef<Parse_AllOrigins>(&binfile),target_basename,json_output); break;
          case ePowerDefinitions: doConvert(doLoadRef<AllPowerCategories>(&binfile),target_basename,json_output); break;
          case eNpcDefinitions:
         {
            auto data = doLoadRef<AllNpcs_Data>(&binfile);
            if (qApp->arguments().size() > 2)
            {
                QString name_to_find = app.arguments()[2];
                std::sort(data->begin(), data->end(), [](const Parse_NPC &a, const Parse_NPC &b) -> bool {
                    return QString(a.m_Name).compare(QString(b.m_Name), Qt::CaseInsensitive) < 0;
                });
                auto iter = std::find_if(data->begin(), data->end(), [name_to_find](const Parse_NPC &n) -> bool {
                    if (n.m_Name == name_to_find)
                        return true;
                    return false;
                });
                qDebug() << iter - data->begin();
            } else
                doConvert(data, target_basename, json_output);
        }

          break;
          case eFxBehavior_Definitions: doConvert(doLoadRef<Fx_AllBehaviors>(&binfile),target_basename,json_output); break;
          case eFxInfo_Definitions: doConvert(doLoadRef<Fx_AllInfos>(&binfile),target_basename,json_output); break;
          default:
              break;
      }
    }
    catch(cereal::RapidJSONException &e)
    {
        qWarning() << e.what();
        return -1;
    }
    catch(std::exception &e)
    {
      qCritical() << e.what();
      return -1;
    }

    return 0;
}