… | |
… | |
48 | #endif |
48 | #endif |
49 | |
49 | |
50 | #define PANGO_ENABLE_BACKEND |
50 | #define PANGO_ENABLE_BACKEND |
51 | #define G_DISABLE_CAST_CHECKS |
51 | #define G_DISABLE_CAST_CHECKS |
52 | |
52 | |
53 | #include <glib/gmacros.h> |
53 | #include <glib.h> |
54 | |
54 | |
55 | #include <pango/pango.h> |
55 | #include <pango/pango.h> |
56 | |
56 | |
57 | #ifndef PANGO_VERSION_CHECK |
57 | #ifndef PANGO_VERSION_CHECK |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
… | |
… | |
577 | |
577 | |
578 | return mod; |
578 | return mod; |
579 | } |
579 | } |
580 | |
580 | |
581 | static void |
581 | static void |
582 | deliantra_main () |
582 | deliantra_main (SV *real_main) |
583 | { |
583 | { |
584 | char *argv[] = { 0 }; |
584 | dSP; |
585 | call_argv ("DC::Main::main", G_DISCARD | G_VOID, argv); |
585 | |
|
|
586 | PUSHMARK (SP); |
|
|
587 | call_sv (real_main, G_DISCARD | G_VOID); |
586 | } |
588 | } |
587 | |
589 | |
588 | #ifdef __MACOSX__ |
590 | #ifdef __MACOSX__ |
|
|
591 | static SV *real_main; |
|
|
592 | |
589 | /* to due surprising braindamage on the side of SDL design, we |
593 | /* to due surprising braindamage on the side of SDL design, we |
590 | * do some mind-boggling hack here: SDL requires a custom main() |
594 | * do some mind-boggling hack here: SDL requires a custom main() |
591 | * on OS X, so... we provide one and call the original main(), which, |
595 | * on OS X, so... we provide one and call the original main(), which, |
592 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
596 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
593 | * and which calls our main (== SDL_main) back. |
597 | * and which calls our main (== SDL_main) back. |
594 | */ |
598 | */ |
595 | extern C_LINKAGE int |
599 | extern C_LINKAGE int |
596 | main (int argc, char *argv[]) |
600 | main (int argc, char *argv[]) |
597 | { |
601 | { |
598 | deliantra_main (); |
602 | deliantra_main (real_main); |
599 | } |
603 | } |
600 | |
604 | |
601 | #undef main |
605 | #undef main |
602 | |
606 | |
603 | extern C_LINKAGE int main (int argc, char *argv[]); |
607 | extern C_LINKAGE int main (int argc, char *argv[]); |
604 | |
608 | |
605 | static void |
609 | static void |
606 | SDL_braino (void) |
610 | SDL_main_hack (SV *real_main_) |
607 | { |
611 | { |
|
|
612 | real_main = real_main_; |
|
|
613 | |
608 | char *argv[] = { "deliantra client", 0 }; |
614 | char *argv[] = { "deliantra client", 0 }; |
609 | (main) (1, argv); |
615 | (main) (1, argv); |
610 | } |
616 | } |
611 | #else |
617 | #else |
612 | static void |
618 | static void |
613 | SDL_braino (void) |
619 | SDL_main_hack (SV *real_main) |
614 | { |
620 | { |
615 | deliantra_main (); |
621 | deliantra_main (real_main); |
616 | } |
622 | } |
617 | #endif |
623 | #endif |
618 | |
624 | |
619 | MODULE = Deliantra::Client PACKAGE = DC |
625 | MODULE = Deliantra::Client PACKAGE = DC |
620 | |
626 | |
… | |
… | |
871 | #endif |
877 | #endif |
872 | } |
878 | } |
873 | |
879 | |
874 | char *SDL_GetError () |
880 | char *SDL_GetError () |
875 | |
881 | |
876 | void SDL_braino () |
882 | void SDL_main_hack (SV *real_main) |
|
|
883 | PROTOTYPE: & |
877 | |
884 | |
878 | int SDL_Init (U32 flags) |
885 | int SDL_Init (U32 flags) |
879 | |
886 | |
880 | int SDL_InitSubSystem (U32 flags) |
887 | int SDL_InitSubSystem (U32 flags) |
881 | |
888 | |
… | |
… | |
1485 | |
1492 | |
1486 | void |
1493 | void |
1487 | set_height (DC::Layout self, int base_height) |
1494 | set_height (DC::Layout self, int base_height) |
1488 | CODE: |
1495 | CODE: |
1489 | if (self->base_height != base_height) |
1496 | if (self->base_height != base_height) |
1490 | { |
1497 | { |
1491 | self->base_height = base_height; |
1498 | self->base_height = base_height; |
1492 | layout_update_font (self); |
1499 | layout_update_font (self); |
1493 | } |
1500 | } |
1494 | |
1501 | |
1495 | void |
1502 | void |
… | |
… | |
2025 | self->y += MAP_EXTEND_Y; |
2032 | self->y += MAP_EXTEND_Y; |
2026 | } |
2033 | } |
2027 | } |
2034 | } |
2028 | |
2035 | |
2029 | SV * |
2036 | SV * |
2030 | map1a_update (DC::Map self, SV *data_, int extmap) |
2037 | map1a_update (DC::Map self, SV *data_) |
2031 | CODE: |
2038 | CODE: |
2032 | { |
2039 | { |
2033 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2040 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2034 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2041 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2035 | mapcell *cell; |
2042 | mapcell *cell; |
… | |
… | |
2056 | |
2063 | |
2057 | //TODO: don't trust server data to be in-range(!) |
2064 | //TODO: don't trust server data to be in-range(!) |
2058 | |
2065 | |
2059 | if (flags & 8) |
2066 | if (flags & 8) |
2060 | { |
2067 | { |
|
|
2068 | uint8_t ext, cmd; |
|
|
2069 | |
2061 | if (extmap) |
2070 | do |
2062 | { |
2071 | { |
2063 | uint8_t ext, cmd; |
2072 | ext = *data++; |
|
|
2073 | cmd = ext & 0x7f; |
2064 | |
2074 | |
2065 | do |
2075 | if (cmd < 4) |
|
|
2076 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2077 | else if (cmd == 5) // health |
2066 | { |
2078 | { |
2067 | ext = *data++; |
|
|
2068 | cmd = ext & 0x7f; |
|
|
2069 | |
|
|
2070 | if (cmd < 4) |
|
|
2071 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2072 | else if (cmd == 5) // health |
|
|
2073 | { |
|
|
2074 | cell->stat_width = 1; |
2079 | cell->stat_width = 1; |
2075 | cell->stat_hp = *data++; |
2080 | cell->stat_hp = *data++; |
2076 | } |
|
|
2077 | else if (cmd == 6) // monster width |
|
|
2078 | cell->stat_width = *data++ + 1; |
|
|
2079 | else if (cmd == 0x47) |
|
|
2080 | { |
|
|
2081 | if (*data == 1) cell->player = data [1]; |
|
|
2082 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2083 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2084 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2085 | |
|
|
2086 | data += *data + 1; |
|
|
2087 | } |
|
|
2088 | else if (cmd == 8) // cell flags |
|
|
2089 | cell->flags = *data++; |
|
|
2090 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2091 | data += *data + 1; |
|
|
2092 | else |
|
|
2093 | data++; |
|
|
2094 | } |
2081 | } |
2095 | while (ext & 0x80); |
2082 | else if (cmd == 6) // monster width |
|
|
2083 | cell->stat_width = *data++ + 1; |
|
|
2084 | else if (cmd == 0x47) |
|
|
2085 | { |
|
|
2086 | if (*data == 1) cell->player = data [1]; |
|
|
2087 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2088 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2089 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2090 | |
|
|
2091 | data += *data + 1; |
|
|
2092 | } |
|
|
2093 | else if (cmd == 8) // cell flags |
|
|
2094 | cell->flags = *data++; |
|
|
2095 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2096 | data += *data + 1; |
|
|
2097 | else |
|
|
2098 | data++; |
2096 | } |
2099 | } |
2097 | else |
2100 | while (ext & 0x80); |
2098 | cell->darkness = *data++ + 1; |
|
|
2099 | } |
2101 | } |
2100 | |
2102 | |
2101 | for (z = 0; z <= 2; ++z) |
2103 | for (z = 0; z <= 2; ++z) |
2102 | if (flags & (4 >> z)) |
2104 | if (flags & (4 >> z)) |
2103 | { |
2105 | { |