Annotation of quake1/cl_main.c, revision 1.1.1.3

1.1       root        1: // cl_main.c  -- client main loop
                      2: 
                      3: #include "quakedef.h"
                      4: 
                      5: // we need to declare some mouse variables here, because the menu system
                      6: // references them even when on a unix system.
                      7: 
                      8: // these two are not intended to be set directly
                      9: cvar_t cl_name = {"_cl_name", "player", true};
                     10: cvar_t cl_color = {"_cl_color", "0", true};
                     11: 
                     12: cvar_t cl_shownet = {"cl_shownet","0"};        // can be 0, 1, or 2
                     13: cvar_t cl_nolerp = {"cl_nolerp","0"};
                     14: 
                     15: cvar_t lookspring = {"lookspring","0", true};
                     16: cvar_t lookstrafe = {"lookstrafe","0", true};
                     17: cvar_t sensitivity = {"sensitivity","3", true};
                     18: 
                     19: cvar_t m_pitch = {"m_pitch","0.022", true};
1.1.1.3 ! root       20: cvar_t m_yaw = {"m_yaw","0.022", true};
        !            21: cvar_t m_forward = {"m_forward","1", true};
        !            22: cvar_t m_side = {"m_side","0.8", true};
1.1       root       23: 
                     24: 
                     25: client_static_t        cls;
                     26: client_state_t cl;
                     27: // FIXME: put these on hunk?
                     28: efrag_t                        cl_efrags[MAX_EFRAGS];
                     29: entity_t               cl_entities[MAX_EDICTS];
                     30: entity_t               cl_static_entities[MAX_STATIC_ENTITIES];
                     31: lightstyle_t   cl_lightstyle[MAX_LIGHTSTYLES];
                     32: dlight_t               cl_dlights[MAX_DLIGHTS];
                     33: 
                     34: int                            cl_numvisedicts;
                     35: entity_t               *cl_visedicts[MAX_VISEDICTS];
                     36: 
                     37: /*
                     38: =====================
                     39: CL_ClearState
                     40: 
                     41: =====================
                     42: */
                     43: void CL_ClearState (void)
                     44: {
                     45:        int                     i;
                     46: 
                     47:        if (!sv.active)
                     48:                Host_ClearMemory ();
                     49: 
                     50: // wipe the entire cl structure
                     51:        memset (&cl, 0, sizeof(cl));
                     52: 
                     53:        SZ_Clear (&cls.message);
                     54: 
                     55: // clear other arrays  
                     56:        memset (cl_efrags, 0, sizeof(cl_efrags));
                     57:        memset (cl_entities, 0, sizeof(cl_entities));
                     58:        memset (cl_dlights, 0, sizeof(cl_dlights));
                     59:        memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
                     60:        memset (cl_temp_entities, 0, sizeof(cl_temp_entities));
                     61:        memset (cl_beams, 0, sizeof(cl_beams));
                     62: 
                     63: //
                     64: // allocate the efrags and chain together into a free list
                     65: //
                     66:        cl.free_efrags = cl_efrags;
                     67:        for (i=0 ; i<MAX_EFRAGS-1 ; i++)
                     68:                cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
                     69:        cl.free_efrags[i].entnext = NULL;
                     70: }
                     71: 
                     72: /*
                     73: =====================
                     74: CL_Disconnect
                     75: 
                     76: Sends a disconnect message to the server
                     77: This is also called on Host_Error, so it shouldn't cause any errors
                     78: =====================
                     79: */
                     80: void CL_Disconnect (void)
                     81: {
                     82: // stop sounds (especially looping!)
1.1.1.3 ! root       83:        S_StopAllSounds (true);
1.1       root       84:        
                     85: // bring the console down and fade the colors back to normal
                     86: //     SCR_BringDownConsole ();
                     87: 
                     88: // if running a local server, shut it down
                     89:        if (cls.demoplayback)
                     90:                CL_StopPlayback ();
                     91:        else if (cls.state == ca_connected)
                     92:        {
                     93:                if (cls.demorecording)
                     94:                        CL_Stop_f ();
                     95: 
                     96:                Con_DPrintf ("Sending clc_disconnect\n");
                     97:                SZ_Clear (&cls.message);
                     98:                MSG_WriteByte (&cls.message, clc_disconnect);
                     99:                NET_SendUnreliableMessage (cls.netcon, &cls.message);
                    100:                SZ_Clear (&cls.message);
                    101:                NET_Close (cls.netcon);
                    102: 
                    103:                cls.state = ca_disconnected;
                    104:                if (sv.active)
                    105:                        Host_ShutdownServer(false);
                    106:        }
                    107: 
1.1.1.3 ! root      108:        cls.demoplayback = cls.timedemo = false;
1.1       root      109:        cls.signon = 0;
                    110: }
                    111: 
                    112: void CL_Disconnect_f (void)
                    113: {
                    114:        CL_Disconnect ();
                    115:        if (sv.active)
                    116:                Host_ShutdownServer (false);
                    117: }
                    118: 
                    119: 
                    120: 
                    121: 
                    122: /*
                    123: =====================
                    124: CL_EstablishConnection
                    125: 
                    126: Host should be either "local" or a net address to be passed on
                    127: =====================
                    128: */
                    129: void CL_EstablishConnection (char *host)
                    130: {
                    131:        if (cls.state == ca_dedicated)
                    132:                return;
                    133: 
                    134:        if (cls.demoplayback)
                    135:                return;
                    136: 
                    137:        CL_Disconnect ();
                    138: 
                    139:        cls.netcon = NET_Connect (host);
                    140:        if (!cls.netcon)
                    141:                Host_Error ("CL_Connect: connect failed\n");
                    142:        Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
                    143:        
                    144:        cls.demonum = -1;                       // not in the demo loop now
                    145:        cls.state = ca_connected;
                    146:        cls.signon = 0;                         // need all the signon messages before playing
                    147: }
                    148: 
                    149: /*
                    150: =====================
                    151: CL_SignonReply
                    152: 
                    153: An svc_signonnum has been received, perform a client side setup
                    154: =====================
                    155: */
                    156: void CL_SignonReply (void)
                    157: {
                    158:        char    str[8192];
                    159: 
                    160: Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
                    161: 
                    162:        switch (cls.signon)
                    163:        {
                    164:        case 1:
                    165:                MSG_WriteByte (&cls.message, clc_stringcmd);
                    166:                MSG_WriteString (&cls.message, "prespawn");
                    167:                break;
                    168:                
                    169:        case 2:         
                    170:                MSG_WriteByte (&cls.message, clc_stringcmd);
1.1.1.3 ! root      171:                MSG_WriteString (&cls.message, va("name \"%s\"\n", cl_name.string));
1.1       root      172:        
                    173:                MSG_WriteByte (&cls.message, clc_stringcmd);
                    174:                MSG_WriteString (&cls.message, va("color %i %i\n", ((int)cl_color.value)>>4, ((int)cl_color.value)&15));
                    175:        
                    176:                MSG_WriteByte (&cls.message, clc_stringcmd);
                    177:                sprintf (str, "spawn %s", cls.spawnparms);
                    178:                MSG_WriteString (&cls.message, str);
                    179:                break;
                    180:                
                    181:        case 3: 
                    182:                MSG_WriteByte (&cls.message, clc_stringcmd);
                    183:                MSG_WriteString (&cls.message, "begin");
                    184:                Cache_Report ();                // print remaining memory
                    185:                break;
                    186:                
                    187:        case 4:
                    188:                SCR_EndLoadingPlaque ();                // allow normal screen updates
                    189:                break;
                    190:        }
                    191: }
                    192: 
                    193: /*
                    194: =====================
                    195: CL_NextDemo
                    196: 
                    197: Called to play the next demo in the demo loop
                    198: =====================
                    199: */
                    200: void CL_NextDemo (void)
                    201: {
                    202:        char    str[1024];
                    203: 
                    204:        if (cls.demonum == -1)
                    205:                return;         // don't play demos
                    206: 
                    207:        SCR_BeginLoadingPlaque ();
                    208: 
                    209:        if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS)
                    210:        {
                    211:                cls.demonum = 0;
                    212:                if (!cls.demos[cls.demonum][0])
                    213:                {
                    214:                        Con_Printf ("No demos listed with startdemos\n");
                    215:                        cls.demonum = -1;
                    216:                        return;
                    217:                }
                    218:        }
                    219: 
                    220:        sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]);
                    221:        Cbuf_InsertText (str);
                    222:        cls.demonum++;
                    223: }
                    224: 
                    225: /*
                    226: ==============
                    227: CL_PrintEntities_f
                    228: ==============
                    229: */
                    230: void CL_PrintEntities_f (void)
                    231: {
                    232:        entity_t        *ent;
                    233:        int                     i;
                    234:        
                    235:        for (i=0,ent=cl_entities ; i<cl.num_entities ; i++,ent++)
                    236:        {
                    237:                Con_Printf ("%3i:",i);
                    238:                if (!ent->model)
                    239:                {
                    240:                        Con_Printf ("EMPTY\n");
                    241:                        continue;
                    242:                }
                    243:                Con_Printf ("%s:%2i  (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n"
                    244:                ,ent->model->name,ent->frame, ent->origin[0], ent->origin[1], ent->origin[2], ent->angles[0], ent->angles[1], ent->angles[2]);
                    245:        }
                    246: }
                    247: 
                    248: 
                    249: /*
                    250: ===============
                    251: SetPal
                    252: 
                    253: Debugging tool, just flashes the screen
                    254: ===============
                    255: */
                    256: void SetPal (int i)
                    257: {
                    258: #if 0
                    259:        static int old;
                    260:        byte    pal[768];
                    261:        int             c;
                    262:        
                    263:        if (i == old)
                    264:                return;
                    265:        old = i;
                    266: 
                    267:        if (i==0)
                    268:                VID_SetPalette (host_basepal);
                    269:        else if (i==1)
                    270:        {
                    271:                for (c=0 ; c<768 ; c+=3)
                    272:                {
                    273:                        pal[c] = 0;
                    274:                        pal[c+1] = 255;
                    275:                        pal[c+2] = 0;
                    276:                }
                    277:                VID_SetPalette (pal);
                    278:        }
                    279:        else
                    280:        {
                    281:                for (c=0 ; c<768 ; c+=3)
                    282:                {
                    283:                        pal[c] = 0;
                    284:                        pal[c+1] = 0;
                    285:                        pal[c+2] = 255;
                    286:                }
                    287:                VID_SetPalette (pal);
                    288:        }
                    289: #endif
                    290: }
                    291: 
                    292: /*
                    293: ===============
                    294: CL_AllocDlight
                    295: 
                    296: ===============
                    297: */
