mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
Merge remote-tracking branch 'devhead/Preview4_0' into tsneo
# Conflicts: # Templates/BaseGame/game/data/ui/guis/loadingGui.gui # Templates/BaseGame/game/data/ui/guis/mainMenu.gui # Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui # Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui # Templates/BaseGame/game/tools/forestEditor/brushes.tscript
This commit is contained in:
commit
717c7acca9
2266 changed files with 48780 additions and 26034 deletions
|
|
@ -177,7 +177,7 @@ const U8 *FileObject::readLine()
|
|||
return mFileBuffer + tokPos;
|
||||
}
|
||||
|
||||
void FileObject::peekLine( U8* line, S32 length )
|
||||
void FileObject::peekLine( S32 peekLineOffset, U8* line, S32 length )
|
||||
{
|
||||
if(!mFileBuffer)
|
||||
{
|
||||
|
|
@ -189,6 +189,31 @@ void FileObject::peekLine( U8* line, S32 length )
|
|||
// we can't modify the file buffer.
|
||||
S32 i = 0;
|
||||
U32 tokPos = mCurPos;
|
||||
S32 lineOffset = 0;
|
||||
|
||||
//Lets push our tokPos up until we've offset the requested number of lines
|
||||
while (lineOffset < peekLineOffset && tokPos <= mBufferSize)
|
||||
{
|
||||
if (mFileBuffer[tokPos] == '\r')
|
||||
{
|
||||
tokPos++;
|
||||
if (mFileBuffer[tokPos] == '\n')
|
||||
tokPos++;
|
||||
lineOffset++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mFileBuffer[tokPos] == '\n')
|
||||
{
|
||||
tokPos++;
|
||||
lineOffset++;
|
||||
continue;
|
||||
}
|
||||
|
||||
tokPos++;
|
||||
}
|
||||
|
||||
//now peek that line, then return the results
|
||||
while( ( tokPos != mBufferSize ) && ( mFileBuffer[tokPos] != '\r' ) && ( mFileBuffer[tokPos] != '\n' ) && ( i < ( length - 1 ) ) )
|
||||
line[i++] = mFileBuffer[tokPos++];
|
||||
|
||||
|
|
@ -317,7 +342,7 @@ DefineEngineMethod( FileObject, readLine, const char*, (),,
|
|||
return (const char *) object->readLine();
|
||||
}
|
||||
|
||||
DefineEngineMethod( FileObject, peekLine, const char*, (),,
|
||||
DefineEngineMethod( FileObject, peekLine, const char*, (S32 peekOffset), (0),
|
||||
"@brief Read a line from the file without moving the stream position.\n\n"
|
||||
|
||||
"Emphasis on *line*, as in you cannot parse individual characters or chunks of data. "
|
||||
|
|
@ -345,7 +370,7 @@ DefineEngineMethod( FileObject, peekLine, const char*, (),,
|
|||
{
|
||||
static const U32 bufSize = 512;
|
||||
char *line = Con::getReturnBuffer( bufSize );
|
||||
object->peekLine( (U8*)line, bufSize );
|
||||
object->peekLine(peekOffset, (U8*)line, bufSize );
|
||||
return line;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
bool readMemory(const char *fileName);
|
||||
const U8 *buffer() { return mFileBuffer; }
|
||||
const U8 *readLine();
|
||||
void peekLine(U8 *line, S32 length);
|
||||
void peekLine(S32 peekLineOffset, U8 *line, S32 length);
|
||||
bool isEOF();
|
||||
void writeLine(const U8 *line);
|
||||
void close();
|
||||
|
|
|
|||
|
|
@ -228,10 +228,10 @@ void BitStream::writeBits(S32 bitCount, const void *bitPtr)
|
|||
if(!bitCount)
|
||||
return;
|
||||
|
||||
if(bitCount + bitNum > maxWriteBitNum)
|
||||
if((bitCount + bitNum) > maxWriteBitNum)
|
||||
{
|
||||
error = true;
|
||||
AssertFatal(false, "Out of range write");
|
||||
AssertFatal(false, avar("BitStream::writeBits - Out of range write [(%i+%i)/%i]", bitCount, bitNum, maxWriteBitNum));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -264,10 +264,10 @@ bool BitStream::testBit(S32 bitCount)
|
|||
|
||||
bool BitStream::writeFlag(bool val)
|
||||
{
|
||||
if(bitNum + 1 > maxWriteBitNum)
|
||||
if((bitNum + 1) > maxWriteBitNum)
|
||||
{
|
||||
error = true;
|
||||
AssertFatal(false, "Out of range write");
|
||||
AssertFatal(false, avar("BitStream::writeFlag - Out of range write [%i/%i]", bitNum+1, maxWriteBitNum));
|
||||
return false;
|
||||
}
|
||||
if(val)
|
||||
|
|
@ -344,22 +344,52 @@ void BitStream::writeInt(S32 val, S32 bitCount)
|
|||
|
||||
void BitStream::writeFloat(F32 f, S32 bitCount)
|
||||
{
|
||||
writeInt((S32)(f * ((1 << bitCount) - 1)), bitCount);
|
||||
auto maxInt = (1U << bitCount) - 1;
|
||||
U32 i;
|
||||
if (f < POINT_EPSILON)
|
||||
{
|
||||
// Special case: <= 0 serializes to 0
|
||||
i = 0.0f;
|
||||
}
|
||||
else if (f == 0.5)
|
||||
{
|
||||
// Special case: 0.5 serializes to maxInt / 2 + 1
|
||||
i = maxInt / 2 + 1;
|
||||
}
|
||||
else if (f > (1.0f- POINT_EPSILON))
|
||||
{
|
||||
// Special case: >= 1 serializes to maxInt
|
||||
i = maxInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Serialize normally but round the number
|
||||
i = static_cast<U32>(roundf(f * maxInt));
|
||||
}
|
||||
writeInt(i, bitCount);
|
||||
}
|
||||
|
||||
F32 BitStream::readFloat(S32 bitCount)
|
||||
{
|
||||
return readInt(bitCount) / F32((1 << bitCount) - 1);
|
||||
auto maxInt = (1U << bitCount) - 1;
|
||||
auto i = static_cast<U32>(readInt(bitCount));
|
||||
if (i == 0)
|
||||
return 0;
|
||||
if (i == maxInt / 2 + 1)
|
||||
return 0.5;
|
||||
if (i == maxInt)
|
||||
return 1;
|
||||
return i / static_cast<F32>(maxInt);
|
||||
}
|
||||
|
||||
void BitStream::writeSignedFloat(F32 f, S32 bitCount)
|
||||
{
|
||||
writeInt((S32)(((f + 1) * .5) * ((1 << bitCount) - 1)), bitCount);
|
||||
writeFloat((f + 1) / 2, bitCount);
|
||||
}
|
||||
|
||||
F32 BitStream::readSignedFloat(S32 bitCount)
|
||||
{
|
||||
return readInt(bitCount) * 2 / F32((1 << bitCount) - 1) - 1.0f;
|
||||
return readFloat(bitCount) * 2 - 1;
|
||||
}
|
||||
|
||||
void BitStream::writeSignedInt(S32 value, S32 bitCount)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace StringUnit
|
|||
|
||||
buffer[0] = 0;
|
||||
|
||||
U32 sz;
|
||||
dsize_t sz;
|
||||
while(index--)
|
||||
{
|
||||
if(!*string)
|
||||
|
|
@ -71,7 +71,7 @@ namespace StringUnit
|
|||
if( startIndex > endIndex )
|
||||
return "";
|
||||
|
||||
S32 sz;
|
||||
dsize_t sz;
|
||||
S32 index = startIndex;
|
||||
while(index--)
|
||||
{
|
||||
|
|
@ -89,7 +89,7 @@ namespace StringUnit
|
|||
sz = dStrcspn(string, set);
|
||||
string += sz;
|
||||
|
||||
if( i < endIndex )
|
||||
if( i < endIndex && *string )
|
||||
string ++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@
|
|||
/// @addtogroup zip_group Zip Code
|
||||
// @{
|
||||
|
||||
/// Password to use when opening encrypted zip files. Change this to whatever the password is for your zips.
|
||||
#define DEFAULT_ZIP_PASSWORD "changeme"
|
||||
|
||||
class ZipTestWrite;
|
||||
class ZipTestRead;
|
||||
|
|
@ -235,7 +233,7 @@ class ZipTempStream;
|
|||
/// exists and may be released as a resource in the future.
|
||||
///
|
||||
/// To set the password used for zips, you need to modify the #DEFAULT_ZIP_PASSWORD
|
||||
/// define in core/zip/zipArchive.h. This password will be used for all zips that
|
||||
/// define in torqueConfig.h. This password will be used for all zips that
|
||||
/// require a password. The default password is changeme. This may be used by
|
||||
/// TGB Binary users to test encrypted zips with their game. Shipping with the
|
||||
/// default password is not recommended for obvious reasons.
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void ZipCryptRStream::setPassword(const char *password)
|
|||
|
||||
bool ZipCryptRStream::attachStream(Stream* io_pSlaveStream)
|
||||
{
|
||||
mStream = io_pSlaveStream;
|
||||
mStream = io_pSlaveStream->clone();
|
||||
mStreamStartPos = mStream->getPosition();
|
||||
|
||||
// [tom, 12/20/2005] Encrypted zip files have an extra 12 bytes
|
||||
|
|
|
|||
|
|
@ -58,7 +58,10 @@ bool ZipSubRStream::attachStream(Stream* io_pSlaveStream)
|
|||
AssertFatal(io_pSlaveStream != NULL, "NULL Slave stream?");
|
||||
AssertFatal(m_pStream == NULL, "Already attached!");
|
||||
|
||||
m_pStream = io_pSlaveStream->clone();
|
||||
if (!m_pStream)
|
||||
m_pStream = io_pSlaveStream;
|
||||
|
||||
m_originalSlavePosition = io_pSlaveStream->getPosition();
|
||||
m_uncompressedSize = 0;
|
||||
m_currentPosition = 0;
|
||||
|
|
|
|||
|
|
@ -357,6 +357,10 @@ ZipFileSystem::ZipFileSystem(String& zipFilename, bool zipNameIsDir /* = false *
|
|||
if(mZipNameIsDir)
|
||||
{
|
||||
Path path(zipFilename);
|
||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
if (path.getFileName().equal(path.getRoot()))
|
||||
mZipNameIsDir = false;
|
||||
#endif
|
||||
mFakeRoot = Path::Join(path.getPath(), '/', path.getFileName());
|
||||
}
|
||||
|
||||
|
|
@ -397,6 +401,81 @@ FileNodeRef ZipFileSystem::resolve(const Path& path)
|
|||
|
||||
if(name.isEmpty() && mZipNameIsDir)
|
||||
return new ZipFakeRootNode(mZipArchive, path, mFakeRoot);
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
name = String::ToLower(name);
|
||||
#endif
|
||||
if(mZipNameIsDir)
|
||||
{
|
||||
// Remove the fake root from the name so things can be found
|
||||
if(name.find(mFakeRoot) == 0)
|
||||
name = name.substr(mFakeRoot.length());
|
||||
|
||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
else
|
||||
// If a zip file's name isn't the root of the path we're looking for
|
||||
// then do not continue. Otherwise, we'll continue to look for the
|
||||
// path's root within the zip file itself. i.e. we're looking for the
|
||||
// path "scripts/test.cs". If the zip file itself isn't called scripts.zip
|
||||
// then we won't look within the archive for a "scripts" directory.
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (name.find("/") == 0)
|
||||
name = name.substr(1, name.length() - 1);
|
||||
}
|
||||
|
||||
// first check to see if input path is a directory
|
||||
// check for request of root directory
|
||||
if (name.isEmpty())
|
||||
{
|
||||
ZipDirectoryNode* zdn = new ZipDirectoryNode(mZipArchive, path, mZipArchive->getRoot());
|
||||
return zdn;
|
||||
}
|
||||
|
||||
ZipArchive::ZipEntry* ze = mZipArchive->findZipEntry(name);
|
||||
if (ze == NULL)
|
||||
return NULL;
|
||||
|
||||
if (ze->mIsDirectory)
|
||||
{
|
||||
ZipDirectoryNode* zdn = new ZipDirectoryNode(mZipArchive, path, ze);
|
||||
return zdn;
|
||||
}
|
||||
|
||||
// pass in the zip entry so that openFile() doesn't need to look it up again.
|
||||
Stream* stream = mZipArchive->openFile(name, ze, ZipArchive::Read);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
||||
ZipFileNode* zfn = new ZipFileNode(mZipArchive, name, stream, ze);
|
||||
return zfn;
|
||||
}
|
||||
|
||||
FileNodeRef ZipFileSystem::resolveLoose(const Path& path)
|
||||
{
|
||||
if (!mInitted)
|
||||
_init();
|
||||
|
||||
if (mZipArchive.isNull())
|
||||
return NULL;
|
||||
|
||||
// eat leading "/"
|
||||
String name = path.getFullPathWithoutRoot();
|
||||
if (name.find("/") == 0)
|
||||
name = name.substr(1, name.length() - 1);
|
||||
|
||||
if(name.isEmpty() && mZipNameIsDir)
|
||||
return new ZipFakeRootNode(mZipArchive, path, mFakeRoot);
|
||||
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
name = String::ToLower(name);
|
||||
#endif
|
||||
|
||||
if ((mFakeRoot.find(name) == 0) && (mFakeRoot.length() > name.length()))
|
||||
{ // This file system is mounted as a sub-directory of the path being searched.
|
||||
String tmpRoot = mFakeRoot.substr(name.length());
|
||||
return new ZipFakeRootNode(mZipArchive, path, tmpRoot);
|
||||
}
|
||||
|
||||
if(mZipNameIsDir)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,8 +40,15 @@ public:
|
|||
|
||||
String getTypeStr() const { return "Zip"; }
|
||||
|
||||
// Strict resolve function will reteurn a node if it is mounted *AS* the requested path.
|
||||
FileNodeRef resolve(const Path& path);
|
||||
|
||||
// Loose resolve function will return a node if it is mounted as or under the requested path.
|
||||
// This is needed so mounted subdirectories will be included in recursive FindByPatern searches.
|
||||
// i.e. If data/ui.zip is mounted as data/ui, a search for data/*.module will only include files
|
||||
// under data/ui if the loose resolve function is used.
|
||||
FileNodeRef resolveLoose(const Path& path);
|
||||
|
||||
// these are unsupported, ZipFileSystem is currently read only access
|
||||
FileNodeRef create(const Path& path,FileNode::Mode) { return 0; }
|
||||
bool remove(const Path& path) { return 0; }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ bool VirtualMountSystem::mount(String root, FileSystemRef fs)
|
|||
if (!ok)
|
||||
return false;
|
||||
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
root = String::ToLower(root);
|
||||
#endif
|
||||
|
||||
mRootMap[root].push_back(fs);
|
||||
|
||||
|
|
@ -263,13 +265,17 @@ FileSystemRef VirtualMountSystem::_removeMountFromList(String root)
|
|||
|
||||
FileSystemRef VirtualMountSystem::_getFileSystemFromList(const Path& fullpath) const
|
||||
{
|
||||
String root = String::ToLower(fullpath.getRoot());
|
||||
String root = fullpath.getRoot();
|
||||
String path = fullpath.getFullPathWithoutRoot();
|
||||
// eat leading slash
|
||||
if (path[(String::SizeType)0] == '/')
|
||||
path = path.substr(1);
|
||||
// lowercase it
|
||||
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
// lowercase the root and path
|
||||
root = String::ToLower(root);
|
||||
path = String::ToLower(path);
|
||||
#endif
|
||||
|
||||
// find the dictionary for root
|
||||
// PathFSMap* rootDict = NULL;
|
||||
|
|
|
|||
|
|
@ -730,7 +730,7 @@ S32 MountSystem::findByPattern( const Path &inBasePath, const String &inFilePatt
|
|||
else
|
||||
{
|
||||
// use specified filesystem to open directory
|
||||
FileNodeRef fNode = mFindByPatternOverrideFS->resolve(inBasePath);
|
||||
FileNodeRef fNode = mFindByPatternOverrideFS->resolveLoose(inBasePath);
|
||||
if (fNode && (dir = dynamic_cast<Directory*>(fNode.getPointer())) != NULL)
|
||||
dir->open();
|
||||
}
|
||||
|
|
@ -1074,6 +1074,18 @@ bool IsFile(const Path &path)
|
|||
return sgMountSystem.isFile(path);
|
||||
}
|
||||
|
||||
bool IsScriptFile(const char* pFilePath)
|
||||
{
|
||||
return (sgMountSystem.isFile(pFilePath)
|
||||
|| sgMountSystem.isFile(pFilePath + String(".dso"))
|
||||
|| sgMountSystem.isFile(pFilePath + String(".mis"))
|
||||
|| sgMountSystem.isFile(pFilePath + String(".mis.dso"))
|
||||
|| sgMountSystem.isFile(pFilePath + String(".gui"))
|
||||
|| sgMountSystem.isFile(pFilePath + String(".gui.dso"))
|
||||
|| sgMountSystem.isFile(pFilePath + String("." TORQUE_SCRIPT_EXTENSION))
|
||||
|| sgMountSystem.isFile(pFilePath + String("." TORQUE_SCRIPT_EXTENSION) + String(".dso")));
|
||||
}
|
||||
|
||||
bool IsDirectory(const Path &path)
|
||||
{
|
||||
return sgMountSystem.isDirectory(path);
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ public:
|
|||
virtual String getTypeStr() const = 0; ///< Used for describing the file system type
|
||||
|
||||
virtual FileNodeRef resolve(const Path& path) = 0;
|
||||
virtual FileNodeRef resolveLoose(const Path& path) { return resolve(path); }
|
||||
virtual FileNodeRef create(const Path& path,FileNode::Mode) = 0;
|
||||
virtual bool remove(const Path& path) = 0;
|
||||
virtual bool rename(const Path& a,const Path& b) = 0;
|
||||
|
|
@ -549,6 +550,7 @@ bool CreatePath(const Path &path);
|
|||
bool IsReadOnly(const Path &path);
|
||||
bool IsDirectory(const Path &path);
|
||||
bool IsFile(const Path &path);
|
||||
bool IsScriptFile(const char* pFilePath);
|
||||
bool VerifyWriteAccess(const Path &path);
|
||||
|
||||
/// This returns a unique file path from the components
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue