diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 249a9482..b5980afb 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -236,8 +236,7 @@ int teamworkid = -1; void showhudextras(char hudextras, char value){ void (*outf)(const char *s, ...) = (hudextras > 1 ? hudoutf : conoutf); - char *(*spam)(const char *s, char *o, int max) = (hudextras == 2 ? stolower : stoupper), o[50]; -#define SSPAM(x) spam(x,o,40) + bool caps = hudextras < 3 ? false : true; switch(value) { case HE_COMBO: @@ -247,17 +246,17 @@ void showhudextras(char hudextras, char value){ case HE_COMBO5: { int n = value - HE_COMBO; - if (n > 3) outf("\f3%s",SSPAM("monster combo!!!")); // I expect to never see this one - else if (!n) outf("\f5%s",SSPAM("combo")); - else outf("\f5%s x%d",SSPAM("multi combo"),n+1); + if (n > 3) outf("\f3%s",strcaps("monster combo!!!",caps)); // I expect to never see this one + else if (!n) outf("\f5%s",strcaps("combo", caps)); + else outf("\f5%s x%d",strcaps("multi combo", caps),n+1); break; } case HE_TEAMWORK: - outf("\f5%s",SSPAM("teamwork done")); break; + outf("\f5%s",strcaps("teamwork done", caps)); break; case HE_FLAGDEFENDED: - outf("\f5%s",SSPAM("you defended the flag")); break; + outf("\f5%s",strcaps("you defended the flag", caps)); break; case HE_FLAGCOVERED: - outf("\f5%s",SSPAM("you covered the flag")); break; + outf("\f5%s",strcaps("you covered the flag", caps)); break; case HE_COVER: if (teamworkid >= 0) { playerent *p = getclient(teamworkid); diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 32d837ea..0e504978 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -14,7 +14,8 @@ float raycube(const vec &o, const vec &ray, vec &surface) vec v = o; float dist = 0, dx = 0, dy = 0, dz = 0; - for(int nr=0;nr<1024;nr++) // sam's suggestion + int nr; + for(nr=0;nr<512;nr++) // sam's suggestion :: I found no map which got nr > 350 { int x = int(v.x), y = int(v.y); if(x < 0 || y < 0 || x >= ssize || y >= ssize) return -1; @@ -55,6 +56,7 @@ float raycube(const vec &o, const vec &ray, vec &surface) v.add(vec(ray).mul(disttonext)); dist += disttonext; } + if (nr == 512) return -1; return dist; } diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index 43c74b51..b51c55fd 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -565,26 +565,29 @@ struct servernickblacklist : serverconfigfile } }; -#define FORBIDDENSIZE 30 +#define FORBIDDENSIZE 15 struct serverforbiddenlist : serverconfigfile { int num; - char entries[100][FORBIDDENSIZE+1]; // it is stupid to have more than 100 entries + char entries[100][2][FORBIDDENSIZE+1]; // 100 entries and 2 words per entry is more than enough void initlist() { num = 0; - memset(entries,0,100*(FORBIDDENSIZE+1)); + memset(entries,'\0',2*100*(FORBIDDENSIZE+1)); } void addentry(char *s) { - int i = 0; - if (num < 100) { // no warnings - while( *s != '\n' && *s != '\r' && i < FORBIDDENSIZE) { - entries[num][i] = *s; s++; i++; - } - entries[num][i] = '\0'; + int len = strlen(s); + if ( len > 128 || len < 3 ) return; + int n = 0; + string s1, s2; + char *c1 = s1, *c2 = s2; + if (num < 100 && (n = sscanf(s,"%s %s",s1,s2)) > 0 ) { // no warnings + strncpy(entries[num][0],c1,FORBIDDENSIZE); + if ( n > 1 ) strncpy(entries[num][1],c2,FORBIDDENSIZE); + else entries[num][1][0]='\0'; num++; } } @@ -607,29 +610,12 @@ struct serverforbiddenlist : serverconfigfile bool canspeech(char *s) { - char *a, *b, *c, *d, *end; for (int i=0; i 0 ) { // this is not a pair, but there is a previous pattern + if (*s == '.' || *s == *(s-1) || issimilar(*(s+1),*dp) ); // separator or typo (do nothing) + else if ( issimilar(*(s+1),*(dp+1)) || *s == '*' ) dp++; // wild card or typo + else hit--; // maybe this is nothing + } + else dp = d; // nothing here + s++; // walk on the string + if ( hit && 5 * hit > 4 * len ) return true; // found it! + } + return false; } #define loopv(v) for(int i = 0; i<(v).length(); i++)