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.306 by root, Thu Oct 14 00:02:39 2010 UTC vs.
Revision 1.316 by root, Sun Nov 4 02:13:53 2012 UTC

577 577
578 return mod; 578 return mod;
579} 579}
580 580
581static void 581static void
582deliantra_main () 582deliantra_main (SV *real_main)
583{ 583{
584 char *argv[] = { 0 }; 584 dSP;
585 call_argv ("::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 share dlibrary 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
619MODULE = Deliantra::Client PACKAGE = DC 625MODULE = Deliantra::Client PACKAGE = DC
620 626
821 827
822 const_iv (FOW_DARKNESS) 828 const_iv (FOW_DARKNESS)
823# undef const_iv 829# undef const_iv
824 }; 830 };
825 831
826 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 832 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
827 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 833 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
828 834
829 assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); 835 assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK);
830 assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); 836 assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE);
831} 837}
832 838
871#endif 877#endif
872} 878}
873 879
874char *SDL_GetError () 880char *SDL_GetError ()
875 881
876void SDL_braino () 882void SDL_main_hack (SV *real_main)
883 PROTOTYPE: &
877 884
878int SDL_Init (U32 flags) 885int SDL_Init (U32 flags)
879 886
880int SDL_InitSubSystem (U32 flags) 887int SDL_InitSubSystem (U32 flags)
881 888
950 ); 957 );
951 958
952 if (RETVAL) 959 if (RETVAL)
953 { 960 {
954 av_clear (texture_av); 961 av_clear (texture_av);
955
956 SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra");
957#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); 962#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name);
958#include "glfunc.h" 963#include "glfunc.h"
959#undef GL_FUNC 964#undef GL_FUNC
960
961 if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; 965 if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB;
962 if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; 966 if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB;
963 } 967 }
964} 968}
965 OUTPUT: 969 OUTPUT:
966 RETVAL 970 RETVAL
967 971
968void 972void
973SDL_WM_SetCaption (const char *title, const char *icon)
974
975void
969SDL_GL_SwapBuffers () 976SDL_GL_SwapBuffers ()
970 977
971char * 978char *
972SDL_GetKeyName (int sym) 979SDL_GetKeyName (int sym)
973 980
975SDL_GetAppState () 982SDL_GetAppState ()
976 983
977int 984int
978SDL_GetModState () 985SDL_GetModState ()
979 986
987int
988SDL_WaitEvent ()
989 C_ARGS: 0
990
980void 991void
992SDL_PumpEvents ()
993
994void
981poll_events () 995peep_events ()
982 PPCODE: 996 PPCODE:
983{ 997{
984 SDL_Event ev; 998 SDL_Event ev;
985 999
986 SDL_PumpEvents (); 1000 SDL_PumpEvents ();
1139 OUTPUT: 1153 OUTPUT:
1140 RETVAL 1154 RETVAL
1141 1155
1142void 1156void
1143IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) 1157IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG)
1158
1159# MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s
1160void
1161Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG)
1144 1162
1145void 1163void
1146load_image_inline (SV *image_) 1164load_image_inline (SV *image_)
1147 ALIAS: 1165 ALIAS:
1148 load_image_file = 1 1166 load_image_file = 1
2014 self->y += MAP_EXTEND_Y; 2032 self->y += MAP_EXTEND_Y;
2015 } 2033 }
2016} 2034}
2017 2035
2018SV * 2036SV *
2019map1a_update (DC::Map self, SV *data_, int extmap) 2037map1a_update (DC::Map self, SV *data_)
2020 CODE: 2038 CODE:
2021{ 2039{
2022 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 2040 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
2023 uint8_t *data_end = (uint8_t *)SvEND (data_); 2041 uint8_t *data_end = (uint8_t *)SvEND (data_);
2024 mapcell *cell; 2042 mapcell *cell;
2045 2063
2046 //TODO: don't trust server data to be in-range(!) 2064 //TODO: don't trust server data to be in-range(!)
2047 2065
2048 if (flags & 8) 2066 if (flags & 8)
2049 { 2067 {
2068 uint8_t ext, cmd;
2069
2050 if (extmap) 2070 do
2051 { 2071 {
2052 uint8_t ext, cmd; 2072 ext = *data++;
2073 cmd = ext & 0x7f;
2053 2074
2054 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
2055 { 2078 {
2056 ext = *data++;
2057 cmd = ext & 0x7f;
2058
2059 if (cmd < 4)
2060 cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */
2061 else if (cmd == 5) // health
2062 {
2063 cell->stat_width = 1; 2079 cell->stat_width = 1;
2064 cell->stat_hp = *data++; 2080 cell->stat_hp = *data++;
2065 }
2066 else if (cmd == 6) // monster width
2067 cell->stat_width = *data++ + 1;
2068 else if (cmd == 0x47)
2069 {
2070 if (*data == 1) cell->player = data [1];
2071 else if (*data == 2) cell->player = data [2] + (data [1] << 8);
2072 else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16);
2073 else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24);
2074
2075 data += *data + 1;
2076 }
2077 else if (cmd == 8) // cell flags
2078 cell->flags = *data++;
2079 else if (ext & 0x40) // unknown, multibyte => skip
2080 data += *data + 1;
2081 else
2082 data++;
2083 } 2081 }
2084 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++;
2085 } 2099 }
2086 else 2100 while (ext & 0x80);
2087 cell->darkness = *data++ + 1;
2088 } 2101 }
2089 2102
2090 for (z = 0; z <= 2; ++z) 2103 for (z = 0; z <= 2; ++z)
2091 if (flags & (4 >> z)) 2104 if (flags & (4 >> z))
2092 { 2105 {
2566 int x, y; 2579 int x, y;
2567 int sw1 = sw + 2; 2580 int sw1 = sw + 2;
2568 int sh1 = sh + 2; 2581 int sh1 = sh + 2;
2569 int sh3 = sh * 3; 2582 int sh3 = sh * 3;
2570 int sw3 = sw * 3; 2583 int sw3 = sw * 3;
2571 uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1);
2572 SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); 2584 SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3));
2573 uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); 2585 uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv);
2586 uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1);
2587 memset (darkness1, 0, sw1*sh1);
2574 2588
2575 SvPOK_only (darkness3_sv); 2589 SvPOK_only (darkness3_sv);
2576 SvCUR_set (darkness3_sv, sw3 * sh3); 2590 SvCUR_set (darkness3_sv, sw3 * sh3);
2577 2591
2578 mx += self->x - 1; 2592 mx += self->x - 1;
3157 const_iv (GL_FUNC_SUBTRACT), 3171 const_iv (GL_FUNC_SUBTRACT),
3158 const_iv (GL_FUNC_REVERSE_SUBTRACT), 3172 const_iv (GL_FUNC_REVERSE_SUBTRACT),
3159# undef const_iv 3173# undef const_iv
3160 }; 3174 };
3161 3175
3162 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 3176 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
3163 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 3177 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
3164 3178
3165 texture_av = newAV (); 3179 texture_av = newAV ();
3166 AvREAL_off (texture_av); 3180 AvREAL_off (texture_av);
3167} 3181}
3168 3182

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines