Esempio n. 1
0
void Loop::run()
{
	_frameEvent = event_new(_base, -1, EV_PERSIST, frameEventCallback, this);
	if (NULL == _frameEvent)
	{
		return;
	}

	struct timeval tv = {};
	evutil_timerclear(&tv);
	tv.tv_sec = 0;
	tv.tv_usec = 5000;

	if (0 != event_add(_frameEvent, &tv))
	{
		event_free(_frameEvent);
		_frameEvent = NULL;
		return;
	}

	curThreadLoop = this;
	doEvent(ec::Loop::kEventRun);
	event_base_loop(_base, 0);
	doEvent(ec::Loop::kEventEnd);
	curThreadLoop = NULL;
	_thread = NULL;
}
Esempio n. 2
0
/**
* 停止拖动
*/
bool UILabel::touchEnd(float x,float y)
{
	if (_editable && _touchIn)
	{
		this->doEvent(UIBase::EVENT_EDIT_DOWN,this);
	}
	_touchIn = false;
	if (_editable) return false;
	CCPoint pos = ccp(x,y);
	pos = this->convertToNodeSpace(pos);
	if (text)
	{
		CCRect rect = CCRectMake(
			text->getPosition().x - (text->getContentSize().width/2),
			text->getPosition().y - (text->getContentSize().height/2),
			text->getContentSize().width,
			text->getContentSize().height);
		if (rect.containsPoint(pos))
		{
			// 触发事件
			doEvent(UIBase::EVENT_CLICK_DOWN,this);
		}
	}
	return true;
}
Esempio n. 3
0
/**
 * 停止拖动
 */
bool UITextButton::touchEnd(float x,float y)
{
	if (_editable && _touchIn)
	{
		this->doEvent(UIBase::EVENT_EDIT_DOWN,this);
	}
	_touchIn = false;
	if (_editable) return false;
	CCPoint pos = ccp(x,y);
	pos = this->convertToNodeSpace(pos);
	if (_textDown && _textUp)
	{
		float width = _textUp->getContentSize().width * _textUp->getScaleX();
		float height = _textUp->getContentSize().height * _textUp->getScaleY();
		CCRect rect = CCRectMake(
			_textUp->getPosition().x - (width/2),
			_textUp->getPosition().y - (_textUp->getContentSize().height/2),
			width,
			height);
		_textUp->setVisible(true);
		_textDown->setVisible(false);
		if (rect.containsPoint(pos))
		{
			// 触发事件
			doEvent(UIBase::EVENT_CLICK_DOWN,this);
		}
		
	}
	return true;
}
Esempio n. 4
0
bool Loop::startThread()
{
	if (!doEvent(ec::Loop::kEventStart))
	{
		return false;
	}

	_thread = new std::thread(std::bind(&Loop::run, this));// 这个地方有点迷糊
	return true;
}
Esempio n. 5
0
bool Loop::start()
{
	if (!doEvent(ec::Loop::kEventStart))
	{
		return false;
	}

	run();
	return true;
}
Esempio n. 6
0
void DispatchThread::myExec()
{
  boost::mutex::scoped_lock lock(_newEventMutex);

  for (;;) {
    if (!_newEvent)
      _newEventCondition.wait(lock);

    doEvent();

    if (_app->_finalized)
      return;

    _newEvent = false;
  }
}
Esempio n. 7
0
	void Player::playChain(Player* plai) {
		uint64_t micros = 0;
		auto iter = plai->first->returnNext();
		while (plai->playing) {
			while (micros >= iter->getDelay()) {
				iter->doEvent();
				micros -= iter->getDelay();
				iter = iter->returnNext();
				if (iter == nullptr) {
					emit plai->donePlaying();
					return;
				}
			}
			std::this_thread::sleep_for(std::chrono::milliseconds(1));
			micros += 1000;
		}
	}
Esempio n. 8
0
void DispatchThread::myExec()
{
  boost::mutex::scoped_lock lock(newEventMutex_);
  eventLock_ = &lock;

  for (;;) {
    if (!newEvent_) {
      log("debug") << "WQApplication: [thread] waiting for event";
      newEventCondition_.wait(lock);
    }

    doEvent();

    if (app_->finalized_)
      return;

    newEvent_ = false;
  }
}
Esempio n. 9
0
/**
 * 停止拖动
 */
bool UIButton::touchEnd(float x,float y)
{
	bool  tag = false;
	if (_editable && _touchIn)
	{
		this->doEvent(UIBase::EVENT_EDIT_DOWN,this);
		tag = true;
	}
	
	if (_editable) return false;
	CCPoint pos = ccp(x,y);
	pos = this->convertToNodeSpace(pos);
	if (_up && _down && _touchIn)
	{
		CCRect rect = CCRectMake(
			_up->getPosition().x - (_up->getContentSize().width/2),
			_up->getPosition().y - (_up->getContentSize().height/2),
			_up->getContentSize().width,
			_up->getContentSize().height);
		_up->setVisible(true);
		_down->setVisible(false);
		if (_move)
		{
			_move->setVisible(false);
		}
		if (rect.containsPoint(pos))
		{
			// 触发事件
			doEvent(UIBase::EVENT_CLICK_DOWN,this);
			tag = true;
		}
		else
			tag = false;
	}
	_touchIn = false;
	return tag;
}
Esempio n. 10
0
void TERMWINDOWMEMBER GiveRoomPrompt(Bool JustDisplayedEvent)
	{
	static int roomCounter;
	label rn, gn, np, ex, hn;
	char rd[81];
	char tm[128], dt[128];
	int i;

	CommPort->FlushInput();

	OC.User.Reset();

	OC.Echo = BOTH;
	OC.setio();

	OC.ansiattr = cfg.attr;

	doEvent(EVT_ROOMPROMPT);

	if (CurrentUser->IsYouAreHere())
		{
		youAreHere();
		}

#ifdef WINCIT
	// if (!PendingSystemEvents)
    	// {
    	OC.SetOutFlag(PendingSystemEvents ? NOSTOP : IMPERVIOUS);
	// }

//	if (IdlePrompt)
//		{
//		return;
//		}

	if (!(CurrentUser->IsErasePrompt() && JustDisplayedEvent))
    	{
	    doCR();
		}

	if (JustDisplayedEvent)
		{
		numLines = 0;
		}
#endif

	OC.Formatting = FALSE;

	roomCounter++;

	RoomTab[thisRoom].GetName(rn, sizeof(rn));

	*gn = 0;
	if (RoomTab[thisRoom].IsGroupOnly())
		{
		if (RoomTab[thisRoom].IsBooleanGroup())
			{
			CopyStringToBuffer(gn, getmsg(471));
			}
		else
			{
			GroupData[RoomTab[thisRoom].GetGroupNumber()].GetName(gn, sizeof(gn));
			}
		}

	*np = 0;
	if (RoomTab[thisRoom].IsShared())
		{
		label Buffer;
		CopyStringToBuffer(np, loggedIn ? CurrentUser->GetNetPrefix(Buffer, sizeof(Buffer)) : cfg.netPrefix);
		}


	*ex = 0;
	i = 0;
	if (RoomTab[thisRoom].IsMsDOSdir())
		{
		if (CurrentUser->IsIBMRoom() && TermCap->IsIBMExtended())
			{
			ex[i++] = roomCounter == 6969 ? '\xcc' : '\xb9';
			}
		else
			{
			ex[i++] = roomCounter == 6969 ? '[' : ']';
			}
		}

	if (RoomTab[thisRoom].IsGroupOnly())
		{
		if (CurrentUser->IsIBMRoom() && TermCap->IsIBMExtended())
			{
			ex[i++] = roomCounter == 6969 ? '\xba' : '\xb3';
			}
		else
			{
			ex[i++] = roomCounter == 6969 ? ';' : ':';
			}
		}

	if (RoomTab[thisRoom].IsHidden())
		{
		ex[i++] = roomCounter == 6969 ? '(' : ')';
		}
	if (RoomTab[thisRoom].IsBIO())
		{
		ex[i++] = roomCounter == 6969 ? '{' : '}';
		}
	else if (!RoomTab[thisRoom].IsGroupOnly() && !RoomTab[thisRoom].IsMsDOSdir() && !RoomTab[thisRoom].IsHidden())
		{
		if (!(iswindow(thisRoom) && CurrentUser->IsIBMRoom() && TermCap->IsIBMExtended()))
			{
			ex[i++] = roomCounter == 6969 ? '<' : '>';
			}
		}

	if (iswindow(thisRoom))
		{
		if (CurrentUser->IsIBMRoom() && TermCap->IsIBMExtended())
			{
			ex[i++] = roomCounter == 6969 ? '\xae' : '\xaf';
			}
		else
			{
			ex[i++] = roomCounter == 6969 ? '<' : '>';
			}
		}
	ex[i] = 0;

	HallData[thisHall].GetName(hn, sizeof(hn));
	CurrentRoom->GetInfoLine(rd, sizeof(rd));

	char Buffer[64];
	strftime(tm, 127, (loggedIn) ? special_deansi(CurrentUser->GetDateStamp(Buffer, sizeof(Buffer)),
			TERM_TIME) : special_deansi(cfg.datestamp, TERM_TIME), 0l);

	strftime(dt, 127, (loggedIn) ? special_deansi(CurrentUser->GetVerboseDateStamp(Buffer,
			sizeof(Buffer)), TERM_DATE) : special_deansi(cfg.vdatestamp, TERM_DATE), 0l);

	Andy(loggedIn ? CurrentUser->GetPromptFormat(Buffer, sizeof(Buffer)) :
			cfg.prompt, getmsg(638), rn, gn, np, ex, hn, rd, tm, dt);

	OC.Formatting = TRUE;
	ansi(14);
	OC.MCI_goto = FALSE;

	termCap(TERM_NORMAL);
	mPrintf(spc);
    CursorIsAtPrompt = TRUE;

	OC.SetOutFlag(OUTOK);

	if (roomCounter == 6969)
		{
		roomCounter = 0;
		}
	}
