Exemplo n.º 1
0
void Joueur::setTypeGamplay(TypeGameplay t)
{
	if(!m_equipe)
		return;
	if(m_type_gamplay==TypeGameplay::RTS)
	{
		m_equipe->setJoueurRTS(nullptr);
		delete getRTS();
		setRTS(nullptr);
	}
	else if (m_type_gamplay==TypeGameplay::RPG) 
	{
		m_equipe->removeRPG(getRPG());
		delete getRPG();
		setRPG(nullptr);	
	}
	m_type_gamplay = t;
	if(t==TypeGameplay::RTS)
	{
		setRTS(new JoueurRTS(this));
		m_equipe->setJoueurRTS(getRTS());
	}
	else if (t==TypeGameplay::RPG) 
	{
		setRPG(new JoueurRPG(this));
		m_equipe->addRPG(getRPG());
	}
}
Exemplo n.º 2
0
// updatePortConfig is called when emulated app changes the serial port
// parameters baudrate, stopbits, number of databits, parity.
void CDirectSerial::updatePortConfig (Bit16u divider, Bit8u lcr) {
	Bit8u parity = 0;

	switch ((lcr & 0x38)>>3) {
	case 0x1: parity='o'; break;
	case 0x3: parity='e'; break;
	case 0x5: parity='m'; break;
	case 0x7: parity='s'; break;
	default: parity='n'; break;
	}

	Bit8u bytelength = (lcr & 0x3)+5;

	// baudrate
	Bitu baudrate;
	if(divider==0) baudrate=115200;
	else baudrate = 115200 / divider;

	// stopbits
	Bit8u stopbits;
	if (lcr & 0x4) {
		if (bytelength == 5) stopbits = SERIAL_15STOP;
		else stopbits = SERIAL_2STOP;
	} else stopbits = SERIAL_1STOP;

	if(!SERIAL_setCommParameters(comport, baudrate, parity, stopbits, bytelength)) {
#if SERIAL_DEBUG
		log_ser(dbg_aux,"Serial port settings not supported by host." );
#endif
		LOG_MSG ("Serial%d: Desired serial mode not supported (%d,%d,%c,%d)",
			COMNUMBER, baudrate,bytelength,parity,stopbits);
	} 
	CDirectSerial::setRTSDTR(getRTS(), getDTR());
}
Exemplo n.º 3
0
bool CNullModem::ServerConnect() {
	// check if a connection is available.
	clientsocket=serversocket->Accept();
	if (!clientsocket) return false;
	
	Bit8u peeripbuf[16];
	clientsocket->GetRemoteAddressString(peeripbuf);
	LOG_MSG("Serial%d: A client (%s) has connected.",(int)COMNUMBER,peeripbuf);
#if SERIAL_DEBUG
	log_ser(dbg_aux,"Nullmodem: A client (%s) has connected.", peeripbuf);
#endif

    /* FIXME: It would be nice if the SDL net library had a bind() call to bind only to a specific interface.
     *        Or maybe it does... what am I missing? */
    if (!nonlocal && strcmp((char*)peeripbuf,"127.0.0.1") != 0) {
        LOG_MSG("Serial%d: Non-localhost client (%s) dropped by nonlocal:0 policy. To accept connections from network, set nonlocal:1",(int)COMNUMBER,peeripbuf);
        delete clientsocket;
        clientsocket = NULL;
        return false;
    }

	clientsocket->SetSendBufferSize(256);
	rx_state=N_RX_IDLE;
	setEvent(SERIAL_POLLING_EVENT, 1);
	
	// we don't accept further connections
	delete serversocket;
	serversocket=0;

	// transmit the line status
	setRTSDTR(getRTS(), getDTR());
	if (transparent) setCD(true);
	return true;
}
Exemplo n.º 4
0
bool CNullModem::ClientConnect(TCPClientSocket* newsocket) {
	Bit8u peernamebuf[16];
	clientsocket = newsocket;
 
	if (!clientsocket->isopen) {
		LOG_MSG("Serial%d: Connection failed.",COMNUMBER);
		delete clientsocket;
		clientsocket=0;
		setCD(false);
		return false;
	}
	clientsocket->SetSendBufferSize(256);
	clientsocket->GetRemoteAddressString(peernamebuf);
	// transmit the line status
	if (!transparent) setRTSDTR(getRTS(), getDTR());
	rx_state=N_RX_IDLE;
	LOG_MSG("Serial%d: Connected to %s",COMNUMBER,peernamebuf);
	setEvent(SERIAL_POLLING_EVENT, 1);
	setCD(true);
	return true;
}
Exemplo n.º 5
0
int main(int argc, char *argv[]) 
{
	RegionTable *rt;
	int i;

	initRTS(2,3,4,5);

	rt = getRTS(0,0,0,0); i = getIndex(0,0,0,0);
	printf("getRTS(0,0,0,0) = %d (%p)\n", i, rt);
	rt = getRTS(0,0,0,1);
	printf("getRTS(0,0,0,1) = %d (%p)\n", i, rt);
	rt = getRTS(0,0,0,2);
	printf("getRTS(0,0,0,2) = %d (%p)\n", i, rt);
	rt = getRTS(0,0,0,3);
	printf("getRTS(0,0,0,3) = %d (%p)\n", i, rt);
	rt = getRTS(0,0,0,4);
	printf("getRTS(0,0,0,4) = %d (%p)\n", i, rt);
	rt = getRTS(0,0,1,0);
	printf("getRTS(0,0,1,0) = %d (%p)\n", i, rt);
	rt = getRTS(0,0,1,1);
	printf("getRTS(0,0,1,1) = %d (%p)\n", i, rt);
	rt = getRTS(1,2,3,4);
	printf("getRTS(1,2,3,4) = %d (%p)\n", i, rt);
}
Exemplo n.º 6
0
bool CNullModem::ServerConnect() {
	// check if a connection is available.
	clientsocket=serversocket->Accept();
	if (!clientsocket) return false;
	
	Bit8u peeripbuf[16];
	clientsocket->GetRemoteAddressString(peeripbuf);
	LOG_MSG("Serial%d: A client (%s) has connected.",COMNUMBER,peeripbuf);
#if SERIAL_DEBUG
	log_ser(dbg_aux,"Nullmodem: A client (%s) has connected.", peeripbuf);
#endif
	clientsocket->SetSendBufferSize(256);
	rx_state=N_RX_IDLE;
	setEvent(SERIAL_POLLING_EVENT, 1);
	
	// we don't accept further connections
	delete serversocket;
	serversocket=0;

	// transmit the line status
	setRTSDTR(getRTS(), getDTR());
	if (transparent) setCD(true);
	return true;
}
Exemplo n.º 7
0
void CNullModem::setDTR(bool val) {
	setRTSDTR(getRTS(), val);
}
Exemplo n.º 8
0
void CNullModem::setBreak (bool /*value*/) {
	CNullModem::setRTSDTR(getRTS(), getDTR());
}