mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +00:00
Remove some unused CoreLib stuff
- plRefCnt duplicates hsRefCnt (Wtf?) - hsNamedPipeStream nasty, unused - VDB stuff in hsStream left over from Plasma 1 (realMyst/DIRT) - hsColor32 moved to be less promiscuous
This commit is contained in:
@ -82,7 +82,6 @@ set(CoreLib_HEADERS
|
||||
plGeneric.h
|
||||
plLoadMask.h
|
||||
plQuality.h
|
||||
plRefCnt.h
|
||||
plString.h
|
||||
plTweak.h
|
||||
plViewTransform.h
|
||||
|
@ -246,43 +246,6 @@ inline void hsSwap(float& a, float& b)
|
||||
b = c;
|
||||
}
|
||||
|
||||
//======================================
|
||||
// Color32 Type
|
||||
//======================================
|
||||
struct hsColor32 {
|
||||
|
||||
uint8_t b, g, r, a;
|
||||
|
||||
inline void SetARGB(uint8_t aa, uint8_t rr, uint8_t gg, uint8_t bb)
|
||||
{
|
||||
this->a = aa;
|
||||
this->r = rr;
|
||||
this->g = gg;
|
||||
this->b = bb;
|
||||
}
|
||||
|
||||
// Compatibility inlines, should be depricated
|
||||
inline void Set(uint8_t rr, uint8_t gg, uint8_t bb)
|
||||
{
|
||||
this->r = rr;
|
||||
this->g = gg;
|
||||
this->b = bb;
|
||||
}
|
||||
inline void Set(uint8_t aa, uint8_t rr, uint8_t gg, uint8_t bb)
|
||||
{
|
||||
this->SetARGB(aa, rr, gg, bb);
|
||||
}
|
||||
|
||||
int operator==(const hsColor32& aa) const
|
||||
{
|
||||
return *(uint32_t*)&aa == *(uint32_t*)this;
|
||||
}
|
||||
int operator!=(const hsColor32& aa) { return !(aa == *this); }
|
||||
};
|
||||
hsCTypeDefStruct(hsColor32)
|
||||
typedef hsColor32 hsRGBAColor32;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Define a NOOP (null) statement
|
||||
//===========================================================================
|
||||
|
@ -45,6 +45,39 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "hsStream.h"
|
||||
|
||||
struct hsColor32 {
|
||||
|
||||
uint8_t b, g, r, a;
|
||||
|
||||
inline void SetARGB(uint8_t aa, uint8_t rr, uint8_t gg, uint8_t bb)
|
||||
{
|
||||
this->a = aa;
|
||||
this->r = rr;
|
||||
this->g = gg;
|
||||
this->b = bb;
|
||||
}
|
||||
|
||||
// Compatibility inlines, should be depricated
|
||||
inline void Set(uint8_t rr, uint8_t gg, uint8_t bb)
|
||||
{
|
||||
this->r = rr;
|
||||
this->g = gg;
|
||||
this->b = bb;
|
||||
}
|
||||
inline void Set(uint8_t aa, uint8_t rr, uint8_t gg, uint8_t bb)
|
||||
{
|
||||
this->SetARGB(aa, rr, gg, bb);
|
||||
}
|
||||
|
||||
int operator==(const hsColor32& aa) const
|
||||
{
|
||||
return *(uint32_t*)&aa == *(uint32_t*)this;
|
||||
}
|
||||
int operator!=(const hsColor32& aa) { return !(aa == *this); }
|
||||
};
|
||||
hsCTypeDefStruct(hsColor32)
|
||||
typedef hsColor32 hsRGBAColor32;
|
||||
|
||||
struct hsColorRGBA {
|
||||
float r,g,b,a;
|
||||
|
||||
|
@ -153,241 +153,3 @@ const void *hsVectorStream::GetData()
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
|
||||
hsNamedPipeStream::hsNamedPipeStream(uint8_t flags, uint32_t timeout) :
|
||||
fFlags(flags),
|
||||
fPipe(INVALID_HANDLE_VALUE),
|
||||
fReadMode(false),
|
||||
fTimeout(timeout)
|
||||
{
|
||||
memset(&fOverlap, 0, sizeof(OVERLAPPED));
|
||||
fOverlap.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
|
||||
}
|
||||
|
||||
hsNamedPipeStream::~hsNamedPipeStream()
|
||||
{
|
||||
CloseHandle(fOverlap.hEvent);
|
||||
fOverlap.hEvent = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::WaitForClientConnect()
|
||||
{
|
||||
// Look for a client connect (this should return zero since it's overlapped)
|
||||
BOOL ret = ConnectNamedPipe(fPipe, &fOverlap);
|
||||
if (ret)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
switch (GetLastError())
|
||||
{
|
||||
// Waiting for client to connect
|
||||
case ERROR_IO_PENDING:
|
||||
if (WaitForSingleObject(fOverlap.hEvent, fTimeout) == WAIT_OBJECT_0)
|
||||
return true;
|
||||
break;
|
||||
|
||||
// Client is already connected
|
||||
case ERROR_PIPE_CONNECTED:
|
||||
// if (SetEvent(fOverlap.hEvent))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::Open(const char *name, const char *mode)
|
||||
{
|
||||
wchar_t* wName = hsStringToWString(name);
|
||||
wchar_t* wMode = hsStringToWString(mode);
|
||||
bool ret = Open(wName, wMode);
|
||||
delete [] wName;
|
||||
delete [] wMode;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::Open(const wchar_t *name, const wchar_t *mode)
|
||||
{
|
||||
if (wcschr(mode, L'w'))
|
||||
{
|
||||
fReadMode = false;
|
||||
|
||||
// Try to create the pipe
|
||||
fPipe = CreateNamedPipeW(name,
|
||||
PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED,
|
||||
PIPE_TYPE_BYTE,
|
||||
1,
|
||||
1024,
|
||||
1024,
|
||||
fTimeout,
|
||||
NULL);
|
||||
|
||||
if (fPipe != INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
}
|
||||
else if (wcschr(mode, L'r'))
|
||||
{
|
||||
fReadMode = true;
|
||||
|
||||
fPipe = CreateFileW(name,
|
||||
GENERIC_READ,
|
||||
0, // no sharing
|
||||
NULL, // no security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
FILE_FLAG_OVERLAPPED, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
if (fPipe != INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::Close()
|
||||
{
|
||||
if (fPipe == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
|
||||
if (fReadMode)
|
||||
{
|
||||
CloseHandle(fPipe); // Close our end of the pipe
|
||||
fPipe = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
FlushFileBuffers(fPipe); // Make sure the client is done reading
|
||||
DisconnectNamedPipe(fPipe); // Disconnect the pipe from the client
|
||||
CloseHandle(fPipe); // Close our end of the pipe
|
||||
fPipe = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::ICheckOverlappedResult(BOOL result, uint32_t &numTransferred)
|
||||
{
|
||||
// Read/Write succeeded, return now
|
||||
if (result)
|
||||
return true;
|
||||
// Read failed because the operation is taking a while. Wait for it
|
||||
else if (GetLastError() == ERROR_IO_PENDING)
|
||||
{
|
||||
if (WaitForSingleObject(fOverlap.hEvent, fTimeout) == WAIT_OBJECT_0)
|
||||
{
|
||||
BOOL oResult = GetOverlappedResult(fPipe, &fOverlap, (LPDWORD)&numTransferred, FALSE);
|
||||
if (oResult)
|
||||
return true;
|
||||
hsAssert(oResult, "GetOverlappedResult failed");
|
||||
}
|
||||
else
|
||||
hsAssert(0, "Wait failed");
|
||||
}
|
||||
else
|
||||
hsAssert(0, "Read/Write failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::IRead(uint32_t byteCount, void *buffer, uint32_t &numRead)
|
||||
{
|
||||
numRead = 0;
|
||||
|
||||
if (fPipe != INVALID_HANDLE_VALUE && fReadMode)
|
||||
{
|
||||
BOOL result = ReadFile(fPipe, buffer, byteCount, (LPDWORD)&numRead, &fOverlap);
|
||||
if (ICheckOverlappedResult(result, numRead))
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we got here, the pipe is probably broken. Throw if it is enabled.
|
||||
if (fFlags & kThrowOnError)
|
||||
throw this;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hsNamedPipeStream::IWrite(uint32_t byteCount, const void *buffer, uint32_t &numWritten)
|
||||
{
|
||||
numWritten = 0;
|
||||
|
||||
if (fPipe != INVALID_HANDLE_VALUE && !fReadMode)
|
||||
{
|
||||
BOOL result = WriteFile(fPipe, buffer, byteCount, (LPDWORD)&numWritten, &fOverlap);
|
||||
if (ICheckOverlappedResult(result, numWritten))
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we got here, the pipe is probably broken. Throw if it is enabled.
|
||||
if (fFlags & kThrowOnError)
|
||||
throw this;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t hsNamedPipeStream::Read(uint32_t byteCount, void *buffer)
|
||||
{
|
||||
uint32_t totalRead = 0;
|
||||
|
||||
// Read until we get all our data or an error
|
||||
uint32_t numRead = 0;
|
||||
while (IRead(byteCount-totalRead, (void*)((uint32_t)buffer+totalRead), numRead))
|
||||
{
|
||||
totalRead += numRead;
|
||||
|
||||
if (totalRead >= byteCount)
|
||||
return totalRead;
|
||||
}
|
||||
|
||||
return totalRead;
|
||||
}
|
||||
|
||||
uint32_t hsNamedPipeStream::Write(uint32_t byteCount, const void *buffer)
|
||||
{
|
||||
uint32_t totalWritten = 0;
|
||||
|
||||
// Write until we get all our data or an error
|
||||
uint32_t numWritten = 0;
|
||||
while (IWrite(byteCount-totalWritten, (const void*)((uint32_t)buffer+totalWritten), numWritten))
|
||||
{
|
||||
totalWritten += numWritten;
|
||||
|
||||
if (totalWritten >= byteCount)
|
||||
return totalWritten;
|
||||
}
|
||||
|
||||
return totalWritten;
|
||||
}
|
||||
|
||||
#ifdef __SGI_STL_PORT
|
||||
using std::min;
|
||||
#endif
|
||||
|
||||
void hsNamedPipeStream::Skip(uint32_t deltaByteCount)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
// Read until we get all our data or an error
|
||||
uint32_t totalRead = 0;
|
||||
uint32_t numRead = 0;
|
||||
while (IRead(min((uint32_t)256L, deltaByteCount-totalRead), buf, numRead))
|
||||
{
|
||||
totalRead += numRead;
|
||||
|
||||
if (totalRead >= deltaByteCount)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void hsNamedPipeStream::Rewind()
|
||||
{
|
||||
hsAssert(0, "Rewind not allowed on a pipe");
|
||||
}
|
||||
|
||||
#endif // HS_BUILD_FOR_WIN32
|
||||
|
@ -82,48 +82,3 @@ public:
|
||||
// In case you want to try and be efficient with your memory allocations
|
||||
void Reserve(uint32_t bytes) { fVector.reserve(bytes); }
|
||||
};
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
|
||||
|
||||
|
||||
class hsNamedPipeStream : public hsStream
|
||||
{
|
||||
protected:
|
||||
HANDLE fPipe;
|
||||
OVERLAPPED fOverlap;
|
||||
bool fReadMode; // True for read, false for write
|
||||
uint8_t fFlags;
|
||||
uint32_t fTimeout;
|
||||
|
||||
bool ICheckOverlappedResult(BOOL result, uint32_t &numTransferred);
|
||||
bool IRead(uint32_t byteCount, void *buffer, uint32_t &numRead);
|
||||
bool IWrite(uint32_t byteCount, const void *buffer, uint32_t &numWritten);
|
||||
|
||||
public:
|
||||
enum { kThrowOnError = 1 }; // Throws if a read or write operation fails
|
||||
|
||||
hsNamedPipeStream(uint8_t flags=0, uint32_t timeout=INFINITE);
|
||||
virtual ~hsNamedPipeStream();
|
||||
|
||||
// The server (writer) and client (reader) need to open the same file.
|
||||
// The format is "\\.\pipe\pipeName". The '.' can be replaced with a
|
||||
// computer name to do it over the network. 'pipeName' is whatever you
|
||||
// want.
|
||||
virtual bool Open(const char *name, const char *mode);
|
||||
virtual bool Open(const wchar_t *name, const wchar_t *mode);
|
||||
virtual bool Close();
|
||||
|
||||
virtual uint32_t Read(uint32_t byteCount, void *buffer);
|
||||
virtual uint32_t Write(uint32_t byteCount, const void *buffer);
|
||||
virtual void Skip(uint32_t deltaByteCount);
|
||||
virtual void Rewind();
|
||||
|
||||
// - For the server (writer) only -
|
||||
// After calling open, signal your client to start reading and call this function.
|
||||
// If a client connects, this will return true and you can start writing. If it
|
||||
// returns false, close the pipe, it ain't happening.
|
||||
bool WaitForClientConnect();
|
||||
};
|
||||
|
||||
#endif // HS_BUILD_FOR_WIN32
|
||||
|
@ -48,9 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsMemory.h"
|
||||
#include "plString.h"
|
||||
|
||||
namespace hsPackFileSys {
|
||||
struct FileEntry;
|
||||
}
|
||||
|
||||
// Define this for use of Streams with Logging (commonly used w/ a packet sniffer)
|
||||
// These streams log their reads to an event list
|
||||
@ -77,10 +74,6 @@ enum {
|
||||
kEolnCode = '\n',
|
||||
kComment = '#'
|
||||
};
|
||||
enum VDB_Type {// Virtual Database type
|
||||
kVDB_GroupObject,
|
||||
kVDB_Mesh
|
||||
};
|
||||
protected:
|
||||
uint32_t fBytesRead;
|
||||
uint32_t fPosition;
|
||||
@ -287,9 +280,6 @@ public:
|
||||
void WriteLE(uint32_t* tag, uint32_t size) { WriteLEAtom(*tag, size); }
|
||||
void ReadLE(uint32_t* tag, uint32_t *size) { *tag = ReadLEAtom(size); }
|
||||
/* Overloaded End */
|
||||
virtual void VirtualSetPosition(uint32_t pos, VDB_Type ){ SetPosition(pos); };
|
||||
virtual hsPackFileSys::FileEntry *GetFileEntry() { return nil; } // Streams from Packfiles can return a FileEntry
|
||||
|
||||
};
|
||||
|
||||
class hsStreamable {
|
||||
|
@ -1,89 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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==*/
|
||||
#ifndef plRefCnt_Defined
|
||||
#define plRefCnt_Defined
|
||||
|
||||
#include "HeadSpin.h"
|
||||
|
||||
// plRef count addes refcount abilities to any plCreatable
|
||||
|
||||
class plRefCnt
|
||||
{ uint32_t fRefCnt;
|
||||
public:
|
||||
plRefCnt() : fRefCnt(1){}
|
||||
~plRefCnt(){}
|
||||
bool TimeToDelete() { return (fRefCnt == 1); }
|
||||
void Incr() { fRefCnt++; }
|
||||
void Decr() { fRefCnt--; }
|
||||
};
|
||||
|
||||
|
||||
#define DEFINE_REF_COUNT plRefCnt fMyRef;\
|
||||
virtual void UnRef() { /*hsDebugCode(hsThrowIfFalse(fRefCnt >= 1);)*/if (fMyRef.TimeToDelete()) delete this; else fMyRef.Decr(); }\
|
||||
virtual void Ref() { fMyRef.Incr(); }
|
||||
/*
|
||||
class hsRefCnt {
|
||||
private:
|
||||
int32_t fRefCnt;
|
||||
public:
|
||||
hsRefCnt() : fRefCnt(1) {}
|
||||
virtual ~hsRefCnt();
|
||||
|
||||
int32_t RefCnt() const { return fRefCnt; }
|
||||
virtual void UnRef();
|
||||
virtual void Ref();
|
||||
};
|
||||
|
||||
#define hsRefCnt_SafeRef(obj) do { if (obj) (obj)->Ref(); } while (0)
|
||||
#define hsRefCnt_SafeUnRef(obj) do { if (obj) (obj)->UnRef(); } while (0)
|
||||
|
||||
#define hsRefCnt_SafeAssign(dst, src) \
|
||||
do { \
|
||||
hsRefCnt_SafeRef(src); \
|
||||
hsRefCnt_SafeUnRef(dst); \
|
||||
dst = src; \
|
||||
} while (0)
|
||||
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user