Exemplo n.º 1
0
double SIMPSON(int FN, double A, double B)
{
   double Z[5];
   double Y,H,simpson; 
   int I;
  
   H = (B - A) / 4.0;
   for (I=0; I<=4; I++) {
      Y = A + I * H;
      switch (FN) {
         case 1:
            Z[I] = ( 4.0 - I ) * I * H * H * QQ( Y ); 
            break;
         case 2:
            Z[I] = ( I * H ) * ( I * H ) * QQ( Y );
            break;
         case 3:
            Z[I] = ( H * ( 4.0 - I ) ) * ( H * ( 4.0 - I ) ) * QQ( Y );
            break;
         case 4:
            Z[I] = P( Y );
            break;
         case 5:
            Z[I] = I * H * F( Y );
            break;
         case 6:
            Z[I] = ( 4.0 - I ) * H * F( Y );
            break;
      }  
   }
   simpson = ( Z[0] + Z[4] + 2.0 * Z[2] + 4.0 * ( Z[1] + Z[3] ) ) * H / 3.0;
   return simpson;
}  
Exemplo n.º 2
0
void PreferenceDialog::browseApp()
{
    QStringList list = QStandardPaths::standardLocations(
                QStandardPaths::ApplicationsLocation);
#ifdef Q_OS_WIN
    QString path = QFileDialog::getOpenFileName(
                this, tr("アプリケーションを選択"), getenv("PROGRAMFILES"),
                tr("実行ファイル (*.exe *.com *.bat *.pif);;すべてのファイル (*)"));
#elif defined(Q_OS_MAC)
    QString path = QFileDialog::getOpenFileName(
                this, tr("アプリケーションを選択"), list.at(0),
                tr("実行ファイル (*.app);;すべてのファイル (*)"));
#else
    QString path = QFileDialog::getOpenFileName(
                this, tr("アプリケーションを選択"), list.at(0),
                tr("すべてのファイル (*)"));
#endif
    if (!path.isEmpty()) {
        if (path.indexOf(" ") != -1) {
            path = QQ(path);
        }

        if (sender() == ui->browseEditor) {
            ui->editorPath->setText(path);
        }
        else if (sender() == ui->browseTerminal) {
            ui->terminalPath->setText(path);
        }
        else if (sender() == ui->browseArchiver) {
            ui->archiverPath->setText(path);
        }
    }
}
Exemplo n.º 3
0
void
HaikuAggGlue::ViewNeeded()
{
    QQ(8);
    if (*_win)
    {
        QQ(8);
        if (_view == NULL)
        {
            QQ(8);
            _view = new BeV(_gui);
            (*_win)->AddChild(_view);
        }
        _view->SetBuffer(_offscreenbuf, _width, _height);
    }
}
Exemplo n.º 4
0
 void unsetFullscreenEtc()
 {
     QQ(8);
     if (_fullscreen == false)
         return;
     _fullscreen = false;
     MoveTo(_unfullscreen_frame.left, _unfullscreen_frame.top);
     ResizeTo(_unfullscreen_frame.Width(), _unfullscreen_frame.Height());
 }
Exemplo n.º 5
0
 void FrameResized(float width, float height)
 {
     BMessage msg(GNASH_RESIZE);
     if (msg.AddFloat("w", width) != B_OK
         || msg.AddFloat("h", height) != B_OK)
         QQ(1);
     else
         be_app_messenger.SendMessage(&msg);
 }
Exemplo n.º 6
0
    void ScreenChanged(BRect frame, color_space mode)
    {
        (void) mode;

        QQ(8);
        if (_fullscreen == false)
            return;
        // XXX perform in beapp thread
        MoveTo(0,0);
        ResizeTo(frame.Width(), frame.Height());
    }
Exemplo n.º 7
0
 bool
 CreateWindow(int width, int height, int xPosition, int yPosition,
             const char *title)
 {
     assert(_win == NULL);
     QQ(8);
     _win = new BeWin(BRect(xPosition, yPosition, xPosition+width-1, yPosition+height-1),
         title, _gui);
     _win->Show();
     return true;
 }
Exemplo n.º 8
0
    void MouseMoved(BPoint point, uint32 transit, const BMessage *message)
    {
        (void) transit;
        (void) message;

        BMessage msg(GNASH_MOUSE_MOVED);
        if (B_OK != msg.AddInt32("x", point.x)
            || B_OK != msg.AddInt32("y", point.y))
            QQ(1);
        else
            be_app_messenger.SendMessage(&msg);
    }
Exemplo n.º 9
0
    void setFullscreenEtc()
    {
        QQ(8);
        if (_fullscreen == true)
            return;
        _fullscreen = true;

        BScreen s(this);
        BRect r(s.Frame());
        _unfullscreen_frame = Frame();
        MoveTo(0,0);
        ResizeTo(r.Width(), r.Height());
    }
Exemplo n.º 10
0
 void KeyUp(const char *bytes, int32 numBytes)
 {
     for (int32 i = 0; i < numBytes; ++i)
     {
         BMessage msg(GNASH_KEY_EVENT);
         if (B_OK != msg.AddInt32("key", gnash_keycode(bytes[i]))
                 || B_OK != msg.AddInt32("modifiers", 0)
                 || B_OK != msg.AddBool("pressed", false))
             QQ(1);
         else
             be_app_messenger.SendMessage(&msg);
         //XXX parse multibyte character codes
     }
 }
Exemplo n.º 11
0
void CCollegeTimeTableView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{  int j,k,height,maxheight;
	UINT line;
   CString temp;
   CStringArray arr;
   arr.SetSize(20);
   
   CFont fon;
   CFont* oldfont;
   fon.CreateFont(18,8,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
   CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"COURIER NEW");

   oldfont=pDC->SelectObject(&fon); 


   pDC->SetMapMode(MM_LOENGLISH);
   pDC->SetBkMode(TRANSPARENT);
   CPoint PP(70,-25);
   CPoint QQ(771,-25);
   CPoint tempPP,tempQQ;
   UINT lastline=PageArray[(pInfo->m_nCurPage)-1].Line.GetUpperBound();///
   for(line=0;line<=lastline;line++)
   {    maxheight=1;
	   for(j=0;j<7;j++)
		{tempPP=PP;//tempQQ=QQ;
		 temp=m_master.GetItemText(PageArray[(pInfo->m_nCurPage)-1].Line[line],j);
		 if(temp[0]>='0' && temp[0]<='9')
		 {PP.Offset(0,-25); 
		  tempPP=PP;QQ.Offset(0,-25);  /////create blank space between lecture blocks
		 }
         GetParallelLectureList(temp,arr);// in CStringarray arr
         height=arr.GetSize();
		 if(height<1) height=1;
		 if(height>maxheight) maxheight=height;
		 for(k=0;k<height;k++)
			{pDC->TextOut(74+j*100,PP.y-2,arr[k]);
		     PP.Offset(0,-25);
			 }
         PP=tempPP;//Reset to normal lecture line
		}
		QQ.Offset(0,-25*maxheight);
		DisplayGrid(PP,QQ,1,7,pDC);
		PP.Offset(0,-25*maxheight);
		
   }  

pDC->SelectObject(&oldfont); 
}
Exemplo n.º 12
0
    void MouseUp(BPoint where)
    {
        (void) where;

        BPoint mouseWhere;
        ulong buttons;
        GetMouse(&mouseWhere, &buttons);

        BMessage msg(GNASH_MOUSE_CLICKED);
        if (B_OK != msg.AddBool("pressed", false)
            || B_OK != msg.AddInt32("mask", _pressedbuttons & ~buttons))
            QQ(1);
        else
            be_app_messenger.SendMessage(&msg);
        _pressedbuttons = buttons;
    }
Exemplo n.º 13
0
    void MouseDown(BPoint where)
    {
        (void) where;

        MakeFocus();
        BPoint mouseWhere;
        ulong buttons;
        GetMouse(&mouseWhere, &buttons);
        // XXX many buttons clicked simultaneously
        BMessage msg(GNASH_MOUSE_CLICKED);
        if (B_OK != msg.AddBool("pressed", true)
            || B_OK != msg.AddInt32("mask", buttons))
            QQ(1);
        else
            be_app_messenger.SendMessage(&msg);
        _pressedbuttons = buttons;
    }
Exemplo n.º 14
0
bool
HaikuAggGlue::init(int /*argc*/, char*** /*argv*/, BWindow **win, std::string sharefilename)
{
    //    GNASH_REPORT_FUNCTION;
    _win = win;
    assert(_win);

    if (_xid != 0)
    {
        _sharefilename = sharefilename;

        _sharefd = open(_sharefilename.c_str(), O_RDWR);
        if (_sharefd == -1)
            return false;
        if (unlink(_sharefilename.c_str()) == -1)
            QQ(1);
    }


    return true;
}
Exemplo n.º 15
0
bool
HaikuGui::init(int argc, char **argv[])
{
    QQ(8);
    GNASH_REPORT_FUNCTION;
    _app = new BeApp(this);

//    if (_xid)
//            log_error (_("Ignoring request to display in X11 window"));

    char c;
    int origopterr = opterr;

    optind = 0;
    opterr = 0;

    while ((c = getopt(argc, *argv, "D:")) != -1) {
        if (c == 'D') {
            // Terminate if no filename is given.
            if (!optarg) {
                std::cout << 
                    _("# FATAL:  No filename given with -D argument.") << std::endl;      
                return false;
            }
            _sharefilename = optarg;
        }
    }


    opterr = origopterr;

    _glue.init(argc, argv, _app->GetWinAddr(), _sharefilename);

    _renderer.reset(_glue.createRenderHandler(32));
    if ( ! _renderer ) return false;

    return true;
}
Exemplo n.º 16
0
void G_BotDel( int clientNum )
{
	gentity_t *bot = &g_entities[clientNum];
	char userinfo[MAX_INFO_STRING];
	const char *autoname;

	if ( !( bot->r.svFlags & SVF_BOT ) || !bot->botMind )
	{
		Log::Warn( "'^7%s^7' is not a bot", bot->client->pers.netname );
		return;
	}

	trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );

	autoname = Info_ValueForKey( userinfo, "autoname" );
	if ( autoname && *autoname )
	{
		G_BotNameUsed( BotGetEntityTeam( bot ), autoname, false );
	}

	trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_( "$1$^7 disconnected" ) ),
					Quote( bot->client->pers.netname ) ) );
	trap_DropClient( clientNum, "disconnected" );
}
Exemplo n.º 17
0
/*
===========
ClientConnect

Called when a player begins connecting to the server.
Called again for every map change or tournement restart.

The session information will be valid after exit.

Return nullptr if the client should be allowed, otherwise return
a string with the reason for denial.

Otherwise, the client will be sent the current gamestate
and will eventually get to ClientBegin.

firstTime will be true the very first time a client connects
to the server machine, but false on map changes and tournement
restarts.
============
*/
const char *ClientConnect( int clientNum, bool firstTime )
{
	const char      *value;
	const char      *userInfoError;
	gclient_t       *client;
	char            userinfo[ MAX_INFO_STRING ];
	char            pubkey[ RSA_STRING_LENGTH ];
	gentity_t       *ent;
	char            reason[ MAX_STRING_CHARS ] = { "" };
	int             i;
	const char      *country;

	ent = &g_entities[ clientNum ];
	client = &level.clients[ clientNum ];

	// ignore if client already connected
	if ( client->pers.connected != CON_DISCONNECTED )
	{
		return nullptr;
	}

	ent->client = client;
	memset( client, 0, sizeof( *client ) );

	trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );

	value = Info_ValueForKey( userinfo, "ip" );

	// check for local client
	if ( !strcmp( value, "localhost" ) )
	{
		client->pers.localClient = true;
	}

	G_AddressParse( value, &client->pers.ip );

	trap_GetPlayerPubkey( clientNum, pubkey, sizeof( pubkey ) );

	if ( strlen( pubkey ) != RSA_STRING_LENGTH - 1 )
	{
		return "Invalid pubkey key";
	}

	trap_GenFingerprint( pubkey, sizeof( pubkey ), client->pers.guid, sizeof( client->pers.guid ) );
	client->pers.admin = G_admin_admin( client->pers.guid );

	client->pers.pubkey_authenticated = false;

	if ( client->pers.admin )
	{
		Com_GMTime( &client->pers.admin->lastSeen );
	}

	// check for admin ban
	if ( G_admin_ban_check( ent, reason, sizeof( reason ) ) )
	{
		return va( "%s", reason ); // reason is local
	}

	// check for a password
	value = Info_ValueForKey( userinfo, "password" );

	if ( g_password.string[ 0 ] && Q_stricmp( g_password.string, "none" ) &&
	     strcmp( g_password.string, value ) != 0 )
	{
		return "Invalid password";
	}

	// if a player reconnects quickly after a disconnect, the client disconnect may never be called, thus flag can get lost in the ether
	if ( ent->inuse )
	{
		G_LogPrintf( "Forcing disconnect on active client: %i", (int)( ent - g_entities ) );
		// so lets just fix up anything that should happen on a disconnect
		ClientDisconnect( ent-g_entities );
	}

	for ( i = 0; i < level.maxclients; i++ )
	{
		if ( level.clients[ i ].pers.connected == CON_DISCONNECTED )
		{
			continue;
		}

		if ( !( g_entities[i].r.svFlags & SVF_BOT ) && !Q_stricmp( client->pers.guid, level.clients[ i ].pers.guid ) )
		{
			if ( !G_ClientIsLagging( level.clients + i ) )
			{
				trap_SendServerCommand( i, "cp \"Your GUID is not secure\"" );
				return "Duplicate GUID";
			}

			trap_DropClient( i, "Ghost" );
		}
	}

	client->pers.connected = CON_CONNECTING;

	// read or initialize the session data
	if ( firstTime )
	{
		G_InitSessionData( client, userinfo );
	}

	G_ReadSessionData( client );

	// get and distribute relevent paramters
	G_namelog_connect( client );
	userInfoError = ClientUserinfoChanged( clientNum, false );

	if ( userInfoError != nullptr )
	{
		return userInfoError;
	}

	G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s^7\" \"%s^7\"",
	             clientNum, client->pers.ip.str[0] ? client->pers.ip.str : "127.0.0.1", client->pers.guid,
	             client->pers.netname,
	             client->pers.netname );

	country = Info_ValueForKey( userinfo, "geoip" );
	Q_strncpyz( client->pers.country, country, sizeof( client->pers.country ) );

	G_SendClientPmoveParams(clientNum);

	// don't do the "xxx connected" messages if they were caried over from previous level
	if ( firstTime )
	{
		if ( g_geoip.integer && country && *country )
		{
			trap_SendServerCommand( -1, va( "print_tr %s %s %s", QQ( N_("$1$^7 connected from $2$") ),
			                                Quote( client->pers.netname ), Quote( country ) ) );
		}
		else
		{
			trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 connected") ),
			                                Quote( client->pers.netname ) ) );
		}
	}

	// count current clients and rank for scoreboard
	CalculateRanks();

	// if this is after !restart keepteams or !restart switchteams, apply said selection
	if ( client->sess.restartTeam != TEAM_NONE )
	{
		G_ChangeTeam( ent, client->sess.restartTeam );
		client->sess.restartTeam = TEAM_NONE;
	}

	return nullptr;
}
Exemplo n.º 18
0
Arquivo: dw.c Projeto: AkaBlood/ogs5
/* ---------------------------------------------------------------------- */
static int
DFIND (double *DOUT, double P, double D, double T)
/* ---------------------------------------------------------------------- */
/*
C
C     ROUTINE TO FIND DENSITY CORRESPONDING TO INPUT PRESSURE P(MPA), AN
C     TEMPERATURE T(K), USING INITIAL GUESS DENSITY D(G/CM3). THE OUTPUT
C     DENSITY IS IN G/CM3.
C
C     FROM L. HAAR, J. S. GALLAGHER, AND G. S. KELL, (1984)
C
*/
{
  int L;
  double DD, RT, PP_dfind, DPD, DPDX, DP, X;
  /*      double DD, RT, PP, DPD, DPDX, DP, X; */

  DD = D;
  RT = GASCON * T;
  if (DD <= 0.e0)
    DD = 1.e-8;
  if (DD > 1.9e0)
    DD = 1.9e0;
  L = 0;
  for (L = 1; L <= 30; L++)
  {
    if (DD <= 0.e0)
      DD = 1.e-8;
    if (DD > 1.9e0)
      DD = 1.9e0;
    QQ (T, DD);
    PP_dfind = RT * DD * BASE (DD) + Q0;
    DPD = RT * (Z + Y * DZ) + Q5;
    /*
       C
       C  THE FOLLOWING 3 LINES CHECK FOR NEGATIVE DP/DRHO, AND IF SO ASSUME
       C    GUESS TO BE IN 2-PHASE REGION, AND CORRECT GUESS ACCORDINGLY.
       C
     */
    if (DPD <= 0.e0)
    {
      if (D >= .2967e0)
	DD = DD * 1.02e0;
      if (D < .2967e0)
	DD = DD * .98e0;
      if (L <= 10)
	continue;
    }
    else
    {
/* 13 */
      DPDX = DPD * 1.1e0;
      if (DPDX < 0.1e0)
	DPDX = 0.1e0;
      DP = fabs (1.e0 - PP_dfind / P);
      if (DP < 1.e-8)
	break;
      if (D > .3e0 && DP < 1.e-7)
	break;
      if (D > .7e0 && DP < 1.e-6)
	break;
      X = (P - PP_dfind) / DPDX;
      if (fabs (X) > .1e0)
	X = X * .1e0 / fabs (X);
      DD = DD + X;
      if (DD < 0.e0)
	DD = 1.e-8;
    }
  }
  if (L > 30)
    error_msg ("In subroutine DFIND", STOP);
/*   20 CONTINUE */
  *DOUT = DD;
  return OK;
}
Exemplo n.º 19
0
/*
===========
ClientBegin

Called when a client has finished connecting, and is ready
to be placed into the level. This will happen on every
level load and level restart, but doesn't happen on respawns.
============
*/
void ClientBegin( int clientNum )
{
	gentity_t       *ent;
	gclient_t       *client;
	int             flags;
	char            startMsg[ MAX_STRING_CHARS ];

	ent = g_entities + clientNum;

	client = level.clients + clientNum;

	// ignore if client already entered the game
	if ( client->pers.connected != CON_CONNECTING )
	{
		return;
	}

	if ( ent->r.linked )
	{
		trap_UnlinkEntity( ent );
	}

	G_InitGentity( ent );
	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;

	ClientAdminChallenge( clientNum );

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset( &client->ps, 0, sizeof( client->ps ) );
	memset( &client->pmext, 0, sizeof( client->pmext ) );
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn( ent, NULL, NULL, NULL );

	trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 entered the game\n") ), Quote( client->pers.netname ) ) );

	trap_Cvar_VariableStringBuffer( "g_mapStartupMessage", startMsg, sizeof( startMsg ) );

	if ( *startMsg )
	{
		trap_SendServerCommand( ent - g_entities, va( "cpd %d %s", g_mapStartupMessageDelay.integer, Quote( startMsg ) ) );
	}

	G_namelog_restore( client );

	G_LogPrintf( "ClientBegin: %i\n", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();

	// send the client a list of commands that can be used
	if ( !client->pers.admin )
	{
		G_ListCommands( ent );
	}
}
Exemplo n.º 20
0
void G_BotListNames( gentity_t *ent )
{
	G_BotListTeamNames( ent, QQ( N_( "^3Alien bot names:" ) ), TEAM_ALIENS, "^1*" );
	G_BotListTeamNames( ent, QQ( N_( "^3Human bot names:" ) ), TEAM_HUMANS, "^5*" );
}
Exemplo n.º 21
0
/**
 * @brief Log deconstruct/destroy events
 * @param self
 * @param actor
 * @param mod
 */
void G_LogDestruction( gentity_t *self, gentity_t *actor, int mod )
{
	buildFate_t fate;

	switch ( mod )
	{
		case MOD_DECONSTRUCT:
			fate = BF_DECONSTRUCT;
			break;

		case MOD_REPLACE:
			fate = BF_REPLACE;
			break;

		case MOD_NOCREEP:
			fate = ( actor->client ) ? BF_UNPOWER : BF_AUTO;
			break;

		default:
			if ( actor->client )
			{
				if ( actor->client->pers.team ==
				     BG_Buildable( self->s.modelindex )->team )
				{
					fate = BF_TEAMKILL;
				}
				else
				{
					fate = BF_DESTROY;
				}
			}
			else
			{
				fate = BF_AUTO;
			}

			break;
	}

	G_BuildLogAuto( actor, self, fate );

	// don't log when marked structures are removed
	if ( mod == MOD_REPLACE )
	{
		return;
	}

	G_LogPrintf( S_COLOR_YELLOW "Deconstruct: %d %d %s %s: %s %s by %s\n",
	             ( int )( actor - g_entities ),
	             ( int )( self - g_entities ),
	             BG_Buildable( self->s.modelindex )->name,
	             modNames[ mod ],
	             BG_Buildable( self->s.modelindex )->humanName,
	             mod == MOD_DECONSTRUCT ? "deconstructed" : "destroyed",
	             actor->client ? actor->client->pers.netname : "<world>" );

	// No-power deaths for humans come after some minutes and it's confusing
	//  when the messages appear attributed to the deconner. Just don't print them.
	if ( mod == MOD_NOCREEP && actor->client &&
	     actor->client->pers.team == TEAM_HUMANS )
	{
		return;
	}

	if ( actor->client && actor->client->pers.team ==
	     BG_Buildable( self->s.modelindex )->team )
	{
		G_TeamCommand( (team_t) actor->client->pers.team,
		               va( "print_tr %s %s %s", mod == MOD_DECONSTRUCT ? QQ( N_("$1$ ^3DECONSTRUCTED^7 by $2$\n") ) :
						   QQ( N_("$1$ ^3DESTROYED^7 by $2$\n") ),
		                   Quote( BG_Buildable( self->s.modelindex )->humanName ),
		                   Quote( actor->client->pers.netname ) ) );
	}
}
Exemplo n.º 22
0
/*
===========
ClientUserInfoChanged

Called from ClientConnect when the player first connects and
directly by the server system when the player updates a userinfo variable.

The game can override any of the settings and call trap_SetUserinfo
if desired.
============
*/
const char *ClientUserinfoChanged( int clientNum, bool forceName )
{
	gentity_t *ent;
	const char      *s;
	char      model[ MAX_QPATH ];
	char      buffer[ MAX_QPATH ];
	char      oldname[ MAX_NAME_LENGTH ];
	char      newname[ MAX_NAME_LENGTH ];
	char      err[ MAX_STRING_CHARS ];
	bool  revertName = false;
	gclient_t *client;
	char      userinfo[ MAX_INFO_STRING ];

	ent = g_entities + clientNum;
	client = ent->client;

	trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );

	// check for malformed or illegal info strings
	if ( !Info_Validate( userinfo ) )
	{
		trap_SendServerCommand( ent - g_entities,
		                        "disconnect \"illegal or malformed userinfo\"" );
		trap_DropClient( ent - g_entities,
		                 "dropped: illegal or malformed userinfo" );
		return "Illegal or malformed userinfo";
	}
	// If their userinfo overflowed, tremded is in the process of disconnecting them.
	// If we send our own disconnect, it won't work, so just return to prevent crashes later
	//  in this function. This check must come after the Info_Validate call.
	else if ( !userinfo[ 0 ] )
	{
		return "Empty (overflowed) userinfo";
	}

	// stickyspec toggle
	s = Info_ValueForKey( userinfo, "cg_stickySpec" );
	client->pers.stickySpec = atoi( s ) != 0;

	// set name
	Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) );
	s = Info_ValueForKey( userinfo, "name" );
	G_ClientCleanName( s, newname, sizeof( newname ), client );

	if ( strcmp( oldname, newname ) )
	{
		if ( !forceName && client->pers.namelog->nameChangeTime &&
		     level.time - client->pers.namelog->nameChangeTime <=
		     g_minNameChangePeriod.value * 1000 )
		{
			trap_SendServerCommand( ent - g_entities, va(
			                          "print_tr %s %d", QQ( N_("Name change spam protection (g_minNameChangePeriod = $1$)") ),
			                          g_minNameChangePeriod.integer ) );
			revertName = true;
		}
		else if ( !forceName && g_maxNameChanges.integer > 0 &&
		          client->pers.namelog->nameChanges >= g_maxNameChanges.integer )
		{
			trap_SendServerCommand( ent - g_entities, va(
			                          "print_tr %s %d", QQ( N_("Maximum name changes reached (g_maxNameChanges = $1$)") ),
			                          g_maxNameChanges.integer ) );
			revertName = true;
		}
		else if ( !forceName && client->pers.namelog->muted )
		{
			trap_SendServerCommand( ent - g_entities,
			                        va( "print_tr %s", QQ( N_("You cannot change your name while you are muted") ) ) );
			revertName = true;
		}
		else if ( !G_admin_name_check( ent, newname, err, sizeof( err ) ) )
		{
			trap_SendServerCommand( ent - g_entities, va( "print_tr %s %s %s", QQ( "$1t$ $2$" ), Quote( err ), Quote( newname ) ) );
			revertName = true;
		}
		else if ( Q_UTF8_Strlen( newname ) > MAX_NAME_CHARACTERS )
		{
			trap_SendServerCommand( ent - g_entities,
			                        va( "print_tr %s %d", QQ( N_("Name is too long! Must be less than $1$ characters.") ), MAX_NAME_CHARACTERS ) );
			revertName = true;

		}

		if ( revertName )
		{
			Q_strncpyz( client->pers.netname, *oldname ? oldname : G_UnnamedClientName( client ),
			            sizeof( client->pers.netname ) );
		}
		else
		{
			if( G_IsUnnamed( newname ) )
			{
				Q_strncpyz( client->pers.netname, G_UnnamedClientName( client ), sizeof( client->pers.netname ) );
			}
			else
			{
				Q_strncpyz( client->pers.netname, newname, sizeof( client->pers.netname ) );
			}

			if ( !forceName && client->pers.connected == CON_CONNECTED )
			{
				client->pers.namelog->nameChangeTime = level.time;
				client->pers.namelog->nameChanges++;
			}

			if ( *oldname )
			{
				G_LogPrintf( "ClientRename: %i [%s] (%s) \"%s^7\" -> \"%s^7\" \"%s^7\"",
				             clientNum, client->pers.ip.str, client->pers.guid,
				             oldname, client->pers.netname,
				             client->pers.netname );
			}
		}

		G_namelog_update_name( client );

		Info_SetValueForKey(userinfo, "name", client->pers.netname, false);
		trap_SetUserinfo(clientNum, userinfo);
	}

	if ( client->pers.classSelection == PCL_NONE )
	{
		//This looks hacky and frankly it is. The clientInfo string needs to hold different
		//model details to that of the spawning class or the info change will not be
		//registered and an axis appears instead of the player model. There is zero chance
		//the player can spawn with the battlesuit, hence this choice.
		Com_sprintf( buffer, MAX_QPATH, "%s/%s",  BG_ClassModelConfig( PCL_HUMAN_BSUIT )->modelName,
		             BG_ClassModelConfig( PCL_HUMAN_BSUIT )->skinName );
	}
	else
	{
		Com_sprintf( buffer, MAX_QPATH, "%s/%s",  BG_ClassModelConfig( client->pers.classSelection )->modelName,
		             BG_ClassModelConfig( client->pers.classSelection )->skinName );

		if ( BG_ClassModelConfig( client->pers.classSelection )->segmented )
		{
			client->ps.persistant[ PERS_STATE ] |= PS_NONSEGMODEL;
		}
		else
		{
			client->ps.persistant[ PERS_STATE ] &= ~PS_NONSEGMODEL;
		}
	}

	Q_strncpyz( model, buffer, sizeof( model ) );

	// wallwalk follow
	s = Info_ValueForKey( userinfo, "cg_wwFollow" );

	if ( atoi( s ) )
	{
		client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGFOLLOW;
	}
	else
	{
		client->ps.persistant[ PERS_STATE ] &= ~PS_WALLCLIMBINGFOLLOW;
	}

	// wallwalk toggle
	s = Info_ValueForKey( userinfo, "cg_wwToggle" );

	if ( atoi( s ) )
	{
		client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGTOGGLE;
	}
	else
	{
		client->ps.persistant[ PERS_STATE ] &= ~PS_WALLCLIMBINGTOGGLE;
	}

	// always sprint
	s = Info_ValueForKey( userinfo, "cg_sprintToggle" );

	if ( atoi( s ) )
	{
		client->ps.persistant[ PERS_STATE ] |= PS_SPRINTTOGGLE;
	}
	else
	{
		client->ps.persistant[ PERS_STATE ] &= ~PS_SPRINTTOGGLE;
	}

	// fly speed
	s = Info_ValueForKey( userinfo, "cg_flySpeed" );

	if ( *s )
	{
		client->pers.flySpeed = atoi( s );
	}
	else
	{
		client->pers.flySpeed = BG_Class( PCL_NONE )->speed;
	}

	// disable blueprint errors
	s = Info_ValueForKey( userinfo, "cg_disableBlueprintErrors" );

	if ( atoi( s ) )
	{
		client->pers.disableBlueprintErrors = true;
	}
	else
	{
		client->pers.disableBlueprintErrors = false;
	}

	// teamInfo
	s = Info_ValueForKey( userinfo, "teamoverlay" );

	if ( atoi( s ) != 0 )
	{
		// teamoverlay was enabled so we need an update
		if ( client->pers.teamInfo == 0 )
		{
			client->pers.teamInfo = 1;
		}
	}
	else
	{
		client->pers.teamInfo = 0;
	}

	s = Info_ValueForKey( userinfo, "cg_unlagged" );

	if ( !s[ 0 ] || atoi( s ) != 0 )
	{
		client->pers.useUnlagged = true;
	}
	else
	{
		client->pers.useUnlagged = false;
	}

	Q_strncpyz( client->pers.voice, Info_ValueForKey( userinfo, "voice" ),
	            sizeof( client->pers.voice ) );

	// send over a subset of the userinfo keys so other clients can
	// print scoreboards, display models, and play custom sounds

	Com_sprintf( userinfo, sizeof( userinfo ),
	             "n\\%s\\t\\%i\\model\\%s\\ig\\%16s\\v\\%s",
	             client->pers.netname, client->pers.team, model,
	             Com_ClientListString( &client->sess.ignoreList ),
	             client->pers.voice );

	trap_SetConfigstring( CS_PLAYERS + clientNum, userinfo );

	/*G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, userinfo );*/

	return nullptr;
}
Exemplo n.º 23
0
void
MediaHandlerHaiku::cameraNames(std::vector<std::string>& /*names*/) const
{
    QQ(2);
    log_unimpl("Haiku: camera names");
}
Exemplo n.º 24
0
 void MessageReceived(BMessage *msg)
 {
     switch (msg->what)
     {
         case GNASH_PULSE:
             if (_mouse_moves_this_pulse > 3)
                 _gui->notifyMouseMove(_mousemovedx, _mousemovedy);
             _mouse_moves_this_pulse = 0;
             _gui->GnashPulse();
             if (B_OK != send_data(_pulse_tid, GNASH_SEND_PULSE, NULL, 0)) {
                 log_error(_("send_data failed"));
                 Quit();
             }
             break;
         case GNASH_RESIZE:
         {
             float width, height;
             if (msg->FindFloat("w", &width) != B_OK
                 || msg->FindFloat("h", &height) != B_OK)
                 QQ(1);
             else
                 _gui->resize_view(width+1, height+1);
             break;
         }
         case GNASH_HIDDEN:
         {
             _gui->Hidden();
             break;
         }
         case GNASH_SHOWN:
         {
             _gui->Shown();
             break;
         }
         case GNASH_SET_FULLSCREEN:
             _gui->setFullscreenEtc();
             break;
         case GNASH_UNSET_FULLSCREEN:
             _gui->unsetFullscreenEtc();
             break;
         case GNASH_MOUSE_CLICKED:
         {
             bool pressed;
             int32 mask;
             if (B_OK != msg->FindBool("pressed", &pressed)
                 || B_OK != msg->FindInt32("mask", &mask))
                 QQ(1);
             else
                 _gui->notifyMouseClick(pressed);
             break;
         }
         case GNASH_MOUSE_MOVED:
         {
             ++ _mouse_moves_this_pulse;
             int32 x, y;
             if (B_OK != msg->FindInt32("x", &x)
                 || B_OK != msg->FindInt32("y", &y))
                 QQ(1);
             else
             {
                 if (_mouse_moves_this_pulse > 3)
                 {
                     _mousemovedx = x;
                     _mousemovedy = y;
                 } else
                     _gui->notifyMouseMove(x, y);
             }
             break;
         }
         case GNASH_KEY_EVENT:
         {
             int32 key, modifiers;
             bool pressed;
             if (B_OK != msg->FindInt32("key", &key)
                 || B_OK != msg->FindInt32("modifiers", &modifiers)
                 || B_OK != msg->FindBool("pressed", &pressed))
                 QQ(1);
             else
                 _gui->notify_key_event(static_cast<gnash::key::code>(key), modifiers, pressed);
             break;
         }
         default:
             BApplication::MessageReceived(msg);
     };
 }
