X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Finit.c;h=fe585257360fc68d0dc3785be8dbf0f4761013b4;hb=335f4db8f7a8bea9b06eeea911b6d1e1d4de4623;hp=ec0a1c74a26369bf9e7361bc3b3c063552ce73a8;hpb=d0893e6987c21c25ec137438a18cfe1288362139;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index ec0a1c74..fe585257 100644 --- a/src/init.c +++ b/src/init.c @@ -1,456 +1,1542 @@ /*********************************************************** -* 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-2001 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 "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 "tape.h" +#include "tools.h" +#include "files.h" +#include "network.h" +#include "netserv.h" +#include "cartoons.h" +#include "config.h" -#include +static char *image_filename[NUM_PICTURES] = +{ + "RocksScreen.pcx", + "RocksDoor.pcx", + "RocksHeroes.pcx", + "RocksToons.pcx", + "RocksSP.pcx", + "RocksDC.pcx", + "RocksMore.pcx", + "RocksFont.pcx", + "RocksFont2.pcx", + "RocksFont3.pcx" +}; -int sound_process_id=0; +static void InitSetup(void); +static void InitPlayerInfo(void); +static void InitLevelInfo(void); +static void InitArtworkInfo(void); +static void InitNetworkServer(void); +static void InitSound(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, getWindowTitleString(), + ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME, + MSDOS_POINTER_FILENAME, + COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL); + + InitSetup(); + InitPlayerInfo(); InitCounter(); InitSound(); - InitSoundProcess(); - InitJoystick(); + InitJoysticks(); InitRND(NEW_RANDOMIZE); - signal(SIGINT, CloseAll); - signal(SIGTERM, CloseAll); + InitVideoDisplay(); + InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, + setup.fullscreen); - InitDisplay(argc, argv); - InitWindow(argc, argv); + InitEventFilter(FilterMouseMotionEvents); + + InitArtworkInfo(); InitGfx(); + InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ + + InitLevelInfo(); + InitGadgets(); /* needs to know number of level series */ + + InitGfxBackground(); + InitToons(); DrawMainMenu(); - XMapWindow(display, window); - XFlush(display); + InitNetworkServer(); } -void InitSound() +void InitSetup() +{ + LoadSetup(); /* global setup info */ +} + +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) - { - fprintf(stderr,"%s: cannot access sound device - no sounds\n",progname); - sound_status=SOUND_OFF; - return; - } + for (i=0; iconnected = TRUE; +} + +void InitLevelInfo() +{ + LoadLevelInfo(); /* global level info */ + LoadLevelSetup_LastSeries(); /* last played series info */ + LoadLevelSetup_SeriesInfo(); /* last played level info */ +} + +void InitArtworkInfo() +{ + LoadArtworkInfo(); +} + +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); -#ifdef VOXWARE - sound_loops_allowed = TRUE; - sound_loops_on = TRUE; + if (!ConnectToServer(options.server_host, options.server_port)) + Error(ERR_EXIT, "cannot connect to network game server"); + + SendToServer_PlayerName(setup.player_name); + SendToServer_ProtocolVersion(); + + if (nr_wanted) + SendToServer_NrWanted(nr_wanted); #endif +} - for(i=0;iclip_mask, + clip_gc_valuemask, &clip_gc_values); - if (access(joystick_device_name[joystick_nr],R_OK)<0) + 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.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); + } } - if ((joystick_device=open(joystick_device_name[joystick_nr],O_RDONLY))<0) +#if defined(TARGET_X11_NATIVE) + /* create only those clipping Pixmaps we really need */ + for(i=0; tile_needs_clipping[i].start>=0; i++) { - fprintf(stderr,"%s: cannot open joystick device '%s'\n", - joystick_device_name[joystick_nr],progname); - joystick_status = JOYSTICK_OFF; - return; - } + int j; - joystick_status = JOYSTICK_AVAILABLE; - LoadJoystickData(); + for(j=0; jclip_mask; + + tile_clipmask[tile] = XCreatePixmap(display, window->drawable, + TILEX, TILEY, 1); + + XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc, + src_x, src_y, TILEX, TILEY, 0, 0); + } + } +#endif /* TARGET_X11_NATIVE */ +#endif /* TARGET_X11 */ } -void InitDisplay(int argc, char *argv[]) +void InitGfx() { - char *display_name = NULL; int i; - /* get X server to connect to, if given as an argument */ - for (i=1;i