diff --git a/Sources/Plasma/Apps/plClient/CMakeLists.txt b/Sources/Plasma/Apps/plClient/CMakeLists.txt
index 55e903c7..0816daf2 100644
--- a/Sources/Plasma/Apps/plClient/CMakeLists.txt
+++ b/Sources/Plasma/Apps/plClient/CMakeLists.txt
@@ -154,7 +154,6 @@ target_link_libraries(plClient pnProduct)
target_link_libraries(plClient pnSceneObject)
target_link_libraries(plClient pnTimer)
target_link_libraries(plClient pnUtils)
-target_link_libraries(plClient pnUtilsExe)
target_link_libraries(plClient pnUUID)
if(PYTHON_DEBUG_LIBRARY)
diff --git a/Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt b/Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt
index c1b6c37a..541c72a3 100644
--- a/Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt
+++ b/Sources/Plasma/Apps/plCrashHandler/CMakeLists.txt
@@ -14,7 +14,6 @@ target_link_libraries(plCrashHandler CoreLib)
target_link_libraries(plCrashHandler pfCrashHandler)
target_link_libraries(plCrashHandler plFile)
target_link_libraries(plCrashHandler pnProduct)
-target_link_libraries(plCrashHandler pnUtils)
# Platform specific libs
if(WIN32)
diff --git a/Sources/Plasma/Apps/plCrashHandler/main.cpp b/Sources/Plasma/Apps/plCrashHandler/main.cpp
index 235564b2..b56ad9e9 100644
--- a/Sources/Plasma/Apps/plCrashHandler/main.cpp
+++ b/Sources/Plasma/Apps/plCrashHandler/main.cpp
@@ -42,31 +42,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "pfCrashHandler/plCrashSrv.h"
-#include "pnUtils/pnUtils.h"
-enum
-{
- kArgMemFile
-};
-
-static const CmdArgDef s_cmdLineArgs[] =
-{
- { (kCmdArgRequired | kCmdTypeString), nil, kArgMemFile },
-};
-
-int main(int argc, char* argv[])
+int main(int argc, const char* argv[])
{
// Parse command line arguments. We MUST have the file argument
- CCmdParser cmdParser(s_cmdLineArgs, arrsize(s_cmdLineArgs));
- if (!cmdParser.Parse())
+ if (argc != 2)
{
hsMessageBox("You should never run this manually.", "Error", hsMessageBoxNormal, hsMessageBoxIconExclamation);
return 1;
}
- char* file = hsWStringToString(cmdParser.GetString(kArgMemFile));
- plCrashSrv srv(file);
- delete[] file;
+ plCrashSrv srv(argv[1]);
srv.HandleCrash();
return 0;
}
diff --git a/Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt b/Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
index 65228010..4c8a955e 100644
--- a/Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
+++ b/Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
@@ -55,7 +55,6 @@ target_link_libraries(plUruLauncher pnNetProtocol)
target_link_libraries(plUruLauncher pnProduct)
target_link_libraries(plUruLauncher pnTimer)
target_link_libraries(plUruLauncher pnUtils)
-target_link_libraries(plUruLauncher pnUtilsExe)
target_link_libraries(plUruLauncher ${DirectX_LIBRARIES})
target_link_libraries(plUruLauncher ${OPENSSL_LIBRARIES})
diff --git a/Sources/Plasma/Apps/plUruLauncher/Main.cpp b/Sources/Plasma/Apps/plUruLauncher/Main.cpp
index 7d59c579..06b94ab5 100644
--- a/Sources/Plasma/Apps/plUruLauncher/Main.cpp
+++ b/Sources/Plasma/Apps/plUruLauncher/Main.cpp
@@ -834,7 +834,7 @@ int __stdcall WinMain (
// Wait for the other process to exit
Sleep(1000);
- if (!PathDeleteFile(newPatcherFile)) {
+ if (!plFileUtils::RemoveFile(newPatcherFile)) {
wchar_t error[256];
DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode);
@@ -844,7 +844,7 @@ int __stdcall WinMain (
LocalFree(msg);
break;
}
- if (!PathMoveFile(curPatcherFile, newPatcherFile)) {
+ if (!plFileUtils::FileMove(curPatcherFile, newPatcherFile)) {
wchar_t error[256];
DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode);
@@ -852,7 +852,7 @@ int __stdcall WinMain (
StrPrintf(error, arrsize(error), L"Failed to replace old patcher executable. %s", msg);
MessageBoxW(GetTopWindow(nil), error, L"Error", MB_OK);
// attempt to clean up this tmp file
- PathDeleteFile(curPatcherFile);
+ plFileUtils::RemoveFile(curPatcherFile);
LocalFree(msg);
break;
}
@@ -896,7 +896,7 @@ int __stdcall WinMain (
PathAddFilename(fileSpec, fileSpec, L"*.tmp", arrsize(fileSpec));
PathFindFiles(&paths, fileSpec, kPathFlagFile);
for (PathFind * path = paths.Ptr(); path != paths.Term(); ++path)
- PathDeleteFile(path->name);
+ plFileUtils::RemoveFile(path->name);
SetConsoleCtrlHandler(CtrlHandler, TRUE);
InitAsyncCore(); // must do this before self patch, since it needs to connect to the file server
diff --git a/Sources/Plasma/Apps/plUruLauncher/Pch.h b/Sources/Plasma/Apps/plUruLauncher/Pch.h
index 7c1be92d..990524d8 100644
--- a/Sources/Plasma/Apps/plUruLauncher/Pch.h
+++ b/Sources/Plasma/Apps/plUruLauncher/Pch.h
@@ -62,6 +62,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "pnEncryption/plChecksum.h"
+#include "plFile/plFileUtils.h"
#include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h"
diff --git a/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp b/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
index 172e4eba..8e1b4689 100644
--- a/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
+++ b/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
@@ -232,7 +232,7 @@ static void FileSrvIpAddressCallback (
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
- PathDeleteFile(s_newPatcherFile);
+ plFileUtils::RemoveFile(s_newPatcherFile);
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
}
diff --git a/Sources/Plasma/CoreLib/hsThread_Unix.cpp b/Sources/Plasma/CoreLib/hsThread_Unix.cpp
index f4952482..c625fc05 100644
--- a/Sources/Plasma/CoreLib/hsThread_Unix.cpp
+++ b/Sources/Plasma/CoreLib/hsThread_Unix.cpp
@@ -320,7 +320,7 @@ hsBool hsSemaphore::TryWait()
{
#ifdef USE_SEMA
int status = ::sem_trywait(fPSema);
- return status != E_AGAIN;
+ return status != EAGAIN;
#else
int status = ::pthread_mutex_trylock(&fPMutex);
hsThrowIfOSErr(status);
diff --git a/Sources/Plasma/NucleusLib/CMakeLists.txt b/Sources/Plasma/NucleusLib/CMakeLists.txt
index 06e94361..490fc8e8 100644
--- a/Sources/Plasma/NucleusLib/CMakeLists.txt
+++ b/Sources/Plasma/NucleusLib/CMakeLists.txt
@@ -20,5 +20,4 @@ add_subdirectory(pnProduct)
add_subdirectory(pnSceneObject)
add_subdirectory(pnTimer)
add_subdirectory(pnUtils)
-add_subdirectory(pnUtilsExe)
add_subdirectory(pnUUID)
diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h
index 249c0b25..188a4281 100644
--- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h
+++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h
@@ -54,6 +54,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
+#include "hsThread.h"
#include "Private/pnAceInt.h"
#include "Private/W9x/pnAceW9x.h"
diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceIo.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceIo.cpp
index a4b6bc6d..a0bf3ecf 100644
--- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceIo.cpp
+++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceIo.cpp
@@ -83,7 +83,7 @@ struct ISocketConnType : ISocketConnHash {
};
-static CLock s_notifyProcLock;
+static hsReaderWriterLock s_notifyProcLock;
static HASHTABLEDECL(
ISocketConnType,
ISocketConnHash,
@@ -340,11 +340,11 @@ void AsyncSocketRegisterNotifyProc (
ct->productId = productId;
ct->flags = kConnHashFlagsIgnore;
- s_notifyProcLock.EnterWrite();
+ s_notifyProcLock.LockForWriting();
{
s_notifyProcs.Add(ct);
}
- s_notifyProcLock.LeaveWrite();
+ s_notifyProcLock.UnlockForWriting();
}
//===========================================================================
@@ -365,7 +365,7 @@ void AsyncSocketUnregisterNotifyProc (
hash.flags = kConnHashFlagsExactMatch;
ISocketConnType * scan;
- s_notifyProcLock.EnterWrite();
+ s_notifyProcLock.LockForWriting();
{
scan = s_notifyProcs.Find(hash);
for (; scan; scan = s_notifyProcs.FindNext(hash, scan)) {
@@ -377,7 +377,7 @@ void AsyncSocketUnregisterNotifyProc (
break;
}
}
- s_notifyProcLock.LeaveWrite();
+ s_notifyProcLock.UnlockForWriting();
// perform memory deallocation outside the lock
delete scan;
@@ -403,12 +403,12 @@ FAsyncNotifySocketProc AsyncSocketFindNotifyProc (
// Lookup notifyProc based on connType
FAsyncNotifySocketProc proc;
- s_notifyProcLock.EnterRead();
+ s_notifyProcLock.LockForReading();
if (const ISocketConnType * scan = s_notifyProcs.Find(hash))
proc = scan->notifyProc;
else
proc = nil;
- s_notifyProcLock.LeaveRead();
+ s_notifyProcLock.UnlockForReading();
if (!proc)
break;
diff --git a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
index ce0441c4..3e46f898 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
+++ b/Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
@@ -18,7 +18,6 @@ set(pnUtils_HEADERS
pnUtRef.h
pnUtSort.h
pnUtStr.h
- pnUtSync.h
pnUtTime.h
pnUtUuid.h
)
@@ -41,14 +40,11 @@ if(WIN32)
Win32/pnUtW32Misc.cpp
Win32/pnUtW32Path.cpp
Win32/pnUtW32Str.cpp
- Win32/pnUtW32Sync.cpp
- Win32/pnUtW32Time.cpp
Win32/pnUtW32Uuid.cpp
)
else()
set(pnUtils_UNIX
Unix/pnUtUxStr.cpp
- #Unix/pnUtUxSync.cpp
Unix/pnUtUxUuid.cpp
)
endif()
diff --git a/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxSync.cpp b/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxSync.cpp
deleted file mode 100644
index c43bfea2..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/Unix/pnUtUxSync.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/Unix/pnUtUxSync.cpp
-*
-***/
-
-#include "../pnUtSync.h"
-
-#ifdef HS_BUILD_FOR_UNIX
-
-
-#else
-
-// Dummy function to prevent a linker warning complaining about no public symbols if the
-// contents of the file get compiled out via pre-processor
-void UxSyncPreventLNK4221Warning () {
-}
-
-#endif
diff --git a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp
index ccc846a6..a7abfd00 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp
+++ b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp
@@ -112,47 +112,21 @@ static wchar_t * PathSkipOverSeparator (wchar_t * path) {
}
//===========================================================================
-static unsigned CommonPrefixLength (
- const wchar_t src1[],
- const wchar_t src2[]
+const wchar_t * PathFindFilename (
+ const wchar_t path[]
) {
- ASSERT(src1);
- ASSERT(src2);
-
- wchar_t const * const base = src1;
- const wchar_t * common = nil;
- for (;;) {
- // Are the next components equal in length?
- const wchar_t * next1 = PathSkipOverSeparator(const_cast(src1));
- const wchar_t * next2 = PathSkipOverSeparator(const_cast(src2));
- const int componentLen = next1 - src1;
- if (componentLen != (next2 - src2))
- break;
-
- // Are the next components equal in value?
- if (!StrCmpI(src1, src2, componentLen))
- common = next1;
- else
- break;
+ ASSERT(path);
- if (!*next1)
- break;
- src1 = next1 + 1;
+ if (IsUncPath(path))
+ path = SkipUncDrive(path);
- if (!*next2)
- break;
- src2 = next2 + 1;
+ const wchar_t * last_slash = path;
+ for (const wchar_t * p = path; *p; p++) {
+ if ((*p == L'/') || (*p == L'\\') || (*p == L':'))
+ last_slash = p + 1;
}
- if (!common)
- return 0;
-
- // Compute length of common subchunk;
- // if it is "C:" convert it to "C:\"
- unsigned commonLen = common - base;
- if ((commonLen == 2) && (base[1] == L':'))
- ++commonLen;
- return commonLen;
+ return last_slash;
}
//===========================================================================
@@ -170,6 +144,16 @@ static void GetProgramName (
}
}
+//============================================================================
+bool PathDoesDirectoryExist (const wchar_t directory[]) {
+ uint32_t attributes = GetFileAttributesW(directory);
+ if (attributes == (uint32_t) -1)
+ return false;
+ if (attributes & FILE_ATTRIBUTE_DIRECTORY)
+ return true;
+ return false;
+}
+
/****************************************************************************
*
@@ -177,14 +161,6 @@ static void GetProgramName (
*
***/
-//===========================================================================
-void PathGetModuleName (
- wchar_t * dst,
- unsigned dstChars
-) {
- GetProgramName(ModuleGetInstance(), dst, dstChars);
-}
-
//===========================================================================
void PathGetProgramName (
wchar_t * dst,
@@ -226,32 +202,6 @@ bool PathFromString (
return false;
}
-//===========================================================================
-bool PathFromString (
- wchar_t * dst, // ASSERT(dst);
- const wchar_t src[], // ASSERT(src);
- unsigned dstChars, // ASSERT(dstChars);
- const wchar_t baseDir[] // ASSERT(baseDir);
-) {
- ASSERT(baseDir);
- ASSERT(dstChars);
-
- // Save current directory
- wchar_t curr[MAX_PATH];
- PathGetCurrentDirectory(curr, arrsize(curr));
-
- // Perform string conversion from specified directory
- bool result;
- if (0 != (result = PathSetCurrentDirectory(baseDir)))
- result = PathFromString(dst, src, dstChars);
- else
- *dst = 0;
-
- // Restore directory
- PathSetCurrentDirectory(curr);
- return result;
-}
-
//===========================================================================
// this function was originally derived from _tsplitpath in the MSVCRT library,
// but has been updated to support UNC paths and to avoid blasting off the end
@@ -399,140 +349,6 @@ void PathMakePath (
}
//===========================================================================
-bool PathMakeRelative (
- wchar_t *dst,
- unsigned fromFlags, // 0 or kPathFlagDirectory
- const wchar_t from[],
- unsigned toFlags, // 0 or kPathFlagDirectory
- const wchar_t to[],
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(from);
- ASSERT(to);
- ASSERT(dstChars);
- *dst = 0;
-
- unsigned prefixLength = CommonPrefixLength(from, to);
- if (!prefixLength)
- return false;
-
- wchar_t fromBuf[MAX_PATH];
- if (fromFlags & kPathFlagDirectory)
- StrCopy(fromBuf, from, arrsize(fromBuf));
- else
- PathRemoveFilename(fromBuf, from, arrsize(fromBuf));
-
- wchar_t toBuf[MAX_PATH];
- if (toFlags & kPathFlagDirectory)
- StrCopy(toBuf, to, arrsize(toBuf));
- else
- PathRemoveFilename(toBuf, to, arrsize(toBuf));
-
- const wchar_t * curr = fromBuf + prefixLength;
- if (*curr) {
- // build ..\.. part of the path
- if (IsSlash(*curr))
- curr++; // skip slash
-
- while (*curr) {
- curr = PathSkipOverSeparator(const_cast(curr));
- StrPack(dst, *curr ? L"..\\" : L"..", dstChars);
- }
- }
- else {
- StrCopy(dst, L".", dstChars);
- }
-
- if (to[prefixLength]) {
- // deal with root case
- if (!IsSlash(to[prefixLength]))
- --prefixLength;
-
- ASSERT(IsSlash(to[prefixLength]));
- StrPack(dst, to + prefixLength, dstChars);
- }
-
- return true;
-}
-
-//===========================================================================
-bool PathIsRelative (
- const wchar_t src[]
-) {
- ASSERT(src);
- if (!src[0])
- return true;
- if (IsSlash(src[0]))
- return false;
- if (src[1] == L':')
- return false;
- return true;
-}
-
-//===========================================================================
-const wchar_t * PathFindFilename (
- const wchar_t path[]
-) {
- ASSERT(path);
-
- if (IsUncPath(path))
- path = SkipUncDrive(path);
-
- const wchar_t * last_slash = path;
- for (const wchar_t * p = path; *p; p++) {
- if ((*p == L'/') || (*p == L'\\') || (*p == L':'))
- last_slash = p + 1;
- }
-
- return last_slash;
-}
-
-//===========================================================================
-const wchar_t * PathFindExtension (
- const wchar_t path[]
-) {
- ASSERT(path);
-
- const wchar_t * last_dot = 0;
- const wchar_t * p = PathFindFilename(path);
- for ( ; *p; p++) {
- if (*p == L'.')
- last_dot = p;
- }
-
- return last_dot ? last_dot : p;
-}
-
-//===========================================================================
-void PathGetCurrentDirectory (
- wchar_t * dst,
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(dstChars);
-
- DWORD result = GetCurrentDirectoryW(dstChars, dst);
- if (!result || (result >= dstChars)) {
- ErrorAssert(__LINE__, __FILE__, "GetDir failed");
- *dst = 0;
- }
-}
-
-//===========================================================================
-void PathGetTempDirectory (
- wchar_t * dst,
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(dstChars);
-
- DWORD result = GetTempPathW(dstChars, dst);
- if (!result || (result >= dstChars))
- StrCopy(dst, L"C:\\temp\\", dstChars);
-}
-
-//============================================================================
void PathGetUserDirectory (
wchar_t * dst,
unsigned dstChars
@@ -578,21 +394,6 @@ void PathGetInitDirectory (
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
}
-//===========================================================================
-bool PathSetCurrentDirectory (
- const wchar_t path[]
-) {
- ASSERT(path);
- return SetCurrentDirectoryW(path) != 0;
-}
-
-//===========================================================================
-void PathSetProgramDirectory () {
- wchar_t dir[MAX_PATH];
- PathGetProgramDirectory(dir, arrsize(dir));
- PathSetCurrentDirectory(dir);
-}
-
//===========================================================================
void PathFindFiles (
ARRAY(PathFind) * paths,
@@ -772,46 +573,6 @@ EPathCreateDirError PathCreateDirectory (const wchar_t path[], unsigned flags) {
}
}
-//===========================================================================
-void PathDeleteDirectory (const wchar_t path[], unsigned flags) {
- ASSERT(path);
-
- // convert from relative path to full path
- wchar_t dir[MAX_PATH];
- if (!PathFromString(dir, path, arrsize(dir)))
- return;
-
- for (;;) {
- // Important: in order to ensure that we don't delete NTFS
- // partition links, we must ensure that this is a directory!
- uint32_t attributes = GetFileAttributesW(dir);
- if (attributes == (uint32_t) -1)
- break;
- if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
- break;
- if (attributes & FILE_ATTRIBUTE_REPARSE_POINT)
- break;
-
- if (!RemoveDirectoryW(dir))
- break;
-
- if ((flags & kPathCreateDirFlagEntireTree) == 0)
- break;
-
- wchar_t * filename = PathFindFilename(dir);
- if (!filename)
- break;
-
- // Move up one level in the directory hierarchy
- unsigned oldLength = StrLen(dir);
- while ((filename > dir) && IsSlash(filename[-1]))
- --filename;
- *filename = 0;
- if (oldLength == StrLen(dir))
- break;
- }
-}
-
//===========================================================================
bool PathDoesFileExist (const wchar_t fileName[]) {
uint32_t attributes = GetFileAttributesW(fileName);
@@ -822,35 +583,3 @@ bool PathDoesFileExist (const wchar_t fileName[]) {
return true;
}
-//============================================================================
-bool PathDoesDirectoryExist (const wchar_t directory[]) {
- uint32_t attributes = GetFileAttributesW(directory);
- if (attributes == (uint32_t) -1)
- return false;
- if (attributes & FILE_ATTRIBUTE_DIRECTORY)
- return true;
- return false;
-}
-
-//===========================================================================
-bool PathDeleteFile (
- const wchar_t file[]
-) {
- return DeleteFileW(file) != 0;
-}
-
-//===========================================================================
-bool PathMoveFile (
- const wchar_t src[],
- const wchar_t dst[]
-) {
- return MoveFileW(src, dst) != 0;
-}
-
-//===========================================================================
-bool PathCopyFile (
- const wchar_t src[],
- const wchar_t dst[]
-) {
- return CopyFileW(src, dst, FALSE) != 0;
-}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Sync.cpp b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Sync.cpp
deleted file mode 100644
index 1a75b30c..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Sync.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/Win32/pnUtW32Sync.cpp
-*
-***/
-
-#include "../pnUtils.h"
-
-
-/****************************************************************************
-*
-* Spin lock functions
-*
-***/
-
-//===========================================================================
-static inline void EnterSpinLock (long * spinLock) {
- for (;;)
- if (*spinLock < 0)
- if (!InterlockedIncrement(spinLock))
- return;
- else
- InterlockedDecrement(spinLock);
-}
-
-//===========================================================================
-static inline void LeaveSpinLock (long * spinLock) {
- InterlockedDecrement(spinLock);
-}
-
-
-/****************************************************************************
-*
-* CLockWaitSet / CLockWaitSetAllocator
-*
-***/
-
-class CLockWaitSet {
-private:
- unsigned m_refCount;
- HANDLE m_waitEvent;
-
-public:
- LINK(CLockWaitSet) link;
-
- inline CLockWaitSet ();
- inline ~CLockWaitSet ();
- inline void DecRef ();
- inline void IncRef ();
- inline void Signal ();
- inline void Wait ();
-};
-
-class CLockWaitSetAllocator {
-private:
- CLockWaitSet m_array[256];
- CLockWaitSetAllocator * m_prev;
- LISTDECL(CLockWaitSet, link) m_spareList;
- LISTDECL(CLockWaitSet, link) m_usedList;
-
- static CLockWaitSetAllocator * s_allocator;
- static long s_spinLock;
-
-public:
- CLockWaitSetAllocator (CLockWaitSetAllocator * prev);
- ~CLockWaitSetAllocator ();
- static CLockWaitSet * Alloc ();
- static void Free (CLockWaitSet * waitSet);
- static void __cdecl Shutdown ();
-};
-
-CLockWaitSetAllocator * CLockWaitSetAllocator::s_allocator;
-long CLockWaitSetAllocator::s_spinLock = -1;
-
-//===========================================================================
-CLockWaitSet::CLockWaitSet () {
- m_refCount = 0;
- m_waitEvent = CreateEvent(nil, true, false, nil);
-}
-
-//===========================================================================
-CLockWaitSet::~CLockWaitSet () {
- ASSERT(!m_refCount);
- CloseHandle(m_waitEvent);
- m_waitEvent = 0;
-}
-
-//===========================================================================
-void CLockWaitSet::DecRef () {
- ASSERT(m_refCount);
- if (!--m_refCount) {
- ResetEvent(m_waitEvent);
- CLockWaitSetAllocator::Free(this);
- }
-}
-
-//===========================================================================
-void CLockWaitSet::IncRef () {
- ++m_refCount;
-}
-
-//===========================================================================
-void CLockWaitSet::Signal () {
- ASSERT(m_refCount);
- SetEvent(m_waitEvent);
-}
-
-//===========================================================================
-void CLockWaitSet::Wait () {
- ASSERT(m_refCount);
- WaitForSingleObject(m_waitEvent, INFINITE);
-}
-
-//===========================================================================
-CLockWaitSetAllocator::CLockWaitSetAllocator (CLockWaitSetAllocator * prev) {
- m_prev = prev;
- if (prev) {
- m_spareList.Link(&prev->m_spareList);
- m_usedList.Link(&prev->m_usedList);
- }
- for (unsigned index = arrsize(m_array); index--; )
- m_spareList.Link(&m_array[index]);
-}
-
-//===========================================================================
-CLockWaitSetAllocator::~CLockWaitSetAllocator () {
- delete m_prev;
-}
-
-//===========================================================================
-CLockWaitSet * CLockWaitSetAllocator::Alloc () {
- EnterSpinLock(&s_spinLock);
-
- // If there is no active allocator or if the active allocator is full,
- // create a new one
- if (!s_allocator || !s_allocator->m_spareList.Head()) {
- if (!s_allocator)
- atexit(Shutdown);
- s_allocator = new CLockWaitSetAllocator(s_allocator);
- }
-
- // Get an available wait set from the active allocator
- CLockWaitSet * waitSet = s_allocator->m_spareList.Head();
- s_allocator->m_usedList.Link(waitSet);
-
- LeaveSpinLock(&s_spinLock);
- return waitSet;
-}
-
-//===========================================================================
-void CLockWaitSetAllocator::Free (CLockWaitSet * waitSet) {
- EnterSpinLock(&s_spinLock);
-
- // Return this wait set to the active allocator's spare list
- ASSERT(s_allocator);
- s_allocator->m_spareList.Link(waitSet);
-
- LeaveSpinLock(&s_spinLock);
-}
-
-//===========================================================================
-void CLockWaitSetAllocator::Shutdown () {
- EnterSpinLock(&s_spinLock);
-
- // Free all allocators
- while (s_allocator) {
- CLockWaitSetAllocator * prev = s_allocator->m_prev;
- delete s_allocator;
- s_allocator = prev;
- }
-
- LeaveSpinLock(&s_spinLock);
-}
-
-
-/****************************************************************************
-*
-* CLock
-*
-***/
-
-//===========================================================================
-CLock::CLock () {
- m_waitSet = nil;
- m_spinLock = -1;
- m_readerCount = 0;
- m_writerCount = 0;
-}
-
-//===========================================================================
-CLock::~CLock () {
- ASSERT(!m_waitSet);
- ASSERT(m_spinLock == -1);
- ASSERT(!m_readerCount);
- ASSERT(!m_writerCount);
-}
-
-//===========================================================================
-void CLock::EnterRead () {
- EnterSpinLock(&m_spinLock);
- for (;;) {
-
- // If there are no writers, claim this lock for reading
- if (!m_writerCount) {
- ++m_readerCount;
- break;
- }
-
- // Otherwise, wait until the existing writer releases the lock
- CLockWaitSet * waitSet = m_waitSet = (m_waitSet ? m_waitSet : CLockWaitSetAllocator::Alloc());
- waitSet->IncRef();
- LeaveSpinLock(&m_spinLock);
- waitSet->Wait();
- EnterSpinLock(&m_spinLock);
- waitSet->DecRef();
-
- }
- LeaveSpinLock(&m_spinLock);
-}
-
-//===========================================================================
-void CLock::EnterWrite () {
- EnterSpinLock(&m_spinLock);
- for (;;) {
-
- // If there are no readers or writers, claim this lock for writing
- if (!m_readerCount && !m_writerCount) {
- ++m_writerCount;
- break;
- }
-
- // Otherwise, wait until the existing writer or all existing readers
- // release the lock
- CLockWaitSet * waitSet = m_waitSet = (m_waitSet ? m_waitSet : CLockWaitSetAllocator::Alloc());
- waitSet->IncRef();
- LeaveSpinLock(&m_spinLock);
- waitSet->Wait();
- EnterSpinLock(&m_spinLock);
- waitSet->DecRef();
-
- }
- LeaveSpinLock(&m_spinLock);
-}
-
-//===========================================================================
-void CLock::LeaveRead () {
- EnterSpinLock(&m_spinLock);
-
- // If this is the last reader, signal waiting threads to try claiming
- // the lock again
- ASSERT(m_readerCount);
- if (!--m_readerCount)
- if (m_waitSet) {
- m_waitSet->Signal();
- m_waitSet = nil;
- }
-
- LeaveSpinLock(&m_spinLock);
-}
-
-//===========================================================================
-void CLock::LeaveWrite () {
- EnterSpinLock(&m_spinLock);
-
- // This is the last writer. Signal waiting threads to try claiming the
- // lock again.
- ASSERT(m_writerCount == 1);
- --m_writerCount;
- if (m_waitSet) {
- m_waitSet->Signal();
- m_waitSet = nil;
- }
-
- LeaveSpinLock(&m_spinLock);
-}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Time.cpp b/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Time.cpp
deleted file mode 100644
index 6f344434..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Time.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/Win32/pnUtW32Time.cpp
-*
-***/
-
-#include "../pnUtils.h"
-
-
-/*****************************************************************************
-*
-* Local functions
-*
-***/
-
-//============================================================================
-static void FormatTime (
- uint64_t time,
- wchar_t const dateFmt[],
- wchar_t const timeFmt[],
- unsigned chars,
- wchar_t * buffer
-) {
- COMPILER_ASSERT(sizeof(FILETIME) == sizeof(uint64_t));
-
- SYSTEMTIME sysTime;
- FileTimeToSystemTime((FILETIME *)&time, &sysTime);
-
- unsigned offset = GetDateFormatW(
- LOCALE_SYSTEM_DEFAULT,
- 0,
- &sysTime,
- dateFmt,
- buffer,
- chars
- );
-
- if (timeFmt) {
- // if we printed any characters, move offset back to overwrite the string terminator
- if (offset)
- --offset;
-
- offset += GetTimeFormatW(
- LOCALE_SYSTEM_DEFAULT,
- 0,
- &sysTime,
- timeFmt,
- buffer + offset,
- chars - offset
- );
- }
-
- // if we didn't print any characters, NULL terminate the buffer
- if (!offset && chars)
- buffer[0] = 0;
-}
-
-
-/*****************************************************************************
-*
-* Exported functions
-*
-***/
-
-#ifdef HS_BUILD_FOR_WIN32
-
-//===========================================================================
-void TimeGetDesc (
- uint64_t time,
- TimeDesc * desc
-) {
- ASSERT(desc);
-
- SYSTEMTIME sysTime;
- COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
- FileTimeToSystemTime((FILETIME *) &time, &sysTime);
-
- desc->year = sysTime.wYear;
- desc->month = sysTime.wMonth;
- desc->day = sysTime.wDay;
- desc->dayOfWeek = sysTime.wDayOfWeek;
- desc->hour = sysTime.wHour;
- desc->minute = sysTime.wMinute;
- desc->second = sysTime.wSecond;
-}
-
-//============================================================================
-uint64_t TimeGetTime () {
- uint64_t time;
- COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
- GetSystemTimeAsFileTime((FILETIME *) &time);
- return time;
-}
-
-//============================================================================
-uint64_t TimeGetLocalTime () {
- uint64_t time;
- COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
- GetSystemTimeAsFileTime((FILETIME *) &time);
- FileTimeToLocalFileTime((FILETIME *) &time, (FILETIME *) &time);
- return time;
-}
-
-//============================================================================
-void TimePrettyPrint (
- uint64_t time,
- unsigned chars,
- wchar_t * buffer
-) {
- FormatTime(
- time,
- L"ddd MMM dd',' yyyy ",
- L"hh':'mm':'ss tt",
- chars,
- buffer
- );
-}
-
-
-#endif // HS_BUILD_FOR_WIN32
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h
index c252179c..3b7bda2d 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h
@@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnUtList.h"
#include "pnUtHash.h"
#include "pnUtPriQ.h"
-#include "pnUtSync.h"
#include "pnUtTime.h"
#include "pnUtStr.h"
#include "pnUtRef.h"
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.cpp
index 77549696..95df9bb7 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.cpp
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.cpp
@@ -106,86 +106,6 @@ void PathRemoveFilename (
PathMakePath(dst, dstChars, drive, dir, 0, 0);
}
-//===========================================================================
-void PathRemoveExtension (
- wchar_t *dst,
- const wchar_t src[],
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(src);
- ASSERT(dstChars);
-
- wchar_t drive[MAX_DRIVE];
- wchar_t dir[MAX_DIR];
- wchar_t fname[MAX_FNAME];
- PathSplitPath(src, drive, dir, fname, 0);
- PathMakePath(dst, dstChars, drive, dir, fname, 0);
-}
-
-//===========================================================================
-void PathSetExtension (
- wchar_t *dst,
- const wchar_t src[],
- const wchar_t ext[],
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(src);
- ASSERT(dst != ext);
- ASSERT(dstChars);
-
- wchar_t drive[MAX_DRIVE];
- wchar_t dir[MAX_DIR];
- wchar_t fname[MAX_FNAME];
- PathSplitPath(src, drive, dir, fname, 0);
- PathMakePath(dst, dstChars, drive, dir, fname, ext);
-}
-
-//===========================================================================
-void PathAddExtension (
- wchar_t *dst,
- const wchar_t src[],
- const wchar_t ext[],
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(src);
- ASSERT(dst != ext);
- ASSERT(dstChars);
-
- wchar_t drive[MAX_DRIVE];
- wchar_t dir[MAX_DIR];
- wchar_t fname[MAX_FNAME];
- wchar_t oldext[MAX_EXT];
- PathSplitPath(src, drive, dir, fname, oldext);
- PathMakePath(
- dst,
- dstChars,
- drive,
- dir,
- fname,
- oldext[0] ? oldext : ext
- );
-}
-
-//===========================================================================
-void PathRemoveDirectory (
- wchar_t *dst,
- const wchar_t src[],
- unsigned dstChars
-) {
- ASSERT(dst);
- ASSERT(src);
- ASSERT(dstChars);
-
- wchar_t fname[MAX_FNAME];
- wchar_t ext[MAX_EXT];
- PathSplitPath(src, 0, 0, fname, ext);
- PathMakePath(dst, dstChars, 0, 0, fname, ext);
-}
-
-
/*****************************************************************************
*
* Email formatting functions
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h
index 5eb8c9a4..63310dcf 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h
@@ -97,43 +97,10 @@ void PathGetProgramName (
wchar_t * dst,
unsigned dstChars
);
-void PathGetModuleName (
- wchar_t * dst,
- unsigned dstChars
-);
-
-// this function will use the current directory if is a relative path
-// (see PathSetCurrentDirectory/PathGetCurrentDirectory)
-bool PathFromString (
- wchar_t * dst,
- const wchar_t src[],
- unsigned dstChars
-);
-bool PathFromString (
- wchar_t * dst,
- const wchar_t src[],
- unsigned dstChars,
- const wchar_t baseDir[]
-);
bool PathDoesFileExist (
const wchar_t fileName[]
);
-bool PathDoesDirectoryExist (
- const wchar_t directory[]
-);
-
-bool PathDeleteFile (
- const wchar_t file[]
-);
-bool PathMoveFile (
- const wchar_t src[],
- const wchar_t dst[]
-);
-bool PathCopyFile (
- const wchar_t src[],
- const wchar_t dst[]
-);
/*****************************************************************************
@@ -174,64 +141,6 @@ void PathRemoveFilename (
unsigned dstChars
);
-// c:\file.txt => c:\dir1\dir2\file
-void PathRemoveExtension (
- wchar_t * dst,
- const wchar_t src[],
- unsigned dstChars
-);
-
-// c:\file + .out => c:\file.out
-// c:\file. + .out => c:\file.out
-// c:\file.txt + .out => c:\file.out
-void PathSetExtension (
- wchar_t * dst,
- const wchar_t src[],
- const wchar_t ext[],
- unsigned dstChars
-);
-
-// c:\file + .out => c:\file.out
-// c:\file. + .out => c:\file.
-// c:\file.txt + .out => c:\file.txt
-void PathAddExtension (
- wchar_t * dst,
- const wchar_t src[],
- const wchar_t ext[],
- unsigned dstChars
-);
-
-// c:\dir1\dir2\file.txt => file.txt
-void PathRemoveDirectory (
- wchar_t * dst,
- const wchar_t src[],
- unsigned dstChars
-);
-
-// c:\dir1\dir2\file.txt - c:\dir1 => .\dir2\file.txt
-// c:\dir1\dir2\file1.txt - c:\dir1\dir4\file2.txt => ..\dir4\file2.txt
-bool PathMakeRelative (
- wchar_t * dst,
- unsigned fromFlags,
- const wchar_t from[],
- unsigned toFlags,
- const wchar_t to[],
- unsigned dstChars
-);
-bool PathIsRelative (
- const wchar_t src[]
-);
-
-const wchar_t * PathFindFilename (const wchar_t path[]);
-inline wchar_t * PathFindFilename (wchar_t * path) {
- return const_cast(PathFindFilename(const_cast(path)));
-}
-
-const wchar_t * PathFindExtension (const wchar_t path[]);
-inline wchar_t * PathFindExtension (wchar_t * path) {
- return const_cast(PathFindExtension(const_cast(path)));
-}
-
/*****************************************************************************
*
@@ -263,15 +172,7 @@ EPathCreateDirError PathCreateDirectory (
const wchar_t path[],
unsigned flags
);
-void PathDeleteDirectory (
- const wchar_t path[],
- unsigned flags
-);
-
-// Set directory
-bool PathSetCurrentDirectory (const wchar_t path[]);
-void PathSetProgramDirectory ();
// Get directory
@@ -279,14 +180,6 @@ void PathGetProgramDirectory (
wchar_t * dst,
unsigned dstChars
);
-void PathGetCurrentDirectory (
- wchar_t * dst,
- unsigned dstChars
-);
-void PathGetTempDirectory (
- wchar_t * dst,
- unsigned dstChars
-);
// Product and user-specific common directory locations
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp
index 016bb7b6..b290ae65 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp
@@ -120,18 +120,6 @@ static chartype * IStrChr (chartype * str, findchartype ch, unsigned chars) {
return nil;
}
-//===========================================================================
-template
-static chartype * IStrChrR (chartype * str, findchartype ch) {
- chartype * start = str;
- for (; *str; ++str)
- NULL_STMT;
- while (str-- > start)
- if (*str == ch)
- return str;
- return NULL;
-}
-
//===========================================================================
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar_t * source[], unsigned destChars) {
unsigned ch = *(*source)++;
@@ -226,20 +214,6 @@ static int IStrCmpI (const chartype str1[], const chartype str2[], unsigned char
return 0;
}
-//===========================================================================
-// returns StrLen(dest)
-template
-static unsigned IStrCopyLen (chartype * dest, const chartype source[], unsigned chars) {
- chartype * const start = dest;
- while ((chars > 1) && ((*dest = *source++) != 0)) {
- --chars;
- ++dest;
- }
- if (chars)
- *dest = 0;
- return dest - start;
-}
-
//===========================================================================
template
static void IStrPack (chartype * dest, const chartype source[], unsigned chars) {
@@ -273,46 +247,6 @@ static chartype * IStrStr (chartype source[], const chartype match[]) {
return nil;
}
-
-//===========================================================================
-template
-static chartype * IStrStrI (chartype source[], const chartype match[]) {
- if (!*match)
- return source;
-
- for (chartype * curr = source; *curr; ++curr) {
- chartype * s1 = curr;
- const chartype * s2 = match;
- while (*s1 && *s2 && (CharLowerFast(*s1) == CharLowerFast(*s2)))
- s1++, s2++;
- if (!*s2)
- return curr;
- }
-
- return nil;
-}
-
-//===========================================================================
-template
-static void IStrLower (chartype * dest, unsigned chars) {
- while ((chars > 1) && ((*dest = CharLowerFast(*dest)) != 0)) {
- --chars;
- ++dest;
- }
-}
-
-//===========================================================================
-template
-static void IStrLower (chartype * dest, const chartype source[], unsigned chars) {
- while ((chars > 1) && ((*dest = CharLowerFast(*source)) != 0)) {
- --chars;
- ++dest;
- ++source;
- }
- if (chars)
- *dest = 0;
-}
-
//===========================================================================
template
static uint32_t IStrHash (const chartype str[], unsigned chars) {
@@ -496,26 +430,6 @@ const wchar_t * StrChr (const wchar_t str[], wchar_t ch, unsigned chars) {
return IStrChr(str, ch, chars);
}
-//===========================================================================
-char * StrChrR (char * str, char ch) {
- return IStrChrR(str, ch);
-}
-
-//===========================================================================
-wchar_t * StrChrR (wchar_t * str, wchar_t ch) {
- return IStrChrR(str, ch);
-}
-
-//===========================================================================
-const char * StrChrR (const char str[], char ch) {
- return IStrChrR(str, ch);
-}
-
-//===========================================================================
-const wchar_t * StrChrR (const wchar_t str[], wchar_t ch) {
- return IStrChrR(str, ch);
-}
-
//===========================================================================
unsigned StrPrintf (char * dest, unsigned count, const char format[], ...) {
va_list argList;
@@ -576,16 +490,6 @@ void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars) {
IStrCopy(dest, source, chars);
}
-//===========================================================================
-unsigned StrCopyLen (char * dest, const char source[], unsigned chars) {
- return IStrCopyLen(dest, source, chars);
-}
-
-//===========================================================================
-unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars) {
- return IStrCopyLen(dest, source, chars);
-}
-
//===========================================================================
void StrPack (char * dest, const char source[], unsigned chars) {
IStrPack(dest, source, chars);
@@ -616,26 +520,6 @@ const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]) {
return IStrStr(source, match);
}
-//===========================================================================
-char * StrStrI (char * source, const char match[]) {
- return IStrStrI(source, match);
-}
-
-//===========================================================================
-const char * StrStrI (const char source[], const char match[]) {
- return IStrStrI(source, match);
-}
-
-//===========================================================================
-wchar_t * StrStrI (wchar_t * source, const wchar_t match[]) {
- return IStrStrI(source, match);
-}
-
-//===========================================================================
-const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]) {
- return IStrStrI(source, match);
-}
-
//===========================================================================
unsigned StrLen (const char str[]) {
return IStrLen(str);
@@ -647,29 +531,6 @@ unsigned StrLen (const wchar_t str[]) {
}
//===========================================================================
-unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars) {
- char * destCurr = dest;
- char * destTerm = dest + destChars;
- while (*source && (destCurr + 1 < destTerm))
- if (!ICharUnicodeToUtf8(&destCurr, &source, destTerm - destCurr - 1))
- break;
- if (destCurr < destTerm)
- *destCurr = 0;
- return destCurr - dest; // dest chars not including null terminator
-}
-
-//===========================================================================
-unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars) {
- wchar_t * destCurr = dest;
- wchar_t * destTerm = dest + destChars;
- while (*source && (destCurr + 1 < destTerm))
- ICharUtf8ToUnicode(&destCurr, &source);
- if (destCurr < destTerm)
- *destCurr = 0;
- return destCurr - dest; // dest chars not including null terminator
-}
-
-//============================================================================
float StrToFloat (const char source[], const char ** endptr) {
return (float) strtod(source, const_cast(endptr));
}
@@ -710,26 +571,6 @@ unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int rad
}
//===========================================================================
-void StrLower (char * dest, unsigned chars) {
- IStrLower(dest, chars);
-}
-
-//===========================================================================
-void StrLower (wchar_t * dest, unsigned chars) {
- IStrLower(dest, chars);
-}
-
-//===========================================================================
-void StrLower (char * dest, const char source[], unsigned chars) {
- IStrLower(dest, source, chars);
-}
-
-//===========================================================================
-void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars) {
- IStrLower(dest, source, chars);
-}
-
-//============================================================================
uint32_t StrHash (const char str[], unsigned chars) {
return IStrHash(str, chars);
}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h
index 3ab23464..949737e9 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h
@@ -61,9 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
inline char CharLowerFast (char ch) { return ((ch >= 'A') && (ch <= 'Z')) ? (char )(ch + 'a' - 'A') : ch; }
inline wchar_t CharLowerFast (wchar_t ch) { return ((ch >= L'A') && (ch <= L'Z')) ? (wchar_t)(ch + L'a' - L'A') : ch; }
-inline char CharUpperFast (char ch) { return ((ch >= 'a') && (ch <= 'z')) ? (char )(ch + 'A' - 'a') : ch; }
-inline wchar_t CharUpperFast (wchar_t ch) { return ((ch >= L'a') && (ch <= L'z')) ? (wchar_t)(ch + L'A' - L'a') : ch; }
-
unsigned StrBytes (const char str[]); // includes space for terminator
unsigned StrBytes (const wchar_t str[]); // includes space for terminator
@@ -101,22 +98,9 @@ const char * StrStr (const char source[], const char match[]);
wchar_t * StrStr (wchar_t * source, const wchar_t match[]);
const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]);
-char * StrStrI (char * source, const char match[]);
-const char * StrStrI (const char source[], const char match[]);
-wchar_t * StrStrI (wchar_t * source, const wchar_t match[]);
-const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]);
-
-char * StrChrR (char * str, char ch);
-wchar_t * StrChrR (wchar_t * str, wchar_t ch);
-const char * StrChrR (const char str[], char ch);
-const wchar_t * StrChrR (const wchar_t str[], wchar_t ch);
-
void StrCopy (char * dest, const char source[], unsigned chars);
void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars);
-unsigned StrCopyLen (char * dest, const char source[], unsigned chars);
-unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars);
-
void StrPack (char * dest, const char source[], unsigned chars);
void StrPack (wchar_t * dest, const wchar_t source[], unsigned chars);
@@ -126,9 +110,6 @@ unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars, uns
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars);
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars, unsigned codePage);
-unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars);
-unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars);
-
float StrToFloat (const char source[], const char ** endptr);
float StrToFloat (const wchar_t source[], const wchar_t ** endptr);
@@ -140,11 +121,6 @@ unsigned StrToUnsigned (wchar_t source[], wchar_t ** endptr, int radix);
unsigned StrToUnsigned (const char source[], const char ** endptr, int radix);
unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int radix);
-void StrLower (char * dest, unsigned chars = (unsigned) -1);
-void StrLower (wchar_t * dest, unsigned chars = (unsigned) -1);
-void StrLower (char * dest, const char source[], unsigned chars);
-void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars);
-
uint32_t StrHash (const char str[], unsigned chars = (unsigned)-1);
uint32_t StrHash (const wchar_t str[], unsigned chars = (unsigned)-1);
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h
deleted file mode 100644
index dda44786..00000000
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtSync.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSync.h
-*
-***/
-
-#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSYNC_H
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTSYNC_H
-
-#include "Pch.h"
-
-/****************************************************************************
-*
-* CLock
-* (reader/writer lock)
-*
-***/
-
-class CLockWaitSet;
-
-class CLock {
-private:
- CLockWaitSet * m_waitSet;
- long m_spinLock;
- unsigned m_readerCount;
- unsigned m_writerCount;
-
-public:
- CLock ();
- ~CLock ();
- void EnterRead ();
- void EnterWrite ();
- void LeaveRead ();
- void LeaveWrite ();
-};
-
-#endif
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp b/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp
index 4f892520..31e83eb0 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp
@@ -39,53 +39,107 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtTime.cpp
-*
-***/
-
#include "pnUtTime.h"
+#if HS_BUILD_FOR_UNIX
+#include
+#include
+#endif
+
+/******************************************************************************
+ * I've combined all the pnUtils Time stuff in here and made it work cross-
+ * platform as best as possible.
+ *
+ * At some point, hsTimer needs to be rewritten to ensure that it's fully
+ * corss-platform and using a reliable millisecond clock.
+ * When that happens, these functions should be merged into hsTimer.
+ *
+ * -- dpogue (April 14, 2012)
+ *
+ *****************************************************************************/
+
+namespace pnUtilsExe {
+
+uint32_t TimeGetTickCount () {
+#if HS_BUILD_FOR_WIN32
+ return GetTickCount();
+#else
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) != 0)
+ return 0;
+
+ return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+#endif
+}
/*****************************************************************************
*
-* Exports
+* Time adjustment functions
+*
+* For debug builds, adjust the initial time value so that the high
+* bit or the time value itself is about to wrap, to catch application
+* bugs that don't handle wrapping or depend on the high bit's value.
*
***/
+static uint32_t s_adjustment;
+
//===========================================================================
-void TimeGetElapsedDesc (
- uint32_t minutesElapsed,
- TimeElapsedDesc * desc
-) {
-
- const unsigned kMinutesPerHour = 60;
- const unsigned kMinutesPerDay = 1440;
- const unsigned kMinutesPerWeek = 10080;
- const unsigned kMinutesPerMonth = 43830;
- const unsigned kMinutesPerYear = 525960;
-
- uint32_t & elapsed = minutesElapsed;
- desc->years = (elapsed / kMinutesPerYear); elapsed -= desc->years * kMinutesPerYear;
- desc->months = (elapsed / kMinutesPerMonth); elapsed -= desc->months * kMinutesPerMonth;
- desc->weeks = (elapsed / kMinutesPerWeek); elapsed -= desc->weeks * kMinutesPerWeek;
- desc->days = (elapsed / kMinutesPerDay); elapsed -= desc->days * kMinutesPerDay;
- desc->hours = (elapsed / kMinutesPerHour); elapsed -= desc->hours * kMinutesPerHour;
- desc->minutes = elapsed;
+static void InitializeAdjustment () {
+ ASSERT(!s_adjustment);
+ uint32_t currTime = TimeGetTickCount();
+ uint32_t startBits = (currTime & 0x80) ? 0x7fff0000 : 0xffff0000;
+ uint32_t startMask = 0xffff0000;
+ s_adjustment = (((currTime & ~startMask) | startBits) - currTime) | 1;
+ ASSERT(s_adjustment);
+}
+//===========================================================================
+AUTO_INIT_FUNC(AutoInitializeAdjustment) {
+ if (!s_adjustment)
+ InitializeAdjustment();
}
-//============================================================================
+} using namespace pnUtilsExe;
+
+
+/*****************************************************************************
+*
+* Exports
+*
+***/
+
uint32_t TimeGetSecondsSince2001Utc () {
uint64_t time = TimeGetTime();
uint32_t seconds = (uint32_t)((time - kTime1601To2001) / kTimeIntervalsPerSecond);
return seconds;
}
-//============================================================================
-uint32_t TimeGetSecondsSince1970Utc () {
- uint64_t time = TimeGetTime();
- uint32_t seconds = (uint32_t)((time - kTime1601To1970) / kTimeIntervalsPerSecond);
- return seconds;
+uint64_t TimeGetTime () {
+#ifdef HS_BUILD_FOR_WIN32
+ uint64_t time;
+ COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
+ GetSystemTimeAsFileTime((FILETIME *) &time);
+ return time;
+#else
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts))
+ return 0;
+
+ long long time = ts.tv_sec * 1000000000LL + ts.tv_nsec;
+
+ return time / 100;
+#endif
+}
+
+uint32_t TimeGetMs () {
+#ifdef HS_DEBUGGING
+ // For debug builds, return an adjusted timer value
+ if (!s_adjustment)
+ InitializeAdjustment();
+ return TimeGetTickCount() + s_adjustment;
+#else
+ // For release builds, just return the operating system's timer
+ return TimeGetTickCount();
+#endif
}
diff --git a/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h b/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h
index 6140683c..484f7a5d 100644
--- a/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h
+++ b/Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h
@@ -50,48 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h"
-/*****************************************************************************
-*
-* Time formatting functions
-*
-***/
-
-struct TimeDesc {
- unsigned year;
- unsigned month; // [1, 12]
- unsigned day;
- unsigned dayOfWeek; // [0, 6]
- unsigned hour; // [0, 23]
- unsigned minute; // [0, 59]
- unsigned second; // [0, 59]
-};
-
-struct TimeElapsedDesc {
- unsigned years;
- unsigned months; // [0, 12]
- unsigned days; // [0, 7]
- unsigned weeks; // [0, 6]
- unsigned hours; // [0, 23]
- unsigned minutes; // [0, 59]
-};
-
-void TimeGetDesc (
- uint64_t time,
- TimeDesc * desc
-);
-
-void TimeGetElapsedDesc (
- uint32_t minutesElapsed,
- TimeElapsedDesc * desc
-);
-
-void TimePrettyPrint (
- uint64_t time,
- unsigned chars,
- wchar_t * buffer
-);
-
-
/*****************************************************************************
*
* Time query functions
@@ -109,21 +67,12 @@ uint32_t TimeGetMs ();
// 100 nanosecond intervals; won't wrap in our lifetimes
uint64_t TimeGetTime ();
-uint64_t TimeGetLocalTime ();
-
-// Minutes elapsed since 2001 UTC
-uint32_t TimeGetMinutes ();
// Seconds elapsed since 00:00:00 January 1, 2001 UTC
uint32_t TimeGetSecondsSince2001Utc ();
-// Seconds elapsed since 00:00:00 January 1, 1970 UTC (the Unix Epoch)
-uint32_t TimeGetSecondsSince1970Utc ();
-
// These magic numbers taken from Microsoft's "Shared Source CLI implementation" source code.
// http://msdn.microsoft.com/library/en-us/Dndotnet/html/mssharsourcecli.asp
-
-static const uint64_t kTime1601To1970 = 11644473600 * kTimeIntervalsPerSecond;
static const uint64_t kTime1601To2001 = 12622780800 * kTimeIntervalsPerSecond;
#endif
diff --git a/Sources/Plasma/NucleusLib/pnUtilsExe/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnUtilsExe/CMakeLists.txt
deleted file mode 100644
index dbe63c74..00000000
--- a/Sources/Plasma/NucleusLib/pnUtilsExe/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-include_directories("../../CoreLib")
-include_directories("../../NucleusLib")
-
-set(pnUtilsExe_HEADERS
- Intern.h
- Pch.h
-)
-
-set(pnUtilsExe_PRIVATE
- Private/pnUteTime.cpp
-)
-
-if(WIN32)
- set(pnUtilsExe_WIN32
- Private/Win32/pnUteW32Time.cpp
- )
-else()
- set(pnUtilsExe_UNIX
- Private/Unix/pnUteUxTime.cpp
- )
-endif()
-
-add_library(pnUtilsExe STATIC ${pnUtilsExe_HEADERS} ${pnUtilsExe_PRIVATE}
- ${pnUtilsExe_UNIX} ${pnUtilsExe_WIN32})
-
-source_group("Header Files" FILES ${pnUtilsExe_HEADERS})
-source_group("Private" FILES ${pnUtilsExe_PRIVATE})
-if(WIN32)
- source_group("Private\\Win32" FILES ${pnUtilsExe_WIN32})
-else()
- source_group("Private\\Unix" FILES ${pnUtilsExe_UNIX})
-endif()
diff --git a/Sources/Plasma/NucleusLib/pnUtilsExe/Intern.h b/Sources/Plasma/NucleusLib/pnUtilsExe/Intern.h
deleted file mode 100644
index 5e0c8878..00000000
--- a/Sources/Plasma/NucleusLib/pnUtilsExe/Intern.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Intern.h
-*
-***/
-
-#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILSEXE_INTERN_H
-#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Intern.h included more than once"
-#endif
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILSEXE_INTERN_H
-
-
-namespace pnUtilsExe {
-
-/*****************************************************************************
-*
-* OsTime.cpp
-*
-***/
-
-uint32_t TimeGetTickCount ();
-
-
-} // namespace pnUtilsExe
diff --git a/Sources/Plasma/NucleusLib/pnUtilsExe/Pch.h b/Sources/Plasma/NucleusLib/pnUtilsExe/Pch.h
deleted file mode 100644
index 32908b69..00000000
--- a/Sources/Plasma/NucleusLib/pnUtilsExe/Pch.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Pch.h
-*
-***/
-
-#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILSEXE_PCH_H
-#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Pch.h included more than once"
-#endif
-#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILSEXE_PCH_H
-
-
-#include "pnUtils/pnUtils.h"
-#include "Intern.h"
-
-#include
diff --git a/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Unix/pnUteUxTime.cpp b/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Unix/pnUteUxTime.cpp
deleted file mode 100644
index 74d5f374..00000000
--- a/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Unix/pnUteUxTime.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Unix/pnUteUxTime.cpp
-*
-***/
-
-#include "../../Pch.h"
-#pragma hdrstop
diff --git a/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Win32/pnUteW32Time.cpp b/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Win32/pnUteW32Time.cpp
deleted file mode 100644
index 42ab4ef6..00000000
--- a/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Win32/pnUteW32Time.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Private/Win32/pnUteW32Time.cpp
-*
-***/
-
-#include "../../Pch.h"
-#pragma hdrstop
-
-#ifdef HS_BUILD_FOR_WIN32
-
-namespace pnUtilsExe {
-
-/*****************************************************************************
-*
-* Module functions
-*
-***/
-
-//============================================================================
-uint32_t TimeGetTickCount () {
- return GetTickCount();
-}
-
-
-} // namespace pnUtilsExe
-
-#endif // HS_BUILD_FOR_WIN32
diff --git a/Sources/Plasma/NucleusLib/pnUtilsExe/Private/pnUteTime.cpp b/Sources/Plasma/NucleusLib/pnUtilsExe/Private/pnUteTime.cpp
deleted file mode 100644
index c28eda65..00000000
--- a/Sources/Plasma/NucleusLib/pnUtilsExe/Private/pnUteTime.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-/*****************************************************************************
-*
-* $/Plasma20/Sources/Plasma/NucleusLib/pnUtilsExe/Private/pnUteTime.cpp
-*
-***/
-
-#include "../Pch.h"
-#pragma hdrstop
-
-
-namespace pnUtilsExe {
-
-/*****************************************************************************
-*
-* Time adjustment functions
-*
-* For debug builds, adjust the initial time value so that the high
-* bit or the time value itself is about to wrap, to catch application
-* bugs that don't handle wrapping or depend on the high bit's value.
-*
-***/
-
-static uint32_t s_adjustment;
-
-//===========================================================================
-static void InitializeAdjustment () {
- ASSERT(!s_adjustment);
- uint32_t currTime = TimeGetTickCount();
- uint32_t startBits = (currTime & 0x80) ? 0x7fff0000 : 0xffff0000;
- uint32_t startMask = 0xffff0000;
- s_adjustment = (((currTime & ~startMask) | startBits) - currTime) | 1;
- ASSERT(s_adjustment);
-}
-
-//===========================================================================
-AUTO_INIT_FUNC(AutoInitializeAdjustment) {
- if (!s_adjustment)
- InitializeAdjustment();
-}
-
-} using namespace pnUtilsExe;
-
-
-/*****************************************************************************
-*
-* Exports
-*
-***/
-
-//============================================================================
-uint32_t TimeGetMs () {
-#ifdef HS_DEBUGGING
-
- // For debug builds, return an adjusted timer value
- if (!s_adjustment)
- InitializeAdjustment();
- return TimeGetTickCount() + s_adjustment;
-
-#else
-
- // For release builds, just return the operating system's timer
- return TimeGetTickCount();
-
-#endif
-}
-
diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h b/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h
index a3bfe83a..29c04fca 100644
--- a/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h
+++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h
@@ -56,6 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnNetCli/pnNetCli.h"
#include "pnProduct/pnProduct.h"
+#include "hsThread.h"
#define USES_PROTOCOL_CLI2AUTH
#define USES_PROTOCOL_CLI2GAME
diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
index 3243669b..eddb3971 100644
--- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
+++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
@@ -62,7 +62,7 @@ namespace Ngl { namespace File {
struct CliFileConn : AtomicRef {
LINK(CliFileConn) link;
- CLock sockLock; // to protect the socket pointer so we don't nuke it while using it
+ hsReaderWriterLock sockLock; // to protect the socket pointer so we don't nuke it while using it
AsyncSocket sock;
char name[MAX_PATH];
plNetAddress addr;
@@ -283,12 +283,12 @@ static void UnlinkAndAbandonConn_CS (CliFileConn * conn) {
needsDecref = false;
}
else {
- conn->sockLock.EnterRead();
+ conn->sockLock.LockForReading();
if (conn->sock) {
AsyncSocketDisconnect(conn->sock, true);
needsDecref = false;
}
- conn->sockLock.LeaveRead();
+ conn->sockLock.UnlockForReading();
}
if (needsDecref) {
conn->DecRef("Lifetime");
@@ -311,9 +311,9 @@ static void NotifyConnSocketConnect (CliFileConn * conn) {
}
else
{
- conn->sockLock.EnterRead();
+ conn->sockLock.LockForReading();
AsyncSocketDisconnect(conn->sock, true);
- conn->sockLock.LeaveRead();
+ conn->sockLock.UnlockForReading();
}
}
s_critsect.Leave();
@@ -468,9 +468,9 @@ static bool SocketNotifyCallback (
*userState = conn;
s_critsect.Enter();
{
- conn->sockLock.EnterWrite();
+ conn->sockLock.LockForWriting();
conn->sock = sock;
- conn->sockLock.LeaveWrite();
+ conn->sockLock.UnlockForWriting();
conn->cancelId = 0;
}
s_critsect.Leave();
@@ -690,9 +690,9 @@ void CliFileConn::AutoPing () {
IncRef("PingTimer");
timerCritsect.Enter();
{
- sockLock.EnterRead();
+ sockLock.LockForReading();
unsigned timerPeriod = sock ? 0 : kAsyncTimeInfinite;
- sockLock.LeaveRead();
+ sockLock.UnlockForReading();
AsyncTimerCreate(
&pingTimer,
@@ -718,7 +718,7 @@ void CliFileConn::StopAutoPing () {
//============================================================================
void CliFileConn::TimerPing () {
- sockLock.EnterRead();
+ sockLock.LockForReading();
for (;;) {
if (!sock) // make sure it exists
break;
@@ -745,18 +745,18 @@ void CliFileConn::TimerPing () {
}
break;
}
- sockLock.LeaveRead();
+ sockLock.UnlockForReading();
}
//============================================================================
void CliFileConn::Destroy () {
AsyncSocket oldSock = nil;
- sockLock.EnterWrite();
+ sockLock.LockForWriting();
{
SWAP(oldSock, sock);
}
- sockLock.LeaveWrite();
+ sockLock.UnlockForWriting();
if (oldSock)
AsyncSocketDelete(oldSock);
@@ -765,11 +765,11 @@ void CliFileConn::Destroy () {
//============================================================================
void CliFileConn::Send (const void * data, unsigned bytes) {
- sockLock.EnterRead();
+ sockLock.LockForReading();
if (sock) {
AsyncSocketSend(sock, data, bytes);
}
- sockLock.LeaveRead();
+ sockLock.UnlockForReading();
}
//============================================================================
diff --git a/Sources/Tools/MaxMain/CMakeLists.txt b/Sources/Tools/MaxMain/CMakeLists.txt
index 8eb3773f..6c3c7b81 100644
--- a/Sources/Tools/MaxMain/CMakeLists.txt
+++ b/Sources/Tools/MaxMain/CMakeLists.txt
@@ -191,7 +191,6 @@ target_link_libraries(MaxMain pnProduct)
target_link_libraries(MaxMain pnSceneObject)
target_link_libraries(MaxMain pnTimer)
target_link_libraries(MaxMain pnUtils)
-target_link_libraries(MaxMain pnUtilsExe)
target_link_libraries(MaxMain pnUUID)
if (WIN32)
diff --git a/Sources/Tools/MaxPlasmaLights/CMakeLists.txt b/Sources/Tools/MaxPlasmaLights/CMakeLists.txt
index 0506efa1..bfb3b1d3 100644
--- a/Sources/Tools/MaxPlasmaLights/CMakeLists.txt
+++ b/Sources/Tools/MaxPlasmaLights/CMakeLists.txt
@@ -123,7 +123,6 @@ target_link_libraries(MaxPlasmaLights pnProduct)
target_link_libraries(MaxPlasmaLights pnSceneObject)
target_link_libraries(MaxPlasmaLights pnTimer)
target_link_libraries(MaxPlasmaLights pnUtils)
-target_link_libraries(MaxPlasmaLights pnUtilsExe)
target_link_libraries(MaxPlasmaLights pnUUID)
if (WIN32)
diff --git a/Sources/Tools/plResBrowser/CMakeLists.txt b/Sources/Tools/plResBrowser/CMakeLists.txt
index 7291b2d0..ceb914cc 100644
--- a/Sources/Tools/plResBrowser/CMakeLists.txt
+++ b/Sources/Tools/plResBrowser/CMakeLists.txt
@@ -51,7 +51,6 @@ target_link_libraries(plResBrowser pnProduct)
target_link_libraries(plResBrowser pnSceneObject)
target_link_libraries(plResBrowser pnTimer)
target_link_libraries(plResBrowser pnUtils)
-target_link_libraries(plResBrowser pnUtilsExe)
if (WIN32)
target_link_libraries(plResBrowser Rpcrt4)
@@ -66,4 +65,4 @@ endif(WIN32)
source_group("Source Files" FILES ${plResBrowser_SOURCES})
source_group("Header Files" FILES ${plResBrowser_HEADERS})
-source_group("Resource Files" FILES ${plResBrowser_RESOURCES})
\ No newline at end of file
+source_group("Resource Files" FILES ${plResBrowser_RESOURCES})