From 1145f8aa2ecc4f9d497912bac276edf6c6944b21 Mon Sep 17 00:00:00 2001 From: Hazim Gazov Date: Sat, 26 Jun 2010 17:27:48 +0000 Subject: [PATCH] fix a couple of things for the vfs explorer --- indra/llvfs/llvfs.cpp | 230 ++++++++---------- indra/llvfs/llvfs.h | 47 +++- indra/newview/dofloaterhex.cpp | 10 +- indra/newview/dofloaterhex.h | 2 +- indra/newview/llfloatervfsexplorer.cpp | 9 +- .../xui/en-us/floater_vfs_explorer.xml | 1 + 6 files changed, 163 insertions(+), 136 deletions(-) diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp index 99f338742..9ce3e4b2f 100644 --- a/indra/llvfs/llvfs.cpp +++ b/indra/llvfs/llvfs.cpp @@ -55,32 +55,25 @@ const S32 BLOCK_LENGTH_INVALID = -1; // mLength for invalid LLVFSFileBlocks LLVFS *gVFS = NULL; // internal class definitions -class LLVFSBlock -{ -public: - LLVFSBlock() - { - mLocation = 0; - mLength = 0; - } - - LLVFSBlock(U32 loc, S32 size) - { - mLocation = loc; - mLength = size; - } - - static bool locationSortPredicate( - const LLVFSBlock* lhs, - const LLVFSBlock* rhs) - { - return lhs->mLocation < rhs->mLocation; - } -public: - U32 mLocation; - S32 mLength; // allocated block size -}; +LLVFSBlock::LLVFSBlock() +{ + mLocation = 0; + mLength = 0; +} + +LLVFSBlock::LLVFSBlock(U32 loc, S32 size) +{ + mLocation = loc; + mLength = size; +} + +bool LLVFSBlock::locationSortPredicate( + const LLVFSBlock* lhs, + const LLVFSBlock* rhs) +{ + return lhs->mLocation < rhs->mLocation; +} LLVFSFileSpecifier::LLVFSFileSpecifier() : mFileID(), @@ -108,117 +101,106 @@ bool LLVFSFileSpecifier::operator==(const LLVFSFileSpecifier &rhs) const } -class LLVFSFileBlock : public LLVFSBlock, public LLVFSFileSpecifier + +LLVFSFileBlock::LLVFSFileBlock() : LLVFSBlock(), LLVFSFileSpecifier() { -public: - LLVFSFileBlock() : LLVFSBlock(), LLVFSFileSpecifier() - { - init(); - } - - LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc = 0, S32 size = 0) - : LLVFSBlock(loc, size), LLVFSFileSpecifier( file_id, file_type ) - { - init(); - } + init(); +} - void init() - { - mSize = 0; - mIndexLocation = -1; - mAccessTime = (U32)time(NULL); +LLVFSFileBlock::LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc, S32 size) : + LLVFSBlock(loc, size), LLVFSFileSpecifier( file_id, file_type ) +{ + init(); +} - for (S32 i = 0; i < (S32)VFSLOCK_COUNT; i++) - { - mLocks[(EVFSLock)i] = 0; - } - } +void LLVFSFileBlock::init() +{ + mSize = 0; + mIndexLocation = -1; + mAccessTime = (U32)time(NULL); - #ifdef LL_LITTLE_ENDIAN - inline void swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */} + for (S32 i = 0; i < (S32)VFSLOCK_COUNT; i++) + { + mLocks[(EVFSLock)i] = 0; + } +} - #else - - inline U32 swizzle32(U32 x) - { - return(((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) |((x << 24) & 0xFF000000)); - } - - inline U16 swizzle16(U16 x) - { - return( ((x >> 8) & 0x000000FF) | ((x << 8) & 0x0000FF00) ); - } - - inline void swizzleCopy(void *dst, void *src, int size) - { - if(size == 4) - { - ((U32*)dst)[0] = swizzle32(((U32*)src)[0]); - } - else if(size == 2) - { - ((U16*)dst)[0] = swizzle16(((U16*)src)[0]); - } - else - { - // Perhaps this should assert... - memcpy(dst, src, size); /* Flawfinder: ignore */ - } - } - - #endif +#ifdef LL_LITTLE_ENDIAN +void LLVFSFileBlock::swizzleCopy(void *dst, void *src, int size) { memcpy(dst, src, size); /* Flawfinder: ignore */} - void serialize(U8 *buffer) +#else + +U32 LLVFSFileBlock::swizzle32(U32 x) +{ + return(((x >> 24) & 0x000000FF) | ((x >> 8) & 0x0000FF00) | ((x << 8) & 0x00FF0000) |((x << 24) & 0xFF000000)); +} + +U16 LLVFSFileBlock::swizzle16(U16 x) +{ + return( ((x >> 8) & 0x000000FF) | ((x << 8) & 0x0000FF00) ); +} + +void LLVFSFileBlock::swizzleCopy(void *dst, void *src, int size) +{ + if(size == 4) { - swizzleCopy(buffer, &mLocation, 4); - buffer += 4; - swizzleCopy(buffer, &mLength, 4); - buffer +=4; - swizzleCopy(buffer, &mAccessTime, 4); - buffer +=4; - memcpy(buffer, &mFileID.mData, 16); /* Flawfinder: ignore */ - buffer += 16; - S16 temp_type = mFileType; - swizzleCopy(buffer, &temp_type, 2); - buffer += 2; - swizzleCopy(buffer, &mSize, 4); + ((U32*)dst)[0] = swizzle32(((U32*)src)[0]); } - - void deserialize(U8 *buffer, const S32 index_loc) + else if(size == 2) { - mIndexLocation = index_loc; - - swizzleCopy(&mLocation, buffer, 4); - buffer += 4; - swizzleCopy(&mLength, buffer, 4); - buffer += 4; - swizzleCopy(&mAccessTime, buffer, 4); - buffer += 4; - memcpy(&mFileID.mData, buffer, 16); - buffer += 16; - S16 temp_type; - swizzleCopy(&temp_type, buffer, 2); - mFileType = (LLAssetType::EType)temp_type; - buffer += 2; - swizzleCopy(&mSize, buffer, 4); + ((U16*)dst)[0] = swizzle16(((U16*)src)[0]); } - - static BOOL insertLRU(LLVFSFileBlock* const& first, - LLVFSFileBlock* const& second) + else { - return (first->mAccessTime == second->mAccessTime) - ? *first < *second - : first->mAccessTime < second->mAccessTime; + // Perhaps this should assert... + memcpy(dst, src, size); /* Flawfinder: ignore */ } - -public: - S32 mSize; - S32 mIndexLocation; // location of index entry - U32 mAccessTime; - BOOL mLocks[VFSLOCK_COUNT]; // number of outstanding locks of each type - - static const S32 SERIAL_SIZE; -}; +} + +#endif + +void LLVFSFileBlock::serialize(U8 *buffer) +{ + swizzleCopy(buffer, &mLocation, 4); + buffer += 4; + swizzleCopy(buffer, &mLength, 4); + buffer +=4; + swizzleCopy(buffer, &mAccessTime, 4); + buffer +=4; + memcpy(buffer, &mFileID.mData, 16); /* Flawfinder: ignore */ + buffer += 16; + S16 temp_type = mFileType; + swizzleCopy(buffer, &temp_type, 2); + buffer += 2; + swizzleCopy(buffer, &mSize, 4); +} + +void LLVFSFileBlock::deserialize(U8 *buffer, const S32 index_loc) +{ + mIndexLocation = index_loc; + + swizzleCopy(&mLocation, buffer, 4); + buffer += 4; + swizzleCopy(&mLength, buffer, 4); + buffer += 4; + swizzleCopy(&mAccessTime, buffer, 4); + buffer += 4; + memcpy(&mFileID.mData, buffer, 16); + buffer += 16; + S16 temp_type; + swizzleCopy(&temp_type, buffer, 2); + mFileType = (LLAssetType::EType)temp_type; + buffer += 2; + swizzleCopy(&mSize, buffer, 4); +} + +BOOL LLVFSFileBlock::insertLRU(LLVFSFileBlock* const& first, + LLVFSFileBlock* const& second) +{ + return (first->mAccessTime == second->mAccessTime) + ? *first < *second + : first->mAccessTime < second->mAccessTime; +} // Helper structure for doing lru w/ stl... is there a simpler way? struct LLVFSFileBlock_less diff --git a/indra/llvfs/llvfs.h b/indra/llvfs/llvfs.h index df2d42d9b..db3713f7d 100644 --- a/indra/llvfs/llvfs.h +++ b/indra/llvfs/llvfs.h @@ -59,9 +59,24 @@ enum EVFSLock VFSLOCK_COUNT = 3 }; -// internal classes -class LLVFSBlock; -class LLVFSFileBlock; +// +//the VFS explorer requires that the class definition of these be available outside of llvfs +class LLVFSBlock +{ +public: + LLVFSBlock(); + + LLVFSBlock(U32 loc, S32 size); + + static bool locationSortPredicate( + const LLVFSBlock* lhs, + const LLVFSBlock* rhs); + +public: + U32 mLocation; + S32 mLength; // allocated block size +}; + class LLVFSFileSpecifier { public: @@ -75,6 +90,32 @@ public: LLAssetType::EType mFileType; }; +class LLVFSFileBlock : public LLVFSBlock, public LLVFSFileSpecifier +{ +public: + LLVFSFileBlock(); + LLVFSFileBlock(const LLUUID &file_id, LLAssetType::EType file_type, U32 loc = 0, S32 size = 0); + void init(); +#ifdef LL_LITTLE_ENDIAN + inline void swizzleCopy(void *dst, void *src, int size); +#else + inline U32 swizzle32(U32 x); + inline U16 swizzle16(U16 x); + inline void swizzleCopy(void *dst, void *src, int size); +#endif + void serialize(U8 *buffer); + void deserialize(U8 *buffer, const S32 index_loc); + static BOOL insertLRU(LLVFSFileBlock* const& first, + LLVFSFileBlock* const& second); + S32 mSize; + S32 mIndexLocation; // location of index entry + U32 mAccessTime; + BOOL mLocks[VFSLOCK_COUNT]; // number of outstanding locks of each type + + static const S32 SERIAL_SIZE; +}; +// + class LLVFS { public: diff --git a/indra/newview/dofloaterhex.cpp b/indra/newview/dofloaterhex.cpp index a851798fd..eff028be4 100644 --- a/indra/newview/dofloaterhex.cpp +++ b/indra/newview/dofloaterhex.cpp @@ -473,13 +473,13 @@ void DOFloaterHex::readVFile() delete[] buffer; - floater->mEditor->setValue(new_data); - floater->mEditor->setVisible(TRUE); + mEditor->setValue(new_data); + mEditor->setVisible(TRUE); - floater->childSetText("status_text", std::string("Editing VFile")); + childSetText("status_text", std::string("Editing VFile")); - floater->childSetEnabled("upload_btn", false); - floater->childSetEnabled("save_btn", false); + childSetEnabled("upload_btn", false); + childSetEnabled("save_btn", false); } // diff --git a/indra/newview/dofloaterhex.h b/indra/newview/dofloaterhex.h index 57998b66f..996f08c2a 100644 --- a/indra/newview/dofloaterhex.h +++ b/indra/newview/dofloaterhex.h @@ -15,7 +15,7 @@ class DOFloaterHex { public: DOFloaterHex(LLUUID item_id, BOOL vfs=false, LLAssetType::EType asset_type = LLAssetType::AT_NONE); - static void show(LLUUID item_id); + static void show(LLUUID item_id, BOOL vfs=false, LLAssetType::EType asset_type = LLAssetType::AT_NONE); BOOL postBuild(void); void close(bool app_quitting); static void imageCallback(BOOL success, diff --git a/indra/newview/llfloatervfsexplorer.cpp b/indra/newview/llfloatervfsexplorer.cpp index 6adb0a475..a070d59c7 100644 --- a/indra/newview/llfloatervfsexplorer.cpp +++ b/indra/newview/llfloatervfsexplorer.cpp @@ -10,7 +10,7 @@ #include "lllocalinventory.h" #include "llviewerwindow.h" #include "llassetconverter.h" -#include "dohexeditor.h" +#include "dofloaterhex.h" LLFloaterVFSExplorer* LLFloaterVFSExplorer::sInstance; std::map LLFloaterVFSExplorer::sVFSFileMap; @@ -42,6 +42,7 @@ BOOL LLFloaterVFSExplorer::postBuild() childSetAction("remove_btn", onClickRemove, this); childSetAction("reload_all_btn", onClickReload, this); childSetAction("copy_uuid_btn", onClickCopyUUID, this); + childSetAction("edit_data_btn", onClickEditData, this); refresh(); return TRUE; } @@ -140,6 +141,7 @@ void LLFloaterVFSExplorer::setEditEnabled(bool enabled) childSetEnabled("name_edit", false); childSetEnabled("id_edit", false); childSetEnabled("type_combo", false); + childSetEnabled("edit_data_btn", enabled); childSetEnabled("remove_btn", enabled); childSetEnabled("copy_uuid_btn", enabled); } @@ -175,13 +177,14 @@ void LLFloaterVFSExplorer::onClickReload(void* user_data) // static void LLFloaterVFSExplorer::onClickEditData(void* user_data) { + LLFloaterVFSExplorer* floaterp = (LLFloaterVFSExplorer*)user_data; LLVFSFileSpecifier file; std::map::iterator end = sVFSFileMap.end(); for(std::map::iterator iter = sVFSFileMap.begin(); iter != end; ++iter) { - if((*iter).first.mFileID == mEditID) + if((*iter).first.mFileID == floaterp->mEditID) file = (*iter).first; } - DOHexEditor::showVFS(file.mFileID, file.mFileType); + DOFloaterHex::show(file.mFileID, true, file.mFileType); } // diff --git a/indra/newview/skins/default/xui/en-us/floater_vfs_explorer.xml b/indra/newview/skins/default/xui/en-us/floater_vfs_explorer.xml index 5fd408622..7b840bcb4 100644 --- a/indra/newview/skins/default/xui/en-us/floater_vfs_explorer.xml +++ b/indra/newview/skins/default/xui/en-us/floater_vfs_explorer.xml @@ -85,4 +85,5 @@