ByteBuffer::~ByteBuffer()
{
	Kill();
}
Beispiel #2
0
void Console::Kill()
{
	for(int i = 0; i < processes.GetCount(); i++)
		Kill(i);
}
Beispiel #3
0
void CShotObject::Init ( bool draw )
{	
	Kill();
	if (draw)
		drawable = CDrawManager::instance().New("shot",this);
}
Beispiel #4
0
JThread::~JThread()
{
    Kill();
}
Beispiel #5
0
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  if (msg == WM_TRAY) {
    if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) {
      ToggleState();
    }
    else if (lParam == WM_MBUTTONDOWN) {
      if ((GetAsyncKeyState(VK_SHIFT)&0x8000)) {
        ShellExecute(NULL, L"open", inipath, NULL, NULL, SW_SHOWNORMAL);
      }
      else {
        HookMouse();
      }
    }
    else if (lParam == WM_RBUTTONUP) {
      ShowContextMenu(hwnd);
    }
  }
  else if (msg == WM_UPDATESETTINGS) {
    wchar_t txt[10];
    // TimerCheck
    KillTimer(g_hwnd, CHECKTIMER);
    GetPrivateProfileString(L"General", L"TimerCheck", L"0", txt, ARRAY_SIZE(txt), inipath);
    if (_wtoi(txt)) {
      SetTimer(g_hwnd, CHECKTIMER, CHECKINTERVAL, NULL);
    }
  }
  else if (msg == WM_TASKBARCREATED) {
    tray_added = 0;
    UpdateTray();
  }
  else if (msg == WM_COMMAND) {
    int wmId=LOWORD(wParam), wmEvent=HIWORD(wParam);
    if (wmId == SWM_TOGGLE) {
      ToggleState();
    }
    else if (wmId == SWM_ELEVATE) {
      wchar_t path[MAX_PATH];
      GetModuleFileName(NULL, path, ARRAY_SIZE(path));
      int ret = (INT_PTR) ShellExecute(NULL, L"runas", path, NULL, NULL, SW_SHOWNORMAL);
      if (ret > 32) {
        DestroyWindow(hwnd);
      }
    }
    else if (wmId == SWM_AUTOSTART_ON) {
      SetAutostart(1, 0);
    }
    else if (wmId == SWM_AUTOSTART_OFF) {
      SetAutostart(0, 0);
    }
    else if (wmId == SWM_AUTOSTART_ELEVATE_ON) {
      SetAutostart(1, 1);
    }
    else if (wmId == SWM_AUTOSTART_ELEVATE_OFF) {
      SetAutostart(1, 0);
    }
    else if (wmId == SWM_TIMERCHECK_ON) {
      WritePrivateProfileString(L"General", L"TimerCheck", L"1", inipath);
      SendMessage(g_hwnd, WM_UPDATESETTINGS, 0, 0);
    }
    else if (wmId == SWM_TIMERCHECK_OFF) {
      WritePrivateProfileString(L"General", L"TimerCheck", L"0", inipath);
      SendMessage(g_hwnd, WM_UPDATESETTINGS, 0, 0);
    }
    else if (wmId == SWM_WEBSITE) {
      OpenUrl(APP_URL);
    }
    else if (wmId == SWM_XKILL) {
      HookMouse();
    }
    else if (wmId == SWM_EXIT) {
      DestroyWindow(hwnd);
    }
  }
  else if (msg == WM_DESTROY) {
    showerror = 0;
    UnhookKeyboard();
    UnhookMouse();
    RemoveTray();
    PostQuitMessage(0);
  }
  else if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
    // Hide the window if clicked on, this might happen if it wasn't hidden by the hooks for some reason
    ShowWindow(hwnd, SW_HIDE);
    // Since we take away the skull, make sure we can't kill anything
    UnhookMouse();
  }
  else if (msg == WM_TIMER) {
    if (wParam == CHECKTIMER && ENABLED()) {
      if (GetAsyncKeyState(VK_LCONTROL)&0x8000
       && GetAsyncKeyState(VK_LMENU)&0x8000
       && GetAsyncKeyState(VK_F4)&0x8000) {
        // Get hwnd of foreground window
        HWND hwnd = GetForegroundWindow();
        if (hwnd == NULL) {
          return DefWindowProc(hwnd, msg, wParam, lParam);
        }

        // Kill it!
        Kill(hwnd);
      }
      else {
        // Reset when the user has released the keys
        killing = 0;
      }
    }
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}
/*
 * Wait until process specified by #pid is stopped due to SIGSTOP signal.
 *
 * @returns true if process has come to stop during #timeout_ns nanoseconds,
 * false if the process cannot be found or failed to stop during #timeout_ns
 * nanoseconds.
 *
 * FIXME: Only timeouts < 1s are supported
 */
static bool ProcessWaitUntilStopped(pid_t pid, long timeout_ns)
{
    while (timeout_ns > 0)
    {
        switch (GetProcessState(pid))
        {
        case PROCESS_STATE_RUNNING:
            break;
        case PROCESS_STATE_STOPPED:
            return true;
        case PROCESS_STATE_DOES_NOT_EXIST:
            return false;
        default:
            ProgrammingError("Unexpected value returned from GetProcessState");
        }

        struct timespec ts = {
            .tv_sec = 0,
            .tv_nsec = MIN(SLEEP_POLL_TIMEOUT_NS, timeout_ns),
        };

        while (nanosleep(&ts, &ts) < 0)
        {
            if (errno != EINTR)
            {
                ProgrammingError("Invalid timeout for nanosleep");
            }
        }

        timeout_ns = MAX(0, timeout_ns - SLEEP_POLL_TIMEOUT_NS);
    }

    return false;
}

/*
 * FIXME: Only timeouts < 1s are supported
 */
static bool ProcessWaitUntilExited(pid_t pid, long timeout_ns)
{
    while (timeout_ns > 0)
    {
        if (kill(pid, 0) < 0 && errno == ESRCH)
        {
            return true;
        }

        struct timespec ts = {
            .tv_sec = 0,
            .tv_nsec = MIN(SLEEP_POLL_TIMEOUT_NS, timeout_ns),
        };

        while (nanosleep(&ts, &ts) < 0)
        {
            if (errno != EINTR)
            {
                ProgrammingError("Invalid timeout for nanosleep");
            }
        }

        timeout_ns = MAX(0, timeout_ns - SLEEP_POLL_TIMEOUT_NS);
    }

    return false;
}

/* A timeout to wait for process to stop (pause) or exit.  Note that
 * it's important that it not over-flow 32 bits; no more than nine 9s
 * in a row ! */
#define STOP_WAIT_TIMEOUT 999999999L

/*
 * Safely kill process by checking that the process is the right one by matching
 * process start time.
 *
 * The algorithm:
 *
 *   1. Check that the process has the same start time as stored in lock. If it
 *      is not, return, as we know for sure this is a wrong process. (This step
 *      is an optimization to avoid sending SIGSTOP/SIGCONT to wrong processes).
 *
 *   2. Send SIGSTOP to the process.
 *
 *   3. Poll process state until it is stopped.
 *
 *   Now the process is stopped, so we may examine it and not be afraid that it
 *   will exit and another one with the same PID will appear.
 *
 *   4. Check that the process has the same start time as provided.
 *      If it is, send the signal to the process.
 *
 *   5. Send SIGCONT to the process, so it may continue.
 *
 *
 * Returns 0 on success, -1 on error. Error code is signalled through errno.
 *
 * ERRORS
 *
 *  EINVAL An invalid signal was specified.
 *  EPERM The process does not have permission to send the signal.
 *  ESRCH The pid does not exist or its start time does not match expected one.
 */
