~ubuntu-branches/ubuntu/natty/alien-arena/natty

« back to all changes in this revision

Viewing changes to source/ref_gl/r_script.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia, Barry deFreese, Ansgar Burchardt, Gonéri Le Bouder, Andres Mejia
  • Date: 2008-04-18 17:43:24 UTC
  • mfrom: (1.1.2 upstream) (3.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080418174324-si1umi8dngglaha4
Tags: 7.0-1
[ Barry deFreese ]
* Escape - in alien-arena-server.6.
* Add myself to uploaders.

[ Ansgar Burchardt ]
* Remove deprecated Encoding key from .desktop file.

[ Gonéri Le Bouder ]
* Remove Homepage from package description.

[ Andres Mejia ]
* New upstream release.
* Removing XS- part for Vcs-* lines.
* Removing +ssh part of Vcs-Svn line.
* Bumped to Standards-Version 3.7.3.
* Test for existence of *-stamp stamps before removing them.
* Removed Encoding field in desktop file.
* Modify patch for upstream Makefile to make Makefile more useful in building
  Debian packages.
  + Also fixes problem not detecting the existence of libcurl.
* Remove debug packages for release. Will support nostrip option instead.
* Add description for fix-CVE-2007-4754-CVE-2007-4755.dpatch, silences
  lintian warning.
* Add new link for watchfile.
  + Closes: #453555
* Moved debian/scripts/alien-arena-tarball.sh to
  debian/alien-arena-get-orig-source.
* Modified alien-arena-data-get-orig-source to make it easier to maintain.
* Switched from dpatch to quilt.
* Cut down package description.
* Closing bug about mouse constantly looking up. The submitter could not
  reproduce the bug after deleting the ~/.alien-arena directory.
  + Closes: #457700
* Updated copyright file for new release.
* Updated README.Debian files.
* Adding new images for icons. Need build dependency on sharutils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
void CIN_FreeCin (int texnum);
30
30
 
31
31
extern float    r_turbsin[];
32
 
extern  void GL_BlendFunction (GLenum sfactor, GLenum dfactor);
 
32
extern  void GL_BlendFunction (GLenum sfactor, GLenum dfactor);
33
33
 
34
34
#define         TURBSCALE (256.0 / (2 * M_PI))
35
35
 
217
217
        stage->frames.start = 0;
218
218
        stage->frames.end = 0;
219
219
 
220
 
        stage->rot_speed = 0;
 
220
        stage->rot_speed = 0;
221
221
        
222
222
        VectorClear(stage->origin);
223
223
        VectorClear(stage->angle);
224
224
 
225
225
        stage->texture = NULL;
226
 
 
 
226
 
227
227
        stage->depthhack = 0;
228
228
        stage->envmap = false;
229
229
        stage->dynamic = false;
230
 
        stage->lensflare = false;
 
230
        stage->lensflare = false;
231
231
        stage->normalmap = false;
232
232
 
233
233
        stage->lightmap = true;
546
546
                anim <delay> <tex1> <tex2> <tex3> ... end
547
547
                envmap
548
548
                nolightmap
549
 
                alphamask
550
 
                lensflare
 
549
                alphamask
 
550
                lensflare
551
551
                normalmap
552
552
        }
553
553
}
799
799
        else if (!_stricmp (*token, "-basic"))
800
800
                stage->alphafunc = -ALPHAFUNC_BASIC;
801
801
}
802
 
void rs_stage_lensflare (rs_stage_t *stage, char **token)
803
 
{
804
 
        stage->lensflare = true;
805
 
}
806
 
void rs_stage_normalmap (rs_stage_t *stage, char **token)
807
 
{
808
 
        stage->normalmap = true;
 
802
void rs_stage_lensflare (rs_stage_t *stage, char **token)
 
803
{
 
804
        stage->lensflare = true;
 
805
}
 
806
void rs_stage_normalmap (rs_stage_t *stage, char **token)
 
807
{
 
808
        stage->normalmap = true;
809
809
}
810
810
static rs_stagekey_t rs_stagekeys[] = 
811
811
{
812
812
        {       "colormap",             &rs_stage_colormap              },
813
813
        {       "map",                  &rs_stage_map                   },
814
814
        {       "model",                &rs_stage_model                 },
815
 
        {       "scroll",               &rs_stage_scroll                },
 
815
        {       "scroll",               &rs_stage_scroll                },
816
816
        {       "frames",               &rs_stage_frames                },
817
817
        {       "blendfunc",    &rs_stage_blendfunc             },
818
818
        {       "alphashift",   &rs_stage_alphashift    },
827
827
        {       "angle",                &rs_stage_angle                 },
828
828
        {       "scale",                &rs_stage_scale                 },
829
829
        {       "dynamic",              &rs_stage_dynamic               },
830
 
        {       "alphafunc",    &rs_stage_alphafunc             },
831
 
        {       "lensflare",    &rs_stage_lensflare             },
 
830
        {       "alphafunc",    &rs_stage_alphafunc             },
 
831
        {       "lensflare",    &rs_stage_lensflare             },
832
832
        {   "normalmap",        &rs_stage_normalmap             },
833
833
 
834
834
        {       NULL,                   NULL                                    }
923
923
        rscript_t               *rs = NULL;
924
924
        rs_stage_t              *stage;
925
925
        unsigned char   tcmod = 0;
926
 
        unsigned int    len, i;
927
 
 
 
926
        unsigned int    len, i;
 
927
 
928
928
        len = FS_LoadFile (script, (void **)&fbuf);
929
929
 
930
930
        if (!fbuf || len < 16) 
1020
1020
        free(buf);
1021
1021
}
1022
1022
 
1023
 
#ifdef __unix__
1024
1023
void RS_ScanPathForScripts (void)
1025
1024
{
1026
1025
        char    script[MAX_OSPATH];
1027
 
        char    dirstring[1024], *c;
1028
 
        char    **script_list;
1029
 
        int     script_count, i;
1030
 
        char *path = NULL;
1031
 
 
1032
 
        do {
1033
 
                path = FS_NextPath(path);
1034
 
                Com_sprintf(dirstring, sizeof(dirstring), "%s/scripts/*.rscript", path);
1035
 
                if ((script_list = FS_ListFiles(dirstring, &script_count, SFF_SUBDIR, 0)) != 0)
1036
 
                        break;
1037
 
        } while (path);
1038
 
 
1039
 
        if (!script_list)
1040
 
                return;
1041
 
 
1042
 
        for (i = 0; i < script_count-1; i++)
1043
 
        {
1044
 
                c = COM_SkipPath(script_list[i]);
1045
 
                Com_sprintf(script, MAX_OSPATH, "scripts/%s", c);
1046
 
                RS_LoadScript(script);
1047
 
        }
1048
 
 
1049
 
        FS_FreeFileList(script_list, script_count);
1050
 
 
1051
 
        if(gl_normalmaps->value) { //search for normal map scripts ONLY if we are using normal mapping
1052
 
                path = NULL;
1053
 
                do {
1054
 
                        path = FS_NextPath(path);
1055
 
                        Com_sprintf(dirstring, sizeof(dirstring), "%s/scripts/normals/*.rscript", path);
1056
 
                        if ((script_list = FS_ListFiles(dirstring, &script_count, SFF_SUBDIR, 0)) != 0)
1057
 
                                break;
1058
 
                } while (path);
1059
 
 
1060
 
                if (!script_list)
1061
 
                        return;
1062
 
 
1063
 
                for (i = 0; i < script_count-1; i++)
1064
 
                {
1065
 
                        c = COM_SkipPath(script_list[i]);
1066
 
                        Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1067
 
                        RS_LoadScript(script);
1068
 
                }
1069
 
 
1070
 
                FS_FreeFileList(script_list, script_count);
1071
 
        }
1072
 
}
1073
 
#else
1074
 
void RS_ScanPathForScripts (void)
1075
 
{
1076
 
        char                    script[MAX_OSPATH];
1077
 
        char                    dirstring[1024], *c;
1078
 
        int                             handle;
1079
 
        struct                  _finddata_t fileinfo;
1080
 
        char                    *dir = FS_Gamedir();
1081
 
        char                    *basedir = va("./%s", BASEDIRNAME);
1082
 
 
1083
 
        if (strcmp(dir,basedir))
1084
 
        {
1085
 
 
1086
 
                Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/*.rscript", basedir);
1087
 
                handle = _findfirst (dirstring, &fileinfo);
1088
 
 
1089
 
                if (handle != -1) 
1090
 
                {
1091
 
                        do
1092
 
                        {
1093
 
                                if (fileinfo.name[0] == '.')
1094
 
                                        continue;
1095
 
 
1096
 
                                c = COM_SkipPath(fileinfo.name);
1097
 
                                Com_sprintf(script, MAX_OSPATH, "scripts/%s", c);
1098
 
                                RS_LoadScript (script);
1099
 
                        } while (_findnext( handle, &fileinfo ) != -1);
1100
 
 
1101
 
                        _findclose (handle);
1102
 
                }
1103
 
 
1104
 
        }
1105
 
 
1106
 
        Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/*.rscript", dir);
1107
 
        handle = _findfirst (dirstring, &fileinfo);
1108
 
 
1109
 
        if (handle != -1) 
1110
 
        {
1111
 
                do 
1112
 
                {
1113
 
                        if (fileinfo.name[0] == '.')
1114
 
                                continue;
1115
 
 
1116
 
                        c = COM_SkipPath(fileinfo.name);
 
1026
        char    **script_list, *c;
 
1027
        int     script_count, i;
 
1028
 
 
1029
 
 
1030
        script_list = FS_ListFilesInFS("scripts/*.rscript", &script_count, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
 
1031
 
 
1032
        if(script_list) {
 
1033
                for (i = 0; i < script_count; i++)
 
1034
                {
 
1035
                        c = COM_SkipPath(script_list[i]);
1117
1036
                        Com_sprintf(script, MAX_OSPATH, "scripts/%s", c);
1118
 
                        RS_LoadScript (script);
1119
 
                } while (_findnext( handle, &fileinfo ) != -1);
1120
 
 
1121
 
                _findclose (handle);
1122
 
        }
1123
 
 
1124
 
        if(gl_normalmaps->value) { //search for normal map scripts ONLY if we are using normal mapping
1125
 
                
1126
 
                if (strcmp(dir,basedir))
1127
 
                {
1128
 
 
1129
 
                        Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/normals/*.rscript", basedir);
1130
 
                        handle = _findfirst (dirstring, &fileinfo);
1131
 
 
1132
 
                        if (handle != -1) 
1133
 
                        {
1134
 
                                do
1135
 
                                {
1136
 
                                        if (fileinfo.name[0] == '.')
1137
 
                                                continue;
1138
 
 
1139
 
                                        c = COM_SkipPath(fileinfo.name);
1140
 
                                        Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1141
 
                                        RS_LoadScript (script);
1142
 
                                } while (_findnext( handle, &fileinfo ) != -1);
1143
 
 
1144
 
                                _findclose (handle);
1145
 
                        }
1146
 
 
1147
 
                }
1148
 
 
1149
 
                Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/normals/*.rscript", dir);
1150
 
                handle = _findfirst (dirstring, &fileinfo);
1151
 
 
1152
 
                if (handle != -1) 
1153
 
                {
1154
 
                        do 
1155
 
                        {
1156
 
                                if (fileinfo.name[0] == '.')
1157
 
                                        continue;
1158
 
 
1159
 
                                c = COM_SkipPath(fileinfo.name);
1160
 
                                Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1161
 
                                RS_LoadScript (script);
1162
 
                        } while (_findnext( handle, &fileinfo ) != -1);
1163
 
 
1164
 
                        _findclose (handle);
1165
 
                }
 
1037
                        RS_LoadScript(script);
 
1038
                }
 
1039
 
 
1040
                FS_FreeFileList(script_list, script_count);
 
1041
        }
 
1042
 
 
1043
        script_count = 0;
 
1044
        if(gl_normalmaps->value) { //search for normal map scripts ONLY if we are using normal mapping
 
1045
                
 
1046
                script_list = FS_ListFilesInFS("scripts/normals/*.rscript", &script_count, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
 
1047
 
 
1048
                if(script_list) {
 
1049
                        for (i = 0; i < script_count; i++)
 
1050
                        {
 
1051
                                c = COM_SkipPath(script_list[i]);
 
1052
                                Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
 
1053
                                RS_LoadScript(script);
 
1054
                        }
 
1055
 
 
1056
                        FS_FreeFileList(script_list, script_count);
 
1057
                }
1166
1058
        }
1167
1059
}
1168
 
#endif
1169
1060
 
1170
1061
void RS_SetEnvmap (vec3_t v, float *os, float *ot)
1171
1062
{
1218
1109
                }
1219
1110
        }
1220
1111
}
1221
 
#ifdef __unix__
1222
 
__inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
1223
 
#else
1224
 
_inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
1225
 
#endif
1226
 
{
1227
 
        float cost = cos(degrees), sint = sin(degrees);
1228
 
        float is = *os, it = *ot, c_s, c_t;
1229
 
 
1230
 
        c_s = fa->c_s - (int)fa->c_s;
1231
 
        c_t = fa->c_t - (int)fa->c_t;
1232
 
 
1233
 
        *os = cost * (is - c_s) + sint * (c_t - it) + c_s;
1234
 
        *ot = cost * (it - c_t) + sint * (is - c_s) + c_t;
1235
 
 
1236
 
}
 
1112
#ifdef __unix__
 
1113
__inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
 
1114
#else
 
1115
_inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
 
1116
#endif
 
1117
{
 
1118
        float cost = cos(degrees), sint = sin(degrees);
 
1119
        float is = *os, it = *ot, c_s, c_t;
 
1120
 
 
1121
        c_s = fa->c_s - (int)fa->c_s;
 
1122
        c_t = fa->c_t - (int)fa->c_t;
 
1123
 
 
1124
        *os = cost * (is - c_s) + sint * (c_t - it) + c_s;
 
1125
        *ot = cost * (it - c_t) + sint * (is - c_s) + c_t;
 
1126
 
 
1127
}
1237
1128
 
1238
1129
#ifdef __unix__
1239
1130
__inline void RS_RotateST2 (float *os, float *ot, float degrees)
1247
1138
        *os = cost * (is - 0.5) + sint * (0.5 - it) + 0.5;
1248
1139
        *ot = cost * (it - 0.5) + sint * (is - 0.5) + 0.5;
1249
1140
}
1250
 
 
1251
 
void RS_SetTexcoords (rs_stage_t *stage, float *os, float *ot, msurface_t *fa)
1252
 
{
1253
 
        RS_ScaleTexcoords(stage, os, ot);
1254
 
 
1255
 
        // rotate
1256
 
        if (stage->rot_speed)
1257
 
                RS_RotateST (os, ot, -stage->rot_speed * rs_realtime * 0.0087266388888888888888888888888889, fa);
1258
 
 
 
1141
 
 
1142
void RS_SetTexcoords (rs_stage_t *stage, float *os, float *ot, msurface_t *fa)
 
1143
{
 
1144
        RS_ScaleTexcoords(stage, os, ot);
 
1145
 
 
1146
        // rotate
 
1147
        if (stage->rot_speed)
 
1148
                RS_RotateST (os, ot, -stage->rot_speed * rs_realtime * 0.0087266388888888888888888888888889, fa);
 
1149
 
1259
1150
}
1260
1151
void RS_SetTexcoords2D (rs_stage_t *stage, float *os, float *ot)
1261
1152
{
1262
 
        float   txm = 0, tym = 0;
 
1153
        float   txm = 0, tym = 0;
1263
1154
 
1264
1155
        // scale
1265
1156
        if (stage->scale.scaleX) 
1441
1332
        }
1442
1333
}
1443
1334
 
1444
 
//This is now the primary shader drawing routine for surfaces - it will draw on top of the 
1445
 
//existing texture.  This will help in preventing cheats, in which people create shaders that
 
1335
//This is now the primary shader drawing routine for surfaces - it will draw on top of the 
 
1336
//existing texture.  This will help in preventing cheats, in which people create shaders that
1446
1337
//allow you to see through walls.
1447
1338
void RS_DrawSurfaceTexture (msurface_t *surf, rscript_t *rs)
1448
1339
{
1460
1351
        
1461
1352
        if (!rs)
1462
1353
                return;
1463
 
 
 
1354
 
1464
1355
        nv = surf->polys->numverts;
1465
1356
        stage = rs->stage;
1466
1357
        time = rs_realtime * rs->warpspeed;
1468
1359
        //for envmap by normals
1469
1360
        AngleVectors (r_newrefdef.viewangles, vectors[0], vectors[1], vectors[2]);
1470
1361
 
1471
 
        if(!r_bloom->value) //BLOOMS - this screws with blooms
 
1362
        if(!r_bloom->value) //BLOOMS - this screws with blooms
1472
1363
                SetVertexOverbrights(true);
1473
1364
 
1474
1365
        do
1475
1366
        {
1476
 
 
1477
 
                if (stage->lensflare)
 
1367
 
 
1368
                if (stage->lensflare)
1478
1369
                        break;
1479
1370
 
 
1371
                if (stage->normalmap)
 
1372
                        continue;
 
1373
 
1480
1374
                if (stage->colormap.enabled)
1481
1375
                        qglDisable (GL_TEXTURE_2D);
1482
1376
                else if (stage->rand_count) {
1570
1464
                {
1571
1465
                        GLSTATE_DISABLE_ALPHATEST
1572
1466
                }
1573
 
                if(stage->normalmap)
1574
 
                {
1575
 
                
1576
 
                        qglDepthMask (GL_FALSE); 
1577
 
                        qglEnable (GL_BLEND); 
1578
 
 
1579
 
                        // set the correct blending mode for normal maps 
1580
 
                        qglBlendFunc (GL_ZERO, GL_SRC_COLOR); 
1581
 
 
1582
 
                        GL_SelectTexture(GL_TEXTURE0_ARB);
1583
 
                        GL_MBind (GL_TEXTURE0_ARB, stage->texture->texnum);
1584
 
                        qglEnable (GL_TEXTURE_2D);
1585
 
                        qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
1586
 
                        qglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGB_ARB);
1587
 
 
1588
 
                        qglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
1589
 
                        qglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
1590
 
                        qglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB);
1591
 
                        qglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
1592
 
 
1593
 
 
1594
 
                }
1595
 
 
 
1467
        
1596
1468
                if (rs->subdivide)
1597
1469
                {
1598
1470
                        glpoly_t *bp;
1601
1473
                        for (bp = surf->polys; bp; bp = bp->next)
1602
1474
                        {
1603
1475
                                p = bp;
1604
 
 
 
1476
 
1605
1477
                                qglBegin(GL_TRIANGLE_FAN);
1606
1478
                                for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE)
1607
1479
                                {
1668
1540
                                        }
1669
1541
                                }
1670
1542
                                qglEnd();
1671
 
                        }
1672
 
 
 
1543
                        }
 
1544
 
1673
1545
                } 
1674
1546
                else 
1675
1547
                {
1712
1584
                                        {
1713
1585
                                                
1714
1586
                                                float red=255, green=255, blue=255;
1715
 
                                                
1716
 
                                        //      if (stage->lightmap && p->vertexlight)
1717
 
                                        //      {
1718
 
                                        //              red = p->vertexlight[i*3+0]/255.0f;
1719
 
                                        //              green = p->vertexlight[i*3+1]/255.0f;
1720
 
                                        //              blue = p->vertexlight[i*3+2]/255.0f;
1721
 
                                        //      }
1722
 
                                                
 
1587
                                                        
1723
1588
                                                if (stage->colormap.enabled)
1724
1589
                                                {
1725
1590
                                                        red *= stage->colormap.red/255.0f;
1750
1615
 
1751
1616
                                qglEnd ();
1752
1617
        
1753
 
                        }
1754
 
 
 
1618
                        }
 
1619
 
1755
1620
                }
1756
1621
 
1757
1622
                qglColor4f(1,1,1,1);
1758
1623
                if (stage->colormap.enabled)
1759
 
                        qglEnable (GL_TEXTURE_2D); 
1760
 
 
1761
 
                if(stage->normalmap) {
1762
 
                        // back to replace mode 
1763
 
                        qglTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 
1764
 
 
1765
 
                        // restore the original blend mode 
1766
 
                        qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
1767
 
 
1768
 
                        // switch off blending 
1769
 
                        qglDisable (GL_BLEND); 
1770
 
                        qglDepthMask (GL_TRUE); 
1771
 
                }
1772
 
 
1773
 
        
 
1624
                        qglEnable (GL_TEXTURE_2D); 
 
1625
                
1774
1626
        } while (stage = stage->next);
1775
1627
 
1776
 
        if(!r_bloom->value)
1777
 
                SetVertexOverbrights(false);
1778
 
 
 
1628
        if(!r_bloom->value)
 
1629
                SetVertexOverbrights(false);
 
1630
 
1779
1631
}
1780
1632
 
1781
1633
rscript_t *rs_caustics;
1796
1648
        //Underwater Caustics
1797
1649
        if (surf->flags & SURF_UNDERWATER)
1798
1650
                        RS_DrawSurfaceTexture(surf, rs_caustics);
1799
 
 
1800
 
        //this was moved here to handle all textures shaders as well.
1801
 
        rs_shader = (rscript_t *)surf->texinfo->image->script;
1802
 
        if(rs_shader)
1803
 
                RS_DrawSurfaceTexture(surf, rs_shader);
 
1651
 
 
1652
        //this was moved here to handle all textures shaders as well.
 
1653
        rs_shader = (rscript_t *)surf->texinfo->image->script;
 
1654
        if(rs_shader)
 
1655
                RS_DrawSurfaceTexture(surf, rs_shader);
1804
1656
 
1805
1657
}
1806
 
 
1807
 
 
 
1658
 
 
1659