| 177 | VARF(ambient, 0, 0, 0xFFFFFF, if(!noteditmode("ambient")) { hdr.ambient = ambient; calclight(); unsavededits++;}); |
| 178 | |
| 179 | void calclight() |
| 180 | { |
| 181 | if(editmode) |
| 182 | { |
| 183 | servsqr *servworld = createservworld(world, cubicsize); |
| 184 | calcmapdims(clmapdims, servworld, ssize); |
| 185 | delete[] servworld; |
| 186 | } |
| 187 | uchar r = (hdr.ambient>>16) & 0xFF, g = (hdr.ambient>>8) & 0xFF, b = hdr.ambient & 0xFF; |
| 188 | if(!r && !g) |
| 189 | { |
| 190 | if(!b) b = 10; |
| 191 | r = g = b; |
| 192 | } |
| 193 | else if(!maxtmus) r = g = b = max(max(r, g), b); // the old (white) light code, here for the few people with old video cards that don't support overbright |
| 194 | sqr *s = S(0,0); |
| 195 | loopirev(cubicsize) |
| 196 | { |
| 197 | s->r = r; |
| 198 | s->g = g; |
| 199 | s->b = b; |
| 200 | s++; |
| 201 | } |
| 202 | |
| 203 | seedMT(ents.length() + hdr.maprevision); // static seed -> nothing random here |
| 204 | |
| 205 | loopv(ents) |
| 206 | { |
| 207 | entity &e = ents[i]; |
| 208 | if(e.type==LIGHT) calclightsource(e); |
| 209 | } |
| 210 | |
| 211 | popMT(); // undo the static seedMT() from above |
| 212 | |
| 213 | block bb = { clmapdims.x1 - 1, clmapdims.y1 - 1, clmapdims.xspan + 2, clmapdims.yspan + 2 }; |
| 214 | postlightarea(bb); |
| 215 | setvar("fullbright", 0); |
| 216 | lastcalclight = totalmillis; |
| 217 | } |
| 218 | |
| 219 | struct dlight |
| 220 | { |
no test coverage detected