From 5196ae1cd49b879f0497c5ad863dfa6dfebe61c7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Apr 2019 15:27:52 +1000 Subject: GLK: GLULXE: init_dispatch wasn't being called --- engines/glk/glulxe/glkop.cpp | 5 ----- engines/glk/glulxe/glulxe.cpp | 39 ++++++++++++++++++++++----------------- engines/glk/glulxe/glulxe.h | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'engines/glk/glulxe') diff --git a/engines/glk/glulxe/glkop.cpp b/engines/glk/glulxe/glkop.cpp index 2595a870b1..68e60c7bec 100644 --- a/engines/glk/glulxe/glkop.cpp +++ b/engines/glk/glulxe/glkop.cpp @@ -91,11 +91,6 @@ void Glulxe::glkopInit() { bool Glulxe::init_dispatch() { int ix; - /* What with one thing and another, this *could* be called more than - once. We only need to allocate the tables once. */ - if (classes) - return true; - /* Set up the game-ID hook. (This is ifdeffed because not all Glk libraries have this call.) */ #ifdef GI_DISPA_GAME_ID_AVAILABLE diff --git a/engines/glk/glulxe/glulxe.cpp b/engines/glk/glulxe/glulxe.cpp index 617bcb08c8..5251b30d46 100644 --- a/engines/glk/glulxe/glulxe.cpp +++ b/engines/glk/glulxe/glulxe.cpp @@ -30,24 +30,26 @@ namespace Glulxe { Glulxe *g_vm; Glulxe::Glulxe(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc), _random("glulxe"), - vm_exited_cleanly(false), gamefile_start(0), gamefile_len(0), memmap(nullptr), stack(nullptr), - ramstart(0), endgamefile(0), origendmem(0), stacksize(0), startfuncaddr(0), checksum(0), - stackptr(0), frameptr(0), pc(0), prevpc(0), origstringtable(0), stringtable(0), valstackbase(0), - localsbase(0), endmem(0), protectstart(0), protectend(0), - stream_char_handler(nullptr), stream_unichar_handler(nullptr), - // main - library_autorestore_hook(nullptr), - // accel - classes_table(0), indiv_prop_start(0), class_metaclass(0), object_metaclass(0), - routine_metaclass(0), string_metaclass(0), self(0), num_attr_bytes(0), cpv__start(0), - accelentries(nullptr), - // heap - heap_start(0), alloc_count(0), heap_head(nullptr), heap_tail(nullptr), - // serial - max_undo_level(8), undo_chain_size(0), undo_chain_num(0), undo_chain(nullptr), ramcache(nullptr), - // string - iosys_mode(0), iosys_rock(0), tablecache_valid(false), glkio_unichar_han_ptr(nullptr) { + vm_exited_cleanly(false), gamefile_start(0), gamefile_len(0), memmap(nullptr), stack(nullptr), + ramstart(0), endgamefile(0), origendmem(0), stacksize(0), startfuncaddr(0), checksum(0), + stackptr(0), frameptr(0), pc(0), prevpc(0), origstringtable(0), stringtable(0), valstackbase(0), + localsbase(0), endmem(0), protectstart(0), protectend(0), + stream_char_handler(nullptr), stream_unichar_handler(nullptr), + // main + library_autorestore_hook(nullptr), + // accel + classes_table(0), indiv_prop_start(0), class_metaclass(0), object_metaclass(0), + routine_metaclass(0), string_metaclass(0), self(0), num_attr_bytes(0), cpv__start(0), + accelentries(nullptr), + // heap + heap_start(0), alloc_count(0), heap_head(nullptr), heap_tail(nullptr), + // serial + max_undo_level(8), undo_chain_size(0), undo_chain_num(0), undo_chain(nullptr), ramcache(nullptr), + // string + iosys_mode(0), iosys_rock(0), tablecache_valid(false), glkio_unichar_han_ptr(nullptr) { g_vm = this; + + glkopInit(); } void Glulxe::runGame() { @@ -55,6 +57,9 @@ void Glulxe::runGame() { return; setup_vm(); + if (!init_dispatch()) + return; + if (library_autorestore_hook) library_autorestore_hook(); diff --git a/engines/glk/glulxe/glulxe.h b/engines/glk/glulxe/glulxe.h index cdb3735bb7..b5f13dc492 100644 --- a/engines/glk/glulxe/glulxe.h +++ b/engines/glk/glulxe/glulxe.h @@ -719,7 +719,7 @@ public: _random.setSeed(seed); } inline uint glulx_random() { - return _random.getRandomNumber(0xffffffff); + return _random.getRandomNumber(0xfffffff); } void glulx_sort(void *addr, int count, int size, int(*comparefunc)(const void *p1, const void *p2)); -- cgit v1.2.3