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

Difference between revisions of "EXT CSQC"

From Quake Wiki

(Overview)
(Client Programs Entry Points)
Line 5: Line 5:
 
boomerrang http://members.multimania.co.uk/spatbadveca/henti.com-644553.html henti.com  cartoon network porno http://members.multimania.co.uk/spatbadveca/www.ben10.com-652343.html www.ben10.com  cartoonnet work porn.com http://members.multimania.co.uk/spatbadveca/cartoonnetwork-ben-10-movie-642665.html ben 10 movie 2009  ben 10 movie http://members.multimania.co.uk/spatbadveca/ cartoonnetwork  ben 10 of cartoon network http://members.multimania.co.uk/spatbadveca/w.w.w.cartoonnetwork.hq.net-642510.html cartoonnetworkhq.netl  hiv cartoon http://members.multimania.co.uk/spatbadveca/extremesex.com-642461.html extremesex.coù  old cartoonetwork.com http://members.multimania.co.uk/spatbadveca/porn-new-cartoonnetwork.com-647300.html cartoon network porno  ben ten movie http://members.multimania.co.uk/spatbadveca/www.cartoonetwork-641403.html www.cartoonetwork  www.mom extremesex.com http://members.multimania.co.uk/spatbadveca/cartoonnetwork-638612.html wwww. cartoon. com  strange cosmos http://members.multimania.co.uk/spatbadveca/ben10.com-644329.html ben10.com/
 
boomerrang http://members.multimania.co.uk/spatbadveca/henti.com-644553.html henti.com  cartoon network porno http://members.multimania.co.uk/spatbadveca/www.ben10.com-652343.html www.ben10.com  cartoonnet work porn.com http://members.multimania.co.uk/spatbadveca/cartoonnetwork-ben-10-movie-642665.html ben 10 movie 2009  ben 10 movie http://members.multimania.co.uk/spatbadveca/ cartoonnetwork  ben 10 of cartoon network http://members.multimania.co.uk/spatbadveca/w.w.w.cartoonnetwork.hq.net-642510.html cartoonnetworkhq.netl  hiv cartoon http://members.multimania.co.uk/spatbadveca/extremesex.com-642461.html extremesex.coù  old cartoonetwork.com http://members.multimania.co.uk/spatbadveca/porn-new-cartoonnetwork.com-647300.html cartoon network porno  ben ten movie http://members.multimania.co.uk/spatbadveca/www.cartoonetwork-641403.html www.cartoonetwork  www.mom extremesex.com http://members.multimania.co.uk/spatbadveca/cartoonnetwork-638612.html wwww. cartoon. com  strange cosmos http://members.multimania.co.uk/spatbadveca/ben10.com-644329.html ben10.com/
  
==Client Programs Entry Points==
+
craftsman q 4.5 http://usilguepai.atspace.com/consumer-reports-ellipticals-1117769.html free consumer reports on ellipticals  thompson consumer electronis, inc http://usilguepai.atspace.com/henry-lever-action-.22-921777.html 22 henry lever action  craftsman 4.5 hp lawnmower http://usilguepai.atspace.com/dynamark.lawnmowers-1191630.html dynamark riding lawnmowers  www.action.act.gov .au http://usilguepai.atspace.com/winchester-lever-action-.410-910709.html lever action 410  bolt action .410 shotguns http://usilguepai.atspace.com/50-action-express-874300.html 50 action express  murrey lawnmowers http://usilguepai.atspace.com/410-bolt-action-shotguns-874741.html sears roebuck 410 bolt action  sears roebuck 410 bolt action http://usilguepai.atspace.com/toro-lawnmowers.com-910011.html riding lawn mowers co clare henry 22 lever action http://usilguepai.atspace.com/consumer-reports-.org-491078.html riding lawnmowers.com consumer reports  dynamark riding lawnmowers http://usilguepai.atspace.com/www.experion.com-consumer-771587.html experion.com/consumer  bushhog lawnmowers http://usilguepai.atspace.com/sears.com-lawnmowers-747431.html www.sears.com/lawnmowers
===CSQC_Init===
 
<pre>
 
void() CSQC_Init;
 
</pre>
 
This is called when the csprogs.dat is loaded into memory. It is here that sounds, models and images can be precached with precache_sound precache_model and precache_pic.
 
 
 
===CSQC_Shutdown===
 
<pre>
 
void() CSQC_Shutdown;
 
</pre>
 
This function is called before the csprogs is fully unloaded, both for shutdown and map change. It is possible to store data in cvars to read in after a map change in CSQC_Init, which is feasible in conjunction with the [[DP_CON_SET]] extension.
 
 
 
===CSQC_InputEvent===
 
<pre>
 
float(float event, float key, float ascii) CSQC_InputEvent;
 
float EVENT_KEYDOWN = 0;
 
float EVENT_KEYUP = 1;
 
float EVENT_MOUSEMOVE = 2;
 
</pre>
 
This function is called on keyboard and mouse events. The ''event'' parameter is one of the EVENT_ constants. For keyboard input the ''key'' parameter is the quake key code of the key that was pressed or depressed while ascii is the printable character. Potentially, ascii might be a full unicode char if the engine supports that, and is often 0 on keyup events or keydown events where escape or modifier keys etc were used.
 
For mouse input the 'key' parameter contains the x movement, while the ascii parameter contains the y movement, but in DP, you may be required to use the <tt>vector() getmousepos</tt> builtin instead.
 
 
 
The function returns FALSE if the engine should process the event, or TRUE if the engine should ignore it.
 
 
 
===CSQC_UpdateView===
 
<pre>
 
void(float swidth, float sheight) CSQC_UpdateView;
 
</pre>
 
This function 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:
 
<pre>
 
void(float swidth, float sheight) CSQC_UpdateView =
 
{
 
    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_SetView(VF_MIN_X, 0);
 
    R_SetView(VF_MIN_Y, 0);
 
    R_SetView(VF_SIZE_X, swidth);
 
    R_SetView(VF_SIZE_Y, sheight);
 
    R_SetView(VF_FOV, cvar("fov"));
 
    R_SetView(VF_ORIGIN, player_org); //if absent and the player's entity is sent via the regular protocols, the default is the player's entity origin
 
    R_SetView(VF_ANGLES, player_ang); //the default is the client's current view angle, plus idlescale stuff.
 
    R_SetView(VF_DRAWWORLD, 1);
 
    R_SetView(VF_DRAWCROSSHAIR, 1);
 
    R_SetView(VF_DRAWENGINESBAR, 0);
 
 
 
    // Add any entities that the csqc does not know about
 
    R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
 
 
 
    R_RenderScene();        // draw the view
 
 
 
    csqc_drawsbar();      // call to a custom function drawing the status bar
 
};
 
</pre>
 
 
 
R_SetView Parameters:
 
 
 
{|style="border:1px solid #000000"
 
|-
 
| Flag  || parameters || description
 
|-
 
| VF_MIN || vector    || Top-left corner of the viewport. Only _x and _y are used.
 
|-  
 
| VF_MIN_X || float    || Left edge of the viewport.
 
|-
 
| VF_MIN_Y || float    || Top edge of the viewport.
 
|-
 
| VF_SIZE || vector  || Width and height of the viewport. Only _x and _y are used.
 
|-
 
| VF_SIZE_X || float  || Width of the viewport.
 
|-
 
| VF_SIZE_Y || float  || Height of the viewport.
 
|-
 
| VF_VIEWPORT || vector, vector || Origin and size of the viewport.
 
|-
 
| VF_FOV || vector    || Field of view. Only _x and _y are used. Units are degrees for perspective projection.
 
|-
 
| VF_FOVX  || float  || Horizontal field of view in degrees.
 
|-
 
| VF_FOVY  || float  || Vertical field of view in degrees.
 
|-
 
| VF_ORIGIN || vector  || The position of the camera.
 
|-
 
| VF_ORIGIN_X || float ||
 
|-
 
| VF_ORIGIN_Y || float ||
 
|-
 
| VF_ORIGIN_Z || float ||
 
|-
 
| VF_DRAWWORLD || float || TRUE if the world model (bsp, all submodels and world entities and effects) are to be drawn, else FALSE. Default is TRUE.
 
|-
 
| VF_DRAWENGINESBAR || float || TRUE to draw the engine status bar (scoreboard, intermissions etc.), FALSE if you want to override it with your own code. Default is TRUE.
 
|-
 
| VF_DRAWCROSSHAIR || float || TRUE to draw the engine crosshair, FALSE to hide it or draw your own.
 
|-
 
|}
 
 
 
===CSQC_ConsoleCommand===
 
<pre>
 
float(string s) CSQC_ConsoleCommand;
 
</pre>
 
This function parses console commands entered on the client. The parameter ''s'' contains the entire string entered on the console.
 
 
 
The function must return TRUE if it parses the command or FALSE if it does not. Returning false causes the command to then be parsed by the engine, and will display an error message if the command is then not recognised.
 
 
 
Since the function is called before any engine parsing it is possible to override engine commands (for example +showscores and -showscores) which would be useful in building a custom status bar and scoreboard.
 
  
 
==Sending Data to the Client==
 
==Sending Data to the Client==

Revision as of 14:15, 14 January 2011

VDHSmi <a href="http://ydilhwzllcqc.com/">ydilhwzllcqc</a>, [url=http://kyeillnjzkac.com/]kyeillnjzkac[/url], [link=http://dpyiowgmxofs.com/]dpyiowgmxofs[/link], http://bcpombxxlepz.com/

Wx6sbQ <a href="http://fpbvymhmvpuw.com/">fpbvymhmvpuw</a>, [url=http://wjmdkfkedeqp.com/]wjmdkfkedeqp[/url], [link=http://spsjxzpdghwh.com/]spsjxzpdghwh[/link], http://axqbpjhksbxv.com/

boomerrang http://members.multimania.co.uk/spatbadveca/henti.com-644553.html henti.com cartoon network porno http://members.multimania.co.uk/spatbadveca/www.ben10.com-652343.html www.ben10.com cartoonnet work porn.com http://members.multimania.co.uk/spatbadveca/cartoonnetwork-ben-10-movie-642665.html ben 10 movie 2009 ben 10 movie http://members.multimania.co.uk/spatbadveca/ cartoonnetwork ben 10 of cartoon network http://members.multimania.co.uk/spatbadveca/w.w.w.cartoonnetwork.hq.net-642510.html cartoonnetworkhq.netl hiv cartoon http://members.multimania.co.uk/spatbadveca/extremesex.com-642461.html extremesex.coù old cartoonetwork.com http://members.multimania.co.uk/spatbadveca/porn-new-cartoonnetwork.com-647300.html cartoon network porno ben ten movie http://members.multimania.co.uk/spatbadveca/www.cartoonetwork-641403.html www.cartoonetwork www.mom extremesex.com http://members.multimania.co.uk/spatbadveca/cartoonnetwork-638612.html wwww. cartoon. com strange cosmos http://members.multimania.co.uk/spatbadveca/ben10.com-644329.html ben10.com/

craftsman q 4.5 http://usilguepai.atspace.com/consumer-reports-ellipticals-1117769.html free consumer reports on ellipticals thompson consumer electronis, inc http://usilguepai.atspace.com/henry-lever-action-.22-921777.html 22 henry lever action craftsman 4.5 hp lawnmower http://usilguepai.atspace.com/dynamark.lawnmowers-1191630.html dynamark riding lawnmowers www.action.act.gov .au http://usilguepai.atspace.com/winchester-lever-action-.410-910709.html lever action 410 bolt action .410 shotguns http://usilguepai.atspace.com/50-action-express-874300.html 50 action express murrey lawnmowers http://usilguepai.atspace.com/410-bolt-action-shotguns-874741.html sears roebuck 410 bolt action sears roebuck 410 bolt action http://usilguepai.atspace.com/toro-lawnmowers.com-910011.html riding lawn mowers co clare henry 22 lever action http://usilguepai.atspace.com/consumer-reports-.org-491078.html riding lawnmowers.com consumer reports dynamark riding lawnmowers http://usilguepai.atspace.com/www.experion.com-consumer-771587.html experion.com/consumer bushhog lawnmowers http://usilguepai.atspace.com/sears.com-lawnmowers-747431.html www.sears.com/lawnmowers

Sending Data to the Client

Stats

On the server

The AddStat builtin function is used to specify fields which will be automatically sent to the client whenever they change. This is done upon initialisation - it works in worldspawn().

void(float index, float type, .void field) AddStat = #232;

The index parameter is the index of the stat. Numbers 0-31 are reserved by the engine, so this parameter must be 32 or higher.

The type parameter is one of:

  • AS_FLOAT_TRUNCATED - sends the integer part of a float in a packed form. The field parameter must be a float.
  • AS_FLOAT - sends the whole float without any data loss. The field parameter must be a float.
  • AS_STRING - sends the first 16 characters of a string, requiring the space of 4 consecutive stats. The field parameter must be a string.
On the client

The function corresponding to the type parameter is used to retrieve the data, with the index corresponding to that of the server.

float (float statnum) getstat_float = #330;
float (float statnum) getstat_float_truncated = #331;
string (float statnum) getstat_string = #332;

Entities

On the server

The SendEntity function is used in conjunction with the .Version field. The .Version field should be incremented every time an update is desired. This causes the entity's SendEntity function to be called for every client that the entity is viewable to:

.float(entity viewer) SendEntity;

In this function, the entity which is being sent is self.

The viewer parameter is the client entity to whom the entity is being sent.

The return value should be TRUE if the entity is to be sent to that client, and FALSE if it not to be.

Inside this function, the core builtins WriteCoord, WriteAngle, WriteByte, WriteShort, WriteLong are used with the destination parameter MSG_ENTITY, indicating that the data is part of a CSQC entity update.

On the client

When an entity is received the function CSQC_Ent_Update is called. Here the CSQC core functions ReadCoord, ReadAngle, ReadByte, ReadShort, ReadLong are used to retrieve the data sent by the server. Any Writes that the server used must exactly match the Reads used by the client. No more, no less. The order must match too. You can use flags to conditionally send+receive fields.

void(float isnew) CSQC_Ent_Update;

If the entity does not yet exist it is created on the client and the isnew parameter is TRUE, otherwise FALSE. Basically, isnew says that the client called spawn() for you. The server entity may have previously been visible, just temporarily left the view.

The entity being created or updated is self. You would normally set the entity's drawmask to MASK_NORMAL and set or read a model/modelindex. You will need to animate and interpolate or predict the entity yourself.


If the entity is removed from the server it will also be removed from the client. The function CSQC_Ent_Remove is called on the client:

void() CSQC_Ent_Remove;

In this function, self is the entity to be removed, though it will not be removed automatically by the engine. This allows the mod to clean up any client-created entities associated with the one being removed. You will need to do remove(self) at some point, perhaps via a timer (useful if pvs culling is not in use for this entity).

Example Code
Please Note

Entity updates using this method are transmitted unreliably, meaning that there is no guarantee that a particular update may arrive before the next one supercedes it. This means each update should send the whole amount of data required - it is not possible to send some data as a delta of previously sent information. This is not so much of a problem because this extension allows far fewer updates to be sent.

Rendering Entities on the Client

Spawn your entity:

self = spawn();

Set a model/modelindex:

setmodel(self, "progs/player.mdl");

Set an origin:

setorigin(self, '0 0 0');

Set the drawmask to something that matches your call to addentities:

self.drawmask = MASK_NORMAL;

The entity is now visible.

Or you could do as above, but ignore the drawmask part and call:

addentity(self);

Rendering 2D HUD on the Client

An example can be found here: http://fteqw.svn.sourceforge.net/viewvc/fteqw/trunk/quakec/csqctest/src/cs/hud.qc?view=markup