#include "Nave.h" namespace Nave { HWND hMainWnd = NULL; HINSTANCE hInstance = NULL; void EnableLFH() { HANDLE hHeap[1025]; UINT uEA = GetProcessHeaps(1024, hHeap); for (UINT i=0; i= maxtBuf) break; if(strncmp(&sBuf[index+i], pLine, pLen) == 0) { CopyMemory(tBuf, sBuf+index, i); index += (i+pLen); tBuf[i] = 0; return TRUE; } } INT len = maxsBuf-index; if(maxtBuf <= len) len = maxtBuf-index; CopyMemory(tBuf, sBuf+index, len); tBuf[len] = 0; index += len; return FALSE; } VOID GetString( const CHAR* sBuf, CHAR* tBuf, INT len, LONG& index ) { CopyMemory(tBuf, sBuf+index, len); tBuf[len] = 0; index += len; } BYTE GetByte( const CHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(BYTE); return *(BYTE*)(sBuf+t_index); } SHORT GetShort( const CHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(SHORT); return *(SHORT*)(sBuf+t_index); } INT GetInt( const CHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(INT); return *(INT*)(sBuf+t_index); } DWORD GetDWORD( const CHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(DWORD); return *(DWORD*)(sBuf+t_index); } FLOAT GetFloat( const CHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(FLOAT); return *(FLOAT*)(sBuf+t_index); } DOUBLE GetDouble( const CHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(DOUBLE); return *(DOUBLE*)(sBuf+t_index); } VOID SetString( CHAR* tBuf, const CHAR* sBuf, INT len, LONG& index ) { CopyMemory(tBuf+index, sBuf, len); index += len; } VOID SetByte( CHAR* tBuf, BYTE sByte, LONG& index ) { *(tBuf+index) = (BYTE)sByte; index++; } VOID SetShort( CHAR* tBuf, SHORT sShort, LONG& index ) { SHORT temp = (SHORT)sShort; CopyMemory( tBuf+index, &temp, sizeof(SHORT)); index += sizeof(SHORT); } VOID SetInt( CHAR* tBuf, INT sInt, LONG& index ) { CopyMemory( tBuf+index, &sInt, sizeof(INT)); index += sizeof(INT); } VOID SetDWORD( CHAR* tBuf, DWORD sDword, LONG& index ) { CopyMemory( tBuf+index, &sDword, sizeof(DWORD)); index += sizeof(DWORD); } VOID SetFloat( CHAR* tBuf, FLOAT sFloat, LONG& index ) { CopyMemory( tBuf+index, &sFloat, sizeof(FLOAT)); index += sizeof(FLOAT); } VOID SetDouble( CHAR* tBuf, DOUBLE sDouble, LONG& index ) { CopyMemory( tBuf+index, &sDouble, sizeof(DOUBLE)); index += sizeof(DOUBLE); } BOOL GetLine( const WCHAR* sBuf, INT maxsBuf, WCHAR* tBuf, INT maxtBuf, LONG& index ) { ZeroMemory(tBuf, sizeof(tBuf)); INT DestIndex = index; WCHAR* pLine = L"\n"; INT pLen = wcslen(pLine); for(INT i = 0; i < maxsBuf; i++) { if(index+i >= maxtBuf) break; if(wcsncmp(&sBuf[index+i], pLine, pLen) == 0) { CopyMemory(tBuf, sBuf+index, sizeof(WCHAR)*i); index += (i+pLen); tBuf[index-1] = 0; return TRUE; } } INT len = maxsBuf-index; CopyMemory(tBuf, sBuf+index, sizeof(WCHAR)*len); tBuf[len] = 0; index += len; return FALSE; } VOID GetString( const WCHAR* sBuf, WCHAR* tBuf, INT len, LONG& index ) { CopyMemory(tBuf, sBuf+index, sizeof(WCHAR)*len); tBuf[len] = 0; index += len; } BYTE GetByte( const WCHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(BYTE); return *(BYTE*)(sBuf+t_index); } SHORT GetShort( const WCHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(SHORT); return *(SHORT*)(sBuf+t_index); } INT GetInt( const WCHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(INT); return *(INT*)(sBuf+t_index); } DWORD GetDWORD( const WCHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(DWORD); return *(DWORD*)(sBuf+t_index); } FLOAT GetFloat( const WCHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(FLOAT); return *(FLOAT*)(sBuf+t_index); } DOUBLE GetDouble( const WCHAR* sBuf, LONG& index ) { INT t_index = index; index += sizeof(DOUBLE); return *(DOUBLE*)(sBuf+t_index); } VOID SetString( WCHAR* tBuf, const WCHAR* sBuf, INT len, LONG& index ) { CopyMemory(tBuf+index, sBuf, sizeof(WCHAR)*len); index += len; } VOID SetByte( WCHAR* tBuf, BYTE sByte, LONG& index ) { *(tBuf+index) = (BYTE)sByte; index++; } VOID SetShort( WCHAR* tBuf, SHORT sShort, LONG& index ) { SHORT temp = (SHORT)sShort; CopyMemory( tBuf+index, &temp, sizeof(SHORT)); index += sizeof(SHORT); } VOID SetInt( WCHAR* tBuf, INT sInt, LONG& index ) { CopyMemory( tBuf+index, &sInt, sizeof(INT)); index += sizeof(INT); } VOID SetDWORD( WCHAR* tBuf, DWORD sDword, LONG& index ) { CopyMemory( tBuf+index, &sDword, sizeof(DWORD)); index += sizeof(DWORD); } VOID SetFloat( WCHAR* tBuf, FLOAT sFloat, LONG& index ) { CopyMemory( tBuf+index, &sFloat, sizeof(FLOAT)); index += sizeof(FLOAT); } VOID SetDouble( WCHAR* tBuf, DOUBLE sDouble, LONG& index ) { CopyMemory( tBuf+index, &sDouble, sizeof(DOUBLE)); index += sizeof(DOUBLE); } VOID Read( const char* sBuf, void* tBuf, INT len, LONG& seek ) { CopyMemory(tBuf, &sBuf[seek], len); seek += len; } VOID Write( const void* sBuf, char* tBuf, INT len, LONG& seek ) { CopyMemory(&tBuf[seek], sBuf, len); seek += len; } }