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) |
|
|
8 | # pragma warning(disable:4761) |
7 | #endif |
9 | #endif |
8 | |
10 | |
9 | #include "EXTERN.h" |
11 | #include "EXTERN.h" |
10 | #include "perl.h" |
12 | #include "perl.h" |
11 | #include "XSUB.h" |
13 | #include "XSUB.h" |
… | |
… | |
36 | # include <sys/types.h> |
38 | # include <sys/types.h> |
37 | # include <sys/socket.h> |
39 | # include <sys/socket.h> |
38 | # include <netinet/in.h> |
40 | # include <netinet/in.h> |
39 | # include <netinet/tcp.h> |
41 | # include <netinet/tcp.h> |
40 | # include <inttypes.h> |
42 | # include <inttypes.h> |
41 | #else |
|
|
42 | typedef unsigned char uint8_t; |
|
|
43 | typedef unsigned short uint16_t; |
|
|
44 | typedef unsigned int uint32_t; |
|
|
45 | typedef signed char int8_t; |
|
|
46 | typedef signed short int16_t; |
|
|
47 | typedef signed int int32_t; |
|
|
48 | #endif |
43 | #endif |
49 | |
44 | |
50 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ |
45 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
51 | |
46 | |
52 | #define FOW_DARKNESS 32 |
47 | #define FOW_DARKNESS 32 |
53 | |
48 | |
54 | #define MAP_EXTEND_X 32 |
49 | #define MAP_EXTEND_X 32 |
55 | #define MAP_EXTEND_Y 512 |
50 | #define MAP_EXTEND_Y 512 |
… | |
… | |
315 | |
310 | |
316 | cell = row->col + x - row->c0; |
311 | cell = row->col + x - row->c0; |
317 | |
312 | |
318 | cell->darkness = 0; |
313 | cell->darkness = 0; |
319 | cell->stat_hp = 0; |
314 | cell->stat_hp = 0; |
|
|
315 | cell->flags = 0; |
|
|
316 | cell->player = 0; |
320 | } |
317 | } |
321 | } |
318 | } |
322 | } |
319 | } |
323 | |
320 | |
324 | static void |
321 | static void |
… | |
… | |
649 | #ifndef _WIN32 |
646 | #ifndef _WIN32 |
650 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
647 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
651 | #endif |
648 | #endif |
652 | |
649 | |
653 | void |
650 | void |
|
|
651 | win32_proxy_info () |
|
|
652 | PPCODE: |
|
|
653 | { |
|
|
654 | #ifdef _WIN32 |
|
|
655 | char buffer[2048]; |
|
|
656 | DWORD buflen; |
|
|
657 | |
|
|
658 | EXTEND (SP, 3); |
|
|
659 | |
|
|
660 | buflen = sizeof (buffer); |
|
|
661 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY, (void *)buffer, &buflen)) |
|
|
662 | if (((INTERNET_PROXY_INFO *)buffer)->dwAccessType == INTERNET_OPEN_TYPE_PROXY) |
|
|
663 | { |
|
|
664 | PUSHs (newSVpv (((INTERNET_PROXY_INFO *)buffer)->lpszProxy, 0)); |
|
|
665 | |
|
|
666 | buflen = sizeof (buffer); |
|
|
667 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY_USERNAME, (void *)buffer, &buflen)) |
|
|
668 | { |
|
|
669 | PUSHs (newSVpv (buffer, 0)); |
|
|
670 | |
|
|
671 | buflen = sizeof (buffer); |
|
|
672 | if (InternetQueryOption (0, INTERNET_OPTION_PROXY_PASSWORD, (void *)buffer, &buflen)) |
|
|
673 | PUSHs (newSVpv (buffer, 0)); |
|
|
674 | } |
|
|
675 | } |
|
|
676 | #endif |
|
|
677 | } |
|
|
678 | |
|
|
679 | void |
654 | add_font (char *file) |
680 | add_font (char *file) |
655 | CODE: |
681 | CODE: |
656 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
682 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
657 | |
683 | |
658 | void |
684 | void |
… | |
… | |
760 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
786 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
761 | #endif |
787 | #endif |
762 | _exit (1); |
788 | _exit (1); |
763 | |
789 | |
764 | void |
790 | void |
765 | _exit (int retval) |
791 | _exit (int retval = 0) |
766 | CODE: |
792 | CODE: |
|
|
793 | #ifdef WIN32 |
|
|
794 | ExitThread (retval); // unclean, please beam me up |
|
|
795 | #else |
767 | _exit (retval); |
796 | _exit (retval); |
|
|
797 | #endif |
768 | |
798 | |
769 | MODULE = CFPlus PACKAGE = CFPlus::Font |
799 | MODULE = CFPlus PACKAGE = CFPlus::Font |
770 | |
800 | |
771 | CFPlus::Font |
801 | CFPlus::Font |
772 | new_from_file (SV *class, char *path, int id = 0) |
802 | new_from_file (SV *class, char *path, int id = 0) |
… | |
… | |
1244 | void |
1274 | void |
1245 | scroll (CFPlus::Map self, int dx, int dy) |
1275 | scroll (CFPlus::Map self, int dx, int dy) |
1246 | CODE: |
1276 | CODE: |
1247 | { |
1277 | { |
1248 | if (dx > 0) |
1278 | if (dx > 0) |
1249 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1279 | map_blank (self, self->x, self->y, dx, self->h); |
1250 | else if (dx < 0) |
1280 | else if (dx < 0) |
1251 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
1281 | map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); |
1252 | |
1282 | |
1253 | if (dy > 0) |
1283 | if (dy > 0) |
1254 | map_blank (self, self->x, self->y, self->w, dy - 1); |
1284 | map_blank (self, self->x, self->y, self->w, dy); |
1255 | else if (dy < 0) |
1285 | else if (dy < 0) |
1256 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
1286 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); |
1257 | |
1287 | |
1258 | self->ox += dx; self->x += dx; |
1288 | self->ox += dx; self->x += dx; |
1259 | self->oy += dy; self->y += dy; |
1289 | self->oy += dy; self->y += dy; |
1260 | |
1290 | |
1261 | while (self->y < 0) |
1291 | while (self->y < 0) |
… | |
… | |
1287 | |
1317 | |
1288 | if (flags & 15) |
1318 | if (flags & 15) |
1289 | { |
1319 | { |
1290 | if (!cell->darkness) |
1320 | if (!cell->darkness) |
1291 | { |
1321 | { |
|
|
1322 | memset (cell, 0, sizeof (*cell)); |
1292 | cell->darkness = 256; |
1323 | cell->darkness = 256; |
1293 | cell->face [0] = 0; |
|
|
1294 | cell->face [1] = 0; |
|
|
1295 | cell->face [2] = 0; |
|
|
1296 | } |
1324 | } |
1297 | |
1325 | |
1298 | //TODO: don't trust server data to be in-range(!) |
1326 | //TODO: don't trust server data to be in-range(!) |
1299 | |
1327 | |
1300 | if (flags & 8) |
1328 | if (flags & 8) |
… | |
… | |
1351 | { |
1379 | { |
1352 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1380 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1353 | } |
1381 | } |
1354 | } |
1382 | } |
1355 | else |
1383 | else |
1356 | { |
|
|
1357 | cell->darkness = 0; |
1384 | cell->darkness = 0; |
1358 | cell->stat_hp = 0; |
|
|
1359 | } |
|
|
1360 | } |
1385 | } |
1361 | } |
1386 | } |
1362 | |
1387 | |
1363 | SV * |
1388 | SV * |
1364 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1389 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |