コード例 #1
0
/* pnFileManifest */
const pl_wchar_t* pnFileManifest::read(const pl_wchar_t* src)
{
    size_t len = plwcslen(src);
    fFilename = plString(src, len);
    src += (len + 1);

    len = plwcslen(src);
    fDownloadName = plString(src, len);
    src += (len + 1);

    fHash.fromHex(plString(src).cstr());
    src += 33;

    fCompressedHash.fromHex(plString(src).cstr());
    src += 33;

    fFileSize = (src[0] << 16) | (src[1] & 0xFFFF);
    src += 3;

    fCompressedSize = (src[0] << 16) | (src[1] & 0xFFFF);
    src += 3;

    fFlags = (src[0] << 16) | (src[1] & 0xFFFF);
    src += 3;

    return src;
}
コード例 #2
0
ファイル: PlasmaSum.cpp プロジェクト: GPNMilano/libhsplasma
plString GetInternalName(const plString& filename) {
    // Different files are stored in different locations; this function
    // will try to guess where to put things based on the file's extension.
    // This is all based on the contents of .sum files included with the
    // games that I examined for this.

    plString split = s_oldFormat ? "/" : "\\";
    plString name = FixSlashes(filename).afterLast(PATHSEP);
    plString ext = name.afterLast('.');
    if (s_oldFormat && ext == "prp")
        return name;
    if (ext == "ogg" || ext == "wav")
        return plString("sfx") + split + name;
    if (ext == "exe" || ext == "dll" || ext == "map" || ext == "pdb")
        return name;
    if (ext == "sdl")
        return plString("SDL") + split + name;
    if (ext == "pak")
        return plString("Python") + split + name;
    if (ext == "fx")
        return plString("fx") + split + name;

    // dat is the default, since so many file types go there...
    // To name a few,
    // prp, age, fni, csv, sub, node, pfp, dat, tron, hex, tga, loc
    return plString("dat") + split + name;
}
コード例 #3
0
plString plServerGuid::toString() const {
    char buf[17];
    snprintf(buf, 17, "%02X%02X%02X%02X%02X%02X%02X%02X",
             fGuid[0], fGuid[1], fGuid[2], fGuid[3],
             fGuid[4], fGuid[5], fGuid[6], fGuid[7]);
    return plString(buf);
}
コード例 #4
0
ファイル: plKeyFinder.cpp プロジェクト: Asteral/Plasma
//
// Does name string compare with potentially mangled (ie. [1 0 0]foo) names
//
bool NameMatches(const char* obName, const char* pKName, bool subString)
{
    if (!obName || !pKName)
        return false;

    const char *o = obName;
    const char *p = pKName;

    // If names are mangled, unmangle
    if (*o != '[' || *p != '[')
    {
        // skip past ']' in both names in case mangled
        while (*o && *o != ']')
            o++;
        o = (*o==']') ? o+1 : obName;

        while (*p && *p != ']')
            p++;
        p = (*p==']') ? p+1 : pKName;
    }

    if (!subString)
    {
        if (!stricmp(o, p))
            return true;            // FOUND IT!!!!!!!!!!!!!!!!!!!
    }
    else
    {
        if (plString(p).Find(o, plString::kCaseInsensitive) >= 0)
            return true;
    }

    return false;
}
コード例 #5
0
ファイル: prp-fuse.cpp プロジェクト: GPNMilano/libhsplasma
static int prp_read(const char* path, char* buf, size_t size, off_t offset,
                    fuse_file_info* fi)
{
    if (strcmp(path, "/" PAGEINFO) == 0) {
        // TODO
        return -1;
    }

    plString ext = plString(path).afterLast('.');
    FileCache* fc = s_openfiles[fi->fh - 1];
    if (ext == "prc") {
        if (offset >= fc->prcsize)
            return 0;
        if (offset + size > fc->prcsize)
            size = fc->prcsize - offset;
        memcpy(buf, fc->prcdata + offset, size);
        return size;
    } else if (ext == "po") {
        if (offset >= fc->objsize)
            return 0;
        if (offset + size > fc->objsize)
            size = fc->objsize - offset;
        memcpy(buf, fc->objdata + offset, size);
        return size;
    } else {
        return -ENOENT;
    }
}
コード例 #6
0
ファイル: pnVaultNode.cpp プロジェクト: GPNMilano/libhsplasma
static plString readString(const unsigned char*& buffer, size_t& size) {
    size_t len = readU32(buffer, size);
    plString v = plString((pl_wchar_t*)buffer, (len-1) / sizeof(pl_wchar_t));
    buffer += len;
    size -= len;
    return v;
}
コード例 #7
0
ファイル: hsExceptions.cpp プロジェクト: boq/libhsplasma
/* hsBadParamException */
hsBadParamException::hsBadParamException(const char* file,
                     unsigned long line, const char* details) throw()
                   : hsException(file, line) {
    fWhat = "Bad parameter";
    if (details != NULL)
        fWhat += plString(": ") + details;
}
コード例 #8
0
ファイル: hsExceptions.cpp プロジェクト: boq/libhsplasma
/* hsNotImplementedException */
hsNotImplementedException::hsNotImplementedException(const char* file,
                           unsigned long line, const char* feature) throw()
                         : hsException(file, line) {
    if (feature == NULL)
        fWhat = "Not implemented";
    else
        fWhat = plString("`") + feature + "' not implemented";
}
コード例 #9
0
ファイル: hsBitVector.cpp プロジェクト: dpogue/libhsplasma
unsigned int hsBitVector::getValue(const char* name) {
    std::map<unsigned int, char*>::iterator i;
    for (i = fBitNames.begin(); i != fBitNames.end(); i++) {
        if (strcmp(i->second, name) == 0)
            return i->first;
    }
    return (unsigned int)plString(name).toUint();
}
コード例 #10
0
ファイル: winmain.cpp プロジェクト: Asteral/Plasma
static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
{
    uint32_t cryptKey[4];
    memset(cryptKey, 0, sizeof(cryptKey));
    GetCryptKey(cryptKey, arrsize(cryptKey));

    plString theUser = pLoginParam->username;
    plString thePass = plString(password).Left(kMaxPasswordLength);

    // if the password field is the fake string then we've already
    // loaded the namePassHash from the file
    if (thePass.Compare(FAKE_PASS_STRING) != 0)
    {
        // Regex search for primary email domain
        std::vector<plString> match = theUser.RESearch("[^@]+@([^.]+\\.)*([^.]+)\\.[^.]+");

        if (match.empty() || match[2].CompareI("gametap") == 0) {
            plSHA1Checksum shasum(StrLen(password) * sizeof(password[0]), (uint8_t*)password);
            uint32_t* dest = reinterpret_cast<uint32_t*>(pLoginParam->namePassHash);
            const uint32_t* from = reinterpret_cast<const uint32_t*>(shasum.GetValue());

            // I blame eap for this ass shit
            dest[0] = hsToBE32(from[0]);
            dest[1] = hsToBE32(from[1]);
            dest[2] = hsToBE32(from[2]);
            dest[3] = hsToBE32(from[3]);
            dest[4] = hsToBE32(from[4]);
        }
        else
        {
            CryptHashPassword(theUser, thePass, pLoginParam->namePassHash);
        }
    }

    NetCommSetAccountUsernamePassword(theUser.ToWchar(), pLoginParam->namePassHash);

    // FIXME: Real OS detection
    NetCommSetAuthTokenAndOS(nil, L"win");

    plFileName loginDat = plFileName::Join(plFileSystem::GetInitPath(), "login.dat");
#ifndef PLASMA_EXTERNAL_RELEASE
    // internal builds can use the local init directory
    plFileName local("init\\login.dat");
    if (plFileInfo(local).Exists())
        loginDat = local;
#endif
    hsStream* stream = plEncryptedStream::OpenEncryptedFileWrite(loginDat, cryptKey);
    if (stream)
    {
        stream->Write(sizeof(cryptKey), cryptKey);
        stream->WriteSafeString(pLoginParam->username);
        stream->WriteBool(pLoginParam->remember);
        if (pLoginParam->remember)
            stream->Write(sizeof(pLoginParam->namePassHash), pLoginParam->namePassHash);
        stream->Close();
        delete stream;
    }
}
コード例 #11
0
void pfGUITextBoxMod::read(hsStream* S, plResManager* mgr) {
    pfGUIControlMod::read(S, mgr);

    int len = S->readInt();
    fText = S->readStr(len);

    if ((!S->getVer().isUruSP() || S->getVer().isUniversal())
            && S->readBool())
        fLocalizationPath = S->readSafeWStr();
    else
        fLocalizationPath = plString();
}
コード例 #12
0
ファイル: plFileSystem.cpp プロジェクト: Filtik/Plasma
plFileName plFileName::Normalize(char slash) const
{
    plStringBuffer<char> norm;
    char *norm_p = norm.CreateWritableBuffer(fName.GetSize());
    for (const char *p = fName.c_str(); *p; ++p) {
        if (*p == '/' || *p == '\\')
            *norm_p++ = slash;
        else
            *norm_p++ = *p;
    }
    *norm_p = 0;
    return plString(norm);
}
コード例 #13
0
ファイル: PlasmaSum.cpp プロジェクト: GPNMilano/libhsplasma
plString FixSlashes(const plString& src) {
    if (src.empty())
        return plString();

    char* pbuf = strdup(src);
    for (char* pc = pbuf; *pc != 0; pc++) {
        if (*pc == '/' || *pc == '\\')
            *pc = PATHSEP;
    }
    plString dest(pbuf);
    free(pbuf);
    return dest;
}
コード例 #14
0
static void GetFileList(pnAuthFileItem* files, uint32_t infoSize,
                        const pl_wchar_t* infoBuffer)
{
    pnAuthFileItem* cur = files;
    while (((int)infoSize) > 0 && *infoBuffer != 0) {
        size_t fnLen = plwcslen(infoBuffer);
        cur->fFilename = plString(infoBuffer, fnLen);
        infoBuffer += fnLen + 1;
        infoSize -= fnLen + 1;

        cur->fFileSize = (infoBuffer[0] << 16) | (infoBuffer[1] & 0xFFFF);
        infoBuffer += 3;
        infoSize -= 3;
        cur++;
    }
}
コード例 #15
0
ファイル: plLayerMovie.cpp プロジェクト: GPNMilano/Plasma
void plLayerMovie::Read(hsStream* s, hsResMgr* mgr)
{
    plLayerAnimation::Read(s, mgr);

    int len = s->ReadLE32();
    if( len )
    {
        plStringBuffer<char> movieName;
        char *buf = movieName.CreateWritableBuffer(len);
        s->Read(len, buf);
        buf[len] = 0;
        fMovieName = plString(movieName);
    }
    else
    {
        hsAssert(false, "Reading empty string for movie name");
        fMovieName = "";
    }
}
コード例 #16
0
ファイル: prp-fuse.cpp プロジェクト: GPNMilano/libhsplasma
static int prp_readdir(const char* path, void* buf, fuse_fill_dir_t filler,
                       off_t offset, fuse_file_info* fi)
{
    if (strcmp(path, "/") == 0) {
        // PRP Root:
        filler(buf, ".", NULL, 0);
        filler(buf, "..", NULL, 0);
        filler(buf, PAGEINFO, NULL, 0);

        // PRP Types:
        for (CLASSLIST::iterator it = CLASSES.begin(); it != CLASSES.end(); it++)
            filler(buf, it->clsName, NULL, 0);
        return 0;
    } else {
        // Type directory
        plString typeStr = plString(path + 1);
        if (typeStr.empty())
            return -ENOENT;
        short type = plFactory::ClassIndex(typeStr);
        if (type < 0)
            return -ENOENT;

        // Make sure the type is actually present
        bool hasType = false;
        for (CLASSLIST::iterator it = CLASSES.begin(); it != CLASSES.end() && !hasType; it++) {
            if (it->clsIdx == type)
                hasType = true;
        }
        if (!hasType)
            return -ENOENT;

        filler(buf, ".", NULL, 0);
        filler(buf, "..", NULL, 0);
        std::vector<plKey> keys = RESMGR.getKeys(PAGE->getLocation(), type);
        for (std::vector<plKey>::iterator it = keys.begin(); it != keys.end(); it++) {
            filler(buf, CleanFileName((*it)->getName() + ".po"), NULL, 0);
            filler(buf, CleanFileName((*it)->getName() + ".prc"), NULL, 0);
        }
        return 0;
    }
}
コード例 #17
0
ファイル: winmain.cpp プロジェクト: Drakesinger/Plasma
BOOL CALLBACK UruTOSDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    switch( uMsg )
    {
    case WM_INITDIALOG:
        {
            SetWindowText(hwndDlg, "End User License Agreement");
            SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon((HINSTANCE)lParam, MAKEINTRESOURCE(IDI_ICON_DIRT)));

            hsUNIXStream stream;
            if (stream.Open("TOS.txt", "rt"))
            {
                uint32_t dataLen = stream.GetSizeLeft();
                plStringBuffer<char> eula;
                char* eulaData = eula.CreateWritableBuffer(dataLen);
                memset(eulaData, 0, dataLen + 1);
                stream.Read(dataLen, eulaData);

                SetDlgItemTextW(hwndDlg, IDC_URULOGIN_EULATEXT, plString(eula).ToWchar());
            }
            else // no TOS found, go ahead
                EndDialog(hwndDlg, true);

            break;
        }
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL))
        {
            bool ok = (LOWORD(wParam) == IDOK);
            EndDialog(hwndDlg, ok);
            return TRUE;
        }
        break;

    case WM_NCHITTEST:
        SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, (LONG_PTR)HTCAPTION);
        return TRUE;
    }
    return FALSE;
}
コード例 #18
0
ファイル: PrcExtract.cpp プロジェクト: GPNMilano/libhsplasma
int main(int argc, char** argv) {
    if (argc < 2) {
        doHelp();
        return 0;
    }

    std::vector<plString> fFiles;

    plDebug::Init(plDebug::kDLAll);
    plResManager rm;
    plPageInfo* page;
    plString outDir, outFile;
    bool exVtx = true, exTex = true, noHdr = false;
    for (int i=1; i<argc; i++) {
        if (argv[i][0] == '-') {
            if (argv[i][1] == '-') argv[i]++;
            if (strcmp(argv[i], "-help") == 0) {
                doHelp();
                return 0;
            } else if (strcmp(argv[i], "-vtx") == 0) {
                exVtx = false;
                fprintf(stderr, "Warning: Including Vertex data\n");
            } else if (strcmp(argv[i], "-tex") == 0) {
                exTex = false;
                fprintf(stderr, "Note: Texture data unsupported. -tex will "
                                "be ignored for this export\n");
            } else if (strcmp(argv[i], "-nohdr") == 0) {
                noHdr = true;
            } else {
                fprintf(stderr, "Error: Unrecognized option %s\n", argv[i]);
                return 1;
            }
        } else {
            fFiles.push_back(plString(argv[i]));
        }
    }

    for (size_t i=0; i<fFiles.size(); i++) {
        try {
            page = rm.ReadPage(fFiles[i]);
        } catch (hsException& e) {
            fprintf(stderr, "%s:%lu: %s\n", e.File(), e.Line(), e.what());
            return 1;
        } catch (std::exception& e) {
            fprintf(stderr, "PrcExtract Exception: %s\n", e.what());
            return 1;
        } catch (...) {
            fprintf(stderr, "Undefined error!\n");
            return 1;
        }
        outDir = getOutputDir(fFiles[i], page);
        outFile = outDir + filenameConvert(fFiles[i]);
      #ifdef WIN32
        CreateDirectory(outDir.cstr(), NULL);
      #else
        mkdir(outDir.cstr(), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
      #endif

        printf("Writing %s\n", outFile.cstr());
        hsFileStream* S = new hsFileStream();
        if (!S->open(outFile, fmWrite)) {
            fprintf(stderr, "Error opening %s for writing!\n", outFile.cstr());
            delete S;
            return 1;
        }
        S->setVer(rm.getVer());
        pfPrcHelper* prc = new pfPrcHelper(S);
        if (exVtx) prc->exclude(pfPrcHelper::kExcludeVertexData);
        if (exTex) prc->exclude(pfPrcHelper::kExcludeTextureData);
        if (!noHdr) {
            prc->writeComment("Generator: PrcExtract");
            prc->writeComment(plString("Source: ") + fFiles[i]);
            time_t ts = time(NULL);
            char buf[256];
            strftime(buf, 256, "Created: %Y/%m/%d %H:%M:%S", localtime(&ts));
            prc->writeComment(buf);
            S->writeStr("\n");
        }
        try {
            rm.WritePagePrc(prc, page);
        } catch (hsException& e) {
            fprintf(stderr, "%s:%lu: %s\n", e.File(), e.Line(), e.what());
            return 1;
        } catch (std::exception& e) {
            fprintf(stderr, "PrcExtract Exception: %s\n", e.what());
            return 1;
        } catch (...) {
            fprintf(stderr, "Undefined error!\n");
            return 1;
        }

        delete prc;
        S->close();
        delete S;
    }

    return 0;
}
コード例 #19
0
ファイル: pnVaultNode.cpp プロジェクト: GPNMilano/libhsplasma
plString pnVaultNode::getCreateAgeName() const
{
    return (fFieldMask & (1<<kCreateAgeName)) != 0
           ? fCreateAgeName : plString();
}
コード例 #20
0
ファイル: prp-fuse.cpp プロジェクト: GPNMilano/libhsplasma
static int prp_open(const char* path, fuse_file_info* fi)
{
    // Check if this is the special PageInfo file
    if (strcmp(path, "/" PAGEINFO) == 0) {
        fi->fh = 0;
        return 0;
    }

    // Get the type
    plString typeStr = plString(path + 1).beforeFirst('/');
    if (typeStr.empty())
        return -ENOENT;
    short type = plFactory::ClassIndex(typeStr);
    if (type < 0)
        return -ENOENT;

    // Make sure the object is actually present (O_CREAT is already handled)
    plString oname = plString(path + 1).afterFirst('/').beforeLast('.');
    plKey myKey;
    std::vector<plKey> keys = RESMGR.getKeys(PAGE->getLocation(), type);
    for (std::vector<plKey>::iterator it = keys.begin(); it != keys.end(); it++) {
        if ((*it)->getName() == oname)
            myKey = *it;
    }
    if (!myKey.Exists())
        return -ENOENT;

    // Look for an already-open object:
    for (FILELIST::iterator it = s_openfiles.begin(); it != s_openfiles.end(); it++) {
        if ((*it)->key == myKey) {
            if ((fi->flags & (O_RDWR | O_WRONLY)) != 0)
                return -EACCES;
            (*it)->ref();
            fi->fh = (*it)->fh;
            return 0;
        }
    }

    // First time to open:
    FileCache* fc = new FileCache();
    fc->key = myKey;

    // Cache the object raw data
    {
        hsRAMStream RS(RESMGR.getVer());
        myKey->getObj()->write(&RS, &RESMGR);
        fc->objsize = RS.size();
        fc->objdata = new unsigned char[fc->objsize];
        RS.copyTo(fc->objdata, fc->objsize);
    }

    // Cache the PRC data
    {
        hsRAMStream RS(RESMGR.getVer());
        pfPrcHelper prc(&RS);
        myKey->getObj()->prcWrite(&prc);
        fc->prcsize = RS.size();
        fc->prcdata = new unsigned char[fc->prcsize];
        RS.copyTo(fc->prcdata, fc->prcsize);
    }
    return 0;
}
コード例 #21
0
ファイル: prp-fuse.cpp プロジェクト: GPNMilano/libhsplasma
static int prp_getattr(const char* path, struct stat* stbuf)
{
    memset(stbuf, 0, sizeof(struct stat));
    if (strcmp(path, "/") == 0) {
        stbuf->st_mode = S_IFDIR | 0555;
        stbuf->st_nlink = 2 + CLASSES.size();
        stbuf->st_uid = s_uid;
        stbuf->st_gid = s_gid;
        stbuf->st_atime = s_fatime;
        stbuf->st_mtime = s_fmtime;
        stbuf->st_ctime = s_fctime;
    } else if (strcmp(path, "/" PAGEINFO) == 0) {
        stbuf->st_mode = S_IFREG | 0444;
        stbuf->st_nlink = 1;
        stbuf->st_uid = s_uid;
        stbuf->st_gid = s_gid;
        stbuf->st_size = 0;
        stbuf->st_atime = s_fatime;
        stbuf->st_mtime = s_fmtime;
        stbuf->st_ctime = s_fctime;
    } else {
        // Find the type first
        plString typeStr = plString(path + 1).beforeFirst('/');
        if (typeStr.empty())
            return -ENOENT;
        short type = plFactory::ClassIndex(typeStr);
        if (type < 0)
            return -ENOENT;

        // Make sure the type is actually present
        bool hasType = false;
        for (CLASSLIST::iterator it = CLASSES.begin(); it != CLASSES.end() && !hasType; it++) {
            if (it->clsIdx == type)
                hasType = true;
        }
        if (!hasType)
            return -ENOENT;

        plString fname = plString(path + 1).afterFirst('/');
        if (fname.empty()) {
            // Directory
            stbuf->st_mode = S_IFDIR | 0555;
            stbuf->st_nlink = 2 + RESMGR.getKeys(PAGE->getLocation(), type).size();
            stbuf->st_uid = s_uid;
            stbuf->st_gid = s_gid;
            stbuf->st_atime = s_fatime;
            stbuf->st_mtime = s_fmtime;
            stbuf->st_ctime = s_fctime;
        } else {
            // File
            plString ftype = fname.afterLast('.');
            fname = fname.beforeLast('.');
            std::vector<plKey> keys = RESMGR.getKeys(PAGE->getLocation(), type);
            for (std::vector<plKey>::iterator it = keys.begin(); it != keys.end(); it++) {
                if (CleanFileName((*it)->getName()) == fname) {
                    stbuf->st_mode = S_IFREG | 0444;
                    stbuf->st_nlink = 1;
                    stbuf->st_uid = s_uid;
                    stbuf->st_gid = s_gid;
                    stbuf->st_size = (ftype == "po") ? (*it)->getObjSize() : 0;
                    stbuf->st_atime = s_fatime;
                    stbuf->st_mtime = s_fmtime;
                    stbuf->st_ctime = s_fctime;
                    return 0;
                }
            }
            return -ENOENT;
        }
    }
    return 0;
}
コード例 #22
0
ファイル: prcdc.cpp プロジェクト: boq/libhsplasma
int main(int argc, char** argv) {
    plString inputFile, outputFile;
    bool exVtx = false, exTex = false;
    PlasmaVer inVer = PlasmaVer::pvUnknown;
    plString objName;
    short objType = -1;

    if (argc == 1) {
        doHelp(argv[0]);
        return 0;
    }

    for (int i=1; i<argc; i++) {
        if (strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "--out") == 0) {
            if (++i >= argc) {
                fprintf(stderr, "Error: expected filename\n");
                return 1;
            }
            outputFile = argv[i];
        } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--ver") == 0) {
            if (++i >= argc) {
                fprintf(stderr, "Error: expected version specifier\n");
                return 1;
            }
            plString ver = plString(argv[i]).toLower();
            if (ver == "prime")
                inVer = PlasmaVer::pvPrime;
            else if (ver == "pots")
                inVer = PlasmaVer::pvPots;
            else if (ver == "moul")
                inVer = PlasmaVer::pvMoul;
            else if (ver == "eoa")
                inVer = PlasmaVer::pvEoa;
            else if (ver == "hex")
                inVer = PlasmaVer::pvHex;
            else if (ver == "universal")
                inVer = PlasmaVer::pvUniversal;
            else {
                fprintf(stderr, "Error: unrecognized version: %s\n", ver.cstr());
                return 1;
            }
        } else if (strcmp(argv[i], "-x") == 0 || strcmp(argv[i], "--extract") == 0) {
            if (++i >= argc) {
                fprintf(stderr, "Error: expected object specifier");
                return 1;
            }
            plString objSpec = argv[i];
            plString type = objSpec.beforeFirst(':');
            objType = plFactory::ClassIndex(type);
            if (objType == -1)
                objType = type.toInt();
            objName = objSpec.afterLast(':');
            if (objName.startsWith("\"")) {
                do {
                    if (++i >= argc) {
                        fprintf(stderr, "Error: Unterminated string");
                        return 1;
                    }
                    objName += plString(" ") + argv[i];
                } while (!objName.endsWith("\""));
                objName = objName.mid(1, objName.len() - 2);
            }
        } else if (strcmp(argv[i], "--notex") == 0) {
            exTex = true;
            fprintf(stderr, "Warning: omitting texture data; output files wil be incomplete\n");
        } else if (strcmp(argv[i], "--novtx") == 0) {
            exVtx = true;
            fprintf(stderr, "Warning: omitting vertex data; output files wil be incomplete\n");
        } else if (strcmp(argv[i], "-?") == 0 || strcmp(argv[i], "--help") == 0) {
            doHelp(argv[0]);
            return 0;
        } else if (argv[i][0] == '-') {
            fprintf(stderr, "Warning: unrecognized option %s\n", argv[i]);
        } else {
            if (inputFile.empty())
                inputFile = argv[i];
            else
                fprintf(stderr, "Warning: ignoring extra parameter %s\n", argv[i]);
        }
    }
    if (outputFile.empty())
        outputFile = "out.prc";
    if (!inVer.isValid() && inputFile.afterLast('.') != "prp" && inputFile.afterLast('.') != "age") {
        fprintf(stderr, "Error: Plasma version must be specified for object decompilation\n");
        return 1;
    }

    plDebug::Init(plDebug::kDLAll);
    plResManager rm;
    rm.setVer(inVer, true);

    hsFileStream out;
    out.open(outputFile, fmCreate);
    pfPrcHelper prc(&out);
    if (exTex) prc.exclude(pfPrcHelper::kExcludeTextureData);
    if (exVtx) prc.exclude(pfPrcHelper::kExcludeVertexData);

    try {
        if (inputFile.afterLast('.') == "prp") {
            plPageInfo* page = rm.ReadPage(inputFile);
            if (objType == -1) {
                rm.WritePagePrc(&prc, page);
            } else {
                std::vector<plKey> keys = rm.getKeys(page->getLocation(), objType);
                bool found = false;
                for (std::vector<plKey>::iterator it = keys.begin(); it != keys.end(); it++) {
                    if ((*it)->getName() == objName && (*it)->getObj() != NULL) {
                        (*it)->getObj()->prcWrite(&prc);
                        found = true;
                        break;
                    }
                }
                if (!found)
                    fprintf(stderr, "Object %s:%s does not exist\n",
                                    plFactory::ClassName(objType),
                                    objName.cstr());
            }
        } else if (inputFile.afterLast('.') == "age") {
            plAgeInfo* age = rm.ReadAge(inputFile, false);
            rm.WriteAgePrc(&prc, age);
        } else {
            hsFileStream in;
            if (!in.open(inputFile, fmRead)) {
                fprintf(stderr, "Error opening input file\n");
                return 1;
            }
            in.setVer(inVer);
            plCreatable* cre = rm.ReadCreatable(&in);
            cre->prcWrite(&prc);
        }
    } catch (hsException& e) {
        fprintf(stderr, "%s:%lu: %s\n", e.File(), e.Line(), e.what());
        return 1;
    } catch (std::exception& e) {
        fprintf(stderr, "Caught Exception: %s\n", e.what());
        return 1;
    }

    printf("Successfully decompiled %s!\n", inputFile.cstr());

    return 0;
}
コード例 #23
0
ファイル: qtSDLTreeModel.cpp プロジェクト: zrax/MoulKI
bool qtSDLTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) {
    if(role != Qt::EditRole || value.type() != QVariant::String || index.column() != 0)
        return false;
    QString* strVal = (QString*)value.data();
    SDLModelIndex myIndex = indices[index.internalId()];
    if(myIndex.type != kVal)
        return false;
    plSimpleStateVariable* var = (plSimpleStateVariable*)myIndex.ptr.sv;
    switch(var->getDescriptor()->getType()) {
    case plVarDescriptor::kBool:
        if(*strVal == "True")
            var->Bool(index.row()) = true;
        else if(*strVal == "False")
            var->Bool(index.row()) = false;
        else
            return false;
        break;
    case plVarDescriptor::kInt:
    {
        bool result;
        int value = strVal->toInt(&result);
        if(result)
            var->Int(index.row()) = value;
        else
            return false;
        break;
    }
    case plVarDescriptor::kByte:
    {
        bool result;
        int value = strVal->toInt(&result);
        if(result && value >= 0 && value < 256)
            var->Byte(index.row()) = (unsigned char)value;
        else
            return false;
        break;
    }
    case plVarDescriptor::kChar:
    {
        char* str = strVal->toLocal8Bit().data();
        if(strlen(str) == 1)
            var->Char(index.row()) = str[0];
        else
            return false;
        break;
     }
    case plVarDescriptor::kFloat:
    {
        bool result;
        float value = strVal->toFloat(&result);
        if(result)
            var->Float(index.row()) = value;
        else
            return false;
        break;
    }
    case plVarDescriptor::kDouble:
    {
        bool result;
        double value = strVal->toDouble(&result);
        if(result)
            var->Double(index.row()) = value;
        else
            return false;
        break;
    }
    case plVarDescriptor::kString:
        var->String(index.row()) = plString(strVal->toLocal8Bit().data());
        break;
    default:
        return false;
    }
    emit sdlChanged(sdl);
    return true;
}
コード例 #24
0
ファイル: pnVaultNode.cpp プロジェクト: GPNMilano/libhsplasma
plString pnVaultNode::getIString64(size_t which) const
{
    return (fFieldMask & (uint64_t)((1<<kIString64_1) << which)) != 0
           ? fIString64[which] : plString();
}
コード例 #25
0
ファイル: pnVaultNode.cpp プロジェクト: GPNMilano/libhsplasma
plString pnVaultNode::getText(size_t which) const
{
    return (fFieldMask & (uint64_t)((1<<kText_1) << which)) != 0
           ? fText[which] : plString();
}
コード例 #26
0
ファイル: Prp2Obj.cpp プロジェクト: boq/libhsplasma
plString filenameConvert(const char* filename, const char* ext) {
    plString basename = plString(filename).beforeFirst('.');
    return basename + ext;
}
コード例 #27
0
ファイル: MoulKI.cpp プロジェクト: Lunanne/MoulKI
    }
}

