void node::detach( node_ptr subnode ) { _ASSERT( subnode->get_parent() == this ); remove_subnode( subnode ); subnode->set_parent( NULL ); }
//////////////////////////////////////////////////////////////////////////////////// // GetLeadHashEntryByIndex() // //////////////////////////////////////////////////////////////////////////////////// CHashEntry * CHashTable::GetLeadHashEntryByIndex( DWORD dwIndex ) { _ASSERT( dwIndex < m_dwTableSize ); return m_ppHashTable[ dwIndex ]; }
bool EventCallback::OnBreakpointInternal( Program* prog, Thread* thread, Address address, Enumerator< BPCookie >* iter ) { HRESULT hr = S_OK; int stoppingBPs = 0; while ( iter->MoveNext() ) { if ( iter->GetCurrent() != EntryPointCookie ) { stoppingBPs++; } } iter->Reset(); if ( stoppingBPs > 0 ) { RefPtr<BreakpointEvent> event; CComPtr<IEnumDebugBoundBreakpoints2> enumBPs; hr = MakeCComObject( event ); if ( FAILED( hr ) ) return true; InterfaceArray<IDebugBoundBreakpoint2> array( stoppingBPs ); if ( array.Get() == NULL ) return true; int i = 0; while ( iter->MoveNext() ) { if ( iter->GetCurrent() != EntryPointCookie ) { IDebugBoundBreakpoint2* bp = (IDebugBoundBreakpoint2*) iter->GetCurrent(); _ASSERT( i < stoppingBPs ); array[i] = bp; array[i]->AddRef(); i++; } } hr = MakeEnumWithCount<EnumDebugBoundBreakpoints>( array, &enumBPs ); if ( FAILED( hr ) ) return true; event->Init( enumBPs ); hr = SendEvent( event, prog, thread ); if ( FAILED( hr ) ) return true; return false; } else if ( iter->GetCount() == 0 ) { RefPtr<EmbeddedBreakpointEvent> event; hr = MakeCComObject( event ); if ( FAILED( hr ) ) return true; event->Init( prog ); hr = SendEvent( event, prog, thread ); if ( FAILED( hr ) ) return true; return false; } else if ( (mEntryPoint != 0) && (address == mEntryPoint) ) { RefPtr<EntryPointEvent> entryPointEvent; hr = MakeCComObject( entryPointEvent ); if ( FAILED( hr ) ) return true; hr = SendEvent( entryPointEvent, prog, thread ); if ( FAILED( hr ) ) return true; return false; } return true; }
HRESULT STDMETHODCALLTYPE CaqExtensionRegistrator::get_TargetIntegrationCount(long * Value) { _ASSERT( Value != NULL ); *Value = (long)m_target_integration.size(); return S_OK; }
void FileMap_getPtrs(FileMap *pfm, BYTE **pMem, BYTE **pPastEnd) { _ASSERT(pfm->hFile && pfm->hMap && pfm->pMem); if(pMem) *pMem = (BYTE*)pfm->pMem; if(pPastEnd) *pPastEnd = (BYTE*)pfm->pMem + pfm->size; }
void CaqExtensionRegistrator::SetTargetIntegration(std::vector<GUID> targets) { _ASSERT( targets.size() > 0 ); m_target_integration = targets; }
HRESULT STDMETHODCALLTYPE CaqExtensionRegistrator::get_Name(BSTR * Value) { _ASSERT( Value != NULL ); return m_name.CopyTo(Value); }
STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws) { if (dbcws == NULL || dbcws->szSetting == NULL || dbcws->szModule == NULL || m_bReadOnly) return 1; // the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name int settingNameLen = (int)mir_strlen(dbcws->szSetting); int moduleNameLen = (int)mir_strlen(dbcws->szModule); if (settingNameLen > 0xFE) { #ifdef _DEBUG OutputDebugStringA("WriteContactSetting() got a > 255 setting name length. \n"); #endif return 1; } if (moduleNameLen > 0xFE) { #ifdef _DEBUG OutputDebugStringA("WriteContactSetting() got a > 255 module name length. \n"); #endif return 1; } // used for notifications DBCONTACTWRITESETTING dbcwNotif = *dbcws; if (dbcwNotif.value.type == DBVT_WCHAR) { if (dbcwNotif.value.pszVal != NULL) { char* val = mir_utf8encodeW(dbcwNotif.value.pwszVal); if (val == NULL) return 1; dbcwNotif.value.pszVal = (char*)alloca(mir_strlen(val) + 1); mir_strcpy(dbcwNotif.value.pszVal, val); mir_free(val); dbcwNotif.value.type = DBVT_UTF8; } else return 1; } if (dbcwNotif.szModule == NULL || dbcwNotif.szSetting == NULL) return 1; DBCONTACTWRITESETTING dbcwWork = dbcwNotif; mir_ptr<BYTE> pEncoded(NULL); bool bIsEncrypted = false; switch (dbcwWork.value.type) { case DBVT_BYTE: case DBVT_WORD: case DBVT_DWORD: break; case DBVT_ASCIIZ: case DBVT_UTF8: bIsEncrypted = m_bEncrypted || IsSettingEncrypted(dbcws->szModule, dbcws->szSetting); LBL_WriteString: if (dbcwWork.value.pszVal == NULL) return 1; dbcwWork.value.cchVal = (WORD)mir_strlen(dbcwWork.value.pszVal); if (bIsEncrypted) { size_t len; BYTE *pResult = m_crypto->encodeString(dbcwWork.value.pszVal, &len); if (pResult != NULL) { pEncoded = dbcwWork.value.pbVal = pResult; dbcwWork.value.cpbVal = (WORD)len; dbcwWork.value.type = DBVT_ENCRYPTED; } } break; case DBVT_UNENCRYPTED: dbcwNotif.value.type = dbcwWork.value.type = DBVT_UTF8; goto LBL_WriteString; case DBVT_BLOB: case DBVT_ENCRYPTED: if (dbcwWork.value.pbVal == NULL) return 1; break; default: return 1; } mir_cslockfull lck(m_csDbAccess); DWORD ofsBlobPtr, ofsContact = GetContactOffset(contactID); if (ofsContact == 0) { _ASSERT(false); // contact doesn't exist? return 2; } char *szCachedSettingName = m_cache->GetCachedSetting(dbcwWork.szModule, dbcwWork.szSetting, moduleNameLen, settingNameLen); log3("set [%08p] %s (%p)", hContact, szCachedSettingName, szCachedSettingName); // we don't cache blobs and passwords if (dbcwWork.value.type != DBVT_BLOB && dbcwWork.value.type != DBVT_ENCRYPTED && !bIsEncrypted) { DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(contactID, szCachedSettingName, 1); if (pCachedValue != NULL) { bool bIsIdentical = false; if (pCachedValue->type == dbcwWork.value.type) { switch (dbcwWork.value.type) { case DBVT_BYTE: bIsIdentical = pCachedValue->bVal == dbcwWork.value.bVal; break; case DBVT_WORD: bIsIdentical = pCachedValue->wVal == dbcwWork.value.wVal; break; case DBVT_DWORD: bIsIdentical = pCachedValue->dVal == dbcwWork.value.dVal; break; case DBVT_UTF8: case DBVT_ASCIIZ: bIsIdentical = mir_strcmp(pCachedValue->pszVal, dbcwWork.value.pszVal) == 0; break; } if (bIsIdentical) return 0; } m_cache->SetCachedVariant(&dbcwWork.value, pCachedValue); } if (szCachedSettingName[-1] != 0) { lck.unlock(); log2(" set resident as %s (%p)", printVariant(&dbcwWork.value), pCachedValue); NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwWork); return 0; } } else m_cache->GetCachedValuePtr(contactID, szCachedSettingName, -1); log1(" write database as %s", printVariant(&dbcwWork.value)); DWORD ofsModuleName = GetModuleNameOfs(dbcwWork.szModule); DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL); if (dbc.signature != DBCONTACT_SIGNATURE) return 1; // make sure the module group exists PBYTE pBlob; int bytesRequired, bytesRemaining; DBContactSettings dbcs; DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); if (ofsSettingsGroup == 0) { //module group didn't exist - make it switch (dbcwWork.value.type) { case DBVT_ASCIIZ: case DBVT_UTF8: bytesRequired = dbcwWork.value.cchVal + 2; break; case DBVT_BLOB: case DBVT_ENCRYPTED: bytesRequired = dbcwWork.value.cpbVal + 2; break; default: bytesRequired = dbcwWork.value.type; } bytesRequired += 2 + settingNameLen; bytesRequired += (DB_SETTINGS_RESIZE_GRANULARITY - (bytesRequired % DB_SETTINGS_RESIZE_GRANULARITY)) % DB_SETTINGS_RESIZE_GRANULARITY; ofsSettingsGroup = CreateNewSpace(bytesRequired + offsetof(DBContactSettings, blob)); dbcs.signature = DBCONTACTSETTINGS_SIGNATURE; dbcs.ofsNext = dbc.ofsFirstSettings; dbcs.ofsModuleName = ofsModuleName; dbcs.cbBlob = bytesRequired; dbcs.blob[0] = 0; dbc.ofsFirstSettings = ofsSettingsGroup; DBWrite(ofsContact, &dbc, sizeof(DBContact)); DBWrite(ofsSettingsGroup, &dbcs, sizeof(DBContactSettings)); ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); } else { dbcs = *(DBContactSettings*)DBRead(ofsSettingsGroup, &bytesRemaining); // find if the setting exists ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { NeedBytes(settingNameLen + 1); if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, dbcwWork.szSetting, settingNameLen)) break; NeedBytes(1); MoveAlong(pBlob[0] + 1); NeedBytes(3); MoveAlong(1 + GetSettingValueLength(pBlob)); NeedBytes(1); } // setting already existed, and up to end of name is in cache if (pBlob[0]) { MoveAlong(1 + settingNameLen); // if different type or variable length and length is different NeedBytes(3); if (pBlob[0] != dbcwWork.value.type || ((pBlob[0] == DBVT_ASCIIZ || pBlob[0] == DBVT_UTF8) && *(PWORD)(pBlob + 1) != dbcwWork.value.cchVal) || ((pBlob[0] == DBVT_BLOB || pBlob[0] == DBVT_ENCRYPTED) && *(PWORD)(pBlob + 1) != dbcwWork.value.cpbVal)) { // bin it NeedBytes(3); int nameLen = 1 + settingNameLen; int valLen = 1 + GetSettingValueLength(pBlob); DWORD ofsSettingToCut = ofsBlobPtr - nameLen; MoveAlong(valLen); NeedBytes(1); while (pBlob[0]) { MoveAlong(pBlob[0] + 1); NeedBytes(3); MoveAlong(1 + GetSettingValueLength(pBlob)); NeedBytes(1); } DBMoveChunk(ofsSettingToCut, ofsSettingToCut + nameLen + valLen, ofsBlobPtr + 1 - ofsSettingToCut); ofsBlobPtr -= nameLen + valLen; pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); } else { // replace existing setting at pBlob MoveAlong(1); // skip data type switch (dbcwWork.value.type) { case DBVT_BYTE: DBWrite(ofsBlobPtr, &dbcwWork.value.bVal, 1); break; case DBVT_WORD: DBWrite(ofsBlobPtr, &dbcwWork.value.wVal, 2); break; case DBVT_DWORD: DBWrite(ofsBlobPtr, &dbcwWork.value.dVal, 4); break; case DBVT_BLOB: DBWrite(ofsBlobPtr + 2, dbcwWork.value.pbVal, dbcwWork.value.cpbVal); break; case DBVT_ENCRYPTED: DBWrite(ofsBlobPtr + 2, dbcwWork.value.pbVal, dbcwWork.value.cpbVal); break; case DBVT_UTF8: case DBVT_ASCIIZ: DBWrite(ofsBlobPtr + 2, dbcwWork.value.pszVal, dbcwWork.value.cchVal); break; } // quit DBFlush(1); lck.unlock(); // notify NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwNotif); return 0; } } } // cannot do a simple replace, add setting to end of list // pBlob already points to end of list // see if it fits switch (dbcwWork.value.type) { case DBVT_ASCIIZ: case DBVT_UTF8: bytesRequired = dbcwWork.value.cchVal + 2; break; case DBVT_BLOB: case DBVT_ENCRYPTED: bytesRequired = dbcwWork.value.cpbVal + 2; break; default: bytesRequired = dbcwWork.value.type; } bytesRequired += 2 + settingNameLen; bytesRequired += ofsBlobPtr + 1 - (ofsSettingsGroup + offsetof(DBContactSettings, blob)); if ((DWORD)bytesRequired > dbcs.cbBlob) { // doesn't fit: move entire group DBContactSettings *dbcsPrev; DWORD ofsDbcsPrev, ofsNew; InvalidateSettingsGroupOfsCacheEntry(ofsSettingsGroup); bytesRequired += (DB_SETTINGS_RESIZE_GRANULARITY - (bytesRequired % DB_SETTINGS_RESIZE_GRANULARITY)) % DB_SETTINGS_RESIZE_GRANULARITY; // find previous group to change its offset ofsDbcsPrev = dbc.ofsFirstSettings; if (ofsDbcsPrev == ofsSettingsGroup) ofsDbcsPrev = 0; else { dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, NULL); while (dbcsPrev->ofsNext != ofsSettingsGroup) { if (dbcsPrev->ofsNext == 0) DatabaseCorruption(NULL); ofsDbcsPrev = dbcsPrev->ofsNext; dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, NULL); } } // create the new one ofsNew = ReallocSpace(ofsSettingsGroup, dbcs.cbBlob + offsetof(DBContactSettings, blob), bytesRequired + offsetof(DBContactSettings, blob)); dbcs.cbBlob = bytesRequired; DBWrite(ofsNew, &dbcs, offsetof(DBContactSettings, blob)); if (ofsDbcsPrev == 0) { dbc.ofsFirstSettings = ofsNew; DBWrite(ofsContact, &dbc, sizeof(DBContact)); } else { dbcsPrev = (DBContactSettings*)DBRead(ofsDbcsPrev, NULL); dbcsPrev->ofsNext = ofsNew; DBWrite(ofsDbcsPrev, dbcsPrev, offsetof(DBContactSettings, blob)); } ofsBlobPtr += ofsNew - ofsSettingsGroup; ofsSettingsGroup = ofsNew; pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining); } // we now have a place to put it and enough space: make it DBWrite(ofsBlobPtr, &settingNameLen, 1); DBWrite(ofsBlobPtr + 1, (PVOID)dbcwWork.szSetting, settingNameLen); MoveAlong(1 + settingNameLen); DBWrite(ofsBlobPtr, &dbcwWork.value.type, 1); MoveAlong(1); switch (dbcwWork.value.type) { case DBVT_BYTE: DBWrite(ofsBlobPtr, &dbcwWork.value.bVal, 1); MoveAlong(1); break; case DBVT_WORD: DBWrite(ofsBlobPtr, &dbcwWork.value.wVal, 2); MoveAlong(2); break; case DBVT_DWORD: DBWrite(ofsBlobPtr, &dbcwWork.value.dVal, 4); MoveAlong(4); break; case DBVT_BLOB: DBWrite(ofsBlobPtr, &dbcwWork.value.cpbVal, 2); DBWrite(ofsBlobPtr + 2, dbcwWork.value.pbVal, dbcwWork.value.cpbVal); MoveAlong(2 + dbcwWork.value.cpbVal); break; case DBVT_ENCRYPTED: DBWrite(ofsBlobPtr, &dbcwWork.value.cpbVal, 2); DBWrite(ofsBlobPtr + 2, dbcwWork.value.pbVal, dbcwWork.value.cpbVal); MoveAlong(2 + dbcwWork.value.cpbVal); break; case DBVT_UTF8: case DBVT_ASCIIZ: DBWrite(ofsBlobPtr, &dbcwWork.value.cchVal, 2); DBWrite(ofsBlobPtr + 2, dbcwWork.value.pszVal, dbcwWork.value.cchVal); MoveAlong(2 + dbcwWork.value.cchVal); break; } BYTE zero = 0; DBWrite(ofsBlobPtr, &zero, 1); // quit DBFlush(1); lck.unlock(); // notify NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwNotif); return 0; }
/*!*************************************************************************** @Function Init @Input pContext A pointer to a PVRTContext @Input bRotate true to rotate texture 90 degrees. @Input pszError An option string for returning errors @Return PVR_SUCCESS on success @Description Initialises the background *****************************************************************************/ EPVRTError CPVRTBackground::Init(const SPVRTContext * const pContext, bool bRotate, CPVRTString *pszError) { Destroy(); m_pAPI = new SPVRTBackgroundAPI; if(!m_pAPI) { if(pszError) *pszError = "Error: Insufficient memory to allocate SCPVRTBackgroundAPI."; return PVR_FAIL; } m_pAPI->m_ui32VertexShader = 0; m_pAPI->m_ui32FragShader = 0; m_pAPI->m_ui32ProgramObject = 0; m_pAPI->m_ui32VertexBufferObject = 0; bool bResult; CPVRTString sTmpErrStr; // The shader loading code doesn't expect a null pointer for the error string if(!pszError) pszError = &sTmpErrStr; /* Compiles the shaders. For a more detailed explanation, see IntroducingPVRTools */ // Try binary shaders first bResult = (PVRTShaderLoadBinaryFromMemory(_BackgroundFragShader_fsc, _BackgroundFragShader_fsc_size, GL_FRAGMENT_SHADER, GL_SGX_BINARY_IMG, &m_pAPI->m_ui32FragShader, pszError) == PVR_SUCCESS) && (PVRTShaderLoadBinaryFromMemory(_BackgroundVertShader_vsc, _BackgroundVertShader_vsc_size, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &m_pAPI->m_ui32VertexShader, pszError) == PVR_SUCCESS); if(!bResult) { // if binary shaders don't work, try source shaders bResult = (PVRTShaderLoadSourceFromMemory(_BackgroundFragShader_fsh, GL_FRAGMENT_SHADER, &m_pAPI->m_ui32FragShader, pszError) == PVR_SUCCESS) && (PVRTShaderLoadSourceFromMemory(_BackgroundVertShader_vsh, GL_VERTEX_SHADER, &m_pAPI->m_ui32VertexShader, pszError) == PVR_SUCCESS); } _ASSERT(bResult); if(!bResult) return PVR_FAIL; // Reset the error string if(pszError) *pszError = ""; // Create the shader program m_pAPI->m_ui32ProgramObject = glCreateProgram(); // Attach the fragment and vertex shaders to it glAttachShader(m_pAPI->m_ui32ProgramObject, m_pAPI->m_ui32FragShader); glAttachShader(m_pAPI->m_ui32ProgramObject, m_pAPI->m_ui32VertexShader); // Bind the custom vertex attribute "myVertex" to location VERTEX_ARRAY glBindAttribLocation(m_pAPI->m_ui32ProgramObject, VERTEX_ARRAY, "myVertex"); // Bind the custom vertex attribute "myUV" to location TEXCOORD_ARRAY glBindAttribLocation(m_pAPI->m_ui32ProgramObject, TEXCOORD_ARRAY, "myUV"); // Link the program glLinkProgram(m_pAPI->m_ui32ProgramObject); GLint Linked; glGetProgramiv(m_pAPI->m_ui32ProgramObject, GL_LINK_STATUS, &Linked); if (!Linked) { int i32InfoLogLength, i32CharsWritten; glGetProgramiv(m_pAPI->m_ui32ProgramObject, GL_INFO_LOG_LENGTH, &i32InfoLogLength); char* pszInfoLog = new char[i32InfoLogLength]; glGetProgramInfoLog(m_pAPI->m_ui32ProgramObject, i32InfoLogLength, &i32CharsWritten, pszInfoLog); *pszError = CPVRTString("Failed to link: ") + pszInfoLog + "\n"; delete [] pszInfoLog; bResult = false; } _ASSERT(bResult); if(!bResult) return PVR_FAIL; // Use the loaded shader program glUseProgram(m_pAPI->m_ui32ProgramObject); // Set the sampler2D variable to the first texture unit glUniform1i(glGetUniformLocation(m_pAPI->m_ui32ProgramObject, "sampler2d"), 0); // Create the vertex buffer object GLfloat *pVertexData = 0; // The vertex data for non-rotated GLfloat afVertexData[16] = { -1, -1, 1, -1, -1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1}; // The vertex data for rotated GLfloat afVertexDataRotated[16] = {-1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 0, 1, 1, 0, 0, 0}; if(!bRotate) pVertexData = &afVertexData[0]; else pVertexData = &afVertexDataRotated[0]; glGenBuffers(1, &m_pAPI->m_ui32VertexBufferObject); glBindBuffer(GL_ARRAY_BUFFER, m_pAPI->m_ui32VertexBufferObject); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, pVertexData, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); m_bInit = true; return PVR_SUCCESS; }
void MGridMapModel::SetNodeSize(int nSize) { _ASSERT(nSize>0); m_nCheckNodeSize = nSize; }
extern "C" void __cxa_pure_virtual() { _ASSERT(!!!"Pure virtual call"); while(1);}
/*** CTreeHandler::~CTreeHandler() { int depthno; CTreeLevel** levelarray = 0; CTreeLevel* del_level = 0; //int levelnum; CTreeLevel** curarray = 0; if( rootlevel ){ } DbgOut( "CTreeHandler : destructor : delete treelevel\n" ); if( s2e ){ free( s2e ); s2e = 0; } s2e_leng = 0; DbgOut( "CTreeHandler : destructor : free s2e\n" ); if( d2l ){ // d2l表自体をfree for( depthno = 0; depthno < depthmax; depthno++ ){ curarray = *(d2l + depthno); free( curarray ); } free( d2l ); d2l = 0; } DbgOut( "CTreeHandler : destructor : free d2l\n" ); if( d2lnum ){ free( d2lnum ); d2lnum = 0; } depthmax = 0; DbgOut( "CTreeHandler : destructor : free d2lnum\n" ); } ***/ int CTreeHandler::AddTree( char* srcname, int srcserino ) { //serialno を返す。 //no2ele, depth2ele へのセット //modeによって、同一nameへの対応を変える。 //SetChain もする。 //import時はserialnoを呼び出し側で指定。export時はallocate番号を自動的にセット。 int ret; CTreeElem* parelem = 0; CTreeElem* befelem = 0; if( (mode & TMODE_IMPORT) && (srcserino < 0) ){ DbgOut( "CTreeHandler : AddTree : serialno error %d !!!\n", srcserino ); return -1; } // TMODE_MULT以外は 名前チェック if( mode & TMODE_ONCE ){ // 全ての名前をチェックして、すでにあったら アウト ret = Find( srcname ); if( ret ){ DbgOut( "CTreeHandler : AddTree : TMODE_ONCE : name check error !!!\n" ); return -1; } }else if( mode & TMODE_LEVEL_ONCE ){ // 同じLEVELの名前だけチェックして、すでにあったら アウト ret = Find( srcname, curdepth ); if( ret ){ DbgOut( "CTreeHandler : AddTree : TMODE_LEVEL_ONCE : name check error !!!\n" ); return -1; } } parelem = (*this)( parseri ); befelem = (*this)( befseri ); if( !parelem || !befelem ){ DbgOut( "CTreeHandler : AddTree : invalid elemno error !!! : parseri %d, befseri %d\n", parseri, befseri ); return -1; } switch( addtype ){ case ADDT_DOWN: curseri = AddChild( parelem, srcname, curdepth, srcserino ); //curseri = AddChild( parseri, srcname, curdepth, srcserino ); DbgOut( "CTreeHandler : AddTree : AddChild :%d %s, parseri %d, curdepth %d\n", curseri, srcname, parseri, curdepth ); break; case ADDT_LEVEL: curseri = AddBrother( befelem, srcname, srcserino ); DbgOut( "CTreeHandler : AddTree : AddBrother : %d %s, parseri %d, curdepth %d\n", curseri, srcname, parseri, curdepth ); break; case ADDT_UP: default: // error curseri = -1; break; } //befaddtype = addtype; befseri = curseri; _ASSERT( curseri > 0 ); return curseri; }
/*virtual*/ void CWndToolBar::OnPaint() { const CWndToolBar::CBarItem* pItems = GetMenuItems(); int nFocus = m_nFocus; // find nearest sub menu int nMenu = nFocus; while ( pItems[nMenu].m_eType == CBarItem::ISub && nMenu > 0 ) nMenu--; _ASSERT( pItems[nMenu].m_eType == CBarItem::IMain ); int x = m_rcClient.left; int nExtentx = (strlen(pItems[nMenu].m_pName) << 3); if ( nFocus == nMenu && HasFocus() ) { x += BIOS::LCD::Draw(x, 0, RGB565(ffffff), RGB565(000000), CShapes::corner_left); BIOS::LCD::Bar( x, m_rcClient.top, x + nExtentx, m_rcClient.bottom, RGB565(FFFFFF)); x += BIOS::LCD::Print(x, 0, RGB565(000000), RGBTRANS, pItems[nMenu].m_pName); } else { x += BIOS::LCD::Draw(x, 0, RGB565(0020ff), RGB565(000000), CShapes::corner_left); BIOS::LCD::Bar( x, m_rcClient.top, x + nExtentx, m_rcClient.bottom, RGB565(0020ff)); x += BIOS::LCD::Print(x, 0, RGB565(ffffff), RGBTRANS, pItems[nMenu].m_pName); } CRect rcSub( m_rcClient ); rcSub.left = x; // gradient background CDesign::GradientTop( rcSub ); if ( nFocus == nMenu && HasFocus() ) x += BIOS::LCD::Draw(x, 0, RGB565(ffffff), RGBTRANS, CShapes::corner_right); else x += BIOS::LCD::Draw(x, 0, RGB565(0020ff), RGBTRANS, CShapes::corner_right); x += 10; int nIgnoreFirst = 1; // 1 -> first sub menu // calculate how many items we need to hide from left to reach the selected one int nRequired = 0; int nAvailable = BIOS::LCD::LcdWidth - 16 - x; // 16px reserved for arrows for ( int i = nFocus; i > 0 && pItems[i].m_eType != CBarItem::IMain; i-- ) { nRequired += strlen(pItems[i].m_pName)*8 + 16; if ( nRequired > nAvailable ) nIgnoreFirst++; } if ( nIgnoreFirst > 1 ) x += BIOS::LCD::Print( x, m_rcClient.top, RGB565(b0b0b0), RGBTRANS, "\x11"); for ( int i = nMenu+nIgnoreFirst; pItems[i].m_eType == CBarItem::ISub; i++ ) { ui8 bSelected = (i==nFocus); u16 clr = bSelected ? clrSelected : clrNormal; u16 bgr = bSelected ? 0 : RGBTRANS; if ( HasFocus() && bSelected ) { clr = clrSelectedFocus; bgr = bgrSelectedFocus; } if ( x + 16 + strlen(pItems[i].m_pName)*8 >= BIOS::LCD::LcdWidth ) { x += BIOS::LCD::Print( x, m_rcClient.top, RGB565(b0b0b0), RGBTRANS, "\x10"); break; } if ( bSelected ) x += BIOS::LCD::Draw( x, m_rcClient.top, bgr, RGBTRANS, CShapes::corner_left); else x += 8; if ( bSelected ) BIOS::LCD::Bar( x, m_rcClient.top, x + (strlen(pItems[i].m_pName)<<3), m_rcClient.bottom, bgr); x += BIOS::LCD::Print( x, m_rcClient.top, clr, bgr, pItems[i].m_pName); if ( bSelected ) x += BIOS::LCD::Draw( x, m_rcClient.top, bgr, RGBTRANS, CShapes::corner_right); else x += 8; } }
void TopPane::UpdateBits() { /* ORIGINAL ALLEGIANCE VERSION. ZEnter("TopPane::UpdateBits()"); if (m_bNeedPaint) { ZTrace("m_bNeedPaint == true"); if (CalcPaint()) { m_bNeedPaint = true; m_bPaintAll = true; } ZTrace("after CalcPaint() m_bNeedPaint ==" + ZString(m_bNeedPaint)); ZTrace("after CalcPaint() m_bPaintAll ==" + ZString(m_bPaintAll )); m_bPaintAll |= g_bPaintAll; InternalPaint(m_psurface); m_bNeedPaint = false; } ZExit("TopPane::UpdateBits()");*/ ZEnter("TopPane::UpdateBits()"); { HRESULT hr; bool bRenderTargetRequired; PrivateSurface* pprivateSurface; CastTo(pprivateSurface, m_psurface); bRenderTargetRequired = pprivateSurface->GetSurfaceType().Test(SurfaceTypeRenderTarget() ) == true; if( bRenderTargetRequired == true ) { TEXHANDLE hTexture = pprivateSurface->GetTexHandle( ); _ASSERT( hTexture != INVALID_TEX_HANDLE ); hr = CVRAMManager::Get()->PushRenderTarget( hTexture ); } ZTrace("m_bNeedPaint == true"); CalcPaint(); m_bNeedPaint = true; m_bPaintAll = true; ZTrace("after CalcPaint() m_bPaintAll ==" + ZString(m_bPaintAll )); WinPoint offset( 0, 0 ); // Call InternalPaint() with the child offset and parent size as params and create initial clipping rect. WinRect rectClip( 0, 0, (int) m_psurface->GetSize().X(), (int) m_psurface->GetSize().Y() ); m_bPaintAll |= g_bPaintAll; InternalPaint( m_psurface ); m_bNeedPaint = false; if( bRenderTargetRequired == true ) { CVRAMManager::Get()->PopRenderTarget( ); } } ZExit("TopPane::UpdateBits()"); /* { ZTrace("m_bNeedPaint == true"); CalcPaint(); m_bNeedPaint = true; m_bPaintAll = true; ZTrace("after CalcPaint() m_bNeedPaint ==" + ZString(m_bNeedPaint)); ZTrace("after CalcPaint() m_bPaintAll ==" + ZString(m_bPaintAll )); m_bPaintAll |= g_bPaintAll; // localOffset.SetY( localOffset.Y() - (int)m_psurface->GetSize().Y() ); // localOffset += globalOffset; WinPoint offset( localOffset ); // Remove offset now. offset.SetY( offset.Y() - (int)m_psurface->GetSize().Y() ); // Call InternalPaint() with the child offset and parent size as params and create initial clipping rect. WinRect rectClip( offset.X(), offset.Y(), offset.X() + (int) m_psurface->GetSize().X(), offset.Y() + (int) m_psurface->GetSize().Y() ); // m_psurface is a dummy surface. Store the context. InternalPaint( m_psurface, offset, rectClip ); m_bNeedPaint = false; } ZExit("TopPane::UpdateBits()");*/ }
void STDMETHODCALLTYPE CaqExtensionRegistrator::GetKey(GUID * Value) { _ASSERT( Value != NULL ); _ASSERT( m_key != CLSID_NULL ); // SetDescription must be called *Value = m_key; }
ZRule* ZRule::CreateRule(ZMatch* pMatch, CCMATCH_GAMETYPE nGameType) { switch(nGameType) { case CCMATCH_GAMETYPE_DEATHMATCH_SOLO: { return (new ZRuleSoloDeathMatch(pMatch)); } break; case CCMATCH_GAMETYPE_DEATHMATCH_TEAM: { return (new ZRuleTeamDeathMatch(pMatch)); } break; case CCMATCH_GAMETYPE_GLADIATOR_SOLO: { return (new ZRuleSoloGladiator(pMatch)); } break; case CCMATCH_GAMETYPE_GLADIATOR_TEAM: { return (new ZRuleTeamGladiator(pMatch)); } break; case CCMATCH_GAMETYPE_ASSASSINATE: { return (new ZRuleAssassinate(pMatch)); } break; case CCMATCH_GAMETYPE_TRAINING: { return (new ZRuleTraining(pMatch)); } break; #ifdef _QUEST case CCMATCH_GAMETYPE_SURVIVAL: { return (new ZRuleSurvival(pMatch)); } break; case CCMATCH_GAMETYPE_QUEST: { return (new ZRuleQuest(pMatch)); } break; #endif case CCMATCH_GAMETYPE_BERSERKER: { return (new ZRuleBerserker(pMatch)); } break; case CCMATCH_GAMETYPE_DEATHMATCH_TEAM2: { return (new ZRuleTeamDeathMatch2(pMatch)); } break; case CCMATCH_GAMETYPE_DUEL: { return (new ZRuleDuel(pMatch)); } break; case CCMATCH_GAMETYPE_DUELTOURNAMENT: { return (new ZRuleDuelTournament(pMatch)); } break; default: { // 게임 타입이 없습니다. _ASSERT(0); } } return NULL; }
void CaqExtensionRegistrator::AddPlugin(const CRegPluginInfo* reg_info) { _ASSERT( reg_info != NULL ); _ASSERT( reg_info->PluginCreator != NULL ); m_plugins_info.push_back(*reg_info); }
EIO_Status CConnTest::HttpOkay(string* reason) { SConnNetInfo* net_info = ConnNetInfo_Create(0, m_DebugPrintout); if (net_info) { if (*net_info->http_proxy_host && net_info->http_proxy_port) m_HttpProxy = true; // Make sure there are no extras ConnNetInfo_SetUserHeader(net_info, 0); net_info->args[0] = '\0'; } PreCheck(eHttp, 0/*main*/, "Checking whether NCBI is HTTP accessible"); string host(net_info ? net_info->host : DEF_CONN_HOST); string port(net_info && net_info->port ? ':' + NStr::UIntToString(net_info->port) : kEmptyStr); CConn_HttpStream http("http://" + host + port + "/Service/index.html", net_info, kEmptyStr/*user_header*/, 0/*flags*/, 0, 0, 0, 0, m_Timeout); http.SetCanceledCallback(m_Canceled); string temp; http >> temp; EIO_Status status = ConnStatus(temp.empty(), &http); if (status == eIO_Interrupt) temp = kCanceled; else if (status == eIO_Success) temp = "OK"; else { if (status == eIO_Timeout) temp = x_TimeoutMsg(); else temp.clear(); if (NStr::CompareNocase(host, DEF_CONN_HOST) != 0 || !port.empty()) { int n = 0; temp += "Make sure that "; if (host != DEF_CONN_HOST) { n++; temp += "[CONN]HOST=\""; temp += host; temp += port.empty() ? "\"" : "\" and "; } if (!port.empty()) { n++; temp += "[CONN]PORT=\""; temp += port.c_str() + 1; temp += '"'; } _ASSERT(n); temp += n > 1 ? " are" : " is"; temp += " redefined correctly\n"; } if (m_HttpProxy) { temp += "Make sure that the HTTP proxy server \'"; temp += net_info->http_proxy_host; temp += ':'; temp += NStr::UIntToString(net_info->http_proxy_port); temp += "' specified with [CONN]HTTP_PROXY_{HOST|PORT}" " is correct"; } else { temp += "If your network access requires the use of an HTTP proxy" " server, please contact your network administrator and set" " [CONN]HTTP_PROXY_{HOST|PORT} in your configuration" " accordingly"; } temp += "; and if your proxy server requires authorization, please" " check that appropriate [CONN]HTTP_PROXY_{USER|PASS} have been" " specified\n"; if (net_info && (*net_info->user || *net_info->pass)) { temp += "Make sure there are no stray [CONN]{USER|PASS} appear in" " your configuration -- NCBI services neither require nor use" " them\n"; } } PostCheck(eHttp, 0/*main*/, status, temp); ConnNetInfo_Destroy(net_info); if (reason) reason->swap(temp); return status; }
void CaqExtensionRegistrator::SetTargetProduct(std::vector<GUID> targets) { _ASSERT( targets.size() > 0 ); m_target_product = targets; }
EIO_Status CConnTest::GetFWConnections(string* reason) { SConnNetInfo* net_info = ConnNetInfo_Create(0, m_DebugPrintout); if (net_info) { const char* user_header; net_info->req_method = eReqMethod_Post; if (net_info->firewall) { user_header = "NCBI-RELAY: FALSE"; m_Firewall = true; } else user_header = "NCBI-RELAY: TRUE"; if (net_info->stateless) m_Stateless = true; ConnNetInfo_OverrideUserHeader(net_info, user_header); ConnNetInfo_SetupStandardArgs(net_info, 0/*w/o service*/); } string temp(m_Firewall ? "FIREWALL" : "RELAY (legacy)"); temp += " connection mode has been detected for stateful services\n"; if (m_Firewall) { temp += "This mode requires your firewall to be configured in such a" " way that it allows outbound connections to the port range [" STRINGIFY(CONN_FWD_PORT_MIN) ".." STRINGIFY(CONN_FWD_PORT_MAX) "] (inclusive) at the two fixed NCBI hosts, 130.14.29.112" " and 165.112.7.12\n" "To set that up correctly, please have your network administrator" " read the following (if they have not already done so):" " " NCBI_FWDOC_URL "\n"; } else { temp += "This is an obsolescent mode that requires keeping a wide port" " range [4444..4544] (inclusive) open to let through connections" " to any NCBI host (130.14.2x.xxx/165.112.xx.xxx) -- this mode was" " designed for unrestricted networks when firewall port blocking" " was not an issue\n"; } if (m_Firewall) { _ASSERT(net_info); switch (net_info->firewall) { case eFWMode_Adaptive: temp += "There are also fallback connection ports such as " STRINGIFY(CONN_PORT_SSH) " and " STRINGIFY(CONN_PORT_HTTPS) " at 130.14.29.112. They will be used if connections to" " the ports in the range described above have failed\n"; break; case eFWMode_Firewall: temp += "Also, your configuration explicitly forbids to use any" " fallback firewall ports that may exist to improve network" " connectivity\n"; break; case eFWMode_Fallback: temp += "However, your configuration explicitly requests that only" " fallback firewall ports (if any exist) are to be used for" " connections: this also implies that no conventional ports" " from the range above will be used\n"; break; default: temp += "Internal program error, please report!\n"; _ASSERT(0); break; } } else { temp += "This mode may not be reliable if your site has a restrictive" " firewall imposing fine-grained control over which hosts and" " ports the outbound connections are allowed to use\n"; } if (m_HttpProxy) { temp += "Connections to the aforementioned ports will be made via an" " HTTP proxy at '"; temp += net_info->http_proxy_host; temp += ':'; temp += NStr::UIntToString(net_info->http_proxy_port); temp += "'"; if (net_info && net_info->http_proxy_leak) { temp += ". If that is unsuccessful, a link bypassing the proxy" " will then be attempted"; } if (m_Firewall && *net_info->proxy_host) temp += ". In addition, your"; } if (m_Firewall && *net_info->proxy_host) { if (!m_HttpProxy) temp += "Your"; temp += " configuration specifies that instead of connecting directly" " to NCBI addresses, a forwarding non-transparent proxy host '"; temp += net_info->proxy_host; temp += "' should be used for all links"; if (m_HttpProxy) temp += " (including those originating from the HTTP proxy)"; } temp += '\n'; PreCheck(eFirewallConnPoints, 0/*main*/, temp); PreCheck(eFirewallConnPoints, 1/*sub*/, "Obtaining current NCBI " + string(m_Firewall ? "firewall settings" : "service entries")); EIO_Status status = x_GetFirewallConfiguration(net_info); if (status == eIO_Interrupt) temp = kCanceled; else if (status == eIO_Success) { if (!m_Fwd.empty() || (!m_FwdFB.empty() && m_Firewall && net_info->firewall == eFWMode_Fallback)) { temp = "OK: "; if (!m_Fwd.empty()) { stable_sort(m_Fwd.begin(), m_Fwd.end()); temp += NStr::UInt8ToString(m_Fwd.size()); } if (!m_FwdFB.empty()) { stable_sort(m_FwdFB.begin(), m_FwdFB.end()); if (!m_Fwd.empty()) temp += " + "; temp += NStr::UInt8ToString(m_FwdFB.size()); } temp += m_Fwd.size() + m_FwdFB.size() == 1 ? " port" : " ports"; } else { status = eIO_Unknown; temp = "No connection ports found, please contact " + HELP_EMAIL; } } else if (status == eIO_Timeout) { temp = x_TimeoutMsg(); if (m_Timeout > kTimeout) temp += "You may want to contact " + HELP_EMAIL; } else temp = "Please contact " + HELP_EMAIL; PostCheck(eFirewallConnPoints, 1/*sub*/, status, temp); ConnNetInfo_Destroy(net_info); if (status == eIO_Success) { PreCheck(eFirewallConnPoints, 2/*sub*/, "Verifying configuration for consistency"); bool firewall = true; // Check primary ports only ITERATE(vector<CConnTest::CFWConnPoint>, cp, m_Fwd) { if (cp->port < CONN_FWD_PORT_MIN || CONN_FWD_PORT_MAX < cp->port) firewall = false; if (cp->status != eIO_Success) { status = cp->status; temp = CSocketAPI::HostPortToString(cp->host, cp->port); temp += " is not operational, please contact " + HELP_EMAIL; break; } } if (status == eIO_Success) { if (!m_Firewall && !m_FwdFB.empty()) { status = eIO_Unknown; temp = "Fallback ports found in non-firewall mode, please" " contact " + HELP_EMAIL; } else if (m_Firewall != firewall) { status = eIO_Unknown; temp = "Firewall "; temp += firewall ? "wrongly" : "not"; temp += " acknowledged, please contact " + HELP_EMAIL; } else temp.resize(2); } PostCheck(eFirewallConnPoints, 2/*sub*/, status, temp); }
HRESULT STDMETHODCALLTYPE CaqExtensionRegistrator::get_Copyright(BSTR * Value) { _ASSERT( Value != NULL ); return m_copyright.CopyTo(Value); }
void CTraderApi::RunInThread() { int iRet = 0; while (!m_reqList.empty()&&m_bRunning) { SRequest * pRequest = m_reqList.front(); int lRequest = ++m_lRequestID;// 这个地方是否会出现原子操作的问题呢? switch(pRequest->type) { case E_ReqAuthenticateField: iRet = m_pApi->ReqAuthenticate(&pRequest->ReqAuthenticateField,lRequest); break; case E_ReqUserLoginField: iRet = m_pApi->ReqUserLogin(&pRequest->ReqUserLoginField,lRequest); break; case E_SettlementInfoConfirmField: iRet = m_pApi->ReqSettlementInfoConfirm(&pRequest->SettlementInfoConfirmField,lRequest); break; case E_QryInstrumentField: iRet = m_pApi->ReqQryInstrument(&pRequest->QryInstrumentField,lRequest); break; case E_QryTradingAccountField: iRet = m_pApi->ReqQryTradingAccount(&pRequest->QryTradingAccountField,lRequest); break; case E_QryInvestorPositionField: iRet = m_pApi->ReqQryInvestorPosition(&pRequest->QryInvestorPositionField,lRequest); break; case E_QryInvestorPositionDetailField: iRet=m_pApi->ReqQryInvestorPositionDetail(&pRequest->QryInvestorPositionDetailField,lRequest); break; case E_QryInstrumentCommissionRateField: iRet = m_pApi->ReqQryInstrumentCommissionRate(&pRequest->QryInstrumentCommissionRateField,lRequest); break; case E_QryInstrumentMarginRateField: iRet = m_pApi->ReqQryInstrumentMarginRate(&pRequest->QryInstrumentMarginRateField,lRequest); break; case E_QryDepthMarketDataField: iRet = m_pApi->ReqQryDepthMarketData(&pRequest->QryDepthMarketDataField,lRequest); break; default: _ASSERT(FALSE); break; } if (0 == iRet) { //返回成功,填加到已发送池 m_nSleep = 1; AddRequestMapBuf(lRequest,pRequest); lock_guard<mutex> cl(m_csList); m_reqList.pop_front(); } else { //失败,按4的幂进行延时,但不超过1s m_nSleep *= 4; m_nSleep %= 1023; } Sleep(m_nSleep); } //清理线程 CloseHandle(m_hThread); m_hThread = NULL; m_bRunning = false; }
BOOL LoginDialog::onCommand(UINT controlID, UINT notificationID) { switch (controlID) { case IDC_CSERVER: switch (notificationID) { case CBN_DROPDOWN: updateHistory(); break; // select item in ComboBox with list of history case CBN_SELENDOK: { int selectedItemIndex = m_server.getSelectedItemIndex(); if (selectedItemIndex < 0) { return FALSE; } StringStorage server; m_server.getItemText(selectedItemIndex, &server); ConnectionConfigSM ccsm(RegistryPaths::VIEWER_PATH, server.getString()); m_connectionConfig.loadFromStorage(&ccsm); break; } } enableConnect(); break; // click "Connect" case IDOK: onConnect(); kill(0); break; // cancel connection case IDCANCEL: kill(0); break; case IDC_BCONFIGURATION: onConfiguration(); break; case IDC_BOPTIONS: return onOptions(); case IDC_LISTENING: onListening(); kill(0); break; case IDC_ORDER_SUPPORT_BUTTON: onOrder(); break; case IDC_BABOUT: onAbout(); break; default: _ASSERT(true); return FALSE; } return TRUE; }
HRESULT STDMETHODCALLTYPE CaqExtensionRegistrator::get_TargetProductCount(long * Value) { _ASSERT( Value != NULL ); *Value = (long)m_target_product.size(); return S_OK; }
//-------------------------------------------------------------------------------- /// 4. 임시저장 zip화일을 loading해서 서버로 보낸다. //-------------------------------------------------------------------------------- bool CClanMarkTransfer::SendToServerTempZipFile( const char* TempZipFileName, WORD* pBumCRC16, DWORD* pdwFileSizeHigh, DWORD* pdwFileSizeLow ) { HANDLE hTempZipFile = CreateFile( TempZipFileName, GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_READONLY,NULL ); if( hTempZipFile == INVALID_HANDLE_VALUE ) { DWORD dwErr = GetLastError(); _RPTF1( _CRT_ASSERT,"CreateFile Error : Temporary ZipFile - Invalid_handle_value(%d)", dwErr ); g_itMGR.OpenMsgBox( "CClanMarkTranser::SendToServerTempZipFile - CreateFile Error" ); return false; } *pdwFileSizeLow = GetFileSize( hTempZipFile, pdwFileSizeHigh ); if( *pdwFileSizeLow == INVALID_FILE_SIZE ) { DWORD dwErr = GetLastError(); if( *pdwFileSizeHigh == 0 ) { _RPTF1( _CRT_ASSERT,"GetFileSize Error(%d)", dwErr ); } else { if( dwErr != NO_ERROR ) { _RPTF0( _CRT_ASSERT,"GetFileSize Error" ); } } g_itMGR.OpenMsgBox(" CClanMarkTransfer::SendToServerTempZipFile - GetFileSize Error"); } else { _ASSERT( *pdwFileSizeHigh == 0 );///2^32 크기만 지원한다. 더큰 사이즈일경우는 무시한다. if( *pdwFileSizeHigh == 0 ) { BYTE* buffer = new BYTE[ *pdwFileSizeLow ]; DWORD NumberOfBytesReadZipFile; if( ReadFile( hTempZipFile, buffer, *pdwFileSizeLow, &NumberOfBytesReadZipFile, NULL ) ) { assert( *pdwFileSizeLow == NumberOfBytesReadZipFile ); assert( NumberOfBytesReadZipFile <= 1000 ); if( NumberOfBytesReadZipFile <= 1000 ) { g_pNet->Send_cli_CLANMARK_SET( buffer, NumberOfBytesReadZipFile, *pBumCRC16 ); } else { _RPTF0( _CRT_ASSERT,"Size is too big" ); g_itMGR.OpenMsgBox( CStr::Printf("%s %s",STR_CLANMARK_INVALID_SIZE,STR_CLANMARK_HELP_HOMEPAGE) ); } } else { _RPTF0( _CRT_ASSERT,"ReadFile Error:Temporary ZipFile" ); g_itMGR.OpenMsgBox( "ReadFile Error:Temporary ZipFile"); } delete[] buffer; } } CloseHandle( hTempZipFile ); return true; }
HRESULT STDMETHODCALLTYPE CaqExtensionRegistrator::get_PluginCount(long * Value) { _ASSERT( Value != NULL ); *Value = (long)m_plugins_info.size(); return S_OK; }
ISkill* KSkillManager::InstanceSkill( unsigned long ulSkillID, unsigned long ulSkillLevel) { ISkill *pRetSkill = NULL; int nStyle = GetSkillStyle(ulSkillID); switch (nStyle) // eSkillStyle { case SKILL_SS_Missles: // 子弹类 本技能用于发送子弹类 case SKILL_SS_Melee: case SKILL_SS_InitiativeNpcState: // 主动类 本技能用于改变当前Npc的主动状态 case SKILL_SS_PassivityNpcState: // 被动类 本技能用于改变Npc的被动状态 { KSkill * pNewOrdinSkill = NULL; unsigned long ulFirstLoadLevel = 0; if (m_pOrdinSkill[ulSkillID - 1][ulSkillLevel - 1]) { pRetSkill = m_pOrdinSkill[ulSkillID - 1][ulSkillLevel - 1]; goto Exit1; } pNewOrdinSkill = new KSkill; ulFirstLoadLevel = m_SkillInfo[ulSkillID - 1].m_ulFirstLoadLevel; if (!ulFirstLoadLevel) { pNewOrdinSkill->GetInfoFromTabFile(m_SkillInfo[ulSkillID - 1].m_nTabFileRowId); pNewOrdinSkill->LoadSkillLevelData(ulSkillLevel, m_SkillInfo[ulSkillID - 1].m_nTabFileRowId); m_SkillInfo[ulSkillID - 1].m_ulFirstLoadLevel = ulSkillLevel; } else { _ASSERT(m_pOrdinSkill[ulSkillID - 1][ulFirstLoadLevel - 1]); *pNewOrdinSkill = *(KSkill*)m_pOrdinSkill[ulSkillID - 1][ulFirstLoadLevel - 1]; pNewOrdinSkill->LoadSkillLevelData(ulSkillLevel, m_SkillInfo[ulSkillID - 1].m_nTabFileRowId); } pNewOrdinSkill->SetSkillId(ulSkillID); pNewOrdinSkill->SetSkillLevel(ulSkillLevel); m_pOrdinSkill[ulSkillID - 1][ulSkillLevel - 1] = pNewOrdinSkill; pRetSkill = pNewOrdinSkill; pNewOrdinSkill = NULL; } break; case SKILL_SS_Thief: { if (!m_pOrdinSkill[ulSkillID - 1][0]) { m_pOrdinSkill[ulSkillID - 1][0] = (ISkill*)new KThiefSkill; } pRetSkill = m_pOrdinSkill[ulSkillID - 1][0]; ((KThiefSkill*)pRetSkill)->LoadSetting(THIEFSKILL_SETTINGFILE); }break; default: goto Exit0; } Exit1: Exit0: return pRetSkill; }
HRESULT STDMETHODCALLTYPE CaqExtensionRegistrator::get_PluginDescription(long Index, BSTR * Value) { _ASSERT( Value != NULL ); if ((Index < 0) || (Index >= (long)m_plugins_info.size())) return E_INVALIDARG; return m_plugins_info[Index].Description.CopyTo(Value); }
/*!*************************************************************************** @Function PVRTMatrixLinearEqSolveF @Input pSrc 2D array of floats. 4 Eq linear problem is 5x4 matrix, constants in first column @Input nCnt Number of equations to solve @Output pRes Result @Description Solves 'nCnt' simultaneous equations of 'nCnt' variables. pRes should be an array large enough to contain the results: the values of the 'nCnt' variables. This fn recursively uses Gaussian Elimination. *****************************************************************************/ void PVRTMatrixLinearEqSolveF( float * const pRes, float ** const pSrc, // 2D array of floats. 4 Eq linear problem is 5x4 matrix, constants in first column. const int nCnt) { int i, j, k; float f; #if 0 /* Show the matrix in debug output */ _RPT1(_CRT_WARN, "LinearEqSolve(%d)\n", nCnt); for(i = 0; i < nCnt; ++i) { _RPT1(_CRT_WARN, "%.8f |", pSrc[i][0]); for(j = 1; j <= nCnt; ++j) _RPT1(_CRT_WARN, " %.8f", pSrc[i][j]); _RPT0(_CRT_WARN, "\n"); } #endif if(nCnt == 1) { _ASSERT(pSrc[0][1] != 0); pRes[0] = pSrc[0][0] / pSrc[0][1]; return; } // Loop backwards in an attempt avoid the need to swap rows i = nCnt; while(i) { --i; if(pSrc[i][nCnt] != 0) { // Row i can be used to zero the other rows; let's move it to the bottom if(i != (nCnt-1)) { for(j = 0; j <= nCnt; ++j) { // Swap the two values f = pSrc[nCnt-1][j]; pSrc[nCnt-1][j] = pSrc[i][j]; pSrc[i][j] = f; } } // Now zero the last columns of the top rows for(j = 0; j < (nCnt-1); ++j) { _ASSERT(pSrc[nCnt-1][nCnt] != 0); f = pSrc[j][nCnt] / pSrc[nCnt-1][nCnt]; // No need to actually calculate a zero for the final column for(k = 0; k < nCnt; ++k) { pSrc[j][k] -= f * pSrc[nCnt-1][k]; } } break; } } // Solve the top-left sub matrix PVRTMatrixLinearEqSolveF(pRes, pSrc, nCnt - 1); // Now calc the solution for the bottom row f = pSrc[nCnt-1][0]; for(k = 1; k < nCnt; ++k) { f -= pSrc[nCnt-1][k] * pRes[k-1]; } _ASSERT(pSrc[nCnt-1][nCnt] != 0); f /= pSrc[nCnt-1][nCnt]; pRes[nCnt-1] = f; #if 0 { float fCnt; /* Verify that the result is correct */ fCnt = 0; for(i = 1; i <= nCnt; ++i) fCnt += pSrc[nCnt-1][i] * pRes[i-1]; _ASSERT(abs(fCnt - pSrc[nCnt-1][0]) < 1e-3); } #endif }
void ZObserver::OnDraw(MDrawContext* pDC) { if ( g_pGame->IsReplay() && !g_pGame->IsShowReplayInfo()) return; if ( m_pTargetCharacter == NULL) return; if ( ZGetCamera()->GetLookMode() == ZCAMERA_MINIMAP) return; if ( ZGetMyInfo()->IsAdminGrade()) { MFont *pFont=MFontManager::Get("FONTb11b"); if ( pFont == NULL) _ASSERT(0); pDC->SetFont(pFont); MCOLOR backgroundcolor; if ( m_pTargetCharacter->GetTeamID() == MMT_RED) backgroundcolor = MCOLOR(100,0,0, 150); else if ( m_pTargetCharacter->GetTeamID() == MMT_BLUE) backgroundcolor = MCOLOR(0,0,100, 150); else backgroundcolor = MCOLOR(0,0,0, 150); pDC->SetColor(backgroundcolor); pDC->FillRectangle( MGetWorkspaceWidth() / 2 - 170, MGetWorkspaceHeight() * (650.0f/800.0f) - 7, 340, 30); backgroundcolor = MCOLOR( 255,255,255, 255); pDC->SetColor( backgroundcolor); char szName[128]; sprintf_safe( szName, "%s (HP:%d, AP:%d)", m_pTargetCharacter->GetUserName(), m_pTargetCharacter->GetHP(), m_pTargetCharacter->GetAP()); TextRelative(pDC, 0.5f, 650.0f/800.0f, szName, true); } else if ( ZApplication::GetGame()->GetMatch()->GetMatchType() == MMATCH_GAMETYPE_DUEL) { char charName[3][100]; charName[0][0] = charName[1][0] = charName[2][0] = 0; float fMaxHP[ 2]={ 0.0f, 0.0f}, fMaxAP[ 2]={ 0.0f, 0.0f}; int nHP[ 2]={ 0, 0}, nAP[ 2]={ 0, 0}; bool bExistNextChallenger = false; bool bIsChampOserved = false; bool bIsChlngOserved = false; ZRuleDuel* pDuel = (ZRuleDuel*)ZGetGameInterface()->GetGame()->GetMatch()->GetRule(); for (ZCharacterManager::iterator itor = ZGetCharacterManager()->begin(); itor != ZGetCharacterManager()->end(); ++itor) { ZCharacter* pCharacter = (*itor).second; // Champion if (pCharacter->GetUID() == pDuel->QInfo.m_uidChampion) { strcpy_safe(charName[0], pCharacter->GetUserName()); fMaxHP[ 0] = pCharacter->GetProperty()->fMaxHP; fMaxAP[ 0] = pCharacter->GetProperty()->fMaxAP; if ( pCharacter->IsDie()) { nHP[ 0] = 0; nAP[ 0] = 0; } else { nHP[ 0] = pCharacter->GetHP(); nAP[ 0] = pCharacter->GetAP(); } if ( m_pTargetCharacter) { if ( pCharacter->GetUID() == m_pTargetCharacter->GetUID()) bIsChampOserved = true; } } // Challenger else if (pCharacter->GetUID() == pDuel->QInfo.m_uidChallenger) { strcpy_safe(charName[1], pCharacter->GetUserName()); fMaxHP[ 1] = pCharacter->GetProperty()->fMaxHP; fMaxAP[ 1] = pCharacter->GetProperty()->fMaxAP; if ( pCharacter->IsDie()) { nHP[ 1] = 0; nAP[ 1] = 0; } else { nHP[ 1] = pCharacter->GetHP(); nAP[ 1] = pCharacter->GetAP(); } if ( m_pTargetCharacter) { if ( pCharacter->GetUID() == m_pTargetCharacter->GetUID()) bIsChlngOserved = true; } } // Waiting else if (pCharacter->GetUID() == pDuel->QInfo.m_WaitQueue[0]) { strcpy_safe(charName[2], pCharacter->GetUserName()); bExistNextChallenger = true; } } float fRx = (float)MGetWorkspaceWidth() / 800.0f; float fRy = (float)MGetWorkspaceHeight() / 600.0f; int nWidth; float fPosy; float fLength; float fHeight; // HP fPosy = 10.0f*fRy; fLength = 163.0f*fRx; fHeight = 23.0f*fRy; pDC->SetColor( 255, 0, 0, 210); nWidth = (int)( (float)nHP[0] / fMaxHP[0] * fLength); pDC->FillRectangle( (193.0f+163.0f)*fRx-nWidth, fPosy, nWidth, fHeight); nWidth = (int)( (float)nHP[1] / fMaxHP[1] * fLength); pDC->FillRectangle( 444.0f*fRx, fPosy, nWidth, fHeight); // AP pDC->SetColor( 0, 50, 0, 170); pDC->FillRectangle( 218.0f*fRx, 37.0f*fRy, 150.0f*fRx, 5.0f*fRy); pDC->FillRectangle( 432.0f*fRx, 37.0f*fRy, 150.0f*fRx, 5.0f*fRy); pDC->SetColor( 0, 255, 0, 100); nWidth = (int)( (float)nAP[0] / fMaxAP[0] * 150.0f * fRx); pDC->FillRectangle( (218.0f+150.0f)*fRx-nWidth, 37.0f*fRy, nWidth, 5.0f*fRy); nWidth = (int)( (float)nAP[1] / fMaxAP[1] * 150.0f * fRx); pDC->FillRectangle( 432.0f*fRx, 37.0f*fRy, nWidth, 5.0f*fRy); // °ÔÀÌÁö ÇÁ·¹ÀÓ Ãâ·Â MBitmap* pBitmap = MBitmapManager::Get( "duel_score.tga"); if ( pBitmap) { pDC->SetBitmap( pBitmap); pDC->Draw( 167.0f*fRx, 0, 466.0f*fRx, 49.0f*fRx); } // À̸§ Ãâ·Â MFont *pFont = MFontManager::Get("FONTa10_O2Wht"); if ( pFont == NULL) _ASSERT(0); pDC->SetFont( pFont); int nTime = GetGlobalTimeMS() % 200; if ( bIsChampOserved && (nTime < 100)) pDC->SetColor(MCOLOR(0xFFFFFF00)); else pDC->SetColor(MCOLOR(0xFFA0A0A0)); TextRelative(pDC, 0.34f, 0.026f, charName[0], true); if ( bIsChlngOserved && (nTime < 100)) pDC->SetColor(MCOLOR(0xFFFFFF00)); else pDC->SetColor(MCOLOR(0xFFA0A0A0)); TextRelative(pDC, 0.66f, 0.026f, charName[1], true); if ( bExistNextChallenger) { MBitmap* pBitmap = MBitmapManager::Get( "icon_play.tga"); if ( pBitmap) { pDC->SetBitmap( pBitmap); int nIcon = 20.0f*fRx; pDC->Draw( 646.0f*fRx, 0, nIcon, nIcon); pDC->Draw( 640.0f*fRx, 0, nIcon, nIcon); } pDC->SetColor( MCOLOR(0xFF808080)); TextRelative( pDC, 0.83f, 0.01f, charName[ 2], false); } ZGetCombatInterface()->DrawVictory( pDC, 162, 20, pDuel->QInfo.m_nVictory); } else if ( ZApplication::GetGame()->GetMatch()->GetMatchType() != MMATCH_GAMETYPE_DUEL) { char szName[128]; sprintf_safe(szName, "%s (HP:%d, AP:%d)", m_pTargetCharacter->GetUserName(), m_pTargetCharacter->GetHP(), m_pTargetCharacter->GetAP()); if ( m_pTargetCharacter->IsAdmin()) pDC->SetColor(MCOLOR(ZCOLOR_ADMIN_NAME)); else pDC->SetColor(MCOLOR(0xFFFFFFFF)); MFont *pFont = MFontManager::Get( "FONTb11b"); if ( pFont == NULL) _ASSERT(0); pDC->SetFont( pFont); if ( ZApplication::GetGame()->GetMatch()->GetMatchType() == MMATCH_GAMETYPE_DEATHMATCH_TEAM2) TextRelative( pDC, 0.5f, 75.0f/800.0f, szName, true); else TextRelative( pDC, 0.5f, 50.0f/800.0f, szName, true); } // Ä«¸Þ¶ó Ç¥½Ã if ( !ZGetMyInfo()->IsAdminGrade()) { ZCamera *pCamera = ZGetGameInterface()->GetCamera(); const char *szModes[] = { "normal", "user", "free", "minimap" }; // TextRelative(pDC, 0.9f, 50.0f/800.0f, szModes[pCamera->GetLookMode()], true); char szFileName[ 50]; sprintf_safe( szFileName, "camera_%s.tga", szModes[pCamera->GetLookMode()]); pDC->SetBitmap( MBitmapManager::Get( szFileName)); float fGain = (float)MGetWorkspaceWidth() / 800.0f; pDC->Draw( (int)(720.0f * fGain), (int)(7.0f * fGain), (int)(64.0f * fGain), (int)(64.0f * fGain)); } // Admin ¿ÉÁ®¹öÀÏ °æ¿ì¿¡ ³²Àº Àοø¼ö Ç¥½Ã if ( ZGetMyInfo()->IsAdminGrade()) { // Àοø¼ö ±¸Çϱâ int nNumOfTotal=0, nNumOfRedTeam=0, nNumOfBlueTeam=0; ZCharacterManager::iterator itor; ZCharacter* pCharacter; for (itor = ZGetCharacterManager()->begin(); itor != ZGetCharacterManager()->end(); ++itor) { pCharacter = (*itor).second; if ( pCharacter->GetTeamID() == MMT_SPECTATOR) // ¿ÉÀú¹ö´Â –A´Ù continue; if(pCharacter->IsAdminHide()) continue; if ( (pCharacter->GetTeamID()==4) && ( !pCharacter->IsDie())) nNumOfTotal++; else if ( (pCharacter->GetTeamID()==MMT_RED) && ( !pCharacter->IsDie())) nNumOfRedTeam++; else if ( (pCharacter->GetTeamID()==MMT_BLUE) && ( !pCharacter->IsDie())) nNumOfBlueTeam++; } // ÆÀ À̹ÌÁö Ç¥½Ã float sizex = MGetWorkspaceWidth() / 800.f; float sizey = MGetWorkspaceHeight() / 600.f; char szText[128]; // ¹è°æ Ç¥½Ã MCOLOR backgroundcolor; if (ZApplication::GetGame()->GetMatch()->IsTeamPlay()) { backgroundcolor = MCOLOR(100,0,0, 150); pDC->SetColor(backgroundcolor); pDC->FillRectangle( 700 * sizex, 37 * sizey, 85 * sizex, 22 * sizey); backgroundcolor = MCOLOR(0,0,100, 150); pDC->SetColor(backgroundcolor); pDC->FillRectangle( 700 * sizex, 62 * sizey, 85 * sizex, 22 * sizey); // Àοø¼ö Ç¥½Ã backgroundcolor = MCOLOR(255,180,180, 255); pDC->SetColor(backgroundcolor); sprintf_safe( szText, "%s:%d", ZMsg( MSG_WORD_REDTEAM), nNumOfRedTeam); TextRelative( pDC, 0.92f, 40.0f/600.0f, szText, true); backgroundcolor = MCOLOR(180,180,255, 255); pDC->SetColor(backgroundcolor); sprintf_safe( szText, "%s:%d", ZMsg( MSG_WORD_BLUETEAM), nNumOfBlueTeam); TextRelative( pDC, 0.92f, 65.0f/600.0f, szText, true); } } CheckDeadTarget(); }