static int SafeKill(pid_t pid, time_t expected_start_time, int signal)
{
    /* Preliminary check: in case process start time is different already, we
     * are sure we don't want to STOP it or kill it. */

    time_t pid_start_time = GetProcessStartTime(pid);

    if (pid_start_time != expected_start_time)
    {
        errno = ESRCH;
        return -1;
    }

    /* Now to avoid race conditions we need to stop process so it won't exit
     * voluntarily while we are working on it */

    if (kill(pid, SIGSTOP) < 0)
    {
        return -1;
    }

    if (!ProcessWaitUntilStopped(pid, STOP_WAIT_TIMEOUT))
    {
        /* Ensure the process is started again in case of timeout or error, so
         * we don't leave SIGSTOP'ed processes around on overloaded or
         * misconfigured machine */
        kill(pid, SIGCONT);
        errno = ESRCH;
        return -1;
    }

    /* Here process has stopped, so we may interrogate it without race conditions */

    pid_start_time = GetProcessStartTime(pid);

    if (pid_start_time != expected_start_time)
    {
        /* This is a wrong process, let it continue */
        kill(pid, SIGCONT);
        errno = ESRCH;
        return -1;
    }

    /* We've got a right process, signal it and let it continue */

    int ret = kill(pid, signal);
    int saved_errno = errno;

    /*
     * We don't check return value of SIGCONT, as the process may have been
     * terminated already by previous kill. Moreover, what would we do with the
     * return code?
     */
    kill(pid, SIGCONT);

    errno = saved_errno;
    return ret;
}

static int Kill(pid_t pid, time_t process_start_time, int signal)
{
    if (process_start_time == PROCESS_START_TIME_UNKNOWN)
    {
        /* We don't know when the process has started, do a plain kill(2) */
        return kill(pid, signal);
    }
    else
    {
        return SafeKill(pid, process_start_time, signal);
    }
}

int GracefulTerminate(pid_t pid, time_t process_start_time)
{
    if (Kill(pid, process_start_time, SIGINT) < 0)
    {
        return errno == ESRCH;
    }

    if (ProcessWaitUntilExited(pid, STOP_WAIT_TIMEOUT))
    {
        return true;
    }

    if (Kill(pid, process_start_time, SIGTERM) < 0)
    {
        return errno == ESRCH;
    }

    if (ProcessWaitUntilExited(pid, STOP_WAIT_TIMEOUT))
    {
        return true;
    }

    if (Kill(pid, process_start_time, SIGKILL) < 0)
    {
        return errno == ESRCH;
    }

    return true;
}
Beispiel #7
0
	inline ~ComPtr()                               {Kill();}
Beispiel #8
0
// Deconstructor kills the memory reference of the string
String::~String()
{
	// Calls the Kill function to deallocate the memory for the internal char array
	Kill();
}
Beispiel #9
0
wxThreadError wxThread::Delete(ExitCode *pRc)
{
    ExitCode rc = 0;

    // Delete() is always safe to call, so consider all possible states

    // we might need to resume the thread, but we might also not need to cancel
    // it if it doesn't run yet
    bool shouldResume = false,
         shouldCancel = true,
         isRunning = false;

    // check if the thread already started to run
    {
        wxCriticalSectionLocker         lock((wxCriticalSection &)m_critsect);

        if ( m_internal->GetState() == STATE_NEW )
        {
            // WinThreadStart() will see it and terminate immediately, no need
            // to cancel the thread - but we still need to resume it to let it
            // run
            m_internal->SetState(STATE_EXITED);

            Resume();   // it knows about STATE_EXITED special case

            shouldCancel = false;
            isRunning = true;

            // shouldResume is correctly set to false here
        }
        else
        {
            shouldResume = IsPaused();
        }
    }

    // resume the thread if it is paused
    if ( shouldResume )
        Resume();

    TID hThread = m_internal->GetHandle();

    if ( isRunning || IsRunning())
    {
        if (IsMain())
        {
            // set flag for wxIsWaitingForThread()
            gs_bWaitingForThread = true;
        }

        // ask the thread to terminate
        if ( shouldCancel )
        {
            wxCriticalSectionLocker lock(m_critsect);

            m_internal->Cancel();
        }

#if 0
        // we can't just wait for the thread to terminate because it might be
        // calling some GUI functions and so it will never terminate before we
        // process the Windows messages that result from these functions
        DWORD result = 0;       // suppress warnings from broken compilers
        do
        {
            if ( IsMain() )
            {
                // give the thread we're waiting for chance to do the GUI call
                // it might be in
                if ( (gs_nWaitingForGui > 0) && wxGuiOwnedByMainThread() )
                {
                    wxMutexGuiLeave();
                }
            }

            result = ::DosWaitThread(&hThread, DCWW_NOWAIT);
            // FIXME: We ought to have a message processing loop here!!

            switch ( result )
            {
                case ERROR_INTERRUPT:
                case ERROR_THREAD_NOT_TERMINATED:
                    break;
                case ERROR_INVALID_THREADID:
                case NO_ERROR:
                    // thread we're waiting for just terminated
                    // or even does not exist any more.
                    result = NO_ERROR;
                    break;
                default:
                    wxFAIL_MSG(wxT("unexpected result of DosWaitThread"));
            }
            if ( IsMain() )
            {
                // event processing - needed if we are the main thread
                // to give other threads a chance to do remaining GUI
                // processing and terminate cleanly.
                wxTheApp->HandleSockets();
                if (wxTheApp->Pending())
                  if ( !wxTheApp->DoMessage() )
                  {
                      // WM_QUIT received: kill the thread
                      Kill();

                      return wxTHREAD_KILLED;
                  }
                  else
                    wxUsleep(10);
            }
            else
                wxUsleep(10);
        } while ( result != NO_ERROR );
#else // !wxUSE_GUI
        // simply wait for the thread to terminate
        //
        // OTOH, even console apps create windows (in wxExecute, for WinSock
        // &c), so may be use MsgWaitForMultipleObject() too here?
        if ( ::DosWaitThread(&hThread, DCWW_WAIT) != NO_ERROR )
        {
            wxFAIL_MSG(wxT("unexpected result of DosWaitThread"));
        }
#endif // wxUSE_GUI/!wxUSE_GUI

        if ( IsMain() )
        {
            gs_bWaitingForThread = false;
        }
    }

#if 0
    // although the thread might be already in the EXITED state it might not
    // have terminated yet and so we are not sure that it has actually
    // terminated if the "if" above hadn't been taken
    do
    {
        if ( !::GetExitCodeThread(hThread, (LPDWORD)&rc) )
        {
            wxLogLastError(wxT("GetExitCodeThread"));

            rc = (ExitCode)-1;
        }
    } while ( (DWORD)rc == STILL_ACTIVE );
#endif

    if ( IsDetached() )
    {
        // if the thread exits normally, this is done in WinThreadStart, but in
        // this case it would have been too early because
        // MsgWaitForMultipleObject() would fail if the thread handle was
        // closed while we were waiting on it, so we must do it here
        delete this;
    }

    if ( pRc )
        *pRc = rc;

    return rc == (ExitCode)-1 ? wxTHREAD_MISC_ERROR : wxTHREAD_NO_ERROR;
}
Beispiel #10
0
void putBackTrace(FILE *out)
{   CStr(pid,32);
    int cpid,Cpid,nready,xpid;
    int pipes[2],psync[2];
    CStr(command,128);
    const char *path;
    int mpid = getpid();

    if( INHERENT_fork() == 0 )
        return;

    dout = out;
    dStart = Time();

    IGNRETZ pipe(psync);
    if( (Cpid = fork()) == 0 ) { /* the clone to be traced */
        __BtLog("X target");
        close(psync[1]);
        errno = 0;
        nready =
            PollIn(psync[0],10*1000);
        __BtLog("Y target, nready=%d errno=%d",nready,errno);
        if( nready < 0 && errno == EINTR ) {
            /* INTR by ptrace() attach/detach ? */
            errno = 0;
            /* psync[0] become EOF when DBX finised */
            nready = PollIn(psync[0],10*1000);
            __BtLog("Z target, nready=%d errno=%d",nready,errno);
        }
        _exit(0);
    }

    sprintf(pid,"%d",Cpid);
    sprintf(command,"where\ndetach\nquit\n");
    /*
    sprintf(command,"where\nquit\n");
    */

    IGNRETZ pipe(pipes);
    if( (cpid = fork()) == 0 ) {
        close(pipes[1]);
        dup2(pipes[0],0);
        dup2(fileno(out),1);
        dup2(fileno(out),2);
        if( sizeof(void*) == 8 ) { /* DEC ALPHA ? */
            execlp("dbx","dbx",EXEC_PATH,"-pid",pid,(void*)0);
        }
        execlp("dbx","dbx","-q",EXEC_PATH,pid,(void*)0);
        execlp("gdb","gdb","-q",EXEC_PATH,pid,(void*)0);
        path = getenv("PATH");
        fprintf(out,"#### error: no dbx nor gdb in PATH=%s\n",
                path?path:"");
        exit(-1);
    }
    close(pipes[0]);
    IGNRETP write(pipes[1],command,strlen(command));
    close(psync[1]);

    __BtLog("A caller, poll [target=%d DBX=%d]",Cpid,cpid);
    nready = PollIn(psync[0],10*1000);
    __BtLog("B caller, nready=%d errno=%d",nready,errno);
    close(psync[0]);
    close(pipes[1]);
    xpid = NoHangWait();
    if( xpid == 0 ) {
        sleep(1);
        xpid = NoHangWait();
    }
    __BtLog("C caller, xpid=%d [%d %d]",xpid,Cpid,cpid);

    if( xpid != Cpid ) {
        int Xpid;
        Kill(Cpid,9);
        Xpid = NoHangWait();
        if( Xpid == 0 ) {
            sleep(1);
            Xpid = NoHangWait();
        }
        __BtLog("D caller, Xpid=%d [%d %d]",Xpid,Cpid,cpid);
        if( xpid == 0 )
            xpid = Xpid;
    }
    /*
    if( nready == 0 || xpid != cpid ){
    */
    if( xpid != cpid ) {
        int rcode;
        daemonlog("F","\n#### debugger freezed? nready=%d %d/%d/%d\n",
                  nready,xpid,cpid,Cpid);
        fprintf(out,"#### error: nready=%d xpid=%d/%d/%d\n",
                nready,xpid,cpid,Cpid);

        rcode = Kill(cpid,9);
        sleep(3);
        xpid = NoHangWait();
        fprintf(out,"#### Terminate Debugger: kill(%d)=%d xpid=%d\n",
                cpid,rcode,xpid);
        __BtLog("#### Terminate Debugger: kill(%d)=%d xpid=%d\n",
                cpid,rcode,xpid);
    }
}
Beispiel #11
0
void mtsComponentViewer::ProcessResponse(void)
{
    if (UDrawResponse != "") {
        // Parse command and args (if present).
        std::string command;
        std::string args;
        size_t pos = UDrawResponse.find('(');
        if (pos != std::string::npos) {
            command = UDrawResponse.substr(0,pos);
            size_t epos = UDrawResponse.rfind(')');
            if (epos != std::string::npos)
                args = UDrawResponse.substr(pos+1, epos-pos-1);
        }
        else {
            pos = UDrawResponse.find_first_of("\r\n");
            if (pos != std::string::npos)
                command = UDrawResponse.substr(0,pos);
        }

        if (command == "ok")
            WaitingForResponse = false;
        else if (command == "communication_error") {
            WaitingForResponse = false;
            CMN_LOG_CLASS_RUN_WARNING << "UDrawGraph error: " << args << std::endl;
        }
        else if (command == "quit") {
            CMN_LOG_CLASS_RUN_WARNING << "Received quit command from UDrawGraph" << std::endl;
            ReaderThreadFinished = true;
            Kill();
            // mtsTaskFromSignal::Kill should wake up thread (no need to call PostCommandQueuedMethod)
        }
        else if (command == "menu_selection") {
            // Remove leading and trailing quotes
            args = args.substr(1, args.size()-2);
            if (args == "redraw") {
                CMN_LOG_CLASS_RUN_VERBOSE << "Redrawing graph" << std::endl;
                SendAllInfo();
            }
#if CISST_MTS_HAS_ICE
            else if (args == "showproxies") {
                CMN_LOG_CLASS_RUN_VERBOSE << "Redrawing graph, showing proxies" << std::endl;
                ShowProxies = true;
                SendAllInfo();
                ActivateMenuItems();
            }
            else if (args == "hideproxies") {
                CMN_LOG_CLASS_RUN_VERBOSE << "Redrawing graph, hiding proxies" << std::endl;
                ShowProxies = false;
                SendAllInfo();
                ActivateMenuItems();
            }
#endif
            else if (args == "connectStart") {
                ConnectionRequest.Init();
                ConnectionStarted = true;
                ActivateMenuItems();
                WriteString(UDrawPipe, "window(show_status(\"Starting connection: choose required and provided interfaces\"))\n");
                CMN_LOG_CLASS_RUN_VERBOSE << "Starting connection -- choose required and provided interfaces" << std::endl;
            }
            else if (args == "connectFinish") {
                WriteString(UDrawPipe, "window(show_status(\"\"))\n");
                CMN_LOG_CLASS_RUN_VERBOSE << "Attempting connection: " << ConnectionRequest << std::endl;
                ManagerComponentServices->Connect(ConnectionRequest);
                ChangeComponentBorder(ConnectionRequest.Client.ProcessName,
                                      ConnectionRequest.Client.ComponentName, BORDER_SINGLE);
                ChangeComponentBorder(ConnectionRequest.Server.ProcessName,
                                      ConnectionRequest.Server.ComponentName, BORDER_SINGLE);
                ConnectionStarted = false;
                ConnectionRequest.Init();
                ActivateMenuItems();
            }
            else if (args == "connectCancel") {
                WriteString(UDrawPipe, "window(show_status(\"\"))\n");
                ConnectionStarted = false;
                ChangeComponentBorder(ConnectionRequest.Client.ProcessName,
                                      ConnectionRequest.Client.ComponentName, BORDER_SINGLE);
                ChangeComponentBorder(ConnectionRequest.Server.ProcessName,
                                      ConnectionRequest.Server.ComponentName, BORDER_SINGLE);
                ConnectionRequest.Init();
                ActivateMenuItems();
                CMN_LOG_CLASS_RUN_VERBOSE << "Canceling connection request" << std::endl;
            }
        }
        else if (command == "popup_selection_edge") {
            std::string arg1, arg2;
            ParseArgs(args, arg1, arg2);
            if (arg2 == "disconnect") {
                int connectionID;
                if (sscanf(arg1.c_str(), "%d", &connectionID) == 1) {
                    CMN_LOG_CLASS_RUN_VERBOSE << "Disconnecting connection ID " << connectionID << std::endl;
                    ManagerComponentServices->Disconnect(static_cast<ConnectionIDType>(connectionID));
                }
                else
                    CMN_LOG_CLASS_RUN_ERROR << "Could not parse connection ID from: " << arg1 << std::endl;
            }
        }
        else if (command == "popup_selection_node") {
            std::string arg1, arg2;
            ParseArgs(args, arg1, arg2);
            std::string processName;
            std::string componentName;
            if (ParseProcessAndComponent(arg1, processName, componentName)) {
                if (arg2 == "start") {
                    CMN_LOG_CLASS_RUN_WARNING << "Starting component " << arg1 << std::endl;
                    ManagerComponentServices->ComponentStart(processName, componentName);
                }
                else if (arg2 == "stop") {
                    CMN_LOG_CLASS_RUN_WARNING << "Stopping component " << arg1 << std::endl;
                    ManagerComponentServices->ComponentStop(processName, componentName);
                }
                else if (arg2.compare(0, 9, "Required:") == 0) {
                    if (ConnectionStarted) {
                        ChangeComponentBorder(ConnectionRequest.Client.ProcessName,
                                              ConnectionRequest.Client.ComponentName, BORDER_SINGLE);
                        ConnectionRequest.Client.ProcessName = processName;
                        ConnectionRequest.Client.ComponentName = componentName;
                        ConnectionRequest.Client.InterfaceName = arg2.substr(9);
                        ChangeComponentBorder(ConnectionRequest.Client.ProcessName,
                                              ConnectionRequest.Client.ComponentName, BORDER_DOUBLE);
                        CMN_LOG_CLASS_RUN_VERBOSE << "Selected required interface "
                                                  << processName << ":"
                                                  << componentName << ":"
                                                  << ConnectionRequest.Client.InterfaceName << std::endl;
                        if (ConnectionRequest.Server.ProcessName != "")
                            ActivateMenuItems();
                    }
                }
                else if (arg2.compare(0, 9, "Provided:") == 0) {
                    if (ConnectionStarted) {
                        ChangeComponentBorder(ConnectionRequest.Server.ProcessName,
                                              ConnectionRequest.Server.ComponentName, BORDER_SINGLE);
                        ConnectionRequest.Server.ProcessName = processName;
                        ConnectionRequest.Server.ComponentName = componentName;
                        ConnectionRequest.Server.InterfaceName = arg2.substr(9);
                        ChangeComponentBorder(ConnectionRequest.Server.ProcessName,
                                              ConnectionRequest.Server.ComponentName, BORDER_DOUBLE);
                        CMN_LOG_CLASS_RUN_VERBOSE << "Selected provided interface "
                                                  << processName << ":"
                                                  << componentName << ":"
                                                  << ConnectionRequest.Server.InterfaceName << std::endl;
                        if (ConnectionRequest.Client.ProcessName != "")
                            ActivateMenuItems();
                    }
                }
                else
                    CMN_LOG_CLASS_RUN_WARNING << "Unhandled popup_selection_node: " << args << std::endl;
            }
            else
                CMN_LOG_CLASS_RUN_ERROR << "Could not parse component name from " << arg1 << std::endl;
        }
        else if (command == "node_selections_labels") {
            // Node (component) is selected -- no action implemented
            CMN_LOG_CLASS_RUN_VERBOSE << "Selected component(s): " << args << std::endl;
        }
        else if (command == "edge_selection_label") {
            // Edge (connection) is selected -- no action implemented
            CMN_LOG_CLASS_RUN_VERBOSE << "Selected connection: " << args << std::endl;
        }
        else if (command == "create_edge") {
            // Drag & drop -- not implemented (need a way to select interfaces)
            CMN_LOG_CLASS_RUN_WARNING << "Create connection: " << args << std::endl;
        }
        else {
            // Other actions not implemented
            CMN_LOG_CLASS_RUN_VERBOSE << "Response: " << UDrawResponse << std::endl;
        }

        UDrawResponse = "";
        ReadyToRead.Raise();
    }
}
Beispiel #12
0
void EMPBomb::run(float deltaTime)
{
	lifetime -= deltaTime;
	if(lifetime <= 0.0f)
		Kill();
}
Beispiel #13
0
void guiTask::Run(void){
	ProcessQueuedEvents();
    ProcessQueuedCommands();

	if(clarityClientUI.beepClicked){
		clarityClientUI.beepClicked = false;
		mtsInt numberOfBeeps = (int)clarityClientUI.beepCount->value();
		NDI.Beep(numberOfBeeps);
	}

	if(clarityClientUI.initializeClicked){
		clarityClientUI.initializeClicked = false;
		NDI.Initialize();
		NDI.Query();
		NDI.Enable();
	}

	if(clarityClientUI.trackClicked){
		clarityClientUI.trackClicked = false;
		NDI.Track(trackToggle);
		trackToggle = !trackToggle;
	}

	RobotBase.GetPosition(robotBasePosition);
	RobotBaseQuaternion.W() = robotBasePosition.Element(3);
	RobotBaseQuaternion.X() = robotBasePosition.Element(4);
	RobotBaseQuaternion.Y() = robotBasePosition.Element(5);
	RobotBaseQuaternion.Z() = robotBasePosition.Element(6);
	RobotBaseFrame.Rotation().FromRaw(RobotBaseQuaternion);
	r32 = RobotBaseFrame.Rotation().Element(2,1);
	r33 = RobotBaseFrame.Rotation().Element(2,2);
	r31 = RobotBaseFrame.Rotation().Element(2,0);
	r21 = RobotBaseFrame.Rotation().Element(1,0);
	r11 = RobotBaseFrame.Rotation().Element(0,0);
	RobotBaseEulerAngles.Element(0) = atan2(r32,r33)*cmn180_PI;
	RobotBaseEulerAngles.Element(1) = atan2(-r31,sqrt(pow(r32,2.0) + pow(r33,2.0)))*cmn180_PI;
	RobotBaseEulerAngles.Element(2) = atan2(r21,r11)*cmn180_PI;

	RobotTip.GetPosition(robotTipPosition);
	RobotTipQuaternion.W() = robotTipPosition.Element(3);
	RobotTipQuaternion.X() = robotTipPosition.Element(4);
	RobotTipQuaternion.Y() = robotTipPosition.Element(5);
	RobotTipQuaternion.Z() = robotTipPosition.Element(6);
	RobotTipFrame.Rotation().FromRaw(RobotTipQuaternion);
	r32 = RobotTipFrame.Rotation().Element(2,1);
	r33 = RobotTipFrame.Rotation().Element(2,2);
	r31 = RobotTipFrame.Rotation().Element(2,0);
	r21 = RobotTipFrame.Rotation().Element(1,0);
	r11 = RobotTipFrame.Rotation().Element(0,0);
	RobotTipEulerAngles.Element(0) = atan2(r32,r33)*cmn180_PI;
	RobotTipEulerAngles.Element(1) = atan2(-r31,sqrt(pow(r32,2.0) + pow(r33,2.0)))*cmn180_PI;
	RobotTipEulerAngles.Element(2) = atan2(r21,r11)*cmn180_PI;

	for (unsigned int i=0; i<6; i++){
	  if(robotBasePosition.Element(0) != 999.9){
	    if(i<3)
	      clarityClientUI.BasePosition[i]->value(robotBasePosition.Element(i));
	    else
	      clarityClientUI.BasePosition[i]->value(RobotBaseEulerAngles.Element(i-3));
	  }
	  else
	    clarityClientUI.BasePosition[i]->value(99999.999);

	  if(robotTipPosition.Element(0) != 999.9){
	    if(i<3)
	      clarityClientUI.TipPosition[i]->value(robotTipPosition.Element(i));
	    else
	      clarityClientUI.TipPosition[i]->value(RobotTipEulerAngles.Element(i-3));
	  }
	  else
	    clarityClientUI.TipPosition[i]->value(99999.999);
	}

	if (Fl::check() == 0)
		Kill();
}
Beispiel #14
0
CPlayerObject::~CPlayerObject()
{
	Kill();
	active = false;
}
/* 
 * eval - Evaluate the command line that the user has just typed in
 * 
 * If the user has requested a built-in command (quit, jobs, bg or fg)
 * then execute it immediately. Otherwise, fork a child process and
 * run the job in the context of the child. If the job is running in
 * the foreground, wait for it to terminate and then return.  Note:
 * each child process must have a unique process group ID so that our
 * background children don't receive SIGINT (SIGTSTP) from the kernel
 * when we type ctrl-c (ctrl-z) at the keyboard.  
 */
