aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-09-27 22:43:00 -0700
committerPaul Gilbert2019-09-27 22:43:00 -0700
commitd39583300d3a85867a537158ebc6eff50c898733 (patch)
tree00001e73a5d06d5e1b3977f634ec316fa2395439 /engines/glk
parent772e60526f397349cb8f7be48a278d90477f61a7 (diff)
downloadscummvm-rg350-d39583300d3a85867a537158ebc6eff50c898733.tar.gz
scummvm-rg350-d39583300d3a85867a537158ebc6eff50c898733.tar.bz2
scummvm-rg350-d39583300d3a85867a537158ebc6eff50c898733.zip
GLK: ADRIFT: Removing unused code
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/adrift/scprotos.h1
-rw-r--r--engines/glk/adrift/sxfile.cpp21
-rw-r--r--engines/glk/adrift/sxmain.cpp164
-rw-r--r--engines/glk/adrift/sxprotos.h18
-rw-r--r--engines/glk/adrift/sxtester.cpp97
-rw-r--r--engines/glk/module.mk3
6 files changed, 13 insertions, 291 deletions
diff --git a/engines/glk/adrift/scprotos.h b/engines/glk/adrift/scprotos.h
index 5d39c54409..f137cad896 100644
--- a/engines/glk/adrift/scprotos.h
+++ b/engines/glk/adrift/scprotos.h
@@ -637,7 +637,6 @@ extern void run_quit(CONTEXT, sc_gameref_t game);
extern sc_bool run_is_running(sc_gameref_t game);
extern sc_bool run_has_completed(sc_gameref_t game);
extern sc_bool run_is_undo_available(sc_gameref_t game);
-extern void run_debug_trace(sc_bool flag);
extern void run_get_attributes(sc_gameref_t game,
const sc_char **game_name,
const sc_char **game_author,
diff --git a/engines/glk/adrift/sxfile.cpp b/engines/glk/adrift/sxfile.cpp
index f5df4008d8..992b93bb53 100644
--- a/engines/glk/adrift/sxfile.cpp
+++ b/engines/glk/adrift/sxfile.cpp
@@ -22,6 +22,7 @@
#include "glk/adrift/scare.h"
#include "glk/adrift/sxprotos.h"
+#include "common/textconsole.h"
namespace Glk {
namespace Adrift {
@@ -56,11 +57,11 @@ void *file_open_file_callback(sc_bool is_save) {
/* Detect any problems due to scripting limitations. */
if (stream->is_open) {
- scr_test_failed("File open error: %s",
+ error("File open error: %s",
"stream is in use (script limitation)");
return NULL;
} else if (is_save && stream->data) {
- scr_test_failed("File open error: %s",
+ error("File open error: %s",
"stream has not been read (script limitation)");
return NULL;
}
@@ -87,13 +88,13 @@ sc_int file_read_file_callback(void *opaque, sc_byte *buffer, sc_int length) {
/* Detect any problems with the callback parameters. */
if (stream != &scr_serialization_stream) {
- scr_test_failed("File read error: %s", "stream is invalid");
+ error("File read error: %s", "stream is invalid");
return 0;
} else if (!stream->is_open) {
- scr_test_failed("File read error: %s", "stream is not open");
+ error("File read error: %s", "stream is not open");
return 0;
} else if (stream->is_writable) {
- scr_test_failed("File read error: %s", "stream is not open for read");
+ error("File read error: %s", "stream is not open for read");
return 0;
}
@@ -111,13 +112,13 @@ void file_write_file_callback(void *opaque, const sc_byte *buffer, sc_int length
/* Detect any problems with the callback parameters. */
if (stream != &scr_serialization_stream) {
- scr_test_failed("File write error: %s", "stream is invalid");
+ error("File write error: %s", "stream is invalid");
return;
} else if (!stream->is_open) {
- scr_test_failed("File write error: %s", "stream is not open");
+ error("File write error: %s", "stream is not open");
return;
} else if (!stream->is_writable) {
- scr_test_failed("File write error: %s", "stream is not open for write");
+ error("File write error: %s", "stream is not open for write");
return;
}
@@ -133,10 +134,10 @@ void file_close_file_callback(void *opaque) {
/* Detect any problems with the callback parameters. */
if (stream != &scr_serialization_stream) {
- scr_test_failed("File close error: %s", "stream is invalid");
+ error("File close error: %s", "stream is invalid");
return;
} else if (!stream->is_open) {
- scr_test_failed("File close error: %s", "stream is not open");
+ error("File close error: %s", "stream is not open");
return;
}
diff --git a/engines/glk/adrift/sxmain.cpp b/engines/glk/adrift/sxmain.cpp
deleted file mode 100644
index 63ff12ea61..0000000000
--- a/engines/glk/adrift/sxmain.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "glk/adrift/scare.h"
-#include "glk/adrift/sxprotos.h"
-#include "common/textconsole.h"
-
-namespace Glk {
-namespace Adrift {
-
-/*
- * Module notes:
- *
- * o In order to validate all its arguments, this module creates and retains
- * a copy of every valid game encountered, only freeing them all at the end.
- * This could make it very memory-hungry when running a large number of
- * games and scripts. The alternative is to only create games as needed,
- * and free them once used, but it's nice to fully validate all command line
- * arguments first, and work afterwards, so for now that's what's done.
- *
- * o ...Alternatively, we could validate by creating the game, destroy it,
- * and then re-parse it later when running the test script. Unfortunately,
- * parsing an Adrift game can be lengthy (~seconds), so paying this price
- * twice isn't too attractive either.
- *
- * o For now, then, if running lots of test, run in batches of ten or so.
- */
-
-/*
- * main()
- *
- * Validate the command line, and each argument as a game to be run.
- * Execute scripts for each, and return with an error code if any test fails.
- */
-int glk_main(int argc, const char *argv[]) {
- const sc_char *const program = argv[0];
- sc_bool is_verbose = FALSE, is_tracing = FALSE;
- const sc_char *trace_flags;
- sx_test_descriptor_t *tests;
- sc_int count, index_, errors;
- assert(argc > 0 && argv);
-
- /* Get options and validate the command line. */
- if (argc > 1
- && (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "-vv") == 0)) {
- is_verbose = TRUE;
- is_tracing = (strcmp(argv[1], "-vv") == 0);
- argc--;
- argv++;
- }
-
- if (is_verbose) {
- sx_trace("--- %s Test Suite [Adrift %ld compatible]\n",
- sc_scare_version(), sc_scare_emulation());
- if (argc < 2)
- return EXIT_SUCCESS;
- } else if (argc < 2) {
- error("Usage: %s [-v | -vv] test [test...]\n", program);
- return EXIT_FAILURE;
- }
-
- /* Ensure that the interpreter is in the Latin1 locale, and stays there. */
- if (!sc_set_locale("Latin1")) {
- error("%s: failed to set locale\n", program);
- return EXIT_FAILURE;
- }
-
- /*
- * Force test reproducibility. Because game construction may use random
- * numbers, we also need to remember to reseed this before constructing
- * each game, and then again before running each.
- */
- sc_set_portable_random(TRUE);
-
- /* Set verbosity and tracing for other modules. */
- scr_set_verbose(is_verbose);
- stub_debug_trace(is_tracing);
- trace_flags = 0; // getenv("SC_TRACE_FLAGS");
- if (trace_flags)
- sc_set_trace_flags(strtoul(trace_flags, NULL, 0));
-
- /* Create an array of test descriptors large enough for all tests. */
- tests = (sx_test_descriptor_t *)sx_malloc((argc - 1) * sizeof(*tests));
-
- /* Validate each test argument by opening a game and script for it. */
- count = 0;
- for (index_ = 1; index_ < argc; index_++) {
- const sc_char *name;
- Common::SeekableReadStream *stream;
- sx_script script;
- sc_game game;
-
- name = argv[index_];
-
- script = sx_fopen(name, "scr", "r");
- if (!script) {
- error("%s: %s.scr: %s\n", program, name, "open");
- continue;
- }
-
- stream = sx_fopen(name, "taf", "rb");
- if (!stream) {
- error("%s: %s.taf: %s\n", program, name, "open");
- delete script;
- continue;
- }
-
- sc_reseed_random_sequence(1);
- game = sc_game_from_stream(stream);
- delete stream;
- if (!game) {
- error("%s: %s.taf: Unable to decode Adrift game\n", program, name);
- delete script;
- continue;
- }
-
- tests[count].name = name;
- tests[count].script = script;
- tests[count].game = game;
- count++;
- }
-
- /* Run the available tests and report results. */
- if (count > 0)
- errors = test_run_game_tests(tests, count, is_verbose);
- else
- errors = 1;
-
- /* Clean up allocations and opened files. */
- for (index_ = 0; index_ < count; index_++) {
- delete tests[index_].script;
- sc_free_game(tests[index_].game);
- }
- sx_free(tests);
-
- /* Report results overall. */
- warning("%s [%ld test%s, %ld error%s]\n",
- errors > 0 ? "FAIL" : "PASS",
- count, count == 1 ? "" : "s", errors, errors == 1 ? "" : "s");
-
- return errors > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-}
-
-} // End of namespace Adrift
-} // End of namespace Glk
diff --git a/engines/glk/adrift/sxprotos.h b/engines/glk/adrift/sxprotos.h
index 57ce5f392f..5ea3951775 100644
--- a/engines/glk/adrift/sxprotos.h
+++ b/engines/glk/adrift/sxprotos.h
@@ -72,18 +72,6 @@ extern Common::SeekableReadStream *sx_fopen(const sc_char *name,
extern sc_char *sx_trim_string(sc_char *string);
extern sc_char *sx_normalize_string(sc_char *string);
-/* OS stub hooks controller functions. */
-extern void stub_attach_handlers(sc_bool(*read_line)(sc_char *, sc_int),
- void (*print_string)(const sc_char *),
- void *(*open_file)(sc_bool),
- sc_int(*read_file)
- (void *, sc_byte *, sc_int),
- void (*write_file)
- (void *, const sc_byte *, sc_int),
- void (*close_file)(void *));
-extern void stub_detach_handlers(void);
-extern void stub_debug_trace(sc_bool flag);
-
/* Test controller function. */
extern sc_int test_run_game_tests(const sx_test_descriptor_t tests[],
sc_int count, sc_bool is_verbose);
@@ -92,10 +80,8 @@ extern sc_int test_run_game_tests(const sx_test_descriptor_t tests[],
extern sc_bool glob_match(const sc_char *pattern, const sc_char *string);
/* Script running and checking functions. */
-extern void scr_test_failed(const sc_char *format, const sc_char *string);
-extern void scr_set_verbose(sc_bool flag);
-extern void scr_start_script(sc_game game, Common::SeekableReadStream *script);
-extern sc_int scr_finalize_script(void);
+//extern void scr_test_failed(const sc_char *format, const sc_char *string);
+//extern void scr_set_verbose(sc_bool flag);
/* Serialization helper for script running and checking. */
extern void *file_open_file_callback(sc_bool is_save);
diff --git a/engines/glk/adrift/sxtester.cpp b/engines/glk/adrift/sxtester.cpp
deleted file mode 100644
index c0ea3368ae..0000000000
--- a/engines/glk/adrift/sxtester.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "glk/adrift/scare.h"
-#include "glk/adrift/sxprotos.h"
-
-namespace Glk {
-namespace Adrift {
-
-/*
- * test_run_game_script()
- *
- * Run the game using the given script. Returns the count of errors from
- * the script's monitoring.
- */
-static sc_int test_run_game_script(CONTEXT, sc_game game, sx_script script) {
- sc_int errors;
-
- /* Ensure completely repeatable random number sequences. */
- sc_reseed_random_sequence(1);
-
- /* Start interpreting the script stream. */
- scr_start_script(game, script);
- R0CALL1(sc_interpret_game, game);
-
- /* Wrap up the script interpreter and capture error count. */
- errors = scr_finalize_script();
- return errors;
-}
-
-
-/*
- * test_run_game_tests()
- *
- * Run each test in the given descriptor array, reporting the results and
- * accumulating an error count overall. Return the total error count.
- */
-sc_int test_run_game_tests(const sx_test_descriptor_t tests[], sc_int count, sc_bool is_verbose) {
- const sx_test_descriptor_t *test;
- sc_int errors;
- Context context;
- assert(tests);
-
- errors = 0;
-
- /* Execute each game in turn. */
- for (test = tests; test < tests + count; test++) {
- sc_int test_errors;
-
- if (is_verbose) {
- sx_trace("--- Running Test \"%s\" [\"%s\", by %s]...\n",
- test->name,
- sc_get_game_name(test->game),
- sc_get_game_author(test->game));
- }
-
- test_errors = test_run_game_script(context, test->game, test->script);
- errors += test_errors;
-
- if (is_verbose) {
- sx_trace("--- Test \"%s\": ", test->name);
- if (test_errors > 0)
- sx_trace("%s [%ld error%s]\n",
- "FAIL", test_errors, test_errors == 1 ? "" : "s");
- else
- sx_trace("%s\n", "PASS");
- } else
- sx_trace("%s", test_errors > 0 ? "F" : ".");
- //fflush (stdout);
- //fflush (stderr);
- }
- sx_trace("%s", is_verbose ? "" : "\n");
-
- return errors;
-}
-
-} // End of namespace Adrift
-} // End of namespace Glk
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 8727b9369f..dd63c77952 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -54,9 +54,6 @@ MODULE_OBJS := \
adrift/serialization.o \
adrift/sxfile.o \
adrift/sxglob.o \
- adrift/sxmain.o \
- adrift/sxscript.o \
- adrift/sxtester.o \
adrift/sxutils.o \
advsys/advsys.o \
advsys/detection.o \