Esempio n. 11
0
void DispatchObject::propagateEvent()
{
  emit doEvent();
}
Esempio n. 12
0
DispatchObject::DispatchObject(DispatchThread *thread)
  : thread_(thread)
{
  connect(this, SIGNAL(doEvent()), this, SLOT(onEvent()));
}
Esempio n. 13
0
void trap(TrapKeywords what, char *port, const char *fmt, ...)
	{
	char ToTrap[512];
	va_list ap;

	va_start(ap, fmt);
	vsprintf(ToTrap, fmt, ap);
	va_end(ap);

	stripansi(ToTrap);

	if (what == T_LOGIN || what == T_NEWROOM || what == T_ERROR)
		{
		addStatusText(ToTrap, time(NULL));
		}

	switch (what)
		{
		case T_CARRIER: 	doEvent(EVT_CARRIER);	break;
		case T_NEWROOM: 	doEvent(EVT_NEWROOM);	break;
		case T_ANONYMOUS:	doEvent(EVT_ANONYMOUS); break;
		case T_CHAT:		doEvent(EVT_CHAT);		break;
		case T_PASSWORD:	doEvent(EVT_PASSWORD);	break;
		case T_AIDE:		doEvent(EVT_AIDE);		break;
		case T_SYSOP:		doEvent(EVT_SYSOP); 	break;
		case T_UPLOAD:		doEvent(EVT_UPLOAD);	break;
		case T_DOWNLOAD:	doEvent(EVT_DOWNLOAD);	break;
		case T_ERROR:		doEvent(EVT_ERROR); 	break;
		case T_NETWORK: 	doEvent(EVT_NETWORK);	break;
		case T_ACCOUNT: 	doEvent(EVT_ACCOUNT);	break;
		case T_CRON:		doEvent(EVT_CRON);		break;
		case T_HACK:		doEvent(EVT_HACK);		break;
		}

	// check to see if we are supposed to log this event
	if (!cfg.trapit[what])
		{
		return;
		}

	label dtstr;
	strftime(dtstr, LABELSIZE, getmsg(130), 0l);

#ifndef WINCIT
	if (!onConsole || !cfg.NoConsoleTrap)
#endif

		{

#ifdef WINCIT
		if (TrapMutex != INVALID_HANDLE_VALUE)
			{
			if (WAITFORmTIMED(TrapMutex))
				{
				DWORD TID = GetCurrentThreadId();
				long Seq = TermWindowCollection.FindConnSeqByThreadId(TID);

                if (!(cfg.trapit[T_PORT]) && (Seq >= 0))
					{
                    fprintf(TrapFile, getmsg(13), dtstr, TID, Seq, ToTrap, bn);
					}
                else if (!(cfg.trapit[T_PORT]) && !(Seq >= 0))
					{
                    fprintf(TrapFile, getmsg(12), dtstr, TID, ToTrap, bn);
					}
                else if (cfg.trapit[T_PORT] && (Seq >= 0))
                    {
                    fprintf(TrapFile, getmsg(11), dtstr, TID, Seq, port, ToTrap, bn);
                    }
                else if (cfg.trapit[T_PORT] && !(Seq >= 0))
                    {
                    fprintf(TrapFile, getmsg(12), dtstr, TID, ToTrap, bn);
                    }
                else
                    {
                    fprintf(TrapFile, getmsg(172));
                    }

				fflush(TrapFile);
				RELEASEm(TrapMutex);
				}
			}

#endif
		}
	}