void 
eval(char *cmdline) 
{
    int bg;              /* should the job run in bg or fg? */
    int job_state;      /* initial value of job BG or FG based on bg */
    int status;
    int check;
    struct cmdline_tokens tok;
    pid_t pid = -255;  // Initialzing to
    int jid = -255;   //  dummy values 
    sigset_t mask;      
    sigset_t mask2;      
    int flag = 0; //Used while processing "fg" built in command
    int infile_fd ; //file descriptor to be used for infile if specified in job 
    int outfile_fd ; //file descriptor to be used for outfile if specified in job

    //Get shell pid
    tsh_pid = getpid();

    //Intialize mask for blocked signal
    //Block SIGCHLD SIGINT SIGTSTP signals
    Sigemptyset(&mask);
    Sigemptyset(&mask2);
    Sigaddset(&mask,SIGCHLD);
    Sigaddset(&mask,SIGINT);
    Sigaddset(&mask2,SIGINT);
    Sigaddset(&mask,SIGTSTP);
    Sigaddset(&mask2,SIGTSTP);
    Sigprocmask(SIG_BLOCK,&mask,NULL);

    /* Parse command line */
    bg = parseline(cmdline, &tok); 

    if (bg == -1) return;               /* parsing error */
    if (tok.argv[0] == NULL)  return;   /* ignore empty lines */

    /* If tok is a BUILTIN shell command */
    if (tok.builtins != BUILTIN_NONE) {
        
       switch(tok.builtins) {                           

                           //Built in command quit :
                           //Send SIGKILL to all processes in shell
       case BUILTIN_QUIT : tsh_pid = getpid();
                           kill(-tsh_pid,SIGKILL);
                           break;

                           //List out all jobs when "jobs" called
                           //Also open output file if redirection specified and 
                           //redirect jobs output to the new file's descriptor

       case BUILTIN_JOBS :  if (tok.outfile != NULL) {
				    outfile_fd = open(tok.outfile , O_WRONLY);
				    listjobs(job_list,outfile_fd);
				    break;
			    }

			    else
				    listjobs(job_list,STDOUT_FILENO);
			    break;


			    // Parse job id or pid given with bg command
			    // Change state from ST to BG in job_list
			    // Send SIGCONT signal to job

       case BUILTIN_FG :   if(*(char *)(tok.argv[1]) == '%' ) {
				   jid = atoi( (((char *)(tok.argv[1])) + 1) ); 
				   pid = jid2pid(jid);
			   }
			   else {
				   pid = atoi(tok.argv[1]);
				   jid = pid2jid(pid);
			   }
			   change_job_state(job_list,pid,FG);
			   flag = 1;                            //flag set because we want to jump into else clause below 
			   // to process resumed job as a foreground job
			   Kill(-pid,SIGCONT);  
			   break;

			   //Parse job id or pid given with bg command
			   // Change state from ST to BG in job_list
			   // Send SIGCONT signal to job
       case BUILTIN_BG :   if(*(char *)(tok.argv[1]) == '%' ) {
				   jid = atoi( (((char *)(tok.argv[1])) + 1) ); 
				   pid = jid2pid(jid);
			   }
			   else {
				   pid = atoi(tok.argv[1]);
				   jid = pid2jid(pid);
			   }
			   printjob(pid,STDOUT_FILENO);
			   change_job_state(job_list,pid,BG);
			   Kill(-pid,SIGCONT);
			   break;
       case BUILTIN_NONE : break;
       default : break;

       }

    }


    //If tok is a external program to be run by shell 
    else if ((tok.builtins == BUILTIN_NONE) || (flag == 1)) {

	    if (flag == 1) 
		    bg = 0;

	    if(!bg)
		    job_state = FG;
	    else
		    job_state = BG;




	    //Child process   
	    if ((pid = Fork()) == 0) {

		    setpgid(0,0);  //Start process in new group     
		    Signal(SIGINT,  SIG_DFL);   /* ctrl-c from child handled by parent's sigchld */

		    addjob(job_list,getpid(),job_state,cmdline); 

		    // If input/output redirection specified open given file and point STDIN/STDOUT descriptor
		    // to new file's file descriptor
		    if (tok.infile != NULL) {
			    infile_fd = open(tok.infile , O_RDONLY);
			    dup2(infile_fd,STDIN_FILENO);   
		    }

		    if (tok.outfile != NULL) {
			    outfile_fd = open(tok.outfile , O_WRONLY);
			    dup2(outfile_fd,STDOUT_FILENO);   
		    }

		    //Unblock masks inherited from parent process
		    //and execute program using exec
		    Sigprocmask(SIG_UNBLOCK,&mask,NULL);
		    Execve(tok.argv[0],tok.argv,environ); 

	    }


	    //Parent process
	    //Add child to job list and unblock signal,also set fg_pid if job is foreground job	    
	    addjob(job_list,pid,job_state,cmdline); 
	    if(!bg)
		    fg_pid = pid;
	    Sigprocmask(SIG_UNBLOCK,&mask2,NULL); 

	    //Until foreground process terminates SIGCHLD functionality is done here , SIGINT and SIGTSTP are handled by handlers 
	    if(!bg) {

		    check = waitpid(pid,&status,WUNTRACED);
		    if ((check<0) && (errno!=ECHILD)) 
			    unix_error("waitfg : wait pid error\n");

		    if ((check == pid) && WIFSTOPPED(status)){
			    print_sigtstp_job(job_list,pid,SIGTSTP,STDOUT_FILENO);          //Print message that job was stopped by SIGSTP signal 

			    //Change stopped job state in list to ST (stopped) 
			    change_job_state(job_list,pid,ST);
			    return;
		    }

		    if ((check == pid) && (WIFSIGNALED(status)))
			    print_sigint_job(job_list,pid,WTERMSIG(status),STDOUT_FILENO);       //Print message that job/pid was terminated by a signal 


		    deletejob(job_list,pid);
		    Sigprocmask(SIG_UNBLOCK,&mask,NULL); 

	    }

	    else {
		    Sigprocmask(SIG_UNBLOCK,&mask,NULL); 
		    printjob(pid,STDOUT_FILENO);
	    }



    }

    return;
}
Beispiel #16
0
FMPThread::~FMPThread()
{
	Log::Debug(L"FMPThread::~FMPThread called");
	if(m_pOriginalThread != NULL) Kill();
	Log::Debug(L"FMPThread::~FMPThread complete");
}
Beispiel #17
0
  ~LogCatReader() {
    io_thread.LockRemove(fd);
    fd.Close();

    Kill(pid.exchange(0));
  }
