BOOL CIrcProto::ShowMessage (const CIrcMessage* pmsg) { CMString mess = FormatOutput(pmsg); if ( !pmsg->m_bIncoming ) ReplaceString( mess, _T("%%"), _T("%")); int iTemp = StrToInt( pmsg->sCommand.c_str()); //To active window if (( iTemp > 400 || iTemp < 500 ) && pmsg->sCommand[0] == '4' //all error messages || pmsg->sCommand == _T("303") //ISON command || pmsg->sCommand == _T("INVITE") || ( (pmsg->sCommand == _T("NOTICE")) && ( (pmsg->parameters.getCount() > 2) ? (_tcsstr(pmsg->parameters[1].c_str(), _T("\001"))==NULL) : false)) // CTCP answers should go to m_network Log window! || pmsg->sCommand == _T("515")) //chanserv error { DoEvent(GC_EVENT_INFORMATION, NULL, pmsg->m_bIncoming?pmsg->prefix.sNick.c_str():m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming?false:true); return TRUE; } if ( m_useServer ) { DoEvent( GC_EVENT_INFORMATION, SERVERWINDOW, ( pmsg->m_bIncoming ) ? pmsg->prefix.sNick.c_str() : m_info.sNick.c_str(), mess.c_str(), NULL, NULL, NULL, true, pmsg->m_bIncoming ? false : true ); return true; } return false; }
/** @brief 外部のウインドウにaceの機能で描画を行う。 */ void EmptyExternal() { InitWindow(); // aceを初期化する。 #if _WIN32 asd::Engine::InitializeByExternalWindow(g_handle, nullptr, 640, 480, asd::EngineOption()); #else asd::Engine::InitializeByExternalWindow((void*)(g_display), (void*)(&g_window), 640, 480, asd::EngineOption()); #endif // aceが進行可能かチェックする。 while (asd::Engine::DoEvents()) { if (!DoEvent()) break; // aceを更新する。 asd::Engine::Update(); } // aceを終了する。 asd::Engine::Terminate(); ExitWindow(); }
bool CIrcProto::AddWindowItemData(CMString window, const TCHAR* pszLimit, const TCHAR* pszMode, const TCHAR* pszPassword, const TCHAR* pszTopic) { CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0); if ( wi ) { if ( pszLimit ) { wi->pszLimit = ( TCHAR* )realloc( wi->pszLimit, sizeof(TCHAR)*(lstrlen(pszLimit)+1)); lstrcpy( wi->pszLimit, pszLimit ); } if ( pszMode ) { wi->pszMode = ( TCHAR* )realloc( wi->pszMode, sizeof(TCHAR)*(lstrlen(pszMode)+1)); lstrcpy( wi->pszMode, pszMode ); } if ( pszPassword ) { wi->pszPassword = ( TCHAR* )realloc( wi->pszPassword, sizeof(TCHAR)*(lstrlen(pszPassword)+1)); lstrcpy( wi->pszPassword, pszPassword ); } if ( pszTopic ) { wi->pszTopic = ( TCHAR* )realloc( wi->pszTopic, sizeof(TCHAR)*(lstrlen(pszTopic)+1)); lstrcpy( wi->pszTopic, pszTopic ); } SetChannelSBText(window, wi); return true; } return false; }
//--------------------------------------------收消息------------------------------------------------------------- void NFCChatLogic::OnChatProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqAckPlayerChat xMsg; if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } NFDataList var; var.AddObject(NFINetModule::PBToNF(xMsg.chat_id())); var.AddInt(xMsg.chat_type()); var.AddString(xMsg.chat_name()); var.AddString(xMsg.chat_info()); var.AddInt(xMsg.container_data_size()); for (size_t i = 0; i < xMsg.container_data_size(); i++) { var.AddInt(xMsg.container_data(i).containertype()); var.AddString(xMsg.container_data(i).data_info()); } switch (xMsg.chat_type()) { case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_WORLD: { DoEvent(E_ChatEvent_ChatWorld, var); } break; case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_GUILD: { DoEvent(E_ChatEvent_ChatGuild, var); } break; case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_PRIVATE: { DoEvent(E_ChatEvent_ChatPrivate, var); } break; case NFMsg::ReqAckPlayerChat_EGameChatType::ReqAckPlayerChat_EGameChatType_EGCT_TEAM: { DoEvent(E_ChatEvent_ChatTeam, var); } break; default: break;; } }
//--------------------------------------------------------------------------- int TCustomMsgServer::Start() { int Result = 0; if (Status != SrvRunning) { Result = StartListener(); if (Result != 0) { DoEvent(0, evcListenerCannotStart, Result, 0, 0, 0, 0); Status = SrvError; } else { DoEvent(0, evcServerStarted, SockListener->ClientHandle, LocalPort, 0, 0, 0); Status = SrvRunning; }; }; FLastError = Result; return Result; }
void HandleEvent(EventType et, int errornum) { switch (et) { case EVENT_READ: case EVENT_WRITE: DoEvent(); break; case EVENT_ERROR: DelayReconnect(); } }
int CIrcProto::SetChannelSBText(CMString sWindow, CHANNELINFO * wi) { CMString sTemp = _T(""); if(wi->pszMode) { sTemp += _T("["); sTemp += wi->pszMode; sTemp += _T("] "); } if(wi->pszTopic) sTemp += wi->pszTopic; sTemp = DoColorCodes(sTemp.c_str(), TRUE, FALSE); return DoEvent(GC_EVENT_SETSBTEXT, sWindow.c_str(), NULL, sTemp.c_str(), NULL, NULL, NULL, FALSE, FALSE, 0); }
//--------------------------------------------------------------------------- void TCustomMsgServer::Incoming(socket_t Sock) { int idx; PWorkerSocket WorkerSocket; longword ClientHandle = Msg_GetSockAddr(Sock); if (CanAccept(Sock)) { LockList(); // First position available in the thread buffer idx = FirstFree(); if (idx >= 0) { // Creates the Worker and assigns it the connected socket WorkerSocket = CreateWorkerSocket(Sock); // Creates the Worker thread Workers[idx] = new TMsgWorkerThread(WorkerSocket, this); PMsgWorkerThread(Workers[idx])->Index = idx; // Update the number ClientsCount++; // And Starts the worker PMsgWorkerThread(Workers[idx])->Start(); DoEvent(WorkerSocket->ClientHandle, evcClientAdded, 0, 0, 0, 0, 0); } else { DoEvent(ClientHandle, evcClientNoRoom, 0, 0, 0, 0, 0); Msg_CloseSocket(Sock); } UnlockList(); } else { Msg_CloseSocket(Sock); DoEvent(ClientHandle, evcClientRejected, 0, 0, 0, 0, 0); }; }
void EventLoop() { Boolean gotEvent; EventRecord event; gQuitFlag = false; do { gotEvent = WaitNextEvent(everyEvent,&event,32767,nil); if (gotEvent) DoEvent(&event); } while (!gQuitFlag); ExitToShell(); }
void StartUpdate(HWND hwndPb,TCHAR* pFilePath) { DWORD totalsize; // Size of file and count of TCHAR totalsizestr[32]; totalFileSize(pFilePath,&totalsize); SendMessage(hwndPb, PBM_SETRANGE, 0, MAKELPARAM(0, totalsize / 2048)); SendMessage(hwndPb, PBM_SETSTEP, (WPARAM) 1, 0); BOOL bQuit = TRUE; while(!bQuit){ SendMessage(hwndPb, PBM_STEPIT, 0, 0); bQuit = DoEvent(); } //wsprintf(totalsizestr,"%ubytes",totalsize); // MessageBox (NULL, TEXT(totalsizestr),TEXT(szClassName), MB_ICONERROR) ; return; }
bool CIrcProto::FreeWindowItemData(CMString window, CHANNELINFO* wis) { CHANNELINFO* wi; if ( !wis ) wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0); else wi = wis; if ( wi ) { delete[] wi->pszLimit; delete[]wi->pszMode; delete[]wi->pszPassword; delete[]wi->pszTopic; delete wi; return true; } return false; }
// 移动 void NFCPlayerLogic::OnObjectMove(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqAckPlayerMove xMsg; if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } float fMove = g_pKernelModule->GetPropertyInt(NFINetModule::PBToNF(xMsg.mover()), "MOVE_SPEED")/10000.0f; NFDataList var; var.AddObject(NFINetModule::PBToNF(xMsg.mover())); var.AddFloat(fMove); const NFMsg::Vector3 &pos = xMsg.target_pos(0); var.AddVector3(NFVector3(pos.x(), pos.y(), pos.z())); DoEvent(E_PlayerEvent_PlayerMove, var); }
//--------------------------------------------收消息------------------------------------------------------------- void NFCPlayerLogic::OnRoleList(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::AckRoleLiteInfoList xMsg; if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } // 目前服务器只有一个角色 m_RoleList.clear(); for(int i = 0; i < xMsg.char_data_size(); i++) { m_RoleList.push_back(xMsg.char_data(i)); } DoEvent(E_PlayerEvent_RoleList, NFDataList()); }
void UpdateAI(uint32 diff) override { if (_doFacing) { _doFacing = false; me->SetFacingTo(_positions[_myPack - SUMMON_GROUP_CRUSHER_1].GetOrientation()); } if (!UpdateVictim()) return; _events.Update(diff); while (uint32 eventId = _events.ExecuteEvent()) DoEvent(eventId); DoMeleeAttackIfReady(); }
//--------------------------------------------------------------------------- void TCustomMsgServer::KillAll() { int c, cnt = 0; LockList(); for (c = 0; c < MaxWorkers; c++) { if (Workers[c] != 0) try { PMsgWorkerThread(Workers[c])->Kill(); PMsgWorkerThread(Workers[c])->WorkerSocket->ForceClose(); delete PMsgWorkerThread(Workers[c]); Workers[c] = 0; cnt++; } catch (...) { }; } UnlockList(); DoEvent(0, evcClientsDropped, 0, cnt, 0, 0, 0); }
//--------------------------------------------------------------------------- void TCustomMsgServer::Stop() { if (Status == SrvRunning) { // Kills the listener thread ServerThread->Terminate(); if (ServerThread->WaitFor(ThTimeout) != WAIT_OBJECT_0) ServerThread->Kill(); delete ServerThread; // Kills the listener delete SockListener; // Terminate all client threads TerminateAll(); Status = SrvStopped; LocalBind = 0; DoEvent(0, evcServerStopped, 0, 0, 0, 0, 0); }; FLastError = 0; }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- int main() { g_manager = ::Effekseer::Manager::Create( 2000 ); #if __CULLING_TEST g_manager->CreateCullingWorld(200, 200, 200, 4); #endif #if _WIN32 InitGraphics(g_window_width, g_window_height); InitSound(); #else InitGraphics( g_window_width, g_window_height); InitSound(); #endif Init(); while(DoEvent()) { Loop(); g_manager->Update(); Rendering(); } g_manager->Destroy(); for (size_t i = 0; i < g_effects.size(); i++) { ES_SAFE_RELEASE(g_effects[i]); } TermSound(); TermGraphics(); return 0; }
void Graphics_Mesh(bool isOpenGLMode) { StartGraphicsTest(); SetGLEnable(isOpenGLMode); asd::Log* log = asd::Log_Imp::Create(L"graphics.html", L"メッシュ"); auto window = asd::Window_Imp::Create(640, 480, asd::ToAString(L"メッシュ").c_str()); ASSERT_TRUE(window != nullptr); auto file = asd::File_Imp::Create(); ASSERT_TRUE(file != nullptr); auto graphics = asd::Graphics_Imp::Create(window, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, log, file, false, false); ASSERT_TRUE(graphics != nullptr); auto renderer3d = new asd::Renderer3D(graphics, asd::RenderSettings()); ASSERT_TRUE(renderer3d != nullptr); renderer3d->SetWindowSize(asd::Vector2DI(640, 480)); auto mesh1 = CreateMesh(graphics); auto mesh2 = CreateMesh(graphics); auto deformer = CreateDeformer(graphics); auto animation = CreateAnimation(); SetMeshBone(mesh2); mesh1->SendToGPUMemory(); mesh2->SendToGPUMemory(); auto cameraObject = new asd::RenderedCameraObject3D(graphics); cameraObject->SetPosition(asd::Vector3DF(0, 0, 10)); cameraObject->SetFocus(asd::Vector3DF(0, 0, 0)); cameraObject->SetFieldOfView(20.0f); cameraObject->SetZNear(1.0f); cameraObject->SetZFar(20.0f); cameraObject->SetWindowSize(asd::Vector2DI(800, 600)); auto meshObject1 = new asd::RenderedModelObject3D(graphics); meshObject1->AddMesh(mesh1); meshObject1->SetPosition(asd::Vector3DF(1, 0, 0)); meshObject1->SetRotation(asd::Vector3DF(20.0f, 20.0f, 0.0f)); auto meshObject2 = new asd::RenderedModelObject3D(graphics); meshObject2->AddMesh(mesh2); meshObject2->SetDeformer(deformer.get()); meshObject2->SetPosition(asd::Vector3DF(-1, 0, 0)); meshObject2->SetRotation(asd::Vector3DF(20.0f, 20.0f, 0.0f)); meshObject2->AddAnimationClip(asd::ToAString("anime1").c_str(), animation.get()); meshObject2->PlayAnimation(0, asd::ToAString("anime1").c_str()); auto lightObject = new asd::RenderedDirectionalLightObject3D(graphics); lightObject->SetRotation(asd::Vector3DF(30, 160, 0)); renderer3d->AddObject(cameraObject); renderer3d->AddObject(meshObject1); renderer3d->AddObject(meshObject2); renderer3d->AddObject(lightObject); int32_t time = 0; while (window->DoEvent()) { graphics->Begin(); graphics->Clear(true, false, asd::Color(0, 0, 0, 255)); renderer3d->Flip(1); renderer3d->BeginRendering(1); asd::Sleep(100); renderer3d->EndRendering(); graphics->SetRenderTarget(nullptr, nullptr); graphics->Clear(true, false, asd::Color(0, 0, 0, 255)); renderer3d->RenderResult(); graphics->Present(); graphics->End(); if (time == 10) { SAVE_SCREEN_SHOT(graphics, 0); } if (time == 11) { window->Close(); } time++; } meshObject1->Release(); meshObject2->Release(); cameraObject->Release(); lightObject->Release(); delete renderer3d; graphics->Release(); file->Release(); window->Release(); delete log; }
/** ** Wait for interactive input event. ** ** Handles X11 events, keyboard, mouse. ** Video interrupt for sync. ** Network messages. ** Sound queue. ** ** We must handle atlast one X11 event ** ** FIXME: the initialition could be moved out of the loop */ global void WaitEventsAndKeepSync(void) { #if 0 int connection; int sound; fd_set readfd; fd_set writefd; int maxfd; sound=0; for( ;; ) { if( XPending(TheDisplay) ) { DoEvent(); } if( VideoInterrupts ) { return; } FD_ZERO(&readfd); maxfd=connection=ConnectionNumber(TheDisplay); FD_SET(connection,&readfd); FD_ZERO(&writefd); #ifndef USE_THREAD if( !SoundOff && (sound=SoundFildes)!=-1 ) { if( sound>maxfd ) { maxfd=sound; } FD_SET(sound,&writefd); } #else if( !SoundOff && !SoundThreadRunning && (sound=SoundFildes)!=-1 ) { if( sound>maxfd ) { maxfd=sound; } FD_SET(sound,&writefd); } #endif if( NetworkFildes!=-1 ) { if( NetworkFildes>maxfd ) { maxfd=NetworkFildes; } FD_SET(NetworkFildes,&readfd); } maxfd=select(maxfd+1,&readfd,&writefd,0,0); if( VideoInterrupts ) { return; } if( maxfd!=-1 ) { #ifndef USE_THREAD if( !SoundOff && sound!=-1 && FD_ISSET(sound,&writefd) ) { WriteSound(); continue; } #else if( !SoundOff && !SoundThreadRunning && sound!=-1 && FD_ISSET(sound,&writefd) ) { WriteSound(); continue; } #endif if( NetworkFildes!=-1 && FD_ISSET(NetworkFildes,&readfd) ) { NetworkEvent(); continue; } DoEvent(); } } #endif struct timeval tv; fd_set rfds; fd_set wfds; int maxfd; int* xfd; int n; int i; int morex; int connection; connection=ConnectionNumber(TheDisplay); for( ;; ) { // // Prepare select // tv.tv_sec=0; tv.tv_usec=0; FD_ZERO(&rfds); FD_ZERO(&wfds); maxfd=0; // // X11 how many events already in que // xfd=NULL; morex=XQLength(TheDisplay); if( !morex ) { // // X11 connections number // maxfd=connection; FD_SET(connection,&rfds); // // Get all X11 internal connections // if( !XInternalConnectionNumbers(TheDisplay,&xfd,&n) ) { DebugLevel0(__FUNCTION__": out of memory\n"); abort(); } for( i=n; i--; ) { FD_SET(xfd[i],&rfds); if( xfd[i]>maxfd ) { maxfd=xfd[i]; } } } // // Network // if( NetworkFildes!=-1 ) { if( NetworkFildes>maxfd ) { maxfd=NetworkFildes; } FD_SET(NetworkFildes,&rfds); } // // Sound // if( !SoundOff && !SoundThreadRunning ) { if( SoundFildes>maxfd ) { maxfd=SoundFildes; } FD_SET(SoundFildes,&wfds); } maxfd=select(maxfd+1,&rfds,&wfds,NULL,morex ? &tv : NULL); // // X11 // if( maxfd>0 ) { if( !morex ) { for( i=n; i--; ) { if( FD_ISSET(xfd[i],&rfds) ) { XProcessInternalConnection(TheDisplay,xfd[i]); } } XFree(xfd); if( FD_ISSET(connection,&rfds) ) { XEventsQueued(TheDisplay,QueuedAfterReading); } morex=XQLength(TheDisplay); } } if( morex ) { // handle new + *OLD* x11 events DoEvent(); } if( maxfd>0 ) { // // Network // if( NetworkFildes!=-1 && FD_ISSET(NetworkFildes,&rfds) ) { NetworkEvent(); } // // Network in sync and time for frame over: return // if( !morex && NetworkInSync && VideoInterrupts ) { return; } // // Sound // if( !SoundOff && !SoundThreadRunning && FD_ISSET(SoundFildes,&wfds) ) { WriteSound(); } } // // Network in sync and time for frame over: return // if( !morex && NetworkInSync && VideoInterrupts ) { return; } } }
int main(int argc, char **argv) { int c; SaHpiVersionT hpiVer; SaHpiSessionIdT sessionid; SaHpiRptInfoT rptinfo; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; SaHpiEntryIdT nextrptentryid; SaHpiEntryIdT entryid; SaHpiEntryIdT nextentryid; SaHpiResourceIdT resourceid; SaHpiRdrT rdr; printf("%s ver %s\n", progname,progver); sensor_name = (char *)strdup(s_name); while ( (c = getopt( argc, argv,"ms:xz?")) != EOF ) switch(c) { case 'z': fxdebug = 1; /* fall thru to include next setting */ case 'x': fdebug = 1; break; /* case 'l': slist = 1; break; */ case 'm': sensor_name = (char *)strdup(sm_name); break; case 's': fsensor = 1; if (optarg) { sensor_name = (char *)strdup(optarg); } break; default: printf("Usage: %s [-xm] [-s sensor_descriptor]\n", progname); printf(" -s Sensor descriptor\n"); printf(" -m use Mullins sensor descriptor\n"); /* printf(" -l Display entire sensor list\n"); */ printf(" -x Display debug messages\n"); printf(" -z Display extra debug messages\n"); exit(1); } rv = saHpiInitialize(&hpiVer); if (rv != SA_OK) { printf("saHpiInitialize error %d\n",rv); exit(-1); } rv = saHpiSessionOpen(SAHPI_DEFAULT_DOMAIN_ID,&sessionid,NULL); if (rv != SA_OK) { printf("saHpiSessionOpen error %d\n",rv); exit(-1); } rv = saHpiResourcesDiscover(sessionid); if (fxdebug) printf("saHpiResourcesDiscover rv = %d\n",rv); rv = saHpiRptInfoGet(sessionid,&rptinfo); if (fxdebug) printf("saHpiRptInfoGet rv = %d\n",rv); if (fdebug) printf("RptInfo: UpdateCount = %d, UpdateTime = %lx\n", rptinfo.UpdateCount, (unsigned long)rptinfo.UpdateTimestamp); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); if (rv == SA_OK) { /* walk the RDR list for this RPT entry */ entryid = SAHPI_FIRST_ENTRY; rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; resourceid = rptentry.ResourceId; if (fdebug) printf("rptentry[%d] resourceid=%d\n", entryid,resourceid); printf("Resource Tag: %s\n", rptentry.ResourceTag.Data); while ((rv == SA_OK) && (entryid != SAHPI_LAST_ENTRY)) { rv = saHpiRdrGet(sessionid,resourceid, entryid,&nextentryid, &rdr); if (fxdebug) printf("saHpiRdrGet[%d] rv = %d\n",entryid,rv); if (rv == SA_OK) { if (rdr.RdrType == SAHPI_SENSOR_RDR) { /*type 2 includes sensor and control records*/ rdr.IdString.Data[rdr.IdString.DataLength] = 0; if (strncmp(rdr.IdString.Data, sensor_name, rdr.IdString.DataLength) == 0) { printf( "%02d %s\t", rdr.RecordId, rdr.IdString.Data); DoEvent( sessionid, resourceid, &rdr.RdrTypeUnion.SensorRec); if (rv != SA_OK) printf( "Returned Error from DoEvent: rv=%d\n", rv); } } if (rv != SA_OK) printf( "Returned HPI Error: rv=%d\n", rv); entryid = nextentryid; } } rptentryid = nextrptentryid; } } rv = saHpiSessionClose(sessionid); rv = saHpiFinalize(); exit(0); }
void Graphics_Mesh(bool isOpenGLMode) { StartGraphicsTest(); SetGLEnable(isOpenGLMode); ace::Log* log = ace::Log_Imp::Create(L"graphics.html", L"メッシュ"); auto window = ace::Window_Imp::Create(640, 480, ace::ToAString(L"メッシュ").c_str()); ASSERT_TRUE(window != nullptr); auto graphics = ace::Graphics_Imp::Create(window, isOpenGLMode, log, false); ASSERT_TRUE(graphics != nullptr); auto renderer3d = new ace::Renderer3D(graphics); ASSERT_TRUE(renderer3d != nullptr); renderer3d->SetWindowSize(ace::Vector2DI(640, 480)); auto mesh1 = CreateMesh(graphics); auto mesh2 = CreateMesh(graphics); auto deformer = CreateDeformer(graphics); auto animation = CreateAnimation(); auto cameraObject = new ace::RenderedCameraObject3D(graphics); cameraObject->SetPosition(ace::Vector3DF(0, 0, 10)); cameraObject->SetFocus(ace::Vector3DF(0, 0, 0)); cameraObject->SetFieldOfView(20.0f); cameraObject->SetZNear(1.0f); cameraObject->SetZFar(20.0f); cameraObject->SetWindowSize(ace::Vector2DI(800, 600)); auto meshObject1 = new ace::RenderedModelObject3D(graphics); meshObject1->AddMeshGroup(); meshObject1->AddMesh(0, mesh1); meshObject1->SetPosition(ace::Vector3DF(1, 0, 0)); meshObject1->SetRotation(ace::Vector3DF(20.0f, 20.0f, 0.0f)); auto meshObject2 = new ace::RenderedModelObject3D(graphics); meshObject2->AddMeshGroup(); meshObject2->AddMesh(0, mesh2); meshObject2->SetDeformer(0, deformer.get()); meshObject2->SetPosition(ace::Vector3DF(-1, 0, 0)); meshObject2->SetRotation(ace::Vector3DF(20.0f, 20.0f, 0.0f)); meshObject2->AddAnimationClip(ace::ToAString("anime1").c_str(), animation.get()); meshObject2->PlayAnimation(ace::ToAString("anime1").c_str()); auto lightObject = new ace::RenderedDirectionalLightObject3D(graphics); lightObject->SetRotation(ace::Vector3DF(30, 160, 0)); renderer3d->AddObject(cameraObject); renderer3d->AddObject(meshObject1); renderer3d->AddObject(meshObject2); renderer3d->AddObject(lightObject); auto renderer2d = new ace::Renderer2D_Imp(graphics, log, window->GetSize()); int32_t time = 0; while (window->DoEvent()) { graphics->Begin(); graphics->Clear(true, false, ace::Color(0, 0, 0, 255)); renderer3d->Flip(); renderer3d->BeginRendering(); ace::Sleep(100); renderer3d->EndRendering(); graphics->SetRenderTarget(nullptr, nullptr); ace::Vector2DF positions[4]; ace::Color colors[4]; ace::Vector2DF uvs[4]; colors[0] = ace::Color(255, 255, 255, 255); colors[1] = ace::Color(255, 255, 255, 255); colors[2] = ace::Color(255, 255, 255, 255); colors[3] = ace::Color(255, 255, 255, 255); positions[0].X = 0; positions[0].Y = 0; positions[1].X = 640; positions[1].Y = 0; positions[2].X = 640; positions[2].Y = 480; positions[3].X = 0; positions[3].Y = 480; uvs[0].X = 0; uvs[0].Y = 0; uvs[1].X = 1; uvs[1].Y = 0; uvs[2].X = 1; uvs[2].Y = 1; uvs[3].X = 0; uvs[3].Y = 1; renderer2d->AddSprite(positions, colors, uvs, renderer3d->GetRenderTarget(), ace::eAlphaBlend::ALPHA_BLEND_BLEND, 0); renderer2d->DrawCache(); renderer2d->ClearCache(); graphics->Present(); graphics->End(); if (time == 10) { SAVE_SCREEN_SHOT(graphics, 0); } if (time == 11) { window->Close(); } time++; } meshObject1->Release(); meshObject2->Release(); cameraObject->Release(); lightObject->Release(); delete renderer2d; delete renderer3d; graphics->Release(); window->Release(); delete log; }
void UpdateAI(const uint32 diff) { events.Update(diff); switch(uint32 eventId = events.ExecuteEvent()) { // Event Script case EVENT_FIRST_EVENT: DoEvent(); break; case EVENT_CHECK_WIPE: if (pInstance->IsWipe()) Reset(); events.ScheduleEvent(EVENT_CHECK_WIPE, defaultrand); break; // Combat Script /// Phase 1 case EVENT_TORNADO_KICK: me->CastSpell(me, SPELL_TORNADO_KICK, false); events.ScheduleEvent(EVENT_TORNADO_KICK, urand(7500, 12500)); break; case EVENT_FIST_OF_FURY: if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO)) me->CastSpell(target, SPELL_FIST_OF_FURY, false); events.ScheduleEvent(EVENT_FIST_OF_FURY, urand(5000, 10000)); break; case EVENT_CHASE_DOWN: // Todo events.ScheduleEvent(eventId, defaultrand); break; /// Phase 2 case EVENT_DISAPPEAR: { std::vector<uint8> randomIndex; for (int i = 0; i < 3; ++i) randomIndex.push_back(i); // 0 1 2 std::random_shuffle(randomIndex.begin(), randomIndex.end()); bool isBoss = true; for (auto index : randomIndex) { // The first random pos is for the boss, the two others are for his clones if (isBoss) { me->NearTeleportTo(ClonePos[index].GetPositionX(), ClonePos[index].GetPositionY(), ClonePos[index].GetPositionZ(), ClonePos[index].GetOrientation()); me->SetVisible(true); me->CastSpell(me, SPELL_SMOKE_BOMB, true); isBoss = false; } else if (Creature* clone = me->SummonCreature(NPC_SNOWDRIFT_CLONE, ClonePos[index].GetPositionX(), ClonePos[index].GetPositionY(), ClonePos[index].GetPositionZ(), ClonePos[index].GetOrientation())) clone->CastSpell(clone, SPELL_SMOKE_BOMB, true); } initDefaultEventsForPhase(); break; } case EVENT_FIREBALL: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) me->CastSpell(target, SPELL_BALL_OF_FIRE, false); events.ScheduleEvent(EVENT_FIREBALL, urand(2500, 5000)); break; /// Phase 3 case EVENT_PHASE_3: me->SetReactState(REACT_AGGRESSIVE); phase = PHASE_FIGHT_3; initDefaultEventsForPhase(); break; case EVENT_PARRY_STANCE: me->CastSpell(me, SPELL_PARRY_STANCE, false); events.ScheduleEvent(EVENT_PARRY_STANCE, urand(10000, 15000)); break; case EVENT_QUIVERING_PALM: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM)) me->CastSpell(target, SPELL_QUIVERING_PALM, false); events.ScheduleEvent(EVENT_QUIVERING_PALM, urand(5000, 10000)); break; default: break; } if (phase == PHASE_FIGHT_1 || phase == PHASE_FIGHT_3) DoMeleeAttackIfReady(); }
/** ** Wait for interactive input event. ** ** Handles X11 events, keyboard, mouse. ** Video interrupt for sync. ** Network messages. ** Sound queue. ** ** We must handle atlast one X11 event ** ** FIXME: the initialition could be moved out of the loop */ global void WaitEventsAndKeepSync(void) { #ifndef USE_WIN32 struct timeval tv; fd_set rfds; fd_set wfds; int maxfd; #endif SDL_Event event[1]; for(;;) { // Not very nice, but this is the problem if you use other libraries // The event handling of SDL is very buggy and wrong designed. if( SDL_PollEvent(event) ) { // Handle SDL event DoEvent(event); } else { #ifndef USE_WIN32 // // Prepare select // tv.tv_sec=0; tv.tv_usec=0; FD_ZERO(&rfds); FD_ZERO(&wfds); maxfd=0; // // Network // if( NetworkFildes!=-1 ) { if( NetworkFildes>maxfd ) { maxfd=NetworkFildes; } FD_SET(NetworkFildes,&rfds); } // // Sound // if( !SoundOff && !SoundThreadRunning ) { if( SoundFildes>maxfd ) { maxfd=SoundFildes; } FD_SET(SoundFildes,&wfds); } maxfd=select(maxfd+1,&rfds,&wfds,NULL ,SDL_PollEvent(NULL) ? &tv : NULL); if( maxfd>0 ) { // // Network // if( NetworkFildes!=-1 && FD_ISSET(NetworkFildes,&rfds) ) { NetworkEvent(); } // // Network in sync and time for frame over: return // if( NetworkInSync && VideoInterrupts ) { return; } // // Sound // if( !SoundOff && !SoundThreadRunning && FD_ISSET(SoundFildes,&wfds) ) { WriteSound(); } } #endif } // // Network in sync and time for frame over: return // if(NetworkInSync && VideoInterrupts) { return; } } }
bool OnConnected() { return DoEvent(); }
bool OnWriteReady() { /* Always return true here, false would close the socket - we need to do that ourselves with the pgsql API */ return DoEvent(); }
void CControlUI::Event(TEventUI& event) { if( OnEvent(&event) ) DoEvent(event); }
void Graphics_LayerRenderer(bool isOpenGLMode) { StartGraphicsTest(); SetGLEnable(isOpenGLMode); asd::Log* log = asd::Log_Imp::Create(u"graphics.html", u"レイヤー"); auto window = asd::Window_Imp::Create(640, 480, asd::ToAString(u"レイヤー").c_str(), log, false, asd::WindowPositionType::Default, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, asd::ColorSpaceType::LinearSpace, false); ASSERT_TRUE(window != nullptr); auto synchronizer = std::make_shared<asd::Synchronizer>(); auto file = asd::File_Imp::Create(synchronizer); ASSERT_TRUE(file != nullptr); asd::GraphicsOption go; go.IsFullScreen = false; go.IsReloadingEnabled = false; go.ColorSpace = asd::ColorSpaceType::LinearSpace; go.GraphicsDevice = isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11; auto graphics = asd::Graphics_Imp::Create(window, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, log, file, go); ASSERT_TRUE(graphics != nullptr); auto renderer = new asd::LayerRenderer(graphics); ASSERT_TRUE(renderer != nullptr); auto texture = graphics->CreateTexture2D(asd::ToAString(u"Data/Texture/Sample1.png").c_str()); ASSERT_TRUE(texture != nullptr); int32_t time = 0; while (window->DoEvent()) { graphics->Begin(); graphics->Clear(true, false, asd::Color(0, 0, 0, 255)); { asd::Vector2DF lpos[4]; lpos[0].X = 0; lpos[0].Y = 0; lpos[1].X = 600; lpos[1].Y = 0; lpos[2].X = 640; lpos[2].Y = 480; lpos[3].X = 0; lpos[3].Y = 440; renderer->SetWindowSize(asd::Vector2DI(640, 480)); renderer->SetTexture(texture.get()); renderer->SetLayerPosition(lpos); } { asd::Vector2DF positions[4]; asd::Color colors[4]; asd::Vector2DF uvs[4]; colors[0] = asd::Color(255, 255, 255, 255); colors[1] = asd::Color(255, 255, 255, 255); colors[2] = asd::Color(255, 255, 255, 255); positions[0].X = 0.0f; positions[0].Y = 0.0f; positions[1].X = 1.0f; positions[1].Y = 0.0f; positions[2].X = 1.0f; positions[2].Y = 1.0f; uvs[0].X = 0; uvs[0].Y = 0; uvs[1].X = 1; uvs[1].Y = 0; uvs[2].X = 1; uvs[2].Y = 1; renderer->AddTriangle(positions, colors, uvs); } { asd::Vector2DF positions[4]; asd::Color colors[4]; asd::Vector2DF uvs[4]; colors[0] = asd::Color(255, 255, 255, 255); colors[1] = asd::Color(255, 255, 255, 255); colors[2] = asd::Color(255, 255, 255, 255); positions[0].X = 0.0f; positions[0].Y = 0.0f; positions[1].X = 0.5f; positions[1].Y = 1.0f; positions[2].X = 0.0f; positions[2].Y = 0.5f; uvs[0].X = 0; uvs[0].Y = 0; uvs[1].X = 1; uvs[1].Y = 1; uvs[2].X = 0; uvs[2].Y = 1; renderer->AddTriangle(positions, colors, uvs); } renderer->DrawCache(); renderer->ClearCache(); graphics->Present(); graphics->End(); if (time == 10) { SAVE_SCREEN_SHOT(graphics, 0); } if (time == 11) { window->Close(); } time++; } texture.reset(); renderer->Release(); graphics->Release(); file->Release(); window->Release(); delete log; }
UINT HandleNotifications(LPVOID) { DWORD hr = DS_OK; DWORD hRet = 0; thn=FALSE; thn1=FALSE; char* pdsb1; char* pdsb2; syukai=0; // char bufwav2[OUTPUT_BUFFER_SIZE]; HANDLE ev[] = {(HANDLE)og->timer}; // ULONG PlayCursor,WriteCursor=OUTPUT_BUFFER_SIZE*4,oldw=OUTPUT_BUFFER_SIZE*4; ULONG PlayCursor,WriteCursor=0,oldw=OUTPUT_BUFFER_SIZE*2,oldw2; m_dsb->SetCurrentPosition(0); if(mode==-10){ oldw=OUTPUT_BUFFER_SIZE*2; og->timer.SetEvent(); } fade1=0; for(;;){ DWORD dwDataLen = WAVDALen/10; if(syukai==2) {thn=TRUE;AfxEndThread(0);} if(syukai==1) {syukai2=1;continue;} // int ik; // for(ik=0;ik<60;ik++){ // if(syukai) ::WaitForMultipleObjects(1, ev, FALSE, 40); // else //Sleep(1); if (sek == 1) { if (m_dsb)m_dsb->Stop(); oldw = 0; if ((mode >= 10 && mode <= 20) || mode < -10) { playwavadpcm(bufwav3, oldw, OUTPUT_BUFFER_SIZE / 12 * wavch * 2, 0);//データ獲得 } else if (mode == -10) { playwavmp3(bufwav3, oldw, OUTPUT_BUFFER_SIZE / 12 * wavch * 2, 0);//データ獲得 } else if (mode == -3) { playwavkpi(bufwav3, oldw, OUTPUT_BUFFER_SIZE / 12 * wavch * 2, 0);//データ獲得 } else if (mode == -8) { playwavflac(bufwav3, oldw, OUTPUT_BUFFER_SIZE / 12 * wavch * 2, 0);//データ獲得 } else if (mode == -9) { playwavm4a(bufwav3, oldw, OUTPUT_BUFFER_SIZE / 12 * wavch * 2, 0);//データ獲得 } else { playwavds2(bufwav3, oldw, OUTPUT_BUFFER_SIZE / 12 * wavch * 2, 0);//データ獲得 } oldw = OUTPUT_BUFFER_SIZE / 12 * wavch * 2; WriteCursor = OUTPUT_BUFFER_SIZE / 12 * wavch * 2; if(m_dsb)m_dsb->SetCurrentPosition(0); if(m_dsb)m_dsb->Play(0,0,DSBPLAY_LOOPING); sek=FALSE; //break; } if(thn1) {thn=TRUE;AfxEndThread(0);} // } if(ps==1) continue; if(m_dsb)m_dsb->GetCurrentPosition(&PlayCursor, &WriteCursor);//再生位置取得 int len1=0,len2=0,len3,len4; // oldw = ((oldw / (wavch * 2)) * (wavch * 2)); len1=(int)WriteCursor-(int)oldw;//書き込み範囲取得10 len2=0; if (len1 == 0 && len2 == 0) continue; if(len1<0){ len1=OUTPUT_BUFFER_SIZE*OUTPUT_BUFFER_NUM-oldw; len2= WriteCursor;} if(len2<0) len2=0; //len1 = (len1 / (wavsam / 8)) * (wavsam / 8); //len2 = (len2 / (wavsam / 8)) * (wavsam / 8); len4=len1+len2; if((mode>=10 && mode<=20) || mode<-10) playwavadpcm(bufwav3,oldw,len1,len2);//データ獲得 else if(mode==-10) len4=playwavmp3(bufwav3,oldw,len1,len2);//データ獲得 else if(mode==-3) len4=playwavkpi(bufwav3,oldw,len1,len2);//データ獲得 else if (mode == -8) playwavflac(bufwav3, oldw, len1, len2);//データ獲得 else if (mode == -9) playwavm4a(bufwav3, oldw, len1, len2);//データ獲得 else playwavds2(bufwav3,oldw,len1,len2);//データ獲得 if(m_dsb){ m_dsb->Lock(oldw,len4,(LPVOID *)&pdsb1,(DWORD*)&len3,(LPVOID *)&pdsb2,(DWORD*)&len4,0); thn=FALSE; Sleep(20); thn=FALSE; memcpy(pdsb1,bufwav3+oldw,len3); if(len4!=0)memcpy(pdsb2,bufwav3,len4); if(m_dsb)m_dsb->Unlock(pdsb1,len3,pdsb2,len4); oldw2=oldw+len3; if(len4!=0)oldw2=len4; oldw=WriteCursor; // oldw+=(len3+len4); // oldw%=OUTPUT_BUFFER_SIZE*OUTPUT_BUFFER_NUM; } if(fade1){ // if(m_dsb){ // m_dsb->Lock(0,OUTPUT_BUFFER_SIZE*OUTPUT_BUFFER_NUM,(LPVOID *)&pdsb1,(DWORD*)&len3,(LPVOID *)&pdsb2,(DWORD*)&len4,0); // ZeroMemory(pdsb1,len3); // if(len4!=0)ZeroMemory(pdsb2,len4); // m_dsb->Unlock(pdsb1,len3,pdsb2,len4); // } // Sleep(750); oldw=oldw2-(wavbit); if(((int)oldw)<=0)oldw=wavbit; int flgn=0; playf = 1; thn = FALSE; if(m_dsb && thn==FALSE){ m_dsb->GetCurrentPosition(&PlayCursor, &WriteCursor); if(oldw<=PlayCursor) flgn=1; // DWORD time=timeGetTime()+3000; for(;;){ // if(time<timeGetTime()) break; DoEvent(); if(m_dsb)m_dsb->GetCurrentPosition(&PlayCursor, &WriteCursor); if(oldw>PlayCursor){flgn=0; continue;} if(oldw<=PlayCursor && flgn==0) break; } } // m_dsb->SetVolume(DSBVOLUME_MIN); // m_dsb->Stop(); og->OnPause(); playf=0; thn=TRUE; AfxEndThread(0); // for(int y=0;y<11;y++){ // CloseHandle(hNotifyEvent[y]);hNotifyEvent[y] = (HANDLE)NULL; // } return 0; } } } //handlenotifications()
void UpdateAI(uint32 diff) override { if (_nextMovement) { switch (_nextMovement) { case MOVE_OUTSIDE: { float dist = HUGE_VALF; for (uint8 spawn = 0; spawn < NUM_SPAWNS; ++spawn) { float thisDist = initialMoves[spawn].GetExactDistSq(me); if (thisDist < dist) { _mySpawn = spawn; dist = thisDist; } } me->GetMotionMaster()->MovePoint(MOVE_OUTSIDE, initialMoves[_mySpawn], false); // do not pathfind here, we have to pass through a "wall" of webbing break; } case MOVE_DOWNSTAIRS: me->GetMotionMaster()->MovePoint(MOVE_DOWNSTAIRS, downstairsMoves[_mySpawn]); break; case MOVE_DOWNSTAIRS_2: if (downstairsMoves2[_mySpawn].GetPositionX() > 0.0f) // might be unset for this spawn - if yes, skip { me->GetMotionMaster()->MovePoint(MOVE_DOWNSTAIRS_2, downstairsMoves2[_mySpawn]); break; } // intentional missing break case MOVE_HADRONOX: case MOVE_HADRONOX_REAL: { static const float zCutoff = 702.0f; Creature* hadronox = _instance->GetCreature(DATA_HADRONOX); if (hadronox && hadronox->IsAlive()) { if (_nextMovement != MOVE_HADRONOX_REAL) if (hadronox->GetPositionZ() < zCutoff) { me->GetMotionMaster()->MovePoint(MOVE_HADRONOX, hadronoxStep[2]); break; } AttackStart(hadronox); } break; } default: break; } _nextMovement = MOVE_NONE; } if (!UpdateVictim()) return; _events.Update(diff); while (uint32 eventId = _events.ExecuteEvent()) DoEvent(eventId); DoMeleeAttackIfReady(); }