Exemplo n.º 25
0
bool
HaikuAggGlue::prepDrawingArea(int width, int height, boost::uint32_t sdl_flags)
{
    (void) sdl_flags;

    assert(width > 0);
    assert(height > 0);
    if (_width == width && _height == height)
        QQ(1);
        //return true;

    int depth_bytes = _bpp / 8;  // TODO: <Udo> is this correct? Gives 1 for 15 bit modes!

    assert(_bpp % 8 == 0);

    boost::uint32_t rmask, gmask, bmask, amask;

    switch(_bpp) {
        case 32: // RGBA32
            // BGRA32?
            rmask = 0xFF;
            gmask = 0xFF << 8;
            bmask = 0xFF << 16;
            amask = 0xFF << 24;
            break;
        case 24: // RGB24
            rmask = 0xFF;
            gmask = 0xFF << 8;
            bmask = 0xFF << 16;
            amask = 0;
            break;
        case 16: // RGB565: 5 bits for red, 6 bits for green, and 5 bits for blue
            rmask = 0x1F << 11;
            gmask = 0x3F << 5;
            bmask = 0x1F;
            amask = 0;
            break;
        default:
            abort();
    }

#define CHUNK_SIZE (100 * 100 * depth_bytes)

    int bufsize = static_cast<int>(width * height * depth_bytes / CHUNK_SIZE + 1) * CHUNK_SIZE;

    if (_xid != 0)
    {
        int pagesize = getpagesize();
        bufsize = ((bufsize + pagesize - 1) / pagesize) * pagesize;
    }

    if (_bufsize != (unsigned)bufsize)
    {
        if (_xid != 0 && _bufsize != 0)
        {
            if (msync(_sharebuf, _bufsize, MS_INVALIDATE) != 0)
                perror("msync");
            if (munmap(_sharebuf, _bufsize) != 0)
                perror("munmap");
        }

        delete [] _offscreenbuf;
        _bufsize = bufsize;
        _offscreenbuf = new unsigned char[bufsize];
        //BlankScreen();

        if (_xid != 0)
        {
	        if (ftruncate(_sharefd, _bufsize) != 0)
		        perror("ftruncate");
            _sharebuf =
                static_cast<unsigned char*>(
                mmap(
                    (caddr_t)0,
                    _bufsize,
                    PROT_READ|PROT_WRITE,
                    MAP_SHARED,
                    _sharefd,
                    0
            ));
            if (_sharebuf == (void*) -1)
            {
                perror("mmap");
                exit(1);
            }
            memset(_sharebuf, 0xcc, _bufsize);
        }

        log_debug (_("SDL-AGG: %i byte offscreen buffer allocated"), bufsize);
    }
    _width = width;
    _height = height;


    // Only the AGG renderer has the function init_buffer, which is *not* part of
    // the renderer api. It allows us to change the renderers movie size (and buffer
    // address) during run-time.
    Renderer_agg_base * renderer =
        static_cast<Renderer_agg_base *>(_agg_renderer);
    renderer->init_buffer(_offscreenbuf, bufsize, width, height,
            width*((_bpp+7)/8));

    if (_view != NULL)
        ViewNeeded();

    _validbounds.setTo(0, 0, width-1, height-1);

    return true;
}
Exemplo n.º 26
0
HaikuGui::HaikuGui(unsigned long xid, float scale, bool loop, RunResources& r)
    : Gui(xid, scale, loop, r), _app(NULL),
      _glue(this, xid), _timeout(0)
{
    QQ(8);
}
Exemplo n.º 27
0
//////////////////////////////////////////////////////
//Inputs  H          - the channel matrix
//        NUM_TX     - the number of transmit antennas
//        NUM_RX     - the number of receive antennas
//        Equalized  - the received equalized vector
//        difference - the difference between Equalized and Eq_bits
//        PAM        - the symbol constellation
//Outputs tester     - # times the SD goes through the main loop
//        return (best_bits) - the vector of symbols that are ML
//////////////////////////////////////////////////////
Matrix sphere_decoder(Matrix H, int NUM_TX, int NUM_RX, Matrix Equalized, 
					  Matrix difference, int PAM, int & tester)
{
	Matrix QQ(NUM_RX,NUM_TX);
	Matrix R(NUM_TX,NUM_TX);
	
	//now do the QR factorization of H
	QR(QQ,R,H,NUM_TX,NUM_RX);

	Matrix Q(NUM_TX, NUM_TX);
	int j,k;
	for(j = 0; j< NUM_TX; j++)
	{
		for(k = 0; k< NUM_TX; k++)
		{
			if(k < j) Q(j,k) = 0;
			else if(j == k) Q(j,j) = R(j,j) * R(j,j);
			else Q(j,k) = R(j,k) / R(j,j);
		}
	}

	Matrix prod = R * difference;
	double d_2 = eSize(prod, NUM_TX);
	d_2 = d_2 * d_2 * 1.01;
	Matrix S = Equalized;
	Matrix T(NUM_TX,1);
	for(j = 0; j < NUM_TX; j++) T(j,0) = 0;

	T(NUM_TX-1,0) = d_2;
	int i = NUM_TX-1;

	//won't work if NUM_TX is more than 50
	int L[50];
	int u[50];

	double ep[50];
	int best_point[50];
	for(j= 0; j< NUM_TX; j++) best_point[j] = 0;
	L[i] = floor( sqrt( T(i,0)/Q(i,i) ) + S(i,0) );
	u[i] = ceil( -sqrt( T(i,0)/Q(i,i) ) + S(i,0) );
	if(L[i]%2 == 0) L[i]--;
	if(u[i]%2 == 0) u[i]++;
	adj_uL(PAM,u[i],L[i]);
	u[i] = u[i] - 2;
	tester = 0;
	while (1)
	{
		tester++;
		u[i] = u[i] + 2;
		if(u[i] > L[i])  //case: no more symbols at the layer
		{
			if(i == NUM_TX-1)
			{
				break;
			}
			i = i + 1;
			continue;
		}
		if(i>0)  //normal case for a symbol: move down to a lower layer
		{
			ep[i] = Equalized(i,0) - u[i];
			T(i-1,0) = T(i,0) - Q(i,i) * ( S(i,0) - u[i] ) * ( S(i,0) - u[i] );
			double sum_t = 0;
			for(j = i ; j < NUM_TX; j++)
				sum_t += Q(i-1,j) * ep[j];
			S(i-1,0) = Equalized(i-1,0) + sum_t;
			i = i - 1;
			L[i] = floor( sqrt( T(i,0)/Q(i,i) ) + S(i,0) );
			u[i] = ceil( -sqrt( T(i,0)/Q(i,i) ) + S(i,0) );
			if(L[i]%2 == 0) L[i]--;
			if(u[i]%2 == 0) u[i]++;
			adj_uL(PAM,u[i],L[i]);
			u[i] = u[i] - 2;
		}
		else   //case: lowest layer, see if the symbol has the smallest distance
		{
			double d_hat2 = T(NUM_TX-1,0) - T(0,0) + Q(0,0) 
				              * ( S(0,0) - u[0] ) * ( S(0,0) - u[0] );
			if(d_hat2 < d_2)  //case: smallest distance so far  
			{
				d_2 = d_hat2;
				for(j= 0; j< NUM_TX; j++) 
					best_point[j] = u[j];
				T(NUM_TX-1,0) = d_2;
				i = NUM_TX-1;
				L[i] = floor( sqrt( T(i,0)/Q(i,i) ) + S(i,0) );
				u[i] = ceil( -sqrt( T(i,0)/Q(i,i) ) + S(i,0) );
				if(L[i]%2 == 0) L[i]--;
				if(u[i]%2 == 0) u[i]++;
				adj_uL(PAM,u[i],L[i]);
				u[i] = u[i] - 2;
			}
		}
	} //END OF while(1)
	Matrix sphereBest(NUM_TX,1);
	for(j= 0; j< NUM_TX; j++) 
		sphereBest(j,0) = best_point[j];
	return sphereBest;
}
Exemplo n.º 28
0
/*
===========
ClientBotConnect

Cut-down version of ClientConnect.
Doesn't do things not relevant to bots (which are local GUIDless clients).
============
*/
const char *ClientBotConnect( int clientNum, bool firstTime, team_t team )
{
	const char      *userInfoError;
	gclient_t       *client;
	char            userinfo[ MAX_INFO_STRING ];
	gentity_t       *ent;

	ent = &g_entities[ clientNum ];
	client = &level.clients[ clientNum ];

	ent->client = client;
	memset( client, 0, sizeof( *client ) );

	trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );

	client->pers.localClient = true;
	G_AddressParse( "localhost", &client->pers.ip );

	Q_strncpyz( client->pers.guid, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", sizeof( client->pers.guid ) );
	client->pers.admin = nullptr;
	client->pers.pubkey_authenticated = true;
	client->pers.connected = CON_CONNECTING;

	// read or initialize the session data
	if ( firstTime )
	{
		G_InitSessionData( client, userinfo );
	}

	G_ReadSessionData( client );

	// get and distribute relevant parameters
	G_namelog_connect( client );
	userInfoError = ClientUserinfoChanged( clientNum, false );

	if ( userInfoError != nullptr )
	{
		return userInfoError;
	}

	ent->r.svFlags |= SVF_BOT;

	// can happen during reconnection
	if ( !ent->botMind )
	{
		G_BotSetDefaults( clientNum, team, client->sess.botSkill, client->sess.botTree );
	}

	G_LogPrintf( "ClientConnect: %i [%s] (%s) \"%s^7\" \"%s^7\" [BOT]",
	             clientNum, client->pers.ip.str[0] ? client->pers.ip.str : "127.0.0.1", client->pers.guid,
	             client->pers.netname,
	             client->pers.netname );

	// don't do the "xxx connected" messages if they were caried over from previous level
	if ( firstTime )
	{
		trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 connected") ),
		                                Quote( client->pers.netname ) ) );
	}

	// count current clients and rank for scoreboard
	CalculateRanks();

	return nullptr;
}
Exemplo n.º 29
0
/*
==================
player_die
==================
*/
void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int meansOfDeath )
{
	gentity_t *ent;
	int       anim;
	int       killer;
	int       i;
	const char *killerName, *obit;

	if ( self->client->ps.pm_type == PM_DEAD )
	{
		return;
	}

	if ( level.intermissiontime )
	{
		return;
	}

	self->client->ps.pm_type = PM_DEAD;
	self->suicideTime = 0;

	if ( attacker )
	{
		killer = attacker->s.number;

		if ( attacker->client )
		{
			killerName = attacker->client->pers.netname;
		}
		else
		{
			killerName = "<world>";
		}
	}
	else
	{
		killer = ENTITYNUM_WORLD;
		killerName = "<world>";
	}

	if ( meansOfDeath < 0 || meansOfDeath >= ARRAY_LEN( modNames ) )
	{
		// fall back on the number
		obit = va( "%d", meansOfDeath );
	}
	else
	{
		obit = modNames[ meansOfDeath ];
	}

	G_LogPrintf( "Die: %d %d %s: %s" S_COLOR_WHITE " killed %s\n",
	             killer,
	             ( int )( self - g_entities ),
	             obit,
	             killerName,
	             self->client->pers.netname );

	// deactivate all upgrades
	for ( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
	{
		BG_DeactivateUpgrade( i, self->client->ps.stats );
	}

	// broadcast the death event to everyone
	ent = G_NewTempEntity( self->r.currentOrigin, EV_OBITUARY );
	ent->s.eventParm = meansOfDeath;
	ent->s.otherEntityNum = self->s.number;
	ent->s.otherEntityNum2 = killer;
	ent->r.svFlags = SVF_BROADCAST; // send to everyone

	if ( attacker && attacker->client )
	{
		if ( ( attacker == self || OnSameTeam( self, attacker ) ) )
		{
			//punish team kills and suicides
			if ( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
			{
				G_AddCreditToClient( attacker->client, -ALIEN_TK_SUICIDE_PENALTY, qtrue );
				G_AddCreditsToScore( attacker, -ALIEN_TK_SUICIDE_PENALTY );
			}
			else if ( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
			{
				G_AddCreditToClient( attacker->client, -HUMAN_TK_SUICIDE_PENALTY, qtrue );
				G_AddCreditsToScore( attacker, -HUMAN_TK_SUICIDE_PENALTY );
			}
		}
		else if ( g_showKillerHP.integer )
		{
			trap_SendServerCommand( self - g_entities, va( "print_tr %s %s %3i", QQ( N_("Your killer, $1$^7, had $2$ HP.\n") ),
			                        Quote( killerName ),
			                        attacker->health ) );
		}
	}
	else if ( attacker->s.eType != ET_BUILDABLE )
	{
		if ( self->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
		{
			G_AddCreditsToScore( self, -ALIEN_TK_SUICIDE_PENALTY );
		}
		else if ( self->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
		{
			G_AddCreditsToScore( self, -HUMAN_TK_SUICIDE_PENALTY );
		}
	}

	// give credits for killing this player
	G_RewardAttackers( self );

	ScoreboardMessage( self );  // show scores

	// send updated scores to any clients that are following this one,
	// or they would get stale scoreboards
	for ( i = 0; i < level.maxclients; i++ )
	{
		gclient_t *client;

		client = &level.clients[ i ];

		if ( client->pers.connected != CON_CONNECTED )
		{
			continue;
		}

		if ( client->sess.spectatorState == SPECTATOR_NOT )
		{
			continue;
		}

		if ( client->sess.spectatorClient == self->s.number )
		{
			ScoreboardMessage( g_entities + i );
		}
	}

	VectorCopy( self->s.origin, self->client->pers.lastDeathLocation );

	self->takedamage = qfalse; // can still be gibbed

	self->s.weapon = WP_NONE;
	if ( self->client->noclip )
	{
		self->client->cliprcontents = CONTENTS_CORPSE;
	}
	else
	{
		self->r.contents = CONTENTS_CORPSE;
	}

	self->s.angles[ PITCH ] = 0;
	self->s.angles[ ROLL ] = 0;
	self->s.angles[ YAW ] = self->s.apos.trBase[ YAW ];
	LookAtKiller( self, inflictor, attacker );

	VectorCopy( self->s.angles, self->client->ps.viewangles );

	self->s.loopSound = 0;

	self->r.maxs[ 2 ] = -8;

	// don't allow respawn until the death anim is done
	// g_forcerespawn may force spawning at some later time
	self->client->respawnTime = level.time + 1700;

	// clear misc
	memset( self->client->ps.misc, 0, sizeof( self->client->ps.misc ) );

	{
		static int i;

		if ( !( self->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL ) )
		{
			switch ( i )
			{
				case 0:
					anim = BOTH_DEATH1;
					break;

				case 1:
					anim = BOTH_DEATH2;
					break;

				case 2:
				default:
					anim = BOTH_DEATH3;
					break;
			}
		}
		else
		{
			switch ( i )
			{
				case 0:
					anim = NSPA_DEATH1;
					break;

				case 1:
					anim = NSPA_DEATH2;
					break;

				case 2:
				default:
					anim = NSPA_DEATH3;
					break;
			}
		}

		self->client->ps.legsAnim =
		  ( ( self->client->ps.legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;

		if ( !( self->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL ) )
		{
			self->client->ps.torsoAnim =
			  ( ( self->client->ps.torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;
		}

		// use own entityid if killed by non-client to prevent uint8_t overflow
		G_AddEvent( self, EV_DEATH1 + i,
		            ( killer < MAX_CLIENTS ) ? killer : self - g_entities );

		// globally cycle through the different death animations
		i = ( i + 1 ) % 3;
	}

	trap_LinkEntity( self );

	self->client->pers.infoChangeTime = level.time;
}
Exemplo n.º 30
0
/*
===========
ClientBegin

Called when a client has finished connecting, and is ready
to be placed into the level. This will happen on every
level load and level restart, but doesn't happen on respawns.
============
*/
void ClientBegin( int clientNum )
{
	gentity_t       *ent;
	gclient_t       *client;
	int             flags;
	char            startMsg[ MAX_STRING_CHARS ];

	ent    = g_entities + clientNum;
	client = level.clients + clientNum;

	// ignore if client already entered the game
	if ( client->pers.connected != CON_CONNECTING )
	{
		return;
	}

	if ( ent->r.linked )
	{
		trap_UnlinkEntity( ent );
	}

	G_InitGentity( ent );

	// Create a basic client entity, will be replaced by a more specific one later.
	ent->entity = new ClientEntity({ent, client});

	ent->touch = 0;
	ent->pain = 0;
	ent->client = client;

	client->pers.connected = CON_CONNECTED;
	client->pers.enterTime = level.time;

	ClientAdminChallenge( clientNum );

	// save eflags around this, because changing teams will
	// cause this to happen with a valid entity, and we
	// want to make sure the teleport bit is set right
	// so the viewpoint doesn't interpolate through the
	// world to the new position
	flags = client->ps.eFlags;
	memset( &client->ps, 0, sizeof( client->ps ) );
	memset( &client->pmext, 0, sizeof( client->pmext ) );
	client->ps.eFlags = flags;

	// locate ent at a spawn point
	ClientSpawn( ent, nullptr, nullptr, nullptr );

	trap_SendServerCommand( -1, va( "print_tr %s %s", QQ( N_("$1$^7 entered the game") ), Quote( client->pers.netname ) ) );

	trap_Cvar_VariableStringBuffer( "g_mapStartupMessage", startMsg, sizeof( startMsg ) );

	if ( *startMsg )
	{
		trap_SendServerCommand( ent - g_entities, va( "cpd %d %s", g_mapStartupMessageDelay.integer, Quote( startMsg ) ) );
	}

	G_namelog_restore( client );

	G_LogPrintf( "ClientBegin: %i", clientNum );

	// count current clients and rank for scoreboard
	CalculateRanks();

	// display the help menu, if connecting the first time
	if ( !client->sess.seenWelcome )
	{
		client->sess.seenWelcome = 1;

		// 0 - don't show
		// 1 - always show to all
		// 2 - show only to unregistered
		switch ( g_showHelpOnConnection.integer )
		{
		case 0:
			if (0)
		default:
			if ( !client->pers.admin )
		case 1:
			G_TriggerMenu( client->ps.clientNum, MN_WELCOME );
		}
	}
}