TEST(VersionInfo, getVersion) {
  VersionInfo version;
  jsonxx::Object versionJson = version.getVersion();
  
  ASSERT_EQ(1, versionJson.size());
  ASSERT_EQ(VERSION, versionJson.get<string>("version"));
}
Пример #2
0
void ResultsPage::initializePage()
{
    // Register this instance as the Qt message handler.
    Q_ASSERT(instance == NULL);
    instance = this;
    previousMessageHandler = qInstallMessageHandler(&ResultsPage::messageHandler);

    // Debug log the application version information.
    VersionInfo versionInfo;
    if (versionInfo.isValid()) {
        qDebug() << QApplication::applicationName()
                 << versionInfo.fileVersionString()
                 << versionInfo.fileInfo(QLatin1String("SpecialBuild"));
    }

    // Debug log the hook version information.
#ifdef Q_OS_WIN
    for (int index = 0; index < 2; ++index) {
        const QDir dir = (index == 0) ?
            FlowSyncHook::flowSyncDir() : FlowSyncHook::installableHookDir();
        const int version = FlowSyncHook::getVersion(dir);
        qDebug() << QDir::toNativeSeparators(dir.absolutePath())
                 << "hook version" << version;
    }
#endif

    // Once the application is ready, begin the processing.
    QTimer::singleShot(0, converter, SLOT(start()));
}
Пример #3
0
void UpdateManager::getDownloadInfo()
{
	//string currentVersion,newVersion;
	//currentVersion=UpDateData::sharedInstance()->getVersion();
	//newVersion=UpDateData::sharedInstance()->getNewVersion();
	vector<VersionInfo> data;
	VersionInfo vi;
	UpDateData::sharedInstance()->getVersionDataVector(data);
	for(unsigned int i=0;i<data.size();++i)
	{
		vi=data[i];
		CCLog("getDownloadInfo-------------------------------------------name is %s,path is %s",vi.getName(),vi.getPath());
		
		
			if(getFileExtention(vi.getPath())==string("apk"))
			{
				downloadInfo.clear();
				haveApk=true;
#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
//				Dependence::removeData();
#endif
			}
			downloadInfo.push_back(vi);
		
			
		
	}
	for(unsigned int i=0;i<downloadInfo.size();i++)
	{
		vi=downloadInfo[i];
		CCLog("really download is %s",vi.getName());
	}
	

}
/* Generate a test file that will be used in the frameworks/compile/slang/tests unit tests.
 * This file tests that all RenderScript APIs can be called for the specified API level.
 * To avoid the compiler agressively pruning out our calls, we use globals as inputs and outputs.
 *
 * Since some structures can't be defined at the global level, we use casts of simple byte
 * buffers to get around that restriction.
 *
 * This file can be used to verify the white list that's also generated in this file.  To do so,
 * run "llvm-nm -undefined-only -just-symbol-name" on the resulting bit code.
 */
static bool generateApiTesterFile(const string& slangTestDirectory, int apiLevel) {
    GeneratedFile file;
    if (!file.start(slangTestDirectory, "all" + to_string(apiLevel) + ".rs")) {
        return false;
    }

    /* This unusual comment is used by slang/tests/test.py to know which parameter to pass
     * to llvm-rs-cc when compiling the test.
     */
    file << "// -target-api " << apiLevel << " -Wno-deprecated-declarations\n";

    file.writeNotices();
    file << "#pragma version(1)\n";
    file << "#pragma rs java_package_name(com.example.renderscript.testallapi)\n\n";
    if (apiLevel < 23) {  // All rs_graphics APIs were deprecated in api level 23.
        file << "#include \"rs_graphics.rsh\"\n\n";
    }

    /* The code below emits globals and calls to functions in parallel.  We store
     * the calls in a stream so that we can emit them in the file in the proper order.
     */
    ostringstream calls;
    unsigned int variableNumber = 0;  // Used to generate unique names.
    for (auto f : systemSpecification.getFunctions()) {
        const Function* function = f.second;
        for (auto spec : function->getSpecifications()) {
            VersionInfo info = spec->getVersionInfo();
            if (!info.includesVersion(apiLevel)) {
                continue;
            }
            if (info.intSize == 32) {
                calls << "#ifndef __LP64__\n";
            } else if (info.intSize == 64) {
                calls << "#ifdef __LP64__\n";
            }
            for (auto permutation : spec->getPermutations()) {
                generateTestCall(&file, &calls, &variableNumber, *function, *permutation);
            }
            if (info.intSize != 0) {
                calls << "#endif\n";
            }
        }
    }
    file << "\n";

    // Modify the style of kernel as required by the API level.
    if (apiLevel >= 23) {
        file << "void RS_KERNEL test(int in, rs_kernel_context context) {\n";
    } else if (apiLevel >= 17) {
        file << "void RS_KERNEL test(int in) {\n";
    } else {
        file << "void root(const int* in) {\n";
    }
    file << calls.str();
    file << "}\n";

    return true;
}
Пример #5
0
bool SHMProcess::Private::validate(vector <VersionInfo *> & known_versions)
{
    // try to identify the DF version
    IMAGE_NT_HEADERS32 pe_header;
    IMAGE_SECTION_HEADER sections[16];
    HMODULE hmod = NULL;
    DWORD junk;
    HANDLE hProcess;
    bool found = false;
    identified = false;
    // open process, we only need the process open
    hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, process_ID );
    if (NULL == hProcess)
        return false;

    // try getting the first module of the process
    if(EnumProcessModules(hProcess, &hmod, 1 * sizeof(HMODULE), &junk) == 0)
    {
        CloseHandle(hProcess);
        // cout << "EnumProcessModules fail'd" << endl;
        return false;
    }
    // got base ;)
    uint32_t base = (uint32_t)hmod;

    // read from this process
    uint32_t pe_offset = self->readDWord(base+0x3C);
    self->read(base + pe_offset                   , sizeof(pe_header), (uint8_t *)&pe_header);
    self->read(base + pe_offset+ sizeof(pe_header), sizeof(sections) , (uint8_t *)&sections );

    // iterate over the list of memory locations
    vector<VersionInfo *>::iterator it;
    for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
    {
        uint32_t pe_timestamp;
        try
        {
            pe_timestamp = (*it)->getPE();
        }
        catch(Error::MissingMemoryDefinition&)
        {
            continue;
        }
        if (pe_timestamp == pe_header.FileHeader.TimeDateStamp)
        {
            VersionInfo *m = new VersionInfo(**it);
            m->RebaseAll(base);
            memdescriptor = m;
            m->setParentProcess(self);
            identified = true;
            cerr << "identified " << m->getVersion() << endl;
            CloseHandle(hProcess);
            return true;
        }
    }
    return false;
}
Пример #6
0
int main(int argc, char *argv[]) {
    // Setup the primary Qt application object.
    QApplication app(argc, argv);
    app.setApplicationName(APPLICATION_NAME);
    app.setOrganizationName(ORGANISATION_NAME);
    app.setOrganizationDomain(ORGANISATION_DOMAIN);
    VersionInfo versionInfo;
    if (versionInfo.isValid()) {
        app.setApplicationVersion(versionInfo.fileVersionString());
    }

    // Default to the Oxygen theme, if no other theme is configured yet.
    if (QIcon::themeName().isEmpty()) {
        QIcon::setThemeName(QLatin1String("oxygen"));
    }

    // Try to load a localised translator.
    QTranslator translator;
    if (translator.load(QLocale::system().name(),app.applicationDirPath()+QLatin1String("/../i18n")))
        app.installTranslator(&translator);

#ifdef Q_OS_WIN
    // Install the hook now, if requested via the command line.
    if (app.arguments().contains(QLatin1Literal("-install-hook"))) {
        QErrorMessage::qtHandler(); // Expose any internal errors / warnings.
        const QDir fromDir = FlowSyncHook::installableHookDir();
        const QDir toDir = FlowSyncHook::flowSyncDir();
        if (!fromDir.exists(QLatin1String("Qt5Network.dll"))) {
            QMessageBox::warning(NULL, QString(),
                app.tr("Installable hook not found."));
            return 1;
        }
        if (!toDir.exists(QLatin1String("Qt5Network.dll"))) {
            QMessageBox::warning(NULL, QString(),
                app.tr("Failed to locate Polar FlowSync installation."));
            return 2;
        }
        const int fromVersion = FlowSyncHook::getVersion(fromDir);
        const int toVersion = FlowSyncHook::getVersion(toDir);
        if (fromVersion > toVersion) {
            if (!FlowSyncHook::install(fromDir, toDir)) {
                QMessageBox::warning(NULL, QString(),
                    app.tr("Failed to install hook DLL."));
                return 3;
            }
        }
        return 0;
    }
#endif

    // Instantiate the main window.
    MainWizard mainWizard;
    mainWizard.show();
    return app.exec();
}
Пример #7
0
Engravings::Engravings(DFContextShared * d_)
{
    d = new Private;
    d->d = d_;
    d->owner = d_->p;
    d->p_engr = 0;
    d->Inited = d->Started = false;
    VersionInfo * mem = d->d->offset_descriptor;
    d->engraving_vector = mem->getGroup("Engravings")->getAddress ("vector");
    d->Inited = true;
}
Пример #8
0
Constructions::Constructions(DFContextShared * d_)
{
    d = new Private;
    d->d = d_;
    d->owner = d_->p;
    d->p_cons = 0;
    d->Inited = d->Started = false;
    VersionInfo * mem = d->d->offset_descriptor;
    d->construction_vector = mem->getGroup("Constructions")->getAddress ("vector");
    d->Inited = true;
}
Пример #9
0
void ESDLcompiler::write_esxdl()
{
    esxdlcontent.clear();

    VersionInfo * vi;
    for (vi=versions;vi;vi=vi->next)
    {
        vi->toString(esxdlcontent);
    }

    if(outputIncludes)
    {
        IncludeInfo * ii;
        for (ii=hcp->includes;ii;ii=ii->next)
        {
            ii->toString(esxdlcontent);
        }
    }

    EspMessageInfo * mi;
    for (mi=msgs;mi;mi=mi->next)
    {
        mi->toString(esxdlcontent);
    }

    EspServInfo *si;
    for (si=servs;si;si=si->next)
    {
        si->toString(esxdlcontent);
    }

    if (methods)
    {
        EspMethodInfo *sm;
        for (sm=methods;sm;sm=sm->next)
        {
            sm->toString(esxdlcontent);
        }
    }


    if (esxdlo > 0)
    {
        //Populate the file
        StringBuffer tmp;
        tmp.setf("<esxdl name=\"%s\">\n", name.str()).append(esxdlcontent.str()).append("</esxdl>");
        gOutfile = esxdlo;
        outs(tmp.str());
        gOutfile = -1;
    }
}
Пример #10
0
int main(int, char**)
{
#if ACKWARD_MAJOR_VERSION < 1
// probably not ready for prime-time!
#else
// Feel free to use this code to perform brain surgery while launching a space shuttle.
#endif

    // Get the current version info.
    VersionInfo info = versionInfo();

    // Return the major version.
    return info.majorVersion();
}
Пример #11
0
Gui::Gui(DFContextShared * _d)
{

    d = new Private;
    d->d = _d;
    d->owner = _d->p;
    VersionInfo * mem = d->d->offset_descriptor;
    OffsetGroup * OG_Gui = mem->getGroup("GUI");
    try
    {
        d->current_menu_state_offset = OG_Gui->getAddress("current_menu_state");
        d->MenuStateInited = true;
    }
    catch(exception &){};
    try
    {
        d->view_screen_offset = OG_Gui->getAddress ("view_screen");
        d->ViewScreeInited = true;
    }
    catch(exception &){};
    OffsetGroup * OG_Position;
    try
    {
        OG_Position = mem->getGroup("Position");
        d->window_x_offset = OG_Position->getAddress ("window_x");
        d->window_y_offset = OG_Position->getAddress ("window_y");
        d->window_z_offset = OG_Position->getAddress ("window_z");
        d->cursor_xyz_offset = OG_Position->getAddress ("cursor_xyz");
        d->window_dims_offset = OG_Position->getAddress ("window_dims");
        d->Started = true;
    }
    catch(Error::All &){};
    try
    {
        OffsetGroup * OG_Hotkeys = mem->getGroup("Hotkeys");
        d->hotkey_start = OG_Hotkeys->getAddress("start");
        d->hotkey_mode_offset = OG_Hotkeys->getOffset ("mode");
        d->hotkey_xyz_offset = OG_Hotkeys->getOffset("coords");
        d->hotkey_size = OG_Hotkeys->getHexValue("size");
        d->StartedHotkeys = true;
    }
    catch(Error::All &){};
    try
    {
        d->screen_tiles_ptr_offset = OG_Position->getAddress ("screen_tiles_pointer");
        d->StartedScreen = true;
    }
    catch(Error::All &){};
}
Пример #12
0
bool SHMProcess::Private::validate(vector <VersionInfo *> & known_versions)
{
    char exe_link_name [256];
    char target_name[1024];
    int target_result;
    // find the binary
    sprintf(exe_link_name,"/proc/%d/exe", process_ID);
    target_result = readlink(exe_link_name, target_name, sizeof(target_name)-1);
    if (target_result == -1)
    {
        perror("readlink");
        return false;
    }
    // make sure we have a null terminated string...
    // see http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html
    target_name[target_result] = 0;

    md5wrapper md5;
    // get hash of the running DF process
    string hash = md5.getHashFromFile(target_name);
    vector<VersionInfo *>::iterator it;
    // cerr << exe_file << " " << hash <<  endl;
    // iterate over the list of memory locations
    for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
    {
        try {
            if(hash == (*it)->getMD5()) // are the md5 hashes the same?
            {
                VersionInfo *m = new VersionInfo(**it);
                memdescriptor = m;
                m->setParentProcess(dynamic_cast<Process *>( self ));
                identified = true;
                // cerr << "identified " << m->getVersion() << endl;
                return true;
            }
        }
        catch (Error::AllMemdef&)
        {
            continue;
        }
    }
    return false;
}
int main(int argc, char **argv) {

  Gtk::Main kit(argc, argv);

  InputParser parser(cin);
  _log("Parsing input...");
  Object json = parser.readBody();

  if (json.has<string>("lang")) {
    l10nLabels.setLanguage(json.get<string>("lang"));
  }

  string response;

  if (json.get<string>("protocol") != "https:") {
    ExtensionDialog dialog;
    response = dialog.error(ONLY_HTTPS_ALLOWED).json();
  } else {
    string type = json.get<string>("type");

    if (type == "SIGN") {
      string hashFromStdIn = json.get<String>("hash");
      string certId = json.get<String>("id");
      _log("signing hash: %s, with certId: %s", hashFromStdIn.c_str(), certId.c_str());
      Signer signer(hashFromStdIn, certId);
      response = signer.sign().json();
    } else if (type == "CERT") {
      CertificateSelection cert;
      response = cert.getCert().json();
    } else if (type == "VERSION") {
      VersionInfo version;
      response = version.getVersion().json();
    }
  }
  int responseLength = response.size();
  unsigned char *responseLengthAsBytes = intToBytesLittleEndian(responseLength);
  cout.write((char *) responseLengthAsBytes, 4);
  _log("Response(%i) %s ", responseLength, response.c_str());
  cout << response << endl;
  free(responseLengthAsBytes);
  return EXIT_SUCCESS;
}
Пример #14
0
MainWizard::MainWizard(QWidget *parent, Qt::WindowFlags flags): QWizard(parent,flags) {
    setWindowTitle(tr("%1 %2")
        .arg(QApplication::applicationName())
        .arg(QStringList(QApplication::applicationVersion().split(QLatin1Char('.')).mid(0, 3)).join(QLatin1Char('.'))));
    const VersionInfo versionInfo;
    const QString specialBuild = (versionInfo.isValid()) ?
        versionInfo.fileInfo(QLatin1String("SpecialBuild")) : QString();
    if (!specialBuild.isEmpty()) {
        setWindowTitle(windowTitle() + QLatin1Char(' ') + specialBuild);
    }

    setOption(QWizard::NoBackButtonOnLastPage);
    #if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
    setOption(QWizard::NoCancelButtonOnLastPage);
    #endif

    addPage(new InputsPage());
    addPage(new OutputsPage());
    addPage(new ResultsPage());
}
Пример #15
0
Units::Units()
{
    Core & c = Core::getInstance();
    d = new Private;
    d->owner = c.p;
    VersionInfo * minfo = c.vinfo;
    d->Inited = false;
    d->Started = false;
    d->IdMapReady = false;
    d->trans = c.getTranslation();
    d->trans->InitReadNames(); // FIXME: throws on error

    OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");

    creatures = 0;
    try
    {
        creatures = (vector <df_unit *> *) OG_Creatures->getAddress ("vector");
        d->dwarf_race_index_addr = (void *) OG_Creatures->getAddress("current_race");
        d->dwarf_civ_id_addr = (void *) OG_Creatures->getAddress("current_civ");
    }
    catch(Error::All&){};
    d->Inited = true;
}
/* For the given API level and bitness (e.g. 32 or 64 bit), try to find a
 * substitution for the provided type name, as would be done (mostly) by a
 * preprocessor.  Returns empty string if there's no substitution.
 */
static string findSubstitute(const string& typeName, int apiLevel, int intSize) {
    const auto& types = systemSpecification.getTypes();
    const auto type = types.find(typeName);
    if (type != types.end()) {
        for (TypeSpecification* spec : type->second->getSpecifications()) {
            // Verify this specification applies
            const VersionInfo info = spec->getVersionInfo();
            if (!info.includesVersion(apiLevel) || (info.intSize != 0 && info.intSize != intSize)) {
                continue;
            }
            switch (spec->getKind()) {
                case SIMPLE: {
                    /* For simple typedefs, replace it unless it's the special case of _RS_HANDLE
                     * which is a macro of a struct.
                     */
                    const string s = spec->getSimpleType();
                    if (s != "_RS_HANDLE") {
                        return s;
                    }
                    break;
                }
                case STRUCT: {
                    const string s = spec->getStructName();
                    if (!s.empty()) {
                        return s;
                    }
                    break;
                }
                case ENUM:
                    // Do nothing
                    break;
            }
        }
    }
    return "";
}
Пример #17
0
    void updateLogoButtonText()
    {
        String text;

        if(layoutMode == NormalLayout)
        {
            VersionInfo currentVersion;
            if(String(DOOMSDAY_RELEASE_TYPE) == "Stable")
            {
                text = _E(b) + currentVersion.base();
            }
            else
            {
                text = _E(b) + currentVersion.base() + " " +
                       _E(l) + String("#%1").arg(currentVersion.build);
            }
        }
        else
        {
            // Remove the version number if we're short of space.
        }

        logo->setText(text);
    }
