Paste #XTOoWr9ri4GlYu5tisZM
| 1221 | 1221 | flCost += (1.0f-flFraction)*0.5f; |
|---|---|---|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | if (( |
|
| 1224 | if ((iabs(a) > 4) || (iabs(b) > 4)) continue; | |
| 1225 | 1225 | |
| 1226 | 1226 | vec from = to; |
| 1227 | 1227 | to.z -= (JUMP_HEIGHT - 1.0f); |
| … | ||
| 1249 | 1249 | flCost += (1.0f-flFraction)*0.5f; |
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | if (( |
|
| 1252 | if ((iabs(a) > 4) || (iabs(b) > 4)) continue; | |
| 1253 | 1253 | |
| 1254 | 1254 | vec from = to; |
| 1255 | 1255 | to.z -= (JUMP_HEIGHT - 1.0f); |
| … | ||
| 1671 | 1671 | void CWaypointClass::GetNodeIndexes(const vec &v_origin, short *i, short *j) |
| 1672 | 1672 | { |
| 1673 | 1673 | // Function code by cheesy and PMB |
| 1674 | //*i = abs((int)((int)(v_origin.x + (2*ssize)) / SECTOR_SIZE)); | |
| 1675 | //*j = abs((int)((int)(v_origin.y + (2*ssize)) / SECTOR_SIZE)); | |
| 1674 | //*i = iabs((int)((int)(v_origin.x + (2*ssize)) / SECTOR_SIZE)); | |
| 1675 | //*j = iabs((int)((int)(v_origin.y + (2*ssize)) / SECTOR_SIZE)); | |
| 1676 | 1676 | //*i = (int)((v_origin.x) / ssize * MAX_MAP_GRIDS); |
| 1677 | 1677 | //*j = (int)((v_origin.y) / ssize * MAX_MAP_GRIDS); |
| 1678 | *i = abs((int)((v_origin.x) / MAX_MAP_GRIDS)); | |
| 1679 | *j = abs((int)((v_origin.y) / MAX_MAP_GRIDS)); | |
| 1678 | *i = iabs((int)((v_origin.x) / MAX_MAP_GRIDS)); | |
| 1679 | *j = iabs((int)((v_origin.y) / MAX_MAP_GRIDS)); | |
| 1680 | 1680 | |
| 1681 | 1681 | if (*i > MAX_MAP_GRIDS - 1) |
| 1682 | 1682 | *i = MAX_MAP_GRIDS - 1; |
| 497 | 497 | if(lc<=seer_t1.length()) |
|---|---|---|
| 498 | 498 | { |
| 499 | 499 | int dt = seer_t1[seer_index] - seer_t1[lc]; |
| 500 | if( |
|
| 500 | if(iabs(dt)<2) | |
| 501 | 501 | { |
| 502 | 502 | conoutf("SCRIPT EXECUTION warning [%d:%s]", &p, p); |
| 503 | 503 | seer_t2.add(seer_t1[seer_index]); |
| 86 | 86 | #define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, true) |
|---|---|---|
| 87 | 87 | #define VARF(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, false) |
| 88 | 88 | #define VARFP(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, true) |
| 89 | #define VARNFP(name, global, min, cur, max, body) extern int global; void var_##name() { body; } int global = variable(#name, min, cur, max, &global, var_##name, true) | |
| 89 | 90 | |
| 90 | 91 | #define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, true) |
| 91 | 92 | #define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, false) |
| 763 | 763 | const char *genpwdhash(const char *name, const char *pwd, int salt) |
|---|---|---|
| 764 | 764 | { |
| 765 | 765 | static string temp; |
| 766 | formatstring(temp)("%s %d %s %s %d", pwd, salt, name, pwd, |
|
| 766 | formatstring(temp)("%s %d %s %s %d", pwd, salt, name, pwd, iabs(PROTOCOL_VERSION)); | |
| 767 | 767 | tiger::hashval hash; |
| 768 | 768 | tiger::hash((uchar *)temp, (int)strlen(temp), hash); |
| 769 | 769 | formatstring(temp)("%llx %llx %llx", hash.chunks[0], hash.chunks[1], hash.chunks[2]); |
| 126 | 126 | void makesel(bool isnew) |
|---|---|---|
| 127 | 127 | { |
| 128 | 128 | block &cursel = sels.last(); //RR 10/12/12 - FIXEME, error checking should happen with "isnew", not here checking if it really is new. |
| 129 | if(isnew || sels.length() == 0) addselection(min(lastx, cx), min(lasty, cy), |
|
| 129 | if(isnew || sels.length() == 0) addselection(min(lastx, cx), min(lasty, cy), iabs(lastx-cx)+1, iabs(lasty-cy)+1, max(lasth, ch)); | |
| 130 | 130 | else |
| 131 | 131 | { |
| 132 | 132 | cursel.x = min(lastx, cx); cursel.y = min(lasty, cy); |
| 133 | cursel.xs = |
|
| 133 | cursel.xs = iabs(lastx-cx)+1; cursel.ys = iabs(lasty-cy)+1; | |
| 134 | 134 | cursel.h = max(lasth, ch); |
| 135 | 135 | correctsel(cursel); |
| 136 | 136 | } |
| … | ||
| 645 | 645 | } |
| 646 | 646 | if(xo || yo) |
| 647 | 647 | { |
| 648 | block b = { max(-xo, 0), max(-yo, 0), ssize - |
|
| 648 | block b = { max(-xo, 0), max(-yo, 0), ssize - iabs(xo), ssize - iabs(yo) }, *cp = blockcopy(b); | |
| 649 | 649 | cp->x = max(xo, 0); |
| 650 | 650 | cp->y = max(yo, 0); |
| 651 | 651 | blockpaste(*cp); |
| 540 | 540 | { |
|---|---|---|
| 541 | 541 | const int maxskin[2] = { 4, 6 }; |
| 542 | 542 | t = team_base(t < 0 ? team : t); |
| 543 | nextskin[t] = |
|
| 543 | nextskin[t] = iabs(s) % maxskin[t]; | |
| 544 | 544 | } |
| 545 | 545 | }; |
| 546 | 546 |
| 513 | 513 | COMMANDF(screenres, "ii", (int *w, int *h) { screenres(*w, *h); }); |
|---|---|---|
| 514 | 514 | |
| 515 | 515 | static int curgamma = 100; |
| 516 | VAR |
|
| 516 | VARNFP(gamma, vgamma, 30, 100, 300, | |
| 517 | 517 | { |
| 518 | if(gamma == curgamma) return; | |
| 519 | curgamma = gamma; | |
| 520 | |
|
| 518 | if(vgamma == curgamma) return; | |
| 519 | curgamma = vgamma; | |
| 520 | float f = vgamma/100.0f; | |
| 521 | 521 | if(SDL_SetGamma(f,f,f)==-1) conoutf("Could not set gamma: %s", SDL_GetError()); |
| 522 | 522 | }); |
| 523 | 523 |
| 2 | 2 | #ifdef _FORTIFY_SOURCE |
|---|---|---|
| 3 | 3 | #undef _FORTIFY_SOURCE |
| 4 | 4 | #endif |
| 5 | ||
| 6 | #define gamma __gamma | |
| 7 | #endif | |
| 8 | ||
| 9 | #include <math.h> | |
| 10 | ||
| 11 | #ifdef __GNUC__ | |
| 12 | #undef gamma | |
| 13 | 5 | #endif |
| 14 | 6 | |
| 15 | 7 | #include <string.h> |
| … | ||
| 19 | 11 | #include <ctype.h> |
| 20 | 12 | #include <time.h> |
| 21 | 13 | #include <limits.h> |
| 14 | #include <math.h> | |
| 22 | 15 | #ifdef __GNUC__ |
| 23 | 16 | #include <new> |
| 24 | 17 | #include <signal.h> |
| 1029 | 1029 | { |
|---|---|---|
| 1030 | 1030 | demo_interm = true; |
| 1031 | 1031 | } |
| 1032 | else if(ai > 0) maxdemos = ai; |
|
| 1032 | else if(ai > 0) maxdemos = ai; | |
| 1033 | break; | |
| 1033 | 1034 | } |
| 1034 | 1035 | case 'W': demopath = a; break; |
| 1035 | 1036 | case 'r': maprot = a; break; |
| 202 | 202 | else // continue strip |
|---|---|---|
| 203 | 203 | { |
| 204 | 204 | int lighterr = lighterror*2; |
| 205 | if((abs(ol1r-l3->r)<lighterr && abs(ol2r-l4->r)<lighterr // skip vertices if light values are close enough | |
| 206 | && abs(ol1g-l3->g)<lighterr && abs(ol2g-l4->g)<lighterr | |
| 207 | |
|
| 205 | if((iabs(ol1r-l3->r)<lighterr && iabs(ol2r-l4->r)<lighterr // skip vertices if light values are close enough | |
| 206 | && iabs(ol1g-l3->g)<lighterr && iabs(ol2g-l4->g)<lighterr | |
| 207 | && iabs(ol1b-l3->b)<lighterr && iabs(ol2b-l4->b)<lighterr) || !wtex) | |
| 208 | 208 | { |
| 209 | 209 | verts.setsize(verts.length()-2); |
| 210 | 210 | nquads--; |
| … | ||
| 361 | 361 | { |
| 362 | 362 | int lighterr = lighterror*2; |
| 363 | 363 | if((!hf && !ohf) |
| 364 | && (( |
|
| 364 | && ((iabs(ol1r-l2->r)<lighterr && iabs(ol1g-l2->g)<lighterr && iabs(ol1b-l2->b)<lighterr) || !wtex)) // skip vertices if light values are close enough | |
| 365 | 365 | { |
| 366 | 366 | verts.setsize(verts.length()-2); |
| 367 | 367 | nquads--; |
| 330 | 330 | if(c=='r') c = stack[(sp > 0) ? --sp : sp]; // restore color |
|---|---|---|
| 331 | 331 | else if(c == 'b') { if(allowblinkingtext && !ignoreblinkingbit) stack[sp] *= -1; } // blinking text - only if allowed |
| 332 | 332 | else stack[sp] = c; |
| 333 | switch( |
|
| 333 | switch(iabs(stack[sp])) | |
| 334 | 334 | { |
| 335 | 335 | case '0': color = bvec( 2, 255, 128 ); break; // green: player talk |
| 336 | 336 | case '1': color = bvec( 96, 160, 255 ); break; // blue: team chat |
| … | ||
| 380 | 380 | //default: color = bvec( 255, 255, 255 ); break; |
| 381 | 381 | } |
| 382 | 382 | int b = (int) (sinf(lastmillis / 200.0f) * 115.0f); |
| 383 | b = stack[sp] > 0 ? 100 : min( |
|
| 383 | b = stack[sp] > 0 ? 100 : min(iabs(b), 100); | |
| 384 | 384 | glColor4ub(color.x, color.y, color.z, (a * b) / 100); |
| 385 | 385 | } |
| 386 | 386 | } |
| 54 | 54 | { |
|---|---|---|
| 55 | 55 | return a < b ? a : b; |
| 56 | 56 | } |
| 57 | ||
| 58 | static inline float round(float x) { return floor(x + 0.5f); } | |
| 57 | inline int iabs(int n) { return labs(n); } | |
| 59 | 58 | |
| 60 | 59 | #define clamp(a,b,c) (max(b, min(a, c))) |
| 61 | 60 | #define rnd(x) ((int)(randomMT()&0xFFFFFF)%(x)) |
| 79 | 79 | || o[i]->ceil!=o[3]->ceil |
|---|---|---|
| 80 | 80 | || o[i]->ftex!=o[3]->ftex |
| 81 | 81 | || o[i]->ctex!=o[3]->ctex |
| 82 | || abs(o[i+1]->r-o[0]->r)>lighterr // perfect mip even if light is not exactly equal | |
| 83 | || abs(o[i+1]->g-o[0]->g)>lighterr | |
| 84 | || |
|
| 82 | || iabs(o[i+1]->r-o[0]->r)>lighterr // perfect mip even if light is not exactly equal | |
| 83 | || iabs(o[i+1]->g-o[0]->g)>lighterr | |
| 84 | || iabs(o[i+1]->b-o[0]->b)>lighterr | |
| 85 | 85 | || o[i]->utex!=o[3]->utex |
| 86 | 86 | || o[i]->wtex!=o[3]->wtex) goto c; |
| 87 | 87 | } |
| 270 | 270 | void render_world(float vx, float vy, float vh, float changelod, int yaw, int pitch, float fov, float fovy, int w, int h) |
|---|---|---|
| 271 | 271 | { |
| 272 | 272 | loopi(LARGEST_FACTOR) stats[i] = 0; |
| 273 | min_lod = minimap || (player1->isspectating() && player1->spectatemode == SM_OVERVIEW) ? MAX_LOD : MIN_LOD+ |
|
| 273 | min_lod = minimap || (player1->isspectating() && player1->spectatemode == SM_OVERVIEW) ? MAX_LOD : MIN_LOD+iabs(pitch)/12; | |
| 274 | 274 | yaw = 360-yaw; |
| 275 | 275 | float widef = fov/75.0f; |
| 276 | int cdist = |
|
| 276 | int cdist = iabs(yaw%90-45); | |
| 277 | 277 | if(cdist<7) // hack to avoid popup at high fovs at 45 yaw |
| 278 | 278 | { |
| 279 | 279 | min_lod = max(min_lod, (int)(MIN_LOD+(10-cdist)/1.0f*widef)); // less if lod worked better |