redid set handling, again. did other stuff
[riven-wahrk.git] / src / set.cpp
blob55993689b8c370531f9c9ae7b399e5e0c387e1b5
2 /*
3 * Riven-Wahrk - a reimplementation of the game Riven, by Cyan
4 * Copyright (C) 2010 Tyler Genter <tylergenter@gmail.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <stdio.h>
22 #include "set.h"
23 #include "stack.h"
24 #include "system.h"
26 namespace riven {
28 struct set_t {
30 struct stack_t {
32 struct file_t {
33 // which disk this is
34 unsigned char disk;
35 // true if this file needs to be copied to the hard drive
36 unsigned char install;
37 // the path to the file, from the root of the disk
38 const char *path;
41 unsigned which;
42 file_t *files;
43 file_t *sound;
46 stack_t *stacks;
51 #define make_set(stacks) { \
52 (set_t::stack_t[]) { \
53 stacks \
54 { \
55 0, \
56 (set_t::stack_t::file_t*) NULL, \
57 (set_t::stack_t::file_t*) NULL \
58 }} \
62 #define make_stack(which, files, waves) { \
63 which, \
64 (set_t::stack_t::file_t[]) { \
65 files \
66 {0, 0, (char*) NULL }}, \
67 (set_t::stack_t::file_t[]) { \
68 waves \
69 {0, 0, (char*) NULL }} \
72 #define make_file(disk,install,path) { disk, install, path },
74 static set_t *sets = (set_t[]) {
77 make_set (
79 make_stack( stack_t::ASPIT,
80 make_file(1, 0, "Data/a_Data.MHK"),
81 make_file(1, 0, "ASSETS1/a_Sounds.MHK"))
82 make_stack( stack_t::BSPIT,
83 make_file(1, 0, "Data/b_Data.MHK"),
84 make_file(1, 0, "ASSETS1/b_Sounds.MHK"))
85 make_stack (stack_t::GSPIT,
86 make_file(1, 0, "Data/g_Data.MHK"),
87 make_file(1, 0, "ASSETS1/g_Sounds.MHK"))
88 make_stack( stack_t::JSPIT,
89 make_file(1, 0, "Data/j_Data1.MHK")
90 make_file(1, 0, "Data/j_Data2.MHK"),
91 make_file(1, 0, "ASSETS1/j_Sounds.MHK"))
92 make_stack( stack_t::OSPIT,
93 make_file(1, 0, "Data/o_Data.MHK"),
94 make_file(1, 0, "ASSETS1/o_Sounds.MHK"))
95 make_stack( stack_t::PSPIT,
96 make_file(1, 0, "Data/p_Data.MHK"),
97 make_file(1, 0, "ASSETS1/p_Sounds.MHK"))
98 make_stack( stack_t::RSPIT,
99 make_file(1, 0, "Data/r_Data.MHK"),
100 make_file(1, 0, "ASSETS1/r_Sounds.MHK"))
101 make_stack( stack_t::TSPIT,
102 make_file(1, 0, "Data/t_Data1.MHK")
103 make_file(1, 0, "Data/t_Data2.MHK"),
104 make_file(1, 0, "Data/t_Sounds.MHK"))
110 (set_t::stack_t*) NULL
114 static set_t *current_set;
117 void set::init () {
119 current_set = &sets[0];
124 void set::get_stack_files (
125 unsigned which_stack,
126 std::vector<std::string> &files) {
128 // find the set_t::stack_t
129 set_t::stack_t *stack = current_set->stacks;
131 do {
132 if (stack->which == which_stack)
133 break;
134 stack++;
136 } while (stack->files);
138 std::vector<std::string> disks;
139 list_disks (disks);
140 files.clear ();
142 for (int i=0; i<disks.size(); i++) {
145 for (set_t::stack_t::file_t *file = stack->files; file->path; file++) {
147 std::string path = find_file (disks[i], std::string (file->path));
148 if (path.length() == 0)
149 continue;
151 files.push_back (path);
155 if (files.size() != 0)
156 return;
163 void set::get_stack_sound_files (unsigned stack, std::vector<std::string> &files) {