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.152 by root, Sat Aug 19 18:18:36 2006 UTC vs.
Revision 1.157 by root, Sun Oct 1 14:48:50 2006 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 _WIN32_WINNT 0x0500 // 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# pragma warning(disable:4244) 7# pragma warning(disable:4244)
7#endif 8#endif
8 9
9#include "EXTERN.h" 10#include "EXTERN.h"
10#include "perl.h" 11#include "perl.h"
169 float s, t; 170 float s, t;
170 uint8_t r, g, b, a; 171 uint8_t r, g, b, a;
171} maptex; 172} maptex;
172 173
173typedef struct { 174typedef struct {
175 uint32_t player;
176 mapface face[3];
174 uint16_t darkness; 177 uint16_t darkness;
175 mapface face[3];
176 uint8_t stat_width, stat_hp; 178 uint8_t stat_width, stat_hp, flags;
177} mapcell; 179} mapcell;
178 180
179typedef struct { 181typedef struct {
180 int32_t c0, c1; 182 int32_t c0, c1;
181 mapcell *col; 183 mapcell *col;
314 316
315 cell = row->col + x - row->c0; 317 cell = row->col + x - row->c0;
316 318
317 cell->darkness = 0; 319 cell->darkness = 0;
318 cell->stat_hp = 0; 320 cell->stat_hp = 0;
321 cell->flags = 0;
322 cell->player = 0;
319 } 323 }
320 } 324 }
321} 325}
322 326
323static void 327static void
648#ifndef _WIN32 652#ifndef _WIN32
649 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); 653 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val));
650#endif 654#endif
651 655
652void 656void
657win32_proxy_info ()
658 PPCODE:
659{
660#ifdef _WIN32
661 INTERNET_PROXY_INFO proxyinfo;
662 char buffer[2048];
663 DWORD buflen;
664
665 EXTEND (SP, 3);
666
667 buflen = sizeof (buffer);
668 if (InternetQueryOption (0, INTERNET_OPTION_PROXY, (void *)buffer, &buflen))
669 if (((INTERNET_PROXY_INFO *)buffer)->dwAccessType == INTERNET_OPEN_TYPE_PROXY)
670 {
671 PUSHs (newSVpv (((INTERNET_PROXY_INFO *)buffer)->lpszProxy, 0));
672
673 buflen = sizeof (buffer);
674 if (InternetQueryOption (0, INTERNET_OPTION_PROXY_USERNAME, (void *)buffer, &buflen))
675 {
676 PUSHs (newSVpv (buffer, 0));
677
678 buflen = sizeof (buffer);
679 if (InternetQueryOption (0, INTERNET_OPTION_PROXY_PASSWORD, (void *)buffer, &buflen))
680 PUSHs (newSVpv (buffer, 0));
681 }
682 }
683#endif
684}
685
686void
653add_font (char *file) 687add_font (char *file)
654 CODE: 688 CODE:
655 FcConfigAppFontAddFile (0, (const FcChar8 *)file); 689 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
656 690
657void 691void
1243void 1277void
1244scroll (CFPlus::Map self, int dx, int dy) 1278scroll (CFPlus::Map self, int dx, int dy)
1245 CODE: 1279 CODE:
1246{ 1280{
1247 if (dx > 0) 1281 if (dx > 0)
1248 map_blank (self, self->x, self->y, dx - 1, self->h); 1282 map_blank (self, self->x, self->y, dx, self->h);
1249 else if (dx < 0) 1283 else if (dx < 0)
1250 map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); 1284 map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h);
1251 1285
1252 if (dy > 0) 1286 if (dy > 0)
1253 map_blank (self, self->x, self->y, self->w, dy - 1); 1287 map_blank (self, self->x, self->y, self->w, dy);
1254 else if (dy < 0) 1288 else if (dy < 0)
1255 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); 1289 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy);
1256 1290
1257 self->ox += dx; self->x += dx; 1291 self->ox += dx; self->x += dx;
1258 self->oy += dy; self->y += dy; 1292 self->oy += dy; self->y += dy;
1259 1293
1260 while (self->y < 0) 1294 while (self->y < 0)
1286 1320
1287 if (flags & 15) 1321 if (flags & 15)
1288 { 1322 {
1289 if (!cell->darkness) 1323 if (!cell->darkness)
1290 { 1324 {
1325 memset (cell, 0, sizeof (*cell));
1291 cell->darkness = 256; 1326 cell->darkness = 256;
1292 cell->face [0] = 0;
1293 cell->face [1] = 0;
1294 cell->face [2] = 0;
1295 } 1327 }
1296 1328
1297 //TODO: don't trust server data to be in-range(!) 1329 //TODO: don't trust server data to be in-range(!)
1298 1330
1299 if (flags & 8) 1331 if (flags & 8)
1314 cell->stat_width = 1; 1346 cell->stat_width = 1;
1315 cell->stat_hp = *data++; 1347 cell->stat_hp = *data++;
1316 } 1348 }
1317 else if (cmd == 6) // monster width 1349 else if (cmd == 6) // monster width
1318 cell->stat_width = *data++ + 1; 1350 cell->stat_width = *data++ + 1;
1351 else if (cmd == 0x47) // monster width
1352 {
1353 if (*data == 4)
1354 ; // decode player tag
1355
1356 data += *data + 1;
1357 }
1358 else if (cmd == 8) // cell flags
1359 cell->flags = *data++;
1319 else if (ext & 0x40) // unknown, multibyte => skip 1360 else if (ext & 0x40) // unknown, multibyte => skip
1320 data += *data + 1; 1361 data += *data + 1;
1321 else 1362 else
1322 data++; 1363 data++;
1323 } 1364 }
1341 { 1382 {
1342 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1383 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1343 } 1384 }
1344 } 1385 }
1345 else 1386 else
1346 {
1347 cell->darkness = 0; 1387 cell->darkness = 0;
1348 cell->stat_hp = 0;
1349 }
1350 } 1388 }
1351} 1389}
1352 1390
1353SV * 1391SV *
1354mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1392mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1457 face = cell->face [z]; 1495 face = cell->face [z];
1458 1496
1459 if (face && face < self->texs) 1497 if (face && face < self->texs)
1460 { 1498 {
1461 maptex tex = self->tex [face]; 1499 maptex tex = self->tex [face];
1462
1463 int px = (x + 1) * 32 - tex.w; 1500 int px = (x + 1) * 32 - tex.w;
1464 int py = (y + 1) * 32 - tex.h; 1501 int py = (y + 1) * 32 - tex.h;
1465 1502
1466 if (last_name != tex.name) 1503 if (last_name != tex.name)
1467 { 1504 {
1468 glEnd (); 1505 glEnd ();
1469 last_name = tex.name;
1470 glBindTexture (GL_TEXTURE_2D, last_name); 1506 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1471 glBegin (GL_QUADS); 1507 glBegin (GL_QUADS);
1472 } 1508 }
1473 1509
1474 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1510 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1475 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); 1511 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1476 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); 1512 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1477 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); 1513 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1514 }
1515
1516 if (cell->flags && z == 2)
1517 {
1518 if (cell->flags & 1)
1519 {
1520 maptex tex = self->tex [1];
1521 int px = (x + 1) * 32 - tex.w + 2;
1522 int py = (y + 1) * 32 - tex.h - 6;
1523
1524 glEnd ();
1525 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1526 glBegin (GL_QUADS);
1527
1528 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1529 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1530 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1531 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1532 }
1478 } 1533 }
1479 } 1534 }
1480 } 1535 }
1481 1536
1482 glEnd (); 1537 glEnd ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines