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.165 by root, Fri Dec 8 14:59:54 2006 UTC vs.
Revision 1.173 by root, Wed Apr 4 02:43:29 2007 UTC

1#ifdef _WIN32 1#ifdef _WIN32
2# define WIN32_LEAN_AND_MEAN 2# define WIN32_LEAN_AND_MEAN
3# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls 3# define NTDDI_VERSION NTDDI_WIN2K // needed to get win2000 api calls
4# include <malloc.h> 4# include <malloc.h>
5# include <windows.h> 5# include <windows.h>
6# include <wininet.h> 6# include <wininet.h>
7# pragma warning(disable:4244) 7# pragma warning(disable:4244)
8# pragma warning(disable:4761) 8# pragma warning(disable:4761)
14 14
15#ifdef _WIN32 15#ifdef _WIN32
16# undef pipe 16# undef pipe
17#endif 17#endif
18 18
19#include <assert.h>
19#include <math.h> 20#include <math.h>
20#include <string.h> 21#include <string.h>
21#include <stdio.h> 22#include <stdio.h>
22#include <stdlib.h> 23#include <stdlib.h>
23 24
359 n |= n >> 16; 360 n |= n >> 16;
360 361
361 return n + 1; 362 return n + 1;
362} 363}
363 364
365/* SDL should provide this, really. */
366#define SDLK_MODIFIER_MIN 300
367#define SDLK_MODIFIER_MAX 314
368
364MODULE = CFPlus PACKAGE = CFPlus 369MODULE = CFPlus PACKAGE = CFPlus
365 370
366PROTOTYPES: ENABLE 371PROTOTYPES: ENABLE
367 372
368BOOT: 373BOOT:
371 static const struct { 376 static const struct {
372 const char *name; 377 const char *name;
373 IV iv; 378 IV iv;
374 } *civ, const_iv[] = { 379 } *civ, const_iv[] = {
375# define const_iv(name) { # name, (IV)name } 380# define const_iv(name) { # name, (IV)name }
381 const_iv (SDLK_MODIFIER_MIN),
382 const_iv (SDLK_MODIFIER_MAX),
383
376 const_iv (SDL_ACTIVEEVENT), 384 const_iv (SDL_ACTIVEEVENT),
377 const_iv (SDL_KEYDOWN), 385 const_iv (SDL_KEYDOWN),
378 const_iv (SDL_KEYUP), 386 const_iv (SDL_KEYUP),
379 const_iv (SDL_MOUSEMOTION), 387 const_iv (SDL_MOUSEMOTION),
380 const_iv (SDL_MOUSEBUTTONDOWN), 388 const_iv (SDL_MOUSEBUTTONDOWN),
389 const_iv (SDL_EVENT_RESERVEDA), 397 const_iv (SDL_EVENT_RESERVEDA),
390 const_iv (SDL_EVENT_RESERVEDB), 398 const_iv (SDL_EVENT_RESERVEDB),
391 const_iv (SDL_VIDEORESIZE), 399 const_iv (SDL_VIDEORESIZE),
392 const_iv (SDL_VIDEOEXPOSE), 400 const_iv (SDL_VIDEOEXPOSE),
393 const_iv (SDL_USEREVENT), 401 const_iv (SDL_USEREVENT),
402
403 const_iv (SDL_APPINPUTFOCUS),
404 const_iv (SDL_APPMOUSEFOCUS),
405 const_iv (SDL_APPACTIVE),
406
394 const_iv (SDLK_KP0), 407 const_iv (SDLK_KP0),
395 const_iv (SDLK_KP1), 408 const_iv (SDLK_KP1),
396 const_iv (SDLK_KP2), 409 const_iv (SDLK_KP2),
397 const_iv (SDLK_KP3), 410 const_iv (SDLK_KP3),
398 const_iv (SDLK_KP4), 411 const_iv (SDLK_KP4),
453 const_iv (SDLK_BREAK), 466 const_iv (SDLK_BREAK),
454 const_iv (SDLK_MENU), 467 const_iv (SDLK_MENU),
455 const_iv (SDLK_POWER), 468 const_iv (SDLK_POWER),
456 const_iv (SDLK_EURO), 469 const_iv (SDLK_EURO),
457 const_iv (SDLK_UNDO), 470 const_iv (SDLK_UNDO),
471
458 const_iv (KMOD_NONE), 472 const_iv (KMOD_NONE),
473 const_iv (KMOD_SHIFT),
459 const_iv (KMOD_LSHIFT), 474 const_iv (KMOD_LSHIFT),
460 const_iv (KMOD_RSHIFT), 475 const_iv (KMOD_RSHIFT),
476 const_iv (KMOD_CTRL),
461 const_iv (KMOD_LCTRL), 477 const_iv (KMOD_LCTRL),
462 const_iv (KMOD_RCTRL), 478 const_iv (KMOD_RCTRL),
479 const_iv (KMOD_ALT),
463 const_iv (KMOD_LALT), 480 const_iv (KMOD_LALT),
464 const_iv (KMOD_RALT), 481 const_iv (KMOD_RALT),
482 const_iv (KMOD_META),
465 const_iv (KMOD_LMETA), 483 const_iv (KMOD_LMETA),
466 const_iv (KMOD_RMETA), 484 const_iv (KMOD_RMETA),
467 const_iv (KMOD_NUM), 485 const_iv (KMOD_NUM),
468 const_iv (KMOD_CAPS), 486 const_iv (KMOD_CAPS),
469 const_iv (KMOD_MODE), 487 const_iv (KMOD_MODE),
470 const_iv (KMOD_CTRL),
471 const_iv (KMOD_SHIFT),
472 const_iv (KMOD_ALT),
473 const_iv (KMOD_META)
474# undef const_iv 488# undef const_iv
475 }; 489 };
476 490
477 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 491 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
478 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 492 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
493
494 assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK);
495 assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE);
479} 496}
497
498void
499weaken (SV *rv)
500 PROTOTYPE: $
501 CODE:
502 sv_rvweaken (rv);
480 503
481int 504int
482in_destruct () 505in_destruct ()
483 CODE: 506 CODE:
484 RETVAL = PL_main_cv == Nullcv; 507 RETVAL = PL_main_cv == Nullcv;
587 case SDL_KEYDOWN: 610 case SDL_KEYDOWN:
588 case SDL_KEYUP: 611 case SDL_KEYUP:
589 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 612 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
590 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 613 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
591 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); 614 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0);
615 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */
592 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 616 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
593 break; 617 break;
594 618
595 case SDL_ACTIVEEVENT: 619 case SDL_ACTIVEEVENT:
596 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 620 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
1094 XSRETURN_EMPTY; 1118 XSRETURN_EMPTY;
1095 1119
1096 if (!(lp = pango_layout_get_line (self->pl, line))) 1120 if (!(lp = pango_layout_get_line (self->pl, line)))
1097 XSRETURN_EMPTY; /* do better */ 1121 XSRETURN_EMPTY; /* do better */
1098 1122
1099 if (!pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing)) 1123 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing);
1100 XSRETURN_EMPTY; /* do better */
1101 1124
1102 EXTEND (SP, 2); 1125 EXTEND (SP, 2);
1103 if (GIMME_V == G_SCALAR) 1126 if (GIMME_V == G_SCALAR)
1104 PUSHs (sv_2mortal (newSViv (index + trailing))); 1127 PUSHs (sv_2mortal (newSViv (index + trailing)));
1105 else 1128 else
1389 cell->stat_width = 1; 1412 cell->stat_width = 1;
1390 cell->stat_hp = *data++; 1413 cell->stat_hp = *data++;
1391 } 1414 }
1392 else if (cmd == 6) // monster width 1415 else if (cmd == 6) // monster width
1393 cell->stat_width = *data++ + 1; 1416 cell->stat_width = *data++ + 1;
1394 else if (cmd == 0x47) // monster width 1417 else if (cmd == 0x47)
1395 { 1418 {
1396 if (*data == 4) 1419 if (*data == 8)
1397 ; // decode player tag 1420 ; // decode player uuid
1398 1421
1399 data += *data + 1; 1422 data += *data + 1;
1400 } 1423 }
1401 else if (cmd == 8) // cell flags 1424 else if (cmd == 8) // cell flags
1402 cell->flags = *data++; 1425 cell->flags = *data++;
1463 1486
1464 for (z = 0; z <= 0; z++) 1487 for (z = 0; z <= 0; z++)
1465 { 1488 {
1466 mapface face = cell->face [z]; 1489 mapface face = cell->face [z];
1467 1490
1468 if (face) 1491 if (face > 0 && face < self->texs)
1469 { 1492 {
1470 maptex tex = self->tex [face]; 1493 maptex tex = self->tex [face];
1471 int a0 = 255 - tex.a; 1494 int a0 = 255 - tex.a;
1472 int a1 = tex.a; 1495 int a1 = tex.a;
1473 1496
1490} 1513}
1491 OUTPUT: 1514 OUTPUT:
1492 RETVAL 1515 RETVAL
1493 1516
1494void 1517void
1495draw (CFPlus::Map self, int mx, int my, int sw, int sh) 1518draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T)
1496 CODE: 1519 CODE:
1497{ 1520{
1498 int x, y, z; 1521 int x, y, z;
1499 int last_name; 1522 int last_name;
1500 mapface face; 1523 mapface face;
1524 { 1547 {
1525 mapcell *cell = row->col + (x + mx - row->c0); 1548 mapcell *cell = row->col + (x + mx - row->c0);
1526 1549
1527 face = cell->face [z]; 1550 face = cell->face [z];
1528 1551
1529 if (face && face < self->texs) 1552 if (face > 0 && face < self->texs)
1530 { 1553 {
1531 maptex tex = self->tex [face]; 1554 maptex tex = self->tex [face];
1532 int px = (x + 1) * 32 - tex.w; 1555 int px = (x + 1) * T - tex.w;
1533 int py = (y + 1) * 32 - tex.h; 1556 int py = (y + 1) * T - tex.h;
1534 1557
1535 if (last_name != tex.name) 1558 if (last_name != tex.name)
1536 { 1559 {
1537 glEnd (); 1560 glEnd ();
1538 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1561 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1548 if (cell->flags && z == 2) 1571 if (cell->flags && z == 2)
1549 { 1572 {
1550 if (cell->flags & 1) 1573 if (cell->flags & 1)
1551 { 1574 {
1552 maptex tex = self->tex [1]; 1575 maptex tex = self->tex [1];
1553 int px = (x + 1) * 32 - tex.w + 2; 1576 int px = (x + 1) * T - tex.w + 2;
1554 int py = (y + 1) * 32 - tex.h - 6; 1577 int py = (y + 1) * T - tex.h - 6;
1555 1578
1556 glEnd (); 1579 glEnd ();
1557 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1580 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1558 glBegin (GL_QUADS); 1581 glBegin (GL_QUADS);
1559 1582
1580 for (x = 0; x < sw; x++) 1603 for (x = 0; x < sw; x++)
1581 if (row->c0 <= x + mx && x + mx < row->c1) 1604 if (row->c0 <= x + mx && x + mx < row->c1)
1582 { 1605 {
1583 mapcell *cell = row->col + (x + mx - row->c0); 1606 mapcell *cell = row->col + (x + mx - row->c0);
1584 1607
1585 int px = x * 32; 1608 int px = x * T;
1586 int py = y * 32; 1609 int py = y * T;
1587 1610
1588 if (cell->stat_hp) 1611 if (cell->stat_hp)
1589 { 1612 {
1590 int width = cell->stat_width * 32; 1613 int width = cell->stat_width * T;
1591 int thick = sh / 28 + 1 + cell->stat_width; 1614 int thick = (sh * T / 32) / 28 + 1 + cell->stat_width;
1592 1615
1593 glColor3ub (0, 0, 0); 1616 glColor3ub (0, 0, 0);
1594 glRectf (px + 1, py - thick - 2, 1617 glRectf (px + 1, py - thick - 2,
1595 px + width - 1, py); 1618 px + width - 1, py);
1596 1619

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines