diff --git a/source/src/command.cpp b/source/src/command.cpp index d7e44b66..c0e83f68 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -328,6 +328,7 @@ void writecfg() if(!f) return; fprintf(f, "// automatically written on exit, DO NOT MODIFY\n// delete this file to have defaults.cfg overwrite these settings\n// modify settings in game, or put settings in autoexec.cfg to override anything\n\n"); fprintf(f, "name %s\nteam %s\nskin %d\n", player1->name, player1->team, player1->nextskin); + extern Texture *crosshair; fprintf(f, "loadcrosshair %s\n", crosshair->name+strlen("packages/misc/crosshairs/")); extern int lowfps, highfps; fprintf(f, "fpsrange %d %d\n", lowfps, highfps); diff --git a/source/src/main.cpp b/source/src/main.cpp index 39db8492..b6629e09 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -325,8 +325,8 @@ int main(int argc, char **argv) initlog("gl"); gl_init(scr_w, scr_h, colorbits, depthbits, fsaa); - crosshair = textureload("packages/misc/crosshairs/default.png"); - if(!crosshair) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)"); + notexture = textureload("packages/misc/notexture.png"); + if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)"); initlog("console"); if(!execfile("config/font.cfg")) fatal("cannot find font definitions"); @@ -489,13 +489,5 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } -void loadcrosshair(char *c) -{ - s_sprintfd(p)("packages/misc/crosshairs/%s", c); - crosshair = textureload(p); -} - -COMMAND(loadcrosshair, ARG_1STR); - VAR(version, 1, AC_VERSION, 0); diff --git a/source/src/md2.h b/source/src/md2.h index 99cffc45..6eab03d2 100644 --- a/source/src/md2.h +++ b/source/src/md2.h @@ -226,7 +226,7 @@ struct md2 : vertmodel Texture *skin; loadskin(loadname, pname, skin); loopv(mdl.meshes) mdl.meshes[i]->skin = skin; - if(skin==crosshair) conoutf("could not load model skin for %s", name1); + if(skin==notexture) conoutf("could not load model skin for %s", name1); loadingmd2 = this; s_sprintfd(name2)("packages/models/%s/md2.cfg", loadname); if(!execfile(name2)) diff --git a/source/src/md3.h b/source/src/md3.h index 36c309d2..8300b0ee 100644 --- a/source/src/md3.h +++ b/source/src/md3.h @@ -215,7 +215,7 @@ struct md3 : vertmodel Texture *skin; loadskin(loadname, pname, skin); loopv(mdl.meshes) mdl.meshes[i]->skin = skin; - if(skin==crosshair) conoutf("could not load model skin for %s", name1); + if(skin==notexture) conoutf("could not load model skin for %s", name1); } loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z)); diff --git a/source/src/protos.h b/source/src/protos.h index 5afdc099..2aebb693 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -76,7 +76,7 @@ struct Texture int xs, ys; GLuint id; }; -extern Texture *crosshair; +extern Texture *notexture; extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, GLenum format); extern Texture *textureload(const char *name, int clamp = 0); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 4bf493b0..08c00797 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -69,11 +69,22 @@ void drawscope() glEnd(); } +Texture *crosshair = NULL; + +void loadcrosshair(char *c) +{ + s_sprintfd(p)("packages/misc/crosshairs/%s", c); + crosshair = textureload(p); +} + +COMMAND(loadcrosshair, ARG_1STR); + void drawcrosshair(bool showteamwarning) { glBlendFunc(GL_ONE, GL_ONE); static Texture *teammatetex = NULL; if(!teammatetex) teammatetex = textureload("packages/misc/teammate.png"); + if(!crosshair) crosshair = textureload("packages/misc/crosshairs/default.png"); glBindTexture(GL_TEXTURE_2D, showteamwarning ? teammatetex->id : crosshair->id); glBegin(GL_QUADS); glColor3ub(255,255,255); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 5b22b6c9..830de009 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -271,7 +271,7 @@ int findanim(const char *name) void loadskin(const char *dir, const char *altdir, Texture *&skin) // model skin sharing { - #define ifnoload if((skin = textureload(path))==crosshair) + #define ifnoload if((skin = textureload(path))==notexture) s_sprintfd(path)("packages/models/%s/skin.jpg", dir); ifnoload { diff --git a/source/src/texture.cpp b/source/src/texture.cpp index e06c029f..b0ee5192 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -2,7 +2,7 @@ #include "cube.h" -Texture *crosshair = NULL; +Texture *notexture = NULL; hashtable textures; VAR(hwtexsize, 1, 0, 0); @@ -88,7 +88,7 @@ Texture *textureload(const char *name, int clamp) if(t) return t; int xs, ys; GLuint id = loadsurface(pname, xs, ys, clamp); - if(!id) return crosshair; + if(!id) return notexture; char *key = newstring(pname); t = &textures[key]; t->name = key; @@ -123,7 +123,7 @@ COMMAND(texture, ARG_2STR); Texture *lookuptexture(int tex) { - Texture *t = crosshair; + Texture *t = notexture; if(slots.inrange(tex)) { Slot &s = slots[tex]; diff --git a/source/src/vertmodel.h b/source/src/vertmodel.h index 371a71ba..ccc60994 100644 --- a/source/src/vertmodel.h +++ b/source/src/vertmodel.h @@ -58,7 +58,7 @@ struct vertmodel : model GLuint statlist; int statlen; - mesh() : name(0), verts(0), tcverts(0), tris(0), skin(crosshair), tex(0), dynbuf(0), dynidx(0), statlist(0) + mesh() : name(0), verts(0), tcverts(0), tris(0), skin(notexture), tex(0), dynbuf(0), dynidx(0), statlist(0) { dyncur.fr1 = dynprev.fr1 = -1; }