#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;i<MAX_NAMELEN;i++)
- empty_alias[i] = 0;
- strncpy(empty_alias,EMPTY_ALIAS,MAX_NAMELEN-1);
-
- fputs(SCORE_COOKIE,file); /* Formatkennung */
- for(i=0;i<leveldir[leveldir_nr].levels;i++)
- {
- for(j=0;j<MAX_SCORE_ENTRIES;j++)
- {
- for(k=0;k<MAX_NAMELEN;k++)
- fputc(empty_alias[k],file);
- fputc(0,file);
- fputc(0,file);
- }
- }
- fclose(file);
-
- chmod(filename, SCORE_PERMS);
- return(TRUE);
-}
-
-
-
-#if 0
-
-boolean CreateNewNamesFile(int mode)
-{
- char filename[MAX_FILENAME_LEN];
- FILE *file;
-
- if (mode==PLAYER_LEVEL)
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,NAMES_FILENAME);
- else
- sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
-
- if (!(file=fopen(filename,"w")))
- return(FALSE);
-
- fputs(NAMES_COOKIE,file); /* Formatkennung */
- fclose(file);
-
- chmod(filename, NAMES_PERMS);
- return(TRUE);
-}
-
-#endif
-
-
boolean LoadLevelInfo()
{
int i;
}
}
+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;i<MAX_LEVNAMLEN;i++)
+ fputc(level.name[i],file);
+ for(i=0;i<MAX_LEVSCORE_ENTRIES;i++)
+ fputc(level.score[i],file);
+ for(i=0;i<4;i++)
+ for(y=0;y<3;y++)
+ for(x=0;x<3;x++)
+ fputc(level.mampfer_inhalt[i][x][y],file);
+ fputc(level.tempo_amoebe,file);
+ fputc(level.dauer_sieb,file);
+ fputc(level.dauer_ablenk,file);
+ fputc(level.amoebe_inhalt,file);
+
+ for(i=0;i<NUM_FREE_LVHD_BYTES;i++) /* Rest frei / Headergröße 80 Bytes */
+ fputc(0,file);
+
+ for(y=0;y<lev_fieldy;y++)
+ for(x=0;x<lev_fieldx;x++)
+ fputc(Ur[x][y],file);
+
+ fclose(file);
+
+ chmod(filename, LEVEL_PERMS);
+}
+
void LoadLevelTape(int level_nr)
{
int i;
tape.length_seconds = GetTapeLength();
}
-void LoadScore(int level_nr)
-{
- int i,j;
- char filename[MAX_FILENAME_LEN];
- char cookie[MAX_FILENAME_LEN];
- FILE *file;
-
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME);
-
- if (!(file = fopen(filename,"r")))
- {
- if (!CreateNewScoreFile())
- Error(ERR_WARN, "cannot create score file '%s'", filename);
- else if (!(file = fopen(filename,"r")))
- Error(ERR_WARN, "cannot read score for level %d", level_nr);
- }
-
- if (file)
- {
- fgets(cookie,SCORE_COOKIE_LEN,file);
- if (strcmp(cookie,SCORE_COOKIE)) /* ungültiges Format? */
- {
- Error(ERR_WARN, "wrong format of score file '%s'", filename);
- fclose(file);
- file = NULL;
- }
- }
-
- if (file)
- {
- fseek(file,
- SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
- SEEK_SET);
- for(i=0;i<MAX_SCORE_ENTRIES;i++)
- {
- for(j=0;j<MAX_NAMELEN;j++)
- highscore[i].Name[j] = fgetc(file);
- highscore[i].Score = (fgetc(file)<<8) | fgetc(file);
- }
- fclose(file);
- }
- else
- {
- for(i=0;i<MAX_SCORE_ENTRIES;i++)
- {
- strcpy(highscore[i].Name,EMPTY_ALIAS);
- highscore[i].Score = 0;
- }
- }
-}
-
-
-
-#if 0
-
-void LoadPlayerInfo(int mode)
-{
- int i;
- char filename[MAX_FILENAME_LEN];
- char cookie[MAX_FILENAME_LEN];
- FILE *file;
- char *login_name = GetLoginName();
- struct PlayerInfo default_player, new_player;
- int version_10_file = FALSE;
-
-
-
- if (mode == PLAYER_SETUP)
- LoadSetup();
- else if (mode == PLAYER_LEVEL)
- LoadLevelSetup();
-
-
-
- if (mode==PLAYER_LEVEL)
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,NAMES_FILENAME);
- else
- sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
-
- for(i=0;i<MAX_NAMELEN;i++)
- default_player.login_name[i] = default_player.alias_name[i] = 0;
- strncpy(default_player.login_name,login_name,MAX_NAMELEN-1);
- strncpy(default_player.alias_name,login_name,MAX_NAMELEN-1);
- default_player.handicap = 0;
- default_player.setup = DEFAULT_SETUP;
- default_player.leveldir_nr = 0;
- default_player.level_nr = 0;
-
- new_player = default_player;
-
- if (!(file = fopen(filename,"r")))
- {
- if (!CreateNewNamesFile(mode))
- Error(ERR_WARN, "cannot create names file '%s'", filename);
- else if (!(file = fopen(filename,"r")))
- Error(ERR_WARN, "cannot read player information file '%s'", filename);
- }
-
- if (file)
- {
- fgets(cookie,NAMES_COOKIE_LEN,file);
- if (!strcmp(cookie,NAMES_COOKIE_10)) /* altes Format? */
- version_10_file = TRUE;
- else if (strcmp(cookie,NAMES_COOKIE)) /* ungültiges Format? */
- {
- Error(ERR_WARN, "wrong format of names file '%s'", filename);
- fclose(file);
- file = NULL;
- }
- }
-
- if (!file)
- {
- *local_player = default_player;
- level_nr = default_player.level_nr;
- return;
- }
-
- while(1)
- {
- for(i=0;i<MAX_NAMELEN;i++)
- new_player.login_name[i] = fgetc(file);
- for(i=0;i<MAX_NAMELEN;i++)
- new_player.alias_name[i] = fgetc(file);
- new_player.handicap = fgetc(file);
- new_player.setup = (fgetc(file)<<8) | fgetc(file);
- new_player.leveldir_nr = fgetc(file);
- if (!version_10_file)
- {
- new_player.level_nr = fgetc(file);
- for(i=0;i<10;i++) /* currently unused bytes */
- fgetc(file);
- }
- else
- new_player.level_nr = new_player.handicap;
-
- if (feof(file)) /* Spieler noch nicht in Liste enthalten */
- {
- new_player = default_player;
-
- fclose(file);
- if (!(file = fopen(filename,"a")))
- Error(ERR_WARN, "cannot append new player to names file '%s'",
- filename);
- else
- {
- for(i=0;i<MAX_NAMELEN;i++)
- fputc(new_player.login_name[i],file);
- for(i=0;i<MAX_NAMELEN;i++)
- fputc(new_player.alias_name[i],file);
- fputc(new_player.handicap,file);
- fputc(new_player.setup / 256,file);
- fputc(new_player.setup % 256,file);
- fputc(new_player.leveldir_nr,file);
- if (!version_10_file)
- {
- fputc(new_player.level_nr,file);
- for(i=0;i<10;i++) /* currently unused bytes */
- fputc(0,file);
- }
- }
- break;
- }
- else /* prüfen, ob Spieler in Liste enthalten */
- if (!strncmp(new_player.login_name,login_name,MAX_NAMELEN-1))
- break;
- }
-
- if (mode==PLAYER_SETUP)
- {
- *local_player = new_player;
- if (local_player->leveldir_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;i<MAX_LEVNAMLEN;i++)
- fputc(level.name[i],file);
- for(i=0;i<MAX_LEVSCORE_ENTRIES;i++)
- fputc(level.score[i],file);
- for(i=0;i<4;i++)
- for(y=0;y<3;y++)
- for(x=0;x<3;x++)
- fputc(level.mampfer_inhalt[i][x][y],file);
- fputc(level.tempo_amoebe,file);
- fputc(level.dauer_sieb,file);
- fputc(level.dauer_ablenk,file);
- fputc(level.amoebe_inhalt,file);
-
- for(i=0;i<NUM_FREE_LVHD_BYTES;i++) /* Rest frei / Headergröße 80 Bytes */
- fputc(0,file);
-
- for(y=0;y<lev_fieldy;y++)
- for(x=0;x<lev_fieldx;x++)
- fputc(Ur[x][y],file);
-
- fclose(file);
-
- chmod(filename, LEVEL_PERMS);
-}
-
void SaveLevelTape(int level_nr)
{
int i;
Request("tape saved !",REQ_CONFIRM);
}
-void SaveScore(int level_nr)
+boolean CreateNewScoreFile()
{
- int i,j;
+ 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,"r+")))
- {
- Error(ERR_WARN, "cannot save score for level %d", level_nr);
- return;
- }
+ if (!(file=fopen(filename,"w")))
+ return(FALSE);
- fseek(file,
- SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
- SEEK_SET);
- for(i=0;i<MAX_SCORE_ENTRIES;i++)
+ for(i=0;i<MAX_NAMELEN;i++)
+ empty_alias[i] = 0;
+ strncpy(empty_alias,EMPTY_ALIAS,MAX_NAMELEN-1);
+
+ fputs(SCORE_COOKIE,file); /* Formatkennung */
+ for(i=0;i<leveldir[leveldir_nr].levels;i++)
{
- for(j=0;j<MAX_NAMELEN;j++)
- fputc(highscore[i].Name[j],file);
- fputc(highscore[i].Score / 256,file);
- fputc(highscore[i].Score % 256,file);
+ for(j=0;j<MAX_SCORE_ENTRIES;j++)
+ {
+ for(k=0;k<MAX_NAMELEN;k++)
+ fputc(empty_alias[k],file);
+ fputc(0,file);
+ fputc(0,file);
+ }
}
fclose(file);
-}
-
+ chmod(filename, SCORE_PERMS);
+ return(TRUE);
+}
-#if 0
-
-void SavePlayerInfo(int mode)
+void LoadScore(int level_nr)
{
- int i;
+ int i,j;
char filename[MAX_FILENAME_LEN];
char cookie[MAX_FILENAME_LEN];
FILE *file;
- struct PlayerInfo default_player;
- int version_10_file = FALSE;
-
-
-
- if (mode == PLAYER_SETUP)
- SaveSetup();
- else if (mode == PLAYER_LEVEL)
- SaveLevelSetup();
-
+ sprintf(filename,"%s/%s/%s",
+ level_directory,leveldir[leveldir_nr].filename,SCORE_FILENAME);
- if (mode == PLAYER_LEVEL)
- sprintf(filename,"%s/%s/%s",
- level_directory,leveldir[leveldir_nr].filename,NAMES_FILENAME);
- else
- sprintf(filename,"%s/%s",CONFIG_PATH,NAMES_FILENAME);
+ if (!(file = fopen(filename,"r")))
+ {
+ if (!CreateNewScoreFile())
+ Error(ERR_WARN, "cannot create score file '%s'", filename);
+ else if (!(file = fopen(filename,"r")))
+ Error(ERR_WARN, "cannot read score for level %d", level_nr);
+ }
- if (!(file = fopen(filename,"r+")))
+ if (file)
{
- Error(ERR_WARN, "cannot save player information to file '%s'", filename);
- return;
+ fgets(cookie,SCORE_COOKIE_LEN,file);
+ if (strcmp(cookie,SCORE_COOKIE)) /* ungültiges Format? */
+ {
+ Error(ERR_WARN, "wrong format of score file '%s'", filename);
+ fclose(file);
+ file = NULL;
+ }
}
- fgets(cookie,NAMES_COOKIE_LEN,file);
- if (!strcmp(cookie,NAMES_COOKIE_10)) /* altes Format? */
- version_10_file = TRUE;
- else if (strcmp(cookie,NAMES_COOKIE)) /* ungültiges Format? */
+ if (file)
{
- Error(ERR_WARN, "wrong format of names file '%s'", filename);
+ fseek(file,
+ SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)),
+ SEEK_SET);
+ for(i=0;i<MAX_SCORE_ENTRIES;i++)
+ {
+ for(j=0;j<MAX_NAMELEN;j++)
+ highscore[i].Name[j] = fgetc(file);
+ highscore[i].Score = (fgetc(file)<<8) | fgetc(file);
+ }
fclose(file);
- return;
}
-
- while(1)
+ else
{
- for(i=0;i<MAX_NAMELEN;i++)
- default_player.login_name[i] = fgetc(file);
- for(i=0;i<MAX_NAMELEN;i++)
- default_player.alias_name[i] = fgetc(file);
- default_player.handicap = fgetc(file);
- default_player.setup = (fgetc(file)<<8) | fgetc(file);
- default_player.leveldir_nr = fgetc(file);
- if (!version_10_file)
+ for(i=0;i<MAX_SCORE_ENTRIES;i++)
{
- default_player.level_nr = fgetc(file);
- for(i=0;i<10;i++) /* currently unused bytes */
- fgetc(file);
+ strcpy(highscore[i].Name,EMPTY_ALIAS);
+ highscore[i].Score = 0;
}
- else
- default_player.level_nr = default_player.handicap;
-
- if (feof(file)) /* Spieler noch nicht in Liste enthalten */
- break;
- else /* prüfen, ob Spieler in Liste enthalten */
- if (!strncmp(default_player.login_name,
- local_player->login_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;i<MAX_NAMELEN;i++)
- fputc(local_player->login_name[i],file);
- for(i=0;i<MAX_NAMELEN;i++)
- fputc(local_player->alias_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;i<MAX_SCORE_ENTRIES;i++)
+ {
+ for(j=0;j<MAX_NAMELEN;j++)
+ fputc(highscore[i].Name[j],file);
+ fputc(highscore[i].Score / 256,file);
+ fputc(highscore[i].Score % 256,file);
+ }
fclose(file);
}
-#endif
-
-
-
void LoadJoystickData()
{
int i;
/* new setup functions */
/* ------------------------------------------------------------------------- */
+#define MAX_LINE_LEN 1000
+#define MAX_SETUP_TOKEN_LEN 100
+#define MAX_SETUP_VALUE_LEN 100
+
#define TOKEN_STR_FILE_IDENTIFIER "file_identifier"
#define TOKEN_STR_LAST_LEVEL_SERIES "last_level_series"
#define TOKEN_STR_ALIAS_NAME "alias_name"
#include "main.h"
-
-
-#if 0
-
-/* names file mode: local level setup or global game setup */
-#define PLAYER_LEVEL 0
-#define PLAYER_SETUP 1
-
-/* Setup-Bits */
-#define SETUP_TOONS (1<<0)
-#define SETUP_SOUND (1<<1)
-#define SETUP_SOUND_LOOPS (1<<2)
-#define SETUP_SOUND_MUSIC (1<<3)
-#define SETUP_DIRECT_DRAW (1<<4)
-#define SETUP_FADING (1<<5)
-#define SETUP_AUTO_RECORD (1<<6)
-#define SETUP_2ND_JOYSTICK (1<<7)
-#define SETUP_QUICK_DOORS (1<<8)
-#define SETUP_SCROLL_DELAY (1<<9)
-#define SETUP_SOFT_SCROLL (1<<10)
-
-#define DEFAULT_SETUP (SETUP_TOONS | \
- SETUP_SOUND | \
- SETUP_SOUND_LOOPS | \
- SETUP_SOUND_MUSIC)
-
-/* Setup-Voreinstellungen */
-#define SETUP_TOONS_ON(x) (((x) & SETUP_TOONS) != 0)
-#define SETUP_SOUND_ON(x) (((x) & SETUP_SOUND) != 0)
-#define SETUP_SOUND_LOOPS_ON(x) (((x) & SETUP_SOUND_LOOPS) != 0)
-#define SETUP_SOUND_MUSIC_ON(x) (((x) & SETUP_SOUND_MUSIC) != 0)
-#define SETUP_DIRECT_DRAW_ON(x) (((x) & SETUP_DIRECT_DRAW) != 0)
-#define SETUP_FADING_ON(x) (((x) & SETUP_FADING) != 0)
-#define SETUP_AUTO_RECORD_ON(x) (((x) & SETUP_AUTO_RECORD) != 0)
-#define SETUP_2ND_JOYSTICK_ON(x) (((x) & SETUP_2ND_JOYSTICK) != 0)
-#define SETUP_QUICK_DOORS_ON(x) (((x) & SETUP_QUICK_DOORS) != 0)
-#define SETUP_SCROLL_DELAY_ON(x) (((x) & SETUP_SCROLL_DELAY) != 0)
-#define SETUP_SOFT_SCROLL_ON(x) (((x) & SETUP_SOFT_SCROLL) != 0)
-
-#endif
-
-
-
-/* for LoadSetup() */
-#define MAX_LINE_LEN 1000
-#define MAX_SETUP_TOKEN_LEN 100
-#define MAX_SETUP_VALUE_LEN 100
-
-boolean CreateNewScoreFile(void);
-
-/*
-boolean CreateNewNamesFile(int);
-*/
-
boolean LoadLevelInfo(void);
void LoadLevel(int);
-void LoadLevelTape(int);
-void LoadScore(int);
-
-/*
-void LoadPlayerInfo(int);
-*/
-
void SaveLevel(int);
+void LoadLevelTape(int);
void SaveLevelTape(int);
-void SaveScore(int);
-/*
-void SavePlayerInfo(int);
-*/
+boolean CreateNewScoreFile(void);
+void LoadScore(int);
+void SaveScore(int);
void LoadJoystickData(void);
void SaveJoystickData(void);
void SaveSetup(void);
void SaveLevelSetup(void);
-#endif
+#endif /* FILES_H */
void GetPlayerConfig()
{
-#if 0
int old_joystick_nr = setup.input[0].joystick_nr;
-#endif
-
if (sound_status == SOUND_OFF)
setup.sound_on = FALSE;
setup.sound_simple_on = setup.sound_on;
-
-#if 0
- setup.sound_on = setup.sound_simple_on = SETUP_SOUND_ON(local_player->setup);
- 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)
{
InitJoystick();
}
#endif
-
-#endif
-
}
void InitGame()
player->action = 0;
- /*
- player->local = FALSE;
- */
-
player->score = 0;
player->gems_still_needed = level.edelsteine;
player->sokobanfields_still_needed = 0;
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 */
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)
{
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;
}
}
+
for(i=0; i<MAX_PLAYERS; i++)
{
struct PlayerInfo *player = &stored_player[i];
SaveLevelTape(tape.level_nr); /* Ask to save tape */
}
-
- /*
- if (level_nr == local_player->handicap &&
- 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;
{
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;
FrameCounter++;
TimeFrames++;
-
- /*
- printf("FrameCounter == %d, RND(100) == %d\n", FrameCounter, RND(100));
- */
-
-
for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
{
Stop[x][y] = FALSE;
{
int i;
-
-#if 0
-
- /* initialize local setup */
- setup.sound_on = TRUE;
- setup.sound_loops_on = FALSE;
- setup.sound_music_on = FALSE;
- setup.sound_simple_on = FALSE;
- setup.toons_on = TRUE;
- setup.direct_draw_on = FALSE;
- setup.scroll_delay_on = FALSE;
- setup.soft_scrolling_on = TRUE;
- setup.fading_on = FALSE;
- setup.autorecord_on = FALSE;
- setup.quick_doors = FALSE;
- for (i=0; i<MAX_PLAYERS; i++)
- {
- setup.input[i].use_joystick = FALSE;
- setup.input[i].joystick_nr = 0;
- setup.input[i].joy.snap = (i == 0 ? JOY_BUTTON_1 : 0);
- setup.input[i].joy.bomb = (i == 0 ? JOY_BUTTON_2 : 0);
- setup.input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KEY_UNDEFINDED);
- setup.input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KEY_UNDEFINDED);
- setup.input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KEY_UNDEFINDED);
- setup.input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KEY_UNDEFINDED);
- setup.input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KEY_UNDEFINDED);
- setup.input[i].key.bomb = (i == 0 ? DEFAULT_KEY_BOMB : KEY_UNDEFINDED);
- }
-
-#endif
-
-
-
/* choose default local player */
local_player = &stored_player[0];
+ for (i=0; i<MAX_PLAYERS; i++)
+ stored_player[i].connected = FALSE;
+ local_player->connected = 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; i<MAX_PLAYERS; i++)
- {
- stored_player[i].connected = FALSE;
- stored_player[i].local = FALSE;
- }
- local_player->connected = TRUE;
- local_player->local = TRUE;
}
void InitNetworkServer()
#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;
#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)
#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)
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;
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;
#define ANIM_OSCILLATE 1
#define ANIM_REVERSE 2
-#endif
+#endif /* MAIN_H */
*new_local_player = *old_local_player;
old_local_player->connected = FALSE;
- old_local_player->local = FALSE;
local_player = new_local_player;
}
*new_player = *old_player;
old_player->connected = FALSE;
- old_player->local = FALSE;
}
u = finduser(old_client_nr);
leveldir_nr = new_leveldir_nr;
+ /*
local_player->leveldir_nr = leveldir_nr;
+ */
+
/*
SaveLevelSetup();
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();
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,
if (num_leveldirs)
{
game_status = CHOOSELEVEL;
-
-
SaveLevelSetup();
-
-#if 0
- SavePlayerInfo(PLAYER_LEVEL);
-#endif
-
-
DrawChooseLevel();
}
}
}
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;
}
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;
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();
}
}
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);
redraw = TRUE;
}
}
+
BackToFront();
if (game_status==CHOOSELEVEL)
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;
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));
}
}
{
if (y==pos_end)
{
-
-
SaveSetup();
-
-
-#if 0
- SavePlayerInfo(PLAYER_SETUP);
-#endif
-
SaveJoystickData();
}
}
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:
void HandleSoundButtons(int, int, int);
void HandleGameButtons(int, int, int);
-#endif
+#endif /* SCREENS_H */