X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=36eb3217283048a8d4bfdc10a159057fb27fff2a;hb=d2098db6b7b0cee3b43e341c012beec5bc6ef6bd;hp=ec0a1c74a26369bf9e7361bc3b3c063552ce73a8;hpb=d0893e6987c21c25ec137438a18cfe1288362139;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index ec0a1c74..304b1037 100644 --- a/src/init.c +++ b/src/init.c @@ -1,456 +1,1689 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* ©1995 Artsoft Development * -* Holger Schemel * -* 33659 Bielefeld-Senne * -* Telefon: (0521) 493245 * -* eMail: aeglos@valinor.owl.de * -* aeglos@uni-paderborn.de * -* q99492@pbhrzx.uni-paderborn.de * +* (c) 1995-2000 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* init.c * -* * -* Letzte Aenderung: 15.06.1995 * +* init.c * ***********************************************************/ +#include + +#include "libgame/libgame.h" + #include "init.h" -#include "images.h" -#include "sound.h" +#include "events.h" #include "screens.h" -#include "tools.h" +#include "editor.h" #include "game.h" -#include "misc.h" - -#include +#include "tape.h" +#include "tools.h" +#include "files.h" +#include "joystick.h" +#include "network.h" +#include "netserv.h" -int sound_process_id=0; +static void InitPlayerInfo(void); +static void InitLevelInfo(void); +static void InitNetworkServer(void); +static void InitSound(void); +static void InitSoundServer(void); +static void InitGfx(void); +static void InitGfxBackground(void); +static void InitGadgets(void); +static void InitElementProperties(void); -void OpenAll(int argc, char *argv[]) +void OpenAll(void) { - LoadLevelInfo(); - LoadPlayerInfo(PLAYER_SETUP); - LoadPlayerInfo(PLAYER_LEVEL); + if (options.serveronly) + { +#if defined(PLATFORM_UNIX) + NetworkServer(options.server_port, options.serveronly); +#else + Error(ERR_WARN, "networking only supported in Unix version"); +#endif + exit(0); /* never reached */ + } + + InitProgramInfo(UNIX_USERDATA_DIRECTORY, + PROGRAM_TITLE_STRING, WINDOW_TITLE_STRING, + ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, + MSDOS_POINTER_FILENAME); + + InitPlayerInfo(); InitCounter(); InitSound(); - InitSoundProcess(); - InitJoystick(); + InitSoundServer(); + InitJoysticks(); InitRND(NEW_RANDOMIZE); - signal(SIGINT, CloseAll); - signal(SIGTERM, CloseAll); + InitVideoDisplay(); + InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, + setup.fullscreen); + + InitEventFilter(FilterMouseMotionEvents); - InitDisplay(argc, argv); - InitWindow(argc, argv); InitGfx(); + InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ + + InitLevelInfo(); + InitGadgets(); /* needs to know number of level series */ + InitGfxBackground(); DrawMainMenu(); - XMapWindow(display, window); - XFlush(display); + InitNetworkServer(); } -void InitSound() +void InitPlayerInfo() { int i; - if (sound_status==SOUND_OFF) - return; + /* choose default local player */ + local_player = &stored_player[0]; - if (access(sound_device_name,W_OK)<0) + for (i=0; iconnected = TRUE; + + LoadSetup(); /* global setup info */ +} + +void InitLevelInfo() +{ + LoadLevelInfo(); /* global level info */ + LoadLevelSetup_LastSeries(); /* last played series info */ + LoadLevelSetup_SeriesInfo(); /* last played level info */ +} + +void InitNetworkServer() +{ +#if defined(PLATFORM_UNIX) + int nr_wanted; +#endif + + if (!options.network) return; - } - close(sound_device); - sound_status=SOUND_AVAILABLE; +#if defined(PLATFORM_UNIX) + nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); + + if (!ConnectToServer(options.server_host, options.server_port)) + Error(ERR_EXIT, "cannot connect to network game server"); -#ifdef VOXWARE - sound_loops_allowed = TRUE; - sound_loops_on = TRUE; + SendToServer_PlayerName(setup.player_name); + SendToServer_ProtocolVersion(); + + if (nr_wanted) + SendToServer_NrWanted(nr_wanted); #endif +} - for(i=0;i= SDL_NumJoysticks()) + joystick_nr = -1; -void InitDisplay(int argc, char *argv[]) -{ - char *display_name = NULL; - int i; + /* misuse joystick file descriptor variable to store joystick number */ + stored_player[i].joystick_fd = joystick_nr; - /* get X server to connect to, if given as an argument */ - for (i=1;i= num_joysticks) + joystick_nr = -1; + + /* misuse joystick file descriptor variable to store joystick number */ + stored_player[i].joystick_fd = joystick_nr; } +#endif - wm_hints.initial_state = NormalState; - wm_hints.input = True; - wm_hints.icon_pixmap = icon_pixmap; - wm_hints.icon_mask = iconmask_pixmap; - wm_hints.flags = StateHint | IconPixmapHint | IconMaskHint | InputHint; - - class_hints.res_name = progname; - class_hints.res_class = "Rocks'n'Diamonds"; - - XSetWMProperties(display, window, &windowName, &iconName, - argv, argc, &size_hints, &wm_hints, - &class_hints); - - XFree(windowName.value); - XFree(iconName.value); - - /* Select event types wanted */ - window_event_mask = ExposureMask | StructureNotifyMask | FocusChangeMask | - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | - KeyPressMask | KeyReleaseMask; - XSelectInput(display, window, window_event_mask); - - /* create GC for drawing with window depth */ - gc_values.graphics_exposures = False; - gc_values.foreground = pen_bg; - gc_values.background = pen_bg; - gc_valuemask = GCGraphicsExposures | GCForeground | GCBackground; - gc = XCreateGC(display, window, gc_valuemask, &gc_values); +#endif /* !TARGET_SDL */ } void InitGfx() { - int i,j,x,y; - int xpm_err, xbm_err; - unsigned int width,height; - int hot_x,hot_y; - XGCValues gc_values; - unsigned long gc_valuemask; + int i; + +#if defined(TARGET_X11) + GC copy_clipmask_gc; XGCValues clip_gc_values; unsigned long clip_gc_valuemask; - char filename[256]; - Pixmap shapemask; +#endif - for(i=0;iclip_mask, + clip_gc_valuemask, &clip_gc_values); - for(y=0;y<=SCR_FIELDY;y++) for(x=0;x<=SCR_FIELDX;x++) - XCopyArea(display,clipmask[PIX_BACK],clipmask[PIX_FADEMASK],plane_gc, - SX+2*TILEX,SY+10*TILEY,TILEX,TILEY,x*TILEX,y*TILEY); + clip_gc_values.graphics_exposures = False; + clip_gc_valuemask = GCGraphicsExposures; + tile_clip_gc = + XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values); - for(i=0;iclip_mask) { clip_gc_values.graphics_exposures = False; - clip_gc_values.foreground = pen_fg; - clip_gc_values.background = pen_bg; - clip_gc_values.clip_mask = clipmask[i]; - clip_gc_valuemask = - GCGraphicsExposures | GCForeground | GCBackground | GCClipMask; - clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values); + clip_gc_values.clip_mask = pix[i]->clip_mask; + clip_gc_valuemask = GCGraphicsExposures | GCClipMask; + pix[i]->stored_clip_gc = XCreateGC(display, window->drawable, + clip_gc_valuemask,&clip_gc_values); } } - drawto = drawto_field = backbuffer = pix[PIX_DB_BACK]; + /* initialize pixmap array to Pixmap 'None' */ + for(i=0; i=0; i++) + { + int j; + + for(j=0; jclip_mask; - XCopyArea(display,pix[PIX_BACK],backbuffer,gc, - 0,0, WIN_XSIZE,WIN_YSIZE, 0,0); - XFillRectangle(display,backbuffer,gc, - REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); + tile_clipmask[tile] = XCreatePixmap(display, window->drawable, + TILEX, TILEY, 1); - for(i=0;i