diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 2b419dfe..21db357a 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -79,10 +79,14 @@ void correctsel() // ensures above invaria if(sel.xs<=0 || sel.ys<=0) selset = false; } -bool noteditmode() +bool noteditmode(const char* func) { correctsel(); - if(!editmode) conoutf("this function is only allowed in edit mode"); + if(!editmode) + { + if(func && func[0]!='\0') conoutf("\f4[\f3%s\f4]\f5 is only allowed in edit mode", func); + else conoutf("this function is only allowed in edit mode"); + } return !editmode; } @@ -92,9 +96,9 @@ bool noselection() return !selset; } -#define EDITSEL if(noteditmode() || noselection()) return; -#define EDITSELMP if(noteditmode() || noselection() || multiplayer()) return; -#define EDITMP if(noteditmode() || multiplayer()) return; +#define EDITSEL if(noteditmode("EDITSEL") || noselection()) return; +#define EDITSELMP if(noteditmode("EDITSELMP") || noselection() || multiplayer()) return; +#define EDITMP if(noteditmode("EDITMP") || multiplayer()) return; void selectpos(int x, int y, int xs, int ys) { @@ -470,7 +474,7 @@ void perlin(int scale, int seed, int psize) VARF(fullbright, 0, 0, 1, if(fullbright) { - if(noteditmode()) return; + if(noteditmode("fullbright")) return; fullbrightlight(); } else calclight(); diff --git a/source/src/stream.cpp b/source/src/stream.cpp index 0dcac5da..61e59154 100644 --- a/source/src/stream.cpp +++ b/source/src/stream.cpp @@ -190,7 +190,7 @@ void sethomedir(const char *dir) clientlogf("Using home directory: %s", tmpdir); #endif - if(fixpackagedir(tmpdir) > 0) + if(fixpackagedir(tmpdir) > 0) { copystring(homedir, tmpdir); createdir(homedir); @@ -381,9 +381,6 @@ struct filestream : stream if(file && strchr(mode,'w')) { int fail = fstatvfs(fileno(file), &buf); -#ifndef STANDALONE -// if(!fail) conoutf("file test %lu %lu %lu",buf.f_frsize,buf.f_bsize, buf.f_bavail); -#endif if (fail || buf.f_frsize * buf.f_bavail < MINFSSIZE) { close(); diff --git a/source/src/water.cpp b/source/src/water.cpp index 114d0e24..7aaa4e0c 100644 --- a/source/src/water.cpp +++ b/source/src/water.cpp @@ -4,7 +4,7 @@ int wx1, wy1, wx2, wy2; float wsx1, wsy1, wsx2, wsy2; VARP(watersubdiv, 1, 4, 64); -VARF(waterlevel, -128, -128, 127, if(!noteditmode()) hdr.waterlevel = waterlevel); +VARF(waterlevel, -128, -128, 127, if(!noteditmode("waterlevel")) hdr.waterlevel = waterlevel); void setwatercolor(const char *r, const char *g, const char *b, const char *a) { @@ -84,7 +84,7 @@ void setprojtexmatrix() void setupmultitexrefract(GLuint reflecttex, GLuint refracttex) { setuptmu(0, "K , T @ Ka"); - + colortmu(0, hdr.watercolor[0]/255.0f, hdr.watercolor[1]/255.0f, hdr.watercolor[2]/255.0f, hdr.watercolor[3]/255.0f); glBindTexture(GL_TEXTURE_2D, refracttex); @@ -92,9 +92,9 @@ void setupmultitexrefract(GLuint reflecttex, GLuint refracttex) glActiveTexture_(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); - + setuptmu(1, "P , T @ C~a"); - + glBindTexture(GL_TEXTURE_2D, reflecttex); setprojtexmatrix(); @@ -104,7 +104,7 @@ void setupmultitexrefract(GLuint reflecttex, GLuint refracttex) void setupmultitexreflect(GLuint reflecttex) { setuptmu(0, "T , K @ Ca", "Ka * P~a"); - + float a = hdr.watercolor[3]/255.0f; colortmu(0, hdr.watercolor[0]/255.0f*a, hdr.watercolor[1]/255.0f*a, hdr.watercolor[2]/255.0f*a, 1.0f-a); @@ -116,9 +116,9 @@ void cleanupmultitex(GLuint reflecttex, GLuint refracttex) { resettmu(0); glLoadIdentity(); - + if(refracttex) - { + { glActiveTexture_(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); resettmu(1); @@ -133,7 +133,7 @@ VARP(mtwater, 0, 1, 1); int renderwater(float hf, GLuint reflecttex, GLuint refracttex) { if(wx1<0) return nquads; - + wx1 -= wx1%watersubdiv; wy1 -= wy1%watersubdiv; @@ -143,7 +143,7 @@ int renderwater(float hf, GLuint reflecttex, GLuint refracttex) { if(refracttex) { - setupmultitexrefract(reflecttex, refracttex); + setupmultitexrefract(reflecttex, refracttex); renderwaterstrips(vertwmtc, hf, t); } else @@ -157,11 +157,11 @@ int renderwater(float hf, GLuint reflecttex, GLuint refracttex) glDepthMask(GL_TRUE); } cleanupmultitex(reflecttex, refracttex); - + return nquads; } - if(!refracttex) + if(!refracttex) { glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); @@ -175,7 +175,7 @@ int renderwater(float hf, GLuint reflecttex, GLuint refracttex) { glColor4ubv(hdr.watercolor); renderwaterstrips(vertw, hf, t); - + glEnable(GL_TEXTURE_2D); } @@ -184,7 +184,7 @@ int renderwater(float hf, GLuint reflecttex, GLuint refracttex) glBindTexture(GL_TEXTURE_2D, refracttex ? refracttex : reflecttex); } - if(refracttex) + if(refracttex) { glColor3f(1, 1, 1); renderwaterstrips(vertwt, hf, t); @@ -205,7 +205,7 @@ int renderwater(float hf, GLuint reflecttex, GLuint refracttex) glDisable(GL_BLEND); if(!refracttex) glDepthMask(GL_TRUE); - + return nquads; } @@ -246,7 +246,7 @@ void calcwaterscissor() sy2 = max(sy2, y); } } - if(sx1 >= sx2 || sy1 >= sy2) + if(sx1 >= sx2 || sy1 >= sy2) { sx1 = sy1 = -1; sx2 = sy2 = 1; diff --git a/source/src/world.cpp b/source/src/world.cpp index ff882f7c..b27f0361 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -130,7 +130,7 @@ COMMAND(closestenttype, ARG_1STR); int closestent() // used for delent and edit mode ent display { - if(noteditmode()) return -1; + if(noteditmode("closestent")) return -1; int best = -1, bcnt = 0; float bdist = 99999; loopj(3) @@ -297,7 +297,7 @@ COMMAND(entset, ARG_5STR); void clearents(char *name) { int type = findtype(name); - if(noteditmode() || multiplayer()) return; + if(noteditmode("clearents") || multiplayer()) return; loopv(ents) { entity &e = ents[i]; @@ -357,7 +357,7 @@ void nextplayerstart(char *type) { static int cycle = -1; - if(noteditmode()) return; + if(noteditmode("nextplayerstart")) return; cycle = type[0] ? findentity(PLAYERSTART, cycle + 1, atoi(type)) : findentity(PLAYERSTART, cycle + 1); if(cycle >= 0) { @@ -419,7 +419,7 @@ bool worldbordercheck(int x1, int x2, int y1, int y2, int z1, int z2) // check bool empty_world(int factor, bool force) // main empty world creation routine, if passed factor -1 will enlarge old world by 1, factor -2 will shrink old world by 1 { - if(!force && noteditmode()) return false; + if(!force && noteditmode("empty world")) return false; if(factor == -2 && !worldbordercheck(ssize/4 + MINBORD, ssize/4 + MINBORD, ssize/4 + MINBORD, ssize/4 + MINBORD, 0, 0)) { conoutf("map does not fit into smaller world"); return false; } block *ow = NULL, be = { 0, 0, ssize, ssize }, bs = { ssize/4, ssize/4, ssize/2, ssize/2 }; int oldfactor = sfactor; diff --git a/source/src/worldlight.cpp b/source/src/worldlight.cpp index b5fed9b4..4794c7c1 100644 --- a/source/src/worldlight.cpp +++ b/source/src/worldlight.cpp @@ -158,12 +158,12 @@ void fullbrightlight(int level) lastcalclight = totalmillis; } -VARF(ambient, 0, 0, 0xFFFFFF, if(!noteditmode()) { hdr.ambient = ambient; calclight(); }); +VARF(ambient, 0, 0, 0xFFFFFF, if(!noteditmode("ambient")) { hdr.ambient = ambient; calclight(); }); void calclight() { bvec acol((hdr.ambient>>16)&0xFF, (hdr.ambient>>8)&0xFF, hdr.ambient&0xFF); - if(!acol.x && !acol.y) + if(!acol.x && !acol.y) { if(!acol.z) acol.z = 10; acol.x = acol.y = acol.z;