Beispiel #18
0
CnsMgr::~CnsMgr()
{
	if(initialized)
		Kill();
}
Beispiel #19
0
	inline void Set(T *p)              {Kill(); ptr = p;}
Beispiel #20
0
void Display(FunctionQueue *FQ,PathList *PL)
{
    while (!FunctionEmpty(FQ))
    {
        FuncItem *F;
        F = FunctionFirst(FQ);
        
        switch (F->command)
        {
            // Kill command
            case 0:
                Kill(F->unit,F->flag,PL);
                break;
            // Spawn command
            case 1:
                Spawn(F->unit,PL);
                break;
            // DrawMap command
            case 2:
                DrawMap(F->towerList,PL);
                break;
            // DrawMenu command
            case 3:
                DrawMenu();
                break;
            // DrawAvailableUnits command
            case 4:
                DrawAvailableUnits(F->level,F->unitList);
                break;
            // RedrawQueue command
            case 5:
                RedrawQueue(F->unitList);
                break;
            // RedrawResources command
            case 6:
                RedrawResources(F->level);
                break;
            // RedrawHP command
            case 7:
                RedrawHP(F->level);
                break;
            // ClearMap command
            case 8:
                ClearMap();
                break;
            // ClearPrompts command
            case 9:
                ClearPrompts();
                break;
            // ClearMsg command
            case 10:
                ClearMsg();
                break;
            // PrintMsg command
            case 11:
                PrintMsg(F->flag);
                break;
            // StageLose command
            case 12:
                StageLose();
                break;
            // StageWin command
            case 13:
                StageWin();
                break;
            default:
                break;
        }
        
        FunctionDequeue(FQ);
    }
}
void npc_toc10_announcerAI::UpdateAI(const uint32 diff)
{
	if(check_Timer <= diff)
	{
		Map::PlayerList const& lPlayers = me->GetMap()->GetPlayers();
		bool playerAlive = false;
		if (!lPlayers.isEmpty())
		{
			for(Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
				if (Player* pPlayer = itr->getSource())
					if(pPlayer->isAlive() && !pPlayer->isGameMaster())
						playerAlive = true;
		}

		if(!playerAlive)
		{
			if (Creature* Gormok = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_GormoktheImpaler))))
				Gormok->RemoveFromWorld();
			if (Creature* Acidmaw = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_Acidmaw))))
				Acidmaw->RemoveFromWorld();
			if (Creature* Dreadscale = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_Dreadscale))))
				Dreadscale->RemoveFromWorld();
			if (Creature* Icehowl = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_Icehowl))))
				Icehowl->RemoveFromWorld();
			if (Creature* Jaraxxus = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_JARAXXUS))))
				Jaraxxus->RemoveFromWorld();
			if (Creature* Darkbane = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_Eydis_Darkbane))))
				Darkbane->RemoveFromWorld();
			if (Creature* Lightbane = ((Creature*)Unit::GetUnit((*me), pInstance->GetData64(TYPE_Fjola_Lightbane))))
				Lightbane->RemoveFromWorld();
			for(std::vector<uint32>::const_iterator itr = Champions_Guid.begin(); itr != Champions_Guid.end(); ++itr)
			{
				if (Creature* tmp = ((Creature*)Unit::GetUnit((*me), (*itr))))
					if(tmp->isAlive())
						tmp->RemoveFromWorld();
			}
			Champions_Guid.clear();
			EventStarted = false;
			me->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE);
		}
		check_Timer = 1000;
	}
	else
		check_Timer -= diff;

	if(!EventStarted)
	        return;

	if(!pInstance)
		return;

	if(pInstance->GetData(TYPE_TRY) <= 0)
		return;

	switch(Event_Type)
	{
		case EVENT_TYPE_BEASTS_INTRO:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						me->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE);
						Speak(CHAT_TYPE_SAY,16036,"Bienvenue champions ! Vous avez entendu l'appel de la croisade d'argent et vaillament répondu. C'est ici dans le colisée d'argent que vous affronterez vos plus grands défis. Ceux d'entre vous qui auront survécu aux vigueurs du colisée se joindrons à la marche de la croisade sur la Citadelle de la Couronne de Glace",Fordring);
						Event_Timer = 21000;
						break;
					case 2:
						Yell(16037,"Que les jeux commencent!",Fordring);
						if(Creature* Gormok = CallCreature(34796,TEN_MINS*1.5,PREC_COORDS,AGGRESSIVE_RANDOM,563.135f,	243.306f,395.0f))
						{
							Gormok->GetMotionMaster()->MovePoint(0, 563.832f, 180.223f, 395.0f);
						}
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = 2000;
						break;
					case 3:
						Yell(16038,"Arrivant tout droit des plus noires et profondes cavernes des pics foudroyés, Gormok l'empaleur !",Fordring);
						Event_Timer = 8000;
						break;
					case 4:
						if(team == ALLIANCE)
							Speak(CHAT_TYPE_SAY,16069,"Vos bêtes ne feront pas le poids face à mes champions Tyrion.",Varian);
						else
							Speak(CHAT_TYPE_SAY,16026,"J'ai vu des défis plus ardus dans l'arène de sang. Vous nous faîtes perdre notre temps Paladin !",Garrosh);
						Event_Timer = TEN_MINS;
						
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						EventStarted = false;
						break;
				}
				Event_phase++;
			}
			else 
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_BEASTS_JORM:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						Yell(16039,"Apprêtez vous héros car voici que les terreurs jumelles, Gueule d'Acide et Ecaille d'effroi pénètrent dans l'arène !",Fordring);
						if(Creature* Acidmaw = CallCreature(35144,TEN_MINS*1.5,PREC_COORDS,AGGRESSIVE_RANDOM,572.243f,244.680f,395.0f))
						{
							Acidmaw->GetMotionMaster()->MovePoint(0, 574.376f,180.478f,396.0f);
							Acidmaw->SetSpeedRate(MOVE_RUN,1.3f,true);
						}
						if(Creature* Dreadscale = CallCreature(34799,TEN_MINS,PREC_COORDS,AGGRESSIVE_RANDOM,554.910f,244.888f,395.0f))
						{
							Dreadscale->GetMotionMaster()->MovePoint(0, 563.832f, 180.223f, 395.0f);
							Dreadscale->SetSpeedRate(MOVE_RUN,1.3f,true);
						}
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = 8000;
						break;
					case 2:
						if (Creature* Acidmaw = GetInstanceCreature(TYPE_Dreadscale))
						{
							((ScriptedAI*)Acidmaw->AI())->SetCombatMovement(false);
						}
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = TEN_MINS;
						EventStarted = false;
						break;
				}
				Event_phase++;
			}
			else
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_BEASTS_YETI:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)		
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						Yell(16040,"L'air se gèle à l'entrée de notre prochain combattant : Glace-Hurlante ! Tuez ou soyez tués, champions !",Fordring);
						if(Creature* Icehowl = CallCreature(34797,TEN_MINS*1.5,PREC_COORDS,AGGRESSIVE_RANDOM,563.135f,	243.306f,395.0f))
						{
							Icehowl->GetMotionMaster()->MovePoint(0, 563.832f, 180.223f, 395.0f);
						}
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = 10000;
						break;
					case 2:
						if (Creature* Icehowl = GetInstanceCreature(TYPE_Icehowl))
							((ScriptedAI*)Icehowl->AI())->SetCombatMovement(false);
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						EventStarted = false;
						break;
				}
				Event_phase++;
			}
			else
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_JARAXXUS:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = 1000;
						break;
					case 2:
						Yell(16043,"Le Grand démoniste Wilfried Flopboum va invoquer votre prochain défi, ne bougez pas il arrive !",Fordring);
						if(Flopboum = CallCreature(35458,TEN_MINS,PREC_COORDS,NOTHING,564.057f,203.706f,395.2f))
						{
							Flopboum->GetMotionMaster()->MovePoint(0, 563.659f,145.059,395.0f);
							//Flopboum->SetSpeedRate(MOVE_RUN,2.0f);
						}
						Event_Timer = 8000;
						break;
					case 3:
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Yell(16268,"Merci généralissime, et maintenant aspirant je vais commencer le rituel d'invocation. Quand j'en aurais fini un terrible garde funeste apparaîtra.",Flopboum ? Flopboum : NULL);
						Event_Timer = 10000;
						break;
					case 4:
						Yell(16269,"Préparez vous à l'oubli !",Flopboum ? Flopboum : NULL);
						Event_Timer = 3000;
						break;
					case 5:
						CallCreature(35651,30000,PREC_COORDS,NOTHING,563.711f,139.268f,394.0f);
						Event_Timer = 2000;
						break;
					case 6:
						if(Flopboum)
							Flopboum->CastSpell(Flopboum,45927,false);

						CallCreature(19224,11000,PREC_COORDS,NOTHING,563.711f,139.268f,394.0f);
						Event_Timer = 10000;
						break;
					case 7:
						Yell(16270,"Haha ! J'ai réussi ! Comtemplez l'absolue puissante de Wielfried Flopboum, Maître invocateur. Tu es mon esclave démon",Flopboum ? Flopboum : NULL);
						if(Creature* Jaraxxus = CallCreature(34780,TEN_MINS*1.5,PREC_COORDS,NOTHING,563.711f,139.268f,394.0f))
						{
							Jaraxxus->setFaction(35);
							ModifyAuraStack(67924,1,Jaraxxus);
						}
						Event_Timer = 11000;
						break;
					case 8:
						if (Creature* Jaraxxus = GetInstanceCreature(TYPE_JARAXXUS))
						{
							Speak(CHAT_TYPE_SAY,16143,"Misérable gnome, ton arrogance te perdra !",Jaraxxus);
							Jaraxxus->RemoveAurasDueToSpell(67924);
						}
						Event_Timer = 3500;
						break;
					case 9:
						Speak(CHAT_TYPE_SAY,16271,"Mais c'est moi qui commande ici. Rurrlg...",Flopboum ? Flopboum : NULL);
						Event_Timer = 3000;
						break;
					case 10:
						if (Creature* Jaraxxus = GetInstanceCreature(TYPE_JARAXXUS))
						{
							if(Flopboum)
								Jaraxxus->CastSpell(Flopboum,31008,false);
						}
						Kill(Flopboum);
						Yell(16044,"Vite héros anéantissez le seigneur démon avant qu'il ne puisse ouvrir un portail vers son épouvantable royaume démoniaque !",Fordring);
						if (Creature* Jaraxxus = GetInstanceCreature(TYPE_JARAXXUS))
							Jaraxxus->setFaction(14);
						Event_Timer = DAY * HOUR;
						break;

				}
				Event_phase++;
			}
			else
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_JARAXXUS_OUTRO:
			if(Event_Timer <= diff)
			{
				Speak(CHAT_TYPE_SAY,16045,"La perte de Wielfred Plopboum bien que malheureuse servira de leçon à ceux qui s'adonnent à la magie noire. Hélas vous êtes victorieux et devez affronter le prochain défi.",Fordring);
				EventStarted = false;
			}
			else
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_CHAMPIONS:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						Yell(16047,"La prochaine bataille sera contre les chevaliers de la Croisade d'argent. Ce ne sera qu'après les avoir vaincus que vous serez déclarés dignes.",Fordring);
						Event_Timer = 7500;
						break;
					case 2:
						if(team == ALLIANCE)
						{
							Yell(16065,"Combattez pour la gloire de l'Alliance héros, faîtes honneur à votre Roi et à votre peuple !",Varian);
							Event_Timer = 6000;
						}
						else
						{
							Yell(16022,"N'ayez aucune pitié champions de la Horde ! Lok'tar O'gar !",Garrosh);
							Event_Timer = 5500;
						}
						break;
					case 3:
						if(team == ALLIANCE)
						{
							Yell(16023,"La Horde exige réparation, nous défions l'Alliance. Permettez nous de combattre à la place de vos chevaliers, paladin. Nous allons montrer à ces chiens ce qu'il en coûte d'insulter la Horde !",Garrosh);
							Event_Timer = 14000;
						}
						else
						{
							Yell(16066,"Notre honneur a été souillé, il lance des affirmations absurdes contre nous, de fausses accusations. J'exige réparation. Permettez à mes champions de combattre à la place de vos chevaliers Tyrion. Nous défions la Horde !",Varian);
							Event_Timer = 15000;
						}
						break;
					case 4:
						Yell(16048,"Très bien. Je vous y autorise. Combattez avec honneur !",Fordring);
						Event_Timer = 4000;
						break;
					case 5:
						SpawnChampions();
						EventStarted = false;
						Event_Timer = DAY * 3600;
						break;
				}
				Event_phase++;
			}
			else
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_VALKYR:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						if(Creature* Darkbane = CallCreature(34496,TEN_MINS*1.5,PREC_COORDS,NOTHING,572.243f,244.680f,395.0f))
						{
							Darkbane->GetMotionMaster()->MovePoint(0, 574.376f,180.478f,396.0f);
						}
						if(Creature* Lightbane = CallCreature(34497,TEN_MINS*1.5,PREC_COORDS,NOTHING,554.910f,244.888f,395.0f))
						{
							Lightbane->GetMotionMaster()->MovePoint(0, 563.832f, 180.223f, 395.0f);
						}
						Speak(CHAT_TYPE_SAY,16050,"Ce n'est qu'en travaillant côte à côte que vous pourrez triompher de l'ultime défi. Venues des profondeurs de la Couronne de Glace, voici deux des lieutenants les plus puissants du fléau, deux redoutables valkyrs, messagères ailées du Roi Liche",Fordring);
						CallCreature(34568,TEN_MINS,PREC_COORDS,NOTHING,ValkyrPortal_spawn[0][0],ValkyrPortal_spawn[0][1],ValkyrPortal_spawn[0][2]);
						CallCreature(34567,TEN_MINS,PREC_COORDS,NOTHING,ValkyrPortal_spawn[1][0],ValkyrPortal_spawn[1][1],ValkyrPortal_spawn[1][2]);
						CallCreature(34567,TEN_MINS,PREC_COORDS,NOTHING,ValkyrPortal_spawn[2][0],ValkyrPortal_spawn[2][1],ValkyrPortal_spawn[2][2]);
						CallCreature(34568,TEN_MINS,PREC_COORDS,NOTHING,ValkyrPortal_spawn[3][0],ValkyrPortal_spawn[3][1],ValkyrPortal_spawn[3][2]);
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = 13000;
						break;
					case 2:
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = DAY*HOUR;
						break;
				}
				Event_phase++;
			}
			else
				Event_Timer -= diff;
			break;
		case EVENT_TYPE_VALKYR_OUTRO:
			if(Event_Timer <= diff)
			{
				switch(Event_phase)
				{
					case 1:
						SetInstanceData(TYPE_TRY,0);
						Speak(CHAT_TYPE_SAY,16051,"C'est un rude coup qui vient d'être porté au Roi Liche. Vous avez prouvé que vous êtes aptes à servir comme Champion de la Croisade d'Argent. Ensemble nous frapperons la Citadelle de la Couronne de Glace et détruirons ce qui reste du fléau. Aucun défi ne pourra résister à notre unité !",Fordring);
						Event_Timer = 19500;
						break;
					case 2:
						if(team == ALLIANCE)
						{
							Speak(CHAT_TYPE_SAY,16068,"Même les plus puissants serviteurs du Roi Liche ne sont pas de taille face à l'Alliance. Hourra pour nos vainqueurs !",Varian);
							Event_Timer = 61000;
						}
						else
						{
							Speak(CHAT_TYPE_SAY,16025,"Doutez vous encore de la puissance de la Horde, Paladin ? Nous relèverons tous les gants !",Garrosh);
							Event_Timer = 60000;
						}
						break;
					case 3:
						pInstance->DoUseDoorOrButton(pInstance->GetData64(TYPE_DOOR));
						Event_Timer = 1000;
						break;
					case 4:
						if(LichKing = CallCreature(31301,50000,PREC_COORDS,NOTHING,564.057f,	203.706f,395.2f))
						{
							LichKing->GetMotionMaster()->MovePoint(0, 563.734f,139.577,394.0f);
							LichKing->setFaction(35);
							Yell(16321,"Vous allez l'avoir votre défi, Fordring !",LichKing);
						}
						Event_Timer = 5000;
						break;
					case 5:
						Speak(CHAT_TYPE_SAY,16052,"Arthas, tu es en infériorité, c'est sans espoir. Dépose Deuillegivre et je t'accorderai une mort juste.",Fordring);
						Event_Timer = 7000;
						break;
					case 6:
						if(LichKing)
							LichKing->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION);
						Yell(16322,"Hahahahaha ! Les nérubiens ont batti un empire sous les terres gelées du Norfendre. Un empire sur lequel vous avez si bêtement construit vos bâtiments. Mon empire...",LichKing);
						Event_Timer = 20000;
						break;
					case 7:
						Yell(16323,"Les âmes de vos champions seront miennes, Fordring.",LichKing);
						Event_Timer = 9000;
						break;
					case 8:
						if(LichKing)
						{
							LichKing->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL);
							LichKing->CastSpell(LichKing,68198,false);
						}
						Event_Timer = 1000;
						break;
					case 15:
						if (GameObject* Floor = me->GetMap()->GetGameObject(pInstance->GetData64(TYPE_FLOOR)))
						{
							if (Floor)
							{
								Map::PlayerList const& lPlayers = me->GetMap()->GetPlayers();
								if (!lPlayers.isEmpty())
									for(Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
										if (Player* pPlayer = itr->getSource())
											Floor->DestroyForPlayer(pPlayer,true);

								//Floor->SetFlag(GAMEOBJECT_FLAGS,GO_FLAG_DESTROYED);

								Floor->SetUInt32Value(GAMEOBJECT_DISPLAYID,9060);
								Floor->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN);
								Floor->SetUInt32Value(GAMEOBJECT_BYTES_1,8449);
							}
						}
						Event_Timer = 3000;
						break;
					case 16:
						Map::PlayerList const& lPlayers = me->GetMap()->GetPlayers();
						if (!lPlayers.isEmpty())
							for(Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
								if (Player* pPlayer = itr->getSource())
									if(pPlayer->isAlive() && urand(0,3) == 3)
										Kill(pPlayer);

						if (Creature* AnubArak = GetInstanceCreature(TYPE_ANUBARAK))
						{
							Yell(16235,"Ah. Nos invités sont arrivés... Comme l'avait promis le maître",AnubArak);
						}

						Event_Timer = DAY*HOUR;
						EventStarted = false;
						break;
				}
				Event_phase++;
			}
			else
				Event_Timer -= diff;
			break;
	}
}
Beispiel #22
0
Process::ProcessImpl::~ProcessImpl()
{ if (!m_free) Kill(); }
Beispiel #23
0
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
  if (nCode == HC_ACTION) {
    int vkey = ((PKBDLLHOOKSTRUCT)lParam)->vkCode;

    if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
      // Check for Ctrl+Alt+F4
      if (vkey == VK_LCONTROL) {
        ctrl = 1;
      }
      else if (vkey == VK_LMENU) {
        alt = 1;
      }
      else if (ctrl && alt && vkey == VK_F4) {
        // Double check that Ctrl and Alt are being pressed.
        // This prevents a faulty kill if we didn't received the keyup for these keys.
        if (!(GetAsyncKeyState(VK_LCONTROL)&0x8000)) {
          ctrl = 0;
          return CallNextHookEx(NULL, nCode, wParam, lParam);
        }
        else if (!(GetAsyncKeyState(VK_LMENU)&0x8000)) {
          alt = 0;
          return CallNextHookEx(NULL, nCode, wParam, lParam);
        }

        // Get hwnd of foreground window
        HWND hwnd = GetForegroundWindow();
        if (hwnd == NULL) {
          return CallNextHookEx(NULL, nCode, wParam, lParam);
        }

        // Kill it!
        Kill(hwnd);

        // Prevent this keypress from being propagated
        return 1;
      }
      // Check for [the windows key]+F4
      else if (vkey == VK_LWIN) {
        win = 1;
      }
      else if (win && vkey == VK_F4) {
        // Double check that the windows button is being pressed
        if (!(GetAsyncKeyState(VK_LWIN)&0x8000)) {
          win = 0;
          return CallNextHookEx(NULL, nCode, wParam, lParam);
        }

        // Hook mouse
        HookMouse();
        // Prevent this keypress from being propagated
        return 1;
      }
      else if (vkey == VK_ESCAPE && mousehook) {
        // Unhook mouse
        UnhookMouse();
        // Prevent this keypress from being propagated
        return 1;
      }
    }
    else if (wParam == WM_KEYUP || wParam == WM_SYSKEYUP) {
      killing = 0;
      if (vkey == VK_LCONTROL) {
        ctrl = 0;
      }
      else if (vkey == VK_LMENU) {
        alt = 0;
      }
      else if (vkey == VK_LWIN) {
        win = 0;
      }
    }
  }

  return CallNextHookEx(NULL, nCode, wParam, lParam);
}
Beispiel #24
0
RawPacket::~RawPacket()
{
    Kill();
}
Beispiel #25
0
//virtual 
COsProcess::~COsProcess()
{
	if ( state() != NotRunning )
		Kill();
}
Beispiel #26
0
HeightMapTexture::~HeightMapTexture()
{
	Kill();
	eventHandler.RemoveClient(this);
}
Beispiel #27
0
void Console::SetSlots(int s)
{
	Kill();
	processes.SetCount(s);
}
Beispiel #28
0
CShotObject::~CShotObject()
{
	Kill();
}