topameng's profileQuake3 启示录PhotosBlogListsMore ![]() | Help |
|
|
May 20 quake3 rendercmdsquake3 对于ui,客户端执行渲染命令都是先写入rendercmd列表: November 15 winsock 10053这是个比较烦人的错误。不好遇到不好调试。而往往又不是软件的问题。 November 14 Quake 3 Network ProtocolThis document describes the network protocol that quake 3 uses to converse with clients and the outside world (query servers). Currently more of a work in progress. QueryTo query a server is very simple. Send a connectionless (UDP 对应服务器接收函数SV_ConnectionlessPacket) packet with 4 OOB header bytes (0xff) and the text string getstatus.(例如:NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" )) There are many sites which contain a thorough description of this so I won't go into details. Game Protocol 68 - used by 1.32All game packets are connectionless (UDP), but there is still a handshaking process which much occur before you are allowed to join the server. The client sends a challenge request (sometimes you need to send multiple requests before the server will respond). +------------+----------------+ | Header | Content | +------------+----------------+ | 0xffffffff | getchallenge | +------------+----------------+ If the server is able to accept more connections it will reply with. +------------+------------------------+ | Header | Content | +------------+------------------------+ | 0xffffffff | challengeResponse <ID> | +------------+------------------------+ Once the client has the <ID> it can send a connect request. However, the CS is huffman compressed in protocol 68 and is NOT clear text as indicated below. Protocol 43 uses the plain text version. +------------+----------------+ | Header | Content | +------------+----------------+ | 0xffffffff | connect "<CS>" | +------------+----------------+ If the connect is successful the server will reply with the following +------------+-----------------+ | Header | Content | +------------+-----------------+ | 0xffffffff | connectResponse | +------------+-----------------+ The server will now place you in the CNCT (connecting) state and start sending you game updates. This is where the communication gets substantially more difficult, so I warn you what follows may be incomplete and perhaps incorrect - although I hope not!. Client to Server
Client commands 0 - clc_bad 1 - clc_nop 2 - clc_move 3 - clc_moveNoDelta 4 - clc_clientCommand 5 - clc_EOF Server to Client
Server Commands 0 - svc_bad 1 - svc_nop 2 - svc_gamestate 3 - svc_configstring 4 - svc_baseline 5 - svc_serverCommand 6 - svc_download 7 - svc_snapshot 8 - svc_EOF Details(1) - Huffman compression using a predefined set of nodes to further reduce message length (detailed below). int msg_hData[256] = {
250315,// 0
41193,// 1
6292,// 2
7106,// 3
3730,// 4
3750,// 5
6110,// 6
23283,// 7
33317,// 8
6950,// 9
7838,// 10
9714,// 11
9257,// 12
17259,// 13
3949,// 14
1778,// 15
8288,// 16
1604,// 17
1590,// 18
1663,// 19
1100,// 20
1213,// 21
1238,// 22
1134,// 23
1749,// 24
1059,// 25
1246,// 26
1149,// 27
1273,// 28
4486,// 29
2805,// 30
3472,// 31
21819,// 32
1159,// 33
1670,// 34
1066,// 35
1043,// 36
1012,// 37
1053,// 38
1070,// 39
1726,// 40
888,// 41
1180,// 42
850,// 43
960,// 44
780,// 45
1752,// 46
3296,// 47
10630,// 48
4514,// 49
5881,// 50
2685,// 51
4650,// 52
3837,// 53
2093,// 54
1867,// 55
2584,// 56
1949,// 57
1972,// 58
940,// 59
1134,// 60
1788,// 61
1670,// 62
1206,// 63
5719,// 64
6128,// 65
7222,// 66
6654,// 67
3710,// 68
3795,// 69
1492,// 70
1524,// 71
2215,// 72
1140,// 73
1355,// 74
971,// 75
2180,// 76
1248,// 77
1328,// 78
1195,// 79
1770,// 80
1078,// 81
1264,// 82
1266,// 83
1168,// 84
965,// 85
1155,// 86
1186,// 87
1347,// 88
1228,// 89
1529,// 90
1600,// 91
2617,// 92
2048,// 93
2546,// 94
3275,// 95
2410,// 96
3585,// 97
2504,// 98
2800,// 99
2675,// 100
6146,// 101
3663,// 102
2840,// 103
14253,// 104
3164,// 105
2221,// 106
1687,// 107
3208,// 108
2739,// 109
3512,// 110
4796,// 111
4091,// 112
3515,// 113
5288,// 114
4016,// 115
7937,// 116
6031,// 117
5360,// 118
3924,// 119
4892,// 120
3743,// 121
4566,// 122
4807,// 123
5852,// 124
6400,// 125
6225,// 126
8291,// 127
23243,// 128
7838,// 129
7073,// 130
8935,// 131
5437,// 132
4483,// 133
3641,// 134
5256,// 135
5312,// 136
5328,// 137
5370,// 138
3492,// 139
2458,// 140
1694,// 141
1821,// 142
2121,// 143
1916,// 144
1149,// 145
1516,// 146
1367,// 147
1236,// 148
1029,// 149
1258,// 150
1104,// 151
1245,// 152
1006,// 153
1149,// 154
1025,// 155
1241,// 156
952,// 157
1287,// 158
997,// 159
1713,// 160
1009,// 161
1187,// 162
879,// 163
1099,// 164
929,// 165
1078,// 166
951,// 167
1656,// 168
930,// 169
1153,// 170
1030,// 171
1262,// 172
1062,// 173
1214,// 174
1060,// 175
1621,// 176
930,// 177
1106,// 178
912,// 179
1034,// 180
892,// 181
1158,// 182
990,// 183
1175,// 184
850,// 185
1121,// 186
903,// 187
1087,// 188
920,// 189
1144,// 190
1056,// 191
3462,// 192
2240,// 193
4397,// 194
12136,// 195
7758,// 196
1345,// 197
1307,// 198
3278,// 199
1950,// 200
886,// 201
1023,// 202
1112,// 203
1077,// 204
1042,// 205
1061,// 206
1071,// 207
1484,// 208
1001,// 209
1096,// 210
915,// 211
1052,// 212
995,// 213
1070,// 214
876,// 215
1111,// 216
851,// 217
1059,// 218
805,// 219
1112,// 220
923,// 221
1103,// 222
817,// 223
1899,// 224
1872,// 225
976,// 226
841,// 227
1127,// 228
956,// 229
1159,// 230
950,// 231
7791,// 232
954,// 233
1289,// 234
933,// 235
1127,// 236
3207,// 237
1020,// 238
927,// 239
1355,// 240
768,// 241
1040,// 242
745,// 243
952,// 244
805,// 245
1073,// 246
740,// 247
1013,// 248
805,// 249
1008,// 250
796,// 251
996,// 252
1057,// 253
11457,// 254
13504,// 255
};
(2) - XOR algorithm used by the server to decode the message content. #define CL_ENCODE_START 12 string = (byte *)clc.serverCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ]; if (string[index] > 127 || string[index] == '%') 3) - XOR algorithm used by the client to decode the message content. Notesdata has mixed endianess - is this right? Packet fragmentation is worked out using a sequencetNumber & FRAGMENT_BIT (where FRAGMENT_BIT is 1<<31) calculation. If fragmented, flip the bit to 0 to correct the sequence number. cl_shownet 1 - MSG_SIZE October 20 读取jpeg文件jpeglib 下载地址
quake3 使用的是这个lib的上一个版本,jpeg_stdio_src 函数略有变化。可以直接传递文件指针了。
quake3 有些奇怪,读取得是垂直翻转的jpeg图片. 可能在画图时通过顶点顺序进行了纠正。 正常读取jpeg 数据需要从底部向上读取(这段是错的,还是被一个老外代码忽悠的,郁闷) .不需要从底部读取。 quake3 jpeg 库读取的是RGBA像素格式。新的库是 RGB 格式。 有了库读取的代码很固定。基本没什么大的变化: cinfo.output_components 对于上面的库是3,即返回的*pic 是RGB格式。但 quake3 用的alpha版lib返回的是4.*pic 是RGBA格式。 static void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPARRAY buffer; /* Output row buffer */ int row_stride; /* physical row width in output buffer */ unsigned char *out; byte *bbuf; FILE* pFile = NULL;
if((pFile = fopen(filename, "rb")) == NULL)
{ MessageBox(hWnd, "Error loading jpg file.", "ERROR", MB_OK); return; } cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo); jpeg_stdio_src(&cinfo, pFile); (void) jpeg_read_header(&cinfo, TRUE); (void) jpeg_start_decompress(&cinfo); row_stride = cinfo.output_width * cinfo.output_components; out = (unsigned char*)malloc(cinfo.output_width*cinfo.output_height*cinfo.output_components); *pic = out;
*width = cinfo.output_width; *height = cinfo.output_height; while (cinfo.output_scanline < cinfo.output_height) { bbuf = ((out+(row_stride*cinfo.output_scanline))); buffer = &bbuf; (void) jpeg_read_scanlines(&cinfo, buffer, 1); } jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); fclose(pFile); } 演示代码地址:(opengl 版,改天用MFC实现一个) opengl : http://www.91files.com/?ADPDMNF5EKJG9GR3EBSQ 对于 dx9 不需要,dx9 支持 jpg png bmp dds 等等相当广泛的图形文件格式 October 17 quake3 技术随笔关于纹理压缩 r_ext_compressed_textures 开启纹理压缩,可以提高速度。和图像大小压缩不是一个概念 typedef enum { TC_NONE, TC_S3TC } textureCompression_t; 现在 directx9c 已经支持到了3dc技术 运行中显示控制台窗口 在运行时打开(按tab上面的~键),输入: viewlog 2 去掉CD-KEY菜单 去掉启动时CD 界面 修改 cl_ui.c 中函数 int CL_UISystemCalls( int *args ) { 。。。。。。。。 case UI_VERIFY_CDKEY: 。。。。。。。。 } 获得投影坐标系
qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); //规一化设备坐标到窗口坐标 GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); qglDisable( GL_CULL_FACE ); 设置之后就可以当成平面坐标系使用了:如下在(0,0,640,480) 区域画一张图片 glTexCoord2f(1.0f, 1.0f);
Huffman 压缩 使用动态huffman 网络压缩算法,但网络传输中不再修改编码。还是相当于静态huffman压缩 Mipmap 混合 OpenGL 通过glColorPointer 设置顶点颜色color,相当与 directx 顶点的 diffuse color。
对于半透明特效,如火、水。可以使用不用 alpha 的 jpg 纹理,图片火之外的颜色设为黑色,如下使用混合参数:
static qboolean ParseStage( shaderStage_t *stage, char **text ) // parse up to MAX_IMAGE_ANIMATIONS animations token = COM_ParseExt( text, qfalse );
如果不是放到3d游戏场景中,surfaceparm nomarks ,surfaceparm nolightmap ,cull none 三个可以不需要. 如放到 UI 某个界面。 注意 animMap 后面的参数中不能有回车。 shader 一条命令中的字符串是不允许回车存在的 animMap <播放频率> <依次要播放的图片,最多8个> textures/sfx/testfire // ************************************************* { } 一次消息循环调用了2次 Com_EventLoop 。一次在开头处理消息(大部分为键盘鼠标消息)。第二个为网络通讯后处理消息使网络消息能在当前帧内处理。 Com_EventLoop() -> Com_GetEvent() 首先查看 com_pushedEvents[] 中是否有消息。没有才通过 Com_GetRealEvent() 获得消息。 com_pushEvents 中的事件是 Com_Milliseconds()函数写入的。通过此函数即可获得当前时间,也可压入当前事件。防止当前函数调用时间过长影响事件相应速度 glTexImage2D 生成纹理函数,如果不支持自动 mipmap, 指定纹理滤波的参数必须是 GL_LINEAR. 否则没有图片。为白色图像 qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); quake3 主要参数说明4506版q3参数. 红色字为修改过的说明,参照英文或者 q3.1.32b 源代码 August 22 tga图像文件格式读取
quake3 中读取 tga 图像代码:
name 要加载的图片名称. 指向pic 返回的 tga 图片像素数据.width 返回图片宽度.height 返回图片高度
ri.FS_ReadFile 读取文件,并返回文件内容指针 ri.FS_FreeFile 释放文件内容缓存
ri.Malloc 分配内存
typedef struct _TargaHeader
{ unsigned char id_length, colormap_type, image_type; unsigned short colormap_index, colormap_length; unsigned char colormap_size; unsigned short x_origin, y_origin, width, height; unsigned char pixel_size, attributes; } TargaHeader; static void LoadTGA ( const char *name, byte **pic, int *width, int *height) { int columns, rows, numPixels; byte *pixbuf; int row, column; byte *buf_p; byte *buffer; TargaHeader targa_header; byte *targa_rgba; *pic = NULL;
// load the file
ri.FS_ReadFile ( ( char * ) name, (void **)&buffer); if (!buffer) { return; } buf_p = buffer;
targa_header.id_length = *buf_p++;
targa_header.colormap_type = *buf_p++; //如果colormap_type为0从18位开始为图像数据 targa_header.image_type = *buf_p++; // 第三个字节为文件类型 targa_header.colormap_index = LittleShort ( *(short *)buf_p ); //对于 win32 LittleShort 是空的宏
buf_p += 2; targa_header.colormap_length = LittleShort ( *(short *)buf_p ); buf_p += 2; targa_header.colormap_size = *buf_p++; targa_header.x_origin = LittleShort ( *(short *)buf_p ); //8 图像 x 坐标起始位置 buf_p += 2; targa_header.y_origin = LittleShort ( *(short *)buf_p ); //10 图像 y 坐标起始位置 buf_p += 2; targa_header.width = LittleShort ( *(short *)buf_p ); //12 图像宽度 buf_p += 2; targa_header.height = LittleShort ( *(short *)buf_p ); //14 图像高度 buf_p += 2; targa_header.pixel_size = *buf_p++; //16 图像每像素存储占用位(bit)数 targa_header.attributes = *buf_p++; //17 //2 - 未压缩的,rgb 图像 //3 - 未压缩的,黑白图像 //10 - runlength 编码的 rgb 图像 if (targa_header.image_type!=2&& targa_header.image_type!=10&& targa_header.image_type != 3 ) { ri.Error (ERR_DROP, "LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\n"); } //该字段的内容或者为 0 或者为 1,0 表示没有颜色表,1 表示颜色表存在.格式 2,3,10 是无颜色表的
if ( targa_header.colormap_type != 0 ) { ri.Error( ERR_DROP, "LoadTGA: colormaps not supported\n" ); } //图像每像素存储占用位(bit)数
if ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 ) { ri.Error (ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); } columns = targa_header.width;
rows = targa_header.height; numPixels = columns * rows; //像素个数 if (width)
*width = columns; if (height) *height = rows; targa_rgba = (byte *)ri.Malloc (numPixels*4); //分配内存保存图像像素数据
*pic = targa_rgba; if (targa_header.id_length != 0)
buf_p += targa_header.id_length; // skip TARGA image comment if ( targa_header.image_type==2 || targa_header.image_type == 3 )
{ // Uncompressed RGB or gray scale image for(row=rows-1; row>=0; row--) { pixbuf = targa_rgba + row*columns*4; for(column=0; column<columns; column++) { unsigned char red,green,blue,alphabyte; switch (targa_header.pixel_size) { case 8:
blue = *buf_p++; green = blue; red = blue; *pixbuf++ = red; *pixbuf++ = green; *pixbuf++ = blue; *pixbuf++ = 255; break; case 24:
blue = *buf_p++; green = *buf_p++; red = *buf_p++; *pixbuf++ = red; *pixbuf++ = green; *pixbuf++ = blue; *pixbuf++ = 255; break; case 32: blue = *buf_p++; //tga 存放像素以BGRA 顺序。我们需要转换为 RGBA 顺序 green = *buf_p++; red = *buf_p++; alphabyte = *buf_p++; *pixbuf++ = red; *pixbuf++ = green; *pixbuf++ = blue; *pixbuf++ = alphabyte; break; default: ri.Error( ERR_DROP, "LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name ); break; } } } } else if (targa_header.image_type==10) { // Runlength encoded RGB images unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j; red = 0;
green = 0; blue = 0; alphabyte = 0xff; for(row=rows-1; row>=0; row--)
{ pixbuf = targa_rgba + row*columns*4; for(column=0; column<columns; ) { packetHeader= *buf_p++; packetSize = 1 + (packetHeader & 0x7f); if (packetHeader & 0x80) { // run-length packet switch (targa_header.pixel_size) { case 24: blue = *buf_p++; green = *buf_p++; red = *buf_p++; alphabyte = 255; break; case 32: blue = *buf_p++; green = *buf_p++; red = *buf_p++; alphabyte = *buf_p++; break; default: ri.Error( ERR_DROP, "LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name ); break; } for(j=0;j<packetSize;j++)
{ *pixbuf++=red; *pixbuf++=green; *pixbuf++=blue; *pixbuf++=alphabyte; column++; if (column==columns) { // run spans across rows column=0; if (row>0) row--; else goto breakOut; pixbuf = targa_rgba + row*columns*4; } } } else { // non run-length packet for(j=0;j<packetSize;j++) { switch (targa_header.pixel_size) { case 24: blue = *buf_p++; green = *buf_p++; red = *buf_p++; *pixbuf++ = red; *pixbuf++ = green; *pixbuf++ = blue; *pixbuf++ = 255; break; case 32: blue = *buf_p++; green = *buf_p++; red = *buf_p++; alphabyte = *buf_p++; *pixbuf++ = red; *pixbuf++ = green; *pixbuf++ = blue; *pixbuf++ = alphabyte; break; default: ri.Error( ERR_DROP, "LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name ); break; } column++; if (column==columns) { // pixel packet run spans across rows column=0; if (row>0) row--; else goto breakOut; pixbuf = targa_rgba + row*columns*4; } } } } breakOut:; } } // instead we just print a warning if (targa_header.attributes & 0x20) { ri.Printf( PRINT_WARNING, "WARNING: '%s' TGA file header declares top-down image, ignoring\n", name); } ri.FS_FreeFile (buffer); } August 06 quake3 使用到的 opengl 函数说明对于opengl 扩展函数必须在初始化窗口结束后才能使用 wglGetProcAddress 获得 如果, 2.void ( APIENTRY * glClientActiveTextureARB )( GLenum texture ); 关闭多重纹理:禁用所有非GL_TEXTURE0_ARB层纹理,最后激活GL_TEXTURE0_ARB纹理 对应的头文件 qgl.h : quake 中采用 q+opengl函数名 替代被使用的opengl函数 extern void ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t ); /*opgl1.0版本扩展函数 为了方便指定包含多组纹理坐标的顶点数组,opengl提供了命令glClientActiveTexture。应用程序使用glTexCoordPointer()指定纹理坐标数组时,Opengl将这组纹理坐标分配给glClientActiveTexture指定的纹理单元 /* extern void ( APIENTRY * qglActiveTextureARB )( GLenum texture ); extern void ( APIENTRY * qglClientActiveTextureARB )( GLenum texture ); /* */ extern void ( APIENTRY * qglLockArraysEXT) (GLint, GLint); extern void ( APIENTRY * qglUnlockArraysEXT) (void); extern void ( APIENTRY * qglAccum )(GLenum op, GLfloat value); extern void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref); extern GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences); extern void ( APIENTRY * qglArrayElement )(GLint i); extern void ( APIENTRY * qglBegin )(GLenum mode); /* tells OpenGL to bind the named texture texture to a texture target 将纹理名字texture代表的纹理绑定到纹理目标上。 target: GL_TEXTURE_1D 或者 GL_TEXTURE_2D,代表纹理的维数 texture: 一个数字用来绑定并代表一个纹理目标。 使用它来切换纹理 */ extern void ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture); extern void ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); /* 混合方程: c = (src * sfactor) + (dst * dfactor)
例如:半透明效果 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); 设: dst = (1.0f,0.0f,0.0f,0.0f) red src = (0.0f,0.0f,1.0f,0.3f) blue sfactor = 源Alpha值 = 0.3f dfactor = 1 - 源Alpha值 = 1 - 0.3f 则最终混合后颜色: c = (blue * 0.3f) + (red * 0.7f) sfactor 是输入的片元颜色值混合参数。dfactor 是目前帧缓存中的像素颜色值混合参数 */ extern void ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor); extern void ( APIENTRY * qglCallList )(GLuint list); extern void ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists); /* 清空帧缓存。mask 可以设置为GL_COLOR_BUFFER_BIT 清空颜色缓存 GL_DEPTH_BUFFER_BIT 清空深度缓存 GL_STENCIL_BUFFER_BIT 清空模板缓存 例如: glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) */ extern void ( APIENTRY * qglClear )(GLbitfield mask); extern void ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); /* 指定glClear 清空颜色缓存时使用的颜色,取值范围 0.0-1.0 例如: qglClearColor( 1, 0, 0.5, 1 ) */ extern void ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); /*glClearDepth 指定 glClear 函数清除深度缓存使用的深度值 当调用glClear(GL_DEPTH_BUFFER_BIT)时清空深度缓存写入深度值depth,如果不通过glClearDepth设置,默认写入最大的深度值 例如: glClearDepth( 1.0f ) */ extern void ( APIENTRY * qglClearDepth )(GLclampd depth); extern void ( APIENTRY * qglClearIndex )(GLfloat c); extern void ( APIENTRY * qglClearStencil )(GLint s); extern void ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation); extern void ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue); extern void ( APIENTRY * qglColor3bv )(const GLbyte *v); extern void ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue); extern void ( APIENTRY * qglColor3dv )(const GLdouble *v); extern void ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue); extern void ( APIENTRY * qglColor3fv )(const GLfloat *v); extern void ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue); extern void ( APIENTRY * qglColor3iv )(const GLint *v); extern void ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue); extern void ( APIENTRY * qglColor3sv )(const GLshort *v); extern void ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue); extern void ( APIENTRY * qglColor3ubv )(const GLubyte *v); extern void ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue); extern void ( APIENTRY * qglColor3uiv )(const GLuint *v); extern void ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue); extern void ( APIENTRY * qglColor3usv )(const GLushort *v); extern void ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); extern void ( APIENTRY * qglColor4bv )(const GLbyte *v); extern void ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); extern void ( APIENTRY * qglColor4dv )(const GLdouble *v); extern void ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); extern void ( APIENTRY * qglColor4fv )(const GLfloat *v); extern void ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha); extern void ( APIENTRY * qglColor4iv )(const GLint *v); extern void ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha); extern void ( APIENTRY * qglColor4sv )(const GLshort *v); extern void ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); extern void ( APIENTRY * qglColor4ubv )(const GLubyte *v); extern void ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha); extern void ( APIENTRY * qglColor4uiv )(const GLuint *v); extern void ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha); extern void ( APIENTRY * qglColor4usv )(const GLushort *v); extern void ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); extern void ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode); /*提交颜色数组供OpenGL使用 size: 数据大小 . 如:4 type: 数据类型. 如:GL_UNSIGNED_BYTE ,颜色数据针对 GL_UNSIGNED_BYTE 做了优化。 stride: 如果数据是紧密连接指定其为0,否则为颜色数据之间的跨距 pointer: 数组的位置 例如: qglColorPointer( 4,GL_UNSIGNED_BYTE,0,colors); */ extern void ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); extern void ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); extern void ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); extern void ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); extern void ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); extern void ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); /* OpenGl 面剔除特性根据填充图元面对的方向决定是否将其丢弃,使用前需要掉用 glEnable(GL_CULL_FACE) mode 参数: GL_FRONT 剔除正面 GL_BACK 剔除背面 */ extern void ( APIENTRY * qglCullFace )(GLenum mode); extern void ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range); extern void ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures); /* 深度值比较,默认为 GL_LESS 如果片元窗口空间z值小于存储的在深度缓存中的值,片元将通过深度测试。 如果参数为GL_LEQUAL, 片元窗口空间z值小于或等于存储的在深度缓存中的值,片元将通过深度测试。 这在multipass中很有用。 例如: glDepthFunc( GL_LEQUAL ) */ extern void ( APIENTRY * qglDepthFunc )(GLenum func); /* 调用glDepthMask(GL_FALSE);可将深度缓冲区设置为只读形式。 调用glDepthMask(GL_TRUE);可将深度缓冲区设置为可读可写形式 画透明物体时必须将深度缓冲区设置为只读形式.防止深度缓冲起作用,不画透明物体后面的物体 */ extern void ( APIENTRY * qglDepthMask )(GLboolean flag); /* 深度缓冲区所存储的值范围在-1.0-1.0之间。这个函数允许把一个特定的线性深度值映射到一个标准范围的窗口z坐标。窗口z值的缺省范围是0到1,分别对应近和远裁剪平面 */ extern void ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar); extern void ( APIENTRY * qglDisable )(GLenum cap); extern void ( APIENTRY * qglDisableClientState )(GLenum array); /* 只用1个函数的调用就可以替代几个函数调用:glNormal glColor glVertex 等等 mode: 指定要被渲染的图元 first: 指定从已启用数组什么位置开始 count: 表示有多少个数组元素被提取 */ extern void ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count); /* 指定要写入的缓存,使用双缓存时,通常只绘制后缓存,并在绘制完成后交换缓存。 还可以指定要将立体图像(电子眼镜)渲染到那个缓存(GL*LEFT 和 GL*RIGHT),以及将图像渲染到辅助缓存(GL_AUXi)中 使用单缓存时,mode默认为 GL_FRONT, 使用双缓存时,mode 默认为GL_BACK */ extern void ( APIENTRY * qglDrawBuffer )(GLenum mode); /* 绘制单个Opengl图元,mode可以是任何合法的OpenGL图元类型:GL_POINTS GL_LINES GL_TRIANGLES count: 要渲染的索引个数 type: 是数组indeces的数据类型 indices 是一个索引数组 例如: qglDrawElements( GL_TRIANGLES,numIndexes,GL_UNSIGNED_INT,indexes ); */ extern void ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); extern void ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); extern void ( APIENTRY * qglEdgeFlag )(GLboolean flag); extern void ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer); extern void ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag); /* 设置Opengl特性的启用状态。 默认情况大多数OpenGL特性都被禁用,事实上只有两项特性默认被起用,抖动(GL_DITHER) 和多重采样(GL_MULTISMAPLE) 实际上游戏很多时候不需要抖动 GL_BLEND 混合 GL_DEPTH_TEST 深度测试 GL_LIGHTING 光照 GL_ALPHA_TEST 启用alpha测试 GL_CULL_FACE 启用面剔除 GL_TEXTURE_2D 启用2维纹理映射模式 例如: glEnable(GL_DEPTH_TEST) 启动深度测试 */ extern void ( APIENTRY * qglEnable )(GLenum cap); /* 启用Opengl客户端状态: array: GL_VERTEX_ARRAY 启用顶点数组 GL_NORMAL_ARRAY 启用法线数组 GL_TEXTURE_COORD_ARRAY 启用纹理坐标数组 GL_COLOR_ARRAY 启用颜色数组 */ extern void ( APIENTRY * qglEnableClientState )(GLenum array); extern void ( APIENTRY * qglEnd )(void); extern void ( APIENTRY * qglEndList )(void); extern void ( APIENTRY * qglEvalCoord1d )(GLdouble u); extern void ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u); extern void ( APIENTRY * qglEvalCoord1f )(GLfloat u); extern void ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u); extern void ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v); extern void ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u); extern void ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v); extern void ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u); extern void ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2); extern void ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); extern void ( APIENTRY * qglEvalPoint1 )(GLint i); extern void ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j); extern void ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer); /* The glFinish function does not return until the effects of all previously called OpenGL functions are complete. Such effects include all changes to the OpenGL state, all changes to the connection state, and all changes to the framebuffer contents. 阻塞直到Opengl 执行命令结束 */ extern void ( APIENTRY * qglFinish )(void); /* */ extern void ( APIENTRY * qglFlush )(void); extern void ( APIENTRY * qglFogf )(GLenum pname, GLfloat param); extern void ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params); extern void ( APIENTRY * qglFogi )(GLenum pname, GLint param); extern void ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params); extern void ( APIENTRY * qglFrontFace )(GLenum mode); extern void ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); extern GLuint ( APIENTRY * qglGenLists )(GLsizei range); extern void ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures); extern void ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params); extern void ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation); extern void ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params); /* 返回 Opengl 错误信息 GL_NO_ERROR 没有错误. 这个常量值为0 GL_INVALID_ENUM 向 Opengl 命令传递了无效的枚举值 GL_INVALID_VALUE 向 Opengl 传递的值不再允许的范围内 GL_INVALID_OPERATION 发出的Opengl 命令非法(就当前状态而言,此函数命令不合适) GL_STACK_OVERFLOW 命令导致Opengl堆栈溢出 GL_STACK_UNDERFLOW 命令导致Opengl堆栈下溢 GL_OUT_OF_MEMORY Opengl 无法分配足够的内存来处理命令 Opengl 错误是应用程序的bug,需要修改代码。在应用程序中,通常在初始化后面以及渲染动画中的每帧后调用glGetError().为了避免影响性能通常在非生产代码中调用它 如: assert(glGetError() == GL_NO_ERROR); */ extern GLenum ( APIENTRY * qglGetError )(void); extern void ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params); /* 查询特定的阀值 GL_MAX_TEXTURE_SIZE 查询支持的最大纹理大小 GL_MAX_TEXTURE_UNITS 查询支持的纹理单元个数 quake3 中重定义为 GL_MAX_ACTIVE_TEXTURES_ARB GL_MAX_ELEMENTS_VRTICES 最大支持的顶点数 GL_MAX_ELEMENTS_INDICES 最大支持的索引数 GL_MAX_LIGHTS 查询支持的最大灯光数量 */ extern void ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params); extern void ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params); extern void ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params); extern void ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v); extern void ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v); extern void ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v); extern void ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params); extern void ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params); extern void ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values); extern void ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values); extern void ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values); extern void ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params); extern void ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask); /* 查询信息 根据name的值返回不同的字符串值 GL_VENDOR: 返回OpenGL 实现的厂商 GL_VERSION:返回OpenGL 版本 GL_EXTENSISONS:返回OpenGL实现中可用的扩展 GL_RENDERER: 返回厂商特定的渲染器信息 必须具备渲染上下文时才能调用这个函数 */ extern const GLubyte * ( APIENTRY * qglGetString )(GLenum name); extern void ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params); extern void ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params); extern void ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params); extern void ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params); extern void ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params); extern void ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); extern void ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params); extern void ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params); extern void ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params); extern void ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params); extern void ( APIENTRY * qglHint )(GLenum target, GLenum mode); extern void ( APIENTRY * qglIndexMask )(GLuint mask); extern void ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); extern void ( APIENTRY * qglIndexd )(GLdouble c); extern void ( APIENTRY * qglIndexdv )(const GLdouble *c); extern void ( APIENTRY * qglIndexf )(GLfloat c); extern void ( APIENTRY * qglIndexfv )(const GLfloat *c); extern void ( APIENTRY * qglIndexi )(GLint c); extern void ( APIENTRY * qglIndexiv )(const GLint *c); extern void ( APIENTRY * qglIndexs )(GLshort c); extern void ( APIENTRY * qglIndexsv )(const GLshort *c); extern void ( APIENTRY * qglIndexub )(GLubyte c); extern void ( APIENTRY * qglIndexubv )(const GLubyte *c); extern void ( APIENTRY * qglInitNames )(void); extern void ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer); extern GLboolean ( APIENTRY * qglIsEnabled )(GLenum cap); extern GLboolean ( APIENTRY * qglIsList )(GLuint list); extern GLboolean ( APIENTRY * qglIsTexture )(GLuint texture); extern void ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param); extern void ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params); extern void ( APIENTRY * qglLightModeli )(GLenum pname, GLint param); extern void ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params); extern void ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param); extern void ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params); extern void ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param); extern void ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params); extern void ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern); extern void ( APIENTRY * qglLineWidth )(GLfloat width); extern void ( APIENTRY * qglListBase )(GLuint base); /* 修改当前活动矩阵堆栈的栈顶,将栈顶矩阵替换为单位矩阵 */ extern void ( APIENTRY * qglLoadIdentity )(void); /* 修改当前活动矩阵堆栈的栈顶,将栈顶矩阵替换为矩阵m */ extern void ( APIENTRY * qglLoadMatrixd )(const GLdouble *m); //同上 extern void ( APIENTRY * qglLoadMatrixf )(const GLfloat *m); extern void ( APIENTRY * qglLoadName )(GLuint name); extern void ( APIENTRY * qglLogicOp )(GLenum opcode); extern void ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); extern void ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); extern void ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); extern void ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); extern void ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2); extern void ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2); extern void ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); extern void ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); extern void ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param); extern void ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params); extern void ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param); extern void ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params); /* mode 可以为 GL_PROJECTION GL_MODELVIEW 或 GL_TEXTURE 选择活动矩阵堆栈: GL_PROJECTION 选择投影矩阵堆栈 GL_MODELVIEW 选择模型视点矩阵堆栈 */ extern void ( APIENTRY * qglMatrixMode )(GLenum mode); extern void ( APIENTRY * qglMultMatrixd )(const GLdouble *m); extern void ( APIENTRY * qglMultMatrixf )(const GLfloat *m); extern void ( APIENTRY * qglNewList )(GLuint list, GLenum mode); extern void ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz); extern void ( APIENTRY * qglNormal3bv )(const GLbyte *v); extern void ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz); extern void ( APIENTRY * qglNormal3dv )(const GLdouble *v); extern void ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz); extern void ( APIENTRY * qglNormal3fv )(const GLfloat *v); extern void ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz); extern void ( APIENTRY * qglNormal3iv )(const GLint *v); extern void ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz); extern void ( APIENTRY * qglNormal3sv )(const GLshort *v); extern void ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); extern void ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); extern void ( APIENTRY * qglPassThrough )(GLfloat token); extern void ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values); extern void ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values); extern void ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values); extern void ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param); extern void ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param); extern void ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param); extern void ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param); extern void ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor); extern void ( APIENTRY * qglPointSize )(GLfloat size); /* Opengl可以将填充图元渲染为线段或点。 mode 可以为 GL_POINT 绘制点 GL_LINE 绘制多边形线框 GL_FILL填充多边形 face 可以为 GL_FONT GL_BACK GL_FONT_AND_BACK 它指定用于正面图元,背面图元还是两者 glPloygonMode(GL_FONT_AND_BACK,GL_FILL) */ extern void ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode); extern void ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units); extern void ( APIENTRY * qglPolygonStipple )(const GLubyte *mask); //glPopAttrib此函数未使用 extern void ( APIENTRY * qglPopAttrib )(void); //glPopClientAttrib 此函数未使用 extern void ( APIENTRY * qglPopClientAttrib )(void); extern void ( APIENTRY * qglPopMatrix )(void); extern void ( APIENTRY * qglPopName )(void); extern void ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities); //此函数未使用 extern void ( APIENTRY * qglPushAttrib )(GLbitfield mask); //此函数未使用 extern void ( APIENTRY * qglPushClientAttrib )(GLbitfield mask); extern void ( APIENTRY * qglPushMatrix )(void); extern void ( APIENTRY * qglPushName )(GLuint name); extern void ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y); extern void ( APIENTRY * qglRasterPos2dv )(const GLdouble *v); extern void ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y); extern void ( APIENTRY * qglRasterPos2fv )(const GLfloat *v); extern void ( APIENTRY * qglRasterPos2i )(GLint x, GLint y); extern void ( APIENTRY * qglRasterPos2iv )(const GLint *v); extern void ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y); extern void ( APIENTRY * qglRasterPos2sv )(const GLshort *v); extern void ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z); extern void ( APIENTRY * qglRasterPos3dv )(const GLdouble *v); extern void ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z); extern void ( APIENTRY * qglRasterPos3fv )(const GLfloat *v); extern void ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z); extern void ( APIENTRY * qglRasterPos3iv )(const GLint *v); extern void ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z); extern void ( APIENTRY * qglRasterPos3sv )(const GLshort *v); extern void ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); extern void ( APIENTRY * qglRasterPos4dv )(const GLdouble *v); extern void ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); extern void ( APIENTRY * qglRasterPos4fv )(const GLfloat *v); extern void ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w); extern void ( APIENTRY * qglRasterPos4iv )(const GLint *v); extern void ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w); extern void ( APIENTRY * qglRasterPos4sv )(const GLshort *v); extern void ( APIENTRY * qglReadBuffer )(GLenum mode); extern void ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); extern void ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); extern void ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2); extern void ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); extern void ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2); extern void ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2); extern void ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2); extern void ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2); extern void ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2); extern GLint ( APIENTRY * qglRenderMode )(GLenum mode); extern void ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); extern void ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); extern void ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z); extern void ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z); /* 裁剪测试,可以定义窗口中的一个矩形区域,并将作图限制在其中。若片元部分落在该矩形区,则剪取测试通过,否则片元被删除。超出的部分不会画出 启用裁剪测试 qglEnable(GL_SCISSOR_TEST) qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); */ extern void ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height); extern void ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer); /* 指定使用平滑着色还是恒定着色。mode 可以是 GL_SMOOTH 或 GL_FLAT。 默认为平滑着色,Opengl 在渲染时对顶点颜色执行插值计算 如果用GL_FLAT,一般使用最后一个顶点做为图元的颜色 qglShadeModel( GL_SMOOTH ); */ extern void ( APIENTRY * qglShadeModel )(GLenum mode); extern void ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask); extern void ( APIENTRY * qglStencilMask )(GLuint mask); extern void ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass); extern void ( APIENTRY * qglTexCoord1d )(GLdouble s); extern void ( APIENTRY * qglTexCoord1dv )(const GLdouble *v); extern void ( APIENTRY * qglTexCoord1f )(GLfloat s); extern void ( APIENTRY * qglTexCoord1fv )(const GLfloat *v); extern void ( APIENTRY * qglTexCoord1i )(GLint s); extern void ( APIENTRY * qglTexCoord1iv )(const GLint *v); extern void ( APIENTRY * qglTexCoord1s )(GLshort s); extern void ( APIENTRY * qglTexCoord1sv )(const GLshort *v); extern void ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t); extern void ( APIENTRY * qglTexCoord2dv )(const GLdouble *v); extern void ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t); extern void ( APIENTRY * qglTexCoord2fv )(const GLfloat *v); extern void ( APIENTRY * qglTexCoord2i )(GLint s, GLint t); extern void ( APIENTRY * qglTexCoord2iv )(const GLint *v); extern void ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t); extern void ( APIENTRY * qglTexCoord2sv )(const GLshort *v); extern void ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r); extern void ( APIENTRY * qglTexCoord3dv )(const GLdouble *v); extern void ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r); extern void ( APIENTRY * qglTexCoord3fv )(const GLfloat *v); extern void ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r); extern void ( APIENTRY * qglTexCoord3iv )(const GLint *v); extern void ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r); extern void ( APIENTRY * qglTexCoord3sv )(const GLshort *v); extern void ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q); extern void ( APIENTRY * qglTexCoord4dv )(const GLdouble *v); extern void ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q); extern void ( APIENTRY * qglTexCoord4fv )(const GLfloat *v); extern void ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q); extern void ( APIENTRY * qglTexCoord4iv )(const GLint *v); extern void ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q); extern void ( APIENTRY * qglTexCoord4sv )(const GLshort *v); /* 应用程序使用glTexCoorPointer()指定纹理坐标数组时,Opengl将这组纹理坐标分配给glClientActiveTexture指定的纹理单元. 定义一组纹理坐标数组,用于OpenGL的顶点数组功能 size 每个数组元素坐标数量。有效值 1-4 type 数组的数据类型.GL_FLOAT GL_INT GL_SHORT GL_DOUBLE stride 数组坐标之间的字节偏移。0 表示数据是紧密相邻的 pointer 一个指定顶点数组的数据开始位置的指针 例如: qglTexCoordPointer( 2, GL_FLOAT, 0, texcoords[0] ); */ extern void ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); /* 在进行纹理贴图时,纹理贴图可以直接贴到物体上从而覆盖物体已有的颜色,也可以和物体原有的颜色进行融合。融合是一种重要的图像处理技术,主要用于透明,发光等等效果的处理。 void glTexEnvf(GLenum target,GLenum pname,GLfloat param); target 的参数必须是GL_TEXTURE_ENV; pname的参数可以为GL_TEXTURE_ENV_MODE或GL_TEXTURE_ENV_COLOR; param可以为GL_MODULATE、GL_DECAL、GL_BLEND 、GL_ADD、GL_REPLACE 等等 */ extern void ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param); extern void ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params); extern void ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param); extern void ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params); extern void ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param); extern void ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params); extern void ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param); extern void ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params); extern void ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param); extern void ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params); extern void ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); /*qglTexImage2D 定义一个二维纹理映射。
*/ /* 提交顶点数组供opengl使用 */ /* extern int ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *); extern BOOL ( WINAPI * qwglGetDeviceGammaRamp3DFX)( HDC, LPVOID ); extern BOOL ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);
没有使用 gluLookAt 函数。相机使用默认位置的方向。默认情况下,相机位于原点,镜头指向z轴负方向,向上向量为(0,1,0) July 04 2D bsp 简介凸多边形
BSP 树 June 26 quake3 脚本首先,为了记住你上一次使用的枪,需要设定一个变量,这里用prevweapon,并且把它的值的设定绑定在每把枪上。譬如你用5做炮:
bind 5 "weapon 5;set prevweapon weapon 5" 然后是具体动作的脚本了。先设定一个摁下一个键的动作。 set sniper_hold "weapon 7;+zoom" weapon 7是RG,+zoom是放大,呵呵,有点废话。之后是放开这个键的动作。 set sniper_release "+attack;wait;-attack;-zoom;vstr prevweapon" 这句话里,+attack是攻击,-attack是停止攻击。为什么非得这么写呢?因为在Quake3里,和Zoom,Speed一样,attack分两个状态,当你把它独自绑定在一个键上,摁下代表+attack,松开就是-attack,在这里,由于不是这样的一个键上的单独绑定,+attack就会使“小人儿”处于攻击状态,不停的开枪。所以之后要加一个-attack。为了防止-attack在+attack还没发生做用的时候执行,所以在中间加了一个wait。其实还可以加更多。如果你本来就开了一枪,那么+attack这个状态将在装子弹不能攻击的时候发生作用,而-attack发生作用的时候,根本就没有开枪。根据自己的情况,可以将其改为wait 20之类,这相当于你写20个wait:)。 -zoom没什么说的。接下来的一句,首先,你要明白set prevweapon weapon 5这一句并不是说prevweapon就是等于weapon 5的作用了。prevweapon是一个变量,而不是命令或者代命令。要想使得其中储存的命令得以执行,就需要vstr这个命令。vstr,说白了就是执行变量里的命令的命令。最开始我写脚本的时候,就总忘了vstr呵呵。现在vstr了prevweapon,由于你上次用的枪是RL,当你摁下q的时候,prevweapon里的值是weapon 5,所以在放开这个sniper用的键的最后,它将换回weapon 5,RL。 接下来我们要把它们真正绑定在一个键上了,我这里用MOUSE3。我们要把sniper_hold绑在摁下去、把sniper_release绑在松开来上。 这里有两种方法,其中一种已经过时了,而且特别容易出毛病,我在这里就不说了。另外一种是osp的方法,其实osp文档里就有说明的。我在这里用这个实例给初学者再说一下。 bind Mouse3 "+vstr sniper_hold sniper_release"
这个是osp模式里最好的实现方式了,其他的方式也需要osp、很难使而且可以绑定的键有限。毫不夸张的说,+vstr这个命令是osp发明以来对脚本的最大贡献!举个例子,RB上次发布cfg大家都用了,如果大概意思不改动,实现换电枪无抖动也需要用到+vstr。我认为,只要你想得到,很多地方+vstr已经可以代替以前很多vstr来实现的脚本,一方面它功能强大,可以做出很炫的功能;另一方面,用+vstr可以将一些现存的脚本简化,使得脚本有更大的可读性。 没有安装 osp mod , 对于quake3.1.32b 的代码可以使用如下的脚本: set sniper_hold "weapon 7;+zoom;bind Mouse3 vstr sniper_release"
set sniper_release "+attack;wait ;-attack;-zoom;vstr prevweapon;bind Mouse3 vstr sniper_hold" bind Mouse3 "vstr sniper_hold" 保存脚本到 myscript.cfg 中,进入关卡执行 exec myscript.cfg
或者在 q3config.cfg 中绑定一个键来加载这个文件
由此可以看到 cvar 控制台命令的强大。可以组合各种命令来简化操作。很类似魔兽世界的宏,只是缺少了条件判断。而魔兽的宏更类似脚本,写起来似乎有些长而不实用
June 24 CVars、Commands and vm CommunicationOne of the most common questions I'm asked through e-mail is "How do I get the client to do something from the server code?"... or variations on the theme. The issue is made more complicated by the fact that client, server, and user interface each have their own methods and restrictions. This article aims to de-mystify the methods you can use to pass information between the three Virtual Machines (VM's). There are several complementary methods, and I'll outline the advantages and problems with each. We'll start with a desciption of the client/server/interface model in Quake3. Understanding the relationship between these components is at the core of the need to communicate between them. Some of the restrictions in the system are also clarified. We'll then move onto the main methods: the setting of variables, also called Cvars, and how they're related to configuration strings maintained by the server. We'll then look at the sending of console commands, and finish off by seeing how we can drive the server scripting engine. I've tried to write each main section as an overview and introduction to the sub-sections that follow. As the ideas and definitions can get confusing IT IS IMPORTANT THAT YOU READ AND UNDERSTAND EACH OF THESE OVERVIEWS before proceeding with the more specialized descriptions.
Whether you're compiling binaries or bytecode for the platform independant VMs, it's clear that the game is split into three parts: server (qagame), client (cgame), and user interface (ui). Each carries responsibility for implementing a separate part of the game. What isn't so obvious, and is often forgotten, is that there's a fourth part: the executable that runs the VMs. The server and client complement each other and carry just about everything needed to play the game. The server controls and arbitrates the game: it decides where a player is on the map, whether they've been hit by that rocket, and where the momentum kick sends their corpse. The final word in what happens in the game, the server makes sure that the game world remains consistant. On the other hand, the client has only a limited view of the world. It's given information by the server that it needs to present this localized view to the player... and little else. The client is responsible for drawing the screen, playing the sounds, and adding all those little meaty gibs. It also includes an understanding of the game physics so it can predict motion and make gameplay smoother over an Internet connection, but it doesn't settle the final position of the other players (or yourself). To make this clear with an example: the server concerns itself over who has the quad, applying the damage multiplier, and settling disputes when two players try to pick it up at the same time. The client is told who has the quad, plays announcements and damage sfx, and draws that blue glow that warns "something dangerous comes this way!" It's possible for the client and server to be on separate machines, this is how an Internet game is played. Communication has to occur over a time delay determined by the connection quality and latency (ping), so there will be a delay between a command being sent and received. There's nothing that can be done about that. The client and user interface are always on your local machine. Think of them as connected to your graphics and sound cards, and you won't go far wrong. Servers don't care about these things directly, the closest they get is sending out a command saying "play this sound" or "do this action". The user interface covers all of the menus and pages of controls used to set up personal preferences and game parameters. It is the user interface that draws the menu when you hit the Escape key while playing a game. Anything the behaves like a dialog box or page of controls is drawn (and interacted with) in the user interface. Finally, it's important to recognize that there's a fourth part to all this, hidden away from prying eyes because the source code isn't available: the binary executable. This runs the VMs required to play the game, manages the communication between the VMs, controls the network connection if there is one, and handles all the OpenGL drawing of the graphics. Any communication between VMs is going to have to pass through the binary executable. It's the only way.
Console variables (Cvars) store the current state of the game system in a way that can be accessed through the console while playing, and directly in the game code. Many Cvars are read only: you can't change their value. Some can only be modified when cheats are enabled. Most are saved for the next time you play Q3. As a variable a Cvar isn't a command that must be obeyed immediately. What usually happens is that your code will check the value the next time it needs to use it, and adjusts its behaviour depending on the value it finds stored. This is helped by the way a Cvar is updated. A copy of the Cvar is maintained in the source code, this can be read and used in any part of that source code module. This local copy is updated at regular intervals so you have both consistancy of value, and an (almost) up to date value. Note that we are accessing a "copy" in the source code, the original or "master" of the variable is stored and maintained by the executable. We'll talk about this in more detail when we look at how and when the Cvar copy is updated (section 2.2). A Cvar is created in the code as a data structure. You need to provide a default initialization value, and flags that control access and if it will be saved in q3config.cfg for permanent storage. The Cvar that you access in your code is placed in either game/g_main.c, cgame/cg_main.c, or ui/ui_main.c. You need to choose the most appropriate place: there is no point in putting a Cvar that controls behaviour of the server in the user interface code! There are benefits to putting the Cvar in the correct place, described in section 2.2. You can place a Cvar in another source code file, but you won't get the benefit of automatic initialization and updating. We'll take a quick look at how you initialize a Cvar and make it available for the rest of your code to use. This example looks at the cg_drawFPS variable in the client that draws the frame rate counter on the screen. Although taken from cgame code it applies equally well to the ui in ui_main.c. Its done slightly differently in game, and we'll look at that in a moment. Taken from cg_main.c: A variable of type vmCvar_t is created to store the current value. To take advantage of the automatic updating of the Cvar we need a reference in the array cvarTable[]. This reference takes four components, from left to right they are:
You can find more of the CVAR_* flags in q_shared.h, they're quite well documented there. Finally, so that the Cvar can be accessed easily from within related source code files, you need to add a reference to the vmCvar_t into the local header file. For cgame this is cg_local.h, while the ui and game have their equivalent in ui_local.h and g_local.h respectively. For our example you'll find this in cg_local.h:
I mentioned earlier that the server was slightly different. The change is in how the Cvar is linked into the list for automatic initialization. Here's what a typical Cvar looks like in g_main.c: The first four entries are identical to their cgame and ui counterparts, but there are two new entries at the end:
Even though we can access the Cvars from within the source code, these are not the "master" or "primary" record of the Cvar value. This might sound surprising, but arises from the need to communicate these values between VMs. The authoritative value of each Cvar is stored within the executable running the client or server, and the Cvars within the source code are updated to reflect new values on a regular basis. This update might be slightly delayed, but ensures consistancy in use. More on this in a moment. In the situation where the client and server are running on separate machines, the client still has access to most of the server Cvars. They can only be read by the client, and not modified. The reverse situation where the server accesses a clients Cvars is complicated by the fact that the server can have multiple clients. The mechanism by which a server can access the client is covered in detail in section 2.3.3. The copy of the Cvars stored in each of the *_main.c is updated on a regular basis at a "convenient" point in the game play cycle. This point is usually slightly delayed from the time when it was modified in the primary record. For the client this update occurs just before the next screen is drawn by CG_DrawActiveFrame() in cg_view.c. This makes sense when you realize that these local copies can be accessed through the vmCvar_t data structure without reference to the primary record. For the entire frame that is about to be drawn you will get a consistant value for the Cvar if you use the value stored in a vmCvar_t variable structure. This is important. Go back, read and understand that last paragraph again. Even if the Cvar changes in the primary record while the client is rendering the screen, you get a consistant value to work with while drawing the entire screen. If you always grab the "most up to date value" with a trap_* call then you might get rendering errors for that frame. Also, if you change the value of a Cvar through a trap_* call then you won't see the new value until the next update. For the user interface this Cvar update occurs every time the screen is drawn in UI_Refresh() in ui_atoms.c. For the server code the update is triggered in G_RunFrame() in g_main.c, when the server updates the postion of each entity in the world. As you can see, the Cvars are updated frequently, but not so frequently as to disrupt a frame of activity. The benefit of these local copies is twofold: constancy and speed of access to a local data structure.
With the Cvar created, we need to look at how the value within it can be accessed and changed. The user interface and client behave in a similar way, while there are special considerations for the server. By using a trap_* function to set the variable the primary record is updated correctly. You MUST NOT change the value of the local copy of the Cvar - it won't be moved to the primary record, and will only be over-written at the next update. If the Cvar is archived in q3config.cfg then the new value won't be saved either. A Cvar data structure looks like this: You can read the value of the Cvar by accessing the value, integer, or string fields. This is only possible when the Cvar is stored within the VM you are coding in. In this case it is the optimal method of access. For a Cvar from another VM refer to the methods described below. Although, in principle, you can read and modify Cvars from other VMs, the most cautious approach is to treat Cvars from a different VM as read-only. You might need to know a clients preferences to help make the server run more efficiently, but indiscriminantly changing a clients preferences from the server is anti-social. The method used to set the value of the Cvar happens to be the same in all three modules, treating the Cvar as a string value that can be changed:
The ui also has an additional method that sets the string using a float value rather than a string:
Retrieving the value of the string is done through the complementary methods:
These are described in great detail in the discussion of client Cvars (section 2.3.2, Special methods - Configuration strings). They represent a method that allows the client and user interface to read a set of strings that the server has set: these strings being common to (and used by) all connected clients. You can access these strings through a call to the following function:
You can't change the value of the configuration strings from the user interface. Check below in the client and server sections on how to process and extract information from them. (The truth be told: I didn't find out that the user interface could access these strings until after I'd written the client description of them. I'm too lazy to re-write that description for here :) Setting the value of a Cvar in cgame occurs through the same function call as in ui: You can read a Cvar's string value by making a call into the following function: and this behaves in the same way as the identically named function in the ui module.
For quick access to important Cvars stored in the server, there is a flexible and powerful method available for use. Strictly speaking not all of variables passed through these configuration strings are Cvars, neither are all the server Cvars accessible through this method. However just about all the important ones you'll need in the client are available. These configuration strings are set and maintained by the server, and replicated to each client when a connection is first made. When the server updates any of these configuration strings, each connected client gets an updated version. These configuration strings are also used to pass information about other clients connected to a server. This information is limited (but useful), and includes things like player name, choice of model, and railgun trail colour. Take a look in ClientUserinfoChanged() in game/g_client.c to see how this string is constructed by the server, and in CG_NewClientInfo() in cgame/cg_players.c for parsing of this info in the client. The most up to date version of the configuration strings known to the client can be read through a call to:
Most of the values that index can take are documented in bg_public.h as the CS_* family of flags. You can extend these values by adding new CS_* flags, it looks like there are gaps before CS_MODELS available for expansion, and about 350 free slots after the current value of CS_MAX. When a change is made to one of these configuration strings, the client gets notification though CG_ConfigStringModified() in cg_servercmds.c. You can add or extend any processing of the changed configuration string here, or examine how existing strings are parsed to gain further understanding. Setting these strings is described in the next section about the server. You can also add strings using two of the existing values of index provided (described below). You shouldn't move any of the CS_* values around because comments about the sound values in the source code suggests optimizations within the executable for sending this information across the network. As you can't change the executable, don't mess with the CS_* flags too much! The pointer returned by CG_ConfigString() can currently take two forms, and you need to find out which by examining how these CS_* returned strings are used in the source code. Take a look in CG_ConfigStringModified() in cg_servercmds.c or do a GREP through the source code to find out where else they're used or set. The first form is a simple string that contains the current value. An index value of CS_MOTD, CS_WARMUP, and CS_MESSAGE behave in this way. You can then process them with an atoi() if they're numerical, or treat them as strings. The second form is a list of variable names and value pairs. These can be queried through the provided method:
You'll find that the two most powerful values of index are CS_SYSTEMINFO, and CS_SERVERINFO. They contain the server Cvars that are described respectively by the CVAR_SYSTEMINFO and CVAR_SERVERINFO flags in g_main.c. You can add your own Cvars in the server using these flags, they'll then be sent to each client when they're updated by the server. Use CVAR_SERVERINFO to describe a string that characterizes the game playing on the server (gametype, fraglimit, mapname etc.). Typically these are the values that a program like GameSpy-3D queries and displays. For the remaining Cvars that describe the low-level state of the sytem, CVAR_SYSTEMINFO should be used (g_syncronousClients is an example). Don't put frequently changing values into the CVAR_SERVERINFO or CVAR_SYSTEMINFO flags as the entire string is resent for the change of one variable. Very network inefficient. How the server sets these configuration strings is described later in this article.
Taken from CG_DrawInformation(void) in cg_info.c, we'll get the short name of the map (q3dm10, q3tourney6 etc.) from CS_SERVERINFO and load an image of the level ready for drawing. Initialization of mapname is slightly unusual and occurs as part of the bot AI in ai_main.c instead of g_main.c. Nevertheless, it has been correctly registered and flagged as CVAR_SERVERINFO. Just as in ui and cgame, we have to set the new value of a Cvar through this function: There are two methods available for reading the value of a Cvar. These are The former takes a Cvar name and returns its integer value, and the latter is used in the way described in the ui (section 2.3.1), above.
Of particular importance to the server is the ability to obtain some of the client parameters. Some of these parameters might be used to optimize the servers behaviour towards that client, others repackaged and sent on to the remaining clients for accurate representation. For a client Cvar to be forwarded to the server when it is changed, it must be described by the CVAR_USERINFO flag. The only example of this is the teamoverlay Cvar in the client: it's also a CVAR_ROM so it can only be changed from within the source code, not on the console. This Cvar controls whether the server sends bandwith sucking stats during team games. Other critical Cvars appear to be flagged as CVAR_USERINFO by the executable directly. When a client changes one of its Cvars, the updated value is sent to the server and notification arrives at ClientUserinfoChanged() in g_client.c. The information can be validated (if required), modified (if absolutely necessary), or repackaged as a configuration string and sent on for other clients to use. The client configuration is read and set through the following functions:
The client index is just the array index of the global server array level.clients that points to the gclient_t data structure representing that player. Look in ClientConnect() in g_client.c to see this. To obtain the client index given a gentity_t* use the following code (which relies on the properties of C pointer subtraction): Just like the configuration strings described earlier, you can access the value pairs using Info_ValueForKey(). This example checks whether cg_predictItems is enabled in the client. It's derived from ClientUserinfoChanged() in g_client.c:
In order to use the special parsing function Info_ValueForKey() when constructing your own configuration strings, you need to know how to build these strings. There's a working example in ClientUserinfoChanged() in g_client.c, but we'll take a trivial one for clarity. This is how the string would be constructed in the C source (note that the double slash as used in the source code is reduced to a single slash by the compiler). Values are paired up: each having a unique identifying name (key) and an associated value. The '\\' character is used to separate the values, and you shouldn't pass this character as part of a key name or value (this will prevent Info_ValueForKey() from working), nor a quote ("), or a semi-colon (;). I got these limitations from Info_Validate() in q_shared.c, but be wary of using non-standard characters, and never use a string termination '\0'. In this example string_one_key and string_two_key are the possible arguments to Info_ValueForKey(), and string_one_value and string_two_value will be returned. The key values shouldn't need to be Cvars, they're just a means of identifying the associated value uniquely. If you are only ever going to send a single string value, then you don't need to use this key/value pair system. You will almost certainly end up constructing these strings using the va() variable argument substitution strings, I deliberately avoided them to reduce the complexity of this explanation.
Although there are no examples of the server over-riding the client settings using trap_SetUserinfo(), presumable you just need to send the variables you want changed using the key/value pairing described above. The best place for the server to do this is in ClientUserinfoChanged() in g_client.c
As already described earlier from the point of view of the client, configuration strings contain global information that is maintained by the server. It is transmitted to all the clients connected to the server, and updated when changes are made by the server. The client can't modify these strings, but can (and does) make use of the information. A configuration string is read or changed using these functions:
Each configuration string is described by an index CS_*, a list of these values can be found in bg_public.h. Although there's space for MAX_CONFIGSTRINGS (1024) values, the smallest amount of change that can be transmitted across a network connection is a single string. This is a network efficient way of transmitting state changes in the server, and other global variables maintained by the server. Two special config strings are CS_SYSTEMINFO and CS_SERVERINFO. Described in more detail in the client section above, the Cvars that belong to this group are automatically updated when they're modified by the server using trap_Cvar_Set(). Try to avoid putting frequently changing values in here because it's almost certain that all Cvar strings in this group are transmitted in one go, and this is network inefficient. You can create your own specific CS_* flags and groups instead (like CS_FLAGSTATUS). For an example we'll take a look at how the server updates CS_FLAGSTATUS, this code is from g_team.c: The flag status is sent as a two digit pair, one each for the red and blue flags. Sending the values as a pair of numbers is a limitation of strings: we must avoid sending anything that might prematurely terminate the string (a char value of '\0'), so its encoded based on the ASCII value for the character '0'. This code fragment shows how its decoded in the client, in the function CG_ConfigStringModified() in cg_servercmds.c: and you can see that the binary value of zero, if stored directly in str[0], would have prevented the rest of the string from being transmitted. The status of the blue flag would then be unknown. There are some Cvars that have slightly unusual properties. There are only a few of these Cvars, and I'll only touch on them briefly. One reason for these special Cvars is so that one VM can control or influence another in a transparent manner. The three Cvars that fall into this category are sv_running, cl_paused, and g_syncronousClients.
If sv_running is set then the server is running on your local machine. This is important as its presence enables some menu items in the ui that can be used to influence the local server. You can also check for this in the client code by accessing cgs.localServer (zero if we're connected to a remote server), it's set in the following manner:
cl_paused is used to indicate to the client that the user interface has drawn a menu on screen while the client is running. Setting this variable to a value of 1 (one) will pause the game if the server is local. This appears to be managed by the executable, stopping the server and client VM's temporarily, rather than in any of the VM code itself.
The third variable is g_syncronousClients, this is set if the server allows demo recording, and it also plays a part in client side prediction. It is created in the server VM, and replicated to the client VM via the CS_SYSTEMINFO configuration string. The client can't modify this value, but it can be read in and acted upon. Note that the creation in the client of the vmCvar_t structure doesn't have any CVAR_* flags associated with it, this is because the server stored value is the one with the CVAR_ARCHIVE flag set. In other words, the server has control over the value, while the client contains only a reference.
Another variable, apparently set by the executable, is bot_enable. If this is set to zero then bots aren't loaded onto the system. There is no corresponding copy stored in a VM, it appears to be managed by the executable running the server (but is available to the client). Again, some menu options depend on this value to determine whether they are enabled or not.
With the large amount of ground covered by the Cvars and server configuration strings, you're going to find console commands has less content. Unfortunately the picture is made difficult to follow because of the possibility of confusion between the client and server consoles. In addition the server can issue commands to the client, in a way that looks like the console commands, but is in fact separate. I've tried to give the best description of these as I possibly can below. Client console commands, as their name suggests, can be typed in from the drop down console. There is also a way of executing these commands from within the source code. Whether the command originates from the console or code is irrelevant when it's acted upon. This means that these commands can't be hidden from the user in the same way as configuration strings can. A client console command can be handled in either the user interface, client, or server parts of the code. This makes it a very useful way of asking another VM to do something for you (for example: displaying a menu system using the user interface). We'll look at the client console in section 3.1. The server console is another matter. These commands control how the server behaves and they can only be accessed when the server is running on the same machine, or a particular client has the administrator privilige to change the setup of the server remotely. Some commands that fall into this category are addip and addbot, and we'll cover the server console in section 3.2. What is potentially confusing is that when the client and server are running on the same machine, both the client and server console commands are entered in the same way. The typing of commands through the drop down console is, at best, a confusing use of terminology. Apply this rule of thumb: A command typed in by the player is a client console command if is expected to behave the same whether the server is local (running on the same machine) or remote (on a LAN or across the Internet). Once a console command has been recognized (Cvars are filtered out first), it arrives at the handler for each of the VM modules. For the user interface this handling function is UI_ConsoleCommand() in ui_atoms.c, the client has CG_ConsoleCommand() in cg_consolecmds.c, while the server uses ClientCommand() in g_cmds.c. Some pre-processing has already been done for you, and you can get at arguments for the command by using trap_Argv(int pos) (the argument at a given position), and trap_Argc() (the total number of arguments). The user interface and client have "wrappered" versions that can also be accessed through UI_Argv() and CG_Argv(). You'll find that Argv(0) is always the command string itself.
There's no rocket science to adding a console command to the user interface: just add a Q_stricmp( cmd , "yourcmd")==0 comparison into UI_ConsoleCommand() and route it to you handling function. The most obvious use of a command in the user interface is to pull up a menu for the user to interact with, and there's an obvious example in the ui_teamOrders command. One thing to be cautious of if you're displaying a menu: you'll need to protect against repeatedly adding new menus until the menu stack is used up. Surprisingly there's no way of sending out a console command from the user interface, it has to go through Cvars or server scripting (see section 4). I would guess that's because it's possible for the user interface to be running when the client and server code aren't. Any Cvars that are important and stored outside the user interface are latched anyway - so any updated value is still passed correctly. You can get some information about the state of the client through a call to trap_GetClientState(uiClientState_t*). This data structure is described in ui_public.h, and includes (amongst other things) access to the connection state of the client. This might influence how you draw the menu: in a connected game you'll want to leave the background "transparent" so the player can see the game screen. This code fragment taken from UI_ConfirmMenu() in ui_confirm.c shows how this is done: See my articles on the user interface menu for more information on how and why ths works.
When you press the Escape key while playing a game you get the In Game Menu that allows you to change teams, add bots, change game settings etc. This menu is unusual: it doesn't use a console command to activate it. The ESC key is recognized in the executable and passed into the user interface VM through vmMain() in ui_main.c. Although several menus are created by this method, and all pass through UI_SetActiveMenu() in ui_atoms.c I haven't been able to find a way for the user to extend this and add their own menus. The good news is that you can use console commands to create your own menus. Just make sure that the commands in UI_SetActiveMenu() don't overwrite your menu, and that UIMENU_NONE is always honoured.
Once again, adding a client console command is straight forward. It's made even easier by the use of an array of console commands and associated function handlers in cg_consolecmds.c. As the code fragment below shows, just add an new entry into the the commands[] array, with your command name and your handling function. This handling function must be of type void function_name(void) for the array to work.
You can send out a client command to another VM by calling trap_SendConsoleCommand(const char* cmd_string). You can add arguments with additional information so long as you separate each of them with a space. When they arrive at the VM that handles them they'll already be processed so each argument is easily accessible. There is also a similarly named (and possibly confusing) function called trap_SendClientCommand(const char* cmd_string). This sends the command string directly to the server, without a chance being given to the user interface to act upon it. Use it as part of exclusively client-server issues. When the command string arrives at the server, whether it came from trap_SendConsoleCommand() or trap_SendClientCommand(), it is handled in ClientCommand() in g_cmds.c. This example shows how the tell_target client console command is broken down into a single tell command. Ultimately this will be processed in the server for distribution to the victim under the crosshair.
If you create a command in the server and you want TAB completion to work in the client, then you should also register the server command in the client. This is done in CG_InitConsoleCommands() in cg_consolecmds.c by adding another trap_AddCommand() to the list. Why do it this way? Well if the server is running on another machine then you don't want TAB completion to depend on the availability of the network connection.
There are two types of command that the server can accept, so it's important to put your command into the right place. Go back and read the start of section 3 to understand the difference. We'll look at the client console commands here, while dealing with the server console in section 3.2. Since we're looking at client console commands we need to work in ClientCommand() in g_cmds.c. Each command that you add is just a straight forward Q_stricmp() comparison that passes control to your handler if passed. Note that there is a watershed between commands that can be executed at any point, and those commands which don't make any sense during the intermission (when a level is over and the scoreboard is displayed, but before the next level is loaded). If you want TAB completion of the command name in the client, then you'll need to add the name of the command as described at the end of section 3.1.2, above.
I've not found a way for the server to send a client console command to a particular client (such a command could reach either the ui or cgame). However, there is a way that the server can send a command to the client (cgame), and this is covered in section 3.3. Although this seems to be the reciprocal method for sending a client console command from the server, the commands it sends can't be typed into the client - they can only be sent by the server. Notice the change of subject! We're now talking about commands that get to the server console, described and defined at the start of section 3. These are the commands that can be typed on a client drop down console when the server is running on the same machine, or if the client has administrative privilige on a remote machine. Usually these commands have a drastic effect on gameplay or the behaviour of the server. You want to be careful who you let use these commands, and many of them might be made available through the voting system. All of these commands arrive in ConsoleCommand() in g_svcmds.c for processing (note that console in this case means server console). You don't need to do anything special to separate them from the client console commands, this is done for you automatically (and is outside your control!) As this snipped version of ConsoleCommand() shows, you need to return qtrue if you do handle the server command. Trace through the code to Svcmd_AddBot_f() in g_bot.c to see how trap_Argv() is used to grab the arguments to addbot.
When the server needs to send a command to one or all clients then it uses the following function: The clientNum is the identifying index of the client, look in section 2.3.3 for an example of how to get a clientNum if it isn't provided for you. clientNum may also be -1, in which case the command is broadcast to all connected clients. The command will arrive in the client in CG_ServerCommand() in cg_servercmds.c, all ready for the client to deal with. In an attempt to make this clear to a possibly confused reader, try the following experiment: start up Q3 and get a map going. Pull down the console and type in "/cp test" (without the quotes of course!). It will show an error message. Now look at CG_ServerCommand() in cg_servercmds.c for the cp command. It draws some text in the centre of the screen (cp - center print) and is sent by the server. Can you now see that commands sent by the server aren't connected to the client console?
The last method of control is aimed purely at the server. You can send a list of commands to the server (to be accurate, the binary executable running the game VM), that are equivalent to running a script. These commands remain in memory and are used (for example) to set up a map rotation. Think of this method as having the same effect as using the /exec command in the drop down console. You can add these commands from the user interface part of the source code, or as part of the game code. You are effectively limited to setting up and controlling a server on your machine only, or having a server manipulate its own script. It shouldn't be possible for a local user interface to manipulate a remote server using these functions. From within the user interface code: and from within the server code: Don't be confused by the fact it carries the same name as a function that's used in the client, its behaviour isn't the same. Think of it as acting on the server console only. The text argument is easy enough: it's the text string that contains a command or sets a variable. You should add a newline character '\n' when you issue a single command, or you can put a group of commands together in the same string, separated by a semi-colon, and terminated with a newline. If you don't put the newline in then you'll get two commands running together and confusing the executable's script engine. The other argument, exec_when, is a bit more difficult to understand from just code reading and without access to the source code for the executable. Here's the allowed values and what I've been able to glean:
Although the EXEC_NOW flag is clear enough, it's possible for the other two to be confused. If you start with the idea that EXEC_APPEND is building a script (list of commands) within the executable running the server, then you can see that this script will always be present until the server is shut down. Although you can add new commands and have them executed, you would use the EXEC_INSERT so that it wasn't permanently added to the script being built by EXEC_APPEND. It appears that the EXEC_INSERT command isn't used in the user interface, possibly because the server can't be guaranteed to be running. If you do try to use EXEC_INSERT in the user interface, use it with caution.
Taken from ServerOptions_Start() in ui_startserver.c, this code fragment shows the bots selected for a map being added to the server script through the use of EXEC_APPEND. This code is run when you create a server from the multiplayer menu, or have a skirmish from the single player menu. Notice that each string for the addbot command is finished off with the '\n' character. The wait command is interesting: some of the server parameters are set through trap_Cvar_SetValue(), and this allows their value to propagate through to the binary executable. As this code is run when we set up a server on our local machine, the time delay only needs to be a short one. We've come a long way with this article, and covered a lot of ground that turned out to be more complex that even I'd originally thought. So long as you keep a clear picture in your mind of the differences and relationships between the user interface, the client, the server, and the executable, then you should be able to use this information to the full. When I originally planned this article I was going to talk about manipulating information stored in entities too - I'll have to save that for another time as this article is now far too long to do entities justice. There are also some bot commands for setting variables, but I've left them out for reasons of space and specialization. The ideas that govern the use of these bot commands are going to be very similar to the conventional methods I've described in this article. Let me know if there are any problems with the article, and if it's been of help to you. June 11 修改 shotgunshotgun 是 quake 里面的霰弹枪,射出去的子弹随机分布在一定范围内。目标:修改霰弹枪,当人物蹲射时可以增加霰弹枪精度,使子弹不至过于分散。注:霰弹一次出去为11发。而且不像火箭那样,没有飞行时间。所以当开枪后就计算是否命中。
PMF_DUCKED 标志表示人物处于下蹲状态。
#define PMF_DUCKED 1 #define PMF_JUMP_HELD 2 #define PMF_BACKWARDS_JUMP 8 // go into backwards land #define PMF_BACKWARDS_RUN 16 // coast down to backwards run #define PMF_TIME_LAND 32 // pm_time is time before rejump #define PMF_TIME_KNOCKBACK 64 // pm_time is an air-accelerate only time #define PMF_TIME_WATERJUMP 256 // pm_time is waterjump #define PMF_RESPAWNED 512 // clear after attack and jump buttons come up #define PMF_USE_ITEM_HELD 1024 #define PMF_GRAPPLE_PULL 2048 // pull towards grapple location #define PMF_FOLLOW 4096 // spectate following another player #define PMF_SCOREBOARD 8192 // spectate as a scoreboard #define PMF_INVULEXPAND 16384 // invulnerability sphere set to full size #define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK)
在ShotgunPattern 函数中加入一个变量 accuracyFactor (在 hitClient 声明后面):
qboolean hitClient = qfalse;
int accuracyFactor = 4; // derive the right and up vectors from the forward vector, because
// the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); oldScore = ent->client->ps.persistant[PERS_SCORE];
if(ent->client->ps.pm_flags & PMF_DUCKED) //是否蹲下
{ accuracyFactor = 1; } // generate the "random" spread pattern
for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * accuracyFactor * 16; //这里调节 u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * accuracyFactor * 16; VectorMA( origin, 8192 * 16, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); if( ShotgunPellet( origin, end, ent ) && !hitClient ) { hitClient = qtrue; ent->client->accuracy_hits++; } } 当蹲下是和原来一样,而站立的时候,霰弹枪的子弹将会更加发散。
同时注意在 ShotgunPattern 函数前面的注释,// this should match CG_ShotgunPattern
和 cg_weapons.c 中的 CG_ShotgunPattern 比较起来你会发现两个函数极为相似,除了 CG_ShotgunPattern 被声明为 static ,就是说此函数只能在,cg_weapons.c 文件中使用。
================
CG_ShotgunPattern Perform the same traces the server did to locate the
hit splashes ================ */ static void CG_ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEntNum ) { int i; float r, u; vec3_t end; vec3_t forward, right, up; int accuracyFactor = 4; //add mzz,调整霰弹枪精度 // derive the right and up vectors from the forward vector, because
// the client won't have any other information VectorNormalize2( origin2, forward ); PerpendicularVector( right, forward ); CrossProduct( forward, right, up ); if((otherEntNum == cg.snap->ps.clientNum) && (cg.snap->ps.pm_flags & PMF_DUCKED)) //加入的蹲下的判断
{ accuracyFactor = 1; } // generate the "random" spread pattern
for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * accuracyFactor * 16; //调整散射范围 u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * accuracyFactor * 16; VectorMA( origin, 8192 * 16, forward, end); VectorMA (end, r, right, end); VectorMA (end, u, up, end); CG_ShotgunPellet( origin, end, otherEntNum );
} } Q_crandom( &seed ) 取圆内随机数。
两个函数之所以这样主要为了解决网络带宽问题。这个在后面在做详细的探讨
同步客户端:
尽管在CG_ShotgunPattern 函数中不能使用 gentity_t。但在客户端当你有 一个整形变量如otherEntNum,在客户端有个变量cg, cg 是一个十分重要的变量,因为他带给你最重要的人物: 玩家
cg.snap->ps.clientNum 代表当前客户端的 number, 对于客户端主要关心一个实体:屏幕前的玩家。cg 拥有服务端一部分属性,如玩家是否蹲下。cg.snap->ps.pm_flags
对于移动的惩罚: 当前移动状态存在于 ps.velocity[] 中,这是一个 vec3_t 数据类型。velocity[0] 代表前后移动,velocity[1] 代表左右移动,velocity[2] 代表上下移动。
在 服务端 shotgunpattern 中加入判断
else if (ent->client->ps.velocity[0] || ent->client->ps.velocity[1])
accuracyFactor = 3;
else if (ent->client->ps.velocity[2])
accuracyFactor = 4;
在客户端为:
if(otherEntNum == cg.snap->ps.clientNum)
{
if(cg.snap->ps.pm_flags & PMF_DUCKED)
accuracyFactor = 1;
else if (cg.snap->ps.velocity[0] || cg.snap->ps.velocity[1])
accuracyFactor = 3
else if(cg.snap->ps.velocity[2])
accuracyFactor = 4;
}
一些关于榴弹的参数:
在 fire_grenade 中 blot->s.eFlags = EF_BOUNCE_HALF; 实体的一种标志,可以让榴弹在关卡表面上弹跳而不是爆炸
blot->s.pos.trType 为 TR_GRAVITY 表示弹道受道重力影响,火箭为TR_LINEAR 即走直线
s.eType 是 ET_MISSILE 当遇到可以破坏的目标时, 函数 G_MissileImpact 调用。
游戏当前时间 (level.time) June 05 让火箭自动导航注意:前提知道如何调用自己编译的dll,而不是使用quake的qvm
// client data that stays across multiple respawns, but is cleared
// on each level change or team change at ClientBegin() // 客户端 clientPersistant_t数据会随关卡或者团队改变而改变。
typedef struct {
clientConnected_t connected; usercmd_t cmd; // we would lose angles if not persistant qboolean localClient; // true if "ip" info key is "localhost" qboolean initialSpawn; // the first spawn should be at a cool location qboolean predictItemPickup; // based on cg_predictItems userinfo qboolean pmoveFixed; // char netname[MAX_NETNAME]; int maxHealth; // for handicapping int enterTime; // level.time the client entered the game playerTeamState_t teamState; // status in teamplay games int voteCount; // to prevent people from constantly calling votes int teamVoteCount; // to prevent people from constantly calling votes qboolean teamInfo; // send team overlay updates? } clientPersistant_t; 在第14行加入 qboolean homing_status 。然后变成下面这样
.....
qboolean homing_status; //用于切换自动导航和正常状态 qboolean teamInfo; // send team overlay updates?} clientPersistant_t; 然后创建一个控制台命令来设置这个变量。打开 g_cmds.c 文件1598行,你将会看到
void ClientCommand( int clientNum ) {
gentity_t *ent;
char cmd[MAX_TOKEN_CHARS];
在函数的最后你将看到:
else if (Q_stricmp (cmd, "stats") == 0)
Cmd_Stats_f( ent ); else trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) ); } 在 Cmd_Stats_f( ent ); 后面我们在加入1行
else if(Q_stricmp(cmd,"homing") == 0) Cmd_Homing_f( ent ); else trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) ); } 之后加入Cmd_Homing_f(gentity_t* ent) 处理函数
void Cmd_Homing_f(gentity_t* ent){
if(ent->client->pers.homing_status == 1){ trap_SendServerCommand(ent-g_entities,va("print \Homing Missile are off.\n\"")); ent->client->pers.homing_status = 0; } else{ trap_SendServerCommand(ent-g_entities,va("print \Homing Missile are on.\n\"")); ent->client->pers.homing_status = 1; } } 下面开始创建火箭的自动导航:
火箭查找一点范围内的目标。如果找到目标,将修改它的方向,朝向目标。在 g_utils.c 中加入如下代码用于寻找目标
gentity_t* findradius(gentity_t* from,vec3_t org,float rad){
vec3_t eorg; int j; if(!from) from = g_entities; else from++; for(;from <&g_entities[level.num_entities];from++){ //level.num_entities关卡中实体数目,用MAX_CLIENTS 更好一下。 if(!from->inuse) continue; for(j=0;j<3;j++) eorg[j] = org[j]- (from->r.currentOrigin[j]);//+(from->r.mins[j]+from->r.maxs[j])*0.5); if(VectorLength(eorg) > rad) //检测实体之间的距离 continue; return from; } return NULL; } 接着加入函数:
/*
检查两个实体之间是否可见
*/
qboolean visible(gentity_t* ent1,gentity_t* ent2){
trace_t trace; //ent1 到 ent2 之间发射一条线检测是否与其他物体碰撞
trap_Trace(&trace,ent1->s.pos.trBase,NULL,NULL,ent2->s.pos.trBase,ent1->s.number,MASK_SHOT); if(trace.contents & CONTENTS_SOLID){ //轨迹中与固体发生碰撞 return qfalse; } return qtrue; } 这个函数从1个实体像另一个发射一条线,看是否可见。如果轨迹经过了墙。返回false,否则返回 true
接着你需要在 g_local.h 中放入 visible 和 findradius 两个函数的声明
gentity_t* findradius(gentity_t* from,vec3_t org,float rad);
qboolean visible(gentity_t* ent1,gentity_t* ent2);
当这些完成之后打开 g_missile.c 文件 加入一个新的 think 函数
void G_HomingMissile( gentity_t *ent ) {
gentity_t* target = NULL; gentity_t* rad = NULL; vec3_t dir,dir2,raddir,start; while((rad = findradius(rad,ent->r.currentOrigin,600.0f)) != NULL){ //如果在600个单位范围是否有物体
if(!rad->client) continue; //如果目标不是一个玩家,继续 if(rad == ent->parent) continue; //是否是开枪的人,不要把自己炸了 if(rad->health <=0 ) continue; //目标是否死亡,不去炸尸体 if(rad->client->sess.sessionTeam == TEAM_SPECTATOR) //是否为观众 continue; if((g_gametype.integer == GT_TEAM || g_gametype.integer == GT_CTF)&& rad->client->sess.sessionTeam == rad->parent->client->sess.sessionTeam) //是否为同一队伍玩家 continue; if(!visible(ent,rad)) //目标是否可见 continue; VectorSubtract(rad->r.currentOrigin,ent->r.currentOrigin,raddir);
raddir[2] += 16; if(target == NULL || (VectorLength(raddir)<VectorLength(dir))){ //感觉第二个条件判断不该存在。 target = rad; VectorCopy(raddir,dir); } } if(target != NULL)
{ VectorCopy(ent->r.currentOrigin,start); VectorCopy(ent->r.currentAngles,dir2); VectorNormalize(dir); //归一化dir矢量 //VectorScale(dir,0.2,dir); //注掉更好一点,不至于来不及计算飞过头。即使飞过去也来得及回来 //VectorAdd(dir,dir2,dir); //原来作用是逐步转向,即使要这个,也不需要上面的 0.2 系数。 //VectorNormalize(dir); VectorCopy(start,ent->s.pos.trBase); //ent.s.pos 负责移动物体 VectorScale(dir,600,ent->s.pos.trDelta); //在指向目标的矢量上移动600个单位 ent->s.pos.trDelta = dir * 600 //如果用 VectorCopy(raddir,ent->s.pos.trDelta) 将会发现有趣的现象,火箭一直跟着人跑,人不停,就追不上,呵呵
SnapVector(ent->s.pos.trDelta); //修改矢量浮点数成员x,y,z 为 int //VectorCopy(start,ent->r.currentOrigin); // VectorCopy(dir,ent->r.currentAngles); //改变方向 } ent->nextthink = level.time + 100; }
之后进入关卡可以在控制台输入\Homing 来调整是否使火箭自动导航 June 04 实体 - ENTITIESby SumFuka This is the first in a series of 'articles' explaining various things about the quake3 game world. Every wondered how you interact with the game world ? This is the first question we're going to tackle... by working from the ground up. Quake's design hasn't changed much from quake1 thru to quake3... the most basic thing in the world is - yes, an entity !
事实上任何游戏世界中你可以叫出名字的都是实体。火箭筒? 就是一个简单的实体的例子。一个弹药夹?是实体,一个玩家也是实体。让我们举个例子。。。如用火箭筒开火。下面是其工作过程。
一旦一个实体被移除,槽将被标为未使用。将等待再次被使用 As you can see, a rocket's life is relatively short ! You might be thinking, is there a limit to the number of rockets that can simultaneously be flying around the map ? Well, yes.
在地图上同时出现的火箭筒是否有限制? 是的
这个有限的数组定义了游戏世界的实体数量。2的10次方。或者1024。就是同时的火箭筒,玩家,武器等等不能超过1024个
There is a certain number of entities that are permanently used during the whole game (for example, players, weapons and items). All other non-permanent entities follow the cycle create - live a short life - reuse. This is something to think about when you're coding mods - If you make a cluster grenade that splits into 100 mini grenades, then one idiot could quickly run your world out of entities by firing a bunch of cluster grenades in quick succession. What happens if your world runs out of entities ? Assume the worst-case scenario, that your server will crash. If an entity is going to exist for a relatively long time, make sure that it isn't possible for huge numbers of them to exist at the same time.
开始2个比较重要,entityState_t 和 entityShared_t 包含了实体的位置,实体的类型。包围盒的大小等等。 Further down we can see heaps of interesting fields - classname, speed, movedir, target, team etc. Not all of these fields are used with all entities... a red armor would not use the 'damage' fields, for example (wheras a rocket would). Most of these are pretty self-explanatory.
在g_local.h文件110-116中定义了一些函数指针:think,reached,blocked,touch,use,pain,die.这些函数在c里面模拟了虚函数效果 We want our rockets to explode after 10 seconds. Remember, from g_missile.c : Similarly, a grenade explodes after 2.5 seconds. Can you find the code for this ? (Answer : g_missile.c line 294). 'Thinking' is a nice "fire and forget" mechanism - we create an entity, define what it does at some future time, and then forget about it - the game engine takes care of the entity from then on. 这意味这经过10秒,火箭开始'思考',在该火箭实体上,函数 G_ExplodeMissile 被调用 10 times a second, the server checks if each entity is due to 'think'. If yes, the 'think' function is run for that entity. Similarly, other entity functions are called in response to certain events. If a player is killed, then the player_die function is called (see g_client.c line 921). The same goes for touch, blocked, pain, etc. 1秒10次,服务器检查每个实体是否 think,如果是,该实体think 函数被调用。如果玩家被杀死, player_die 函数被调用 (g_client.c)。同样还有touch,blocked,pain 等等
在q_share.h 中我们看到最大的客户端数量 MAX_CLIENTS 64,在g_entities中开始的64个实体为客户端保留。所以g_entities[0] 代表客户端0,g_entities[1] 代表客户端1。直到 g_entities 代表玩家 63 Just as there exists an array of entities in the world, there also exists an array of 'client information' structures - see line 18 in g_main.c : 头64个实体对应64个客户端信息。 g_entities[0]->client 指向 g_clients[0] 等等。
May 27 Hello qworld TUTORIAL 3 - HELLO, QWORLD ! by SumFuka "Booyakasha !". Ok, now it's a pre-requisite that you're able to compile the qagamex86.dll - if you haven't managed that, then have a look at the previous tutorials. In this tutorial we're not actually going to print "Hello, qworld!" on the console (Boring!), we're going to modify the speed of rockets (as suggested in the id readme file). We're also going to learn a thing or two about rockets along the way. Now let's get into it.
一句话,修改之前做好备份。 Ok then, we simply copy quake3\source to quake3\mymod. Double click on quake3\mymod\q3agame.dsw - from now on, follow all the tutorials using this codebase (I made a shortcut to this .dsw file on my desktop). If you modified the "Output file name" setting correctly in the first tutorial, the .dll for mymod should compile to the quake3\mymod directory - compile the 'game' project and check this. Whenever we've finished messing around with a tutorial and want to refresh the codebase back to the original, simply copy quake3\source to quake3\mymod. You can have as many mod directories as you want... I often have more than one mod in progress at any one time... quake3\rail, quake3\cts, etc... your hard drive's the limit!
在game(服务器工程)工程中找到 g_missile.c文件。 Go to line 362 (hit Ctrl+G for an easy shortcut) and find the fire_rocket function : 到362行(我这里是644行 . quake3 1.3.2 b 源代码) Back already ? Great ! Line 372 is creates a new entity (called bolt). The G_Spawn() function creates a 'blank' entity... then next job is to flesh out all the details (what sort of entity is it ? what are the characteristics ? etc). The next 20 or so lines of code define all this stuff. Line 373-375 define the bolt to be a "rocket", and it will 'think' again in 10 seconds (time is measured in 1000'ths of a second in the quake world, thus 10000 equates to 10 second). When the rocket 'thinks' it will call the function G_ExplodeMissile. In other words, if it hasn't touched anything already, our rocket will explode after 10 seconds. This prevents our rockets flying off into outer space forever. Neat, we've discovered something about the game from looking thru the code! Let's see what else we can figure out about rockets... We can see that the rocket deals 100 damage (direct OR splash), and that the splash damage radius is 120 units. Line 391 tells us that the rocket moves at a speed of 900 units/second. There's also a whole load of constants used in this function (constants are usually in CAPS)... we can guess what most of them mean. 'ET_MISSILE' for example means 'Entitry Type: Missile' (as opposed to an item or a player).
让我们修改391行如下:按F7编译.dll 启动quake,记住设置启动参数 +set sv_pure 0(使用dll启动而不是qvm),你会发现火箭筒速度显著的变慢了 Done! That's our first tutorial. Let's keep blazing onwards... May 18 Quake3 控制台命令3"bot_nochat" - Basicaly, this command lets you turn off those automated taunts that the bots say constantly. I presume there will be a minor framerate increase but I am not sure. Once you tire of the taunts set this to 1. "cg_centertime" - This command lets you limit how long the "you fragged <playername>" message appears when you frag someone. The default setting is 3, but the recommended setting is 1. Setting this command to 0 means no message is displayed. This command works only is server side only. "cg_drawAttacker" - Displays the opponent's name when you face them. Useful for TDM or CTF, but a hinderence to your visibity. Optimal setting is disabled. "cg_drawRewards" - Displays rewards earned in the current battle (excellent, impressive etc...). Optimal setting is disabled. "cg_draw3dIcons" - When turned on, all icons in the HUD will be displayed in 3D. Optimal setting is disabled. "cg_drawGun" - This command let's you toggle between displaying, or not displaying the gun. Many people like to have a gun on screen at all times as it helps distinguish which weapon you currently have selected. Disabling gives the advantage of not having a gun blocking your view. Especialy helpful when using the railgun. Framerate is also noticably higher with this disabled. "cg_gibs" - When activated, characters will "gib" (blow into pieces) with a particulaly viscious shot. "com_blood" must be activated for this to take effect. This looks pretty, and can be satisfying but can slow down gameplay in large scale deathmatches. When turned off, FPS gain is around 1 - 5 FPS depending on the amount of action going on. "cg_marks" - With this enabled, every time a player shoots at the scenary, a mark is left behind. These marks will stay for approximataly 20 seconds. Because of this, noticable framerate loss occurs in large scale deathmatches. Optimal setting is disabled. "cg_brassTime" - With this enabled, when a gun is fired, the shells ejected are thrown and discarded in the air for added realism. Optimal setting is disabled. "cg_bobup / cg_bobroll / cg_bobpitch" - These 3 settings are used to create a more realistic walk or run for your character. For example, when you are slowly walking in a crouch position, you will shuffle side to side to give your character more realistic movement. The default for all settings is 0.0025 but I prefer to turn these settings to 0 as its gives a more fluid movement and prevents possible motion sickness ;-) "cg_fov" - This setting lets you widen or shrink your viewing area or field of vision. The default is 90 but feel free to increase this slightly for a sly advantage (I wouldn't put it over 110 though as the image looks trippy). Unfortunately, because of the larger viewing area, the CPU is under more stress so bear in mind you may get a slightly lower framerate. "cg_shadows" - There are 3 shadow modes - 1, 2, and 3. 1 creates round, unrealistic shadows under the feet of all characters. 2 creates incredibly lifelike shadows, but at a huge performance hit. 3 creates suitably lifelike shadows but again at the cost of some performance. For setting 2, you must ensure your graphics card supports hardware stencil buffing, and r_stencilbits must be set to 8 at the console. The optimal setting is 0 (no shadows) "cg_simpleItems" - With this on, all items and pickups will be displayed in 2D rather than 3D. This is especially helpful for people with slower machines as it can give noticable framerate increase. "com_blood" - Displays blood when a character is shot with this turned on. Additionaly, characters create a small gib when hit hard at the cost of no performance. Keep this setting on and turn "cg_gibs" off. "com_blindlyLoadDLLs" - If you use the Speed Dll's, you may get the warning message telling you that it is unsafe to use them. This message is quite anoying, as it pops up when you load and finish a level. Set this to 1 to disable the warning. "com_hunkmegs" - Only of use if you have more than 64 MB RAM. This setting alocates more system memory to Quake 3 for player models. If you have 128 MB RAM, set this to 96; if you have 96 MB RAM, set this to 64; if you have 192 MB RAM set this to 128; and finaly if you have 256 MB RAM, then set this to 170. You could try higher numbers but your system could become unstable. "r_picmip" - This accounts for overall texture and image quality, with 0 being the best, and higher numbers being progressively worse. This setting is a major player in having a high and consistant framerate. A setting of 1 is suitable for most computers as it ensures excellent image quality with a solid, consistant framerate. Interestingly, many people prefer to use a setting of 5 as it improves visibity between players and background textures, as well as makes weapons such as the LG easier to use. "r_drawsun" - This setting I believe creates shadows in relation to where thet are towards the sunlight. Of course, you will need shadows enabled. I do not think there is a drop in FPS so if you like shadows on, then set this to enabled. "r_gamma" - Brightens/Darkens the screen. This setting varys according to the brightness on your monitor. Default is 1 but this can be set lower to darken image (eg: 0.79010) or it can be increased to brighten the image (eg: 1.10000). Experiment to find the optimal amount. "r_mapOverBrightBits" - This is a setting which controls how bright the scenary, textures and objects are. Lately, I have found this is the best way to achieve optimal image quality. This setting defaults at 2 but I would recommend setting this to 3. Secondly, lower the r_gamma setting to 0.82000 and start a new game. You should either find it too bright or too dark - adjust the gamma accordingly. I have found that setting this setting to 3 results in far more clarity and detail in the textures. "r_intensity" - As the name suggests this setting intensifies the whole image. Default is 1 and this is recommended for most users. If you play in picmip 5 mode, set this to around 1.4 to make the characters stand out more against the background. "r_finish" - This is the "Sync every frame" command in the game options. It Improves response between the keyboard/mouse and the onscreen action. You set this to 1 to stop occasional input frustration. However, you may experience slight framerate loss. "r_railWidth / r_railCoreWidth / r_railSegmentLength" - These settings adjust the way the railgun blast looks. There are so many possible configurations but here is my personal favourite: seta r_railWidth "3" Thanks to VyP3rR. "r_roundImagesDown" - Smoothes and rounds textures when they need to be resized producing slightly inferior visuals. Default is recommended. (Please note: q3dm16 will crash to the desktop if this setting is less than 1) "r_swapInterval" - Enabling this setting eliminates the slight screen ripping that appears when your framerate exceeds your monitors refresh rate. Bear in mind that although the FPS loss is not large, I found there to be a slight lag between mouse/keyboard to the on screen action. Bear in mind that if you have disabled vsync externaly (perhaps through your graphics drivers tools facilty) then this setting is bypassed. "r_detailTextures" - This is enabled by default and produces more detailed textures if available by that particular texture. With this disabled, you get slight framerate increase. "r_colorbits" - Choose between rendering colours in 16 BIT or 32 BIT. 32 BIT colour renders 16.7 million individual colours compared to 16 BIT's 65,000 but can be a large burdon on computer resources. Optimal setting is 16 BIT for framerate and 32 BIT for visuals. Be aware that your video hardware must support 32 BIT colour for you to use it. "r_texturebits" - Similar to colourbits. However, if you run at high resolutions (1024x768 or above) this can cause texture corruption in 32 BIT colour mode. You must also have a card that supports 32 BIT colour. Optimal setting is 16 BIT for framerate and 32 BIT for visuals. Be aware that your video hardware must support 32 BIT colour for you to use it. "r_dynamicLight" - With this enabled, the flare from a weapon projectile will illuminate the surrounding area creating added realism. Be aware that enabling this results in noticable framerate loss. "r_vertexLight" - When enabled, textures use no additional lightmaps for lighting effects. On a slow machine, this will speed things up considerably but the result is inferior visuals. Other benefits of enabling vertex lighting include better visibilty between players and textures, especialy when using r_picmip 5. "r_lodBias" - Produces more rounded images in the character model, objects, and pickups the lower this setting is. Through benchmarking, I have found that the default (0) is the best balance between framerate and image quality. I could see no noticable visual improvement when setting this into the low minuses (the valid range is -2 to 2) but the framerate was lower. Recommended setting is 0 (default) "r_smp" - If you have two CPU's, Windows NT or 2000, and have a graphics card AND driver which supports SMP, then you can benefit from a more sustained Framerate, which may also be noticeably higher. The default of course is 0, but if your system fulfils the above requirements then ensure you set this to 1. "r_subDivisions" - This is a texture setting which when set low, produces a better image with more curves and less graphical inacuracies. The maximum setting I would recommend is around 100 depending on the map. I like this set at 4 but feel free to experiment for the best comprimise between image quality and framerate. "r_lodCurveError" - This setting determines how close you have to be towards a texture before it clips and loses its curves. I recommend a setting between 400 - 800 depending on the power of your machine. "r_stencilBits" - This is a hardware dependent graphical setting which creates more realistic textures. Be sure to set this to 8 if your graphics card has a hardware stencil buffer. Be aware that the screen may darken with this enabled. Be sure to alter the gamma accordingly. "s_musicVolume" - Self explanatary. Bear in mind that turning off the music doesn't result in such a noticably higher framerate as in Quake 2, though the optimal setting is still disabled "s_loadas8bit" - With this set to 1, all the sounds in the game will be forced to be played with half the available sound memory. This increases framerate somewhat. "sv_pure" - Controls whether the game should be played in pure (as the developer intended) or unpure (which means that certain mods can be used). "vm_cgame / vm_game / vm_ui" - These settings MUST be set to 0 for the speed dll's to function correctly. If any of these are set to 1 in your config, then you are losing performance, so change them immediately. 1.25+ new console commands: "cg_scorePlums" - This controls whether the "scoreplum" floats above your victim when they are fragged. Not really a necessity so set this to 0. "cg_smoothClients" - When g_smoothClients is enabled on the server and you enable cg_smoothClients then players in your view will be predicted and will appear more smooth even if they are on a bad network connection (LPB's should love this feature when playing laggy HPB's). However small prediction errors might appear. "pmove_fixed" - Think of this as ID's answer to the 125Hz mod. Basicaly, with this enabled, all players will move at the same frequency (which can be changed using the pmove_msec variable) regardless of the clients framerate. The advantages include even jump physics and movement for all players. The downside is some people have found slight stuttering with this enabled (although through my experience, it is negible). If you are playing online, the server must have first enabled this option before you can use it. "pmove_msec" - Sets the time in milliseconds between two advances of the player physics. Default is 8. "r_inGameVideo" - This feature lets you view small pre-recorded videos that the map maker created to be viewed in game. This has only been implemented in Team Arena maps as I write this, but no doubt standard Q3A levels will be including such features imminently. Be aware that enabling this can have a large impact on framerate, so te optimal setting is to disable. "s_doppler" - A neat sound feature, which produces a "dopplar" effect when a projectile from a rocket sweaps past you. Disabling gives a minor framerate increase, but I like the effect and thus keep it enabled. "headmodel" - changes only the head of the model to another model. Example: If you are playing as the Grunt model, /headmodel "sarge" will stick Sarge's head on Grunt's body. Selecting a new model will load both the model and its matching head. "team_model" - changes to a model that will only be used during team game play. "team_headmodel" - changes head model to a head that will only be used during team game play. Internet connection commands: "cg_lagometer" - This is a very useful utility which lets you monitor your connection on-line. With this enabled while you are playing on-line you will see 2 bouncing lines. The first line displays the conjunction between your graphics card updating the frames in sync with the gameworld updates recieved from the server. Idealy, this should be a straight blue line. If it has bouncing yellow spikes then your display will stutter and be more difficult to view. To combat this, first ensure you have followed my tweaking techniques and then change your snaps setting. Usually, this means lowering it by until your screen is stable and you have a nice flowing blue line in your lagometer. The second line shows if packets are being recieved from the server. This should be green. If it is yellow or red, try increasing your rate or try lowering your snaps. If this does not help, you may be on a bad server so try another. The height of the line is dependent on your current ping. "cl_timenudge" - This interesting setting is identical to the pushlatency setting in Half-Life. This is very user determined and impossible to judge for every machine and every connection. I find this setting works well if you set the cl_timenudge setting to around -30 the ping you currently have with the server. If you don't like the way it affects your timing, then leave it at default (0). Use this command in conjunction with the lagometer for best results. "rate" - This setting controls packets to ensure a good connection. If you have an ISDN modem (128K) then this can be set to around 8000. If you have a 56K modem then this should be around 3000-4500 depending on your connection speed. If you are on a LAN or have ADSL modem, then this can be around 24000 or perhaps even higher. Experimentation is required to find the optimal setting. "snaps" - This is possibly the most important setting for getting a good connection. As everyone knows, in Quake 2, your gameworld updates depended on your current FPS so slower computers were at a disadvantage. Now, in Quake 3, your snaps setting determines how many updates you recieve from the server. 56K modems should have a setting of around 20. ISDN modems (128K) should be around 40 as should any other fast connection devices (LAN, T1 etc....). Remember to read my cg_lagometer section for tips on "snaps". "cl_packetdups" - As the name suggests, this setting is used to send multiple packets to compensate for lost packet drops. This setting should be set at 1 unless you have a VERY good connection in which case set this to 0. Use the lagometer to decide on which setting to use. "cl_maxPackets" - This setting puts a limit on the maximum amount of packets that can be sent to the server via the client. This setting is useful for people with slower modems. The default setting is 30 (comparable to a 56K modem), but lower this if you have a 33.6K modem or less, and higher this setting if you have an ISDN or higher modem. "com_maxFPS" - This command limits your maximum FPS. Why you would want to do this? 2 reasons. Firstly, because it will help stop the server from having lag confusion when your frame rate has a sudden rise or fall. Run a timedemo, collect your average FPS and use that as the limit for when you play on-line. Another important aspect of this setting is that your framerate determines how high you can jump. This is why getting the max_FPS setting right is so important. Have a play around until you find a figure that allows you to make the DM13 MH jump. Once you have one (try to get it as high as it can go) stick with it. Unfortunately, playing online could make achieving maximum height tricky once again. Personaly, I found that setting com_maxFPS to 83 offline and 63 online the best solution for making those long, tricky jumps. Of course, this may be totaly different for your machine so play around. "cg_deferPlayers" - A nice simple setting. With this set to 1, new player skins will only be loaded when you are either fragged or when you look at the scoreboard. With this set to 0, new player models are loaded as soon as a new player joins the server. I like this set to 1 as the screen could stutter at a potentialy crucial time meaning frustration. "cg_predictItems" - This setting determines whether the server or the client decides on whether a weapon has being collected. A setting of 1 means the client decides, and a setting of 0 means the server decides. Setting it to 1 (default) makes gameplay flow quicker for HPB's, but can cause confusion as to whether the item was picked up or not. Setting it to 0 means the server will always decide, reducing the chance of errors, but this can cause slight ldelay after the item has been picked up. I keep this set at 0 to prevent any unneccessary confusion. "cg_forceModel" - If you want to use only the same model or skin throughout, then set this to 1. Every character (human, or bot) will have the same character model as yourself. However, if you are using a custom model with a large polycount, this can hinder performance slightly. Default is 0. May 17 Quake3 控制台命令2messagemode (command) syntax: messagemode Returns the keyboard to text input for the purpose of sending messages to all players. Pressing 'ENTER' will send the message and return the keyboard to gaming functions. --------------------------------------------------------------------------------
messagemode2 (command) syntax: messagemode2 Returns the keyboard to text input for the purpose of sending messages to all players on the same team. Pressing 'ENTER' will send the message and return the keyboard to gaming functions. --------------------------------------------------------------------------------
messagemode3 (command) syntax: messagemode3 Returns the keyboard to text input for the purpose of sending messages to your current target only. Pressing 'ENTER' will send the message and return the keyboard to gaming functions. --------------------------------------------------------------------------------
messagemode4 (command) syntax: messagemode4 Returns the keyboard to text input for the purpose of sending messages to the last player to injure you only. Pressing 'ENTER' will send the message and return the keyboard to gaming functions. --------------------------------------------------------------------------------
midiinfo (command) syntax: midiinfo Reports status of MIDI control and device(s) used. --------------------------------------------------------------------------------
model (variable)(U A) syntax: model [model/skin] default: "visor/default" Sets the player model and skin. --------------------------------------------------------------------------------
modelist (command) syntax: modelist Reports all available video modes. --------------------------------------------------------------------------------
modellist (command) syntax: modellist Lists all model files loaded for the current map. --------------------------------------------------------------------------------
music (command) syntax: music [musicfile] Presumably plays a music file of some type. --------------------------------------------------------------------------------
name (variable)(U A) syntax: name [string] default: Player Sets the player name. Font color can be changed. Possible colors: 0 = Black 1 = Red 2 = Green 3 = Yellow 4 = Blue 5 = Cyan 6 = Magenta 7 = White -------------------------------------------------------------------------------- net_ip (variable)(I) syntax: net_ip [IP_address] default: localhost Allows the binding of a set IP address which is sent to the ID master server. - Kevin Crawley --------------------------------------------------------------------------------
net_noipx (variable)(I) syntax: net_noipx [0/1] default: 0 Toggles IPX network protocol. This command should be passed on the command line. 0=disables;1=enables. --------------------------------------------------------------------------------
net_noudp (variable)(I) syntax: net_noudp [0/1] default: 0 Toggles UDP/IP network protocol. This command should be passed on the command line. 0=disables;1=enables. --------------------------------------------------------------------------------
net_port (variable)(I) syntax: net_port [value] default: 27960 Specifies network server port. --------------------------------------------------------------------------------
net_socksenabled (variable)(I) syntax: net_socksenabled [0/1] default: 0 Toggles proxy and/or firewall protocol. This command should be passed on the command line. 0=disables;1=enables. --------------------------------------------------------------------------------
net_sockspassword (variable)(I) syntax: net_sockspassword [string] default: "" Sets the password on the firewall machine. This command must be passed on the command line. --------------------------------------------------------------------------------
net_socksport (variable)(I) syntax: net_socksport [value] default: 1080 Specifies proxy and/or firewall port. This command should be passed on the command line. --------------------------------------------------------------------------------
net_socksserver (variable)(I) syntax: net_socksserver [value] default: "" Specifies proxy and/or firewall server address. This command should be passed on the command line. --------------------------------------------------------------------------------
net_socksusername (variable)(I) syntax: net_socksusername [string] default: "" Sets the username on the firewall machine. This command must be passed on the command line. --------------------------------------------------------------------------------
nextdemo (variable) syntax: nextdemo [demo demoname] default: "" A string using the demo command and the filename of the next demo to load. No file extension is used. If no demo is specified by the server then no further demos will be run. Note that this cvar is unavailable until it has been set at the console or in a script file. --------------------------------------------------------------------------------
nextframe (command) syntax: nextframe [?] Unknown. See also prevframe (also unknown). --------------------------------------------------------------------------------
nextmap (variable) syntax: nextmap [mapname] default: "" A string using the map command and the filename of the next map to load. No file extension is used. If no map is specified by the server then the one specified by the currently running map will be used, if any. --------------------------------------------------------------------------------
nextskin (command) syntax: nextskin [?] Unknown. See also prevskin (also unknown). --------------------------------------------------------------------------------
noclip (command) syntax: noclip Enables noclipping mode so you can pass through world brushes. Entering the command again disables it. --------------------------------------------------------------------------------
nohealth (variable)(S A) syntax: nohealth [0/1] default: 0 Specifies if health pickups will be spawned on the map. Changes take place on the next map loaded. 0=spawn health;1=don't spawn health. --------------------------------------------------------------------------------
notarget (command) syntax: notarget Enables notarget mode so presumably bots will ignore you if they haven't seen you already. Entering the command again disables it. --------------------------------------------------------------------------------
password (variable)(U) syntax: password [string] default: "" The password required for clients to connect to the host machine. Both server and clients would need to set this. --------------------------------------------------------------------------------
path (command) syntax: path Reports the current quake3.exe search path, including .PK3 files. --------------------------------------------------------------------------------
paused (variable) syntax: paused [0/1} default: 0 Sets whether the game is paused or not. 0=disables;1=enables. --------------------------------------------------------------------------------
ping (command) syntax: ping [server] Pings a selected server. --------------------------------------------------------------------------------
play (command) syntax: play [path/.wav] Plays a .WAV file in the current game directory one time. --------------------------------------------------------------------------------
prevframe (command) syntax: prevframe [?] Unknown. See also nextframe (also unknown). --------------------------------------------------------------------------------
prevskin (command) syntax: prevskin [?] Unknown. See also nextskin (also unknown). --------------------------------------------------------------------------------
protocol (variable)(S R) syntax: protocol [value] default: 39 Sets network protocol version. Useful for backwards compatibility with servers with otherwise incompatible versions. --------------------------------------------------------------------------------
qport (variable)(I) syntax: qport [value] default: "" Sets internal network protocol port. --------------------------------------------------------------------------------
quit (command) syntax: quit Shuts down the game immediately. --------------------------------------------------------------------------------
r_allowextensions (variable)(A L) syntax: r_allowextensions [0/1] default: 1 Toggles the functions of various OpenGL extensions. 0=disables;1=enables. --------------------------------------------------------------------------------
r_allowsoftwaregl (variable)(L) syntax: r_allowsoftwaregl [0/1] default: 0 Toggles the use of the default software OpenGL driver as supplied by the Operating System platform. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ambientscale (variable)(C) syntax: r_ambientscale [value] default: 0.5 Sets the level of ambient lighting effect on entities. - badak --------------------------------------------------------------------------------
r_clear (variable)(C) syntax: r_clear [0/1] default: 0 Toggles the clearing of unrefreshed images (clears hall of mirrors effect). 0=disables;1=enables. --------------------------------------------------------------------------------
r_colorbits (variable)(A L) syntax: r_colorbits [0 to 32] default: 0 Sets color bits-per-pixel. Mutually exclusive with r_depthbits. --------------------------------------------------------------------------------
r_colormiplevels (variable)(L) syntax: r_colormiplevels [0/1] default: 0 Toggles raw RGB mipmap (texture) lighting effect. 0=disables;1=enables. --------------------------------------------------------------------------------
r_customaspect (variable)(A L) syntax: r_customaspect [0/1] default: 1 Toggles the use of a custom video mode. 0=disables;1=enables. See also r_customheight and r_customwidth. --------------------------------------------------------------------------------
r_customheight (variable)(A L) syntax: r_customheight [number of pixels] default: 1024 Defines the height of a custom resolution when r_mode is -1. Note that your hardware may not support what you select. See also r_customwidth. --------------------------------------------------------------------------------
r_customwidth (variable)(A L) syntax: r_customwidth [number of pixels] default: 1600 Defines the width of a custom resolution when r_mode is -1. Note that your hardware may not support what you select. See also r_customheight. --------------------------------------------------------------------------------
r_debuglight (variable)(C) syntax: r_debuglight [0/1] default: 0 Toggles the display of data representing the intensity of ambient light and intensity of direct light. 0=disables;1=enables. - dynamite --------------------------------------------------------------------------------
r_debugsurface (variable)(C) syntax: r_debugsurface [0/1] default: 0 Toggles the curved surfaces debugging grid on whatever curve the weapon crosshair is aimed at. Grid size determined by cm_debugsize. Grid display is also dependent on the setting r_subdivisions. 0=disables;1=enables. - dynamite --------------------------------------------------------------------------------
r_depthbits (variable)(A L) syntax: r_depthbits [0 to 32] default: 0 Sets depth bits-per-pixel. Mutually exclusive with r_colorbits. --------------------------------------------------------------------------------
r_detailtextures (variable)(A L) syntax: r_detailtextures [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_directedscale (variable)(C) syntax: r_directedscale [?] default: 1 Sets the level of direct lighting effect on entities. - badak --------------------------------------------------------------------------------
r_displayrefresh (variable)(L) syntax: r_displayrefresh [value] default: 0 Sets monitor refresh rate at the resolution the game is to be run at. This command should be passed on the command line. Note this will change your desktop refresh rate at this resolution as well. --------------------------------------------------------------------------------
r_dlightbacks (variable)(A) syntax: r_dlightbacks [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_drawbuffer (variable) syntax: r_drawbuffer [buffer] default: "GL BACK" Sets which buffer is drawn to. - Andy Lutomirski --------------------------------------------------------------------------------
r_drawentities (variable)(C) syntax: r_drawentities [0/1] default: 1 Toggles rendering of entities, including brush models. 0=disables;1=enables. --------------------------------------------------------------------------------
r_drawsun (variable)(A) syntax: r_drawsun [0/1] default: 0 Toggles the drawing of the sun and accompanying glare in the sky when r_fastsky is 0. 0=disables;1=enables. - Ryan --------------------------------------------------------------------------------
r_drawworld (variable)(C) syntax: r_drawworld [0/1] default: 1 Toggles rendering of world brushes (map architecture). Entities will still be drawn. 0=disables;1=enables. --------------------------------------------------------------------------------
r_dynamiclight (variable)(A) syntax: r_dynamiclight [0/1] default: 1 Toggles dynamic lighting. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ext_compiled_vertex_array (variable)(A L) syntax: r_ext_compiled_vertex_array [0/1] default: 1 Toggles hardware compiled vertex array rendering method if available. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ext_compress_textures (variable)(A L) syntax: r_ext_compress_textures [0/1] default: 1 Toggles hardware texture compression if available. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ext_gamma_control (variable)(A L) syntax: r_ext_gamma_control [0/1] default: 1 Toggles hardware gamma adjustments if available. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ext_multitexture (variable)(A L) syntax: r_ext_multitexture [0/1] default: 1 Toggles hardware mutitexturing if available. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ext_texenv_add (variable)(A L) syntax: r_ext_texenv_add [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_ext_texture_env_add (variable)(A L) syntax: r_ext_texture_env_add [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_faceplanecull (variable)(A) syntax: r_faceplanecull [0/1] default: 1 Toggles the culling of brush faces not in the direct view of the player. 0=disables;1=enables. --------------------------------------------------------------------------------
r_fastsky (variable)(A) syntax: r_fastsky [0/1] default: 0 Toggles rendering of sky. Setting to 1 will also disable the view through portals. 0=enables;1=disables. --------------------------------------------------------------------------------
r_finish (variable)(A) syntax: r_finish [0/1] default: 0 Toggles syncing to frames. Enabling basically instructs hardware to inform game that GL calls have been completed. 0=disables;1=enables. --------------------------------------------------------------------------------
r_flarefade (variable)(C) syntax: r_flarefade [0 to ?] default: 7 Sets scale of fading of flares in relation to distance when r_flares is 1. --------------------------------------------------------------------------------
r_flares (variable)(A) syntax: r_flares [0/1] default: 0 Toggles lighting flares effect (lights and weapon projectiles). 0=disables;1=enables. --------------------------------------------------------------------------------
r_flaresize (variable)(C) syntax: r_flaresize [0 to ?] default: 40 Adjusts the size of flares when r_flares is 1. --------------------------------------------------------------------------------
r_fullbright (variable)(C L) syntax: r_fullbright [0/1] default: 0 Toggles lightmaps when r_ext_multitexture is 0. Textures will be rendered at full brightness when enabled. See also r_lightmap. 0=disables;1=enables. --------------------------------------------------------------------------------
r_fullscreen (variable)(A L) syntax: r_fullscreen [0/1] default: 1 Toggles fullscreen rendering. When set to 0, windowed rendering is attempted. 0=disables;1=enables. --------------------------------------------------------------------------------
r_gamma (variable)(A) syntax: r_gamma [value] default: 1 Sets in-game gamma levels. --------------------------------------------------------------------------------
r_gldriver (variable)(A L) syntax: r_gldriver [video driver] default: opengl32 Specifies OpenGL driver used. --------------------------------------------------------------------------------
r_ignore (variable)(C) syntax: r_ignore [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_ignoreglerrors (variable)(A) syntax: r_ignoreglerrors [0/1] default: 1 Toggles option to ignore OpenGL errors and to attempt to continue rendering. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ignorefastpath (variable)(L) syntax: r_ignorefastpath [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_ignorehwgamma (variable)(A L) syntax: r_ignorehwgamma [0/1] default: 0 Toggles option to ignore external (not in-game) hardware gamma level setting made within Windows9x's Display Properties. 0=disables;1=enables. --------------------------------------------------------------------------------
r_ignoreoffset (variable)(A C) syntax: r_ignoreoffset [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_intensity (variable)(L) syntax: r_intensity [0 to 5] default: 1 Adjusts the overall strength of colors, with emphasis on the color White. Higher values result in higher apparent overall brightness. An alternative to adjusting gamma values, with the side effect of loss of texture details at too high a value. --------------------------------------------------------------------------------
r_lastvalidrenderer (variable)(A) syntax: r_lastvalidrenderer [video component] default: "" Reports the video hardware that last successfully rendered the Test. --------------------------------------------------------------------------------
r_lightmap (variable)(C) syntax: r_lightmap [0/1] default: 0 Toggles rendering of lightmaps without rendering textures. 0=disables;1=enables. --------------------------------------------------------------------------------
r_lockpvs (variable)(C) syntax: r_lockpvs [0/1] default: 0 Toggles the option of preventing the update of the PVS table as the player moves through the map. When set to 1 new areas entered will not be rendered. A mapper's tool. 0=disables;1=enables. --------------------------------------------------------------------------------
r_lodbias (variable)(A) syntax: r_lodbias [0 to ?] default: 0 Sets Level-Of-Detail bias. An example would be the complexity of weapon rendering. 0=highest detail. --------------------------------------------------------------------------------
r_lodcurveerror (variable) syntax: r_lodcurveerror [?] default: ? Sets rate that polygons are dropped from curved surfaces in relation to distance. --------------------------------------------------------------------------------
r_lodscale (variable)(C) syntax: r_lodscale [0 to ?] default: 5 Sets scale with which to adjust Level-Of-Detail. --------------------------------------------------------------------------------
r_logfile (variable)(C) syntax: r_logfile [0/1] default: 0 Toggles the writing of GL.LOG in the same directory as QUAKE3.EXE which records all OpenGL commands used in a game session. 0=disables;1=enables. --------------------------------------------------------------------------------
r_mapoverbrightbits (variable)(L) syntax: r_mapoverbrightbits [integer] default: 2 Sets intensity of bounced light from textures (adjusts lighting saturation) when r_vertexlight is 0. Higher values=brighter lights reflected from textures. --------------------------------------------------------------------------------
r_maskminidriver (variable)(L) syntax: r_maskminidriver [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_measureoverdraw (variable)(C) syntax: r_measureoverdraw [?] default: 0 Presumably implements sun's stenciling method of measuring overdraw. --------------------------------------------------------------------------------
r_mode (variable)(A L) syntax: r_mode [integer] default: 3 Sets a video mode. Valid resolutions: -1=Custom (see r_customaspect) 0=320x240 1=400x300 2=512x384 3=640x480 4=800x600 5=960x720 6=1024x768 7=1152x864 8=1280x1024 9=1600x1200 10=2048x1536 11=856x480 --------------------------------------------------------------------------------
r_nobind (variable)(C) syntax: r_nobind [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_nocull (variable)(C) syntax: r_nocull [0/1] default: 0 Toggles rendering of items/objects normally not seen from player's point-of-view. 0=disables;1=enables. --------------------------------------------------------------------------------
r_nocurves (variable)(C) syntax: r_nocurves [0/1] default: 0 Presumably enables/disables rendering of curves. --------------------------------------------------------------------------------
r_noportals (variable)(C) syntax: r_noportals [0/1] default: 0 Toggles player view through portals. 0=enables view;1=disables view. --------------------------------------------------------------------------------
r_norefresh (variable)(C) syntax: r_norefresh [0/1] default: 0 Toggles clearing of screen prior to re-rendering. 0=allow refresh;1=disable refresh. --------------------------------------------------------------------------------
r_novis (variable)(C) syntax: r_novis [0/1] default: 0 Toggles the option to ignore vis data when drawing the map. 0=disables;1=enables. --------------------------------------------------------------------------------
r_offsetfactor (variable)(C) syntax: r_offsetfactor [?] default: -1 Unknown. --------------------------------------------------------------------------------
r_offsetunits (variable)(C) syntax: r_offsetunits [?] default: -2 Unknown. --------------------------------------------------------------------------------
r_overbrightbits (variable)(A L) syntax: r_overbrightbits [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_picmip (variable)(A L) syntax: r_picmip [0 to 8] default: 1 Sets maximum texture size. 0=highest detail;8=unbelievably ugly. --------------------------------------------------------------------------------
r_portalonly (variable)(C) syntax: r_portalonly [0/1] default: 0 Toggles seeing what the game engine can see through a portal. When enabled, if the game engine can see a portal, nothing else will be drawn except for the area the portal can see. 0=disables;1=enables. --------------------------------------------------------------------------------
r_preloadtextures (variable)(A L) syntax: r_preloadtextures [?] default: 0 Unknown. Presumably enables/disables the preloading of texture info. --------------------------------------------------------------------------------
r_primitives (variable) syntax: r_primitives [value] default: 0 Sets rendering method. Valid settings: -1=skips drawing 0=uses glDrawelements if compiled vertex arrays are present, or strips of glArrayElement if not. 1=forces strips 2=forces drawElements --------------------------------------------------------------------------------
r_railcorewidth (variable)(A) syntax: r_railcorewidth [value] default: 16 Sets the inner trail width when the Railgun is fired. --------------------------------------------------------------------------------
r_railsegmentlength (variable)(A) syntax: r_railsegmentlength [value] default: 64 Sets the distance between the coils when the Railgun is fired. --------------------------------------------------------------------------------
r_railwidth (variable)(A) syntax: r_railwidth [value] default: 128 Sets the outer trail width when the Railgun is fired. --------------------------------------------------------------------------------
r_roundimagesdown (variable)(A L) syntax: r_roundimagesdown [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_showcluster (variable)(C) syntax: r_showcluster [0/1] default: 0 Toggles display of clusters by number as the player enters them on the currently loaded map. 0=disables;1=enables. --------------------------------------------------------------------------------
r_showimages (variable) syntax: r_showimages [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_shownormals (variable)(C) syntax: r_shownormals [0/1] default: 0 Toggles the drawing of short lines indicating brush and entity polygon vertices. See also r_showtris. 0=disables;1=enables.. --------------------------------------------------------------------------------
r_showsky (variable)(C) syntax: r_showsky [0/1] default: 0 Toggles the drawing of the sky in front of other brushes. 0=disables;1=enables. --------------------------------------------------------------------------------
r_showsmp (variable)(C) syntax: r_showsmp [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_showtris (variable)(C) syntax: r_showtris [0/1] default: 0 Toggles the drawing of polygon triangles. See also r_shownormals. 0=disables,1=enables. --------------------------------------------------------------------------------
r_simplemipmaps (variable)(A L) syntax: r_simplemipmaps [?] default: 1 Unknown. --------------------------------------------------------------------------------
r_skipbackend (variable)(C) syntax: r_skipbackend [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_smp (variable) syntax: r_smp [0/1] default: 0 Toggles multiprocessor acceleration support. 0=disables;1=enables. --------------------------------------------------------------------------------
r_speeds (variable)(C) syntax: r_speeds [0/1] default: 0 Toggles the display of map geometry data. 0=disables,1=enables. --------------------------------------------------------------------------------
r_stencilbits (variable)(A L) syntax: r_stencilbits [0 to 16] default: 8 Adjusts rendering of hardware's stencil buffer depth. --------------------------------------------------------------------------------
r_stereo (variable)(A L) syntax: r_stereo [0/1] default: 0 Toggles stereoscopic glasses feature. 0=disables;1=enables. --------------------------------------------------------------------------------
r_subdivisions (variable)(A L) syntax: r_subdivisions [1 to 999] default: 4 Sets the maximum Level-Of-Detail. An example would be the complexity of curves. 1=highest detail. --------------------------------------------------------------------------------
r_swapinterval (variable)(A) syntax: r_swapinterval [0/1] default: 0 Toggles frame swapping. 0=disables;1=enables. --------------------------------------------------------------------------------
r_texturebits (variable)(A L) syntax: r_texturebits [0 to 32] default: 0 Sets texture color depth. --------------------------------------------------------------------------------
r_texturemode (variable)(A) syntax: r_texturemode [OpenGL extension] default: GL_LINEAR_MIPMAP_NEAREST Sets texture filtering mode. Possible extensions used: GL_NEAREST (nearest interpolation filtering) GL_NEAREST_MIPMAP (nearest interpolation filtering with mipmapping) GL_LINEAR (linear interpolation filtering) GL_LINEAR_MIPMAP_NEAREST (linear interpolation filtering with nearest (bilinear) mipmapping) GL_LINEAR_MIPMAP_LINEAR (linear interpolation filtering with linear (trilinear) mipmapping) --------------------------------------------------------------------------------
r_verbose (variable)(C) syntax: r_verbose [?] default: 0 Unknown. --------------------------------------------------------------------------------
r_vertexlight (variable)(A L) syntax: r_vertexlight [0/1] default: 0 Toggles vertex lighting. Enabling would mean disabling lightmapping. 0=disables; 1=enables. See also r_lightmap. --------------------------------------------------------------------------------
r_znear (variable)(C) syntax: r_znear [distance in map units] default: 4 Sets the point from the player view origin that the game will set the near z-clipping plane and begin drawing the world. If set to less than 1 none of the world will be drawn. --------------------------------------------------------------------------------
rate (variable)(U A) syntax: rate [value] default: 3000 Sets communication rate between client and server. --------------------------------------------------------------------------------
rcon (command) syntax: rcon [password] [string] A remote command to a server. The string is the command to be executed. --------------------------------------------------------------------------------
rcon_password (variable) syntax: rcon_password [string] default: "" A password used to grant remote access for a client using the rcon command. --------------------------------------------------------------------------------
rconaddress (variable) syntax: rconaddress [IP address] default: "" The address the rcon command is sent to. --------------------------------------------------------------------------------
rconpassword (variable) syntax: rconpassword [string] default: "" A password used to grant access for an admin using the rcon command on a dedicated server. --------------------------------------------------------------------------------
record (command) syntax: record [demoname] Record a demo to the /demos/ directory. If the demoname parameter is not included, then a sequentially-numbered filename will be assigned. --------------------------------------------------------------------------------
reset (command) syntax: reset [variable] Resets a variable to its default value. --------------------------------------------------------------------------------
restart (command) syntax: restart Restarts the game on the current map. --------------------------------------------------------------------------------
s_initsound (variable) syntax: s_initsound [0/1] default: 1 Toggles using the sound system. 0=disables;1=enables. --------------------------------------------------------------------------------
s_khz (variable)(A) syntax: s_khz [value] default: 22 Sets the sampling rate, and therefore the quality of game sounds. Valid values are 11, 22 and 44(?). --------------------------------------------------------------------------------
s_loadas8bit (variable)(A) syntax: s_loadas8bit [0/1] default: 1 Toggles loading sound files as 8-bit. 0=disables;1=enables. --------------------------------------------------------------------------------
s_mixahead (variable)(A) syntax: s_mixahead [value] default: 0.2 Sets the time delay before mixing sound samples. --------------------------------------------------------------------------------
s_mixprestep (variable)(A) syntax: s_mixprestep [?] default: 0.05 Unknown. --------------------------------------------------------------------------------
s_musicvolume (variable)(A) syntax: s_musicvolume [0 to 1] default: 1 Presumably sets the music volume level. --------------------------------------------------------------------------------
s_separation (variable)(A) syntax: s_separation [value] default: 0.5 Sets the degree of stereo sound separation. --------------------------------------------------------------------------------
s_show (variable)(C) syntax: s_show [0/1] default: 0 Toggles display of paths and filenames of all sound files as they are called. 0=disables;1=enables. --------------------------------------------------------------------------------
s_testsound (variable)(C) syntax: s_testsound [0/1] default: 0 Toggles the playing of a test tone, overriding all other sounds. 0=disables;1=enables.. --------------------------------------------------------------------------------
s_volume (variable)(A) syntax: s_volume [0 to 1] default: 0.7 Sets the game sounds volume level. --------------------------------------------------------------------------------
say (command) syntax: say [string] Used by the server. The text in the string is sent to all players as a message. --------------------------------------------------------------------------------
say_team command syntax: say_team [string] The text in the string is sent to all players on the same team only, if the server settings allow. --------------------------------------------------------------------------------
scr_conspeed (variable) syntax: scr_conspeed [value] default: 3 Sets the console rise/fall and text scrolling speed. --------------------------------------------------------------------------------
screenshot (command) syntax: screenshot [levelshot/silent] Writes the current view to a .TGA file and saves it in \screenshots\. The parameters are optional. If used, the results are: levelshot = a mini screenshot will be written to the \levelshots\ folder silent = the "wrote shotXXXX.tga" report will not be displayed on the screen. - dynamite --------------------------------------------------------------------------------
sectorlist (command) syntax: sectorlist Lists sectors and number of entities in each on the currently loaded map. --------------------------------------------------------------------------------
sensitivity (variable)(A) syntax: sensitivity [value] default: 5 Sets overall sensitivity of a mouse or similar device. --------------------------------------------------------------------------------
serverinfo (command) syntax: serverinfo Shows server cvars on the local machine, including user created variables set with the sets command. Report includes: gamedate gamename sv_privateclients mapname protocol version teamflags nohealth sv_maxclients timelimit fraglimit dmflags sv_hostname cheats --------------------------------------------------------------------------------
serverrecord (command) syntax: serverrecord [?] Presumably records a demo on the host machine using all client perspectives. --------------------------------------------------------------------------------
serverstop (command) syntax: serverstop Presumably stops recording a demo begun with the serverrecord command. --------------------------------------------------------------------------------
session (variable) syntax: session [value] default: 0 Unknown. --------------------------------------------------------------------------------
session0 (variable) syntax: session0 [?] default: 0 0 1 0 Unknown. --------------------------------------------------------------------------------
set (command) syntax: set [variable] [string] Sets the value of a valid cvar or a user-created variable. --------------------------------------------------------------------------------
seta (command) syntax: set [variable] [string] Sets the value of a valid cvar or a user-created variable. It will also archive the variable and its current setting in Q3CONFIG.CFG (not user-created ones though). --------------------------------------------------------------------------------
setenv (command) syntax: setenv [variable] [string] Sets an environment variable from within the game. --------------------------------------------------------------------------------
sets (command) syntax: set [variable] [string] Sets the value of a valid cvar or a user-created variable in the same manner as set, but this cvar will be reported when the serverinfo command is executed. --------------------------------------------------------------------------------
setu (command) syntax: set [variable] [string] Sets the value of a valid cvar or a user-created variable in the same manner as set, but this cvar will be reported when the userinfo command is executed. --------------------------------------------------------------------------------
shaderlist (command) syntax: shaderlist Lists all shader files loaded on the current map. --------------------------------------------------------------------------------
showdrop (variable) syntax: showdrop [0/1] default: 0 When enabled, reports dropped packets should they occur. 0=disables;1=enables. --------------------------------------------------------------------------------
showpackets (variable) syntax: showpackets [0/1] default: 0 Toggles the running display of all packets sent and received. 0=disables;1=enables. --------------------------------------------------------------------------------
sizedown (command) syntax: sizedown Reduces the size of the play screen by reducing viewsize in 10 percent increments. --------------------------------------------------------------------------------
sizeup (command) syntax: sizeup Increases the size of the play screen by increasing viewsize in 10 percent increments. --------------------------------------------------------------------------------
skinlist (command) syntax: skinlist Lists all skin files that have been loaded on the current map. --------------------------------------------------------------------------------
snaps (variable)(U A) syntax: snaps [integer] default: 20 Sets number of snapshots (states of the game world) per second to receive from the server. Setting to 40 would mean receiving every snapshot, 20 would mean receiving every other snaphot. The value set should be a factor of 40 (i.e., 10, 20, 40) - LOKi --------------------------------------------------------------------------------
snd_restart (command) syntax: snd_restart Reinitializes the sound system so new settings can take effect. --------------------------------------------------------------------------------
soundinfo (command) syntax: soundinfo Reports status of the sound system. --------------------------------------------------------------------------------
soundlist (command) syntax: soundlist Lists all sound files loaded for the current map. --------------------------------------------------------------------------------
status (command) syntax: status Reports map loaded, and information on all connected players. --------------------------------------------------------------------------------
stoprecord (command) syntax: stoprecord Stops recording a demo begun with the demo command. Replaces stopdemo. --------------------------------------------------------------------------------
stopsound (command) syntax: stopsound Stops a currently playing sound. --------------------------------------------------------------------------------
sv_allowdownload (variable) syntax: sv_allowdownload [0/1] default: 1 Toggles whether to enable the downloading of files. 0=disables;1=enables. --------------------------------------------------------------------------------
sv_fps (variable) syntax: sv_fps [integer] default: 20 Sets the number of times per second the server will send gamesatate updates to all clients. Optimum setting dependent on available bandwidth and number of clients. - dynamite --------------------------------------------------------------------------------
sv_hostname (variable)(S A) syntax: sv_hostname [string] default: noname Sets the name of the host machine. Font color can be changed. Possible colors: 0 = Black 1 = Red 2 = Green 3 = Yellow 4 = Blue 5 = Cyan 6 = Magenta 7 = White -------------------------------------------------------------------------------- sv_keywords (variable)(S) syntax: sv_keywords [?] default: "" Unknown. --------------------------------------------------------------------------------
sv_killserver (variable) syntax: sv_killserver [0/1] default: 0 When set to 1, kills the server (shuts down map or demo) without shutting down quake3.exe. Value then returns to 0. --------------------------------------------------------------------------------
sv_mapchecksum (variable)(R) syntax: sv_mapchecksum [bytes] default: "" Reports the file size of the currently loaded map. Used to prevent cheating by ensuring all clients are not using hacked maps. -stone^mhs --------------------------------------------------------------------------------
sv_master1 (variable) syntax: sv_master1 [string] default: master3.idsoftware.com Sets the name or IP address of a master server. --------------------------------------------------------------------------------
sv_master2 (variable)(A) syntax: sv_master2 [string] default: "" Sets the name or IP address of a master server. --------------------------------------------------------------------------------
sv_master3 (variable)(A) syntax: sv_master3 [string] default: "" Sets the name or IP address of a master server. --------------------------------------------------------------------------------
sv_master4 (variable)(A) syntax: sv_master4 [string] default: "" Sets the name or IP address of a master server. --------------------------------------------------------------------------------
sv_master5 (variable)(A) syntax: sv_master5 [string] default: "" Sets the name or IP address of a master server. --------------------------------------------------------------------------------
sv_maxclients (variable)(S A L) syntax: sv_maxclients [integer] default: 8 Sets the maximum number of clients hosted on the server. --------------------------------------------------------------------------------
sv_pad (variable) syntax: sv_pad [?] default: 0 Unknown. --------------------------------------------------------------------------------
sv_privateclients (variable)(S) syntax: sv_privateclients [integer] default: 0 If set to a positive integer n, the server will reserve n connect slots for clients with the proper password. See also sv_privatepassword. (sv_maxclients) - (sv_privateclients) = (total number of public connect slots) - Sideshow_Bob, Andy Lutomirski --------------------------------------------------------------------------------
sv_privatepassword (variable) syntax: sv_privatepassword [string] default: "" Password to allow for the connection of clients to reserved slots. The client would have to set the password cvar to the same value in order to connect. See also sv_privateclients. - Sideshow_Bob, Andy Lutomirski --------------------------------------------------------------------------------
sv_reconnectlimit (variable) syntax: sv_reconnectlimit [value] default: 3 Presumably sets the number of times the server will recognize a client's reconnect command. (However, there is no reconnect command...) --------------------------------------------------------------------------------
sv_running (variable)(R) syntax: sv_running [0/1] default: 0 Reports if the server is running on the local machine. 0=server not on local machine;1=server on local machine. - LOKi --------------------------------------------------------------------------------
sv_serverid (variable)(R) syntax: sv_serverid [id #] default: "" The identification number of the local server. --------------------------------------------------------------------------------
sv_showloss (variable) syntax: sv_showloss [?] default: 0 Unknown. --------------------------------------------------------------------------------
sv_timeout (variable) syntax: sv_timeout [time in seconds] default: 120 Sets the amount of time for the server to wait for a client packet before assuming a disconnected state. --------------------------------------------------------------------------------
sv_zombietime (variable) syntax: sv_zombietime [minutes] default: 2 Sets the amount of time before removing a frozen player. --------------------------------------------------------------------------------
sv_zone (variable)(S) syntax: sv_zone [string] default: default Sets a game type for the server such as Free For All, Tournament, Team Deathmatch and Capture the Flag. - dynamite --------------------------------------------------------------------------------
sys_cpuid (variable) syntax: sys_cpuid [value] default: "" Presumably reports the CPU ID number used on the local machine. --------------------------------------------------------------------------------
sys_cpustring (variable) syntax: sys_cpustring [string] default: "" Identifies the CPU in use on the local machine. --------------------------------------------------------------------------------
systeminfo (command) syntax: systeminfo Reports settings for: g_syncronousclients sv_serverid timescale --------------------------------------------------------------------------------
tcmd (command) syntx: tcmd [?] Unknown. --------------------------------------------------------------------------------
team (command) syntax: team [string] Sets player status. Possible values: p = Player (FFA) s = Spectator blue = Blue Team red = Red Team follow# = Spectator, following player by number scoreboard = Be a scoreboard -------------------------------------------------------------------------------- teamflags (variable)(S A) syntax: teamflags [value] default: 0 Sets the game options for team play. --------------------------------------------------------------------------------
tell (command) syntax: tell [player_name or id] Sends a message to the specified player. - dynamite --------------------------------------------------------------------------------
tell_attacker (command) syntax: tell_attacker [string] Sends a message to the player who last injured you. --------------------------------------------------------------------------------
tell_target (command) syntax: tell_target [string] Sends a message to the player who you are presently targeting. --------------------------------------------------------------------------------
testgun (command) syntax: testgun [model_name] Unknown. --------------------------------------------------------------------------------
testmodel (command) syntax: testmodel [model_name] Unknown. --------------------------------------------------------------------------------
timedemo (variable)(C) syntax: timedemo [0/1] default: 0 Toggles the running of the game as fast as it can, for the purpose of benchmarking with the use of demos. 0=disables;1=enables. --------------------------------------------------------------------------------
timegraph (variable)(C) syntax: timegraph [0/1] default: 0 Toggles the display of the timegraph. 0=disables;1=enables. --------------------------------------------------------------------------------
timelimit (variable)(S A) syntax: timelimit [value] default: 0 Sets the amount of time before a game will end if fraglimit is not reached or set. Setting to 0 disables timelimit. --------------------------------------------------------------------------------
timescale (variable)(C) syntax: timescale [value] default: 1 Sets the ratio between game time and 'real' time. --------------------------------------------------------------------------------
toggle (command) syntax: toggle [cvar] Alternately sets a cvar to 0 and 1. It will affect cvars with valid setting of other than 0 or 1, so use with discretion. --------------------------------------------------------------------------------
toggleconsole (command) syntax: toggleconsole Will bring down the console if up, or raise it if down. --------------------------------------------------------------------------------
touchfile (command) syntax: touchfile [file] Unknown. --------------------------------------------------------------------------------
unbind (command) syntax: unbind [key or button] Remove a binding from a selected key or button. --------------------------------------------------------------------------------
unbindall (command) syntax: unbindall Unbinds all keys except for ESC and ` (tilde key). --------------------------------------------------------------------------------
userinfo (command) syntax: userinfo Leftover from the previous version, now broken. Replaced by clientinfo. --------------------------------------------------------------------------------
username (variable) syntax: username [string] default: "" The name of the currently logged-on user on the machine. --------------------------------------------------------------------------------
version (variable)(S R) syntax: version [string] default: "Q3T 1.05 win-x86 May 10 1999" The current version of Q3Test. --------------------------------------------------------------------------------
versionnumber (variable)(R) syntax: versionnumber [string] default: Q3T 1.06 The current version number of Q3Test. --------------------------------------------------------------------------------
vid_restart (command) syntax: vid_restart Reinitializes the video system so new settings can take effect. --------------------------------------------------------------------------------
vid_xpos (variable)(A) syntax: vid_xpos [number of pixels] default: 3 Positions the game screen the specified number of pixels from the left edge of the monitor screen when in windowed mode. --------------------------------------------------------------------------------
vid_ypos (variable)(A) syntax: vid_ypos [number of pixels] default: 22 Positions the game screen the specified number of pixels from the top edge of the monitor screen when in windowed mode. --------------------------------------------------------------------------------
viewlog (variable)(C) syntax: viewlog [0/1] default: 0 Toggles the display of the startup console window over the game screen. 0=disables;1=enables. --------------------------------------------------------------------------------
viewpos (command) syntax: viewpos Displays the players coordinate position (x-y-z) on the loaded map and the direction he is facing in degrees. --------------------------------------------------------------------------------
viewsize (variable)(A) syntax: viewsize [value] default: 100 Sets the size of the play screen as a percentage of the monitor screen. Maximum value=100. --------------------------------------------------------------------------------
vm_cgame (variable)(A) syntax: vm_cgame [value] default: 0 Unknown. --------------------------------------------------------------------------------
vmprofile (command) syntax: vmprofile [?] Unknown. --------------------------------------------------------------------------------
vmsg (command) syntax: vmsg [string] Same as the say command, except a sound file is played along with the message. The command is present but appears broken. --------------------------------------------------------------------------------
vmsg_team (command) syntax: vmsg_team [string] Same as the say_team command, except a sound file is played along with the message. The command is present but appears broken. --------------------------------------------------------------------------------
vstr (command) syntax: vstr [user-created variable] Executes a variable command created with set, seta, sets or setu. --------------------------------------------------------------------------------
wait (command) syntax: wait [integer] Waits the specified number of game tics (0.1 seconds?). If no parameter is used it will default to a single game tic. Used in command strings to allow enough time for a command to be executed before proceeding to the next. --------------------------------------------------------------------------------
weapnext (command) syntax: weapnext Selects the next available higher numbered weapon in sequence. See also weapprev. --------------------------------------------------------------------------------
weapon (command) syntax: weapon [integer] Selects the weapon specified by the parameter. Valid choices: 1 = Gauntlet 2 = Machinegun 3 = Shotgun 4 = Grenade Launcher 5 = Rocket Launcher 6 = Lightning Gun 7 = Railgun 8 = Plasma Gun 9 = BFG10K 10 = Grappling Hook --------------------------------------------------------------------------------
weapprev (command) syntax: weapprev Selects the next available lower numbered weapon in sequence. See also weapnext. --------------------------------------------------------------------------------
win_hinstance (variable)(R) syntax: win_hinstance [instance_value] default: 4194304 The Windows handle assigned to quake3.exe. Presumably used for debugging and/or for a mod to retrieve a handle to the Q3 application. - Zeb, Andy Lutomirski --------------------------------------------------------------------------------
win_wndproc (variable)(R) syntax: win_wndproc [?] default: 4368704 Presumably the WndProc for the Quake3 window. - Andy Lutomirski --------------------------------------------------------------------------------
writeconfig (command) syntax: writeconfig [?] Unknown. --------------------------------------------------------------------------------
z_stats (command) syntax: z_stats Displays memory and block usage. -------------------------------------------------------------------------------- zoomfov (variable*)(A) syntax: zoomfov [value in degrees] default: 22.5 Sets the size of the field of view when +zoom is active. Sensitivity scales automatically with the change in field of view. Maximum value=160. Quake3 控制台命令1Quake III Console
转自 http://www.terta.de/lwt/docs/q3commands.html
cg_animspeed (variable)(C) syntax: cg_animspeed [0/1] default: 1 Toggles player animations. 0=disables;1=enables. See also cg_noplayeranims. --------------------------------------------------------------------------------
cg_autoswitch (variable)(A) syntax: cg_autoswitch [0/1] default: 1 Toggles the automatic switching to the weapon the player has just picked up. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_bobpitch (variable)(A) syntax: cg_bobpitch [value] default: 0.002 Sets how much the player view pitches forward and back when moving. --------------------------------------------------------------------------------
cg_bobroll (variable)(A) syntax: cg_bobroll [value] default: 0.002 Sets how much the player view rolls from side to side when moving. --------------------------------------------------------------------------------
cg_bobup (variable)(A) syntax: cg_bobup [value] default: 0.005 Sets how much the player view bobs up and down when moving. --------------------------------------------------------------------------------
cg_brasstime (variable) syntax: cg_brasstime [value] default: ? Sets how long weapon effects (like the ejected shells from the shotgun) will be rendered. Setting to 0 disables this effect entirely. --------------------------------------------------------------------------------
cg_centertime (variable)(C) syntax: cg_centertime [time in seconds] default: 3 Sets how long messages are displayed in the center of the screen. If set to 0 no messages will appear. --------------------------------------------------------------------------------
cg_debuganim (variable)(C) syntax: cg_debuganim [0/1] default: 0 Presumably enables/disables debugging of model animations. --------------------------------------------------------------------------------
cg_debugevents (variable)(C) syntax: cg_debugevents [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_debugposition (variable)(C) syntax: cg_debugposition [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_demolook (variable)(C) syntax: cg_demolook [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_draw2d (variable) syntax: cg_draw2d [0/1] default: 1 Toggles display of 2D items on the screen. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_draw3dicons (variable) syntax: cg_draw3dicons [0/1] default: 1 Toggles the drawing of the 3D ammo, skin, and armor icons. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawammowarning (variable)(A) syntax: cg_drawammowarning [0/1] default: 1 Toggles the "Low on Ammo" warning on the player screen. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawattacker (variable)(A) syntax: cg_drawattacker [0/1] default: 1 Toggles the display of the last guy to do damage to you in the upper-right corner of the screen. If you hurt yourself, that guy will be you. 0=disables;1=enables. Replaces cg_drawkiller. --------------------------------------------------------------------------------
cg_drawcrosshair (variable)(A) syntax: cg_drawcrosshair [0/1] default: 1 Toggles the drawing of the crosshair. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawcrosshairnames (variable)(A) syntax: cg_drawcrosshairnames [0/1] default: 1 Toggles the ID display of other players when your crosshair is on them. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawfps (variable)(A) syntax: cg_drawfps [0/1] default: 0 Toggles the frame rate counter. This cannot be displayed at the same time as the timer. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawsnapshot (variable)(A) syntax: cg_drawsnapshot [value] default: 0 Toggles the display of the snapshot count. This cannot be displayed at the same time as the frame rate counter or the timer. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawstatus (variable)(A) syntax: cg_drawstatus [0/1] default: 1 Toggles the drawing of the HUD, the crosshair and any text or readout. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_drawtimer (variable)(A) syntax: cg_drawtimer [0/1] default: 1 Toggles the game timer. This cannot be displayed at the same time as the frame rate counter. 1=disables;0=enables. --------------------------------------------------------------------------------
cg_errordecay (variable) syntax: cg_errordecay [?] default: 100 Unknown. --------------------------------------------------------------------------------
cg_extrapolate (variable) syntax: cg_extrapolate [?] default: 1 Unknown. --------------------------------------------------------------------------------
cg_footsteps (variable)(C) syntax: cg_footsteps [0/1] default: 1 Toggles player footstep sounds. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_gibs (variable)(A) syntax: cg_gibs [0/1] default: 1 Toggles the rendering of gibs. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_gun (variable)(A) syntax: cg_gun [0/1] default: 1 Toggles the rendering of the weapon model. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_ignore (variable) syntax: cg_ignore [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_lagometer (variable)(A) syntax: cg_lagometer [0/1] default: 1 Toggles between displaying the netgraph or the frag counter. 0=display frag counter;1=display netgraph. - Enforcer --------------------------------------------------------------------------------
cg_markoffset (variable)(C) syntax: cg_markoffset [value] default: 1 Presumably sets the offset of the gunshot marks but no effect was noted. --------------------------------------------------------------------------------
cg_marks (variable)(A) syntax: cg_marks [0/1] default: 1 Toggles gunshot marks on the walls, etc. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_noplayeranims (variable)(C) syntax: cg_noplayeranims [0/1] default: 0 Toggles player model animations. The animation frame displayed when this is disabled is rather odd, though. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_nopredict (variable) syntax: cg_nopredict [0/1] default:0 Toggles client-side player prediction. Disabling causes the client to wait for updates from the server before updating the local machine. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_railtrailtime (variable)(A) syntax: cg_railtrailtime [value] default: 400 Sets the amount of time the railgun slug trail is visible. --------------------------------------------------------------------------------
cg_runpitch (variable)(A) syntax: cg_runpitch [value] default: 0.002 Appears to do nothing. --------------------------------------------------------------------------------
cg_runroll (variable)(A) syntax: cg_runroll [value] default: 0.005 Appears to do nothing. --------------------------------------------------------------------------------
cg_shadows (variable)(A) syntax: cg_shadows [integer] default: 1 Sets type of shadows rendering when cg_marks is set to 1. Possible values: 0=no shadows 1=ordinary shadows 2=stencil buffer shadows (r_stencilbits must be set to 8) 3=very dark stencil buffer shadows (r_stencilbits must be set to 8) -------------------------------------------------------------------------------- cg_showmiss (variable) syntax: cg_showmiss [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_simpleitems (variable)(A) syntax: cg_simpleitems [0/1] default: 0 Toggles the drawing of weapon, ammo, powerups, health and armor entities as models or as sprites. 0=draw models;1=draw sprites. --------------------------------------------------------------------------------
cg_stats (variable) syntax: cg_stats[0/1] default: 0 Toggles the display of running count of client frames. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_stereoseparation (variable)(A) syntax: cg_stereoseparation [value] default: 0.4 Sets the degree of stereoscopic separation when r_stereo is 1. --------------------------------------------------------------------------------
cg_swingspeed (variable)(C) syntax: cg_swingspeed [value] default: 0.3 Sets how quickly the player model turns to match a new direction the player is facing. When set to 1 the model follows the turn with no delay, when set to 0 it will not turn (but will continue trying). --------------------------------------------------------------------------------
cg_teamchattime (variable)(A) syntax: cg_teamchattime [value] default: 3000 Adjusts the time team messages are displayed in bright red or blue box in the middle of the screen. Setting to "0" would causes just a one time quick flash (hardly noticeable). - burn --------------------------------------------------------------------------------
cg_temp (variable) syntax: cg_temp [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_testentities (variable)(C) syntax: cg_testentities [?] default: 0 Unknown. --------------------------------------------------------------------------------
cg_thirdperson (variable)(C) syntax: cg_thirdperson [0/1] default: 0 Toggles third person view. 0=disables;1=enables. --------------------------------------------------------------------------------
cg_thirdpersonangle (variable)(C) syntax: cg_thirdpersonangle [value in degrees] default: 0 Sets the viewing angle on the horizontal plane when cg_thirdperson is set to 1. --------------------------------------------------------------------------------
cg_thirdpersonrange (variable)(C) syntax: cg_thirdpersonrange [value] default: 40 Sets the viewing distance from the player when cg_thirdperson is set to 1. --------------------------------------------------------------------------------
cg_tracerchance (variable)(C) syntax: cg_tracerchance [?] default: 0.4 Unknown. Presumably adjusts a lightning gun effect. --------------------------------------------------------------------------------
cg_tracerlength (variable)(C) syntax: cg_tracerlength [?] default: 100 Unknown. Presumably adjusts a lightning gun effect. --------------------------------------------------------------------------------
cg_tracerwidth (variable)(C) syntax: cg_tracerwidth [?] default: 1 Unknown. Presumably adjusts a lightning gun effect. --------------------------------------------------------------------------------
cg_waveamplitude (variable)(C) syntax: cg_waveamplitude [?] default: 1 Unknown. --------------------------------------------------------------------------------
cg_wavefrequency1 (variable)(C) syntax: cg_wavefrequency1 [?] default: 0.4 Unknown. --------------------------------------------------------------------------------
changevectors (command) syntax: changevectors [definition] Unknown. --------------------------------------------------------------------------------
cheats (variable)(R) syntax: cheats [0/1] default: 1 Reports the ability to use commands and variables coded as cheats. Enabled until a map is loaded. Stays enabled if a map is loaded with the "devmap" command. 0=disabled;1=enabled. --------------------------------------------------------------------------------
cinematic (command) syntax: cinematic [videoname] Presumably plays a cinematic from the \videos\ directory. --------------------------------------------------------------------------------
cl_anglespeedkey (variable) syntax: cl_anglespeedkey [value] default: 1.5 Seems to have no effect. --------------------------------------------------------------------------------
cl_avidemo (variable) syntax: cl_avidemo [screenshots per second] default: 0 Writes .TGA files of the current game screen for the creation of an .AVI file using the appropriate editing tool. Setting to 0 disables cl_avidemo. See also screenshot. - Ryan --------------------------------------------------------------------------------
cl_debugmove (variable) syntax: cl_debugmove [?] default: 0 Unknown. --------------------------------------------------------------------------------
cl_freezedemo (variable) syntax: cl_freezedemo [0/1] default: 0 When set to 1, stops the playback of a demo. Value then returns to 0. --------------------------------------------------------------------------------
cl_maxpackets (variable)(A) syntax: cl_maxpackets [5-100] default: 30 Sets maximum client transmission packet size. Optimum setting dependent on hardware type and connection quality. This setting is ignored during LAN play. --------------------------------------------------------------------------------
cl_motd (variable) syntax: cl_motd [?] default: 1 Toggles the sending of the GL_RENDERER string to id's Message of the Day server. The server then responds back with a message of the day. 0=disables;1=enables. --------------------------------------------------------------------------------
cl_mouseaccel (variable)(A) syntax: cl_mouseaccel [value] default: 0 Sets degree of mouse acceleration. Higher numbers=higher acceleration. Setting to 0 disables it. - Alexander Kaiser --------------------------------------------------------------------------------
cl_nodelta (variable) syntax: cl_nodelta [0/1] default: 0 Toggles delta compression on connection. 0=delta compression;1=no delta compression. --------------------------------------------------------------------------------
cl_noprint (variable) syntax: cl_noprint [0/1] default: 0 Toggles the writing of console echoes and player messages in the console buffer, and therefore on the screen. 0=display text;1=don't display text. - LOKi --------------------------------------------------------------------------------
cl_packetdup (variable)(A) syntax: cl_packetdup [0-5] default: 1 Presumably sets the number of times the client sends duplicate packets to the server to compensate for packet loss. - dynamite --------------------------------------------------------------------------------
cl_pitchspeed (variable)(A) syntax: cl_pitchspeed [value] default: 140 Sets the pitch rate when +lookup and/or +lookdown is active. --------------------------------------------------------------------------------
cl_run (variable)(A) syntax: cl_run [0/1] default: 1 Toggles 'always run'. 0=disables;1=enables. --------------------------------------------------------------------------------
cl_running (variable)(R) syntax: cl_running [0/1] default: 1 Reports if the server is running on the local machine. 0=server not on local machine;1=server on local machine. - dynamite --------------------------------------------------------------------------------
cl_showmouserate (variable) syntax: cl_showmouserate [0/1] default: 0 Toggles the display of mouse input info. The first number displays the degree of change when mouse input is received and the second the sensitivity value. 0=disables;1=enables. --------------------------------------------------------------------------------
cl_shownet (variable) syntax: cl_shownet [0/1] default: 0 Toggles the display of numbers presumably reporting some sort of net status. 0=disables;1=enables. --------------------------------------------------------------------------------
cl_showtimedelta (variable) syntax: cl_showtimedelta [0/1] default: 0 Toggles the display of numbers, purpose unknown. 0=disables;1=enables. --------------------------------------------------------------------------------
cl_timenudge (variable) syntax: cl_timenudge [time in seconds] default: 0 Sets time delay between player input and game update. Serves as adding a lag effect to a local connection. --------------------------------------------------------------------------------
cl_timeout (variable) syntax: cl_timeout [time in seconds] default: 125 Sets the amount of time for the client to wait for a server packet before assuming a disconnected state. --------------------------------------------------------------------------------
cl_updateinfostring (variable)(R) syntax: cl_updateinfostring [?] default: "" Default values are not set, and is only used internally. Updates the client info string for the dumpuser report. - dynamite --------------------------------------------------------------------------------
cl_yawspeed (variable)(A) syntax: cl_yawspeed [value] default: 140 Sets the yaw rate when +left and/or +right is active. --------------------------------------------------------------------------------
clear (command) syntax: clear Clears the console buffer (removes text). --------------------------------------------------------------------------------
clientinfo (command) syntax: clientinfo Shows user cvars on the local machine, including user created variables set with the setu command. Report includes: rate, snaps, model, snd, color, handicap, name, status, current server address --------------------------------------------------------------------------------
cm_debugsize (variable) syntax: cm_debugsize [value] default: 2 Sets the size of the debug surface grid for curved surfaces when r_debugsurface is 1. - dynamite --------------------------------------------------------------------------------
cm_noareas (variable)(C) syntax: cm_noareas [?] default: 0 Unknown. --------------------------------------------------------------------------------
cm_nocurves (variable)(C) syntax: cm_nocurves [0/1] default: 0 Toggles the ability of the player bounding box to clip through curved surfaces. 0=disables;1=enables. See also cm_playercurveclip. --------------------------------------------------------------------------------
cm_playercurveclip (variable)(A C) syntax: cm_playercurveclip [0/1] default: 1 Toggles the ability of the player bounding box to respect curved surfaces. 0=disables;1=enables. See also cm_nocurves. --------------------------------------------------------------------------------
cmd (command) syntax: cmd [command] Executes a valid command. Usage generally not necessary. --------------------------------------------------------------------------------
cmdlist (command) syntax: cmdlist Reports to the console all console commands listed. --------------------------------------------------------------------------------
color (variable)(U A) syntax: color [integer] default: 4 Sets the effects color for the railgun. 1=Blue 2=Green 3=Cyan 4=Red 5=Magenta 6=Yellow 7=White -------------------------------------------------------------------------------- com_dropsim (variable)(C) syntax: com_dropsim [?] default: 0 Unknown. --------------------------------------------------------------------------------
com_hunkmegs (variable)(A L) syntax: com_hunkmegs [Mb] default: 20 Sets the amount of memory that QUAKE3.EXE will allocate for itself. - dynamite --------------------------------------------------------------------------------
com_maxfps (variable)(A) syntax: com_maxfps[integer] default: 100 Sets the frames/second cap. Disabled when timedemo is 1. --------------------------------------------------------------------------------
com_showtrace (variable)(C) syntax: com_showtrace [0/1] default=0 Toggles running display of some sort of data. 0=disables;1=enables. --------------------------------------------------------------------------------
com_speeds (variable) syntax: com_speeds [0/1] default=0 Toggles the reporting of game speed data. Output includes (time in milliseconds): All; SV (server time); EV(?); CL (client time); GM (game time); RF (renderer time). 0=disables;1=enables. - dynamite --------------------------------------------------------------------------------
con_notifytime (variable) syntax: con_notifytime [time in seconds] default: 3 Sets the amount of time console messages will appear on the screen. When set to 0 no messages appear. --------------------------------------------------------------------------------
conback (variable) syntax: conback [path/filename] default: "gfx/2d/conback.tga" Sets the image file used as the console background. --------------------------------------------------------------------------------
condump (command) syntax: condump [filename.extension] Writes a file in the working directory containing all text in the console buffer. --------------------------------------------------------------------------------
configstrings (command) syntax: configstrigs Reports server configuration info. --------------------------------------------------------------------------------
connect (command) syntax: connect [IP address] [port] Connects to a server. If no port is specified the default port is used. --------------------------------------------------------------------------------
crash (command) syntax: crash Crashes Q3Test immediately. Be prepared to reset your desktop resolution. --------------------------------------------------------------------------------
crosshairhealth (variable)(A) syntax: crosshairhealth [0/1] default: 1 Toggles the color-changing property of the crosshair based on the player's current health. 0=disables;1=enables. --------------------------------------------------------------------------------
crosshairsize (variable)(A) syntax: crosshairsize [value] default: 24 Sets the size of the crosshair. --------------------------------------------------------------------------------
cvar_restart (command) syntax: cvar_restart Returns all console variables to their default settings. Does not affect key bindings. --------------------------------------------------------------------------------
cvarlist (command) syntax: cvarlist Reports to the console all console variables listed, and their current values. --------------------------------------------------------------------------------
demo (command) syntax: demo [demoname.dm2] Plays a pre-recorded demo. --------------------------------------------------------------------------------
debuggraph (variable)(C) syntax: debuggraph [0/1] default: 0 Toggles the display of some sort of graph, presumably for debugging purposes. 0=disables;1=enables. --------------------------------------------------------------------------------
dedicated (variable)(L) syntax: dedicated [value] default: 0 Toggles the use of the server as dedicated, meaning no graphic environment. This command should be passed on the command line. Valid values: 0=disables 1=enables for internet use, updating id's master server list 2=enables for LAN play -------------------------------------------------------------------------------- developer (variable) syntax: developer [integer] default: 0 Toggles the display of file loadings, errors and cvar change reports on the console. Seems to only have an on/off state. 0=disables;1=enables. --------------------------------------------------------------------------------
devmap (command) syntax: devmap [mapname] Loads a map file specifying cheats 1. The .BSP file extension is not required. See also map. --------------------------------------------------------------------------------
dir (command) syntax: dir [dir] [extension] Reports the contents of a directory. Examples: If you want to see your "scripts" folder, enter: dir scripts If you want to see your "quake3" folder, enter: dir ../ If you want to see your config files, enter: dir ..\baseq3\*.cfg - badak --------------------------------------------------------------------------------
disconnect (command) syntax: disconnect Disconnects the client from the server. --------------------------------------------------------------------------------
dmflags (variable)(A S) syntax: dmflags [value] default: 0 Sets the game options for deathmatch play. --------------------------------------------------------------------------------
dumpuser (command) syntax: dumpuser [userid] Reports info on the specified user. Info includes: name, handicap, color, snd, model, snaps, rate --------------------------------------------------------------------------------
echo (command) syntax: echo [string] Echoes text to the console on the local machine. --------------------------------------------------------------------------------
error (command) syntax: error [string] Causes Q3Test to quit with the error message specified in the string. Will leave the intial Q3Test startup window on the desktop. --------------------------------------------------------------------------------
exec (command) syntax: exec [filename.cfg] Loads a configuration file. --------------------------------------------------------------------------------
fixedtime (variable)(C) syntax: fixedtime [value] default: 0 Sets how fast the game runs. Setting to 0 disables fixedtime. Similar to timescale but frames are not dropped to maintain speed scale. - dynamite --------------------------------------------------------------------------------
follow (command) syntax: follow [player_name or id] Follows indicated player when in team is "s" (spectator mode). --------------------------------------------------------------------------------
fov (variable)(A) syntax: fov [value in degrees] default: 90 Sets the size of the field of view. Values over 90 do not prevent the gun model from appearing. Maximum value=160. --------------------------------------------------------------------------------
fraglimit (variable)(S A) syntax: fraglimit [value] default: 20 Sets the number of frags required for the game to be won if timelimit has been not reached or set. Setting to 0 disables fraglimit. --------------------------------------------------------------------------------
freelook (variable)(A) syntax: freelook [0/1] default: 1 Toggles the use of "always look", so that the mouse or similar device is used for looking and turning rather than movement. 0=disables;1=enables. --------------------------------------------------------------------------------
freeze (command) syntax: freeze [time in seconds] Freezes the game for the specified number of seconds. --------------------------------------------------------------------------------
fs_basepath (variable)(I) syntax: fs_basepath [drive\path\quake3_dir] default: C:\Q3TEST Sets the drive and directory where QUAKE3.EXE and associated files are located. - various --------------------------------------------------------------------------------
fs_cdpath (variable)(I) syntax: fs_cdpath [drive\path\cd_dir] default: "" Presumably sets the CD drive and directory where QUAKE3.EXE should read files from. -various --------------------------------------------------------------------------------
fs_copyfiles (variable)(I) syntax: fs_copyfiles [?] default: 0 Unknown. --------------------------------------------------------------------------------
fs_debug (variable) syntax: fs_debug [0/1] default: 0 Toggles the reporting of debugging info when files are accessed. 0=disables;1=enables. - dynamite --------------------------------------------------------------------------------
fs_game (variable)(S I) syntax: fs_game [game_dir] default: "" The game directory QUAKE3.EXE should read files from first, and where it will write files. Used for mods. - various --------------------------------------------------------------------------------
fs_restrict (variable)(I) syntax: fs_restrict [0/1] default: 1 Toggles restiction of use of the other fs_* cvars. This cannot be changed in the Test, which runs in restricted demo mode. 0=disables;1=enables. - dynamite --------------------------------------------------------------------------------
g_arenaname (variable)(R) syntax: g_arenaname [?] default: 0 Unknown. --------------------------------------------------------------------------------
g_arenarank (variable)(A) syntax: g_arenarank [?] default:"" Unknown. --------------------------------------------------------------------------------
g_arenascores (variable)(A) syntax: g_arenascores [?] default:"" Unknown. --------------------------------------------------------------------------------
g_debugalloc (variable) syntax: g_debugalloc [?] default: 0 Unknown. --------------------------------------------------------------------------------
g_debugmove (variable) syntax: g_debugmove [?] default: 0 Unknown. --------------------------------------------------------------------------------
g_forcerespawn (variable) syntax: g_forcerespawn [time in seconds] default: 20 Sets the amount of time a killed player will be forceably respawned. Setting to 0 disables g_forcerespawn. --------------------------------------------------------------------------------
g_gametype (variable)(S A L) syntax: g_gametype [value] default: 0 Sets the type of game played. Possible values: 0=FFA 1=Tournament(One on One) 2=Team Deathmatch 3=Capture the Flag -------------------------------------------------------------------------------- g_gravity (variable) syntax: g_gravity [value] default: 800 Sets the gravity level. This is normally set by a property of the map loaded. --------------------------------------------------------------------------------
g_inactivity (variable) syntax: g_inactivity [time in seconds] default: 0 Presumably sets the amount of time a player can remain inactive before kicked, or given some sort of no-camping warning. - value definition by burn --------------------------------------------------------------------------------
g_knockback (variable) syntax: g_knockback [value] default: 1000 Sets the amount of knockback effect a player recieves from weapon fire. --------------------------------------------------------------------------------
g_log (variable)(A) syntax: g_log [0/1] default: 1 Toggles the writing of GAMES.LOG in the current game directory, which logs gameplay events in the current session. 0=disables;1=enables. --------------------------------------------------------------------------------
g_maxgameclients (variable)(S A L) syntax: g_maxgameclients [value] default: 0 Unknown. --------------------------------------------------------------------------------
g_motd (variable) syntax: g_motd [string] default: "" Sets server message-of-the-day which appears when you log on to a server. Font color can be changed. Possible colors: 0 = Black 1 = Red 2 = Green 3 = Yellow 4 = Blue 5 = Cyan 6 = Magenta 7 = White --------------------------------------------------------------------------------
g_passwords (variable)(U) syntax: g_passwords [string] default: "" Sets a password for a private game by the server. Clients would need to specify the password also. See also password. --------------------------------------------------------------------------------
g_quadfactor (variable) syntax: g_quadfactor [value] default: 3 Sets the damage multiplier of the quad. --------------------------------------------------------------------------------
g_restarted (variable) syntax: g_restarted [value] default: 0 Unknown. --------------------------------------------------------------------------------
g_singleplayer (variable)(R) syntax: g_singleplayer [value] default: 0 Unknown. --------------------------------------------------------------------------------
g_speed (variable) syntax: g_speed [value] default: 320 Sets the maximum speed a player can move. --------------------------------------------------------------------------------
g_syncronousclients (variable) syntax: g_syncronousclients [0/1] default: 1 Toggles syncing of all clients movements. Must be enabled for recording demos of a game session. 0=disables;1=enables. --------------------------------------------------------------------------------
g_weaponrespawn (variable) syntax: g_weaponrespawn [time in seconds] default: 5 Sets the amount of time to wait before respawning weapons. Setting to 0 causes the weapons to respawn instantly. --------------------------------------------------------------------------------
g_warmup (variable)(A) syntax: g_warmup [time in seconds] default: 5 Sets the amount of warmup time in Tournament mode. --------------------------------------------------------------------------------
gamedate (variable)(R) syntax: gamedate [string] default: "May 10 1999" The release date of the current version. --------------------------------------------------------------------------------
gamename (variable)(S R) syntax: gamename [dir name] default: demoq3 The game directory quake3.exe is working. --------------------------------------------------------------------------------
gfxinfo (command) syntax: gfxinfo Reports current graphics rendering info, including: OpenGL extensions loaded, color depth, resolution, status of multithreaded support and the state of some rendering options. --------------------------------------------------------------------------------
give (command) syntax: give [weapon, item, or ammo] A cheat to give yourself something. Valid choices (not a complete list): all (all weapons, 999 ammo of all types, 200 armor) shotgun grenade launcher rocket launcher flamethrower railgun plasma gun lightning gun bfg10k grappling hook bullets (50 - machinegun ammo) shells (10 - shotgun ammo) grenades (5 - grenade launcher ammo) rockets (5 - rocket launcher ammo) slugs (20 - railgun ammo) cells (30 - plasma gun ammo) armor (200) quad damage personal teleporter medkit flight speed invisibility regeneration -------------------------------------------------------------------------------- globalservers (command) syntax: globalservers [zone] Searches for servers on the internat. --------------------------------------------------------------------------------
god (command) syntax: god Enables invulnerability mode. Entering the command again disables it. --------------------------------------------------------------------------------
graphheight (variable)(C) syntax: graphheight [number of pixels] default: 32 Sets the height of a displayed graph. --------------------------------------------------------------------------------
graphscale (variable)(C) syntax: graphscale [value] default: 1 Sets the scale of the lines in a displayed graph. --------------------------------------------------------------------------------
graphshift (variable)(C) syntax: graphshift [value] default: 0 Setting shifts all graph lines up or down on a displayed graph. --------------------------------------------------------------------------------
gun_x (variable)(C) syntax: gun_x [value] default: 0 Determines the position the gun model will be drawn along the x axis. --------------------------------------------------------------------------------
gun_y (variable)(C) syntax: gun_y [value] default: 0 Determines the position the gun model will be drawn along the y axis. --------------------------------------------------------------------------------
gun_z (variable)(C) syntax: gun_z [value] default: 0 Determines the position the gun model will be drawn along the z axis. --------------------------------------------------------------------------------
gun_frame (variable)(C) syntax: gun_frame [0 to 8] default: 0 Determines the gun model animation frame drawn. Setting to 0 allows normal animation. --------------------------------------------------------------------------------
handicap (variable)(U A) syntax: handicap [number of health points] default: 100 Sets the maximum health of the player when spawned. Setting to a lower number while alive causes the health to slowly erode. Values of 0 and those greater than 100 are ignored. --------------------------------------------------------------------------------
heartbeat (command) syntax: heartbeat Sends an update from the server to the master server with the result of updating server info. --------------------------------------------------------------------------------
hunk_stats (command) syntax: hunkstats Reports how much memory is in use. - dynamite --------------------------------------------------------------------------------
imagelist (command) syntax: imagelist Lists all image files loaded for the current map. --------------------------------------------------------------------------------
in_debugjoystick (variable) syntax: in_debugjoystick [0/1] default: 0 Unknown. --------------------------------------------------------------------------------
in_joyball (variable)(A) syntax: in_joyball [0/1] default: 0 Toggles polling the port used for game controller input, recognizing r, u, andv game controller axes. 0=disables;1=enables. --------------------------------------------------------------------------------
in_joyballscale (variable)(A) syntax: in_joyball [value] default: 0.02 Sets overall sensitivity for a game controller trackball, like that of a PantherXL. --------------------------------------------------------------------------------
in_joystick (variable)(A L) syntax: in_joystick [0/1] default: 0 Toggles polling the port used for game controller input, recognizing x, y, and z game controller axes. 0=disables;1=enables. --------------------------------------------------------------------------------
in_midi (variable)(A) syntax: in_midi [?] default: 0 Presumably enables/disables the use of MIDI music. --------------------------------------------------------------------------------
in_midichannel (variable)(A) syntax: in_midichannel [?] default: 1 Presumably sets number of MIDI channels. --------------------------------------------------------------------------------
in_mididevice (variable)(A) syntax: in_mididevice [?] default: 0 Presumably enables/disables the use of a MIDI device. --------------------------------------------------------------------------------
in_midiport (variable)(A) syntax: in_midiport [?] default: 1 Presumably enables/disables the MIDI input port. --------------------------------------------------------------------------------
in_mouse (variable)(A L) syntax: in_mouse [0/1] default: 1 Toggles polling the port used for mouse input. 0=disables;1=enables. --------------------------------------------------------------------------------
in_restart (command) syntax: in_restart Reinitializes the input system so new settings can take effect. --------------------------------------------------------------------------------
journal (variable)(I) syntax: journal [0/1] default: 0 Sets whether the file JOURNAL.DAT is written in the game directory QUAKE3.EXE is working. 0=don't write file;1=write file. - badak --------------------------------------------------------------------------------
kick (command) syntax: kick [player name or id] Kicks a player off the server. --------------------------------------------------------------------------------
kill (command) syntax: kill Commit suicide. --------------------------------------------------------------------------------
levelshot (command) syntax: levelshot This server command causes the current game to end as if fraglimit or timelimit has been reached, and writes a mini screenshot to the \levelshots\ directory if the command is executed by a player in the game - dynamite --------------------------------------------------------------------------------
localservers (command) syntax: localservers Searches for servers on a LAN. --------------------------------------------------------------------------------
logfile (variable) syntax: logfile [0/1/2] default: 0 Writes all console events to qconsole.log in the current game directory. 0=don't write log;1=write log;2=append log (appending does not seem to work). --------------------------------------------------------------------------------
m_forward (variable)(A) syntax: m_forward [value] default: 0.25 Sets sensitivity of the mouse for forward/back movement when freelook is 0 and +mlook is inactive. Setting to negative inverts the axis action. --------------------------------------------------------------------------------
m_pitch (variable)(A) syntax: m_pitch [value] default: 0.022 Sets sensitivity of the mouse for looking up and down when freelook is 1 and/or +mlook is active. Setting to negative inverts the axis action. --------------------------------------------------------------------------------
m_side (variable)(A) syntax: m_side [value] default: 0.25 Sets sensitivity of the mouse for strafing movement when freelook is 0 and +mlook is inactive. Setting to negative inverts the axis action. --------------------------------------------------------------------------------
m_yaw (variable)(A) syntax: m_yaw [value] default: 0.022 Sets sensitivity of the mouse for turning action when freelook is 1 and/or +mlook is active. Setting to negative inverts the axis action. --------------------------------------------------------------------------------
map (command) syntax: map [mapname] Loads a map file, specifying cheats disabled. The .BSP file extension is not required. See also devmap. --------------------------------------------------------------------------------
map_restart (command) syntax: map_restart Restarts the game on the current map. Replaces restart. --------------------------------------------------------------------------------
mapname (variable)(S R) syntax: mapname [filename] default: nomap Identifies the filename of the currently loaded map. -------------------------------------------------------------------------------- zlib 常用函数说明quake3 的 *.pk3 文件采用的 zip 压缩算法
typedef struct unz_global_info_s
{ unsigned long number_entry; //该成员为整个压缩包包含文件的数量 unsigned long size_comment; /* size of the global comment of the zipfile */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info_s { unsigned long version; /* version made by 2 unsigned chars */ unsigned long version_needed; /* version needed to extract 2 unsigned chars */ unsigned long flag; /* general purpose bit flag 2 unsigned chars */ unsigned long compression_method; /* compression method 2 unsigned chars */ unsigned long dosDate; /* last mod file date in Dos fmt 4 unsigned chars */ unsigned long crc; /* crc-32 4 unsigned chars */ unsigned long compressed_size; /* compressed size 4 unsigned chars */ unsigned long uncompressed_size; /* 成员为解压后文件的大小 4 unsigned chars */ unsigned long size_filename; /* filename length 2 unsigned chars */ unsigned long size_file_extra; /* extra field length 2 unsigned chars */ unsigned long size_file_comment; /* file comment length 2 unsigned chars */ unsigned long disk_num_start; /* disk number start 2 unsigned chars */
unsigned long internal_fa; /* internal file attributes 2 unsigned chars */ unsigned long external_fa; /* external file attributes 4 unsigned chars */ tm_unz tmu_date;
} unz_file_info; typedef struct
{ FILE* file; /* io structore of the zipfile */ unz_global_info gi; /* public global information */ unsigned long byte_before_the_zipfile;/* unsigned char before the zipfile, (>0 for sfx)*/ unsigned long num_file; /* number of the current file in the zipfile*/ unsigned long pos_in_central_dir; /* pos of the current file in the central dir*/ unsigned long current_file_ok; /* flag about the usability of the current file*/ unsigned long central_pos; /* position of the beginning of the central dir*/ unsigned long size_central_dir; /* size of the central directory */
unsigned long offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ unz_file_info cur_file_info; /* public info about the current file in zip*/
unz_file_info_internal cur_file_info_internal; /* private info about it*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ unsigned char* tmpFile; int tmpPos,tmpSize; } unz_s; struct s_path
{
char Filename[MAX_QPATH]; //文件名称 int pos_in_central_dir; //文件在zip包中的位置 } zipfile_t; //打开zip文件
unzFile ZipFile;
ZipFile = unzOpen( FullPath ); //输入压缩文件 如 c:\quake3\pak0.pk3 //获取zip文件信息, zip内文件数量 unz_global_info GlobalInfo;
err = unzGetGlobalInfo( ZipFile, &GlobalInfo ); //将文件指针移动到 zip 文件的第一个文件处。
unzGoToFirstFile(ZipFile);
//获取zip内当前文件指针指向的文件信息
chat filename_inzip[MAX_PATH];
unz_file_info FileInfo;
err = unzGetCurrentFileInfo( ZipFile, &FileInfo, filename_inzip, MAX_PATH, NULL, 0, NULL, 0 );
//获取zip内当前文件指针所在的位置。可以用hashmap 记录文件名称对应zip位置,便于以后读写
int pos;
unzGetCurrentFileInfoPosition(ZipFile,&pos);
//将zip内文件指针移动到指定的位置
unzSetCurrentFileInfoPosition(ZipFile, pos);
//移动到zip内下一个文件
unzGoToNextFile( ZipFile ); //关闭zip当前打开的文件
unzCloseCurrentFile( ZipFile ); //打开zip当前所在的文件
unzOpenCurrentFile( ZipFile ) //读取zip当前打开的文件
char buf[bufsize];
if( unzReadCurrentFile( ZipFile, buffer, bufsize ) < 0 ) //关闭zip当前打开的文件
unzCloseCurrentFile( ZipFile ); 1 个 window api 函数用法
Handle = FindFirstFile(FullPath, &FindFile); FullPath 可以有如下形式 e:\quake3\*.pk3 这样将查找所有*.pk3文件 一个读取zip文件中文本文件的演示程序地址(2007/10/20): http://www.91files.com/?QC89XBQFRDPD1WYP8G4J |
|
|