//-------------------------------------------------------------------------------- // ParseInput //-------------------------------------------------------------------------------- void TIASClient::ParseInput() { UByte ctrlByte; Boolean lastFrame; Boolean ackedFrame; IrDAErr result; // A reply frame has been received - parse it and decide what to do with it fGetPutBuffer->Seek(0, kPosBeg); ctrlByte = fGetPutBuffer->Get(); lastFrame = ctrlByte & kIASFrameLstBit; ackedFrame = ctrlByte & kIASFrameAckBit; XTRACE(kParseInputEvent, ctrlByte, fReceiveState); switch(fReceiveState) { case kIASClientReceiveReply: if (ackedFrame) { // The peer device is acking (unnecessary/optionally) my single frame request // It should have the lst bit on XASSERT(lastFrame); // Keep waiting for the actual reply GetStart(); } else { if (ctrlByte == (kIASOpGetValueByClass | kIASFrameLstBit)) { result = ParseReply(); LookupComplete(result); } else if (lastFrame) { LookupComplete(kIrDAErrGeneric); // ***FIXME: Better error code } else { fReceiveState = kIASClientReceiveWaitFinal; } } break; case kIASClientReceiveWaitFinal: // I don't accept multi-frame replies, so all I want to do is get the // final frame of the reply so I can complete the lookup request with an error. XASSERT(!ackedFrame); if (lastFrame) { // Reset the receive state fReceiveState = kIASClientReceiveReply; LookupComplete(kIrDAErrGeneric); // ***FIXME: Better error code } break; default: break; } // Ack the frame I don't want/care about if (fReceiveState == kIASClientReceiveWaitFinal) { fGetPutBuffer->Seek(0, kPosBeg); fGetPutBuffer->Put(kIASOpGetValueByClass | kIASFrameAckBit); PutStart(); } } // TIASClient::ParseInput
void RestoreDevice() { XTRACE( "XE::RestoreDevice"); _APP->m_Restore = XClientMain::xRST_FONT1; // 폰트리스토어 부터 시작. }
ISC_TIMERFUNC_SCOPE void isc__timermgr_destroy(isc_timermgr_t **managerp) { isc__timermgr_t *manager; isc_mem_t *mctx; /* * Destroy a timer manager. */ REQUIRE(managerp != NULL); manager = (isc__timermgr_t *)*managerp; REQUIRE(VALID_MANAGER(manager)); LOCK(&manager->lock); #ifdef USE_SHARED_MANAGER manager->refs--; if (manager->refs > 0) { UNLOCK(&manager->lock); *managerp = NULL; return; } timermgr = NULL; #endif /* USE_SHARED_MANAGER */ #ifndef USE_TIMER_THREAD isc__timermgr_dispatch((isc_timermgr_t *)manager); #endif REQUIRE(EMPTY(manager->timers)); manager->done = ISC_TRUE; #ifdef USE_TIMER_THREAD XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, ISC_MSG_SIGNALDESTROY, "signal (destroy)")); SIGNAL(&manager->wakeup); #endif /* USE_TIMER_THREAD */ UNLOCK(&manager->lock); #ifdef USE_TIMER_THREAD /* * Wait for thread to exit. */ if (isc_thread_join(manager->thread, NULL) != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_thread_join() %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed")); #endif /* USE_TIMER_THREAD */ /* * Clean up. */ #ifdef USE_TIMER_THREAD (void)isc_condition_destroy(&manager->wakeup); #endif /* USE_TIMER_THREAD */ DESTROYLOCK(&manager->lock); isc_heap_destroy(&manager->heap); manager->common.impmagic = 0; manager->common.magic = 0; mctx = manager->mctx; isc_mem_put(mctx, manager, sizeof(*manager)); isc_mem_detach(&mctx); *managerp = NULL; #ifdef USE_SHARED_MANAGER timermgr = NULL; #endif }
/*** *** Task Manager. ***/ static void dispatch(isc_taskmgr_t *manager) { isc_task_t *task; #ifndef ISC_PLATFORM_USETHREADS unsigned int total_dispatch_count = 0; isc_tasklist_t ready_tasks; #endif /* ISC_PLATFORM_USETHREADS */ REQUIRE(VALID_MANAGER(manager)); /* * Again we're trying to hold the lock for as short a time as possible * and to do as little locking and unlocking as possible. * * In both while loops, the appropriate lock must be held before the * while body starts. Code which acquired the lock at the top of * the loop would be more readable, but would result in a lot of * extra locking. Compare: * * Straightforward: * * LOCK(); * ... * UNLOCK(); * while (expression) { * LOCK(); * ... * UNLOCK(); * * Unlocked part here... * * LOCK(); * ... * UNLOCK(); * } * * Note how if the loop continues we unlock and then immediately lock. * For N iterations of the loop, this code does 2N+1 locks and 2N+1 * unlocks. Also note that the lock is not held when the while * condition is tested, which may or may not be important, depending * on the expression. * * As written: * * LOCK(); * while (expression) { * ... * UNLOCK(); * * Unlocked part here... * * LOCK(); * ... * } * UNLOCK(); * * For N iterations of the loop, this code does N+1 locks and N+1 * unlocks. The while expression is always protected by the lock. */ #ifndef ISC_PLATFORM_USETHREADS ISC_LIST_INIT(ready_tasks); #endif LOCK(&manager->lock); while (!FINISHED(manager)) { #ifdef ISC_PLATFORM_USETHREADS /* * For reasons similar to those given in the comment in * isc_task_send() above, it is safe for us to dequeue * the task while only holding the manager lock, and then * change the task to running state while only holding the * task lock. */ while ((EMPTY(manager->ready_tasks) || manager->exclusive_requested) && !FINISHED(manager)) { XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_WAIT, "wait")); WAIT(&manager->work_available, &manager->lock); XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_AWAKE, "awake")); } #else /* ISC_PLATFORM_USETHREADS */ if (total_dispatch_count >= DEFAULT_TASKMGR_QUANTUM || EMPTY(manager->ready_tasks)) break; #endif /* ISC_PLATFORM_USETHREADS */ XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_WORKING, "working")); task = HEAD(manager->ready_tasks); if (task != NULL) { unsigned int dispatch_count = 0; isc_boolean_t done = ISC_FALSE; isc_boolean_t requeue = ISC_FALSE; isc_boolean_t finished = ISC_FALSE; isc_event_t *event; INSIST(VALID_TASK(task)); /* * Note we only unlock the manager lock if we actually * have a task to do. We must reacquire the manager * lock before exiting the 'if (task != NULL)' block. */ DEQUEUE(manager->ready_tasks, task, ready_link); manager->tasks_running++; UNLOCK(&manager->lock); LOCK(&task->lock); INSIST(task->state == task_state_ready); task->state = task_state_running; XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_RUNNING, "running")); isc_stdtime_get(&task->now); do { if (!EMPTY(task->events)) { event = HEAD(task->events); DEQUEUE(task->events, event, ev_link); /* * Execute the event action. */ XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_EXECUTE, "execute action")); if (event->ev_action != NULL) { UNLOCK(&task->lock); (event->ev_action)(task,event); LOCK(&task->lock); } dispatch_count++; #ifndef ISC_PLATFORM_USETHREADS total_dispatch_count++; #endif /* ISC_PLATFORM_USETHREADS */ } if (task->references == 0 && EMPTY(task->events) && !TASK_SHUTTINGDOWN(task)) { isc_boolean_t was_idle; /* * There are no references and no * pending events for this task, * which means it will not become * runnable again via an external * action (such as sending an event * or detaching). * * We initiate shutdown to prevent * it from becoming a zombie. * * We do this here instead of in * the "if EMPTY(task->events)" block * below because: * * If we post no shutdown events, * we want the task to finish. * * If we did post shutdown events, * will still want the task's * quantum to be applied. */ was_idle = task_shutdown(task); INSIST(!was_idle); } if (EMPTY(task->events)) { /* * Nothing else to do for this task * right now. */ XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_EMPTY, "empty")); if (task->references == 0 && TASK_SHUTTINGDOWN(task)) { /* * The task is done. */ XTRACE(isc_msgcat_get( isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_DONE, "done")); finished = ISC_TRUE; task->state = task_state_done; } else task->state = task_state_idle; done = ISC_TRUE; } else if (dispatch_count >= task->quantum) { /* * Our quantum has expired, but * there is more work to be done. * We'll requeue it to the ready * queue later. * * We don't check quantum until * dispatching at least one event, * so the minimum quantum is one. */ XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, ISC_MSG_QUANTUM, "quantum")); task->state = task_state_ready; requeue = ISC_TRUE; done = ISC_TRUE; } } while (!done); UNLOCK(&task->lock); if (finished) task_finished(task); LOCK(&manager->lock); manager->tasks_running--; #ifdef ISC_PLATFORM_USETHREADS if (manager->exclusive_requested && manager->tasks_running == 1) { SIGNAL(&manager->exclusive_granted); } #endif /* ISC_PLATFORM_USETHREADS */ if (requeue) { /* * We know we're awake, so we don't have * to wakeup any sleeping threads if the * ready queue is empty before we requeue. * * A possible optimization if the queue is * empty is to 'goto' the 'if (task != NULL)' * block, avoiding the ENQUEUE of the task * and the subsequent immediate DEQUEUE * (since it is the only executable task). * We don't do this because then we'd be * skipping the exit_requested check. The * cost of ENQUEUE is low anyway, especially * when you consider that we'd have to do * an extra EMPTY check to see if we could * do the optimization. If the ready queue * were usually nonempty, the 'optimization' * might even hurt rather than help. */ #ifdef ISC_PLATFORM_USETHREADS ENQUEUE(manager->ready_tasks, task, ready_link); #else ENQUEUE(ready_tasks, task, ready_link); #endif } } } #ifndef ISC_PLATFORM_USETHREADS ISC_LIST_APPENDLIST(manager->ready_tasks, ready_tasks, ready_link); #endif UNLOCK(&manager->lock); }
void CCmd_Depots::PostProcess() { // The 'p4 depots' command may produce no output, in which case // GET_SERVERLEVEL() will come up dry. So the first order of // business is to run ANY command that is guaranteed to produce // output. I selected 'p4 client' cuz we already have the header // included and unlike commands like 'p4 info', it wont take a year // and a day on a slow network BOOL hasPlusMapping = FALSE; CCmd_Describe cmd(m_pClient); cmd.Init( NULL, RUN_SYNC ); BOOL cmdStarted= cmd.Run( P4CLIENT_SPEC, GET_P4REGPTR()->GetP4Client() ); if(cmdStarted && !cmd.GetError()) { // get client spec, and set NOCRLF flag and Client root in app TheApp()->m_bNoCRLF = IsLFonly(cmd.GetDescription()); TheApp()->Set_m_ClientRoot(TheApp()->GetClientSpecField( _T("Root"), cmd.GetDescription())); if (GET_SERVERLEVEL() >= 22) TheApp()->Set_m_ClientSubOpts(TheApp()->GetClientSpecField( _T("SubmitOptions"), cmd.GetDescription())); } else { TheApp()->m_ClientRoot.Empty(); m_ErrorTxt= LoadStringResource(IDS_UNABLE_TO_GET_CLIENT_DESCRIPTION); m_FatalError=TRUE; return; } int depotCount= m_LocalDepotList.GetCount() + m_RemoteDepotList.GetCount(); if (GET_P4REGPTR()->ShowEntireDepot() > SDF_DEPOT) { m_LocalDepotList.RemoveAll(); m_LocalDepotList.AddHead(TheApp()->m_ClientRoot); hasPlusMapping = DoesClientViewHavePlusMapping(cmd.GetDescription()); } // If more than one depot returned and in client-view-only mode, // get the client spec and remove any depots that are outside the clientview // else if( depotCount > 1 && !(GET_P4REGPTR()->ShowEntireDepot() == SDF_DEPOT) ) { if(!m_FatalError) { CString depot; CString view; hasPlusMapping = GetViewDepots( cmd.GetDescription(), view ); if(IS_NOCASE()) view.MakeLower(); POSITION pos1, pos2; for( pos1= m_LocalDepotList.GetHeadPosition(); (pos2=pos1) != NULL; ) { depot.Format(_T("%s/"), m_LocalDepotList.GetNext(pos1)); if(IS_NOCASE()) depot.MakeLower(); if( view.Find( depot ) == -1 ) { XTRACE(_T("Removed local depot %s because it is outside client view"), depot ); m_LocalDepotList.RemoveAt( pos2 ); } } for( pos1= m_RemoteDepotList.GetHeadPosition(); (pos2=pos1) != NULL; ) { depot.Format(_T("%s/"), m_RemoteDepotList.GetNext(pos1)); if(IS_NOCASE()) depot.MakeLower(); if( view.Find( depot ) == -1 ) { XTRACE(_T("Removed remote depot %s because it is outside client view"), depot ); m_RemoteDepotList.RemoveAt( pos2 ); } } } } // Else if no depots returned, just add the single remote depot 'depot' // since there is ALWAYS a default depot called 'depot' when no depots have // been defined // else { hasPlusMapping = DoesClientViewHavePlusMapping(cmd.GetDescription()); if ( depotCount == 0 ) m_LocalDepotList.AddHead( _T("//depot") ); } TheApp()->m_HasPlusMapping = hasPlusMapping; }
~Camera() { XTRACE(); }
//---------------------------------------------------------------------------- Input::~Input() { XTRACE(); _callbackMap.clear(); }
Game::Game( void): _limiter() { XTRACE(); }
bool Game::init( void) { XTRACE(); bool result = true; int temp = 0; ConfigS::instance()->getInteger( "maxRate", temp); if(temp > 0) { this->_limiter.setEnabled(true); this->_limiter.setRate(temp); } else { this->_limiter.setEnabled(false); } ScoreKeeperS::instance()->load(); // init subsystems et al if( ! ParticleGroupManagerS::instance()->init()) return false; AudioS::instance()->setDefaultSoundtrack("music/lg-criti.xm"); if( ! AudioS::instance()->init()) return false; if( ! VideoS::instance()->init()) return false; if( ! InputS::instance()->init()) return false; if( ! MenuManagerS::instance()->init()) return false; if( ! HeroS::instance()->init()) return false; StarfieldS::instance()->init( -150.0); ParticleGroupManager *pgm = ParticleGroupManagerS::instance(); if( ! pgm->init()) return false; //init all the paricle groups and links between them pgm->addGroup( HERO_GROUP, 1); pgm->addGroup( ENEMIES_GROUP, 300); pgm->addGroup( ENEMIES_BULLETS_GROUP, 300); //there are 3 effect groups to give very simple control over the order //of drawing which is important for alpha blending. pgm->addGroup( EFFECTS_GROUP1, 1000); pgm->addGroup( EFFECTS_GROUP2, 1000); pgm->addGroup( EFFECTS_GROUP3, 1000); pgm->addGroup( HERO_BULLETS_GROUP, 300); pgm->addGroup( BONUS_GROUP, 50); pgm->addGroup( SHOOTABLE_ENEMY_BULLETS_GROUP, 100); pgm->addGroup( SHOOTABLE_BONUS_GROUP, 50); //collision detect between the following groups pgm->addLink( HERO_BULLETS_GROUP, SHOOTABLE_ENEMY_BULLETS_GROUP); pgm->addLink( HERO_BULLETS_GROUP, ENEMIES_GROUP); pgm->addLink( HERO_BULLETS_GROUP, SHOOTABLE_BONUS_GROUP); pgm->addLink( HERO_GROUP, ENEMIES_GROUP); pgm->addLink( HERO_GROUP, ENEMIES_BULLETS_GROUP); pgm->addLink( HERO_GROUP, BONUS_GROUP); pgm->addLink( HERO_GROUP, SHOOTABLE_ENEMY_BULLETS_GROUP); pgm->addLink( HERO_GROUP, SHOOTABLE_BONUS_GROUP); //reset our stopwatch GameState::stopwatch.reset(); GameState::stopwatch.pause(); if( ! StageManagerS::instance()->init()) return false; ConfigS::instance()->getFloat( "horsePower", GameState::horsePower); //add our hero... ParticleGroupManagerS::instance()-> getParticleGroup( HERO_GROUP)->newParticle( string("Hero"), 0, 0, -100); //make sure we start of in menu mode MenuManagerS::instance()->turnMenuOn(); GameState::startOfStep = Timer::getTime(); GameState::startOfGameStep = GameState::stopwatch.getTime(); LOG_INFO << "Initialization complete OK." << endl; return result; }
void CIrDevice::SetLAPAddress(UInt8 addr) // Set our LAP address { XTRACE(kLogSetAddress, 0, addr); fLAPAddr = addr; }
void CIrDevice::free(void) { XTRACE(kLogFree, 0, this); super::free(); }
void CIrDevice::Start(void) { XTRACE(kLogStart, 0, 0); ChangeSpeed(9600); // set to default speed }
bool ParticleGroupManager::init( void) { XTRACE(); return true; }
ParticleGroupManager::ParticleGroupManager( void) { XTRACE(); }
//-------------------------------------------------------------------------------- // NextState //-------------------------------------------------------------------------------- void TIASServer::NextState(ULong event) { TIrEvent* reqOrReply = GetCurrentEvent(); XTRACE(kLogNextState, reqOrReply->fResult, event); require(reqOrReply == (TIrEvent *)fRequestReply, Fail); if (reqOrReply->fResult != noErr) { // if previous request failed and if (reqOrReply->fEvent != kIrDisconnectReplyEvent && // neither a disconnect or listen reply reqOrReply->fEvent != kIrListenReplyEvent) { // then let's do a disconnect to clean up XTRACE(kDisconnectRequestEvent, 0, this); reqOrReply->fEvent = kIrDisconnectRequestEvent; // request a disconnect fLSAPConn->EnqueueEvent(reqOrReply); return; } } switch (event) { case kIrDisconnectReplyEvent: // disconnect finished, start up a listen again XTRACE(kResettingToListenEvent, 0, 0); // fall through case kIrListenRequestEvent: ListenStart(); // xtrace inside ListenStart() break; case kIrListenReplyEvent: XTRACE(kListenReplyEvent, 0, this); if (reqOrReply->fResult == noErr) { // if listen worked XTRACE(kAcceptRequestEvent, 0, 0); // Send the listen reply back as the accept TIrConnLstnRequest* acceptRequest = (TIrConnLstnRequest*)GetCurrentEvent(); acceptRequest->fEvent = kIrAcceptRequestEvent; fLSAPConn->EnqueueEvent(acceptRequest); } else { // if it failed, listen again ListenStart(); } break; case kIrAcceptReplyEvent: XTRACE(kAcceptReplyEvent, 0, this); GetStart(); break; case kIrPutDataReplyEvent: XTRACE(kPutDataReplyEvent, 0, this); GetStart(); break; case kIrGetDataReplyEvent: XTRACE(kGetDataReplyEvent, 0, this); ParseInput(); break; default: XTRACE(kUnexpectedEvent, 0, event); DebugLog("TIASServer::NextState: unknown event"); break; } Fail: return; } // TIASServer::NextState
static void ModalEditBoxCallbackFunc(const char* pText, void* ctx) { XTRACE( "modal editbox: %s, ctx=0x%08x", pText, (DWORD)ctx ); XE::GetMain()->GetpGame()->OnEndEditBox( x_idEditField, pText ); }
//-------------------------------------------------------------------------------- // ParseInput //-------------------------------------------------------------------------------- void TIASServer::ParseInput() { UByte ctrlByte; Boolean lastFrame; Boolean ackedFrame; UByte iasReturnCode; TIASAttribute* iasEntry = nil; // An operation frame has been received - parse it and decide what to do with it fGetPutBuffer->Seek(0, kPosBeg); ctrlByte = fGetPutBuffer->Get(); lastFrame = ctrlByte & kIASFrameLstBit; ackedFrame = ctrlByte & kIASFrameAckBit; XTRACE(kParseInputEvent, ctrlByte, fReceiveState); switch(fReceiveState) { case kIASServerReceiveStart: if (ackedFrame) { // Must be an ack from my previous response (or some other bogus data) // Keep looking } else { fOpCode = ctrlByte & kIASFrameOpCodeMask; if (lastFrame) { if (fOpCode == kIASOpGetValueByClass) { iasEntry = ParseRequest(iasReturnCode); } else { iasEntry = nil; iasReturnCode = kIASRetUnsupported; } } else { fReceiveState = kIASServerReceiveWaitFinal; } } break; case kIASServerReceiveWaitFinal: // I didn't accept the request, so all I want to do is get the // final frame of the request so I can reject it. XASSERT(!ackedFrame); if (lastFrame) { // I don't really care if they sent an ack w/final, so ignore it ackedFrame = false; // Return no such class for too large get value by class requests // Return unsupported for all other requests iasEntry = nil; iasReturnCode = fOpCode == kIASOpGetValueByClass ? kIASRetNoSuchClass : kIASRetUnsupported; } break; default: break; } // Either respond to the current request or continue accepting more of the request if (lastFrame && !ackedFrame) { // Reply to the request SendResponse(iasReturnCode, iasEntry); // Reset the receive state fOpCode = kIASOpUnassigned; fReceiveState = kIASServerReceiveStart; } else if (fReceiveState == kIASServerReceiveWaitFinal) { // Ack the frame I don't want/care about fGetPutBuffer->Seek(0, kPosBeg); fGetPutBuffer->Put(fOpCode | kIASFrameAckBit); PutStart(); } else { // Post another get GetStart(); } } // TIASServer::ParseInput
NDASUSER_API DWORD WINAPI NdasRegisterDeviceW( LPCWSTR lpszDeviceStringId, LPCWSTR lpszDeviceStringKey, LPCWSTR lpszDeviceName) { // ptr sanity check CHECK_STR_PTRW(lpszDeviceStringId, NDAS_DEVICE_STRING_ID_LEN) CHECK_STR_PTRW_NULLABLE(lpszDeviceStringKey, NDAS_DEVICE_STRING_KEY_LEN) CHECK_STR_PTRW(lpszDeviceName, -1) NDAS_CMD_REGISTER_DEVICE::REQUEST buffer; NDAS_CMD_REGISTER_DEVICE::REQUEST* lpRequest = &buffer; NDAS_CMD_REGISTER_DEVICE::REPLY* lpReply; NDAS_CMD_ERROR::REPLY* lpErrorReply; // check ndas id BOOL fSuccess = NdasIdValidateW(lpszDeviceStringId, lpszDeviceStringKey); if (!fSuccess) { ::SetLastError(NDASUSER_ERROR_INVALID_DEVICE_STRING_ID); return 0; } // Prepare the parameters here lpRequest->GrantingAccess = (lpszDeviceStringKey) ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_READ; fSuccess = NdasIdStringToDeviceW( lpszDeviceStringId, &lpRequest->DeviceId); _ASSERT(fSuccess); // must not fail as we already did Validation HRESULT hr = ::StringCchCopyW( lpRequest->wszDeviceName, MAX_NDAS_DEVICE_NAME_LEN + 1, lpszDeviceName); if (!(SUCCEEDED(hr) || (FAILED(hr) && STRSAFE_E_INSUFFICIENT_BUFFER == hr))) { return 0; } // ready to connect CNdasServiceCommandClient<NDAS_CMD_REGISTER_DEVICE> scc; BOOL fConnected = scc.Connect(); if (!fConnected) { XTRACE(TEXT("Service Connection Failure with error %d\n"), ::GetLastError()); ::SetLastError(NDASUSER_ERROR_SERVICE_CONNECTION_FAILURE); return 0; } DWORD cbRequestExtra(0); DWORD cbReplyExtra, cbErrorExtra; DWORD dwCmdStatus; { BOOL fSuccess = scc.Transact( lpRequest, cbRequestExtra, &lpReply, &cbReplyExtra, &lpErrorReply, &cbErrorExtra, &dwCmdStatus); if (!fSuccess) { DBGPRT_ERR_EX(_FT("Transact failed: ")); return FALSE; } DBGPRT_INFO(_FT("Transact completed successfully.\n")); NDAS_CMD_STATUS cmdStatus = (NDAS_CMD_STATUS)(dwCmdStatus); if (NDAS_CMD_STATUS_SUCCESS != cmdStatus) { DBGPRT_ERR(_FT("Command failed!\n")); SetErrorStatus(cmdStatus, lpErrorReply); return 0; } } // Process the result here return lpReply->SlotNo; }
//---------------------------------------------------------------------------- CallbackManager::CallbackManager( void) { XTRACE(); }
BOOL XShader::LoadShaderFromStr( const GLchar *cVertShader , const GLchar *cFragShader , const char *cszTag ) { GLuint vertShader, fragShader; BOOL bRet = FALSE; do { // Create shader program. m_glProgram = glCreateProgram(); // Create and compile vertex shader. if( !CompileShaderFromString( &vertShader, GL_VERTEX_SHADER, cVertShader, cszTag ) ) { XBREAKF( 1, "Failed to compile vertex shader" ); bRet = FALSE; break; } // Create and compile fragment shader. if( !CompileShaderFromString( &fragShader, GL_FRAGMENT_SHADER, cFragShader, cszTag ) ) { XBREAKF( 1, "Failed to compile fragment shader" ); bRet = FALSE; break; } // Attach vertex shader to program. glAttachShader( m_glProgram, vertShader ); // Attach fragment shader to program. glAttachShader( m_glProgram, fragShader ); // Bind attribute locations. // This needs to be done prior to linking. glBindAttribLocation( m_glProgram, XE::ATTRIB_POS, "position" ); glBindAttribLocation( m_glProgram, XE::ATTRIB_TEXTURE, "texture" ); glBindAttribLocation( m_glProgram, XE::ATTRIB_COLOR, "color" ); glBindAttribLocation( m_glProgram, XE::ATTRIB_SIZE, "size" ); // Link program. if( !LinkShader( m_glProgram, cszTag ) ) { XTRACE( "Failed to link program: %d %s", m_glProgram, C2SZ(cszTag) ); if( vertShader ) { glDeleteShader( vertShader ); vertShader = 0; } if( fragShader ) { glDeleteShader( fragShader ); fragShader = 0; } if( m_glProgram ) { glDeleteProgram( m_glProgram ); m_glProgram = 0; } bRet = FALSE; break; } // Get uniform locations. // 세이더내 유저변수의 로케이션값을 받아둔다. 이 변수에다 값을 쓰려면 이 로케이션 값을 이용해야 한다. m_locUniforms[UNIFORM_MVP_MATRIX] = glGetUniformLocation( m_glProgram, "mMVP" ); m_locUniforms[UNIFORM_COLOR] = glGetUniformLocation( m_glProgram, "col" ); m_locUniforms[UNIFORM_FLOAT] = glGetUniformLocation( m_glProgram, "value" ); // m_locUniforms[UNIFORM_MODEL_MATRIX] = glGetUniformLocation(m_glProgram, "worldMatrix"); // Release vertex and fragment shaders. if( vertShader ) { glDetachShader( m_glProgram, vertShader ); glDeleteShader( vertShader ); } if( fragShader ) { glDetachShader( m_glProgram, fragShader ); glDeleteShader( fragShader ); } bRet = TRUE; } while( 0 ); // if( bRet ) // BTRACE("success."); // else // XTRACE("failed."); return bRet; }
void XClientConnection::RecvLogin( XPacket& p ) { MAIN->m_fpsFromClient.Process(); ID idAccount; int verCGPK; char c0; TCHAR szSessionKey[256]; p >> verCGPK; // 클라의 프로토콜 버전(클라<->게임서버간) p >> idAccount; p.ReadString( szSessionKey ); p >> c0; auto platform = (XGAME::xtPlatform)c0; p >> c0; p >> c0; p >> c0; // 프로퍼티 시리얼라이즈 #ifdef _XPROP_SERIALIZE if( XE::IsEmpty(szSessionKey) ) { XPacket ar( (ID)xCL2GS_PROP_SERIALIZE ); XGame::sGet()->ArchivingProp( ar ); Send( ar ); } #endif // _XPROP_SERIALIZE // 로긴서버로부터 받은 계정중에 내 아이디가 있는지 찾는다. auto pGame = GetGame(); auto pAccLogin = pGame->FindLoginAccount( idAccount ); if( !pAccLogin ) { pGame->AddLoginAccount( idAccount, nullptr ); pAccLogin = pGame->FindLoginAccount( idAccount ); } if( XBREAK( pAccLogin == nullptr ) ) return; if( pAccLogin->m_spAcc ) { // 아직 계정데이타가 도착 안함. auto spAccount = pAccLogin->m_spAcc; spAccount->SetverCGPK( verCGPK ); // 유저객체 만들고 로그인 성공시킴 auto spGameUser = CreateUserObj( idAccount, spAccount, FALSE ); GetGame()->DelLoginAccount( idAccount ); // XPacket ar( (ID)xCL2GS_ACCOUNT_SUCCESS_LOGIN, true, 0x10000 ); XTRACE("%s", __TFUNC__); // reserved XBREAK( XGC->m_apPerOnce > 255 ); ar << (BYTE)XGC->m_apPerOnce; ar << (BYTE)m_CryptObj.GetkeyPrivate(); ar << (WORD)0; for( int i = 0; i < 16; ++i ) ar << (DWORD)0; XArchive arAcc(0x10000); spAccount->Serialize( arAcc ); ar << arAcc; // 암호를 해제할수 있는 랜덤키를 먼저 보냄 m_CryptObj.SerializeKeyTable( ar ); // 퍼블릭키를 암호화해서 보냄. // BYTE cBuff[ 4096 ]; // int sizeBuff; // sizeBuff = XMain::sGet()->GetPublicKeyWithEncrypted( cBuff ); // ar.WriteBuffer( cBuff, sizeBuff ); // ar << XMain::sGet()->GetstrPublicKey(); Send( ar ); ///< 클라에 계정정보를 보낸후 처리할일들을 한다. spGameUser->SetPlatform( platform ); spGameUser->SuccessLoginAfterSend(); MAIN->m_fpsToClientOk.Process(); } else { ++pAccLogin->m_cntTry; XBREAK( pAccLogin->m_cntTry > 5 ); // 서버에서 직접끊는게 아니라 이런경우가 있을수도 있을듯. // 로긴서버로부터 아직 계정정보가 도착안했다 XTRACE( "idAcc:%d 의 계정정보가 로긴서버로부터 아직 도착하지 않음", idAccount ); const bool bToLogin = (pAccLogin->m_cntTry >= 3); OnAccountInfoNotYetFromLoginSvr( idAccount, bToLogin ); // 3번시도했는데도 없으면 로긴서버부터 다시 접속하게 하고 삭제시킴 if( bToLogin ) pGame->DelLoginAccount( idAccount ); } }
/** @brief @param sizeTex 목표 크기 */ void XGraphicsOpenGL::ResizeTexture( ID idTex, const XE::POINT& sizeTexPrev, const XE::POINT& sizeTexNew, GLenum glType, GLenum glFormatSurface ) { // FBO생성 GLuint fbo; glGenFramebuffers( 1, &fbo ); glBindFramebuffer( GL_FRAMEBUFFER, fbo ); // idTex를 어태치 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, idTex, 0 ); _CHECK_GL_ERROR(); GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER ); if( status != GL_FRAMEBUFFER_COMPLETE ) { XTRACE( "fbo status=%d", status ); return; } // 임시 텍스쳐버퍼 생성 GLuint glTexTemp; glGenTextures( 1, &glTexTemp ); _CHECK_GL_ERROR(); glBindTexture( GL_TEXTURE_2D, glTexTemp ); _CHECK_GL_ERROR(); auto glFormatMem = glFormatSurface; // 둘은 반드시 일치해야한다., glTexImage2D( GL_TEXTURE_2D, 0, glFormatSurface, // internal format sizeTexPrev.w, sizeTexPrev.h, 0, glFormatMem, // pImgSrc의 포맷 glType, nullptr ); _CHECK_GL_ERROR(); // 어태치된 소스측 텍스쳐로부터 임시버퍼로 카피 glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sizeTexPrev.w, sizeTexPrev.h ); _CHECK_GL_ERROR(); // 소스측 어태치 해제 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0 ); _CHECK_GL_ERROR(); // 임시버퍼를 FBO에 어태치 glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexTemp, 0 ); _CHECK_GL_ERROR(); status = glCheckFramebufferStatus( GL_FRAMEBUFFER ); if( status != GL_FRAMEBUFFER_COMPLETE ) { XTRACE( "fbo status=%d", status ); return; } // 리사이징 XGraphicsOpenGL::sBindTexture( idTex ); _CHECK_GL_ERROR(); auto pClearBuff = new DWORD[ (int)sizeTexNew.Size() ]; memset( pClearBuff, 0, sizeof(DWORD) * (int)sizeTexNew.Size() ); glTexImage2D( GL_TEXTURE_2D, 0, glFormatSurface, // internal format sizeTexNew.w, sizeTexNew.h, 0, glFormatMem, // pImgSrc의 포맷 glType, pClearBuff /*nullptr*/ ); _CHECK_GL_ERROR(); SAFE_DELETE_ARRAY( pClearBuff ); // 어태치된 임시버퍼 텍스쳐로부터 리사이징된 원래텍스쳐로 카피 glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sizeTexPrev.w, sizeTexPrev.h ); _CHECK_GL_ERROR(); // 임시버퍼 삭제 glDeleteTextures( 1, &glTexTemp ); glTexTemp = 0; _CHECK_GL_ERROR(); glDeleteFramebuffers( 1, &fbo ); _CHECK_GL_ERROR(); }
int OnWndMenuSelect(int nID,BOOL *pbHandled) { XTRACE("select item %d \n",nID); return 0; }
void XConsoleMain::Destroy() { XTRACE( "destroy XLIB\n" ); SAFE_DELETE( XLIB ); }
BOOL CMultiSelTreeCtrl::DeleteAllItems() { XTRACE(_T("CMultiSelSTreeCtrl::DeleteAllItems()\n")); ClearSelection(); return CTreeCtrl::DeleteAllItems(); }
void isc_timermgr_destroy(isc_timermgr_t **managerp) { isc_timermgr_t *manager; isc_mem_t *mctx; /* * Destroy a timer manager. */ REQUIRE(managerp != NULL); manager = *managerp; REQUIRE(VALID_MANAGER(manager)); LOCK(&manager->lock); #ifndef ISC_PLATFORM_USETHREADS if (manager->refs > 1) { manager->refs--; UNLOCK(&manager->lock); *managerp = NULL; return; } isc__timermgr_dispatch(); #endif /* ISC_PLATFORM_USETHREADS */ REQUIRE(EMPTY(manager->timers)); manager->done = ISC_TRUE; #ifdef ISC_PLATFORM_USETHREADS XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, ISC_MSG_SIGNALDESTROY, "signal (destroy)")); SIGNAL(&manager->wakeup); #endif /* ISC_PLATFORM_USETHREADS */ UNLOCK(&manager->lock); #ifdef ISC_PLATFORM_USETHREADS /* * Wait for thread to exit. */ if (isc_thread_join(manager->thread, NULL) != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_thread_join() %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed")); #endif /* ISC_PLATFORM_USETHREADS */ /* * Clean up. */ #ifdef ISC_PLATFORM_USETHREADS (void)isc_condition_destroy(&manager->wakeup); #endif /* ISC_PLATFORM_USETHREADS */ DESTROYLOCK(&manager->lock); isc_heap_destroy(&manager->heap); manager->magic = 0; mctx = manager->mctx; isc_mem_put(mctx, manager, sizeof(*manager)); isc_mem_detach(&mctx); *managerp = NULL; }
/** 구매를 위해 비번까지 입력한 이후 실제 구매요청을 보낸 직후에 호출된다. iOS만 적용된다. */ void OnPurchaseStart( const char *cSku ) { XTRACE( "XE::OnPurchaseStart"); if( GetMain()->GetpGame() ) GetMain()->GetpGame()->OnPurchaseStart( cSku ); }
/// @brief ÉèÖÃGIF¶¯»Í¼Æ¬,´ÓZIPѹËõ°üÖмÓÔØͼƬ. /// @param hEle ÔªËؾä±ú. /// @param pZipFileName ѹËõ°üÎļþ. /// @param pImageName GIFͼƬÃû. /// @param pPassword ѹËõ°üÃÜÂë. void WINAPI XGif_SetImageZip(HELE hEle,wchar_t *pZipFileName,wchar_t *pImageName,wchar_t *pPassword) { IsGifDebug(hEle,__FUNCTION__); gif_ *pObject=(gif_*)hEle; if(pObject->pGif) { delete pObject->pGif; pObject->pGif=NULL; } if(NULL==pZipFileName || NULL==pImageName) { return ; } IsImageTypeDebug(_T(__FUNCTION__),pImageName); char zipfilename[MAX_PATH]={0}; WideCharToMultiByte(CP_ACP,NULL,pZipFileName,wcslen(pZipFileName),zipfilename,MAX_PATH,NULL,NULL); char filename_to_extract[MAX_PATH]={0}; WideCharToMultiByte(CP_ACP,NULL,pImageName,wcslen(pImageName),filename_to_extract,MAX_PATH,NULL,NULL); char password[MAX_PATH]={0}; if(pPassword) WideCharToMultiByte(CP_ACP,NULL,pPassword,wcslen(pPassword),password,MAX_PATH,NULL,NULL); //const char *password=NULL; //char *zipfilename="C:\\Users\\mengfei\\Desktop\\myzip.zip"; //ѹËõ°ü //char *filename_to_extract="dirtt/123.txt"; //ÌáÈ¡ÎļþÃû //char *filename_to_extract="btn.bmp"; //ÌáÈ¡ÎļþÃû unzFile zipFile=NULL; zipFile = unzOpen64(zipfilename); //´ò¿ªÑ¹Ëõ°ü if (zipFile==NULL) { XTRACE("´ò¿ªZIPѹËõ°üʧ°Ü"); return ; } int outSize=0; void *data =NULL; if(pPassword) data=do_extract_onefile(zipFile, filename_to_extract,password,outSize); else data=do_extract_onefile(zipFile, filename_to_extract,NULL,outSize); unzClose(zipFile); if(data) { HGLOBAL hJPG = ::GlobalAlloc(GMEM_MOVEABLE, outSize); LPVOID lpJGP = ::GlobalLock(hJPG); memcpy(lpJGP, data, outSize); ::GlobalUnlock(hJPG); LPSTREAM pstm =NULL; HRESULT hr =CreateStreamOnHGlobal(hJPG, TRUE, &pstm); assert(SUCCEEDED(hr) && pstm); //Image *pImg=Image::FromStream(pstm); pObject->pGif=new ImageEx(pstm); pstm->Release(); free(data); if(Gdiplus::Ok != (pObject->pGif->GetLastStatus())) { delete pObject->pGif; pObject->pGif=NULL; } if(pObject->pGif->InitAnimation(0,0)) SetTimer(XEle_GetHWnd(hEle),(int)hEle,100,Gif_TimerProc); } }
static inline isc_result_t schedule(isc__timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) { isc_result_t result; isc__timermgr_t *manager; isc_time_t due; int cmp; #ifdef USE_TIMER_THREAD isc_boolean_t timedwait; #endif /*! * Note: the caller must ensure locking. */ REQUIRE(timer->type != isc_timertype_inactive); #ifndef USE_TIMER_THREAD UNUSED(signal_ok); #endif /* USE_TIMER_THREAD */ manager = timer->manager; #ifdef USE_TIMER_THREAD /*! * If the manager was timed wait, we may need to signal the * manager to force a wakeup. */ timedwait = ISC_TF(manager->nscheduled > 0 && isc_time_seconds(&manager->due) != 0); #endif /* * Compute the new due time. */ if (timer->type != isc_timertype_once) { result = isc_time_add(now, &timer->interval, &due); if (result != ISC_R_SUCCESS) return (result); if (timer->type == isc_timertype_limited && isc_time_compare(&timer->expires, &due) < 0) due = timer->expires; } else { if (isc_time_isepoch(&timer->idle)) due = timer->expires; else if (isc_time_isepoch(&timer->expires)) due = timer->idle; else if (isc_time_compare(&timer->idle, &timer->expires) < 0) due = timer->idle; else due = timer->expires; } /* * Schedule the timer. */ if (timer->index > 0) { /* * Already scheduled. */ cmp = isc_time_compare(&due, &timer->due); timer->due = due; switch (cmp) { case -1: isc_heap_increased(manager->heap, timer->index); break; case 1: isc_heap_decreased(manager->heap, timer->index); break; case 0: /* Nothing to do. */ break; } } else { timer->due = due; result = isc_heap_insert(manager->heap, timer); if (result != ISC_R_SUCCESS) { INSIST(result == ISC_R_NOMEMORY); return (ISC_R_NOMEMORY); } manager->nscheduled++; } XTRACETIMER(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, ISC_MSG_SCHEDULE, "schedule"), timer, due); /* * If this timer is at the head of the queue, we need to ensure * that we won't miss it if it has a more recent due time than * the current "next" timer. We do this either by waking up the * run thread, or explicitly setting the value in the manager. */ #ifdef USE_TIMER_THREAD /* * This is a temporary (probably) hack to fix a bug on tru64 5.1 * and 5.1a. Sometimes, pthread_cond_timedwait() doesn't actually * return when the time expires, so here, we check to see if * we're 15 seconds or more behind, and if we are, we signal * the dispatcher. This isn't such a bad idea as a general purpose * watchdog, so perhaps we should just leave it in here. */ if (signal_ok && timedwait) { isc_interval_t fifteen; isc_time_t then; isc_interval_set(&fifteen, 15, 0); result = isc_time_add(&manager->due, &fifteen, &then); if (result == ISC_R_SUCCESS && isc_time_compare(&then, now) < 0) { SIGNAL(&manager->wakeup); signal_ok = ISC_FALSE; isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_TIMER, ISC_LOG_WARNING, "*** POKED TIMER ***"); } } if (timer->index == 1 && signal_ok) { XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, ISC_MSG_SIGNALSCHED, "signal (schedule)")); SIGNAL(&manager->wakeup); } #else /* USE_TIMER_THREAD */ if (timer->index == 1 && isc_time_compare(&timer->due, &manager->due) < 0) manager->due = timer->due; #endif /* USE_TIMER_THREAD */ return (ISC_R_SUCCESS); }
//-------------------------------------------------------------------------------- // HandleConnectedStateEvent //-------------------------------------------------------------------------------- void TIASClient::HandleConnectedStateEvent(ULong event) { switch (event) { case kIrLookupRequestEvent: { XTRACE(kLookupRequestEvent, 0, 0); IrDAErr result = SendRequest(); if (result != noErr) { LookupComplete(result); } } break; case kIrPutDataReplyEvent: { TIrPutReply* putReply = (TIrPutReply*)GetCurrentEvent(); XTRACE(kPutDataReplyEvent, 0, putReply->fResult); if (putReply->fResult != noErr) { // Complete lookup request if any errors LookupComplete(putReply->fResult); } else { GetStart(); } } break; case kIrGetDataReplyEvent: { TIrGetReply* getReply = (TIrGetReply*)GetCurrentEvent(); XTRACE(kGetDataReplyEvent, 0, getReply->fResult); if (getReply->fResult != noErr) { // Complete lookup request if any errors LookupComplete(getReply->fResult); } else { ParseInput(); } } break; case kIrReleaseRequestEvent: case kIrDisconnectRequestEvent: XTRACE(kDisconnectRequestEvent, 1, event); // Pass the disconnect request to the lsapConn fLSAPConn->EnqueueEvent(GetCurrentEvent()); break; case kIrReleaseReplyEvent: case kIrDisconnectReplyEvent: XTRACE(kDisconnectReplyEvent, 1, event); // Now we're disconnected again fState = kIrIASClientDisconnected; // Pass the disconnect reply to the client fClient->EnqueueEvent(GetCurrentEvent()); // NOTE: Lookups in progress will be cleaned up. The disconnect // will force either the get or the put in progress to complete // with an error. When they complete with an error LookupComplete // is called (see above) and LookupComplete frees fAttribute if // necessary and sends a reply back to the client. break; default: DebugLog("TIASClient::HandleConnectedStateEvent: bad event"); break; } } // TIASClient::HandleConnectedStateEvent