1.1.1.3 ! root      298: dlight_t *CL_AllocDlight (int key)
1.1       root      299: {
                    300:        int             i;
                    301:        dlight_t        *dl;
1.1.1.3 ! root      302: 
        !           303: // first look for an exact key match
        !           304:        if (key)
        !           305:        {
        !           306:                dl = cl_dlights;
        !           307:                for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
        !           308:                {
        !           309:                        if (dl->key == key)
        !           310:                        {
        !           311:                                memset (dl, 0, sizeof(*dl));
        !           312:                                dl->key = key;
        !           313:                                return dl;
        !           314:                        }
        !           315:                }
        !           316:        }
        !           317: 
        !           318: // then look for anything else
1.1       root      319:        dl = cl_dlights;
                    320:        for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
                    321:        {
                    322:                if (dl->die < cl.time)
                    323:                {
                    324:                        memset (dl, 0, sizeof(*dl));
1.1.1.3 ! root      325:                        dl->key = key;
1.1       root      326:                        return dl;
                    327:                }
                    328:        }
1.1.1.3 ! root      329: 
        !           330:        dl = &cl_dlights[0];
        !           331:        memset (dl, 0, sizeof(*dl));
        !           332:        dl->key = key;
        !           333:        return dl;
1.1       root      334: }
                    335: 
                    336: 
                    337: /*
                    338: ===============
                    339: CL_DecayLights
                    340: 
                    341: ===============
                    342: */
                    343: void CL_DecayLights (void)
                    344: {
                    345:        int                     i;
                    346:        dlight_t        *dl;
                    347:        float           time;
                    348:        
                    349:        time = cl.time - cl.oldtime;
                    350: 
                    351:        dl = cl_dlights;
                    352:        for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
                    353:        {
                    354:                if (dl->die < cl.time || !dl->radius)
                    355:                        continue;
                    356:                
                    357:                dl->radius -= time*dl->decay;
                    358:                if (dl->radius < 0)
                    359:                        dl->radius = 0;
                    360:        }
                    361: }
                    362: 
                    363: 
                    364: /*
                    365: ===============
                    366: CL_LerpPoint
                    367: 
                    368: Determines the fraction between the last two messages that the objects
                    369: should be put at.
                    370: ===============
                    371: */
                    372: float  CL_LerpPoint (void)
                    373: {
                    374:        float   f, frac;
                    375: 
                    376:        f = cl.mtime[0] - cl.mtime[1];
                    377:        
                    378:        if (!f || cl_nolerp.value || cls.timedemo || sv.active)
                    379:        {
                    380:                cl.time = cl.mtime[0];
                    381:                return 1;
                    382:        }
                    383:                
                    384:        if (f > 0.1)
                    385:        {       // dropped packet, or start of demo
                    386:                cl.mtime[1] = cl.mtime[0] - 0.1;
                    387:                f = 0.1;
                    388:        }
                    389:        frac = (cl.time - cl.mtime[1]) / f;
                    390: //Con_Printf ("frac: %f\n",frac);
                    391:        if (frac < 0)
                    392:        {
                    393:                if (frac < -0.01)
                    394:                {
                    395: SetPal(1);
                    396:                        cl.time = cl.mtime[1];
                    397: //                             Con_Printf ("low frac\n");
                    398:                }
                    399:                frac = 0;
                    400:        }
                    401:        else if (frac > 1)
                    402:        {
                    403:                if (frac > 1.01)
                    404:                {
                    405: SetPal(2);
                    406:                        cl.time = cl.mtime[0];
                    407: //                             Con_Printf ("high frac\n");
                    408:                }
                    409:                frac = 1;
                    410:        }
                    411:        else
                    412:                SetPal(0);
                    413:                
                    414:        return frac;
                    415: }
                    416: 
                    417: 
                    418: /*
                    419: ===============
                    420: CL_RelinkEntities
                    421: ===============
                    422: */
                    423: void CL_RelinkEntities (void)
                    424: {
                    425:        entity_t        *ent;
                    426:        int                     i, j;
                    427:        float           frac, f, d;
                    428:        vec3_t          delta;
                    429:        float           bobjrotate;
                    430:        vec3_t          oldorg;
                    431:        dlight_t        *dl;
                    432: 
                    433: // determine partial update time       
                    434:        frac = CL_LerpPoint ();
                    435: 
                    436:        cl_numvisedicts = 0;
                    437: 
                    438: //
                    439: // interpolate player info
                    440: //
                    441:        for (i=0 ; i<3 ; i++)
                    442:                cl.velocity[i] = cl.mvelocity[1][i] + 
                    443:                        frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
                    444: 
                    445:        if (cls.demoplayback)
                    446:        {
                    447:        // interpolate the angles       
                    448:                for (j=0 ; j<3 ; j++)
                    449:                {
                    450:                        d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
                    451:                        if (d > 180)
                    452:                                d -= 360;
                    453:                        else if (d < -180)
                    454:                                d += 360;
                    455:                        cl.viewangles[j] = cl.mviewangles[1][j] + frac*d;
                    456:                }
                    457:        }
                    458:        
                    459:        bobjrotate = anglemod(100*cl.time);
                    460:        
                    461: // start on the entity after the world
                    462:        for (i=1,ent=cl_entities+1 ; i<cl.num_entities ; i++,ent++)
                    463:        {
                    464:                if (!ent->model)
                    465:                {       // empty slot
                    466:                        if (ent->forcelink)
                    467:                                R_RemoveEfrags (ent);   // just became empty
                    468:                        continue;
                    469:                }
                    470: 
                    471: // if the object wasn't included in the last packet, remove it
                    472:                if (ent->msgtime != cl.mtime[0])
                    473:                {
                    474:                        ent->model = NULL;
                    475:                        continue;
                    476:                }
                    477: 
                    478:                VectorCopy (ent->origin, oldorg);
                    479: 
                    480:                if (ent->forcelink)
                    481:                {       // the entity was not updated in the last message
                    482:                        // so move to the final spot
                    483:                        VectorCopy (ent->msg_origins[0], ent->origin);
                    484:                        VectorCopy (ent->msg_angles[0], ent->angles);
                    485:                }
                    486:                else
                    487:                {       // if the delta is large, assume a teleport and don't lerp
                    488:                        f = frac;
                    489:                        for (j=0 ; j<3 ; j++)
                    490:                        {
                    491:                                delta[j] = ent->msg_origins[0][j] - ent->msg_origins[1][j];
                    492:                                if (delta[j] > 100 || delta[j] < -100)
                    493:                                        f = 1;          // assume a teleportation, not a motion
                    494:                        }
                    495: 
                    496:                // interpolate the origin and angles
                    497:                        for (j=0 ; j<3 ; j++)
                    498:                        {
                    499:                                ent->origin[j] = ent->msg_origins[1][j] + f*delta[j];
                    500: 
                    501:                                d = ent->msg_angles[0][j] - ent->msg_angles[1][j];
                    502:                                if (d > 180)
                    503:                                        d -= 360;
                    504:                                else if (d < -180)
                    505:                                        d += 360;
                    506:                                ent->angles[j] = ent->msg_angles[1][j] + f*d;
                    507:                        }
                    508:                        
                    509:                }
                    510: 
                    511: // rotate binary objects locally
                    512:                if (ent->model->flags & EF_ROTATE)
                    513:                        ent->angles[1] = bobjrotate;
                    514: 
                    515:                if (ent->effects & EF_BRIGHTFIELD)
                    516:                        R_EntityParticles (ent);
1.1.1.3 ! root      517: #ifdef QUAKE2
        !           518:                if (ent->effects & EF_DARKFIELD)
        !           519:                        R_DarkFieldParticles (ent);
        !           520: #endif
1.1       root      521:                if (ent->effects & EF_MUZZLEFLASH)
                    522:                {
                    523:                        vec3_t          fv, rv, uv;
                    524: 
1.1.1.3 ! root      525:                        dl = CL_AllocDlight (i);
1.1       root      526:                        VectorCopy (ent->origin,  dl->origin);
                    527:                        dl->origin[2] += 16;
                    528:                        AngleVectors (ent->angles, fv, rv, uv);
                    529:                         
                    530:                        VectorMA (dl->origin, 18, fv, dl->origin);
                    531:                        dl->radius = 200 + (rand()&31);
                    532:                        dl->minlight = 32;
                    533:                        dl->die = cl.time + 0.1;
                    534:                }
                    535:                if (ent->effects & EF_BRIGHTLIGHT)
                    536:                {                       
1.1.1.3 ! root      537:                        dl = CL_AllocDlight (i);
1.1       root      538:                        VectorCopy (ent->origin,  dl->origin);
                    539:                        dl->origin[2] += 16;
                    540:                        dl->radius = 400 + (rand()&31);
                    541:                        dl->die = cl.time + 0.001;
                    542:                }
                    543:                if (ent->effects & EF_DIMLIGHT)
                    544:                {                       
1.1.1.3 ! root      545:                        dl = CL_AllocDlight (i);
1.1       root      546:                        VectorCopy (ent->origin,  dl->origin);
                    547:                        dl->radius = 200 + (rand()&31);
                    548:                        dl->die = cl.time + 0.001;
                    549:                }
1.1.1.3 ! root      550: #ifdef QUAKE2
        !           551:                if (ent->effects & EF_DARKLIGHT)
        !           552:                {                       
        !           553:                        dl = CL_AllocDlight (i);
        !           554:                        VectorCopy (ent->origin,  dl->origin);
        !           555:                        dl->radius = 200.0 + (rand()&31);
        !           556:                        dl->die = cl.time + 0.001;
        !           557:                        dl->dark = true;
        !           558:                }
        !           559:                if (ent->effects & EF_LIGHT)
        !           560:                {                       
        !           561:                        dl = CL_AllocDlight (i);
        !           562:                        VectorCopy (ent->origin,  dl->origin);
        !           563:                        dl->radius = 200;
        !           564:                        dl->die = cl.time + 0.001;
        !           565:                }
        !           566: #endif
1.1       root      567: 
                    568:                if (ent->model->flags & EF_GIB)
                    569:                        R_RocketTrail (oldorg, ent->origin, 2);
                    570:                else if (ent->model->flags & EF_ZOMGIB)
                    571:                        R_RocketTrail (oldorg, ent->origin, 4);
                    572:                else if (ent->model->flags & EF_TRACER)
                    573:                        R_RocketTrail (oldorg, ent->origin, 3);
                    574:                else if (ent->model->flags & EF_TRACER2)
                    575:                        R_RocketTrail (oldorg, ent->origin, 5);
                    576:                else if (ent->model->flags & EF_ROCKET)
                    577:                {
                    578:                        R_RocketTrail (oldorg, ent->origin, 0);
1.1.1.3 ! root      579:                        dl = CL_AllocDlight (i);
1.1       root      580:                        VectorCopy (ent->origin, dl->origin);
                    581:                        dl->radius = 200;
                    582:                        dl->die = cl.time + 0.01;
                    583:                }
                    584:                else if (ent->model->flags & EF_GRENADE)
                    585:                        R_RocketTrail (oldorg, ent->origin, 1);
                    586:                else if (ent->model->flags & EF_TRACER3)
                    587:                        R_RocketTrail (oldorg, ent->origin, 6);
                    588: 
                    589:                ent->forcelink = false;
1.1.1.3 ! root      590: 
        !           591:                if (i == cl.viewentity && !chase_active.value)
        !           592:                        continue;
        !           593: 
        !           594: #ifdef QUAKE2
        !           595:                if ( ent->effects & EF_NODRAW )
        !           596:                        continue;
        !           597: #endif
        !           598:                if (cl_numvisedicts < MAX_VISEDICTS)
1.1       root      599:                {
1.1.1.3 ! root      600:                        cl_visedicts[cl_numvisedicts] = ent;
        !           601:                        cl_numvisedicts++;
1.1       root      602:                }
                    603:        }
                    604: 
                    605: }
                    606: 
                    607: 
                    608: /*
                    609: ===============
                    610: CL_ReadFromServer
                    611: 
                    612: Read all incoming data from the server
                    613: ===============
                    614: */
                    615: int CL_ReadFromServer (void)
                    616: {
                    617:        int             ret;
                    618: 
                    619:        cl.oldtime = cl.time;
                    620:        cl.time += host_frametime;
                    621:        
                    622:        do
                    623:        {
                    624:                ret = CL_GetMessage ();
                    625:                if (ret == -1)
                    626:                        Host_Error ("CL_ReadFromServer: lost server connection");
                    627:                if (!ret)
                    628:                        break;
                    629:                
                    630:                cl.last_received_message = realtime;
                    631:                CL_ParseServerMessage ();
                    632:        } while (ret && cls.state == ca_connected);
                    633:        
                    634:        if (cl_shownet.value)
                    635:                Con_Printf ("\n");
                    636: 
                    637:        CL_RelinkEntities ();
                    638:        CL_UpdateTEnts ();
                    639: 
                    640: //
                    641: // bring the links up to date
                    642: //
                    643:        return 0;
                    644: }
                    645: 
                    646: /*
                    647: =================
                    648: CL_SendCmd
                    649: =================
                    650: */
                    651: void CL_SendCmd (void)
                    652: {
                    653:        usercmd_t               cmd;
                    654: 
                    655:        if (cls.state != ca_connected)
                    656:                return;
                    657: 
                    658:        if (cls.signon == SIGNONS)
                    659:        {
                    660:        // get basic movement from keyboard
                    661:                CL_BaseMove (&cmd);
                    662:        
                    663:        // allow mice or other external controllers to add to the move
                    664:                IN_Move (&cmd);
                    665:        
                    666:        // send the unreliable message
                    667:                CL_SendMove (&cmd);
                    668:        
                    669:        }
                    670: 
                    671:        if (cls.demoplayback)
                    672:        {
                    673:                SZ_Clear (&cls.message);
                    674:                return;
                    675:        }
                    676:        
                    677: // send the reliable message
                    678:        if (!cls.message.cursize)
                    679:                return;         // no message at all
                    680:        
                    681:        if (!NET_CanSendMessage (cls.netcon))
                    682:        {
                    683:                Con_DPrintf ("CL_WriteToServer: can't send\n");
                    684:                return;
                    685:        }
                    686: 
                    687:        if (NET_SendMessage (cls.netcon, &cls.message) == -1)
                    688:                Host_Error ("CL_WriteToServer: lost server connection");
                    689: 
                    690:        SZ_Clear (&cls.message);
                    691: }
                    692: 
                    693: /*
                    694: =================
                    695: CL_Init
                    696: =================
                    697: */
                    698: void CL_Init (void)
                    699: {      
                    700:        SZ_Alloc (&cls.message, 1024);
                    701: 
                    702:        CL_InitInput ();
                    703:        CL_InitTEnts ();
                    704:        
                    705: //
                    706: // register our commands
                    707: //
                    708:        Cvar_RegisterVariable (&cl_name);
                    709:        Cvar_RegisterVariable (&cl_color);
                    710:        Cvar_RegisterVariable (&cl_upspeed);
                    711:        Cvar_RegisterVariable (&cl_forwardspeed);
                    712:        Cvar_RegisterVariable (&cl_backspeed);
                    713:        Cvar_RegisterVariable (&cl_sidespeed);
                    714:        Cvar_RegisterVariable (&cl_movespeedkey);
                    715:        Cvar_RegisterVariable (&cl_yawspeed);
                    716:        Cvar_RegisterVariable (&cl_pitchspeed);
                    717:        Cvar_RegisterVariable (&cl_anglespeedkey);
                    718:        Cvar_RegisterVariable (&cl_shownet);
                    719:        Cvar_RegisterVariable (&cl_nolerp);
                    720:        Cvar_RegisterVariable (&lookspring);
                    721:        Cvar_RegisterVariable (&lookstrafe);
                    722:        Cvar_RegisterVariable (&sensitivity);
                    723: 
                    724:        Cvar_RegisterVariable (&m_pitch);
                    725:        Cvar_RegisterVariable (&m_yaw);
                    726:        Cvar_RegisterVariable (&m_forward);
                    727:        Cvar_RegisterVariable (&m_side);
                    728: 
                    729: //     Cvar_RegisterVariable (&cl_autofire);
                    730:        
                    731:        Cmd_AddCommand ("entities", CL_PrintEntities_f);
                    732:        Cmd_AddCommand ("disconnect", CL_Disconnect_f);
                    733:        Cmd_AddCommand ("record", CL_Record_f);
                    734:        Cmd_AddCommand ("stop", CL_Stop_f);
                    735:        Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
                    736:        Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
                    737: }
                    738: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.