Пример #18
0
Gui::Gui()
{
    Core & c = Core::getInstance();
    d = new Private;
    d->owner = c.p;
    VersionInfo * mem = c.vinfo;
    // Setting up menu state
    df_menu_state = (uint32_t *) & df::global::ui->main.mode;

    d->window_x_offset = (int32_t *) mem->getAddress ("window_x");
    d->window_y_offset = (int32_t *) mem->getAddress ("window_y");
    d->window_z_offset = (int32_t *) mem->getAddress ("window_z");
    if(d->window_z_offset && d->window_y_offset && d->window_x_offset)
        d->Started = true;

    d->menu_width_offset = (uint8_t *) mem->getAddress("ui_menu_width");
    d->area_map_width_offset = (uint8_t *) mem->getAddress("ui_area_map_width");
    if (d->menu_width_offset && d->area_map_width_offset)
        d->StartedMenu = true;

    d->screen_tiles_ptr_offset = (void *) mem->getAddress ("screen_tiles_pointer");
    if(d->screen_tiles_ptr_offset)
        d->StartedScreen = true;
}
Пример #19
0
NormalProcess::NormalProcess(uint32_t pid, vector <VersionInfo *> & known_versions)
: d(new Private())
{
    HMODULE hmod = NULL;
    DWORD junk;
    HANDLE hProcess;
    bool found = false;

    IMAGE_NT_HEADERS32 pe_header;
    IMAGE_SECTION_HEADER sections[16];
    d->identified = false;
    // open process
    hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pid );
    if (NULL == hProcess)
        return;

    // try getting the first module of the process
    if(EnumProcessModules(hProcess, &hmod, 1 * sizeof(HMODULE), &junk) == 0)
    {
        CloseHandle(hProcess);
        // cout << "EnumProcessModules fail'd" << endl;
        return; //if enumprocessModules fails, give up
    }

    // got base ;)
    uint32_t base = (uint32_t)hmod;

    // temporarily assign this to allow some checks
    d->my_handle = hProcess;
    d->my_main_thread = 0;
    // read from this process
    try
    {
        uint32_t pe_offset = readDWord(base+0x3C);
        read(base + pe_offset                   , sizeof(pe_header), (uint8_t *)&pe_header);
        read(base + pe_offset+ sizeof(pe_header), sizeof(sections) , (uint8_t *)&sections );
        d->my_handle = 0;
    }
    catch (exception &)
    {
        CloseHandle(hProcess);
        d->my_handle = 0;
        return;
    }

    // see if there's a version entry that matches this process
    vector<VersionInfo*>::iterator it;
    for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
    {
        // filter by OS
        if(VersionInfo::OS_WINDOWS != (*it)->getOS())
            continue;
        uint32_t pe_timestamp;
        // filter by timestamp, skip entries without a timestamp
        try
        {
            pe_timestamp = (*it)->getPE();
        }
        catch(Error::MissingMemoryDefinition&)
        {
            continue;
        }
        if (pe_timestamp != pe_header.FileHeader.TimeDateStamp)
            continue;

        // all went well
        {
            printf("Match found! Using version %s.\n", (*it)->getVersion().c_str());
            d->identified = true;
            // give the process a data model and memory layout fixed for the base of first module
            VersionInfo *m = new VersionInfo(**it);
            m->RebaseAll(base);
            // keep track of created memory_info object so we can destroy it later
            d->my_descriptor = m;
            m->setParentProcess(this);
            // process is responsible for destroying its data model
            d->my_pid = pid;
            d->my_handle = hProcess;
            d->identified = true;

            // TODO: detect errors in thread enumeration
            vector<uint32_t> threads;
            getThreadIDs( threads );
            d->my_main_thread = OpenThread(THREAD_ALL_ACCESS, FALSE, (DWORD) threads[0]);
            OffsetGroup * strGrp = m->getGroup("string")->getGroup("MSVC");
            d->STLSTR_buf_off = strGrp->getOffset("buffer");
            d->STLSTR_size_off = strGrp->getOffset("size");
            d->STLSTR_cap_off = strGrp->getOffset("capacity");
            found = true;
            break; // break the iterator loop
        }
    }
    // close handle of processes that aren't DF
    if(!found)
    {
        CloseHandle(hProcess);
    }
}
Пример #20
0
bool VersionInfo::operator==(const VersionInfo &rhs) const
{
    return this->GetString() == rhs.GetString();    //only equal data produces equal strings
}
Пример #21
0
Creatures::Creatures(DFContextShared* _d)
{
    d = new Private;
    d->d = _d;
    d->owner = _d->p;
    d->Inited = false;
    d->Started = false;
    d->d->InitReadNames(); // throws on error
    VersionInfo * minfo = d->d->offset_descriptor;
    OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");
    OffsetGroup *OG_creature = OG_Creatures->getGroup("creature");
    OffsetGroup *OG_creature_ex = OG_creature->getGroup("advanced");
    OffsetGroup *OG_soul = OG_Creatures->getGroup("soul");
    OffsetGroup * OG_name = minfo->getGroup("name");
    d->OG_jobs = OG_Creatures->getGroup("job");
    d->OG_job_mats = d->OG_jobs->getGroup("material");
    d->Ft_basic = d->Ft_advanced = d->Ft_jobs = d->Ft_soul = false;

    Creatures2010::creature_offsets &creatures = d->creatures;
    try
    {
        // Creatures
        creatures.vector = OG_Creatures->getAddress ("vector");
        d->dwarf_race_index_addr = OG_Creatures->getAddress("current_race");
        d->dwarf_civ_id_addr = OG_Creatures->getAddress("current_civ");
        // Creatures/creature
        creatures.name_offset = OG_creature->getOffset ("name");
        creatures.custom_profession_offset = OG_creature->getOffset ("custom_profession");
        creatures.profession_offset = OG_creature->getOffset ("profession");
        creatures.race_offset = OG_creature->getOffset ("race");
        creatures.pos_offset = OG_creature->getOffset ("position");
        creatures.flags1_offset = OG_creature->getOffset ("flags1");
        creatures.flags2_offset = OG_creature->getOffset ("flags2");
        creatures.sex_offset = OG_creature->getOffset ("sex");
        creatures.caste_offset = OG_creature->getOffset ("caste");
        creatures.id_offset = OG_creature->getOffset ("id");
        creatures.civ_offset = OG_creature->getOffset ("civ");
        // name struct
        creatures.name_firstname_offset = OG_name->getOffset("first");
        creatures.name_nickname_offset = OG_name->getOffset("nick");
        creatures.name_words_offset = OG_name->getOffset("second_words");
        d->Ft_basic = true;
        try
        {
            creatures.inventory_offset = OG_creature_ex->getOffset("inventory_vector");
            creatures.pickup_equipment_bit = OG_creature_ex->getOffset("pickup_equipment_bit");
            creatures.mood_offset = OG_creature_ex->getOffset("mood");
            // pregnancy
            // pregnancy_ptr
            creatures.birth_year_offset = OG_creature_ex->getOffset("birth_year");
            creatures.birth_time_offset = OG_creature_ex->getOffset("birth_time");
            creatures.current_job_offset = OG_creature_ex->getOffset("current_job");
            creatures.mood_skill_offset = OG_creature_ex->getOffset("current_job_skill");
            creatures.physical_offset = OG_creature_ex->getOffset("physical");
            creatures.appearance_vector_offset = OG_creature_ex->getOffset("appearance_vector");
            creatures.artifact_name_offset = OG_creature_ex->getOffset("artifact_name");
            creatures.labors_offset = OG_creature_ex->getOffset ("labors");
            creatures.happiness_offset = OG_creature_ex->getOffset ("happiness");
            d->Ft_advanced = true;
        }
        catch(Error::All&) {};
        try
        {
            creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector");
            creatures.default_soul_offset = OG_creature_ex->getOffset("current_soul");
            creatures.soul_mental_offset = OG_soul->getOffset("mental");
            creatures.soul_skills_vector_offset = OG_soul->getOffset("skills_vector");
            creatures.soul_traits_offset = OG_soul->getOffset("traits");
            d->Ft_soul = true;
        }
        catch(Error::All&) {};
    }
    catch(Error::All&) {};
    d->Inited = true;
}
Пример #22
0
AboutBox&
AboutBox::Display() const
{
    VersionInfo info = mVersionInfo;
    string versionNumber = info[ "Version" ];
    info.erase( "Version" );
    string versionDetails;
    for( VersionInfo::reverse_iterator i = info.rbegin(); i != info.rend(); ++i )
        versionDetails += ", " + i->first + ": " + i->second;
    versionDetails.erase( 0, 2 );

#ifdef __BORLANDC__
    TForm* pForm = new TForm( static_cast<TComponent*>( NULL ) );
    pForm->BorderStyle = bsDialog;
    pForm->Position = poScreenCenter;
    pForm->Caption = ( string( "About " ) + mApplicationName + "..." ).c_str();

    TPanel* pPanel = new TPanel( pForm );
    pPanel->Parent = pForm;
    pPanel->BorderStyle = bsNone;
    pPanel->BorderWidth = 0;
    pPanel->BevelOuter = bvLowered;
    pPanel->BevelInner = bvNone;
    pPanel->Color = clWhite;
    pPanel->Left = 10;
    pPanel->Top = 10;
    pPanel->Width = pForm->ClientWidth - 2 * pPanel->Left;

    Graphics::TBitmap* pBitmap = new Graphics::TBitmap;
    int logoWidth = GraphicResource::Width( Resources::BCI2000logo_mini ),
        logoHeight = GraphicResource::Width( Resources::BCI2000logo_mini );
    pBitmap->Width = logoWidth + 1;
    pBitmap->Height = logoHeight + 1;
    pBitmap->Canvas->Brush->Color = pPanel->Color;
    pBitmap->Canvas->FillRect( TRect( 0, 0, pBitmap->Width, pBitmap->Height ) );
    DrawContext dc = { pBitmap->Canvas->Handle, { 0, 0, logoWidth, logoHeight } };
    GraphicResource::Render<RenderingMode::Transparent>( Resources::BCI2000logo_mini, dc );

    TPicture* pPicture = new TPicture;
    pPicture->Graphic = pBitmap;
    TImage* pImage = new TImage( pForm );
    pImage->Parent = pPanel;
    pImage->Left = pPanel->Left;
    pImage->Top = pPanel->Top;
    pImage->Width = pBitmap->Width;
    pImage->Height = pBitmap->Height;
    pImage->Picture = pPicture;

    TLabel* pNameLabel = new TLabel( pForm );
    pNameLabel->Parent = pPanel;
    pNameLabel->Top = pImage->Top;
    pNameLabel->Left = 3 * pImage->Left + pImage->Width;
    pNameLabel->Font->Size *= 2;
    pNameLabel->Font->Style = pNameLabel->Font->Style << fsBold;
    pNameLabel->Caption = mApplicationName.c_str();

    TLabel* pCopyrightLabel = new TLabel( pForm );
    pCopyrightLabel->Parent = pPanel;
    pCopyrightLabel->Alignment = taLeftJustify;
    pCopyrightLabel->Caption = ( versionNumber + "\n\n" + BCI2000_COPYRIGHT ).c_str();
    pCopyrightLabel->Top = pNameLabel->Top + pNameLabel->Height;
    pCopyrightLabel->Left = pNameLabel->Left;

    int textWidth = max( pCopyrightLabel->Width, pNameLabel->Width );
    pPanel->ClientWidth = 4 * pImage->Left + pImage->Width + textWidth;
    pPanel->ClientHeight = pImage->Height + 2 * pImage->Top;
    pForm->ClientWidth = 2 * pPanel->Left + pPanel->Width;

    TLabel* pVersionLabel = new TLabel( pForm );
    pVersionLabel->Parent = pForm;
    pVersionLabel->Alignment = taCenter;
    pVersionLabel->Top = 2 * pPanel->Top + pPanel->Height;
    pVersionLabel->WordWrap = true;
    pVersionLabel->Left = pPanel->Left;
    pVersionLabel->Width = pPanel->Width;
    pVersionLabel->Caption = versionDetails.c_str();
    pVersionLabel->Left = ( pForm->ClientWidth - pVersionLabel->Width ) / 2;

    TButton* pButton = new TButton( pForm );
    pButton->Parent = pForm;
    pButton->ModalResult = mrOk;
    pButton->Caption = "Close";
    pButton->Left = ( pForm->ClientWidth - pButton->Width ) / 2;
    pButton->Top = pVersionLabel->Top + pVersionLabel->Height + pButton->Height / 2;

    pForm->ClientHeight = pButton->Top + ( 3 * pButton->Height ) / 2;

    pForm->ShowModal();
    delete pForm;
#endif // __BORLANDC__
    return *const_cast<AboutBox*>( this );
}
Пример #23
0
bool Materials::ReadCreatureTypesEx (void)
{
    Process *p = d->owner;
    VersionInfo *mem = p->getDescriptor();
    OffsetGroup * OG_string = mem->getGroup("string");
    uint32_t sizeof_string = OG_string->getHexValue ("sizeof");

    OffsetGroup * OG_Mats = mem->getGroup("Materials");
    DfVector <uint32_t> p_races (OG_Mats->getAddress ("creature_type_vector"));

    OffsetGroup * OG_Creature = OG_Mats->getGroup("creature");
        uint32_t castes_vector_offset = OG_Creature->getOffset ("caste_vector");
        uint32_t extract_vector_offset = OG_Creature->getOffset ("extract_vector");
        uint32_t tile_offset = OG_Creature->getOffset ("tile");
        uint32_t tile_color_offset = OG_Creature->getOffset ("tile_color");

    bool have_advanced = false;
    uint32_t caste_colormod_offset;
    uint32_t caste_attributes_offset;
    uint32_t caste_bodypart_offset;
    uint32_t bodypart_id_offset;
    uint32_t bodypart_category_offset;
    uint32_t color_modifier_part_offset;
    uint32_t color_modifier_startdate_offset;
    uint32_t color_modifier_enddate_offset;
    try
    {
        OffsetGroup * OG_Caste = OG_Creature->getGroup("caste");
            caste_colormod_offset = OG_Caste->getOffset ("color_modifiers");
            caste_attributes_offset = OG_Caste->getOffset ("attributes");
            caste_bodypart_offset = OG_Caste->getOffset ("bodypart_vector");
        OffsetGroup * OG_CasteBodyparts = OG_Creature->getGroup("caste_bodyparts");
            bodypart_id_offset = OG_CasteBodyparts->getOffset ("id");
            bodypart_category_offset = OG_CasteBodyparts->getOffset ("category");
        OffsetGroup * OG_CasteColorMods = OG_Creature->getGroup("caste_color_mods");
            color_modifier_part_offset = OG_CasteColorMods->getOffset ("part");
            color_modifier_startdate_offset = OG_CasteColorMods->getOffset ("startdate");
            color_modifier_enddate_offset = OG_CasteColorMods->getOffset ("enddate");
        have_advanced = true;
    }
    catch (Error::All &){};

    uint32_t size = p_races.size();
    uint32_t sizecas = 0;
    uint32_t sizecolormod;
    uint32_t sizecolorlist;
    uint32_t sizebp;
    raceEx.clear();
    raceEx.reserve (size);
    for (uint32_t i = 0; i < size;i++)
    {
        t_creaturetype mat;
        mat.id = p->readSTLString (p_races[i]);
        mat.tile_character = p->readByte( p_races[i] + tile_offset );
        mat.tilecolor.fore = p->readWord( p_races[i] + tile_color_offset );
        mat.tilecolor.back = p->readWord( p_races[i] + tile_color_offset + 2 );
        mat.tilecolor.bright = p->readWord( p_races[i] + tile_color_offset + 4 );

        DfVector <uint32_t> p_castes(p_races[i] + castes_vector_offset);
        sizecas = p_castes.size();
        for (uint32_t j = 0; j < sizecas;j++)
        {
            /* caste name */
            t_creaturecaste caste;
            uint32_t caste_start = p_castes[j];
            caste.id = p->readSTLString (caste_start);
            caste.singular = p->readSTLString (caste_start + sizeof_string);
            caste.plural = p->readSTLString (caste_start + 2 * sizeof_string);
            caste.adjective = p->readSTLString (caste_start + 3 * sizeof_string);
            //cout << "Caste " << caste.rawname << " " << caste.singular << ": 0x" << hex << caste_start << endl;
            if(have_advanced)
            {
                /* color mod reading */
                // Caste + offset > color mod vector
                DfVector <uint32_t> p_colormod(caste_start + caste_colormod_offset);
                sizecolormod = p_colormod.size();
                caste.ColorModifier.resize(sizecolormod);
                for(uint32_t k = 0; k < sizecolormod;k++)
                {
                    // color mod [0] -> color list
                    DfVector <uint32_t> p_colorlist(p_colormod[k]);
                    sizecolorlist = p_colorlist.size();
                    caste.ColorModifier[k].colorlist.resize(sizecolorlist);
                    for(uint32_t l = 0; l < sizecolorlist; l++)
                        caste.ColorModifier[k].colorlist[l] = p_colorlist[l];
                    // color mod [color_modifier_part_offset] = string part
                    caste.ColorModifier[k].part = p->readSTLString( p_colormod[k] + color_modifier_part_offset);
                    caste.ColorModifier[k].startdate = p->readDWord( p_colormod[k] + color_modifier_startdate_offset );
                    caste.ColorModifier[k].enddate = p->readDWord( p_colormod[k] + color_modifier_enddate_offset );
                }
                /* body parts */
                DfVector <uint32_t> p_bodypart(caste_start + caste_bodypart_offset);
                caste.bodypart.empty();
                sizebp = p_bodypart.size();
                for(uint32_t k = 0; k < sizebp; k++)
                {
                    t_bodypart part;
                    part.id = p->readSTLString (p_bodypart[k] + bodypart_id_offset);
                    part.category = p->readSTLString (p_bodypart[k] + bodypart_category_offset);
                    caste.bodypart.push_back(part);
                }
                p->read(caste_start + caste_attributes_offset, sizeof(t_attrib) * NUM_CREAT_ATTRIBS, (uint8_t *)&caste.strength);
            }
            else
            {
                memset(&caste.strength, 0,  sizeof(t_attrib) * NUM_CREAT_ATTRIBS);
            }
            mat.castes.push_back(caste);
        }
        DfVector <uint32_t> p_extract(p_races[i] + extract_vector_offset);
        for(uint32_t j = 0; j < p_extract.size(); j++)
        {
            t_creatureextract extract;
            extract.id = p->readSTLString( p_extract[j] );
            mat.extract.push_back(extract);
        }
        raceEx.push_back(mat);
    }
    return true;
}
Пример #24
0
int main(int argc, char* argv[])
{
  // The exit code of the sample application
  int exitCode = 0;

  // Automagically call PylonInitialize and PylonTerminate to ensure the
  // pylon runtime system is initialized during the lifetime of this object.
  Pylon::PylonAutoInitTerm autoInitTerm;

  CTlFactory *_TlFactory = NULL;
  int nTransportLayers;
  TlInfoList_t transportLayers;
  TlInfoList::const_iterator tl_it;
  ITransportLayer* tl_;
  Pylon::DeviceInfoList_t devices;
  int nCameras = 0;
  Pylon::DeviceInfoList_t::const_iterator it;
  //CDeviceInfo devInfo;
  Camera_t::DeviceInfo_t devInfo;
  IPylonDevice *pDevice = NULL;
  Camera_t *bCamera;
  scoped_ptr<Camera_t> scoped_bCamera;

  //FIXME: this arguments haven't been checked
  Pylon::String_t pylon_camera_ip(argv[1]);
  Pylon::String_t devInfoSource(argv[2]);
  Pylon::String_t devInfoIterator("it");
  int devInfoOptions = 0;
  if (devInfoSource == "")
  {
    cout << "Second argument not specified, using default" << endl;
    devInfoSource = devInfoIterator;
  }
  if (devInfoSource == "it")
  {
    cout << "To build the objects, the iterator reference will be used" << endl;
    devInfoOptions = 1;
  }
  else if (devInfoSource == "devInfo")
  {
    cout << "To build the objects, the devInfo object will be used" << endl;
    devInfoOptions = 2;
  }
  else
  {
    cout << "invalid device information source" << endl;
    goto exit;
  }

goto continueNormal;

exit://Moved from the bottom to avoid declarations with
     //initialisations in the middle.
  cout << "exit(" << exitCode << ")" << endl;
  try
  {
    _TlFactory->ReleaseTl(tl_);
  }
  catch(exception& e)
  {
    cout << "couldn't release the transport layer" << endl;
  }
  try
  {
    scoped_bCamera.reset();
  }
  catch(exception& e)
  {
    cout << "couldn't reset the scoped_ptr" << endl;
  }
  cout << endl;
  return exitCode;

continueNormal:
  VersionInfo pylonVersionInfo;
  cout << endl << "Working with Pylon version " \
       << pylonVersionInfo.getMajor() << " (" \
       << pylonVersionInfo.getVersionString() << ")" << endl;

  cout << endl << "Get factory instance" << endl;
  _TlFactory = &CTlFactory::GetInstance();
  nTransportLayers = _TlFactory->EnumerateTls(transportLayers);
  cout << "Available "<< nTransportLayers <<" transport layers" << endl;
  for (tl_it = transportLayers.begin(); tl_it != transportLayers.end();tl_it++)
  {
    const Pylon::CTlInfo& tl_info = \
              static_cast<const Pylon::CTlInfo&>(*tl_it);
    cout << "\t- " << tl_info.GetFullName() << endl;
  }

  cout << endl << "Create a transport layer to access " \
      << Camera_t::DeviceClass() << " cameras" << endl;
  tl_ = _TlFactory->CreateTl( Camera_t::DeviceClass() );

  nCameras = tl_->EnumerateDevices( devices );
  cout << "Found " << nCameras << " cameras" << endl;
  if (nCameras == 0)
  {
    exitCode = -1;
    goto exit;
  }
  cout << "\tIterate searching " << pylon_camera_ip << " camera"
      << endl;
  for (it = devices.begin(); it != devices.end(); it++)
  {
    const Camera_t::DeviceInfo_t& gige_device_info = \
        static_cast<const Camera_t::DeviceInfo_t&>(*it);
    Pylon::String_t current_ip = gige_device_info.GetIpAddress();
    cout << "\t\t- Found a " << gige_device_info.GetModelName() << " (" \
        << gige_device_info.GetSerialNumber() << ")" \
        << " with ip " << current_ip << endl;
    if (current_ip == pylon_camera_ip)
    {
      cout << "\t\t\t** This is the camera wanted (" << current_ip << ") **"
          << endl;
      devInfo = gige_device_info;
      break;
    }
  }
  if (it == devices.end())
  {
    cout << "\t\tCamera not found" << endl;
    exitCode = -2;
    goto exit;
  }
  cout << endl << "Wanted camera information:" << endl;
  cout << "\t- FullName: \"" << devInfo.GetFullName() \
      << "\""<< endl;
  cout << "\t- SerialNumber: \"" << devInfo.GetSerialNumber() \
        << "\""<< endl;
  cout << "\t- ModelName: \"" << devInfo.GetModelName() \
      << "\""<< endl;
  cout << "\t- DeviceClass: \"" << devInfo.GetDeviceClass() \
      << "\""<< endl;
  cout << "\t- DeviceVersion: \"" << devInfo.GetDeviceVersion() \
      << "\""<< endl;
  cout << "\t- DeviceFactory: \"" << devInfo.GetDeviceFactory() \
      << "\""<< endl;
  cout << "\t- Interface: \"" << devInfo.GetInterface() \
      << "\""<< endl;

  cout << endl << "Connect to the Camera for further control" << endl;

  try
  {
    cout << "Build and attach in one step" << endl;

    if (devInfoOptions == 1)
    {
      bCamera = new Camera_t(_TlFactory->CreateDevice(*it));
    }
    else
    {
      bCamera = new Camera_t(_TlFactory->CreateDevice(devInfo));
    }
    scoped_bCamera.reset(bCamera);
  }
  catch(exception& e)
  {
    cout << "\tIt doesn't work!\n\t" << e.what() << endl \
         << "Try an alternative" << endl;
    try
    {
      cout << "\tFirst build..." << endl;
      bCamera = new Camera_t();
      scoped_ptr<Camera_t> camera(new Camera_t());
      scoped_bCamera.reset(bCamera);
      cout << "\tThen attach..." << endl;
      if (devInfoOptions == 1)
      {
        bCamera->Attach(_TlFactory->CreateDevice(*it));
      }
      else
      {
        bCamera->Attach(_TlFactory->CreateDevice(devInfo));
      }
    }
    catch(exception& e)
    {
      cout << "\t\tFailed!\n\t" << e.what() << endl;
      exitCode = -3;
      goto exit;
    }
  }

  if (scoped_bCamera.get() == NULL)
  {
    cout << "\t* Camera object points to NULL" << endl;
    exitCode = -4;
    goto exit;
  }
  else if (not scoped_bCamera.get()->IsAttached())
  {
    cout << "\t* Camera object build but not attached to a Device object" \
         << endl;
    exitCode = -5;
    goto exit;
  }

  pDevice = scoped_bCamera.get()->GetDevice();
  if (!pDevice)
  {
    cout << "\tPylon Device points to NULL" << endl;
    exitCode = -6;
    goto exit;
  }

  cout << endl << "Play with the build objects" << endl;
  cout << "\t- Pylon device has " << pDevice->GetNumStreamGrabberChannels() \
       << " stream grabber channels" << endl;
  Camera_t::TlParams_t TlParams(scoped_bCamera->GetTLNodeMap());
  cout << "\t- TL read timeout:" << dec << TlParams.ReadTimeout.GetValue() \
       << endl;
  cout << "\t- TL write timeout:" << dec << TlParams.WriteTimeout.GetValue() \
       << endl;
  cout << "\t- TL heartbeat timeout:" << dec \
       << TlParams.HeartbeatTimeout.GetValue() << endl;

  cout << "\t- Open Pylon Device" << endl;
  pDevice->Open();
  if (not scoped_bCamera.get()->IsOpen())
  {
    cout << "\t* Open the Device object didn't show the Camera Object open" \
         << endl;
    exitCode = -7;
    goto exit;
  }

  cout << endl << "Information requested directly to the camera:" << endl;
  cout << "\t\t- Firmware version: " \
          << scoped_bCamera.get()->DeviceFirmwareVersion.GetValue() << endl;

//close: //TODO: label to be used in the checks after the communication is open.
  cout << "\tClose Pylon Device" << endl;
  pDevice->Close();
  cout << "\tDetele Pylon Device object" << endl;
  _TlFactory->DestroyDevice(pDevice);
  goto exit;//with exitCode = 0, that means "everything went well"!
}