[Scummvm-git-logs] scummvm master -> 5b59b1045bdf1a4512121785cdaa1423cf515f24
dreammaster
paulfgilbert at gmail.com
Wed Aug 19 02:42:49 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3403e82cc4 ULTIMA4: Fixes to Ultima 5 style mix menu
5b59b1045b GLK: AGT: Removal of platform-specific define blocks
Commit: 3403e82cc421ee5fa1d3e56b052048eb90eed22a
https://github.com/scummvm/scummvm/commit/3403e82cc421ee5fa1d3e56b052048eb90eed22a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-08-18T19:19:43-07:00
Commit Message:
ULTIMA4: Fixes to Ultima 5 style mix menu
Changed paths:
engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
engines/ultima/ultima4/core/debugger.cpp
diff --git a/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp b/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
index 2894410ba8..ccfc69bc9d 100644
--- a/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
+++ b/engines/ultima/ultima4/controllers/reagents_menu_controller.cpp
@@ -37,21 +37,43 @@ bool ReagentsMenuController::keyPressed(int key) {
case 'f':
case 'g':
case 'h': {
- /* select the corresponding reagent (if visible) */
+ // Select the corresponding reagent (if visible)
Menu::MenuItemList::iterator mi = _menu->getById(key - 'a');
if ((*mi)->isVisible()) {
_menu->setCurrent(_menu->getById(key - 'a'));
keyPressed(Common::KEYCODE_SPACE);
}
+ break;
}
- break;
- case Common::KEYCODE_LEFT:
- case Common::KEYCODE_RIGHT:
- case Common::KEYCODE_SPACE:
+
+ default:
+ return MenuController::keyPressed(key);
+ }
+
+ return true;
+}
+
+void ReagentsMenuController::keybinder(KeybindingAction action) {
+ switch (action) {
+ case KEYBIND_ESCAPE:
+ _ingredients->revert();
+ eventHandler->setControllerDone();
+ break;
+
+ case KEYBIND_UP:
+ _menu->prev();
+ break;
+
+ case KEYBIND_DOWN:
+ _menu->next();
+ break;
+
+ case KEYBIND_LEFT:
+ case KEYBIND_RIGHT:
if (_menu->isVisible()) {
MenuItem *item = *_menu->getCurrent();
- /* change whether or not it's selected */
+ // change whether or not it's selected
item->setSelected(!item->isSelected());
if (item->isSelected())
@@ -61,21 +83,12 @@ bool ReagentsMenuController::keyPressed(int key) {
}
break;
- case Common::KEYCODE_RETURN:
+ case KEYBIND_INTERACT:
eventHandler->setControllerDone();
break;
default:
- return MenuController::keyPressed(key);
- }
-
- return true;
-}
-
-void ReagentsMenuController::keybinder(KeybindingAction action) {
- if (action == KEYBIND_ESCAPE) {
- _ingredients->revert();
- eventHandler->setControllerDone();
+ break;
}
}
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 0db4ee487b..bcd62b42c0 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -808,7 +808,7 @@ bool Debugger::cmdMixReagents(int argc, const char **argv) {
break;
int spell = choice - 'a';
- print("%s", g_spells->spellGetName(spell));
+ print("\n%s", g_spells->spellGetName(spell));
// ensure the mixtures for the spell isn't already maxed out
if (g_ultima->_saveGame->_mixtures[spell] == 99) {
Commit: 5b59b1045bdf1a4512121785cdaa1423cf515f24
https://github.com/scummvm/scummvm/commit/5b59b1045bdf1a4512121785cdaa1423cf515f24
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-08-18T19:39:04-07:00
Commit Message:
GLK: AGT: Removal of platform-specific define blocks
Changed paths:
engines/glk/agt/filename.cpp
engines/glk/agt/interface.cpp
diff --git a/engines/glk/agt/filename.cpp b/engines/glk/agt/filename.cpp
index f3e95533cf..fba5c4f41c 100644
--- a/engines/glk/agt/filename.cpp
+++ b/engines/glk/agt/filename.cpp
@@ -27,24 +27,6 @@ namespace AGT {
#ifdef force16
#undef int
-#endif
-
-#ifdef UNIX_IO
-#include <fcntl.h>
-#include <sys/stat.h> /* Needed only for file permission bits */
-
-#ifdef __STRICT_ANSI__
-int fileno(FILE *f);
-FILE *popen(char *s, char *how);
-int pclose(FILE *p);
-#endif
-
-#ifdef MSDOS16
-#include <io.h>
-#endif
-#endif /* UNIX_IO */
-
-#ifdef force16
#define int short
#endif
@@ -196,23 +178,7 @@ static int search_for_ext(const char *name, filetype base_ft,
return xlen;
}
}
-#ifdef UNIX_IO
- /* This is code to make the Unix/etc ports easier to use under
- tab-completing shells (which often complete "gamename._" or
- "gamename.ag_" since there are other files in the directory
- with the same root.) */
- assert(*pft == fNONE);
- if (name[len - 1] == '.') return 1;
- if (fnamecmp(name + len - 3, ".ag") == 0) {
- if (base_ft == fDA1 || base_ft == fAGX) *pft = fAGX;
- if (base_ft == fAGT) *pft = fAGT;
- }
- if (fnamecmp(name + len - 3, ".da") == 0) {
- if (base_ft == fDA1 || base_ft == fAGX) *pft = fDA1;
- if (base_ft == fAGT) *pft = fAGT;
- }
- if (*pft != fNONE) return 3;
-#endif
+
return 0;
}
@@ -323,27 +289,8 @@ fc_type init_file_context(const char *name, filetype ft) {
fc = (file_context_rec *)rmalloc(sizeof(file_context_rec));
fc->special = 0;
-#ifdef UNIX
- if (name[0] == '|') { /* Output pipe */
- name++;
- fc->special = 1;
- }
-#endif
-
fc->gamename = rstrdup(name);
-#ifdef UNIX
- x = strlen(fc->gamename);
- if (fc->gamename[x - 1] == '|') { /* Input pipe */
- fc->gamename[x - 1] = 0;
- fc->special |= 2;
- }
- if (fc->special) {
- fc->path = fc->shortname = fc->ext = NULL;
- return fc;
- }
-#endif
-
p = find_path_sep(fc->gamename);
if (p < 0)
fc->path = NULL;
@@ -426,27 +373,6 @@ void release_file_context(fc_type *pfc) {
/* Routines for Finding Files */
/*----------------------------------------------------------------------*/
-#ifdef UNIX
-/* This requires that no two sav/scr/log files be open at the same time. */
-static int pipecnt = 0;
-static FILE *pipelist[6];
-
-static genfile try_open_pipe(fc_type fc, filetype ft, rbool rw) {
- FILE *f;
-
- errno = 0;
- if (ft != fSAV && ft != fSCR && ft != fLOG) return NULL;
- if (rw && fc->special != 1) return NULL;
- if (!rw && fc->special != 2) return NULL;
- if (pipecnt >= 6) return NULL;
-
- f = popen(fc->gamename, rw ? "w" : "r"); /* Need to indicate this is a pipe */
- pipelist[pipecnt++] = f;
- return f;
-}
-#endif
-
-
static genfile try_open_file(const char *path, const char *root,
const char *ext, const char *how,
rbool nofix) {
@@ -463,12 +389,6 @@ static genfile findread(file_context_rec *fc, filetype ft) {
f = NULL;
-#ifdef UNIX
- if (fc->special) { /* It's a pipe */
- f = try_open_pipe(fc, ft, 0);
- return f;
- }
-#endif
if (ft == fAGT_STD) {
f = try_open_file(fc->path, AGTpSTD, "", filetype_info(ft, 0), 0);
return f;
@@ -517,17 +437,6 @@ genfile writeopen(fc_type fc, filetype ft,
*errstr = NULL;
name = NULL;
-#ifdef UNIX
- if (fc->special) { /* It's a pipe */
- f = try_open_pipe(fc, ft, 1);
- if (f == NULL && errno == 0) {
- *errstr = rstrdup("Invalid pipe request.");
- return f;
- }
- if (f == NULL) /* For error messages */
- name = rstrdup(fc->gamename);
- } else
-#endif
{
name = assemble_filename(FC(fc)->path, FC(fc)->shortname, extname[ft]);
f = fopen(name, filetype_info(ft, 1));
@@ -563,24 +472,12 @@ long varread(genfile f, void *buff, long recsize, long recnum, const char **errs
*errstr = NULL;
assert(f != NULL);
-#ifdef UNIX_IO
-#ifdef MSDOS16
- num = (unsigned int)read(fileno(f), buff, recsize * recnum);
- if (num == (unsigned int) - 1)
-#else
- num = read(fileno(f), buff, recsize * recnum);
- if (num == -1)
-#endif
- {
- *errstr = rstrdup(strerror(errno));
- return 0;
- }
-#else
+
num = fread(buff, recsize, recnum, f);
if (num != recnum)
*errstr = "varread";
num = num * recsize;
-#endif
+
return num;
}
@@ -596,47 +493,24 @@ rbool binread(genfile f, void *buff, long recsize, long recnum, const char **err
rbool binwrite(genfile f, void *buff, long recsize, long recnum, rbool ferr) {
assert(f != NULL);
-#ifdef UNIX_IO
- if (write(fileno(f), buff, recsize * recnum) == -1)
-#else
- if (fwrite(buff, recsize, recnum, f) != (size_t)recnum)
-#endif
- {
+
+ if (fwrite(buff, recsize, recnum, f) != (size_t)recnum) {
if (ferr) fatal("binwrite");
return 0;
}
return 1;
}
-#ifdef UNIX
-static rbool closepipe(genfile f) {
- int i;
- for (i = 0; i < pipecnt; i++)
- if (pipelist[i] == f) {
- pclose(f);
- for (; i < pipecnt - 1; i++)
- pipelist[i] = pipelist[i + 1];
- pipecnt--;
- return 1;
- }
- return 0;
-}
-#endif
-
void readclose(genfile f) {
assert(f != NULL);
-#ifdef UNIX
- if (closepipe(f)) return;
-#endif
+
fclose(f);
}
void writeclose(genfile f, file_id_type fileid) {
assert(f != NULL);
rfree(fileid);
-#ifdef UNIX
- if (closepipe(f)) return;
-#endif
+
fclose(f);
}
@@ -654,21 +528,12 @@ long binsize(genfile f)
long pos, leng;
assert(f != NULL);
-#ifdef UNIX_IO
- {
- long fd;
- fd = fileno(f);
- pos = lseek(fd, 0, SEEK_CUR);
- leng = lseek(fd, 0, SEEK_END);
- lseek(fd, pos, SEEK_SET);
- }
-#else
pos = ftell(f);
fseek(f, 0, SEEK_END);
leng = ftell(f);
fseek(f, pos, SEEK_SET);
-#endif
+
return leng;
}
diff --git a/engines/glk/agt/interface.cpp b/engines/glk/agt/interface.cpp
index 1e4debd7e0..818b43c5fb 100644
--- a/engines/glk/agt/interface.cpp
+++ b/engines/glk/agt/interface.cpp
@@ -35,25 +35,6 @@ namespace AGT {
/* --Some lower level file stuff */
/* --main() and command line parseing stuff */
-#ifdef _DOS
-#ifdef UNIX_IO
-#undef UNIX_IO
-#endif
-#endif
-
-#ifndef REPLACE_GETFILE
-#ifdef UNIX_IO
-#include <dirent.h>
-#endif
-#endif
-
-
-#ifdef UNIX
-/* Needed because we are compiling with ANSI set */
-FILE *popen(const char *, const char *);
-int pclose(FILE *);
-#endif
-
#ifndef REPLACE_BNW
/* #define DEBUG_BELLS_AND_WHISTLES */
@@ -170,12 +151,6 @@ static rbool savenl = 0;
static rbool needfill; /* Used for paragraph filling */
static rbool quotemode = 0;
-#ifdef UNIX
-static rbool ispipe[3] = {0, 0, 0}; /* script, log_in, log_out */
-#endif
-
-
-
void debugout(const char *s) {
int i;
@@ -720,97 +695,18 @@ void set_test_mode(fc_type fc) {
#ifndef REPLACE_GETFILE
-
-#ifdef UNIX_IO
-
-extern const char *extname[]; /* From filename.c */
-
-static rbool check_fname(char *name, filetype ext) {
- return 0 == strcmp(name + strlen(name) - strlen(extname[ext]), extname[ext]);
-}
-
-
-static void list_files(char *type, filetype ext) {
- DIR *currdir;
- struct dirent *entry;
- char **filelist;
- int filecnt, listsize;
- int maxleng; /* Longest filename; used for formatting */
- int i, j;
- int numcols, height;
-
- filelist = NULL;
- filecnt = listsize = 0;
- maxleng = 0;
- currdir = opendir(".");
- if (currdir == NULL) return; /* Nothing we can do except give up */
- do {
- entry = readdir(currdir);
- if (entry != NULL && check_fname(entry->d_name, ext)) {
- /* It has the right extension; add it to our list of files */
- if (filecnt >= listsize) {
- listsize += 5;
- filelist = rrealloc(filelist, listsize * sizeof(char *));
- }
- filelist[filecnt] = rstrdup(entry->d_name);
- i = strlen(entry->d_name);
- if (i > screen_width - 1) {
- filelist[filecnt][screen_width - 1] = 0;
- i = screen_width - 1;
- }
- if (i > maxleng) maxleng = i;
- filecnt++;
- }
- } while (entry != NULL);
- closedir(currdir);
- if (filecnt == 0) return; /* No files */
-
- numcols = (screen_width - 1) / (maxleng + 2); /* Two spaces between columns */
- if (numcols < 1)
- numcols = 1;
- height = (filecnt + numcols - 1) / numcols; /* Height, rounded up. */
-
- writeln("");
- writestr("Existing ");
- writestr(type);
- writestr("files:");
- for (i = 0; i < height; i++) {
- writeln("");
- for (j = 0; j < numcols; j++)
- if (i + j * height < filecnt) {
- if (maxleng + 2 <= screen_width - 1) writestr(" ");
- writestr(filelist[i + j * height]);
- padout(maxleng - strlen(filelist[i + j * height]));
- rfree(filelist[i + j * height]);
- }
- }
- writeln("");
- rfree(filelist);
-}
-#endif /* UNIX_IO */
-
-
-
-
/* This opens the file refered to by fname and returns it */
static genfile uf_open(fc_type fc, filetype ext, rbool rw) {
char *errstr;
genfile f;
if (rw) { /* Check to see if we are overwriting... */
-#ifdef UNIX
- if (fc->special)
- f = writeopen(fc, ext, NULL, &errstr);
- else
-#endif
- {
- if (fileexist(fc, ext) && ext != fSCR) {
- if (!yesno("This file already exists; overwrite?"))
- /* That is, DON'T overwrite */
- return badfile(ext);
- }
- f = writeopen(fc, ext, NULL, &errstr);
+ if (fileexist(fc, ext) && ext != fSCR) {
+ if (!yesno("This file already exists; overwrite?"))
+ /* That is, DON'T overwrite */
+ return badfile(ext);
}
+ f = writeopen(fc, ext, NULL, &errstr);
} else
f = readopen(fc, ext, &errstr);
if (errstr != NULL) writeln(errstr);
@@ -871,15 +767,9 @@ genfile get_user_file(int ft)
writeln("<INTERNAL ERROR: invalid file type>");
return badfile(fSAV);
}
-#ifdef UNIX_IO
- if (!rw) { /* List available files. */
- list_files(ftype, ext);
- ftype = NULL;
- } else
-#else
+
writestr(" ");
-#endif
- writestr("Enter ");
+ writestr("Enter ");
if (ftype != NULL) writestr(ftype);
writestr("file name");
if (def_fc != NULL) {
@@ -1076,11 +966,7 @@ static rbool setarg(char **optptr) {
}
#endif
-#ifdef UNIX
-#define fixcase(c) (c)
-#else
#define fixcase(c) tolower(c)
-#endif
#if 0
void parse_options(char *opt, char *next) {
@@ -1116,17 +1002,9 @@ void parse_options(char *opt, char *next) {
#ifndef REPLACE_MAIN
-#ifdef MSDOS
-extern rbool use_bios;
-#endif
-
-
int main(int argc, char *argv[]) {
int i;
char *gamefile;
-#ifdef MSDOS
- rbool biosvar = 0;
-#endif
set_default_options();
end_cmd_options = 0;
@@ -1134,11 +1012,6 @@ int main(int argc, char *argv[]) {
for (i = 1; i < argc; i++)
if (argv[i][0] == '-' && !end_cmd_options)
parse_options(argv[i] + 1, argv[i + 1]);
-#ifdef MSDOS /* For backward compatibility w/ original AGT interpreters */
- else if (argv[i][0] == '/' && tolower(argv[i][1]) == 'b'
- && argv[i][2] == 0)
- biosvar = 1;
-#endif
else if (gamefile == NULL)
gamefile = argv[i];
else fatal("Please specify only one game\n");
@@ -1151,9 +1024,7 @@ int main(int argc, char *argv[]) {
/* From this point on, MUST use writestr/writeln or may
cause problems w/ the interfaces on some platforms
that have to keep track of cursor position */
-#ifdef MSDOS
- use_bios = biosvar;
-#endif
+
run_game(init_file_context(gamefile, fDA1));
return EXIT_SUCCESS;
}
More information about the Scummvm-git-logs
mailing list