X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=0a0c7580c460bd184622b944a91fb6e14d09b052;hb=2fe0fbc2a34fd4b50081f1829931dea3ca2c4c1c;hp=7a6057a79ad948320c4057282fc244b1a1b6eaba;hpb=29014045f4de045f8452fdf7ab32622c94b37eef;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 7a6057a7..0a0c7580 100644 --- a/src/init.c +++ b/src/init.c @@ -44,11 +44,11 @@ struct IconFileInfo static int sound_process_id = 0; -static void InitServer(void); static void InitLevelAndPlayerInfo(void); +static void InitNetworkServer(void); static void InitDisplay(void); static void InitSound(void); -static void InitSoundProcess(void); +static void InitSoundServer(void); static void InitWindow(int, char **); static void InitGfx(void); static void LoadGfx(int, struct PictureFileInfo *); @@ -57,16 +57,15 @@ static void InitElementProperties(void); void OpenAll(int argc, char *argv[]) { InitLevelAndPlayerInfo(); - InitServer(); InitCounter(); InitSound(); - InitSoundProcess(); + InitSoundServer(); InitJoystick(); InitRND(NEW_RANDOMIZE); - signal(SIGINT, CloseAll); - signal(SIGTERM, CloseAll); + signal(SIGINT, CloseAllAndExit); + signal(SIGTERM, CloseAllAndExit); InitDisplay(); InitWindow(argc, argv); @@ -78,6 +77,8 @@ void OpenAll(int argc, char *argv[]) InitElementProperties(); DrawMainMenu(); + + InitNetworkServer(); } void InitLevelAndPlayerInfo() @@ -85,24 +86,31 @@ void InitLevelAndPlayerInfo() local_player = &stored_player[0]; if (!LoadLevelInfo()) /* global level info */ - CloseAll(); + Error(ERR_EXIT, NULL); LoadPlayerInfo(PLAYER_SETUP); /* global setup info */ LoadPlayerInfo(PLAYER_LEVEL); /* level specific info */ } -void InitServer() +void InitNetworkServer() { - standalone = FALSE + TRUE; + int nr_wanted; + + standalone = FALSE; if (standalone) return; + nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); + if (!ConnectToServer(server_host, server_port)) Error(ERR_EXIT, "cannot connect to multiplayer server"); - SendNicknameToServer(local_player->alias_name); - SendProtocolVersionToServer(); + SendToServer_Nickname(local_player->alias_name); + SendToServer_ProtocolVersion(); + + if (nr_wanted) + SendToServer_NrWanted(nr_wanted); } void InitSound() @@ -153,7 +161,7 @@ void InitSound() } } -void InitSoundProcess() +void InitSoundServer() { if (sound_status==SOUND_OFF) return; @@ -438,6 +446,7 @@ void InitGfx() { GFX_GEBLUBBER, 4 }, { GFX_DYNAMIT, 7 }, { GFX_DYNABOMB, 4 }, + { GFX_EXPLOSION, 8 }, { GFX_SOKOBAN_OBJEKT, 1 }, { GFX_FUNKELN_BLAU, 3 }, { GFX_FUNKELN_WEISS, 3 }, @@ -615,21 +624,13 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) switch(xpm_err) { case XpmOpenFailed: - fprintf(stderr,"Cannot open Xpm file '%s' !\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "cannot open XPM file '%s'", filename); case XpmFileInvalid: - fprintf(stderr,"Invalid Xpm file '%s'!\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "invalid XPM file '%s'", filename); case XpmNoMemory: - fprintf(stderr,"Not enough memory for Xpm file '%s'!\n",filename); - CloseAll(); - exit(1); + Error(ERR_EXIT, "not enough memory for XPM file '%s'", filename); case XpmColorFailed: - fprintf(stderr,"Can't get colors for Xpm file '%s'!\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "cannot get colors for XPM file '%s'", filename); default: break; } @@ -650,25 +651,15 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) case GIF_Success: break; case GIF_OpenFailed: - fprintf(stderr,"Cannot open GIF file '%s' !\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "cannot open GIF file '%s'", filename); case GIF_ReadFailed: - fprintf(stderr,"Cannot read GIF file '%s' !\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "cannot read GIF file '%s'", filename); case GIF_FileInvalid: - fprintf(stderr,"Invalid GIF file '%s'!\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "invalid GIF file '%s'", filename); case GIF_NoMemory: - fprintf(stderr,"Not enough memory for GIF file '%s'!\n",filename); - CloseAll(); - exit(1); + Error(ERR_EXIT, "not enough memory for GIF file '%s'", filename); case GIF_ColorFailed: - fprintf(stderr,"Can't get colors for GIF file '%s'!\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "cannot get colors for GIF file '%s'", filename); default: break; } @@ -707,19 +698,11 @@ void LoadGfx(int pos, struct PictureFileInfo *pic) case BitmapSuccess: break; case BitmapOpenFailed: - fprintf(stderr,"Bitmap file open failed on '%s' !\n",filename); - CloseAll(); - exit(-1); - break; + Error(ERR_EXIT, "cannot open XBM file '%s'", filename); case BitmapFileInvalid: - fprintf(stderr,"Bitmap file invalid: '%s' !\n",filename); - CloseAll(); - exit(-1); - break; + Error(ERR_EXIT, "invalid XBM file '%s'", filename); case BitmapNoMemory: - fprintf(stderr,"No memory for file '%s' !\n",filename); - CloseAll(); - exit(-1); + Error(ERR_EXIT, "not enough memory for XBM file '%s'", filename); break; default: break; @@ -788,6 +771,9 @@ void InitElementProperties() EL_BETON, EL_MAUERWERK, EL_MAUER_LEBT, + EL_MAUER_X, + EL_MAUER_Y, + EL_MAUER_XY, EL_FELSBODEN, EL_AUSGANG_ZU, EL_AUSGANG_ACT, @@ -889,6 +875,9 @@ void InitElementProperties() EL_MAUERWERK, EL_FELSBODEN, EL_MAUER_LEBT, + EL_MAUER_X, + EL_MAUER_Y, + EL_MAUER_XY, EL_MAUERND }; static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int); @@ -1286,7 +1275,7 @@ void InitElementProperties() Elementeigenschaften[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE); } -void CloseAll() +void CloseAllAndExit(int exit_value) { int i; @@ -1326,5 +1315,5 @@ void CloseAll() XCloseDisplay(display); } - exit(0); + exit(exit_value); }