ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.324 by root, Sun Nov 18 01:58:53 2018 UTC vs.
Revision 1.333 by root, Mon Nov 19 01:23:01 2018 UTC

76# include <netinet/in.h> 76# include <netinet/in.h>
77# include <netinet/tcp.h> 77# include <netinet/tcp.h>
78# include <inttypes.h> 78# include <inttypes.h>
79#endif 79#endif
80 80
81#if __GNUC__ >= 4 81#include "ecb.h"
82# define expect(expr,value) __builtin_expect ((expr),(value)) 82#include "salloc.h"
83#else
84# define expect(expr,value) (expr)
85#endif
86
87#define expect_false(expr) expect ((expr) != 0, 0)
88#define expect_true(expr) expect ((expr) != 0, 1)
89 83
90#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
91 85
92/* this is used as fow flag as well, so has to have a different value */ 86/* this is used as fow flag as well, so has to have a different value */
93/* then anything that is computed by incoming darkness */ 87/* then anything that is computed by incoming darkness */
111fast_sv_grow (SV *sv, STRLEN need) 105fast_sv_grow (SV *sv, STRLEN need)
112{ 106{
113 STRLEN len = SvLEN (sv); 107 STRLEN len = SvLEN (sv);
114 STRLEN want = SvCUR (sv) + need; 108 STRLEN want = SvCUR (sv) + need;
115 109
116 if (expect_false (len < want)) 110 if (ecb_expect_false (len < want))
117 { 111 {
118 do 112 do
119 len *= 2; 113 len *= 2;
120 while (len < want); 114 while (len < want);
121 115
205struct cf_layout { 199struct cf_layout {
206 PangoLayout *pl; 200 PangoLayout *pl;
207 float r, g, b, a; // default color for rgba mode 201 float r, g, b, a; // default color for rgba mode
208 int base_height; 202 int base_height;
209 DC__Font font; 203 DC__Font font;
210 rc_t *rc; 204 rc_t rc;
211}; 205};
212 206
213typedef cf_layout *DC__Layout; 207typedef cf_layout *DC__Layout;
214 208
215static DC__Font default_font; 209static DC__Font default_font;
255 if (!rect.height) rect.height = 1; 249 if (!rect.height) rect.height = 1;
256 250
257 *w = rect.width; 251 *w = rect.width;
258 *h = rect.height; 252 *h = rect.height;
259} 253}
254
255/////////////////////////////////////////////////////////////////////////////
260 256
261typedef uint16_t tileid; 257typedef uint16_t tileid;
262typedef uint16_t faceid; 258typedef uint16_t faceid;
263 259
264struct maptex 260struct maptex
296 maprow *row; 292 maprow *row;
297}; 293};
298 294
299typedef mapgrid *DC__Map; 295typedef mapgrid *DC__Map;
300 296
301static char * 297template<typename T>
298static void
302prepend (char *ptr, int sze, int inc) 299prepend (T *&ptr, int sze, int inc)
303{ 300{
304 char *p; 301 T *p;
305 302
306 New (0, p, sze + inc, char); 303 Newx (p, inc + sze, T);
307 Zero (p, inc, char); 304 Zero (p, inc, T);
308 Move (ptr, p + inc, sze, char); 305 Move (ptr, p + inc, sze, T);
309 Safefree (ptr); 306 Safefree (ptr);
310 307
311 return p; 308 ptr = p;
312} 309}
313 310
314static char * 311template<typename T>
312static void
315append (char *ptr, int sze, int inc) 313append (T *&ptr, int sze, int inc)
316{ 314{
317 Renew (ptr, sze + inc, char); 315 Renew (ptr, sze + inc, T);
318 Zero (ptr + sze, inc, char); 316 Zero (ptr + sze, inc, T);
319
320 return ptr;
321} 317}
322
323#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
324#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
325 318
326static void 319static void
327need_facenum (struct mapgrid *self, faceid face) 320need_facenum (struct mapgrid *self, faceid face)
328{ 321{
329 while (self->faces <= face) 322 while (self->faces <= face)
330 { 323 {
331 Append (tileid, self->face2tile, self->faces, self->faces); 324 append (self->face2tile, self->faces, self->faces);
332 self->faces *= 2; 325 self->faces *= 2;
333 } 326 }
334} 327}
335 328
336static void 329static void
337need_texid (struct mapgrid *self, int texid) 330need_texid (struct mapgrid *self, int texid)
338{ 331{
339 while (self->texs <= texid) 332 while (self->texs <= texid)
340 { 333 {
341 Append (maptex, self->tex, self->texs, self->texs); 334 append (self->tex, self->texs, self->texs);
342 self->texs *= 2; 335 self->texs *= 2;
343 } 336 }
344} 337}
345 338
346static maprow * 339static maprow *
347map_get_row (mapgrid *self, int y) 340map_get_row (mapgrid *self, int y)
348{ 341{
349 if (0 > y) 342 if (0 > y)
350 { 343 {
351 int extend = - y + MAP_EXTEND_Y; 344 int extend = - y + MAP_EXTEND_Y;
352 Prepend (maprow, self->row, self->rows, extend); 345 prepend (self->row, self->rows, extend);
353 346
354 self->rows += extend; 347 self->rows += extend;
355 self->y += extend; 348 self->y += extend;
356 y += extend; 349 y += extend;
357 } 350 }
358 else if (y >= self->rows) 351 else if (y >= self->rows)
359 { 352 {
360 int extend = y - self->rows + MAP_EXTEND_Y; 353 int extend = y - self->rows + MAP_EXTEND_Y;
361 Append (maprow, self->row, self->rows, extend); 354 append (self->row, self->rows, extend);
362 self->rows += extend; 355 self->rows += extend;
363 } 356 }
364 357
365 return self->row + y; 358 return self->row + y;
366} 359}
376 } 369 }
377 370
378 if (row->c0 > x) 371 if (row->c0 > x)
379 { 372 {
380 int extend = row->c0 - x + MAP_EXTEND_X; 373 int extend = row->c0 - x + MAP_EXTEND_X;
381 Prepend (mapcell, row->col, row->c1 - row->c0, extend); 374 prepend (row->col, row->c1 - row->c0, extend);
382 row->c0 -= extend; 375 row->c0 -= extend;
383 } 376 }
384 else if (x >= row->c1) 377 else if (x >= row->c1)
385 { 378 {
386 int extend = x - row->c1 + MAP_EXTEND_X; 379 int extend = x - row->c1 + MAP_EXTEND_X;
387 Append (mapcell, row->col, row->c1 - row->c0, extend); 380 append (row->col, row->c1 - row->c0, extend);
388 row->c1 += extend; 381 row->c1 += extend;
389 } 382 }
390 383
391 return row->col + (x - row->c0); 384 return row->col + (x - row->c0);
392} 385}
534 n |= n >> 4; 527 n |= n >> 4;
535 n |= n >> 8; 528 n |= n >> 8;
536 n |= n >> 16; 529 n |= n >> 16;
537 530
538 return n + 1; 531 return n + 1;
539}
540
541static unsigned int
542popcount (unsigned int n)
543{
544 n -= (n >> 1) & 0x55555555U;
545 n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U);
546 n = ((n >> 4) + n) & 0x0f0f0f0fU;
547 n *= 0x01010101U;
548
549 return n >> 24;
550} 532}
551 533
552/* SDL should provide this, really. */ 534/* SDL should provide this, really. */
553#define SDLK_MODIFIER_MIN 300 535#define SDLK_MODIFIER_MIN 300
554#define SDLK_MODIFIER_MAX 314 536#define SDLK_MODIFIER_MAX 314
885 867
886NV ceil (NV x) 868NV ceil (NV x)
887 869
888IV minpot (UV n) 870IV minpot (UV n)
889 871
872UV ld32 (UV n)
873 CODE:
874 RETVAL = ecb_ld32 (n);
875 OUTPUT:
876 RETVAL
877
890IV popcount (UV n) 878IV popcount (UV n)
879 CODE:
880 RETVAL = ecb_popcount32 (n);
881 OUTPUT:
882 RETVAL
891 883
892NV distance (NV dx, NV dy) 884NV distance (NV dx, NV dy)
893 CODE: 885 CODE:
894 RETVAL = pow (dx * dx + dy * dy, 0.5); 886 RETVAL = pow (dx * dx + dy * dy, 0.5);
895 OUTPUT: 887 OUTPUT:
1369 tc_restore (); 1361 tc_restore ();
1370 1362
1371DC::Layout 1363DC::Layout
1372new (SV *klass) 1364new (SV *klass)
1373 CODE: 1365 CODE:
1374 New (0, RETVAL, 1, struct cf_layout); 1366 RETVAL = new cf_layout;
1375 1367
1376 RETVAL->pl = pango_layout_new (opengl_context); 1368 RETVAL->pl = pango_layout_new (opengl_context);
1377 RETVAL->r = 1.; 1369 RETVAL->r = 1.;
1378 RETVAL->g = 1.; 1370 RETVAL->g = 1.;
1379 RETVAL->b = 1.; 1371 RETVAL->b = 1.;
1380 RETVAL->a = 1.; 1372 RETVAL->a = 1.;
1381 RETVAL->base_height = MIN_FONT_HEIGHT; 1373 RETVAL->base_height = MIN_FONT_HEIGHT;
1382 RETVAL->font = 0; 1374 RETVAL->font = 0;
1383 RETVAL->rc = rc_alloc ();
1384 1375
1385 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); 1376 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR);
1386 layout_update_font (RETVAL); 1377 layout_update_font (RETVAL);
1387 OUTPUT: 1378 OUTPUT:
1388 RETVAL 1379 RETVAL
1389 1380
1390void 1381void
1391DESTROY (DC::Layout self) 1382DESTROY (DC::Layout self)
1392 CODE: 1383 CODE:
1393 g_object_unref (self->pl); 1384 g_object_unref (self->pl);
1394 rc_free (self->rc);
1395 Safefree (self); 1385 delete self;
1396 1386
1397void 1387void
1398set_text (DC::Layout self, SV *text_) 1388set_text (DC::Layout self, SV *text_)
1399 CODE: 1389 CODE:
1400{ 1390{
1654} 1644}
1655 1645
1656void 1646void
1657render (DC::Layout self, float x, float y, int flags = 0) 1647render (DC::Layout self, float x, float y, int flags = 0)
1658 CODE: 1648 CODE:
1659 rc_clear (self->rc); 1649 self->rc.clear ();
1660 pango_opengl_render_layout_subpixel ( 1650 pango_opengl_render_layout_subpixel (
1661 self->pl, 1651 self->pl,
1662 self->rc, 1652 &self->rc,
1663 x * PANGO_SCALE, y * PANGO_SCALE, 1653 x * PANGO_SCALE, y * PANGO_SCALE,
1664 self->r, self->g, self->b, self->a, 1654 self->r, self->g, self->b, self->a,
1665 flags 1655 flags
1666 ); 1656 );
1667 // we assume that context_change actually clears/frees stuff 1657 // we assume that context_change actually clears/frees stuff
1678 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1668 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
1679 GL_ONE , GL_ONE_MINUS_SRC_ALPHA); 1669 GL_ONE , GL_ONE_MINUS_SRC_ALPHA);
1680 glEnable (GL_ALPHA_TEST); 1670 glEnable (GL_ALPHA_TEST);
1681 glAlphaFunc (GL_GREATER, 7.f / 255.f); 1671 glAlphaFunc (GL_GREATER, 7.f / 255.f);
1682 1672
1683 rc_draw (self->rc); 1673 self->rc.draw ();
1684 1674
1685 glDisable (GL_ALPHA_TEST); 1675 glDisable (GL_ALPHA_TEST);
1686 glDisable (GL_BLEND); 1676 glDisable (GL_BLEND);
1687 glDisable (GL_TEXTURE_2D); 1677 glDisable (GL_TEXTURE_2D);
1688} 1678}
2058 self->ox += dx; self->x += dx; 2048 self->ox += dx; self->x += dx;
2059 self->oy += dy; self->y += dy; 2049 self->oy += dy; self->y += dy;
2060 2050
2061 while (self->y < 0) 2051 while (self->y < 0)
2062 { 2052 {
2063 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); 2053 prepend (self->row, self->rows, MAP_EXTEND_Y);
2064 2054
2065 self->rows += MAP_EXTEND_Y; 2055 self->rows += MAP_EXTEND_Y;
2066 self->y += MAP_EXTEND_Y; 2056 self->y += MAP_EXTEND_Y;
2067 } 2057 }
2068} 2058}
2227 int x, y, z; 2217 int x, y, z;
2228 2218
2229 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! 2219 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static!
2230 int pl_x, pl_y; 2220 int pl_x, pl_y;
2231 maptex pl_tex; 2221 maptex pl_tex;
2232 rc_t *rc = rc_alloc (); 2222 rc_t rc;
2233 rc_t *rc_ov = rc_alloc (); 2223 rc_t rc_ov;
2234 rc_key_t key; 2224 rc_key_t key;
2235 rc_array_t *arr; 2225 rc_t::array_t *arr;
2236 2226
2237 pl_tex.name = 0; 2227 pl_tex.name = 0;
2238 2228
2239 // that's current max. sorry. 2229 // that's current max. sorry.
2240 if (sw > 255) sw = 255; 2230 if (sw > 255) sw = 255;
2277 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 2267 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2278 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2268 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2279 2269
2280 for (z = 0; z <= 2; z++) 2270 for (z = 0; z <= 2; z++)
2281 { 2271 {
2282 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 2272 std::bitset<256> smooth_level; // one bit for every possible smooth level
2283 smooth_key skey; 2273 smooth_key skey;
2284 smooth_hash smooth; 2274 smooth_hash smooth;
2285 memset (smooth_level, 0, sizeof (smooth_level));
2286 key.texname = -1; 2275 key.texname = -1;
2287 2276
2288 for (y = 0; y < sh; y++) 2277 for (y = 0; y < sh; y++)
2289 if (0 <= y + my && y + my < self->rows) 2278 if (0 <= y + my && y + my < self->rows)
2290 { 2279 {
2307 2296
2308 if (!tex.name) 2297 if (!tex.name)
2309 tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ 2298 tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */
2310 2299
2311 key.texname = tex.name; 2300 key.texname = tex.name;
2312 arr = rc_array (rc, &key); 2301 arr = &rc.array (key);
2313 } 2302 }
2314 2303
2315 px = (x + 1) * Th - tex.w; 2304 px = (x + 1) * Th - tex.w;
2316 py = (y + 1) * Tw - tex.h; 2305 py = (y + 1) * Tw - tex.h;
2317 2306
2318 if (expect_false (cell->player == player) && expect_false (z == 2)) 2307 if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2))
2319 { 2308 {
2320 pl_x = px; 2309 pl_x = px;
2321 pl_y = py; 2310 pl_y = py;
2322 pl_tex = tex; 2311 pl_tex = tex;
2323 continue; 2312 continue;
2324 } 2313 }
2325 2314
2326 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2315 arr->t2f_v3f (0 , 0 , px , py , 0);
2327 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); 2316 arr->t2f_v3f (0 , tex.t, px , py + tex.h, 0);
2328 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2317 arr->t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0);
2329 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2318 arr->t2f_v3f (tex.s, 0 , px + tex.w, py , 0);
2330 2319
2331 // update smooth hash 2320 // update smooth hash
2332 if (tex.smoothtile) 2321 if (tex.smoothtile)
2333 { 2322 {
2334 skey.tile = tex.smoothtile; 2323 skey.tile = tex.smoothtile;
2335 skey.level = tex.smoothlevel; 2324 skey.level = tex.smoothlevel;
2336 2325
2337 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); 2326 smooth_level[tex.smoothlevel] = 1;
2338 2327
2339 // add bits to current tile and all neighbours. skey.x|y is 2328 // add bits to current tile and all neighbours. skey.x|y is
2340 // shifted +1|+1 so we always stay positive. 2329 // shifted +1|+1 so we always stay positive.
2341 2330
2342 // bits is ___n cccc CCCC bbbb 2331 // bits is ___n cccc CCCC bbbb
2366 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); 2355 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400);
2367 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); 2356 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800);
2368 } 2357 }
2369 } 2358 }
2370 2359
2371 if (expect_false (z == 2) && expect_false (cell->flags)) 2360 if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags))
2372 { 2361 {
2373 // overlays such as the speech bubble, probably more to come 2362 // overlays such as the speech bubble, probably more to come
2374 if (cell->flags & 1) 2363 if (cell->flags & 1)
2375 { 2364 {
2376 rc_key_t key_ov = key; 2365 rc_key_t key_ov = key;
2377 maptex tex = self->tex [TEXID_SPEECH]; 2366 maptex tex = self->tex[TEXID_SPEECH];
2378 rc_array_t *arr;
2379 int px = x * Tw + Tw * 2 / 32; 2367 int px = x * Tw + Tw * 2 / 32;
2380 int py = y * Th - Th * 6 / 32; 2368 int py = y * Th - Th * 6 / 32;
2381 2369
2382 key_ov.texname = tex.name; 2370 key_ov.texname = tex.name;
2383 arr = rc_array (rc_ov, &key_ov); 2371 rc_t::array_t &arr = rc_ov.array (key_ov);
2384 2372
2385 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2373 arr.t2f_v3f (0 , 0 , px , py , 0);
2386 rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); 2374 arr.t2f_v3f (0 , tex.t, px , py + Th, 0);
2387 rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); 2375 arr.t2f_v3f (tex.s, tex.t, px + Tw, py + Th, 0);
2388 rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); 2376 arr.t2f_v3f (tex.s, 0 , px + Tw, py , 0);
2389 } 2377 }
2390 } 2378 }
2391 } 2379 }
2392 } 2380 }
2393 2381
2394 rc_draw (rc); 2382 rc.draw ();
2395 rc_clear (rc); 2383 rc.clear ();
2396 2384
2397 // go through all smoothlevels, lowest to highest, then draw. 2385 // go through all smoothlevels, lowest to highest, then draw.
2398 // this is basically counting sort 2386 // this is basically counting sort
2399 { 2387 {
2400 int w, b; 2388 int w, b;
2401 2389
2402 glEnable (GL_TEXTURE_2D); 2390 glEnable (GL_TEXTURE_2D);
2403 glBegin (GL_QUADS); 2391 glBegin (GL_QUADS);
2404 for (w = 0; w < 256 / 32; ++w) 2392 for (int level = 0; level < smooth_level.size (); ++level)
2393 if (smooth_level[level])
2394 for (auto &&it = smooth.begin (); it != smooth.end (); ++it)
2405 { 2395 {
2406 uint32_t smask = smooth_level [w]; 2396 smooth_key &skey = it->first;
2407 if (smask) 2397 IV bits = it->second;
2408 for (b = 0; b < 32; ++b) 2398
2409 if (smask & (((uint32_t)1) << b)) 2399 if (!(bits & 0x1000)
2400 && skey.level == level
2401 && level > smooth_max [skey.x][skey.y])
2410 { 2402 {
2411 int level = (w << 5) | b; 2403 maptex tex = self->tex [skey.tile];
2404 int px = (((int)skey.x) - 1) * Tw;
2405 int py = (((int)skey.y) - 1) * Th;
2406 int border = bits & 15;
2407 int corner = (bits >> 8) & ~(bits >> 4) & 15;
2408 float dx = tex.s * .0625f; // 16 images/row
2409 float dy = tex.t * .5f ; // 2 images/column
2410
2412 HE *he; 2411 if (tex.name)
2413
2414 for (auto &&it = smooth.begin (); it != smooth.end (); ++it)
2415 { 2412 {
2416 smooth_key &skey = it->first; 2413 // this time avoiding texture state changes
2417 IV bits = it->second; 2414 // save gobs of state changes.
2418 2415 if (key.texname != tex.name)
2419 if (!(bits & 0x1000)
2420 && skey.level == level
2421 && level > smooth_max [skey.x][skey.y])
2422 { 2416 {
2423 maptex tex = self->tex [skey.tile];
2424 int px = (((int)skey.x) - 1) * Tw;
2425 int py = (((int)skey.y) - 1) * Th;
2426 int border = bits & 15;
2427 int corner = (bits >> 8) & ~(bits >> 4) & 15;
2428 float dx = tex.s * .0625f; // 16 images/row
2429 float dy = tex.t * .5f ; // 2 images/column
2430
2431 if (tex.name)
2432 {
2433 // this time avoiding texture state changes
2434 // save gobs of state changes.
2435 if (key.texname != tex.name)
2436 {
2437 self->tex [skey.tile].unused = 0; 2417 self->tex [skey.tile].unused = 0;
2438 2418
2439 glEnd (); 2419 glEnd ();
2440 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); 2420 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
2441 glBegin (GL_QUADS); 2421 glBegin (GL_QUADS);
2442 } 2422 }
2443 2423
2444 if (border) 2424 if (border)
2445 { 2425 {
2446 float ox = border * dx; 2426 float ox = border * dx;
2447 2427
2448 glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); 2428 glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
2449 glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); 2429 glTexCoord2f (ox , dy ); glVertex2i (px , py + Th);
2450 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); 2430 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th);
2451 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); 2431 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py );
2452 } 2432 }
2453 2433
2454 if (corner) 2434 if (corner)
2455 { 2435 {
2456 float ox = corner * dx; 2436 float ox = corner * dx;
2457 2437
2458 glTexCoord2f (ox , dy ); glVertex2i (px , py ); 2438 glTexCoord2f (ox , dy ); glVertex2i (px , py );
2459 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); 2439 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th);
2460 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); 2440 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th);
2461 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); 2441 glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py );
2462 }
2463 }
2464 } 2442 }
2465 } 2443 }
2466 } 2444 }
2467 } 2445 }
2468 2446
2469 glEnd (); 2447 glEnd ();
2470 glDisable (GL_TEXTURE_2D); 2448 glDisable (GL_TEXTURE_2D);
2471 key.texname = -1; 2449 key.texname = -1;
2472 } 2450 }
2477 maptex tex = pl_tex; 2455 maptex tex = pl_tex;
2478 int px = pl_x + sdx; 2456 int px = pl_x + sdx;
2479 int py = pl_y + sdy; 2457 int py = pl_y + sdy;
2480 2458
2481 key.texname = tex.name; 2459 key.texname = tex.name;
2482 arr = rc_array (rc, &key); 2460 rc_t::array_t &arr = rc.array (key);
2483 2461
2484 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2462 arr.t2f_v3f (0 , 0 , px , py , 0);
2485 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); 2463 arr.t2f_v3f (0 , tex.t, px , py + tex.h, 0);
2486 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2464 arr.t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0);
2487 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2465 arr.t2f_v3f (tex.s, 0 , px + tex.w, py , 0);
2488 2466
2489 rc_draw (rc); 2467 rc.draw ();
2490 } 2468 }
2491 2469
2492 rc_draw (rc_ov); 2470 rc_ov.draw ();
2493 rc_clear (rc_ov); 2471 rc_ov.clear ();
2494 2472
2495 glDisable (GL_BLEND); 2473 glDisable (GL_BLEND);
2496 rc_free (rc);
2497 rc_free (rc_ov);
2498 2474
2499 // top layer: overlays such as the health bar 2475 // top layer: overlays such as the health bar
2500 for (y = 0; y < sh; y++) 2476 for (y = 0; y < sh; y++)
2501 if (0 <= y + my && y + my < self->rows) 2477 if (0 <= y + my && y + my < self->rows)
2502 { 2478 {
2508 mapcell *cell = row->col + (x + mx - row->c0); 2484 mapcell *cell = row->col + (x + mx - row->c0);
2509 2485
2510 int px = x * Tw; 2486 int px = x * Tw;
2511 int py = y * Th; 2487 int py = y * Th;
2512 2488
2513 if (expect_false (cell->player == player)) 2489 if (ecb_expect_false (cell->player == player))
2514 { 2490 {
2515 px += sdx; 2491 px += sdx;
2516 py += sdy; 2492 py += sdy;
2517 } 2493 }
2518 2494

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines