From f6bb7a899d08c4d59ca24fca16dacffa777ad0bd Mon Sep 17 00:00:00 2001 From: Tyler Genter Date: Sun, 25 Jul 2010 22:16:23 -0700 Subject: [PATCH] redid set handling, again. did other stuff --- src/CMakeLists.txt | 5 +- src/Gtk/Main.cpp | 2 +- src/Makefile.mingw | 39 ----- src/card.cpp | 5 +- src/card.h | 2 + src/common.cpp | 16 -- src/common.h | 9 -- src/file.cpp | 12 +- src/file.h | 11 +- src/game.cpp | 38 +++-- src/game.h | 30 ++-- src/hotspot.cpp | 2 +- src/mohawk.h | 1 + src/name.cpp | 4 +- src/name.h | 2 +- src/script.cpp | 22 +-- src/set.cpp | 391 ++++++++++++++++++++++--------------------------- src/{Ini.h => set.h} | 48 +++--- src/stack.cpp | 60 +++----- src/stack.h | 64 ++++---- src/system/windows.cpp | 8 +- src/tbmp.cpp | 6 +- src/variables.cpp | 2 +- 23 files changed, 332 insertions(+), 447 deletions(-) delete mode 100644 src/Makefile.mingw rewrite src/set.cpp (78%) rename src/{Ini.h => set.h} (53%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7adeb47..a07ce41 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,9 +3,11 @@ set (RIVEN_SRC_FILES card.cpp common.cpp + dictionary.cpp file.cpp game.cpp hotspot.cpp + iniparser.cpp mohawk.cpp name.cpp plst.cpp @@ -15,8 +17,7 @@ set (RIVEN_SRC_FILES stack.cpp tbmp.cpp variables.cpp - iniparser.cpp - dictionary.cpp + system/linux.cpp ) diff --git a/src/Gtk/Main.cpp b/src/Gtk/Main.cpp index 913abab..1d2b768 100644 --- a/src/Gtk/Main.cpp +++ b/src/Gtk/Main.cpp @@ -44,7 +44,7 @@ int main (int argc, char *argv[]) { Gtk::GL::init(argc, argv); - riven::game::reset (); + riven::game::reset ("/home/tyler/riven-wahrk/sub.rvn"); Window window; diff --git a/src/Makefile.mingw b/src/Makefile.mingw deleted file mode 100644 index a7ba779..0000000 --- a/src/Makefile.mingw +++ /dev/null @@ -1,39 +0,0 @@ - -CPPFLAGS= -ggdb -Wall -I. -Iwin32/ -I- -DLIBCONFIG_STATIC -D_WIN32_WINNT=0x0501 -LDFLAGS= -ggdb -Lwin32/ -lopengl32 -lgdi32 -lglu32 -lComCtl32 -lconfig++32 #-Wl,-subsystem,windows - -CPP=g++ - -OBJS=Card.o\ - Common.o\ - File.o\ - Game.o\ - Hotspot.o\ - Mohawk.o\ - Name.o\ - Plst.o\ - Scene.o\ - Script.o\ - Stack.o\ - Tbmp.o\ - Twav.o\ - Variable.o\ - iniparser.o\ - dictionary.o\ - win32/GLee.o\ - win32/Main.o\ - win32/resource.o - - -all: riven-wahrk.exe - -riven-wahrk.exe: $(OBJS) - del $@ - $(CPP) -o $@ $^ $(LDFLAGS) - -win32/resource.o: win32/resource.rc - windres win32/resource.rc -o win32/resource.o - -clean: - del *.o win32\*.o riven-wahrk.exe - diff --git a/src/card.cpp b/src/card.cpp index 94ea29d..92b1093 100644 --- a/src/card.cpp +++ b/src/card.cpp @@ -1,6 +1,5 @@ /* - * * Riven-Wahrk - a reimplementation of the game Riven, by Cyan * Copyright (C) 2009-2010 Tyler Genter * @@ -16,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ #include @@ -27,6 +25,7 @@ using namespace riven; static std::vector old_cards; +card_t *card_t::current; card_t::card_t (int idIn) : @@ -39,7 +38,7 @@ card_t::card_t (int idIn) : std::cout << "opening new card " << id << "\n"; - game::card = this; + current = this; script.run_handler (handler_t::CardLoad); script.run_handler (handler_t::DisplayUpdate); diff --git a/src/card.h b/src/card.h index 13401ef..cafd2f5 100644 --- a/src/card.h +++ b/src/card.h @@ -62,6 +62,8 @@ public: hotspot.mouseUp (); }; + static card_t *current; + }; } diff --git a/src/common.cpp b/src/common.cpp index 2b3967c..a45731e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -19,7 +19,6 @@ * */ -#include #include #include @@ -48,21 +47,6 @@ uint16_t big_to_native (uint16_t in) { } -// TODO: this needs to be case-insensitive -bool isFilePresent (const std::string &folder, const std::string &file) { - std::string temp; - temp = folder; - if ((folder.at(folder.length()-1) != '/') && - (file.at(0) != '/')) - temp += "/"; - temp += file; - FILE *handle = fopen (temp.c_str(), "r"); - if (handle == NULL) - return false; - fclose (handle); - return true; -} - } diff --git a/src/common.h b/src/common.h index adb26fb..0b1bf69 100644 --- a/src/common.h +++ b/src/common.h @@ -45,15 +45,6 @@ namespace riven { uint32_t big_to_native (uint32_t i); uint16_t big_to_native (uint16_t in); -#if 0 -inline int getFileSize (int handle) { - struct stat buf; - fstat (handle, &buf); - return buf.st_size; -} - -#endif - inline std::string toLower (const std::string &in) { std::string result = in; for (unsigned int i=0; i::iterator iter = stack->mohawks.begin (); - for (; iter != stack->mohawks.end(); ++iter) { + std::vector::iterator iter = group->mohawks.begin (); + for (; iter != group->mohawks.end(); ++iter) { try { data = (*iter)->get_file (type, id); if (data) { @@ -46,6 +46,8 @@ void file_t::load (stack_t *stack, uint32_t type, int id) { } catch (...) {} } + data = NULL; + } diff --git a/src/file.h b/src/file.h index dec53be..ab27c58 100644 --- a/src/file.h +++ b/src/file.h @@ -1,6 +1,5 @@ /* - * * Riven-Wahrk - a reimplementation of the game Riven, by Cyan * Copyright (C) 2009-2010 Tyler Genter * @@ -16,7 +15,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ #ifndef RIVEN_FILE_H @@ -26,6 +24,7 @@ #include "common.h" #include "mohawk.h" // for resource_t +#include "stack.h" namespace riven { @@ -39,11 +38,11 @@ class file_t { uint8_t *data; int size; - void load (stack_t *stack, uint32_t type, int id); + void load (mhk_group_t *group, uint32_t type, int id); public: - file_t (stack_t *stack, uint32_t type, int id) { - load (stack, type, id); + file_t (mhk_group_t *group, uint32_t type, int id) { + load (group, type, id); } file_t (uint32_t type, int id) { @@ -83,7 +82,7 @@ public: return big_to_native (*(uint32_t*) (data + addr)); } - uint8_t *readCharArray (int addr) { + uint8_t *readCharArray (int count, int addr) { return data + addr; } diff --git a/src/game.cpp b/src/game.cpp index c0c7438..7fe1dd7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -19,23 +19,30 @@ * */ -#include #include -#include +#include "card.h" #include "game.h" +#include "set.h" +#include "stack.h" +#include "variables.h" using namespace riven; Coor game::mouseCoor; -bool game::insideCard; -bool game::ignoreMouseUp; +namespace { -card_t *game::card; -bool game::zipMode; +// this is true when we are currently running a script inside a card +bool insideCard; -void game::reset () { +bool ignoreMouseUp; + +bool zipMode; + +} + +void game::reset (const std::string &save_game) { zipMode = false; insideCard = false; @@ -43,12 +50,12 @@ void game::reset () { stack_t::choose_set (); - stack_t::load_game (stack_t::JSPIT); + stack_t::load_stack (stack_t::JSPIT); variables::change_stack (); - variables::load_game ("sub.rvn"); + variables::load_game ("/home/tyler/riven-wahrk/src/sub.rvn"); - card = new card_t (527); + card_t::current = new card_t (527); mouseCoor.y = mouseCoor.x = 0; } @@ -59,22 +66,23 @@ void game::mouseMove (const Coor &coorIn) { mouseCoor = coorIn; if (insideCard) return; insideCard = true; - card->mouseMove (mouseCoor); + card_t::current->mouseMove (mouseCoor); insideCard = false; } void game::mouseDown () { if (insideCard) return; insideCard = true; - card_t *old = card; - card->mouseDown (); - if (old != card) + card_t *old = card_t::current; + card_t::current->mouseDown (); + if (old != card_t::current) // we are at a new card, so ignore the next time we get a mouse // up signal. ignoreMouseUp = true; insideCard = false; } + void game::mouseUp () { if (insideCard) return; if (ignoreMouseUp) { @@ -82,7 +90,7 @@ void game::mouseUp () { return; } insideCard = true; - card->mouseUp (); + card_t::current->mouseUp (); insideCard = false; } diff --git a/src/game.h b/src/game.h index f9118b3..bf8817e 100644 --- a/src/game.h +++ b/src/game.h @@ -19,19 +19,13 @@ * */ -#ifndef _GAME_H_ -#define _GAME_H_ +#ifndef RIVEN_GAME_H +#define RIVEN_GAME_H #include #include "common.h" -#include "stack.h" -#include "variables.h" -#include "card.h" - -//#include "scene.h" -//#include "sound.h" namespace riven { @@ -39,18 +33,18 @@ namespace game { extern Coor mouseCoor; -// this is true when we are currently running a script inside -// a card -extern bool insideCard; -extern bool ignoreMouseUp; - -extern card_t *card; - -// true when we are in zip mode -extern bool zipMode; - +/** + * Starts a new game, at the beginning. + */ void reset (); +/** + * Starts a game based on a save file. + * + * @param std::string Path to the save file to be loaded. + */ +void reset (const std::string &save_game); + void mouseMove (const Coor &coorIn); void mouseDown (); void mouseUp (); diff --git a/src/hotspot.cpp b/src/hotspot.cpp index 28540d4..1596298 100644 --- a/src/hotspot.cpp +++ b/src/hotspot.cpp @@ -71,7 +71,7 @@ void hotspot_t::findRecord (int16_t x, int16_t y) { do { iter--; if (iter->second.isInside(x,y)) - if ((!iter->second.isZip || (iter->second.isZip && game::zipMode)) && + if ((!iter->second.isZip /* || (iter->second.isZip && game::zipMode ) FIXME*/) && iter->second.isEnabled) { current = &(iter->second); return; diff --git a/src/mohawk.h b/src/mohawk.h index f125f37..dfd1548 100644 --- a/src/mohawk.h +++ b/src/mohawk.h @@ -85,6 +85,7 @@ public: }; +// Represents a single *.mhk file. class mohawk_t { diff --git a/src/name.cpp b/src/name.cpp index a34d89b..7174b23 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -28,7 +28,9 @@ using namespace riven; std::string name_t::get_string (int n) { - std::string result = std::string ((const char*)readCharArray (2 + count*4 + readUShort (2 + n*2))); + int offset = 2 + count*4 + readUShort (2 + n*2); + + std::string result = std::string ((const char*)readCharArray (get_size() - offset, offset)); // for some reason, there is 0xbd at the beginning and end of some strings std::string::size_type loc; diff --git a/src/name.h b/src/name.h index be9ab66..5a58fb3 100644 --- a/src/name.h +++ b/src/name.h @@ -35,7 +35,7 @@ class name_t : public file_t { uint16_t count; public: - name_t (stack_t *stack, int id) : file_t (stack, resource_t::NAME, id) { + name_t (mhk_group_t *stack, int id) : file_t (stack, resource_t::NAME, id) { count = readUShort (0); } diff --git a/src/script.cpp b/src/script.cpp index 55c4c48..55eb218 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -24,8 +24,10 @@ #include "common.h" -#include "script.h" +#include "card.h" #include "game.h" +#include "script.h" +#include "variables.h" using namespace riven; @@ -123,8 +125,8 @@ void handler_t::runCmd (uint16_t *cmd) { case 2: if (cmd[1] == 1) { std::cout << "going to card " << cmd[2] << std::endl; - game::card->close (); - game::card = new card_t (cmd[2]); + card_t::current->close (); + card_t::current = new card_t (cmd[2]); } break; case 3: @@ -139,11 +141,11 @@ void handler_t::runCmd (uint16_t *cmd) { break; case 9: std::cout << "cmd enable hotspot\n"; - game::card->hotspot.enable (cmd[2]); + card_t::current->hotspot.enable (cmd[2]); break; case 10: std::cout << "cmd disable hotspot\n"; - game::card->hotspot.disable (cmd[2]); + card_t::current->hotspot.disable (cmd[2]); break; case 13: std::cout << "cmd set mouse cursor\n"; @@ -161,9 +163,9 @@ void handler_t::runCmd (uint16_t *cmd) { break; case 19: std::cout << "cmd reload card\n"; - temp = game::card->id; - game::card->close (); - game::card = new card_t(temp); + temp = card_t::current->id; + card_t::current->close (); + card_t::current = new card_t(temp); break; case 20: std::cout << "cmd disable screen update\n"; @@ -186,14 +188,14 @@ void handler_t::runCmd (uint16_t *cmd) { break; case 39: std::cout << "cmd activate plst\n"; - game::card->plst.draw (cmd[2]); + card_t::current->plst.draw (cmd[2]); break; case 40: std::cout << "cmd activate slst\n"; break; case 43: std::cout << "cmd activate blst\n"; - game::card->hotspot.activateBlst (cmd[2]); + card_t::current->hotspot.activateBlst (cmd[2]); break; case 44: std::cout << "cmd activate flst\n"; diff --git a/src/set.cpp b/src/set.cpp dissimilarity index 78% index edbf8b7..5599368 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -1,219 +1,172 @@ - -/* - * Riven-Wahrk - a reimplementation of the game Riven, by Cyan - * Copyright (C) 2010 Tyler Genter - * - * 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 3 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, see . - */ - -#include - -#include "gui.h" -#include "set.h" -#include "system.h" - -using namespace riven; - -void set_t::nada () { -} - -bool set_t::disk_belong (const std::string &path) { - - for (unsigned i=0; i files; - files.reserve (2); - for (unsigned i=0; ifile_count; i++) { - if (disk->files[i].id == name) - files.push_back (disk->files[i].fs_path); - } - - return new stack_t (files); - -} - - -set_t::disk_t *set_t::load_disk (stack_t::name_t name) { - - // find out which disk we want - disk_t *disk; - for (unsigned i=0; ifiles[0].fs_path[0] != 0) - // if one file is found, all files on the disk are found - return disk; - - gui::prompt_disk (std::string (disk->name)); - - } - -} - - -void set_t::scan_disks () { - - std::vector disks; - list_disks (disks); - - std::vector::iterator iter; - for (iter = disks.begin(); iter != disks.end(); ++iter) { - for (unsigned i=0; i + * + * 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 3 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, see . + */ + +#include + +#include "set.h" +#include "stack.h" +#include "system.h" + +namespace riven { + +struct set_t { + + struct stack_t { + + struct file_t { + // which disk this is + unsigned char disk; + // true if this file needs to be copied to the hard drive + unsigned char install; + // the path to the file, from the root of the disk + const char *path; + }; + + unsigned which; + file_t *files; + file_t *sound; + }; + + stack_t *stacks; + +}; + + +#define make_set(stacks) { \ +(set_t::stack_t[]) { \ +stacks \ +{ \ +0, \ +(set_t::stack_t::file_t*) NULL, \ +(set_t::stack_t::file_t*) NULL \ +}} \ +}, + + +#define make_stack(which, files, waves) { \ +which, \ +(set_t::stack_t::file_t[]) { \ +files \ +{0, 0, (char*) NULL }}, \ +(set_t::stack_t::file_t[]) { \ +waves \ +{0, 0, (char*) NULL }} \ +}, + +#define make_file(disk,install,path) { disk, install, path }, + +static set_t *sets = (set_t[]) { + + +make_set ( + + make_stack( stack_t::ASPIT, + make_file(1, 0, "Data/a_Data.MHK"), + make_file(1, 0, "ASSETS1/a_Sounds.MHK")) + make_stack( stack_t::BSPIT, + make_file(1, 0, "Data/b_Data.MHK"), + make_file(1, 0, "ASSETS1/b_Sounds.MHK")) + make_stack (stack_t::GSPIT, + make_file(1, 0, "Data/g_Data.MHK"), + make_file(1, 0, "ASSETS1/g_Sounds.MHK")) + make_stack( stack_t::JSPIT, + make_file(1, 0, "Data/j_Data1.MHK") + make_file(1, 0, "Data/j_Data2.MHK"), + make_file(1, 0, "ASSETS1/j_Sounds.MHK")) + make_stack( stack_t::OSPIT, + make_file(1, 0, "Data/o_Data.MHK"), + make_file(1, 0, "ASSETS1/o_Sounds.MHK")) + make_stack( stack_t::PSPIT, + make_file(1, 0, "Data/p_Data.MHK"), + make_file(1, 0, "ASSETS1/p_Sounds.MHK")) + make_stack( stack_t::RSPIT, + make_file(1, 0, "Data/r_Data.MHK"), + make_file(1, 0, "ASSETS1/r_Sounds.MHK")) + make_stack( stack_t::TSPIT, + make_file(1, 0, "Data/t_Data1.MHK") + make_file(1, 0, "Data/t_Data2.MHK"), + make_file(1, 0, "Data/t_Sounds.MHK")) +) + + + +{ + (set_t::stack_t*) NULL +}}; + + +static set_t *current_set; + + +void set::init () { + + current_set = &sets[0]; + +} + + +void set::get_stack_files ( + unsigned which_stack, + std::vector &files) { + + // find the set_t::stack_t + set_t::stack_t *stack = current_set->stacks; + + do { + if (stack->which == which_stack) + break; + stack++; + + } while (stack->files); + + std::vector disks; + list_disks (disks); + files.clear (); + + for (int i=0; ifiles; file->path; file++) { + + std::string path = find_file (disks[i], std::string (file->path)); + if (path.length() == 0) + continue; + + files.push_back (path); + + } + + if (files.size() != 0) + return; + + } + +} + + +void set::get_stack_sound_files (unsigned stack, std::vector &files) { + + +} + + + + +} + diff --git a/src/Ini.h b/src/set.h similarity index 53% rename from src/Ini.h rename to src/set.h index 635a673..7059c75 100644 --- a/src/Ini.h +++ b/src/set.h @@ -1,8 +1,7 @@ /* - * * Riven-Wahrk - a reimplementation of the game Riven, by Cyan - * Copyright (C) 2009-2010 Tyler Genter + * Copyright (C) 2010 Tyler Genter * * 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 @@ -16,46 +15,35 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ -#ifndef INI_H -#define INI_H - -#include -#include "iniparser.h" +#ifndef RIVEN_SET_H +#define RIVEN_SET_H -class Ini { +#include +#include - dictionary *dic; +namespace riven { -public: - Ini (string file) { - dic = iniparser_load (file.c_str ()); - } - ~Ini () { - iniparser_freedict (dic); - } +namespace set { - string getString (string key) { - return string (iniparser_getstring (dic, key.c_str(), "")); - } +// does everything to ensure that get_stack_files will find the actual +// mohawks. Prompts the user to insert a disk, installs the files, etc. +void init (); - int getInt (string key) { - return iniparser_getint (dic, key.c_str(), 0); - } - double getDouble (string key) { - return iniparser_getdouble (dic, key.c_str (), 0); - } +// returns a vector of the paths for all the mohawks for this stack. +// The will be accessible, and directly opened by fopen, etc +void get_stack_files (unsigned stack, std::vector &files); - bool getBool (string key) { - return (iniparser_getboolean (dic, key.c_str (), 0) == 1); - } +// the same, but for all the sound mohawks for this stack +void get_stack_sound_files (unsigned stack, std::vector &files); -}; +} +} #endif + diff --git a/src/stack.cpp b/src/stack.cpp index 0676fd9..b67f527 100644 --- a/src/stack.cpp +++ b/src/stack.cpp @@ -1,5 +1,6 @@ /* + * * Riven-Wahrk - a reimplementation of the game Riven, by Cyan * Copyright (C) 2009-2010 Tyler Genter * @@ -15,71 +16,56 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * */ -#include -#include -#include - - +#include "mohawk.h" #include "set.h" #include "stack.h" -#include "mohawk.h" using namespace riven; -stack_t *riven::game_stack; -static set_t *set; +stack_t *riven::game_stack = NULL; -stack_t::stack_t (std::vector &files) { - - mohawks.reserve (files.size()); +void mhk_group_t::load (std::vector &files) { std::vector::iterator iter; - for (iter = files.begin(); iter != files.end(); ++iter) { - mohawks.push_back (new mohawk_t (*iter)); - } -} - -stack_t::stack_t (const std::string &mohawk) { + mohawks.reserve (files.size ()); - mohawks.push_back (new mohawk_t (mohawk)); + for (iter = files.begin(); iter != files.end(); ++iter) + mohawks.push_back (new mohawk_t (*iter)); } +mhk_group_t::mhk_group_t (const std::string &path) { + + mohawks.push_back (new mohawk_t (path)); -#if 0 -std::string Stack::getFileLoc (uint32_t type, int id, uint32_t &offset) { - offset = mohawk1->getFileLoc (type, id); - if (offset) - return mohawk1->fileName; - if (mohawk2->getFileLoc (type, id)) { - offset = mohawk2->getFileLoc (type, id); - if (offset) - return mohawk2->fileName; - } - offset = 0; - return ""; } -#endif +void stack_t::choose_set () { + game_stack = new stack_t; + + set::init (); +} -void riven::stack_t::load_game (name_t name) { - game_stack = set->load_stack (name); +void stack_t::load_stack (unsigned which) { -} + std::vector files; + set::get_stack_files (which, files); -void riven::stack_t::choose_set () { + for (int i=0; iwhich = which; + game_stack->load (files); } - diff --git a/src/stack.h b/src/stack.h index bcb421a..378ecec 100644 --- a/src/stack.h +++ b/src/stack.h @@ -2,7 +2,7 @@ /* * * Riven-Wahrk - a reimplementation of the game Riven, by Cyan - * Copyright (C) 2009-2010 Tyler Genter + * Copyright (C) 2010 Tyler Genter * * 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 @@ -22,63 +22,69 @@ #ifndef RIVEN_STACK_H #define RIVEN_STACK_H -#include #include -#include "common.h" +#include +#include + +/* + * + * Manages a stack (each island is its own stack) + * + * a - main menu + * b - boiler/lake + * g - garden island - has large map/where you locate the domes + * j - has the community, lake in the middle, submarine, etc + * o - ghens office - the sky looks red, your in the cage + * p - prison, where whats-her-name is trapped + * r - rebels, the beehive thing in the middle of the lake + * t - temple, telescope, lake in the building + * + */ namespace riven { class mohawk_t; +class file_t; -// riven is divided up into stacks (one corresponds to each island), -// with each stack being split up into different resource types (image, -// script, movie) and those split up into different numbers. +class mhk_group_t { + friend class file_t; -// this exception will be thrown when we need to change the stack. -class change_stack { - uint32_t stack, hi, lo; + std::vector mohawks; public: - change_stack (uint16_t stackIn, uint16_t hiIn, uint16_t loIn) : - stack (stackIn), - hi (hiIn), - lo (loIn) { - } - void handle (); + mhk_group_t (const std::string &path); + mhk_group_t () {} + + void load (std::vector &files); }; -class stack_t { - friend class file_t; - std::vector mohawks; +class stack_t : public mhk_group_t { -public: + unsigned which; - // Takes a list of mohawks that make up this stack. The list must be - // null terminated. - stack_t (std::vector &files); - stack_t (const std::string &mohawk); +public: - enum name_t { ASPIT=0, BSPIT, GSPIT, JSPIT, OSPIT, PSPIT, RSPIT, TSPIT }; + mhk_group_t *sound_group (); - static void load_game (name_t name); + enum { ASPIT, BSPIT, GSPIT, JSPIT, OSPIT, PSPIT, RSPIT, TSPIT }; static void choose_set (); -}; + static void load_stack (unsigned which); -// a pointer to the stack that is loaded for the current island -extern stack_t *game_stack; +}; +extern stack_t *game_stack; } - #endif + diff --git a/src/system/windows.cpp b/src/system/windows.cpp index 3be10da..a3ee54c 100644 --- a/src/system/windows.cpp +++ b/src/system/windows.cpp @@ -74,7 +74,13 @@ void riven::list_disks (std::vector &disks) { std::string riven::find_file (const std::string &dir, const std::string &path) { - return dir + "\\" + path; + std::string res = dir + "\\" + path; + FILE *file = fopen (res.c_str(), "r"); + if (!file) + return ""; + + fclose (file) + return res; } diff --git a/src/tbmp.cpp b/src/tbmp.cpp index 024ce60..03634be 100644 --- a/src/tbmp.cpp +++ b/src/tbmp.cpp @@ -49,7 +49,7 @@ tbmp_t::tbmp_t (int id) : decompress (); std::cout << "compressed\n"; } else { - mapColorTable (readCharArray (784)); + mapColorTable (readCharArray (get_size() - 784, 784)); } } @@ -57,7 +57,7 @@ tbmp_t::tbmp_t (int id) : void tbmp_t::decompress () { uint8_t *data; - data = readCharArray (784); + data = readCharArray (get_size() - 784, 784); uint8_t *image; image = new uint8_t[bytesPerRow*height]; @@ -242,7 +242,7 @@ done: void tbmp_t::mapColorTable (uint8_t *data) { bitmap = new uint8_t[width*height*3]; - uint8_t *table = readCharArray (12); + uint8_t *table = readCharArray (256, 12); for (int i=0; i