From 82b1f76754f039e4ee151c7da7c49819c7310546 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 26 Oct 1998 01:23:09 +0100 Subject: [PATCH] rnd-19981026-2 --- src/files.c | 523 +++++++++++++------------------------------------- src/files.h | 71 +------ src/game.c | 100 +--------- src/init.c | 55 +----- src/main.h | 24 +-- src/network.c | 5 +- src/screens.c | 195 ++++--------------- src/screens.h | 2 +- 8 files changed, 183 insertions(+), 792 deletions(-) diff --git a/src/files.c b/src/files.c index 17bc45e5..c3cb4b8d 100644 --- a/src/files.c +++ b/src/files.c @@ -19,68 +19,6 @@ #include "tape.h" #include "joystick.h" -boolean CreateNewScoreFile() -{ - int i,j,k; - char filename[MAX_FILENAME_LEN]; - char empty_alias[MAX_NAMELEN]; - FILE *file; - - sprintf(filename,"%s/%s/%s", - level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME); - - if (!(file=fopen(filename,"w"))) - return(FALSE); - - for(i=0;ileveldir_nr < num_leveldirs) - leveldir_nr = local_player->leveldir_nr; - else - leveldir_nr = 0; - } - else - { - local_player->handicap = new_player.handicap; - local_player->level_nr = new_player.level_nr; - } - - level_nr = local_player->level_nr; - - if (file) - fclose(file); -} - -#endif - - - -void SaveLevel(int level_nr) -{ - int i,x,y; - char filename[MAX_FILENAME_LEN]; - FILE *file; - - sprintf(filename,"%s/%s/%d", - level_directory,leveldir[leveldir_nr].filename,level_nr); - - if (!(file=fopen(filename,"w"))) - { - Error(ERR_WARN, "cannot save level file '%s'", filename); - return; - } - - fputs(LEVEL_COOKIE,file); /* Formatkennung */ - fputc(0x0a,file); - - fputc(level.fieldx,file); - fputc(level.fieldy,file); - fputc(level.time / 256,file); - fputc(level.time % 256,file); - fputc(level.edelsteine / 256,file); - fputc(level.edelsteine % 256,file); - - for(i=0;ilogin_name, MAX_NAMELEN-1)) - { - fseek(file,-(2*MAX_NAMELEN+1+2+1+(version_10_file ? 0 : 11)),SEEK_CUR); - break; - } } +} - local_player->level_nr = level_nr; +void SaveScore(int level_nr) +{ + int i,j; + char filename[MAX_FILENAME_LEN]; + FILE *file; - for(i=0;ilogin_name[i],file); - for(i=0;ialias_name[i],file); - fputc(local_player->handicap,file); - fputc(local_player->setup / 256,file); - fputc(local_player->setup % 256,file); - fputc(local_player->leveldir_nr,file); - if (!version_10_file) + sprintf(filename,"%s/%s/%s", + level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME); + + if (!(file=fopen(filename,"r+"))) { - fputc(local_player->level_nr,file); - for(i=0;i<10;i++) /* currently unused bytes */ - fputc(0,file); + Error(ERR_WARN, "cannot save score for level %d", level_nr); + return; } + fseek(file, + SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)), + SEEK_SET); + for(i=0;isetup); - setup.sound_loops_on = SETUP_SOUND_LOOPS_ON(local_player->setup); - setup.sound_music_on = SETUP_SOUND_MUSIC_ON(local_player->setup); - setup.toons_on = SETUP_TOONS_ON(local_player->setup); - setup.direct_draw_on = SETUP_DIRECT_DRAW_ON(local_player->setup); - setup.fading_on = SETUP_FADING_ON(local_player->setup); - setup.autorecord_on = SETUP_AUTO_RECORD_ON(local_player->setup); - -#if 0 - setup.joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); -#endif - - setup.input[0].joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); - - setup.quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup); - setup.scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup); - setup.soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup); - #ifndef MSDOS if (setup.input[0].joystick_nr != old_joystick_nr) { @@ -69,9 +46,6 @@ void GetPlayerConfig() InitJoystick(); } #endif - -#endif - } void InitGame() @@ -95,10 +69,6 @@ void InitGame() player->action = 0; - /* - player->local = FALSE; - */ - player->score = 0; player->gems_still_needed = level.edelsteine; player->sokobanfields_still_needed = 0; @@ -140,24 +110,10 @@ void InitGame() DigField(player, 0,0,0,0,DF_NO_PUSH); SnapField(player, 0,0); - - /* TEST TEST TEST */ - - /* - stored_player[i].active = TRUE; - */ - - /* TEST TEST TEST */ - player->LevelSolved = FALSE; player->GameOver = FALSE; } - /* - local_player->active = TRUE; - local_player->local = TRUE; - */ - network_player_action_received = FALSE; /* initial null action */ @@ -207,10 +163,6 @@ void InitGame() struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_SPIELER1]; int jx = player->jx, jy = player->jy; - /* - player->active = TRUE; - */ - player->present = TRUE; if (!network_playing || player->connected) { @@ -228,14 +180,6 @@ void InitGame() local_player->active ? "active" : "not active"); } -#if 0 - /* remove potentially duplicate players */ - if (StorePlayer[jx][jy] == Feld[x][y]) - StorePlayer[jx][jy] = 0; - - StorePlayer[x][y] = Feld[x][y]; -#endif - Feld[x][y] = EL_LEERRAUM; player->jx = player->last_jx = x; player->jy = player->last_jy = y; @@ -349,6 +293,7 @@ void InitGame() } } + for(i=0; ihandicap && - level_nr < leveldir[leveldir_nr].levels-1) - { - local_player->handicap++; - bumplevel = TRUE; - - -#if 0 - SavePlayerInfo(PLAYER_LEVEL); -#endif - - } - */ - - if ((hi_pos=NewHiScore()) >= 0) { game_status = HALLOFFAME; @@ -3027,31 +2955,11 @@ void GameActions() { int actual_player_action = stored_player[i].action; - /* TEST TEST TEST */ - - /* - if (i != TestPlayer && !stored_player[i].MovPos) - actual_player_action = 0; - */ - - /* - if (!options.network && i != TestPlayer) - actual_player_action = 0; - */ - - /* TEST TEST TEST */ - - if (recorded_player_action) actual_player_action = recorded_player_action[i]; PlayerActions(&stored_player[i], actual_player_action); ScrollFigure(&stored_player[i], SCROLL_GO_ON); - - /* - stored_player[i].action = 0; - */ - } network_player_action_received = FALSE; @@ -3061,12 +2969,6 @@ void GameActions() FrameCounter++; TimeFrames++; - - /* - printf("FrameCounter == %d, RND(100) == %d\n", FrameCounter, RND(100)); - */ - - for(y=0;yconnected = TRUE; if (!LoadLevelInfo()) /* global level info */ Error(ERR_EXIT, NULL); - LoadSetup(); /* global setup info */ LoadLevelSetup(); /* info about last played level */ - - -#if 0 - LoadPlayerInfo(PLAYER_SETUP); /* global setup info */ - LoadPlayerInfo(PLAYER_LEVEL); /* level specific info */ -#endif - - -#if 0 - /* after LoadPlayerInfo(), because it overwrites 'local_player' */ -#endif - for (i=0; iconnected = TRUE; - local_player->local = TRUE; } void InitNetworkServer() diff --git a/src/main.h b/src/main.h index ef25edc8..81a67831 100644 --- a/src/main.h +++ b/src/main.h @@ -35,9 +35,9 @@ #ifdef XPM_INCLUDE_FILE #include XPM_INCLUDE_FILE #endif -#else +#else /* MSDOS */ #include "msdos.h" -#endif /* #ifndef MSDOS */ +#endif /* MSDOS */ typedef unsigned char boolean; typedef unsigned char byte; @@ -52,10 +52,10 @@ typedef unsigned char byte; #ifndef MSDOS #define WIN_XPOS 0 #define WIN_YPOS 0 -#else +#else /* MSDOS */ #define WIN_XPOS ((XRES - WIN_XSIZE) / 2) #define WIN_YPOS ((YRES - WIN_YSIZE) / 2) -#endif +#endif /* MSDOS */ #define SCR_FIELDX 17 #define SCR_FIELDY 17 #define MAX_BUF_XSIZE (SCR_FIELDX + 2) @@ -82,6 +82,7 @@ typedef unsigned char byte; #ifndef SIGN #define SIGN(a) ((a) < 0 ? -1 : ((a)>0 ? 1 : 0)) #endif + #define SCREENX(a) ((a) - scroll_x) #define SCREENY(a) ((a) - scroll_y) #define LEVELX(a) ((a) + scroll_x) @@ -265,8 +266,7 @@ struct SetupFileList struct PlayerInfo { boolean present; /* player present in level playfield */ - boolean connected; /* player connected locally or via network */ - boolean local; /* player connected locally */ + boolean connected; /* player connected (locally or via network) */ boolean active; /* player (present && connected) */ int index_nr, client_nr, element_nr; @@ -276,16 +276,6 @@ struct PlayerInfo char login_name[MAX_NAMELEN]; char alias_name[MAX_NAMELEN]; - -#if 0 - int handicap; - unsigned int setup; -#endif - - - int leveldir_nr; - int level_nr; - int jx,jy, last_jx,last_jy; int MovDir, MovPos, GfxPos; int Frame; @@ -1243,4 +1233,4 @@ extern int num_bg_loops; #define ANIM_OSCILLATE 1 #define ANIM_REVERSE 2 -#endif +#endif /* MAIN_H */ diff --git a/src/network.c b/src/network.c index 3f51426c..6ddf52b2 100644 --- a/src/network.c +++ b/src/network.c @@ -324,7 +324,6 @@ static void Handle_OP_YOUR_NUMBER() *new_local_player = *old_local_player; old_local_player->connected = FALSE; - old_local_player->local = FALSE; local_player = new_local_player; } @@ -373,7 +372,6 @@ static void Handle_OP_NUMBER_WANTED() *new_player = *old_player; old_player->connected = FALSE; - old_player->local = FALSE; } u = finduser(old_client_nr); @@ -484,7 +482,10 @@ static void Handle_OP_START_PLAYING() leveldir_nr = new_leveldir_nr; + /* local_player->leveldir_nr = leveldir_nr; + */ + /* SaveLevelSetup(); diff --git a/src/screens.c b/src/screens.c index acc371dc..68132cf5 100644 --- a/src/screens.c +++ b/src/screens.c @@ -70,10 +70,22 @@ void DrawMainMenu() DrawGraphic(14,3,GFX_PFEIL_R); DrawText(SX+40+16,SY+326,"A Game by Artsoft Entertainment",FS_SMALL,FC_BLUE); + + /* DrawText(SX+40+16,SY+344,"Graphics: Deluxe Paint IV Amiga", FS_SMALL,FC_BLUE); DrawText(SX+60+16,SY+362,"Sounds: AudioMaster IV Amiga", FS_SMALL,FC_BLUE); + */ + + if (leveldir[leveldir_nr].name) + { + int len = strlen(leveldir[leveldir_nr].name); + int lxpos = SX+(SXSIZE-len*FONT4_XSIZE)/2; + int lypos = SY+352; + + DrawText(lxpos,lypos,leveldir[leveldir_nr].name,FS_SMALL,FC_SPECIAL2); + } FadeToFront(); InitAnimation(); @@ -151,13 +163,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) level_nr = new_level_nr; - - /* - if (level_nr > local_player->handicap) - level_nr = local_player->handicap; - */ - - DrawTextExt(drawto,gc,SX+11*32,SY+3*32, int2str(level_nr,3), FS_BIG,FC_RED); DrawTextExt(window,gc,SX+11*32,SY+3*32, @@ -198,15 +203,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (num_leveldirs) { game_status = CHOOSELEVEL; - - SaveLevelSetup(); - -#if 0 - SavePlayerInfo(PLAYER_LEVEL); -#endif - - DrawChooseLevel(); } } @@ -247,13 +244,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (y==10) { - SaveLevelSetup(); - -#if 0 - SavePlayerInfo(PLAYER_LEVEL); -#endif - if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED)) game_status = EXITGAME; } @@ -701,24 +692,6 @@ void HandleHelpScreen(int button) BackToFront(); } - -#if 0 -void CheckCheat() -{ - int old_handicap = local_player->handicap; - - if (!strcmp(local_player->alias_name,"Artsoft")) - local_player->handicap = leveldir[leveldir_nr].levels-1; - - if (local_player->handicap != old_handicap) - { - SavePlayerInfo(PLAYER_LEVEL); - level_nr = local_player->handicap; - } -} -#endif - - void HandleTypeName(int newxpos, KeySym key) { static int xpos = 0, ypos = 2; @@ -765,27 +738,10 @@ void HandleTypeName(int newxpos, KeySym key) DrawText(SX+6*32,SY+ypos*32,local_player->alias_name,FS_BIG,FC_RED); DrawGraphic(xpos+6,ypos,GFX_LEERRAUM); - SaveSetup(); - - -#if 0 - SavePlayerInfo(PLAYER_SETUP); -#endif - - - -#if 0 - CheckCheat(); -#endif - - game_status = MAINMENU; -/* - DrawMainMenu(); -*/ - } + BackToFront(); } @@ -864,21 +820,9 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) } else { - local_player->leveldir_nr = leveldir_nr = y-3; - + leveldir_nr = y-3; SaveLevelSetup(); - /* - LoadPlayerInfo(PLAYER_LEVEL); - SavePlayerInfo(PLAYER_SETUP); - */ - - -#if 0 - CheckCheat(); -#endif - - TapeErase(); LoadLevelTape(level_nr); @@ -887,6 +831,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) redraw = TRUE; } } + BackToFront(); if (game_status==CHOOSELEVEL) @@ -940,68 +885,33 @@ void HandleHallOfFame(int button) void DrawSetupScreen() { int i; - - -#if 0 - static struct setup - { - unsigned int bit; - char *text, *mode[2]; - int color[2]; - } setup[] = - { - {SETUP_SOUND, "Sound:", {"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_SOUND_LOOPS, " Sound Loops:",{"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_SOUND_MUSIC, " Game Music:", {"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_TOONS, "Toons:", {"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_DIRECT_DRAW, "Buffered gfx:",{"off","on" }, {FC_BLUE,FC_YELLOW}}, - {SETUP_SCROLL_DELAY,"Scroll Delay:",{"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_SOFT_SCROLL, "Soft Scroll.:",{"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_FADING, "Fading:", {"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_QUICK_DOORS, "Quick Doors:", {"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {SETUP_AUTO_RECORD, "Auto-Record:", {"on", "off"}, {FC_YELLOW,FC_BLUE}}, - {0, "Input Devices",{"", ""}, {0,0}}, - {0, "", {"", ""}, {0,0}}, - {0, "", {"", ""}, {0,0}}, - {0, "Exit", {"", ""}, {0,0}}, - {0, "Save and exit",{"", ""}, {0,0}} - }; -#endif - static struct setup { boolean *value; char *text, *mode[2]; - int color[2]; } setup_info[] = { - { &setup.sound_on, "Sound:", {"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.sound_loops_on," Sound Loops:",{"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.sound_music_on," Game Music:", {"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.toons_on, "Toons:", {"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.direct_draw_on,"Buffered gfx:",{"off","on" },{FC_BLUE,FC_YELLOW}}, - { &setup.scroll_delay_on,"Scroll Delay:",{"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.soft_scrolling_on, "Soft Scroll.:",{"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.fading_on, "Fading:", {"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.quick_doors,"Quick Doors:", {"on", "off"},{FC_YELLOW,FC_BLUE}}, - { &setup.autorecord_on,"Auto-Record:", {"on", "off"},{FC_YELLOW,FC_BLUE}}, - { NULL, "Input Devices",{"", ""}, {0,0}}, - { NULL, "", {"", ""}, {0,0}}, - { NULL, "", {"", ""}, {0,0}}, - { NULL, "Exit", {"", ""}, {0,0}}, - { NULL, "Save and exit",{"", ""}, {0,0}} + { &setup.sound_on, "Sound:", { "on", "off" } }, + { &setup.sound_loops_on, " Sound Loops:",{ "on", "off" } }, + { &setup.sound_music_on, " Game Music:", { "on", "off" } }, + { &setup.toons_on, "Toons:", { "on", "off" } }, + { &setup.direct_draw_on, "Buffered gfx:",{ "off","on" } }, + { &setup.scroll_delay_on, "Scroll Delay:",{ "on", "off" } }, + { &setup.soft_scrolling_on, "Soft Scroll.:",{ "on", "off" } }, + { &setup.fading_on, "Fading:", { "on", "off" } }, + { &setup.quick_doors, "Quick Doors:", { "on", "off" } }, + { &setup.autorecord_on, "Auto-Record:", { "on", "off" } }, + { NULL, "Input Devices",{ "", "" } }, + { NULL, "", { "", "" } }, + { NULL, "", { "", "" } }, + { NULL, "Exit", { "", "" } }, + { NULL, "Save and exit",{ "", "" } } }; CloseDoor(DOOR_CLOSE_2); ClearWindow(); DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW); - - /* - printf("setup.sound_loops_on == %d\n", setup.sound_loops_on); - */ - - for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++) { int base = i - SETUP_SCREEN_POS_START; @@ -1012,21 +922,14 @@ void DrawSetupScreen() DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN); } -#if 0 - if (i < SETUP_SCREEN_POS_EMPTY1) - { - int setting_bit = setup_info[base].bit; - int setting_pos = ((local_player->setup & setting_bit) != 0 ? 0 : 1); - } -#endif - if (setup_info[base].value) { int setting_value = *setup_info[base].value; int setting_pos = (setting_value != 0 ? 0 : 1); + int fc_on = (strcmp(setup_info[base].mode[setting_pos], "on") == 0); - DrawText(SX+14*32, SY+i*32,setup_info[base].mode[setting_pos], - FS_BIG,setup_info[base].color[setting_pos]); + DrawText(SX+14*32, SY+i*32, setup_info[base].mode[setting_pos], + FS_BIG, (fc_on ? FC_YELLOW : FC_BLUE)); } } @@ -1202,15 +1105,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) { if (y==pos_end) { - - SaveSetup(); - - -#if 0 - SavePlayerInfo(PLAYER_SETUP); -#endif - SaveJoystickData(); } @@ -2143,30 +2038,6 @@ void HandleGameButtons(int mx, int my, int button) } else TapeTogglePause(); - - /* - if (tape.pausing) - { - if (options.network) - SendToServer_ContinuePlaying(); - else - { - tape.pausing = FALSE; - DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0); - } - } - else - { - if (options.network) - SendToServer_PausePlaying(); - else - { - tape.pausing = TRUE; - DrawVideoDisplay(VIDEO_STATE_PAUSE_ON,0); - } - } - */ - break; case BUTTON_GAME_PLAY: diff --git a/src/screens.h b/src/screens.h index cf7ec696..5971af20 100644 --- a/src/screens.h +++ b/src/screens.h @@ -52,4 +52,4 @@ void HandleVideoButtons(int, int, int); void HandleSoundButtons(int, int, int); void HandleGameButtons(int, int, int); -#endif +#endif /* SCREENS_H */ -- 2.34.1