blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0c9acb8aa9e2bb872ae3f52278c0f1e16a03bbc6 | 6e4f9952ef7a3a47330a707aa993247afde65597 | /PROJECTS_ROOT/SmartWires/SystemUtils/Asserts/WheatyException.cpp | 7ce47f5725d58ab0cb6dfe6f4acd85ac6d267239 | []
| no_license | meiercn/wiredplane-wintools | b35422570e2c4b486c3aa6e73200ea7035e9b232 | 134db644e4271079d631776cffcedc51b5456442 | refs/heads/master | 2021-01-19T07:50:42.622687 | 2009-07-07T03:34:11 | 2009-07-07T03:34:11 | 34,017,037 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 24,257 | cpp | //==========================================
// Matt Pietrek
// MSDN Magazine, 2002
// FILE: WheatyExceptionReport.CPP
//==========================================
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <dbghelp.h>
#include "WheatyExceptionReport.h"
#pragma comment(linker, "/defaultlib:dbghelp.lib")
//============================== Global Variables =============================
//
// Declare the static variables of the WheatyExceptionReport class
//
TCHAR WheatyExceptionReport::m_szLogFileName[MAX_PATH];
LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter;
HANDLE WheatyExceptionReport::m_hReportFile;
HANDLE WheatyExceptionReport::m_hProcess;
// Declare global instance of class
WheatyExceptionReport g_WheatyExceptionReport;
//============================== Class Methods =============================
WheatyExceptionReport::WheatyExceptionReport( ) // Constructor
{
// Install the unhandled exception filter function
m_previousFilter =
SetUnhandledExceptionFilter(WheatyUnhandledExceptionFilter);
// Figure out what the report file will be named, and store it away
GetModuleFileName( 0, m_szLogFileName, MAX_PATH );
// Look for the '.' before the "EXE" extension. Replace the extension
// with "RPT"
PTSTR pszDot = _tcsrchr( m_szLogFileName, _T('.') );
if ( pszDot )
{
pszDot++; // Advance past the '.'
if ( _tcslen(pszDot) >= 3 )
_tcscpy( pszDot, _T("RPT") ); // "RPT" -> "Report"
}
m_hProcess = GetCurrentProcess();
}
//============
// Destructor
//============
WheatyExceptionReport::~WheatyExceptionReport( )
{
SetUnhandledExceptionFilter( m_previousFilter );
}
//==============================================================
// Lets user change the name of the report file to be generated
//==============================================================
void WheatyExceptionReport::SetLogFileName( PTSTR pszLogFileName )
{
_tcscpy( m_szLogFileName, pszLogFileName );
}
//===========================================================
// Entry point where control comes on an unhandled exception
//===========================================================
LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter(
PEXCEPTION_POINTERS pExceptionInfo )
{
m_hReportFile = CreateFile( m_szLogFileName,
GENERIC_WRITE,
0,
0,
OPEN_ALWAYS,
FILE_FLAG_WRITE_THROUGH,
0 );
if ( m_hReportFile )
{
SetFilePointer( m_hReportFile, 0, 0, FILE_END );
GenerateExceptionReport( pExceptionInfo );
CloseHandle( m_hReportFile );
m_hReportFile = 0;
}
if ( m_previousFilter )
return m_previousFilter( pExceptionInfo );
else
return EXCEPTION_CONTINUE_SEARCH;
}
//===========================================================================
// Open the report file, and write the desired information to it. Called by
// WheatyUnhandledExceptionFilter
//===========================================================================
void WheatyExceptionReport::GenerateExceptionReport(
PEXCEPTION_POINTERS pExceptionInfo )
{
// Start out with a banner
_tprintf(_T("//=====================================================\r\n"));
PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
// First print information about the type of fault
_tprintf( _T("Exception code: %08X %s\r\n"),
pExceptionRecord->ExceptionCode,
GetExceptionString(pExceptionRecord->ExceptionCode) );
// Now print information about where the fault occured
TCHAR szFaultingModule[MAX_PATH];
DWORD section, offset;
GetLogicalAddress( pExceptionRecord->ExceptionAddress,
szFaultingModule,
sizeof( szFaultingModule ),
section, offset );
_tprintf( _T("Fault address: %08X %02X:%08X %s\r\n"),
pExceptionRecord->ExceptionAddress,
section, offset, szFaultingModule );
PCONTEXT pCtx = pExceptionInfo->ContextRecord;
// Show the registers
#ifdef _M_IX86 // X86 Only!
_tprintf( _T("\r\nRegisters:\r\n") );
_tprintf(_T("EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n")
,pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx,
pCtx->Esi, pCtx->Edi );
_tprintf( _T("CS:EIP:%04X:%08X\r\n"), pCtx->SegCs, pCtx->Eip );
_tprintf( _T("SS:ESP:%04X:%08X EBP:%08X\r\n"),
pCtx->SegSs, pCtx->Esp, pCtx->Ebp );
_tprintf( _T("DS:%04X ES:%04X FS:%04X GS:%04X\r\n"),
pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
_tprintf( _T("Flags:%08X\r\n"), pCtx->EFlags );
#endif
SymSetOptions( SYMOPT_DEFERRED_LOADS );
// Initialize DbgHelp
if ( !SymInitialize( GetCurrentProcess(), 0, TRUE ) )
return;
CONTEXT trashableContext = *pCtx;
WriteStackDetails( &trashableContext, false );
#ifdef _M_IX86 // X86 Only!
_tprintf( _T("========================\r\n") );
_tprintf( _T("Local Variables And Parameters\r\n") );
trashableContext = *pCtx;
WriteStackDetails( &trashableContext, true );
_tprintf( _T("========================\r\n") );
_tprintf( _T("Global Variables\r\n") );
SymEnumSymbols( GetCurrentProcess(),
(DWORD64)GetModuleHandle(szFaultingModule),
0, EnumerateSymbolsCallback, 0 );
#endif // X86 Only!
SymCleanup( GetCurrentProcess() );
_tprintf( _T("\r\n") );
}
//======================================================================
// Given an exception code, returns a pointer to a static string with a
// description of the exception
//======================================================================
LPTSTR WheatyExceptionReport::GetExceptionString( DWORD dwCode )
{
#define EXCEPTION( x ) case EXCEPTION_##x: return _T(#x);
switch ( dwCode )
{
EXCEPTION( ACCESS_VIOLATION )
EXCEPTION( DATATYPE_MISALIGNMENT )
EXCEPTION( BREAKPOINT )
EXCEPTION( SINGLE_STEP )
EXCEPTION( ARRAY_BOUNDS_EXCEEDED )
EXCEPTION( FLT_DENORMAL_OPERAND )
EXCEPTION( FLT_DIVIDE_BY_ZERO )
EXCEPTION( FLT_INEXACT_RESULT )
EXCEPTION( FLT_INVALID_OPERATION )
EXCEPTION( FLT_OVERFLOW )
EXCEPTION( FLT_STACK_CHECK )
EXCEPTION( FLT_UNDERFLOW )
EXCEPTION( INT_DIVIDE_BY_ZERO )
EXCEPTION( INT_OVERFLOW )
EXCEPTION( PRIV_INSTRUCTION )
EXCEPTION( IN_PAGE_ERROR )
EXCEPTION( ILLEGAL_INSTRUCTION )
EXCEPTION( NONCONTINUABLE_EXCEPTION )
EXCEPTION( STACK_OVERFLOW )
EXCEPTION( INVALID_DISPOSITION )
EXCEPTION( GUARD_PAGE )
EXCEPTION( INVALID_HANDLE )
}
// If not one of the "known" exceptions, try to get the string
// from NTDLL.DLL's message table.
static TCHAR szBuffer[512] = { 0 };
FormatMessage( FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
GetModuleHandle( _T("NTDLL.DLL") ),
dwCode, 0, szBuffer, sizeof( szBuffer ), 0 );
return szBuffer;
}
//=============================================================================
// Given a linear address, locates the module, section, and offset containing
// that address.
//
// Note: the szModule paramater buffer is an output buffer of length specified
// by the len parameter (in characters!)
//=============================================================================
BOOL WheatyExceptionReport::GetLogicalAddress(
PVOID addr, PTSTR szModule, DWORD len, DWORD& section, DWORD& offset )
{
MEMORY_BASIC_INFORMATION mbi;
if ( !VirtualQuery( addr, &mbi, sizeof(mbi) ) )
return FALSE;
DWORD hMod = (DWORD)mbi.AllocationBase;
if ( !GetModuleFileName( (HMODULE)hMod, szModule, len ) )
return FALSE;
// Point to the DOS header in memory
PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod;
// From the DOS header, find the NT (PE) header
PIMAGE_NT_HEADERS pNtHdr = (PIMAGE_NT_HEADERS)(hMod + pDosHdr->e_lfanew);
PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION( pNtHdr );
DWORD rva = (DWORD)addr - hMod; // RVA is offset from module load address
// Iterate through the section table, looking for the one that encompasses
// the linear address.
for ( unsigned i = 0;
i < pNtHdr->FileHeader.NumberOfSections;
i++, pSection++ )
{
DWORD sectionStart = pSection->VirtualAddress;
DWORD sectionEnd = sectionStart
+ max(pSection->SizeOfRawData, pSection->Misc.VirtualSize);
// Is the address in this section???
if ( (rva >= sectionStart) && (rva <= sectionEnd) )
{
// Yes, address is in the section. Calculate section and offset,
// and store in the "section" & "offset" params, which were
// passed by reference.
section = i+1;
offset = rva - sectionStart;
return TRUE;
}
}
return FALSE; // Should never get here!
}
//============================================================
// Walks the stack, and writes the results to the report file
//============================================================
void WheatyExceptionReport::WriteStackDetails(
PCONTEXT pContext,
bool bWriteVariables ) // true if local/params should be output
{
_tprintf( _T("\r\nCall stack:\r\n") );
_tprintf( _T("Address Frame Function SourceFile\r\n") );
DWORD dwMachineType = 0;
// Could use SymSetOptions here to add the SYMOPT_DEFERRED_LOADS flag
STACKFRAME sf;
memset( &sf, 0, sizeof(sf) );
#ifdef _M_IX86
// Initialize the STACKFRAME structure for the first call. This is only
// necessary for Intel CPUs, and isn't mentioned in the documentation.
sf.AddrPC.Offset = pContext->Eip;
sf.AddrPC.Mode = AddrModeFlat;
sf.AddrStack.Offset = pContext->Esp;
sf.AddrStack.Mode = AddrModeFlat;
sf.AddrFrame.Offset = pContext->Ebp;
sf.AddrFrame.Mode = AddrModeFlat;
dwMachineType = IMAGE_FILE_MACHINE_I386;
#endif
while ( 1 )
{
// Get the next stack frame
if ( ! StackWalk( dwMachineType,
m_hProcess,
GetCurrentThread(),
&sf,
pContext,
0,
SymFunctionTableAccess,
SymGetModuleBase,
0 ) )
break;
if ( 0 == sf.AddrFrame.Offset ) // Basic sanity check to make sure
break; // the frame is OK. Bail if not.
_tprintf( _T("%08X %08X "), sf.AddrPC.Offset, sf.AddrFrame.Offset );
// Get the name of the function for this stack frame entry
BYTE symbolBuffer[ sizeof(SYMBOL_INFO) + 1024 ];
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)symbolBuffer;
pSymbol->SizeOfStruct = sizeof(symbolBuffer);
pSymbol->MaxNameLen = 1024;
DWORD64 symDisplacement = 0; // Displacement of the input address,
// relative to the start of the symbol
if ( SymFromAddr(m_hProcess,sf.AddrPC.Offset,&symDisplacement,pSymbol))
{
_tprintf( _T("%hs+%I64X"), pSymbol->Name, symDisplacement );
}
else // No symbol found. Print out the logical address instead.
{
TCHAR szModule[MAX_PATH] = _T("");
DWORD section = 0, offset = 0;
GetLogicalAddress( (PVOID)sf.AddrPC.Offset,
szModule, sizeof(szModule), section, offset );
_tprintf( _T("%04X:%08X %s"), section, offset, szModule );
}
// Get the source line for this stack frame entry
IMAGEHLP_LINE lineInfo = { sizeof(IMAGEHLP_LINE) };
DWORD dwLineDisplacement;
if ( SymGetLineFromAddr( m_hProcess, sf.AddrPC.Offset,
&dwLineDisplacement, &lineInfo ) )
{
_tprintf(_T(" %s line %u"),lineInfo.FileName,lineInfo.LineNumber);
}
_tprintf( _T("\r\n") );
// Write out the variables, if desired
if ( bWriteVariables )
{
// Use SymSetContext to get just the locals/params for this frame
IMAGEHLP_STACK_FRAME imagehlpStackFrame;
imagehlpStackFrame.InstructionOffset = sf.AddrPC.Offset;
SymSetContext( m_hProcess, &imagehlpStackFrame, 0 );
// Enumerate the locals/parameters
SymEnumSymbols( m_hProcess, 0, 0, EnumerateSymbolsCallback, &sf );
_tprintf( _T("\r\n") );
}
}
}
//////////////////////////////////////////////////////////////////////////////
// The function invoked by SymEnumSymbols
//////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK
WheatyExceptionReport::EnumerateSymbolsCallback(
PSYMBOL_INFO pSymInfo,
ULONG SymbolSize,
PVOID UserContext )
{
char szBuffer[2048];
__try
{
if ( FormatSymbolValue( pSymInfo, (STACKFRAME*)UserContext,
szBuffer, sizeof(szBuffer) ) )
_tprintf( _T("\t%s\r\n"), szBuffer );
}
__except( 1 )
{
_tprintf( _T("punting on symbol %s\r\n"), pSymInfo->Name );
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
// Given a SYMBOL_INFO representing a particular variable, displays its
// contents. If it's a user defined type, display the members and their
// values.
//////////////////////////////////////////////////////////////////////////////
bool WheatyExceptionReport::FormatSymbolValue(
PSYMBOL_INFO pSym,
STACKFRAME * sf,
char * pszBuffer,
unsigned cbBuffer )
{
char * pszCurrBuffer = pszBuffer;
// Indicate if the variable is a local or parameter
if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER )
pszCurrBuffer += sprintf( pszCurrBuffer, "Parameter " );
else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL )
pszCurrBuffer += sprintf( pszCurrBuffer, "Local " );
// If it's a function, don't do anything.
if ( pSym->Tag == 5 ) // SymTagFunction from CVCONST.H from the DIA SDK
return false;
// Emit the variable name
pszCurrBuffer += sprintf( pszCurrBuffer, "\'%s\'", pSym->Name );
DWORD_PTR pVariable = 0; // Will point to the variable's data in memory
if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE )
{
// if ( pSym->Register == 8 ) // EBP is the value 8 (in DBGHELP 5.1)
{ // This may change!!!
pVariable = sf->AddrFrame.Offset;
pVariable += (DWORD_PTR)pSym->Address;
}
// else
// return false;
}
else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER )
{
return false; // Don't try to report register variable
}
else
{
pVariable = (DWORD_PTR)pSym->Address; // It must be a global variable
}
// Determine if the variable is a user defined type (UDT). IF so, bHandled
// will return true.
bool bHandled;
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer,pSym->ModBase, pSym->TypeIndex,
0, pVariable, bHandled );
if ( !bHandled )
{
// The symbol wasn't a UDT, so do basic, stupid formatting of the
// variable. Based on the size, we're assuming it's a char, WORD, or
// DWORD.
BasicType basicType = GetBasicType( pSym->TypeIndex, pSym->ModBase );
pszCurrBuffer = FormatOutputValue(pszCurrBuffer, basicType, pSym->Size,
(PVOID)pVariable );
}
return true;
}
//////////////////////////////////////////////////////////////////////////////
// If it's a user defined type (UDT), recurse through its members until we're
// at fundamental types. When he hit fundamental types, return
// bHandled = false, so that FormatSymbolValue() will format them.
//////////////////////////////////////////////////////////////////////////////
char * WheatyExceptionReport::DumpTypeIndex(
char * pszCurrBuffer,
DWORD64 modBase,
DWORD dwTypeIndex,
unsigned nestingLevel,
DWORD_PTR offset,
bool & bHandled )
{
bHandled = false;
// Get the name of the symbol. This will either be a Type name (if a UDT),
// or the structure member name.
WCHAR * pwszTypeName;
if ( SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_SYMNAME,
&pwszTypeName ) )
{
pszCurrBuffer += sprintf( pszCurrBuffer, " %ls", pwszTypeName );
LocalFree( pwszTypeName );
}
// Determine how many children this type has.
DWORD dwChildrenCount = 0;
SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT,
&dwChildrenCount );
if ( !dwChildrenCount ) // If no children, we're done
return pszCurrBuffer;
// Prepare to get an array of "TypeIds", representing each of the children.
// SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a
// TI_FINDCHILDREN_PARAMS struct has. Use derivation to accomplish this.
struct FINDCHILDREN : TI_FINDCHILDREN_PARAMS
{
ULONG MoreChildIds[1024];
FINDCHILDREN(){Count = sizeof(MoreChildIds) / sizeof(MoreChildIds[0]);}
} children;
children.Count = dwChildrenCount;
children.Start= 0;
// Get the array of TypeIds, one for each child type
if ( !SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN,
&children ) )
{
return pszCurrBuffer;
}
// Append a line feed
pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
// Iterate through each of the children
for ( unsigned i = 0; i < dwChildrenCount; i++ )
{
// Add appropriate indentation level (since this routine is recursive)
for ( unsigned j = 0; j <= nestingLevel+1; j++ )
pszCurrBuffer += sprintf( pszCurrBuffer, "\t" );
// Recurse for each of the child types
bool bHandled2;
pszCurrBuffer = DumpTypeIndex( pszCurrBuffer, modBase,
children.ChildId[i], nestingLevel+1,
offset, bHandled2 );
// If the child wasn't a UDT, format it appropriately
if ( !bHandled2 )
{
// Get the offset of the child member, relative to its parent
DWORD dwMemberOffset;
SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
TI_GET_OFFSET, &dwMemberOffset );
// Get the real "TypeId" of the child. We need this for the
// SymGetTypeInfo( TI_GET_TYPEID ) call below.
DWORD typeId;
SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
TI_GET_TYPEID, &typeId );
// Get the size of the child member
ULONG64 length;
SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH,&length);
// Calculate the address of the member
DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
BasicType basicType = GetBasicType(children.ChildId[i], modBase );
pszCurrBuffer = FormatOutputValue( pszCurrBuffer, basicType,
length, (PVOID)dwFinalOffset );
pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
}
}
bHandled = true;
return pszCurrBuffer;
}
char * WheatyExceptionReport::FormatOutputValue( char * pszCurrBuffer,
BasicType basicType,
DWORD64 length,
PVOID pAddress )
{
// Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
if ( length == 1 )
pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PBYTE)pAddress );
else if ( length == 2 )
pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PWORD)pAddress );
else if ( length == 4 )
{
if ( basicType == btFloat )
{
pszCurrBuffer += sprintf(pszCurrBuffer," = %f", *(PFLOAT)pAddress);
}
else if ( basicType == btChar )
{
if ( !IsBadStringPtr( *(PSTR*)pAddress, 32) )
{
pszCurrBuffer += sprintf( pszCurrBuffer, " = \"%.31s\"",
*(PDWORD)pAddress );
}
else
pszCurrBuffer += sprintf( pszCurrBuffer, " = %X",
*(PDWORD)pAddress );
}
else
pszCurrBuffer += sprintf(pszCurrBuffer," = %X", *(PDWORD)pAddress);
}
else if ( length == 8 )
{
if ( basicType == btFloat )
{
pszCurrBuffer += sprintf( pszCurrBuffer, " = %lf",
*(double *)pAddress );
}
else
pszCurrBuffer += sprintf( pszCurrBuffer, " = %I64X",
*(DWORD64*)pAddress );
}
return pszCurrBuffer;
}
BasicType
WheatyExceptionReport::GetBasicType( DWORD typeIndex, DWORD64 modBase )
{
BasicType basicType;
if ( SymGetTypeInfo( m_hProcess, modBase, typeIndex,
TI_GET_BASETYPE, &basicType ) )
{
return basicType;
}
// Get the real "TypeId" of the child. We need this for the
// SymGetTypeInfo( TI_GET_TYPEID ) call below.
DWORD typeId;
if (SymGetTypeInfo(m_hProcess,modBase, typeIndex, TI_GET_TYPEID, &typeId))
{
if ( SymGetTypeInfo( m_hProcess, modBase, typeId, TI_GET_BASETYPE,
&basicType ) )
{
return basicType;
}
}
return btNoType;
}
//============================================================================
// Helper function that writes to the report file, and allows the user to use
// printf style formating
//============================================================================
int __cdecl WheatyExceptionReport::_tprintf(const TCHAR * format, ...)
{
TCHAR szBuff[1024];
int retValue;
DWORD cbWritten;
va_list argptr;
va_start( argptr, format );
retValue = vsprintf( szBuff, format, argptr );
va_end( argptr );
WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0 );
return retValue;
}
| [
"wplabs@3fb49600-69e0-11de-a8c1-9da277d31688"
]
| [
[
[
1,
666
]
]
]
|
886d15a64d13de81160840a98008894f3d52da50 | b8fbe9079ce8996e739b476d226e73d4ec8e255c | /src/apps/mermaid/jslidegame.h | 767f9d1562a07d69274a4664856cb14b22336edf | []
| no_license | dtbinh/rush | 4294f84de1b6e6cc286aaa1dd48cf12b12a467d0 | ad75072777438c564ccaa29af43e2a9fd2c51266 | refs/heads/master | 2021-01-15T17:14:48.417847 | 2011-06-16T17:41:20 | 2011-06-16T17:41:20 | 41,476,633 | 1 | 0 | null | 2015-08-27T09:03:44 | 2015-08-27T09:03:44 | null | UTF-8 | C++ | false | false | 4,429 | h | /***********************************************************************************/
/* File: JSlideGame.h
/* Date: 27.05.2006
/* Author: Ruslan Shestopalyuk
/***********************************************************************************/
#ifndef __JSlideGame_H__
#define __JSlideGame_H__
#include "JMathTypeCast.h"
#include "JSlidePiece.h"
/***********************************************************************************/
/* Class: JSlideGame
/* Desc:
/***********************************************************************************/
class JSlideGame : public JLocation
{
int m_CatchID; // ID of piece which is right in this cycle
int m_NumToCatch; // number of pieces of given ID to catch
int m_MinToCatch;
int m_MaxToCatch;
int m_MaxIncorrect; // maximal number of incorrect pieces before restart
int m_NumCaught; // number of pieces already caught
int m_NumCaughtWrong; // number of incorrectly caught pieces
int m_TopLine; // Y coordinate from which pieces start to fall
int m_BottomLine; // Y coordinate at which pieces stop to fall
int m_LeftLine; // X coordinate from which pieces random create
int m_RightLine; // X coordinate to which pieces random create
int m_NumCycles; // Count of cycles
int m_MinSpeed; // Minimum of random speed
int m_MaxSpeed; // Maximum of random speed
int m_NumRightCycles; // Count of right cycles
int m_CurRightCycle; // Count of right cycles
bool m_bRandomCatchID; // on each cycle randomly change id of the piece to catch
std::string m_SndTakeRight; // Right take piece sound
std::string m_SndTakeWrong; // Wrong take piece sound
int m_NumID; // how much different kinds of pieces we have
friend class JSlidePiece;
public:
JSlideGame ();
virtual void Render ();
virtual void Init ();
void StartCycle ();
void StartGame ();
void OnSuccess (){}
void OnCycleEnd (){}
void OnTakeWrong ();
void OnTakeRight ();
int GetCatchID () const { return m_CatchID; }
int GetLeftToCatch () const;
expose( JSlideGame )
{
parent( JLocation );
field ( "SndTakeRight", m_SndTakeRight );
field ( "SndTakeWrong", m_SndTakeWrong );
field ( "NumCycles", m_NumCycles );
field ( "NumRightCycles", m_NumRightCycles );
field ( "CatchID", m_CatchID );
field ( "MaxIncorrect", m_MaxIncorrect );
field ( "NumCaughtWrong", m_NumCaughtWrong );
field ( "NumToCatch", m_NumToCatch );
field ( "MinToCatch", m_MinToCatch );
field ( "MaxToCatch", m_MaxToCatch );
field ( "TopLine", m_TopLine );
field ( "BottomLine", m_BottomLine );
field ( "LeftLine", m_LeftLine );
field ( "RightLine", m_RightLine );
field ( "MinSpeed", m_MinSpeed );
field ( "MaxSpeed", m_MaxSpeed );
field ( "RandomCatchID", m_bRandomCatchID );
rprop ( "LeftToCatch", GetLeftToCatch );
method( "StartCycle", StartCycle );
method( "OnSuccess", OnSuccess );
method( "OnCycleEnd", OnCycleEnd );
method( "OnTakeRight", OnTakeRight );
method( "OnTakeWrong", OnTakeWrong );
method( "StartGame", StartGame );
}
}; // class JSlideGame
#endif //__JSlideGame_H__ | [
"[email protected]"
]
| [
[
[
1,
92
]
]
]
|
4f63d81dae178e716ca2c66b9d7fcf8ed09bb7c5 | 208475bcab65438eed5d8380f26eacd25eb58f70 | /QianExe/yx_MonAlert.cpp | 48874856721ef962e435e48b35f2bfa4edf76b35 | []
| no_license | awzhang/MyWork | 83b3f0b9df5ff37330c0e976310d75593f806ec4 | 075ad5d0726c793a0c08f9158080a144e0bb5ea5 | refs/heads/master | 2021-01-18T07:57:03.219372 | 2011-07-05T02:41:55 | 2011-07-05T02:46:30 | 15,523,223 | 1 | 2 | null | null | null | null | GB18030 | C++ | false | false | 79,301 | cpp | #include "yx_QianStdAfx.h"
#undef MSG_HEAD
#define MSG_HEAD ("QianExe-MonAlert ")
void G_TmMon(void *arg, int len)
{
g_objMonAlert.P_TmMon();
}
void G_TmAlertInvalid(void *arg, int len)
{
g_objMonAlert.P_TmAlertInvalid();
}
void G_TmAlertSilent(void *arg, int len)
{
g_objMonAlert.P_TmAlertSilent();
}
void G_TmAutoReqLsn(void *arg, int len)
{
g_objMonAlert.P_TmAutoReqLsn();
}
void G_TmAlertInitQuery(void *arg, int len)
{
g_objMonAlert.P_TmAlertInitQuery();
}
void G_TmAlertTest(void *arg, int len)
{
g_objMonAlert.P_TmAlertTest();
}
//////////////////////////////////////////////////////////////////////////
CMonAlert::CMonAlert()
{
m_dwAlertSymb = 0;
m_dwAlertFootTm = 0;
m_dwAlertPowerOffTm = 0;
m_dwAlertBrownoutTm = 0;
m_dwAlertFrontDoorTm = 0;
m_dwAlertBackDoorTm = 0;
m_dwAlertOverTurnTm = 0;
m_dwAlertBumpTm = 0;
m_bytAutoReqLsnCount = 0;
m_bytAutoReqLsnContBusyCt = 0;
memset( m_szAutoReqLsnTel, 0, sizeof(m_szAutoReqLsnTel) );
m_dSpdAlermMinSpd = 9999999;
m_bytSpdAlermPrid = 255;
m_bytSpdAlermSta = 0; // 必须初始化为false
}
CMonAlert::~CMonAlert()
{
}
void CMonAlert::P_TmMon()
{
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
int iResult = 0;
/// 获得基本数据和信息
DWORD dwCur = GetTickCount();
DWORD dwIntervChk = dwCur - m_objMonStatus.m_dwLstChkTime; // 距上次定时检查的时间
tag2QGprsCfg objGprsCfg;
tagGPSData objGps(0);
bool bNeedSend = false;
GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg) ,sizeof(objGprsCfg) );
// 递减剩余监控时间
if( INVALID_NUM_32 != m_objMonStatus.m_dwMonTime )
{
if( m_objMonStatus.m_dwMonTime >= dwIntervChk )
m_objMonStatus.m_dwMonTime -= dwIntervChk;
else
m_objMonStatus.m_dwMonTime = 0;
}
// 修改上次检查时间,以便后续的监控时间到判断
m_objMonStatus.m_dwLstChkTime = dwCur;
// 获取当前GPS信息
iResult = GetCurGPS( objGps, true );
if( iResult ) goto MONTIMER_END;
/// 判断是否要发送监控数据
if( m_objMonStatus.m_bInterv )
{
DWORD dwIntervSend = dwCur - m_objMonStatus.m_dwLstSendTime; // 距上次发送监控数据的时间
if( dwIntervSend >= m_objMonStatus.m_dwMonInterv ) // 若监控间隔到
{
bNeedSend = true;
}
}
if( m_objMonStatus.m_bSpace && !bNeedSend )
{
m_objMonStatus.m_dLstSendDis += G_CalGeoDis2(m_objMonStatus.m_dLstLon, m_objMonStatus.m_dLstLat,
objGps.longitude, objGps.latitude);
m_objMonStatus.m_dLstLon = objGps.longitude;
m_objMonStatus.m_dLstLat = objGps.latitude;
if( m_objMonStatus.m_dLstSendDis >= double( m_objMonStatus.m_dwSpace ) )
{
bNeedSend = true;
m_objMonStatus.m_dLstSendDis = 0;
}
}
/// 发送监控数据
if( bNeedSend )
{
_Snd0145( objGps, objGprsCfg );
// 只要发送了监控数据就更新 (重要)
m_objMonStatus.m_dwLstSendTime = dwCur; // 使得重新判断定时
m_objMonStatus.m_dLstSendDis = 0; // 使得重新判断定距
m_objMonStatus.m_dLstLon = objGps.longitude;
m_objMonStatus.m_dLstLat = objGps.latitude;
// 递减GPS数据个数
if( m_objMonStatus.m_dwGpsCount > 0 ) -- m_objMonStatus.m_dwGpsCount;
}
MONTIMER_END:
// 车台终止监控判断
if( 0 == m_objMonStatus.m_dwMonTime || 0 == m_objMonStatus.m_dwGpsCount ) // 若监控时间到,或者上传GPS个数到限
{
BYTE bytEndType = 0 == m_objMonStatus.m_dwGpsCount ? 0x05 : 0x01;
iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, sizeof(bytEndType), 0x01, 0x44, buf, sizeof(buf), iBufLen);
if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV11, // 优先级应和监控数据一样
(objGprsCfg.m_bytChannelBkType_1 & 0x40) ? DATASYMB_SMSBACKUP : 0 );
_EndMon(); // 要放在后面,因为函数内会清除监控状态,放在前面导致后面根据状态填写的“终止监控原因”不正确
#if USE_LEDTYPE == 3
//清空LED顶灯报警信息
g_objKTLed.SetLedShow('A',0xff,0);
#endif
}
else
{
// 约每10次,重新设置一次定时器
static BYTE sta_bytCt = 0;
if( 0 == sta_bytCt ++ % 10 )
{
if( m_objMonStatus.m_dwChkInterv < 1000 ) m_objMonStatus.m_dwChkInterv = 1000; // 安全起见
_SetTimer(&g_objTimerMng, MON_TIMER, m_objMonStatus.m_dwChkInterv, G_TmMon );
}
}
}
void CMonAlert::P_TmAlertSilent()
{
_KillTimer(&g_objTimerMng, ALERT_SILENT_TIMER );
char cResult = 0;
// 判断是否还存在断电报警
m_dwAlertSymb &= ~ALERT_TYPE_POWOFF;
//if( g_objIO.QueryOneIOState(IOCTL_GPT_POWDET_STATE, cResult) )
{
if( 1 == cResult )
{
m_dwAlertSymb |= ALERT_TYPE_POWOFF;
}
}
if( ALERT_TYPE_POWOFF & m_dwAlertSymb )
SetAlertPowOff( true );
else if( ALERT_TYPE_POWBROWNOUT & m_dwAlertSymb )
SetAlertPowBrownout( true );
}
void CMonAlert::P_TmAlertInvalid()
{
_ClrAlertSta();
}
void CMonAlert::P_TmAutoReqLsn()
{
_KillTimer(&g_objTimerMng, AUTO_REQLSN_TIMER );
// EVDO和TD模块使用USB口通信,可以同时打电话和拨号
if (NETWORK_TYPE == NETWORK_EVDO || NETWORK_TYPE == NETWORK_TD || NETWORK_TYPE == NETWORK_WCDMA)
{
if( 0 != _AutoReqLsn() )
{
if( m_bytAutoReqLsnCount < AUTO_REQLSN_MAXTIMES ) // 若请求监听次数未到限定次数
_SetTimer(&g_objTimerMng, AUTO_REQLSN_TIMER, AUTO_REQLSN_SHORTINTERVAL, G_TmAutoReqLsn );
}
}
else if (NETWORK_TYPE == NETWORK_GSM)
{
if( g_objPhoto.IsPhotoEnd() // 且拍照结束
&& // 且满足如下条件
(
g_objPhoto.IsUploadPhotoEnd() // 照片上传结束
||
g_objPhoto.IsUploadPhotoBreak() // 或上传照片因故中断
||
!g_objSock.IsOnline() // 或GPRS未连接未登陆
)
)
{
if( 0 != _AutoReqLsn() )
{
if( m_bytAutoReqLsnCount < AUTO_REQLSN_MAXTIMES ) // 若请求监听次数未到限定次数
_SetTimer(&g_objTimerMng, AUTO_REQLSN_TIMER, AUTO_REQLSN_SHORTINTERVAL, G_TmAutoReqLsn );
}
}
else
_SetTimer(&g_objTimerMng, AUTO_REQLSN_TIMER, 3000, G_TmAutoReqLsn );
}
}
void CMonAlert::P_TmAlertTest()
{
}
void CMonAlert::P_TmAlertInitQuery()
{
_KillTimer(&g_objTimerMng, ALERT_INITQUERY_TIMER );
}
void CMonAlert::P_TmAlertSpd()
{
}
int CMonAlert::_BeginMon( double v_dLon, double v_dLat )
{
// GPS模块上电
g_objQianIO.StopAccChk();
char buf = 0x04;
DataPush(&buf, 1, DEV_QIAN, DEV_DIAODU, LV2);
// 关闭主动上报
#if USE_AUTORPT == 1
g_objAutoRpt.EndAutoRpt();
#endif
// 更新监控条件,并设置监控初始状态
m_objMonStatus.m_dwLstChkTime = GetTickCount();
m_objMonStatus.m_dwLstSendTime = m_objMonStatus.m_dwLstChkTime;
if( 0 == v_dLon || 0 == v_dLat )
{
tagGPSData objGps(0);
GetCurGPS( objGps, true );
m_objMonStatus.m_dLstLon = objGps.longitude;
m_objMonStatus.m_dLstLat = objGps.latitude;
}
else
{
m_objMonStatus.m_dLstLon = v_dLon;
m_objMonStatus.m_dLstLat = v_dLat;
}
#if 0 == USE_PROTOCOL || 1 == USE_PROTOCOL
m_objMonStatus.m_dwGpsCount = 0xffffffff;
#endif
// 重启监控定时
if( m_objMonStatus.m_bSpace ) m_objMonStatus.m_dwChkInterv = MON_MININTERVAL; // 有定距时,则采用默认监控间隔
else m_objMonStatus.m_dwChkInterv = m_objMonStatus.m_dwMonInterv;
unsigned int uiTmId = _SetTimer(&g_objTimerMng, MON_TIMER, m_objMonStatus.m_dwChkInterv, G_TmMon );
PRTMSG(MSG_NOR, "Mon Start, TmId = %d\n", uiTmId );
return 0;
}
/// 不仅仅是终止监控,清除报警的相关工作也要在这里进行
int CMonAlert::_EndMon()
{
// 启动关闭GPS电源检查
g_objQianIO.StartAccChk( 2000 );
// 关闭监控定时
m_objMonStatus.Init();
_KillTimer(&g_objTimerMng, MON_TIMER );
// 取消报警时中止通话
{
char buf[2];
buf[0] = (char)0xf3;
buf[1] = 0;
DataPush(buf, 2, DEV_QIAN, DEV_PHONE, LV2);
}
// 清除报警状态
_ClrAlertSta();
PRTMSG(MSG_NOR, "Mon Stop!\n" );
#if USE_AUTORPT == 1
// 重新启动主动上报
g_objAutoRpt.Init();
#endif
return 0;
}
int CMonAlert::_Snd0145( const tagGPSData &v_objGps, const tag2QGprsCfg &v_objGprsCfg, bool v_bFbidAllowSms /*=false*/ )
{
int iBufLen = 0;
int iRet = 0;
char buf[ SOCK_MAXSIZE ];
tagQianGps objQianGps;
tag0145 data;
DWORD dwAlertSta = 0;
PRTMSG(MSG_DBG, "_Send0145 Alerm data.\n");
// 遍历所有报警状态,生成报警数据
dwAlertSta = g_objMonAlert.GetAlertSta();
//FillAlertSymb( dwAlertSta, data.m_bytAlertHi, data.m_bytAlertLo );
FillAlertSymb(dwAlertSta, &(data.m_bytAlertHi), &(data.m_bytAlertLo));
// 中心个数暂填1
data.m_bytMonCentCount = 1;
// gps数据
GpsToQianGps( v_objGps, objQianGps );
memcpy( &(data.m_objQianGps), &objQianGps, sizeof(data.m_objQianGps) );
#if 2 == USE_PROTOCOL
// 报警区域赋值
data.m_szAlertAreaCode[0] = 0;
data.m_szAlertAreaCode[1] = (char)g_objDriveRecord.m_bytAreaCode;
#endif
// SMS封装
iRet = g_objSms.MakeSmsFrame((char*)&data, sizeof(data), 0x01, 0x45, buf, sizeof(buf), iBufLen);
if( iRet ) return iRet;
// 发送
BYTE bytLvl = LV8, bytSndSymb = 0;
if( !dwAlertSta )
{
bytLvl = LV11;
bytSndSymb = 0;
}
else
{
bytLvl = LV13;
bytSndSymb = DATASYMB_SMSBACKUP;
}
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, bytLvl, bytSndSymb );
return iRet;
}
int CMonAlert::_Snd0149( const tagGPSData &v_objGps, const tag2QGprsCfg &v_objGprsCfg, bool v_bFbidAllowSms /*=false*/ )
{
int iBufLen = 0;
int iRet = 0;
char buf[ SOCK_MAXSIZE ];
tagQianGps objQianGps;
tag0149 data;
DWORD dwAlertSta = 0;
PRTMSG(MSG_DBG, "_Send0149 Alerm data.\n");
// 遍历所有报警状态,生成报警数据
dwAlertSta = g_objMonAlert.GetAlertSta();
FillAlertSymbFor0149(dwAlertSta, &(data.m_bytAlertHi), &(data.m_bytAlertLo));
// 中心个数暂填1
data.m_bytMonCentCount = 1;
// gps数据
GpsToQianGps( v_objGps, objQianGps );
memcpy( &(data.m_objQianGps), &objQianGps, sizeof(data.m_objQianGps) );
// SMS封装
iRet = g_objSms.MakeSmsFrame((char*)&data, sizeof(data), 0x01, 0x49, buf, sizeof(buf), iBufLen);
if( iRet ) return iRet;
// 发送
BYTE bytLvl = LV8, bytSndSymb = 0;
if( !dwAlertSta )
{
bytLvl = LV11;
bytSndSymb = 0;
}
else
{
bytLvl = LV13;
bytSndSymb = DATASYMB_SMSBACKUP;
}
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, bytLvl, bytSndSymb );
return iRet;
}
int CMonAlert::_SendOne0149Alert(const tagGPSData &v_objGps, byte v_bytAlertType)
{
int iBufLen = 0;
int iRet = 0;
char buf[ SOCK_MAXSIZE ];
tagQianGps objQianGps;
char szTempBuf[SOCK_MAXSIZE] = {0};
int iTempLen = 0;
// 中心个数
szTempBuf[iTempLen++] = 1;
// gps数据
GpsToQianGps( v_objGps, objQianGps );
memcpy( szTempBuf+iTempLen, &objQianGps, sizeof(objQianGps) );
iTempLen += sizeof(objQianGps);
// 版本号
szTempBuf[iTempLen++] = 0x01;
// 扩展参数个数
szTempBuf[iTempLen++] = 0x01;
// 参数类型:报警类
szTempBuf[iTempLen++] = 0x02;
// 参数长度
szTempBuf[iTempLen++] = 0x01;
// 参数数据
szTempBuf[iTempLen++] = v_bytAlertType;
// SMS封装
iRet = g_objSms.MakeSmsFrame((char*)szTempBuf, iTempLen, 0x01, 0x49, buf, sizeof(buf), iBufLen);
if( iRet ) return iRet;
// 发送
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV13, 0 );
return iRet;
}
void CMonAlert::Init()
{
_SetTimer(&g_objTimerMng, ALERT_INITQUERY_TIMER, 5000, G_TmAlertInitQuery );
}
// 仅适合于主线程中调用
// 若要在子线程中获取GPS,请直接调用dll接口——::GetCurGps
int CMonAlert::GetCurGPS( tagGPSData& v_objGps, bool v_bGetLstValid )
{
bool bNeedSetBackGps = false;
int iRet = GetCurGps( &v_objGps, sizeof(v_objGps), v_bGetLstValid ? GPS_LSTVALID : GPS_REAL );
#if USE_BLK == 1
// 第1次GPS有效时的保险处理:删除有效日期之后的黑匣子数据
static bool sta_bDelLaterBlk = false;
if( !sta_bDelLaterBlk && 'A' == v_objGps.valid )
{
g_objBlk.DelLaterBlk( v_objGps );
sta_bDelLaterBlk = true;
}
// 每600次有效时的检测:当日期变化时,删除1年之前的黑匣子数据
if( 'A' == v_objGps.valid )
{
static DWORD sta_dwGpsValidTime = 0;
++ sta_dwGpsValidTime;
if( 599 == sta_dwGpsValidTime % 600 ) // 每600次
{
static byte bytDay = 0;
struct tm pCurrentTime;
G_GetTime(&pCurrentTime);
if( bytDay != pCurrentTime.tm_mday ) // 若日期变化
{
g_objBlk.DelOlderBlk( v_objGps );
bytDay = pCurrentTime.tm_mday;
}
}
}
static bool sta_bGetBlk = false;
if( !sta_bGetBlk && v_bGetLstValid && (0 == v_objGps.longitude || 0 == v_objGps.latitude) )
{
// 若获取的GPS数据完全无效(全0),且允许使用上次有效数据代替,则读取最后一个黑匣子数据
tagGPSData objGps(0);
iRet = g_objBlk.GetLatestBlkGps( objGps );
if( !iRet )
{
v_objGps = objGps;
bNeedSetBackGps = true;
}
sta_bGetBlk = true; // 无论是否读到黑匣子数据,都只读1次
}
#endif
#if USE_DRVRECRPT == 1 || USE_DRVRECRPT == 2 || USE_DRVRECRPT == 3 || USE_DRVRECRPT == 4 || USE_DRVRECRPT == 11|| USE_DRVRECRPT == 0
static bool sta_bGetDrvRec = false;
if( !sta_bGetDrvRec && v_bGetLstValid && (0 == v_objGps.longitude || 0 == v_objGps.latitude) )
{
double dLichen;
long lLon = 0, lLat = 0;
g_objCarSta.GetLstValidLonlatAndLichen( lLon, lLat, dLichen );
v_objGps.longitude = double(lLon) / LONLAT_DO_TO_L;
v_objGps.latitude = double(lLat) / LONLAT_DO_TO_L;
v_objGps.speed = 0;
v_objGps.direction = 0;
v_objGps.valid = 'V';
bNeedSetBackGps = true;
sta_bGetDrvRec = true;
}
#endif
if( bNeedSetBackGps )
{
SetCurGps( &v_objGps, GPS_REAL | GPS_LSTVALID );
GetCurGps( &v_objGps, sizeof(v_objGps), GPS_LSTVALID );
}
// ACC无效而且GPS无效时,速度强制为0
if( 'A' !=v_objGps.valid )
{
v_objGps.speed = 0;
}
return 0; // 无论是否失败,都返回成功,因为有的地方如果读GPS失败,将发送失败应答,似乎不好,比如监控应答
}
int CMonAlert::GetCurQianGps( tagQianGps &v_objQianGps, bool v_bGetLstValid )
{
tagGPSData gps(0);
int iResult = GetCurGPS( gps, v_bGetLstValid );
if( iResult )
{
memset( (void*)&v_objQianGps, 0, sizeof(v_objQianGps) );
v_objQianGps.m_bytMix = 0x60;
return iResult;
}
GpsToQianGps( gps, v_objQianGps );
return 0; // 无论是否失败,都返回成功,因为有的地方如果读GPS失败,将发送失败应答,似乎不好
}
void CMonAlert::GpsToQianGps( const tagGPSData &v_objGps, tagQianGps &v_objQianGps )
{
v_objQianGps.m_bytGpsType = 0x42; // 标准GPS数据
// 千里眼通用版,公开版_研三
// 01ASCLGV
// A:GPS数据有效位,0-有效;1-无效
// L:车台负载状态,0-空车;1-重车
// S:省电模式,0-非省电模式;1-省电模式
// C: ACC状态, 0-ACC OFF, 1 - ACC ON
// G:经度字段中度字节的最高位
// V:速度字段最高位
// 千里眼公开版_研一
// 字节定义为:01A0TTGV
// A:GPS数据有效位,0-有效;1-无效
// G:经度字段中度字节的最高位
// V:速度字段最高位
// TT:空重车及停业状态 01-空车 10-重车 11-待定
v_objQianGps.m_bytMix = 0x40;
// 空车/重车
DWORD dwVeSta = g_objCarSta.GetVeSta();
if( dwVeSta & VESTA_HEAVY )
{
#if 0 == USE_PROTOCOL || 1 == USE_PROTOCOL
v_objQianGps.m_bytMix |= 0x04;
#endif
#if 2 == USE_PROTOCOL
v_objQianGps.m_bytMix &= 0xf3;
v_objQianGps.m_bytMix |= 0x08;
#endif
}
else
{
#if 0 == USE_PROTOCOL || 1 == USE_PROTOCOL
v_objQianGps.m_bytMix &= 0xfb;
#endif
#if 2 == USE_PROTOCOL
v_objQianGps.m_bytMix &= 0xf3;
v_objQianGps.m_bytMix |= 0x04;
#endif
}
// 省电模式
if( g_objQianIO.GetDeviceSta() & DEVSTA_SYSTEMSLEEP )
v_objQianGps.m_bytMix |= 0x10;
else
v_objQianGps.m_bytMix &= 0xef;
// ACC状态
byte bytSta = 0;
IOGet(IOS_ACC, &bytSta);
if( bytSta == IO_ACC_ON )
v_objQianGps.m_bytMix |= 0x08;
else
v_objQianGps.m_bytMix &= 0xf7;
// GPS是否有效
if( 'A' == v_objGps.valid ) v_objQianGps.m_bytMix &= 0xdf;
else v_objQianGps.m_bytMix |= 0x20;
v_objQianGps.m_bytDay = BYTE(v_objGps.nDay);
v_objQianGps.m_bytMon = BYTE(v_objGps.nMonth);
v_objQianGps.m_bytYear = BYTE(v_objGps.nYear % 1000);
v_objQianGps.m_bytSec = BYTE(v_objGps.nSecond);
v_objQianGps.m_bytMin = BYTE(v_objGps.nMinute);
v_objQianGps.m_bytHour = BYTE(v_objGps.nHour);
v_objQianGps.m_bytDir = BYTE(v_objGps.direction / 3 + 1);
// 北京时间->格林威治 (仅仅是小时改变)
if( v_objQianGps.m_bytHour < 8 )
v_objQianGps.m_bytHour += 24;
v_objQianGps.m_bytHour -= 8;
// 原始纬度
v_objQianGps.m_bytLatDu = BYTE(v_objGps.latitude);
double dLatFen = ( v_objGps.latitude - v_objQianGps.m_bytLatDu ) * 60;
v_objQianGps.m_bytLatFenzen = BYTE(dLatFen);
WORD wLatFenxiao = WORD( (dLatFen - v_objQianGps.m_bytLatFenzen) * 10000 );
v_objQianGps.m_bytLatFenxiao1 = wLatFenxiao / 100;
v_objQianGps.m_bytLatFenxiao2 = wLatFenxiao % 100;
// 原始经度
v_objQianGps.m_bytLonDu = BYTE(v_objGps.longitude);
double dLonFen = (v_objGps.longitude - v_objQianGps.m_bytLonDu) * 60;
v_objQianGps.m_bytLonFenzen = BYTE(dLonFen);
WORD wLonFenxiao = WORD( (dLonFen - v_objQianGps.m_bytLonFenzen) * 10000 );
v_objQianGps.m_bytLonFenxiao1 = wLonFenxiao / 100;
v_objQianGps.m_bytLonFenxiao2 = wLonFenxiao % 100;
// 原始速度
double dSpeed = v_objGps.speed * 3.6 / 1.852; // 转换为海里/小时
v_objQianGps.m_bytSpeed = BYTE( dSpeed );
// 校验和
{
BYTE bytSum = 0;
char szTemp[64];
int i;
// 纬度
int iTemp = int( v_objQianGps.m_bytLatDu );
sprintf( szTemp, "%02d", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 纬度整数分
iTemp = int( v_objQianGps.m_bytLatFenzen );
sprintf( szTemp, "%02d.", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 纬度小数分_1
iTemp = int( v_objQianGps.m_bytLatFenxiao1 );
sprintf( szTemp, "%02d", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 纬度小数分_2
iTemp = int( v_objQianGps.m_bytLatFenxiao2 );
sprintf( szTemp, "%02d", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 经度
iTemp = int( v_objQianGps.m_bytLonDu );
sprintf( szTemp, "%03d", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 经度整数分
iTemp = int( v_objQianGps.m_bytLonFenzen );
sprintf( szTemp, "%02d.", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 经度小数分_1
iTemp = int( v_objQianGps.m_bytLonFenxiao1 );
sprintf( szTemp, "%02d", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 经度小数分_2
iTemp = int( v_objQianGps.m_bytLonFenxiao2 );
sprintf( szTemp, "%02d", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
// 速度
iTemp = int( v_objQianGps.m_bytSpeed );
sprintf( szTemp, "%03d.0", iTemp );
for( i = 0; i < int(strlen(szTemp)); i++ ) bytSum += BYTE( szTemp[i] );
bytSum &= 0x7f;
if( 0 == bytSum ) bytSum = 0x7f;
v_objQianGps.m_bytChk = bytSum;
}
// 转义
if( 0 == v_objQianGps.m_bytLatDu ) v_objQianGps.m_bytLatDu = 0x7f;
if( 0 == v_objQianGps.m_bytLatFenzen ) v_objQianGps.m_bytLatFenzen = 0x7f;
if( 0 == v_objQianGps.m_bytLatFenxiao1 ) v_objQianGps.m_bytLatFenxiao1 = 0x7f;
if( 0 == v_objQianGps.m_bytLatFenxiao2 ) v_objQianGps.m_bytLatFenxiao2 = 0x7f;
if( 0 == v_objQianGps.m_bytLonFenzen ) v_objQianGps.m_bytLonFenzen = 0x7f;
if( 0 == v_objQianGps.m_bytLonFenxiao1 ) v_objQianGps.m_bytLonFenxiao1 = 0x7f;
if( 0 == v_objQianGps.m_bytLonFenxiao2 ) v_objQianGps.m_bytLonFenxiao2 = 0x7f;
if( 0 == v_objQianGps.m_bytLonDu ) v_objQianGps.m_bytLonDu = 0xff;
else if( 0x80 == v_objQianGps.m_bytLonDu ) v_objQianGps.m_bytLonDu = 0xfe;
if( v_objQianGps.m_bytLonDu & 0x80 ) v_objQianGps.m_bytMix |= 0x02;
else v_objQianGps.m_bytMix &= 0xfd;
v_objQianGps.m_bytLonDu &= 0x7f;
if( 0 == v_objQianGps.m_bytSpeed ) v_objQianGps.m_bytSpeed = 0xff;
else if( 0x80 == v_objQianGps.m_bytSpeed ) v_objQianGps.m_bytSpeed = 0xfe;
if( v_objQianGps.m_bytSpeed & 0x80 ) v_objQianGps.m_bytMix |= 0x01;
else v_objQianGps.m_bytMix &= 0xfe;
v_objQianGps.m_bytSpeed &= 0x7f;
}
//(需补充)
int CMonAlert::DealPhoneAutoReqLsnRes( BYTE v_bytResType )
{
}
/// 执行报警操作 (业务处理优先) (过滤了重复报警,只有新报警才会调用本过程)
int CMonAlert::_DealAlert( bool v_bReqLsn, bool v_bSilentTimer )
{
int iRet = 0;
if (NETWORK_TYPE != NETWORK_CDMA)
{
// 屏蔽CDMA车台的主动监听功能,因为会导致一直发送报警短信
// 启动主动监听
if( v_bReqLsn )
{
_BeginAutoReqLsn( ALERTREQLSN_DEALYPERIOD ); // 不立刻启动监听,以尽量保证第一个报警数据能发送出去
}
}
// 打开报警静默定时
if( v_bSilentTimer )
_SetTimer(&g_objTimerMng, ALERT_SILENT_TIMER, ALERT_SILENT_PERIOD, G_TmAlertSilent );
// 打开清除报警状态的定时
_KillTimer(&g_objTimerMng, ALERT_INVALID_TIMER );
_SetTimer(&g_objTimerMng, ALERT_INVALID_TIMER, ALERT_INVALID_PERIOD, G_TmAlertInvalid );
// 修改定时监控参数
if( !m_objMonStatus.m_bInterv || m_objMonStatus.m_dwMonInterv > ALERT_SNDDATA_INTERVAL )
m_objMonStatus.m_dwMonInterv = ALERT_SNDDATA_INTERVAL;
m_objMonStatus.m_bInterv = true;
if( ALERT_SNDDATA_PERIOD > m_objMonStatus.m_dwMonTime + 2000 )
{
m_objMonStatus.m_dwMonTime = ALERT_SNDDATA_PERIOD;
m_objMonStatus.m_bAlertAuto = true; // 标记为报警主动激发的监控
}
// 立刻发送第一个报警数据
tagGPSData objGps(0);
tag2QGprsCfg objGprsCfg;
GetCurGPS( objGps, true );
objGprsCfg.Init();
::GetSecCfg( &objGprsCfg, sizeof(objGprsCfg),
offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
_Snd0145( objGps, objGprsCfg, true );
// 打开(重设)监控定时
_BeginMon( 0, 0 );
return iRet;
}
void CMonAlert::_ClrAlertSta()
{
// 关闭 "清除报警状态"定时
// m_dwAlertSymb = 0;
m_dwAlertSymb &= 0x00000808;//前后车门只有在关车门时才清除报警状态
m_objMonStatus.m_bAlertAuto = false;
_KillTimer(&g_objTimerMng, ALERT_INVALID_TIMER );
// 关闭主动监听定时
_KillTimer(&g_objTimerMng, AUTO_REQLSN_TIMER );
#if USE_LEDTYPE == 1
char cCmd = LED_CMD_ALERMCANCEL;
g_objLedBohai.m_objLocalCmdQue.push( (unsigned char*)&cCmd, 1 );
#endif
#if USE_LEDTYPE == 2
g_objLedChuangLi.DealEvent(0x04, 'A', 0);
#endif
// 指示灯慢闪
char szbuf[10] = {0};
szbuf[0] = 0x02; // 0x02表示控制指示灯
szbuf[1] = 0x06; // 撤销抢劫报警通知
DataPush(szbuf, 2, DEV_QIAN, DEV_DIAODU, LV2);
}
/// 打开/关闭抢劫报警
int CMonAlert::SetAlertFoot( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
objAlertCfg.Init();
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x20) )
{
m_dwAlertSymb &= ~ALERT_TYPE_FOOT;
PRTMSG(MSG_NOR, "Deal FootAlerm, but this func is Disabled! Exit!\n" );
return 0;
}
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( !(ALERT_TYPE_FOOT & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
#if USE_LEDTYPE == 3
//LED 顶灯显示报警
g_objKTLed.SetLedShow('A',0,1);
#endif
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertFootTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_FOOT; // 设置该报警状态
}
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start FootAlerm\n" );
char buf[16] = { 0 };
//增加报警时中止通话
buf[0] = (char) 0xf3;
buf[1] = (char) ALERT_STOP_PHONE_PRD;
DataPush(buf, 2, DEV_QIAN, DEV_PHONE, LV2);
PRTMSG(MSG_NOR, "Deal Foot Alerm,Req Comu handoff phone,and Fbid Phone in %d s\n", ALERT_STOP_PHONE_PRD );
#if USE_LEDTYPE == 1
char cCmd = LED_CMD_ALERM;
g_objLedBohai.m_objLocalCmdQue.push( (unsigned char*)&cCmd, 1 );
#endif
#if USE_LEDTYPE == 2
g_objLedChuangLi.DealEvent(0x03, 'A', 0);
#endif
// 统一报警处理
iRet = _DealAlert( true, false ); // (与老大商定,抢劫报警之后,不检查抢劫报警电平)
// 更新报警初始时刻
m_dwAlertFootTm = dwCur;
// 抢劫报警时视频主动上传
char szbuf[100];
// int iBufLen = 0;
// byte bytType = 0x00; // 抢劫报警时的视频主动上传类型为0x00
// int iResult = g_objSms.MakeSmsFrame((char*)&bytType, 1, 0x38, 0x46, szbuf, sizeof(szbuf), iBufLen);
// if( !iResult ) g_objSock.SOCKSNDSMSDATA( szbuf, iBufLen, LV12, 0 );
// 指示灯快闪
szbuf[0] = 0x02; // 0x02表示控制指示灯
szbuf[1] = 0x05; // 绿灯快闪(160VC), 或 抢劫报警通知(V6-60)
DataPush(szbuf, 2, DEV_QIAN, DEV_DIAODU, LV2);
#if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2
g_objPhoto.AddPhoto( PHOTOEVT_FOOTALERM );
#endif
}
return 0;
}
/// 打开/关闭断电报警
int CMonAlert::SetAlertPowOff( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x04) )
{
m_dwAlertSymb &= ~ALERT_TYPE_POWOFF;
PRTMSG(MSG_NOR, "Deal Powoff Alerm,but this func is Disabled! Exit!\n" );
return 0;
}
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( !(ALERT_TYPE_POWOFF & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertPowerOffTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_POWOFF; // 设置该报警状态
}
else // 若是清除报警
{
PRTMSG(MSG_NOR, "Stop Powoff Alerm!\n" );
if( m_dwAlertSymb & ALERT_TYPE_POWOFF )
{
m_dwAlertSymb &= ~ALERT_TYPE_POWOFF; // 清除该报警状态
// 不用关闭监控定时,因为可能报警关了,监控还存在
// 不用打开主动上报定时,因为监控停止时会打开主动上报定时
if( !m_dwAlertSymb ) // 若清除后没有任何报警
bytAlertDealType = 2; // 要关闭报警处理
}
}
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start Powoff Alerm!\n" );
// 统一报警处理
iRet = _DealAlert( false, true );
// 更新报警初始时刻
m_dwAlertPowerOffTm = dwCur;
}
else if( 2 == bytAlertDealType ) // 若要关闭所有报警
{
if( m_objMonStatus.m_bAlertAuto )
{
_EndMon(); // 若是报警激发的,关闭监控
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
BYTE bytEndType = 0x04; // 因为报警信号终止
int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
}
}
return 0;
}
int CMonAlert::SetAlertPowBrownout( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x40) )
{
m_dwAlertSymb &= ~ALERT_TYPE_POWBROWNOUT;
PRTMSG(MSG_NOR, "Deal Pow Brownout Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( !(ALERT_TYPE_POWBROWNOUT & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertPowerOffTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_POWBROWNOUT; // 设置该报警状态
}
else // 若是清除报警
{
PRTMSG(MSG_NOR, "Stop Pow Brownout Alerm!\n" );
if( m_dwAlertSymb & ALERT_TYPE_POWBROWNOUT )
{
m_dwAlertSymb &= ~ALERT_TYPE_POWBROWNOUT; // 清除该报警状态
// 不用关闭监控定时,因为可能报警关了,监控还存在
// 不用打开主动上报定时,因为监控停止时会打开主动上报定时
if( !m_dwAlertSymb ) // 若清除后没有任何报警
bytAlertDealType = 2; // 要关闭报警处理
}
}
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start Pow Brownout Alerm!\n" );
// 统一报警处理
iRet = _DealAlert( false, true );
// 更新报警初始时刻
m_dwAlertPowerOffTm = dwCur;
}
else if( 2 == bytAlertDealType ) // 若要关闭所有报警
{
// 到时候检查发现报警信号不存在时自然会关闭 _KillTimer(&g_objTimerMng, ALERT_SILENT_TIMER ); // 关闭静默报警定时器
if( m_objMonStatus.m_bAlertAuto )
{
_EndMon(); // 若是报警激发的,关闭监控
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
BYTE bytEndType = 0x04; // 因为报警信号终止
int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
}
}
return 0;
}
/// 打开/关闭非法开前车门报警
int CMonAlert::SetAlertFrontDoor( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
tag2QGprsCfg objGprsCfg;
GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x08) )
{
m_dwAlertSymb &= ~ALERT_TYPE_FRONTDOOR;
PRTMSG(MSG_NOR, "Deal FrontDooropen Alerm, but this func is Disabled, Exit!\n" );
return 0;
}
if( !(ALERT_TYPE_FRONTDOOR & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertFrontDoorTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_FRONTDOOR; // 设置该报警状态
}
else // 若是清除报警
{
PRTMSG(MSG_NOR, "Stop FrontDooropen Alerm!\n" );
if( m_dwAlertSymb & ALERT_TYPE_FRONTDOOR )
{
m_dwAlertSymb &= ~ALERT_TYPE_FRONTDOOR; // 清除该报警状态
// 不用关闭监控定时,因为可能报警关了,监控还存在
// 不用打开主动上报定时,因为监控停止时会打开主动上报定时
if( !m_dwAlertSymb ) // 若清除后没有任何报警
bytAlertDealType = 2; // 要关闭报警处理
}
}
PRTMSG(MSG_NOR, "bytAlertDealType = %d\n", bytAlertDealType);
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start FrontDooropen Alerm!\n" );
// 统一报警处理
iRet = _DealAlert( false, false );
// 更新报警初始时刻
m_dwAlertFrontDoorTm = dwCur;
#if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2
g_objPhoto.AddPhoto( PHOTOEVT_OPENDOOR );
#endif
}
else if( 2 == bytAlertDealType ) // 若要关闭所有报警
{
if( m_objMonStatus.m_bAlertAuto )
{
_EndMon(); // 若是报警激发的,关闭监控
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
BYTE bytEndType = 0x04; // 因为报警信号终止
int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
}
}
return 0;
}
/// 打开/关闭非法开后车门报警
int CMonAlert::SetAlertBackDoor( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
tag2QGprsCfg objGprsCfg;
GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x08) )
{
m_dwAlertSymb &= ~ALERT_TYPE_BACKDOOR;
PRTMSG(MSG_NOR, "Deal BackDooropen Alerm, but this func is Disabled, Exit!\n" );
return 0;
}
if( !(ALERT_TYPE_BACKDOOR & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertBackDoorTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_BACKDOOR; // 设置该报警状态
}
else // 若是清除报警
{
PRTMSG(MSG_NOR, "Stop BackDooropen Alerm!\n" );
if( m_dwAlertSymb & ALERT_TYPE_BACKDOOR )
{
m_dwAlertSymb &= ~ALERT_TYPE_BACKDOOR; // 清除该报警状态
// 不用关闭监控定时,因为可能报警关了,监控还存在
// 不用打开主动上报定时,因为监控停止时会打开主动上报定时
if( !m_dwAlertSymb ) // 若清除后没有任何报警
bytAlertDealType = 2; // 要关闭报警处理
}
}
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start BackDooropen Alerm!\n" );
// 统一报警处理
iRet = _DealAlert( false, false );
// 更新报警初始时刻
m_dwAlertBackDoorTm = dwCur;
#if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2
g_objPhoto.AddPhoto( PHOTOEVT_OPENDOOR );
#endif
}
else if( 2 == bytAlertDealType ) // 若要关闭所有报警
{
if( m_objMonStatus.m_bAlertAuto )
{
_EndMon(); // 若是报警激发的,关闭监控
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
BYTE bytEndType = 0x04; // 因为报警信号终止
int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
}
}
return 0;
}
int CMonAlert::SetAlertOverTurn( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x08) )
{
m_dwAlertSymb &= ~ALERT_TYPE_OVERTURN;
PRTMSG(MSG_NOR, "Deal OverTurn Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( !(ALERT_TYPE_OVERTURN & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertOverTurnTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_OVERTURN; // 设置该报警状态
}
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start OverTurn Alerm\n" );
// 统一报警处理
iRet = _DealAlert( false, false ); // 侧翻报警之后,虽然定期会有报警电平出现,但主动查询时不一定能查到,故不需要检查
// 更新报警初始时刻
m_dwAlertOverTurnTm = dwCur;
// 侧翻报警拍照(去除)
char szBuf[2] = {0};
szBuf[0] = 0x04;
szBuf[1] = 0x02;
DataPush(szBuf, 2, DEV_QIAN, DEV_DVR, LV2);
}
return 0;
}
int CMonAlert::SetAlertBump( const bool v_bSet )
{
int iRet = 0;
DWORD dwCur = GetTickCount();
tag2QAlertCfg objAlertCfg;
::GetSecCfg( &objAlertCfg, sizeof(objAlertCfg),
offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_1 & 0x10) )
{
m_dwAlertSymb &= ~ALERT_TYPE_BUMP;
PRTMSG(MSG_NOR, "Deal Bump Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
// 注意初始化值
BYTE bytAlertDealType = 0; // 1,要新处理报警; 2,要关闭所有报警处理
// (注意处理时的顺序)
if( v_bSet ) // 若是设置报警
{
if( !(ALERT_TYPE_BUMP & m_dwAlertSymb) ) // 若之前没有该报警状态
{
bytAlertDealType = 1; // 要新处理该报警
}
else // 若已经有该报警状态
{
if( dwCur - m_dwAlertBumpTm > ALERT_SNDDATA_PERIOD ) // 若超过报警活动时间
{
bytAlertDealType = 1; // 要新处理该报警
}
}
m_dwAlertSymb |= ALERT_TYPE_BUMP; // 设置该报警状态
}
// 新报警处理
if( 1 == bytAlertDealType ) // 若要新处理报警
{
PRTMSG(MSG_NOR, "Start Bump Alerm\n" );
// 统一报警处理
iRet = _DealAlert( false, false ); // 碰撞报警之后,不需要定时检查报警电平
// 更新报警初始时刻
m_dwAlertBumpTm = dwCur;
// 侧翻报警拍照(去除)
char szBuf[2] = {0};
szBuf[0] = 0x04;
szBuf[1] = 0x03;
DataPush(szBuf, 2, DEV_QIAN, DEV_DVR, LV2);
}
return 0;
}
int CMonAlert::SetAlertDrive( const bool v_bSet )
{
int iRet = 0;
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_2 & 0x04) )
{
m_dwAlertSymb &= ~ALERT_TYPE_DRIVE;
PRTMSG(MSG_NOR, "Deal Illegal Drive Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
if( v_bSet ) // 若要开始报警
{
PRTMSG(MSG_NOR, "Start Illegal Drive Alerm!\n" );
m_dwAlertSymb |= ALERT_TYPE_DRIVE;
// 发送一条非法启动报警
tagGPSData objGps(0);
tag2QGprsCfg objGprsCfg;
GetCurGPS( objGps, true );
objGprsCfg.Init();
::GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
_SendOne0149Alert(objGps, ALERM_0149_25);
m_dwAlertSymb &= ~ALERT_TYPE_DRIVE; // 报警之后,将标志位清除
// // 统一报警处理
// iRet = _DealAlert( false, false );
//
// // 非法发动车辆报警拍照
// char szBuf[2] = {0};
// szBuf[0] = 0x04;
// szBuf[1] = 0x0a;
// DataPush(szBuf, 2, DEV_QIAN, DEV_DVR, LV2);
}
// else
// {
// if( m_dwAlertSymb & ALERT_TYPE_DRIVE )
// {
// m_dwAlertSymb &= ~ALERT_TYPE_DRIVE;
//
// if( 0 == m_dwAlertSymb && m_objMonStatus.m_bAlertAuto )
// {
// _EndMon(); // 若是报警激发的,关闭监控
//
// char buf[ 200 ] = { 0 };
// int iBufLen = 0;
// BYTE bytEndType = 0x04; // 因为报警信号终止
// int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
// if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
// }
// }
// }
return 0;
}
int CMonAlert::SetAlertOverSpd( const bool v_bSet )
{
int iRet = 0;
tag2QAlertCfg objAlertCfg;
::GetSecCfg( &objAlertCfg, sizeof(objAlertCfg),
offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_2 & 0x20) )
{
m_dwAlertSymb &= ~ALERT_TYPE_OVERSPEED;
PRTMSG(MSG_NOR, "Deal OverSpeed Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
if( v_bSet ) // 若要开始报警
{
PRTMSG(MSG_NOR, "Start OverSpeed Alerm!\n" );
m_dwAlertSymb |= ALERT_TYPE_OVERSPEED;
// 统一报警处理(超速报警不统一处理,因为只报一次)
//iRet = _DealAlert( false, false );
// 发送一条超速报警
tagGPSData objGps(0);
tag2QGprsCfg objGprsCfg;
GetCurGPS( objGps, true );
objGprsCfg.Init();
::GetSecCfg( &objGprsCfg, sizeof(objGprsCfg),
offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
_Snd0145( objGps, objGprsCfg, true );
m_dwAlertSymb &= ~ALERT_TYPE_OVERSPEED; // 超速报警之后,将标志位清除
#if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2
g_objPhoto.AddPhoto( PHOTOEVT_OVERSPEED );
#endif
}
// else
// {
// if( m_dwAlertSymb & ALERT_TYPE_OVERSPEED )
// {
// m_dwAlertSymb &= ~ALERT_TYPE_OVERSPEED;
//
// if( 0 == m_dwAlertSymb && m_objMonStatus.m_bAlertAuto )
// {
// _EndMon(); // 若是报警激发的,关闭监控
//
// char buf[ 200 ] = { 0 };
// int iBufLen = 0;
// BYTE bytEndType = 0x04; // 因为报警信号终止
// int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
// if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
// }
// }
// }
return 0;
}
int CMonAlert::SetAlertBelowSpd( const bool v_bSet )
{
int iRet = 0;
tag2QAlertCfg objAlertCfg;
::GetSecCfg( &objAlertCfg, sizeof(objAlertCfg),
offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_2 & 0x04) )
{
m_dwAlertSymb &= ~ALERT_TYPE_BELOWSPEED;
PRTMSG(MSG_NOR, "Deal BelowSpeed Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
if( v_bSet ) // 若要开始报警
{
PRTMSG(MSG_NOR, "Start BelowSpeed Alerm!\n" );
m_dwAlertSymb |= ALERT_TYPE_BELOWSPEED;
// 统一报警处理(低速报警不统一处理,因为只报一次)
//iRet = _DealAlert( false, false );
// 发送一条低速报警
tagGPSData objGps(0);
tag2QGprsCfg objGprsCfg;
GetCurGPS( objGps, true );
objGprsCfg.Init();
::GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
_SendOne0149Alert(objGps, ALERM_0149_1);
m_dwAlertSymb &= ~ALERT_TYPE_BELOWSPEED; // 超速报警之后,将标志位清除
#if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2
g_objPhoto.AddPhoto( PHOTOEVT_BELOWSPEED );
#endif
}
// else
// {
// if( m_dwAlertSymb & ALERT_TYPE_BELOWSPEED )
// {
// m_dwAlertSymb &= ~ALERT_TYPE_BELOWSPEED;
//
// if( 0 == m_dwAlertSymb && m_objMonStatus.m_bAlertAuto )
// {
// _EndMon(); // 若是报警激发的,关闭监控
//
// char buf[ 200 ] = { 0 };
// int iBufLen = 0;
// BYTE bytEndType = 0x04; // 因为报警信号终止
// int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
// if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
// }
// }
// }
return 0;
}
int CMonAlert::SetAlertArea( const bool v_bSet )
{
int iRet = 0;
tag2QAlertCfg objAlertCfg;
::GetSecCfg( &objAlertCfg, sizeof(objAlertCfg),
offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( v_bSet && !(objAlertCfg.m_bytAlert_2 & 0x40) )
{
m_dwAlertSymb &= ~ALERT_TYPE_RANGE;
PRTMSG(MSG_NOR, "Deal Area Alerm, but this func is Disabled! Exit!\n" );
return 0;
}
if( v_bSet ) // 若要开始报警
{
PRTMSG(MSG_NOR, "Start Area Alerm!\n" );
m_dwAlertSymb |= ALERT_TYPE_RANGE;
// 发送一条越界报警
tagGPSData objGps(0);
tag2QGprsCfg objGprsCfg;
GetCurGPS( objGps, true );
objGprsCfg.Init();
::GetSecCfg( &objGprsCfg, sizeof(objGprsCfg),
offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
_Snd0145( objGps, objGprsCfg, true );
m_dwAlertSymb &= ~ALERT_TYPE_RANGE; // 报警之后,将标志位清除
#if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2
g_objPhoto.AddPhoto( PHOTOEVT_AREA );
#endif
}
return 0;
}
/// 现在用于JG2
int CMonAlert::SetAlertOther(DWORD v_dwType, const bool v_bSet)
{
if(v_bSet)
{
m_dwAlertSymb |= v_dwType; // 设置该报警状态
_DealAlert( false, false );
}
else
{
if( m_dwAlertSymb & v_dwType )
{
m_dwAlertSymb &= ~v_dwType;
if( 0 == m_dwAlertSymb ) // 若清除后没有任何报警
{
if( m_objMonStatus.m_bAlertAuto )
{
_EndMon(); // 若是报警激发的,关闭监控
char buf[ 200 ] = { 0 };
int iBufLen = 0;
BYTE bytEndType = 0x04; // 因为报警信号终止
int iResult = g_objSms.MakeSmsFrame((char*)&bytEndType, 1, 0x01, 0x44, buf, sizeof(buf), iBufLen);
if( !iResult ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, 0 );
}
}
}
}
return 1;
}
int CMonAlert::SetAlertTest()
{
_KillTimer(&g_objTimerMng, ALERT_TEST_TIMER );
_SetTimer(&g_objTimerMng, ALERT_TEST_TIMER, ALERT_TEST_PERIOD, G_TmAlertTest );
m_dwAlertSymb |= ALERT_TYPE_TEST;
return 0;
}
int CMonAlert::_BeginAutoReqLsn( DWORD v_dwBeginInterval, char* v_szLsnTel/*=NULL*/ )
{
// 设置监听号码
memset( m_szAutoReqLsnTel, 0, sizeof(m_szAutoReqLsnTel) );
if( !v_szLsnTel )
{
tag2QServCodeCfg objLsnCfg;
objLsnCfg.Init();
GetSecCfg( &objLsnCfg, sizeof(objLsnCfg), offsetof(tagSecondCfg, m_uni2QServCodeCfg.m_obj2QServCodeCfg), sizeof(objLsnCfg) );
strncpy( m_szAutoReqLsnTel, (char*)&(objLsnCfg.m_aryLsnHandtel[0]), sizeof(m_szAutoReqLsnTel) - 1 );
}
else
{
strncpy( m_szAutoReqLsnTel, v_szLsnTel, sizeof(m_szAutoReqLsnTel) - 1 );
}
m_szAutoReqLsnTel[ 14 ] = 0;
char* pBlank = strchr( m_szAutoReqLsnTel, 0x20 );
if( pBlank ) *pBlank = 0;
// 清除监听状态并启动监听
m_bytAutoReqLsnCount = 0;
m_bytAutoReqLsnContBusyCt = 0;
_KillTimer(&g_objTimerMng, AUTO_REQLSN_TIMER );
_SetTimer(&g_objTimerMng, AUTO_REQLSN_TIMER, v_dwBeginInterval, G_TmAutoReqLsn ); // 多少时间之后启动监听
return 0;
}
int CMonAlert::_AutoReqLsn()
{
// 保险起见
m_szAutoReqLsnTel[ sizeof(m_szAutoReqLsnTel) - 1 ] = 0;
WORD wTelLen = WORD( strlen(m_szAutoReqLsnTel) );
if( wTelLen > 20 || wTelLen < 3 ) return ERR_AUTOLSN_NOTEL;
char buf[ 100 ] = { 0 };
buf[ 0 ] = BYTE(0xf1);
buf[ 1 ] = BYTE( wTelLen );
memcpy( buf + 2, m_szAutoReqLsnTel, wTelLen );
if( DataPush(buf, 2+wTelLen, DEV_QIAN, DEV_PHONE, LV2) )
return ERR_AUTOLSN;
return 0;
}
bool CMonAlert::JugFootAlert()
{
return m_dwAlertSymb & ALERT_TYPE_FOOT ? true : false;
}
DWORD CMonAlert::GetAlertSta()
{
return m_dwAlertSymb;
}
/*
void CMonAlert::FillAlertSymb( const DWORD v_dwAlertSta, BYTE &v_byt1, BYTE &v_byt2 )
{
// 千里眼通用版,公开版_研三
// 高字节:
// 0 A1 A2 E1 E2 E3 V 1
// 低字节:
// 0 C K S1 S2 S3 T 1
// A1,A2:外接报警器状态
// 00:正常
// 01:震动报警
// 10:非法打开车门报警
// 11:保留待定
// E1,E2,E3:越界报警器状态(本组报警状态适合于危险车辆)
// 000:正常
// 001:在规定的时间段以外行驶
// 010:超速行驶
// 011:停留时间过长
// 100:越界行驶
// 其它保留待定
// V:欠压报警
// 0:正常 1:欠压
// C:断路报警
// 0:正常 1:断路
// K:抢劫报警
// 0:正常 1:抢劫
// T:测试标志位
// 0:正常 1:测试
// S1,S2,S3:保留待定
// 千里眼公开版_研一
// 高字节:
// 0 A1 A2 E1 E2 E3 V 1
// 低字节:
// 0 C K S1 S2 S3 T 1
// A1,A2:外接报警器状态
// 00:正常
// 01:震动报警
// 10:非法打开车门报警
// 11:保留待定
// E1:越界行驶标志
// 0:正常
// 1:越界行驶
// E2:超速行驶标志
// 0:正常
// 1:超速行驶
// E3:在规定时间段外行驶标志
// 0:正常
// 1:在规定时间段外行驶
// S1:非法发动车辆标志
// 0:正常
// 1:非法发动车辆
// V:欠压报警
// 0:正常 1:欠压
// C:断路报警
// 0:正常 1:断路
// K:抢劫报警
// 0:正常 1:抢劫
// T:测试标志位
// 0:正常 1:测试
// S2,S3:保留待定
v_byt1 = 1, v_byt2 = 1;
if( ALERT_TYPE_POWBROWNOUT & v_dwAlertSta ) // 欠压报警
v_byt1 |= 0x02;
if( ALERT_TYPE_TIME & v_dwAlertSta ) // 时间段外行驶报警
v_byt1 |= 0x04;
if( ALERT_TYPE_RSPEED & v_dwAlertSta ) // 区域超速报警(越界并超速)
{
v_byt1 |= 0x08;
v_byt1 |= 0x10;
}
if( ALERT_TYPE_RANGE & v_dwAlertSta ) // 越界报警
v_byt1 |= 0x10;
if( ALERT_TYPE_OVERTURN & v_dwAlertSta ) // 侧翻报警
v_byt1 |= 0x20;
#if USE_PROTOCOL == 0 || USE_PROTOCOL == 1 || USE_PROTOCOL == 2
if( ALERT_TYPE_FRONTDOOR & v_dwAlertSta ) // 非法开车门报警
v_byt1 |= 0x40;
#endif
#if USE_PROTOCOL == 30
if( ALERT_TYPE_BUMP & v_dwAlertSta ) // 碰撞报警
v_byt1 |= 0x40;
#endif
if( ALERT_TYPE_DRIVE & v_dwAlertSta ) // 非法启动车辆
v_byt2 |= 0x10;
if( ALERT_TYPE_OVERSPEED & v_dwAlertSta ) // 超速报警
v_byt2 |= 0x08;
if( ALERT_TYPE_FOOT & v_dwAlertSta ) // 抢劫报警
v_byt2 |= 0x20;
if( ALERT_TYPE_POWOFF & v_dwAlertSta ) // 断电报警
v_byt2 |= 0x40;
if( ALERT_TYPE_TEST & v_dwAlertSta ) // 报警测试
v_byt2 |= 0x02;
}
*/
void CMonAlert::FillAlertSymb( const DWORD v_dwAlertSta, BYTE *v_byt1, BYTE *v_byt2 )
{
// 千里眼通用版,公开版_研三
// 高字节:
// 0 A1 A2 E1 E2 E3 V 1
// 低字节:
// 0 C K S1 S2 S3 T 1
// A1,A2:外接报警器状态
// 00:正常
// 01:震动报警
// 10:非法打开车门报警
// 11:保留待定
// E1,E2,E3:越界报警器状态(本组报警状态适合于危险车辆)
// 000:正常
// 001:在规定的时间段以外行驶
// 010:超速行驶
// 011:停留时间过长
// 100:越界行驶
// 其它保留待定
// V:欠压报警
// 0:正常 1:欠压
// C:断路报警
// 0:正常 1:断路
// K:抢劫报警
// 0:正常 1:抢劫
// T:测试标志位
// 0:正常 1:测试
// S1,S2,S3:保留待定
// 千里眼公开版_研一
// 高字节:
// 0 A1 A2 E1 E2 E3 V 1
// 低字节:
// 0 C K S1 S2 S3 T 1
// A1,A2:外接报警器状态
// 00:正常
// 01:震动报警
// 10:非法打开车门报警
// 11:保留待定
// E1:越界行驶标志
// 0:正常
// 1:越界行驶
// E2:超速行驶标志
// 0:正常
// 1:超速行驶
// E3:在规定时间段外行驶标志
// 0:正常
// 1:在规定时间段外行驶
// S1:非法发动车辆标志
// 0:正常
// 1:非法发动车辆
// V:欠压报警
// 0:正常 1:欠压
// C:断路报警
// 0:正常 1:断路
// K:抢劫报警
// 0:正常 1:抢劫
// T:测试标志位
// 0:正常 1:测试
// S2,S3:保留待定
*v_byt1 = 1, *v_byt2 = 1;
if( ALERT_TYPE_POWBROWNOUT & v_dwAlertSta ) // 欠压报警
*v_byt1 |= 0x02;
if( ALERT_TYPE_TIME & v_dwAlertSta ) // 时间段外行驶报警
*v_byt1 |= 0x04;
if( ALERT_TYPE_RSPEED & v_dwAlertSta ) // 区域超速报警(越界并超速)
{
*v_byt1 |= 0x08;
*v_byt1 |= 0x10;
}
if( ALERT_TYPE_RANGE & v_dwAlertSta ) // 越界报警
*v_byt1 |= 0x10;
if( ALERT_TYPE_OVERTURN & v_dwAlertSta ) // 侧翻报警
*v_byt1 |= 0x20;
#if USE_PROTOCOL == 0 || USE_PROTOCOL == 1 || USE_PROTOCOL == 2
if( (ALERT_TYPE_FRONTDOOR & v_dwAlertSta) || (ALERT_TYPE_BACKDOOR & v_dwAlertSta) ) // 非法开车门报警
*v_byt1 |= 0x40;
#endif
#if USE_PROTOCOL == 30
if( ALERT_TYPE_BUMP & v_dwAlertSta ) // 碰撞报警
*v_byt1 |= 0x40;
#endif
if( ALERT_TYPE_DRIVE & v_dwAlertSta ) // 非法启动车辆
*v_byt2 |= 0x10;
if( ALERT_TYPE_OVERSPEED & v_dwAlertSta ) // 超速报警
*v_byt1 |= 0x08;
if( ALERT_TYPE_FOOT & v_dwAlertSta ) // 抢劫报警
*v_byt2 |= 0x20;
if( ALERT_TYPE_POWOFF & v_dwAlertSta ) // 断电报警
*v_byt2 |= 0x40;
if( ALERT_TYPE_TEST & v_dwAlertSta ) // 报警测试
*v_byt2 |= 0x02;
}
void CMonAlert::FillAlertSymbFor0149( const DWORD v_dwAlertSta, BYTE *v_byt1, BYTE *v_byt2 )
{
// 千里眼通用版,公开版_研三
// 高字节:
// A15 A14 A13 A12 A11 A10 A9 A8
// 低字节:
// A7 A6 A5 A4 A3 A2 A1 A0
// A0,A1:
// 00:正常
// 01:碰撞报警
// 10:侧翻报警
// A2:
// 1:低速报警
// 0:正常
*v_byt1 = 0, *v_byt2 = 0;
if( ALERT_TYPE_BUMP & v_dwAlertSta ) // 碰撞报警
*v_byt2 |= 0x02;
if( ALERT_TYPE_OVERTURN & v_dwAlertSta ) // 侧翻报警
*v_byt2 |= 0x01;
if( ALERT_TYPE_BELOWSPEED & v_dwAlertSta ) // 低速报警
*v_byt2 |= 0x04;
}
bool CMonAlert::IsMonAlert()
{
return (m_objMonStatus.m_bInterv || m_objMonStatus.m_bSpace) && m_objMonStatus.m_dwMonTime >= 1000;
}
/// 监控请求 (应答成功优先)
int CMonAlert::Deal0101(char* v_szSrcHandtel, char *v_szData, DWORD v_dwDataLen, bool v_bFromSM, bool v_bSendRes/*=true*/)
{
// 通用版,公开版_研三
// 监控业务类型(1)+ 监控时间(2)+ 监控周期(2)+ 定距距离(2)
// 公开版_研一
// 监控业务类型(1)+ 监控时间(2)+ 监控周期(2)+ 定距距离(2)+ 上传GPS数据总条数(2)
PRTMSG(MSG_NOR, "Rcv Cent Mon Req\n" );
tag0141 res;
tagMonStatus objMonStatus;
tagGPSData objGps(0);
int iRet = 0;
int iBufLen = 0;
char buf[ SOCK_MAXSIZE ];
BYTE bytAnsType = 0x01;
if( v_dwDataLen < sizeof(tag0101) )
{
PRTMSG(MSG_ERR, "Deal0101 error 1, v_dwDatalen = %d, sizeof(tag0101) = %d\n", v_dwDataLen, sizeof(tag0101));
XUN_ASSERT_VALID( false, "" );
return ERR_DATA_INVALID;
}
tag0101 req;
memcpy( &req, v_szData, sizeof(req) );
BYTE bytTemp = req.m_bytMonType & 0x18;
// 解析参数,设置监控条件
objMonStatus = m_objMonStatus; // 先用原参数初始化
if( 0 == bytTemp || 0x10 == bytTemp ) // 有定时
{
if( 0x7f == req.m_bytIntervMin ) req.m_bytIntervMin = 0;
if( 0x7f == req.m_bytIntervSec ) req.m_bytIntervSec = 0;
if( req.m_bytIntervMin > 126 )
{
PRTMSG(MSG_ERR, "Deal0101 error 2\n");
iRet = ERR_DATA_INVALID;
goto DEAL0101_FAIL;
}
if( req.m_bytIntervSec > 59 )
{
PRTMSG(MSG_ERR, "Deal0101 error 3\n");
iRet = ERR_DATA_INVALID;
goto DEAL0101_FAIL;
}
objMonStatus.m_bInterv = true;
objMonStatus.m_dwMonInterv = (req.m_bytIntervMin * 60 + req.m_bytIntervSec) * 1000 ;
if( objMonStatus.m_dwMonInterv < 1000 ) objMonStatus.m_dwMonInterv = 1000; // 保险起见
}
else
{
objMonStatus.m_bInterv = false;
}
if( 0x08 == bytTemp || 0x10 == bytTemp ) // 有定距
{
if( 0x7f == req.m_bytSpaceKilo ) req.m_bytSpaceKilo = 0;
if( 0x7f == req.m_bytSpaceTenmeter ) req.m_bytSpaceTenmeter = 0;
if( req.m_bytSpaceKilo > 126 )
{
PRTMSG(MSG_ERR, "Deal0101 error 4\n");
iRet = ERR_DATA_INVALID;
goto DEAL0101_FAIL;
}
if( req.m_bytSpaceTenmeter > 99 )
{
PRTMSG(MSG_ERR, "Deal0101 error 5\n");
iRet = ERR_DATA_INVALID;
goto DEAL0101_FAIL;
}
objMonStatus.m_bSpace = true;
objMonStatus.m_dwSpace = req.m_bytSpaceKilo * 1000 + req.m_bytSpaceTenmeter * 10;
if( objMonStatus.m_dwSpace < 10 ) objMonStatus.m_dwSpace = 10;
}
else
{
objMonStatus.m_bSpace = false;
}
if( 0x18 == bytTemp ) // 这个判断重要,防止不正确的监控参数,导致不停的异常监控处理
{
PRTMSG(MSG_ERR, "Deal0101 error 6\n");
iRet = ERR_DATA_INVALID;
goto DEAL0101_FAIL; // 无效的更新方式
}
// 监控时间
if( 0x7f == req.m_bytTimeHour ) req.m_bytTimeHour = 0;
if( 0x7f == req.m_bytTimeMin ) req.m_bytTimeMin = 0;
if( 0 == req.m_bytTimeHour && 0 == req.m_bytTimeMin )
{
objMonStatus.m_dwMonTime = INVALID_NUM_32; // (注意哦)
m_objMonStatus.m_bAlertAuto = false;
}
else
{
DWORD dwMonTime = (req.m_bytTimeHour * DWORD(60) + req.m_bytTimeMin) * 60 * 1000;
if( dwMonTime > objMonStatus.m_dwMonTime ) // 若新监控时间超过了原有的监控时间(可能是报警时间)
m_objMonStatus.m_bAlertAuto = false;
objMonStatus.m_dwMonTime = dwMonTime;
}
#if 2 == USE_PROTOCOL
// GPS数据个数
if( 0x7f == req.m_bytUpGpsHund ) req.m_bytUpGpsHund = 0;
if( 0x7f == req.m_bytUpGpsCount ) req.m_bytUpGpsCount = 0;
if( 0 == req.m_bytUpGpsHund && 0 == req.m_bytUpGpsCount )
objMonStatus.m_dwGpsCount = 0xffffffff; // (注意哦)
else
{
if( req.m_bytUpGpsHund > 126 || req.m_bytUpGpsCount > 99 )
{
PRTMSG(MSG_ERR, "Deal0101 error 7\n");
iRet = ERR_DATA_INVALID;
goto DEAL0101_FAIL;
}
objMonStatus.m_dwGpsCount = req.m_bytUpGpsHund * 100 + req.m_bytUpGpsCount;
}
#endif
#if 0 == USE_PROTOCOL || 1 == USE_PROTOCOL
objMonStatus.m_dwGpsCount = 0xffffffff;
#endif
// 目的手机号
if( 0x20 != v_szSrcHandtel[0] && 0 != v_szSrcHandtel[0] && '0' != v_szSrcHandtel[0] )
memcpy( objMonStatus.m_szMonHandTel, v_szSrcHandtel, sizeof(objMonStatus.m_szMonHandTel) );
// 发送监控成功应答
if( v_bSendRes )
{
tagQianGps objQianGps;
res.m_bytAnsType = 0x01;
iRet = GetCurGPS( objGps, true );
if( iRet )
goto DEAL0101_FAIL;
GpsToQianGps( objGps, objQianGps );
memcpy( &(res.m_objQianGps), &objQianGps, sizeof(res.m_objQianGps) );
iRet = g_objSms.MakeSmsFrame( (char*)&res, sizeof(res), 0x01, 0x41, buf, sizeof(buf), iBufLen );
if( iRet )
goto DEAL0101_FAIL;
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV13, v_bFromSM ? DATASYMB_USESMS : 0, v_szSrcHandtel );
if( iRet )
goto DEAL0101_FAIL;
}
m_objMonStatus = objMonStatus; // 监控参数更新到内存中的常驻状态
_BeginMon( objGps.longitude, objGps.latitude );
return 0;
DEAL0101_FAIL:
// 发送监控失败应答
if( v_bSendRes )
{
bytAnsType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame((char*)&bytAnsType, 1, 0x01, 0x41, buf, sizeof(buf), iBufLen);
if( !iRet2 ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, v_bFromSM ? DATASYMB_USESMS : 0, v_szSrcHandtel );
}
return iRet;
}
/// 撤销监控 (撤销优先)
int CMonAlert::Deal0102(char* v_szSrcHandtel, char *v_szData, DWORD v_dwDataLen, bool v_bFromSM)
{
PRTMSG(MSG_NOR, "Rcv Cent Stop Mon Req\n" );
int iRet = 0;
int iBufLen = 0;
char buf[ SOCK_MAXSIZE ];
BYTE bytResType = 1;
iRet = g_objSms.MakeSmsFrame((char*)&bytResType, 1, 0x01, 0x42, buf, sizeof(buf), iBufLen);
if( !iRet )
{
g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV11, v_bFromSM ? DATASYMB_USESMS : 0, v_szSrcHandtel );
}
_EndMon();
PRTMSG(MSG_NOR, "Stop Mon Succ\n" );
return iRet;
}
/// 修改监控参数 (业务处理优先)
int CMonAlert::Deal0103(char* v_szSrcHandtel, char *v_szData, DWORD v_dwDataLen)
{
PRTMSG(MSG_NOR, "Rcv Cent Modify Mon Par Req\n" );
if( sizeof(tag0103) != v_dwDataLen ) return ERR_DATA_INVALID;
tag2QGprsCfg objGprsCfg;
GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
tag0103 req;
memcpy( &req, v_szData, sizeof(req) );
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
BYTE bytResType;
int iRet = Deal0101( v_szSrcHandtel, (char*)&(req.m_objO101), sizeof(req.m_objO101), false );
if( !iRet )
{
bytResType = 0x01;
iRet = g_objSms.MakeSmsFrame((char*)&bytResType, 1, 0x01, 0x43, buf, sizeof(buf), iBufLen);
if( !iRet ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, (objGprsCfg.m_bytChannelBkType_1 & 0x40) ? DATASYMB_SMSBACKUP : 0 );
}
else goto DEAL0103_FAILED;
PRTMSG(MSG_NOR, "Modify mon par Succ\n" );
return 0;
DEAL0103_FAILED:
bytResType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame((char*)&bytResType, 1, 0x01, 0x43, buf, sizeof(buf), iBufLen);
if( !iRet2 ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12,
(objGprsCfg.m_bytChannelBkType_1 & 0x40) ? DATASYMB_SMSBACKUP : 0 );
return iRet;
}
/// 报警处理指示 (业务处理优先)
int CMonAlert::Deal0105(char* v_szSrcHandtel, char *v_szData, DWORD v_dwDataLen)
{
int iRet = 0;
int iBufLen = 0;
char buf[ SOCK_MAXSIZE ];
bool bNeedSendRes = false; // 注意初始化的值是false
bool bDealSucc = false; // 注意初始化的值是false
tag2QGprsCfg objGprsCfg;
GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
if( v_dwDataLen < 1 ) return ERR_DATA_INVALID;
switch( BYTE(*v_szData) )
{
case 0x01: // 默认处理
{
PRTMSG(MSG_NOR, "Rcv Cent Alerm Res: Default\n" );
if( m_dwAlertSymb & ALERT_TYPE_TEST )
{
m_dwAlertSymb &= ~ALERT_TYPE_TEST; // 清除报警测试标记
_KillTimer(&g_objTimerMng, ALERT_TEST_TIMER );
// 发送测试成功通知到调度屏
char buf[3] = { 0x01, 0x43, 0x01 };
DataPush(buf, sizeof(buf), DEV_QIAN, DEV_DIAODU, LV2);
_EndMon(); // 关闭监控
}
bDealSucc = true;
}
break;
case 0x02: // 撤销报警
{
PRTMSG(MSG_NOR, "Rcv Cent Alerm Res: Stop Alerm\n" );
bNeedSendRes = true;
if( m_objMonStatus.m_bAlertAuto ) // 若是报警激发的,关闭监控
_EndMon();
else // 否则,清除报警标志 (监控仍继续)
_ClrAlertSta();
bDealSucc = true;
}
break;
case 0x03: // 修改监控参数
{
PRTMSG(MSG_NOR, "Rcv Cent Alerm Res: Modify Mon Par\n" );
bNeedSendRes = true;
if( sizeof(tag0105) != v_dwDataLen )
break;
tag0105 req;
memcpy( &req, v_szData, sizeof(req) );
iRet = Deal0101( v_szSrcHandtel, (char*)&(req.m_obj0101), sizeof(req.m_obj0101), false );
if( !iRet ) bDealSucc = true;
}
break;
default:
;
}
// 收到报警处理指示,则关闭静默报警定时
_KillTimer(&g_objTimerMng, ALERT_SILENT_TIMER );
if( bDealSucc )
{
BYTE bytAnsType = 0x01;
iRet = g_objSms.MakeSmsFrame( (char*)&bytAnsType, 1, 0x01, 0x52, buf, sizeof(buf), iBufLen );
if( !iRet ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, DATASYMB_SMSBACKUP );
}
else goto DEAL0105_FAILED;
PRTMSG(MSG_NOR, "Deal Cent Alerm Res Succ\n" );
return 0;
DEAL0105_FAILED:
BYTE bytAnsType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame( (char*)&bytAnsType, 1, 0x01, 0x52, buf, sizeof(buf), iBufLen );
if( !iRet2 ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, DATASYMB_SMSBACKUP );
return iRet;
}
/// 位置查询请求 (应答成功优先)
int CMonAlert::Deal0111( char* v_szSrcHandtel, bool v_bFromSM )
{
tagQianGps objQianGps;
tag0151 res;
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
int iRet = 0;
tag2QGprsCfg objGprsCfg;
GetSecCfg( &objGprsCfg, sizeof(objGprsCfg), offsetof(tagSecondCfg, m_uni2QGprsCfg.m_obj2QGprsCfg), sizeof(objGprsCfg) );
iRet = GetCurQianGps( objQianGps, true );
if( !iRet )
{
res.m_bytAnsType = 0x01;
memcpy( &(res.m_objQianGps), &objQianGps, sizeof(res.m_objQianGps) );
iRet = g_objSms.MakeSmsFrame((char*)&res, sizeof(res), 0x01, 0x51, buf, sizeof(buf), iBufLen);
if( !iRet )
{
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12,
(objGprsCfg.m_bytChannelBkType_1 & 0x10) ? DATASYMB_SMSBACKUP : 0 );
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, v_bFromSM ? DATASYMB_USESMS : 0, v_szSrcHandtel );
if( iRet )
goto DEAL0111_FAILED;
// GPS模块上电 (其实只有以后再位置查询,才可能收到有效GPS)
//g_objQianIO.PowerOnGps( true );
//g_objQianIO.StartAccChk( 300000 );
}
else goto DEAL0111_FAILED;
}
else goto DEAL0111_FAILED;
return 0;
DEAL0111_FAILED:
BYTE bytAnsType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame((char*)&bytAnsType, 1, 0x01, 0x51, buf, sizeof(buf), iBufLen);
if( !iRet2 ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12,
(objGprsCfg.m_bytChannelBkType_1 & 0x10) ? DATASYMB_SMSBACKUP : 0 );
if( !iRet2 ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, v_bFromSM ? DATASYMB_USESMS : 0, v_szSrcHandtel );
return iRet;
}
// 指令监听请求 公开版_研一
int CMonAlert::Deal0720( char* v_szSrcHandtel, char* v_szData, DWORD v_dwDataLen )
{
// 电话号码串(15)
int iRet = 0;
char szLsnTel[20] = { 0 };
char buf[300] = { 0 };
int iBufLen = 0;
char* pStop = NULL;
BYTE bytResType = 1;
if( v_dwDataLen < 15 )
{
iRet = ERR_PAR;
goto DEAL0720_FAILED;
}
strncpy( szLsnTel, v_szData, 15 );
szLsnTel[ sizeof(szLsnTel) - 1 ] = 0;
pStop = strchr( szLsnTel, 0x20 );
if( pStop ) *pStop = 0;
iRet = _BeginAutoReqLsn( 3000, szLsnTel );
if( iRet ) goto DEAL0720_FAILED;
bytResType = 1;
iRet = g_objSms.MakeSmsFrame( (char*)&bytResType, 1, 0x07, 0x60, buf, sizeof(buf), iBufLen );
if( !iRet )
{
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV11, DATASYMB_SMSBACKUP, v_szSrcHandtel );
}
return 0;
DEAL0720_FAILED:
bytResType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame( (char*)&bytResType, 1, 0x07, 0x60, buf, sizeof(buf), iBufLen );
if( !iRet2 ) iRet2 = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV11, DATASYMB_SMSBACKUP );
return iRet;
}
// 指令监听请求 千里眼通用版,公开版_研三
int CMonAlert::Deal0723( char* v_szSrcHandtel, char* v_szData, DWORD v_dwDataLen )
{
// 电话号码长度(1)+ 电话号码(N≤15)
char szLsnTel[20] = { 0 };
char buf[300];
int iBufLen = 0;
int iRet = 0;
BYTE bytResType = 1;
BYTE bytTelLen = 0;
if( v_dwDataLen < 2 )
{
iRet = ERR_PAR;
goto DEAL0723_FAILED;
}
bytTelLen = v_szData[0];
if( bytTelLen > 15 || bytTelLen < 1 || bytTelLen > sizeof(szLsnTel) )
{
iRet = ERR_PAR;
goto DEAL0723_FAILED;
}
if( v_dwDataLen < DWORD(1 + bytTelLen) )
{
iRet = ERR_PAR;
goto DEAL0723_FAILED;
}
strncpy( szLsnTel, v_szData + 1, bytTelLen );
szLsnTel[ sizeof(szLsnTel) - 1 ] = 0;
iRet = _BeginAutoReqLsn( 3000, szLsnTel );
if( iRet ) goto DEAL0723_FAILED;
bytResType = 1;
iRet = g_objSms.MakeSmsFrame( (char*)&bytResType, 1, 0x07, 0x63, buf, sizeof(buf), iBufLen );
if( !iRet )
{
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV11, DATASYMB_SMSBACKUP, v_szSrcHandtel );
}
return 0;
DEAL0723_FAILED:
bytResType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame( (char*)&bytResType, 1, 0x07, 0x63, buf, sizeof(buf), iBufLen );
if( !iRet2 ) iRet2 = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV11, DATASYMB_SMSBACKUP );
return iRet;
}
/// 报警设置 (应答成功优先)
int CMonAlert::Deal1009( char* v_szSrcHandtel, char* v_szData, DWORD v_dwDataLen, bool v_bFromSM )
{
tag2QAlertCfg obj2QAlertCfg, obj2QAlertCfgBkp;
int iRet = 0;
char buf[ SOCK_MAXSIZE ];
int iBufLen = 0;
BYTE bytResType = 0;
// 数据参数检查
if( 2 != v_dwDataLen )
{
iRet = ERR_PAR;
goto DEAL1009_FAILED;
}
// 读取->修改
iRet = GetSecCfg( &obj2QAlertCfg, sizeof(obj2QAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(obj2QAlertCfg) );
if( iRet ) goto DEAL1009_FAILED;
obj2QAlertCfgBkp = obj2QAlertCfg; // 先备份
obj2QAlertCfg.m_bytAlert_1 = BYTE(v_szData[0] & 0x7f);
obj2QAlertCfg.m_bytAlert_2 = BYTE(v_szData[1] & 0x7f);
// 写回和发送应答
bytResType = 0x01;
iRet = g_objSms.MakeSmsFrame( (char*)&bytResType, 1, 0x10, 0x49, buf, sizeof(buf), iBufLen);
if( !iRet )
{
if( iRet = SetSecCfg(&obj2QAlertCfg, offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(obj2QAlertCfg)) )
{
goto DEAL1009_FAILED;
}
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, v_bFromSM ? DATASYMB_USESMS : 0, v_bFromSM ? v_szSrcHandtel : NULL ); // 发送
if( iRet ) // 若发送失败
{
SetSecCfg( &obj2QAlertCfgBkp, offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(obj2QAlertCfgBkp) ); // 恢复原设置
goto DEAL1009_FAILED;
}
}
else goto DEAL1009_FAILED;
return 0;
DEAL1009_FAILED:
bytResType = 0x7f;
int iRet2 = g_objSms.MakeSmsFrame( (char*)&bytResType, 1, 0x10, 0x49, buf, sizeof(buf), iBufLen);
if( !iRet2 ) g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, v_bFromSM ? DATASYMB_USESMS : 0, v_bFromSM ? v_szSrcHandtel : NULL );
return iRet;
}
/// 状态查询
int CMonAlert::Deal101a(char* v_szSrcHandtel, char *v_szData, DWORD v_dwDataLen )
{
// 千里眼通用版,公开版_研三
// 状态字(2)+ 标准GPS数据
// 填充状态字
// ——VM1、JG2、JG3协议定义
// Bit 15~8: 0 1 T1 T2 T3 T4 T5 0
// Bit 7~0: 0 1 D1 D2 D3 D4 0 0
// T1-报警号码设置位, 1:设置;0:未设置
// T2-调度号码设置位, 1:设置;0:未设置
// T3-税控号码设置位, 1:设置;0:未设置
// T4-短信中心号码设置位, 1:设置;0:未设置
// T5-抢劫报警设置位, 1:允许;0:禁止
// T6-GPS模块状态 1:正常 0:异常
// D1-与调度终端通讯状态位,1:正常;0:异常
// D2-税控时间设置位, 1:正常;0:异常
// D3-传呼号码设置位, 1:正常;0:异常
// D4-黑匣子采集时间设置位,1:正常;0:异常
// KJ2协议通用版
// 状态字(2)+传感状态(1)+ GPS数据
// 状态字
// Bit 15~8: 0 1 T1 T2 1 T4 T5 T6
// Bit 7~0: 0 1 1 1 1 1 T7 1
// T1-报警号码设置位, 1:设置;0:未设置
// T2-调度号码设置位, 1:设置;0:未设置
// T4-短信中心号码设置位, 1:设置;0:未设置
// T5-抢劫报警设置位, 1:允许;0:禁止
// T6-GPS模块状态位, 1:正常;0:异常 (是关电吗?)
// T7-调度屏状态位, 1:正常;0:异常
// 其它保留
// 千里眼公开版_研一
// 状态字(2)+传感状态(1)+ GPS数据
// 状态字:
// Bit 15~8: 0 1 T1 1 1 T4 T5 T6
// Bit 7~0: 0 1 1 1 1 1 T7 1
// T1-报警号码设置位, 1:设置;0:未设置
// T4-短信中心号码设置位, 1:设置;0:未设置
// T5-抢劫报警设置位, 1:允许;0:禁止
// T6-GPS模块状态位, 1:正常;0:异常
// T7-调度屏状态位, 1:正常;0:异常
int iRet = 0;
int iBufLen = 0;
tag105a res;
tagQianGps objQianGps;
char buf[ 500 ];
memset( &res, 0, sizeof(res) );
res.m_bytSta_1 = 0x40; // 注意,这样填是因为各版本的最高2位都是01
res.m_bytSta_2 = 0x40; // 注意,这样填是因为各版本的最高2位都是01
{
tag2QServCodeCfg objServCodeCfg;
GetSecCfg( &objServCodeCfg, sizeof(objServCodeCfg), offsetof(tagSecondCfg, m_uni2QServCodeCfg.m_obj2QServCodeCfg), sizeof(objServCodeCfg) );
if( objServCodeCfg.m_szQianSmsTel[0] && 0x20 != objServCodeCfg.m_szQianSmsTel[0] )
res.m_bytSta_1 |= 0x20; // 报警号码(特服号)设置
if( objServCodeCfg.m_szDiaoduHandtel[0] && 0x20 != objServCodeCfg.m_szDiaoduHandtel[0] )
res.m_bytSta_1 |= 0x10; // 调度号码设置
#if 0 == USE_PROTOCOL || 1 == USE_PROTOCOL
if( objServCodeCfg.m_szTaxHandtel[0] && 0x20 != objServCodeCfg.m_szTaxHandtel[0] ) res.m_bytSta_1 |= 0x08; // 税控号码设置
#endif
}
{
tag1PComuCfg objComuCfg;
GetImpCfg( &objComuCfg, sizeof(objComuCfg), offsetof(tagImportantCfg, m_uni1PComuCfg.m_obj1PComuCfg), sizeof(objComuCfg) );
if( objComuCfg.m_szSmsCentID[0] && 0x20 != objComuCfg.m_szSmsCentID[0] )
res.m_bytSta_1 |= 0x04; // 短信中心号设置
}
{
tag2QAlertCfg objAlertCfg;
GetSecCfg( &objAlertCfg, sizeof(objAlertCfg), offsetof(tagSecondCfg, m_uni2QAlertCfg.m_obj2QAlertCfg), sizeof(objAlertCfg) );
if( objAlertCfg.m_bytAlert_1 & 0x20 )
res.m_bytSta_1 |= 0x02; // 抢劫报警设置位
}
{
if( g_objQianIO.GetDeviceSta() & DEVSTA_GPSON ) res.m_bytSta_1 |= 0x01; // GPS模块状态
}
{
DWORD dwComuSta;
dwComuSta = g_objComu.GetComuSta();
#if 2 == USE_PROTOCOL || 30 == USE_PROTOCOL
if( dwComuSta & COMUSTA_DIAODUCONN ) res.m_bytSta_2 |= 0x02; // 调度屏状态
#endif
#if 0 == USE_PROTOCOL || 1 == USE_PROTOCOL
if( dwComuSta & COMUSTA_DIAODUCONN ) res.m_bytSta_2 |= 0x20; // 调度屏状态
#endif
#if USE_BLK == 1 && (0 == USE_PROTOCOL || 1 == USE_PROTOCOL)
res.m_bytSta_2 |= 0x04; // 黑匣子采集间隔固定,只要启动黑匣子功能
#endif
}
#if 30 == USE_PROTOCOL
// 传感器状态
// 0 FB HB LL RL FD BD A
// A -ACC信号状态, 1:ON; 0:OFF
// BD-后车门状态, 1:有效;0:无效
// FD-前车门状态, 1:有效;0:无效
// RL-右转向灯, 1:有效;0:无效
// LL-左转向灯, 1:有效;0:无效
// HB-手刹, 1:有效;0:无效
// FB-脚刹, 1:有效;0:无效
{
DWORD dwIoSta = 0;
if( g_objQianIO.IN_QueryIOSta(dwIoSta) )
{
if( !(dwIoSta & 0x00000001) ) res.m_bytIO |= 0x01;
if( !(dwIoSta & 0x00000004) ) res.m_bytIO |= 0x02;
if( !(dwIoSta & 0x00000008) ) res.m_bytIO |= 0x04;
if( !(dwIoSta & 0x00000010) ) res.m_bytIO |= 0x08;
if( !(dwIoSta & 0x00000020) ) res.m_bytIO |= 0x10;
if( !(dwIoSta & 0x00000040) ) res.m_bytIO |= 0x20;
if( !(dwIoSta & 0x00000080) ) res.m_bytIO |= 0x40;
}
}
#endif
#if 2 == USE_PROTOCOL
// 传感器状态
// Bit 7 -> 0
// 0 1 0 0 0 0 D A
// A-ACC信号状态, 1:ON; 0:OFF
// D-车门状态, 1:关闭;0:打开
{
DWORD dwIoSta = 0;
if( g_objQianIO.IN_QueryIOSta(dwIoSta) )
{
if( !(dwIoSta & 0x00000001) ) res.m_bytIO |= 0x01;
if( dwIoSta & 0x00000008 ) res.m_bytIO |= 0x02;
}
}
#endif
// 标准GPS数据
iRet = GetCurQianGps( res.objQianGps, true );
if( iRet ) goto DEAL101A_FAILED;
else memcpy( &res.objQianGps, &objQianGps, sizeof(res.objQianGps) );
iRet = g_objSms.MakeSmsFrame( (char*)&res, sizeof(res), 0x10, 0x5a, buf, sizeof(buf), iBufLen);
if( !iRet )
{
// 发送应答
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, DATASYMB_SMSBACKUP );
if( iRet ) goto DEAL101A_FAILED;
}
else goto DEAL101A_FAILED;
return 0;
DEAL101A_FAILED:
return iRet;
}
// 超速报警设置
int CMonAlert::Deal103d( char* v_szSrcHandtel, char* v_szData, DWORD v_dwDataLen, bool v_bFromSM )
{
// 公开版协议_研一
// 报警速度 1 单位:海里/小时, 取值范围:0~7EH,0转义成7FH
// 连续超速时间 1 单位:秒
int iRet = 0;
#if 2 == USE_PROTOCOL
DrvCfg objDrvCfg;
BYTE bytResType = 0;
BYTE bytAlermSpd = 0;
BYTE bytAlermPrid = 0;
char buf[100] = { 0 };
int iBufLen = 0;
if( v_dwDataLen < 2 )
{
iRet = ERR_PAR;
goto DEAL103D_FAILED;
}
bytAlermSpd = BYTE( v_szData[0] );
if( bytAlermSpd > 0x7f )
{
iRet = ERR_PAR;
goto DEAL103D_FAILED;
}
if( 0x7f == bytAlermSpd ) bytAlermSpd = 0;
bytAlermPrid = BYTE( v_szData[1] );
iRet = GetSecCfg( &objDrvCfg, sizeof(objDrvCfg), offsetof(tagSecondCfg, m_uniDrvCfg.m_szReservered), sizeof(objDrvCfg) );
if( iRet ) goto DEAL103D_FAILED;
objDrvCfg.max_speed = bytAlermSpd;
objDrvCfg.min_over = bytAlermPrid;
iRet = SetSecCfg( &objDrvCfg, offsetof(tagSecondCfg, m_uniDrvCfg.m_szReservered), sizeof(objDrvCfg) );
if( iRet ) goto DEAL103D_FAILED;
bytResType = 1;
goto DEAL103D_END;
DEAL103D_FAILED:
bytResType = 0x7f;
DEAL103D_END:
if( !g_objSms.MakeSmsFrame((char*)&bytResType, sizeof(bytResType), 0x10, 0x7d, buf, sizeof(buf), iBufLen) )
{
g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, v_bFromSM ? DATASYMB_USESMS : 0, v_bFromSM ? v_szSrcHandtel : NULL );
}
#endif
return iRet;
}
///区域查车
// 查询索引号(1)+ 监控终端ID(8)+区域个数(1)+【区域(18)】×N
int CMonAlert::Deal0136( char* v_szSrcHandtel, char* v_szData, DWORD v_dwDataLen )
{
tag0176 res;
tag0136 *p = (tag0136*)v_szData;
char buf[500] = {0};
int iBufLen = 0;
int i, r1, r2, r3, r4;
bool in_zone = false;
int iRet = GetCurQianGps( res.m_objQianGps, true );
if( iRet ) goto DEAL0136_FAILED;
// 判断当前经纬度是否在所给的区域内
for(i=0; i<p->m_bytZoneCount; i++)
{
r1 = memcmp(p->m_Zone[i].lat1, &res.m_objQianGps.m_bytLatDu, 4);
r2 = memcmp(p->m_Zone[i].lat2, &res.m_objQianGps.m_bytLatDu, 4);
// 将经度最高位放回度字节中,方便判断
if(p->m_Zone[i].hbit1 & 0x02) p->m_Zone[i].lon1[0] |= 0x80;
if(p->m_Zone[i].hbit2 & 0x02) p->m_Zone[i].lon2[0] |= 0x80;
if(res.m_objQianGps.m_bytMix & 0x02) res.m_objQianGps.m_bytLonDu |= 0x80;
r3 = memcmp(p->m_Zone[i].lon1, &res.m_objQianGps.m_bytLonDu, 4);
r4 = memcmp(p->m_Zone[i].lon2, &res.m_objQianGps.m_bytLonDu, 4);
if( r1<=0 && r2>=0 && r3<=0 && r4>=0 ) { in_zone = true; break; }
}
if(in_zone)
{
memcpy(&res.m_bytQueryIndex, &p->m_bytQueryIndex, 10);
res.m_objQianGps.m_bytLonDu &= ~0x80; //清空经度的度字节最高位
iRet = g_objSms.MakeSmsFrame( (char*)&res, sizeof(res), 0x01, 0x76, buf, sizeof(buf), iBufLen);
if( !iRet ) {
// 发送应答
iRet = g_objSock.SOCKSNDSMSDATA( buf, iBufLen, LV12, DATASYMB_SMSBACKUP );
if( iRet ) goto DEAL0136_FAILED;
} else goto DEAL0136_FAILED;
}
return 0;
DEAL0136_FAILED:
return iRet;
}
| [
"[email protected]"
]
| [
[
[
1,
2709
]
]
]
|
22df518e94ee01e9178c882d6332e13b715b1e1f | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Components/Resamplers/CUDAResampler/elxCUDAResampler.hxx | 6a619b6f5c7e26a3e44a1cf6c2e812a2a99063ba | []
| no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,546 | hxx | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
#ifndef __elxCUDAResampler_hxx
#define __elxCUDAResampler_hxx
#include "elxCUDAResampler.h"
namespace elastix
{
/**
* ******************* BeforeAll ***********************
*/
template <class TElastix>
int
CUDAResampler<TElastix>
::BeforeAll( void )
{
int res = Superclass1::CudaResampleImageFilterType::checkExecutionParameters();
if ( res != 0 )
{
itkExceptionMacro( "ERROR: no valid CUDA devices found!" );
}
return res;
// implement checks for CUDA cards available.
} // end BeforeAll()
/**
* ******************* BeforeRegistration ***********************
*/
template <class TElastix>
void
CUDAResampler<TElastix>
::BeforeRegistration( void )
{
/** Are we using a CUDA enabled GPU for resampling? */
bool useCUDA = false;
this->m_Configuration->ReadParameter( useCUDA, "UseCUDA", 0 );
this->SetUseCuda( useCUDA );
} // end BeforeRegistration()
} /* namespace elastix */
#endif
| [
"[email protected]"
]
| [
[
[
1,
63
]
]
]
|
3395a906ea944651e74656553276121b1c34c147 | c7120eeec717341240624c7b8a731553494ef439 | /src/cplusplus/freezone-samp/src/core/geo/detail/geo_info_getter_org.cpp | 8946fac73bbf9a8b321c38a2c3fe3f7294f188fc | []
| no_license | neverm1ndo/gta-paradise-sa | d564c1ed661090336621af1dfd04879a9c7db62d | 730a89eaa6e8e4afc3395744227527748048c46d | refs/heads/master | 2020-04-27T22:00:22.221323 | 2010-09-04T19:02:28 | 2010-09-04T19:02:28 | 174,719,907 | 1 | 0 | null | 2019-03-09T16:44:43 | 2019-03-09T16:44:43 | null | UTF-8 | C++ | false | false | 945 | cpp | #include "config.hpp"
#include "geo_info_getter_org.hpp"
#include "maxmind-geoip/GeoIP.h"
#include "../geo_ip_info.hpp"
#include <boost/algorithm/string.hpp>
namespace geo {
info_getter_org::info_getter_org(GeoIPTag* gi):info_getter_db(gi) {
}
info_getter_org::~info_getter_org() {
}
void info_getter_org::process_ip_info(ip_info& info) {
if (!info.organization) {
char const* rezult = GeoIP_name_by_addr(db, info.ip_string.c_str());
if (rezult) {
std::string org(rezult);
boost::replace_all(org, ",", " ");
boost::trim(org);
boost::erase_all(org, "(");
boost::erase_all(org, ")");
info.organization.reset(org);
}
}
}
std::string info_getter_org::get_db_info_prefix() const {
return "Organization";
}
} // namespace geo {
| [
"dimonml@19848965-7475-ded4-60a4-26152d85fbc5"
]
| [
[
[
1,
31
]
]
]
|
211aa2eb72855d26a14007ff57317e48434bf1e4 | eec70a1718c685c0dbabeee59eb7267bfaece58c | /Sense Management Irrlicht AI/MessageSender.h | 6bad52955a08fd4421566404352bf7889c617665 | []
| no_license | mohaider/sense-management-irrlicht-ai | 003939ee770ab32ff7ef3f5f5c1b77943a4c7489 | c5ef02f478d00a4957a294254fc4f3920037bd7a | refs/heads/master | 2020-12-24T14:44:38.254964 | 2011-05-19T14:29:53 | 2011-05-19T14:29:53 | 32,393,908 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 784 | h | #ifndef MESSAGE_SENDER_H
#define MESSAGE_SENDER_H
#include <queue>
#include <iostream>
#include "Singleton.h"
#include "Message.h"
class AIObject;
class MessageSender
{
public:
void SendMessage(double delay, int sender, int receiver, int msg, Signal signal);
// send message without a signal
void SendMessageNS(double delay, int sender, int receiver, int msg);
void SendDelayedMessages();
struct LessThan
{
bool operator()(Message* a,Message* b);
};
private:
MessageSender() {}
friend class Singleton<MessageSender>;
void Discharge(AIObject* pReceiver, Message* msg);
typedef std::priority_queue<Message*, std::vector<Message*>, LessThan> Q;
Q m_messageQueue;
};
typedef Singleton<MessageSender> TheMessageSender;
#endif | [
"[email protected]@2228f7ce-bb98-ac94-67a7-be962254a327"
]
| [
[
[
1,
39
]
]
]
|
e21b92e556c4fa4e0ff2ff119119bfe8f702a752 | b7c505dcef43c0675fd89d428e45f3c2850b124f | /Src/SimulatorQt/Util/qt/Win32/include/Qt/qtest_global.h | a5590b14a13b9ca36a424687624cf9638b191e58 | [
"BSD-2-Clause"
]
| permissive | pranet/bhuman2009fork | 14e473bd6e5d30af9f1745311d689723bfc5cfdb | 82c1bd4485ae24043aa720a3aa7cb3e605b1a329 | refs/heads/master | 2021-01-15T17:55:37.058289 | 2010-02-28T13:52:56 | 2010-02-28T13:52:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,047 | h | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTEST_GLOBAL_H
#define QTEST_GLOBAL_H
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Test)
#ifdef QTEST_EMBED
# define Q_TESTLIB_EXPORT
#elif !defined(QT_SHARED)
# define Q_TESTLIB_EXPORT
#else
# ifdef QTESTLIB_MAKEDLL
# define Q_TESTLIB_EXPORT Q_DECL_EXPORT
# else
# define Q_TESTLIB_EXPORT Q_DECL_IMPORT
# endif
#endif
#if (defined (Q_CC_MSVC) && _MSC_VER < 1310) || defined (Q_CC_SUN) || defined (Q_CC_XLC) || (defined (Q_CC_GNU) && (__GNUC__ - 0 < 3))
# define QTEST_NO_SPECIALIZATIONS
#endif
#if (defined Q_CC_HPACC) && (defined __ia64)
# ifdef Q_TESTLIB_EXPORT
# undef Q_TESTLIB_EXPORT
# endif
# define Q_TESTLIB_EXPORT
#endif
#define QTEST_VERSION QT_VERSION
#define QTEST_VERSION_STR QT_VERSION_STR
namespace QTest
{
enum SkipMode { SkipSingle = 1, SkipAll = 2 };
enum TestFailMode { Abort = 1, Continue = 2 };
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...);
}
QT_END_NAMESPACE
QT_END_HEADER
#endif
| [
"alon@rogue.(none)"
]
| [
[
[
1,
91
]
]
]
|
8737d1e67d31b64742405d196076c86dfdbcaf39 | 6e563096253fe45a51956dde69e96c73c5ed3c18 | /Sockets/Ipv4Address.cpp | 3201e52d517ef49c363de58d28fc783907d1bd41 | []
| no_license | 15831944/phoebemail | 0931b76a5c52324669f902176c8477e3bd69f9b1 | e10140c36153aa00d0251f94bde576c16cab61bd | refs/heads/master | 2023-03-16T00:47:40.484758 | 2010-10-11T02:31:02 | 2010-10-11T02:31:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,905 | cpp | /**
** \file Ipv4Address.cpp
** \date 2006-09-21
** \author [email protected]
**/
/*
Copyright (C) 2007-2009 Anders Hedstrom
This library is made available under the terms of the GNU GPL, with
the additional exemption that compiling, linking, and/or using OpenSSL
is allowed.
If you would like to use this library in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for the C++ sockets library,
please visit http://www.alhem.net/Sockets/license.html and/or
email [email protected].
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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "Ipv4Address.h"
#include "Utility.h"
#ifndef _WIN32
#include <netdb.h>
#endif
#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif
Ipv4Address::Ipv4Address(port_t port) : m_valid(true)
{
memset(&m_addr, 0, sizeof(m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons( port );
}
Ipv4Address::Ipv4Address(ipaddr_t a,port_t port) : m_valid(true)
{
memset(&m_addr, 0, sizeof(m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons( port );
memcpy(&m_addr.sin_addr, &a, sizeof(struct in_addr));
}
Ipv4Address::Ipv4Address(struct in_addr& a,port_t port) : m_valid(true)
{
memset(&m_addr, 0, sizeof(m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons( port );
m_addr.sin_addr = a;
}
Ipv4Address::Ipv4Address(const std::string& host,port_t port) : m_valid(false)
{
memset(&m_addr, 0, sizeof(m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons( port );
{
ipaddr_t a;
if (Utility::u2ip(host, a))
{
memcpy(&m_addr.sin_addr, &a, sizeof(struct in_addr));
m_valid = true;
}
}
}
Ipv4Address::Ipv4Address(struct sockaddr_in& sa)
{
m_addr = sa;
m_valid = sa.sin_family == AF_INET;
}
Ipv4Address::~Ipv4Address()
{
}
Ipv4Address::operator struct sockaddr *()
{
return (struct sockaddr *)&m_addr;
}
Ipv4Address::operator socklen_t()
{
return sizeof(struct sockaddr_in);
}
void Ipv4Address::SetPort(port_t port)
{
m_addr.sin_port = htons( port );
}
port_t Ipv4Address::GetPort()
{
return ntohs( m_addr.sin_port );
}
bool Ipv4Address::Resolve(const std::string& hostname,struct in_addr& a)
{
struct sockaddr_in sa;
memset(&a, 0, sizeof(a));
if (Utility::isipv4(hostname))
{
if (!Utility::u2ip(hostname, sa, AI_NUMERICHOST))
return false;
a = sa.sin_addr;
return true;
}
if (!Utility::u2ip(hostname, sa))
return false;
a = sa.sin_addr;
return true;
}
bool Ipv4Address::Reverse(struct in_addr& a,std::string& name)
{
struct sockaddr_in sa;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_addr = a;
return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name);
}
std::string Ipv4Address::Convert(bool include_port)
{
if (include_port)
return Convert(m_addr.sin_addr) + ":" + Utility::l2string(GetPort());
return Convert(m_addr.sin_addr);
}
std::string Ipv4Address::Convert(struct in_addr& a)
{
struct sockaddr_in sa;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_addr = a;
std::string name;
Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name, NI_NUMERICHOST);
return name;
}
void Ipv4Address::SetAddress(struct sockaddr *sa)
{
memcpy(&m_addr, sa, sizeof(struct sockaddr_in));
}
int Ipv4Address::GetFamily()
{
return m_addr.sin_family;
}
bool Ipv4Address::IsValid()
{
return m_valid;
}
bool Ipv4Address::operator==(SocketAddress& a)
{
if (a.GetFamily() != GetFamily())
return false;
if ((socklen_t)a != sizeof(m_addr))
return false;
struct sockaddr *sa = a;
struct sockaddr_in *p = (struct sockaddr_in *)sa;
if (p -> sin_port != m_addr.sin_port)
return false;
if (memcmp(&p -> sin_addr, &m_addr.sin_addr, 4))
return false;
return true;
}
std::auto_ptr<SocketAddress> Ipv4Address::GetCopy()
{
return std::auto_ptr<SocketAddress>(new Ipv4Address(m_addr));
}
std::string Ipv4Address::Reverse()
{
std::string tmp;
Reverse(m_addr.sin_addr, tmp);
return tmp;
}
#ifdef SOCKETS_NAMESPACE
} // namespace SOCKETS_NAMESPACE {
#endif
| [
"guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd"
]
| [
[
[
1,
223
]
]
]
|
e9bc0e9caa165db03056ad91ffe929cbd97c524f | 4d838ba98a21fc4593652e66eb7df0fac6282ef6 | /CaveProj/GameObject.h | 32dfd0b2c7da8273a95de88f749d080621702b78 | []
| no_license | davidhart/ProceduralCaveEditor | 39ed0cf4ab4acb420fa2ad4af10f9546c138a83a | 31264591f2dcd250299049c826aeca18fc52880e | refs/heads/master | 2021-01-17T15:10:09.100572 | 2011-05-03T19:24:06 | 2011-05-03T19:24:06 | 69,302,913 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 256 | h | #pragma once
#ifndef _GAMEOBJECT_H_
#define _GAMEOBJECT_H_
#include "Vector.h"
#include <D3DX10.h>
class GameObject
{
public:
GameObject();
D3DXMATRIX GetMatrix();
Vector3f Position;
Vector3f Rotation;
Vector3f Scale;
};
#endif | [
"[email protected]"
]
| [
[
[
1,
20
]
]
]
|
9d9d4dd3bd659815a4cf25e10d8b5e1f1e4377e5 | 01fa2d8a6dead72c3f05e22b9e63942b4422214f | /src/engine/engine.cpp | 148f73f64fcab8bda1a859e337aca2a83fa55283 | []
| no_license | AlekseiCherkes/ttscpp | 693f7aac56ae59cf2555b0852eb26a6f96a4dbe3 | e3976e6f5e4f5a7923effa95b25c8ba2031ae9f1 | refs/heads/master | 2021-01-10T20:36:58.267873 | 2011-12-17T10:00:24 | 2011-12-17T10:00:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 888 | cpp | #include "engine.hpp"
//--------------------------------------------------------------------------------------------------
namespace tts { namespace engine {
//--------------------------------------------------------------------------------------------------
Engine& Engine::instance()
{
static Engine instance;
return instance;
}
//--------------------------------------------------------------------------------------------------
void Engine::init()
{
}
void Engine::release()
{
}
//--------------------------------------------------------------------------------------------------
Engine::Engine() :
m_allocator(),
m_mainAllocator("main", &m_allocator),
m_logAllocator("log", &m_mainAllocator)
{
}
Engine::~Engine()
{
}
//--------------------------------------------------------------------------------------------------
}} | [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
23d7227de6694c71bceb1ddbe15cd0685e8e830d | 04480fe64bb0d0535711f534ac1d343f41fa297d | /arquiteturaQuaseFinal/Arquitetura/unidade_controle.cpp | f360fe057bdac01ee40a341be8cd13003a3532d7 | []
| no_license | prosanes/arquitetura-pli | e37a69cd6b5e0c9dc6e8ae605cda5f1f21f328b4 | 05fc902d4cce4c009a1714e893bb04e02e7f94a9 | refs/heads/master | 2020-04-27T17:08:41.913097 | 2010-12-13T18:55:08 | 2010-12-13T18:55:08 | 32,121,762 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 275,096 | cpp | #include "unidade_controle.h"
#include <stdio.h>
#include <stdlib.h>
/**
* Inicializa a memoria de controle da unidade de controle.
* Usa-se um arquivo binario para carregar na memoria de controle.
*/
Unidade_Controle::Unidade_Controle()
{
}
Unidade_Controle::Unidade_Controle(int a)
{
//Inicializar memoria de controle
FILE* entrada;
entrada = fopen("memoria_controle_binario.txt", "r");
if (!entrada)
{
printf ("Erro ao abrir arquivo de memoria.\n");
return;
}
int i = 0;
while ( !feof(entrada) )
{
char c;
for (int j = 0; j < MAX_CONTROLES; j++)
{
fscanf(entrada, " %c", &c);
memoria_controle[i].controle[j] = c - '0';
}
i++;
}
fclose(entrada);
/* DEBUG */
#ifdef DEBUG
printf("Memoria de controle:\n");
for (int i = 0; i < MAX_MICROS; i++)
{
printf("%d: ", i);
for (int j = 0; j < MAX_CONTROLES; j++)
printf("%d", memoria_controle[i].controle[j]);
printf("\n");
}
#endif
//Inicializa Registrador de Endereco
registrador_endereco = 0;
}
/**
* Dado a intrucao atual, a micro-instrucao atual e as flags da ultima operacao na ULA
* retorna o endereco da proxima micro
*/
int Unidade_Controle::gerador_endereco(int instrucao, Flags flags_ula)
{
/*case 0: //Ler instrucao e decodificar
switch (registrador_endereco)
{
case 0:
return 4;
case 4:
return 3;
case 3:
return 217;
case 217:
return 0;
}
break;*/
switch(instrucao)
{
case 0:
switch (registrador_endereco)
{
case 0:
return 4;
case 4:
return 20;
case 20:
return 3;
case 3:
return 217;
case 217:
return 0;
}
case 1:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 54;
case 54:
return 0;
}
break;
case 2:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 84;
case 84:
return 0;
}
break;
case 3:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 114;
case 114:
return 0;
}
break;
case 4:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 140;
case 140:
return 0;
}
break;
case 5:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 166;
case 166:
return 0;
}
break;
case 6:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 7:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 8:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 9:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 10:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 11:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 54;
case 54:
return 0;
}
break;
case 12:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 84;
case 84:
return 0;
}
break;
case 13:
switch (registrador_endereco)
{
case 0:
return 115;
case 115:
return 0;
}
break;
case 14:
switch (registrador_endereco)
{
case 0:
return 141;
case 141:
return 0;
}
break;
case 15:
switch (registrador_endereco)
{
case 0:
return 167;
case 167:
return 0;
}
break;
case 16:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 54;
case 54:
return 0;
}
break;
case 17:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 84;
case 84:
return 0;
}
break;
case 18:
switch (registrador_endereco)
{
case 0:
return 116;
case 116:
return 0;
}
break;
case 19:
switch (registrador_endereco)
{
case 0:
return 142;
case 142:
return 0;
}
break;
case 20:
switch (registrador_endereco)
{
case 0:
return 168;
case 168:
return 0;
}
break;
case 21:
switch (registrador_endereco)
{
case 0:
return 55;
case 55:
return 0;
}
break;
case 22:
switch (registrador_endereco)
{
case 0:
return 85;
case 85:
return 0;
}
break;
case 23:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 117;
case 117:
return 0;
}
break;
case 24:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 143;
case 143:
return 0;
}
break;
case 25:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 169;
case 169:
return 0;
}
break;
case 26:
switch (registrador_endereco)
{
case 0:
return 56;
case 56:
return 0;
}
break;
case 27:
switch (registrador_endereco)
{
case 0:
return 86;
case 86:
return 0;
}
break;
case 28:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 117;
case 117:
return 0;
}
break;
case 29:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 143;
case 143:
return 0;
}
break;
case 30:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 169;
case 169:
return 0;
}
break;
case 31:
switch (registrador_endereco)
{
case 0:
return 57;
case 57:
return 0;
}
break;
case 32:
switch (registrador_endereco)
{
case 0:
return 87;
case 87:
return 0;
}
break;
case 33:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 117;
case 117:
return 0;
}
break;
case 34:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 143;
case 143:
return 0;
}
break;
case 35:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 169;
case 169:
return 0;
}
break;
case 36:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 5;
case 5:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 37:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 6;
case 6:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 38:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 7;
case 7:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 39:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 8;
case 8:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 40:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 9;
case 9:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 41:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 5;
case 5:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 42:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 6;
case 6:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 43:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 7;
case 7:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 44:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 8;
case 8:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 45:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 9;
case 9:
return 20;
case 20:
return 22;
case 22:
return 0;
}
break;
case 46:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 23;
case 23:
return 0;
}
break;
case 47:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 23;
case 23:
return 0;
}
break;
case 48:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 23;
case 23:
return 0;
}
break;
case 49:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 23;
case 23:
return 0;
}
break;
case 50:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 23;
case 23:
return 0;
}
break;
case 51:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 24;
case 24:
return 0;
}
break;
case 52:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 24;
case 24:
return 0;
}
break;
case 53:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 24;
case 24:
return 0;
}
break;
case 54:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 24;
case 24:
return 0;
}
break;
case 55:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 24;
case 24:
return 0;
}
break;
case 56:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 25;
case 25:
return 0;
}
break;
case 57:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 25;
case 25:
return 0;
}
break;
case 58:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 25;
case 25:
return 0;
}
break;
case 59:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 25;
case 25:
return 0;
}
break;
case 60:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 25;
case 25:
return 0;
}
break;
case 61:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 49;
case 49:
return 58;
case 58:
return 0;
}
break;
case 62:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 50;
case 50:
return 88;
case 88:
return 0;
}
break;
case 63:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 114;
case 114:
return 0;
}
break;
case 64:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 140;
case 140:
return 0;
}
break;
case 65:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 166;
case 166:
return 0;
}
break;
case 66:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 49;
case 49:
return 58;
case 58:
return 0;
}
break;
case 67:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 50;
case 50:
return 88;
case 88:
return 0;
}
break;
case 68:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 114;
case 114:
return 0;
}
break;
case 69:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 140;
case 140:
return 0;
}
break;
case 70:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 166;
case 166:
return 0;
}
break;
case 71:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 49;
case 49:
return 58;
case 58:
return 0;
}
break;
case 72:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 50;
case 50:
return 88;
case 88:
return 0;
}
break;
case 73:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 114;
case 114:
return 0;
}
break;
case 74:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 140;
case 140:
return 0;
}
break;
case 75:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 166;
case 166:
return 0;
}
break;
case 76:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 49;
case 49:
return 58;
case 58:
return 0;
}
break;
case 77:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 50;
case 50:
return 88;
case 88:
return 0;
}
break;
case 78:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 114;
case 114:
return 0;
}
break;
case 79:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 140;
case 140:
return 0;
}
break;
case 80:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 166;
case 166:
return 0;
}
break;
case 81:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 49;
case 49:
return 58;
case 58:
return 0;
}
break;
case 82:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 50;
case 50:
return 88;
case 88:
return 0;
}
break;
case 83:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 114;
case 114:
return 0;
}
break;
case 84:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 140;
case 140:
return 0;
}
break;
case 85:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 166;
case 166:
return 0;
}
break;
case 86:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 22;
case 22:
return 0;
}
break;
case 87:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 88:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 89:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 90:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 91:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 92:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 22;
case 22:
return 0;
}
break;
case 93:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 94:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 95:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 96:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 97:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 98:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 22;
case 22:
return 0;
}
break;
case 99:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 100:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 101:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 102:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 103:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 104:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 22;
case 22:
return 0;
}
break;
case 105:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 106:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 107:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 108:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 109:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 22;
case 22:
return 0;
}
break;
case 110:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 22;
case 22:
return 0;
}
break;
case 111:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 59;
case 59:
return 0;
}
break;
case 112:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 89;
case 89:
return 0;
}
break;
case 113:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 118;
case 118:
return 0;
}
break;
case 114:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 144;
case 144:
return 0;
}
break;
case 115:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 170;
case 170:
return 0;
}
break;
case 116:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 117:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 118:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 119:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 120:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 121:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 59;
case 59:
return 0;
}
break;
case 122:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 89;
case 89:
return 0;
}
break;
case 123:
switch (registrador_endereco)
{
case 0:
return 119;
case 119:
return 0;
}
break;
case 124:
switch (registrador_endereco)
{
case 0:
return 145;
case 145:
return 0;
}
break;
case 125:
switch (registrador_endereco)
{
case 0:
return 171;
case 171:
return 0;
}
break;
case 126:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 59;
case 59:
return 0;
}
break;
case 127:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 89;
case 89:
return 0;
}
break;
case 128:
switch (registrador_endereco)
{
case 0:
return 120;
case 120:
return 0;
}
break;
case 129:
switch (registrador_endereco)
{
case 0:
return 146;
case 146:
return 0;
}
break;
case 130:
switch (registrador_endereco)
{
case 0:
return 172;
case 172:
return 0;
}
break;
case 131:
switch (registrador_endereco)
{
case 0:
return 60;
case 60:
return 0;
}
break;
case 132:
switch (registrador_endereco)
{
case 0:
return 90;
case 90:
return 0;
}
break;
case 133:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 121;
case 121:
return 0;
}
break;
case 134:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 147;
case 147:
return 0;
}
break;
case 135:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 173;
case 173:
return 0;
}
break;
case 136:
switch (registrador_endereco)
{
case 0:
return 61;
case 61:
return 0;
}
break;
case 137:
switch (registrador_endereco)
{
case 0:
return 91;
case 91:
return 0;
}
break;
case 138:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 121;
case 121:
return 0;
}
break;
case 139:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 147;
case 147:
return 0;
}
break;
case 140:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 173;
case 173:
return 0;
}
break;
case 141:
switch (registrador_endereco)
{
case 0:
return 62;
case 62:
return 0;
}
break;
case 142:
switch (registrador_endereco)
{
case 0:
return 92;
case 92:
return 0;
}
break;
case 143:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 121;
case 121:
return 0;
}
break;
case 144:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 147;
case 147:
return 0;
}
break;
case 145:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 173;
case 173:
return 0;
}
break;
case 146:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 5;
case 5:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 147:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 6;
case 6:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 148:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 7;
case 7:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 149:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 8;
case 8:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 150:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 9;
case 9:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 151:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 5;
case 5:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 152:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 6;
case 6:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 153:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 7;
case 7:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 154:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 8;
case 8:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 155:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 9;
case 9:
return 20;
case 20:
return 26;
case 26:
return 0;
}
break;
case 156:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 27;
case 27:
return 0;
}
break;
case 157:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 27;
case 27:
return 0;
}
break;
case 158:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 27;
case 27:
return 0;
}
break;
case 159:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 27;
case 27:
return 0;
}
break;
case 160:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 27;
case 27:
return 0;
}
break;
case 161:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 28;
case 28:
return 0;
}
break;
case 162:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 28;
case 28:
return 0;
}
break;
case 163:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 28;
case 28:
return 0;
}
break;
case 164:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 28;
case 28:
return 0;
}
break;
case 165:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 28;
case 28:
return 0;
}
break;
case 166:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 29;
case 29:
return 0;
}
break;
case 167:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 29;
case 29:
return 0;
}
break;
case 168:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 29;
case 29:
return 0;
}
break;
case 169:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 29;
case 29:
return 0;
}
break;
case 170:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 29;
case 29:
return 0;
}
break;
case 171:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 49;
case 49:
return 63;
case 63:
return 0;
}
break;
case 172:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 50;
case 50:
return 93;
case 93:
return 0;
}
break;
case 173:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 118;
case 118:
return 0;
}
break;
case 174:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 144;
case 144:
return 0;
}
break;
case 175:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 170;
case 170:
return 0;
}
break;
case 176:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 49;
case 49:
return 63;
case 63:
return 0;
}
break;
case 177:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 50;
case 50:
return 93;
case 93:
return 0;
}
break;
case 178:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 118;
case 118:
return 0;
}
break;
case 179:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 144;
case 144:
return 0;
}
break;
case 180:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 170;
case 170:
return 0;
}
break;
case 181:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 49;
case 49:
return 63;
case 63:
return 0;
}
break;
case 182:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 50;
case 50:
return 93;
case 93:
return 0;
}
break;
case 183:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 118;
case 118:
return 0;
}
break;
case 184:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 144;
case 144:
return 0;
}
break;
case 185:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 170;
case 170:
return 0;
}
break;
case 186:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 49;
case 49:
return 63;
case 63:
return 0;
}
break;
case 187:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 50;
case 50:
return 93;
case 93:
return 0;
}
break;
case 188:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 118;
case 118:
return 0;
}
break;
case 189:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 144;
case 144:
return 0;
}
break;
case 190:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 170;
case 170:
return 0;
}
break;
case 191:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 49;
case 49:
return 63;
case 63:
return 0;
}
break;
case 192:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 50;
case 50:
return 93;
case 93:
return 0;
}
break;
case 193:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 118;
case 118:
return 0;
}
break;
case 194:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 144;
case 144:
return 0;
}
break;
case 195:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 170;
case 170:
return 0;
}
break;
case 196:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 26;
case 26:
return 0;
}
break;
case 197:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 198:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 199:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 200:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 201:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 202:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 26;
case 26:
return 0;
}
break;
case 203:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 204:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 205:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 206:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 207:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 208:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 26;
case 26:
return 0;
}
break;
case 209:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 210:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 211:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 212:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 213:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 214:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 26;
case 26:
return 0;
}
break;
case 215:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 216:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 217:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 218:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 219:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 26;
case 26:
return 0;
}
break;
case 220:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 26;
case 26:
return 0;
}
break;
case 221:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 64;
case 64:
return 0;
}
break;
case 222:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 94;
case 94:
return 0;
}
break;
case 223:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 122;
case 122:
return 0;
}
break;
case 224:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 148;
case 148:
return 0;
}
break;
case 225:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 174;
case 174:
return 0;
}
break;
case 226:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 10;
case 10:
return 0;
}
break;
case 227:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 11;
case 11:
return 0;
}
break;
case 228:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 12;
case 12:
return 0;
}
break;
case 229:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 13;
case 13:
return 0;
}
break;
case 230:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 14;
case 14:
return 0;
}
break;
case 231:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 232:
switch (registrador_endereco)
{
case 0:
return 95;
case 95:
return 0;
}
break;
case 233:
switch (registrador_endereco)
{
case 0:
return 123;
case 123:
return 0;
}
break;
case 234:
switch (registrador_endereco)
{
case 0:
return 149;
case 149:
return 0;
}
break;
case 235:
switch (registrador_endereco)
{
case 0:
return 175;
case 175:
return 0;
}
break;
case 236:
switch (registrador_endereco)
{
case 0:
return 65;
case 65:
return 0;
}
break;
case 237:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 238:
switch (registrador_endereco)
{
case 0:
return 124;
case 124:
return 0;
}
break;
case 239:
switch (registrador_endereco)
{
case 0:
return 150;
case 150:
return 0;
}
break;
case 240:
switch (registrador_endereco)
{
case 0:
return 176;
case 176:
return 0;
}
break;
case 241:
switch (registrador_endereco)
{
case 0:
return 66;
case 66:
return 0;
}
break;
case 242:
switch (registrador_endereco)
{
case 0:
return 96;
case 96:
return 0;
}
break;
case 243:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 244:
switch (registrador_endereco)
{
case 0:
return 151;
case 151:
return 0;
}
break;
case 245:
switch (registrador_endereco)
{
case 0:
return 177;
case 177:
return 0;
}
break;
case 246:
switch (registrador_endereco)
{
case 0:
return 67;
case 67:
return 0;
}
break;
case 247:
switch (registrador_endereco)
{
case 0:
return 97;
case 97:
return 0;
}
break;
case 248:
switch (registrador_endereco)
{
case 0:
return 125;
case 125:
return 0;
}
break;
case 249:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 250:
switch (registrador_endereco)
{
case 0:
return 178;
case 178:
return 0;
}
break;
case 251:
switch (registrador_endereco)
{
case 0:
return 68;
case 68:
return 0;
}
break;
case 252:
switch (registrador_endereco)
{
case 0:
return 98;
case 98:
return 0;
}
break;
case 253:
switch (registrador_endereco)
{
case 0:
return 126;
case 126:
return 0;
}
break;
case 254:
switch (registrador_endereco)
{
case 0:
return 152;
case 152:
return 0;
}
break;
case 255:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 256:
switch (registrador_endereco)
{
case 0:
return 15;
case 15:
return 30;
case 30:
return 0;
}
break;
case 257:
switch (registrador_endereco)
{
case 0:
return 16;
case 16:
return 30;
case 30:
return 0;
}
break;
case 258:
switch (registrador_endereco)
{
case 0:
return 17;
case 17:
return 30;
case 30:
return 0;
}
break;
case 259:
switch (registrador_endereco)
{
case 0:
return 18;
case 18:
return 30;
case 30:
return 0;
}
break;
case 260:
switch (registrador_endereco)
{
case 0:
return 19;
case 19:
return 30;
case 30:
return 0;
}
break;
case 261:
switch (registrador_endereco)
{
case 0:
return 15;
case 15:
return 31;
case 31:
return 0;
}
break;
case 262:
switch (registrador_endereco)
{
case 0:
return 16;
case 16:
return 31;
case 31:
return 0;
}
break;
case 263:
switch (registrador_endereco)
{
case 0:
return 17;
case 17:
return 31;
case 31:
return 0;
}
break;
case 264:
switch (registrador_endereco)
{
case 0:
return 18;
case 18:
return 31;
case 31:
return 0;
}
break;
case 265:
switch (registrador_endereco)
{
case 0:
return 19;
case 19:
return 31;
case 31:
return 0;
}
break;
case 266:
switch (registrador_endereco)
{
case 0:
return 15;
case 15:
return 32;
case 32:
return 0;
}
break;
case 267:
switch (registrador_endereco)
{
case 0:
return 16;
case 16:
return 32;
case 32:
return 0;
}
break;
case 268:
switch (registrador_endereco)
{
case 0:
return 17;
case 17:
return 32;
case 32:
return 0;
}
break;
case 269:
switch (registrador_endereco)
{
case 0:
return 18;
case 18:
return 32;
case 32:
return 0;
}
break;
case 270:
switch (registrador_endereco)
{
case 0:
return 19;
case 19:
return 32;
case 32:
return 0;
}
break;
case 271:
switch (registrador_endereco)
{
case 0:
return 15;
case 15:
return 33;
case 33:
return 0;
}
break;
case 272:
switch (registrador_endereco)
{
case 0:
return 16;
case 16:
return 33;
case 33:
return 0;
}
break;
case 273:
switch (registrador_endereco)
{
case 0:
return 17;
case 17:
return 33;
case 33:
return 0;
}
break;
case 274:
switch (registrador_endereco)
{
case 0:
return 18;
case 18:
return 33;
case 33:
return 0;
}
break;
case 275:
switch (registrador_endereco)
{
case 0:
return 19;
case 19:
return 33;
case 33:
return 0;
}
break;
case 276:
switch (registrador_endereco)
{
case 0:
return 15;
case 15:
return 34;
case 34:
return 0;
}
break;
case 277:
switch (registrador_endereco)
{
case 0:
return 16;
case 16:
return 34;
case 34:
return 0;
}
break;
case 278:
switch (registrador_endereco)
{
case 0:
return 17;
case 17:
return 34;
case 34:
return 0;
}
break;
case 279:
switch (registrador_endereco)
{
case 0:
return 18;
case 18:
return 34;
case 34:
return 0;
}
break;
case 280:
switch (registrador_endereco)
{
case 0:
return 19;
case 19:
return 34;
case 34:
return 0;
}
break;
case 281:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 64;
case 64:
return 0;
}
break;
case 282:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 94;
case 94:
return 0;
}
break;
case 283:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 122;
case 122:
return 0;
}
break;
case 284:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 148;
case 148:
return 0;
}
break;
case 285:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 174;
case 174:
return 0;
}
break;
case 286:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 64;
case 64:
return 0;
}
break;
case 287:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 94;
case 94:
return 0;
}
break;
case 288:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 122;
case 122:
return 0;
}
break;
case 289:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 148;
case 148:
return 0;
}
break;
case 290:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 174;
case 174:
return 0;
}
break;
case 291:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 64;
case 64:
return 0;
}
break;
case 292:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 94;
case 94:
return 0;
}
break;
case 293:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 122;
case 122:
return 0;
}
break;
case 294:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 148;
case 148:
return 0;
}
break;
case 295:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 174;
case 174:
return 0;
}
break;
case 296:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 64;
case 64:
return 0;
}
break;
case 297:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 94;
case 94:
return 0;
}
break;
case 298:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 122;
case 122:
return 0;
}
break;
case 299:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 148;
case 148:
return 0;
}
break;
case 300:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 174;
case 174:
return 0;
}
break;
case 301:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 64;
case 64:
return 0;
}
break;
case 302:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 94;
case 94:
return 0;
}
break;
case 303:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 122;
case 122:
return 0;
}
break;
case 304:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 148;
case 148:
return 0;
}
break;
case 305:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 174;
case 174:
return 0;
}
break;
case 306:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 307:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 11;
case 11:
return 0;
}
break;
case 308:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 12;
case 12:
return 0;
}
break;
case 309:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 13;
case 13:
return 0;
}
break;
case 310:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 14;
case 14:
return 0;
}
break;
case 311:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 10;
case 10:
return 0;
}
break;
case 312:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 313:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 12;
case 12:
return 0;
}
break;
case 314:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 13;
case 13:
return 0;
}
break;
case 315:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 14;
case 14:
return 0;
}
break;
case 316:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 10;
case 10:
return 0;
}
break;
case 317:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 11;
case 11:
return 0;
}
break;
case 318:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 319:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 13;
case 13:
return 0;
}
break;
case 320:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 14;
case 14:
return 0;
}
break;
case 321:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 10;
case 10:
return 0;
}
break;
case 322:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 11;
case 11:
return 0;
}
break;
case 323:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 12;
case 12:
return 0;
}
break;
case 324:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 325:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 14;
case 14:
return 0;
}
break;
case 326:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 10;
case 10:
return 0;
}
break;
case 327:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 11;
case 11:
return 0;
}
break;
case 328:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 12;
case 12:
return 0;
}
break;
case 329:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 13;
case 13:
return 0;
}
break;
case 330:
switch (registrador_endereco)
{
case 0:
return 0;
}
break;
case 331:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 192;
case 192:
return 0;
}
break;
case 332:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 196;
case 196:
return 0;
}
break;
case 333:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 200;
case 200:
return 0;
}
break;
case 334:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 204;
case 204:
return 0;
}
break;
case 335:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 208;
case 208:
return 0;
}
break;
case 336:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 337:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 338:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 339:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 340:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 341:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 192;
case 192:
return 0;
}
break;
case 342:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 196;
case 196:
return 0;
}
break;
case 343:
switch (registrador_endereco)
{
case 0:
return 201;
case 201:
return 0;
}
break;
case 344:
switch (registrador_endereco)
{
case 0:
return 205;
case 205:
return 0;
}
break;
case 345:
switch (registrador_endereco)
{
case 0:
return 209;
case 209:
return 0;
}
break;
case 346:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 192;
case 192:
return 0;
}
break;
case 347:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 196;
case 196:
return 0;
}
break;
case 348:
switch (registrador_endereco)
{
case 0:
return 202;
case 202:
return 0;
}
break;
case 349:
switch (registrador_endereco)
{
case 0:
return 206;
case 206:
return 0;
}
break;
case 350:
switch (registrador_endereco)
{
case 0:
return 210;
case 210:
return 0;
}
break;
case 351:
switch (registrador_endereco)
{
case 0:
return 193;
case 193:
return 0;
}
break;
case 352:
switch (registrador_endereco)
{
case 0:
return 197;
case 197:
return 0;
}
break;
case 353:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 203;
case 203:
return 0;
}
break;
case 354:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 207;
case 207:
return 0;
}
break;
case 355:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 211;
case 211:
return 0;
}
break;
case 356:
switch (registrador_endereco)
{
case 0:
return 194;
case 194:
return 0;
}
break;
case 357:
switch (registrador_endereco)
{
case 0:
return 198;
case 198:
return 0;
}
break;
case 358:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 203;
case 203:
return 0;
}
break;
case 359:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 207;
case 207:
return 0;
}
break;
case 360:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 211;
case 211:
return 0;
}
break;
case 361:
switch (registrador_endereco)
{
case 0:
return 195;
case 195:
return 0;
}
break;
case 362:
switch (registrador_endereco)
{
case 0:
return 199;
case 199:
return 0;
}
break;
case 363:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 203;
case 203:
return 0;
}
break;
case 364:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 207;
case 207:
return 0;
}
break;
case 365:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 211;
case 211:
return 0;
}
break;
case 366:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 5;
case 5:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 367:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 6;
case 6:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 368:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 7;
case 7:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 369:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 8;
case 8:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 370:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 9;
case 9:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 371:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 5;
case 5:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 372:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 6;
case 6:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 373:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 7;
case 7:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 374:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 8;
case 8:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 375:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 9;
case 9:
return 20;
case 20:
return 212;
case 212:
return 0;
}
break;
case 376:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 213;
case 213:
return 0;
}
break;
case 377:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 213;
case 213:
return 0;
}
break;
case 378:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 213;
case 213:
return 0;
}
break;
case 379:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 213;
case 213:
return 0;
}
break;
case 380:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 213;
case 213:
return 0;
}
break;
case 381:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 214;
case 214:
return 0;
}
break;
case 382:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 214;
case 214:
return 0;
}
break;
case 383:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 214;
case 214:
return 0;
}
break;
case 384:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 214;
case 214:
return 0;
}
break;
case 385:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 214;
case 214:
return 0;
}
break;
case 386:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 215;
case 215:
return 0;
}
break;
case 387:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 215;
case 215:
return 0;
}
break;
case 388:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 215;
case 215:
return 0;
}
break;
case 389:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 215;
case 215:
return 0;
}
break;
case 390:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 215;
case 215:
return 0;
}
break;
case 391:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 49;
case 49:
return 216;
case 216:
return 0;
}
break;
case 392:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 50;
case 50:
return 216;
case 216:
return 0;
}
break;
case 393:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 200;
case 200:
return 0;
}
break;
case 394:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 204;
case 204:
return 0;
}
break;
case 395:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 208;
case 208:
return 0;
}
break;
case 396:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 49;
case 49:
return 216;
case 216:
return 0;
}
break;
case 397:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 50;
case 50:
return 216;
case 216:
return 0;
}
break;
case 398:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 200;
case 200:
return 0;
}
break;
case 399:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 204;
case 204:
return 0;
}
break;
case 400:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 208;
case 208:
return 0;
}
break;
case 401:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 49;
case 49:
return 216;
case 216:
return 0;
}
break;
case 402:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 50;
case 50:
return 216;
case 216:
return 0;
}
break;
case 403:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 200;
case 200:
return 0;
}
break;
case 404:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 204;
case 204:
return 0;
}
break;
case 405:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 208;
case 208:
return 0;
}
break;
case 406:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 49;
case 49:
return 216;
case 216:
return 0;
}
break;
case 407:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 50;
case 50:
return 216;
case 216:
return 0;
}
break;
case 408:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 200;
case 200:
return 0;
}
break;
case 409:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 204;
case 204:
return 0;
}
break;
case 410:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 208;
case 208:
return 0;
}
break;
case 411:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 49;
case 49:
return 216;
case 216:
return 0;
}
break;
case 412:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 50;
case 50:
return 216;
case 216:
return 0;
}
break;
case 413:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 200;
case 200:
return 0;
}
break;
case 414:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 204;
case 204:
return 0;
}
break;
case 415:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 208;
case 208:
return 0;
}
break;
case 416:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 212;
case 212:
return 0;
}
break;
case 417:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 418:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 419:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 420:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 421:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 422:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 212;
case 212:
return 0;
}
break;
case 423:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 424:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 425:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 426:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 427:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 428:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 212;
case 212:
return 0;
}
break;
case 429:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 430:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 431:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 432:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 433:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 434:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 212;
case 212:
return 0;
}
break;
case 435:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 436:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 437:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 438:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 439:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 212;
case 212:
return 0;
}
break;
case 440:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 212;
case 212:
return 0;
}
break;
case 441:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 69;
case 69:
return 0;
}
break;
case 442:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 99;
case 99:
return 0;
}
break;
case 443:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 127;
case 127:
return 0;
}
break;
case 444:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 153;
case 153:
return 0;
}
break;
case 445:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 179;
case 179:
return 0;
}
break;
case 446:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 447:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 448:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 449:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 450:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 451:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 69;
case 69:
return 0;
}
break;
case 452:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 99;
case 99:
return 0;
}
break;
case 453:
switch (registrador_endereco)
{
case 0:
return 128;
case 128:
return 0;
}
break;
case 454:
switch (registrador_endereco)
{
case 0:
return 154;
case 154:
return 0;
}
break;
case 455:
switch (registrador_endereco)
{
case 0:
return 180;
case 180:
return 0;
}
break;
case 456:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 69;
case 69:
return 0;
}
break;
case 457:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 99;
case 99:
return 0;
}
break;
case 458:
switch (registrador_endereco)
{
case 0:
return 129;
case 129:
return 0;
}
break;
case 459:
switch (registrador_endereco)
{
case 0:
return 155;
case 155:
return 0;
}
break;
case 460:
switch (registrador_endereco)
{
case 0:
return 181;
case 181:
return 0;
}
break;
case 461:
switch (registrador_endereco)
{
case 0:
return 70;
case 70:
return 0;
}
break;
case 462:
switch (registrador_endereco)
{
case 0:
return 100;
case 100:
return 0;
}
break;
case 463:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 130;
case 130:
return 0;
}
break;
case 464:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 156;
case 156:
return 0;
}
break;
case 465:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 182;
case 182:
return 0;
}
break;
case 466:
switch (registrador_endereco)
{
case 0:
return 71;
case 71:
return 0;
}
break;
case 467:
switch (registrador_endereco)
{
case 0:
return 101;
case 101:
return 0;
}
break;
case 468:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 130;
case 130:
return 0;
}
break;
case 469:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 156;
case 156:
return 0;
}
break;
case 470:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 182;
case 182:
return 0;
}
break;
case 471:
switch (registrador_endereco)
{
case 0:
return 72;
case 72:
return 0;
}
break;
case 472:
switch (registrador_endereco)
{
case 0:
return 102;
case 102:
return 0;
}
break;
case 473:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 130;
case 130:
return 0;
}
break;
case 474:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 156;
case 156:
return 0;
}
break;
case 475:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 182;
case 182:
return 0;
}
break;
case 476:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 5;
case 5:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 477:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 6;
case 6:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 478:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 7;
case 7:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 479:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 8;
case 8:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 480:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 9;
case 9:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 481:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 5;
case 5:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 482:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 6;
case 6:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 483:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 7;
case 7:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 484:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 8;
case 8:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 485:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 9;
case 9:
return 20;
case 20:
return 35;
case 35:
return 0;
}
break;
case 486:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 36;
case 36:
return 0;
}
break;
case 487:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 36;
case 36:
return 0;
}
break;
case 488:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 36;
case 36:
return 0;
}
break;
case 489:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 36;
case 36:
return 0;
}
break;
case 490:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 36;
case 36:
return 0;
}
break;
case 491:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 37;
case 37:
return 0;
}
break;
case 492:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 37;
case 37:
return 0;
}
break;
case 493:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 37;
case 37:
return 0;
}
break;
case 494:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 37;
case 37:
return 0;
}
break;
case 495:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 37;
case 37:
return 0;
}
break;
case 496:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 38;
case 38:
return 0;
}
break;
case 497:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 38;
case 38:
return 0;
}
break;
case 498:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 38;
case 38:
return 0;
}
break;
case 499:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 38;
case 38:
return 0;
}
break;
case 500:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 38;
case 38:
return 0;
}
break;
case 501:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 49;
case 49:
return 73;
case 73:
return 0;
}
break;
case 502:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 50;
case 50:
return 103;
case 103:
return 0;
}
break;
case 503:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 127;
case 127:
return 0;
}
break;
case 504:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 153;
case 153:
return 0;
}
break;
case 505:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 179;
case 179:
return 0;
}
break;
case 506:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 49;
case 49:
return 73;
case 73:
return 0;
}
break;
case 507:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 50;
case 50:
return 103;
case 103:
return 0;
}
break;
case 508:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 127;
case 127:
return 0;
}
break;
case 509:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 153;
case 153:
return 0;
}
break;
case 510:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 179;
case 179:
return 0;
}
break;
case 511:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 49;
case 49:
return 73;
case 73:
return 0;
}
break;
case 512:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 50;
case 50:
return 103;
case 103:
return 0;
}
break;
case 513:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 127;
case 127:
return 0;
}
break;
case 514:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 153;
case 153:
return 0;
}
break;
case 515:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 179;
case 179:
return 0;
}
break;
case 516:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 49;
case 49:
return 73;
case 73:
return 0;
}
break;
case 517:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 50;
case 50:
return 103;
case 103:
return 0;
}
break;
case 518:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 127;
case 127:
return 0;
}
break;
case 519:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 153;
case 153:
return 0;
}
break;
case 520:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 179;
case 179:
return 0;
}
break;
case 521:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 49;
case 49:
return 73;
case 73:
return 0;
}
break;
case 522:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 50;
case 50:
return 103;
case 103:
return 0;
}
break;
case 523:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 127;
case 127:
return 0;
}
break;
case 524:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 153;
case 153:
return 0;
}
break;
case 525:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 179;
case 179:
return 0;
}
break;
case 526:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 35;
case 35:
return 0;
}
break;
case 527:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 528:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 529:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 530:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 531:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 532:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 35;
case 35:
return 0;
}
break;
case 533:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 534:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 535:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 536:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 537:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 538:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 35;
case 35:
return 0;
}
break;
case 539:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 540:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 541:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 542:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 543:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 544:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 35;
case 35:
return 0;
}
break;
case 545:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 546:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 547:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 548:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 549:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 35;
case 35:
return 0;
}
break;
case 550:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 35;
case 35:
return 0;
}
break;
case 551:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 74;
case 74:
return 0;
}
break;
case 552:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 104;
case 104:
return 0;
}
break;
case 553:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 131;
case 131:
return 0;
}
break;
case 554:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 157;
case 157:
return 0;
}
break;
case 555:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 183;
case 183:
return 0;
}
break;
case 556:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 557:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 558:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 559:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 560:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 561:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 74;
case 74:
return 0;
}
break;
case 562:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 104;
case 104:
return 0;
}
break;
case 563:
switch (registrador_endereco)
{
case 0:
return 132;
case 132:
return 0;
}
break;
case 564:
switch (registrador_endereco)
{
case 0:
return 158;
case 158:
return 0;
}
break;
case 565:
switch (registrador_endereco)
{
case 0:
return 184;
case 184:
return 0;
}
break;
case 566:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 74;
case 74:
return 0;
}
break;
case 567:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 104;
case 104:
return 0;
}
break;
case 568:
switch (registrador_endereco)
{
case 0:
return 133;
case 133:
return 0;
}
break;
case 569:
switch (registrador_endereco)
{
case 0:
return 159;
case 159:
return 0;
}
break;
case 570:
switch (registrador_endereco)
{
case 0:
return 185;
case 185:
return 0;
}
break;
case 571:
switch (registrador_endereco)
{
case 0:
return 75;
case 75:
return 0;
}
break;
case 572:
switch (registrador_endereco)
{
case 0:
return 105;
case 105:
return 0;
}
break;
case 573:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 134;
case 134:
return 0;
}
break;
case 574:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 160;
case 160:
return 0;
}
break;
case 575:
switch (registrador_endereco)
{
case 0:
return 51;
case 51:
return 186;
case 186:
return 0;
}
break;
case 576:
switch (registrador_endereco)
{
case 0:
return 76;
case 76:
return 0;
}
break;
case 577:
switch (registrador_endereco)
{
case 0:
return 106;
case 106:
return 0;
}
break;
case 578:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 134;
case 134:
return 0;
}
break;
case 579:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 160;
case 160:
return 0;
}
break;
case 580:
switch (registrador_endereco)
{
case 0:
return 52;
case 52:
return 186;
case 186:
return 0;
}
break;
case 581:
switch (registrador_endereco)
{
case 0:
return 77;
case 77:
return 0;
}
break;
case 582:
switch (registrador_endereco)
{
case 0:
return 107;
case 107:
return 0;
}
break;
case 583:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 134;
case 134:
return 0;
}
break;
case 584:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 160;
case 160:
return 0;
}
break;
case 585:
switch (registrador_endereco)
{
case 0:
return 53;
case 53:
return 186;
case 186:
return 0;
}
break;
case 586:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 5;
case 5:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 587:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 6;
case 6:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 588:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 7;
case 7:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 589:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 8;
case 8:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 590:
switch (registrador_endereco)
{
case 0:
return 49;
case 49:
return 9;
case 9:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 591:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 5;
case 5:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 592:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 6;
case 6:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 593:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 7;
case 7:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 594:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 8;
case 8:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 595:
switch (registrador_endereco)
{
case 0:
return 50;
case 50:
return 9;
case 9:
return 20;
case 20:
return 39;
case 39:
return 0;
}
break;
case 596:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 40;
case 40:
return 0;
}
break;
case 597:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 40;
case 40:
return 0;
}
break;
case 598:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 40;
case 40:
return 0;
}
break;
case 599:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 40;
case 40:
return 0;
}
break;
case 600:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 40;
case 40:
return 0;
}
break;
case 601:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 41;
case 41:
return 0;
}
break;
case 602:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 41;
case 41:
return 0;
}
break;
case 603:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 41;
case 41:
return 0;
}
break;
case 604:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 41;
case 41:
return 0;
}
break;
case 605:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 41;
case 41:
return 0;
}
break;
case 606:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 42;
case 42:
return 0;
}
break;
case 607:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 42;
case 42:
return 0;
}
break;
case 608:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 42;
case 42:
return 0;
}
break;
case 609:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 42;
case 42:
return 0;
}
break;
case 610:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 42;
case 42:
return 0;
}
break;
case 611:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 49;
case 49:
return 78;
case 78:
return 0;
}
break;
case 612:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 50;
case 50:
return 108;
case 108:
return 0;
}
break;
case 613:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 131;
case 131:
return 0;
}
break;
case 614:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 157;
case 157:
return 0;
}
break;
case 615:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 183;
case 183:
return 0;
}
break;
case 616:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 49;
case 49:
return 78;
case 78:
return 0;
}
break;
case 617:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 50;
case 50:
return 108;
case 108:
return 0;
}
break;
case 618:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 131;
case 131:
return 0;
}
break;
case 619:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 157;
case 157:
return 0;
}
break;
case 620:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 183;
case 183:
return 0;
}
break;
case 621:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 49;
case 49:
return 78;
case 78:
return 0;
}
break;
case 622:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 50;
case 50:
return 108;
case 108:
return 0;
}
break;
case 623:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 131;
case 131:
return 0;
}
break;
case 624:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 157;
case 157:
return 0;
}
break;
case 625:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 183;
case 183:
return 0;
}
break;
case 626:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 49;
case 49:
return 78;
case 78:
return 0;
}
break;
case 627:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 50;
case 50:
return 108;
case 108:
return 0;
}
break;
case 628:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 131;
case 131:
return 0;
}
break;
case 629:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 157;
case 157:
return 0;
}
break;
case 630:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 183;
case 183:
return 0;
}
break;
case 631:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 49;
case 49:
return 78;
case 78:
return 0;
}
break;
case 632:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 50;
case 50:
return 108;
case 108:
return 0;
}
break;
case 633:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 131;
case 131:
return 0;
}
break;
case 634:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 157;
case 157:
return 0;
}
break;
case 635:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 183;
case 183:
return 0;
}
break;
case 636:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 39;
case 39:
return 0;
}
break;
case 637:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 638:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 639:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 640:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 641:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 642:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 39;
case 39:
return 0;
}
break;
case 643:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 644:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 645:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 646:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 647:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 648:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 39;
case 39:
return 0;
}
break;
case 649:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 650:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 651:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 652:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 653:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 654:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 39;
case 39:
return 0;
}
break;
case 655:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 48;
case 48:
return 9;
case 9:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 656:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 5;
case 5:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 657:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 6;
case 6:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 658:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 7;
case 7:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 659:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 8;
case 8:
return 21;
case 21:
return 39;
case 39:
return 0;
}
break;
case 660:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 48;
case 48:
return 39;
case 39:
return 0;
}
break;
case 661:
switch (registrador_endereco)
{
case 0:
return 79;
case 79:
return 0;
}
break;
case 662:
switch (registrador_endereco)
{
case 0:
return 109;
case 109:
return 0;
}
break;
case 663:
switch (registrador_endereco)
{
case 0:
return 135;
case 135:
return 0;
}
break;
case 664:
switch (registrador_endereco)
{
case 0:
return 161;
case 161:
return 0;
}
break;
case 665:
switch (registrador_endereco)
{
case 0:
return 187;
case 187:
return 0;
}
break;
case 666:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 43;
case 43:
return 0;
}
break;
case 667:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 43;
case 43:
return 0;
}
break;
case 668:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 43;
case 43:
return 0;
}
break;
case 669:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 43;
case 43:
return 0;
}
break;
case 670:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 43;
case 43:
return 0;
}
break;
case 671:
switch (registrador_endereco)
{
case 0:
return 80;
case 80:
return 0;
}
break;
case 672:
switch (registrador_endereco)
{
case 0:
return 110;
case 110:
return 0;
}
break;
case 673:
switch (registrador_endereco)
{
case 0:
return 136;
case 136:
return 0;
}
break;
case 674:
switch (registrador_endereco)
{
case 0:
return 162;
case 162:
return 0;
}
break;
case 675:
switch (registrador_endereco)
{
case 0:
return 188;
case 188:
return 0;
}
break;
case 676:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 44;
case 44:
return 0;
}
break;
case 677:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 44;
case 44:
return 0;
}
break;
case 678:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 44;
case 44:
return 0;
}
break;
case 679:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 44;
case 44:
return 0;
}
break;
case 680:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 44;
case 44:
return 0;
}
break;
case 681:
switch (registrador_endereco)
{
case 0:
return 81;
case 81:
return 0;
}
break;
case 682:
switch (registrador_endereco)
{
case 0:
return 111;
case 111:
return 0;
}
break;
case 683:
switch (registrador_endereco)
{
case 0:
return 137;
case 137:
return 0;
}
break;
case 684:
switch (registrador_endereco)
{
case 0:
return 163;
case 163:
return 0;
}
break;
case 685:
switch (registrador_endereco)
{
case 0:
return 189;
case 189:
return 0;
}
break;
case 686:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 45;
case 45:
return 0;
}
break;
case 687:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 45;
case 45:
return 0;
}
break;
case 688:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 45;
case 45:
return 0;
}
break;
case 689:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 45;
case 45:
return 0;
}
break;
case 690:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 45;
case 45:
return 0;
}
break;
case 691:
switch (registrador_endereco)
{
case 0:
return 82;
case 82:
return 0;
}
break;
case 692:
switch (registrador_endereco)
{
case 0:
return 112;
case 112:
return 0;
}
break;
case 693:
switch (registrador_endereco)
{
case 0:
return 138;
case 138:
return 0;
}
break;
case 694:
switch (registrador_endereco)
{
case 0:
return 164;
case 164:
return 0;
}
break;
case 695:
switch (registrador_endereco)
{
case 0:
return 190;
case 190:
return 0;
}
break;
case 696:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 46;
case 46:
return 0;
}
break;
case 697:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 46;
case 46:
return 0;
}
break;
case 698:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 46;
case 46:
return 0;
}
break;
case 699:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 46;
case 46:
return 0;
}
break;
case 700:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 46;
case 46:
return 0;
}
break;
case 701:
switch (registrador_endereco)
{
case 0:
return 83;
case 83:
return 0;
}
break;
case 702:
switch (registrador_endereco)
{
case 0:
return 113;
case 113:
return 0;
}
break;
case 703:
switch (registrador_endereco)
{
case 0:
return 139;
case 139:
return 0;
}
break;
case 704:
switch (registrador_endereco)
{
case 0:
return 165;
case 165:
return 0;
}
break;
case 705:
switch (registrador_endereco)
{
case 0:
return 191;
case 191:
return 0;
}
break;
case 706:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 47;
case 47:
return 0;
}
break;
case 707:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 47;
case 47:
return 0;
}
break;
case 708:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 47;
case 47:
return 0;
}
break;
case 709:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 47;
case 47:
return 0;
}
break;
case 710:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 47;
case 47:
return 0;
}
break;
case 711:
if (flags_ula.zero == 1)
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
}
else
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 0;
}
}
break;
case 712:
if (flags_ula.negativo == 1)
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
}
else
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 0;
}
}
break;
case 713:
if (flags_ula.zero == 1)
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
}
else
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 0;
}
}
break;
case 714:
if (flags_ula.zero == 0 && flags_ula.negativo == 0 && flags_ula.carry == 0)
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
}
else
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 0;
}
}
break;
case 715:
if (flags_ula.negativo == 1)
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
}
else
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 0;
}
}
break;
case 716:
if (flags_ula.carry == 1)
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
}
else
{
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 0;
}
}
break;
case 717:
switch (registrador_endereco)
{
case 0:
return 1;
case 1:
return 4;
case 4:
return 20;
case 20:
return 2;
}
break;
case 719:
switch (registrador_endereco)
{
case 0:
return 218;
case 218:
return 0;
}
break;
case 720:
switch (registrador_endereco)
{
case 0:
return 219;
case 219:
return 0;
}
break;
case 721:
switch (registrador_endereco)
{
case 0:
return 220;
case 220:
return 0;
}
break;
case 722:
switch (registrador_endereco)
{
case 0:
return 221;
case 221:
return 0;
}
break;
case 723:
switch (registrador_endereco)
{
case 0:
return 222;
case 222:
return 0;
}
break;
case 724:
switch (registrador_endereco)
{
case 0:
return 223;
case 223:
return 0;
}
break;
case 725:
switch (registrador_endereco)
{
case 0:
return 224;
case 224:
return 0;
}
break;
case 726:
switch (registrador_endereco)
{
case 0:
return 225;
case 225:
return 0;
}
break;
case 727:
switch (registrador_endereco)
{
case 0:
return 226;
case 226:
return 0;
}
break;
case 728:
switch (registrador_endereco)
{
case 0:
return 227;
case 227:
return 0;
}
break;
case 729:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 228;
case 228:
return 0;
}
break;
case 730:
switch (registrador_endereco)
{
case 0:
return 6;
case 5:
return 20;
case 20:
return 228;
case 228:
return 0;
}
break;
case 731:
switch (registrador_endereco)
{
case 0:
return 7;
case 5:
return 20;
case 20:
return 228;
case 228:
return 0;
}
break;
case 732:
switch (registrador_endereco)
{
case 0:
return 8;
case 5:
return 20;
case 20:
return 228;
case 228:
return 0;
}
break;
case 733:
switch (registrador_endereco)
{
case 0:
return 9;
case 5:
return 20;
case 20:
return 228;
case 228:
return 0;
}
break;
case 734:
switch (registrador_endereco)
{
case 0:
return 5;
case 5:
return 20;
case 20:
return 229;
case 229:
return 0;
}
break;
case 735:
switch (registrador_endereco)
{
case 0:
return 6;
case 6:
return 20;
case 20:
return 229;
case 229:
return 0;
}
break;
case 736:
switch (registrador_endereco)
{
case 0:
return 7;
case 7:
return 20;
case 20:
return 229;
case 229:
return 0;
}
break;
case 737:
switch (registrador_endereco)
{
case 0:
return 8;
case 8:
return 20;
case 20:
return 229;
case 229:
return 0;
}
break;
case 738:
switch (registrador_endereco)
{
case 0:
return 9;
case 9:
return 20;
case 20:
return 229;
case 229:
return 0;
}
break;
}
}
/**
* Executa todas as operacoes correspondentes a um ciclo de maquina
*/
void Unidade_Controle::ciclo_de_maquina(int instrucao, Flags flags_ula)
{
#ifdef DEBUG
printf("Executando a instrucao (interno): %d\n", registrador_instrucao_interno);
printf("Executando a instrucao (externo): %d\n", instrucao);
#endif
//Pega o endereco da proxima micro
registrador_endereco = gerador_endereco(registrador_instrucao_interno, flags_ula);
#ifdef DEBUG
printf("Endereco da micro sendo executada: %d\n", registrador_endereco);
#endif
//Copia o ponto de controle da memoria de controle para o registrador de controle
registrador_controle = memoria_controle[registrador_endereco];
#ifdef DEBUG
printf("Sinais: ");
for (int i = 0; i < MAX_CONTROLES; i++)
printf("%d", registrador_controle.controle[i]);
printf("\n");
#endif
/* O processador sempre deve decodificar as instrucoes. (Decodificar instrucao -> instrucao = 0)
* Portanto, ao final da decodificacao (Ultima micro da decodificacao = 163) podemos comecar a executar a intrucao decodificada.
* (registrador_instrucao_interno = instrucao;)
* Ao terminar de executar uma instrucao qualquer (registrador_instrucao_interno != 0 e ultima micro = 0), devemos decodificar a proxima intrucao
* (registrador_instrucao_interno = 0;)
*/
if (registrador_instrucao_interno == 0 && registrador_endereco == 217)
{
registrador_instrucao_interno = instrucao;
registrador_endereco = 0;
}
else if (registrador_instrucao_interno != 0 && registrador_endereco == 0)
{
registrador_instrucao_interno = 0;
}
else if (registrador_instrucao_interno > 710 && registrador_instrucao_interno < 718 && registrador_endereco == 2)
{
registrador_instrucao_interno = 0;
registrador_endereco = 0;
}
}
/**
* Comeca o processador
*/
void Unidade_Controle::start(Flags flag_ula)
{
#ifdef DEBUG
printf("Comecou!\n");
#endif
//Inicializa Registrador de Endereco
registrador_endereco = 0;
registrador_instrucao_interno = 0;
ciclo_de_maquina(0, flag_ula);
}
| [
"prosanes@d2cc51ec-644b-ba46-3315-dce07c01be90"
]
| [
[
[
1,
10982
]
]
]
|
2d3b3612e40e1cfe2466ac1d39cadd0edebca55f | c7120eeec717341240624c7b8a731553494ef439 | /src/cplusplus/freezone-samp/src/profile_cpu.hpp | bbc48f7eb8c77794c93d18570e1394ef0ee90040 | []
| no_license | neverm1ndo/gta-paradise-sa | d564c1ed661090336621af1dfd04879a9c7db62d | 730a89eaa6e8e4afc3395744227527748048c46d | refs/heads/master | 2020-04-27T22:00:22.221323 | 2010-09-04T19:02:28 | 2010-09-04T19:02:28 | 174,719,907 | 1 | 0 | null | 2019-03-09T16:44:43 | 2019-03-09T16:44:43 | null | WINDOWS-1251 | C++ | false | false | 838 | hpp | #ifndef PROFILE_CPU_HPP
#define PROFILE_CPU_HPP
#include <ctime>
class profile_cpu
{
public:
profile_cpu();
~profile_cpu();
bool is_active;
void update();
float user_utility_get() const;
float kernel_utility_get() const;
void raw_get(std::clock_t& ticks_per_seconds, std::clock_t& clock_delta, std::clock_t& user_delta, std::clock_t& kernel_delta) const;
private: // Данные, необходимые между интерациями
std::clock_t cpu_clock_last;
std::clock_t cpu_user_last;
std::clock_t cpu_kernel_last;
void update_impl();
private: // Результаты замеров
std::clock_t ticks_per_seconds;
std::clock_t clock_delta;
std::clock_t user_delta;
std::clock_t kernel_delta;
};
#endif // PROFILE_CPU_HPP
| [
"dimonml@19848965-7475-ded4-60a4-26152d85fbc5"
]
| [
[
[
1,
29
]
]
]
|
73f851138134fa440f0547344413fde6a7c2136b | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /libs/STLPort-4.0/src/ctype_byname_w.cpp | ad16cb6432a47a82c1c899a2f013821e4300e6fa | [
"LicenseRef-scancode-stlport-4.5"
]
| permissive | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,060 | cpp | /*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
# include "stlport_prefix.h"
#include <string>
#include <stl/_locale.h>
#include <stl/_ctype.h>
#include <stl/_threads.h>
__STL_BEGIN_NAMESPACE
_Locale_ctype* __acquire_ctype(const char* name);
void __release_ctype(_Locale_ctype* cat);
// ctype_byname<wchar_t>
# ifndef __STL_NO_WCHAR_T
struct _Ctype_byname_w_is_mask {
typedef wchar_t argument_type;
typedef bool result_type;
/* ctype_base::mask*/ int M;
_Locale_ctype* M_ctp;
_Ctype_byname_w_is_mask(/* ctype_base::mask */ int m, _Locale_ctype* c) : M((int)m), M_ctp(c) {}
bool operator()(wchar_t c) const
{ return (M & _Locale_wchar_ctype(M_ctp, c)) != 0; }
};
ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
: ctype<wchar_t>(refs),
_M_ctype(__acquire_ctype(name))
{
if (!_M_ctype)
locale::_M_throw_runtime_error();
}
ctype_byname<wchar_t>::~ctype_byname()
{
__release_ctype(_M_ctype);
}
bool ctype_byname<wchar_t>::do_is(mask m, wchar_t c) const
{
return (m & _Locale_wchar_ctype(_M_ctype, c)) != 0;
}
const wchar_t*
ctype_byname<wchar_t>::do_is(const wchar_t* low, const wchar_t* high,
mask* m) const
{
for ( ; low < high; ++low, ++m)
*m = mask(_Locale_wchar_ctype(_M_ctype, *low));
return high;
}
const wchar_t*
ctype_byname<wchar_t>
::do_scan_is(mask m, const wchar_t* low, const wchar_t* high) const
{
return find_if(low, high, _Ctype_byname_w_is_mask(m, _M_ctype));
}
const wchar_t*
ctype_byname<wchar_t>
::do_scan_not(mask m, const wchar_t* low, const wchar_t* high) const
{
return find_if(low, high, not1(_Ctype_byname_w_is_mask(m, _M_ctype)));
}
wchar_t ctype_byname<wchar_t>::do_toupper(wchar_t c) const
{
return _Locale_wchar_toupper(_M_ctype, c);
}
const wchar_t*
ctype_byname<wchar_t>::do_toupper(wchar_t* low, const wchar_t* high) const
{
for ( ; low < high; ++low)
*low = _Locale_wchar_toupper(_M_ctype, *low);
return high;
}
wchar_t ctype_byname<wchar_t>::do_tolower(wchar_t c) const
{
return _Locale_wchar_tolower(_M_ctype, c);
}
const wchar_t*
ctype_byname<wchar_t>::do_tolower(wchar_t* low, const wchar_t* high) const
{
for ( ; low < high; ++low)
*low = _Locale_wchar_tolower(_M_ctype, *low);
return high;
}
# endif /* WCHAR_T */
__STL_END_NAMESPACE
// Local Variables:
// mode:C++
// End:
| [
"[email protected]"
]
| [
[
[
1,
120
]
]
]
|
5472069718eeb2cef5fbb2f23344ed64f031114a | 8b68ff41fd39c9cf20d27922bb9f8b9d2a1c68e9 | /TWL/include/out/lock.h | bd6dbf9995b6e6698c7e7f0f020669c6dee52276 | []
| no_license | dandycheung/dandy-twl | 2ec6d500273b3cb7dd6ab9e5a3412740d73219ae | 991220b02f31e4ec82760ece9cd974103c7f9213 | refs/heads/master | 2020-12-24T15:06:06.260650 | 2009-05-20T14:46:07 | 2009-05-20T14:46:07 | 32,625,192 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,918 | h | #ifndef __LOCK_H__
#define __LOCK_H__
#ifndef ASSERT
#define ASSERT(e)
#endif // ASSERT
/////////////////////////////////////////////////////////////////////////////
// CNullSyncObj
class CNullSyncObj
{
public:
CNullSyncObj() {}
virtual ~CNullSyncObj() {}
// Operations
public:
BOOL Lock() { return TRUE; }
BOOL Lock(DWORD /* dwTimeOut */) { return TRUE; }
BOOL Unlock() { return TRUE; }
};
/////////////////////////////////////////////////////////////////////////////
// CCriticalSection
class CCriticalSection
{
public:
CCriticalSection() { ::InitializeCriticalSection(&m_sect); }
virtual ~CCriticalSection() { ::DeleteCriticalSection(&m_sect); }
// Attributes
public:
operator CRITICAL_SECTION*() { return (CRITICAL_SECTION*)&m_sect; }
CRITICAL_SECTION m_sect;
// Operations
public:
BOOL Lock() { ::EnterCriticalSection(&m_sect); return TRUE; }
BOOL Lock(DWORD /* dwTimeOut */) { return Lock(); }
BOOL Unlock() { ::LeaveCriticalSection(&m_sect); return TRUE; }
};
/////////////////////////////////////////////////////////////////////////////
// CSingleLock
template <typename T>
class CSingleLock
{
public:
CSingleLock(T* pObject, BOOL bInitialLock = FALSE)
{
ASSERT(pObject != NULL);
m_pObject = pObject;
m_bAcquired = FALSE;
if(bInitialLock)
Lock();
}
~CSingleLock()
{
Unlock();
}
// Operations
public:
BOOL Lock(DWORD dwTimeOut = INFINITE)
{
ASSERT(m_pObject != NULL);
ASSERT(!m_bAcquired);
m_bAcquired = m_pObject->Lock(dwTimeOut);
return m_bAcquired;
}
BOOL Unlock()
{
ASSERT(m_pObject != NULL);
if(m_bAcquired)
m_bAcquired = !m_pObject->Unlock();
// successfully unlocking means it isn't acquired
return !m_bAcquired;
}
BOOL IsLocked()
{
return m_bAcquired;
}
protected:
T* m_pObject;
BOOL m_bAcquired;
};
#endif // __LOCK_H__
| [
"dandycheung@9b253700-4547-11de-82b9-170f4fd74ac7"
]
| [
[
[
1,
99
]
]
]
|
46eb7e1d951ca82ac71943cf7a7f4bf152dc2bf7 | 9566086d262936000a914c5dc31cb4e8aa8c461c | /EnigmaCommon/Entities/Object.cpp | 9fa479dc365cc7ce012c527fe74bd40bacb6995b | []
| no_license | pazuzu156/Enigma | 9a0aaf0cd426607bb981eb46f5baa7f05b66c21f | b8a4dfbd0df206e48072259dbbfcc85845caad76 | refs/heads/master | 2020-06-06T07:33:46.385396 | 2011-12-19T03:14:15 | 2011-12-19T03:14:15 | 3,023,618 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,397 | cpp | /*
Copyright © 2009 Christopher Joseph Dean Schaefer (disks86)
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "Object.hpp"
namespace Enigma
{
Object::Object()
{
this->mData=NULL;
this->mName="";
}
Object::~Object()
{
}
const std::string& Object::GetName() const
{
return this->mName;
}
void Object::SetName(const std::string& value)
{
this->mName=value;
}
void* Object::GetData() const
{
return this->mData;
}
void Object::SetData(void* value)
{
this->mData=value;
}
};
| [
"[email protected]"
]
| [
[
[
1,
48
]
]
]
|
b70ebcd091a712ce3ddc2de83d97255e53a51826 | b83c990328347a0a2130716fd99788c49c29621e | /include/boost/interprocess/shared_memory_object.hpp | e27dc391c31b4fca827464330b90dba366d51cc3 | []
| no_license | SpliFF/mingwlibs | c6249fbb13abd74ee9c16e0a049c88b27bd357cf | 12d1369c9c1c2cc342f66c51d045b95c811ff90c | refs/heads/master | 2021-01-18T03:51:51.198506 | 2010-06-13T15:13:20 | 2010-06-13T15:13:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,924 | hpp | //////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2005-2008. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/interprocess for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTERPROCESS_SHARED_MEMORY_OBJECT_HPP
#define BOOST_INTERPROCESS_SHARED_MEMORY_OBJECT_HPP
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/creation_tags.hpp>
#include <boost/interprocess/exceptions.hpp>
#include <boost/interprocess/detail/move.hpp>
#include <boost/interprocess/interprocess_fwd.hpp>
#include <boost/interprocess/exceptions.hpp>
#include <boost/interprocess/detail/os_file_functions.hpp>
#include <boost/interprocess/detail/tmp_dir_helpers.hpp>
#include <cstddef>
#include <string>
#include <algorithm>
#if defined(BOOST_INTERPROCESS_SYSTEM_V_SHARED_MEMORY_OBJECTS)
# include <sys/shm.h> //System V shared memory...
#elif defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
# include <fcntl.h> //O_CREAT, O_*...
# include <sys/mman.h> //shm_xxx
# include <unistd.h> //ftruncate, close
# include <sys/stat.h> //mode_t, S_IRWXG, S_IRWXO, S_IRWXU,
#else
//
#endif
//!\file
//!Describes a shared memory object management class.
namespace boost {
namespace interprocess {
//!A class that wraps a shared memory mapping that can be used to
//!create mapped regions from the mapped files
class shared_memory_object
{
/// @cond
//Non-copyable and non-assignable
shared_memory_object(shared_memory_object &);
shared_memory_object &operator=(shared_memory_object &);
/// @endcond
public:
BOOST_INTERPROCESS_ENABLE_MOVE_EMULATION(shared_memory_object)
//!Default constructor. Represents an empty shared_memory_object.
shared_memory_object();
//!Creates a shared memory object with name "name" and mode "mode", with the access mode "mode"
//!If the file previously exists, throws an error.*/
shared_memory_object(create_only_t, const char *name, mode_t mode)
{ this->priv_open_or_create(detail::DoCreate, name, mode); }
//!Tries to create a shared memory object with name "name" and mode "mode", with the
//!access mode "mode". If the file previously exists, it tries to open it with mode "mode".
//!Otherwise throws an error.
shared_memory_object(open_or_create_t, const char *name, mode_t mode)
{ this->priv_open_or_create(detail::DoOpenOrCreate, name, mode); }
//!Tries to open a shared memory object with name "name", with the access mode "mode".
//!If the file does not previously exist, it throws an error.
shared_memory_object(open_only_t, const char *name, mode_t mode)
{ this->priv_open_or_create(detail::DoOpen, name, mode); }
//!Moves the ownership of "moved"'s shared memory object to *this.
//!After the call, "moved" does not represent any shared memory object.
//!Does not throw
shared_memory_object(BOOST_INTERPROCESS_RV_REF(shared_memory_object) moved)
: m_handle(file_handle_t(detail::invalid_file()))
{ this->swap(moved); }
//!Moves the ownership of "moved"'s shared memory to *this.
//!After the call, "moved" does not represent any shared memory.
//!Does not throw
shared_memory_object &operator=(BOOST_INTERPROCESS_RV_REF(shared_memory_object) moved)
{
shared_memory_object tmp(boost::interprocess::move(moved));
this->swap(tmp);
return *this;
}
//!Swaps the shared_memory_objects. Does not throw
void swap(shared_memory_object &moved);
//!Erases a shared memory object from the system.
//!Returns false on error. Never throws
static bool remove(const char *name);
//!Sets the size of the shared memory mapping
void truncate(offset_t length);
//!Destroys *this and indicates that the calling process is finished using
//!the resource. All mapped regions are still
//!valid after destruction. The destructor function will deallocate
//!any system resources allocated by the system for use by this process for
//!this resource. The resource can still be opened again calling
//!the open constructor overload. To erase the resource from the system
//!use remove().
~shared_memory_object();
//!Returns the name of the file.
const char *get_name() const;
//!Returns the name of the file
//!used in the constructor
bool get_size(offset_t &size) const;
//!Returns access mode
mode_t get_mode() const;
//!Returns mapping handle. Never throws.
mapping_handle_t get_mapping_handle() const;
/// @cond
private:
//!Closes a previously opened file mapping. Never throws.
void priv_close();
//!Closes a previously opened file mapping. Never throws.
bool priv_open_or_create(detail::create_enum_t type, const char *filename, mode_t mode);
file_handle_t m_handle;
mode_t m_mode;
std::string m_filename;
/// @endcond
};
/// @cond
inline shared_memory_object::shared_memory_object()
: m_handle(file_handle_t(detail::invalid_file()))
{}
inline shared_memory_object::~shared_memory_object()
{ this->priv_close(); }
inline const char *shared_memory_object::get_name() const
{ return m_filename.c_str(); }
inline bool shared_memory_object::get_size(offset_t &size) const
{ return detail::get_file_size((file_handle_t)m_handle, size); }
inline void shared_memory_object::swap(shared_memory_object &other)
{
std::swap(m_handle, other.m_handle);
std::swap(m_mode, other.m_mode);
m_filename.swap(other.m_filename);
}
inline mapping_handle_t shared_memory_object::get_mapping_handle() const
{
return detail::mapping_handle_from_file_handle(m_handle);
}
inline mode_t shared_memory_object::get_mode() const
{ return m_mode; }
#if !defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
inline bool shared_memory_object::priv_open_or_create
(detail::create_enum_t type, const char *filename, mode_t mode)
{
m_filename = filename;
std::string shmfile;
detail::create_tmp_dir_and_get_filename(filename, shmfile);
//Set accesses
if (mode != read_write && mode != read_only){
error_info err = other_error;
throw interprocess_exception(err);
}
switch(type){
case detail::DoOpen:
m_handle = detail::open_existing_file(shmfile.c_str(), mode, true);
break;
case detail::DoCreate:
m_handle = detail::create_new_file(shmfile.c_str(), mode, true);
break;
case detail::DoOpenOrCreate:
m_handle = detail::create_or_open_file(shmfile.c_str(), mode, true);
break;
default:
{
error_info err = other_error;
throw interprocess_exception(err);
}
}
//Check for error
if(m_handle == detail::invalid_file()){
error_info err = system_error_code();
this->priv_close();
throw interprocess_exception(err);
}
m_mode = mode;
return true;
}
inline bool shared_memory_object::remove(const char *filename)
{
try{
//Make sure a temporary path is created for shared memory
std::string shmfile;
detail::tmp_filename(filename, shmfile);
return detail::delete_file(shmfile.c_str()) == 0;
}
catch(...){
return false;
}
}
inline void shared_memory_object::truncate(offset_t length)
{
if(!detail::truncate_file(m_handle, length)){
error_info err = system_error_code();
throw interprocess_exception(err);
}
}
inline void shared_memory_object::priv_close()
{
if(m_handle != detail::invalid_file()){
detail::close_file(m_handle);
m_handle = detail::invalid_file();
}
}
#else //!defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
inline bool shared_memory_object::priv_open_or_create
(detail::create_enum_t type,
const char *filename,
mode_t mode)
{
#ifndef BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
detail::add_leading_slash(filename, m_filename);
#else
detail::create_tmp_dir_and_get_filename(filename, m_filename);
#endif
//Create new mapping
int oflag = 0;
if(mode == read_only){
oflag |= O_RDONLY;
}
else if(mode == read_write){
oflag |= O_RDWR;
}
else{
error_info err(mode_error);
throw interprocess_exception(err);
}
switch(type){
case detail::DoOpen:
//No addition
break;
case detail::DoCreate:
oflag |= (O_CREAT | O_EXCL);
break;
case detail::DoOpenOrCreate:
oflag |= O_CREAT;
break;
default:
{
error_info err = other_error;
throw interprocess_exception(err);
}
}
//Open file using POSIX API
m_handle = shm_open(m_filename.c_str(), oflag, S_IRWXO | S_IRWXG | S_IRWXU);
//Check for error
if(m_handle == -1){
error_info err = errno;
this->priv_close();
throw interprocess_exception(err);
}
m_filename = filename;
m_mode = mode;
return true;
}
inline bool shared_memory_object::remove(const char *filename)
{
try{
std::string file_str;
#ifndef BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
detail::add_leading_slash(filename, file_str);
#else
detail::tmp_filename(filename, file_str);
#endif
return 0 != shm_unlink(file_str.c_str());
}
catch(...){
return false;
}
}
inline void shared_memory_object::truncate(offset_t length)
{
if(0 != ftruncate(m_handle, length)){
error_info err(system_error_code());
throw interprocess_exception(err);
}
}
inline void shared_memory_object::priv_close()
{
if(m_handle != -1){
::close(m_handle);
m_handle = -1;
}
}
#endif
///@endcond
//!A class that stores the name of a shared memory
//!and calls shared_memory_object::remove(name) in its destructor
//!Useful to remove temporary shared memory objects in the presence
//!of exceptions
class remove_shared_memory_on_destroy
{
const char * m_name;
public:
remove_shared_memory_on_destroy(const char *name)
: m_name(name)
{}
~remove_shared_memory_on_destroy()
{ shared_memory_object::remove(m_name); }
};
} //namespace interprocess {
} //namespace boost {
#include <boost/interprocess/detail/config_end.hpp>
#endif //BOOST_INTERPROCESS_SHARED_MEMORY_OBJECT_HPP
| [
"[email protected]"
]
| [
[
[
1,
358
]
]
]
|
669dbd264da91eadf98cc07100162a37a14cae39 | 3276915b349aec4d26b466d48d9c8022a909ec16 | /c++/函数/引用和一般的引用的特别差别.cpp | 25b17e00c21e42b880505354eecd6746b6e49ee5 | []
| no_license | flyskyosg/3dvc | c10720b1a7abf9cf4fa1a66ef9fc583d23e54b82 | 0279b1a7ae097b9028cc7e4aa2dcb67025f096b9 | refs/heads/master | 2021-01-10T11:39:45.352471 | 2009-07-31T13:13:50 | 2009-07-31T13:13:50 | 48,670,844 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 564 | cpp | #include<iostream> //常引用和一般的引用的特别差别
using namespace std;
void f0(const int a)
{
cout<<0<<endl;
}
void f1(int & a)
{
cout<<1<<endl;
}
int main()
{
int a=10;double b=20.0;
f0(a);f0(b);f0(10);f0(10.0); //当函数的参数是常引用的时候,前边的这些都对
f1(a); //当不是常引用的时候,只能精确匹配,只能是该类型的变量
//f1(b); //下边的这三个都是错的
//f1(10);
//f1(10.0);
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
d84a8e161d5f71e57b2ffe8a0c765e27a51bdb23 | 353bd39ba7ae46ed521936753176ed17ea8546b5 | /src/layer0_base/sequential_buffer/src/axsb_state.h | 3e740761ba16bbfe9236a211ffdc7d68fa794698 | []
| no_license | d0n3val/axe-engine | 1a13e8eee0da667ac40ac4d92b6a084ab8a910e8 | 320b08df3a1a5254b776c81775b28fa7004861dc | refs/heads/master | 2021-01-01T19:46:39.641648 | 2007-12-10T18:26:22 | 2007-12-10T18:26:22 | 32,251,179 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 550 | h | /**
* @file
*
* @author Carlos Fuentes
* @date 22 Aug 2004
*/
#ifndef __AXSB_STATE_H__
#define __AXSB_STATE_H__
#include "axsb_stdafx.h"
/**
* This class stores all data related to the state of the library
*/
class axsb_state : public axe_state
{
public:
axsb_buffer_id default_buffer;
public:
axsb_state() :
axe_state()
{
default_buffer = -1;
}
~axsb_state()
{
}
};
#endif // __AXSB_STATE_H__
/* $Id: axsb_state.h,v 1.2 2004/08/23 21:26:11 ilgenio Exp $ */
| [
"d0n3val@2cff7946-3f3c-0410-b79f-f9b517ddbf54"
]
| [
[
[
1,
32
]
]
]
|
2ee5165b4da7e97010fa493c15c8b9417cb1089d | 96fefafdfbb413a56e0a2444fcc1a7056afef757 | /MQ2EQBH/MQ2EQBH.cpp | a318b40df734b13daee479df93ff9d4b07946345 | []
| no_license | kevrgithub/peqtgc-mq2-sod | ffc105aedbfef16060769bb7a6fa6609d775b1fa | d0b7ec010bc64c3f0ac9dc32129a62277b8d42c0 | refs/heads/master | 2021-01-18T18:57:16.627137 | 2011-03-06T13:05:41 | 2011-03-06T13:05:41 | 32,849,784 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 51,141 | cpp | /*
MQ2EQBH
Clone of EQBC that has been hacked down to suit our needs.
By: Tim Hansen
*/
// MQ2EQBC.cpp - Much of the code here came from MQ2Irc and MQ2Telnet.
// Author: Omnictrl (o)
// Contributor: ascii (a)
// Contributor: Vladus2000 (v)
// Contributor: pms (p)
// Contributor: ieatacid (i)
/*
* Version 1.0.o2 - 20050926
*/
#define PROG_VERSION "MQ2EQBH v1.3.p5"
#pragma comment(lib,"wsock32.lib")
#include "../MQ2Plugin.h"
#include <vector>
//Tim: 9/22/10
#include <sstream>
//End Tim
PreSetup("MQ2Eqbh");
// Shared Info
class EQBHType : public MQ2Type
{
public:
enum VarMembers { Connected=1 };
EQBHType();
~EQBHType();
bool GetMember(MQ2VARPTR VarPtr, PCHAR Member, PCHAR Index, MQ2TYPEVAR &Dest);
bool ToString(MQ2VARPTR VarPtr, PCHAR Destination);
bool FromData(MQ2VARPTR &VarPtr, MQ2TYPEVAR &Source);
bool FromString(MQ2VARPTR &VarPtr, PCHAR Source);
};
class EQBHType *pEQBHType=0;
CRITICAL_SECTION ConnectCS;
bool bConnecting=false;
bool bTriedConnect=false;
bool bConnected=false;
SOCKADDR_IN serverInfo;
CHAR szServer[MAX_STRING] = {0};
CHAR szPort[MAX_STRING] = {0};
CHAR szToonName[MAX_STRING] = {0};
CHAR szToonCmdStart[MAX_STRING] = {0};
CHAR szToonToRelog[MAX_STRING] = {0};
CHAR szColorChars[] = "yogurtbmpwx";
// Don't change MAX_PASSWORD without checking out the cmd buffer in eqbcs
#define MAX_PASSWORD 40
CHAR szPassword[MAX_PASSWORD] = {0};
#define SUPPORTED_COMMANDS "connect quit help status names colordump reconnect togglecontrol toggleautoconnect togglecompatmode togglereconnect togglewindow setreconnectsecs stopreconnect relog version channels togglelocalecho toggletellwatch toggleguildwatch togglegroupwatch togglefswatch togglesilentcmd togglesavebychar"
#define COLOR_NAME "\ay"
#define COLOR_NAME_BRACKET "\ar"
#define COLOR_OFF "\ax"
#define COLOR_STELL1 "\ax\ar[(\ax\aymsg\ax\ar)\ax\ay"
#define COLOR_STELL2 "\ax\ar]\ax "
#define CONNECT_START "LOGIN"
#define CONNECT_START2 "="
#define CONNECT_END ";"
#define CONNECT_PWSEP ":"
#define SEND_LINE_TERM "\n"
#define CMD_DISCONNECT "\tDISCONNECT\n"
#define CMD_NAMES "\tNAMES\n"
#define CMD_PONG "\tPONG\n"
#define CMD_MSGALL "\tMSGALL\n"
#define CMD_TELL "\tTELL\n"
#define CMD_CHANNELS "\tCHANNELS\n"
#define CMD_LOCALECHO "\tLOCALECHO "
#define CMD_BCI "\tBCI\n"
//Tim
//10/14/10
#define CMD_START "\tSTARTROTATION\n"
#define CMD_STOP "\tSTOPROTATION\n"
#define CMD_DELAY "\tDELAY\n"
#define CMD_TANK "\tTANK\n"
//End Tim
//Tim: 9/22/10
#define CMD_GVAR "\tGVAR\n"
void HandleGlobalVar(std::string line);
//End Tim
#define MAX_READBUF 512
#define MAX_COMMAND_HISTORY 50
WORD sockVersion;
WSADATA wsaData;
int nret;
LPHOSTENT hostEntry;
SOCKET theSocket;
CHAR *ireadbuf = new CHAR[MAX_READBUF];
int lastReadBufPos;
bool bForceCmd = false;
int bSetTitle = 0;
int bSaveCharacter = 1;
int bUseWindow=0;
int bAutoConnect = 0;
int bAllowControl = 1;
int bSocketGone = 0;
int bIrcCompatMode = 0;
int bReconnectMode = 0;
int bLocalEchoMode = 1;
int bDoTellWatch = 0;
int bDoGuildWatch = 0;
int bDoGroupWatch = 0;
int bDoFSWatch = 0;
int bSilentCmd = 0;
int iReconnectSeconds = 0;
unsigned long lastReconnectTimeSecs = 0;
unsigned long reloginBeforeSecs = 0;
clock_t lastPingTime = 0;
// ------------------------
typedef VOID (__cdecl *fNetBotOnMsg)(PCHAR, PCHAR);
typedef VOID (__cdecl *fNetBotOnEvent)(PCHAR);
void WriteOut(char *szText);
void transmit(bool handleDisconnect, PCHAR szMsg);
void HandleIncomingString(PCHAR rawmsg);
VOID BoxHChatCommand(PSPAWNINFO pChar, PCHAR szLine);
VOID BoxHChatTell(PSPAWNINFO pChar, PCHAR szLine);
VOID BoxHChatAll(PSPAWNINFO pChar, PCHAR szLine);
VOID BoxHChatAllButMe(PSPAWNINFO pChar, PCHAR szLine);
BOOL dataEQBH(PCHAR Index, MQ2TYPEVAR &Dest)
{
Dest.DWord=1;
Dest.Type=pEQBHType;
return true;
}
// ------------------------
DWORD WINAPI EQBHConnectThread(LPVOID lpParam)
{
EnterCriticalSection(&ConnectCS);
bConnecting=true;
nret = connect(theSocket, (LPSOCKADDR)&serverInfo, sizeof(struct sockaddr));
if (nret == SOCKET_ERROR)
{
bConnected=false;
}
else
{
// DebugSpew("MQ2Eqbh Connecting");
unsigned long nonblocking = 1;
ioctlsocket(theSocket, FIONBIO, &nonblocking);
Sleep((clock_t)4 * CLOCKS_PER_SEC/2);
send(theSocket, CONNECT_START, strlen(CONNECT_START), 0);
if (*szPassword)
{
// DebugSpew("With Password");
send(theSocket, CONNECT_PWSEP, strlen(CONNECT_PWSEP), 0);
send(theSocket, szPassword, strlen(szPassword), 0);
}
send(theSocket, CONNECT_START2, strlen(CONNECT_START2), 0);
send(theSocket, szToonName, strlen(szToonName), 0);
send(theSocket, CONNECT_END, strlen(CONNECT_END), 0);
// DebugSpew("MQ2Eqbh Connected");
bConnected=true;
}
bTriedConnect=true;
bConnecting=false;
LeaveCriticalSection(&ConnectCS);
return 0;
}
void CheckSocket(char *szFunc, int err)
{
int werr = WSAGetLastError();
if (werr == WSAECONNABORTED)
{
bSocketGone = true;
}
WSASetLastError(0);
// DebugSpewAlways("Sock Error-%s: %d / w%d", szFunc, err, werr);
}
char *getCurPlayerName()
{
if (gGameState != GAMESTATE_INGAME) return NULL;
PCHARINFO pChar = GetCharInfo();
char *name = (pChar && pChar->Name) ? pChar->Name : NULL;
return name;
}
VOID SetPlayer()
{
char *pszName = getCurPlayerName();
strcpy(szToonName, (pszName) ? pszName : "YouPlayer");
sprintf(szToonCmdStart, "%s //", szToonName);
}
void WriteOut(char *szText)
{
WriteChatColor(szText);
return;
}
int WriteStringGetCount(CHAR *dest, CHAR *src)
{
int i=0;
for(; dest && src && *src; src++)
{
dest[i++] = *src;
}
return i;
}
void transmit(bool handleDisconnect, PCHAR szMsg)
{
if (bConnected)
{
int err = send(theSocket, szMsg, strlen(szMsg), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
if (handleDisconnect) CheckSocket("broadcast:send1", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
if (handleDisconnect) CheckSocket("broadcast:send2", err);
}
}
}
void echoTransmit(bool handleDisconnect, PCHAR szMsg)
{
CHAR szTemp[MAX_STRING];
sprintf(szTemp, "\ar#\ax %s", szMsg);
WriteOut(szTemp);
transmit(handleDisconnect, szMsg);
}
VOID HandleToggleRequest(int *piFlag, char *szProfName, char *szFlagDesc)
{
char szTemp[MAX_STRING];
*piFlag = (*piFlag) ? 0 : 1;
sprintf(szTemp,"\ar#\ax Setting: %s turned %s", szFlagDesc, (*piFlag) ? "ON" : "OFF");
WriteOut(szTemp);
sprintf(szTemp, "%d", (int)(*piFlag));
WritePrivateProfileString("Settings", szProfName, szTemp, INIFileName);
}
VOID HandleStatusRequest()
{
CHAR szTemp[MAX_STRING];
if (bConnected)
{
sprintf(szTemp,"\ar#\ax MQ2Eqbh Status: ONLINE - %s - %s", szServer, szPort);
WriteOut(szTemp);
}
else
{
WriteOut("\ar#\ax MQ2Eqbh Status: OFFLINE");
}
sprintf(szTemp,"\ar#\ax Allow Control: %s, Auto Connect: %s", (bAllowControl) ? "ON" : "OFF", (bAutoConnect) ? "ON" : "OFF");
WriteOut(szTemp);
sprintf(szTemp,"\ar#\ax IRC Compat Mode: %s, Reconnect: %s: (every %d secs)", (bIrcCompatMode) ? "ON" : "OFF", (bReconnectMode) ? "ON" : "OFF", iReconnectSeconds);
WriteOut(szTemp);
}
void HandleHelpRequest()
{
HandleStatusRequest();
WriteOut("\ar#\ax Commands Available");
WriteOut("\ar#\ax \ay/bhcmd connect <server> <port> <pw>\ax (defaults: 127.0.0.1 2112)");
WriteOut("\ar#\ax \ay/bhcmd quit\ax (disconnects)");
WriteOut("\ar#\ax \ay/bhcmd help\ax (show this screen)");
WriteOut("\ar#\ax \ay/bhcmd status\ax (show connected or not and settings)");
WriteOut("\ar#\ax \ay/bhcmd reconnect\ax (close current connection and connect again)");
WriteOut("\ar#\ax \ay/bhcmd colordump\ax (Shows all available color codes)");
WriteOut("\ar#\ax \ay/bhcmd togglecontrol\ax (allow remote control)");
WriteOut("\ar#\ax \ay/bhcmd togglewindow\ax (toggles use of dedicated window)");
WriteOut("\ar#\ax \ay/bhcmd togglecompatmode\ax (toggle IRC Compatability mode)");
WriteOut("\ar#\ax \ay/bhcmd toggleautoconnect\ax (toggle auto connect)");
WriteOut("\ar#\ax \ay/bhcmd togglereconnect\ax (toggle auto-reconnect mode on server disconnect)");
WriteOut("\ar#\ax \ay/bhcmd toggletellwatch\ax (toggle relay of tells received to /bh)");
WriteOut("\ar#\ax \ay/bhcmd toggleguildwatch\ax (toggle relay of guild chat to /bh)");
WriteOut("\ar#\ax \ay/bhcmd togglegroupwatch\ax (toggle relay of group chat to /bh)");
WriteOut("\ar#\ax \ay/bhcmd togglefswatch\ax (toggle relay of fellowship chat to /bh)");
WriteOut("\ar#\ax \ay/bhcmd togglesilentcmd\ax (toggle display of 'CMD: [command]' echo)");
WriteOut("\ar#\ax \ay/bhcmd togglesavebychar\ax (toggle saving UI data to [CharName] in INI)");
WriteOut("\ar#\ax \ay/bhcmd setreconnectsecs n\ax (n is seconds to reconnect: default 15)");
WriteOut("\ar#\ax \ay/bhcmd stopreconnect\ax (stop trying to reconnect for now)");
WriteOut("\ar#\ax \ay/bhcmd relog <charname>\ax (relog in as charname if you camp < 60 seconds): No charname resets");
WriteOut("\ar#\ax \ay/bhcmd channels <channel list>\ax (set list of channels to receive tells from)");
WriteOut("\ar#\ax \ay/bhcmd togglelocalecho\ax (toggle echoing my commands back to me if I am in channel)");
WriteOut("\ar#\ax \ay/bh your text\ax (send text)");
WriteOut("\ar#\ax \ay/bht ToonName your text\ax (send your text to specific Toon)");
WriteOut("\ar#\ax \ay/bht ToonName //command\ax (send Command to ToonName)");
WriteOut("\ar#\ax \ay/bha //command\ax (send Command to all connected names EXCLUDING yourself)");
WriteOut("\ar#\ax \ay/bhaa //command\ax (send Command to all connected names INCLUDING yourself)");
//Tim
//10/14/10
WriteOut("\ar#\ax \ay/bhcmd start (Starts the CH Rotation)");
WriteOut("\ar#\ax \ay/bhcmd start (Starts the CH Rotation)");
WriteOut("\ar#\ax \ay/bhcmd start (Starts the CH Rotation)");
WriteOut("\ar#\ax \ay/bhcmd start (Starts the CH Rotation)");
//End
}
void HandleConnectRequest(PCHAR szLine)
{
CHAR szMsg[MAX_STRING];
CHAR szIniServer[MAX_STRING] = {0};
CHAR szIniPort[MAX_STRING] = {0};
CHAR szIniPassword[MAX_PASSWORD] = {0};
if (bConnected)
{
WriteOut("\ar#\ax Already connected. Use /bhcmd quit to disconnect first.");
return;
}
if (bConnecting)
{
WriteOut("\ar#\ax Already trying to connect! Hold on a minute there");
return;
}
SetPlayer();
CHAR szArg1[MAX_STRING] = {0};
CHAR szArg2[MAX_STRING] = {0};
CHAR szArg3[MAX_STRING] = {0};
GetArg(szArg1, szLine, 2); // 1 was the connect statement.
GetArg(szArg2, szLine, 3);
GetArg(szArg3, szLine, 4);
GetPrivateProfileString("Last Connect", "Server", "127.0.0.1", szIniServer, MAX_STRING, INIFileName);
GetPrivateProfileString("Last Connect", "Port", "2112", szIniPort, MAX_STRING, INIFileName);
GetPrivateProfileString("Last Connect", "Password","", szIniPassword, MAX_STRING, INIFileName);
strcpy(szServer, (*szArg1) ? szArg1 : szIniServer);
strcpy(szPort, (*szArg2) ? szArg2 : szIniPort);
strcpy(szPassword, (*szArg3) ? szArg3 : szIniPassword);
sockVersion = MAKEWORD(1, 1);
WSAStartup(sockVersion, &wsaData);
hostEntry = gethostbyname(szServer);
if (!hostEntry)
{
WriteOut("\ar#\ax gethostbyname error");
WSACleanup();
return;
}
theSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (theSocket == INVALID_SOCKET) {
WriteOut("\ar#\ax Socket error");
WSACleanup();
return;
}
sprintf(szMsg, "\ar#\ax Connecting to %s %s...", szServer, szPort);
WriteOut(szMsg);
lastPingTime = 0;
serverInfo.sin_family = AF_INET;
serverInfo.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list);
serverInfo.sin_port = htons(atoi(szPort));
DWORD ThreadId;
CreateThread(NULL, 0, &EQBHConnectThread, 0, 0, &ThreadId);
return;
}
VOID HandleDisconnect(bool sendDisconnect)
{
if (bConnected)
{
bConnected = false;
// Could set linger off here..
if (sendDisconnect)
{
int err = send(theSocket, CMD_DISCONNECT, sizeof(CMD_DISCONNECT), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("HandleDisconnect:Send", err);
}
}
closesocket(theSocket);
lastReadBufPos = 0;
}
}
VOID HandleReconnectRequest()
{
HandleDisconnect(true);
HandleConnectRequest("");
}
VOID HandleVersionRequest()
{
CHAR szTemp[MAX_STRING];
sprintf(szTemp, "\ar#\ax %s", PROG_VERSION);
WriteOut(szTemp);
}
VOID HandleNamesRequest()
{
if (bConnected)
{
WriteOut("\ar#\ax Requesting names...");
int err = send(theSocket, CMD_NAMES, strlen(CMD_NAMES), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("HandleNamesRequest:send", err);
}
}
else
{
WriteOut("You are not connected");
}
}
VOID HandleChannels(PCHAR szLine)
{
CHAR szTemp[MAX_STRING]={0};
CHAR szTemp1[MAX_STRING]={0};
CHAR *szArg;
CHAR szCommand[] = CMD_CHANNELS;
int err;
if (!bConnected) {
WriteOut("\ar#\ax You are not connected. Please use \ag/bhcmd connect\ax to establish a connection.");
return;
}
char *playerName = (getCurPlayerName()) ? getCurPlayerName() : "Settings";
if (!szLine) {
GetPrivateProfileString(playerName, "Channels", "", szTemp1, MAX_STRING, INIFileName);
strlwr(szTemp1);
if (!(szArg=strtok(szTemp1, " \n"))) return;
} else {
strlwr(szLine);
szArg=strtok(szLine, " \n"); // first token will be command CHANNELS, skip it
szArg=strtok(NULL, " \n");
}
while(szArg!=NULL){
strncat(szTemp, szArg, MAX_STRING-1);
if ((szArg=strtok(NULL, " \n"))) strcat(szTemp, " ");
}
if (*playerName) WritePrivateProfileString(playerName, "Channels", szTemp, INIFileName);
err = send(theSocket, szCommand, strlen(szCommand), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleChannels:Send1", err);
}
err = send(theSocket, szTemp, strlen(szTemp), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleChannels:Send2", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleChannels:Send3", err);
}
}
VOID SendCmdLocalEcho()
{
CHAR szCommand[15];
int err;
sprintf(szCommand, "%s%i\n", CMD_LOCALECHO, bLocalEchoMode);
err = send(theSocket, szCommand, strlen(szCommand), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("SendCmdLocalEcho:Send1", err);
}
}
//Tim
//10/14/10
VOID HandleStartRotation() {
int err = send(theSocket, CMD_START, strlen(CMD_START), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleStartRotation:Send1", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleStartRotation:Send3", err);
}
}
VOID HandleStopRotation() {
int err = send(theSocket, CMD_STOP, strlen(CMD_STOP), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleStopRotation:Send1", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleStopRotation:Send3", err);
}
}
VOID HandleSetDelay(std::string newDelay) {
int err = send(theSocket, CMD_DELAY, strlen(CMD_DELAY), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleDelay:Send1", err);
}
err = send(theSocket, newDelay.c_str(), strlen(newDelay.c_str()), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleDelay:Send1", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleDelay:Send3", err);
}
}
VOID HandleSetTank(std::string newTank) {
int err = send(theSocket, CMD_TANK, strlen(CMD_TANK), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleTank:Send1", err);
}
err = send(theSocket, newTank.c_str(), strlen(newTank.c_str()), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleTank:Send1", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("HandleTank:Send3", err);
}
}
//End Tim
VOID BoxHChatCommand(PSPAWNINFO pChar, PCHAR szLine)
{
static CHAR szCommandConnect[] = "connect";
static CHAR szCommandDisconnect[] = "quit";
static CHAR szCommandHelp[] = "help";
static CHAR szCommandStatus[] = "status";
static CHAR szCommandReconnect[] = "reconnect";
static CHAR szCommandNames[] = "names";
static CHAR szCommandToggleAutoConnect[] = "toggleautoconnect";
static CHAR szCommandToggleControl[] = "togglecontrol";
static CHAR szCommandToggleCompatMode[] = "togglecompatmode";
static CHAR szCommandToggleReconnect[] = "togglereconnect";
static CHAR szCommandToggleWindow[] = "togglewindow";
static CHAR szCommandStopReconnect[] = "stopreconnect";
static CHAR szCommandSetReconnect[] = "setreconnectsecs";
static CHAR szCommandRelog[] = "relog";
static CHAR szCommandVersion[] = "version";
static CHAR szCommandColorDump[] = "colordump";
static CHAR szCommandChannels[] = "channels";
static CHAR szCommandToggleLocalEcho[] = "togglelocalecho";
static CHAR szCommandToggleTellWatch[] = "toggletellwatch";
static CHAR szCommandToggleGuildWatch[] = "toggleguildwatch";
static CHAR szCommandToggleGroupWatch[] = "togglegroupwatch";
static CHAR szCommandToggleFSWatch[] = "togglefswatch";
static CHAR szCommandToggleSilentCmd[] = "togglesilentcmd";
static CHAR szCommandToggleSaveByChar[] = "togglesavebychar";
//Tim
//10/14/10
static CHAR szCommandStartRotation[] = "start";
static CHAR szCommandStopRotation[] = "stop";
static CHAR szCommandSetDelay[] = "delay";
static CHAR szCommandSetTank[] = "tank";
//End Tim
CHAR szArg[MAX_STRING] = {0};
CHAR szMsg[MAX_STRING]={0};
//sprintf(szMsg, "BCCMD: %s", szLine);
//WriteOut(szMsg);
GetArg(szArg, szLine, 1);
if (stricmp(szCommandConnect, szArg) == 0)
{
HandleConnectRequest(szLine);
}
else if (stricmp(szCommandDisconnect, szArg) == 0)
{
HandleDisconnect(true);
WriteOut("\ar#\ax Connection Closed, you can unload MQ2Eqbh now.");
}
else if (stricmp(szCommandStatus, szArg) == 0)
{
HandleStatusRequest();
}
else if (stricmp(szCommandHelp, szArg) == 0)
{
HandleHelpRequest();
}
else if (stricmp(szCommandNames, szArg) == 0)
{
HandleNamesRequest();
}
else if (stricmp(szCommandReconnect, szArg) == 0)
{
HandleReconnectRequest();
}
else if (stricmp(szCommandToggleControl, szArg) == 0)
{
HandleToggleRequest(&bAllowControl, "AllowControl", "Allow Control");
}
else if (stricmp(szCommandToggleAutoConnect, szArg) == 0)
{
HandleToggleRequest(&bAutoConnect, "AutoConnect", "Auto Connect");
}
else if (stricmp(szCommandToggleCompatMode, szArg) == 0)
{
HandleToggleRequest(&bIrcCompatMode, "IRCCompatMode", "IRC Compat Mode");
}
else if (stricmp(szCommandToggleReconnect, szArg) == 0)
{
HandleToggleRequest(&bReconnectMode, "AutoReconnect", "Auto Reconnect (on remote disconnect)");
}
else if (stricmp(szCommandRelog, szArg) == 0)
{
GetArg(szArg, szLine, 2);
if (reloginBeforeSecs && *szArg == 0)
{
sprintf(szMsg, "Aborting relog to [%s], you must cancel /camp.", szToonToRelog);
echoTransmit(true, szMsg);
reloginBeforeSecs = 0;
*szToonToRelog = 0;
}
else if (*szArg != 0)
{
strcpy(szToonToRelog, szArg);
reloginBeforeSecs = (GetTickCount() / 1000) + 60;
sprintf(szMsg, "Now logging in as [%s], %s must /camp and reach Character Selection in 60 seconds.", szToonToRelog, szToonName);
echoTransmit(true, szMsg);
}
}
else if (stricmp(szCommandStopReconnect, szArg) == 0)
{
if (lastReconnectTimeSecs == 0)
{
WriteOut("\ar#\ax You are not trying to reconnect");
}
else
{
WriteOut("\ar#\ax Disabling reconnect mode for now.");
lastReconnectTimeSecs = 0;
}
}
else if (stricmp(szCommandSetReconnect, szArg) == 0)
{
GetArg(szArg, szLine, 2);
if (*szArg && atoi(szArg) > 0)
{
iReconnectSeconds = atoi(szArg);
sprintf(szMsg, "%d", iReconnectSeconds);
WritePrivateProfileString("Settings", "ReconnectRetrySeconds", szMsg, INIFileName);
sprintf(szMsg, "\ar#\ax Will now try to reconnect every %d seconds after server disconnect.", iReconnectSeconds);
}
else
{
sprintf(szMsg, "\ar#\ax Invalid value given - proper example: /bhcmd setreconnectsecs 15");
}
WriteOut(szMsg);
}
else if (stricmp(szCommandColorDump, szArg) == 0)
{
CHAR ch;
int i;
strcpy(szMsg, "\ar#\ax Bright Colors:");
for (i=0; i < (int)strlen(szColorChars)-1; i++)
{
ch = szColorChars[i];
sprintf(szArg, " \a%c[+%c+]", ch, ch);
strcat(szMsg, szArg);
}
WriteOut(szMsg);
strcpy(szMsg, "\ar#\ax Dark Colors:");
for (i=0; i < (int)strlen(szColorChars)-1; i++)
{
ch = szColorChars[i];
sprintf(szArg, " \a-%c[+%c+]", ch, toupper(ch));
strcat(szMsg, szArg);
}
WriteOut(szMsg);
WriteOut("\ar#\ax [+x+] and [+X+] set back to default color.");
}
else if (stricmp(szCommandVersion, szArg) == 0)
{
sprintf(szMsg, "\ar#\ax %s", PROG_VERSION);
WriteOut(szMsg);
}
else if (stricmp(szCommandChannels, szArg) == 0)
{
HandleChannels(szLine);
}
else if (stricmp(szCommandToggleLocalEcho, szArg) == 0)
{
HandleToggleRequest(&bLocalEchoMode, "LocalEcho", "Echo my channel commands back to me");
SendCmdLocalEcho();
}
else if (stricmp(szCommandToggleTellWatch, szArg) == 0)
{
HandleToggleRequest(&bDoTellWatch, "TellWatch", "'Relay all tells to /bh'");
}
else if (stricmp(szCommandToggleGuildWatch, szArg) == 0)
{
HandleToggleRequest(&bDoGuildWatch, "GuildWatch", "'Relay guild chat to /bh'");
}
else if (stricmp(szCommandToggleGroupWatch, szArg) == 0)
{
HandleToggleRequest(&bDoGroupWatch, "GroupWatch", "'Relay group chat to /bh'");
}
else if (stricmp(szCommandToggleFSWatch, szArg) == 0)
{
HandleToggleRequest(&bDoFSWatch, "FSWatch", "'Relay fellowship chat to /bh'");
}
else if (stricmp(szCommandToggleSilentCmd, szArg) == 0)
{
HandleToggleRequest(&bSilentCmd, "SilentCmd", "Silence 'CMD: [command]' echo");
}
else if (stricmp(szCommandToggleSaveByChar, szArg) == 0)
{
HandleToggleRequest(&bSaveCharacter, "SaveByCharacter", "Save UI data by character name");
}
//Tim
//10/14/10
else if (stricmp(szCommandStartRotation, szArg) == 0) {
HandleStartRotation();
WriteChatColor("Starting rotation.");
} else if (stricmp(szCommandStopRotation, szArg) == 0) {
HandleStopRotation();
WriteChatColor("Stopping rotation.");
} else if (stricmp(szCommandSetDelay, szArg) == 0) {
GetArg(szArg, szLine, 2);
char szTemp[MAX_STRING] = {0};
sprintf(szTemp, "New delay is:%s", szArg);
WriteChatColor(szTemp);
std::string delay = szArg;
HandleSetDelay(delay);
} else if (stricmp(szCommandSetTank, szArg) == 0) {
GetArg(szArg, szLine, 2);
char szTemp[MAX_STRING] = {0};
sprintf(szTemp, "New tank is:%s", szArg);
WriteChatColor(szTemp);
std::string tank = szArg;
HandleSetTank(tank);
}
//End Tim
else
{
sprintf(szMsg, "\ar#\ax Unsupported command, supported commands are: %s", SUPPORTED_COMMANDS);
WriteOut(szMsg);
}
}
// BoxChatSay
VOID BoxHChatSay(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szMsg[MAX_STRING]={0};
int err;
if (!bConnected) {
WriteOut("\ar#\ax You are not connected. Please use \ag/bhcmd connect\ax to establish a connection.");
return;
}
if (szLine && strlen(szLine))
{
err = send(theSocket, szLine, strlen(szLine), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("BoxChatSay:Send1", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("BoxChatSay:Send2", err);
}
}
}
// BoxChatTell
VOID BoxHChatTell(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szTemp[MAX_STRING]={0};
int i_src=0;
int i_dest=0;
int i_len;
CHAR szCommand[] = CMD_TELL;
int err;
if (!bConnected) {
WriteOut("\ar#\ax You are not connected. Please use \ag/bhcmd connect\ax to establish a connection.");
return;
}
if (szLine && strlen(szLine)) {
err = send(theSocket, szCommand, strlen(szCommand), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("BoxChatTell:Send1", err);
}
err = send(theSocket, szLine, strlen(szLine), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("BoxChatTell:Send2", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("BoxChatTell:Send3", err);
}
if (bIrcCompatMode) {
i_len=strlen(szLine);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_STELL1);
while (szLine[i_src]!=' ' && szLine[i_src]!='\n' && i_src <= i_len) {
szTemp[i_dest++]=szLine[i_src++];
}
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_STELL2);
i_src++;
while (i_src <= i_len) {
szTemp[i_dest++]=szLine[i_src++];
}
szTemp[i_dest]='\n';
WriteOut(szTemp);
}
}
}
void BciTransmit(char *szLine, char *szCmd)
{
CHAR szCommand[] = CMD_BCI;
int err;
strcat(szLine, " ");
strcat(szLine, szCmd);
if (szLine && strlen(szLine))
{
err = send(theSocket, szCommand, strlen(szCommand), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("BciTransmit:Send1", err);
}
err = send(theSocket, szLine, strlen(szLine), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("BciTransmit:Send2", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("BciTransmit:Send3", err);
}
}
}
VOID BoxHChatAllButMe(PSPAWNINFO pChar, PCHAR szLine)
{
CHAR szCommand[] = CMD_MSGALL;
CHAR szMsg[MAX_STRING]={0};
int err;
if (!bConnected) {
WriteOut("\ar#\ax You are not connected. Please use \ag/bhcmd connect\ax to establish a connection.");
return;
}
if (szLine && strlen(szLine))
{
err = send(theSocket, szCommand, strlen(szCommand), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("BoxChatSayAll:Send1", err);
}
err = send(theSocket, szLine, strlen(szLine), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("BoxChatSayAll:Send2", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK))
{
CheckSocket("BoxChatSayAll:Send3", err);
}
}
}
VOID BoxHChatAll(PSPAWNINFO pChar, PCHAR szLine)
{
BoxHChatAllButMe(pChar, szLine);
CHAR szTemp[ MAX_STRING ];
sprintf(szTemp, "<%s> %s %s", pChar->Name, pChar->Name, szLine);
bForceCmd = true;
HandleIncomingString(szTemp);
bForceCmd = false;
}
char getColorCharFromCode(CHAR *test)
{
// Colors From MQToSTML (already assigned here to szColorChars)
// 'y'ellow, 'o'range, 'g'reen, bl'u'e, 'r'ed, 't'eal, 'b'lack (none),
// 'm'agenta, 'p'urple, 'w'hite, 'x'=back to default
// Color code format: "[+r+]"
if ( test[0] == '[' &&
test[1] == '+' &&
test[2] != '\0' &&
test[3] == '+' &&
test[4] == ']')
{
if (strchr(szColorChars, (int)tolower(test[2])))
{
return test[2];
}
}
return 0;
}
void strCleanEnd(PCHAR pszStr)
{
// Remove trailing spaces and CR/LF's
int len;
if (pszStr && *pszStr)
{
for (len = strlen(pszStr)-1;
len >= 0 && strchr(" \r\n", pszStr[len]);
pszStr[len--]=0);
}
}
void HandleIncomingCommand(PCHAR pszCmd)
{
CHAR szTemp[MAX_STRING] = {0};
CHAR *szAllowed = (bAllowControl || bForceCmd) ? "" : " - Not allowed (Control turned off)";
sprintf(szTemp, "\ar#\ax CMD: [%s]%s", pszCmd, szAllowed);
if (!bSilentCmd) WriteOut(szTemp);
if (bAllowControl == false)
{
if (!bForceCmd)
{
return;
}
}
sprintf(szTemp, pszCmd);
strCleanEnd(szTemp);
PCHARINFO pCharInfo=GetCharInfo();
PSPAWNINFO pSpawn=(PSPAWNINFO)pCharSpawn;
if (pCharInfo) pSpawn=pCharInfo->pSpawn;
if (pSpawn)
{
DoCommand((PSPAWNINFO)pSpawn,szTemp);
}
bForceCmd = false;
}
void HandleControlMessage(PCHAR rawmsg)
{
// DebugSpew("HandleIncomingMessage Start()");
if (!strncmp(rawmsg, "PING", 4))
{
lastPingTime = clock();
transmit(true, CMD_PONG);
}
// DebugSpew("HandleIncomingMessage End()");
}
void HandleIncomingString(PCHAR rawmsg)
{
CHAR szTemp[MAX_STRING] = {0};
CHAR lastChar = 0;
int i_src = 0;
int i_dest = 0;
int msgCharCount = -1;
int msgTell = 0;
CHAR colorCh=0;
boolean isSysMsg = false;
PCHAR pszCmdStart = NULL;
bool bBciCmd = false;
// DebugSpew("HandleIncomingMsg: %s", rawmsg);
if (!rawmsg) return;
isSysMsg = (*rawmsg == '-');
//Tim: Added 9/22/10
//WriteChatColor("RAW:");
//WriteChatColor(rawmsg);
std::string msg = rawmsg;
if(msg.find("<GVAR>") != std::string.npos) {
WriteChatColor("GLOBAL VAR RECIEVED!");
HandleGlobalVar(msg);
return;
}
//End Add
if (*rawmsg == '\t')
{
HandleControlMessage(rawmsg + 1);
return;
}
while (rawmsg[i_src] != 0 && i_dest < (MAX_STRING-1))
{
if (i_src == 0 && isSysMsg) // first char
{
i_dest += WriteStringGetCount(&szTemp[i_dest], "\ar#\ax ");
lastChar = *rawmsg;
msgCharCount=1;
}
else if (lastChar != ' ' || rawmsg[i_src] != ' ') // Do not add extra spaces
{
if (msgCharCount <= 1 && strnicmp(&rawmsg[i_src], szToonCmdStart, strlen(szToonCmdStart)) == 0)
{
pszCmdStart = &rawmsg[i_src + strlen(szToonCmdStart) - 1];
}
if (msgCharCount <=1 && msgTell==1 && strnicmp(&rawmsg[i_src], "//", 2) == 0)
{
pszCmdStart = &rawmsg[i_src + 1];
}
if (msgCharCount <=1 && bBciCmd)
{
pszCmdStart = &rawmsg[i_src];
}
if (msgCharCount >= 0)
{
msgCharCount++;
// if not in cmdMode and have room, check for colorCode.
if (pszCmdStart == NULL && (colorCh = getColorCharFromCode(&rawmsg[i_src])) != 0 && (i_dest + (isupper(colorCh) ? 5 : 4)) < MAX_STRING)
{
//DebugSpewAlways("Got Color: %c", colorCh);
boolean bDark = isupper(colorCh);
szTemp[i_dest++] = '\a';
if (bDark) szTemp[i_dest++] = '-';
szTemp[i_dest++] = tolower(colorCh);
lastChar = '\a'; // Something that should not exist otherwise
i_src += 4; // Color code format is [+x+] - 5 characters.
}
else
{
lastChar = szTemp[i_dest] = rawmsg[i_src];
i_dest++;
}
}
else if (isSysMsg == false)
{
switch (rawmsg[i_src])
{
case '<':
{
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME_BRACKET);
szTemp[i_dest++] = (bIrcCompatMode) ? '<' : '>';
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME);
break;
}
case '>':
{
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME_BRACKET);
szTemp[i_dest++] = (bIrcCompatMode) ? '>' : '<';
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
msgCharCount = 0;
break;
}
case '[':
{
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME_BRACKET);
szTemp[i_dest++] = '[';
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME);
break;
}
case ']':
{
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME_BRACKET);
if (bIrcCompatMode) {
szTemp[i_dest++] = '(';
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME);
i_dest += WriteStringGetCount(&szTemp[i_dest], "msg");
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_NAME_BRACKET);
i_dest += WriteStringGetCount(&szTemp[i_dest], ")]");
} else {
szTemp[i_dest++] = ']';
}
i_dest += WriteStringGetCount(&szTemp[i_dest], COLOR_OFF);
msgCharCount = 0;
msgTell=1;
break;
}
case '{':
break;
case '}':
i_dest++;
msgCharCount = 0;
bBciCmd = true;
break;
default:
{
lastChar = szTemp[i_dest] = rawmsg[i_src];
i_dest++;
break;
}
}
}
}
i_src++;
}
if (pszCmdStart)
{
if(bBciCmd)
{
return;
}
HandleIncomingCommand(pszCmdStart);
}
// DebugSpew("Writing incoming");
WriteOut(szTemp);
// DebugSpew("HandleIncomingMessage finish");
}
void TryRelogin()
{
CHAR szMsg[MAX_STRING];
if (reloginBeforeSecs == 0) return;
if (reloginBeforeSecs < (GetTickCount() / 1000))
{
// timed out
sprintf(szMsg, "Failed to reach character select in time to relog as [%s]", szToonToRelog);
echoTransmit(false, szMsg);
reloginBeforeSecs = 0;
*szToonToRelog = 0;
return;
}
if (*szToonToRelog == 0)
{
reloginBeforeSecs = 0;
return;
}
}
//Tim: 9/22/10
/********************************************************************************
*********************************************************************************
BEGIN TYPE VERIFICATION
*********************************************************************************
********************************************************************************/
bool StringIsInt(std::string value) {
std::istringstream iss(value);
int integer = 0;
if(!(iss >> integer))
return false;
else
return true;
}
int StringToInt(std::string value) {
std::istringstream iss(value);
int integer = 0;
if(!(iss >> integer))
return false;
else
return integer;
}
bool StringIsFloat(std::string value) {
std::istringstream iss(value);
float floating = 0;
if(!(iss >> floating))
return false;
else
return true;
}
float StringToFloat(std::string value) {
std::istringstream iss(value);
float floating = 0;
if(!(iss >> floating))
return false;
else
return floating;
}
bool StringIsBool(std::string value) {
if(value == "true" || value == "TRUE" || value == "false" || value == "FALSE" || value == "null" || value == "NULL")
return true;
return false;
}
bool StringToBool(std::string value) {
if(value == "true" || value == "TRUE")
return true;
return false;
}
/*****************************
******************************
END TYPE VERIFICATION
******************************
*****************************/
//class MQ2GlobalBHValType *pGlobalBHValType = 0;
class MQ2GlobalBHVarType *pGlobalBHVarType = 0;
/* variables used */
map<std::string, std::string> globals;
const std::string DELETE_STR = "delete";
const std::string SET_STR = "set";
typedef pair<std::string, std::string> value_type;
typedef map<std::string, std::string>::iterator iter_type;
void sendGlobalVarPacket(std::string variable, std::string value, std::string action);
/* function to get a val for a variable */
std::string getValByVarName(std::string variable) {
/*
char szTemp[1024];
sprintf(szTemp, "GET:[%s]", variable.c_str());
WriteChatColor(szTemp);
*/
iter_type it = globals.find(variable);
if(it == globals.end())
return "";
return it->second;
}
/* function to set a val for a variable */
void setValByVarName(std::string variable, std::string value, bool sendUpdate = true) {
/*
char szTemp[1024];
sprintf(szTemp, "SET:[%s][%s]", variable.c_str(), value.c_str());
WriteChatColor(szTemp);
*/
bool bFound = false;
iter_type it = globals.begin();
while(it != globals.end()) {
if(it->first == variable) {
it->second = value;
bFound = true;
break;
} else {
++it;
}
}
if(!bFound) {
value_type global;
global.first = variable;
global.second = value;
globals.insert(global);
}
if(sendUpdate)
sendGlobalVarPacket(variable, value, SET_STR);
}
/* function to declare a variable */
void declareVar(std::string variable) {
/*
char szTemp[1024];
sprintf(szTemp, "DECLARE:[%s]", variable.c_str());
WriteChatColor(szTemp);
*/
std::string value = "null";
value_type global;
global.first = variable;
global.second = value;
globals.insert(global);
sendGlobalVarPacket(variable, value, SET_STR);
}
/* function to delete a variable */
bool deleteVarByName(std::string variable, bool sendUpdate = true) {
/*
char szTemp[1024];
sprintf(szTemp, "DELETE:[%s]", variable.c_str());
WriteChatColor(szTemp);
*/
bool bFound = false;
iter_type it = globals.begin();
value_type deleted;
while(it != globals.end()) {
if(it->first == variable) {
deleted.first = it->first;
deleted.second = it->second;
globals.erase(it);
bFound = true;
break;
} else {
++it;
}
}
if(bFound) {
if(sendUpdate)
sendGlobalVarPacket(deleted.first, deleted.second, DELETE_STR);
return true;
}
return false;
}
/*
{GlobalVarName}{GlobalVarVal}{Action}
Action can be:set, delete
*/
void HandleGlobalVar(std::string line) {
/*
char szTemp[1024];
sprintf(szTemp, "GLOBAL:%s", line.c_str());
WriteChatColor(szTemp);
*/
std::string variable, value, action;
value_type varSet;
bool bCopy = false;
int varCount = 1;
for(int i = 0; i < line.length(); ++i) {
if(line[i] == '{')
bCopy = true;
else if(line[i] == '}') {
bCopy = false;
++varCount;
} else if(bCopy) {
if(varCount == 1)
variable += line[i];
else if(varCount == 2)
value += line[i];
else if(varCount == 3)
action += line[i];
}
}
varSet.first = variable;
varSet.second = value;
/*
sprintf(szTemp, "VAR:[%s]", variable.c_str());
WriteChatColor(szTemp);
sprintf(szTemp, "VALUE:[%s]", value.c_str());
WriteChatColor(szTemp);
sprintf(szTemp, "ACTION:[%s]", action.c_str());
WriteChatColor(szTemp);
*/
if(action == SET_STR)
setValByVarName(varSet.first, varSet.second, false);
else if(action == DELETE_STR)
deleteVarByName(varSet.first, false);
}
bool GlobalVarExists(PCHAR szName) {
iter_type it;
std::string name = szName;
for(it = globals.begin(); it != globals.end(); ++it) {
if(name == it->first)
return true;
}
return false;
}
void DeleteGlobalVars() {
globals.clear();
}
/*
Action can be:set, delete
*/
void sendGlobalVarPacket(std::string variable, std::string value, std::string action) {
/*
char szTemp[1024];
sprintf(szTemp, "SENDING:[%s][%s][%s]", variable.c_str(), value.c_str(), action.c_str());
WriteChatColor(szTemp);
*/
char szBuff[1024] = {0};
CHAR szCommand[] = CMD_GVAR;
std::string packet;
if(GetCharInfo()->pSpawn) {
sprintf(szBuff, "{%s}{%s}{%s}", variable.c_str(), value.c_str(), action.c_str());
int err;
err = send(theSocket, szCommand, strlen(szCommand), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("GlobalVar:Send1", err);
}
err = send(theSocket, szBuff, strlen(szBuff), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("GlobalVar:Send2", err);
}
err = send(theSocket, SEND_LINE_TERM, strlen(SEND_LINE_TERM), 0);
if (err == SOCKET_ERROR || (err == 0 && WSAGetLastError() != WSAEWOULDBLOCK)) {
CheckSocket("GlobalVar:Send3", err);
}
}
}
class MQ2GlobalBHVarType : public MQ2Type {
private:
std::string variable, value;
public:
enum GlobalBHVarMembers {
GetVal=1,
SetVal=2,
Delete=3
};
MQ2GlobalBHVarType(std::string var, std::string val):MQ2Type("GlobalBHVar") {
TypeMember(GetVal);
TypeMember(SetVal);
TypeMember(Delete);
variable = var;
value = val;
}
MQ2GlobalBHVarType():MQ2Type("GlobalBHVar") {
TypeMember(GetVal);
TypeMember(SetVal);
TypeMember(Delete);
}
~MQ2GlobalBHVarType() {}
void setVar(std::string var) {
variable = var;
}
void setVal(std::string val) {
value = val;
}
bool GetMember(MQ2VARPTR VarPtr, PCHAR Member, PCHAR Index, MQ2TYPEVAR &Dest) {
PMQ2TYPEMEMBER pMember=MQ2GlobalBHVarType::FindMember(Member);
if (!pMember)
return false;
switch((GlobalBHVarMembers)pMember->ID) {
case GetVal:
if (StringIsInt(value)) {
Dest.Int = StringToInt(value);
Dest.Type = pIntType;
} else if(StringIsFloat(value)) {
Dest.Float = StringToFloat(value);
Dest.Type = pFloatType;
} else if (StringIsBool(value)) {
Dest.DWord = StringToBool(value);
Dest.Type = pBoolType;
} else {
strcpy(DataTypeTemp, value.c_str());
Dest.Ptr = DataTypeTemp;
Dest.Type = pStringType;
}
return true;
case SetVal:
setValByVarName(variable, Index);
strcpy(DataTypeTemp, Index);
value = Index;
if (StringIsInt(value)) {
Dest.Int = StringToInt(value);
Dest.Type = pIntType;
} else if(StringIsFloat(value)) {
Dest.Float = StringToFloat(value);
Dest.Type = pFloatType;
} else if (StringIsBool(value)) {
Dest.DWord = StringToBool(value);
Dest.Type = pBoolType;
} else {
strcpy(DataTypeTemp, value.c_str());
Dest.Ptr = DataTypeTemp;
Dest.Type = pStringType;
}
return true;
case Delete:
if(deleteVarByName(variable))
Dest.DWord = true;
else
Dest.DWord = false;
Dest.Type = pBoolType;
return true;
}
return false;
}
bool ToString(MQ2VARPTR VarPtr, PCHAR Destination) {
if(value.length() > 0)
strcpy(Destination, value.c_str());
else
strcpy(Destination, "NULL");
return true;
}
bool FromData(MQ2VARPTR &VarPtr, MQ2TYPEVAR &Source) {
return false;
}
bool FromString(MQ2VARPTR &VarPtr, PCHAR Source) {
return false;
}
};
BOOL dataGlobalVar(PCHAR szName, MQ2TYPEVAR &Ret) {
Ret.DWord = true;
Ret.Type = pGlobalBHVarType;
if(!GlobalVarExists(szName)) {
//create the variable
declareVar(szName);
}
pGlobalBHVarType->setVal(getValByVarName(szName));
pGlobalBHVarType->setVar(szName);
return true;
}
//End Tim 9/22/10
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
CHAR szTemp[MAX_STRING] = {0};
DebugSpewAlways("Initializing MQ2Eqbh");
AddCommand("/bh", BoxHChatSay);
AddCommand("/bht", BoxHChatTell);
AddCommand("/bha", BoxHChatAllButMe);
AddCommand("/bhaa", BoxHChatAll);
AddCommand("/bhcmd", BoxHChatCommand);
//Tim: 9/22/10
pGlobalBHVarType = new MQ2GlobalBHVarType;
AddMQ2Data("GlobalsBH", dataGlobalVar);
//End Tim
pEQBHType= new EQBHType;
AddMQ2Data("EQBH",dataEQBH);
GetPrivateProfileString("Last Connect", "Server", "127.0.0.1", szServer, MAX_STRING, INIFileName);
GetPrivateProfileString("Last Connect", "Port", "2112", szPort, MAX_STRING, INIFileName);
bAutoConnect = GetPrivateProfileInt("Settings", "AutoConnect", 0, INIFileName);
bAllowControl = GetPrivateProfileInt("Settings", "AllowControl", 1, INIFileName);
bSilentCmd = GetPrivateProfileInt("Settings", "SilentCmd", 0, INIFileName);
bDoTellWatch = GetPrivateProfileInt("Settings", "TellWatch", 0, INIFileName);
bDoGuildWatch = GetPrivateProfileInt("Settings", "GuildWatch", 0, INIFileName);
bDoGroupWatch = GetPrivateProfileInt("Settings", "GroupWatch", 0, INIFileName);
bDoFSWatch = GetPrivateProfileInt("Settings", "FSWatch", 0, INIFileName);
bIrcCompatMode = GetPrivateProfileInt("Settings", "IRCCompatMode", 1, INIFileName);
bReconnectMode = GetPrivateProfileInt("Settings","AutoReconnect",1,INIFileName);
iReconnectSeconds = GetPrivateProfileInt("Settings", "ReconnectRetrySeconds", 15, INIFileName);
bUseWindow = GetPrivateProfileInt("Settings", "UseWindow", 0, INIFileName);
bLocalEchoMode = GetPrivateProfileInt("Settings", "LocalEcho", 1, INIFileName);
bSaveCharacter = GetPrivateProfileInt("Settings", "SaveByCharacter", 1, INIFileName);
SetPlayer();
sprintf(szTemp, "\ar#\ax Welcome to \ayMQ2Eqbh\ax, %s: Use \ar/bhcmd help\ax to see help.", szToonName);
WriteChatColor(szTemp);
//WriteOut(szTemp);
InitializeCriticalSection(&ConnectCS);
}
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
DebugSpewAlways("Shutting down MQ2Eqbh");
if (bConnected)
{
WriteChatColor("\ar#\ax You are still connected! Attempting to disconnect.");
DebugSpewAlways("MQ2Eqbh::Still Connected::Attempting disconnect.");
HandleDisconnect(false);
}
RemoveCommand("/bh");
RemoveCommand("/bht");
RemoveCommand("/bha");
RemoveCommand("/bhaa");
RemoveCommand("/bhcmd");
RemoveMQ2Data("EQBH");
delete pEQBHType;
//Tim: 9/22/10
RemoveMQ2Data("GlobalsBH");
delete pGlobalBHVarType;
if(globals.size() > 0)
globals.clear();
//End Tim
// make sure we're not trying to connect...
EnterCriticalSection(&ConnectCS);
LeaveCriticalSection(&ConnectCS);
DeleteCriticalSection(&ConnectCS);
}
// This is called every time MQ pulses
PLUGIN_API VOID OnPulse(VOID)
{
int err;
if (bTriedConnect)
{
bTriedConnect=false;
if (bConnected)
{
WriteOut("\ar#\ax Connected!");
WritePrivateProfileString("Last Connect", "Server", szServer, INIFileName);
WritePrivateProfileString("Last Connect", "Port", szPort, INIFileName);
lastReadBufPos = 0;
lastReconnectTimeSecs = 0;
HandleChannels(NULL);
SendCmdLocalEcho();
}
else
{
WriteOut("\ar#\ax Could not connect.");
}
}
// Fill the input buffer with new data, if any.
if (bConnected)
{
for (;lastReadBufPos<(MAX_READBUF-1);lastReadBufPos++)
{
err = recv(theSocket, &ireadbuf[lastReadBufPos], 1, 0);
if ((ireadbuf[lastReadBufPos] == '\n') || (err == 0) || (err == SOCKET_ERROR))
{
if (ireadbuf[lastReadBufPos] == '\n')
{
ireadbuf[lastReadBufPos] = '\0';
HandleIncomingString(ireadbuf);
lastReadBufPos = -1;
}
//break;
}
if (err == 0 || err == SOCKET_ERROR) break;
}
if (lastReadBufPos < 0) lastReadBufPos = 0;
if (err == 0 && WSAGetLastError() == 0)
{
// Should be giving WSAWOULDBLOCK
bSocketGone = true;
}
if (bSocketGone)
{
bSocketGone = false;
HandleIncomingString("-- Remote connection closed, you are no longer connected");
HandleDisconnect(false);
if (bReconnectMode && iReconnectSeconds > 0)
{
lastReconnectTimeSecs = GetTickCount()/1000;
}
}
if ( lastPingTime > 0 && lastPingTime + 120000 < clock() )
{
WriteChatf( "\arMQ2EQBH: did not recieve expected ping from server, pinging..." );
transmit( true, CMD_PONG );
lastPingTime = 0;
}
}
else if (lastReconnectTimeSecs > 0 && bConnecting == false)
{
if (lastReconnectTimeSecs + iReconnectSeconds < GetTickCount()/1000)
{
lastReconnectTimeSecs = GetTickCount()/1000;
HandleConnectRequest("");
}
}
if (reloginBeforeSecs)
{
TryRelogin();
}
}
PLUGIN_API VOID SetGameState(DWORD GameState)
{
if (GameState==GAMESTATE_INGAME && !bConnected)
{
if (bAutoConnect && !bConnected)
{
SetPlayer();
HandleConnectRequest("");
}
}
else if (bConnected && GameState==GAMESTATE_CHARSELECT)
{
if (reloginBeforeSecs == 0)
{
HandleDisconnect(true);
}
}
}
PLUGIN_API DWORD OnIncomingChat(PCHAR Line, DWORD Color)
{
PSPAWNINFO pChar = (PSPAWNINFO)pCharSpawn;
if (!pChar)
{
return 0;
}
if (bConnected)
{
CHAR szSender[MAX_STRING];
CHAR szTell[MAX_STRING];
CHAR szBCMSG[MAX_STRING];
PSTR Text;
if (bDoTellWatch && Color == USERCOLOR_TELL)
{
GetArg(szSender, Line, 1);
Text = GetNextArg(Line, 1, FALSE, '\'');
strcpy(szTell, Text);
szTell[strlen(Text)-1] = '\0';
sprintf(szBCMSG, "Tell received from %s: %s", szSender, szTell);
BoxHChatSay(pChar, szBCMSG);
return 0;
}
if (bDoGuildWatch && Color == USERCOLOR_GUILD)
{
GetArg(szSender, Line, 1);
Text = GetNextArg(Line, 1, FALSE, '\'');
strcpy(szTell, Text);
szTell[strlen(Text)-1] = '\0';
sprintf(szBCMSG, "Guild chat from %s: %s", szSender, szTell);
BoxHChatSay(pChar, szBCMSG);
return 0;
}
if (bDoGroupWatch && Color == USERCOLOR_GROUP)
{
GetArg(szSender, Line, 1);
Text = GetNextArg(Line, 1, FALSE, '\'');
strcpy(szTell, Text);
szTell[strlen(Text)-1] = '\0';
sprintf(szBCMSG, "Group chat from %s: %s", szSender, szTell);
BoxHChatSay(pChar, szBCMSG);
return 0;
}
}
return 0;
}
// ---------- EQBHType Methods
EQBHType::EQBHType():MQ2Type("EQBH")
{
TypeMember(Connected);
}
EQBHType::~EQBHType() { }
bool EQBHType::GetMember(MQ2VARPTR VarPtr, PCHAR Member, PCHAR Index, MQ2TYPEVAR &Dest)
{
PMQ2TYPEMEMBER pMember=EQBHType::FindMember(Member);
if(!pMember) return false;
switch((VarMembers)pMember->ID)
{
case Connected:
Dest.DWord=bConnected;
Dest.Type=pBoolType;
return true;
}
return false;
}
bool EQBHType::ToString(MQ2VARPTR VarPtr, PCHAR Destination)
{
strcpy(Destination,"EQBH");
return true;
}
bool EQBHType::FromData(MQ2VARPTR &VarPtr, MQ2TYPEVAR &Source)
{
return false;
}
bool EQBHType::FromString(MQ2VARPTR &VarPtr, PCHAR Source)
{
return false;
}
PLUGIN_API WORD isConnected(void)
{
return (WORD)bConnected;
}
| [
"[email protected]@39408780-f958-9dab-a28b-4b240efc9052"
]
| [
[
[
1,
1875
]
]
]
|
8e90ec2a664743e2ea55bf072a64f9f9dbde3df2 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/wave/util/file_position.hpp | 3400b695cf618c79928e039220f2a2d3ac0d72e2 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,007 | hpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the position_iterator and file_position templates
http://www.boost.org/
Copyright (c) 2001-2007 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(FILE_POSITION_H_52BDEDF7_DAD3_4F24_802F_E66BB8098F68_INCLUDED)
#define FILE_POSITION_H_52BDEDF7_DAD3_4F24_802F_E66BB8098F68_INCLUDED
#include <string>
#include <ostream>
#include <boost/assert.hpp>
#include <boost/spirit/version.hpp>
#include <boost/spirit/iterator/position_iterator.hpp>
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SERIALIZATION != 0
#include <boost/serialization/serialization.hpp>
#endif
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
namespace debug {
// Used only when BOOST_ASSERT expands to something
// make sure the string literal does not contain any escapes ('\\' just
// before '\\', '\"' or '?')
template <typename StringT>
inline bool
is_escaped_lit(StringT const &value)
{
typename StringT::size_type pos = value.find_first_of ("\\", 0);
if (StringT::npos != pos) {
do {
if ('\\' == value[pos+1] ||
'\"' == value[pos+1] ||
'?' == value[pos+1])
{
return true;
}
else {
pos = value.find_first_of ("\\", pos+1);
}
} while (pos != StringT::npos);
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
} // namespace debug
///////////////////////////////////////////////////////////////////////////////
//
// file_position
//
// A structure to hold positional information. This includes the filename,
// line number and column number of a current token position.
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
struct file_position {
public:
typedef StringT string_type;
file_position()
: file(), line(1), column(1)
{}
explicit file_position(string_type const& file_, int line_ = 1,
int column_ = 1)
: file(file_), line(line_), column(column_)
{
BOOST_ASSERT(!debug::is_escaped_lit(file));
}
// accessors
string_type const &get_file() const { return file; }
unsigned int get_line() const { return line; }
unsigned int get_column() const { return column; }
void set_file(string_type const &file_)
{
file = file_;
BOOST_ASSERT(!debug::is_escaped_lit(file));
}
void set_line(unsigned int line_) { line = line_; }
void set_column(unsigned int column_) { column = column_; }
private:
#if BOOST_WAVE_SERIALIZATION != 0
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & file;
ar & line;
ar & column;
}
#endif
string_type file;
unsigned int line;
unsigned int column;
};
template <typename StringT>
bool operator== (file_position<StringT> const &lhs,
file_position<StringT> const &rhs)
{
return lhs.get_column() == rhs.get_column() &&
lhs.get_line() == rhs.get_line() && lhs.get_file() == rhs.get_file();
}
template <typename StringT>
inline std::ostream &
operator<< (std::ostream &o, file_position<StringT> const &pos)
{
o << pos.get_file() << ":" << pos.get_line() << ":" << pos.get_column();
return o;
}
typedef file_position<BOOST_WAVE_STRINGTYPE> file_position_type;
///////////////////////////////////////////////////////////////////////////////
//
// position_iterator
//
// The position_iterator used by Wave is now based on the corresponding Spirit
// type. This type is used with our own file_position though. The needed
// specialization of the boost::spirit::position_policy class is provided
// below.
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT>
struct position_iterator
: boost::spirit::position_iterator<IteratorT, PositionT>
{
typedef boost::spirit::position_iterator<IteratorT, PositionT> base_type;
position_iterator()
{
}
position_iterator(IteratorT const &begin, IteratorT const &end,
PositionT const &pos)
: base_type(begin, end, pos)
{
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
///////////////////////////////////////////////////////////////////////////////
#if SPIRIT_VERSION >= 0x1700
namespace spirit {
///////////////////////////////////////////////////////////////////////////////
//
// The boost::spirit::position_policy has to be specialized for our
// file_position class
//
///////////////////////////////////////////////////////////////////////////////
template <>
class position_policy<boost::wave::util::file_position_type> {
public:
position_policy()
: m_CharsPerTab(4)
{}
void next_line(boost::wave::util::file_position_type &pos)
{
pos.set_line(pos.get_line() + 1);
pos.set_column(1);
}
void set_tab_chars(unsigned int chars)
{
m_CharsPerTab = chars;
}
void next_char(boost::wave::util::file_position_type &pos)
{
pos.set_column(pos.get_column() + 1);
}
void tabulation(boost::wave::util::file_position_type &pos)
{
pos.set_column(pos.get_column() + m_CharsPerTab -
(pos.get_column() - 1) % m_CharsPerTab);
}
private:
unsigned int m_CharsPerTab;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace spirit
#endif // SPIRIT_VERSION >= 0x1700
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(FILE_POSITION_H_52BDEDF7_DAD3_4F24_802F_E66BB8098F68_INCLUDED)
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
231
]
]
]
|
4b2e7fc699caf6bf9378765089b38962807bc7d5 | 9a48be80edc7692df4918c0222a1640545384dbb | /Libraries/Boost1.40/libs/wave/test/testwave/testfiles/t_6_023.cpp | 19e57690d9226b41604bad53d8d04a93bd105706 | [
"BSL-1.0"
]
| permissive | fcrick/RepSnapper | 05e4fb1157f634acad575fffa2029f7f655b7940 | a5809843f37b7162f19765e852b968648b33b694 | refs/heads/master | 2021-01-17T21:42:29.537504 | 2010-06-07T05:38:05 | 2010-06-07T05:38:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,400 | cpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2009 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
The tests included in this file were initially taken from the mcpp V2.5
preprocessor validation suite and were modified to fit into the Boost.Wave
unit test requirements.
The original files of the mcpp preprocessor are distributed under the
license reproduced at the end of this file.
=============================================================================*/
// Tests error reporting: Trailing junk of #else, #endif.
// 16.1: Trailing junk of #else.
//E t_6_023.cpp(22): error: ill formed preprocessor directive: #else MACRO_0
#define MACRO_0 0
#if MACRO_0
#else MACRO_0
#endif
/*-
* Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
| [
"metrix@Blended.(none)"
]
| [
[
[
1,
50
]
]
]
|
97608a0f614df16240191db54682e31a9994d512 | 63c8b343dec45ac3b70f368928567ed3fb0bc73e | /include/wrapper/zlib.h | ee044580189bcee57c2c9c354f80b244a5fc036e | []
| no_license | xushiwei/w-zlib | 1829fc72d754774a77842ce5ccb75f5e6c5dd0f0 | 539fb9d3de8f1e7a370d46c23579870803cd77c0 | refs/heads/master | 2016-09-01T20:20:46.557315 | 2011-07-23T07:25:01 | 2011-07-23T07:25:01 | 2,092,263 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,456 | h | /* -------------------------------------------------------------------------
// WINX: a C++ template GUI library - MOST SIMPLE BUT EFFECTIVE
//
// This file is a part of the WINX Library.
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.txt at this distribution. By using
// this software in any fashion, you are agreeing to be bound by the terms
// of this license. You must not remove this notice, or any other, from
// this software.
//
// Module: wrapper/zlib.h
// Creator: xushiwei
// Email: [email protected]
// Date: 2003-10-14 17:57:09
//
// $Id: zlib.h,v 1.1 2006/11/30 08:45:42 xushiwei Exp $
// -----------------------------------------------------------------------*/
#ifndef WRAPPER_ZLIB_H
#define WRAPPER_ZLIB_H
#ifndef STDEXT_BASIC_H
#include "../../../stdext/include/stdext/Basic.h"
#endif
#ifndef ZLIB_H
#include "zlib/zlib.h"
#endif
#ifndef S_ZIP_NONEED_COMPRESSION
#define S_ZIP_NONEED_COMPRESSION 0x80
#endif
// -------------------------------------------------------------------------
// Link zlib.lib
#if !defined(Wrapper_Linked_zlib)
#define Wrapper_Linked_zlib
#pragma comment(lib, "zlib1")
#endif
// -------------------------------------------------------------------------
// zlibCompress
template <class AllocT>
inline HRESULT winx_call zlibCompress(
AllocT& alloc, const void* pSrc, size_t cbSize,
void** ppBuf, size_t* pcbAfterCompress, int method = Z_DEFAULT_COMPRESSION)
{
WINX_ASSERT(Z_OK == S_OK && sizeof(size_t) >= sizeof(uLongf));
uLongf const cbAfterCompress0 = cbSize + cbSize/1000 + (12 + 4); // 4 是额外加的
Bytef* const pDest = (Bytef*)alloc.allocate(cbAfterCompress0);
HRESULT hr;
uLongf cbAfterCompress = cbAfterCompress0;
try
{
hr = compress2(pDest, &cbAfterCompress, (const Bytef*)pSrc, cbSize, method);
}
catch (...)
{
hr = E_UNEXPECTED;
}
if (hr == Z_OK)
{
if (cbAfterCompress >= cbSize)
{
hr = S_ZIP_NONEED_COMPRESSION;
// 就算返回了S_ZIP_NONEED_COMPRESSION,仍然进行压缩,返回压缩结果。
//--> goto lzExit;
}
*ppBuf = alloc.reallocate(pDest, cbAfterCompress0, cbAfterCompress);
*pcbAfterCompress = cbAfterCompress;
return hr;
}
alloc.deallocate(pDest, cbAfterCompress0);
return hr;
}
// -------------------------------------------------------------------------
// zlibDecompress
template <class AllocT>
inline HRESULT winx_call zlibDecompress(
AllocT& alloc, const void* pSrc, size_t cbSize, size_t cbOrgSize,
void** ppBuf, UINT nErrLevel = 0)
{
WINX_ASSERT(Z_OK == S_OK && sizeof(size_t) >= sizeof(uLongf));
Bytef* const pDest = (Bytef*)alloc.allocate(cbOrgSize);
uLongf cbDecodeSize = cbOrgSize;
HRESULT hr;
try
{
hr = uncompress(pDest, &cbDecodeSize, (const Bytef*)pSrc, cbSize); //, nErrLevel);
WINX_ASSERT(hr == Z_OK);
if (cbDecodeSize != cbOrgSize)
{
hr = E_FAIL;
goto lzExit;
}
}
catch (...)
{
WINX_ASSERT( !"ZlibDecompress failed!" );
hr = E_UNEXPECTED;
}
if (hr == Z_OK) // if success!!
{
*ppBuf = pDest;
return S_OK;
}
lzExit:
alloc.deallocate(pDest, cbOrgSize);
return hr;
}
// -------------------------------------------------------------------------
// $Log: zlib.h,v $
#endif /* WRAPPER_ZLIB_H */
| [
"[email protected]"
]
| [
[
[
1,
127
]
]
]
|
cd004c066821f34b0e3aaabe3eb9ae1c9d3529c2 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/nebula2/src/video/nvideoserver_main.cc | 277f3dc5da682fb4e79cac965ab3397f62754f6b | []
| no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,251 | cc | //------------------------------------------------------------------------------
// nvideoserver_main.cc
// (C) 2004 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "kernel/nkernelserver.h"
#include "video/nvideoserver.h"
nNebulaScriptClass(nVideoServer, "nroot");
nVideoServer* nVideoServer::Singleton = 0;
//------------------------------------------------------------------------------
/**
*/
nVideoServer::nVideoServer() :
isOpen(false),
isPlaying(false),
scalingEnabled(false)
{
n_assert(0 == Singleton);
Singleton = this;
}
//------------------------------------------------------------------------------
/**
*/
nVideoServer::~nVideoServer()
{
n_assert(!this->isOpen);
n_assert(!this->isPlaying);
n_assert(Singleton);
Singleton = 0;
}
//------------------------------------------------------------------------------
/**
*/
bool
nVideoServer::Open()
{
n_assert(!this->isOpen);
this->isOpen = true;
return true;
}
//------------------------------------------------------------------------------
/**
*/
void
nVideoServer::Close()
{
n_assert(this->isOpen);
this->isOpen = false;
}
//------------------------------------------------------------------------------
/**
*/
bool
nVideoServer::PlayFile(const char* filename)
{
n_assert(filename);
n_assert(!this->isPlaying);
this->isPlaying = true;
return true;
}
//------------------------------------------------------------------------------
/**
*/
void
nVideoServer::Stop()
{
n_assert(this->isPlaying);
this->isPlaying = false;
}
//------------------------------------------------------------------------------
/**
*/
void
nVideoServer::Trigger()
{
n_assert(this->isOpen);
}
//------------------------------------------------------------------------------
/**
*/
nVideoPlayer*
nVideoServer::NewVideoPlayer(nString name)
{
// n_assert(this->isOpen);
return 0;
}
//------------------------------------------------------------------------------
/**
delete video player
*/
void
nVideoServer::DeleteVideoPlayer(nVideoPlayer* player)
{
};
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
104
]
]
]
|
7a01fd9dfe3d309d7bc123f0ef1f8ce28dbb9577 | bdb8fc8eb5edc84cf92ba80b8541ba2b6c2b0918 | /TPs CPOO/Gareth & Maxime/Projet/CanonNoir_Moteur_C++/fichiers/Etat.cpp | d85051c6ab27ec45af570e7efdb73e851838db68 | []
| no_license | Issam-Engineer/tp4infoinsa | 3538644b40d19375b6bb25f030580004ed4a056d | 1576c31862ffbc048890e72a81efa11dba16338b | refs/heads/master | 2021-01-10T17:53:31.102683 | 2011-01-27T07:46:51 | 2011-01-27T07:46:51 | 55,446,817 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 227 | cpp | /**
*\file Etat.cpp
*\brief File which contains the functions of the Etat interface
*\author Maxime HAVEZ
*\author Gareth THIVEUX
*\version 1.0
*/
#include "Etat.h"
void Etat::modifMotor(MoteurJeu* m){
motor=m;
} | [
"havez.maxime.01@9f3b02c3-fd90-5378-97a3-836ae78947c6",
"garethiveux@9f3b02c3-fd90-5378-97a3-836ae78947c6"
]
| [
[
[
1,
1
],
[
3,
3
],
[
7,
13
]
],
[
[
2,
2
],
[
4,
6
]
]
]
|
67f57b8abfe45bd2477f83a04b650e221c5f7da7 | 23df069203762da415d03da6f61cdf340e84307b | /2009-2010/winter10/csci245/archive/eval/sexpr.cpp | 3d027dcae34b582c22006aa56674adf6f9797c71 | []
| no_license | grablisting/ray | 9356e80e638f3a20c5280b8dba4b6577044d4c6e | 967f8aebe2107c8052c18200872f9389e87d19c1 | refs/heads/master | 2016-09-10T19:51:35.133301 | 2010-09-29T13:37:26 | 2010-09-29T13:37:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,743 | cpp | #include "sexpr.h"
Sexpr* Sexpr::eval()
{
return this;
}
Sexpr* Sexpr::eval_map()
{
std::cout << "eval_map failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::add_list()
{
std::cout << "Add_list failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::subtract_list()
{
std::cout << "Subtract_list failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::multiply_list()
{
std::cout << "multiply_list, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
string Sexpr::get_string()
{
std::cout << "Get_string failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
bignum Sexpr::get_number()
{
std::cout << "get_number failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
bool Sexpr::zero()
{
return false;
}
Sexpr* Sexpr::get_first()
{
std::cout << "Get_first failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::get_rest()
{
std::cout << "get_rest failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::add(Sexpr* other)
{
std::cout << "add failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::subtract(Sexpr* other)
{
std::cout << "subtract failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
Sexpr* Sexpr::multiply(Sexpr* other)
{
std::cout << "multiply failed, received this-> ";
this->print(std::cout);
std::cout << endl;
exit(2);
}
| [
"Bobbbbommmbb@Bobbbbommmbb-PC.(none)"
]
| [
[
[
1,
99
]
]
]
|
e4944eeba91c09537451627e6c54c956c4890b53 | 67346d8d188dbf2a958520a7e80637481d15e676 | /source/GameStateOptions.cpp | 8b9a0094d8374589d14fae94d1b7636804f93ad0 | []
| no_license | Alrin77/ndsgameengine | 1a137621eb1b32849c179cd7f8c719c600b1a1f6 | 7afbb847273074ba0f7d3050322d7183c2b2c212 | refs/heads/master | 2016-09-03T07:30:11.105686 | 2010-12-04T22:05:16 | 2010-12-04T22:05:16 | 33,461,675 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 358 | cpp | #include "GameStateOptions.h"
GameStateOptions::GameStateOptions(){
}
GameStateOptions::~GameStateOptions(){
}
void GameStateOptions::Initialize(){
}
void GameStateOptions::Update(){
}
void GameStateOptions::Draw(){
}
void GameStateOptions::Cleanup(){
}
void GameStateOptions::Pause(){
}
void GameStateOptions::Resume(){
}
| [
"[email protected]@21144042-5242-e64c-d35b-eb64d47aa59c"
]
| [
[
[
1,
26
]
]
]
|
f6a5e7d22958762fef1c89050e265e6173f86913 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Tutorials/Tutorial_1_5/App.cpp | 298b563a366f06261c13b18f269f04516f3176ed | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,374 | cpp | #include "App.h"
#include "nGENE.h"
void App::createApplication()
{
FrameworkWin32::createApplication();
m_pMouse->setSensitivity(0.02f);
m_pPartitioner = new ScenePartitionerQuadTree();
SceneManager* sm = Engine::getSingleton().getSceneManager(0);
sm->setScenePartitioner(m_pPartitioner);
Renderer& renderer = Renderer::getSingleton();
renderer.setClearColour(0);
renderer.setCullingMode(CULL_CW);
uint anisotropy = 0;
renderer.getDeviceRender().testCapabilities(CAPS_MAX_ANISOTROPY, &anisotropy);
for(uint i = 0; i < 8; ++i)
renderer.setAnisotropyLevel(i, anisotropy);
CameraFirstPerson* cam;
cam = (CameraFirstPerson*)sm->createCamera(L"CameraFirstPerson", L"Camera");
cam->setVelocity(10.0f);
cam->setPosition(Vector3(0.0f, 5.0f, -10.0f));
sm->getRootNode()->addChild(L"Camera", cam);
Engine::getSingleton().setActiveCamera(cam);
NodeMesh <MeshLoadPolicyXFile>* pSculp = sm->createMesh <MeshLoadPolicyXFile>(L"statue.x");
pSculp->setPosition(0.0f, 0.0f, 7.0f);
pSculp->setScale(0.25f, 0.25f, 0.25f);
Surface* pSurface = pSculp->getSurface(L"surface_2");
pSurface->flipWindingOrder();
Material* matstone = MaterialManager::getSingleton().getLibrary(L"default")->getMaterial(L"dotCel");
pSurface->setMaterial(matstone);
sm->getRootNode()->addChild(L"Sculpture", *pSculp);
PrefabBox* pBox = sm->createBox(100.0f, 0.5f, 100.0f, Vector2(80.0f, 80.0f));
pBox->setPosition(0.0f, 1.2, 0.0f);
pSurface = pBox->getSurface(L"Base");
Material* matGround = MaterialManager::getSingleton().getLibrary(L"default")->getMaterial(L"normalMap");
pSurface->setMaterial(matGround);
sm->getRootNode()->addChild(L"Plane", pBox);
NodeLight* pLight = sm->createLight(LT_DIRECTIONAL);
pLight->setPosition(-4.0f, 5.0f, 0.0f);
pLight->setDirection(Vector3(0.7f, -0.5f, 1.0f));
pLight->setDrawDebug(false);
Colour clrWorld(204, 204, 0);
pLight->setColour(clrWorld);
pLight->setRadius(180.0f);
sm->getRootNode()->addChild(L"WorldLight", *pLight);
renderer.addLight(pLight);
m_pInputListener = new MyInputListener();
m_pInputListener->setApp(this);
InputSystem::getSingleton().addInputListener(m_pInputListener);
PhysicsWorld* pWorld = Physics::getSingleton().createWorld(L"MyPhysicsWorld");
PhysicsMaterial* physMat = pWorld->createPhysicsMaterial(L"DefaultMaterial");
physMat->setRestitution(0.5f);
physMat->setDynamicFriction(0.5f);
physMat->setStaticFriction(0.5f);
pWorld->setGravity(Vector3(0.0f, -9.8f, 0.0f));
PhysicsActor* pActor = pWorld->createPhysicsActorMesh(pSculp->getScale(),
*pSculp->getSurface(L"surface_2")->getVertexBuffer());
pActor->attachNode(pSculp);
pActor->setShapeMaterial(0, *physMat);
pActor = pWorld->createPhysicsActor(L"Box", Vector3(100.0f, 0.5f, 100.0f));
pActor->attachNode(pBox);
pActor->setShapeMaterial(0, *physMat);
pWorld->addPhysicsActor(L"Plane", pActor);
CONTROLLER_DESC charDesc;
charDesc.height = 2.0f;
charDesc.obstacleLimit = 0.7f;
charDesc.radius = 0.8f;
m_pController = pWorld->createController(charDesc);
m_pController->attachNode(cam);
pWorld->addController(L"Player", m_pController);
}
CharacterController* App::getController() const
{
return m_pController;
}
int main()
{
App app;
app.createApplication();
app.run();
app.shutdown();
return 0;
}
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
105
]
]
]
|
bee26b3337be0a6051b1b956b8dc489656824eef | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Common/MevisDicomTiff/itkMevisDicomTiffImageIO.h | 8e3d0bd226d17a96ebece90cb4ae1dc020ace8c4 | []
| no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,543 | h | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkMevisDicomTiffImageIO.h,v $
Language: C++
Date: $Date: 2009/10/14 13:28:12 $
Version: $Revision: 1.7 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkMevisDicomTiffImageIO_h
#define __itkMevisDicomTiffImageIO_h
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#endif
#include <fstream>
#include <string>
#include "itkImageIOBase.h"
#include "itk_tiff.h"
namespace itk
{
/** \class MevisDicomTiffImageIO
*
* ImageIO for handling Mevis dcm/tiff images,
*
* PROPERTIES:
* - developed using gdcm 2.0.10, tiff 3.8.2 and itk 3.10.0
* - only 2D/3D, scalar types supported
* - input/output tiff image expected to be tiled
* - types supported uchar, char, ushort, short, uint, int, and float
* (double is not accepted by MevisLab)
* - writing defaults is tiled tiff, tilesize is 128, 128,
* LZW compression and cm metric system
* - default extension for tiff-image is ".tif" to comply with mevislab
* standards
*
* GDCM (current 2.0.12):
* - gdcm header during reading is stored as (global) metadata
* to fill in the gdcm header when writing. All 'image' values,
* eg voxelsize, dimensions etc are overwritten, except
* min/max value of the image and intercept/slope.
*
* TIFF (current 3.9.1):
*
* ITK (current 3.14.0):
* FUNCTIONALITIES:
* - reading gdcm file
* always 3D to allocate memory for spacing, dimensions etc
* gdcm::DataSet header, storing header into metadict
* using attribute to read standard values, except min/max
* (somehow is not supported by gdcm). The superclass may
* resize the variables depending on the dimensions (eg spacing,
* dimensions etc). Therefore when reading we check whether the
* image is 2d or 3d based on dcm header file, and do a re-sizing
* of the vector if required.
* - writing gdcm file
* fixed adding comments to see which version has been used
* pixeltype of dcm header is unsigned short for int, float
* and double images (see bugfix 20 feb 09)
*
* todo
* - streaming support, rgb support
* - inch support for tiff
* - user selection of compression
* - implementing writing tiffimages if x,y < 16 (tilesize)
* - add uniform testing for linux, windows, 32/64 bits
* in particular for reading/creating/writing dcm files
* and all header values, as well 2d/3d. Things to consider
* for testing 1. proper handling position 2. proper handling
* pixeltype and sign 3. windows/linux testing 4. both dcm
* and tiff (especially dcm file handling)
*
* 20 Feb 2009
* bugfixed; always set the pixeltype of the dcm image to
* unsigned short when writing, otherwise the origin is not
* read in correctly by mevislab (for int, float, double)
* 30 sep 2009
* bugfix: consistent handling of 2d/3d throughout code,
* thanks to Stefan Klein for pointing out of this bug which
* revealed after usage on 2d on windows and thanks for
* his suggestions to fix this.
*
*
* email: [email protected]
*
* \ingroup IOFilters
*/
class TIFFReaderInternal;
class ITK_EXPORT MevisDicomTiffImageIO : public ImageIOBase
{
public:
typedef MevisDicomTiffImageIO Self;
typedef ImageIOBase Superclass;
typedef SmartPointer<Self> Pointer;
itkNewMacro(Self);
itkTypeMacro(MevisDicomTiffImageIO, Superclass);
itkGetMacro(RescaleSlope, double);
itkGetMacro(RescaleIntercept, double);
virtual bool CanReadFile(const char*);
virtual void ReadImageInformation();
virtual void Read(void* buffer);
virtual bool CanWriteFile(const char*);
virtual void WriteImageInformation();
virtual void Write(const void* buffer);
virtual bool CanStreamRead()
{
return false;
}
virtual bool CanStreamWrite()
{
return false;
}
protected:
MevisDicomTiffImageIO();
~MevisDicomTiffImageIO();
void PrintSelf(std::ostream& os, Indent indent) const;
private:
MevisDicomTiffImageIO(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
// the following includes the pathname
// (if these are given)!
std::string m_DcmFileName;
std::string m_TiffFileName;
TIFF * m_TIFFImage;
unsigned int m_TIFFDimension;
bool m_IsOpen;
unsigned short m_Compression;
unsigned int m_BitsPerSample;
unsigned int m_Width;
unsigned int m_Length;
unsigned int m_Depth;
bool m_IsTiled;
unsigned int m_TileWidth;
unsigned int m_TileLength;
unsigned int m_TileDepth;
unsigned short m_NumberOfTiles;
double m_RescaleSlope;
double m_RescaleIntercept;
double m_EstimatedMinimum;
double m_EstimatedMaximum;
};
} // end namespace itk
#endif // __itkMevisDicomTiffImageIO_h
| [
"[email protected]"
]
| [
[
[
1,
186
]
]
]
|
a8f25ef202b572c981ae8612cea32a7a4ff14f9e | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/newton20/engine/rules/include/StateSet.h | 0e6990f5d612c12742cfbf74ea4e405cba166889 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,707 | h | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* 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
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#ifndef __STATESET_H__
#define __STATESET_H__
#include "RulesPrerequisites.h"
namespace rl
{
class _RlRulesExport StateSet
{
public:
StateSet();
virtual ~StateSet();
virtual int getValue(bool getUnmodfiedValue = false) const;
virtual int getOriginalValue() const;
virtual void setOriginalValue(int newValue);
virtual void modifyOriginalValue(int modifier);
virtual int getModifier() const;
virtual void setModifier(int newModifier);
virtual void modifyModifier(int modifier);
virtual int getProbenModifier() const;
virtual void setProbenModifier(int newProbenModifier);
virtual void modifyProbenModifier(int modifier);
virtual int getMultiplier() const;
virtual void setMultiplier(int newMultiplier);
protected:
/// Der unmodifizierte Wert
int mOriginalValue;
int mModifier;
int mProbenModifier;
/// Dieser Faktor wird nach dem modifizieren auf den Wert draufmultipliziert.
int mMultiplier;
};
}
#endif //__STATESET_H__
| [
"melven@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
52
]
]
]
|
749ed99773f6710da22526602e0233dca5526435 | b738fc6ffa2205ea210d10c395ae47b25ba26078 | /TUDT/tudtnew/TBaseNetwork.h | 6579eef019f3bb4474bb3d89f170dcd37f632764 | []
| no_license | RallyWRT/ppsocket | d8609233df9bba8d316a85a3d96919b8618ea4b6 | b4b0b16e2ceffe8a697905b1ef1aeb227595b110 | refs/heads/master | 2021-01-19T16:23:26.812183 | 2009-09-23T06:57:58 | 2009-09-23T06:57:58 | 35,471,076 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,550 | h | #pragma once
#include <set>
#include "tudt.h"
#include "JMutex.h"
#include "MonitorGroup.h"
//#include "../src/common.h"
class TBaseNetwork
{
public:
TBaseNetwork(int iUDPPort);
TBaseNetwork(const sockaddr* name, int namelen);
~TBaseNetwork(void);
int GetPort();
//设置网络消息侦听器
void SetNetworkListener(UDT::INetworkListener *pListener);
//向某个地址尝试连接(连接如果成功,会触发 NL_CODE_NEWCONN 消息)
void ShootTo(const sockaddr* name, int namelen);
//发送数据。
//这是异步发送。
//发送成功会触发NL_CODE_SENDSUCCEED信息,否则触发NL_CODE_SENDFAILED消息。
//消息的param就是iMsgID。
int SendTo(int iConn,int iLen, const char *pData);
//关闭连接
void CloseConn(int iConn);
//将外部创建的socket放入这里管理
void AddConn(UDTSOCKET u);
//获取所有连接
void GetConns(std::set<UDTSOCKET> &setConns);
//===============================
void AddConnection(UDTSOCKET socketNew);
void RemoveConnection(UDTSOCKET socketNew);
void ThreadWaitConn();
void ThreadCheckData();
UDTSOCKET CreateSocket(bool bRendezvous=true);
private:
int m_iServicePort;
sockaddr_in m_addrService;
UDTSOCKET m_ServerSocket;
UDT::INetworkListener *m_pListener;
volatile bool m_bExiting;
uintptr_t m_threadWaitConnection;
uintptr_t m_threadCheckDataStart;
JMutex m_ConnMutex;
//所有建立了连接的socket列表
std::set<UDTSOCKET> m_setConns;
private:
void Init();
void HandleSocketBread(UDTSOCKET u);
};
| [
"tantianzuo@159e4f46-9839-11de-8efd-97b2a7529d09"
]
| [
[
[
1,
55
]
]
]
|
368f8e18b67812d8450ec0c5fe69834bea7ad83c | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/Scd/ScdLib/ScdCtrls.h | 27981e74ce2feb2d0d30e72e4a23e3a04350700c | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,130 | h | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#ifndef __SCDCTRLS_H
#define __SCDCTRLS_H
#ifdef __SCDCTRLS_CPP
#define DllImportExport DllExport
#elif !defined(SCDLIB)
#define DllImportExport DllImport
#else
#define DllImportExport
#endif
typedef word Cursor_Types;
//extern DllImportExport long MemAvailInit;
//DllImportExport long MemUsed();
extern DllImportExport LOGFONT SysCADFontStruct[];
DllImportExport HFONT SysCADFont(byte No);
DllImportExport HFONT SetSysCADFont(HDC my_HDC, byte No);
DllImportExport int SysCADFontHeight(HDC my_HDC, pchar p);
DllImportExport int SysCADFontWidth(HDC my_HDC, pchar p);
enum eFilterRule { eFROff, eFRContains, eFRWildCard, eFRRegExp, eFRCount };
const LPCTSTR eFilterRuleNames[eFRCount] = { "Off", "Contains","Wildcards","Regular Expressions"};
DllImportExport void REMenuOptions(CWnd * pWnd, CString &Txt, eFilterRule Rule, bool ForFind);
typedef struct WinMsgName {char Name[25]; word MsgNum;} WinMsgName;
DllImportExport void dbgWM_Msg(pchar Where, UINT message, WPARAM w, LPARAM l, flag DoAt);
//===========================================================================
DllImportExport void ScdCtrls_Entry();
DllImportExport void SetVisibleWindowPos(CWnd* pWnd, int xPos, int yPos, int Width=-1, int Height=-1, bool AsFloating=false);
//===========================================================================
class DllImportExport CBitmapFile
{
public:
CBitmapFile();
~CBitmapFile();
void Clear();
BOOL LoadBitmap(char* pFilename, int MaxBitCount=8);
BOOL Paint(CDC* pDC, int XPos, int YPos);
BOOL Paint(CDC* pDC, LPCRECT lpRect, BOOL Centre=TRUE, BOOL Stretch=FALSE);
HBITMAP hBitmap() { return hbm; };
BITMAPINFOHEADER & HDR() { return bmih; };
protected:
BOOL bValidBmp; //has a bitmap been loaded
BITMAPINFOHEADER bmih; //BITMAPINFOHEADER struct
char* lpbmi; //points to variable length BITMAPINFO
char* lpvBits; //points to data for bitmap bits
HBITMAP hbm; //bitmap handle (for dc)
};
//===========================================================================
class DllImportExport CTxtWnd : public CWnd
{
public:
CTxtWnd();
//{{AFX_VIRTUAL(CTxtWnd)
//}}AFX_VIRTUAL
virtual ~CTxtWnd() {};
void Enable(flag Enable) { bEnabled = Enable; Invalidate(); };
void SetBkCol(COLORREF Col) { BkCol = Col; };
void SetEnabledCol(COLORREF Col) { EnTxCol = Col; };
void SetDisabledCol(COLORREF Col) { DisTxCol = Col; };
void SetText(char* p) { Txt = p; };
void SetFont(CFont* Font) { pFont = Font; };
protected:
CFont* pFont;
byte bEnabled:1;
COLORREF BkCol;
COLORREF EnTxCol;
COLORREF DisTxCol;
Strng Txt;
//{{AFX_MSG(CTxtWnd)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//===========================================================================
//simple dialog used to enter a single string...
class DllImportExport CStringDlg : public CDialog
{
public:
CStringDlg(char* pTitle, char* pFieldName, char* pPrevData = "", CWnd* pParent = NULL);
char* Data() { return (char*)(const char*)m_Data; };
CString sTitle;
CString sFieldName;
//{{AFX_DATA(CStringDlg)
//enum { IDD = IDD_SIMPLE_STRING_DLG };
CString m_Data;
//}}AFX_DATA
//{{AFX_VIRTUAL(CStringDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG(CStringDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//===========================================================================
// "Owned" button: sends notifications to owner instead of parent.
class DllImportExport COwnedButton : public CButton
{
public:
virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
};
//===========================================================================
class DllImportExport CCustomListBox : public CListBox
{
public:
CCustomListBox();
BOOL SubclassMoveUpDownControls(CWnd* pParent, UINT idListBox_, UINT idMoveUpBtn, UINT idMoveDownBtn);
BOOL SubclassDeleteControl(CWnd* pParent, UINT idListBox_, UINT idDeleteBtn);
int SetCurSel(int nSelect); //override
inline void UpdateButtons() { GetParent()->UpdateDialogControls(this, FALSE); }; // Update buttons, using myself as target!
inline BOOL Changed() { return bChanged; }; //has the list box been changed by any of the sub-classed buttons
inline void SetChanged(BOOL Changed) { bChanged = Changed; };
public:
//{{AFX_VIRTUAL(CCustomListBox)
//}}AFX_VIRTUAL
public:
virtual ~CCustomListBox();
protected:
UCHAR bChanged:1; //has the list changed, because of subclassed buttons
COwnedButton MoveUpBtn; //Move selected item up button
COwnedButton MoveDownBtn; //Move selected item down button
COwnedButton DeleteBtn; //Remove selected item button
UINT idListBox; //ID of ListBox
UINT idMoveUp; //ID of MoveUp button
UINT idMoveDown; //ID of MoveDown button
UINT idDelete; //ID of Delete button
protected:
virtual BOOL OnChildNotify(UINT msg, WPARAM wp, LPARAM lp, LRESULT* pLRes);
//{{AFX_MSG(CCustomListBox)
//}}AFX_MSG
afx_msg void OnCmdRange(UINT id);
afx_msg void OnCmdUiRange(CCmdUI* pCmdUi);
DECLARE_MESSAGE_MAP()
};
//===========================================================================
class DllImportExport CListBoxHeader : public CHeaderCtrl
{
public:
CListBoxHeader() { pOwner = NULL; };
inline void SetOwner(CWnd* pWnd) { pOwner = pWnd; };
//{{AFX_VIRTUAL(CListBoxHeader)
public:
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
//}}AFX_VIRTUAL
public:
virtual ~CListBoxHeader() {};
protected:
CWnd* pOwner; //pointer to window associated with the header
//{{AFX_MSG(CListBoxHeader)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//---------------------------------------------------------------------------
class DllImportExport CHeaderListBox : public CCustomListBox
{
public:
CHeaderListBox();
void SetHeaderCount(int Count);
void SetHeaderItem(int index, char* Txt, int Width, int fmt = HDF_LEFT);
BOOL MakeHeader(UINT nID);
void UpdateHeader();
void GetTextInColumn(int nColumn, int nIndex, CString& rString);
int SetTextInColumn(int nColumn, int nIndex, LPCTSTR lpszItem);
int FindStringExactInColumn(int nColumn, int nIndexStart, LPCTSTR lpszFind);
public:
//{{AFX_VIRTUAL(CHeaderListBox)
//}}AFX_VIRTUAL
public:
virtual ~CHeaderListBox();
protected:
CListBoxHeader Header; //header control
int iHeadCount; //number of columns
HD_ITEM* pHDItems; //array of column info
CStringArray Headings; //array of column titles
int iFontWidth; //width of font used
BOOL bCreatedHeader; //true once header control has been created
protected:
void SetTabs();
//{{AFX_MSG(CHeaderListBox)
//}}AFX_MSG
afx_msg LRESULT OnSetHeaderTabs(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
//===========================================================================
// COMCOMBO Shows how to implement a self-contained combo box with buttons.
// Combo box with Add/Delete buttons.
class DllImportExport CComboCombo : public CComboBox
{
private:
COwnedButton m_buttonAdd; //"Add" button
COwnedButton m_buttonDel; //"Delete" button
COwnedButton m_buttonPrev; //"Prev" button
COwnedButton m_buttonNext; //"Next" button
UINT m_idCombo; //ID of combo box
UINT m_idAdd; //ID of add button
UINT m_idDel; //ID of delete button
UINT m_idPrev; //ID of prev button
UINT m_idNext; //ID of next button
public:
CComboCombo();
virtual ~CComboCombo() {};
//{{AFX_VIRTUAL(CComboCombo)
public:
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
//}}AFX_VIRTUAL
void UpdateButtons(); //helper to update button states
BOOL SubclassAddDelControls(CWnd* pParent, UINT idCombo, UINT idAdd, UINT idDel);
BOOL SubclassPrevNextControls(CWnd* pParent, UINT idCombo, UINT idPrev, UINT idNext);
protected:
//{{AFX_MSG(CComboCombo)
//}}AFX_MSG
afx_msg void OnCmdRange(UINT id);
afx_msg void OnCmdUiRange(CCmdUI* pCmdUi);
DECLARE_MESSAGE_MAP()
};
//===========================================================================
class DllImportExport CCustomTreeCtrl : public CTreeCtrl
{
public:
CPoint PrevDownPoint; //last point where left OR right mouse button was pressed DOWN
CCustomTreeCtrl() {};
virtual ~CCustomTreeCtrl();
HTREEITEM FindChildItem(HTREEITEM H, char* pTxt);
HTREEITEM FindItem(char* pTxt, byte RqdLevel=0);
//{{AFX_VIRTUAL(CCustomTreeCtrl)
//}}AFX_VIRTUAL
protected:
HTREEITEM FindItem(HTREEITEM H, byte Level, char* pTxt, byte RqdLevel);
//{{AFX_MSG(CCustomTreeCtrl)
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//===========================================================================
//see commctrl.h
#ifdef UNICODE
#define STVN_SELECTEDCHANGED (TVN_FIRST-73)
#else
#define STVN_SELECTEDCHANGED (TVN_FIRST-22)
#endif
class DllImportExport CSelectTreeCtrl : public CCustomTreeCtrl
{
public:
CSelectTreeCtrl() {};
virtual ~CSelectTreeCtrl();
void LoadImage();
void ToggleItem(HTREEITEM hItem);
BOOL IsAnItemSelected(HTREEITEM hStartItem);
void SelectAll(BOOL On);
int CntSelected(HTREEITEM hStartItem);
BOOL GetItemSelected(HTREEITEM hItem, BOOL MustBeEndItem=TRUE);
void SetItemSelected(HTREEITEM hItem, flag Selected);
int CntLocked(HTREEITEM hStartItem);
BOOL GetItemLocked(HTREEITEM hItem, BOOL MustBeEndItem=TRUE);
void SetItemLocked(HTREEITEM hItem);
void FixAllLockImages();
void FixAllSelectedImages();
//{{AFX_VIRTUAL(CSelectTreeCtrl)
//}}AFX_VIRTUAL
protected:
CImageList SelImgList;
void DoCnt(HTREEITEM hStartItem, int Image, int& Cnt, int& TtlCnt);
BOOL DoGetItem(HTREEITEM hItem, int Image, BOOL MustBeEndItem);
void DoSetItem(HTREEITEM hItem, int Image, BOOL SetChildren);
void DoSetAllChildrenImage(HTREEITEM h, int Image);
void DoFixParentImages(HTREEITEM hStartItem, int Image, int PartImage, int NoneImage);
void SetAllChildrenSelectedImage(HTREEITEM h, int Selected);
//{{AFX_MSG(CSelectTreeCtrl)
afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//===========================================================================
class DllImportExport CCustomListCtrl : public CListCtrl
{
public:
CPoint PrevDownPoint; //last point where left OR right mouse button was pressed DOWN
CCustomListCtrl() {};
//{{AFX_VIRTUAL(CCustomListCtrl)
//}}AFX_VIRTUAL
public:
virtual ~CCustomListCtrl();
void SetItemImage(int iPos, int iImage)
{
SetItem(iPos, 0, LVIF_IMAGE, "", iImage, 0, 0, 0);
};
int GetItemImage(int iPos)
{
LVITEM item;
memset(&item, 0, sizeof(item));
item.mask = LVIF_IMAGE;
item.iItem = iPos;
if (GetItem(&item))
return item.iImage;
return -1;
};
int GetFirstSelectedItem()
{
POSITION pos = GetFirstSelectedItemPosition();
return pos ? GetNextSelectedItem(pos) : -1;
};
int FindString(int nIndexStart, LPCTSTR lpszFind);
int FindStringExact(int nIndexStart, LPCTSTR lpszFind);
protected:
//{{AFX_MSG(CCustomListCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//===========================================================================
extern DllImportExport COLORREF gs_CustomColours[16];
//===========================================================================
//===========================================================================
#undef DllImportExport
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
361
],
[
363,
371
]
],
[
[
362,
362
]
]
]
|
ee9dfb1f318e62d700bd219d13f43fbc0ec54b26 | abafdd61ea123f3e90deb02fe5709951b453eec6 | /fuzzy/patl/impl/partial_base.hpp | 7301a8c4e57f9c5d97724a31869e841d7aaab29e | [
"BSD-3-Clause"
]
| permissive | geoiq/geojoin-ruby | 8a6a07938fe3d629de74aac50e61eb8af15ab027 | 247a80538c4fc68c365e71f9014b66d3c38526c1 | refs/heads/master | 2016-09-06T15:22:47.436634 | 2010-08-11T13:00:24 | 2010-08-11T13:00:24 | 13,863,658 | 2 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 5,158 | hpp | #ifndef PATL_PARTIAL_BASE_HPP
#define PATL_PARTIAL_BASE_HPP
#include <vector>
#include <map>
#include <algorithm>
namespace uxn
{
namespace patl
{
namespace impl
{
template <typename Container, bool SameLength>
class partial_base
{
protected:
typedef typename Container::key_type key_type;
typedef typename Container::bit_compare bit_compare;
typedef typename bit_compare::char_type char_type;
public:
partial_base(
const Container &cont, // экземпляр контейнера
const key_type &mask, // маска поиска (образец)
word_t mask_len = ~word_t(0), // длина маски в символах (для бесконечных строк)
const char_type &terminator = '\0') // символ окончания строки
: mask_(mask)
, mask_len_(get_min(
mask_len,
cont.bit_comp().bit_length(mask) / bit_compare::bit_size - 1))
, mask_bit_len_(mask_len_ * bit_compare::bit_size)
, terminator_(terminator)
, bit_comp_(cont.bit_comp())
{
}
static const bool accept_subtree = !SameLength;
//void init();
bool operator()(word_t i) const
{
return i <= mask_len_;
}
//bool operator()(word_t i, const char_type &ch);
/// bit-level optimization; implementation by default
bool bit_level(word_t, word_t) const
{
return true;
}
const key_type &mask() const
{
return mask_;
}
protected:
key_type mask_;
word_t
mask_len_,
mask_bit_len_;
char_type terminator_;
bit_compare bit_comp_;
};
template <typename This, typename Container, bool SameLength>
class levenshtein_generic
: public partial_base<Container, SameLength>
{
typedef This this_t;
typedef impl::partial_base<Container, SameLength> super;
typedef typename Container::key_type key_type;
typedef typename Container::bit_compare bit_compare;
typedef typename bit_compare::char_type char_type;
typedef std::vector<std::pair<word_t, word_t> > states_vector;
typedef std::vector<states_vector> states_sequence;
public:
levenshtein_generic(
const Container &cont,
word_t dist,
const key_type &mask,
word_t mask_len = ~word_t(0),
const char_type &terminator = '\0') // символ окончания строки
: super(cont, mask, mask_len, terminator)
, dist_(dist)
, states_seq_(1, states_vector(1, std::make_pair(0, 0)))
{
}
word_t distance() const
{
return cur_dist_;
}
void init()
{
states_seq_.clear();
states_seq_.push_back(states_vector(1, std::make_pair(0, 0)));
}
bool operator()(word_t i)
{
while (states_seq_.size() > i + 1)
states_seq_.pop_back();
return !states_seq_.back().empty();
}
bool operator()(word_t, const char_type &ch)
{
states_seq_.push_back(states_vector());
const states_vector ¤t = states_seq_[states_seq_.size() - 2];
if (ch == super::terminator_)
{
cur_dist_ = ~word_t(0);
for (states_vector::const_iterator it = current.begin()
; it != current.end()
; ++it)
{
if (impl::bits_but_highest(it->first) == super::mask_len_ && it->second < cur_dist_)
cur_dist_ = it->second;
}
return cur_dist_ != ~word_t(0);
}
states_vector &next = states_seq_.back();
std::back_insert_iterator<states_vector> next_ins(next);
for (states_vector::const_iterator it = current.begin()
; it != current.end()
; ++it)
{
const word_t
i = it->first,
e = it->second;
// C4127: conditional expression is constant
#pragma warning(push)
#pragma warning(disable : 4127)
if (!SameLength && impl::bits_but_highest(i) == super::mask_len_)
#pragma warning(pop)
{
next.clear();
cur_dist_ = e;
for (++it; it != current.end(); ++it)
{
if (impl::bits_but_highest(it->first) == super::mask_len_ &&
it->second < cur_dist_)
cur_dist_ = it->second;
}
return true;
}
static_cast<this_t*>(this)->transitions(i, e, ch, next_ins);
// sort & remove duplicates
std::sort(next.begin(), next.end());
next.resize(std::distance(
next.begin(),
std::unique(next.begin(), next.end())));
}
return !next.empty();
}
protected:
word_t dist_;
private:
states_sequence states_seq_;
word_t cur_dist_;
};
} // namespace impl
} // namespace patl
} // namespace uxn
#endif
| [
"sderle@goldman.(none)"
]
| [
[
[
1,
177
]
]
]
|
56265ff13ca25a9deac0a53e505790e42dc3b7b8 | 7b379862f58f587d9327db829ae4c6493b745bb1 | /JuceLibraryCode/modules/juce_audio_basics/sources/juce_ReverbAudioSource.cpp | 67d9d554e6e377717e552470b1a58110ebc58853 | []
| no_license | owenvallis/Nomestate | 75e844e8ab68933d481640c12019f0d734c62065 | 7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd | refs/heads/master | 2021-01-19T07:35:14.301832 | 2011-12-28T07:42:50 | 2011-12-28T07:42:50 | 2,950,072 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,887 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
BEGIN_JUCE_NAMESPACE
//==============================================================================
ReverbAudioSource::ReverbAudioSource (AudioSource* const inputSource, const bool deleteInputWhenDeleted)
: input (inputSource, deleteInputWhenDeleted),
bypass (false)
{
jassert (inputSource != nullptr);
}
ReverbAudioSource::~ReverbAudioSource() {}
void ReverbAudioSource::prepareToPlay (int samplesPerBlockExpected, double sampleRate)
{
const ScopedLock sl (lock);
input->prepareToPlay (samplesPerBlockExpected, sampleRate);
reverb.setSampleRate (sampleRate);
}
void ReverbAudioSource::releaseResources() {}
void ReverbAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
const ScopedLock sl (lock);
input->getNextAudioBlock (bufferToFill);
if (! bypass)
{
float* const firstChannel = bufferToFill.buffer->getSampleData (0, bufferToFill.startSample);
if (bufferToFill.buffer->getNumChannels() > 1)
{
reverb.processStereo (firstChannel,
bufferToFill.buffer->getSampleData (1, bufferToFill.startSample),
bufferToFill.numSamples);
}
else
{
reverb.processMono (firstChannel, bufferToFill.numSamples);
}
}
}
void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams)
{
const ScopedLock sl (lock);
reverb.setParameters (newParams);
}
void ReverbAudioSource::setBypassed (bool b) noexcept
{
if (bypass != b)
{
const ScopedLock sl (lock);
bypass = b;
reverb.reset();
}
}
END_JUCE_NAMESPACE
| [
"ow3nskip"
]
| [
[
[
1,
87
]
]
]
|
51519a8cbda593f13ec20a8fc65b0508ccbbbc93 | db5271c632341a315c709b638cbd4ea1fb147864 | /kg2/widget.h | c668567228bbb455f4b82faa344a7b7ec0c2b4c0 | []
| no_license | spetz911/CG | b81974913040c5820718e8d64f9061ba5a52b052 | dac535c69c9228ec32d241f4fc21c566b514cbb2 | refs/heads/master | 2021-01-20T07:04:51.304452 | 2011-09-30T22:53:08 | 2011-09-30T22:53:08 | 2,492,573 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 628 | h | #ifndef WIDGET_H
#define WIDGET_H
#include <QtGui/QWidget>
namespace Ui
{
class Widget;
}
void initialize();
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
void paintEvent(QPaintEvent * event);
void Widget::mousePressEvent(QMouseEvent *event);
void Widget::mouseMoveEvent(QMouseEvent *event);
void Widget::wheelEvent(QWheelEvent *event);
void Widget::keyPressEvent(QKeyEvent* event);
void Widget::keyReleaseEvent(QKeyEvent* event);
void Widget::init();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
| [
"[email protected]"
]
| [
[
[
1,
35
]
]
]
|
5cfa9b4ee3759dbd0d34000383f0c69fc0bc5cae | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/3rdParty/boost/libs/regex/example/timer/regex_timer.cpp | 98c412a7f329b23e1bde0f072af4dc32a15bc926 | [
"BSL-1.0"
]
| permissive | bugbit/cipsaoscar | 601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4 | 52aa8b4b67d48f59e46cb43527480f8b3552e96d | refs/heads/master | 2021-01-10T21:31:18.653163 | 2011-09-28T16:39:12 | 2011-09-28T16:39:12 | 33,032,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,959 | cpp | /*
*
* Copyright (c) 1998-2002
* Dr John Maddock
*
* Use, modification and distribution are subject to the
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#include <string>
#include <algorithm>
#include <deque>
#include <iterator>
#ifdef BOOST_RE_OLD_IOSTREAM
#include <iostream.h>
#include <fstream.h>
#else
#include <iostream>
#include <fstream>
using std::cout;
using std::cin;
using std::cerr;
using std::istream;
using std::ostream;
using std::endl;
using std::ifstream;
using std::streambuf;
using std::getline;
#endif
#include <boost/config.hpp>
#include <boost/regex.hpp>
#include <boost/timer.hpp>
#include <boost/smart_ptr.hpp>
#if (defined(_MSC_VER) && (_MSC_VER <= 1300)) || defined(__sgi)
// maybe no Koenig lookup, use using declaration instead:
using namespace boost;
#endif
#ifndef BOOST_NO_WREGEX
ostream& operator << (ostream& os, const std::wstring& s)
{
std::wstring::const_iterator i, j;
i = s.begin();
j = s.end();
while(i != j)
{
os.put(*i);
++i;
}
return os;
}
#endif
template <class S>
class string_out_iterator
#ifndef BOOST_NO_STD_ITERATOR
: public std::iterator<std::output_iterator_tag, void, void, void, void>
#endif // ndef BOOST_NO_STD_ITERATOR
{
#ifdef BOOST_NO_STD_ITERATOR
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
#endif // BOOST_NO_STD_ITERATOR
S* out;
public:
string_out_iterator(S& s) : out(&s) {}
string_out_iterator& operator++() { return *this; }
string_out_iterator& operator++(int) { return *this; }
string_out_iterator& operator*() { return *this; }
string_out_iterator& operator=(typename S::value_type v)
{
out->append(1, v);
return *this;
}
};
namespace boost{
#if defined(BOOST_MSVC) || (defined(__BORLANDC__) && (__BORLANDC__ == 0x550)) || defined(__SGI_STL_PORT)
//
// problem with std::getline under MSVC6sp3
// and C++ Builder 5.5, is this really that hard?
istream& getline(istream& is, std::string& s)
{
s.erase();
char c = is.get();
while(c != '\n')
{
s.append(1, c);
c = is.get();
}
return is;
}
#elif defined(__CYGWIN__)
istream& getline(istream& is, std::string& s)
{
std::getline(is, s);
if(s.size() && (s[s.size() -1] == '\r'))
s.erase(s.size() - 1);
return is;
}
#else
using std::getline;
#endif
}
int main(int argc, char**argv)
{
ifstream ifs;
streambuf* pbuf = 0;
if(argc == 2)
{
ifs.open(argv[1]);
if(ifs.bad())
{
cout << "Bad filename: " << argv[1] << endl;
return -1;
}
pbuf = cin.rdbuf(ifs.rdbuf());
}
boost::regex ex;
boost::match_results<std::string::const_iterator> sm;
#ifndef BOOST_NO_WREGEX
std::wstring ws1, ws2;
boost::wregex wex;
boost::match_results<std::wstring::const_iterator> wsm;
#endif
boost::match_results<std::deque<char>::iterator> dm;
std::string s1, s2, ts;
std::deque<char> ds;
boost::regex_t r;
boost::scoped_array<boost::regmatch_t> matches;
std::size_t nsubs;
boost::timer t;
double tim;
bool result;
int iters = 100;
double wait_time = (std::min)(t.elapsed_min() * 1000, 1.0);
while(true)
{
cout << "Enter expression (or \"quit\" to exit): ";
boost::getline(cin, s1);
if(argc == 2)
cout << endl << s1 << endl;
if(s1 == "quit")
break;
#ifndef BOOST_NO_WREGEX
ws1.erase();
std::copy(s1.begin(), s1.end(), string_out_iterator<std::wstring>(ws1));
#endif
try{
ex.assign(s1);
#ifndef BOOST_NO_WREGEX
wex.assign(ws1);
#endif
}
catch(std::exception& e)
{
cout << "Error in expression: \"" << e.what() << "\"" << endl;
continue;
}
int code = regcomp(&r, s1.c_str(), boost::REG_PERL);
if(code != 0)
{
char buf[256];
regerror(code, &r, buf, 256);
cout << "regcomp error: \"" << buf << "\"" << endl;
continue;
}
nsubs = r.re_nsub + 1;
matches.reset(new boost::regmatch_t[nsubs]);
while(true)
{
cout << "Enter string to search (or \"quit\" to exit): ";
boost::getline(cin, s2);
if(argc == 2)
cout << endl << s2 << endl;
if(s2 == "quit")
break;
#ifndef BOOST_NO_WREGEX
ws2.erase();
std::copy(s2.begin(), s2.end(), string_out_iterator<std::wstring>(ws2));
#endif
ds.erase(ds.begin(), ds.end());
std::copy(s2.begin(), s2.end(), std::back_inserter(ds));
int i;
iters = 10;
tim = 1.1;
#if defined(_WIN32) && defined(BOOST_REGEX_USE_WIN32_LOCALE)
MSG msg;
PeekMessage(&msg, 0, 0, 0, 0);
Sleep(0);
#endif
// cache load:
regex_search(s2, sm, ex);
// measure time interval for reg_expression<char>
do{
iters *= (tim > 0.001) ? (1.1/tim) : 100;
t.restart();
for(i =0; i < iters; ++i)
{
result = regex_search(s2, sm, ex);
}
tim = t.elapsed();
}while(tim < wait_time);
cout << "regex time: " << (tim * 1000000 / iters) << "us" << endl;
if(result)
{
for(i = 0; i < sm.size(); ++i)
{
ts = sm[i];
cout << "\tmatch " << i << ": \"";
cout << ts;
cout << "\" (matched=" << sm[i].matched << ")" << endl;
}
cout << "\tmatch $`: \"";
cout << std::string(sm[-1]);
cout << "\" (matched=" << sm[-1].matched << ")" << endl;
cout << "\tmatch $': \"";
cout << std::string(sm[-2]);
cout << "\" (matched=" << sm[-2].matched << ")" << endl << endl;
}
#ifndef BOOST_NO_WREGEX
// measure time interval for boost::wregex
iters = 10;
tim = 1.1;
// cache load:
regex_search(ws2, wsm, wex);
do{
iters *= (tim > 0.001) ? (1.1/tim) : 100;
t.restart();
for(i = 0; i < iters; ++i)
{
result = regex_search(ws2, wsm, wex);
}
tim = t.elapsed();
}while(tim < wait_time);
cout << "wregex time: " << (tim * 1000000 / iters) << "us" << endl;
if(result)
{
std::wstring tw;
for(i = 0; i < wsm.size(); ++i)
{
tw.erase();
std::copy(wsm[i].first, wsm[i].second, string_out_iterator<std::wstring>(tw));
cout << "\tmatch " << i << ": \"" << tw;
cout << "\" (matched=" << sm[i].matched << ")" << endl;
}
cout << "\tmatch $`: \"";
tw.erase();
std::copy(wsm[-1].first, wsm[-1].second, string_out_iterator<std::wstring>(tw));
cout << tw;
cout << "\" (matched=" << sm[-1].matched << ")" << endl;
cout << "\tmatch $': \"";
tw.erase();
std::copy(wsm[-2].first, wsm[-2].second, string_out_iterator<std::wstring>(tw));
cout << tw;
cout << "\" (matched=" << sm[-2].matched << ")" << endl << endl;
}
#endif
// measure time interval for reg_expression<char> using a deque
iters = 10;
tim = 1.1;
// cache load:
regex_search(ds.begin(), ds.end(), dm, ex);
do{
iters *= (tim > 0.001) ? (1.1/tim) : 100;
t.restart();
for(i = 0; i < iters; ++i)
{
result = regex_search(ds.begin(), ds.end(), dm, ex);
}
tim = t.elapsed();
}while(tim < wait_time);
cout << "regex time (search over std::deque<char>): " << (tim * 1000000 / iters) << "us" << endl;
if(result)
{
for(i = 0; i < dm.size(); ++i)
{
ts.erase();
std::copy(dm[i].first, dm[i].second, string_out_iterator<std::string>(ts));
cout << "\tmatch " << i << ": \"" << ts;
cout << "\" (matched=" << sm[i].matched << ")" << endl;
}
cout << "\tmatch $`: \"";
ts.erase();
std::copy(dm[-1].first, dm[-1].second, string_out_iterator<std::string>(ts));
cout << ts;
cout << "\" (matched=" << sm[-1].matched << ")" << endl;
cout << "\tmatch $': \"";
ts.erase();
std::copy(dm[-2].first, dm[-2].second, string_out_iterator<std::string>(ts));
cout << ts;
cout << "\" (matched=" << sm[-2].matched << ")" << endl << endl;
}
// measure time interval for POSIX matcher:
iters = 10;
tim = 1.1;
// cache load:
regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
do{
iters *= (tim > 0.001) ? (1.1/tim) : 100;
t.restart();
for(i = 0; i < iters; ++i)
{
result = regexec(&r, s2.c_str(), nsubs, matches.get(), 0);
}
tim = t.elapsed();
}while(tim < wait_time);
cout << "POSIX regexec time: " << (tim * 1000000 / iters) << "us" << endl;
if(result == 0)
{
for(i = 0; i < nsubs; ++i)
{
if(matches[i].rm_so >= 0)
{
ts.assign(s2.begin() + matches[i].rm_so, s2.begin() + matches[i].rm_eo);
cout << "\tmatch " << i << ": \"" << ts << "\" (matched=" << (matches[i].rm_so != -1) << ")"<< endl;
}
else
cout << "\tmatch " << i << ": \"\" (matched=" << (matches[i].rm_so != -1) << ")" << endl; // no match
}
cout << "\tmatch $`: \"";
ts.erase();
ts.assign(s2.begin(), s2.begin() + matches[0].rm_so);
cout << ts;
cout << "\" (matched=" << (matches[0].rm_so != 0) << ")" << endl;
cout << "\tmatch $': \"";
ts.erase();
ts.assign(s2.begin() + matches[0].rm_eo, s2.end());
cout << ts;
cout << "\" (matched=" << (matches[0].rm_eo != s2.size()) << ")" << endl << endl;
}
}
regfree(&r);
}
if(pbuf)
{
cin.rdbuf(pbuf);
ifs.close();
}
return 0;
}
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
380
]
]
]
|
d1287bd3d5f666dd1d9819cc7fc4a848a17a4985 | 22b6d8a368ecfa96cb182437b7b391e408ba8730 | /engine/include/qvInputReceiver.h | 3559c36e473b80ffada269703eec9f9a6eaa742b | [
"MIT"
]
| permissive | drr00t/quanticvortex | 2d69a3e62d1850b8d3074ec97232e08c349e23c2 | b780b0f547cf19bd48198dc43329588d023a9ad9 | refs/heads/master | 2021-01-22T22:16:50.370688 | 2010-12-18T12:06:33 | 2010-12-18T12:06:33 | 85,525,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,917 | h | /**************************************************************************************************
//
//This code is part of QuanticVortex for latest information, see http://www.quanticvortex.org
//
//Copyright (c) 2009-2010 QuanticMinds Software Ltda.
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
//
**************************************************************************************************/
#ifndef __INPUT_RECEIVER_H_
#define __INPUT_RECEIVER_H_
#include <vector>
#include "qvSingleKeyInputTranslator.h"
#include "qvAnyKeyInputTranslator.h"
#include "qvIInputTranslator.h"
#include "qvIInputTranslatorFactory.h"
namespace qv
{
namespace input
{
class InputReceiverContext
// used to test user inputs
{
public:
InputReceiverContext()
{
}
~InputReceiverContext()
{
}
void updateKeyboard(qv::input::EKEY_CODE keycode, bool pressedDown);
//context
bool keyPressed(qv::input::EKEY_CODE keycode) const;
bool keyDown(qv::input::EKEY_CODE keycode) const;
bool keyUp(qv::input::EKEY_CODE keycode) const;
bool keyReleased(qv::input::EKEY_CODE keycode) const;
private:
EKEY_STATE mKeyState[qv::input::KEY_KEY_CODES_COUNT];
};
//context
inline void InputReceiverContext::updateKeyboard(qv::input::EKEY_CODE keycode, bool pressedDown)
{
if (pressedDown)
{
if (mKeyState[keycode] != qv::input::EKS_DOWN)
mKeyState[keycode] = qv::input::EKS_PRESSED;
else
mKeyState[keycode] = qv::input::EKS_DOWN;
}
else if (mKeyState[keycode] != qv::input::EKS_UP)
{
mKeyState[keycode] = qv::input::EKS_RELEASED;
}
}
inline bool InputReceiverContext::keyPressed(qv::input::EKEY_CODE keycode) const
{
return (mKeyState[keycode] == EKS_PRESSED);
};
inline bool InputReceiverContext::keyDown(qv::input::EKEY_CODE keycode) const
{
return (mKeyState[keycode] == EKS_DOWN || mKeyState[keycode] == EKS_PRESSED);
};
inline bool InputReceiverContext::keyUp(qv::input::EKEY_CODE keycode) const
{
return (mKeyState[keycode] == EKS_UP || mKeyState[keycode] == EKS_RELEASED);
};
inline bool InputReceiverContext::keyReleased(qv::input::EKEY_CODE keycode) const
{
return (mKeyState[keycode] == EKS_RELEASED);
};
class _QUANTICVORTEX_API_ InputReceiver
//base input receiver shoud be derived to each plataform, like: Irrlicht, OIS, etc
{
public:
InputReceiver()
{
}
virtual ~InputReceiver(void)
{
std::vector<IInputTranslator*>::iterator itr = mInputTranslators.begin();
for(; itr != mInputTranslators.end(); itr++)
delete (*itr);
mInputTranslators.clear();
}
qv::input::InputReceiverContext& getInputContext();
bool translateInput() const;
//passe input trought all translators, until first return true.
void updateTime( u32 currentTimeMs, u32 elapsedTimeMs)
{
mCurrentTimeMs = currentTimeMs;
mElapsedTimeMs = elapsedTimeMs;
}
protected:
IInputTranslator* getInputTranslator( u32 inputTranslatorHashId)
{
IInputTranslator* inputTranslator = 0;
// for(u32 i = 0; i < mInputTranslators.size(); ++i)
// {
// if(mInputTranslators[i]->getHashId() == inputTranslatorHashId)
// {
// inputTranslator = mInputTranslators[i];
// break;
// }
// }
return inputTranslator;
}
//translators
// virtual IInputTranslatorSharedPtr addSingleKeyTranslator (const c8* inputTranslatorName, EKEY_CODE keyCode, EKEY_STATE checkState, events::IEventArgsSharedPtr args, bool realTime = false)
// {
// IInputTranslatorSharedPtr translator(new SingleKeyInputTranslator( mEventManager, keyCode, checkState, realTime, args, inputTranslatorName));
// mInputTranslators.push_back(translator);
//
// return translator;
// }
// virtual IInputTranslatorSharedPtr addSingleKeyTranslator (const c8* inputTranslatorName, EKEY_CODE keyCode, EKEY_STATE checkState, u32 inputTranslatorHashType, bool realTime = false)
// {
// IInputTranslatorSharedPtr translator(new SingleKeyInputTranslator( mEventManager, keyCode, checkState, realTime, inputTranslatorHashType, inputTranslatorName));
// registerInputTranslator(translator);
//
// return translator;
// }
// virtual IInputTranslatorSharedPtr addAnyKeyTranslator (const c8* inputTranslatorName, events::IEventArgsSharedPtr args, bool realTime = false)
// {
// IInputTranslatorSharedPtr translator(new AnyKeyInputTranslator( mEventManager, realTime, args,inputTranslatorName));
// mInputTranslators.push_back(translator);
//
// return translator;
// }
//
void registerInputTranslator( IInputTranslator* translator)
{
// IInputTranslatorSharedPtr inputTranslator = getInputTranslator(translator->getHashId());
//
// if(!inputTranslator)
// mInputTranslators.push_back(translator);
}
void unregisterInputTranslator( u32 inputTranslatorHashId)
{
}
void unregisterInputTranslator( IInputTranslator* translator)
{
}
void registerInputTranslatorFactory( IInputTranslatorFactory* factory)
{
// factory->grab();
// mInputTranslatorsFactories.push_back(factory);
}
private:
u32 mCurrentTimeMs;
u32 mElapsedTimeMs;
InputReceiverContext mInputContext;
// crrent of input receiver context
//i need see which collection will work bether here
std::vector<IInputTranslator*> mInputTranslators;
std::vector<IInputTranslatorFactory*> mInputTranslatorsFactories;
};
//inlines
inline qv::input::InputReceiverContext& InputReceiver::getInputContext()
{
return mInputContext;
};
inline bool InputReceiver::translateInput() const
{
//command for keyboard event registred by InputTranslators can executed here
for(u32 i = 0; i < mInputTranslators.size(); ++i)
if(mInputTranslators[i]->translate(mInputContext))
return true;
return false;
};
}
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
247
]
]
]
|
5d6b9636ef3d949083f63e25921860d52ddbc4ab | 724cded0e31f5fd52296d516b4c3d496f930fd19 | /source/Bittorrent/tools/libtorrenttest/libtorrenttest/libtorrenttest.cpp | 72309ffd02f660abd0de8b18430c9c0098e03eda | []
| no_license | yubik9/p2pcenter | 0c85a38f2b3052adf90b113b2b8b5b312fefcb0a | fc4119f29625b1b1f4559ffbe81563e6fcd2b4ea | refs/heads/master | 2021-08-27T15:40:05.663872 | 2009-02-19T00:13:33 | 2009-02-19T00:13:33 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 867 | cpp | // libtorrenttest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "../libtorrent/IBittorrent.h"
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
if ( argc < 2)
{
printf("par error.\nright: libtorrenttest.exe <.torrent file filepath>\n");
return -1;
}
IBittorrent* bittorrent =CreateIBittorrent();
if ( bittorrent->InitModule( 0))
{
printf("Init succeed.\n");
DWORD torrent =bittorrent->OpenSource( argv[1], false);
//DWORD torrent =bittorrent->OpenSource( "C:\\bbs[1].wofei.net@穿越大吉岭.torrent", false);
printf("open torrent: %d\n", torrent);
while ( 1 )
{
if ( kbhit() )
{
char key = getch();
if ( key == 27 )
{
break;
}
}
bittorrent->tick_it();
Sleep(50);
}
bittorrent->ReleaseModule();
}
return 0;
}
| [
"fuwenke@b5bb1052-fe17-11dd-bc25-5f29055a2a2d"
]
| [
[
[
1,
43
]
]
]
|
ccbbb0a68e8860936a44b75e709d54ec36a73280 | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /NpcServer/NpcServer.h | dd160143f5c3e525d12dac5d0c490e85c993afd5 | []
| no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 926 | h | // NpcServer.h : main header file for the NPCSERVER application
//
#pragma once
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
///////
// CNpcServerApp:
// See NpcServer.cpp for the implementation of this class
//
class CNpcServerApp : public CWinApp
{
public:
CNpcServerApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNpcServerApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CNpcServerApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
///////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
]
| [
[
[
1,
43
]
]
]
|
085b0f6324650482a5bde5a087f213b8e77b2640 | ad80c85f09a98b1bfc47191c0e99f3d4559b10d4 | /code/inc/ode/dcOBBCollider.h | a01fd67bbd2bb03b6225d0809015ea5616c6eb19 | []
| no_license | DSPNerd/m-nebula | 76a4578f5504f6902e054ddd365b42672024de6d | 52a32902773c10cf1c6bc3dabefd2fd1587d83b3 | refs/heads/master | 2021-12-07T18:23:07.272880 | 2009-07-07T09:47:09 | 2009-07-07T09:47:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,116 | h | #ifndef __DCOBBCOLLIDER_INCLUDED__
#define __DCOBBCOLLIDER_INCLUDED__
class __declspec(dllexport) dcOBBTreeCollider{
Point Box;
float BBx1;
float BBy1;
float BBz1;
float BB_1;
float BB_2;
float BB_3;
float BB_4;
float BB_5;
float BB_6;
float BB_7;
float BB_8;
float BB_9;
Matrix3x3 mAR;
Matrix3x3 mR0to1;
Matrix3x3 mR1to0;
Point mT0to1;
Point mT1to0;
Point LeafVerts[3];
udword LeafIndex;
public:
/* In */
const dcVector3*& Vertices;
const int*& Indices;
dArray<const AABBNoLeafNode*>* TCData;
/* Out */
dArray<int> Contacts;
/* Constructor/destructor */
dcOBBTreeCollider(const dcVector3*& Vertices, const int*& Indices);
~dcOBBTreeCollider();
/* Collision queries */
void Collide(const AABBNoLeafTree* Tree, const Point& Box, const Matrix4x4& BoxMatrix);
private:
void _CollideTriBox();
void _Collide(const AABBNoLeafNode* a);
bool BoxBoxOverlap(const Point& a, const Point& Pa);
bool TriBoxOverlap();
void InitQuery(const Point& Box, const Matrix4x4& BoxMatrix);
};
#endif // __DCCOBBCOLLIDER_INCLUDED__
| [
"plushe@411252de-2431-11de-b186-ef1da62b6547"
]
| [
[
[
1,
56
]
]
]
|
43b3350271e66abd7377d50a7ea1a0af2b41b1ff | b22c254d7670522ec2caa61c998f8741b1da9388 | /common/ScriptableActor.cpp | f36cee7048b64b7f23a234910a21efc4006a02d7 | []
| no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,982 | cpp | /*
------------------------[ Lbanet Source ]-------------------------
Copyright (C) 2009
Author: Vivien Delage [Rincevent_123]
Email : [email protected]
-------------------------------[ GNU License ]-------------------------------
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/>.
-----------------------------------------------------------------------------
*/
#include "ScriptableActor.h"
#include <math.h>
#include <algorithm>
#ifndef _LBANET_SERVER_SIDE_
#include "ThreadSafeWorkpile.h"
#include "DataLoader.h"
#include "MusicHandler.h"
#include "CharacterRenderer.h"
#else
#include "ServerCharacterRenderer.h"
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846f
#endif
/***********************************************************
Constructor
***********************************************************/
ScriptableActor::ScriptableActor(const std::vector<PlayerScriptPart> & scripts, bool IsLift)
: _scripts(scripts), _curr_script_position(0), _started_timer(false),
_playedsound(-1), _playingsound(0), _IsLift(IsLift), _needs_update(false),
_forceanim(false)
{
}
/***********************************************************
Destructor
***********************************************************/
ScriptableActor::~ScriptableActor()
{
#ifndef _LBANET_SERVER_SIDE_
if(_playingsound > 0)
{
MusicHandler::getInstance()->StopSample(_playingsound);
_playingsound = 0;
}
#endif
}
/***********************************************************
do all check to be done when idle
***********************************************************/
int ScriptableActor::Process(double tnow, float tdiff)
{
if(_curr_script_position < _scripts.size())
{
PlayerScriptPart &ps = _scripts[_curr_script_position];
#ifndef _LBANET_SERVER_SIDE_
if(ps.Sound >= 0)
{
if(_playedsound != ps.Sound)
{
if(_playingsound > 0)
{
MusicHandler::getInstance()->StopSample(_playingsound);
_playingsound = 0;
}
std::string soundp = DataLoader::getInstance()->GetSoundPath(ps.Sound);
if(soundp != "")
_playingsound = MusicHandler::getInstance()->PlaySample(soundp, ps.SoundNum);
}
}
else
{
if(_playingsound > 0)
{
MusicHandler::getInstance()->StopSample(_playingsound);
_playingsound = 0;
}
}
_playedsound = ps.Sound;
if(ps.Type == 2 && _last_script_position != _curr_script_position)
_forceanim = true;
if(ps.Animation >= 0 && _Renderer && _Renderer->GetType() == 3)
static_cast<CharacterRenderer *>(_Renderer)->setActorAnimation(ps.Animation, _forceanim);
_forceanim = false;
_last_script_position = _curr_script_position;
#else
if(ps.Animation >= 0 && _Renderer && _Renderer->GetType() == 3)
static_cast<ServerCharacterRenderer *>(_Renderer)->setActorAnimation(ps.Animation);
#endif
switch(ps.Type)
{
case 0: // rotation
{
double expectedR = ps.ValueA;
double currR = GetRotation();
double diff, diff2;
if(expectedR < currR)
expectedR += 360;
diff = expectedR - currR;
diff2 = diff-360;
if(fabs(diff2) < fabs(diff))
diff = diff2;
float step = (float)(tdiff*ps.Speed * ((diff > 0) ? 1 : -1));
if(fabs(step) > fabs(diff))
{
IncreaseScriptPosition();
step = (float)diff;
}
SetRotation(GetRotation() + step);
}
break;
case 1: // translation
{
double expectedX = ps.ValueA;
double expectedY = ps.ValueB;
double expectedZ = ps.ValueC;
double currX = GetPosX();
double currY = GetPosY();
double currZ = GetPosZ();
double diffX = expectedX - currX;
double diffY = expectedY - currY;
double diffZ = expectedZ - currZ;
double stepX = tdiff*ps.Speed * ((diffX > 0) ? 1 : -1);
double stepY = tdiff*ps.Speed * ((diffY > 0) ? 1 : -1);
double stepZ = tdiff*ps.Speed * ((diffZ > 0) ? 1 : -1);
if(fabs(stepX) > fabs(diffX))
stepX = diffX;
if(fabs(stepY) > fabs(diffY))
stepY = diffY;
if(fabs(stepZ) > fabs(diffZ))
stepZ = diffZ;
if(stepX == 0 && stepY == 0 && stepZ == 0)
IncreaseScriptPosition();
UpdatePosition(stepX, stepY, stepZ, tdiff);
}
break;
case 2: // animation
{
int animend = (int)ps.ValueA;
#ifndef _LBANET_SERVER_SIDE_
if(_Renderer)
{
if(animend >= 0)
{
if(_Renderer && _Renderer->GetType() == 3)
if(static_cast<CharacterRenderer *>(_Renderer)->getKeyframe() >= animend)
IncreaseScriptPosition();
}
else
{
if(_Renderer && _Renderer->GetType() == 3)
if(static_cast<CharacterRenderer *>(_Renderer)->IsAnimationFinished())
IncreaseScriptPosition();
}
}
if(!_started_timer)
{
_started_timer = true;
_timer_start_time = tnow;
}
else
{
// put a timer in case the animation gets stuck
if(tnow - _timer_start_time > 30000)
IncreaseScriptPosition();
}
#else
if(_Renderer)
{
if(animend >= 0)
{
if(_Renderer && _Renderer->GetType() == 3)
if(static_cast<ServerCharacterRenderer *>(_Renderer)->getKeyframe() >= animend)
IncreaseScriptPosition();
}
else
{
if(_Renderer && _Renderer->GetType() == 3)
if(static_cast<ServerCharacterRenderer *>(_Renderer)->Process(tnow, tdiff) == 1)
IncreaseScriptPosition();
}
}
#endif
}
break;
case 3: // inform event
{
std::vector<long> vectar;
vectar.push_back((int)ps.ValueA);
int targetsignal = (int)ps.ValueB;
SendSignal(targetsignal, vectar);
IncreaseScriptPosition();
}
break;
case 4: // wait for signal event
{
long sig = (long)ps.ValueA;
std::vector<long>::iterator it = std::find(_receivedsignals.begin(), _receivedsignals.end(), sig);
if(it != _receivedsignals.end())
{
_receivedsignals.erase(it);
IncreaseScriptPosition();
}
}
break;
case 5: // wait for ms
{
if(!_started_timer)
{
_started_timer = true;
_timer_start_time = tnow;
}
else
{
if(tnow - _timer_start_time > ps.ValueA)
IncreaseScriptPosition();
}
}
break;
case 6: // do a curve
{
// do rotation part
double expectedR = ps.ValueA;
double currR = GetRotation();
double diff, diff2;
if(expectedR < currR)
expectedR += 360;
diff = expectedR - currR;
diff2 = diff-360;
if(fabs(diff2) < fabs(diff))
diff = diff2;
float step = (float)(tdiff*ps.Speed * ((diff > 0) ? 1 : -1));
if(fabs(step) > fabs(diff))
{
IncreaseScriptPosition();
step = (float)diff;
}
SetRotation(GetRotation() + step);
// do translation part
{
double translationSpeed = -ps.ValueB;
int nbA = ((int)GetRotation()) / 90;
int modA = ((int)GetRotation()) % 90;
float radA = M_PI * (modA) / 180.0f;
double _velocityX, _velocityZ;
if(nbA == 0)
{
_velocityX = sin(radA) * -translationSpeed;
_velocityZ = cos(radA) * -translationSpeed;
}
if(nbA == 1)
{
_velocityX = cos((float)radA) * -translationSpeed;
_velocityZ = sin((float)radA) * translationSpeed;
}
if(nbA == 2)
{
_velocityX = sin(radA) * translationSpeed;
_velocityZ = cos(radA) * translationSpeed;
}
if(nbA == 3)
{
_velocityX = cos((float)radA) * translationSpeed;
_velocityZ = sin((float)radA) * -translationSpeed;
}
double stepX = tdiff*_velocityX;
double stepZ = tdiff*_velocityZ;
UpdatePosition(stepX, 0, stepZ, tdiff);
}
}
break;
case 7: // hide
{
Hide();
IncreaseScriptPosition();
}
break;
case 8: // show
{
Show();
IncreaseScriptPosition();
}
break;
case 9: // change body
{
#ifndef _LBANET_SERVER_SIDE_
if(_Renderer)
{
CharacterRenderer * rend = static_cast<CharacterRenderer *>(_Renderer);
rend->changeAnimEntity(rend->GetModel(), (int)ps.ValueA);
rend->setActorAnimation(((ps.Animation>= 0) ? ps.Animation : 0));
}
#endif
IncreaseScriptPosition();
}
break;
}
}
return Actor::Process(tnow, tdiff);
}
/***********************************************************
called on signal
***********************************************************/
bool ScriptableActor::OnSignal(long SignalNumber)
{
_receivedsignals.push_back(SignalNumber);
return true;
}
/***********************************************************
get current actor state
return false if the actor is stateless
***********************************************************/
bool ScriptableActor::Getstate(ActorStateInfo & currState)
{
currState.ActorId = _ID;
currState.CurrentScript = _curr_script_position;
currState.CurrentSignals = _receivedsignals;
currState.X = GetPosX();
currState.Y = GetPosY();
currState.Z = GetPosZ();
currState.Rotation = GetRotation();
currState.Visible = Visible();
currState.Targets = _actiontargets;
return true;
}
/***********************************************************
set the actor state
***********************************************************/
void ScriptableActor::Setstate(const ActorStateInfo & currState)
{
_receivedsignals = currState.CurrentSignals;
while(_curr_script_position != currState.CurrentScript)
{
if(_curr_script_position < _scripts.size())
{
PlayerScriptPart &ps = _scripts[_curr_script_position];
if(_scripts[_curr_script_position].Type == 3)
{
std::vector<long> vectar;
vectar.push_back((int)ps.ValueA);
int targetsignal = (int)ps.ValueB;
SendSignal(targetsignal, vectar);
}
}
IncreaseScriptPosition(true);
}
SetRotation(currState.Rotation);
SetPosition(currState.X, currState.Y, currState.Z);
if(currState.Visible)
Show();
else
Hide();
_actiontargets = currState.Targets;
_forceanim = true;
}
/***********************************************************
check if the actor should be attached
***********************************************************/
bool ScriptableActor::CheckAttach(Actor * act)
{
if(!_IsLift)
return false;
float posX = GetPosX();
float posY = GetPosY();
float posZ = GetPosZ();
if( (act->GetPosX() >= (posX-_sizeX) && act->GetPosX() < (posX+_sizeX)) &&
(act->GetPosY() >= (posY) && act->GetPosY() < (posY+_sizeY+1)) &&
(act->GetPosZ() >= (posZ-_sizeZ) && act->GetPosZ() < (posZ+_sizeZ)))
{
//act->SetPosition(act->GetPosX(), posY+_sizeY, act->GetPosZ());
Attach(act);
return true;
}
return false;
}
/***********************************************************
check if the actor should be dettached
***********************************************************/
bool ScriptableActor::CheckDettach(Actor * act)
{
if(!_IsLift)
return false;
float posX = GetPosX();
float posY = GetPosY();
float posZ = GetPosZ();
if( (act->GetPosX() >= (posX-_sizeX) && act->GetPosX() < (posX+_sizeX)) &&
(act->GetPosY() >= (posY) && act->GetPosY() < (posY+_sizeY+1)) &&
(act->GetPosZ() >= (posZ-_sizeZ) && act->GetPosZ() < (posZ+_sizeZ)))
{
return false;
}
return Dettach(act);
}
/***********************************************************
increase script position
***********************************************************/
void ScriptableActor::IncreaseScriptPosition(bool forcedreset)
{
++_curr_script_position;
_started_timer = false;
if(_curr_script_position >= _scripts.size())
{
#ifdef _LBANET_SERVER_SIDE_
_curr_script_position = 0;
_needs_update = true;
#else
if(forcedreset || !ThreadSafeWorkpile::getInstance()->IsServeron())
_curr_script_position = 0;
#endif
}
}
/***********************************************************
if the actor needs to be updated client side
***********************************************************/
bool ScriptableActor::NeedsUpdate()
{
bool res = _needs_update;
_needs_update = false;
return res;
} | [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
512
]
]
]
|
4c227d662fe5db9e18f8930e0dd10332e0c5bc74 | a29ec259efa2c2f13e24be86a4c6ba174780857d | /projects/tpfinal/RPGCharacter.h | bc34ca6cf026b491d7dcf60494c2fac1c12ec4c0 | []
| no_license | nlelouche/programacion2 | 639ffb55d06af4f696031ec777bec898b6224774 | 5ec9b29014c13786230e834deb44679b110351b4 | refs/heads/master | 2016-09-06T15:40:38.888016 | 2007-11-09T01:03:51 | 2007-11-09T01:03:51 | 32,653,635 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,301 | h | #ifndef _RPG_CHARACTER_H_
#define _RPG_CHARACTER_H_
//---------------------------------------------------------------------------
#include "RPGMap.h"
using namespace zak;
//---------------------------------------------------------------------------
#define MAX_ACTIONS 10 //TO-DO: Pasar al config
#define MAX_ITEMS 10 //TO-DO: Pasar al config
//---------------------------------------------------------------------------
class RPGAction;
class RPGItem;
//---------------------------------------------------------------------------
class RPGCharacter : public Sprite
{
protected:
// propiedades generales
static RPGCharacter* m_pkPlayer; // puntero al personaje del jugador
RPGCharacter* m_pkColliding; // puntero al personaje con el cual se esta colisionando
// acciones
RPGAction* m_kActions[MAX_ACTIONS]; // array de acciones
RPGAction* m_pCurrentAction; // puntero a la accion actual
unsigned int m_uiActionsCount; // cantidad actual de acciones
float m_fCurrentActionTime; // tiempo actual de la accion
RPGAction* m_pLastAction; // puntero a la accion del frame anterior
bool m_WasActionExecuted; // indica si la accion ya fue ejecutada
// items
RPGItem* m_kItems[MAX_ITEMS]; // array de items
unsigned int m_uiItemsCount; // cantidad actual de items
// atributos
float m_fEnergy; // cantidad actual de energia
float m_fMaxEnergy; // cantidad maxima de energia
public:
RPGCharacter();
virtual ~RPGCharacter();
// le agrega una nueva accion al personaje
void AddNewAction(
char *pszName, Animation *pAnimation,
float fTimeToExecute, float fTimeToFinish
);
void AddNewAction(RPGAction* pkAction);
// setea el personaje del jugador para ser accedido por todas las instancias de RPGCharacter
static void SetPlayerCharacter(RPGCharacter* pkPlayer);
static RPGCharacter* GetPlayerCharacter();
// setea el personaje con el cual esta colisionando
void SetCollisionCharacter(RPGCharacter* pkColliding);
RPGCharacter* GetCollisionCharacter();
// setea la accion actual del personaje
bool SetCurrentAction(char *pszActionName);
// metodo llamado cuando se termina una accion
virtual void OnActionFinished(char *pszName);
// agrega un item al inventario
void AddItem(RPGItem *pkItemToInsert);
// devuelve el valor de un item
RPGItem *GetItem(unsigned int uiIndex);
// sobrecargas de los metodos de Entity2D
virtual void Draw();
virtual void Update(float fTimeBetweenFrames);
// actualiza la IA del personaje
virtual void UpdateIA(float fTimeBetweenFrames);
// acciones genericas
virtual void Idle();
virtual void Hit();
virtual void Move(float fDirection);
void UseItem(unsigned int uiIndex);
// chequea colision contra un Entity2D (solamente cajas...)
bool CheckCollision(Sprite *pkSprite);
//-----------------------------------------------------------
// acceso a atributos
float GetEnergy(); // devuelve la cantidad actual de energia
void SetEnergy(float fEnergy); // setea la cantidad actual de energia
float GetMaxEnergy(); // devuelve la cantidad maxima de energia
void SetMaxEnergy(float fMaxEnergy); // setea la cantidad maxima de energia
};
#endif //_RPG_CHARACTER_H_ | [
"yoviacthulhu@70076bbf-733e-0410-a12a-85c366f55b74"
]
| [
[
[
1,
99
]
]
]
|
3ec1ea064028ae74e37f53bbcc622eb42e828522 | f08e489d72121ebad042e5b408371eaa212d3da9 | /TP1_v2/src/BPlusTree/KeyElement.cpp | 1bd21c6b68b83aff3f0edd29a7abccd280eed7d5 | []
| no_license | estebaneze/datos022011-tp1-vane | 627a1b3be9e1a3e4ab473845ef0ded9677e623e0 | 33f8a8fd6b7b297809a0feac14d10f9815f8388b | refs/heads/master | 2021-01-20T03:35:36.925750 | 2011-12-04T18:19:55 | 2011-12-04T18:19:55 | 41,821,700 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,282 | cpp | /*
* KeyElement.cpp
*
* Created on: Apr 3, 2010
* Author: sergio
*/
#include "KeyElement.h"
KeyElement::KeyElement() {
this->rightNode=-1;
}
KeyElement::KeyElement(Key key,Offset rightNode) {
this->key = key;
this->rightNode = rightNode;
}
KeyElement::~KeyElement() {
}
void KeyElement::setRightNode(Offset rightNode) {
this->rightNode = rightNode;
}
Offset KeyElement::getrightNode(){
return rightNode;
}
void KeyElement::setKey(Key key) {
this->key = key;
}
Key KeyElement::getKey(){
return this->key;
}
ostream& operator<<(ostream& myOstream, KeyElement& elem){
myOstream<<elem.getKey()<<" RightOffSet: "<<elem.getrightNode()<<" ";
return myOstream;
}
/******************************************************
* PERSISTENCIA
*
****************************************************/
std::string KeyElement::serialize() {
std::string buffer = "";
buffer.append((char*)&key,sizeof(Key));
buffer.append((char*)&rightNode,sizeof(Offset));
return buffer;
}
void KeyElement::unserialize(std::string &buffer) {
buffer.copy((char*)&key,sizeof(key));
buffer.erase(0,sizeof(key));
buffer.copy((char*)&rightNode,sizeof(Offset));
buffer.erase(0,sizeof(Offset));
}
int KeyElement::getDataSize(){
return (sizeof(Key) + sizeof(Offset));
}
| [
"[email protected]"
]
| [
[
[
1,
71
]
]
]
|
9e6148c2ece0a4a179918e471ba4a4efcfa8cf81 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ClientShellDLL/ClientShellShared/CursorMgr.cpp | 831dbfa0e03f9bc1e8217495b8ceb673448dadb2 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,468 | cpp | // ----------------------------------------------------------------------- //
//
// MODULE : CursorMgr.cpp
//
// PURPOSE : Manage all mouse cursor related functionality
//
// CREATED : 12/3/01
//
// (c) 2001-2002 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#include "stdafx.h"
#include "VarTrack.h"
#include "InterfaceMgr.h"
#include "CursorMgr.h"
#include "ClientResShared.h"
VarTrack g_vtCursorHack;
CCursorMgr * g_pCursorMgr = LTNULL;
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr constructor and destructor
//
// PURPOSE: Set initial values on ctor, force a Term() on dtor
//
// ----------------------------------------------------------------------- //
CCursorMgr::CCursorMgr()
{
g_pCursorMgr = this;
m_bUseCursor = LTFALSE;
m_bUseHardwareCursor = LTFALSE;
m_bInitialized = LTFALSE;
m_pCursorSprite = LTNULL;
m_pCursorGlowSprite = LTNULL;
m_pCursorBackgroundSprite = LTNULL;
}
CCursorMgr::~CCursorMgr()
{
Term();
g_pCursorMgr = LTNULL;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::Init
//
// PURPOSE: Init the cursor
//
// ----------------------------------------------------------------------- //
LTBOOL CCursorMgr::Init()
{
if (m_bInitialized)
return LTTRUE;
// The following line was pulled from InterfaceMgr::Init()
g_vtCursorHack.Init(g_pLTClient, "CursorHack", NULL, 0.0f);
if (g_pLTClient->Cursor()->LoadCursorBitmapResource(MAKEINTRESOURCE(IDC_POINTER), m_hCursor) != LT_OK)
{
g_pLTClient->CPrint("can't load cursor resource.");
return LTFALSE;
}
if (g_pLTClient->Cursor()->SetCursor(m_hCursor) != LT_OK)
{
g_pLTClient->CPrint("can't set cursor.");
return LTFALSE;
}
UseHardwareCursor( GetConsoleInt("HardwareCursor",0) > 0 && GetConsoleInt("DisableHardwareCursor",0) == 0);
if (!m_hSurfCursor)
m_hSurfCursor = g_pLTClient->CreateSurfaceFromBitmap("interface\\cursor0.pcx");
_ASSERT(m_hSurfCursor);
m_pCursorSprite = LTNULL; // stay with the default cursor until this points to something
m_pCursorGlowSprite = LTNULL;
m_pCursorBackgroundSprite = LTNULL;
// Uncomment the line below if you want to see an animated cursor!
// UseSprite("Interface\\Menu\\spr\\cursortest.spr");
m_bInitialized = LTTRUE;
m_CursorCenter.x = 16;
m_CursorCenter.y = 16;
return LTTRUE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::Term
//
// PURPOSE: Free cursor resources
//
// ----------------------------------------------------------------------- //
void CCursorMgr::Term()
{
if (!m_bInitialized)
return;
if (m_hSurfCursor)
{
g_pLTClient->DeleteSurface(m_hSurfCursor);
m_hSurfCursor = LTNULL;
}
// don't need to clean this up, just erase the list. SpriteMgr will clean up.
m_SpriteArray.clear();
m_pCursorSprite = LTNULL;
m_pCursorGlowSprite = LTNULL;
m_pCursorBackgroundSprite = LTNULL;
m_bInitialized = LTFALSE;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::ScheduleReinit(float fHack)
//
// PURPOSE: Set up a delayed initialization
//
// ----------------------------------------------------------------------- //
void CCursorMgr::ScheduleReinit(float fDelay)
{
g_vtCursorHack.SetFloat(fDelay);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::CheckForReinit
//
// PURPOSE: Update any hack variables (reducing frame delay counter)
//
// ----------------------------------------------------------------------- //
void CCursorMgr::CheckForReinit()
{
// because of driver bugs, we need to wait a frame after reinitializing the renderer and
// reinitialize the cursor
int nCursorHackFrameDelay = (int)g_vtCursorHack.GetFloat();
if (nCursorHackFrameDelay)
{
nCursorHackFrameDelay--;
g_vtCursorHack.SetFloat((LTFLOAT)nCursorHackFrameDelay);
if (nCursorHackFrameDelay == 1)
Init();
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::UseCursor
//
// PURPOSE: Handle activation and deactivation of visible cursor
//
// ----------------------------------------------------------------------- //
void CCursorMgr::UseCursor(LTBOOL bUseCursor, LTBOOL bLockCursorToCenter)
{
m_bUseCursor = bUseCursor;
// New hardware code:
// if the cursor is visible and being used, ONLY enable the hardware
// cursor if no sprite has been specified
if (m_bUseCursor && m_bUseHardwareCursor && !m_pCursorSprite)
{
g_pLTClient->Cursor()->SetCursorMode(CM_Hardware);
// copied the following 4 lines from Init()
if (g_pLTClient->Cursor()->SetCursor(m_hCursor) != LT_OK)
{
g_pLTClient->CPrint("can't set cursor.");
}
}
else
{
g_pLTClient->Cursor()->SetCursorMode(CM_None);
// Kill any cursor sprite
KillSprite();
}
// Lock or don't lock the cursor to the center of the screen
if(bLockCursorToCenter)
{
g_pLTClient->RunConsoleString("CursorCenter 1");
}
else
{
g_pLTClient->RunConsoleString("CursorCenter 0");
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::UseHardwareCursor
//
// PURPOSE: (De)activate the Windows cursor drawing routines
//
// ----------------------------------------------------------------------- //
void CCursorMgr::UseHardwareCursor(LTBOOL bUseHardwareCursor,bool bForce)
{
m_bUseHardwareCursor = bUseHardwareCursor;
if (m_bUseHardwareCursor && m_bUseCursor && !m_pCursorSprite)
{
g_pLTClient->Cursor()->SetCursorMode(CM_Hardware,bForce);
}
else
{
g_pLTClient->Cursor()->SetCursorMode(CM_None,bForce);
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::Update
//
// PURPOSE: Display a cursor bitmap, if required, or update the sprite coords
//
// ----------------------------------------------------------------------- //
void CCursorMgr::Update()
{
static const HLTCOLOR kTrans = SETRGB_T(255,0,255);
LTBOOL bHWC = (GetConsoleInt("HardwareCursor",0) > 0 && GetConsoleInt("DisableHardwareCursor",0) == 0);
if (bHWC != m_bUseHardwareCursor)
UseHardwareCursor(bHWC);
if (!m_bUseCursor)
return;
if (m_bUseHardwareCursor && !m_pCursorSprite)
return;
LTIntPt CursorPos = g_pInterfaceMgr->GetCursorPos();
// If a software cursor is needed but none has been specified, use the default
if (!m_pCursorSprite)
{
// TODO: replace with DrawPrim
g_pLTClient->Start3D();
g_pLTClient->StartOptimized2D();
g_pLTClient->DrawSurfaceToSurfaceTransparent(g_pLTClient->GetScreenSurface(), m_hSurfCursor, LTNULL,
CursorPos.x, CursorPos.y, kTrans);
g_pLTClient->EndOptimized2D();
g_pLTClient->End3D();
return;
}
// Update the sprite coordinates
m_pCursorSprite->SetPosition(CursorPos);
// update any additional bitmaps
if (m_pCursorGlowSprite)
m_pCursorGlowSprite->SetPosition(CursorPos);
if (m_pCursorBackgroundSprite)
m_pCursorBackgroundSprite->SetPosition(CursorPos);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::SetCenter
//
// PURPOSE: Specify a new "center" point for any sprites used to
// display the current cursor position
//
// ----------------------------------------------------------------------- //
void CCursorMgr::SetCenter(int x, int y)
{
m_CursorCenter.x = x;
m_CursorCenter.y = y;
if (m_pCursorSprite)
m_pCursorSprite->SetCenter(m_CursorCenter);
if (m_pCursorGlowSprite)
m_pCursorGlowSprite->SetCenter(m_CursorCenter);
if (m_pCursorBackgroundSprite)
m_pCursorBackgroundSprite->SetCenter(m_CursorCenter);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::UseSprite
//
// PURPOSE: Attach a sprite to the mouse cursor. Note: only one sprite
// may be used at a time to represent the mouse cursor. You may
// specify a sprite using either a resource file name or a
// pointer to an existing sprite.
//
// ----------------------------------------------------------------------- //
void CCursorMgr::UseSprite(char * pFile)
{
KillSprite();
// if pFile is null, just turn the sprite off and set the pointer to null
if (!pFile)
return;
// See if this sprite is in the list
ScreenSpriteArray::iterator iter = m_SpriteArray.begin();
while (iter != m_SpriteArray.end())
{
// If it is, then set it to "active"
if (!strcmpi(pFile, (*iter)->GetName()))
{
m_pCursorSprite = *iter;
m_pCursorSprite->Show(LTTRUE);
m_pCursorSprite->SetCenter(m_CursorCenter);
UseHardwareCursor(LTFALSE);
return;
}
iter++;
}
// No sprite exists, so create one using this file name
CScreenSprite * pSprite = g_pScreenSpriteMgr->CreateScreenSprite(pFile, LTFALSE, SPRITELAYER_CURSOR_FOREGROUND);
_ASSERT(pSprite != LTNULL);
if (!pSprite)
return;
// Default center coordinates
pSprite->SetCenter(m_CursorCenter);
pSprite->Show(LTTRUE);
m_SpriteArray.push_back(pSprite);
m_pCursorSprite = pSprite;
UseHardwareCursor(LTFALSE);
}
void CCursorMgr::UseSprite(CScreenSprite * pSprite)
{
if (m_pCursorSprite == pSprite)
return;
KillSprite();
if (!pSprite)
{
return;
}
// See if this sprite is in our list.
ScreenSpriteArray::iterator iter = m_SpriteArray.begin();
while (iter != m_SpriteArray.end())
{
// If it is, then set it to "active"
if (!strcmpi((*iter)->GetName(), pSprite->GetName()))
{
m_pCursorSprite = *iter;
m_pCursorSprite->SetCenter(m_CursorCenter);
m_pCursorSprite->Show(LTTRUE);
UseHardwareCursor(LTFALSE);
return;
}
iter++;
}
// This sprite has not been used before. Add it to our local array
// ABM 2/20/02 TWEAK add a new sprite that is a DUPLICATE of the one passed in
CScreenSprite * pNewSprite = g_pScreenSpriteMgr->CreateScreenSprite(pSprite->GetName(), LTFALSE, SPRITELAYER_CURSOR_FOREGROUND);
_ASSERT(pNewSprite != LTNULL);
if (!pNewSprite)
return;
// Default center coordinates
pNewSprite->SetCenter(m_CursorCenter);
pNewSprite->Show(LTTRUE);
m_SpriteArray.push_back(pNewSprite);
m_pCursorSprite = pNewSprite;
UseHardwareCursor(LTFALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::UseGlowSprite
//
// PURPOSE: Attach an additive glow sprite to overlay the current sprite
// must be specified by filename, and must be used AFTER setting
// the bitmap
//
// ----------------------------------------------------------------------- //
void CCursorMgr::UseGlowSprite(char * pSpriteFile)
{
if (m_pCursorGlowSprite)
{
m_pCursorGlowSprite->Show(LTFALSE);
m_pCursorGlowSprite = LTNULL;
}
// if pFile is null, just turn the sprite off and set the pointer to null
if (!pSpriteFile)
return;
// See if this sprite is in the list
ScreenSpriteArray::iterator iter = m_SpriteArray.begin();
while (iter != m_SpriteArray.end())
{
// If it is, then set it to "active"
if (!strcmpi(pSpriteFile, (*iter)->GetName()))
{
m_pCursorGlowSprite = *iter;
m_pCursorGlowSprite->SetCenter(m_CursorCenter);
m_pCursorGlowSprite->Show(LTTRUE);
UseHardwareCursor(LTFALSE);
return;
}
iter++;
}
// No sprite exists, so create one using this file name
CScreenSprite * pSprite = g_pScreenSpriteMgr->CreateScreenSprite(pSpriteFile, LTFALSE, SPRITELAYER_CURSOR_ADDITIVE);
_ASSERT(pSprite != LTNULL);
if (!pSprite)
return;
// Default center coordinates
pSprite->SetCenter(m_CursorCenter);
pSprite->SetAdditive(LTTRUE);
pSprite->Show(LTTRUE);
m_SpriteArray.push_back(pSprite);
m_pCursorGlowSprite = pSprite;
UseHardwareCursor(LTFALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::UseBackgroundSprite
//
// PURPOSE: Attach a background image sprite under the current sprite
// must be specified by filename, and must be used AFTER setting
// the bitmap
//
// ----------------------------------------------------------------------- //
void CCursorMgr::UseBackgroundSprite(char * pSpriteFile)
{
if (m_pCursorBackgroundSprite)
{
m_pCursorBackgroundSprite->Show(LTFALSE);
m_pCursorBackgroundSprite = LTNULL;
}
// if pFile is null, just turn the sprite off and set the pointer to null
if (!pSpriteFile)
return;
// See if this sprite is in the list
ScreenSpriteArray::iterator iter = m_SpriteArray.begin();
while (iter != m_SpriteArray.end())
{
// If it is, then set it to "active"
if (!strcmpi(pSpriteFile, (*iter)->GetName()))
{
m_pCursorBackgroundSprite = *iter;
m_pCursorBackgroundSprite->SetCenter(m_CursorCenter);
m_pCursorBackgroundSprite->Show(LTTRUE);
UseHardwareCursor(LTFALSE);
return;
}
iter++;
}
// No sprite exists, so create one using this file name
CScreenSprite * pSprite = g_pScreenSpriteMgr->CreateScreenSprite(pSpriteFile, LTFALSE, SPRITELAYER_CURSOR_BACKGROUND);
_ASSERT(pSprite != LTNULL);
if (!pSprite)
return;
// Default center coordinates
pSprite->SetCenter(m_CursorCenter);
pSprite->Show(LTTRUE);
m_SpriteArray.push_back(pSprite);
m_pCursorBackgroundSprite = pSprite;
UseHardwareCursor(LTFALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CCursorMgr::KillSprite
//
// PURPOSE: Disassociate a sprite from the mouse cursor
//
// ----------------------------------------------------------------------- //
void CCursorMgr::KillSprite()
{
if (m_pCursorSprite)
{
m_pCursorSprite->Show(LTFALSE);
m_pCursorSprite = LTNULL;
}
if (m_pCursorGlowSprite)
{
m_pCursorGlowSprite->Show(LTFALSE);
m_pCursorGlowSprite = LTNULL;
}
if (m_pCursorBackgroundSprite)
{
m_pCursorBackgroundSprite->Show(LTFALSE);
m_pCursorBackgroundSprite = LTNULL;
}
UseHardwareCursor(LTTRUE);
} | [
"[email protected]"
]
| [
[
[
1,
535
]
]
]
|
e2fda08de414ce3dd09f26c4dc7a67b07ac57486 | c1589fb41425e22a09038beab97e1fd7afafe965 | /Code/RTSTRUCT/Utilities_gdcm_src/bkp_old_files/gdcmFileHelper_10.h | 11f9fa606ab8d2d50d37576d020a79f315611e57 | []
| no_license | dehuakang/midas-journal-316 | 70dcc1ac69dc5701abea0ec10c8765cb906c4e81 | eb39f43bb560340478ba54381935d007b40d9d27 | refs/heads/master | 2020-03-24T02:19:11.785693 | 2011-08-22T13:46:27 | 2011-08-22T13:46:27 | null | 0 | 0 | null | null | null | null | WINDOWS-1258 | C++ | false | false | 8,956 | h | /*=========================================================================
Program: gdcm
Module: $RCSfile: gdcmFileHelper.h,v $
Language: C++
Date: $Date: 2007-12-11 11:19:48 $
Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef GDCMFILEHELPER_H
#define GDCMFILEHELPER_H
#include "gdcmDebug.h"
#include "gdcmBase.h"
namespace gdcm
{
class File;
class ValEntry;
class BinEntry;
class SeqEntry;
class PixelReadConvert;
class PixelWriteConvert;
class DocEntryArchive;
typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *);
//-----------------------------------------------------------------------------
/**
* \brief In addition to Dicom header exploration, this class is designed
* for accessing the image/volume content. One can also use it to
* write Dicom/ACR-NEMA/RAW files.
*/
class GDCM_EXPORT FileHelper : public Base
{
public:
enum FileMode
{
WMODE_RAW,
WMODE_RGB
};
public:
FileHelper( );
FileHelper( File *header );
GDCM_LEGACY(FileHelper( std::string const &filename ))
virtual ~FileHelper();
void Print(std::ostream &os = std::cout, std::string const &indent = "");
/// Accessor to \ref File
File *GetFile() { return FileInternal; }
void SetLoadMode(int loadMode);
void SetFileName(std::string const &fileName);
bool Load();
/// to allow user to modify pixel order (e.g. Mirror, TopDown,...)
void SetUserFunction( VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
{ UserFunction = userFunc; }
// File methods
bool SetValEntry(std::string const &content,
uint16_t group, uint16_t elem);
bool SetBinEntry(uint8_t *content, int lgth,
uint16_t group, uint16_t elem);
ValEntry *InsertValEntry(std::string const &content,
uint16_t group, uint16_t elem);
BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
uint16_t group, uint16_t elem);
SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
// File helpers
size_t GetImageDataSize();
size_t GetImageDataRawSize();
uint8_t *GetImageData();
uint8_t *GetImageDataRaw();
GDCM_LEGACY(size_t GetImageDataIntoVector(void *destination,size_t maxSize))
void SetImageData(uint8_t *data, size_t expectedSize);
// User data
size_t ComputeExpectedImageDataSize();
void SetUserData(uint8_t *data, size_t expectedSize);
uint8_t *GetUserData();
size_t GetUserDataSize();
// RBG data (from file)
uint8_t *GetRGBData();
size_t GetRGBDataSize();
// RAW data (from file)
uint8_t *GetRawData();
size_t GetRawDataSize();
// LUT
uint8_t* GetLutRGBA();
int GetLutItemNumber();
int GetLutItemSize();
// Write mode
/// \brief Tells the writer we want to keep 'Grey pixels + Palettes color'
/// when possible (as opposed to convert 'Palettes color' to RGB)
void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); }
/// \brief Tells the writer we want to write RGB image when possible
/// (as opposed to 'Grey pixels + Palettes color')
void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); }
/// \brief Sets the Write Mode ( )
void SetWriteMode(FileMode mode) { WriteMode = mode; }
/// \brief Gets the Write Mode ( )
FileMode GetWriteMode() { return WriteMode; }
// Write format
/// \brief Tells the writer we want to write as Implicit VR
void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); }
/// \brief Tells the writer we want to write as Explicit VR
void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); }
/// \brief Tells the writer we want to write as ACR-NEMA
void SetWriteTypeToAcr() { SetWriteType(ACR); }
/// \brief Tells the writer we want to write as LibIDO
void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); }
/// \brief Tells the writer we want to write as JPEG
void SetWriteTypeToJPEG() { SetWriteType(JPEG); }
/// \brief Tells the writer we want to write as JPEG2000
void SetWriteTypeToJPEG2000() { SetWriteType(JPEG2000); }
/// \brief Tells the writer which format we want to write
/// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
void SetWriteType(FileType format) { WriteType = format; }
/// \brief Gets the format we talled the write we wanted to write
/// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
FileType GetWriteType() { return WriteType; }
// Write pixels of ONE image on hard drive
// No test is made on processor "endianness"
// The user must call his reader correctly
bool WriteRawData (std::string const &fileName);
bool WriteDcmImplVR(std::string const &fileName);
bool WriteDcmExplVR(std::string const &fileName);
bool WriteAcr (std::string const &fileName);
bool Write (std::string const &fileName);
/// \brief if user knows he didn't modify the pixels (e.g. he just anonymized
/// the file), he is allowed to ask to keep the original
/// 'Media Storage SOP Class UID' and 'Image Type'
void SetKeepMediaStorageSOPClassUID (bool v)
{ KeepMediaStorageSOPClassUID = v; }
// no GetKeepMediaStorageSOPClassUID() method, on purpose!
protected:
bool CheckWriteIntegrity();
void SetWriteToRaw();
void SetWriteToRGB();
void RestoreWrite();
void SetWriteFileTypeToACR();
void SetWriteFileTypeToJPEG();
void SetWriteFileTypeToJPEG2000();
void SetWriteFileTypeToExplicitVR();
void SetWriteFileTypeToImplicitVR();
void RestoreWriteFileType();
void SetWriteToLibido();
void SetWriteToNoLibido();
void RestoreWriteOfLibido();
ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
BinEntry *CopyBinEntry(uint16_t group, uint16_t elem,
const std::string &vr);
void CheckMandatoryElements();
void CheckMandatoryEntry(uint16_t group, uint16_t elem,std::string value);
void CopyMandatoryEntry(uint16_t group, uint16_t elem,std::string value);
void RestoreWriteMandatory();
private:
void Initialize();
uint8_t *GetRaw();
// members variables:
/// gdcm::File to use to load the file
File *FileInternal;
/// \brief Whether the underlying \ref gdcm::File was loaded by
/// the constructor or passed to the constructor.
/// When false the destructor is in charge of deletion.
bool SelfHeader;
/// Whether already parsed or not
bool Parsed;
// Utility pixel converter
/// \brief Pointer to the PixelReadConverter
PixelReadConvert *PixelReadConverter;
/// \brief Pointer to the PixelWriteConverter
PixelWriteConvert *PixelWriteConverter;
// Utility header archive
/// \brief Pointer to the DocEntryArchive (used while writting process)
DocEntryArchive *Archive;
// Write variables
/// \brief (WMODE_RAW, WMODE_RGB)
FileMode WriteMode;
/// \brief (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
FileType WriteType;
/// \brief Pointer to a user supplied function to allow modification of pixel order
/// (i.e. : Mirror, TopDown, 90°Rotation, ...)
/// use as : void userSuppliedFunction(uint8_t *im, gdcm::File *f)
/// NB : the "uint8_t *" type of first param is just for prototyping.
/// User will Cast it according what he founds with f->GetPixelType()
/// See vtkgdcmSerieViewer for an example
VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
/// \brief if user knows he didn't modify the pixels (e.g. he just
/// anonymized the file), he is allowed to ask to keep the original
/// 'Media Storage SOP Class UID' and 'Image Type'
bool KeepMediaStorageSOPClassUID;
};
} // end namespace gdcm
//-----------------------------------------------------------------------------
#endif
| [
"[email protected]"
]
| [
[
[
1,
238
]
]
]
|
acaff878014f8f8dc8e16ef6d87468787ec61482 | 18760393ff08e9bdefbef1d5ef054065c59cedbc | /Source/CppCLR/CppLib/Stdafx.cpp | a621a930ff68ad932f987232df86650c94fa5820 | []
| no_license | robertraaijmakers/koppijn | 530d0b0111c8416ea7a688c3e5627fd421b41068 | 5af4f9c8472570aa2f2a70e170e671c6e338c3c6 | refs/heads/master | 2021-01-17T22:13:45.697435 | 2011-06-23T19:27:59 | 2011-06-23T19:27:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 202 | cpp | // stdafx.cpp : source file that includes just the standard includes
// CppLib.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"[email protected]"
]
| [
[
[
1,
5
]
]
]
|
9656cfc1891ccb75c3db2f1ed347397207c5762a | 38d9a3374e52b67ca01ed8bbf11cd0b878cce2a5 | /branches/tbeta/CCV-fid/addons/ofxNCore/src/Communication/TUIO.cpp | 148afd3c30d915290c210635d3f3fdf56b696aec | []
| no_license | hugodu/ccv-tbeta | 8869736cbdf29685a62d046f4820e7a26dcd05a7 | 246c84989eea0b5c759944466db7c591beb3c2e4 | refs/heads/master | 2021-04-01T10:39:18.368714 | 2011-03-09T23:05:24 | 2011-03-09T23:05:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,519 | cpp | /*
* TUIO.h
*
*
* Created on 2/2/09.
* Copyright 2009 NUI Group. All rights reserved.
*
*/
#include "TUIO.h"
#include "Poco/Environment.h"
#include "Poco/Net/NetworkInterface.h"
using Poco::Environment;
using namespace Poco::Net;
TUIO::TUIO() {
host_name = new char[64];
tuio_source_String = new char[256];
setNetworkInterface(1);//default
// cout << "NetworkInterface.address:" << NetworkInterface::list()[0].address().toString() << endl;
//NetworkInterface::list().size()[1].address()!= Null
// int index = 0;
//if(NetworkInterface::list().size() >1 ){ index = 1;}
//strcpy(host_name,NetworkInterface::list()[index].address().toString().c_str( ));//char * strcpy ( char * destination, const char * source );
// host_name = NetworkInterface::list()[1].address().toString().c_str( );
/*
gethostname(host_name,64);
struct hostent *phe = gethostbyname(host_name);
//struct in_addr addr;
memcpy(&addr, phe->h_addr_list[0], sizeof(struct in_addr));
cout << "IPAddress " << inet_ntoa(addr) << endl;
*/
}
TUIO::~TUIO() {
if (tuio_source_String) delete[] tuio_source_String;
if (host_name) delete[] host_name;
// this could be useful for whenever we get rid of an object
}
void TUIO::setup(const char* host, int port, int flashport,int _camWidth,int _camHeight) {
localHost = host;
TUIOPort = port;
TUIOFlashPort = flashport;
frameseq = 0;
//FOR TCP
bIsConnected = m_tcpServer.setup(TUIOFlashPort);
//FOR OSC
TUIOSocket.setup(localHost, TUIOPort);
camWidth= _camWidth;
camHeight= _camHeight;
}
void TUIO::setFiducialModus(bool status){
//----added by Stefan Schlupek
bTrackFiducials = status;
}
void TUIO::setNetworkInterface(int id){
//copy the IPadress from POCO.Net.NetworkInterface to a char*
int index = 0;
if(NetworkInterface::list().size() > id ){
index = id;
}else if(NetworkInterface::list().size() >1 ){
index = 1;
}
strcpy(host_name,NetworkInterface::list()[index].address().toString().c_str( ));
}
void TUIO::setup_tuio_source_String(){
//cout << "setup_tuio_source_String " << inet_ntoa(addr) << endl;
// source message from TUIO 1.1 /tuio/[profileName] source [application@address]
//NetworkInterface::list()[1].address().toString() ;// to get the IP-Adress we could use POCO
sprintf(tuio_source_String,"%s@%s",tuio_source_application, host_name);
// sprintf(tuio_source_String,"%s@%s",tuio_source_application,inet_ntoa(addr));
cout << "TUIO.SOURCE: "<< tuio_source_String << endl ;
}
void TUIO::sendTUIO(std::map<int, Blob> * blobs, std::list <ofxFiducial> * fiducialsList)
{
frameseq += 1;
//if sending OSC (not TCP)
if(bOSCMode){
ofxOscBundle b;
//added by Stefan Schlupek
// source message from TUIO 1.1 /tuio/[profileName] source [application@address]
ofxOscMessage source;
source.setAddress( "/tuio/2Dcur" );
source.addStringArg( "source" );
source.addStringArg(tuio_source_String);
ofxOscMessage alive;
alive.setAddress("/tuio/2Dcur");
alive.addStringArg("alive");
ofxOscMessage fseq;
fseq.setAddress( "/tuio/2Dcur" );
fseq.addStringArg( "fseq" );
fseq.addIntArg(frameseq);
if(blobs->size() == 0 )
{
//Sends alive message - saying 'Hey, there's no alive blobs'
//Send fseq message
b.addMessage( source ); //add message to bundle
b.addMessage( alive ); //add message to bundle
b.addMessage( fseq ); //add message to bundle
//TUIOSocket.sendBundle( b ); //send bundle
}
else //actually send the blobs
{
b.addMessage( source ); //add message to bundle
//Send alive message of all alive IDs
std::map<int, Blob>::iterator this_blobID;
for(this_blobID = blobs->begin(); this_blobID != blobs->end(); this_blobID++)
{
alive.addIntArg(this_blobID->second.id); //Get list of ALL active IDs
}
b.addMessage( alive ); //add message to bundle
map<int, Blob>::iterator this_blob;
for(this_blob = blobs->begin(); this_blob != blobs->end(); this_blob++)
{
//Set Message /tuio/2Dcur set s x y X Y m
ofxOscMessage set;
set.setAddress("/tuio/2Dcur");
set.addStringArg("set");
set.addIntArg(this_blob->second.id); //id
set.addFloatArg(this_blob->second.centroid.x); // x
set.addFloatArg(this_blob->second.centroid.y); // y
set.addFloatArg(this_blob->second.D.x); //dX
set.addFloatArg(this_blob->second.D.y); //dY
set.addFloatArg(this_blob->second.maccel); //m
/*
if(bHeightWidth){
set.addFloatArg(this_blob->second.boundingRect.width); // wd
set.addFloatArg(this_blob->second.boundingRect.height);// ht
}
*/
b.addMessage( set ); //add message to bundle
}//for
b.addMessage( fseq ); //add message to bundle
}//if
TUIOSocket.sendBundle( b ); //send bundle
// BLOB-END----------------
//Fiducial: //----added by Stefan Schlupek
if(bTrackFiducials){
ofxOscBundle b_obj;
ofxOscMessage source_obj;
source_obj.setAddress( "/tuio/2Dobj" );
source_obj.addStringArg( "source" );
source_obj.addStringArg(tuio_source_String);
ofxOscMessage alive_obj;
alive_obj.setAddress("/tuio/2Dobj");
alive_obj.addStringArg("alive");
ofxOscMessage fseq_obj;
fseq_obj.setAddress( "/tuio/2Dobj" );
fseq_obj.addStringArg( "fseq" );
fseq_obj.addIntArg(frameseq);
if( fiducialsList->size() == 0){
//Sends alive message - saying 'Hey, there's no alive blobs'
b_obj.addMessage( source_obj ); //add message to bundle
b_obj.addMessage( alive_obj ); //add message to bundle
b_obj.addMessage( fseq_obj ); //add message to bundle
}else
{
//printf("FIDUCIALS->SIZE: %i\n", fiducialsList->size() );
b_obj.addMessage( source_obj ); //add message to bundle
list <ofxFiducial>::iterator this_fiducial ;
for(this_fiducial = fiducialsList->begin();this_fiducial != fiducialsList->end(); this_fiducial++){
//printf("FIDUCIAL: %f\n", this_fiducial. );
//Set Message /tuio/2Dobj set s i x y a X Y A m r
ofxOscMessage set;
set.setAddress("/tuio/2Dobj");
set.addStringArg("set");
set.addIntArg(this_fiducial->getId()); //s sessionID????
set.addIntArg(this_fiducial->getId()); //i
set.addFloatArg(this_fiducial->getCameraToScreenX()); // x Normalized
set.addFloatArg(this_fiducial->getCameraToScreenY()); // y Normalized
set.addFloatArg(this_fiducial->getAngle()); //a
set.addFloatArg(this_fiducial->getMSpeedX()); //X
set.addFloatArg(this_fiducial->getMSpeedY()); //Y
set.addFloatArg(this_fiducial->getRSpeed()); //A
set.addFloatArg(this_fiducial->getMAccel()); //m
set.addFloatArg(this_fiducial->getRAccel()); //r
b_obj.addMessage( set ); //add message to bundle
//Send alive message of all alive IDs
alive_obj.addIntArg(this_fiducial->getId());
}//for
b_obj.addMessage( alive_obj ); //add message to bundle
b_obj.addMessage( fseq_obj ); //add message to bundle
}//if
TUIOSocket.sendBundle( b_obj ); //send bundle
}//end if(bTrackFiducials
//--------Fiducial END--------------------------------
//---------End OSC Mode-------------------------------
}else if(bTCPMode) //else, if TCP (flash) mode
{
if(blobs->size() == 0){
m_tcpServer.sendToAll("<OSCPACKET ADDRESS=\"127.0.0.1\" PORT=\""+ofToString(TUIOPort)+"\" TIME=\""+ofToString(ofGetElapsedTimef())+"\">" +
"<MESSAGE NAME=\"/tuio/2Dcur\">"+
"<ARGUMENT TYPE=\"s\" VALUE=\"alive\"/>"+
"</MESSAGE>"+
"<MESSAGE NAME=\"/tuio/2Dcur\">"+
"<ARGUMENT TYPE=\"s\" VALUE=\"fseq\"/>"+
"<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(frameseq)+"\"/>" +
"</MESSAGE>"+
"</OSCPACKET>");
}
else
{
string setBlobsMsg;
map<int, Blob>::iterator this_blob;
for(this_blob = blobs->begin(); this_blob != blobs->end(); this_blob++)
{
//if sending height and width
if(bHeightWidth){
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(this_blob->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.maccel)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.boundingRect.width)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.boundingRect.height)+"\"/>"+
"</MESSAGE>";
}
else{
setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(this_blob->second.id)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.x)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.y)+"\"/>"+
"<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.maccel)+"\"/>"+
"</MESSAGE>";
}
}
string aliveBeginMsg = "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"alive\"/>";
string aliveBlobsMsg;
std::map<int, Blob>::iterator this_blobID;
for(this_blobID = blobs->begin(); this_blobID != blobs->end(); this_blobID++)
{
aliveBlobsMsg += "<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(this_blobID->second.id)+"\"/>";
}
string aliveEndMsg = "</MESSAGE>";
string fseq = "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"fseq\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(frameseq)+"\"/></MESSAGE>";
m_tcpServer.sendToAll("<OSCPACKET ADDRESS=\"127.0.0.1\" PORT=\""+ofToString(TUIOPort)+"\" TIME=\""+ofToString(ofGetElapsedTimef())+"\">" +
setBlobsMsg + aliveBeginMsg + aliveBlobsMsg + aliveEndMsg + fseq + "</OSCPACKET>");
}
}
}
| [
"schlupek@463ed9da-a5aa-4e33-a7e2-2d3b412cff85"
]
| [
[
[
1,
317
]
]
]
|
4f8e0c6e2980f83b4326eb12963670cf4429cdbd | 67298ca8528b753930a3dc043972dceab5e45d6a | /FileSharing/src/SocketLibrary.hpp | 43ea8247850a92885d1d86d4f28d548a7018469f | []
| no_license | WhyKay92/cs260assignment3 | 3cf28dd92b9956b2cd4f850652651cb11f25c753 | 77ad90cd2dc0b44f3ba0a396dc8399021de4faa5 | refs/heads/master | 2021-05-30T14:59:21.297733 | 2010-12-13T09:18:17 | 2010-12-13T09:18:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,731 | hpp | /*!
* @File SocketLibrary.hpp
* @Author Steven Liss
* @Date 24 Sept 2010
* @Brief A collection of routines and data for global winsock operations.
* @Note The data and routines in this file should be collected into a single class.
*/
#pragma once
#include "winsock2.h"
#pragma comment(lib, "ws2_32.lib")
#include "shared.hpp"
std::string const gTerminate = "quit";
static u32 const MAX_INPUT_SIZE = 1000;
struct WinSockErrExcep : public BaseErrExcep
{
WinSockErrExcep( int eCode, char const *msg );
WinSockErrExcep( int eCode, std::string const &msg );
void Print( void );
//data
int eCode_;
};
typedef WinSockErrExcep WSErr;
struct SocketAddress
{
SocketAddress()
{
SecureZeroMemory( &adr_, sizeof( adr_ ) );
adr_.sin_family = AF_INET;
}
SocketAddress( sockaddr_in adr ) : adr_( adr ) {}
void SetPortNumber( u32 port )
{
adr_.sin_port = htons( port );
}
void SetIP( std::string IP )
{
adr_.sin_addr.s_addr = inet_addr( IP.c_str() );
}
bool operator ==( SocketAddress const &rhs )
{
if( adr_.sin_port != rhs.adr_.sin_port )
return false;
if( adr_.sin_addr.s_addr != rhs.adr_.sin_addr.s_addr )
return false;
return true;
}
sockaddr_in adr_;
};
typedef SocketAddress SockAddr;
struct NetworkMessage
{
enum
{
DISCON = 1000,
JOIN,
SERVER_FILES,
REQ_FILES,
QUIT,
TRANSFER,
INFORM_SENDER,
INFORM_RECEIVER,
GET,
ERR,
// always at bottom
SIZE
};
NetworkMessage() :
msg_(), conID_( -1 ), type_( -1 )
{}
DataBuffer msg_;
int conID_;
MsgType type_;
SocketAddress receiverAddress_;
void operator<<( DataBuffer const &data )
{
if( data.Size() == 0 )
{
type_ = SIZE;
return;
}
u32 sizeType = sizeof( MsgType );
memcpy( &( type_ ), data.Bytes(), sizeType );
msg_.Assign( data.Bytes( sizeType ), data.Size() - sizeType );
}
template < typename T >
void operator>>( T &t )
{
u32 sizeType = sizeof( MsgType );
t.type_ = type_;
unsigned sizeOfData = sizeof( T::Data );
memcpy( (char *)&t.data_, msg_.Bytes(), sizeOfData );
}
template < typename T >
void operator<<( T const &t )
{
u32 sizeType = sizeof( MsgType );
type_ = t.type_;
unsigned sizeOfData = sizeof( T::Data );
msg_.Assign( (const char *)&t.data_, sizeOfData );
}
};
typedef NetworkMessage NetMsg;
void StartWinSock( void );
void CloseWinSock( void );
void ShowWinSockVersion( WSAData const &dat );
void GetLocalIP( char* &localIP );
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
46
],
[
48,
48
],
[
50,
67
],
[
69,
70
],
[
73,
73
],
[
86,
97
],
[
108,
110
],
[
112,
116
],
[
118,
125
],
[
128,
135
]
],
[
[
47,
47
],
[
49,
49
],
[
68,
68
],
[
71,
72
],
[
74,
85
],
[
98,
107
],
[
111,
111
],
[
117,
117
],
[
126,
127
],
[
136,
136
]
]
]
|
23b2ab026ee0ff501d67b2179b59967982d3b349 | 4797c7058b7157e3d942e82cf8ad94b58be488ae | /SpaceFightGame.cpp | e950863661b204b142ee4f6d6f7ec664d7cb963d | []
| no_license | koguz/DirectX-Space-Game | 2d1d8179439870fd1427beb9624f1c5452546c39 | be672051fd0009cbd5851c92bd344d3b23645474 | refs/heads/master | 2020-05-18T02:11:47.963185 | 2011-05-25T14:35:26 | 2011-05-25T14:35:26 | 1,799,267 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,300 | cpp | #include "SpaceFightGame.h"
bool SpaceFightGame::Setup()
{
cam = MyCamera(Device);
Listener.Init(Sound);
Listener.setPosition(D3DXVECTOR3(0.0f, 0.0f, 0.0f));
fpscount = GetTickCount();
fps = 0;
timeStart = 0;
timeEnd = 0;
timerFreq = 0;
SetFrameLimit(true);
msPerFrame = (float)1000 / FRAMELIMITVAL;
sky = new CubeMap(Device);
SetupCamera();
SetupPerspective();
light.direction = D3DXVECTOR3(0.0f, -1.0f, 1.0f);
D3DXVec3Normalize(&light.direction, &light.direction);
light.ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
light.diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
light.spec = D3DXCOLOR(1.0f, 1.0f, 1.0f, 0.0f);
ID3DXBuffer* err = 0;
D3DXCreateEffectFromFile(Device, "mymesh.fx", 0, 0, D3DXSHADER_DEBUG, 0, &MeshEffect, &err);
if (err)
MessageBox(0, (char*)err->GetBufferPointer(), 0, 0);
err = 0;
D3DXCreateEffectFromFile(Device, "fonteffect.fx", 0, 0, D3DXSHADER_DEBUG, 0, &FontEffect, &err);
if (err)
MessageBox(0, (char*)err->GetBufferPointer(), 0, 0);
D3DXHANDLE mhLight;
mhLight = MeshEffect->GetParameterByName(0, "gLight");
MeshEffect->SetValue(mhLight, &light, sizeof(DirLight));
D3DXHANDLE mhFLight;
D3DXVECTOR3 a(0.0f, -1.5f, -1.0f);
D3DXVec3Normalize(&a, &a);
mhFLight = FontEffect->GetParameterByName(0, "gLightVecW");
FontEffect->SetValue(mhFLight, &a, sizeof(D3DXVECTOR3));
Ship = 0;
Portal = 0;
Button.Init(Sound, "button.wav");
Button.SetLoop(false);
Button.setPosition(D3DXVECTOR3(0,0,0));
continueGame = pexitGame = parrow = pauseTitle = earrow = equitgame = ewin = elose = enewgame = 0;
state = MAINSCREEN;
LoadMainScreen();
return true;
}
void SpaceFightGame::LoadNewGame()
{
level = 1;
points = 0;
typeACount = typeBCount = typeCCount = 0;
portalPosition = D3DXVECTOR3(0, 0, 100);
if (Ship != 0)
{
delete Ship;
Ship = 0;
}
Ship = new PlayerShip();
Ship->Init(Device, Sound);
info = new MyFont(Device, "Level: ");
info->SetPosition(10, 10, 800, 400);
info->AddText((float)level);
info->AddText("\n");
if (enemyShips.size() != 0)
{
std::vector<EnemyShipBase*>::iterator it;
for(it = enemyShips.begin(); it != enemyShips.end(); ++it)
{
delete (*it);
}
enemyShips.clear();
}
EnemyShipBig *bigShip = new EnemyShipBig();
bigShip->Init(Device, Sound);
bigShip->TranslateV(portalPosition - D3DXVECTOR3(0, 6, 0));
enemyShips.push_back(bigShip);
EnemyShipStation *station = new EnemyShipStation();
station->Init(Device, Sound);
station->TranslateV(D3DXVECTOR3(40, 0, 100));
enemyShips.push_back(station);
GameMusic.Init(Sound, "gameplay.wav");
GameMusic.Play();
Mission1.Init(Sound, "mission01.wav");
Mission1.SetLoop(false);
Mission2.Init(Sound, "mission02.wav");
Mission2.SetLoop(false);
End.Init(Sound, "end.wav");
End.SetLoop(false);
endWaitTime = 0;
Damage.Init(Sound, "damage.wav");
Damage.SetLoop(false);
Win.Init(Sound, "win.wav");
Lose.Init(Sound, "lose.wav");
EvilLaugh.Init(Sound, "laugh.wav");
EvilLaugh.SetLoop(false);
bm1 = be = bm2 = bd = bigship = tower = finalcon = false;
if (Portal != 0)
{
delete Portal;
Portal = 0;
}
Portal = new MyMesh();
Portal->Init(Device, "portal.x");
Portal->Translate(portalPosition.x, portalPosition.y, portalPosition.z);
cam.AttachObject(Ship);
}
void SpaceFightGame::LoadMainScreen()
{
//
title = new MyFontMesh(Device, "DEEPSPACE", "CloneWars");
title->Translate(-4.5f, 3.0f, 5.0f);
newGame = new MyFontMesh(Device, "start", "Zrnic");
newGame->Scale(0.3f);
newGame->Translate(0.3f, 0.0f, 2.0f);
exitGame = new MyFontMesh(Device, "quit", "Zrnic");
exitGame->Scale(0.3f);
exitGame->Translate(0.3f, -0.3f, 2.0f);
arrow = new MyFontMesh(Device, "*", "Zrnic");
arrow->Scale(0.3f);
arrow->Translate(0.12f, -0.03f, 2.0f);
theShip = new MyMesh();
theShip->Init(Device, "ship01.x");
theShip->Translate(-2.0f, -0.2f, 4.0f);
theShip->RotateX(3*D3DX_PI/2);
MenuMusic.Init(Sound, "menu.wav");
MenuMusic.setPosition(cam.position);
MenuMusic.Play();
selectedMenu = 0;
lastChanged = 0;
}
void SpaceFightGame::LoadEndGameScreen()
{
cam.position = D3DXVECTOR3(0, 0, 0);
cam.look = D3DXVECTOR3(0, 0, 1);
cam.up = D3DXVECTOR3(0, 1, 0);
cam.Display();
if (ewin == 0)
{
ewin = new MyFontMesh(Device, "C0NGRATS!", "CloneWars");
ewin->Translate(-3.9f, 3.0f, 5.0f);
}
if (elose == 0)
{
elose = new MyFontMesh(Device, "Y0U L0SE", "CloneWars");
elose->Translate(-3.5f, 3.0f, 5.0f);
}
if (enewgame == 0)
{
enewgame = new MyFontMesh(Device, "new game", "Zrnic");
enewgame->Scale(0.3f);
enewgame->Translate(0.3f, 0.0f, 2.0f);
}
if (equitgame == 0)
{
equitgame = new MyFontMesh(Device, "exit", "Zrnic");
equitgame->Scale(0.3f);
equitgame->Translate(0.3f, -0.3f, 2.0f);
}
if (earrow == 0)
{
earrow = new MyFontMesh(Device, "*", "Zrnic");
earrow->Scale(0.3f);
earrow->Translate(0.12f, -0.03f, 2.0f);
}
selectedEnd = 0;
}
void SpaceFightGame::PauseScreen()
{
cam.position = D3DXVECTOR3(0, 0, 0);
cam.look = D3DXVECTOR3(0, 0, 1);
cam.up = D3DXVECTOR3(0, 1, 0);
cam.Display();
if (pauseTitle == 0)
{
pauseTitle = new MyFontMesh(Device, "DEEPSPACE", "CloneWars");
pauseTitle->Translate(-4.5f, 3.0f, 5.0f);
}
if (continueGame == 0)
{
continueGame = new MyFontMesh(Device, "continue", "Zrnic");
continueGame->Scale(0.3f);
continueGame->Translate(0.3f, 0.0f, 2.0f);
}
if (pexitGame == 0)
{
pexitGame = new MyFontMesh(Device, "exit", "Zrnic");
pexitGame->Scale(0.3f);
pexitGame->Translate(0.3f, -0.3f, 2.0f);
}
if (parrow == 0)
{
parrow = new MyFontMesh(Device, "*", "Zrnic");
parrow->Scale(0.3f);
parrow->Translate(0.12f, -0.03f, 2.0f);
}
selectedPause = 0;
}
bool SpaceFightGame::Display(float timeDelta)
{
if (Device)
{
QueryPerformanceCounter((LARGE_INTEGER*)&timeStart);
ClearBuffer(D3DCOLOR_XRGB(0x00,0x00,0x00));
Device->BeginScene();
ProcessInput();
sky->Draw(cam.position); // sky (space) is always drawn
/* display according to the state */
switch(state)
{
case MAINSCREEN:
title->Draw(FontEffect);
newGame->Draw(FontEffect);
exitGame->Draw(FontEffect);
arrow->Draw(FontEffect);
theShip->Draw(MeshEffect);
theShip->RotateX(0.01f);
theShip->RotateY(0.01f);
theShip->RotateZ(-0.01f);
break;
case PAUSE:
pauseTitle->Draw(FontEffect);
continueGame->Draw(FontEffect);
exitGame->Draw(FontEffect);
parrow->Draw(FontEffect);
break;
case LOADING:
Listener.setPosition(D3DXVECTOR3(1000, 1000, 1000));
break;
case END:
if (Ship->getHealth() < 0)
elose->Draw(FontEffect);
else ewin->Draw(FontEffect);
enewgame->Draw(FontEffect);
equitgame->Draw(FontEffect);
earrow->Draw(FontEffect);
break;
case GAMEPLAY:
info->SetText("Health: ");
info->AddText((float)Ship->getHealth());
info->AddText("\nPoints: ");
info->AddText((float)points);
info->Draw();
// players
Portal->RotateZ(0.01f);
Portal->Draw(MeshEffect);
if (Ship->getHealth() > 0)
{
Ship->Update(timeDelta);
Ship->Draw(MeshEffect);
}
for (std::vector<EnemyShipBase*>::iterator it = enemyShips.begin(); it != enemyShips.end(); ++it)
{
(*it)->Update(Ship->getPosition(), timeDelta);
(*it)->Draw(MeshEffect);
}
bool ed = false;
std::vector<Explosion*>::iterator temp;
for(std::vector<Explosion*>::iterator it = explosions.begin(); it != explosions.end(); ++it)
{
(*it)->Update(timeDelta);
if (!(*it)->isAlive())
{
ed = true;
temp = it;
}
}
if (ed) { delete (*temp); explosions.erase(temp); }
cam.Update();
GameMusic.setPosition(Ship->getPosition());
Mission1.setPosition(Ship->getPosition());
Mission2.setPosition(Ship->getPosition());
End.setPosition(Ship->getPosition());
Damage.setPosition(Ship->getPosition());
Win.setPosition(Ship->getPosition());
Lose.setPosition(Ship->getPosition());
EvilLaugh.setPosition(Ship->getPosition());
Listener.setPosition(Ship->getPosition());
CheckGameLogic();
break;
}
Device->EndScene();
Device->Present(0, 0, 0, 0);
if ( GetTickCount() - fpscount >= 1000)
{
fps = 0;
fpscount = GetTickCount();
}
else fps++;
QueryPerformanceCounter((LARGE_INTEGER*)&timeEnd);
QueryPerformanceFrequency((LARGE_INTEGER*)&timerFreq);
double d = (timeEnd - timeStart) * ((float)1/(float)timerFreq);
if (d < msPerFrame && frameLimit)
{
Sleep((DWORD)msPerFrame - (DWORD)d);
}
}
return true;
}
void SpaceFightGame::SetFrameLimit(bool f)
{
frameLimit = f;
}
bool SpaceFightGame::ColDetect(MyMesh* one, MyMesh* two)
{
D3DXVECTOR3 min1, max1, min2, max2;
one->CalcAABBFromOBB(&min1, &max1);
two->CalcAABBFromOBB(&min2, &max2);
bool col = false;
if (
(max1.x < min2.x) ||
(min1.x > max2.x) ||
(max1.y < min2.y) ||
(min1.y > max2.y) ||
(max1.z < min2.z) ||
(min1.z > max2.z)
)
{
col = true;
}
return col;
}
void SpaceFightGame::CreateShip(EnemyShipBase::ShipType type)
{
std::vector<EnemyShipBase*>::iterator it;
for(it = enemyShips.begin(); it != enemyShips.end(); ++it)
{
if((*it)->getState() == EnemyShipBase::MOVETOPOSITION)
return; // portal is busy
}
EnemyShipBase *temp;
switch(type)
{
case EnemyShipBase::TYPEA:
temp = new EnemyShipA();
typeACount++;
break;
case EnemyShipBase::TYPEB:
temp = new EnemyShipB();
typeBCount++;
break;
case EnemyShipBase::TYPEC:
temp = new EnemyShipC();
typeCCount++;
break;
default:
temp = 0;
break;
}
if (temp == 0) return; // failed!
temp->Init(Device, Sound);
temp->TranslateV(portalPosition);
temp->setMoveVector(portalPosition.x, portalPosition.y, portalPosition.z + 5);
enemyShips.push_back(temp);
}
bool SpaceFightGame::CheckGameLogic()
{
bool goOn = true;
if (Ship->getHealth() < 500 && !bd )
{
Damage.Play();
bd = true;
}
if (Ship->getHealth() < 0 && !finalcon)
{
finalcon = true;
GameMusic.Stop();
Lose.Play();
EvilLaugh.Play();
for(std::vector<EnemyShipBase*>::iterator i=enemyShips.begin(); i != enemyShips.end(); ++i)
(*i)->setState(EnemyShipBase::HOLD);
// LoadEndGameScreen();
Ship->Engine.Stop();
endWaitTime = GetTickCount();
Explosion* e = new Explosion(Device, Sound, Ship->getPosition());
explosions.push_back(e);
return true;
}
if (endWaitTime != 0 && GetTickCount() - endWaitTime > 5000 && Ship->getHealth() < 0)
{
LoadEndGameScreen();
state = END;
}
switch(level)
{
case 1:
if (!bm1)
{
Mission1.Play();
bm1 = true;
}
if (points < 500)
{
if (typeACount == 0)
CreateShip(EnemyShipBase::TYPEA);
}
else level = 2;
break;
case 2:
if (points < 1500)
{
if (typeBCount == 0)
CreateShip(EnemyShipBase::TYPEB);
}
else level = 3;
break;
case 3:
if (points < 3000)
{
if (typeCCount == 0)
CreateShip(EnemyShipBase::TYPEC);
}
else level = 4;
break;
case 4:
if (points < 4000)
{
if (typeACount == 0)
CreateShip(EnemyShipBase::TYPEA);
if (typeBCount == 0)
CreateShip(EnemyShipBase::TYPEB);
}
if (points > 4800)
level = 5;
break;
case 5:
if (points < 6000)
{
if (typeACount == 0)
CreateShip(EnemyShipBase::TYPEA);
if (typeBCount == 0)
CreateShip(EnemyShipBase::TYPEB);
if (typeCCount == 0)
CreateShip(EnemyShipBase::TYPEC);
}
if (points > 7500)
level = 6;
break;
case 6:
if (typeACount == 0 && typeBCount == 0 && typeCCount == 0 && !bm2)
{
Mission2.Play();
bm2 = true;
}
if (bigship && tower && !be)
{
GameMusic.Stop();
Win.Play();
End.Play();
endWaitTime = GetTickCount();
be = true;
}
if (endWaitTime != 0)
{
if (GetTickCount() - endWaitTime > 15000 && Ship->getHealth() > 0)
{
Ship->Engine.Stop();
LoadEndGameScreen();
state = END;
}
}
break;
}
if (Ship->getHealth() < 0) return goOn; // no need to do these if the ship is dead
if (!ColDetect(Ship, Portal))
{
Ship->TranslateV(0.06f*(Ship->getPosition()-portalPosition));
}
std::vector<EnemyShipBase*>::iterator it;
for(it = enemyShips.begin();it != enemyShips.end(); it++)
{
if (!ColDetect(Ship, (*it)))
{
if ((*it)->getType() == EnemyShipBase::TYPEBIG ||(*it)->getType() == EnemyShipBase::STATION)
{
Ship->Scratched();
Ship->TranslateV(0.01f*(Ship->getPosition()-(*it)->getPosition()));
}
else (*it)->TranslateV(0.05f*((*it)->getPosition() - Ship->getPosition()));
}
// check its lasers
std::vector<Laser>::iterator lit;
for(lit = (*it)->lasers.begin(); lit != (*it)->lasers.end(); lit++)
{
(*lit).Draw(MeshEffect);
if (!ColDetect((MyMesh*)&(*lit), Ship))
{
Ship->Hit((*lit).getDamage());
(*lit).TargetHit();
}
}
// check with other ships
// the trick is that we should check with the rest of the remaining, not all
std::vector<EnemyShipBase*>::iterator rem;
for(rem = it; rem != enemyShips.end(); rem++)
{
if (rem == it) continue;
if (!ColDetect((*it), (*rem)))
{
if( (*it)->getType() == EnemyShipBase::TYPEBIG)
(*rem)->TranslateV(0.01f*((*rem)->getPosition() - (*it)->getPosition()));
else
(*it)->TranslateV(0.05f*((*it)->getPosition() - (*rem)->getPosition()));
}
}
}
std::vector<EnemyShipBase*>::iterator temp;
bool dead = false;
for(std::vector<Laser>::iterator it = Ship->lasers.begin(); it != Ship->lasers.end(); ++it)
{
(*it).Draw(MeshEffect);
for(std::vector<EnemyShipBase*>::iterator enit = enemyShips.begin(); enit != enemyShips.end(); ++enit)
{
if (!ColDetect((MyMesh*)&(*it), (*enit)))
{
(*enit)->Hit((*it).getDamage());
(*it).TargetHit();
if ((*enit)->isDead())
{
// get an explosion at this location:
// (*enit)->getPosition();
Explosion* tmp = new Explosion(Device, Sound, (*enit)->getPosition());
explosions.push_back(tmp);
dead = true;
temp = enit;
}
switch((*enit)->getType())
{
case EnemyShipBase::TYPEA:
points += 20;
if (dead) points += 250;
break;
case EnemyShipBase::TYPEB:
points += 30;
if (dead) points += 350;
break;
case EnemyShipBase::TYPEC:
points += 40;
if (dead) points += 500;
break;
case EnemyShipBase::TYPEBIG:
points += 5;
if (dead) { points += 10000; bigship = true; }
break;
case EnemyShipBase::STATION:
points += 5;
if (dead) { points += 10000; tower = true; }
break;
}
}
}
}
if (dead)
{
switch ((*temp)->getType())
{
case EnemyShipBase::TYPEA:
typeACount--;
break;
case EnemyShipBase::TYPEB:
typeBCount--;
break;
case EnemyShipBase::TYPEC:
typeCCount--;
break;
default:
break;
}
delete (*temp);
enemyShips.erase(temp);
}
return goOn;
}
void SpaceFightGame::ProcessKeyboard()
{
#define KEYDOWN(name, key) (name[key] & 0x80)
char buffer[256];
HRESULT hr;
hr = Keyboard->GetDeviceState(sizeof(buffer), (LPVOID)&buffer);
if (FAILED(hr))
{
hr = Keyboard->Acquire();
while(hr == DIERR_INPUTLOST)
{
hr = Keyboard->Acquire();
}
return;
}
// dont forget this
if (KEYDOWN(buffer, DIK_ESCAPE))
{
quit = true;
}
switch(state)
{
case MAINSCREEN:
if (KEYDOWN(buffer, DIK_DOWN))
{
if (GetTickCount() - lastChanged < 200)
break;
if (selectedMenu == 0)
{
selectedMenu = 1;
arrow->Translate(0.0f, -0.3f, 0.0f);
Button.Play();
}
lastChanged = GetTickCount();
}
if (KEYDOWN(buffer, DIK_UP))
{
if (GetTickCount() - lastChanged < 200)
break;
if (selectedMenu == 1)
{
selectedMenu = 0;
arrow->Translate(0.0f, 0.3f, 0.0f);
Button.Play();
}
lastChanged = GetTickCount();
}
if (KEYDOWN(buffer, DIK_RETURN))
{
if (selectedMenu == 1)
quit = true;
else if (selectedMenu == 0)
{
// start a new game
MenuMusic.Stop();
state = LOADING;
LoadNewGame();
state = GAMEPLAY;
}
lastChanged = GetTickCount();
}
break;
case PAUSE:
if (KEYDOWN(buffer, DIK_DOWN))
{
if (GetTickCount() - lastChanged < 200)
break;
if (selectedPause == 0)
{
selectedPause = 1;
parrow->Translate(0.0f, -0.3f, 0.0f);
Button.Play();
}
lastChanged = GetTickCount();
}
if (KEYDOWN(buffer, DIK_UP))
{
if (GetTickCount() - lastChanged < 200)
break;
if (selectedPause == 1)
{
selectedPause = 0;
parrow->Translate(0.0f, 0.3f, 0.0f);
Button.Play();
}
lastChanged = GetTickCount();
}
if (KEYDOWN(buffer, DIK_RETURN))
{
if (selectedPause == 1)
quit = true;
else if (selectedPause == 0)
{
// continue game
cam.position = Ship->getPosition();
cam.up = Ship->getUp();
cam.look = Ship->getLook();
Ship->Engine.Play();
for(unsigned int i=0;i<enemyShips.size();i++)
enemyShips[i]->Engine.Play();
state = GAMEPLAY;
}
lastChanged = GetTickCount();
}
break;
case END:
if (KEYDOWN(buffer, DIK_DOWN))
{
if (GetTickCount() - lastChanged < 200)
break;
if (selectedEnd == 0)
{
selectedEnd = 1;
earrow->Translate(0.0f, -0.3f, 0.0f);
Button.Play();
}
lastChanged = GetTickCount();
}
if (KEYDOWN(buffer, DIK_UP))
{
if (GetTickCount() - lastChanged < 200)
break;
if (selectedEnd == 1)
{
selectedEnd = 0;
earrow->Translate(0.0f, 0.3f, 0.0f);
Button.Play();
}
lastChanged = GetTickCount();
}
if (KEYDOWN(buffer, DIK_RETURN))
{
if (selectedEnd == 1)
quit = true;
else if (selectedEnd == 0)
{
End.Stop();
Win.Stop();
state = LOADING;
LoadNewGame();
state = GAMEPLAY;
}
lastChanged = GetTickCount();
}
break;
break;
case GAMEPLAY:
if (KEYDOWN(buffer, DIK_P))
{
Ship->Engine.Stop();
for(unsigned int i=0;i<enemyShips.size();i++)
enemyShips[i]->Engine.Stop();
state = PAUSE;
PauseScreen();
}
if (KEYDOWN(buffer, DIK_UP))
{
Ship->RotateX(2*ANGLE);
}
if (KEYDOWN(buffer, DIK_DOWN))
{
Ship->RotateX(-2*ANGLE);
}
if (KEYDOWN(buffer, DIK_LEFT))
{
Ship->RotateY(-2*ANGLE);
}
if (KEYDOWN(buffer, DIK_RIGHT))
{
Ship->RotateY(2*ANGLE);
}
if (KEYDOWN(buffer, DIK_K))
{
Explosion *t = new Explosion(Device, Sound, Ship->getPosition() + D3DXVECTOR3(0, 0, 20));
explosions.push_back(t);
}
if (KEYDOWN(buffer, DIK_J))
{
Explosion *t = new Explosion(Device, Sound, Ship->getPosition() + D3DXVECTOR3(0, 0, 100));
explosions.push_back(t);
}
if (KEYDOWN(buffer, DIK_L))
{
Explosion *t = new Explosion(Device, Sound, Ship->getPosition() + D3DXVECTOR3(0, 0, 1));
explosions.push_back(t);
}
if (KEYDOWN(buffer, DIK_A))
{
Ship->RotateZ(2*ANGLE);
}
if (KEYDOWN(buffer, DIK_D))
{
Ship->RotateZ(-2*ANGLE);
}
if (KEYDOWN(buffer, DIK_W))
{
Ship->SpeedUp();
}
else if (KEYDOWN(buffer, DIK_S))
{
Ship->SpeedDown();
}
else { Ship->SpeedNormal(); }
if (KEYDOWN(buffer, DIK_LCONTROL))
{
Ship->FireLaser();
}
break;
}
/*
if (KEYDOWN(buffer, DIK_ESCAPE))
{
quit = true;
}
*/
}
void SpaceFightGame::ProcessMouse()
{
DIMOUSESTATE mouseState;
HRESULT hr;
hr = Mouse->GetDeviceState(sizeof(mouseState), (LPVOID)&mouseState);
if (FAILED(hr))
{
hr = Mouse->Acquire();
while(hr == DIERR_INPUTLOST)
{
hr = Mouse->Acquire();
}
return;
}
switch(state)
{
case GAMEPLAY:
if (mouseState.lX != 0)
{
Ship->RotateY((float)mouseState.lX/20.5f); // maybe Z?
}
if (mouseState.lY != 0)
{
Ship->RotateX((float)mouseState.lY/20.5f);
}
if (mouseState.rgbButtons[0] & 0x80)
{
Ship->FireLaser();
}
break;
}
}
void SpaceFightGame::ProcessJoystick()
{
HRESULT hr;
Joystick->Poll();
DIJOYSTATE2 js;
hr = Joystick->GetDeviceState(sizeof(DIJOYSTATE2), &js);
if (FAILED(hr))
{
hr = Joystick->Acquire();
while(hr == DIERR_INPUTLOST)
{
hr = Joystick->Acquire();
}
return;
}
switch(state)
{
case GAMEPLAY:
if (js.lX != 32767)
{
float val = ((float)js.lX/65535)*4;
if (val < 2.0f)
val = - (2.0f - val);
else
val = val - 2.0f;
Ship->RotateY(val);
}
if (js.lY != 32767)
{
float val = ((float)js.lY/65535)*4;
if (val < 2.0f)
val = val - 2.0f;
else
val = - (2.0f - val);
Ship->RotateX(-val);
}
if (js.lZ != 32767)
{
float val = ((float)js.lZ/65535)*4;
if (val < 2.0f)
val = val - 2.0f;
else
val = - (2.0f - val);
Ship->RotateZ(-val);
}
if (js.rgbButtons[4] & 0x80)
{
Ship->SpeedUp();
}
else if (js.rgbButtons[5] & 0x80)
{
Ship->SpeedDown();
}
if (js.rgbButtons[0] & 0x80)
{
Ship->FireLaser();
}
break;
}
/*
*/
/* // check this later
if (js.rgdwPOV[0] >= 0)
{
if (js.rgdwPOV[0] >= 0 && js.rgdwPOV[0] < 9000)
Ship->RotateX(ANGLE);
if (js.rgdwPOV[0] <= 18000 && js.rgdwPOV[0] > 9000)
Ship->RotateX(-ANGLE);
if (js.rgdwPOV[0] == 27000)
Ship->RotateY(-ANGLE);
if (js.rgdwPOV[0] == 9000)
Ship->RotateY(ANGLE);
}
*/
}
void SpaceFightGame::SetupCamera()
{
cam.Display();
}
void SpaceFightGame::SetupPerspective()
{
D3DXMATRIX proj;
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI*0.5, getFWidth()/getFHeight(), 0.1f, 10000.0f);
Device->SetTransform(D3DTS_PROJECTION, &proj);
}
void SpaceFightGame::ClearBuffer(DWORD dwColor)
{
Device->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, dwColor, 1.0f, 0 );
}
| [
"[email protected]"
]
| [
[
[
1,
1009
]
]
]
|
1af29e3c8cbe80c6721940d82324f66ddb1c60be | 36d0ddb69764f39c440089ecebd10d7df14f75f3 | /プログラム/Ngllib/include/Ngl/OpenGL/Texture1DGL.h | 5dd21ca652da76fb4363221ebe0164845b98e43e | []
| no_license | weimingtom/tanuki-mo-issyo | 3f57518b4e59f684db642bf064a30fc5cc4715b3 | ab57362f3228354179927f58b14fa76b3d334472 | refs/heads/master | 2021-01-10T01:36:32.162752 | 2009-04-19T10:37:37 | 2009-04-19T10:37:37 | 48,733,344 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 2,367 | h | /*******************************************************************************/
/**
* @file Texture1DGL.h.
*
* @brief OpenGL 1Dテクスチャクラスヘッダファイル.
*
* @date 2008/07/20.
*
* @version 1.00.
*
* @author Kentarou Nishimura.
*/
/******************************************************************************/
#ifndef _NGL_OPENGL_TEXTURE1DGL_H_
#define _NGL_OPENGL_TEXTURE1DGL_H_
#include "TextureGL.h"
namespace Ngl{
namespace OpenGL{
/**
* @class Texture1DGL.
* @brief OpenGL 1Dテクスチャクラス.
*/
class Texture1DGL : public TextureGL
{
public:
/*=========================================================================*/
/**
* @brief コンストラクタ
*
* @param[in] desc テクスチャ作成記述子.
* @param[in] data テクスチャイメージデータ配列.
*/
Texture1DGL( const TextureDesc& desc, const void* data=0 );
private:
/*=========================================================================*/
/**
* @brief イメージを設定
*
* @param[in] data 設定するイメージの配列.
* @param[in] mipLevel 設定先のミップマップレベル.
* @param[in] index 設定先のインデックス番号.
* @return なし.
*/
virtual void texImage( const void* data, unsigned int mipLevel, unsigned int index );
/*=========================================================================*/
/**
* @brief イメージの更新
*
* @param[in] data 更新するイメージデータの配列.
* @param[in] mipLevel 更新先のミップマップレベル.
* @param[in] index 更新先のインデックス番号.
* @return OpenGLターゲットフラグ.
*/
virtual void texSubImage( const void* data, unsigned int mipLevel, unsigned int index );
/*=========================================================================*/
/**
* @brief フレームバッファオブジェクトへのアタッチ
*
* @param[in] drawBuffer 描画バッファ番号.
* @param[in] index インデックス番号.
* @return なし.
*/
virtual void framebufferTexture( GLuint drawBuffer, unsigned int index );
};
} // namespace OpenGL
} // namespace Ngl
#endif
/*===== EOF ==================================================================*/ | [
"rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33"
]
| [
[
[
1,
86
]
]
]
|
f98dd34ffa3a38d8a97d96427497742121f876cd | 011359e589f99ae5fe8271962d447165e9ff7768 | /src/burner/win32/localise.cpp | e9014936b9628484c3b2d3e55fc0cfc4f4621e42 | []
| no_license | PS3emulators/fba-next-slim | 4c753375fd68863c53830bb367c61737393f9777 | d082dea48c378bddd5e2a686fe8c19beb06db8e1 | refs/heads/master | 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,334 | cpp | // Language module, added by regret
/* changelog:
update 2: add string cache
update 1: create
*/
#include "burner.h"
#define LANG_CACHE 0
bool bLanguageActive = false;
TCHAR szLanguage[MAX_PATH] = _T("");
HMODULE hLanguage = NULL;
#if LANG_CACHE
map<int, tstring> stringMap;
#endif
// ----------------------------------------------------------------------------
INT_PTR FBADialogBox(int id, HWND parent, DLGPROC lpDialogFunc)
{
return DialogBox(hLanguage ? hLanguage : hAppInst, MAKEINTRESOURCE(id), parent, lpDialogFunc);
}
HWND FBACreateDialog(int id, HWND parent, DLGPROC lpDialogFunc)
{
return CreateDialog(hLanguage ? hLanguage : hAppInst, MAKEINTRESOURCE(id), parent, lpDialogFunc);
}
HMENU FBALoadMenu(int id)
{
return LoadMenu(hLanguage ? hLanguage : hAppInst, MAKEINTRESOURCE(id));
}
HBITMAP FBALoadBitmap(int id)
{
return LoadBitmap(hLanguage ? hLanguage : hAppInst, MAKEINTRESOURCE(id));
}
int FBALoadString(UINT id, LPTSTR buffer, int maxsize)
{
int ret = 0;
#if LANG_CACHE
map<int, tstring>::iterator iter = stringMap.find(id);
if (iter != stringMap.end()) {
tstring str = iter->second;
int size = str.size() > maxsize ? maxsize : str.size() + 1;
_tcsncpy(buffer, str.c_str(), size);
return size;
}
#endif
ret = LoadString(hLanguage ? hLanguage : hAppInst, id, buffer, maxsize);
#if LANG_CACHE
if (ret > 0) {
// cache string
stringMap[id] = buffer;
}
#endif
return ret;
}
TCHAR* FBALoadStringEx(UINT id, bool translate)
{
static TCHAR loadstr[2048] = _T("");
if (translate) {
FBALoadString(id, loadstr, sizearray(loadstr));
} else {
LoadString(hAppInst, id, loadstr, sizearray(loadstr));
}
return loadstr;
}
// ----------------------------------------------------------------------------
HMODULE FBALocaliseInstance()
{
return hLanguage ? hLanguage : hAppInst;
}
void FBALocaliseExit()
{
// Unload the dll
if (hLanguage) {
FreeLibrary(hLanguage);
hLanguage = NULL;
}
#if LANG_CACHE
stringMap.clear();
#endif
bLanguageActive = false;
}
int FBALocaliseInit(TCHAR* lanaugae)
{
FBALocaliseExit();
if (!lanaugae || !lanaugae[0]) {
return 0;
}
hLanguage = LoadLibrary(lanaugae);
if (!hLanguage) {
FBAPopupAddText(PUF_TYPE_WARNING, _T("Language dll load failed!"));
FBAPopupDisplay(PUF_TYPE_WARNING);
return 1;
}
_tcsncpy(szLanguage, lanaugae, sizearray(szLanguage));
bLanguageActive = true;
return 0;
}
// ---------------------------------------------------------------------------
// Dialog box to load language
static void localiseMakeOfn()
{
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hScrnWnd;
ofn.lpstrFilter = _T("Language (*.dll)\0*.dll\0All Files (*.*)\0*.*\0\0");
ofn.lpstrFile = szChoice;
ofn.nMaxFile = sizearray(szChoice);
ofn.lpstrInitialDir = _T("lang");
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
ofn.lpstrDefExt = _T("dll");
}
int FBALocaliseLoad()
{
localiseMakeOfn();
ofn.lpstrTitle = FBALoadStringEx(IDS_LOCAL_SELECT);
int bOldPause = bRunPause;
bRunPause = 1;
int ret = GetOpenFileName(&ofn);
bRunPause = bOldPause;
if (ret == 0) {
return 1;
}
return FBALocaliseInit(szChoice);
}
| [
"[email protected]"
]
| [
[
[
1,
152
]
]
]
|
d512796564ac6f051b4522240c958200d88933ef | e109ae97b8a43dbf4f4a42a40f8c8da0641237a5 | /Game.h | aeb6f2a3fd8137d4dbd8b7fa35147ae14f1ac9ff | []
| no_license | mtturner/strategoo-code | 8346d48e7b5c038d53843a5195fecd1dc0a4fec9 | 6bdd46fdbd8cc77eca1afdd0bc9e1d293e59e882 | refs/heads/master | 2016-09-06T15:57:20.713674 | 2011-05-06T03:36:15 | 2011-05-06T03:36:15 | 32,553,378 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,176 | h | /******************************************************
Game.h
This is the header file for the Game class.
******************************************************/
#ifndef GAME_H
#define GAME_H
#include "SDL.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include "Player.h"
#include "Computer.h"
#include "Board.h"
#include "Sprite.h"
#include "Piece.h"
#include "Marshal.h"
#include "General.h"
#include "Colonel.h"
#include "Major.h"
#include "Captain.h"
#include "Lieutenant.h"
#include "Sergeant.h"
#include "Miner.h"
#include "Scout.h"
#include "Spy.h"
#include "Bomb.h"
#include "Flag.h"
#include "EmptySpace.h"
#include "Selector.h"
#include "StringInput.h"
#include "PieceButton.h"
#include "Sound.h"
class Game
{
public:
//constructor and destructor
Game();
~Game();
//getters and setters
inline int getState() const;
void setState(const int gameState);
inline int getPreviousState() const;
void setPreviousState(const int gameState);
inline int getTurn() const;
void setTurn(const int turn);
inline SDL_Surface* getScreen() const;
void setScreen(SDL_Surface* s);
inline bool getIsPieceSelected() const;
void setIsPieceSelected(const bool selected);
inline bool getIsButtonSelected() const;
void setIsButtonSelected(const bool selected);
//start up, closing, and render
bool initialize();
void cleanUp() const;
bool render() const;
//main loop functions
bool doIntro();
bool login();
bool doStartMenu();
bool doSetPiece();
bool doPlayGame();
bool doInGameMenu();
bool doStatistics();
//game functions
void startGame();
void resetGame();
bool checkPlayerWins();
bool checkComputerWins();
//collection functions
void addPiece(Piece* const piece);
inline void clearPieces();
//piece functions
Piece* findEmptySpacePiece();
void swapLocation(Piece* const first, Piece* const second) const;
bool isMoveablePiece(Piece* const selected, const int mover) const;
bool isValidMove(Piece* const selected, Piece* const destination) const;
void moveComputerPiece();
//play-by-play
void updatePlayByPlay(Piece* const first, Piece* const sencond,
const int mover, const int winner) const;
void updatePlayByPlay(Piece* const moved, Piece* const destination,
const int mover) const;
void updateComputerPlayByPlay(Piece* const moved,
Piece* const destination) const;
void shiftPlayByPlayDown() const;
void resetPlayByPlay() const;
private:
//SDL_Event structure
SDL_Event gEvent;
//player, computer, and board
Player* gPlayer;
Computer* gComputer;
Board* gBoard;
//game's collection of pieces
std::vector<Piece*> pieces;
//game state backgrounds
Sprite* introBG;
Sprite* loginBG;
Sprite* startMenuBG;
Sprite* setPieceBG;
Sprite* playGameBG;
Sprite* endGameBG;
Sprite* menuBG;
Sprite* statisticsBG;
//piece and piece button overlays
Sprite* pieceOverlay;
Sprite* buttonOverlay;
//sprite for set piece finish
Sprite* finishedSetPiece;
//sprite for naming pieces
Sprite* namePieceBG;
//sprites for winner of game
Sprite* playerWinsImage;
Sprite* computerWinsImage;
//play-by-play sprites
Sprite* playByPlayHeader;
Sprite* playByPlayArea;
Sprite* playByPlayOne;
Sprite* playByPlayTwo;
Sprite* playByPlayThree;
Sprite* playByPlayFour;
Sprite* playByPlayFive;
Sprite* playByPlaySix;
Sprite* playByPlaySeven;
Sprite* playByPlayEight;
Sprite* playByPlayNine;
//selector
Selector* gSelector;
//screen surface
SDL_Surface* screen;
//string input class for login
StringInput* name;
//sound player
Sound* gameSound;
//current and previous game states
int gameState_,
previousState_;
//turn
int turn_;
//piece buttons for set piece
PieceButton* buttons[12];
//selected bools
bool isPieceSelected,
isButtonSelected;
//enumeration of all game states
enum GameStates {STATE_INTRO, STATE_LOGIN, STATE_STARTMENU,
STATE_SETPIECE, STATE_PLAYGAME, STATE_MENU,
STATE_STATISTICS, STATE_EXIT};
};
//*****************************************************
inline int Game::getState() const
{
return gameState_;
}
//*****************************************************
inline int Game::getPreviousState() const
{
return previousState_;
}
//*****************************************************
inline int Game::getTurn() const
{
return turn_;
}
//*****************************************************
inline SDL_Surface* Game::getScreen() const
{
return screen;
}
//*****************************************************
inline bool Game::getIsPieceSelected() const
{
return isPieceSelected;
}
//*****************************************************
inline bool Game::getIsButtonSelected() const
{
return isButtonSelected;
}
//*****************************************************
inline void Game::clearPieces()
{
pieces.clear();
}
#endif
| [
"cakeeater07@28384a92-424b-c9e9-0b9a-6d5e880deeca",
"[email protected]@28384a92-424b-c9e9-0b9a-6d5e880deeca",
"[email protected]@28384a92-424b-c9e9-0b9a-6d5e880deeca",
"member.cory@28384a92-424b-c9e9-0b9a-6d5e880deeca"
]
| [
[
[
1,
5
],
[
7,
37
],
[
39,
39
],
[
41,
131
],
[
134,
156
],
[
158,
161
],
[
164,
225
]
],
[
[
6,
6
],
[
226,
226
]
],
[
[
38,
38
],
[
132,
133
],
[
157,
157
],
[
163,
163
]
],
[
[
40,
40
],
[
162,
162
]
]
]
|
e18efade9791f960bc76976d875f2dc569da5199 | c1a2953285f2a6ac7d903059b7ea6480a7e2228e | /deitel/ch23/Pong/Pong/Pong.cpp | aa520a57d4097611bf35026f515421557449ef0e | []
| no_license | tecmilenio/computacion2 | 728ac47299c1a4066b6140cebc9668bf1121053a | a1387e0f7f11c767574fcba608d94e5d61b7f36c | refs/heads/master | 2016-09-06T19:17:29.842053 | 2008-09-28T04:27:56 | 2008-09-28T04:27:56 | 50,540 | 4 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 12,937 | cpp | // Pong.cpp
// Pong class member-function definitions.
#include <sstream>
using std::ostringstream;
#include <stdexcept>
using std::runtime_error;
#include <Ogre.h> // Ogre class definition
using namespace Ogre; // use the Ogre namespace
#include <OgreAL.h> // OgreAL class definition
#include <OgreStringConverter.h> // OgreStringConverter class definition
#include <OIS\OISEvents.h> // OISEvents class definition
#include <OIS\OISInputManager.h> // OISInputManager class definition
#include <OIS\OISKeyboard.h> // OISKeyboard class definition
#include "Ball.h" // Ball class definition
#include "Paddle.h" // Paddle class definition
#include "Pong.h" // Pong class definition
int Pong::player1Score = 0; // initialize player 1's score to 0
int Pong::player2Score = 0; // initialize player 2's score to 0
bool Pong::wait = false; // initialize wait to false
// directions to move the Paddles
const Vector3 PADDLE_DOWN = Vector3( 0, -15, 0 );
const Vector3 PADDLE_UP = Vector3( 0, 15, 0 );
// constructor
Pong::Pong()
{
rootPtr = new Root(); // initialize Root object
// use the Ogre Config Dialog Box to choose the settings
if ( !( rootPtr->showConfigDialog() ) ) // user canceled the dialog box
throw runtime_error( "User Canceled Ogre Setup Dialog Box." );
// get a pointer to the RenderWindow
windowPtr = rootPtr->initialise( true, "Pong" );
// create the SceneManager
sceneManagerPtr = rootPtr->createSceneManager( ST_GENERIC );
// create the Camera
cameraPtr = sceneManagerPtr->createCamera( "PongCamera" );
cameraPtr->setPosition( Vector3( 0, 0, 200 ) ); // set Camera position
cameraPtr->lookAt( Vector3( 0, 0, 0 ) ); // set where Camera looks
cameraPtr->setNearClipDistance( 5 ); // near distance Camera can see
cameraPtr->setFarClipDistance( 1000 ); // far distance Camera can see
// create the Viewport
viewportPtr = windowPtr->addViewport( cameraPtr );
viewportPtr->setBackgroundColour( ColourValue( 1, 1, 1 ) );
// set the Camera's aspect ratio
cameraPtr->setAspectRatio( Real( viewportPtr->getActualWidth() ) /
( viewportPtr->getActualHeight() ) );
// set the scene's ambient light
sceneManagerPtr->setAmbientLight( ColourValue( 0.75, 0.75, 0.75 ) );
// create the Light
Light *lightPtr = sceneManagerPtr->createLight( "Light" ); // a Light
lightPtr->setPosition( 0, 0, 50 ); // set the Light's position
unsigned long hWnd; // variable to hold the window handle
windowPtr->getCustomAttribute( "WINDOW", &hWnd ); // get window handle
OIS::ParamList paramList; // create an OIS ParamList
// add the window to the ParamList
paramList.insert( OIS::ParamList::value_type( "WINDOW",
Ogre::StringConverter::toString( hWnd ) ) );
// create the InputManager
inputManagerPtr = OIS::InputManager::createInputSystem( paramList );
keyboardPtr = static_cast< OIS::Keyboard* >( inputManagerPtr->
createInputObject( OIS::OISKeyboard, true ) ); // create a Keyboard
keyboardPtr->setEventCallback( this ); // add a KeyListener
rootPtr->addFrameListener( this ); // add this Pong as a FrameListener
// load resources for Pong
ResourceGroupManager::getSingleton().addResourceLocation(
"../../media/pongResources", "FileSystem", "Pong" );
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
quit = pause = false; // player has not quit or paused the game
time = 0; // initialize the time since Ball was reset to 0
} // end Pong constructor
// Pong destructor erases objects contained in a Pong object
Pong::~Pong()
{
// free dynamically allocated memory for Keyboard
inputManagerPtr->destroyInputObject( keyboardPtr );
OIS::InputManager::destroyInputSystem( inputManagerPtr );
// free dynamically allocated memory for Root
delete rootPtr; // release memory pointer points to
rootPtr = 0; // point pointer at 0
// free dynamically allocated memory for Ball
delete ballPtr; // release memory pointer points to
ballPtr = 0; // point pointer at 0
// free dynamically allocated memory for Paddle
delete leftPaddlePtr; // release memory pointer points to
leftPaddlePtr = 0; // point pointer at 0
// free dynamically allocated memory for Paddle
delete rightPaddlePtr; // release memory pointer points to
rightPaddlePtr = 0; // point pointer at 0
} // end Pong destructor
// create the scene to be displayed
void Pong::createScene()
{
// get a pointer to the Score Overlay
Overlay *scoreOverlayPtr =
OverlayManager::getSingleton().getByName( "Score" );
scoreOverlayPtr->show(); // show the Overlay
// make the game objects
ballPtr = new Ball( sceneManagerPtr ); // make the Ball
ballPtr->addToScene(); // add the Ball to the scene
rightPaddlePtr = new Paddle( sceneManagerPtr, "RightPaddle", 90 );
rightPaddlePtr->addToScene(); // add a Paddle to the scene
leftPaddlePtr = new Paddle( sceneManagerPtr, "LeftPaddle", -90 );
leftPaddlePtr->addToScene(); // add a Paddle to the scene
// create the walls
Entity *entityPtr = sceneManagerPtr->
createEntity( "WallLeft", "cube.mesh" ); // create the left wall
entityPtr->setMaterialName( "wall" ); // set material for left wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the left wall
SceneNode *nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallLeft" );
nodePtr->attachObject( entityPtr ); // attach left wall to SceneNode
nodePtr->setPosition( -95, 0, 0 ); // set the left wall's position
nodePtr->setScale( .05, 1.45, .1 ); // set the left wall's size
entityPtr = sceneManagerPtr->createEntity( "WallRight", "cube.mesh" );
entityPtr->setMaterialName( "wall" ); // set material for right wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the right wall
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallRight" );
nodePtr->attachObject( entityPtr ); // attach right wall to SceneNode
nodePtr->setPosition( 95, 0, 0 ); // set the right wall's position
nodePtr->setScale( .05, 1.45, .1 ); // set the right wall's size
entityPtr = sceneManagerPtr->createEntity( "WallBottom", "cube.mesh" );
entityPtr->setMaterialName( "wall" ); // set material for bottom wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the bottom wall
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallBottom" );
nodePtr->attachObject( entityPtr ); // attach bottom wall to SceneNode
nodePtr->setPosition( 0, -70, 0 ); // set the bottom wall's position
nodePtr->setScale( 1.95, .05, .1 ); // set bottom wall's size
entityPtr = sceneManagerPtr->createEntity( "WallTop", "cube.mesh" );
entityPtr->setMaterialName( "wall" ); // set the material for wall
entityPtr->setNormaliseNormals( true ); // fix the normals when scaled
// create the SceneNode for the top wall
nodePtr = sceneManagerPtr->getRootSceneNode()->
createChildSceneNode( "WallTop" );
nodePtr->attachObject( entityPtr ); // attach top wall to SceneNode
nodePtr->setPosition( 0, 70, 0 ); // set the top wall's position
nodePtr->setScale( 1.95, .05, .1 ); // set the top wall's size
} // end function createScene
// start a game of Pong
void Pong::run()
{
createScene(); // create the scene
rootPtr->startRendering(); // start rendering frames
} // end function run
// update the score
void Pong::updateScore( Players player )
{
// increase the correct player's score
if ( player == Players::PLAYER1 )
player1Score++;
else
player2Score++;
wait = true; // the game should wait to restart the Ball
updateScoreText(); // update the score text on the screen
} // end function updateScore
// update the score text
void Pong::updateScoreText()
{
ostringstream scoreText; // text to be displayed
scoreText << "Player 2 Score: " << player2Score; // make the text
// get the right player's TextArea
OverlayElement *textElementPtr =
OverlayManager::getSingletonPtr()->getOverlayElement( "right" );
textElementPtr->setCaption( scoreText.str() ); // set the text
scoreText.str( "" ); // reset the text in scoreText
scoreText << "Player 1 Score: " << player1Score; // make the text
// get the left player's TextArea
textElementPtr =
OverlayManager::getSingletonPtr()->getOverlayElement( "left" );
textElementPtr->setCaption( scoreText.str() ); // set the text
} // end function updateScoreText
// respond to user keyboard input
bool Pong::keyPressed( const OIS::KeyEvent &keyEventRef )
{
// if the game is not paused
if ( !pause )
{
// process KeyEvents that apply when the game is not paused
switch ( keyEventRef.key )
{
case OIS::KC_ESCAPE: // escape key hit: quit
quit = true;
break;
case OIS::KC_UP: // up-arrow key hit: move the right Paddle up
rightPaddlePtr->movePaddle( PADDLE_UP );
break;
case OIS::KC_DOWN: // down-arrow key hit: move the right Paddle down
rightPaddlePtr->movePaddle( PADDLE_DOWN );
break;
case OIS::KC_A: // A key hit: move left Paddle up
leftPaddlePtr->movePaddle( PADDLE_UP );
break;
case OIS::KC_Z: // Z key hit: move left Paddle down
leftPaddlePtr->movePaddle( PADDLE_DOWN );
break;
case OIS::KC_P: // P key hit: pause the game
pause = true; // set pause to true when the user pauses the game
Overlay *pauseOverlayPtr =
OverlayManager::getSingleton().getByName( "PauseOverlay" );
pauseOverlayPtr->show(); // show the pause Overlay
break;
} // end switch
} // end if
else // game is paused
{
// user hit 'R' on the keyboard
if ( keyEventRef.key == OIS::KC_R )
{
pause = false; // set pause to false when user resumes the game
Overlay *pauseOverlayPtr =
OverlayManager::getSingleton().getByName( "PauseOverlay" );
pauseOverlayPtr->hide(); // hide the pause Overlay
} // end if
} // end else
return true;
} // end function keyPressed
// process key released events
bool Pong::keyReleased( const OIS::KeyEvent &keyEventRef )
{
return true;
} // end function keyReleased
// return true if the program should render the next frame
bool Pong::frameEnded( const FrameEvent &frameEvent )
{
return !quit; // quit = false if the user hasn't quit yet
} // end function frameEnded
// process game logic, return true if the next frame should be rendered
bool Pong::frameStarted( const FrameEvent &frameEvent )
{
keyboardPtr->capture(); // get keyboard events
// the game is not paused and the Ball should move
if ( !wait && !pause )
{
// move the Ball
ballPtr->moveBall( frameEvent.timeSinceLastFrame );
} // end if
// don't move the Ball if wait is true
else if ( wait )
{
// increase time if it is less than 4 seconds
if ( time < 4 )
// add the seconds since the last frame
time += frameEvent.timeSinceLastFrame;
else
{
wait = false; // shouldn't wait to move the Ball any more
time = 0; // reset the control variable to 0
} // end else
} // end else
return !quit; // quit = false if the user hasn't quit yet
} // end function frameStarted
/**************************************************************************
* (C) Copyright 1992-2008 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/
| [
"[email protected]"
]
| [
[
[
1,
315
]
]
]
|
eacad6266e828d8786f654518f4055861720e055 | 370d07b4ae576fc268ff0b5a9d11b3baa0a87ef8 | /defines.cpp | 1f0ccd9c8adbaf4ce2938f9611908575e7cf6110 | []
| no_license | syu93/uelplayer | db94ee55d155316adac95c77864862a9dfa306a2 | e090d3ed2a96424489c43f428f1dd285036f15a9 | refs/heads/master | 2021-01-02T09:34:32.921487 | 2009-11-05T03:14:44 | 2009-11-05T03:14:44 | 39,090,735 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 1,397 | cpp | //nome de músicas
#define MAX_NAME 150
//resolução
#define MAX_X 640
#define MAX_Y 480
//tempos
#define REFRESH 0.002 //2ms
#define BUTTON 0.200 //200ms
#define BUTTON2 0.150 //150ms
//modos
#define BIBLIOTECA 1
#define LETRA 2
#define CONFIG 3
#define AJUDA 4
//cores
#define BLUE makecol(40,40,170)
#define BLUE2 makecol(20,20,150)
#define RED makecol(150,40,40)
#define RED2 makecol(130,20,20)
#define GREEN makecol(40,130,40)
#define GREEN2 makecol(20,110,20)
#define GRAY makecol(80,80,80)
#define GRAY2 makecol(60,60,60)
//abas
#define ABA_Y1 61
#define ABA_Y2 380
#define ABA_Y ABA_Y2-ABA_Y1
#define ABA_X1 150
#define ABA_X2 300
#define ABA_X3 450
//botões
#define REPEAT_X 123
#define REPEAT_Y 448
#define PLAY_X 323
#define PLAY_Y 448
#define STOP_X 203
#define STOP_Y 448
#define FWARD_X 373
#define FWARD_Y 448
#define BWARD_X 273
#define BWARD_Y 448
#define MUTE_X 603
#define MUTE_Y 448
#define COR_X1 100
#define COR_Y1 100
#define COR_X2 200
#define COR_Y2 100
#define COR_X3 300
#define COR_Y3 100
#define COR_X4 400
#define COR_Y4 100
//posição
#define POS_X1 5
#define POS_X2 505
#define POS_Y1 388
#define POS_Y2 392
//volume
#define VOL_X1 501
#define VOL_X2 564
#define VOL_Y1 436
#define VOL_Y2 455
| [
"marokamura@edcf5732-aeb1-11de-b4c2-c9e47ae42fda"
]
| [
[
[
1,
70
]
]
]
|
7ed5e7f0e0306732b57b2cb31bdab3291d1e5f1a | 4a2b2d6d07714e82ecf94397ea6227edbd7893ad | /Curl/CurlTest/Listener.cpp | 3f44cc62cf36410185e71fe3e207f7104b7ca868 | []
| no_license | intere/tmee | 8b0a6dd4651987a580e3194377cfb999e9615758 | 327fed841df6351dc302071614a9600e2fa67f5f | refs/heads/master | 2021-01-25T07:28:47.788280 | 2011-07-21T04:24:31 | 2011-07-21T04:24:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 148 | cpp | #include "StdAfx.h"
#include ".\listener.h"
#using <mscorlib.dll>
template <class E>
void Listener<E>::eventOccurred(const E& event)
{
} | [
"intere@8c6822e2-464b-4b1f-8ae9-3c1f0a8e8225"
]
| [
[
[
1,
10
]
]
]
|
0bb28a223d41b2c30563770041a2f9660c9fd76c | 515e917815568d213e75bfcbd3fb9f0e08cf2677 | /modelconverter/modelconverter.h | f1812bb6cdd3554266482b42c21a43cfc0820593 | [
"BSD-2-Clause"
]
| permissive | dfk789/CodenameInfinite | bd183aec6b9e60e20dda6764d99f4e8d8a945add | aeb88b954b65f6beca3fb221fe49459b75e7c15f | refs/heads/master | 2020-05-30T15:46:20.450963 | 2011-10-15T00:21:38 | 2011-10-15T00:21:38 | 5,652,791 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,813 | h | #ifndef Lw_MODELCONVERTER_H
#define LW_MODELCONVERTER_H
#include <EASTL/vector.h>
#include <EASTL/string.h>
#include <iostream>
#include <fstream>
#include <worklistener.h>
#include "convmesh.h"
class CModelConverter
{
public:
CModelConverter(CConversionScene* pScene);
public:
bool ReadModel(const tstring& sFilename);
void ReadOBJ(const tstring& sFilename);
void ReadMTL(const tstring& sFilename);
// SIA and its utility functions.
void ReadSIA(const tstring& sFilename);
const tchar* ReadSIAMat(const tchar* pszLine, const tchar* pszEnd, CConversionSceneNode* pScene, const tstring& sFilename);
const tchar* ReadSIAShape(const tchar* pszLine, const tchar* pszEnd, CConversionSceneNode* pScene, bool bCare = true);
void ReadDAE(const tstring& sFilename);
void ReadDAESceneTree(class FCDSceneNode* pNode, CConversionSceneNode* pScene);
bool SaveModel(const tstring& sFilename);
void SaveOBJ(const tstring& sFilename);
void SaveSIA(const tstring& sFilename);
void SaveDAE(const tstring& sFilename);
void SaveDAEScene(class FCDSceneNode* pNode, CConversionSceneNode* pScene);
void WriteSMDs(const tstring& sFilename = _T(""));
void WriteSMD(size_t iMesh, const tstring& sFilename = _T(""));
tstring GetFilename(const tstring& sFilename);
tstring GetDirectory(const tstring& sFilename);
bool IsWhitespace(tstring::value_type cChar);
tstring StripWhitespace(tstring sLine);
void SetScene(CConversionScene* pScene) { m_pScene = pScene; };
CConversionScene* GetScene() { return m_pScene; };
void SetWorkListener(IWorkListener* pWorkListener) { m_pWorkListener = pWorkListener; }
protected:
CConversionScene* m_pScene;
IWorkListener* m_pWorkListener;
};
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
17
],
[
19,
19
],
[
22,
23
],
[
27,
27
],
[
29,
30
],
[
32,
32
],
[
36,
37
],
[
40,
40
],
[
45,
56
]
],
[
[
18,
18
],
[
20,
21
],
[
24,
26
],
[
28,
28
],
[
31,
31
],
[
33,
35
],
[
38,
39
],
[
41,
44
],
[
57,
57
]
]
]
|
08496e0017d4c7e8500179f57399378290c3ee77 | 5f0b8d4a0817a46a9ae18a057a62c2442c0eb17e | /Include/theme/Default/TitleBarTheme.cpp | 8a724f52efd088f2e2f55f3e277f8e64c7584cc7 | [
"BSD-3-Clause"
]
| permissive | gui-works/ui | 3327cfef7b9bbb596f2202b81f3fc9a32d5cbe2b | 023faf07ff7f11aa7d35c7849b669d18f8911cc6 | refs/heads/master | 2020-07-18T00:46:37.172575 | 2009-11-18T22:05:25 | 2009-11-18T22:05:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,790 | cpp | /*
* Copyright (c) 2003-2006, Bram Stein
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "./TitleBarTheme.h"
#include "../../component/Button.h"
namespace ui
{
namespace theme
{
namespace defaulttheme
{
TitleBarTheme::TitleBarTheme()
: background(util::Color(224,224,224),util::Color(180,180,180),util::GradientColor::DEGREES_90),
borderColor(128,128,128),
border(borderColor,1), // is this dangerous? initialization order?
foreground(0,0,0)
{
}
void TitleBarTheme::installTheme(Component *comp)
{
TitleBar * titleBar = static_cast<TitleBar*>(comp);
titleBar->getCloseButton()->setDefaultIcon(&closeIcon);
titleBar->getCloseButton()->setSelectedIcon(&closeIcon);
titleBar->getCloseButton()->setMargin(util::Insets(0,0,0,0));
titleBar->getCloseButton()->setFocusPainted(false);
titleBar->getTitleLabel()->setMargin(util::Insets(0,5,0,0));
//titleBar->getTitleLabel()->setForeground(&foreground);
titleBar->setBackground(SchemeManager::getInstance().getScheme()->getTitleBarDeselected());
titleBar->setBorder(&border);
titleBar->setInsets(util::Insets(0,0,1,0)); // draw only the bottom border (looks better)
titleBar->getTitleLabel()->setBackground(&background);
}
void TitleBarTheme::deinstallTheme(Component *comp)
{
}
// -------------------------------------------------------------------
TitleBarTheme::CloseIcon::CloseIcon()
: foreground(0,0,0)
{
}
int TitleBarTheme::CloseIcon::getIconHeight() const
{
return 15;
}
int TitleBarTheme::CloseIcon::getIconWidth() const
{
return 15;
}
void TitleBarTheme::CloseIcon::paint(const Component *comp, Graphics &g, int x, int y) const
{
int spacing = 2;
int border = 1;
g.setPaint(&foreground);
int xbase = x + spacing + border;
int ybase = y + spacing + border;
g.setLineWidth(2);
g.drawLine(xbase, ybase, xbase + getIconWidth() - spacing - spacing - border - border, ybase + getIconHeight() - spacing - spacing - border - border);
g.drawLine(xbase + getIconWidth() - spacing - spacing - border - border, ybase, xbase, ybase + getIconHeight() - spacing - spacing - border - border);
g.setLineWidth(1);
}
}
}
} | [
"bs@bram.(none)"
]
| [
[
[
1,
99
]
]
]
|
4c40fcc41016b362f9d235c1ecd2ae5e4963b9a3 | 001a97b7d4dba30c022f7fe118161f69fa8bed24 | /Launchy_VC7/src/PluginDialog.cpp | 8ad61d7665b70c819c0716431338d5ca87924375 | []
| no_license | svn2github/Launchy | 8d8e56727a9a1df600a42f349cbca3d51840c943 | 601356dbb4e9cdda87605cfff049b315a70b438f | refs/heads/master | 2023-09-03T11:37:28.828055 | 2010-11-10T01:14:44 | 2010-11-10T01:14:44 | 98,788,809 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,603 | cpp | // PluginDialog.cpp : implementation file
//
#include "stdafx.h"
#include "Launchy.h"
#include "PluginDialog.h"
#include ".\plugindialog.h"
#include "LaunchyDlg.h"
#include "Plugin.h"
#include <map>
using namespace std;
// CPluginDialog dialog
IMPLEMENT_DYNAMIC(CPluginDialog, CDialog)
CPluginDialog::CPluginDialog(CWnd* pParent /*=NULL*/)
: CDialog(CPluginDialog::IDD, pParent)
{
}
CPluginDialog::~CPluginDialog()
{
}
void CPluginDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PLUGINLIST, PluginList);
DDX_Control(pDX, IDC_OPTIONS, OptionsButton);
}
BEGIN_MESSAGE_MAP(CPluginDialog, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDC_OPTIONS, OnBnClickedOptions)
ON_LBN_SELCHANGE(IDC_PLUGINLIST, OnSelChange)
END_MESSAGE_MAP()
// CPluginDialog message handlers
BOOL CPluginDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
shared_ptr<Plugin> plugins = ((CLaunchyDlg*)AfxGetMainWnd())->plugins;
if (plugins == NULL) return true;
plugins->LoadDlls(false);
PluginList.ResetContent();
PluginList.SetCheckStyle( BS_AUTOCHECKBOX );
for(int i = 0; i < plugins->allPlugins.size(); i++) {
CString str;
str.Format(L" %s - %s", plugins->allPlugins[i].name, plugins->allPlugins[i].description);
PluginList.AddString(str);
PluginList.SetCheck(i, plugins->allPlugins[i].loaded);
}
if (plugins->allPlugins.size() > 0)
PluginList.SetSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPluginDialog::OnBnClickedOk()
{
shared_ptr<Plugin> plugins = ((CLaunchyDlg*)AfxGetMainWnd())->plugins;
if (plugins == NULL) return;
// Tell the plugin manager of the
int changes = 0;
for(int i = 0; i < PluginList.GetCount(); i++) {
if (PluginList.GetCheck(i) != plugins->allPlugins[i].loaded)
changes++;
plugins->allPlugins[i].loaded = PluginList.GetCheck(i);
}
if (changes > 0) {
AfxMessageBox(L"Launchy will now be restarted to apply the plugin changes you have made");
// Load a new Launchy
int numArgs;
LPWSTR* strings = CommandLineToArgvW(GetCommandLine(), &numArgs);
SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = strings[0];
ShExecInfo.lpParameters = L"/wait";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_NORMAL;
ShExecInfo.hInstApp = NULL;
BOOL ret = ShellExecuteEx(&ShExecInfo);
((CLaunchyDlg*)AfxGetMainWnd())->options->Store();
((CLaunchyDlg*)AfxGetMainWnd())->EndDialog(1);
// ASSERT(AfxGetApp()->m_pMainWnd != NULL);
// AfxGetApp()->m_pMainWnd->PostMessage(WM_CLOSE);
}
OnOK();
}
void CPluginDialog::OnBnClickedOptions()
{
shared_ptr<Plugin> plugins = ((CLaunchyDlg*)AfxGetMainWnd())->plugins;
if (plugins == NULL) return;
int id = PluginList.GetCurSel();
if (id == LB_ERR) return;
plugins->CallOptionsDlg(plugins->allPlugins[id], this->GetSafeHwnd());
}
void CPluginDialog::OnSelChange()
{
shared_ptr<Plugin> plugins = ((CLaunchyDlg*)AfxGetMainWnd())->plugins;
if (plugins == NULL) {
OptionsButton.EnableWindow(false);
return;
}
int id = PluginList.GetCurSel();
if (id == LB_ERR) return;
if (plugins->allPlugins[id].hasOptionsDlg)
OptionsButton.EnableWindow(true);
else
OptionsButton.EnableWindow(false);
}
| [
"karlinjf@a198a55a-610f-0410-8134-935da841aa8c"
]
| [
[
[
1,
143
]
]
]
|
eac4085b38aafffd23462ebf65b724e5dd001831 | dca366f7f7597c87e3b7936c5f4f8dbc612a7fec | /BotNet/client/CrazyUncleBurton/c/rrbase/rrbase.cpp | e604617243f94898a47976b41cd4e40069d8e503 | []
| no_license | mojomojomojo/MegaMinerAI | 6e0183b45f20e57af90e31a412c303f9b3e508d7 | 4457c8255583c10da3ed683ec352f32e1b35295a | refs/heads/master | 2020-05-18T10:44:16.037341 | 2011-12-12T17:13:46 | 2011-12-12T17:13:46 | 2,779,888 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,261 | cpp | #include "rrbase.h"
#include <stdint.h>
#include <map>
using namespace std;
map<int,uint32_t> spawnCounts; // global
map<int,uint32_t>::iterator counti;
// if we've already attempted to spawn this turn.
map<int,bool> spawnedThisTurn;
void distribute_base_spawning( AI* ai, Map& m ) {
int max_iters = 6;
// While we can afford a level 0.
int iters = 0;
cout << "Spawn Counts: ";
for (counti=spawnCounts.begin();
counti != spawnCounts.end();
counti++) {
cout << " [" << (*counti).first << "]" << (*counti).second;
}
cout << endl;
while (ai->baseCost() <= ai->players[ai->playerID()].cycles()
&& iters++ < max_iters) {
//cout << " [SPAWN_LOOP]" << endl;
uint32_t min_spawns = 0xFFFFFFFF;
vector<Base>::iterator min_base;
uint8_t canSpawn = ai->bases.size();
for (vector<Base>::iterator base = ai->bases.begin();
base != ai->bases.end();
base++) {
spawnedThisTurn[(*base).id()] = false;
}
// Find the base with the least amount of spawned viruses.
for (vector<Base>::iterator base = ai->bases.begin();
base != ai->bases.end();
base++) {
// cout << " [BASE_LOOP]" << endl;
if ((*base).owner() != ai->playerID()) {
canSpawn--;
continue;
}
if (spawnedThisTurn[(*base).id()]) {
canSpawn--;
continue;
}
if ((*base).spawnsLeft() < 1) {
canSpawn--;
continue;
}
if (spawnCounts.count((*base).id()) > 0) {
uint32_t spawns = spawnCounts[(*base).id()];
if (spawns < min_spawns) {
// new low base
min_spawns = spawns;
min_base = base;
}
} else {
cout << " Base " << (*base).id() << " never spawned" << endl;
min_base = base;
min_spawns = 0;
}
}
cout << "Spawning from base " << (*min_base).id() << " (min:" << min_spawns << ")" << endl;
(*min_base).spawn(0);
spawnCounts[(*min_base).id()] = min_spawns+1;
spawnedThisTurn[(*min_base).id()] = true;
cout << "Bases that can spawn: " << (uint32_t)canSpawn << endl;
if (canSpawn == 0) break;
}
return;
}
| [
"[email protected]"
]
| [
[
[
1,
80
]
]
]
|
299a79fa8852bdc804b9b52d163bb24211d7ab50 | b49cf93c06ea6b4b13fee18cf64cd2f6f8528cc8 | /src/Native/db.h | 13410372043671975f5a5bd561f1317d51f3b72e | []
| no_license | Yitzchok/LevelDBWrapper | ba43c3f259c91f52683865fedbe8385920b0fbd0 | d8e9f950af57e0511a39605b50c736754b2709e7 | refs/heads/master | 2021-01-13T01:43:58.764843 | 2011-11-21T09:01:20 | 2011-11-21T09:01:20 | 2,818,192 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,509 | h | // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#ifndef STORAGE_LEVELDB_INCLUDE_DB_H_
#define STORAGE_LEVELDB_INCLUDE_DB_H_
#include <stdint.h>
#include <stdio.h>
#include "iterator.h"
#include "options.h"
namespace leveldb {
static const int kMajorVersion = 1;
static const int kMinorVersion = 2;
struct Options;
struct ReadOptions;
struct WriteOptions;
class WriteBatch;
// Abstract handle to particular state of a DB.
// A Snapshot is an immutable object and can therefore be safely
// accessed from multiple threads without any external synchronization.
class Snapshot {
protected:
virtual ~Snapshot();
};
// A range of keys
struct Range {
Slice start; // Included in the range
Slice limit; // Not included in the range
Range() { }
Range(const Slice& s, const Slice& l) : start(s), limit(l) { }
};
// A DB is a persistent ordered map from keys to values.
// A DB is safe for concurrent access from multiple threads without
// any external synchronization.
class DB {
public:
// Open the database with the specified "name".
// Stores a pointer to a heap-allocated database in *dbptr and returns
// OK on success.
// Stores NULL in *dbptr and returns a non-OK status on error.
// Caller should delete *dbptr when it is no longer needed.
static Status Open(const Options& options,
const std::string& name,
DB** dbptr);
DB() { }
virtual ~DB();
// Set the database entry for "key" to "value". Returns OK on success,
// and a non-OK status on error.
// Note: consider setting options.sync = true.
virtual Status Put(const WriteOptions& options,
const Slice& key,
const Slice& value) = 0;
// Remove the database entry (if any) for "key". Returns OK on
// success, and a non-OK status on error. It is not an error if "key"
// did not exist in the database.
// Note: consider setting options.sync = true.
virtual Status Delete(const WriteOptions& options, const Slice& key) = 0;
// Apply the specified updates to the database.
// Returns OK on success, non-OK on failure.
// Note: consider setting options.sync = true.
virtual Status Write(const WriteOptions& options, WriteBatch* updates) = 0;
// If the database contains an entry for "key" store the
// corresponding value in *value and return OK.
//
// If there is no entry for "key" leave *value unchanged and return
// a status for which Status::IsNotFound() returns true.
//
// May return some other Status on an error.
virtual Status Get(const ReadOptions& options,
const Slice& key, std::string* value) = 0;
// Return a heap-allocated iterator over the contents of the database.
// The result of NewIterator() is initially invalid (caller must
// call one of the Seek methods on the iterator before using it).
//
// Caller should delete the iterator when it is no longer needed.
// The returned iterator should be deleted before this db is deleted.
virtual Iterator* NewIterator(const ReadOptions& options) = 0;
// Return a handle to the current DB state. Iterators created with
// this handle will all observe a stable snapshot of the current DB
// state. The caller must call ReleaseSnapshot(result) when the
// snapshot is no longer needed.
virtual const Snapshot* GetSnapshot() = 0;
// Release a previously acquired snapshot. The caller must not
// use "snapshot" after this call.
virtual void ReleaseSnapshot(const Snapshot* snapshot) = 0;
// DB implementations can export properties about their state
// via this method. If "property" is a valid property understood by this
// DB implementation, fills "*value" with its current value and returns
// true. Otherwise returns false.
//
//
// Valid property names include:
//
// "leveldb.num-files-at-level<N>" - return the number of files at level <N>,
// where <N> is an ASCII representation of a level number (e.g. "0").
// "leveldb.stats" - returns a multi-line string that describes statistics
// about the internal operation of the DB.
// "leveldb.sstables" - returns a multi-line string that describes all
// of the sstables that make up the db contents.
virtual bool GetProperty(const Slice& property, std::string* value) = 0;
// For each i in [0,n-1], store in "sizes[i]", the approximate
// file system space used by keys in "[range[i].start .. range[i].limit)".
//
// Note that the returned sizes measure file system space usage, so
// if the user data compresses by a factor of ten, the returned
// sizes will be one-tenth the size of the corresponding user data size.
//
// The results may not include the sizes of recently written data.
virtual void GetApproximateSizes(const Range* range, int n,
uint64_t* sizes) = 0;
// Compact the underlying storage for the key range [*begin,*end].
// In particular, deleted and overwritten versions are discarded,
// and the data is rearranged to reduce the cost of operations
// needed to access the data. This operation should typically only
// be invoked by users who understand the underlying implementation.
//
// begin==NULL is treated as a key before all keys in the database.
// end==NULL is treated as a key after all keys in the database.
// Therefore the following call will compact the entire database:
// db->CompactRange(NULL, NULL);
virtual void CompactRange(const Slice* begin, const Slice* end) = 0;
private:
// No copying allowed
DB(const DB&);
void operator=(const DB&);
};
// Destroy the contents of the specified database.
// Be very careful using this method.
Status DestroyDB(const std::string& name, const Options& options);
// If a DB cannot be opened, you may attempt to call this method to
// resurrect as much of the contents of the database as possible.
// Some data may be lost, so be careful when calling this function
// on a database that contains important information.
Status RepairDB(const std::string& dbname, const Options& options);
} // namespace leveldb
#endif // STORAGE_LEVELDB_INCLUDE_DB_H_
| [
"[email protected]"
]
| [
[
[
1,
160
]
]
]
|
9c460f7d9926fafcd714b4c533a80cca27d59ea4 | 0d717689533512937c427d3695e7f47839f23a9b | /scbwai/BWSAL_0.9.11/BWSAL_0.9.11/Addons/TaskStream.cpp | bf3dde2bfd3a86d7ce462086f246b254428833ec | [
"MIT"
]
| permissive | unqueued/bwmas | 1b6d506ab390339b82992563230622dbedd1a76f | 22ad91482aed041684bc2389661260e0d8d8dda5 | refs/heads/master | 2020-12-24T13:28:48.836488 | 2011-05-17T21:40:27 | 2011-05-17T21:40:27 | 35,456,383 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,564 | cpp | #include <MacroManager/TaskStream.h>
#include <MacroManager/TaskStreamObserver.h>
#include <MacroManager/UnitReadyTimeCalculator.h>
#include <BasicWorkerFinder.h>
#include <TerminateIfEmpty.h>
#include <BasicTaskExecutor.h>
#include <BFSBuildingPlacer.h>
#include <math.h>
using namespace BWAPI;
using namespace std;
TaskStream::TaskStream(Task t0, Task t1, Task t2, Task t3)
{
task.clear();
task.push_back(t0);
task.push_back(t1);
task.push_back(t2);
task.push_back(t3);
worker = NULL;
buildUnit = NULL;
status = None;
killSwitch = false;
plannedAdditionalResources = false;
}
TaskStream::~TaskStream()
{
//delete observers that we own
for each(std::pair<TaskStreamObserver*, bool> obs in observers)
{
obs.first->detached(this);
if (obs.second)
delete obs.first;
}
observers.clear();
}
void TaskStream::terminate()
{
TheMacroManager->killSet.insert(this);
killSwitch = true;
}
void TaskStream::onRevoke(BWAPI::Unit* unit)
{
if (worker == unit)
{
worker = NULL;
workerReady = false;
}
}
void TaskStream::computeBuildUnit()
{
if (task[0].getType()!=TaskTypes::Unit)
{
buildUnit = NULL;
return;
}
UnitType ut = task[0].getUnit();
//if the building dies, or isn't the right type, set it to null
if (!(buildUnit != NULL && buildUnit->exists() && (buildUnit->getType() == ut || buildUnit->getBuildType() == ut)))
buildUnit = NULL;
if (locationReady)
{
if (buildUnit==NULL && ut.isBuilding()) //if we don't have a building yet, look for it
{
TilePosition bl = task[0].getTilePosition();
//look at the units on the tile to see if it exists yet
for each(Unit* u in Broodwar->unitsOnTile(bl.x(), bl.y()))
if (u->getType() == ut && !u->isLifted())
{
//we found the building
buildUnit = u;
break;
}
}
if (buildUnit == NULL && ut.isAddon()) //if we don't have a building yet, look for it
{
TilePosition bl = task[0].getTilePosition();
bl.x()+=4;
bl.y()++;
for each(Unit* u in Broodwar->unitsOnTile(bl.x(), bl.y()))
if (u->getType() == ut && !u->isLifted())
{
//we found the building
buildUnit = u;
break;
}
}
}
if (workerReady==false) return;
if (!worker->exists() || !worker->isCompleted()) return;
if (worker->exists() && worker->isCompleted() && worker->getBuildUnit() != NULL && worker->getBuildUnit()->exists() && (worker->getBuildUnit()->getType() == ut || worker->getBuildUnit()->getBuildType() == ut))
buildUnit = worker->getBuildUnit();
if (worker->getAddon() != NULL && worker->getAddon()->exists() && (worker->getAddon()->getType() == ut || worker->getAddon()->getBuildType() == ut))
buildUnit = worker->getAddon();
//check to see if the worker is the right type
//Zerg_Nydus_Canal is special since Zerg_Nydus_Canal can construct Zerg_Nydus_Canal
if ((worker->getType() == ut || (worker->isMorphing() && worker->getBuildType() == ut)) && worker->getType()!=UnitTypes::Zerg_Nydus_Canal)
buildUnit = worker;
}
void TaskStream::computeStatus()
{
locationReady = true;
workerReady = (worker != NULL) && worker->exists() && TheArbitrator->hasBid(worker) && TheArbitrator->getHighestBidder(worker).first==TheMacroManager;
computeBuildUnit();
if (task[0].getType()==TaskTypes::Unit)
{
UnitType ut = task[0].getUnit();
if (ut.isBuilding() && !ut.whatBuilds().first.isBuilding() && buildUnit == NULL && (worker==NULL || worker->getBuildUnit()==NULL))
{
TilePosition tp = task[0].getTilePosition();
if (ut.isAddon())
{
tp.x()+=4;
tp.y()++;
}
bool canBuildHere = Broodwar->canBuildHere(NULL,tp,ut);
if (workerReady)
canBuildHere = Broodwar->canBuildHere(worker,tp,ut);
if (task[0].getTilePosition().isValid()==false || !canBuildHere)
locationReady = false;
}
}
if (task[0].getType()==TaskTypes::Unit && task[0].getTilePosition().isValid() && task[0].getUnit().isBuilding())
{
UnitType ut = task[0].getUnit();
TilePosition tp = task[0].getTilePosition();
if (ut.isAddon())
{
tp.x()+=4;
tp.y()++;
}
if (locationReady)
Broodwar->drawBoxMap(tp.x()*32,tp.y()*32,tp.x()*32+ut.tileWidth()*32,tp.y()*32+ut.tileHeight()*32,Colors::Green);
else
Broodwar->drawBoxMap(tp.x()*32,tp.y()*32,tp.x()*32+ut.tileWidth()*32,tp.y()*32+ut.tileHeight()*32,Colors::Red);
Broodwar->drawTextMap(tp.x()*32,tp.y()*32,"%s",ut.getName().c_str());
}
if (task[0] == NULL)
{
status = Error_Task_Not_Specified;
return;
}
if (task[0].isExecuting() || task[0].isCompleted() || buildUnit ||
(task[0].hasSpentResources() && workerReady && locationReady))
status = Executing_Task;
else
{
if (task[0].getType()==TaskTypes::Unit)
{
UnitType ut = task[0].getUnit();
if (ut.isBuilding() && !ut.whatBuilds().first.isBuilding() && buildUnit == NULL)
{
if (task[0].getTilePosition().isValid()==false)
{
status = Error_Location_Not_Specified;
return;
}
TilePosition tp = task[0].getTilePosition();
if (ut.isAddon())
{
tp.x()+=4;
tp.y()++;
}
bool canBuildHere = Broodwar->canBuildHere(NULL,tp,ut);
if (workerReady)
canBuildHere = Broodwar->canBuildHere(worker,tp,ut);
if (!canBuildHere) //doesn't work for blocked addons!
{
status = Error_Location_Blocked;
return;
}
}
}
if (task[0].getType()==TaskTypes::Unit && workerReady)
{
UnitType ut = task[0].getUnit();
for each(std::pair<UnitType, int> t in ut.requiredUnits())
{
if (t.first.isAddon() && t.first.whatBuilds().first == worker->getType() && worker->getAddon() == NULL)
{
status = Error_Task_Requires_Addon;
return;
}
}
}
}
for(int i=0;i<(int)(task.size());i++)
{
if (i>0 && task[i-1].getStartTime()==-1) break;
if (task[i].getType()==TaskTypes::None) break;
if (!task[i].hasReservedResourcesThisFrame())
{
UnitReadyTimeStatus::Enum reason;
int first_valid_frame = UnitReadyTimeCalculator::getFirstFreeTime(worker, task[i], reason,true,true);
if (first_valid_frame==Broodwar->getFrameCount() && !workerReady)
{
first_valid_frame = Broodwar->getFrameCount()+10;
if (worker==NULL || worker->exists() == false)
reason = UnitReadyTimeStatus::Error_Worker_Not_Specified;
else
reason = UnitReadyTimeStatus::Error_Worker_Not_Owned;
}
task[i].setStartTime(first_valid_frame);
//if we need to wait to start the first task, compute the correct status
if ( i==0 ) //compute task stream status based on status of first unit
{
if (task[0].getStartTime()!=-1 && task[0].getStartTime()<=Broodwar->getFrameCount() && workerReady)
status = Executing_Task;
else
{
if (reason == UnitReadyTimeStatus::Error_Task_Requires_Addon)
status = Error_Task_Requires_Addon;
else if (reason == UnitReadyTimeStatus::Waiting_For_Worker_To_Be_Ready)
status = Waiting_For_Worker_To_Be_Ready;
else if (reason == UnitReadyTimeStatus::Waiting_For_Free_Time)
status = Waiting_For_Free_Time;
else if (reason == UnitReadyTimeStatus::Waiting_For_Earliest_Start_Time)
status = Waiting_For_Earliest_Start_Time;
else if (reason == UnitReadyTimeStatus::Waiting_For_Required_Units)
status = Waiting_For_Required_Units;
else if (reason == UnitReadyTimeStatus::Waiting_For_Required_Tech)
status = Waiting_For_Required_Tech;
else if (reason == UnitReadyTimeStatus::Waiting_For_Required_Upgrade)
status = Waiting_For_Required_Upgrade;
else if (reason == UnitReadyTimeStatus::Waiting_For_Supply)
status = Waiting_For_Supply;
else if (reason == UnitReadyTimeStatus::Waiting_For_Gas)
status = Waiting_For_Gas;
else if (reason == UnitReadyTimeStatus::Waiting_For_Minerals)
status = Waiting_For_Minerals;
else if (reason == UnitReadyTimeStatus::Error_Worker_Not_Specified)
status = Error_Worker_Not_Specified;
else
status = Error_Worker_Not_Owned;
}
}
if (first_valid_frame==-1) break;
if (!TheMacroManager->rtl.reserveResources(first_valid_frame,task[i].getResources()))
Broodwar->printf("Error: Unable to reserve resources for %s",task[i].getName().c_str());
if (workerReady)
{
//protoss buildings don't take up worker time.
if (!(task[i].getType()==TaskTypes::Unit && task[i].getUnit().isBuilding() && task[i].getRace()==Races::Protoss))
{
if (task[i].getType() == TaskTypes::Unit && task[i].getUnit().whatBuilds().first == UnitTypes::Zerg_Larva && worker->getType().producesLarva())
{
if (!TheMacroManager->ltl.reserveLarva(worker,first_valid_frame))
Broodwar->printf("Error: Unable to reserve larva for %s",task[i].getName().c_str());
}
else
{
if (!TheMacroManager->wttl.reserveTime(worker,first_valid_frame,&task[i]))
Broodwar->printf("Error: Unable to reserve time for %s",task[i].getName().c_str());
}
}
}
TheMacroManager->plan[first_valid_frame].push_back(std::make_pair(this,task[i]));
if (task[i].getType()==TaskTypes::Tech)
TheMacroManager->ttl.registerTechStart(first_valid_frame,task[i].getTech());
task[i].setReservedResourcesThisFrame(true);
}
if (task[i].hasReservedResourcesThisFrame() && !task[i].hasReservedFinishDataThisFrame())
{
if (task[i].getType()==TaskTypes::Unit)
{
if (task[i].getUnit().supplyProvided()>0)
TheMacroManager->rtl.registerSupplyIncrease(task[i].getFinishTime(), task[i].getUnit().supplyProvided());
int count = 1;
if (task[i].getUnit().isTwoUnitsInOneEgg())
count = 2;
TheMacroManager->uctl.registerUnitCountChange(task[i].getFinishTime(), task[i].getUnit(), count);
if (task[i].getType()==TaskTypes::Tech)
TheMacroManager->ttl.registerTechFinish(task[i].getFinishTime(),task[i].getTech());
if (task[i].getType()==TaskTypes::Upgrade)
TheMacroManager->utl.registerUpgradeLevelIncrease(task[i].getFinishTime(),task[i].getUpgrade());
plannedAdditionalResources = true;
}
task[i].setReservedFinishDataThisFrame(true);
}
}
for(int i=1;i<(int)(task.size());i++)
{
if (task[i-1].getStartTime()==-1)
task[i].setStartTime(-1);
}
}
void TaskStream::update()
{
if (killSwitch) return;
if (status == Executing_Task)
{
if (task[0].isCompleted())
{
notifyCompletedTask();
status = None;
Broodwar->printf("Completed Task %s!",task[0].getName().c_str());
for(int i=0;i+1<(int)(task.size());i++)
task[i]=task[i+1];
task[task.size()-1] = Task();
buildUnit = NULL;
}
if (workerReady)
{
Broodwar->drawTextMap(worker->getPosition().x(),worker->getPosition().y(),"Task: %s",task[0].getName().c_str());
}
}
for each(std::pair<TaskStreamObserver*, bool> obs in observers)
{
obs.first->update(this);
}
}
bool TaskStream::updateStatus()
{
plannedAdditionalResources = false;
if (killSwitch) return false;
Status lastStatus = status;
computeStatus();
if (status != lastStatus)
notifyNewStatus();
return plannedAdditionalResources;
}
void TaskStream::attach(TaskStreamObserver* obs, bool owned)
{
//add observer to our observers set
observers.insert(std::make_pair(obs, owned));
//let the observer know they have been attached to us
obs->attached(this);
}
void TaskStream::detach(TaskStreamObserver* obs)
{
//remove observer from our observers set
observers.erase(obs);
//let the observer know they have been detached from us
obs->detached(this);
}
void TaskStream::notifyNewStatus()
{
//notify all observers of our new status
for each(std::pair<TaskStreamObserver*, bool> obs in observers)
{
obs.first->newStatus(this);
}
}
void TaskStream::notifyCompletedTask()
{
//notify all observers that we have completed a task
for each(std::pair<TaskStreamObserver*, bool> obs in observers)
{
obs.first->completedTask(this,task[0]);
}
}
void TaskStream::notifyForkedTask(TaskStream* newTS)
{
//notify all observers that we have forked a task
for each(std::pair<TaskStreamObserver*, bool> obs in observers)
{
obs.first->forkedTask(this,newTS->task[0],newTS);
}
}
TaskStream::Status TaskStream::getStatus() const
{
return status;
}
std::string TaskStream::getStatusString() const
{
//turn the status into a string
switch (status)
{
case None:
return "None";
break;
case Error_Worker_Not_Specified:
return "Error_Worker_Not_Specified";
break;
case Error_Worker_Not_Owned:
return "Error_Worker_Not_Owned";
break;
case Error_Task_Not_Specified:
return "Error_Task_Not_Specified";
break;
case Error_Location_Not_Specified:
return "Error_Location_Not_Specified";
break;
case Error_Location_Blocked:
return "Error_Location_Blocked";
break;
case Error_Task_Requires_Addon:
return "Error_Task_Requires_Addon";
break;
case Waiting_For_Worker_To_Be_Ready:
return "Waiting_For_Worker_To_Be_Ready";
break;
case Waiting_For_Free_Time:
return "Waiting_For_Free_Time";
break;
case Waiting_For_Earliest_Start_Time:
return "Waiting_For_Earliest_Start_Time";
break;
case Waiting_For_Required_Units:
return "Waiting_For_Required_Units";
break;
case Waiting_For_Required_Tech:
return "Waiting_For_Required_Tech";
break;
case Waiting_For_Required_Upgrade:
return "Waiting_For_Required_Upgrade";
break;
case Waiting_For_Supply:
return "Waiting_For_Supply";
break;
case Waiting_For_Gas:
return "Waiting_For_Gas";
break;
case Waiting_For_Minerals:
return "Waiting_For_Minerals";
break;
case Executing_Task:
return "Executing_Task";
break;
default:
return "Unknown";
}
return "Unknown";
}
void TaskStream::setWorker(BWAPI::Unit* w)
{
BWAPI::Unit* oldWorker = worker;
worker = w;
if (oldWorker!=NULL)
{
//tell the macro manager the old worker no longer belongs to us
if (TheMacroManager->unitToTaskStreams.find(oldWorker)!=TheMacroManager->unitToTaskStreams.end())
TheMacroManager->unitToTaskStreams[oldWorker].erase(this);
}
if (worker!=NULL)
{
//tell the macro manager the new worker now belongs to us
TheMacroManager->unitToTaskStreams[worker].insert(this);
}
//workerReady is false until we own the new worker
workerReady = false;
}
BWAPI::Unit* TaskStream::getWorker() const
{
return worker;
}
void TaskStream::setBuildUnit(BWAPI::Unit* b)
{
buildUnit = b;
}
BWAPI::Unit* TaskStream::getBuildUnit() const
{
return buildUnit;
}
void TaskStream::setTask(int index, Task t)
{
if (index<0 || index>=(int)(task.size())) return;
task[index] = t;
}
Task& TaskStream::getTask(int index)
{
return task[index];
}
void TaskStream::setUrgent(bool isUrgent)
{
urgent = isUrgent;
}
bool TaskStream::isUrgent() const
{
return urgent;
}
void TaskStream::printToScreen(int x, int y)
{
Broodwar->drawTextScreen(x,y,"[ ] %s - w=%x bu=%x",
getStatusString().c_str(),
getWorker(),
getBuildUnit());
Broodwar->drawTextScreen(x+200,y,"%s %d",
task[0].getName().c_str(),
task[0].getStartTime());
Broodwar->drawTextScreen(x+300,y,"%s %d",
task[1].getName().c_str(),
task[1].getStartTime());
Broodwar->drawTextScreen(x+400,y,"%s %d",
task[2].getName().c_str(),
task[2].getStartTime());
Broodwar->drawTextScreen(x+500,y,"%s %d",
task[3].getName().c_str(),
task[3].getStartTime());
}
bool TaskStream::isWorkerReady() const
{
return workerReady;
}
bool TaskStream::isLocationReady() const
{
return locationReady;
}
void TaskStream::clearPlanningData()
{
//clear reserved resources and reserved finish data
for(int i=0;i<(int)(task.size());i++)
{
task[i].setReservedFinishDataThisFrame(task[i].isCompleted());
task[i].setReservedResourcesThisFrame(task[i].hasSpentResources());
if (task[i].hasReservedResourcesThisFrame() && !task[i].hasReservedFinishDataThisFrame())
{
if (task[i].getType()==TaskTypes::Unit)
{
if (task[i].getUnit().supplyProvided()>0)
TheMacroManager->rtl.registerSupplyIncrease(task[i].getFinishTime(), task[i].getUnit().supplyProvided());
int count = 1;
if (task[i].getUnit().isTwoUnitsInOneEgg())
count = 2;
TheMacroManager->uctl.registerUnitCountChange(task[i].getFinishTime(), task[i].getUnit(), count);
if (task[i].getType()==TaskTypes::Tech)
TheMacroManager->ttl.registerTechFinish(task[i].getFinishTime(),task[i].getTech());
if (task[i].getType()==TaskTypes::Upgrade)
TheMacroManager->utl.registerUpgradeLevelIncrease(task[i].getFinishTime(),task[i].getUpgrade());
}
task[i].setReservedFinishDataThisFrame(true);
}
}
plannedAdditionalResources = false;
}
int TaskStream::getStartTime() const
{
//start time of task stream is start time of first task in stream
return task[0].getStartTime();
}
int TaskStream::getFinishTime() const
{
//finish time of task stream is finish time of last task in stream
if (task[0]==NULL)
return Broodwar->getFrameCount();
for(int i=0;i<(int)(task.size());i++)
if (task[i].getFinishTime() == -1)
return -1; //just to be safe, return never if any of the tasks will never finish
return task[task.size()-1].getFinishTime();
}
int TaskStream::getFinishTime(BWAPI::UnitType t) const
{
//returns the first time that a task of the given unit type will finish
for(int i=0;i<(int)(task.size());i++)
if (task[i].getType()==TaskTypes::Unit && task[i].getUnit()==t)
return task[i].getFinishTime();
//or returns never if the task stream will never finish a task of the given unit type
return -1;
}
TaskStream* TaskStream::forkCurrentTask()
{
TaskStream* ts = new TaskStream(task[0]);
ts->attach(BasicTaskExecutor::getInstance(),false);
ts->attach(new TerminateIfEmpty(),true);
ts->attach(BFSBuildingPlacer::getInstance(),false);
ts->attach(new BasicWorkerFinder(),true);
ts->buildUnit = buildUnit;
Broodwar->printf("Forked Task %s!",task[0].getName().c_str());
for(int i=0;i+1<(int)(task.size());i++)
task[i]=task[i+1];
task[task.size()-1] = Task();
buildUnit = NULL;
status = None;
notifyForkedTask(ts);
return ts;
} | [
"[email protected]"
]
| [
[
[
1,
577
]
]
]
|
ba57a20cd08f834ca5544fcaecee24dea10620a4 | 14bc620a0365e83444dad45611381c7f6bcd052b | /ITUEngine/Managers/InputManager.hpp | e963fc2bd3149d227b47a602324435a4e826e18e | []
| no_license | jumoel/itu-gameengine | a5750bfdf391ae64407217bfc1df8b2a3db551c7 | 062dd47bc1be0f39a0add8615e81361bcaa2bd4c | refs/heads/master | 2020-05-03T20:39:31.307460 | 2011-12-19T10:54:10 | 2011-12-19T10:54:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,605 | hpp | #ifndef ITUENGINE_INPUTMANAGER_H
#define ITUENGINE_INPUTMANAGER_H
#include <Events/Interfaces/InterfaceTemplateEventManager.hpp>
#include <Events/Input/KeyPressedEvent.hpp>
#include <Events/Input/MouseClickEvent.hpp>
#include <Events/Input/MouseMoveEvent.hpp>
namespace InputManager
{
static InterfaceTemplateEventManager<IKeyboardEvent> KeyboardEventManager; //instantiate the general event manager for keyboard events
static InterfaceTemplateEventManager<IMouseClickEvent> MouseClickEventManager; //instantiate the general event manager for mouse click events
static InterfaceTemplateEventManager<IMouseMoveEvent> MouseMoveEventManager; //instantiate the general event manager for mouse move events
/* KEYBOARD EVENTS */
// Notifiers
void NotifyKeyDown(KeyPressedEvent *key);
void NotifyKeyUp(KeyPressedEvent *key);
// Register / Unregister event handlers
void RegisterKeyboardEventHandler(IKeyboardEvent *client);
void UnregisterKeyboardEventHandler(IKeyboardEvent *client);
/* MOUSE CLICK EVENTS */
// Notifiers
void NotifyButtonDown(MouseClickEvent *button);
void NotifyButtonUp(MouseClickEvent *button);
// Register / Unregister event handlers
void RegisterMouseClickEventHandler(IMouseClickEvent *client);
void UnregisterMouseClickEventHandler(IMouseClickEvent *client);
/* MOUSE MOVE EVENTS */
// Notifiers
void NotifyMotion(MouseMoveEvent *motion);
// Register / Unregister event handlers
void RegisterMouseMoveEventHandler(IMouseMoveEvent *client);
void UnregisterMouseMoveEventHandler(IMouseMoveEvent *client);
};
#endif | [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
4
],
[
8,
42
]
],
[
[
5,
7
]
]
]
|
8a34f5e55ab665a59a96eb2417bcd31e58df8630 | b7c505dcef43c0675fd89d428e45f3c2850b124f | /Src/SimulatorQt/Util/qt/Win32/include/Qt/qstyleditemdelegate.h | 5f1c3d7c82871b1aa841a26112a24aa01ed63064 | [
"BSD-2-Clause"
]
| permissive | pranet/bhuman2009fork | 14e473bd6e5d30af9f1745311d689723bfc5cfdb | 82c1bd4485ae24043aa720a3aa7cb3e605b1a329 | refs/heads/master | 2021-01-15T17:55:37.058289 | 2010-02-28T13:52:56 | 2010-02-28T13:52:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,210 | h | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSTYLEDITEMDELEGATE_H
#define QSTYLEDITEMDELEGATE_H
#include <QtGui/qabstractitemdelegate.h>
#include <QtCore/qstring.h>
#include <QtGui/qpixmap.h>
#include <QtCore/qvariant.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_ITEMVIEWS
class QStyledItemDelegatePrivate;
class QItemEditorFactory;
class Q_GUI_EXPORT QStyledItemDelegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
explicit QStyledItemDelegate(QObject *parent = 0);
~QStyledItemDelegate();
// painting
void paint(QPainter *painter,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
// editing
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
// editor factory
QItemEditorFactory *itemEditorFactory() const;
void setItemEditorFactory(QItemEditorFactory *factory);
virtual QString displayText(const QVariant &value, const QLocale &locale) const;
protected:
virtual void initStyleOption(QStyleOptionViewItem *option,
const QModelIndex &index) const;
bool eventFilter(QObject *object, QEvent *event);
bool editorEvent(QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option, const QModelIndex &index);
private:
Q_DECLARE_PRIVATE(QStyledItemDelegate)
Q_DISABLE_COPY(QStyledItemDelegate)
Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
};
#endif // QT_NO_ITEMVIEWS
QT_END_NAMESPACE
QT_END_HEADER
#endif // QSTYLEDITEMDELEGATE_H
| [
"alon@rogue.(none)"
]
| [
[
[
1,
116
]
]
]
|
bc433d462ce8a16b347e95b3598f664ddf74d52c | 222bc22cb0330b694d2c3b0f4b866d726fd29c72 | /src/nv38box/Math/WmlMatrix3.h | 06a0374fab74a1e81fe77a5e195f4f6157bc0dc9 | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | darwin/inferno | 02acd3d05ca4c092aa4006b028a843ac04b551b1 | e87017763abae0cfe09d47987f5f6ac37c4f073d | refs/heads/master | 2021-03-12T22:15:47.889580 | 2009-04-17T13:29:39 | 2009-04-17T13:29:39 | 178,477 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,998 | h | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#ifndef WMLMATRIX3_H
#define WMLMATRIX3_H
// The (x,y,z) coordinate system is assumed to be right-handed. Coordinate
// axis rotation matrices are of the form
// RX = 1 0 0
// 0 cos(t) -sin(t)
// 0 sin(t) cos(t)
// where t > 0 indicates a counterclockwise rotation in the yz-plane
// RY = cos(t) 0 sin(t)
// 0 1 0
// -sin(t) 0 cos(t)
// where t > 0 indicates a counterclockwise rotation in the zx-plane
// RZ = cos(t) -sin(t) 0
// sin(t) cos(t) 0
// 0 0 1
// where t > 0 indicates a counterclockwise rotation in the xy-plane.
#include "WmlMatrix.h"
#include "WmlVector3.h"
#include "WmlMatrix4.h"
namespace Wml
{
template<class Real>
class WML_ITEM Matrix3: public Matrix<3, Real>
{
public:
// construction
Matrix3();
Matrix3(const Matrix3& rkM);
Matrix3(const Matrix<3, Real>& rkM);
// input Mrc is in row r, column c.
Matrix3(Real fM00,
Real fM01,
Real fM02,
Real fM10,
Real fM11,
Real fM12,
Real fM20,
Real fM21,
Real fM22);
operator Matrix4<Real>() const;
// Create a matrix from an array of numbers. The input array is
// interpreted based on the Boolean input as
// true: entry[0..8]={m00,m01,m02,m10,m11,m12,m20,m21,m22} [row major]
// false: entry[0..8]={m00,m10,m20,m01,m11,m21,m02,m12,m22} [col major]
Matrix3(const Real afEntry[9], bool bRowMajor);
// Create matrices based on vector input. The Boolean is interpreted as
// true: vectors are columns of the matrix
// false: vectors are rows of the matrix
Matrix3(const Vector3<Real>& rkU,
const Vector3<Real>& rkV,
const Vector3<Real>& rkW,
bool bColumns);
Matrix3(const Vector3<Real>* akV, bool bColumns);
// create a tensor product U*V^T
Matrix3(const Vector3<Real>& rkU, const Vector3<Real>& rkV);
void MakeTensorProduct(const Vector3<Real>& rkU, const Vector3<Real>& rkV);
// create a diagonal matrix
Matrix3(Real fM00, Real fM11, Real fM22);
void MakeDiagonal(Real fM00, Real fM11, Real fM22);
// Create rotation matrices (positive angle - counterclockwise). The
// angle must be in radians, not degrees.
Matrix3(const Vector3<Real>& rkAxis, Real fAngle);
void FromAxisAngle(const Vector3<Real>& rkAxis, Real fAngle);
// assignment
Matrix3& operator=(const Matrix3& rkM);
Matrix3& operator=(const Matrix<3, Real>& rkM);
// matrix operations
Matrix3 Inverse() const;
Matrix3 Adjoint() const;
Real Determinant() const;
// The matrix must be a rotation for these functions to be valid. The
// last function uses Gram-Schmidt orthonormalization applied to the
// columns of the rotation matrix. The angle must be in radians, not
// degrees.
void ToAxisAngle(Vector3<Real>& rkAxis, Real& rfAngle) const;
void Orthonormalize();
// The matrix must be orthonormal. The decomposition is yaw*pitch*roll
// where yaw is rotation about the Up vector, pitch is rotation about the
// Right axis, and roll is rotation about the Direction axis.
bool ToEulerAnglesXYZ(Real& rfYAngle, Real& rfPAngle, Real& rfRAngle) const;
bool ToEulerAnglesXZY(Real& rfYAngle, Real& rfPAngle, Real& rfRAngle) const;
bool ToEulerAnglesYXZ(Real& rfYAngle, Real& rfPAngle, Real& rfRAngle) const;
bool ToEulerAnglesYZX(Real& rfYAngle, Real& rfPAngle, Real& rfRAngle) const;
bool ToEulerAnglesZXY(Real& rfYAngle, Real& rfPAngle, Real& rfRAngle) const;
bool ToEulerAnglesZYX(Real& rfYAngle, Real& rfPAngle, Real& rfRAngle) const;
void FromEulerAnglesXYZ(Real fYAngle, Real fPAngle, Real fRAngle);
void FromEulerAnglesXZY(Real fYAngle, Real fPAngle, Real fRAngle);
void FromEulerAnglesYXZ(Real fYAngle, Real fPAngle, Real fRAngle);
void FromEulerAnglesYZX(Real fYAngle, Real fPAngle, Real fRAngle);
void FromEulerAnglesZXY(Real fYAngle, Real fPAngle, Real fRAngle);
void FromEulerAnglesZYX(Real fYAngle, Real fPAngle, Real fRAngle);
// SLERP (spherical linear interpolation) without quaternions. Computes
// R(t) = R0*(Transpose(R0)*R1)^t. If Q is a rotation matrix with
// unit-length axis U and angle A, then Q^t is a rotation matrix with
// unit-length axis U and rotation angle t*A.
static Matrix3 Slerp(Real fT, const Matrix3& rkR0, const Matrix3& rkR1);
// The matrix must be symmetric. Factor M = R * D * R^T where
// R = [u0|u1|u2] is a rotation matrix with columns u0, u1, and u2 and
// D = diag(d0,d1,d2) is a diagonal matrix whose diagonal entries are d0,
// d1, and d2. The eigenvector u[i] corresponds to eigenvector d[i].
// The eigenvalues are ordered as d0 <= d1 <= d2.
void EigenDecomposition(Matrix3& rkRot, Matrix3& rkDiag) const;
// Singular value decomposition, M = L*S*R, where L and R are orthogonal
// and S is a diagonal matrix whose diagonal entries are nonnegative.
void SingularValueDecomposition(Matrix3& rkL, Matrix3& rkS, Matrix3& rkR) const;
void SingularValueComposition(const Matrix3& rkL, const Matrix3& rkS, const Matrix3& rkR);
// factor M = Q*D*U with orthogonal Q, diagonal D, upper triangular U
void QDUDecomposition(Matrix3& rkQ, Matrix3& rkD, Matrix3& rkU) const;
void MakeRotationX(Real angle);
void MakeRotationY(Real angle);
void MakeRotationZ(Real angle);
// special matrices
static const Matrix3 ZERO;
static const Matrix3 IDENTITY;
protected:
// support for eigendecomposition
void Tridiagonalize(Real afDiag[3], Real afSubDiag[3]);
bool QLAlgorithm(Real afDiag[3], Real afSubDiag[3]);
// support for singular value decomposition
static void Bidiagonalize(Matrix3& rkA, Matrix3& rkL, Matrix3& rkR);
static void GolubKahanStep(Matrix3& rkA, Matrix3& rkL, Matrix3& rkR);
};
typedef Matrix3<float> Matrix3f;
typedef Matrix3<double> Matrix3d;
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
160
]
]
]
|
dede2d9128cb3fc4b044b15eb9ad99eb16e5195f | 6d680e20e4a703f0aa0d4bb5e50568143241f2d5 | /src/ActionsMenu/moc_GenericStep.cpp | 460dd9aec59b28c867fea9e04ed0c9ad427d23e5 | []
| no_license | sirnicolaz/MobiHealt | f7771e53a4a80dcea3d159eca729e9bd227e8660 | bbfd61209fb683d5f75f00bbf81b24933922baac | refs/heads/master | 2021-01-20T12:21:17.215536 | 2010-04-21T14:21:16 | 2010-04-21T14:21:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,136 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'GenericStep.h'
**
** Created: Mon Mar 1 11:48:28 2010
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "GenericStep.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'GenericStep.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.6.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_GenericStep[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_GenericStep[] = {
"GenericStep\0"
};
const QMetaObject GenericStep::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_GenericStep,
qt_meta_data_GenericStep, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &GenericStep::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *GenericStep::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *GenericStep::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_GenericStep))
return static_cast<void*>(const_cast< GenericStep*>(this));
return QWidget::qt_metacast(_clname);
}
int GenericStep::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
| [
"devnull@localhost"
]
| [
[
[
1,
69
]
]
]
|
3bac8883bda6970964e398bd5d6aee50a8e8ce79 | 188058ec6dbe8b1a74bf584ecfa7843be560d2e5 | /GodDK/io/PushbackInputStream.h | b559725b05bf06bc83dbf3791fc0b7f313fb2465 | []
| no_license | mason105/red5cpp | 636e82c660942e2b39c4bfebc63175c8539f7df0 | fcf1152cb0a31560af397f24a46b8402e854536e | refs/heads/master | 2021-01-10T07:21:31.412996 | 2007-08-23T06:29:17 | 2007-08-23T06:29:17 | 36,223,621 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,317 | h |
#ifndef _CLASS_GOD_IO_PUSHBACKINPUTSTREAM_H
#define _CLASS_GOD_IO_PUSHBACKINPUTSTREAM_H
#ifdef __cplusplus
#include "io/FilterInputStream.h"
using namespace goddk::io;
namespace goddk {
namespace io {
/*!\ingroup CXX_IO_m
*/
class PushbackInputStream : public FilterInputStream
{
private:
bool _closed;
protected:
bytearray buf;
jint pos;
public:
PushbackInputStream(InputStream& in, jint size = 1);
virtual ~PushbackInputStream();
bool instanceof(const char* class_name)const throw()
{
if(strcmp("PushbackInputStream", class_name)== 0)
return true;
else
return __super::instanceof(class_name);
}
virtual jint available() throw (IOExceptionPtr);
virtual void close() throw (IOExceptionPtr);
virtual bool markSupported() throw ();
virtual jint read() throw (IOExceptionPtr);
virtual jint read(byte* data, jint offset, jint length) throw (IOExceptionPtr);
virtual jint skip(jint n) throw (IOExceptionPtr);
void unread(byte) throw (IOExceptionPtr);
void unread(const byte* data, jint offset, jint length) throw (IOExceptionPtr);
void unread(const bytearray& b) throw (IOExceptionPtr);
};
typedef CSmartPtr<PushbackInputStream> PushbackInputStreamPtr;
}
}
#endif
#endif
| [
"soaris@46205fef-a337-0410-8429-7db05d171fc8"
]
| [
[
[
1,
50
]
]
]
|
d632c35f94a9e6c632b400ff17f4db47752c8590 | 2bf60292f4a81cc99284103e2c6052f35e313081 | /wrapper/formats/Standalone/juce_AudioFilterStreamer.h | 7eceb3a80c6e2a9ecaa41803c60093bfa5bf9926 | []
| no_license | alessandrostone/kitty-vst | 9f6affd00d70051296986bf6d1db274df90f6c91 | 9ff955558a15aadf23dadfb553fdf1cbeb770eef | refs/heads/master | 2016-09-06T02:55:19.454457 | 2009-02-03T21:50:20 | 2009-02-03T21:50:20 | 39,379,847 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,924 | h | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE 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 JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#ifndef __JUCE_AUDIOFILTERSTREAMER_JUCEHEADER__
#define __JUCE_AUDIOFILTERSTREAMER_JUCEHEADER__
#include <juce.h>
//==============================================================================
/**
A class that wraps an AudioProcessor as an AudioIODeviceCallback, so its
output can be streamed directly to/from some audio and midi inputs and outputs.
To use it, just create an instance of this for your filter, and register it
as the callback with an AudioIODevice or AudioDeviceManager object.
To receive midi input in your filter, you should also register it as a
MidiInputCallback with a suitable MidiInput or an AudioDeviceManager.
And for an even easier way of doing a standalone plugin, see the
AudioFilterStreamingDeviceManager class...
*/
class AudioFilterStreamer : public AudioIODeviceCallback,
public MidiInputCallback,
public AudioPlayHead
{
public:
//==============================================================================
AudioFilterStreamer (AudioProcessor& filterToUse);
~AudioFilterStreamer();
//==============================================================================
void audioDeviceIOCallback (const float** inputChannelData,
int totalNumInputChannels,
float** outputChannelData,
int totalNumOutputChannels,
int numSamples);
void audioDeviceAboutToStart (AudioIODevice* device);
void audioDeviceStopped();
void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message);
bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info);
juce_UseDebuggingNewOperator
private:
//==============================================================================
AudioProcessor& filter;
bool isPlaying;
double sampleRate;
MidiMessageCollector midiCollector;
float* outChans [128];
float* inChans [128];
AudioSampleBuffer emptyBuffer;
};
//==============================================================================
/**
Wraps an AudioFilterStreamer in an AudioDeviceManager to make it easy to
create a standalone filter.
This simply acts as a singleton AudioDeviceManager, which continuously
streams audio from the filter you give it with the setFilter() method.
To use it, simply create an instance of it (or use getInstance() if you're
using it as a singleton), initialise it like you would a normal
AudioDeviceManager, and call setFilter() to start it running your plugin.
*/
class AudioFilterStreamingDeviceManager : public AudioDeviceManager
{
public:
//==============================================================================
AudioFilterStreamingDeviceManager();
~AudioFilterStreamingDeviceManager();
juce_DeclareSingleton (AudioFilterStreamingDeviceManager, true);
//==============================================================================
/** Tells the device which filter to stream audio through.
Pass in 0 to deselect the current filter.
*/
void setFilter (AudioProcessor* filterToStream);
//==============================================================================
juce_UseDebuggingNewOperator
private:
AudioFilterStreamer* streamer;
};
#endif // __JUCE_AUDIOFILTERSTREAMER_JUCEHEADER__
| [
"kubiak.roman@a6f206e7-e34c-0410-924b-53c493b60f4e"
]
| [
[
[
1,
128
]
]
]
|
d69b7486b664da165f77cab8fa3135a1e5ce079f | 4d1a438ee0c80053e33431d10683ce4872118957 | /dumbhippo/branches/production-replaced-2007-06-29/client/common/hippoipc/hippo-serialized-controller.cpp | f63b079a00a4763e02efac66ff7b519aef75f55e | []
| no_license | nihed/magnetism | 7a5223e7dd0ae172937358c1b72df7e9ec5f28b8 | c64dfb9b221862e81c9e77bb055f65dcee422027 | refs/heads/master | 2016-09-05T20:01:07.262277 | 2009-04-29T06:48:39 | 2009-04-29T06:48:39 | 39,454,577 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,479 | cpp | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
#include "hippo-serialized-controller.h"
#include <string>
class HippoSerializedControllerArgs
{
public:
virtual ~HippoSerializedControllerArgs() {};
virtual void invoke(HippoIpcController *controller) = 0;
virtual HippoEndpointId getResultEndpointId();
};
HippoEndpointId
HippoSerializedControllerArgs::getResultEndpointId()
{
return 0;
}
class HippoSerializedControllerAddListener : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerAddListener(HippoIpcListener *listener) {
listener_ = listener;
}
virtual void invoke(HippoIpcController *controller);
private:
HippoIpcListener *listener_;
};
void
HippoSerializedControllerAddListener::invoke(HippoIpcController *controller)
{
controller->addListener(listener_);
}
class HippoSerializedControllerRemoveListener : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerRemoveListener(HippoIpcListener *listener) {
listener_ = listener;
}
virtual void invoke(HippoIpcController *controller);
private:
HippoIpcListener *listener_;
};
void
HippoSerializedControllerRemoveListener::invoke(HippoIpcController *controller)
{
controller->removeListener(listener_);
}
class HippoSerializedControllerRegisterEndpoint : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerRegisterEndpoint(HippoIpcListener *listener) {
listener_ = listener;
result_ = 0;
}
virtual void invoke(HippoIpcController *controller);
virtual HippoEndpointId getResultEndpointId();
private:
HippoIpcListener *listener_;
HippoEndpointId result_;
};
void
HippoSerializedControllerRegisterEndpoint::invoke(HippoIpcController *controller)
{
result_ = controller->registerEndpoint(listener_);
}
HippoEndpointId
HippoSerializedControllerRegisterEndpoint::getResultEndpointId()
{
return result_;
}
class HippoSerializedControllerUnregisterEndpoint : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerUnregisterEndpoint(HippoEndpointId endpoint) {
endpoint_ = endpoint;
}
virtual void invoke(HippoIpcController *controller);
private:
HippoEndpointId endpoint_;
};
void
HippoSerializedControllerUnregisterEndpoint::invoke(HippoIpcController *controller)
{
controller->unregisterEndpoint(endpoint_);
}
class HippoSerializedControllerSetWindowId : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerSetWindowId(HippoEndpointId endpoint, HippoWindowId windowId) {
endpoint_ = endpoint;
windowId_ = windowId;
}
virtual void invoke(HippoIpcController *controller);
private:
HippoEndpointId endpoint_;
HippoWindowId windowId_;
};
void
HippoSerializedControllerSetWindowId::invoke(HippoIpcController *controller)
{
controller->setWindowId(endpoint_, windowId_);
}
class HippoSerializedControllerJoinChatRoom : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerJoinChatRoom(HippoEndpointId endpoint, const char *chatId, bool participant) {
endpoint_ = endpoint;
chatId_ = chatId;
participant_ = participant;
}
virtual void invoke(HippoIpcController *controller);
private:
HippoEndpointId endpoint_;
std::string chatId_;
bool participant_;
};
void
HippoSerializedControllerJoinChatRoom::invoke(HippoIpcController *controller)
{
controller->joinChatRoom(endpoint_, chatId_.c_str(), participant_);
}
class HippoSerializedControllerLeaveChatRoom : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerLeaveChatRoom(HippoEndpointId endpoint, const char *chatId) {
endpoint_ = endpoint;
chatId_ = chatId;
}
virtual void invoke(HippoIpcController *controller);
private:
HippoEndpointId endpoint_;
std::string chatId_;
};
void
HippoSerializedControllerLeaveChatRoom::invoke(HippoIpcController *controller)
{
controller->leaveChatRoom(endpoint_, chatId_.c_str());
}
class HippoSerializedControllerSendChatMessage : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerSendChatMessage(const char *chatId, const char *text, int sentiment) {
chatId_ = chatId;
text_ = text;
sentiment_ = sentiment;
}
virtual void invoke(HippoIpcController *controller);
private:
std::string chatId_;
std::string text_;
int sentiment_;
};
void
HippoSerializedControllerSendChatMessage::invoke(HippoIpcController *controller)
{
controller->sendChatMessage(chatId_.c_str(), text_.c_str(), sentiment_);
}
class HippoSerializedControllerShowChatWindow : public HippoSerializedControllerArgs
{
public:
HippoSerializedControllerShowChatWindow(const char *chatId) {
chatId_ = chatId;
}
virtual void invoke(HippoIpcController *controller);
private:
std::string chatId_;
};
void
HippoSerializedControllerShowChatWindow::invoke(HippoIpcController *controller)
{
controller->showChatWindow(chatId_.c_str());
}
HippoSerializedController::HippoSerializedController()
{
args_ = 0;
}
HippoSerializedController::~HippoSerializedController()
{
clear();
}
void
HippoSerializedController::invoke(HippoIpcController *controller)
{
if (args_)
args_->invoke(controller);
}
HippoEndpointId
HippoSerializedController::getResultEndpointId()
{
if (args_)
return args_->getResultEndpointId();
else
return 0;
}
void
HippoSerializedController::addListener(HippoIpcListener *listener)
{
clear();
args_ = new HippoSerializedControllerAddListener(listener);
}
void
HippoSerializedController::removeListener(HippoIpcListener *listener)
{
clear();
args_ = new HippoSerializedControllerRemoveListener(listener);
}
HippoEndpointId
HippoSerializedController::registerEndpoint(HippoIpcListener *listener)
{
clear();
args_ = new HippoSerializedControllerRegisterEndpoint(listener);
return 0; // Dummy value
}
void
HippoSerializedController::unregisterEndpoint(HippoEndpointId endpoint)
{
clear();
args_ = new HippoSerializedControllerUnregisterEndpoint(endpoint);
}
void
HippoSerializedController::setWindowId(HippoEndpointId endpoint, HippoWindowId windowId)
{
clear();
args_ = new HippoSerializedControllerSetWindowId(endpoint, windowId);
}
void
HippoSerializedController::joinChatRoom(HippoEndpointId endpoint, const char *chatId, bool participant)
{
clear();
args_ = new HippoSerializedControllerJoinChatRoom(endpoint, chatId, participant);
}
void
HippoSerializedController::leaveChatRoom(HippoEndpointId endpoint, const char *chatId)
{
clear();
args_ = new HippoSerializedControllerLeaveChatRoom(endpoint, chatId);
}
void
HippoSerializedController::sendChatMessage(const char *chatId, const char *text, int sentiment)
{
clear();
args_ = new HippoSerializedControllerSendChatMessage(chatId, text, sentiment);
}
void
HippoSerializedController::showChatWindow(const char *chatId)
{
clear();
args_ = new HippoSerializedControllerShowChatWindow(chatId);
}
void
HippoSerializedController::clear()
{
if (args_) {
delete args_;
args_ = NULL;
}
}
| [
"hp@69951b7c-304f-11de-8daa-cfecb5f7ff5b",
"marinaz@69951b7c-304f-11de-8daa-cfecb5f7ff5b"
]
| [
[
[
1,
105
],
[
127,
173
],
[
175,
176
],
[
178,
184
],
[
186,
190
],
[
192,
270
],
[
278,
292
],
[
294,
295
],
[
297,
313
]
],
[
[
106,
126
],
[
174,
174
],
[
177,
177
],
[
185,
185
],
[
191,
191
],
[
271,
277
],
[
293,
293
],
[
296,
296
]
]
]
|
8bd57e19dfee719cb53e0a76d3625c8642a7fe8e | 6a925ad6f969afc636a340b1820feb8983fc049b | /librtsp/librtsp/src/InetAddr.cpp | e7c15582af05016337cd1d9a61eaf4d4f76b2797 | []
| no_license | dulton/librtsp | c1ac298daecd8f8008f7ab1c2ffa915bdbb710ad | 8ab300dc678dc05085f6926f016b32746c28aec3 | refs/heads/master | 2021-05-29T14:59:37.037583 | 2010-05-30T04:07:28 | 2010-05-30T04:07:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 852 | cpp | /*!@file InetAddr.cpp
@brief
Copyright (c) 2009 HUST ITEC VoIP Lab.
All rights reserved.
@author Wentao Tang
@date 2009.3.21
@version 1.0
*/
#include "InetAddr.h"
#include <string.h>
InetAddr::~InetAddr(void)
{
}
void InetAddr::SetHostName( const char *hostname )
{
in_addr inaddr;
inaddr.s_addr = inet_addr(hostname);
if ( INADDR_NONE == inaddr.s_addr )
{
hostent* hp = gethostbyname(hostname);
if ( 0 == hp )
{
// report error
return;
}
memcpy(&inaddr, hp->h_addr, hp->h_length);
socketaddr_.sin_family = hp->h_addrtype;
}
else
{
socketaddr_.sin_family = AF_INET;
socketaddr_.sin_addr = inaddr;
}
}
char *InetAddr::GetAddrStr()
{
return inet_ntoa(socketaddr_.sin_addr);
}
| [
"TangWentaoHust@95ff1050-1aa1-11de-b6aa-3535bc3264a2"
]
| [
[
[
1,
43
]
]
]
|
85051fa39e00bd990053c3ac28651e58d43c3102 | e95784c83b6cec527f3292d2af4f2ee9b257a0b7 | /Arduino/SPI.h | 10693725e121c9a8e7fe34c9f889430b1862899e | []
| no_license | ehaskins/scoe-robotics-onboard-controller | 5e6818cb469c512a4429aa6ccb96478b89c9ce6f | f44887f79cf89c9ff85963e515381199c9b2b2d7 | refs/heads/master | 2020-06-06T12:53:54.350781 | 2011-05-01T00:26:17 | 2011-05-01T00:26:17 | 32,115,864 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,680 | h | /*
* Copyright (c) 2010 by Cristian Maglie <[email protected]>
* SPI Master library for arduino.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either the GNU General Public License version 2
* or the GNU Lesser General Public License version 2.1, both as
* published by the Free Software Foundation.
*/
#ifndef _SPI_H_INCLUDED
#define _SPI_H_INCLUDED
#include <stdio.h>
#include "WProgram.h"
#include <avr/pgmspace.h>
#define SPI_CLOCK_DIV4 0x00
#define SPI_CLOCK_DIV16 0x01
#define SPI_CLOCK_DIV64 0x02
#define SPI_CLOCK_DIV128 0x03
#define SPI_CLOCK_DIV2 0x04
#define SPI_CLOCK_DIV8 0x05
#define SPI_CLOCK_DIV32 0x06
#define SPI_CLOCK_DIV64 0x07
#define SPI_MODE0 0x00
#define SPI_MODE1 0x04
#define SPI_MODE2 0x08
#define SPI_MODE3 0x0C
#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR
#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR
#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
class SPIClass {
public:
inline static byte transfer(byte _data);
// SPI Configuration methods
inline static void attachInterrupt();
inline static void detachInterrupt(); // Default
static void begin(); // Default
static void end();
static void setBitOrder(uint8_t);
static void setDataMode(uint8_t);
static void setClockDivider(uint8_t);
};
extern SPIClass SPI;
byte SPIClass::transfer(byte _data) {
SPDR = _data;
while (!(SPSR & _BV(SPIF)))
;
return SPDR;
}
void SPIClass::attachInterrupt() {
SPCR |= _BV(SPIE);
}
void SPIClass::detachInterrupt() {
SPCR &= ~_BV(SPIE);
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
70
]
]
]
|
d502aac473898e00656605bf55f41506b4db376f | 15732b8e4190ae526dcf99e9ffcee5171ed9bd7e | /INC/object.h | 88e845e61ea6e054b70afcb9dfcc41a712213998 | []
| no_license | clovermwliu/whutnetsim | d95c07f77330af8cefe50a04b19a2d5cca23e0ae | 924f2625898c4f00147e473a05704f7b91dac0c4 | refs/heads/master | 2021-01-10T13:10:00.678815 | 2010-04-14T08:38:01 | 2010-04-14T08:38:01 | 48,568,805 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,469 | h | //Copyright (c) 2010, Information Security Institute of Wuhan Universtiy(ISIWhu)
//All rights reserved.
//
//PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM
//BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF
//THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO
//NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER.
//
//This License allows you to:
//1. Make copies and distribute copies of the Program's source code provide that any such copy
// clearly displays any and all appropriate copyright notices and disclaimer of warranty as set
// forth in this License.
//2. Modify the original copy or copies of the Program or any portion thereof ("Modification(s)").
// Modifications may be copied and distributed under the terms and conditions as set forth above.
// Any and all modified files must be affixed with prominent notices that you have changed the
// files and the date that the changes occurred.
//Termination:
// If at anytime you are unable to comply with any portion of this License you must immediately
// cease use of the Program and all distribution activities involving the Program or any portion
// thereof.
//Statement:
// In this program, part of the code is from the GTNetS project, The Georgia Tech Network
// Simulator (GTNetS) is a full-featured network simulation environment that allows researchers in
// computer networks to study the behavior of moderate to large scale networks, under a variety of
// conditions. Our work have great advance due to this project, Thanks to Dr. George F. Riley from
// Georgia Tech Research Corporation. Anyone who wants to study the GTNetS can come to its homepage:
// http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/
//
//File Information:
//
//
//File Name:
//File Purpose:
//Original Author:
//Author Organization:
//Construct Data:
//Modify Author:
//Author Organization:
//Modify Data:
// Georgia Tech Network Simulator - Object class
// George F. Riley. Georgia Tech, Spring 2002
// Object is the base class for all named objects in gtsim
#ifndef __object_h__
#define __object_h__
#include <string>
//Doc:ClassXRef
class Object {
public:
Object();
virtual ~Object();
void Name(const std::string& s);
void Name(const char* s);
std::string Name() const;
private:
std::string* name;
};
#endif
| [
"pengelmer@f37e807c-cba8-11de-937e-2741d7931076"
]
| [
[
[
1,
70
]
]
]
|
dccc439354ba1f31485054dcfb6c689cee8a25cf | 2b80036db6f86012afcc7bc55431355fc3234058 | /src/core/Query/Base.cpp | 775935b01086aba3ddcd141c048ff60551f0845c | [
"BSD-3-Clause"
]
| permissive | leezhongshan/musikcube | d1e09cf263854bb16acbde707cb6c18b09a0189f | e7ca6a5515a5f5e8e499bbdd158e5cb406fda948 | refs/heads/master | 2021-01-15T11:45:29.512171 | 2011-02-25T14:09:21 | 2011-02-25T14:09:21 | null | 0 | 0 | null | null | null | null | ISO-8859-9 | C++ | false | false | 4,018 | cpp | //////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#ifdef WIN32
#include "pch.hpp"
#else
#include <core/pch.hpp>
#endif
#include <core/Query/Base.h>
#include <core/Library/Base.h>
#include <core/xml/ParserNode.h>
#include <core/xml/WriterNode.h>
using namespace musik::core;
Query::Base::Base(void)
:status(0)
,options(0)
,uniqueId(0)
{
// This will guarantee that the query id is uniq for each query, but copies will not.
// This is usefull when canceling similar queries
static unsigned int uniqueQueryId(0);
uniqueQueryId++;
this->queryId = uniqueQueryId;
}
Query::Base::~Base(void){
}
//////////////////////////////////////////
///\brief
///Receive the query from XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully received
//////////////////////////////////////////
bool Query::Base::ReceiveQuery(musik::core::xml::ParserNode &queryNode){
return false;
}
//////////////////////////////////////////
///\brief
///Serialize query to XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully send
//////////////////////////////////////////
bool Query::Base::SendQuery(musik::core::xml::WriterNode &queryNode){
return false;
}
//////////////////////////////////////////
///\brief
///Receive results from XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully received
//////////////////////////////////////////
bool Query::Base::ReceiveResults(musik::core::xml::ParserNode &queryNode,Library::Base *library){
return false;
}
//////////////////////////////////////////
///\brief
///Serialize results to XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully send
//////////////////////////////////////////
bool Query::Base::SendResults(musik::core::xml::WriterNode &queryNode,Library::Base *library){
return false;
}
std::string Query::Base::Name(){
return "Unknown";
}
void Query::Base::PostCopy(){
static unsigned int uniqueQueryId(0);
uniqueQueryId++;
this->uniqueId = uniqueQueryId;
}
| [
"onnerby@6a861d04-ae47-0410-a6da-2d49beace72e",
"Urioxis@6a861d04-ae47-0410-a6da-2d49beace72e",
"[email protected]@6a861d04-ae47-0410-a6da-2d49beace72e"
]
| [
[
[
1,
36
],
[
42,
67
],
[
69,
73
],
[
75,
75
],
[
77,
95
],
[
97,
101
],
[
103,
103
],
[
105,
131
]
],
[
[
37,
41
]
],
[
[
68,
68
],
[
74,
74
],
[
76,
76
],
[
96,
96
],
[
102,
102
],
[
104,
104
]
]
]
|
27b21266749be1660175d119a0e2e9724b6ce03a | 823e34ee3931091af33fbac28b5c5683a39278e4 | /WebBrowser/RefreshDlg.cpp | 5d472fd617f0493e787e544fbed084c803b1aab3 | []
| no_license | tangooricha/tangoorichas-design-for-graduation | aefdd0fdf0e8786308c22311f2598ad62b3f5be8 | cf227651b9baa0deb5748a678553b145a3ce6803 | refs/heads/master | 2020-06-06T17:48:37.691814 | 2010-04-14T07:22:23 | 2010-04-14T07:22:23 | 34,887,842 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 957 | cpp | // RefreshDlg.cpp : implementation file
//
#include "stdafx.h"
#include "WebBrowser.h"
#include "RefreshDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// RefreshDlg dialog
RefreshDlg::RefreshDlg(CWnd* pParent /*=NULL*/)
: CDialog(RefreshDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(RefreshDlg)
m_edit = _T("");
//}}AFX_DATA_INIT
}
void RefreshDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(RefreshDlg)
DDX_Text(pDX, IDC_EDIT, m_edit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(RefreshDlg, CDialog)
//{{AFX_MSG_MAP(RefreshDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// RefreshDlg message handlers
| [
"[email protected]@91cf4698-544a-0410-9e3e-f171e2291419"
]
| [
[
[
1,
43
]
]
]
|
d8ed723a4eff3d5cdf905c3274467b82477c6e3a | c1a2953285f2a6ac7d903059b7ea6480a7e2228e | /deitel/ch08/Fig08_13/fig08_13.cpp | f1c62b4cc276238e5bf2f85cd1166aa2930b68c3 | []
| no_license | tecmilenio/computacion2 | 728ac47299c1a4066b6140cebc9668bf1121053a | a1387e0f7f11c767574fcba608d94e5d61b7f36c | refs/heads/master | 2016-09-06T19:17:29.842053 | 2008-09-28T04:27:56 | 2008-09-28T04:27:56 | 50,540 | 4 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,602 | cpp | // Fig. 8.13: fig08_13.cpp
// Attempting to modify a constant pointer to nonconstant data.
int main()
{
int x, y;
// ptr is a constant pointer to an integer that can
// be modified through ptr, but ptr always points to the
// same memory location.
int * const ptr = &x; // const pointer must be initialized
*ptr = 7; // allowed: *ptr is not const
ptr = &y; // error: ptr is const; cannot assign to it a new address
return 0; // indicates successful termination
} // end main
/**************************************************************************
* (C) Copyright 1992-2008 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/
| [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
7351f9727c394c9d7b468e66bb9391f8612ac405 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/xpressive/test/test1u.cpp | a4449aa2ba0207b58054a8310122df9262082e67 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 821 | cpp | ///////////////////////////////////////////////////////////////////////////////
// test1.cpp
//
// Copyright 2004 Eric Niebler. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <algorithm>
#include "./test1.hpp"
///////////////////////////////////////////////////////////////////////////////
// test_main
// read the tests from the input file and execute them
int test_main( int, char*[] )
{
#ifndef BOOST_XPRESSIVE_NO_WREGEX
typedef std::wstring::const_iterator iterator_type;
boost::iterator_range<test_case<iterator_type> const *> rng = get_test_cases<iterator_type>();
std::for_each(rng.begin(), rng.end(), test_runner<iterator_type>());
#endif
return 0;
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
23
]
]
]
|
ad093cd1b69baa089230f12afe8ae637821285b8 | 4fdc157f7d6c5af784c3492909d848a0371e5877 | /vision_PO/robot/Communication.cpp | ab513413b49beb9309cdd66feb497f775de62aa8 | []
| no_license | moumen19/robotiquecartemere | d969e50aedc53844bb7c512ff15e6812b8b469de | 8333bb0b5c1b1396e1e99a870af2f60c9db149b0 | refs/heads/master | 2020-12-24T17:17:14.273869 | 2011-02-11T15:44:38 | 2011-02-11T15:44:38 | 34,446,411 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 8,984 | cpp | /*
*
* Bureau d'étude Robotique M2 ISEN 2010-2011
*
* DELBERGUE Julien
* JACQUEL Olivier
* PIETTE Ferdinand ([email protected])
*
* Fichier Communication.cpp
*
*/
#include "Communication.hpp"
#include <time.h>
using namespace std;
/**
* Constructeur
* @param sensors - Module des capteurs
* @param sensorsData - Module des données capteurs
* @param environment - Module de données environnement
* @param strategy - Module de strategie
* @param planning - Module de planification
*/
Communication::Communication(Sensors & sensors, Data & sensorsData, Data & environment, Strategy & strategy, Planning & planning) :
a_sensors(sensors),
a_sensorsData(sensorsData),
a_environmentData(environment),
a_strategy(strategy),
a_planning(planning),
a_RS232Asservissement("/dev/ttyUSB0"),
a_RS232Sensor(sensors, "/dev/ttyUSB1")
{
this->a_RS232Asservissement.open();
this->a_RS232Sensor.open();
this->a_thread_active = false;
_DEBUG("Initialisation du module de communication", INFORMATION);
}
/**
* Destructeur
*/
Communication::~Communication()
{
this->stop();
_DEBUG("Destruction du module de communication", INFORMATION);
}
/**
* Methode envoyant un message à un peripherique (seul l'asservissement est implemente)
* @param port - le nom du peripherique
* @param vg - vitesse gauche
* @param vd - vitesse droite
* @param a - angle
* @param c - commande
*/
void Communication::send(Port::Port port, int vg, int vd, int a, int c)
{
if(port == Port::ASSERVISSEMENT)
{
messageAsservissement msg;
msg.id = 42;
msg.x.value = vg;
msg.y.value = vd;
msg.alpha.value = a;
msg.commande = c;
this->a_RS232Asservissement.send(msg);
}
else if(port == Port::SENSOR)
{
}
else
_DEBUG("Envoie des données à un port non existant !", WARNING);
}
/**
* Test si le thread est lance
* @return true si le thread est lance, false sinon
*/
bool Communication::isActive()
{
return this->a_thread_active;
}
/**
* Demarre le thread
*/
void Communication::start()
{
this->a_thread_active = true;
a_thread = new boost::thread(&Communication::run, this);
}
/**
* Arrete le thread
*/
void Communication::stop()
{
this->a_thread_active = false;
}
/**
* Methode execute par le thread
* Cette methode recupere et traite les differents messages provenant des peripheriques
*/
void Communication::run()
{
_DEBUG("Debut de la routine d'ecoute des ports de communications", INFORMATION);
bool stop_BAU = false;
bool stop_obs = false;
// Tant qu'on a pas arrete le thread
while(this->a_thread_active)
{
// Recuperation du message asservissement
if(this->a_RS232Asservissement.isDataAvailable())
{
try
{
messageAsservissement msg = boost::any_cast<messageAsservissement>(this->a_RS232Asservissement.getData());
_DISPLAY((int)msg.id << " : ");
/*
for(int i = 0; i < 4; i++)
_DISPLAY((int)msg.x.data[i] << " : ");
for(int i = 0; i < 4; i++)
_DISPLAY((int)msg.y.data[i] << " : ");
for(int i = 0; i < 4; i++)
_DISPLAY((int)msg.alpha.data[i] << " : ");
//*/
_DISPLAY(msg.x.value << " : " << msg.y.value << " : " << msg.alpha.value << " : ");
_DISPLAY((int)msg.commande << std::endl);
// Traitement du message
switch(msg.commande)
{
case 7:
a_sensorsData.set((int)msg.commande, msg);
break;
default:
_DEBUG("Le message asservissement n'a pas pu etre traite, la commande ne correspond a aucune action repertoriee", WARNING);
}
}
catch(std::exception & e)
{
_DEBUG(e.what(), WARNING);
}
}
// Recuperation du message capteur
if(this->a_RS232Sensor.isDataAvailable())
{
try
{
boost::any msg_boost = this->a_RS232Sensor.getData(); // a commenter... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
messageSensor msg = boost::any_cast<messageSensor>(msg_boost);
// Stockage du message capteur dans le module de stockage de donnee capteur
a_sensorsData.set((int)msg.id_sensor, msg);
//_DISPLAY((int)msg.id << " : ");
//_DISPLAY((int)msg.id_sensor << " : ");
/*
for(int i = 0; i < 4; i++)
_DISPLAY((int)msg.time.getData(i) << " : ");
for(int i = 0; i < 4; i++)
_DISPLAY((int)msg.data.getData(i) << " : ");
for(int i = 0; i < 4; i++)
_DISPLAY((int)msg.crc.getData(i) << " : ");
//*/
//_DISPLAY(msg.time.getValue() << " : " << msg.data.getValue() << " : " << msg.crc.getValue());
//_DISPLAY(std::endl);
// Traitement du message capteur
messageAsservissement msgSend;
switch(msg.id_sensor) // Juste pour l'arret d'urgence capteurs ou BAU
{
// Capteur BAU
case 144:
if(msg.data.getValue() == 0)
{
// Desactivation de l'arret d'urgence
if(stop_BAU == true && stop_obs == false)
{
a_strategy.set(BAU_OFF);
msgSend.id = 42;
msgSend.x.value = 0;
msgSend.y.value = 0;
msgSend.alpha.value = 0;
msgSend.commande = 9;
this->a_RS232Asservissement.send(msgSend);
_DISPLAY("Message asservissement : tout est OK [ENVOYE]"<<std::endl);
}
stop_BAU = false;
}
else
{
// Activation de l'arret d'urgence
if(stop_BAU == false)
{
a_strategy.set(BAU_ON);
msgSend.id = 42;
msgSend.x.value = 0;
msgSend.y.value = 0;
msgSend.alpha.value = 0;
msgSend.commande = 8;
this->a_RS232Asservissement.send(msgSend);
_DISPLAY("Message asservissement : ARRET [ENVOYE]"<<std::endl);
}
stop_BAU = true;
}
// Pingage des codeuse à chaque fois que l'on reçoit le message BAU
msgSend.id = 42;
msgSend.x.value = 0;
msgSend.y.value = 0;
msgSend.alpha.value = 0;
msgSend.commande = 7;
this->a_RS232Asservissement.send(msgSend);
break;
// Arret d'urgence capteurs
case 48:
case 50:
case 52:
case 54:
case 56:
case 58:
case 60:
case 62:
/*if(msg.data.getValue() <= 150 && msg.id_sensor == 50) // Si un obstacle est trop proche d'un capteur, il entre en arret d'urgence
{
if(stop_obs == false)
{
messageAsservissement msgSend;
msgSend.id = 42;
msgSend.x.value = 0;
msgSend.y.value = 0;
msgSend.alpha.value = 0;
msgSend.commande = 8;
this->a_RS232Asservissement.send(msgSend);
_DEBUG("STOP D'URGENCE !!! Obstacle trop proche", INFORMATION);
}
stop_obs = true;
}
else
{
if(stop_BAU == false && stop_obs == true)
{
messageAsservissement msgSend;
msgSend.id = 42;
msgSend.x.value = 5;
msgSend.y.value = 5;
msgSend.alpha.value = 0;
msgSend.commande = 9;
this->a_RS232Asservissement.send(msgSend);
_DEBUG("Arret d'urgence desactive", INFORMATION);
stop_obs = false;
}
}*/
break;
default:
break;
//_DEBUG("Le message capteur n'a pas pu etre traite...", WARNING);
}
}
catch(std::exception & e)
{
_DEBUG(e.what(), WARNING);
}
}
}
this->a_RS232Asservissement.close();
this->a_RS232Sensor.close();
_DEBUG("Fin de la routine d'ecoute des ports de communications", INFORMATION);
}
/*void Communication::test(int i)
{
//*
messageAsservissement msg;
int vg = 5, vd = 5;
switch(i)
{
case 3:
msg.id = 42;
msg.x.value = 0;
msg.y.value = 0;
msg.alpha.value = 0;
msg.commande = 3;
break;
case 4:
/*
std::cout << "Vitesse gauche : ";
std::cin >> vg;
std::cout << "Vitesse droite : ";
std::cin >> vd;//*/
/*msg.id = 42;
msg.x.value = vg;
msg.y.value = vd;
msg.alpha.value = 0;
msg.commande = 4;
break;
case 7:
msg.id = 42;
msg.x.value = 0;
msg.y.value = 0;
msg.alpha.value = 0;
msg.commande = 7;
break;
case 8:
msg.id = 42;
msg.x.value = 0;
msg.y.value = 0;
msg.alpha.value = 0;
msg.commande = 8;
break;
case 9:
msg.id = 42;
msg.x.value = 0;
msg.y.value = 0;
msg.alpha.value = 0;
msg.commande = 9;
break;
default:
_DEBUG("La commande asservissement n'est pas valide", WARNING);
return;
}//*/
/*
SerialPort::DataBuffer msg;
msg.push_back(42);
msg.push_back(5);
msg.push_back(0);
msg.push_back(0);
msg.push_back(0);
msg.push_back(5);
msg.push_back(0);
msg.push_back(0);
msg.push_back(0);
msg.push_back(0);
msg.push_back(0);
msg.push_back(0);
msg.push_back(0);
msg.push_back(4);//*/
/* this->a_RS232Asservissement.send(msg);
}*/
| [
"ferdinand.piette@308fe9b9-b635-520e-12eb-2ef3f824b1b6"
]
| [
[
[
1,
365
]
]
]
|
900d724879f9f3f60539fb0e658f4e70a33eb37f | 426ce36f170ef51acea1583c4c76c5fc5923fe08 | /CamShift.cpp | d19b1b8f444bc6cdcc65b95aea5207a1e53191d0 | []
| no_license | ayushpurohit/human-action-recognition | b42c7c6c746c9fb1e83e6d85fe88804a38ef70ef | da9653b4f41119e23de9b66ad65871a02f1b3dc7 | refs/heads/master | 2021-01-10T14:00:39.120712 | 2008-08-18T21:25:41 | 2008-08-18T21:25:41 | 46,225,758 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,329 | cpp | #include "CamShift.h"
CamShift::CamShift(CvSize frameSize)
{
_backproject_mode = 0;
_hdims = 16;
_hranges_arr[0] = 0;
_hranges_arr[1] = 180;
_hranges = _hranges_arr;
_vmin = 10;
_vmax = 256;
_smin = 30;
_hsv = cvCreateImage( frameSize, IPL_DEPTH_8U, 3 );
_hue = cvCreateImage( frameSize, IPL_DEPTH_8U, 1 );
_mask = cvCreateImage( frameSize, IPL_DEPTH_8U, 1 );
_backproject = cvCreateImage( frameSize, IPL_DEPTH_8U, 1 );
_hist = cvCreateHist( 1, &_hdims, CV_HIST_ARRAY, &_hranges, 1 );
}
CamShift::~CamShift(void)
{
cvReleaseImage(&_hsv);
cvReleaseImage(&_hue);
cvReleaseImage(&_mask);
cvReleaseImage(&_backproject);
cvReleaseHist(&_hist);
}
void CamShift::Track(IplImage *frame, CvRect &selection, bool calc_hist)
{
int i, bin_w, c;
cvCvtColor( frame, _hsv, CV_BGR2HSV );
cvInRangeS( _hsv, cvScalar(0,_smin,MIN(_vmin,_vmax),0),
cvScalar(180,256,MAX(_vmin,_vmax),0), _mask );
cvSplit( _hsv, _hue, 0, 0, 0 );
if(calc_hist)
{
float max_val = 0.f;
cvSetImageROI( _hue, selection );
cvSetImageROI( _mask, selection );
cvCalcHist( &_hue, _hist, 0, _mask );
cvGetMinMaxHistValue( _hist, 0, &max_val, 0, 0 );
cvConvertScale( _hist->bins, _hist->bins, max_val ? 255. / max_val : 0., 0 );
cvResetImageROI( _hue );
cvResetImageROI( _mask );
_track_window = selection;
}
cvCalcBackProject( &_hue, _backproject, _hist );
cvAnd( _backproject, _mask, _backproject, 0 );
cvCamShift( _backproject, _track_window,
cvTermCriteria( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 ),
&_track_comp, &_track_box );
_track_window = _track_comp.rect;
if( frame->origin )
_track_box.angle = -_track_box.angle;
selection = cvRect(_track_box.center.x-_track_box.size.width/2, _track_box.center.y-_track_box.size.height/2,
selection.width, selection.height);
}
CvScalar CamShift::_HSV2RGB( float _hue )
{
int rgb[3], p, sector;
static const int sector_data[][3] =
{{0,2,1}, {1,2,0}, {1,0,2}, {2,0,1}, {2,1,0}, {0,1,2}};
_hue *= 0.033333333333333333333333333333333f;
sector = cvFloor(_hue);
p = cvRound(255*(_hue - sector));
p ^= sector & 1 ? 255 : 0;
rgb[sector_data[sector][0]] = 255;
rgb[sector_data[sector][1]] = 0;
rgb[sector_data[sector][2]] = p;
return cvScalar(rgb[2], rgb[1], rgb[0], 0);
} | [
"mnbayazit@391b830b-d650-0410-bb89-83bffae94361"
]
| [
[
[
1,
83
]
]
]
|
173faf650eaf92ef2a38c0de25b71bcd9c85b594 | 31ebb87c61e3a7afefc35539defa83a0ca8b31db | /branches/tk/common/point.h | 598cc76cf9cb7fce9f7d5c3441a5a1659104bc53 | []
| no_license | benrick/win-tk | d5a582fefcffb7def655a4cba3e95003e0cf467e | 4eebe5ae2f848f5301e1f255f9975aa8d0e59c43 | refs/heads/master | 2016-09-16T11:40:01.714442 | 2007-05-15T16:55:48 | 2007-05-15T16:55:48 | 32,125,230 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 515 | h | /*
win-tk Project
Daniel A. White
common/point.h
*/
#ifndef TK_POINT
#define TK_POINT
namespace Common
{
class Point
{
private:
int _x, _y;
public:
// Constructor
Point(int x = 0, int y = 0) : _x(x), _y(y) { }
// Accessors and mutators
int& X() { return _x; }
int& Y() { return _y; }
// Operators
bool operator==(const Point&);
bool operator!=(const Point&);
};
};
#endif
| [
"thetrueaplus@86042e1f-1e30-0410-badd-c55c161c65e0"
]
| [
[
[
1,
32
]
]
]
|
6e6eb25c0280738ba6eede5f75eb8260cce2ae66 | b2155efef00dbb04ae7a23e749955f5ec47afb5a | /include/OECore/IOERenderData.h | ff0decdc3e632c777c3cfa1b204969e12ceead83 | []
| no_license | zjhlogo/originengine | 00c0bd3c38a634b4c96394e3f8eece86f2fe8351 | a35a83ed3f49f6aeeab5c3651ce12b5c5a43058f | refs/heads/master | 2021-01-20T13:48:48.015940 | 2011-04-21T04:10:54 | 2011-04-21T04:10:54 | 32,371,356 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,487 | h | /*!
* \file IOERenderData.h
* \date 12-2-2010 20:00:23
*
*
* \author zjhlogo ([email protected])
*/
#ifndef __IOERENDERDATA_H__
#define __IOERENDERDATA_H__
#include "../libOEBase/IOEObject.h"
#include "IOEMesh.h"
#include "IOEMaterial.h"
#include "IOEAnimData.h"
#include "IOEMaterialsList.h"
class IOERenderData : public IOEObject
{
public:
RTTI_DEF(IOERenderData, IOEObject);
IOERenderData() {};
virtual ~IOERenderData() {};
virtual bool SetInt(const tstring& strKey, int nValue) = 0;
virtual bool RemoveInt(const tstring& strKey) = 0;
virtual bool GetInt(int& nValue, const tstring& strKey) = 0;
virtual bool SetFloat(const tstring& strKey, float fValue) = 0;
virtual bool RemoveFloat(const tstring& strKey) = 0;
virtual bool GetFloat(float& fValue, const tstring& strKey) = 0;
virtual bool SetVector(const tstring& strKey, const CVector3& vValue) = 0;
virtual bool RemoveVector(const tstring& strKey) = 0;
virtual bool GetVector(CVector3& vValue, const tstring& strKey) = 0;
virtual bool SetMatrix(const tstring& strKey, const CMatrix4x4& matValue) = 0;
virtual bool RemoveMatrix(const tstring& strKey) = 0;
virtual bool GetMatrix(CMatrix4x4& matOut, const tstring& strKey) = 0;
virtual bool SetTexture(const tstring& strKey, IOETexture* pTexture) = 0;
virtual bool RemoveTexture(const tstring& strKey) = 0;
virtual IOETexture* GetTexture(const tstring& strKey) = 0;
virtual bool SetMesh(const tstring& strKey, IOEMesh* pMesh) = 0;
virtual bool RemoveMesh(const tstring& strKey) = 0;
virtual IOEMesh* GetMesh(const tstring& strKey) = 0;
virtual bool SetAnimData(const tstring& strKey, IOEAnimData* pAnimData) = 0;
virtual bool RemoveAnimData(const tstring& strKey) = 0;
virtual IOEAnimData* GetAnimData(const tstring& strKey) = 0;
virtual bool SetMaterial(const tstring& strKey, IOEMaterial* pMaterial) = 0;
virtual bool RemoveMaterial(const tstring& strKey) = 0;
virtual IOEMaterial* GetMaterial(const tstring& strKey) = 0;
virtual bool SetMaterialsList(const tstring& strKey, IOEMaterialsList* pMaterialsList) = 0;
virtual bool RemoveMaterialsList(const tstring& strKey) = 0;
virtual IOEMaterialsList* GetMaterialsList(const tstring& strKey) = 0;
virtual bool SetObject(const tstring& strKey, IOEObject* pObject) = 0;
virtual bool RemoveObject(const tstring& strKey) = 0;
virtual IOEObject* GetObject(const tstring& strKey) = 0;
};
#endif // __IOERENDERDATA_H__
| [
"zjhlogo@fdcc8808-487c-11de-a4f5-9d9bc3506571"
]
| [
[
[
1,
66
]
]
]
|
ab2d467abab417eba69a6010f68a89ebb97019f1 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/trunk/engine/script/src/EnvironmentProcessor.cpp | 90af064731467ac4d812f624048c3a499925204d | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,995 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* 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
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h" //precompiled header
#include "EnvironmentProcessor.h"
#include "CoreSubsystem.h"
#include "World.h"
#include "XmlProcessor.h"
using namespace Ogre;
namespace rl
{
bool EnvironmentProcessor::processNode(const TiXmlElement* nodeElem, const Ogre::String& resourceGroup, bool loadGameObjects)
{
if (nodeElem)
{
processSkySettings(getChildNamed(nodeElem, "sky"));
processFogSettings(getChildNamed(nodeElem, "fog"));
}
return true;
}
void EnvironmentProcessor::processSkySettings(const TiXmlElement* skyElem)
{
if (skyElem)
{
if (!hasAttribute(skyElem, "material")
|| !hasAttribute(skyElem, "type"))
{
LOG_ERROR(Logger::RULES, "<sky> element must have at least attributes 'type' and 'material'.");
}
else
{
Ogre::String type = getAttributeValueAsStdString(skyElem, "type");
Ogre::String material = getAttributeValueAsStdString(skyElem, "material");
bool drawFirst = true;
if (hasAttribute(skyElem, "drawfirst"))
{
drawFirst = getAttributeValueAsBool(skyElem, "drawfirst");
}
Ogre::Real distance = 5000;
if (hasAttribute(skyElem, "distance"))
{
distance = getAttributeValueAsReal(skyElem, "distance");
}
if (type == "dome")
{
Ogre::Real curvature = 10;
Ogre::Real tiling = 8;
const TiXmlElement* domeSettings = getChildNamed(skyElem, "skydomesettings");
if (domeSettings != NULL)
{
if (hasAttribute(domeSettings, "curvature"))
{
curvature = getAttributeValueAsReal(domeSettings, "curvature");
}
if (hasAttribute(domeSettings, "tiling"))
{
curvature = getAttributeValueAsReal(domeSettings, "tiling");
}
}
CoreSubsystem::getSingleton().getWorld()->setSkyDome(
true, material, curvature, tiling, distance, drawFirst);
}
else if (type == "box")
{
CoreSubsystem::getSingleton().getWorld()->setSkyBox(true, material, distance, drawFirst);
}
else if (type == "plane")
{
LOG_ERROR(Logger::RULES, "Sky Plane is not implemented yet.");
}
}
}
}
void EnvironmentProcessor::processFogSettings(const TiXmlElement* fogElem)
{
if (fogElem)
{
if (!hasAttribute(fogElem, "type"))
{
LOG_ERROR(
Logger::RULES,
"<fog> element must have at least the attribute 'type'.");
return;
}
const TiXmlElement* colourElem = getChildNamed(fogElem, "colour");
if (colourElem == NULL)
{
LOG_ERROR(Logger::RULES, "No fog colour set.");
return;
}
ColourValue fogColour = processColour(colourElem);
Ogre::String type = getAttributeValueAsStdString(fogElem, "type");
if (type == "exp" || type == "exp2")
{
if (hasAttribute(fogElem, "density"))
{
Ogre::Real density = getAttributeValueAsReal(fogElem, "density");
if (type == "exp")
{
CoreSubsystem::getSingleton().getWorld()->setFog(
World::FOG_EXP, fogColour, density);
}
else if (type == "exp2")
{
CoreSubsystem::getSingleton().getWorld()->setFog(
World::FOG_EXP2, fogColour, density);
}
}
else
{
LOG_ERROR(
Logger::RULES, type + " fog needs attribute 'density'.");
}
}
else if (type == "linear")
{
if (hasAttribute(fogElem, "start")
&& hasAttribute(fogElem, "end"))
{
Ogre::Real start = getAttributeValueAsReal(fogElem, "start");
Ogre::Real end = getAttributeValueAsReal(fogElem, "end");
CoreSubsystem::getSingleton().getWorld()->setFog(
World::FOG_LINEAR, fogColour, 0, start, end);
}
else
{
LOG_ERROR(
Logger::RULES, "linear fog needs attributes 'start' and 'end'.");
}
}
else
{
LOG_ERROR(
Logger::RULES, type + " is an unknown fog type.");
}
}
}
}
| [
"blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013",
"ablock@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
15
],
[
17,
166
]
],
[
[
16,
16
]
]
]
|
27296698213804476583266773eb33f22a1fb398 | f3ed6f9abb7be30e410c733cbcf7923dbefdbc32 | /globals.cpp | bd774aa661311df883896bbdcbaf8ba51fffe21f | []
| no_license | walle/exoudus | 8f045b534408034a513fe25fc97ba725df998ab3 | 344b79c44eeb2d1500e36cc0eefa972a7fe0d288 | refs/heads/master | 2018-12-29T02:00:46.191421 | 2010-11-16T22:48:39 | 2010-11-22T20:02:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,359 | cpp | #include "globals.h"
bool done = false;
SDL_Surface *screen;
SDL_Event event;
Uint8* keys;
cFramerate framerate;
//Colors
SDL_Color red = { 255, 0, 0 };
SDL_Color green = { 0, 255, 0 };
SDL_Color blue = { 0, 0, 255 };
SDL_Color white = { 255, 255, 255 };
SDL_Color black = { 0, 0, 0 };
SDL_Color colorkey = { 0, 255, 0 };
cLog *pLog = NULL;
cLog *pDebug = NULL;
cSettings *pSettings = NULL;
cImgManager *pImgManager = NULL;
cSoundManager *pSoundManager = NULL;
cGamestatemanager *pGamestatemanager = NULL;
cMenustate *pMenustate = NULL;
cPlaystate *pPlaystate = NULL;
cOptionsstate *pOptionsstate = NULL;
cBackground *pBackground = NULL;
cFont *pFont;
bool valid_file( string filename )
{
ifstream ifs( filename.c_str(), ios::in );
if( ifs )
{
ifs.close();
return true;
}
return false;
}
// Used by the valid_number function
struct nondigit
{
bool operator() (char c) { return !isdigit(c); }
};
string int_to_string( int number )
{
stringstream temp;
temp << number;
return temp.str();
}
int count(string str, string ch)
{
int j = 0;
for(int i = 0; i < str.size(); i++)
{
if(str.at(i) == ch.at(0)) { j++; }
}
return j;
}
int string_to_int( string str )
{
int num;
stringstream temp( str );
temp >> num;
return num;
}
bool pixel_collision(cSprite *sprite, int x, int y)
{
if( ( (x >= sprite->getx()) && (x <= sprite->getx() + sprite->getw())))
{
if( ( (y >= sprite->gety()) && (y <= sprite->gety() + sprite->geth())))
{
return true;
}
}
return false;
}
void Toggle_Fullscreen( void )
{
#ifdef WIN32
Uint32 flags = screen->flags;
flags ^= SDL_FULLSCREEN;
Uint8 bpp = screen->format->BitsPerPixel;
int w = screen->w;
int h = screen->h;
screen = SDL_SetVideoMode( w, h, bpp, flags );
#else
// unfortunately, this command doesn't work for non-X11 platforms:
SDL_WM_ToggleFullScreen( screen );
#endif
}
SDL_Surface *load_image(string file)
{
SDL_Surface *temp1, *temp2;
temp1 = IMG_Load(file.c_str());
temp2 = SDL_DisplayFormat(temp1);
SDL_FreeSurface(temp1);
return temp2;
}
void draw_img( int image, int x, int y )
{
SDL_Rect rect;
rect.x = x;
rect.y = y;
SDL_BlitSurface(pImgManager->get(image), NULL, screen, &rect);
}
| [
"[email protected]"
]
| [
[
[
1,
123
]
]
]
|
1b52c83a3cc61567d6b8946ae69aeb6beeaa2972 | 171daeea8e21d62e4e1ea549f94fcf638c542c25 | /JiangChen/UniSens_16405/UniSens/AngView.cpp | 47c98f3f0b79948195777d0680764dd39318d792 | []
| no_license | sworldy/snarcmotioncapture | b8c848ee64212cfb38f002bdd183bf4b6257a9c7 | d4f57f0b7e2ecda6375c11eaa7f6a6b6d3d0af21 | refs/heads/master | 2021-01-13T02:02:54.097775 | 2011-08-07T16:46:24 | 2011-08-07T16:46:24 | 33,110,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,883 | cpp | /*===================================================*\
| |
| Uni-Sensor Demostration System |
| |
| Copyright (c) 2009 - Guanhong Tao |
| [email protected] |
| [email protected] |
| |
| Created: |
| 2009/03/25 |
| License: |
| |
| Copyright 2009 Guanhong Tao, All Rights Reserved. |
| For educational purposes only. |
| Please do not republish in electronic or |
| print form without permission |
| |
| Email me for the docs and new versions |
| |
\*===================================================*/
// AngView.cpp : implementation file
//
#include "stdafx.h"
#include "UniSens.h"
#include "AngView.h"
#include <list>
#include <iterator>
#include "mmsystem.h"
#include <math.h>
#pragma comment(lib,"winmm.lib")
// CAngView
IMPLEMENT_DYNCREATE(CAngView, CView)
CAngView::CAngView()
{
m_strTitle = _T("Angular Velocity");
m_strValueName = _T("Gry X");
m_strValueName1 = _T("Gry Y");
m_strValueName2 = _T("Gry Z");
m_strUnitName = _T("deg/s");
m_dDimT = 3.0;
m_dDimY = 1.0;
m_nBase = 5;
m_nRange = 10;
m_dValue= 0.0;
m_dValue1 = 0.0;
m_dValue2 = 0.0;
m_nArrowIndex =-1;
row = 0;
frames = 0;
m_bPressed = FALSE;
isCheckOrder = TRUE ;
isCheckOutput = TRUE ;
isCheckError = TRUE ;
}
CAngView::~CAngView()
{
}
BEGIN_MESSAGE_MAP(CAngView, CView)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
END_MESSAGE_MAP()
// CAngView drawing
BOOL CAngView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
GetClientRect(&rect);
pDC->FillRect(&rect,&m_BkBrush);//Draw background
rect.InflateRect(-3,-25,-4,-60);//curve panel
m_rectCurvePanel = rect;
m_rectCurve = rect;
m_rectCurve.InflateRect(-45,-5,-23,-25);//curve area
m_rectScroll = m_rectCurve;
m_rectScroll.left = m_rectCurve.right+8;
m_rectScroll.right = m_rectScroll.left+10;//rect scroll created
m_rectValuePanel = rect;
m_rectValuePanel.top = rect.bottom+5;
m_rectValuePanel.bottom= m_rectValuePanel.top+51;//rectValuePanel created
CFont *pOldFont;
pOldFont = pDC->SelectObject(&m_FontLabel);
CSize size = pDC->GetTextExtent(m_strValueName);
m_rectValue.left = m_rectValuePanel.left+20+size.cx;
m_rectValue.top = m_rectValuePanel.top+(m_rectValuePanel.Height()-size.cy)/2-2;
m_rectValue.bottom = m_rectValue.top+size.cy+4;
size = pDC->GetTextExtent(m_strUnitName);
m_rectValue.right = m_rectValuePanel.right/3 - 20 - size.cx;
m_rectValue1.left = m_rectValue.right + size.cx + 65;
m_rectValue1.top = m_rectValue.top;
m_rectValue1.bottom = m_rectValue.bottom;
m_rectValue1.right = m_rectValue1.left + m_rectValue.right - m_rectValue.left ;
m_rectValue2.left = m_rectValue1.right + size.cx + 65;
m_rectValue2.top = m_rectValue.top;
m_rectValue2.bottom = m_rectValue.bottom;
m_rectValue2.right = m_rectValue2.left + m_rectValue.right - m_rectValue.left ;
pDC->SelectObject(pOldFont);
if(m_rgnCurve.m_hObject==NULL)
m_rgnCurve.CreateRectRgn(m_rectCurve.left+2,m_rectCurve.top+2,m_rectCurve.right-2,m_rectCurve.bottom-2);
POINT ptYPlus[3];
POINT ptYMinus[3];
POINT ptTPlus[3];
POINT ptTMinus[3];
ptYPlus[0].x = m_rectCurvePanel.left+15;
ptYPlus[0].y = m_rectCurve.bottom+3;
ptYPlus[1].x = ptYPlus[0].x-5;
ptYPlus[1].y = ptYPlus[0].y+6;
ptYPlus[2].x = ptYPlus[0].x+5;
ptYPlus[2].y = ptYPlus[0].y+6;
ptYMinus[0].x = m_rectCurvePanel.left+15;
ptYMinus[0].y = m_rectCurve.bottom+18;
ptYMinus[1].x = ptYMinus[0].x-5;
ptYMinus[1].y = ptYMinus[0].y-6;
ptYMinus[2].x = ptYMinus[0].x+5;
ptYMinus[2].y = ptYMinus[0].y-6;
ptTPlus[0].x = m_rectScroll.left+m_rectScroll.Width()/2;
ptTPlus[0].y = m_rectCurve.bottom+3;
ptTPlus[1].x = ptTPlus[0].x-5;
ptTPlus[1].y = ptTPlus[0].y+6;
ptTPlus[2].x = ptTPlus[0].x+5;
ptTPlus[2].y = ptTPlus[0].y+6;
ptTMinus[0].x = m_rectScroll.left+m_rectScroll.Width()/2;
ptTMinus[0].y = m_rectCurve.bottom+18;
ptTMinus[1].x = ptTMinus[0].x-5;
ptTMinus[1].y = ptTMinus[0].y-6;
ptTMinus[2].x = ptTMinus[0].x+5;
ptTMinus[2].y = ptTMinus[0].y-6;
if(m_rgnYPlus.m_hObject==NULL)
m_rgnYPlus.CreatePolygonRgn( ptYPlus, 3, ALTERNATE );
if(m_rgnYMinus.m_hObject==NULL)
m_rgnYMinus.CreatePolygonRgn( ptYMinus, 3, ALTERNATE );
if(m_rgnTPlus.m_hObject==NULL)
m_rgnTPlus.CreatePolygonRgn( ptTPlus, 3, ALTERNATE );
if(m_rgnTMinus.m_hObject==NULL)
m_rgnTMinus.CreatePolygonRgn( ptTMinus, 3, ALTERNATE );
return TRUE;
}
// CAngView diagnostics
#ifdef _DEBUG
void CAngView::AssertValid() const
{
CView::AssertValid();
}
#ifndef _WIN32_WCE
void CAngView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif
#endif //_DEBUG
// CAngView message handlers
void CAngView::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
double gyr_x, gyr_y, gyr_z;
double dTime = ::timeGetTime()/1000.0;
if(row < frames)
{
gyr_x = v->at(row).at(3);
gyr_y = v->at(row).at(4);
gyr_z = v->at(row).at(5);
row++;
AddValue(dTime, gyr_x, gyr_y, gyr_z);
SetValue(gyr_x, gyr_y, gyr_z);
UpdateCurve();
}
CView::OnTimer(nIDEvent);
}
| [
"macrotao86@4a66b584-afee-11de-9d1a-45ab25924541"
]
| [
[
[
1,
203
]
]
]
|
a54e824bb5aab7a696ce376bd4c1ab0d48de67f5 | 785c626de66963b4e04c98a8856d0a45418297c5 | /util.cpp | d3f305e23ca3ef9396424c27edf4c2f436ac0bcf | []
| no_license | Ruijie-Qin/CLibShow | 7372f4360fe3c4b7207a9c8ea50694c619187d30 | 1736808ffc25e3361d4510318e051cb417328a2d | refs/heads/master | 2021-01-16T19:01:59.505117 | 2011-09-27T02:48:03 | 2011-09-27T02:48:03 | 2,449,476 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,772 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
// 清空输入缓冲区
static void clearInputBuffer()
{
// 简单的清空输入缓冲区的办法
// 可移植性不佳,但是目前没有这方面的需求
// 未来需要的时候再做改进
fflush(stdin);
}
// 让用户输入一个 int 型的数字
int getInt(const char * message)
{
while (true)
{
if (message != NULL)
{
printf(message);
}
int v = 0;
int success = scanf("%d", &v);
if (success != 0)
{
clearInputBuffer();
return v;
}
else
{
// 如果用户输入了垃圾数据,则将要求用户重新输入
// 在此之前,先清除当前输入缓冲中的字符,否则会造成
// 下次 scanf() 也会失败,导致无限循环
clearInputBuffer();
}
}
}
// 让用户输入一个 double 型的数字
double getDouble(const char * message)
{
while (true)
{
if (message != NULL)
{
printf(message);
}
double v = 0.0;
int success = scanf("%lf", &v);
if (success != 0)
{
clearInputBuffer();
return v;
}
else
{
// 如果用户输入了垃圾数据,则将要求用户重新输入
// 在此之前,先清除当前输入缓冲中的字符,否则会造成
// 下次 scanf() 也会失败,导致无限循环
clearInputBuffer();
}
}
}
// 让用户输入一个 char 型字符
char getChar(const char * message)
{
while (true)
{
if (message != NULL)
{
printf(message);
}
char v = 0;
int success = scanf("%c", &v);
if (success != 0)
{
clearInputBuffer();
// 如果用户输入了中文字符,则要求用户重新输入
if (v < 0)
{
continue;
}
else
{
return v;
}
}
else
{
// 如果用户输入了垃圾数据,则将要求用户重新输入
// 在此之前,先清除当前输入缓冲中的字符,否则会造成
// 下次 scanf() 也会失败,导致无限循环
clearInputBuffer();
}
}
}
// 内存分配函数
// 其实是对 calloc 的封装
// 之所以要再封装,是在 calloc 的基础上定义了内存分配失败时的处理策略
// 如果内存不足,立刻结束程序,不再继续执行
// 这是比较粗糙的处理手法,但是可以保证不会再发生其他致命错误
// 在本项目中不涉及用户数据的保存,因此粗暴的结束程序
// 并不会带来数据丢失等问题
void * memoryAllocate(size_t size)
{
void * p = calloc(1, size);
if (p == NULL)
{
puts("allocate memory failed!\n");
exit(0);
}
else
{
return p;
}
}
void run(const char * exe, const char * params)
{
ShellExecuteA(NULL, "open", exe, params, NULL, SW_SHOWNORMAL);
} | [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
65
],
[
100,
124
]
],
[
[
66,
99
]
]
]
|
a2abec7df0e6f7c319a050677ee9ee117e39cfde | 310a6e92333860268302ed1a24163f47211358b4 | /GuiContext.h | d097ceb8d39c8fd4575e795aef5bb5c9109e9f03 | [
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain"
]
| permissive | bramstein/ui-demo | fde0b03d955146f940ee263281a36f40edce5f15 | 102757bdc3ca99bdda9e7390a67a21a53a04cf1f | refs/heads/master | 2021-01-10T19:23:22.526035 | 2009-11-18T22:11:41 | 2009-11-18T22:11:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 537 | h | #ifndef GUICONTEXT_H
#define GUICONTEXT_H
#include ".\includes.h"
#include ".\MainGui.h"
#include ".\BitmapFontFactory.h"
#include "Gui.h"
namespace demo
{
class GuiContext
{
public:
GuiContext();
bool isRunning();
~GuiContext();
private:
void paint() const;
bool gatherInput() const;
void update();
float deltaTime;
unsigned int lastFrameIndex;
unsigned int thisFrameIndex;
std::auto_ptr<ui::Gui> guiInstance;
MainGui *mainGui;
BitmapFontFactory *fontFactory;
};
}
#endif | [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
50fca79937fd16a88c16d1c32de7e0b2d56eafcf | 57855d23617d6a65298c2ae3485ba611c51809eb | /Zen/Enterprise/AppServer/src/I_ResourceLocation.cpp | 855ac72ff889af6a8cfc0f4587845099ac71d85d | []
| no_license | Azaezel/quillus-daemos | 7ff4261320c29e0125843b7da39b7b53db685cd5 | 8ee6eac886d831eec3acfc02f03c3ecf78cc841f | refs/heads/master | 2021-01-01T20:35:04.863253 | 2011-04-08T13:46:40 | 2011-04-08T13:46:40 | 32,132,616 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,912 | cpp | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// Zen Enterprise Framework
//
// Copyright (C) 2001 - 2008 Tony Richards
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
// Tony Richards [email protected]
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
#include "../I_ResourceLocation.hpp"
#include "ResourceLocation.hpp"
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
namespace Zen {
namespace Enterprise {
namespace AppServer {
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
I_ResourceLocation::I_ResourceLocation()
{
}
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
I_ResourceLocation::~I_ResourceLocation()
{
}
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
} // namespace AppServer
} // namespace Enterprise
} // namespace Zen
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| [
"sgtflame@Sullivan"
]
| [
[
[
1,
47
]
]
]
|
c1edb9b9ddf634c4234085901411dcee5bccf65f | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/Com/ScdVB/ScdEventRelay.h | cd5835418cd17f87f8505126c75e1a4784eb9138 | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,610 | h | // ScdEventRelay.h : Declaration of the CScdEventRelay
#ifndef __SCDEVENTRELAY_H_
#define __SCDEVENTRELAY_H_
#include "resource.h" // main symbols
#include "ScdVBCP.h"
/////////////////////////////////////////////////////////////////////////////
// CScdEventRelay
class ATL_NO_VTABLE CScdEventRelay :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CScdEventRelay, &CLSID_ScdEventRelay>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CScdEventRelay>,
public IDispatchImpl<IScdEventRelay, &IID_IScdEventRelay, &LIBID_ScdVBLib>,
public CProxy_IScdEventRelayEvents< CScdEventRelay >
{
public:
CScdEventRelay()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_SCDEVENTRELAY)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CScdEventRelay)
COM_INTERFACE_ENTRY(IScdEventRelay)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CScdEventRelay)
CONNECTION_POINT_ENTRY(DIID__ScdEventRelayEvents)
END_CONNECTION_POINT_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
// IScdEventRelay
public:
void FinalRelease();
HRESULT FinalConstruct();
STDMETHOD(NotifyMe)(/*[in]*/ long i_lCookie);
private:
DWORD ThreadProc();
static DWORD WINAPI StaticThreadProc( LPVOID );
HANDLE m_evStop;
HANDLE m_hThreadProc;
HANDLE m_evNotify;
std::queue< long , std::list<long> > m_qCookies;
};
#endif //__SCDEVENTRELAY_H_
| [
"[email protected]"
]
| [
[
[
1,
57
]
]
]
|
667ae64cc43ff01c9fa46758efe56efaf47a8535 | f89e32cc183d64db5fc4eb17c47644a15c99e104 | /pcsx2-rr/plugins/zzogl-pg/opengl/zerogs.cpp | 774995403e5b0fe078f1a46988e7f9d41b4657cb | []
| no_license | mauzus/progenitor | f99b882a48eb47a1cdbfacd2f38505e4c87480b4 | 7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae | refs/heads/master | 2021-01-10T07:24:00.383776 | 2011-04-28T11:03:43 | 2011-04-28T11:03:43 | 45,171,114 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,012 | cpp | /* ZZ Open GL graphics plugin
* Copyright (c)2009-2010 [email protected], [email protected]
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
//-------------------------- Includes
#if defined(_WIN32)
# include <windows.h>
# include "resource.h"
#endif
#include <stdlib.h>
#include "GS.h"
#include "Mem.h"
#include "x86.h"
#include "zerogs.h"
#include "zpipe.h"
#include "targets.h"
#include "GLWin.h"
#include "ZZoglShaders.h"
//----------------------- Defines
//-------------------------- Typedefs
typedef void (APIENTRYP _PFNSWAPINTERVAL)(int);
//-------------------------- Extern variables
using namespace ZeroGS;
extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve;
extern char *libraryName;
extern int g_nFrame, g_nRealFrame;
//extern int s_nFullscreen;
//-------------------------- Variables
primInfo *prim;
ZZshProgram g_vsprog = 0, g_psprog = 0; // 2 -- ZZ
inline u32 FtoDW(float f) { return (*((u32*)&f)); }
int g_nDepthUpdateCount = 0;
// Consts
const GLenum primtype[8] = { GL_POINTS, GL_LINES, GL_LINES, GL_TRIANGLES, GL_TRIANGLES, GL_TRIANGLES, GL_TRIANGLES, 0xffffffff };
static const int PRIMMASK = 0x0e; // for now ignore 0x10 (AA)
PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL;
PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL;
PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL;
PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = NULL;
PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL;
PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT = NULL;
PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT = NULL;
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL;
PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL;
PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL;
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL;
PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT = NULL;
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL;
PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL;
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL;
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL;
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
PFNGLDRAWBUFFERSPROC glDrawBuffers = NULL;
/////////////////////
// graphics resources
ZZshParameter g_vparamPosXY[2] = {0}, g_fparamFogColor = 0;
bool s_bTexFlush = false;
int s_nLastResolveReset = 0;
int s_nResolveCounts[30] = {0}; // resolve counts for last 30 frames
////////////////////
// State parameters
int nBackbufferWidth, nBackbufferHeight; // ZZ
namespace ZeroGS
{
Vector g_vdepth, vlogz;
// = Vector( 255.0 /256.0f, 255.0/65536.0f, 255.0f/(65535.0f*256.0f), 1.0f/(65536.0f*65536.0f));
// Vector g_vdepth = Vector( 65536.0f*65536.0f, 256.0f*65536.0f, 65536.0f, 256.0f);
extern CRangeManager s_RangeMngr; // manages overwritten memory
GLenum GetRenderTargetFormat() { return GetRenderFormat() == RFT_byte8 ? 4 : g_internalRGBAFloat16Fmt; }
// returns the first and last addresses aligned to a page that cover
void GetRectMemAddress(int& start, int& end, int psm, int x, int y, int w, int h, int bp, int bw);
int s_nNewWidth = -1, s_nNewHeight = -1;
void ChangeDeviceSize(int nNewWidth, int nNewHeight);
void ProcessMessages();
void RenderCustom(float fAlpha); // intro anim
struct MESSAGE
{
MESSAGE() {}
MESSAGE(const char* p, u32 dw) { strcpy(str, p); dwTimeStamp = dw; }
char str[255];
u32 dwTimeStamp;
};
static list<MESSAGE> listMsgs;
///////////////////////
// Method Prototypes //
///////////////////////
void KickPoint();
void KickLine();
void KickTriangle();
void KickTriangleFan();
void KickSprite();
void KickDummy();
void ResolveInRange(int start, int end);
void ExtWrite();
void ResetRenderTarget(int index)
{
FBTexture(index);
}
DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy,
KickDummy, KickDummy, KickDummy, KickDummy
};
}; // end namespace
// does one time only initializing/destruction
class ZeroGSInit
{
public:
ZeroGSInit()
{
const u32 mem_size = MEMORY_END + 0x10000; // leave some room for out of range accesses (saves on the checks)
// clear
g_pbyGSMemory = (u8*)_aligned_malloc(mem_size, 1024);
memset(g_pbyGSMemory, 0, mem_size);
g_pbyGSClut = (u8*)_aligned_malloc(256 * 8, 1024); // need 512 alignment!
memset(g_pbyGSClut, 0, 256*8);
memset(&GLWin, 0, sizeof(GLWin));
}
~ZeroGSInit()
{
_aligned_free(g_pbyGSMemory);
g_pbyGSMemory = NULL;
_aligned_free(g_pbyGSClut);
g_pbyGSClut = NULL;
}
};
static ZeroGSInit s_ZeroGSInit;
#ifndef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8
#endif
void ZeroGS::HandleGLError()
{
FUNCLOG
// check the error status of this framebuffer */
GLenum error = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
// if error != GL_FRAMEBUFFER_COMPLETE_EXT, there's an error of some sort
if (error != 0)
{
int w = 0;
int h = 0;
GLint fmt;
glGetRenderbufferParameterivEXT(GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT_EXT, &fmt);
glGetRenderbufferParameterivEXT(GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_WIDTH_EXT, &w);
glGetRenderbufferParameterivEXT(GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_HEIGHT_EXT, &h);
switch (error)
{
case GL_FRAMEBUFFER_COMPLETE_EXT:
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
ZZLog::Error_Log("Error! missing a required image/buffer attachment!");
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
ZZLog::Error_Log("Error! has no images/buffers attached!");
break;
// case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
// ZZLog::Error_Log("Error! has an image/buffer attached in multiple locations!");
// break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
ZZLog::Error_Log("Error! has mismatched image/buffer dimensions!");
break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
ZZLog::Error_Log("Error! colorbuffer attachments have different types!");
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
ZZLog::Error_Log("Error! trying to draw to non-attached color buffer!");
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
ZZLog::Error_Log("Error! trying to read from a non-attached color buffer!");
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
ZZLog::Error_Log("Error! format is not supported by current graphics card/driver!");
break;
default:
ZZLog::Error_Log("*UNKNOWN ERROR* reported from glCheckFramebufferStatusEXT(0x%x)!", error);
break;
}
}
}
void ZeroGS::GSStateReset()
{
FUNCLOG
icurctx = -1;
for (int i = 0; i < 2; ++i)
{
vb[i].Destroy();
memset(&vb[i], 0, sizeof(ZeroGS::VB));
vb[i].tex0.tw = 1;
vb[i].tex0.th = 1;
vb[i].scissor.x1 = 639;
vb[i].scissor.y1 = 479;
vb[i].tex0.tbw = 64;
vb[i].Init(VB_BUFFERSIZE);
}
s_RangeMngr.Clear();
g_MemTargs.Destroy();
s_RTs.Destroy();
s_DepthRTs.Destroy();
s_BitwiseTextures.Destroy();
vb[0].ictx = 0;
vb[1].ictx = 1;
}
void ZeroGS::Reset()
{
FUNCLOG
s_RTs.ResolveAll();
s_DepthRTs.ResolveAll();
vb[0].nCount = 0;
vb[1].nCount = 0;
memset(s_nResolveCounts, 0, sizeof(s_nResolveCounts));
s_nLastResolveReset = 0;
icurctx = -1;
g_vsprog = g_psprog = 0;
GSStateReset();
Destroy(0);
drawfn[0] = KickDummy;
drawfn[1] = KickDummy;
drawfn[2] = KickDummy;
drawfn[3] = KickDummy;
drawfn[4] = KickDummy;
drawfn[5] = KickDummy;
drawfn[6] = KickDummy;
drawfn[7] = KickDummy;
}
void ZeroGS::GSReset()
{
FUNCLOG
memset(&gs, 0, sizeof(gs));
ZeroGS::GSStateReset();
gs.prac = 1;
prim = &gs._prim[0];
gs.nTriFanVert = -1;
gs.imageTransfer = -1;
gs.q = 1;
}
void ZeroGS::GSSoftReset(u32 mask)
{
FUNCLOG
if (mask & 1) memset(&gs.path[0], 0, sizeof(gs.path[0]));
if (mask & 2) memset(&gs.path[1], 0, sizeof(gs.path[1]));
if (mask & 4) memset(&gs.path[2], 0, sizeof(gs.path[2]));
gs.imageTransfer = -1;
gs.q = 1;
gs.nTriFanVert = -1;
}
void ZeroGS::AddMessage(const char* pstr, u32 ms)
{
FUNCLOG
listMsgs.push_back(MESSAGE(pstr, timeGetTime() + ms));
ZZLog::Log("%s\n", pstr);
}
extern RasterFont* font_p;
void ZeroGS::DrawText(const char* pstr, int left, int top, u32 color)
{
FUNCLOG
ZZshGLDisableProfile();
Vector v;
v.SetColor(color);
glColor3f(v.z, v.y, v.x);
//glColor3f(((color >> 16) & 0xff) / 255.0f, ((color >> 8) & 0xff)/ 255.0f, (color & 0xff) / 255.0f);
font_p->printString(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight, 0);
ZZshGLEnableProfile();
}
void ZeroGS::ChangeWindowSize(int nNewWidth, int nNewHeight)
{
FUNCLOG
nBackbufferWidth = max(nNewWidth, 16);
nBackbufferHeight = max(nNewHeight, 16);
if (!(conf.fullscreen()))
{
conf.width = nNewWidth;
conf.height = nNewHeight;
}
}
void ZeroGS::SetChangeDeviceSize(int nNewWidth, int nNewHeight)
{
FUNCLOG
s_nNewWidth = nNewWidth;
s_nNewHeight = nNewHeight;
if (!(conf.fullscreen()))
{
conf.width = nNewWidth;
conf.height = nNewHeight;
}
}
void ZeroGS::ChangeDeviceSize(int nNewWidth, int nNewHeight)
{
FUNCLOG
//int oldscreen = s_nFullscreen;
int oldwidth = nBackbufferWidth, oldheight = nBackbufferHeight;
if (!Create(nNewWidth&~7, nNewHeight&~7))
{
ZZLog::Error_Log("Failed to recreate, changing to old device.");
if (Create(oldwidth, oldheight))
{
SysMessage("Failed to create device, exiting...");
exit(0);
}
}
for (int i = 0; i < 2; ++i)
{
vb[i].bNeedFrameCheck = vb[i].bNeedZCheck = 1;
vb[i].CheckFrame(0);
}
assert(vb[0].pBufferData != NULL && vb[1].pBufferData != NULL);
}
void ZeroGS::SetAA(int mode)
{
FUNCLOG
float f = 1.0f;
// need to flush all targets
s_RTs.ResolveAll();
s_RTs.Destroy();
s_DepthRTs.ResolveAll();
s_DepthRTs.Destroy();
AA.x = AA.y = 0; // This is code for x0, x2, x4, x8 and x16 anti-aliasing.
if (mode > 0)
{
// ( 1, 0 ) ; ( 1, 1 ) ; ( 2, 1 ) ; ( 2, 2 )
// it's used as a binary shift, so x >> AA.x, y >> AA.y
AA.x = (mode + 1) / 2;
AA.y = mode / 2;
f = 2.0f;
}
memset(s_nResolveCounts, 0, sizeof(s_nResolveCounts));
s_nLastResolveReset = 0;
vb[0].prndr = NULL;
vb[0].pdepth = NULL;
vb[1].prndr = NULL;
vb[1].pdepth = NULL;
vb[0].bNeedFrameCheck = vb[0].bNeedZCheck = 1;
vb[1].bNeedFrameCheck = vb[1].bNeedZCheck = 1;
glPointSize(f);
}
void ZeroGS::Prim()
{
FUNCLOG
VB& curvb = vb[prim->ctxt];
if (curvb.CheckPrim()) Flush(prim->ctxt);
curvb.curprim._val = prim->_val;
curvb.curprim.prim = prim->prim;
}
void ZeroGS::ProcessMessages()
{
FUNCLOG
if (listMsgs.size() > 0)
{
int left = 25, top = 15;
list<MESSAGE>::iterator it = listMsgs.begin();
while (it != listMsgs.end())
{
DrawText(it->str, left + 1, top + 1, 0xff000000);
DrawText(it->str, left, top, 0xffffff30);
top += 15;
if ((int)(it->dwTimeStamp - timeGetTime()) < 0)
it = listMsgs.erase(it);
else ++it;
}
}
}
void ZeroGS::RenderCustom(float fAlpha)
{
FUNCLOG
GL_REPORT_ERROR();
fAlpha = 1;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the backbuffer
DisableAllgl() ;
SetShaderCaller("RenderCustom");
glViewport(0, 0, nBackbufferWidth, nBackbufferHeight);
// play custom animation
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// tex coords
Vector v = Vector(1 / 32767.0f, 1 / 32767.0f, 0, 0);
ZZshSetParameter4fv(pvsBitBlt.sBitBltPos, v, "g_fBitBltPos");
v.x = (float)nLogoWidth;
v.y = (float)nLogoHeight;
ZZshSetParameter4fv(pvsBitBlt.sBitBltTex, v, "g_fBitBltTex");
v.x = v.y = v.z = v.w = fAlpha;
ZZshSetParameter4fv(ppsBaseTexture.sOneColor, v, "g_fOneColor");
if (conf.wireframe()) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// inside vhDCb[0]'s target area, so render that region only
ZZshGLSetTextureParameter(ppsBaseTexture.sFinal, ptexLogo, "Logo");
glBindBuffer(GL_ARRAY_BUFFER, vboRect);
SET_STREAM();
ZZshSetVertexShader(pvsBitBlt.prog);
ZZshSetPixelShader(ppsBaseTexture.prog);
DrawTriangleArray();
// restore
if (conf.wireframe()) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
ProcessMessages();
GLWin.SwapGLBuffers();
glEnable(GL_SCISSOR_TEST);
glEnable(GL_STENCIL_TEST);
vb[0].bSyncVars = 0;
vb[1].bSyncVars = 0;
GL_REPORT_ERROR();
}
//////////////////////////
// Internal Definitions //
//////////////////////////
__forceinline void MOVZ(VertexGPU *p, u32 gsz, const VB& curvb)
{
p->z = (curvb.zprimmask == 0xffff) ? min((u32)0xffff, gsz) : gsz;
}
__forceinline void MOVFOG(VertexGPU *p, Vertex gsf)
{
p->f = ((s16)(gsf).f << 7) | 0x7f;
}
int Values[100] = {0, };
void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
{
int index = Index;
p->x = ((((int)gs.gsvertex[index].x - curvb.offset.x) >> 1) & 0xffff);
p->y = ((((int)gs.gsvertex[index].y - curvb.offset.y) >> 1) & 0xffff);
p->f = ((s16)gs.gsvertex[index].f << 7) | 0x7f;
MOVZ(p, gs.gsvertex[index].z, curvb);
p->rgba = prim->iip ? gs.gsvertex[index].rgba : gs.rgba;
// This code is somehow incorrect
// if ((gs.texa.aem) && ((p->rgba & 0xffffff ) == 0))
// p->rgba = 0;
if (conf.settings().texa)
{
u32 B = ((p->rgba & 0xfe000000) >> 1) +
(0x01000000 * curvb.fba.fba) ;
p->rgba = (p->rgba & 0xffffff) + B;
}
if (prim->tme)
{
if (prim->fst)
{
p->s = (float)gs.gsvertex[index].u * fiTexWidth[prim->ctxt];
p->t = (float)gs.gsvertex[index].v * fiTexHeight[prim->ctxt];
p->q = 1;
}
else
{
p->s = gs.gsvertex[index].s;
p->t = gs.gsvertex[index].t;
p->q = gs.gsvertex[index].q;
}
}
}
static __forceinline void OUTPUT_VERT(VertexGPU vert, u32 id)
{
#ifdef WRITE_PRIM_LOGS
ZZLog::Prim_Log("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d), rgba=0x%8.8x, stq = (%2.5f,%2.5f,%2.5f)\n",
id == 0 ? '*' : ' ', id, prim->prim, vert.x / 8, vert.y / 8, vert.z, vert.f / 128,
vert.rgba, Clamp(vert.s, -10, 10), Clamp(vert.t, -10, 10), Clamp(vert.q, -10, 10));
#endif
}
void ZeroGS::KickPoint()
{
FUNCLOG
assert(gs.primC >= 1);
VB& curvb = vb[prim->ctxt];
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
assert(vb[prim->ctxt].nCount == 0);
Flush(!prim->ctxt);
}
curvb.NotifyWrite(1);
int last = gs.primNext(2);
VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], last, curvb);
curvb.nCount++;
OUTPUT_VERT(p[0], 0);
}
void ZeroGS::KickLine()
{
FUNCLOG
assert(gs.primC >= 2);
VB& curvb = vb[prim->ctxt];
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
assert(vb[prim->ctxt].nCount == 0);
Flush(!prim->ctxt);
}
curvb.NotifyWrite(2);
int next = gs.primNext();
int last = gs.primNext(2);
VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], next, curvb);
SET_VERTEX(&p[1], last, curvb);
curvb.nCount += 2;
OUTPUT_VERT(p[0], 0);
OUTPUT_VERT(p[1], 1);
}
void ZeroGS::KickTriangle()
{
FUNCLOG
assert(gs.primC >= 3);
VB& curvb = vb[prim->ctxt];
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
assert(vb[prim->ctxt].nCount == 0);
Flush(!prim->ctxt);
}
curvb.NotifyWrite(3);
VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], 0, curvb);
SET_VERTEX(&p[1], 1, curvb);
SET_VERTEX(&p[2], 2, curvb);
curvb.nCount += 3;
OUTPUT_VERT(p[0], 0);
OUTPUT_VERT(p[1], 1);
OUTPUT_VERT(p[2], 2);
}
void ZeroGS::KickTriangleFan()
{
FUNCLOG
assert(gs.primC >= 3);
VB& curvb = vb[prim->ctxt];
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
assert(vb[prim->ctxt].nCount == 0);
Flush(!prim->ctxt);
}
curvb.NotifyWrite(3);
VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], 0, curvb);
SET_VERTEX(&p[1], 1, curvb);
SET_VERTEX(&p[2], 2, curvb);
curvb.nCount += 3;
// add 1 to skip the first vertex
if (gs.primIndex == gs.nTriFanVert) gs.primIndex = gs.primNext();
OUTPUT_VERT(p[0], 0);
OUTPUT_VERT(p[1], 1);
OUTPUT_VERT(p[2], 2);
}
void SetKickVertex(VertexGPU *p, Vertex v, int next, const VB& curvb)
{
SET_VERTEX(p, next, curvb);
MOVZ(p, v.z, curvb);
MOVFOG(p, v);
}
void ZeroGS::KickSprite()
{
FUNCLOG
assert(gs.primC >= 2);
VB& curvb = vb[prim->ctxt];
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
assert(vb[prim->ctxt].nCount == 0);
Flush(!prim->ctxt);
}
curvb.NotifyWrite(6);
int next = gs.primNext();
int last = gs.primNext(2);
// sprite is too small and AA shows lines (tek4, Mana Khemia)
gs.gsvertex[last].x += (4 * AA.x);
gs.gsvertex[last].y += (4 * AA.y);
// might be bad sprite (KH dialog text)
//if( gs.gsvertex[next].x == gs.gsvertex[last].x || gs.gsvertex[next].y == gs.gsvertex[last].y )
//return;
VertexGPU* p = curvb.pBufferData + curvb.nCount;
SetKickVertex(&p[0], gs.gsvertex[last], next, curvb);
SetKickVertex(&p[3], gs.gsvertex[last], next, curvb);
SetKickVertex(&p[1], gs.gsvertex[last], last, curvb);
SetKickVertex(&p[4], gs.gsvertex[last], last, curvb);
SetKickVertex(&p[2], gs.gsvertex[last], next, curvb);
p[2].s = p[1].s;
p[2].x = p[1].x;
SetKickVertex(&p[5], gs.gsvertex[last], last, curvb);
p[5].s = p[0].s;
p[5].x = p[0].x;
curvb.nCount += 6;
OUTPUT_VERT(p[0], 0);
OUTPUT_VERT(p[1], 1);
}
void ZeroGS::KickDummy()
{
FUNCLOG
//ZZLog::Greg_Log("Kicking bad primitive: %.8x\n", *(u32*)prim);
}
void ZeroGS::SetFogColor(u32 fog)
{
FUNCLOG
// Always set the fog color, even if it was already set.
// if (gs.fogcol != fog)
// {
gs.fogcol = fog;
ZeroGS::FlushBoth();
SetShaderCaller("SetFogColor");
Vector v;
// set it immediately
v.SetColor(gs.fogcol);
ZZshSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
// }
}
void ZeroGS::SetFogColor(GIFRegFOGCOL* fog)
{
FUNCLOG
SetShaderCaller("SetFogColor");
Vector v;
v.x = fog->FCR / 255.0f;
v.y = fog->FCG / 255.0f;
v.z = fog->FCB / 255.0f;
ZZshSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
}
void ZeroGS::ExtWrite()
{
FUNCLOG
ZZLog::Warn_Log("A hollow voice says 'EXTWRITE'! Nothing happens.");
// use local DISPFB, EXTDATA, EXTBUF, and PMODE
// int bpp, start, end;
// tex0Info texframe;
// bpp = 4;
// if( texframe.psm == PSMT16S ) bpp = 3;
// else if (PSMT_ISHALF(texframe.psm)) bpp = 2;
//
// // get the start and end addresses of the buffer
// GetRectMemAddress(start, end, texframe.psm, 0, 0, texframe.tw, texframe.th, texframe.tbp0, texframe.tbw);
}
////////////
// Caches //
////////////
// case 0: return false;
// case 1: break;
// case 2: m_CBP[0] = TEX0.CBP; break;
// case 3: m_CBP[1] = TEX0.CBP; break;
// case 4: if(m_CBP[0] == TEX0.CBP) return false; m_CBP[0] = TEX0.CBP; break;
// case 5: if(m_CBP[1] == TEX0.CBP) return false; m_CBP[1] = TEX0.CBP; break;
// case 6: ASSERT(0); return false; // ffx2 menu
// case 7: ASSERT(0); return false;
// default: __assume(0);
bool IsDirty(u32 highdword, u32 psm, int cld, int cbp)
{
int cpsm = ZZOglGet_cpsm_TexBits(highdword);
int csm = ZZOglGet_csm_TexBits(highdword);
if (cpsm > 1 || csm)
{
// Mana Khemia triggers this.
//ZZLog::Error_Log("16 bit clut not supported.");
return true;
}
int csa = ZZOglGet_csa_TexBits(highdword);
int entries = PSMT_IS8CLUT(psm) ? 256 : 16;
u64* src = (u64*)(g_pbyGSMemory + cbp * 256);
u64* dst = (u64*)(g_pbyGSClut + 64 * csa);
bool bRet = false;
// do a fast test with MMX
#ifdef _MSC_VER
int storeebx;
__asm
{
mov storeebx, ebx
mov edx, dst
mov ecx, src
mov ebx, entries
Start:
movq mm0, [edx]
movq mm1, [edx+8]
pcmpeqd mm0, [ecx]
pcmpeqd mm1, [ecx+16]
movq mm2, [edx+16]
movq mm3, [edx+24]
pcmpeqd mm2, [ecx+32]
pcmpeqd mm3, [ecx+48]
pand mm0, mm1
pand mm2, mm3
movq mm4, [edx+32]
movq mm5, [edx+40]
pcmpeqd mm4, [ecx+8]
pcmpeqd mm5, [ecx+24]
pand mm0, mm2
pand mm4, mm5
movq mm6, [edx+48]
movq mm7, [edx+56]
pcmpeqd mm6, [ecx+40]
pcmpeqd mm7, [ecx+56]
pand mm0, mm4
pand mm6, mm7
pand mm0, mm6
pmovmskb eax, mm0
cmp eax, 0xff
je Continue
mov bRet, 1
jmp Return
Continue:
cmp ebx, 16
jle Return
test ebx, 0x10
jz AddEcx
sub ecx, 448 // go back and down one column,
AddEcx:
add ecx, 256 // go to the right block
jne Continue1
add ecx, 256 // skip whole block
Continue1:
add edx, 64
sub ebx, 16
jmp Start
Return:
emms
mov ebx, storeebx
}
#else // linux
// do a fast test with MMX
__asm__(
".intel_syntax\n"
"Start:\n"
"movq %%mm0, [%%ecx]\n"
"movq %%mm1, [%%ecx+8]\n"
"pcmpeqd %%mm0, [%%edx]\n"
"pcmpeqd %%mm1, [%%edx+16]\n"
"movq %%mm2, [%%ecx+16]\n"
"movq %%mm3, [%%ecx+24]\n"
"pcmpeqd %%mm2, [%%edx+32]\n"
"pcmpeqd %%mm3, [%%edx+48]\n"
"pand %%mm0, %%mm1\n"
"pand %%mm2, %%mm3\n"
"movq %%mm4, [%%ecx+32]\n"
"movq %%mm5, [%%ecx+40]\n"
"pcmpeqd %%mm4, [%%edx+8]\n"
"pcmpeqd %%mm5, [%%edx+24]\n"
"pand %%mm0, %%mm2\n"
"pand %%mm4, %%mm5\n"
"movq %%mm6, [%%ecx+48]\n"
"movq %%mm7, [%%ecx+56]\n"
"pcmpeqd %%mm6, [%%edx+40]\n"
"pcmpeqd %%mm7, [%%edx+56]\n"
"pand %%mm0, %%mm4\n"
"pand %%mm6, %%mm7\n"
"pand %%mm0, %%mm6\n"
"pmovmskb %%eax, %%mm0\n"
"cmp %%eax, 0xff\n"
"je Continue\n"
".att_syntax\n"
"movb $1, %0\n"
".intel_syntax\n"
"jmp Return\n"
"Continue:\n"
"cmp %%esi, 16\n"
"jle Return\n"
"test %%esi, 0x10\n"
"jz AddEcx\n"
"sub %%edx, 448\n" // go back and down one column
"AddEcx:\n"
"add %%edx, 256\n" // go to the right block
"cmp %%esi, 0x90\n"
"jne Continue1\n"
"add %%edx, 256\n" // skip whole block
"Continue1:\n"
"add %%ecx, 64\n"
"sub %%esi, 16\n"
"jmp Start\n"
"Return:\n"
"emms\n"
".att_syntax\n" : "=m"(bRet) : "c"(dst), "d"(src), "S"(entries) : "eax", "memory");
#endif // _WIN32
return bRet;
}
// cld state:
// 000 - clut data is not loaded; data in the temp buffer is stored
// 001 - clut data is always loaded.
// 010 - clut data is always loaded; cbp0 = cbp.
// 011 - clut data is always loadedl cbp1 = cbp.
// 100 - cbp0 is compared with cbp. if different, clut data is loaded.
// 101 - cbp1 is compared with cbp. if different, clut data is loaded.
// GSdx sets cbp0 & cbp1 when checking for clut changes. ZeroGS sets them in texClutWrite.
bool ZeroGS::CheckChangeInClut(u32 highdword, u32 psm)
{
FUNCLOG
int cld = ZZOglGet_cld_TexBits(highdword);
int cbp = ZZOglGet_cbp_TexBits(highdword);
// processing the CLUT after tex0/2 are written
//ZZLog::Error_Log("high == 0x%x; cld == %d", highdword, cld);
switch (cld)
{
case 0:
return false;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
if (gs.cbp[0] == cbp) return false;
break;
case 5:
if (gs.cbp[1] == cbp) return false;
break;
//case 4: return gs.cbp[0] != cbp;
//case 5: return gs.cbp[1] != cbp;
// default: load
default:
break;
}
return IsDirty(highdword, psm, cld, cbp);
}
void ZeroGS::texClutWrite(int ctx)
{
FUNCLOG
s_bTexFlush = false;
tex0Info& tex0 = vb[ctx].tex0;
assert(PSMT_ISCLUT(tex0.psm));
// processing the CLUT after tex0/2 are written
switch (tex0.cld)
{
case 0:
return;
case 1:
break; // tex0.cld is usually 1.
case 2:
gs.cbp[0] = tex0.cbp;
break;
case 3:
gs.cbp[1] = tex0.cbp;
break;
case 4:
if (gs.cbp[0] == tex0.cbp) return;
gs.cbp[0] = tex0.cbp;
break;
case 5:
if (gs.cbp[1] == tex0.cbp) return;
gs.cbp[1] = tex0.cbp;
break;
default: //ZZLog::Debug_Log("cld isn't 0-5!");
break;
}
Flush(!ctx);
int entries = PSMT_IS8CLUT(tex0.psm) ? 256 : 16;
if (tex0.csm)
{
switch (tex0.cpsm)
{
// 16bit psm
// eggomania uses non16bit textures for csm2
case PSMCT16:
{
u16* src = (u16*)g_pbyGSMemory + tex0.cbp * 128;
u16 *dst = (u16*)(g_pbyGSClut + 32 * (tex0.csa & 15) + (tex0.csa >= 16 ? 2 : 0));
for (int i = 0; i < entries; ++i)
{
*dst = src[getPixelAddress16_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst += 2;
// check for wrapping
if (((u32)(uptr)dst & 0x3ff) == 0) dst = (u16*)(g_pbyGSClut + 2);
}
break;
}
case PSMCT16S:
{
u16* src = (u16*)g_pbyGSMemory + tex0.cbp * 128;
u16 *dst = (u16*)(g_pbyGSClut + 32 * (tex0.csa & 15) + (tex0.csa >= 16 ? 2 : 0));
for (int i = 0; i < entries; ++i)
{
*dst = src[getPixelAddress16S_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst += 2;
// check for wrapping
if (((u32)(uptr)dst & 0x3ff) == 0) dst = (u16*)(g_pbyGSClut + 2);
}
break;
}
case PSMCT32:
case PSMCT24:
{
u32* src = (u32*)g_pbyGSMemory + tex0.cbp * 64;
u32 *dst = (u32*)(g_pbyGSClut + 64 * tex0.csa);
// check if address exceeds src
if (src + getPixelAddress32_0(gs.clut.cou + entries - 1, gs.clut.cov, gs.clut.cbw) >= (u32*)g_pbyGSMemory + 0x00100000)
ZZLog::Error_Log("texClutWrite out of bounds.");
else
for (int i = 0; i < entries; ++i)
{
*dst = src[getPixelAddress32_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst++;
}
break;
}
default:
{
//ZZLog::Debug_Log("Unknown cpsm: %x (%x).", tex0.cpsm, tex0.psm);
break;
}
}
}
else
{
u32* src = (u32*)(g_pbyGSMemory + 256 * tex0.cbp);
if (entries == 16)
{
switch (tex0.cpsm)
{
case PSMCT24:
case PSMCT32:
WriteCLUT_T32_I4_CSM1(src, (u32*)(g_pbyGSClut + 64 * tex0.csa));
break;
default:
WriteCLUT_T16_I4_CSM1(src, (u32*)(g_pbyGSClut + 32*(tex0.csa & 15) + (tex0.csa >= 16 ? 2 : 0)));
break;
}
}
else
{
switch (tex0.cpsm)
{
case PSMCT24:
case PSMCT32:
WriteCLUT_T32_I8_CSM1(src, (u32*)(g_pbyGSClut + 64 * tex0.csa));
break;
default:
// sse2 for 256 is more complicated, so use regular
WriteCLUT_T16_I8_CSM1_c(src, (u32*)(g_pbyGSClut + 32*(tex0.csa & 15) + (tex0.csa >= 16 ? 2 : 0)));
break;
}
}
}
}
| [
"koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5"
]
| [
[
[
1,
1189
]
]
]
|
c9cdd855618c425847be23dd6e3ba7203c61be00 | 0454def9ffc8db9884871a7bccbd7baa4322343b | /src/QUStringSupport.cpp | 82ac047487cee22ce5e4f22a6cdc8bbcfc27163a | []
| no_license | escaped/uman | e0187d1d78e2bb07dade7ef6ef041b6ed424a2d3 | bedc1c6c4fc464be4669f03abc9bac93e7e442b0 | refs/heads/master | 2016-09-05T19:26:36.679240 | 2010-07-26T07:55:31 | 2010-07-26T07:55:31 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,848 | cpp | #include "QUStringSupport.h"
#include <QRegExp>
QUStringSupport::QUStringSupport(QObject *parent): QObject(parent) {}
/*!
* Removes all characters of the given text that cannot be used in a file or
* directory name.
*
* Path separator '/' is not removed.
*
* \param text A single line of text without line breaks.
*/
QString QUStringSupport::withoutUnsupportedCharacters (const QString &text) {
QString cleanText = text;
#ifdef Q_OS_WIN32
cleanText.remove(QRegExp("[\\\\:\\*\\?\"\\|<>]"));
// remove trailing dots
bool dotsRemoved = false;
while(cleanText.endsWith(".")) {
dotsRemoved = true;
cleanText.chop(1);
}
while (cleanText.startsWith(".")) {
dotsRemoved = true;
cleanText.remove(0, 1);
}
if(dotsRemoved)
cleanText = cleanText.trimmed();
#endif
return cleanText;
}
QString QUStringSupport::withoutPathDelimiters(const QString &text) {
// return QString(text).remove("/");
return QString(text).replace("/", "-");
}
/*!
* Remove all "folder tags" like [SC], [VIDEO], a.s.o. from the given text.
*/
QString QUStringSupport::withoutFolderTags(const QString &text) {
QRegExp rx("\\[.*\\]");
rx.setMinimal(true);
return QString(text).remove(rx).trimmed();
}
/*!
* Remove all leading spaces and tabs.
*/
QString QUStringSupport::withoutLeadingBlanks(const QString &text) {
QString result = text;
while(result.startsWith(" "))
result.remove(0, 1);
while(result.startsWith("\t"))
result.remove(0, 1);
return result;
}
QString QUStringSupport::withoutAnyUmlaut(const QString &text) {
QString result = text;
result.replace("ä", "ae", Qt::CaseInsensitive);
result.replace("ö", "oe", Qt::CaseInsensitive);
result.replace("ü", "ue", Qt::CaseInsensitive);
result.replace("ß", "ss", Qt::CaseInsensitive);
return result;
}
QString QUStringSupport::withoutAnyUmlautEx(const QString &text) {
QString result = text;
result.replace("ä", "ae", Qt::CaseInsensitive);
result.replace("ö", "oe", Qt::CaseInsensitive);
result.replace("ü", "ue", Qt::CaseInsensitive);
result.replace("ß", "ss", Qt::CaseInsensitive);
result.replace("ô", "o", Qt::CaseInsensitive);
result.replace("é", "e", Qt::CaseInsensitive);
result.replace("è", "e", Qt::CaseInsensitive);
result.replace("_", " ");
result.replace("-", " ");
result.replace("~", " ");
result.replace("#", " ");
return result;
}
QStringList QUStringSupport::extractTags(const QString &text) {
QRegExp rx = QRegExp("\\[([^\\]]*)\\]");
QStringList tags;
int pos = 0;
while ((pos = rx.indexIn(text, pos)) != -1) {
tags << rx.cap(1).trimmed();
pos += rx.matchedLength();
}
if(text.contains("(kar)", Qt::CaseInsensitive))
tags << "kar";
return tags;
}
| [
"[email protected]"
]
| [
[
[
1,
114
]
]
]
|
b50cf457623d36d1549421c5b5fbaa4de5107a02 | 58ef4939342d5253f6fcb372c56513055d589eb8 | /ScheduleKiller/source/Model/src/SHModel.cpp | 98fd8033e6050b89609f33d53fb93d3f8afadc42 | []
| no_license | flaithbheartaigh/lemonplayer | 2d77869e4cf787acb0aef51341dc784b3cf626ba | ea22bc8679d4431460f714cd3476a32927c7080e | refs/heads/master | 2021-01-10T11:29:49.953139 | 2011-04-25T03:15:18 | 2011-04-25T03:15:18 | 50,263,327 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,235 | cpp | /*
============================================================================
Name : SHModel.cpp
Author : zengcity
Version : 1.0
Copyright : Your copyright notice
Description : CSHModel implementation
============================================================================
*/
#include "SHModel.h"
#include "MacroUtil.h"
CSHModel::CSHModel()
{
// No implementation required
}
CSHModel::~CSHModel()
{
SAFE_DELETE(iRule)
SAFE_DELETE_ACTIVE(iTimeWork)
SAFE_DELETE(iRuleManager)
SAFE_DELETE(iTaskInfoManager)
}
CSHModel* CSHModel::NewLC()
{
CSHModel* self = new (ELeave) CSHModel();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CSHModel* CSHModel::NewL()
{
CSHModel* self = CSHModel::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CSHModel::ConstructL()
{
iRuleManager = CRuleManager::NewL();
iTimeWork = CTimeWorkManager::NewL();
iRule = CRule::NewL();
iTaskInfoManager = CTaskInfoManager::NewL();
}
void CSHModel::SetRule(const TInt& aType,const TInt& aCountdown,const TTime& aClock)
{
if (iRule)
{
iRule->SetType(aType);
iRule->SetCountDown(aCountdown);
iRule->SetClock(aClock);
}
}
| [
"zengcity@415e30b0-1e86-11de-9c9a-2d325a3e6494"
]
| [
[
[
1,
58
]
]
]
|
917b69cace976894df4668ee03ffe253e1432e18 | b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a | /Code/TootleFilesys/TLFile.cpp | b1a8ce62eadbd1f982acb0457f1c301fbe78b82c | []
| no_license | SoylentGraham/Tootle | 4ae4e8352f3e778e3743e9167e9b59664d83b9cb | 17002da0936a7af1f9b8d1699d6f3e41bab05137 | refs/heads/master | 2021-01-24T22:44:04.484538 | 2010-11-03T22:53:17 | 2010-11-03T22:53:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,633 | cpp | #include "TLFile.h"
#include <TootleCore/TBinaryTree.h>
#include <TootleCore/TAxisAngle.h>
#include <TootleCore/TEuler.h>
#include <TootleCore/TQuaternion.h>
#include <TootleCore/TMatrix.h>
#include <TootleCore/TLUnitTest.h>
#include <TootleCore/TColour.h>
#include <TootleCore/TRef.h>
namespace TLBinary
{
template<typename TYPE>
bool Debug_CheckImportExport(const TYPE& That);
}
//---------------------------------------------
// test that the literal data types match with the typed ones
// can we put this into the declaration macro?
//---------------------------------------------
TEST(TBinary_Types)
{
// not sure how these could be wrong...
CHECK( TLBinary::GetDataTypeRef<TRef>() == TLBinary_TypeRef(TRef) );
CHECK( TLBinary::GetDataTypeRef<Bool>() == TLBinary_TypeRef(Bool) );
CHECK( TLBinary::GetDataTypeRef<float>() == TLBinary_TypeRef(float) );
}
//---------------------------------------------
//---------------------------------------------
template<typename TYPE>
bool TLBinary::Debug_CheckImportExport(const TYPE& That)
{
// check it matches the expected hint type
TRef ExpectedHintType = TLBinary::GetDataTypeRef<TYPE>();
if ( !ExpectedHintType.IsValid() )
{
TLDebug_Print("Failed to calculate the TYPE's hint.");
return false;
}
// write the variable out to the binary
TBinary b;
b.Write( That );
b.ResetReadPos();
// make sure the type hint is correct
if ( b.GetDataTypeHint() != ExpectedHintType )
{
TDebugString Debug_String;
Debug_String << "Binary failed to set data type hint " << ExpectedHintType << ". Instead determined type: " << b.GetDataTypeHint();
return false;
}
// if this doesn't return true then this type's not yet supported
TString s1;
if ( !TLFile::ExportBinaryData( s1, b ) )
{
TDebugString Debug_String;
Debug_String << "Export of " << TLBinary::GetDataTypeRef<TYPE>() << " not yet supported";
TLDebug_Print( Debug_String );
return true;
}
// do another export and ensure they match up
// if this fails due to string length, then just increase the buffer size
TBufferString<4000> s2;
if ( !TLFile::ExportBinaryData( s2, b ) )
{
TDebugString Debug_String;
Debug_String << "Export of " << TLBinary::GetDataTypeRef<TYPE>() << " failed 2nd time.";
TLDebug_Print( Debug_String );
CHECK(false);
return false;
}
// now re-import the string
TBinary b2;
if ( TLFile::ImportBinaryData( s1, b2, ExpectedHintType ) != SyncTrue )
{
TDebugString Debug_String;
Debug_String << "Exported string (\"" << s1 << "\") of data type " << TLBinary::GetDataTypeRef<TYPE>() << " failed to re-import";
TLDebug_Print( Debug_String );
return false;
}
// now make sure the binary data matches up
// gr: todo
return true;
}
//---------------------------------------------
// that that the binary import/export values match up
//---------------------------------------------
TEST(TBinary_ImportExport)
{
CHECK( TLBinary::Debug_CheckImportExport<bool>(true) );
CHECK( TLBinary::Debug_CheckImportExport( 12.34f ) );
CHECK( TLBinary::Debug_CheckImportExport<u8>( 255 ) );
CHECK( TLBinary::Debug_CheckImportExport<u16>( 1024 ) );
CHECK( TLBinary::Debug_CheckImportExport<u32>( 50000 ) );
CHECK( TLBinary::Debug_CheckImportExport<s16>( -300 ) );
CHECK( TLBinary::Debug_CheckImportExport<s32>( -50000 ) );
TRef Hello = "Hello";
CHECK( TLBinary::Debug_CheckImportExport( Hello ) );
}
//--------------------------------------------------------
//
//--------------------------------------------------------
template<typename TYPE>
SyncBool ImportBinaryDataIntegerInRange(TBinary& Data,const TString& DataString)
{
s32 Min = TLTypes::GetIntegerMin<TYPE>();
u32 Max = TLTypes::GetIntegerMax<TYPE>(); // gr: note, we lose the max for u32 here, but assume that will never be a problem...
THeapArray<s32> Integers;
if ( !DataString.GetIntegers( Integers ) )
return SyncFalse;
// make sure they're in range
for ( u32 i=0; i<Integers.GetSize(); i++ )
{
const s32& Integer = Integers[i];
if ( !TLDebug_CheckInRange( Integer, Min, (u32)Max ) )
return SyncFalse;
}
// no integers found...
if ( Integers.GetSize() == 0 )
return SyncFalse;
// single value, just write it
if ( Integers.GetSize() == 1 )
{
Data.Write( (TYPE)Integers[0] );
return SyncTrue;
}
// array. have to convert to type to write properly
THeapArray<TYPE> TypeIntegers;
TypeIntegers.Copy( Integers );
Data.WriteArray( TypeIntegers );
return SyncTrue;
}
//--------------------------------------------------------
//
//--------------------------------------------------------
Bool TLString::ReadNextLetter(const TString& String,u32& CharIndex, TChar& Char)
{
// step over whitespace
s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );
if ( NonWhitespaceIndex == -1 )
return FALSE;
// move char past whitespace
CharIndex = (u32)NonWhitespaceIndex;
const TChar& NextChar = String.GetCharAt(CharIndex);
// is next char a letter?
if ( TLString::IsCharLetter( NextChar ) )
{
Char = NextChar;
// move string past this letter for next thing
CharIndex++;
return TRUE;
}
else
{
// not a char, could be a number or summink
return FALSE;
}
}
//--------------------------------------------------------
//
//--------------------------------------------------------
Bool TLString::ReadNextInteger(const TString& String,u32& CharIndex,s32& Integer)
{
// step over whitespace
s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );
// no more non-whitespace? no more data then
if ( NonWhitespaceIndex == -1 )
return FALSE;
// move char past whitespace
CharIndex = (u32)NonWhitespaceIndex;
s32 NextComma = String.GetCharIndex(',', CharIndex);
s32 NextWhitespace = String.GetCharIndexWhitespace( CharIndex );
s32 NextSplit = String.GetLength();
if ( NextComma != -1 && NextComma < NextSplit )
NextSplit = NextComma;
if ( NextWhitespace != -1 && NextWhitespace < NextSplit )
NextSplit = NextWhitespace;
// split
TTempString StringValue;
StringValue.Append( String, CharIndex, NextSplit-CharIndex );
if ( !StringValue.GetInteger( Integer ) )
{
TLDebug_Break("Failed to parse integer from string");
return FALSE;
}
// move string along past split
CharIndex = NextSplit+1;
// out of string
if ( CharIndex >= String.GetLength() )
CharIndex = String.GetLength();
return TRUE;
}
//--------------------------------------------------------
// reads an integer out of a string, and does a min/max CheckInRange check.
// returns FALSE if out of range (in debug only, uses TLDebug_CHeckInRange)
//--------------------------------------------------------
Bool TLString::ReadIntegerInRange(const TString& String,s32& Integer,s32 Min,s32 Max)
{
if ( !String.GetInteger( Integer ) )
return FALSE;
if ( !TLDebug_CheckInRange( Integer, Min, Max ) )
return FALSE;
return TRUE;
}
//--------------------------------------------------------
//
//--------------------------------------------------------
Bool TLString::ReadNextFloatArray(const TString& String,u32& CharIndex,float* pFloats,u32 FloatSize,Bool ReturnInvalidFloatZero)
{
// loop through parsing seperators and floats
u32 FloatIndex = 0;
while ( FloatIndex < FloatSize )
{
// step over whitespace
s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );
// no more non-whitespace? no more floats then
if ( NonWhitespaceIndex == -1 )
return FALSE;
// move char past whitespace
CharIndex = (u32)NonWhitespaceIndex;
s32 NextComma = String.GetCharIndex(',', CharIndex);
s32 NextWhitespace = String.GetCharIndexWhitespace( CharIndex );
s32 NextSplit = String.GetLength();
if ( NextComma != -1 && NextComma < NextSplit )
NextSplit = NextComma;
if ( NextWhitespace != -1 && NextWhitespace < NextSplit )
NextSplit = NextWhitespace;
// split
TTempString Stringf;
Stringf.Append( String, CharIndex, NextSplit-CharIndex );
if ( !Stringf.GetFloat( pFloats[FloatIndex] ) )
{
// gr: this is a work around when processing floats but encounter invalid floats in strings... say 1.1e07 (invalid floats from outputter)
if ( ReturnInvalidFloatZero )
{
pFloats[FloatIndex] = 0.f;
}
else
{
TLDebug_Break("Failed to parse first float");
return FALSE;
}
}
// next float
FloatIndex++;
// move string along past split
CharIndex = NextSplit+1;
// out of string
if ( CharIndex >= String.GetLength() )
{
CharIndex = String.GetLength();
break;
}
}
return TRUE;
}
TRef TLFile::GetDataTypeFromString(const TString& String)
{
// turn string into a ref and check against the ref types...
TRef StringRef( String );
// add "tootle data xml" supported types to this case statement
switch ( StringRef.GetData() )
{
case TLBinary_TypeRef(TRef):
case TLBinary_TypeRef(Bool):
case TLBinary_TypeRef(float):
case TLBinary_TypeRef(float2):
case TLBinary_TypeRef(float3):
case TLBinary_TypeRef(float4):
case TLBinary_TypeRef(u8):
case TLBinary_TypeRef(u16):
case TLBinary_TypeRef(u32):
case TLBinary_TypeRef(u64):
case TLBinary_TypeRef(s8):
case TLBinary_TypeRef(s16):
case TLBinary_TypeRef(s32):
case TLBinary_TypeRef(s64):
case TLBinary_TypeRef_Hex8:
case TLBinary_TypeRef_Hex16:
case TLBinary_TypeRef_Hex32:
case TLBinary_TypeRef_Hex64:
case TLBinary_TypeRef(TQuaternion):
case TLBinary_TypeRef(TEuler):
case TLBinary_TypeRef(TAxisAngle):
case TLBinary_TypeRef(TColour):
case TLBinary_TypeRef(TColour24):
case TLBinary_TypeRef(TColour32):
case TLBinary_TypeRef(TColour64):
case TLBinary_TypeRef_String:
case TLBinary_TypeRef_WideString:
{
// matches an existing data type ref
return StringRef;
}
break;
default:
break;
};
#ifdef _DEBUG
TTempString Debug_String("Warning: using old data type name ");
Debug_String.Append( String );
TLDebug_Print( Debug_String );
#endif
// old string -> type detection
if ( String == "float" ) return TLBinary::GetDataTypeRef<float>();
if ( String == "float2" ) return TLBinary::GetDataTypeRef<float2>();
if ( String == "float3" ) return TLBinary::GetDataTypeRef<float3>();
if ( String == "float4" ) return TLBinary::GetDataTypeRef<float4>();
if ( String == "quaternion" ) return TLBinary::GetDataTypeRef<TLMaths::TQuaternion>();
if ( String == "colour" ) return TLBinary::GetDataTypeRef<TColour>();
// unknown type
#ifdef _DEBUG
Debug_String.Set("Unsupported data type ");
Debug_String.Append( String );
TLDebug_Break( Debug_String );
#endif
return TRef_Invalid;
}
template<typename TYPE>
bool AppendBinaryDataToString(TString& String,const TBinary& BinaryData)
{
const TYPE* pData = BinaryData.Get<TYPE>();
if ( !pData )
return false;
String << ( *pData );
return true;
}
bool TLFile::ExportBinaryData(TString& String,const TBinary& BinaryData)
{
// based on the type, turn the data [back] into a string in the same format that we import with
TRefRef BinaryDataType = BinaryData.GetDataTypeHint();
#define case_ExportBinaryData(PodType) \
case TLBinary_TypeRef(PodType): return AppendBinaryDataToString<PodType>( String, BinaryData ); \
case TLBinary_TypeNRef(Type2,PodType): return AppendBinaryDataToString<Type2<PodType> >( String, BinaryData ); \
case TLBinary_TypeNRef(Type3,PodType): return AppendBinaryDataToString<Type3<PodType> >( String, BinaryData ); \
case TLBinary_TypeNRef(Type4,PodType): return AppendBinaryDataToString<Type4<PodType> >( String, BinaryData );
switch ( BinaryDataType.GetData() )
{
case_ExportBinaryData(TRef);
case_ExportBinaryData(float);
case_ExportBinaryData(u8);
case_ExportBinaryData(u16);
case_ExportBinaryData(u32);
case_ExportBinaryData(s8);
case_ExportBinaryData(s16);
case_ExportBinaryData(s32);
case_ExportBinaryData(Bool);
}
#undef case_ExportBinaryData
String << "(???)";
return SyncTrue;
}
//--------------------------------------------------------
//
//--------------------------------------------------------
SyncBool TLFile::ImportBinaryData(const TString& DataString,TBinary& BinaryData,TRef DataType)
{
/*
// work out the type of data
TRefRef BinaryDataType = BinaryData.GetDataTypeHint();
// check for conflicting type hints
if ( DataType.IsValid() && BinaryDataType.IsValid() && DataType != BinaryDataType )
{
TDebugString Debug_String;
Debug_String << "Data import type hint mismatch; Tried to import as " << DataType << " but binary says it's " << BinaryDataType;
TLDebug_Break( Debug_String );
// fall through to use the data type embedded in the binary data
DataType = BinaryDataType;
}
else if ( BinaryDataType.IsValid() && !DataType.IsValid() )
{
// use the type specified in the binary
DataType = BinaryDataType;
}
*/
// import the data based on the type
u32 CharIndex = 0;
switch ( DataType.GetData() )
{
case TLBinary_TypeRef(float):
{
float f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, &f, 1 ) )
return SyncFalse;
BinaryData.Write( f );
return SyncTrue;
}
case TLBinary_TypeRef(float2):
{
float2 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
BinaryData.Write( f );
return SyncTrue;
}
case TLBinary_TypeRef(float3):
{
float3 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
BinaryData.Write( f );
return SyncTrue;
}
case TLBinary_TypeRef(float4):
{
float4 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
BinaryData.Write( f );
return SyncTrue;
}
case TLBinary_TypeRef(TQuaternion):
{
float4 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
// convert to normalised quaternion
TLMaths::TQuaternion Quat( f );
Quat.Normalise();
BinaryData.Write( Quat );
return SyncTrue;
}
case TLBinary_TypeRef(TEuler):
{
float3 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
// convert to Euler type
TLMaths::TEuler Euler( f );
BinaryData.Write( Euler );
return SyncTrue;
}
case TLBinary_TypeRef(TAxisAngle):
{
float4 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
// convert to normalised quaternion
TLMaths::TAxisAngle AxisAngle( f );
BinaryData.Write( AxisAngle );
return SyncTrue;
}
case TLBinary_TypeRef(TRef):
{
TRef Ref( DataString );
BinaryData.Write( Ref );
return SyncTrue;
}
case TLBinary_TypeRef_String:
{
// do string cleanup, convert "\n" to a linefeed etc
if ( TLString::IsStringDirty( DataString ) )
{
TString OutputString = DataString;
TLString::CleanString( OutputString );
BinaryData.WriteString( OutputString );
}
else
{
// already clean, just write the original
BinaryData.WriteString( DataString );
}
return SyncTrue;
}
case TLBinary_TypeRef(TColour):
{
float4 f;
if ( !TLString::ReadNextFloatArray( DataString, CharIndex, f.GetData(), f.GetSize() ) )
return SyncFalse;
// check range
// gr: use TLDebug_CheckInRange() ?
if ( f.x > 1.0f || f.x < 0.0f ||
f.y > 1.0f || f.y < 0.0f ||
f.z > 1.0f || f.z < 0.0f ||
f.w > 1.0f || f.w < 0.0f )
{
if ( !TLDebug_Break( TString("Colour float type has components out of range (0..1); %.3f,%.3f,%.3f,%.3f", f.x, f.y, f.z, f.w) ) )
return SyncFalse;
}
TColour Colour( f );
BinaryData.Write( Colour );
return SyncTrue;
}
case TLBinary_TypeRef(TColour24):
{
Type3<s32> Colours;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) ) return SyncFalse;
// check range
// gr: use TLDebug_CheckInRange() ?
if ( Colours.x > 255 || Colours.x < 0 ||
Colours.y > 255 || Colours.y < 0 ||
Colours.z > 255 || Colours.z < 0 )
{
if ( !TLDebug_Break( TString("Colour24 type has components out of range (0..255); %d,%d,%d", Colours.x, Colours.y, Colours.z ) ) )
return SyncFalse;
}
TColour24 Colour( Colours.x, Colours.y, Colours.z );
BinaryData.Write( Colour );
return SyncTrue;
}
case TLBinary_TypeRef(TColour32):
{
Type4<s32> Colours;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.w ) ) return SyncFalse;
// check range
// gr: use TLDebug_CheckInRange() ?
if ( Colours.x > 255 || Colours.x < 0 ||
Colours.y > 255 || Colours.y < 0 ||
Colours.z > 255 || Colours.z < 0 ||
Colours.w > 255 || Colours.w < 0 )
{
if ( !TLDebug_Break( TString("Colour32 type has components out of range (0..255); %d,%d,%d,%d", Colours.x, Colours.y, Colours.z, Colours.w ) ) )
return SyncFalse;
}
TColour32 Colour( Colours.x, Colours.y, Colours.z, Colours.w );
BinaryData.Write( Colour );
return SyncTrue;
}
case TLBinary_TypeRef(TColour64):
{
Type4<s32> Colours;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.w ) ) return SyncFalse;
// check range
// gr: use TLDebug_CheckInRange() ?
if ( Colours.x > 65535 || Colours.x < 0 ||
Colours.y > 65535 || Colours.y < 0 ||
Colours.z > 65535 || Colours.z < 0 ||
Colours.w > 65535 || Colours.w < 0 )
{
if ( !TLDebug_Break( TString("Colour64 type has components out of range (0..65535); %d,%d,%d,%d", Colours.x, Colours.y, Colours.z, Colours.w ) ) )
return SyncFalse;
}
TColour64 Colour( Colours.x, Colours.y, Colours.z, Colours.w );
BinaryData.Write( Colour );
return SyncTrue;
}
case TLBinary_TypeRef(u8):
return ImportBinaryDataIntegerInRange<u8>( BinaryData, DataString );
case TLBinary_TypeRef(s8):
return ImportBinaryDataIntegerInRange<s8>( BinaryData, DataString );
case TLBinary_TypeRef(u16):
return ImportBinaryDataIntegerInRange<u16>( BinaryData, DataString );
case TLBinary_TypeRef(s16):
return ImportBinaryDataIntegerInRange<s16>( BinaryData, DataString );
case TLBinary_TypeRef(u32):
return ImportBinaryDataIntegerInRange<u32>( BinaryData, DataString );
case TLBinary_TypeRef(s32):
return ImportBinaryDataIntegerInRange<s32>( BinaryData, DataString );
case TLBinary_TypeRef(Bool):
{
// read first char, we can work out true/false/0/1 from that
if ( DataString.GetLength() == 0 )
return SyncFalse;
const TChar& BoolChar = DataString.GetCharAt(0);
if ( BoolChar == 't' || BoolChar == 'T' || BoolChar == '1' )
{
BinaryData.Write( (Bool)TRUE );
return SyncTrue;
}
else if ( BoolChar == 'f' || BoolChar == 'F' || BoolChar == '0' )
{
BinaryData.Write( (Bool)FALSE );
return SyncTrue;
}
else
{
TLDebug_Break("Bool data is not True,False,0 or 1");
return SyncFalse;
}
}
default:
break;
};
TDebugString Debug_String;
Debug_String << "Unsupported/todo data type " << DataType << ". Data string: [" << DataString << "]";
TLDebug_Break( Debug_String );
return SyncFalse;
}
//--------------------------------------------------------
// parse XML tag to Binary data[tree]
//--------------------------------------------------------
Bool TLFile::ParseXMLDataTree(TXmlTag& Tag,TBinaryTree& Data)
{
/*
XML examples
// root data
<Data><u32>100</u32></Data>
// put in "translate" child
<Data DataRef="translate"><float3>0,40,0</float3></Data>
// "Node" data inside "NodeList" data
<Data DataRef="NodeList">
<Bool>TRUE</Bool> // written to "NodeList"
<Data DataRef="Node"><TRef>ohai</TRef></Data>
</Data>
*/
// read the data ref
const TString* pDataRefString = Tag.GetProperty("DataRef");
TRef DataRef( pDataRefString ? *pDataRefString : "" );
// establish the data we're writing data to
TPtr<TBinaryTree> pDataChild;
// add a child to the node data if it has a ref, otherwise data is added to root of the node
if ( DataRef.IsValid() )
{
pDataChild = Data.AddChild( DataRef );
// failed to add child data...
if ( !pDataChild )
{
TLDebug_Break("failed to add child data");
return FALSE;
}
}
// import contents of data
TBinaryTree& NodeData = pDataChild ? *pDataChild.GetObjectPointer() : Data;
// if the tag has no children (eg. type like <float />) but DOES have data (eg. 1.0) throw up an error and fail
// assume the data is malformed and someone has forgotten to add the type specifier.
// if something automated has output it and doesnt know the type it should still output it as hex raw data
if ( !Tag.GetChildren().GetSize() && Tag.GetDataString().GetLength() > 0 )
{
TTempString Debug_String("<Data ");
DataRef.GetString( Debug_String );
Debug_String.Append("> tag with no children, but DOES have data inside (eg. 1.0). Missing type specifier? (eg. <flt3>)\n");
Debug_String.Append( Tag.GetDataString() );
TLDebug_Break( Debug_String );
return SyncFalse;
}
// deal with child tags
for ( u32 c=0; c<Tag.GetChildren().GetSize(); c++ )
{
TPtr<TXmlTag>& pChildTag = Tag.GetChildren().ElementAt(c);
SyncBool TagImportResult = SyncFalse;
if ( pChildTag->GetTagName() == "data" )
{
// import child data
if ( ParseXMLDataTree( *pChildTag, NodeData ) )
TagImportResult = SyncTrue;
else
TagImportResult = SyncFalse;
if ( TagImportResult != SyncTrue )
Data.Debug_PrintTree();
}
else
{
TRef DataTypeRef = TLFile::GetDataTypeFromString( pChildTag->GetTagName() );
// update type of data
// gr: DONT do this, if the type is mixed, this overwrites it. Setting the DataTypeHint should be automaticly done when we Write() in ImportBinaryData
//NodeData.SetDataTypeHint( DataTypeRef );
TagImportResult = TLFile::ImportBinaryData( pChildTag->GetDataString(), NodeData, DataTypeRef );
// gr: just to check the data hint is being set from the above function...
if ( TagImportResult == SyncTrue && !NodeData.GetDataTypeHint().IsValid() && NodeData.GetSize() > 0 )
{
TTempString Debug_String("Data imported is missing data type hint after successfull write? We just wrote data type ");
DataTypeRef.GetString( Debug_String );
Debug_String.Append(". This can be ignored if the data is mixed types");
TLDebug_Break( Debug_String );
Data.Debug_PrintTree();
}
}
// failed
if ( TagImportResult == SyncFalse )
{
TTempString str;
str << "failed to import <data> tag \"" << pChildTag->GetTagName() << "\"";
TLDebug_Break( str );
return FALSE;
}
// async is unsupported
if ( TagImportResult == SyncWait )
{
TLDebug_Break("todo: async Scheme import");
return FALSE;
}
}
return TRUE;
}
//--------------------------------------------------------
// check if string marked as a datum
//--------------------------------------------------------
Bool TLString::IsDatumString(const TString& String,TRef& DatumRef,TRef& ShapeType,Bool& IsJustDatum)
{
// split the string - max at 4 splits
TFixedArray<TStringLowercase<TTempString>, 4> StringParts;
if ( !String.Split( '_', StringParts ) )
{
// didn't split at all, can't be valid
return FALSE;
}
// if it splits 4 times, there's too many parts
if ( StringParts.GetSize() >= 4 )
return false;
// check first part is named "datum"
if ( StringParts[0] == "datum" )
{
// just a datum
IsJustDatum = TRUE;
}
else if ( StringParts[0] == "anddatum" )
{
// not just a datum
IsJustDatum = FALSE;
}
else
{
// no kinda datum
return FALSE;
}
// should be 3 parts
if ( StringParts.GetSize() != 3 )
{
TLDebug_Break( TString("Malformed Datum name (%s) on SVG geometry. Should be Datum_SHAPEREF_DATUMREF", String.GetData() ) );
return FALSE;
}
// make shape ref from 2nd string
ShapeType.Set( StringParts[1] );
DatumRef.Set( StringParts[2] );
// if either are invalid, fail
if ( !ShapeType.IsValid() || !DatumRef.IsValid() )
{
TLDebug_Break( TString("Failed to set valid Ref's from Datum identifier: %s", String.GetData() ) );
return FALSE;
}
return TRUE;
}
//--------------------------------------------------------
// cleanup string. Convert "\n" to a linefeed, convert tabs, do other generic string-replace's etc, returns if any changes are made
//--------------------------------------------------------
Bool TLString::CleanString(TString& String)
{
Bool Changes = FALSE;
TArray<TChar>& StringCharArray = String.GetStringArray();
// run through the string until we find something we might want to change
for ( u32 i=0; i<StringCharArray.GetSize(); i++ )
{
char Prevc = (i==0) ? 0 : StringCharArray.ElementAt(i-1);
TChar& c = StringCharArray.ElementAt(i);
Bool IsLast = (i==StringCharArray.GetLastIndex());
// it's a slash, check the next control char - but ignore if previous char was also a slash
if ( c == '\\' && !IsLast && Prevc != '\\' )
{
TChar& Nextc = StringCharArray.ElementAt(i+1);
// line feed, replace the 2 characters with one line feed
if ( Nextc == 'n' || Nextc == 'N' )
{
c = '\n';
StringCharArray.RemoveAt(i+1);
Changes = TRUE;
continue;
}
}
}
return Changes;
}
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
1
],
[
3,
6
],
[
113,
113
],
[
154,
157
],
[
159,
166
],
[
168,
189
],
[
191,
193
],
[
196,
203
],
[
205,
205
],
[
210,
210
],
[
215,
215
],
[
217,
219
],
[
222,
222
],
[
226,
230
],
[
246,
248
],
[
250,
278
],
[
289,
315
],
[
319,
319
],
[
363,
384
],
[
386,
388
],
[
430,
432
],
[
434,
434
],
[
457,
457
],
[
461,
467
],
[
470,
476
],
[
479,
485
],
[
488,
494
],
[
510,
519
],
[
522,
531
],
[
534,
538
],
[
541,
541
],
[
555,
556
],
[
559,
564
],
[
566,
578
],
[
649,
649
],
[
698,
702
],
[
746,
746
]
],
[
[
2,
2
],
[
7,
112
],
[
114,
153
],
[
158,
158
],
[
167,
167
],
[
190,
190
],
[
194,
195
],
[
204,
204
],
[
206,
209
],
[
211,
214
],
[
216,
216
],
[
220,
221
],
[
223,
225
],
[
231,
245
],
[
249,
249
],
[
279,
288
],
[
316,
318
],
[
320,
362
],
[
385,
385
],
[
389,
429
],
[
433,
433
],
[
435,
456
],
[
458,
460
],
[
468,
469
],
[
477,
478
],
[
486,
487
],
[
495,
509
],
[
520,
521
],
[
532,
533
],
[
539,
540
],
[
542,
554
],
[
557,
558
],
[
565,
565
],
[
579,
648
],
[
650,
697
],
[
703,
745
],
[
747,
911
]
]
]
|
8f426bb4db3126330fa140ad8e1330353390954d | f177993b13e97f9fecfc0e751602153824dfef7e | /ImProSln/MyLib/CMuxTransformFilter.h | 55e383df9aa246c92c7d3e4ffefe5f599c074841 | []
| no_license | svn2github/imtophooksln | 7bd7412947d6368ce394810f479ebab1557ef356 | bacd7f29002135806d0f5047ae47cbad4c03f90e | refs/heads/master | 2020-05-20T04:00:56.564124 | 2010-09-24T09:10:51 | 2010-09-24T09:10:51 | 11,787,598 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,065 | h | #pragma once
#include "dshow.h"
#include "Streams.h"
#include <initguid.h>
#include "combase.h"
#include <vector>
#include "D3DBaseFilter.h"
using namespace std;
class CMuxTransformFilter;
class CMuxTransformInputPin : public CBaseInputPin, public D3DBaseInputPin
{
friend class CMuxTransformFilter;
public:
bool m_bVisible;
protected:
CMuxTransformFilter *m_pTransformFilter;
public:
// override to expose IDXBasePin
DECLARE_IUNKNOWN
virtual STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
CMuxTransformInputPin(
__in_opt LPCTSTR pObjectName,
__inout CMuxTransformFilter *pTransformFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pName);
#ifdef UNICODE
CMuxTransformInputPin(
__in_opt LPCSTR pObjectName,
__inout CMuxTransformFilter *pTransformFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pName);
#endif
virtual ~CMuxTransformInputPin();
virtual STDMETHODIMP QueryId(__deref_out LPWSTR * Id)
{
return AMGetWideString(m_pName, Id);
}
// Grab and release extra interfaces if required
virtual HRESULT CheckConnect(IPin *pPin);
virtual HRESULT BreakConnect();
virtual HRESULT CompleteConnect(IPin *pReceivePin);
// check that we can support this output type
virtual HRESULT CheckMediaType(const CMediaType* mtIn);
// set the connection media type
virtual HRESULT SetMediaType(const CMediaType* mt);
// --- IMemInputPin -----
// here's the next block of data from the stream.
// AddRef it yourself if you need to hold it beyond the end
// of this call.
virtual STDMETHODIMP Receive(IMediaSample * pSample);
// provide EndOfStream that passes straight downstream
// (there is no queued data)
virtual STDMETHODIMP EndOfStream(void);
// passes it to CTransformFilter::BeginFlush
virtual STDMETHODIMP BeginFlush(void);
// passes it to CTransformFilter::EndFlush
virtual STDMETHODIMP EndFlush(void);
virtual STDMETHODIMP NewSegment(
REFERENCE_TIME tStart,
REFERENCE_TIME tStop,
double dRate);
// Check if it's OK to process samples
virtual HRESULT CheckStreaming();
// Media type
public:
virtual CMediaType& CurrentMediaType() { return m_mt; };
virtual HRESULT GetD3DFilter(IDXBaseFilter*& pFilter);
virtual HRESULT GetConnectedPin(IPin*& pPin);
};
class CMuxTransformOutputPin : public CBaseOutputPin, public D3DBaseOutputPin
{
friend class CMuxTransformFilter;
public:
bool m_bVisible;
protected:
CMuxTransformFilter *m_pTransformFilter;
public:
// implement IMediaPosition by passing upstream
IUnknown * m_pPosition;
CMuxTransformOutputPin(
__in_opt LPCTSTR pObjectName,
__inout CMuxTransformFilter *pTransformFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pName);
#ifdef UNICODE
CMuxTransformOutputPin(
__in_opt LPCSTR pObjectName,
__inout CMuxTransformFilter *pTransformFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pName);
#endif
virtual ~CMuxTransformOutputPin();
DECLARE_IUNKNOWN;
// override to expose IMediaPosition
virtual STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// --- CBaseOutputPin ------------
virtual STDMETHODIMP QueryId(__deref_out LPWSTR * Id)
{
return AMGetWideString(m_pName, Id);
}
// Grab and release extra interfaces if required
virtual HRESULT CheckConnect(IPin *pPin);
virtual HRESULT BreakConnect();
virtual HRESULT CompleteConnect(IPin *pReceivePin);
// check that we can support this output type
virtual HRESULT CheckMediaType(const CMediaType* mtOut);
// set the connection media type
virtual HRESULT SetMediaType(const CMediaType *pmt);
// called from CBaseOutputPin during connection to ask for
// the count and size of buffers we need.
virtual HRESULT DecideBufferSize(
IMemAllocator * pAlloc,
__inout ALLOCATOR_PROPERTIES *pProp);
// returns the preferred formats for a pin
virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);
// inherited from IQualityControl via CBasePin
virtual STDMETHODIMP Notify(IBaseFilter * pSender, Quality q);
// Media type
public:
virtual CMediaType& CurrentMediaType() { return m_mt; };
virtual IMemAllocator* Allocator() {return m_pAllocator;};
virtual HRESULT GetD3DFilter(IDXBaseFilter*& pFilter);
virtual HRESULT GetConnectedPin(IPin*& pPin);
};
class CMuxTransformStream : public CAMThread, public CBaseOutputPin, public D3DBaseOutputPin
{
friend class CMuxTransformFilter;
public:
// override to expose IDXBasePin
DECLARE_IUNKNOWN;
virtual STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
CMuxTransformStream(__in_opt LPCTSTR pObjectName,
__inout HRESULT *phr,
__inout CMuxTransformFilter *pms,
__in_opt LPCWSTR pName);
#ifdef UNICODE
CMuxTransformStream(__in_opt LPCSTR pObjectName,
__inout HRESULT *phr,
__inout CMuxTransformFilter *pms,
__in_opt LPCWSTR pName);
#endif
virtual ~CMuxTransformStream(void); // virtual destructor ensures derived class destructors are called too.
protected:
CMuxTransformFilter *m_pFilter; // The parent of this stream
// *
// * Data Source
// *
// * The following three functions: FillBuffer, OnThreadCreate/Destroy, are
// * called from within the ThreadProc. They are used in the creation of
// * the media samples this pin will provide
// *
virtual HRESULT DecideBufferSize(
IMemAllocator * pAlloc,
__inout ALLOCATOR_PROPERTIES *pProp);
// Override this to provide the worker thread a means
// of processing a buffer
virtual HRESULT FillBuffer(IMediaSample *pSamp);
// implement it by calling filter
virtual HRESULT CheckConnect(IPin *pPin);
virtual HRESULT BreakConnect();
virtual HRESULT CompleteConnect(IPin *pReceivePin);
// Called as the thread is created/destroyed - use to perform
// jobs such as start/stop streaming mode
// If OnThreadCreate returns an error the thread will exit.
virtual HRESULT OnThreadCreate(void);
virtual HRESULT OnThreadDestroy(void);
virtual HRESULT OnThreadStartPlay(void);
// *
// * Worker Thread
// *
HRESULT Active(void); // Starts up the worker thread
HRESULT Inactive(void); // Exits the worker thread.
public:
bool m_bVisible;
// thread commands
enum Command {CMD_INIT, CMD_PAUSE, CMD_RUN, CMD_STOP, CMD_EXIT};
HRESULT Init(void) { return CallWorker(CMD_INIT); }
HRESULT Exit(void) { return CallWorker(CMD_EXIT); }
HRESULT Run(void) { return CallWorker(CMD_RUN); }
HRESULT Pause(void) { return CallWorker(CMD_PAUSE); }
HRESULT Stop(void) { return CallWorker(CMD_STOP); }
virtual STDMETHODIMP Notify(IBaseFilter * pSender, Quality q);
virtual CMediaType& CurrentMediaType() { return m_mt; };
virtual HRESULT GetD3DFilter(IDXBaseFilter*& pFilter);
virtual HRESULT GetConnectedPin(IPin*& pPin);
protected:
Command GetRequest(void) { return (Command) CAMThread::GetRequest(); }
BOOL CheckRequest(Command *pCom) { return CAMThread::CheckRequest( (DWORD *) pCom); }
// override these if you want to add thread commands
virtual DWORD ThreadProc(void); // the thread function
virtual HRESULT DoBufferProcessingLoop(void); // the loop executed whilst running
virtual float GetFrameRateLimit();
// *
// * AM_MEDIA_TYPE support
// *
// If you support more than one media type then override these 2 functions
virtual HRESULT CheckMediaType(const CMediaType *pMediaType);
virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType); // List pos. 0-n
virtual STDMETHODIMP QueryId(__deref_out LPWSTR * Id)
{
return AMGetWideString(m_pName, Id);
}
};
class CMuxTransformFilter : public CBaseFilter, public D3DBaseFilter
{
public:
virtual int GetPinCount();
virtual CBasePin * GetPin(int n);
STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);
STDMETHODIMP Stop();
STDMETHODIMP Pause();
public:
CMuxTransformFilter(__in_opt LPCTSTR , __inout_opt LPUNKNOWN, REFCLSID clsid);
#ifdef UNICODE
CMuxTransformFilter(__in_opt LPCSTR , __inout_opt LPUNKNOWN, REFCLSID clsid);
#endif
virtual ~CMuxTransformFilter();
// These must be supplied in a derived class
// Transform Filter Method
virtual HRESULT Receive(IMediaSample *pSample, const IPin* pReceivePin) { return E_UNEXPECTED; };
virtual HRESULT CheckInputType(const CMediaType* mtIn, const IPin* pPin) { return E_UNEXPECTED;};
virtual HRESULT CheckOutputType(const CMediaType* mtOut, const IPin* pPin) { return E_UNEXPECTED;};
virtual HRESULT DecideBufferSize(
IMemAllocator * pAllocator, const IPin* pOutPin,
__inout ALLOCATOR_PROPERTIES *pprop) { return E_UNEXPECTED;};
virtual HRESULT GetMediaType(int iPosition, const IPin* pOutPin, __inout CMediaType *pMediaType) { return E_UNEXPECTED;};
// Source Filter Method
virtual HRESULT FillBuffer(IMediaSample *pSamp, IPin* pPin) { return E_UNEXPECTED; };
virtual float GetFrameRateLimit(IPin* pPin) { return 10000.0;}
// =================================================================
// ----- Optional Override Methods -----------------------
// =================================================================
// Source Filter Method
virtual HRESULT OnThreadCreate(IPin* pPin){return NOERROR;};
virtual HRESULT OnThreadDestroy(IPin* pPin){return NOERROR;};
virtual HRESULT OnThreadStartPlay(IPin* pPin){return NOERROR;};
// Transform Filter Method
// you can also override these if you want to know about streaming
virtual HRESULT StartStreaming();
virtual HRESULT StopStreaming();
// override if you can do anything constructive with quality notifications
virtual HRESULT AlterQuality(Quality q);
// override this to know when the media type is actually set
virtual HRESULT SetMediaType(PIN_DIRECTION direction, const IPin* pPin, const CMediaType *pmt);
// chance to grab extra interfaces on connection
virtual HRESULT CheckConnect(PIN_DIRECTION dir, const IPin* pMyPin, const IPin* pOtherPin);
virtual HRESULT BreakConnect(PIN_DIRECTION dir, const IPin* pPin);
virtual HRESULT CompleteConnect(PIN_DIRECTION direction, const IPin* pMyPin, const IPin* pOtherPin);
// Standard setup for output sample
virtual HRESULT InitializeOutputSample(IMediaSample *pSample, const IPin* pInputPin, const IPin* pOutputPin, __deref_out IMediaSample **ppOutSample);
// if you override Receive, you may need to override these three too
virtual STDMETHODIMP Notify(IBaseFilter * pSender, Quality q, IPin* pPin);
virtual HRESULT EndOfStream(void);
virtual HRESULT BeginFlush(void);
virtual HRESULT EndFlush(void);
virtual HRESULT NewSegment(
REFERENCE_TIME tStart,
REFERENCE_TIME tStop,
double dRate);
CCritSec* pStateLock(void) { return &m_csFilter; }
#ifdef PERF
// Override to register performance measurement with a less generic string
// You should do this to avoid confusion with other filters
virtual void RegisterPerfId()
{m_idTransform = MSR_REGISTER(TEXT("Transform"));}
#endif // PERF
// implementation details
protected:
#ifdef PERF
int m_idTransform; // performance measuring id
#endif
BOOL m_bEOSDelivered; // have we sent EndOfStream
BOOL m_bSampleSkipped; // Did we just skip a frame
BOOL m_bQualityChanged; // Have we degraded?
// critical section protecting filter state.
CCritSec m_csFilter;
// critical section stopping state changes (ie Stop) while we're
// processing a sample.
//
// This critical section is held when processing
// events that occur on the receive thread - Receive() and EndOfStream().
//
// If you want to hold both m_csReceive and m_csFilter then grab
// m_csFilter FIRST - like CTransformFilter::Stop() does.
CCritSec m_csReceive;
// these hold our input and output pins
friend class CMuxTransformInputPin;
friend class CMuxTransformOutputPin;
vector<CMuxTransformInputPin*> m_pInputPins;
vector<CMuxTransformOutputPin*> m_pOutputPins;
vector<CMuxTransformStream*> m_pStreamPins;
private:
virtual BOOL IsAnyInputPinConnect();
virtual BOOL IsAnyOutPinConnect();
protected:
virtual HRESULT CreatePins() = 0;
virtual CCritSec* GetReceiveCS(IPin* pPin);
};
class CSourceOutputPin : public CMuxTransformOutputPin
{
friend class CMuxTransformFilter;
public:
CSourceOutputPin(
__in_opt LPCTSTR pObjectName,
__inout CMuxTransformFilter *pTransformFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pName);
#ifdef UNICODE
CSourceOutputPin(
__in_opt LPCSTR pObjectName,
__inout CMuxTransformFilter *pTransformFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pName);
#endif
virtual ~ CSourceOutputPin();
virtual HRESULT CheckConnect(IPin *pPin);
virtual HRESULT CheckMediaType(const CMediaType* mtOut);
virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);
virtual HRESULT CompleteConnect(IPin *pReceivePin);
};
| [
"ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a",
"claire3kao@fa729b96-8d43-11de-b54f-137c5e29c83a"
]
| [
[
[
1,
217
],
[
219,
305
],
[
307,
386
]
],
[
[
218,
218
],
[
306,
306
]
]
]
|
8a5919dcce5236ebd58cc2b9ab993c5804a1e197 | 55d6f54f463bf0f97298eb299674e2065863b263 | /mmain.h | 7e66d0a0c39dbd5ca3dcc89602b56a5a93773950 | []
| no_license | Coinche/CoinchePAV | a344e69b096ef5fd4e24c98af1b24de2a99235f0 | 134cac106ee8cea78abc5b29b23a32706b2aad08 | refs/heads/master | 2020-06-01T09:35:51.793153 | 2011-12-01T19:57:12 | 2011-12-01T19:57:12 | 2,729,958 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 682 | h | #ifndef MMAIN_H
#define MMAIN_H
#include <vector>
#include "carte.h"
class Main
{
public:
Main();
Main(const Main&);
//Main& operator=(const Main&);
Carte& operator[](unsigned int n);
const Carte& operator[](unsigned int n) const;
void push_back(const Carte& carte);
unsigned int size() const;
bool empty() const;
void enlever(const Carte&);
void trierParCouleur();
Main extraire(Couleur) const;
bool contient(Carte) const;
private:
std::vector<Carte> conteneur;
};
bool operator==(const Main &main1, const Main &main2);
#endif
| [
"lucas@graham.(none)"
]
| [
[
[
1,
33
]
]
]
|
7281834c3147f980b9c19a23c9cb6fce2e56941d | 989aa92c9dab9a90373c8f28aa996c7714a758eb | /HydraIRC/include/CObjectManager.h | 4e17a9ca451aac7181950c857acab90d8756fb25 | []
| no_license | john-peterson/hydrairc | 5139ce002e2537d4bd8fbdcebfec6853168f23bc | f04b7f4abf0de0d2536aef93bd32bea5c4764445 | refs/heads/master | 2021-01-16T20:14:03.793977 | 2010-04-03T02:10:39 | 2010-04-03T02:10:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,577 | h | /*
HydraIRC
Copyright (C) 2002-2006 Dominic Clifton aka Hydra
HydraIRC limited-use source license
1) You can:
1.1) Use the source to create improvements and bug-fixes to send to the
author to be incorporated in the main program.
1.2) Use it for review/educational purposes.
2) You can NOT:
2.1) Use the source to create derivative works. (That is, you can't release
your own version of HydraIRC with your changes in it)
2.2) Compile your own version and sell it.
2.3) Distribute unmodified, modified source or compiled versions of HydraIRC
without first obtaining permission from the author. (I want one place
for people to come to get HydraIRC from)
2.4) Use any of the code or other part of HydraIRC in anything other than
HydraIRC.
3) All code submitted to the project:
3.1) Must not be covered by any license that conflicts with this license
(e.g. GPL code)
3.2) Will become the property of the author.
*/
// simple CNode wrapper that stores an ObjectID, so we just use m_Data and m_ObjectID
class ObjectItem : public CNode
{
public:
int m_ObjectID;
};
// ObjectManager is a simple class to return objects given an object id.
// so it functions like an array, but without a linear index
// object ID's are just ints starting from 0.
// if an object is freed then so is it's id. so make sure you only store the
// id of an object for as long as the object exists.
// you also might liken this class to a managed linked list with each node having
// an ID.
// returns objects given a specific ID.
class ObjectManager
{
private:
IDManager m_IDManager;
CList m_ObjectList;
public:
~ObjectManager( void )
{
ATLASSERT(m_ObjectList.IsEmpty()); // you didn't remove your objects..
#ifdef DEBUG
// you shouldn't need this bit code...
// remove ojects..
ObjectItem *pObjectItem;
while (!m_ObjectList.IsEmpty())
{
pObjectItem = (ObjectItem *)m_ObjectList.GetFirst();
pObjectItem->Remove();
m_IDManager.RelinquishID(pObjectItem->m_ObjectID);
}
#endif
}
// return TRUE if we're managing some objects
BOOL IsEmpty( void )
{
// just a wrapper
return m_ObjectList.IsEmpty();
}
// adds an object to a managed list of objects and returns the object id.
int AddObject(void *pObject)
{
ObjectItem *pObjectItem = new ObjectItem;
if (!pObjectItem)
return -1; // failed!
pObjectItem->m_ObjectID = m_IDManager.ObtainID();
pObjectItem->m_Data = pObject;
m_ObjectList.AddTail((CNode *)pObjectItem);
return pObjectItem->m_ObjectID;
}
// removes the first object matching pObject from the list and returns true, or false if it can't find it.
BOOL RemoveObject(void *pObject)
{
ObjectItem *pObjectItem;
for (pObjectItem = (ObjectItem *)m_ObjectList.GetFirst(); pObjectItem->m_Next != NULL; pObjectItem = (ObjectItem *)pObjectItem->m_Next)
{
if (pObjectItem->m_Data != pObject)
continue;
pObjectItem->Remove();
m_IDManager.RelinquishID(pObjectItem->m_ObjectID);
delete pObjectItem;
return TRUE;
}
return FALSE;
}
// returns amount of object matching pObject that were removed from the list.
int RemoveMatchingObjects(void *pObject)
{
int Count = 0;
ObjectItem *pObjectItem;
for (pObjectItem = (ObjectItem *)m_ObjectList.GetFirst(); pObjectItem->m_Next != NULL; pObjectItem = (ObjectItem *)pObjectItem->m_Next)
{
if (pObjectItem->m_Data != pObject)
continue;
pObjectItem->Remove();
m_IDManager.RelinquishID(pObjectItem->m_ObjectID);
delete pObjectItem;
Count ++;
}
return Count;
}
// removed an object with the ID of ObjectID and returns true if it found it, false otherwise.
BOOL RemoveObjectByID(int ObjectID)
{
ObjectItem *pObjectItem;
for (pObjectItem = (ObjectItem *)m_ObjectList.GetFirst(); pObjectItem->m_Next != NULL; pObjectItem = (ObjectItem *)pObjectItem->m_Next)
{
if (pObjectItem->m_ObjectID != ObjectID)
continue;
pObjectItem->Remove();
m_IDManager.RelinquishID(pObjectItem->m_ObjectID);
delete pObjectItem;
return TRUE;
}
return FALSE;
}
// returns the object ID for a given object, or -1 if it's not found.
int GetObjectID(void *pObject)
{
ObjectItem *pObjectItem;
for (pObjectItem = (ObjectItem *)m_ObjectList.GetFirst(); pObjectItem->m_Next != NULL; pObjectItem = (ObjectItem *)pObjectItem->m_Next)
{
if (pObjectItem->m_Data != pObject)
continue;
return pObjectItem->m_ObjectID;
}
return -1;
}
// returns the object, given the ID, or NULL if the object is not found.
void *GetObjectByID(int ObjectID)
{
ObjectItem *pObjectItem;
for (pObjectItem = (ObjectItem *)m_ObjectList.GetFirst(); pObjectItem->m_Next != NULL; pObjectItem = (ObjectItem *)pObjectItem->m_Next)
{
if (pObjectItem->m_ObjectID != ObjectID)
continue;
return pObjectItem->m_Data;
}
return NULL;
}
// returns the object first NULL if there are no objects
void *GetFirstObject()
{
ObjectItem *pObjectItem = (ObjectItem *)m_ObjectList.GetFirst();
if (pObjectItem->m_Next != NULL) // empty list ?
return pObjectItem->m_Data; //no
else
return NULL; // yes
}
};
| [
"hydra@b2473a34-e2c4-0310-847b-bd686bddb4b0"
]
| [
[
[
1,
191
]
]
]
|
f73c9780cadae6535d3b6f1f20c6e0a8607d8552 | 4c3c35e4fe1ff2567ef20f0b203fe101a4a2bf20 | /HW4/src/GzVector.h | 47ef66398a38fe0a4c5b26995f3d98c681fc49a5 | []
| no_license | kolebole/monopolocoso | 63c0986707728522650bd2704a5491d1da20ecf7 | a86c0814f5da2f05e7676b2e41f6858d87077e6a | refs/heads/master | 2021-01-19T15:04:09.283953 | 2011-03-27T23:21:53 | 2011-03-27T23:21:53 | 34,309,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,408 | h | #ifndef __GZ_VECTOR_H_
#define __GZ_VECTOR_H_
#include <cmath>
#include <vector>
#include "GzCommon.h"
using namespace std;
//============================================================================
//Declarations in Assignment #4
//============================================================================
//3D vector data type---------------------------------------------------------
struct GzVector:public vector<GzReal>
{
GzVector();
GzVector(GzReal x, GzReal y, GzReal z);
GzReal length();
void normalize();
};
//----------------------------------------------------------------------------
//Vector operators------------------------------------------------------------
GzVector operator + (const GzVector& a, const GzVector& b);
GzVector operator - (const GzVector& a, const GzVector& b);
GzReal dotProduct(const GzVector& a, const GzVector& b);
GzVector crossProduct(const GzVector& a, const GzVector& b);
GzVector operator * (GzReal a, const GzVector& b);
GzVector operator * (const GzVector& a, GzReal b);
GzVector operator / (const GzVector& a, GzReal b);
//----------------------------------------------------------------------------
//============================================================================
//End of Declarations in Assignment #4
//============================================================================
#endif
| [
"chuminhtri@a7811d78-34aa-4512-2aaf-9c23cbf1bc95"
]
| [
[
[
1,
40
]
]
]
|
f509e9e9b6bd53fda7e91d13e966d8cb20e057a1 | 324524076ba7b05d9d8cf5b65f4cd84072c2f771 | /Checkers/Libraries/eThemes/Public/ColorFunctions.cpp | 129a11fbfec94651852cd3c36cb74ba96ab1759a | [
"BSD-2-Clause"
]
| permissive | joeyespo-archive/checkers-c | 3bf9ff11f5f1dee4c17cd62fb8af9ba79246e1c3 | 477521eb0221b747e93245830698d01fafd2bd66 | refs/heads/master | 2021-01-01T05:32:45.964978 | 2011-03-13T04:53:08 | 2011-03-13T04:53:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,865 | cpp | // ColorFunctions.cpp
// Color Functions Internal Implementation File
// By Joe Esposito
// Draws a line using a scheme color
BOOL ESTDCALL SchemeLineTo (HDC hDC, HETHEMEOBJ hThemeObj, INT nColorIndex, INT x, INT y)
{
BOOL bResult;
HPEN hpenTemp = (HPEN)SelectObject(hDC, GetSchemeColorObjEx(hThemeObj, nColorIndex, CSM_HPEN));
bResult = LineTo(hDC, x, y);
SelectObject(hDC, hpenTemp);
return bResult;
}
// Draws a line using a scheme color
BOOL ESTDCALL DrawSchemeLine (HDC hDC, HETHEMEOBJ hThemeObj, INT nColorIndex, INT x1, INT y1, INT x2, INT y2, LPPOINT lpPoint)
{
BOOL bResult;
HPEN hpenTemp = (HPEN)SelectObject(hDC, GetSchemeColorObjEx(hThemeObj, nColorIndex, CSM_HPEN));
if (!MoveToEx(hDC, x1, y1, lpPoint)) { SelectObject(hDC, hpenTemp); return FALSE; }
bResult = LineTo(hDC, x2, y2);
SelectObject(hDC, hpenTemp);
return bResult;
}
// Draws a windows edge using scheme colors
BOOL ESTDCALL DrawSchemeEdge (HDC hDC, LPRECT lprt, HETHEMEOBJ hThemeObj, UINT uEdge, UINT uFlags)
{
LPSCHEMECOLORSTRUCT lpcs = NULL;
HBRUSH hbrBackground = NULL;
HPEN m_hpenLight = NULL, hpenLight, m_hpenHighlight = NULL, hpenHighlight;
HPEN m_hpenShadow = NULL, hpenShadow, m_hpenDkShadow = NULL, hpenDkShadow;
HPEN m_hpenDefaultBorder = NULL, hpenDefaultBorder = NULL;
HPEN hpenTemp;
LONG X, Y, nHeight, nWidth;
RECT rt;
// Check first
if (lprt == NULL) return FALSE;
if (hThemeObj) lpcs = _GetColorObject((LPETHEMEOBJ)hThemeObj);
// Initialize data
// ----------------
// Set up pens and brushes
if (lpcs)
{
hbrBackground = lpcs->hbrBackground;
m_hpenDefaultBorder = hpenDefaultBorder = lpcs->hpenDefaultBorder;
m_hpenLight = hpenLight = lpcs->hpenLight; m_hpenHighlight = hpenHighlight = lpcs->hpenHighlight;
m_hpenShadow = hpenShadow = lpcs->hpenShadow; m_hpenDkShadow = hpenDkShadow = lpcs->hpenDkShadow;
}
if (!hbrBackground) hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
if (!m_hpenLight) hpenLight = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT));
if (!m_hpenHighlight) hpenHighlight = CreatePen(PS_SOLID, 0, GetSysColor( ((uFlags & BF_MONO)?(COLOR_WINDOW):(COLOR_3DHILIGHT)) ));
if (!m_hpenShadow) hpenShadow = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW));
if (!m_hpenDkShadow) hpenDkShadow = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW));
// Set up coordinates
X = lprt->left; Y = lprt->top;
nWidth = (lprt->right - lprt->left); nHeight = (lprt->bottom - lprt->top);
// Set up device context
hpenTemp = (HPEN)GetCurrentObject(hDC, OBJ_PEN);
// Drawing
// --------
// Draw edge !!!!! if BF_<BORDER>, then draw correctly
if (uFlags & BF_DEFAULT)
{
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, hpenDefaultBorder, (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, hpenDefaultBorder, (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenDefaultBorder, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenDefaultBorder, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
X++; Y++; nHeight -= 2; nWidth -= 2;
}
if (uFlags & BF_MONO)
{
if (uEdge & (BDR_SUNKENOUTER | BDR_RAISEDOUTER)) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, hpenDkShadow, (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, hpenDkShadow, (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenDkShadow, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenDkShadow, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
X++; Y++; nHeight -= 2; nWidth -= 2;
}
if (uEdge & (BDR_SUNKENINNER | BDR_RAISEDINNER)) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, hpenHighlight, (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, hpenHighlight, (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenHighlight, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenHighlight, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
X++; Y++; nHeight -= 2; nWidth -= 2;
}
}else if (uFlags & BF_FLAT)
{
if (uEdge & (BDR_SUNKENOUTER | BDR_RAISEDOUTER)) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, hpenShadow, (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, hpenShadow, (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenShadow, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenShadow, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
X++; Y++; nHeight -= 2; nWidth -= 2;
}
if (uEdge & (BDR_SUNKENINNER | BDR_RAISEDINNER)) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, hpenLight, (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, hpenLight, (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenLight, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenLight, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
X++; Y++; nHeight -= 2; nWidth -= 2;
}
}else
{
if (uEdge & (BDR_SUNKENOUTER | BDR_RAISEDOUTER)) {
if (uEdge & BDR_SUNKENOUTER) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenDkShadow):(hpenShadow)), (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenDkShadow):(hpenShadow)), (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenHighlight, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenHighlight, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
}
if (uEdge & BDR_RAISEDOUTER) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenHighlight):(hpenLight)), (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenHighlight):(hpenLight)), (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenDkShadow, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenDkShadow, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
} X++; Y++; nHeight -= 2; nWidth -= 2;
}
if (uEdge & (BDR_SUNKENINNER | BDR_RAISEDINNER)) {
if (uEdge & BDR_SUNKENINNER) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenShadow):(hpenDkShadow)), (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenShadow):(hpenDkShadow)), (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenLight, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenLight, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
}
if (uEdge & BDR_RAISEDINNER) {
MoveToEx(hDC, (X+(nWidth-2)), Y, NULL);
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenLight):(hpenHighlight)), (X), (Y), (uFlags & BF_TOP));
DRAWLINE(hDC, ((uFlags & BF_SOFT)?(hpenLight):(hpenHighlight)), (X), (Y+(nHeight-1)), (uFlags & BF_LEFT));
DRAWLINE(hDC, hpenShadow, (X+(nWidth-1)), (Y+(nHeight-1)), (uFlags & BF_BOTTOM));
DRAWLINE(hDC, hpenShadow, (X+(nWidth-1)), (Y-1), (uFlags & BF_RIGHT));
} X++; Y++; nHeight -= 2; nWidth -= 2;
}
}
// Fill middle
if (uFlags & BF_MIDDLE) {
rt.left = X; rt.right = (X + nWidth);
rt.top = Y; rt.bottom = (Y + nHeight);
FillRect(hDC, &rt, hbrBackground);
}
// Adjust client rect
if (uFlags & BF_ADJUST) {
lprt->left = X; lprt->right = (X + nWidth);
lprt->top = Y; lprt->bottom = (Y + nHeight);
}
// Termination
// ------------
// Clean up
SelectObject(hDC, hpenTemp);
// Delete local pens (if <m_nn> is NULL, then <nn> was created locally)
if (!m_hpenLight) DeleteObject(hpenLight);
if (!m_hpenHighlight) DeleteObject(hpenHighlight);
if (!m_hpenShadow) DeleteObject(hpenShadow);
if (!m_hpenDkShadow) DeleteObject(hpenDkShadow);
if (!m_hpenDefaultBorder) DeleteObject(hpenDefaultBorder);
// Return OK
return TRUE;
}
// Draws an item using scheme colors
BOOL ESTDCALL DrawSchemeItem (LPDRAWITEMSTRUCT lpds, UINT uStateExtra, LPRECT lpFocusRect, HETHEMEOBJ hThemeObj, LPVOID lpData, BOOL bNoFlicker)
{
char *m_Str;
int n;
switch (lpds->CtlType) {
case ODT_BUTTON:
// Draw a button
// --------------
// Get the window's text
if (!lpData) {
n = (GetWindowTextLength(lpds->hwndItem) + 1);
if ((m_Str = new char [n]) == NULL) return FALSE;
GetWindowText(lpds->hwndItem, m_Str, n);
}
DrawSchemeButton(lpds->hDC, &lpds->rcItem, lpFocusRect, hThemeObj, (lpds->itemState | uStateExtra), (LPSTR)((lpData)?(lpData):(m_Str)), bNoFlicker);
// Clean up
if (m_Str) delete [n] m_Str;
// Success
return TRUE;
};
return FALSE;
}
// Draws a button using scheme colors
// !!!!! Draw on memory bitmap, then copy
BOOL ESTDCALL DrawSchemeButton (HDC hDC, LPRECT lprt, LPRECT lpFocusRect, HETHEMEOBJ hThemeObj, UINT uState, LPSTR lpszWindowText, BOOL bNoFlicker)
{
RECT rt;
HDC hdcBitmap;
BITMAPINFO bmi;
HBITMAP hbmpBitmap, hbmpTemp;
LONG X, Y, nHeight, nWidth;
COLORREF crTemp;
HFONT hfntTemp;
bool bDefault;
int i;
// Check first
if (!lprt) return FALSE;
// Initialize locals
// ------------------
// Set up coordinates
X = rt.left = lprt->left; rt.right = lprt->right;
Y = rt.top = lprt->top; rt.bottom = lprt->bottom;
nHeight = (rt.bottom-rt.top); nWidth = (rt.right-rt.left);
// Locals
bDefault = ((uState & ODS_DEFAULT) || (uState & ODS_FOCUS));
// Create Bitmap
// --------------
if (bNoFlicker)
{
// Bitmap header
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = nWidth; bmi.bmiHeader.biHeight = -nHeight; bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biSizeImage = 0;
// Create the bitmap
hdcBitmap = CreateCompatibleDC(NULL);
hbmpBitmap = CreateDIBSection(hdcBitmap, &bmi, DIB_RGB_COLORS, NULL, NULL, NULL);
hbmpTemp = (HBITMAP)SelectObject(hdcBitmap, hbmpBitmap);
} else { hdcBitmap = hDC; }
// Drawing
// --------
// Background
FillRect(hdcBitmap, lprt, GetSchemeBkBrush(hThemeObj));
// Draw Text // !!!!! Draw disabled button (DFCS_INACTIVE)
// ----------
// Set up position
if (uState & ODS_SELECTED) { rt.left += 2; rt.top += 2; }
// Initialize text drawing
i = SetBkMode(hdcBitmap, TRANSPARENT); crTemp = SetTextColor(hdcBitmap, GetSchemeColor(hThemeObj, CSI_BTNTEXT));
if (bNoFlicker) hfntTemp = (HFONT)SelectObject(hdcBitmap, GetCurrentObject(hDC, OBJ_FONT));
// Draw the text
DrawText(hdcBitmap, lpszWindowText, -1, &rt, (DT_SINGLELINE | DT_CENTER | DT_VCENTER));
// Restore original
SetBkMode(hdcBitmap, i); SetTextColor(hdcBitmap, crTemp);
if (bNoFlicker) SelectObject(hdcBitmap, hfntTemp);
// Postion back to original
if (uState & ODS_SELECTED) { rt.left -= 2; rt.top -= 2; }
// Draw frame
// -----------
DrawSchemeEdge(hdcBitmap, lprt, hThemeObj, ((uState & ODS_SELECTED)?(BDR_RAISEDOUTER):(EDGE_RAISED)), (BF_RECT | ((uState & ODS_SELECTED)?(BF_FLAT):( (uState & DFCS_FLAT)?(BF_FLAT):( (uState & DFCS_MONO)?(BF_MONO):(BF_SOFT) ) )) | ((bDefault)?(BF_DEFAULT):(NULL)) ));
// Draw focus rect
if ((lpFocusRect) && (uState & ODS_FOCUS))
{
// Set up rectangle
rt.left += lpFocusRect->left; rt.right -= lpFocusRect->right;
rt.top += lpFocusRect->top; rt.bottom -= lpFocusRect->bottom;
// Draw frame rect, then restore
crTemp = SetTextColor(hdcBitmap, 0);
DrawFocusRect(hdcBitmap, &rt);
SetTextColor(hdcBitmap, crTemp);
}
// Draw on actual window
if (bNoFlicker) BitBlt(hDC, X, Y, nWidth, nHeight, hdcBitmap, 0, 0, SRCCOPY);
// Clean up
// ---------
if (bNoFlicker)
{
// Restore original objects
SelectObject(hdcBitmap, hbmpTemp); // Bitmap
// Delete objects
DeleteDC(hdcBitmap); // Delete the bitmap DC
DeleteObject(hbmpBitmap); // Delete the bitmap
}
return TRUE;
}
| [
"[email protected]"
]
| [
[
[
1,
341
]
]
]
|
070c06fab49bb834d3e4cf577e5d64a91f326012 | 77aa13a51685597585abf89b5ad30f9ef4011bde | /dep/src/boost/boost/fusion/container/vector/vector.hpp | 6e133676185eac9a1272b1d6fc3d3b34965968f8 | [
"BSL-1.0"
]
| permissive | Zic/Xeon-MMORPG-Emulator | 2f195d04bfd0988a9165a52b7a3756c04b3f146c | 4473a22e6dd4ec3c9b867d60915841731869a050 | refs/heads/master | 2021-01-01T16:19:35.213330 | 2009-05-13T18:12:36 | 2009-05-14T03:10:17 | 200,849 | 8 | 10 | null | null | null | null | UTF-8 | C++ | false | false | 4,535 | hpp | /*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(FUSION_VECTOR_07072005_1244)
#define FUSION_VECTOR_07072005_1244
#include <boost/fusion/container/vector/vector_fwd.hpp>
#include <boost/fusion/container/vector/detail/vector_n_chooser.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/detail/workaround.hpp>
namespace boost { namespace fusion
{
struct void_;
struct fusion_sequence_tag;
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
struct vector
: sequence_base<vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> >
{
private:
typedef typename detail::vector_n_chooser<
BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>::type
vector_n;
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
friend struct vector;
public:
typedef typename vector_n::types types;
typedef typename vector_n::fusion_tag fusion_tag;
typedef typename vector_n::tag tag;
typedef typename vector_n::size size;
typedef typename vector_n::category category;
typedef typename vector_n::is_view is_view;
vector()
: vec() {}
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
vector(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
: vec(rhs.vec) {}
vector(vector const& rhs)
: vec(rhs.vec) {}
template <typename Sequence>
vector(Sequence const& rhs)
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
: vec(ctor_helper(rhs, is_base_of<vector, Sequence>())) {}
#else
: vec(rhs) {}
#endif
// Expand a couple of forwarding constructors for arguments
// of type (T0), (T0, T1), (T0, T1, T2) etc. Example:
//
// vector(
// typename detail::call_param<T0>::type _0
// , typename detail::call_param<T1>::type _1)
// : vec(_0, _1) {}
#include <boost/fusion/container/vector/detail/vector_forward_ctor.hpp>
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename U)>
vector&
operator=(vector<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, U)> const& rhs)
{
vec = rhs.vec;
return *this;
}
template <typename T>
vector&
operator=(T const& rhs)
{
vec = rhs;
return *this;
}
template <int N>
typename add_reference<
typename mpl::at_c<types, N>::type
>::type
at_impl(mpl::int_<N> index)
{
return vec.at_impl(index);
}
template <int N>
typename add_reference<
typename add_const<
typename mpl::at_c<types, N>::type
>::type
>::type
at_impl(mpl::int_<N> index) const
{
return vec.at_impl(index);
}
template <typename I>
typename add_reference<
typename mpl::at<types, I>::type
>::type
at_impl(I index)
{
return vec.at_impl(mpl::int_<I::value>());
}
template<typename I>
typename add_reference<
typename add_const<
typename mpl::at<types, I>::type
>::type
>::type
at_impl(I index) const
{
return vec.at_impl(mpl::int_<I::value>());
}
private:
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
static vector_n const&
ctor_helper(vector const& rhs, mpl::true_)
{
return rhs.vec;
}
template <typename T>
static T const&
ctor_helper(T const& rhs, mpl::false_)
{
return rhs;
}
#endif
vector_n vec;
};
}}
#endif
| [
"pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88"
]
| [
[
[
1,
151
]
]
]
|
988df23daba1d8a92d8a3e7ce3d090b4b19d603b | d504537dae74273428d3aacd03b89357215f3d11 | /src/main/eel.cpp | d983e7485bc450324f5fd71c22e98f9419f6ab57 | []
| no_license | h0MER247/e6 | 1026bf9aabd5c11b84e358222d103aee829f62d7 | f92546fd1fc53ba783d84e9edf5660fe19b739cc | refs/heads/master | 2020-12-23T05:42:42.373786 | 2011-02-18T16:16:24 | 2011-02-18T16:16:24 | 237,055,477 | 1 | 0 | null | 2020-01-29T18:39:15 | 2020-01-29T18:39:14 | null | UTF-8 | C++ | false | false | 2,933 | cpp |
//
// script shell,
// loads a dll containing the interpreter
// make: make -f makefile.eel
// run : eel [script_dll] [script_file]
//
//
// 9/22/2005 - lua static shell
// 3/5/2006 - dynload interpreter from dll
// 2/8/2006 - try to load file first, then switch to interactive
//
//
#include <stdio.h>
#include <string.h>
#include "../e6/e6_sys.h"
#include "../e6/e6_impl.h"
#include "../e6/e6_enums.h"
#include "../Script/Script.h"
//~ #include "Windows.h"
struct DefLogger : e6::Logger
{
virtual bool printLog( const char * s )
{
printf( s );
return 1;
}
};
struct FileLogger : e6::Logger
{
FILE * f;
FileLogger( char * name )
{
f = fopen(name, "wb" );
}
~FileLogger()
{
fclose(f);
}
virtual bool printLog( const char * s )
{
fprintf( f, s );
fflush( f );
return 1;
}
};
// eel [-s dll] [-e errlog] [-o outlog] [script] [script] [...]
int main(int argc, char *argv[])
{
// options
DefLogger _defLog;
e6::Logger *le =&_defLog, *lo=&_defLog;
char *fe = "ScriptSquirrel";
char *scr[8];
int nscr = 0;
bool w;
bool interactive = 0;
for ( int i=1; i<argc; i++ )
{
if ( argv[i][0] == '-' )
{
if ( argv[i][1] == 'w' )
{
w = 1;
}
if ( argv[i][1] == 'i' )
{
interactive = 1;
}
if ( argv[i][1] == 's' )
{
fe = argv[++i];
}
//if ( argv[i][1] == 'e' )
//{
// le = FileLogger( argv[++i] );
//}
//if ( argv[i][1] == 'o' )
//{
// lo = FileLogger( argv[++i] );
//}
continue;
}
scr[nscr++] = argv[i];
}
// setup
e6::Engine * engine = e6::CreateEngine();
Script::Interpreter * speek = (Script::Interpreter *)engine->createInterface( fe, "Script.Interpreter" );
if ( ! speek )
{
std::cout << "Could not load interpreter " << fe << ".\n";
E_RELEASE(engine);
return 1;
}
if ( ! speek->setup( engine ) )
{
std::cout << "Could not start interpreter " << fe << ".\n";
E_RELEASE(speek);
E_RELEASE(engine);
return 1;
}
//speek->setErrlog( *le );
//speek->setOutlog( *lo );
// load script(s)
for ( int i=0; i<nscr; i++ )
{
const char * s = e6::sys::loadFile(scr[i], false) ;
if ( ! s )
{
std::cout << "Could not load script '" << scr[i] << "'.\n";
continue;
}
bool ok = speek->exec(s, scr[i]);
if ( ! ok )
{
std::cout << "script '" << scr[i] << "' failed on execution.\n";
continue;
}
std::cout << "script '" << scr[i] << "' executed.\n";
}
if( interactive || ! nscr )
{
char buf[4300];
for (;;)
{
memset(buf,0,4300);
printf("\n%s> ", speek->getFileExtension() );
if ( ! fgets( buf, 4300, stdin ) ) break;
if ( ! strncmp( buf, "ok.",3 ) ) break;
if ( ! speek->exec( buf, "konsole" ) ) break;
}
}
E_RELEASE(speek);
E_RELEASE(engine);
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
153
]
]
]
|
22ded3e9f72e21c907ef4eb2cad7b5fbb9722428 | 09a84291381a2ae9e366b848aff5ac94342e6d4b | /WinSubst/Source/WinSubstApp.cpp | cd5467016deb17f013df2382ca2f65a82202a1f0 | []
| no_license | zephyrer/xsubst | 0088343300d62d909a87e235da490728b9af5106 | 111829b6094d796aefb7c8e4ec7bd40bae4d6449 | refs/heads/master | 2020-05-20T03:22:44.200074 | 2011-06-18T05:50:34 | 2011-06-18T05:50:34 | 40,066,695 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,881 | cpp | // WinSubst application.
// Copyright (c) 2004-2011 by Elijah Zarezky,
// All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// WinSubstApp.cpp - implementation of the CWinSubstApp class
// initially generated by AfxScratch v1.0.2297 on 25.07.2004 at 13:26:11
// visit http://zarezky.spb.ru/projects/afx_scratch.html for more info
//////////////////////////////////////////////////////////////////////////////////////////////
// PCH includes
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////////////////////////
// resource includes
#include "Resource.h"
//////////////////////////////////////////////////////////////////////////////////////////////
// other includes
#include "WinSubstApp.h"
#include "SubstsList.h"
#include "MainDialog.h"
//////////////////////////////////////////////////////////////////////////////////////////////
// misc defines
#define SZ_MUTEX_APP_INST_NAME _T("WinSubst.Instance.326F8F0D-E321-4832-B29F-08542F06BCB9")
//////////////////////////////////////////////////////////////////////////////////////////////
// debugging support
#if defined(_DEBUG)
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif // _DEBUG
//////////////////////////////////////////////////////////////////////////////////////////////
// object model
IMPLEMENT_DYNAMIC(CWinSubstApp, CWinApp)
//////////////////////////////////////////////////////////////////////////////////////////////
// message map
BEGIN_MESSAGE_MAP(CWinSubstApp, CWinApp)
END_MESSAGE_MAP()
//////////////////////////////////////////////////////////////////////////////////////////////
// construction/destruction
CWinSubstApp::CWinSubstApp(void):
m_hMutexAppInst(NULL)
{
#if defined(WINSUBST_DETOURED)
if (RegQueryCatchpit() > 0)
{
Detoured();
(PVOID&)m_pfnLoadLibrary = ::DetourFindFunction("kernel32.dll", STRINGIZE(LoadLibrary));
(PVOID&)m_pfnLoadLibraryEx = ::DetourFindFunction("kernel32.dll", STRINGIZE(LoadLibraryEx));
DetourTransactionBegin();
DetourUpdateThread(::GetCurrentThread());
DetourAttach(reinterpret_cast<PVOID*>(&m_pfnLoadLibrary), &CWinSubstApp::LoadLibrary);
DetourAttach(reinterpret_cast<PVOID*>(&m_pfnLoadLibraryEx), &CWinSubstApp::LoadLibraryEx);
DetourTransactionCommit();
}
#endif // WINSUBST_DETOURED
}
CWinSubstApp::~CWinSubstApp(void)
{
#if defined(WINSUBST_DETOURED)
if (!IsCatchpitEmpty())
{
DetourTransactionBegin();
DetourUpdateThread(::GetCurrentThread());
DetourDetach(reinterpret_cast<PVOID*>(&m_pfnLoadLibrary), &CWinSubstApp::LoadLibrary);
DetourDetach(reinterpret_cast<PVOID*>(&m_pfnLoadLibraryEx), &CWinSubstApp::LoadLibraryEx);
DetourTransactionCommit();
}
#endif // WINSUBST_DETOURED
}
//////////////////////////////////////////////////////////////////////////////////////////////
// operations
HICON CWinSubstApp::LoadSmIcon(LPCTSTR pszResName)
{
HINSTANCE hInstRes = AfxGetResourceHandle();
int cxSmIcon = ::GetSystemMetrics(SM_CXSMICON);
int cySmIcon = ::GetSystemMetrics(SM_CYSMICON);
HANDLE hSmIcon = ::LoadImage(hInstRes, pszResName, IMAGE_ICON, cxSmIcon, cySmIcon, 0);
return (static_cast<HICON>(hSmIcon));
}
void CWinSubstApp::GetVersionString(CString& strDest)
{
TCHAR szExeName[_MAX_PATH];
DWORD dwHandle;
CString strValueName;
void* pvVerString;
UINT cchFileVer;
::GetModuleFileName(AfxGetInstanceHandle(), szExeName, _MAX_PATH);
DWORD cbSize = ::GetFileVersionInfoSize(szExeName, &dwHandle);
BYTE* pbVerInfo = new BYTE[cbSize];
::GetFileVersionInfo(szExeName, dwHandle, cbSize, pbVerInfo);
strValueName.LoadString(IDS_FILE_VERSION);
::VerQueryValue(pbVerInfo, strValueName.GetBuffer(0), &pvVerString, &cchFileVer);
strValueName.ReleaseBuffer();
strDest = reinterpret_cast<LPCTSTR>(pvVerString);
delete[] pbVerInfo;
}
//////////////////////////////////////////////////////////////////////////////////////////////
// overridables
BOOL CWinSubstApp::InitInstance(void)
{
m_hMutexAppInst = ::CreateMutex(NULL, TRUE, SZ_MUTEX_APP_INST_NAME);
if (m_hMutexAppInst == NULL)
{
AfxMessageBox(IDS_APP_INIT_FAILED, MB_OK | MB_ICONSTOP);
return (FALSE);
}
else if (::GetLastError() == ERROR_ALREADY_EXISTS)
{
HWND hMainDialog = ::FindWindow(CMainDialog::GetWindowClassName(), NULL);
ASSERT(::IsWindow(hMainDialog));
::SetForegroundWindow(hMainDialog);
::CloseHandle(m_hMutexAppInst);
return (FALSE);
}
CMainDialog dlgMain;
m_pMainWnd = &dlgMain;
dlgMain.DoModal();
::CloseHandle(m_hMutexAppInst);
m_hMutexAppInst = NULL;
return (FALSE);
}
//////////////////////////////////////////////////////////////////////////////////////////////
// implementation helpers
#if defined(WINSUBST_DETOURED)
CWinSubstApp::PFN_LOAD_LIBRARY CWinSubstApp::m_pfnLoadLibrary(NULL);
CWinSubstApp::PFN_LOAD_LIBRARY_EX CWinSubstApp::m_pfnLoadLibraryEx(NULL);
HMODULE WINAPI CWinSubstApp::LoadLibrary(LPCTSTR pszFileName)
{
TRACE(_T("*** CWinSubstApp::LoadLibrary(%s)\n"), pszFileName);
CWinSubstApp* pApp = DYNAMIC_DOWNCAST(CWinSubstApp, AfxGetApp());
ASSERT(pApp != NULL);
CString strFileNameLower(::PathFindFileName(pszFileName));
strFileNameLower.MakeLower();
DWORD fCatch = false;
if (pApp->m_mapCatchpit.Lookup(strFileNameLower, fCatch) && fCatch != 0)
{
::SetLastError(ERROR_FILE_NOT_FOUND);
return (NULL);
}
else {
return (m_pfnLoadLibrary(pszFileName));
}
}
HMODULE WINAPI CWinSubstApp::LoadLibraryEx(LPCTSTR pszFileName, HANDLE hFile, DWORD fdwFlags)
{
TRACE(_T("*** CWinSubstApp::LoadLibraryEx(%s, 0x%08X, 0x%08X)\n"), pszFileName, hFile, fdwFlags);
CWinSubstApp* pApp = DYNAMIC_DOWNCAST(CWinSubstApp, AfxGetApp());
ASSERT(pApp != NULL);
CString strFileNameLower(::PathFindFileName(pszFileName));
strFileNameLower.MakeLower();
DWORD fCatch = FALSE;
if (pApp->m_mapCatchpit.Lookup(strFileNameLower, fCatch) && fCatch != 0)
{
::SetLastError(ERROR_FILE_NOT_FOUND);
return (NULL);
}
else {
return (m_pfnLoadLibraryEx(pszFileName, hFile, fdwFlags));
}
}
INT_PTR CWinSubstApp::RegQueryCatchpit(void)
{
CString strKeyName;
CRegKey regKey;
m_mapCatchpit.RemoveAll();
// build the name of the registry key...
::LoadString(::GetModuleHandle(NULL), IDS_REGISTRY_KEY, strKeyName.GetBuffer(_MAX_PATH), _MAX_PATH);
strKeyName.ReleaseBuffer();
strKeyName.Insert(0, _T(".DEFAULT\\Software\\"));
strKeyName += _T("\\WinSubst\\Catchpit");
// ...and then open this key
regKey.Create(HKEY_USERS, strKeyName);
DWORD cNumValues = 0;
if (::RegQueryInfoKey(regKey, 0, 0, 0, 0, 0, 0, &cNumValues, 0, 0, 0, 0) == ERROR_SUCCESS)
{
for (DWORD i = 0; i < cNumValues; ++i)
{
TCHAR szValueName[_MAX_PATH] = { 0 };
DWORD cchNameLen = _countof(szValueName);
DWORD fdwValueType = REG_NONE;
if (::RegEnumValue(regKey, i, szValueName, &cchNameLen, 0, &fdwValueType, 0, 0) == ERROR_SUCCESS)
{
if (fdwValueType == REG_DWORD)
{
DWORD fCatch = FALSE;
regKey.QueryDWORDValue(szValueName, fCatch);
_tcslwr_s(szValueName, cchNameLen + 1);
m_mapCatchpit.SetAt(szValueName, fCatch);
}
}
}
}
return (m_mapCatchpit.GetCount());
}
#endif // WINSUBST_DETOURED
//////////////////////////////////////////////////////////////////////////////////////////////
// diagnostic services
#if defined(_DEBUG)
void CWinSubstApp::AssertValid(void) const
{
// first perform inherited validity check...
CWinApp::AssertValid();
// ...and then verify our own state as well
}
void CWinSubstApp::Dump(CDumpContext& dumpCtx) const
{
try
{
// first invoke inherited dumper...
CWinApp::Dump(dumpCtx);
// ...and then dump own unique members
dumpCtx << "m_hMutexAppInst = " << m_hMutexAppInst;
#if defined(WINSUBST_DETOURED)
dumpCtx << "\nm_mapCatchpit = " << m_mapCatchpit;
#endif // WINSUBST_DETOURED
}
catch (CFileException* pXcpt)
{
pXcpt->ReportError();
pXcpt->Delete();
}
}
#endif // _DEBUG
//////////////////////////////////////////////////////////////////////////////////////////////
// the one and only application object
static CWinSubstApp g_appWinSubst;
// end of file
| [
"Elijah Zarezky@9a190745-9f41-0410-876d-23307a9d09e3",
"elijah@9a190745-9f41-0410-876d-23307a9d09e3"
]
| [
[
[
1,
4
],
[
17,
268
],
[
271,
279
],
[
282,
294
]
],
[
[
5,
16
],
[
269,
270
],
[
280,
281
]
]
]
|
a3968c9d1a59203569325aee3dc996d976a1d23e | 22b6d8a368ecfa96cb182437b7b391e408ba8730 | /engine/include/qvAbstractCommand.h | 15c309b6872dc43760b6f6113e4745d188f6d27d | [
"MIT"
]
| permissive | drr00t/quanticvortex | 2d69a3e62d1850b8d3074ec97232e08c349e23c2 | b780b0f547cf19bd48198dc43329588d023a9ad9 | refs/heads/master | 2021-01-22T22:16:50.370688 | 2010-12-18T12:06:33 | 2010-12-18T12:06:33 | 85,525,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,255 | h | /**************************************************************************************************
//This code is part of QuanticVortex for latest information, see http://www.quanticvortex.org
//
//Copyright (c) 2009-2010 QuanticMinds Software Ltda.
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
**************************************************************************************************/
#ifndef __ABSTRACT_COMMAND_H_
#define __ABSTRACT_COMMAND_H_
#include <algorithm>
#include <tr1/unordered_map>
#include "qvCommandArgs.h"
namespace qv
{
class AbstractCommand
/// basic interface to execute a command inside the engine
{
public:
// AbstractCommand(const qv::CI_COMMAND_ID& commandId, const qv::CT_COMMAND_TYPE& commandType)
/// command constructor getting name and type of command args
AbstractCommand( const qv::CT_COMMAND_TYPE& commandType)
: mCommandType(commandType)
{}
virtual ~AbstractCommand() {}
/// destructor
// const qv::CI_COMMAND_ID& getId() const;
// /// unique command id
const qv::CT_COMMAND_TYPE& getType() const;
/// command type family
virtual void executeCommand(const qv::CommandArgs* args) = 0;
/// body of command
private:
AbstractCommand(const AbstractCommand&); // to avoid copy of command args
AbstractCommand& operator = (const AbstractCommand&); // to avoid copy of command args
// qv::CI_COMMAND_ID mCommandId;
qv::CT_COMMAND_TYPE mCommandType;
};
//inlines
//inline const qv::CI_COMMAND_ID& qv::AbstractCommand::getId() const
//{
// return mCommandId;
//}
inline const qv::CT_COMMAND_TYPE& qv::AbstractCommand::getType() const
{
return mCommandType;
}
typedef std::vector<qv::AbstractCommand*> CommandArray;
/// commands vector for fast iteration.
typedef std::tr1::unordered_map<qv::u32, qv::AbstractCommand*> CommandsMap;
/// hashmap of command to command using types.
//typedef std::tr1::unordered_multimap<u32, qv::AbstractCommand*> CommandsMap;
///// hashmap of command args to command using types.
//
//typedef std::pair<CommandsMap::iterator, CommandsMap::iterator> CommandsMapRangeResult;
///// iterator for navegate throught hash_multmap result
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
97
]
]
]
|
38b7361ffa42b30cf909dbc36a82436c51c7ca81 | b2c66c8de198d9915dfc63b8c60cb82e57643a6b | /WordsCheater/trunk/PlacedTileInfo.cpp | c1d495cdcad3042aa42beb7863b379c521429aeb | []
| no_license | feleio/words-with-friends-exhaustive-cheater | 88d6d401c28ef7bb82099c0cd9d77459828b89ca | bc198ee2677be02fc935fb8bb8e74b580f0540df | refs/heads/master | 2021-01-02T08:54:47.975272 | 2011-05-10T14:51:06 | 2011-05-10T14:51:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 560 | cpp | #include "PlacedTileInfo.h"
PlacedTileInfo::PlacedTileInfo()
{
m_row = -1;
m_col = -1;
m_placedChar = 0;
}
PlacedTileInfo::PlacedTileInfo(int row, int col, int ch )
{
m_row = row;
m_col = col;
m_placedChar = ch;
}
bool PlacedTileInfo::operator==( const PlacedTileInfo& rhs ) const
{
return ( m_row == rhs.m_row &&
m_col == rhs.m_col &&
m_placedChar == rhs.m_placedChar );
}
bool PlacedTileInfo::operator!=( const PlacedTileInfo& rhs ) const
{
return !( *this == rhs );
} | [
"[email protected]@2165158a-c2d0-8582-d542-857db5896f79"
]
| [
[
[
1,
28
]
]
]
|
fc824c808ff2e48891185b61a28f109c69c874f8 | ef25bd96604141839b178a2db2c008c7da20c535 | /src/src/Engine/Core/Types/Crc32.cpp | dd7256fa458d4dcbff5f87f7a0b67ecca412b702 | []
| no_license | OtterOrder/crock-rising | fddd471971477c397e783dc6dd1a81efb5dc852c | 543dc542bb313e1f5e34866bd58985775acf375a | refs/heads/master | 2020-12-24T14:57:06.743092 | 2009-07-15T17:15:24 | 2009-07-15T17:15:24 | 32,115,272 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 599 | cpp | #include "Crc32.h"
#include <string.h>
#include "CCRC32.h"
//******************************************************************
/***********************************************************
* Donne le crc32 de la chaîne.
* @param[in] s : chaîne de caractères
* @return crc32 de la chaîne
**********************************************************/
crc32 CRC32_GetCrc32( const char *s )
{
CCRC32 crc32Computer;
crc32 crc32Result;
crc32Computer.Initialize();
crc32Computer.FullCRC( (unsigned char*)s, (unsigned int)strlen( s ), &crc32Result );
return crc32Result;
}
| [
"mathieu.chabanon@7c6770cc-a6a4-11dd-91bf-632da8b6e10b"
]
| [
[
[
1,
20
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.