diff -ruN src/clientgame.cpp src-jjh/clientgame.cpp --- src/clientgame.cpp 2004-11-18 17:21:26.000000000 -0800 +++ src-jjh/clientgame.cpp 2005-01-15 22:07:46.000000000 -0800 @@ -326,6 +326,8 @@ strcpy_s(clientmap, name); ///if(!editmode) toggleedit(); setvar("gamespeed", 100); + setvar("fog", 4000); + setvar("fogcolour", 0x8099B3); showscores(false); intermission = false; conoutf("game mode is %s", (int)modestr(gamemode)); diff -ruN src/command.cpp src-jjh/command.cpp --- src/command.cpp 2004-02-28 12:58:19.000000000 -0800 +++ src-jjh/command.cpp 2005-01-15 22:07:46.000000000 -0800 @@ -148,7 +148,7 @@ ident *id = idents->access(c); if(!id) { - val = atoi(c); + val = ATOI(c); if(!val && *c!='0') conoutf("unknown command: %s", (int)c); } else switch(id->type) @@ -156,10 +156,10 @@ case ID_COMMAND: // game defined commands switch(id->narg) // use very ad-hoc function signature, and just call it { - case ARG_1INT: if(isdown) ((void (__cdecl *)(int))id->fun)(atoi(w[1])); break; - case ARG_2INT: if(isdown) ((void (__cdecl *)(int, int))id->fun)(atoi(w[1]), atoi(w[2])); break; - case ARG_3INT: if(isdown) ((void (__cdecl *)(int, int, int))id->fun)(atoi(w[1]), atoi(w[2]), atoi(w[3])); break; - case ARG_4INT: if(isdown) ((void (__cdecl *)(int, int, int, int))id->fun)(atoi(w[1]), atoi(w[2]), atoi(w[3]), atoi(w[4])); break; + case ARG_1INT: if(isdown) ((void (__cdecl *)(int))id->fun)(ATOI(w[1])); break; + case ARG_2INT: if(isdown) ((void (__cdecl *)(int, int))id->fun)(ATOI(w[1]), ATOI(w[2])); break; + case ARG_3INT: if(isdown) ((void (__cdecl *)(int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; + case ARG_4INT: if(isdown) ((void (__cdecl *)(int, int, int, int))id->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; case ARG_NONE: if(isdown) ((void (__cdecl *)())id->fun)(); break; case ARG_1STR: if(isdown) ((void (__cdecl *)(char *))id->fun)(w[1]); break; case ARG_2STR: if(isdown) ((void (__cdecl *)(char *, char *))id->fun)(w[1], w[2]); break; @@ -193,13 +193,20 @@ if(!w[1][0]) conoutf("%s = %d", (int)c, *id->storage); // var with no value just prints its current value else { - int i1 = atoi(w[1]); - if(i1min || i1>id->max) + if(id->min>id->max) { - i1 = i1min ? id->min : id->max; // clamp to valid range - conoutf("valid range for %s is %d..%d", (int)c, id->min, id->max); + conoutf("variable is read-only"); } - *id->storage = i1; + else + { + int i1 = ATOI(w[1]); + if(i1min || i1>id->max) + { + i1 = i1min ? id->min : id->max; // clamp to valid range + conoutf("valid range for %s is %d..%d", (int)c, id->min, id->max); + } + *id->storage = i1; + }; if(id->fun) ((void (__cdecl *)())id->fun)(); // call trigger function if available }; }; diff -ruN src/cube.h src-jjh/cube.h --- src/cube.h 2005-01-15 20:46:23.000000000 -0800 +++ src-jjh/cube.h 2005-01-15 22:07:46.000000000 -0800 @@ -243,6 +243,8 @@ #define VAR(name, min, cur, max) static int name = variable(#name, min, cur, max, &name, NULL) #define VARF(name, min, cur, max, body) void var_##name(); static int name = variable(#name, min, cur, max, &name, var_##name); void var_##name() { body; } +#define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers + // protos for ALL external functions in cube... // command diff -ruN src/rendergl.cpp src-jjh/rendergl.cpp --- src/rendergl.cpp 2005-01-03 18:45:48.000000000 -0800 +++ src-jjh/rendergl.cpp 2005-01-15 22:08:24.000000000 -0800 @@ -25,10 +25,8 @@ void gl_init(int w, int h) { - #define fogvalues 0.5f, 0.6f, 0.7f, 1.0f glViewport(0, 0, w, h); - glClearColor(fogvalues); glClearDepth(1.0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); @@ -37,10 +35,8 @@ glEnable(GL_FOG); glFogi(GL_FOG_MODE, GL_LINEAR); - glFogf(GL_FOG_DENSITY, 0.25); + glFogf(GL_FOG_DENSITY, 0.25); // No effect with linear fog glHint(GL_FOG_HINT, GL_NICEST); - GLfloat fogcolor[4] = { fogvalues }; - glFogfv(GL_FOG_COLOR, fogcolor); glEnable(GL_LINE_SMOOTH); @@ -244,6 +240,8 @@ int xtraverts; VAR(fog, 16, 4000, 1000024); +VAR(skyfog, 1, 1000, 1000024); +VAR(fogcolour, 0, 0x8099B3, 0xFFFFFF); VAR(hudgun, 0, 1, 1); @@ -298,6 +296,11 @@ glFogi(GL_FOG_START, (fog+64)/8); glFogi(GL_FOG_END, fog); + float fogc[4] = { (fogcolour>>16)/256.0f, ((fogcolour>>8)&255)/256.0f, (fogcolour&255)/256.0f, 1.0f }; + glFogfv(GL_FOG_COLOR, fogc); + glClearColor(fogc[0], fogc[1], fogc[2], 1.0f); + + if(underwater) { @@ -307,9 +310,10 @@ glFogi(GL_FOG_END, (fog+96)/8); }; + glMatrixMode(GL_PROJECTION); glLoadIdentity(); - int farplane = max(fog*2, 384); + int farplane = max(fog*5/2, 384); gluPerspective(fovy, aspect, 4, farplane); glMatrixMode(GL_MODELVIEW); @@ -330,18 +334,23 @@ //renderstripssky(); /* + */ glLoadIdentity(); glRotated(player1->pitch, -1.0, 0.0, 0.0); glRotated(player1->yaw, 0.0, 1.0, 0.0); glRotated(90.0, 1.0, 0.0, 0.0); glColor3f(1.0f, 1.0f, 1.0f); - glDisable(GL_FOG); - glDepthFunc(GL_GREATER); + //glDisable(GL_FOG); + //glDepthFunc(GL_GREATER); + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, (skyfog/10000000.0 )); draw_envbox(14, fog*4/3); - glDepthFunc(GL_LESS); - glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_LINEAR); + //glDepthFunc(GL_LESS); + //glEnable(GL_FOG); transplayer(); + /* */ renderstrips();