2004-01-06 13:44:17 +00:00
|
|
|
/* Copyright (C) 1994-2004 Revolution Software Ltd
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RESMAN_H
|
|
|
|
#define RESMAN_H
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
#define MAX_res_files 20
|
|
|
|
|
2003-11-08 15:47:51 +00:00
|
|
|
class Sword2Engine;
|
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
struct Resource {
|
|
|
|
byte *ptr;
|
|
|
|
uint32 size;
|
|
|
|
uint32 refCount;
|
|
|
|
uint32 refTime;
|
|
|
|
};
|
|
|
|
|
2003-10-04 01:09:29 +00:00
|
|
|
class ResourceManager {
|
2003-09-26 10:07:18 +00:00
|
|
|
public:
|
2003-11-08 15:47:51 +00:00
|
|
|
ResourceManager(Sword2Engine *vm); // read in the config file
|
2003-11-03 07:47:42 +00:00
|
|
|
~ResourceManager(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *openResource(uint32 res, bool dump = false);
|
|
|
|
void closeResource(uint32 res);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
bool checkValid(uint32 res);
|
2003-09-30 09:27:27 +00:00
|
|
|
uint32 fetchLen(uint32 res);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
void expelOldResources(void);
|
|
|
|
|
|
|
|
void passTime(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// Prompts the user for the specified CD.
|
2003-09-30 09:27:27 +00:00
|
|
|
void getCd(int cd);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
int whichCd() {
|
|
|
|
return _curCd;
|
2003-09-26 10:07:18 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
void remove(int res);
|
|
|
|
|
2003-09-26 10:07:18 +00:00
|
|
|
// ----console commands
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
void printConsoleClusters(void);
|
2003-10-26 15:42:49 +00:00
|
|
|
void examine(int res);
|
|
|
|
void kill(int res);
|
|
|
|
void killAll(bool wantInfo);
|
|
|
|
void killAllObjects(bool wantInfo);
|
2003-09-30 09:27:27 +00:00
|
|
|
void removeAll(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
Resource *_resList;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
private:
|
2003-11-08 15:47:51 +00:00
|
|
|
Sword2Engine *_vm;
|
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
int _curCd;
|
|
|
|
uint32 _totalResFiles;
|
|
|
|
uint32 _totalClusters;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint32 _resTime;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// Gode generated res-id to res number/rel number conversion table
|
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint16 *_resConvTable;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
char _resourceFiles[MAX_res_files][20];
|
|
|
|
uint8 _cdTab[MAX_res_files]; // Location of each cluster.
|
2003-09-26 10:07:18 +00:00
|
|
|
};
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
#endif
|