Esempio n. 14
0
//
// start generation
//
void
IDLBase::generate_the_item(IR__::Contained_ptr item)
{
	IR__::HomeDef_var act_home;
	IR__::ComponentDef_var act_component;
	IR__::InterfaceDef_var act_interface;
	IR__::AliasDef_var act_alias;
	IR__::ValueDef_var act_value;
	IR__::EventDef_var act_event;
	IR__::ExceptionDef_var act_exception;
	IR__::EnumDef_var act_enum;
	IR__::ModuleDef_var act_module;
	IR__::StructDef_var act_struct;
	IR__::UnionDef_var act_union;

	std::cout << "Debug: item to generate: " << item->id() << std::endl;
	if(!definedInInterface(item)) {
		this->open_module(item);
	}

	switch (item->describe()->kind) {
	case CORBA__::dk_Module:
		act_module = IR__::ModuleDef::_narrow(item);
		doModule(act_module);
		break;
	case CORBA__::dk_Home:
		act_home = IR__::HomeDef::_narrow(item);
		doHome(act_home);
		break;
	case CORBA__::dk_Component:
		act_component = IR__::ComponentDef::_narrow(item);
		doComponent(act_component);
		break;
	case CORBA__::dk_Interface:
		act_interface = IR__::InterfaceDef::_narrow(item);
		doInterface ( act_interface );
		break;
	case CORBA__::dk_Value:
		act_event = IR__::EventDef::_narrow(item);
		if (!CORBA::is_nil ( act_event ) ) {
			doEvent ( act_event );
		} else {
			act_value = IR__::ValueDef::_narrow(item);
			doValue(act_value);
		}
		break;
	case CORBA__::dk_Alias:
		act_alias = IR__::AliasDef::_narrow(item);
		doAlias (act_alias);
		break;
	case CORBA__::dk_Exception:
		act_exception = IR__::ExceptionDef::_narrow(item);
		doException(act_exception);
		break;
	case CORBA__::dk_Enum:
		act_enum = IR__::EnumDef::_narrow(item);
		doEnum(act_enum);
		break;
	case CORBA__::dk_Struct:
		act_struct = IR__::StructDef::_narrow(item);
		doStruct(act_struct);
		break;
	case CORBA__::dk_Union:
		act_union = IR__::UnionDef::_narrow(item);
		doUnion(act_union);
		break;
	case CORBA__::dk_Composition : {
		CIDL::CompositionDef_var a_composition = CIDL::CompositionDef::_narrow(item);
		doComposition(a_composition);
		break; }
	default:
		break;
	};

	if(!definedInInterface(item)) {
		this->close_module(item);
	}
}
Esempio n. 15
0
void startUp(int argc, const char *argv[])
    {
#if __BORLANDC__ >= 1106
    set_new_handler(0);
#endif

    strcpy(fullExePath, argv[0]);

#ifndef WINCIT
    fseek(stdin, 0, SEEK_CUR);  // Borland says to fseek() before setbuf()
    setbuf(stdin, NULL);
#endif

#ifndef WINCIT
#ifdef MULTI
    if (!initTaskInfo(&ti))
#else
    cfg.maxrooms = 0 ;
    if (!initFakeTaskInfo())
#endif
        {
        printf("Could not create initial task information structure.\n");
        exit(200);
        }
#endif

    tzset();

    critical(TRUE);

#ifndef WINCIT
    if (checkDataVer() != NumericVer)
        {
        printf("CTDL.DAT is version %d; version %d needed.\n", checkDataVer(), NumericVer);
        critical(FALSE);
        exit(200);
        }

    if (!read_messages())
        {
        printf("Could not read messages from CTDL.DAT\n");
        critical(FALSE);
        exit(200);
        }

    InitializeTimer();
#else
    if (checkDataVer() != NumericVer)
        {
		char bbb[100];
		sprintf(bbb, "CTDL.DAT is version %d; version %d needed.", checkDataVer(), NumericVer);

        MessageBox(NULL, bbb, NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

    if (!read_messages())
        {
        MessageBox(NULL, "Could not read messages from CTDL.DAT.", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

    WNDCLASS wndclass;

    // define and register the main window class
    wndclass.style = 0; // CS_HREDRAW | CS_VREDRAW
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(hInstance, "CITADEL");
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

    // define and register the logo window class
    wndclass.lpszMenuName = NULL;
    wndclass.lpfnWndProc = logoWndProc;
    wndclass.lpszClassName = "Citadel Logo";
    if (!RegisterClass(&wndclass))
        {
        MessageBox(NULL, "Could not register logo window", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

#ifdef NAHERROR
    // define and register the error window class
    wndclass.style = CS_VREDRAW;
    wndclass.lpfnWndProc = errorWndProc;
    wndclass.lpszClassName = "Citadel Error";
    if (!RegisterClass(&wndclass))
        {
        MessageBox(NULL, "Could not register error window", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

    // define and register the msg window class
    wndclass.lpfnWndProc = msgWndProc;
    wndclass.lpszClassName = "Citadel Message";
    if (!RegisterClass(&wndclass))
        {
        MessageBox(NULL, "Could not register msg window", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }
#endif
#endif

    // initialize all drivers to internal functions

#ifdef WINCIT
    // com
//  initrs          = (void (cdecl *)(int,int,int,int,int,int)) nullFunc;
//  deinitrs        = nullFunc;
//  ringstatrs      = (int (cdecl *)(void)) nullFunc;
//  carrstatrs      = (int (cdecl *)(void)) nullFunc;
//  statrs          = (int (cdecl *)(void)) nullFunc;
//  flushrs         = nullFunc;
//  getrs           = (int (cdecl *)(void)) nullFunc;
//  putrs           = (void (cdecl *)(char)) nullFunc;
//  dtrrs           = (void (cdecl *)(int)) nullFunc;
//  flushoutrs      = nullFunc;
#else
    // Start using BIOS
    charattr = bioschar;
    stringattr = biosstring;

    // com
    initrs          = InitRS;
    deinitrs        = DeInitRS;
    ringstatrs      = RingStatRS;
    carrstatrs      = CarrStatRS;
    statrs          = StatRS;
    flushrs         = FlushRS;
    getrs           = GetRS;
    putrs           = PutRS;
    dtrrs           = DtrRS;
    flushoutrs      = nullFunc;

    // ups
    initups         = nullFunc;
    deinitups       = nullFunc;
    statups         = NULL;

    // kbd
    initkbd         = nullFunc;
    deinitkbd       = nullFunc;
    statcon         = StatCON;
    getcon          = GetCON;
    sp_press        = special_pressed;

    // snd
    init_sound      = (int (cdecl *)(void)) nullFunc;
    close_sound     = (int (cdecl *)(void)) nullFunc;
    get_version     = (int (cdecl *)(void)) nullFunc;
    query_drivers   = (int (cdecl *)(void)) nullFunc;
    query_status    = (int (cdecl *)(void)) nullFunc;
    start_snd_src   = (int (cdecl *)(int, const void *)) nullFunc;
    play_sound      = (int (cdecl *)(int)) nullFunc;
    stop_sound      = (int (cdecl *)(int)) nullFunc;
    pause_sound     = (int (cdecl *)(int)) nullFunc;
    resume_sound    = (int (cdecl *)(int)) nullFunc;
    read_snd_stat   = (int (cdecl *)(int)) nullFunc;
    set_midi_map    = (int (cdecl *)(int)) nullFunc;
    get_src_vol     = (int (cdecl *)(int)) nullFunc;
    set_src_vol     = (int (cdecl *)(int, int)) nullFunc;
    set_fade_pan    = (int (cdecl *)(void *)) nullFunc;
    strt_fade_pan   = (int (cdecl *)(void)) nullFunc;
    stop_fade_pan   = (int (cdecl *)(int)) nullFunc;
    pse_fade_pan    = (int (cdecl *)(void)) nullFunc;
    res_fade_pan    = (int (cdecl *)(void)) nullFunc;
    read_fade_pan   = (int (cdecl *)(int)) nullFunc;
    get_pan_pos     = (int (cdecl *)(int)) nullFunc;
    set_pan_pos     = (int (cdecl *)(int, int)) nullFunc;
    say_ascii       = (int (cdecl *)(const char *, int)) nullFunc;
#endif

    parseArgs(argc, argv);

#ifndef WINCIT
    if (!cfg.bios)
        {
        charattr = directchar;
        stringattr = directstring;
        }
#endif

#ifndef WINCIT
    if (!cmdLine[1])
        {
        uchar *ptr = (uchar *) MK_FP(_psp, 128);

        if (ptr[0])
            {
            memcpy(cmdLine, ptr + 1, max(128, ptr[0]));

            cmdLine[ptr[0]] = 0;
            }
        }

    OC.whichIO = CONSOLE;
#endif


    if (!initCitadel())
        {
#ifndef WINCIT
        DeinitializeTimer();
#endif
        critical(FALSE);
        exit(200);
        }


#ifndef WINCIT
    ScreenSaver.Update();
#endif

    if (BoardNameHash && hash(cfg.nodeTitle) != BoardNameHash)
        {
        crashout(getmsg(681));
        }

#ifndef WINCIT
    // Set system to a known state
    OC.Echo = BOTH;
    OC.SetOutFlag(IMPERVIOUS);
    modStat = FALSE;
    OC.whichIO = CONSOLE;

    OC.setio();

    if (!(login_pw || login_user || (slv_door && cfg.forcelogin)))
        {
        CommPort->FlushInput();
        greeting();
        }

    Cron.ResetTimer();

    if (slv_net)
        {
        doccr();

        if(read_tr_messages())
            {
            cPrintf(gettrmsg(49), slv_node);
            dump_tr_messages();
            }

        if (net_callout(slv_node))
            {
            did_net(slv_node);
            }

        ExitToMsdos = TRUE;
        }

    if (slv_door) // set according to carrier
        {
        // set baud rate even if carrier not present
        if (slv_baud != PS_ERROR)
            {
            CommPort->SetSpeed(slv_baud);
            }
        else
            {
            CommPort->SetSpeed(cfg.initbaud);
            }

        for (ModemSpeedE i = MS_300; i < MS_NUM; i = (ModemSpeedE) (i +1))
            {
            if (connectbauds[i] == bauds[CommPort->GetSpeed()])
                {
                CommPort->SetModemSpeed(i);
                break;
                }
            }

        if (CommPort->HaveConnection())
            {
            CarrierJustFound();

            OC.whichIO = MODEM;
            OC.setio();
            }
        else
            {
            OC.whichIO = CONSOLE;
            OC.setio();
            }
        }

    setdefaultTerm(TT_ANSI);

    StatusLine.Toggle();        // Turns it on (starts life off).

    ScreenSaver.SetMayTurnOn(TRUE);

    time(&LastActiveTime);
    TimeoutChecking = TRUE;

    if (*cmd_script)
        {
#ifdef WINCIT
        runScript(cmd_script, NULL);
#else
        runScript(cmd_script);
#endif
        }

    doEvent(EVT_STARTUP);
#endif
    }
Esempio n. 16
0
void TERMWINDOWMEMBER terminate(Bool discon)
    {
    char dtstr[80];
    Bool initport = FALSE;

    if (!altF3Timeout && (cfg.chatmail == 2 && chatReq) || (cfg.chatmail == 3) || (cfg.chatmail == 4))
        {
        if (cfg.chatmail == 2)
            {
            dispBlb(B_CHATTED);
            }

        Message *Msg = new Message;

        if (Msg)
            {
            msgtosysop(Msg);
            delete Msg;
            }
        else
            {
            OutOfMemory(41);
            }
        }

    if (loggedIn && onConsole)
        {
        last_console_login_callno = cfg.callno;
        }

    chatReq = FALSE;
    const Bool doStore = HaveConnectionToUser();

    if (discon || !doStore)
        {
        sysopNew = FALSE;
        }

    const long balance = CurrentUser->GetCredits();

    OC.SetOutFlag(OUTOK);

    if ((doStore && (MRO.Verbose == 2)) || CurrentUser->IsAutoVerbose() || CurrentUser->IsVerboseLogOut() ||
            CurrentUser->IsNode())
        {
        if (CurrentUser->IsNode())
            {
            OC.SetOutFlag(IMPERVIOUS);  // no carrier
            }

        CRmPrintfCR(getmsg(119), ltoac(cfg.callno));
        if (loggedIn)
           {
           mPrintfCR(getmsg(118), diffstamp(logtimestamp));
           }
        label Entered, L;
        CopyStringToBuffer(Entered, ltoac(MS.Entered));
        mPrintfCR(getmsg(117), Entered, MS.Entered == 1 ? cfg.Lmsg_nym : cfg.Lmsgs_nym, ltoac(MS.Read));

        if (cfg.accounting && CurrentUser->IsAccounting())
            {
            long C = (CurrentUserAccount->GetBalanceAtLogin() - balance) / 60;

            mPrintfCR(getmsg(116), ltoac(C), (C == 1) ? cfg.Lcredit_nym : cfg.Lcredits_nym, L);

            C = balance / 60;

            mPrintfCR(getmsg(115), ltoac(C), (C == 1) ? cfg.Lcredit_nym : cfg.Lcredits_nym);
            }

        char Buffer[64];
        strftime(dtstr, 79, (loggedIn) ? CurrentUser->GetVerboseDateStamp(Buffer, sizeof(Buffer)) : cfg.vdatestamp, 0l);
        }

    if (doStore && MRO.Verbose)
        {
        goodbye();
        }

    OC.SetOutFlag(IMPERVIOUS);

    label Buffer;
    if (loggedIn)
        {
        if ((MRO.Verbose == 2) || CurrentUser->IsAutoVerbose() || CurrentUser->IsVerboseLogOut() || CurrentUser->IsNode())
            {
            CRmPrintfCR(getmsg(614), CurrentUser->GetName(Buffer, sizeof(Buffer)), dtstr);
            }
        else
            {
            CRmPrintfCR(getmsg(114), CurrentUser->GetName(Buffer, sizeof(Buffer)));
            }
        }

    // Go back to the default hall
    thisHall = HallData.GetDefault();

    if (discon)
        {
#ifdef WINCIT
        switch(CommPort->GetType())
            {
            case CT_SERIAL:
                {
                initport = TRUE;
                break;
                }

            case CT_TELNET:
                {
                initport = FALSE;
                break;
                }

            default:
                {
                initport = FALSE;
                break;
                }
            }
#endif

        if (CommPort->HaveConnection())
            {
            CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(82));

            Hangup();

            if (w)
                {
                destroyCitWindow(w, FALSE);
                }
            }

        //OC.whichIO = MODEM; // I really don't know
        //OC.setio();
        }

    if (!slv_door && !CommPort->HaveConnection())
        {
        CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(19));

#ifdef WINCIT
        if(initport)
#endif
            {
            Initport();
            }

        if (w)
            {
            destroyCitWindow(w, FALSE);
            }
        }

    CurrentUser->SetInRoom(thisRoom, TRUE);

    if (!doStore) // if carrier dropped
        {
        if(!read_tr_messages())
            {
            errorDisp(getmsg(172));
            }

#ifdef WINCIT
        trap(T_CARRIER, WindowCaption, gettrmsg(19), WindowCaption);
#else
        trap(T_CARRIER, gettrmsg(19));
#endif
        dump_tr_messages();
        }

    // update new pointer only if carrier not dropped
    if (loggedIn && doStore)
        {
        CurrentUser->SetRoomNewPointer(thisRoom, MessageDat.NewestMessage());
        }

    if (loggedIn)
        {
        CurrentUser->SetCallNumber(cfg.callno);
        CurrentUser->SetCallTime(logtimestamp);

        // for the Minibin() function to calculate #new messages
        CurrentUser->SetLastMessage(MessageDat.NewestMessage());

        CurrentUser->SetTotalTime(CurrentUser->GetTotalTime() + (time(NULL) - logtimestamp));

        CurrentUser->SetLogins(CurrentUser->GetLogins() + 1);
        CurrentUser->SetPosted(CurrentUser->GetPosted() + MS.Entered);
        CurrentUser->SetRead(CurrentUser->GetRead() + MS.Read);

        CurrentUser->Save(ThisLog, thisRoom);

        // this stuff puts the current room at the end of jumpback,
        // so J will take you back here.
        jumpback jb;

        jb.hall = thisHall;
        jb.room = thisRoom;
        jb.newpointer = CurrentUser->GetRoomNewPointer(thisRoom);
        jb.bypass = Talley->Bypassed(thisRoom);
        jb.newMsgs = Talley->NewInRoom(thisRoom);

        CurrentUser->JumpbackPush(jb);

#ifdef MULTI
        char LogoffEvent[256];
        label NameBuffer;

        sprintf(LogoffEvent, doStore ? getmsg(665) : getmsg(29), CurrentUser->GetName(NameBuffer, sizeof(NameBuffer)));
        TermWindowCollection.SystemEvent(SE_LOGONOFF, FALSE, NULL, FALSE, LogoffEvent);
#endif

        loggedIn = FALSE;

        if (CurrentUser->IsPrintFile() && OC.Printing)
            {
            OC.Printing = OC.WasPrinting;

            if (!OC.Printing)
                {
                fclose(OC.PrintFile);
                }
            }

        // trap it
        if (CurrentUser->IsNode())
            {
            if (netError)
                {
                Bool OldTrapit = cfg.trapit[T_NETWORK];

                if (node->GetNetFail() > 0)
                    {
                    cfg.trapit[T_NETWORK] = TRUE;
                    }
                else if (node->GetNetFail() < 0)
                    {
                    cfg.trapit[T_NETWORK] = FALSE;
                    }

#ifdef WINCIT
                trap(T_NETWORK, WindowCaption, getmsg(606), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#else
                trap(T_NETWORK, getmsg(606), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#endif

                cfg.trapit[T_NETWORK] = OldTrapit;
                }
            else
                {
#ifdef WINCIT
                trap(T_NETWORK, WindowCaption, getmsg(22), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#else
                trap(T_NETWORK, getmsg(22), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#endif
                }
            }
        else
            {
            doEvent(EVT_LOGOUT);
            if(!read_tr_messages())
                {
                errorDisp(getmsg(172));
                }
#ifdef WINCIT
            trap(T_LOGIN, WindowCaption, gettrmsg(24), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#else
            trap(T_LOGIN, gettrmsg(24), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#endif
            dump_tr_messages();
            }

        const TrapKeywords TrapType = CurrentUser->IsNode() ? T_NETWORK : T_ACCOUNT;
        if(!read_tr_messages())
            {
            errorDisp(getmsg(172));
            }
#ifndef WINCIT
        trap(TrapType, gettrmsg(25), MS.Entered);
        trap(TrapType, gettrmsg(26), MS.Read);
#else
        trap(TrapType, WindowCaption, gettrmsg(25), MS.Entered);
        trap(TrapType, WindowCaption, gettrmsg(26), MS.Read);
#endif
        dump_tr_messages();

        if (CurrentUser->IsNode())
            {
            if(!read_tr_messages())
                {
                errorDisp(getmsg(172));
                }
#ifndef WINCIT
            trap(T_NETWORK, gettrmsg(20), MS.Expired);
            trap(T_NETWORK, gettrmsg(21), MS.Duplicate);
#else
            trap(T_NETWORK, WindowCaption, gettrmsg(20), MS.Expired);
            trap(T_NETWORK, WindowCaption, gettrmsg(21), MS.Duplicate);
#endif
            dump_tr_messages();
            }
        else if (cfg.accounting)    // There's just no accounting for nodes
            {
            if(!read_tr_messages())
                {
                errorDisp(getmsg(172));
                }
#ifdef WINCIT
            trap(T_ACCOUNT, WindowCaption, gettrmsg(27), CurrentUserAccount->GetBalanceAtLogin() - balance);
#else
            trap(T_ACCOUNT, gettrmsg(27), CurrentUserAccount->GetBalanceAtLogin() - balance);
#endif
            dump_tr_messages();
            }

        delete MS.AbortedMessage;
        MS.AbortedMessage = NULL;

#ifdef MULTI
        LoginList.Remove(ThisLog);
#endif
        }

    setdefaultconfig(FALSE);

    if (discon)
        {
        setdefaultTerm(TT_ANSI);
        }
    else
        {
        setdefaultTerm(TT_DUMB);
        }

    CurrentUser->SetCredits(discon ? 0L : cfg.unlogtimeout * 60L);
    StatusLine.Update(WC_TWp);

    Talley->Fill();

    CurrentRoom->Load(LOBBY);
    checkdir();
    thisRoom = LOBBY;

    AideQueueClear();
    clearFileQueue();
    MS.AutoMKC = AM_NONE;
    MS.MarkedID = 0L;

    freeNode(&node);
    netError = FALSE;   // just in case

    Cron.ResetTimer();
    }