diff --git a/char.c b/char.c index 3957b49..99f26c9 100644 --- a/char.c +++ b/char.c @@ -23,6 +23,10 @@ int initplayer(void) #endif lname = getlogin(); +#ifdef __EMSCRIPTEN__ + /* the browser has no user names */ + lname = "Adventurer"; +#endif #ifndef MSDOS if (!lname || strlen(lname) == 0) { @@ -788,8 +792,8 @@ void user_character_stats(void) Player.pow = Player.maxpow = 3 + powpts / 2; - Player.preference = - cinema_interact("mfyn", "Are you sexually interested in males or females? ", 0, 0); + /* fredygames.com: the question is left out; the House of the Eclipse is a club for games and conversation */ + Player.preference = 'n'; } @@ -832,10 +836,8 @@ void omegan_character_stats(void) strcpy(Player.name,msgscanstring()); if (Player.name[0] >= 'a' && Player.name[0] <= 'z') Player.name[0] += 'A'-'a'; /* capitalise 1st letter */ - print1("Is your character sexually interested in males or females? [mf] "); - do Player.preference = (char) mcigetc(); - while ((Player.preference != 'm') && (Player.preference != 'f') && - (Player.preference != 'y') && (Player.preference != 'n')); /* :-) */ + /* fredygames.com: the question is left out; the House of the Eclipse is a club for games and conversation */ + Player.preference = 'n'; } diff --git a/date.c b/date.c new file mode 100644 index 0000000..8b4387f --- /dev/null +++ b/date.c @@ -0,0 +1 @@ +const char * LAST_OMEGA_BUILD_TIME = "Debian omega-rpg_0.90-pa9.orig.tar.gz"; diff --git a/defs.h b/defs.h index 0481131..df7406c 100644 --- a/defs.h +++ b/defs.h @@ -71,7 +71,15 @@ on save and restore. */ This might usually be "/usr/games/lib/omegalib/", for unix, or something like "c:\\games\\omega\\omegalib\\" for msdos */ +#ifdef __EMSCRIPTEN__ +/* the browser build: the game data is preloaded in /omega/lib/; the high scores, the log and the saved + game are in /omega-saves/, which the page keeps in the browser (IndexedDB) */ +#define OMEGALIB "/omega/lib/" +#define OMEGASAVES "/omega-saves/" +#else #define OMEGALIB "./lib/" +#define OMEGASAVES OMEGALIB +#endif /* TILEFILE is the name of the file you want to use for graphics tiles. You */ /* aren't really free to use any file you want here. It should be the Omega */ diff --git a/file.c b/file.c index 61f545d..33a902b 100644 --- a/file.c +++ b/file.c @@ -160,7 +160,7 @@ void lock_score_file(void) FILE * lockfile; - strcpy(Str1,Omegalib); + strcpy(Str1,Omegasaves); strcat(Str1,"omega.hi.lock"); do @@ -206,7 +206,7 @@ void lock_score_file(void) void unlock_score_file(void) { #ifndef MSDOS - strcpy(Str1,Omegalib); + strcpy(Str1,Omegasaves); strcat(Str1,"omega.hi.lock"); unlink(Str1); #endif @@ -218,7 +218,7 @@ void showscores(void) int i; lock_score_file(); - strcpy(Str1,Omegalib); + strcpy(Str1,Omegasaves); strcat(Str1,"omega.hi"); fd = checkfopen(Str1,"rb"); filescanstring(fd,Hiscorer); @@ -302,10 +302,10 @@ void save_hiscore_npc(int npc) if (gamestatusp(CHEATED)) return; lock_score_file(); - strcpy(Str1,Omegalib); + strcpy(Str1,Omegasaves); strcat(Str1,"omega.hi"); infile = checkfopen(Str1,"rb"); - strcpy(Str2,Omegalib); + strcpy(Str2,Omegasaves); #ifdef MSDOS strcat(Str2,"omegahi.new"); /* stupid 8.3 msdos filename limit */ #else @@ -434,7 +434,7 @@ void extendlog(char *descrip, int lifestatus) change_to_game_perms(); npcbehavior=fixnpc(lifestatus); checkhigh(descrip,npcbehavior); - strcpy(Str1,Omegalib); + strcpy(Str1,Omegasaves); strcat(Str1,"omega.log"); fd = checkfopen(Str1,"a"); fprintf(fd, " %d %d %d %s\n", lifestatus, Player.level, npcbehavior, @@ -520,6 +520,17 @@ int filecheck(void) endpos = strlen(Str1); for (file = 0; required_file_list[file]; file++) { + if (strcmp(required_file_list[file], "omega.hi") == 0 || + strcmp(required_file_list[file], "omega.log") == 0) + { + strcpy(Str1, Omegasaves); + endpos = strlen(Str1); + } + else + { + strcpy(Str1, Omegalib); + endpos = strlen(Str1); + } strcpy(&(Str1[endpos]), required_file_list[file]); if ((strcmp(required_file_list[file], "omega.hi") == 0 || strcmp(required_file_list[file], "omega.log") == 0) && diff --git a/glob.h b/glob.h index 9c0e5cc..dcc3ea6 100644 --- a/glob.h +++ b/glob.h @@ -25,6 +25,7 @@ extern char SaveFileName[80]; /* This string holds the path to the library files */ extern char *Omegalib; +extern char *Omegasaves; /* one of each monster */ extern struct monster Monsters[NUMMONSTERS]; diff --git a/mon.c b/mon.c index 2fd4c87..cf63f9b 100644 --- a/mon.c +++ b/mon.c @@ -696,7 +696,7 @@ void make_log_npc(pmt npc) status = 2; strcpy(Str2,"Malaprop the Misnamed"); - strcpy(Str1,Omegalib); + strcpy(Str1,Omegasaves); strcat(Str1,"omega.log"); fd = checkfopen(Str1,"r"); n = 1; diff --git a/omega.c b/omega.c index ccb1457..ffcf085 100644 --- a/omega.c +++ b/omega.c @@ -21,7 +21,8 @@ /* most globals originate in omega.c */ -char *Omegalib; /* contains the path to the library files */ +char *Omegalib; +char *Omegasaves = OMEGASAVES; /* contains the path to the library files */ #ifdef DEBUG FILE *DG_debug_log; /* debug log file pointer */ @@ -249,6 +250,29 @@ void signalquit(int ignore) quit(); } +#ifdef __EMSCRIPTEN__ +/* the first visit: the high score table and the log start from the files that come with the game */ +static void seed_saves_file(const char *name) +{ + char from[200], to[200], buf[512]; + FILE *in, *out; + size_t n; + + sprintf(to, "%s%s", OMEGASAVES, name); + if (access(to, F_OK) == 0) + return; + sprintf(from, "%s%s", OMEGALIB, name); + if ((in = fopen(from, "rb")) == NULL) + return; + if ((out = fopen(to, "wb")) != NULL) { + while ((n = fread(buf, 1, sizeof buf, in)) > 0) + fwrite(buf, 1, n, out); + fclose(out); + } + fclose(in); +} +#endif + int main(int argc, char *argv[]) { int continuing = 0; @@ -292,7 +316,15 @@ int main(int argc, char *argv[]) if (optind >= argc ) { /* no save file given */ -#if defined( BSD ) || defined( SYSV ) +#ifdef __EMSCRIPTEN__ + /* the browser build: the saved game (if any) is in /omega-saves, and the visit continues it */ + chdir(OMEGASAVES); + seed_saves_file("omega.hi"); + seed_saves_file("omega.log"); + strcpy( SaveFileName,"Omega"); + if (access(SaveFileName, R_OK) == 0) + continuing = 1; +#elif defined( BSD ) || defined( SYSV ) sprintf( SaveFileName, "Omega%d", getuid() ); #else strcpy( SaveFileName,"Omega"); diff --git a/scr.c b/scr.c index 92b8b78..e712c14 100644 --- a/scr.c +++ b/scr.c @@ -560,7 +560,11 @@ void initgraf(void) scrollok(Cinema,0); noecho(); +#ifdef __EMSCRIPTEN__ + cbreak(); /* crmode() is the old name of cbreak() */ +#else crmode(); +#endif clear(); touchwin(stdscr); diff --git a/site2.c b/site2.c index 5db47e2..086257b 100644 --- a/site2.c +++ b/site2.c @@ -492,6 +492,8 @@ void l_vault(void) void l_brothel(void) { char response; + /* fredygames.com: here the house is a club for games and conversation, whatever the character's preference */ + Player.preference = 'n'; print1("You come to a heavily reinforced inner door."); print2("A sign reads `The House of the Eclipse'"); morewait(); @@ -501,7 +503,7 @@ void l_brothel(void) menuprint("a:knock on the door.\n"); menuprint("b:try to pick the lock.\n"); menuprint("c:bash down the door.\n"); - menuprint("ESCAPE: Leave this house of ill repute.\n"); + menuprint("ESCAPE: Leave.\n"); showmenu(); do response = menugetc(); @@ -611,7 +613,7 @@ void l_brothel(void) print1("You arise, tired but happy, the next morning..."); } } - else print2("What are you, some kinda prude?"); + else print2("Suit yourself."); } } else if (response == 'b') {