1. This forum is in read-only mode.

sourse code

Discussion in 'Non-Emulation Help' started by kingofgamemasters777, Mar 13, 2008.

  1. kingofgamemasters777

    kingofgamemasters777 Well-Known Member

    can some one tell me how to build source code?
     
  2. Born2killx

    Born2killx Well-Known Member

    Please post in proper English. "Building source code" is more complicated than it seems. (Well, to me at least. Maybe not to l33t haxx0r3rz like Seph or Loonylion.) You can find some tutorials online.

    http://w3schools.com/
     
  3. Loonylion

    Loonylion Administrator Staff Member

    no-one can tell you how to build source from the information you've given.
     
  4. Born2killx

    Born2killx Well-Known Member

    Yeah, everything has source code. Quote from Posting And You...

     
  5. kingofgamemasters777

    kingofgamemasters777 Well-Known Member

    ok how about the quake one source code and i also wanted the basic guild lines on how to build all source code.
     
  6. Loonylion

    Loonylion Administrator Staff Member

    still not enough information, we need to know what OS you are using, what language the source is in...
     
  7. DorTheScripter

    DorTheScripter Well-Known Member

    Besides that, I also think that Emulation Technical Help, isn't quite the place for things of this nature...
     
  8. kingofgamemasters777

    kingofgamemasters777 Well-Known Member

    ok sorry im kinda new at this i am useing windows xp its quak1 and as for the langrage i dont know il just give u a sample:

    ok this one is titled cl_demo:
    */

    #include "quakedef.h"

    void CL_FinishTimeDemo (void);

    /*
    ==============================================================================

    DEMO CODE

    When a demo is playing back, all NET_SendMessages are skipped, and
    NET_GetMessages are read from the demo file.

    Whenever cl.time gets past the last received message, another message is
    read from the demo file.
    ==============================================================================
    */

    /*
    ==============
    CL_StopPlayback

    Called when a demo file runs out, or the user starts a game
    ==============
    */
    void CL_StopPlayback (void)
    {
    if (!cls.demoplayback)
    return;

    fclose (cls.demofile);
    cls.demoplayback = false;
    cls.demofile = NULL;
    cls.state = ca_disconnected;

    if (cls.timedemo)
    CL_FinishTimeDemo ();
    }

    /*
    ====================
    CL_WriteDemoMessage

    Dumps the current net message, prefixed by the length and view angles
    ====================
    */
    void CL_WriteDemoMessage (void)
    {
    int len;
    int i;
    float f;

    len = LittleLong (net_message.cursize);
    fwrite (&len, 4, 1, cls.demofile);
    for (i=0 ; i<3 ; i++)
    {
    f = LittleFloat (cl.viewangles);
    fwrite (&f, 4, 1, cls.demofile);
    }
    fwrite (net_message.data, net_message.cursize, 1, cls.demofile);
    fflush (cls.demofile);
    }

    /*
    ====================
    CL_GetMessage

    Handles recording and playback of demos, on top of NET_ code
    ====================
    */
    int CL_GetMessage (void)
    {
    int r, i;
    float f;

    if (cls.demoplayback)
    {
    // decide if it is time to grab the next message
    if (cls.signon == SIGNONS) // allways grab until fully connected
    {
    if (cls.timedemo)
    {
    if (host_framecount == cls.td_lastframe)
    return 0; // allready read this frame's message
    cls.td_lastframe = host_framecount;
    // if this is the second frame, grab the real td_starttime
    // so the bogus time on the first frame doesn't count
    if (host_framecount == cls.td_startframe + 1)
    cls.td_starttime = realtime;
    }
    else if ( /* cl.time > 0 && */ cl.time <= cl.mtime[0])
    {
    return 0; // don't need another message yet
    }
    }

    // get the next message
    fread (&net_message.cursize, 4, 1, cls.demofile);
    VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
    for (i=0 ; i<3 ; i++)
    {
    r = fread (&f, 4, 1, cls.demofile);
    cl.mviewangles[0] = LittleFloat (f);
    }

    net_message.cursize = LittleLong (net_message.cursize);
    if (net_message.cursize > MAX_MSGLEN)
    Sys_Error ("Demo message > MAX_MSGLEN");
    r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
    if (r != 1)
    {
    CL_StopPlayback ();
    return 0;
    }

    return 1;
    }

    while (1)
    {
    r = NET_GetMessage (cls.netcon);

    if (r != 1 && r != 2)
    return r;

    // discard nop keepalive message
    if (net_message.cursize == 1 && net_message.data[0] == svc_nop)
    Con_Printf ("<-- server to client keepalive\n");
    else
    break;
    }

    if (cls.demorecording)
    CL_WriteDemoMessage ();

    return r;
    }


    /*
    ====================
    CL_Stop_f

    stop recording a demo
    ====================
    */
    void CL_Stop_f (void)
    {
    if (cmd_source != src_command)
    return;

    if (!cls.demorecording)
    {
    Con_Printf ("Not recording a demo.\n");
    return;
    }

    // write a disconnect message to the demo file
    SZ_Clear (&net_message);
    MSG_WriteByte (&net_message, svc_disconnect);
    CL_WriteDemoMessage ();

    // finish up
    fclose (cls.demofile);
    cls.demofile = NULL;
    cls.demorecording = false;
    Con_Printf ("Completed demo\n");
    }

    /*
    ====================
    CL_Record_f

    record <demoname> <map> [cd track]
    ====================
    */
    void CL_Record_f (void)
    {
    int c;
    char name[MAX_OSPATH];
    int track;

    if (cmd_source != src_command)
    return;

    c = Cmd_Argc();
    if (c != 2 && c != 3 && c != 4)
    {
    Con_Printf ("record <demoname> [<map> [cd track]]\n");
    return;
    }

    if (strstr(Cmd_Argv(1), ".."))
    {
    Con_Printf ("Relative pathnames are not allowed.\n");
    return;
    }

    if (c == 2 && cls.state == ca_connected)
    {
    Con_Printf("Can not record - already connected to server\nClient demo recording must be started before connecting\n");
    return;
    }

    // write the forced cd track number, or -1
    if (c == 4)
    {
    track = atoi(Cmd_Argv(3));
    Con_Printf ("Forcing CD track to %i\n", cls.forcetrack);
    }
    else
    track = -1;

    sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));

    //
    // start the map up
    //
    if (c > 2)
    Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command);

    //
    // open the demo file
    //
    COM_DefaultExtension (name, ".dem");

    Con_Printf ("recording to %s.\n", name);
    cls.demofile = fopen (name, "wb");
    if (!cls.demofile)
    {
    Con_Printf ("ERROR: couldn't open.\n");
    return;
    }

    cls.forcetrack = track;
    fprintf (cls.demofile, "%i\n", cls.forcetrack);

    cls.demorecording = true;
    }


    /*
    ====================
    CL_PlayDemo_f

    play [demoname]
    ====================
    */
    void CL_PlayDemo_f (void)
    {
    char name[256];
    int c;
    qboolean neg = false;

    if (cmd_source != src_command)
    return;

    if (Cmd_Argc() != 2)
    {
    Con_Printf ("play <demoname> : plays a demo\n");
    return;
    }

    //
    // disconnect from server
    //
    CL_Disconnect ();

    //
    // open the demo file
    //
    strcpy (name, Cmd_Argv(1));
    COM_DefaultExtension (name, ".dem");

    Con_Printf ("Playing demo from %s.\n", name);
    COM_FOpenFile (name, &cls.demofile);
    if (!cls.demofile)
    {
    Con_Printf ("ERROR: couldn't open.\n");
    cls.demonum = -1; // stop demo loop
    return;
    }

    cls.demoplayback = true;
    cls.state = ca_connected;
    cls.forcetrack = 0;

    while ((c = getc(cls.demofile)) != '\n')
    if (c == '-')
    neg = true;
    else
    cls.forcetrack = cls.forcetrack * 10 + (c - '0');

    if (neg)
    cls.forcetrack = -cls.forcetrack;
    // ZOID, fscanf is evil
    // fscanf (cls.demofile, "%i\n", &cls.forcetrack);
    }

    /*
    ====================
    CL_FinishTimeDemo

    ====================
    */
    void CL_FinishTimeDemo (void)
    {
    int frames;
    float time;

    cls.timedemo = false;

    // the first frame didn't count
    frames = (host_framecount - cls.td_startframe) - 1;
    time = realtime - cls.td_starttime;
    if (!time)
    time = 1;
    Con_Printf ("%i frames %5.1f seconds %5.1f fps\n", frames, time, frames/time);
    }

    /*
    ====================
    CL_TimeDemo_f

    timedemo [demoname]
    ====================
    */
    void CL_TimeDemo_f (void)
    {
    if (cmd_source != src_command)
    return;

    if (Cmd_Argc() != 2)
    {
    Con_Printf ("timedemo <demoname> : gets demo speeds\n");
    return;
    }

    CL_PlayDemo_f ();

    // cls.td_starttime will be grabbed at the second frame of the demo, so
    // all the loading time doesn't get counted

    cls.timedemo = true;
    cls.td_startframe = host_framecount;
    cls.td_lastframe = -1; // get a new message this frame
    }

    and hears one more thats called asm_draw:
    */
    //
    // asm_draw.h
    //
    // Include file for asm drawing routines.
    //

    //
    // !!! note that this file must match the corresponding C structures at all
    // times !!!
    //

    // !!! if this is changed, it must be changed in r_local.h too !!!
    #define NEAR_CLIP 0.01

    // !!! if this is changed, it must be changed in r_local.h too !!!
    #define CYCLE 128

    // espan_t structure
    // !!! if this is changed, it must be changed in r_shared.h too !!!
    #define espan_t_u 0
    #define espan_t_v 4
    #define espan_t_count 8
    #define espan_t_pnext 12
    #define espan_t_size 16

    // sspan_t structure
    // !!! if this is changed, it must be changed in d_local.h too !!!
    #define sspan_t_u 0
    #define sspan_t_v 4
    #define sspan_t_count 8
    #define sspan_t_size 12

    // spanpackage_t structure
    // !!! if this is changed, it must be changed in d_polyset.c too !!!
    #define spanpackage_t_pdest 0
    #define spanpackage_t_pz 4
    #define spanpackage_t_count 8
    #define spanpackage_t_ptex 12
    #define spanpackage_t_sfrac 16
    #define spanpackage_t_tfrac 20
    #define spanpackage_t_light 24
    #define spanpackage_t_zi 28
    #define spanpackage_t_size 32

    // edge_t structure
    // !!! if this is changed, it must be changed in r_shared.h too !!!
    #define et_u 0
    #define et_u_step 4
    #define et_prev 8
    #define et_next 12
    #define et_surfs 16
    #define et_nextremove 20
    #define et_nearzi 24
    #define et_owner 28
    #define et_size 32

    // surf_t structure
    // !!! if this is changed, it must be changed in r_shared.h too !!!
    #define SURF_T_SHIFT 6
    #define st_next 0
    #define st_prev 4
    #define st_spans 8
    #define st_key 12
    #define st_last_u 16
    #define st_spanstate 20
    #define st_flags 24
    #define st_data 28
    #define st_entity 32
    #define st_nearzi 36
    #define st_insubmodel 40
    #define st_d_ziorigin 44
    #define st_d_zistepu 48
    #define st_d_zistepv 52
    #define st_pad 56
    #define st_size 64

    // clipplane_t structure
    // !!! if this is changed, it must be changed in r_local.h too !!!
    #define cp_normal 0
    #define cp_dist 12
    #define cp_next 16
    #define cp_leftedge 20
    #define cp_rightedge 21
    #define cp_reserved 22
    #define cp_size 24

    // medge_t structure
    // !!! if this is changed, it must be changed in model.h too !!!
    #define me_v 0
    #define me_cachededgeoffset 4
    #define me_size 8

    // mvertex_t structure
    // !!! if this is changed, it must be changed in model.h too !!!
    #define mv_position 0
    #define mv_size 12

    // refdef_t structure
    // !!! if this is changed, it must be changed in render.h too !!!
    #define rd_vrect 0
    #define rd_aliasvrect 20
    #define rd_vrectright 40
    #define rd_vrectbottom 44
    #define rd_aliasvrectright 48
    #define rd_aliasvrectbottom 52
    #define rd_vrectrightedge 56
    #define rd_fvrectx 60
    #define rd_fvrecty 64
    #define rd_fvrectx_adj 68
    #define rd_fvrecty_adj 72
    #define rd_vrect_x_adj_shift20 76
    #define rd_vrectright_adj_shift20 80
    #define rd_fvrectright_adj 84
    #define rd_fvrectbottom_adj 88
    #define rd_fvrectright 92
    #define rd_fvrectbottom 96
    #define rd_horizontalFieldOfView 100
    #define rd_xOrigin 104
    #define rd_yOrigin 108
    #define rd_vieworg 112
    #define rd_viewangles 124
    #define rd_ambientlight 136
    #define rd_size 140

    // mtriangle_t structure
    // !!! if this is changed, it must be changed in model.h too !!!
    #define mtri_facesfront 0
    #define mtri_vertindex 4
    #define mtri_size 16 // !!! if this changes, array indexing in !!!
    // !!! d_polysa.s must be changed to match !!!
    #define mtri_shift 4

    and just for feuter referans how do i know what language its in (i ant bothering with the spell check because of all this code)
     
  9. Loonylion

    Loonylion Administrator Staff Member

    it is C or C++. You have to know the language to be able to recognise it. To compile it you need a compiler, such as Borland C++ Builder or Microsoft Visual C++. Also you cannot compile a single file, you need all the libraries, header files, any linked files and the project file.

    You are well out of your depth.
     
  10. iamlegend

    iamlegend Well-Known Member

    Well well out of your depth...

    I suggest you go learn C++
    http://cplusplus.com has some good tutorials....

    Read up on game programming in general....

    Join a Quake modding community....
    They should be able to answer any questions you have
    Try http://quakedev.com

    Maybe, with a lot of hard work, in a few months you will be able to tackle the Quake engine....

    Good luck...
     
  11. kingofgamemasters777

    kingofgamemasters777 Well-Known Member

    wow it was more complicated that i thought i thought that i could just put the code in to notepad and then do save as but i guss i was way off
     
  12. Loonylion

    Loonylion Administrator Staff Member

    yes its complicated, and C++ is one of the most complicated programming languages.
     
  13. iamlegend

    iamlegend Well-Known Member

    You use NotePad to write the code (provided you know how)...
    But you still need a compiler to convert it to a language the computer can understand and execute...
     
  14. kingofgamemasters777

    kingofgamemasters777 Well-Known Member

    ahh i just figured it you could make a HTML file with it than you could make eney other file with it by just putting in the right extension with save as


    and is septh and loonylion like programmers or something?
     
  15. Born2killx

    Born2killx Well-Known Member

    HTML is not a programming language, and please do not use internet shorthand; you have been warned once already. And yeah, they are. :p
     
  16. iamlegend

    iamlegend Well-Known Member

    ....He didn't say it was....
    And anyway he's got the right idea...

    A C++ compiler will only compile a file with a .cpp or .h extension....because thats all it recognises
    (There's obviously different file types for different languages)
    In the same way a browser recognises a file with a .html/.htm extension
    as a html file...
     
  17. anandjones

    anandjones Well-Known Member

    You forgot .c extension. Most compilers can use that type.