void MoulKI::closeEvent(QCloseEvent*) {
    // log the player out when the window is closed
    if(gameClient != NULL) {
        logoutActivePlayer();
    }
}

void MoulKI::logoutActivePlayer() {
    foreach(qtVaultNode* child, vault.getNode(activePlayer)->getChildren()) {
        if(child->getNodeType() == plVault::kNodePlayerInfo) {
            child->setInt32(0, 0);
            child->setUuid(0, plUuid());
            child->setString64(0, plString());
            if(authClient->isConnected()) {
                authClient->sendVaultNodeSave(child->getNodeIdx(), plUuid(), *child);
            }
        }
    }
}

void MoulKI::showLoginDialog() {
    LoginDialog* dialog = new LoginDialog(this);
    connect(dialog, SIGNAL(login(QString,QString,QString)), this, SLOT(login(QString,QString,QString)));
    dialog->exec();
    delete dialog;
}

void MoulKI::login(QString user, QString pass, QString iniFilename) {
コード例 #28
0
ファイル: plSDLParser.cpp プロジェクト: branan/Plasma
//
// Parse a variable descriptor.
// read type, name, count [default]
// return true to skip the next token read
//
bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc, 
                                plVarDescriptor*& curVar) const
{
    hsAssert(curDesc, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
    if ( !curDesc )
        return false;

    bool skipNext=false;
    plString dbgStr;
    static char seps[] = "( ,)[]";
    // read type, name, cnt, [default]
    
    //
    // TYPE
    // create new state var, make current
    //
    if (*token == '$')
    {
        // nested sdls
        char* sdlName = token+1;
        plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion);
        hsAssert(stateDesc, plString::Format("can't find nested state desc reference %s, fileName=%s",
                sdlName, fileName).c_str());
        curVar = new plSDVarDescriptor(stateDesc);
    }
    else
        curVar = new plSimpleVarDescriptor;
    
    curDesc->AddVar(curVar);
    bool ok=curVar->SetType(token);
    hsAssert(ok, plString::Format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str());
    dbgStr = plString::Format("\tVAR Type=%s ", token);
    
    //
    // NAME (foo[1])
    //          
    if (stream->GetToken(token, kTokenLen))
    {
        hsAssert(strstr(token, "[") && strstr(token, "]"), plString::Format("invalid var syntax, missing [x], fileName=%s",
                fileName).c_str());
        char* ptr = strtok( token, seps );  // skip [
        
        hsAssert(curVar, plString::Format("Missing current var.  Syntax problem with .sdl file, fileName=%s", fileName).c_str());
        curVar->SetName(token);
        //
        // COUNT
        //
        char* cntTok=strtok(nil, seps);     // kill ]
        int cnt = cntTok ? atoi(cntTok) : 0;
        curVar->SetCount(cnt);
        if (cnt==0)
            curVar->SetVariableLength(true);
        dbgStr += plString::Format("Name=%s[%d]", curVar->GetName().c_str(), cnt);
    }
    
    //
    // optional tokens: DEFAULT, INTERNAL
    //
    while (stream->GetToken(token, kTokenLen))
    {
        if (!strcmp(token, "DEFAULT"))
        {
            hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
            // read state var type
            
            plString defaultStr;
            plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar;
            if (sVar)
            {
                int i;
                for(i=0;i<sVar->GetAtomicCount();i++)
                {
                    if (stream->GetToken(token, kTokenLen))
                    {
                        defaultStr += token;
                        if (i!=sVar->GetAtomicCount()-1)
                            defaultStr += ",";
                    }
                }
            }
            if (!defaultStr.IsEmpty())
            {
                curVar->SetDefault(defaultStr);
                dbgStr += " DEFAULT=" + defaultStr;
            }
        }
        else
        if (!strcmp(token, "DISPLAYOPTION"))
        {
            hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
            dbgStr += plString(" ") + token;

            bool read=stream->GetToken(token, kTokenLen);
            if (read)
            {
                plString oldOptions=curVar->GetDisplayOptions();
                if (!oldOptions.IsEmpty())
                    oldOptions += ",";
                oldOptions += token;
                curVar->SetDisplayOptions(oldOptions);
                dbgStr += plString("=") + token;
                if (!stricmp(token, "hidden"))
                    curVar->SetInternal(true);
            }
            else
            {
                hsAssert(false, plString::Format("missing displayOption string, fileName=%s", fileName).c_str());
            }
        }
        else
        if (!strcmp(token, "DEFAULTOPTION"))
        {
            hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
            dbgStr += plString(" ") + token;

            bool read=stream->GetToken(token, kTokenLen);
            if (read)
            {
                dbgStr += plString("=") + token;
                if (!stricmp(token, "vault"))
                    curVar->SetAlwaysNew(true);
            }
            else
            {
                hsAssert(false, plString::Format("missing defaultOption string, fileName=%s", fileName).c_str());
            }
        }

#if 1   // delete me in May 2003
        else
        if (!strcmp(token, "INTERNAL"))
        {
            hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
            curVar->SetInternal(true);
            dbgStr += plString(" ") + token;
        }
        else
        if (!strcmp(token, "PHASED"))
        {
            hsAssert(curVar, plString::Format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
            curVar->SetAlwaysNew(true);
            dbgStr += plString(" ") + token;
        }
#endif
        else
        {
            skipNext=true;
            break;
        }
    }

    DebugMsg((char*)dbgStr.c_str());

    return skipNext;
}