Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

EXT CSQC

From Quake Wiki

Revision as of 18:10, 17 January 2008 by KrimZon (talk | contribs)

Introduction

QuakeC code is normally run only on the server as a progs.dat file. Engines which support the EXT_CSQC extension run QuakeC code on the client. This enables the mod to control certain extra features:

  • Customize the status bar.
  • Adjust models and draw extra things on models (even with only one entity on the server).
  • Implement prediction.
  • Override the FOV.
  • Launch sounds locally.
  • Implement what would otherwise require another QSG extension.


By standard, CSQC should be compiled into and loaded from a csprogs.dat. Engines can provide cvars to specify a different name but that isn't part of this extension.


EXT_CSQC is intended to replace as much of the fixed function engine code as possible, without requiring knowledge of the engine code mechanisms and in a way that is consistent with the existing style of QuakeC.


The extension defines the whole csprogs, as well as adding some builtins and constants on the server.


EXT_CSQC System Globals Fields and Builtins List lists the core features of EXT_CSQC on the client. The following sections in this article explain their use.

Overview

Client Programs Entry Points

CSQC_Draw

This function is required always, and overrides the engine drawing code. It orders the rendering of everything including views, scoreboards and huds. If the csqc were to simply return, nothing would be drawn. Areas that the function fails to draw over will contain undefined pixels.

Example code:

void() CSQC_Draw =
{
    R_ClearScene();       //wipe the scene, and apply the default rendering values.

    //These lines, if used, specifiy various global view properties to the engine.
    //The engine returns 0 if it accepted the command, and -1 if it had an error.
    //The names listed here are the basic set required for basic compatability.
    R_SetViewf(VF_MIN_X, 0);
    R_SetViewf(VF_MIN_Y, 0);
    R_SetViewf(VF_SIZE_X, cvar("vid_conwidth"));
    R_SetViewf(VF_SIZE_Y, cvar("vid_conheight"));
    R_SetViewf(VF_FOV, cvar("fov"));
    R_SetViewv(VF_ORIGIN, player_org);
    R_SetViewv(VF_ANGLES, player_ang);
    R_SetView(VF_DRAWWORLD, 1);
    R_SetView(VF_DRAWCROSSHAIR, 1);
    R_SetView(VF_DRAWENGINESBAR, 0);

    R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS); // Add any entities that the csqc does not know about

    R_DrawScene();        // draw the view

    csqc_drawsbar();       // call to a custom function drawing the status bar
 };