bool JackSocketServerChannel::Execute() { try { // Global poll if ((poll(fPollTable, fSocketTable.size() + 1, 10000) < 0) && (errno != EINTR)) { jack_error("JackSocketServerChannel::Execute : engine poll failed err = %s request thread quits...", strerror(errno)); return false; } else { // Poll all clients for (unsigned int i = 1; i < fSocketTable.size() + 1; i++) { int fd = fPollTable[i].fd; jack_log("JackSocketServerChannel::Execute : fPollTable i = %ld fd = %ld", i, fd); if (fPollTable[i].revents & ~POLLIN) { jack_log("JackSocketServerChannel::Execute : poll client error err = %s", strerror(errno)); ClientKill(fd); } else if (fPollTable[i].revents & POLLIN) { JackClientSocket* socket = fSocketTable[fd].second; // Decode header JackRequest header; if (header.Read(socket) < 0) { jack_log("JackSocketServerChannel::Execute : cannot decode header"); ClientKill(fd); // Decode request } else { // Result is not needed here fDecoder->HandleRequest(socket, header.fType); } } } // Check the server request socket */ if (fPollTable[0].revents & POLLERR) { jack_error("Error on server request socket err = %s", strerror(errno)); } if (fPollTable[0].revents & POLLIN) { ClientCreate(); } } BuildPoolTable(); return true; } catch (JackQuitException& e) { jack_log("JackSocketServerChannel::Execute : JackQuitException"); return false; } }
bool JackClientPipeThread::Execute() { try { jack_log("JackClientPipeThread::Execute %x", this); JackRequest header; int res = header.Read(fPipe); bool ret = true; // Lock the global mutex if (WaitForSingleObject(fMutex, INFINITE) == WAIT_FAILED) { jack_error("JackClientPipeThread::Execute : mutex wait error"); } // Decode header if (res < 0) { jack_log("JackClientPipeThread::Execute : cannot decode header"); ClientKill(); ret = false; // Decode request } else if (fDecoder->HandleRequest(fPipe, header.fType) < 0) { ret = false; } // Unlock the global mutex if (!ReleaseMutex(fMutex)) { jack_error("JackClientPipeThread::Execute : mutex release error"); } return ret; } catch (JackQuitException& e) { jack_log("JackClientPipeThread::Execute : JackQuitException"); return false; } }
void CHL2MP_Player::ChangeTeam( int iTeam ) { /* if ( GetNextTeamChangeTime() >= gpGlobals->curtime ) { char szReturnString[128]; Q_snprintf( szReturnString, sizeof( szReturnString ), "Please wait %d more seconds before trying to switch teams again.\n", (int)(GetNextTeamChangeTime() - gpGlobals->curtime) ); ClientPrint( this, HUD_PRINTTALK, szReturnString ); return; }*/ bool bKill = false; if ( HL2MPRules()->IsTeamplay() != true && iTeam != TEAM_SPECTATOR ) { //don't let them try to join combine or rebels during deathmatch. iTeam = TEAM_UNASSIGNED; } if ( HL2MPRules()->IsTeamplay() == true ) { if ( iTeam != GetTeamNumber() && GetTeamNumber() != TEAM_UNASSIGNED ) { bKill = true; } } BaseClass::ChangeTeam( iTeam ); m_flNextTeamChangeTime = gpGlobals->curtime + TEAM_CHANGE_INTERVAL; if ( HL2MPRules()->IsTeamplay() == true ) { SetPlayerTeamModel(); } else { SetPlayerModel(); } if ( iTeam == TEAM_SPECTATOR ) { RemoveAllItems( true ); State_Transition( STATE_OBSERVER_MODE ); } if ( bKill == true ) { ClientKill( edict() ); } }
qboolean ClientCommand() { char cmd_command[1024]; self = PROG_TO_EDICT( g_globalvars.self ); trap_CmdArgv( 0, cmd_command, sizeof( cmd_command ) ); if ( !strcmp( cmd_command, "kill" ) ) { ClientKill(); return true; } //G_Printf("ClientCommand %s\n",cmd_command); return false; }
bool CHL2MP_Player::HandleCommand_JoinTeam( int team ) { if ( !GetGlobalTeam( team ) ) { Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team ); return false; } if ( team == TEAM_SPECTATOR ) { // Prevent this is the cvar is set if ( !mp_allowspectators.GetInt() ) { ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" ); return false; } if ( GetTeamNumber() != TEAM_UNASSIGNED && !IsDead() ) { m_fNextSuicideTime = gpGlobals->curtime; // allow the suicide to work ClientKill( edict() ); // add 1 to frags to balance out the 1 subtracted for killing yourself IncrementFragCount( 1 ); } ChangeTeam( TEAM_SPECTATOR ); return true; } else { StopObserverMode(); State_Transition(STATE_ACTIVE); } // Switch their actual team... ChangeTeam( team ); return true; }