[Scummvm-cvs-logs] CVS: residual model.cpp,1.12,1.13 model.h,1.4,1.5 registry.cpp,1.5,1.6 registry.h,1.1,1.2 resource.cpp,1.9,1.10 resource.h,1.5,1.6 scene.cpp,1.18,1.19 scene.h,1.11,1.12
Pawel Kolodziejski
aquadran at users.sourceforge.net
Tue Feb 24 14:59:00 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.104,1.105 player_mod.cpp,2.14,2.15 player_v2.cpp,2.46,2.47 scummvm.cpp,2.587,2.588
- Next message: [Scummvm-cvs-logs] CVS: scummvm/backends/sdl build.rules,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13522
Modified Files:
model.cpp model.h registry.cpp registry.h resource.cpp
resource.h scene.cpp scene.h
Log Message:
update copyright date, some formating stuff, rest later
Index: model.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/model.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- model.cpp 12 Dec 2003 08:39:07 -0000 1.12
+++ model.cpp 24 Feb 2004 22:43:32 -0000 1.13
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -28,130 +28,125 @@
#include "screen.h"
Model::Model(const char *filename, const char *data, int len,
- const CMap &cmap) : Resource(filename)
[...1204 lines suppressed...]
- glBegin(GL_POLYGON);
- for (int i = 0; i < numVertices_; i++) {
- glNormal3fv(vertNormals + 3 * vertices_[i]);
- if (texVertices_ != NULL)
- glTexCoord2fv(textureVerts + 2 * texVertices_[i]);
- glVertex3fv(vertices + 3 * vertices_[i]);
- }
- glEnd();
+void Model::Face::draw(float *vertices, float *vertNormals, float *textureVerts) const {
+ material_->select();
+ glNormal3fv(normal_.coords_);
+ glBegin(GL_POLYGON);
+ for (int i = 0; i < numVertices_; i++) {
+ glNormal3fv(vertNormals + 3 * vertices_[i]);
+ if (texVertices_ != NULL)
+ glTexCoord2fv(textureVerts + 2 * texVertices_[i]);
+ glVertex3fv(vertices + 3 * vertices_[i]);
+ }
+ glEnd();
}
Index: model.h
===================================================================
RCS file: /cvsroot/scummvm/residual/model.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- model.h 5 Oct 2003 17:45:46 -0000 1.4
+++ model.h 24 Feb 2004 22:43:32 -0000 1.5
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -29,99 +29,99 @@
class Model : public Resource {
public:
- // Construct a 3D model from the given data.
- Model(const char *filename, const char *data, int len, const CMap &cmap);
- void loadBinary(const char *data, const CMap &cmap);
- void loadText(TextSplitter &ts, const CMap &cmap);
+ // Construct a 3D model from the given data.
+ Model(const char *filename, const char *data, int len, const CMap &cmap);
+ void loadBinary(const char *data, const CMap &cmap);
+ void loadText(TextSplitter &ts, const CMap &cmap);
- void draw() const;
+ void draw() const;
- ~Model();
+ ~Model();
- struct Geoset;
- struct Mesh;
- struct HierNode {
- void loadBinary(const char *&data, HierNode *hierNodes, const Geoset &g);
- void draw() const;
- void addChild(HierNode *child);
- void removeChild(HierNode *child);
- void setMatrix(Matrix4 matrix);
- void update();
+ struct Geoset;
+ struct Mesh;
+ struct HierNode {
+ void loadBinary(const char *&data, HierNode *hierNodes, const Geoset &g);
+ void draw() const;
+ void addChild(HierNode *child);
+ void removeChild(HierNode *child);
+ void setMatrix(Matrix4 matrix);
+ void update();
- char name_[64];
- Mesh *mesh_;
- int flags_, type_;
- int depth_, numChildren_;
- HierNode *parent_, *child_, *sibling_;
- Vector3d pos_, pivot_;
- float pitch_, yaw_, roll_;
- Vector3d animPos_;
- float animPitch_, animYaw_, animRoll_;
- bool meshVisible_, hierVisible_;
- int priority_, totalWeight_;
- Matrix4 matrix_;
- Matrix4 localMatrix_;
- Matrix4 pivotMatrix;
- };
+ char name_[64];
+ Mesh *mesh_;
+ int flags_, type_;
+ int depth_, numChildren_;
+ HierNode *parent_, *child_, *sibling_;
+ Vector3d pos_, pivot_;
+ float pitch_, yaw_, roll_;
+ Vector3d animPos_;
+ float animPitch_, animYaw_, animRoll_;
+ bool meshVisible_, hierVisible_;
+ int priority_, totalWeight_;
+ Matrix4 matrix_;
+ Matrix4 localMatrix_;
+ Matrix4 pivotMatrix;
+ };
- HierNode *copyHierarchy();
- int numNodes() const { return numHierNodes_; }
+ HierNode *copyHierarchy();
+ int numNodes() const { return numHierNodes_; }
private:
- struct Face {
- void loadBinary(const char *&data, ResPtr<Material> *materials);
- void draw(float *vertices, float *vertNormals, float *textureVerts) const;
- ~Face();
+ struct Face {
+ void loadBinary(const char *&data, ResPtr<Material> *materials);
+ void draw(float *vertices, float *vertNormals, float *textureVerts) const;
+ ~Face();
- Material *material_;
- int type_, geo_, light_, tex_;
- float extraLight_;
- int numVertices_;
- int *vertices_, *texVertices_;
- Vector3d normal_;
- };
+ Material *material_;
+ int type_, geo_, light_, tex_;
+ float extraLight_;
+ int numVertices_;
+ int *vertices_, *texVertices_;
+ Vector3d normal_;
+ };
- struct Mesh {
- void loadBinary(const char *&data, ResPtr<Material> *materials);
- void loadText(TextSplitter &ts, ResPtr<Material> *materials);
- void draw() const;
- void update();
- ~Mesh();
+ struct Mesh {
+ void loadBinary(const char *&data, ResPtr<Material> *materials);
+ void loadText(TextSplitter &ts, ResPtr<Material> *materials);
+ void draw() const;
+ void update();
+ ~Mesh();
- char name_[32];
- float radius_;
- int shadow_, geometryMode_, lightingMode_, textureMode_;
+ char name_[32];
+ float radius_;
+ int shadow_, geometryMode_, lightingMode_, textureMode_;
- int numVertices_;
- float *vertices_; // sets of 3
- float *verticesI_;
- float *vertNormals_; // sets of 3
+ int numVertices_;
+ float *vertices_; // sets of 3
+ float *verticesI_;
+ float *vertNormals_; // sets of 3
- int numTextureVerts_;
- float *textureVerts_; // sets of 2
+ int numTextureVerts_;
+ float *textureVerts_; // sets of 2
- int numFaces_;
- Face *faces_;
- Matrix4 matrix_;
- };
+ int numFaces_;
+ Face *faces_;
+ Matrix4 matrix_;
+ };
- struct Geoset {
- void loadBinary(const char *&data, ResPtr<Material> *materials);
- void loadText(TextSplitter &ts, ResPtr<Material> *materials);
- ~Geoset();
+ struct Geoset {
+ void loadBinary(const char *&data, ResPtr<Material> *materials);
+ void loadText(TextSplitter &ts, ResPtr<Material> *materials);
+ ~Geoset();
- int numMeshes_;
- Mesh *meshes_;
- };
+ int numMeshes_;
+ Mesh *meshes_;
+ };
- int numMaterials_;
- ResPtr<Material> *materials_;
- Vector3d insertOffset_;
- int numGeosets_;
- Geoset *geosets_;
- float radius_;
- int numHierNodes_;
- HierNode *rootHierNode_;
+ int numMaterials_;
+ ResPtr<Material> *materials_;
+ Vector3d insertOffset_;
+ int numGeosets_;
+ Geoset *geosets_;
+ float radius_;
+ int numHierNodes_;
+ HierNode *rootHierNode_;
};
#endif
Index: registry.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/registry.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- registry.cpp 24 Aug 2003 17:56:03 -0000 1.5
+++ registry.cpp 24 Feb 2004 22:43:32 -0000 1.6
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -21,75 +21,76 @@
#include <cstdlib>
Registry::Registry() : dirty_(false) {
- #ifdef WIN32
- std::string filename = "residual.ini";
- #else
- std::string filename = std::string(std::getenv("HOME")) + "/.residualrc";
- #endif
+#ifdef WIN32
+ std::string filename = "residual.ini";
+#else
+ std::string filename = std::string(std::getenv("HOME")) + "/.residualrc";
+#endif
- std::FILE *f = fopen(filename.c_str(), "r");
- if (f != NULL) {
- char line[1024];
- while (!feof(f) && fgets(line, sizeof(line), f) != NULL) {
- char *equals = std::strchr(line, '=');
- char *newline = std::strchr(line, '\n');
- if (newline != NULL)
- *newline = '\0';
- if (equals != NULL) {
- std::string key = std::string(line, equals - line);
- std::string val = std::string(equals + 1);
- settings_[key] = val;
- }
- }
- std::fclose(f);
- }
+ std::FILE *f = fopen(filename.c_str(), "r");
+ if (f != NULL) {
+ char line[1024];
+ while (!feof(f) && fgets(line, sizeof(line), f) != NULL) {
+ char *equals = std::strchr(line, '=');
+ char *newline = std::strchr(line, '\n');
+ if (newline != NULL)
+ *newline = '\0';
+ if (equals != NULL) {
+ std::string key = std::string(line, equals - line);
+ std::string val = std::string(equals + 1);
+ settings_[key] = val;
+ }
+ }
+ std::fclose(f);
+ }
}
Registry *Registry::instance_ = NULL;
Registry *Registry::instance() {
- if (instance_ == NULL)
- instance_ = new Registry;
- return instance_;
+ if (instance_ == NULL)
+ instance_ = new Registry;
+ return instance_;
}
const char *Registry::get(const char *key) const {
- group::const_iterator i = settings_.find(key);
- if (i == settings_.end())
- return NULL;
- else
- return i->second.c_str();
+ group::const_iterator i = settings_.find(key);
+ if (i == settings_.end())
+ return NULL;
+ else
+ return i->second.c_str();
}
void Registry::set(const char *key, const char *val) {
- // Hack: Don't save these, so we can run in good_times mode
- // without new games being bogus.
- if (strstr(key, "GrimLastSet") || strstr(key, "GrimMannyState"))
- return;
+ // Hack: Don't save these, so we can run in good_times mode
+ // without new games being bogus.
+ if (strstr(key, "GrimLastSet") || strstr(key, "GrimMannyState"))
+ return;
- settings_[key] = val;
- dirty_ = true;
+ settings_[key] = val;
+ dirty_ = true;
}
void Registry::save() {
- if (! dirty_)
- return;
+ if (! dirty_)
+ return;
- #ifdef WIN32
- std::string filename = "residual.ini";
- #else
- std::string filename = std::string(std::getenv("HOME")) + "/.residualrc";
- #endif
+#ifdef WIN32
+ std::string filename = "residual.ini";
+#else
+ std::string filename = std::string(std::getenv("HOME")) + "/.residualrc";
+#endif
- std::FILE *f = std::fopen(filename.c_str(), "w");
- if (f == NULL) {
- warning("Could not open registry file %s for writing\n",
- filename.c_str());
- return;
- }
+ std::FILE *f = std::fopen(filename.c_str(), "w");
+ if (f == NULL) {
+ warning("Could not open registry file %s for writing\n",
+ filename.c_str());
+ return;
+ }
- for (group::iterator i = settings_.begin(); i != settings_.end(); i++)
- std::fprintf(f, "%s=%s\n", i->first.c_str(), i->second.c_str());
- std::fclose(f);
- dirty_ = false;
+ for (group::iterator i = settings_.begin(); i != settings_.end(); i++)
+ std::fprintf(f, "%s=%s\n", i->first.c_str(), i->second.c_str());
+
+ std::fclose(f);
+ dirty_ = false;
}
Index: registry.h
===================================================================
RCS file: /cvsroot/scummvm/residual/registry.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- registry.h 15 Aug 2003 19:41:26 -0000 1.1
+++ registry.h 24 Feb 2004 22:43:32 -0000 1.2
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -23,21 +23,21 @@
class Registry {
public:
- static Registry *instance();
+ static Registry *instance();
- const char * get(const char *key) const;
- void set(const char *key, const char *val);
- void save();
+ const char * get(const char *key) const;
+ void set(const char *key, const char *val);
+ void save();
private:
- Registry();
- ~Registry() { }
+ Registry();
+ ~Registry() { }
- static Registry *instance_;
+ static Registry *instance_;
- typedef std::map<std::string, std::string> group;
- group settings_;
- bool dirty_;
+ typedef std::map<std::string, std::string> group;
+ group settings_;
+ bool dirty_;
};
#endif
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- resource.cpp 13 Dec 2003 11:03:42 -0000 1.9
+++ resource.cpp 24 Feb 2004 22:43:32 -0000 1.10
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,7 @@
#include <algorithm>
static void makeLower(std::string& s) {
- std::transform(s.begin(), s.end(), s.begin(), tolower);
+ std::transform(s.begin(), s.end(), s.begin(), tolower);
}
ResourceLoader *ResourceLoader::instance_ = NULL;
@@ -95,162 +95,161 @@
}
const Lab *ResourceLoader::findFile(const char *filename) const {
- for (LabList::const_iterator i = labs_.begin(); i != labs_.end(); i++)
- if ((*i)->fileExists(filename))
- return *i;
- return NULL;
+ for (LabList::const_iterator i = labs_.begin(); i != labs_.end(); i++)
+ if ((*i)->fileExists(filename))
+ return *i;
+ return NULL;
}
bool ResourceLoader::fileExists(const char *filename) const {
- return findFile(filename) != NULL;
+ return findFile(filename) != NULL;
}
Block *ResourceLoader::getFileBlock(const char *filename) const {
- const Lab *l = findFile(filename);
- if (l == NULL)
- return NULL;
- else
- return l->getFileBlock(filename);
+ const Lab *l = findFile(filename);
+ if (l == NULL)
+ return NULL;
+ else
+ return l->getFileBlock(filename);
}
std::FILE *ResourceLoader::openNewStream(const char *filename) const {
- const Lab *l = findFile(filename);
+ const Lab *l = findFile(filename);
- if (l == NULL)
- return NULL;
- else
- return l->openNewStream(filename);
+ if (l == NULL)
+ return NULL;
+ else
+ return l->openNewStream(filename);
}
int ResourceLoader::fileLength(const char *filename) const {
- const Lab *l = findFile(filename);
- if (l == NULL)
- return 0;
- else
- return l->fileLength(filename);
+ const Lab *l = findFile(filename);
+ if (l == NULL)
+ return 0;
+ else
+ return l->fileLength(filename);
}
Bitmap *ResourceLoader::loadBitmap(const char *filename) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end()) {
- return dynamic_cast<Bitmap *>(i->second);
- }
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end()) {
+ return dynamic_cast<Bitmap *>(i->second);
+ }
- Block *b = getFileBlock(filename);
- if (b == NULL) { // Grim sometimes asks for non-existant bitmaps (eg, ha_overhead)
- warning("Could not find bitmap %s\n", filename);
- return NULL;
- }
+ Block *b = getFileBlock(filename);
+ if (b == NULL) { // Grim sometimes asks for non-existant bitmaps (eg, ha_overhead)
+ warning("Could not find bitmap %s\n", filename);
+ return NULL;
+}
- Bitmap *result = new Bitmap(filename, b->data(), b->len());
- delete b;
- cache_[fname] = result;
- return result;
+Bitmap *result = new Bitmap(filename, b->data(), b->len());
+ delete b;
+ cache_[fname] = result;
+ return result;
}
CMap *ResourceLoader::loadColormap(const char *filename) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end()) {
- return dynamic_cast<CMap *>(i->second);
- }
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end()) {
+ return dynamic_cast<CMap *>(i->second);
+ }
- Block *b = getFileBlock(filename);
- if (b == NULL)
- error("Could not find colormap %s\n", filename);
- CMap *result = new CMap(filename, b->data(), b->len());
- delete b;
- cache_[fname] = result;
- return result;
+ Block *b = getFileBlock(filename);
+ if (b == NULL)
+ error("Could not find colormap %s\n", filename);
+ CMap *result = new CMap(filename, b->data(), b->len());
+ delete b;
+ cache_[fname] = result;
+ return result;
}
Costume *ResourceLoader::loadCostume(const char *filename, Costume *prevCost) {
- std::string fname = filename;
- makeLower(fname);
- Block *b = getFileBlock(filename);
- if (b == NULL)
- error("Could not find costume %s\n", filename);
- Costume *result = new Costume(filename, b->data(), b->len(), prevCost);
- delete b;
- return result;
+ std::string fname = filename;
+ makeLower(fname);
+ Block *b = getFileBlock(filename);
+ if (b == NULL)
+ error("Could not find costume %s\n", filename);
+ Costume *result = new Costume(filename, b->data(), b->len(), prevCost);
+ delete b;
+ return result;
}
KeyframeAnim *ResourceLoader::loadKeyframe(const char *filename) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end()) {
- return dynamic_cast<KeyframeAnim *>(i->second);
- }
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end()) {
+ return dynamic_cast<KeyframeAnim *>(i->second);
+ }
- Block *b = getFileBlock(filename);
- if (b == NULL)
- error("Could not find keyframe file %s\n", filename);
- KeyframeAnim *result = new KeyframeAnim(filename, b->data(), b->len());
- delete b;
- cache_[fname] = result;
- return result;
+ Block *b = getFileBlock(filename);
+ if (b == NULL)
+ error("Could not find keyframe file %s\n", filename);
+ KeyframeAnim *result = new KeyframeAnim(filename, b->data(), b->len());
+ delete b;
+ cache_[fname] = result;
+ return result;
}
-Material *ResourceLoader::loadMaterial(const char *filename,
- const CMap &c) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end()) {
- return dynamic_cast<Material *>(i->second);
- }
+Material *ResourceLoader::loadMaterial(const char *filename, const CMap &c) {
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end()) {
+ return dynamic_cast<Material *>(i->second);
+ }
- Block *b = getFileBlock(filename);
- if (b == NULL)
- error("Could not find material %s\n", filename);
- Material *result = new Material(filename, b->data(), b->len(), c);
- delete b;
- cache_[fname] = result;
- return result;
+ Block *b = getFileBlock(filename);
+ if (b == NULL)
+ error("Could not find material %s\n", filename);
+ Material *result = new Material(filename, b->data(), b->len(), c);
+ delete b;
+ cache_[fname] = result;
+ return result;
}
Model *ResourceLoader::loadModel(const char *filename, const CMap &c) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end()) {
- return dynamic_cast<Model *>(i->second);
- }
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end()) {
+ return dynamic_cast<Model *>(i->second);
+ }
- Block *b = getFileBlock(filename);
- if (b == NULL)
- error("Could not find model %s\n", filename);
- Model *result = new Model(filename, b->data(), b->len(), c);
- delete b;
- cache_[fname] = result;
- return result;
+ Block *b = getFileBlock(filename);
+ if (b == NULL)
+ error("Could not find model %s\n", filename);
+ Model *result = new Model(filename, b->data(), b->len(), c);
+ delete b;
+ cache_[fname] = result;
+ return result;
}
Sound *ResourceLoader::loadSound(const char *filename) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end()) {
- return dynamic_cast<Sound *>(i->second);
- }
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end()) {
+ return dynamic_cast<Sound *>(i->second);
+ }
- Block *b = getFileBlock(filename);
- if (b == NULL)
- return NULL;
- Sound *result = new Sound(filename, b->data(), b->len());
- delete b;
- cache_[fname] = result;
- return result;
+ Block *b = getFileBlock(filename);
+ if (b == NULL)
+ return NULL;
+ Sound *result = new Sound(filename, b->data(), b->len());
+ delete b;
+ cache_[fname] = result;
+ return result;
}
void ResourceLoader::uncache(const char *filename) {
- std::string fname = filename;
- makeLower(fname);
- cache_type::iterator i = cache_.find(fname);
- if (i != cache_.end())
- cache_.erase(i);
+ std::string fname = filename;
+ makeLower(fname);
+ cache_type::iterator i = cache_.find(fname);
+ if (i != cache_.end())
+ cache_.erase(i);
}
Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- resource.h 21 Feb 2004 15:20:01 -0000 1.5
+++ resource.h 24 Feb 2004 22:43:32 -0000 1.6
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -33,99 +33,98 @@
class Resource {
public:
- Resource(const char *filename) :
- fname_(filename), ref_(0), luaRef_(false) { }
- Resource(const Resource &r) : fname_(r.fname_), ref_(0), luaRef_(false)
- { }
- virtual ~Resource() { }
- void ref() { ref_++; }
- void deref();
- const char *filename() const { return fname_.c_str(); }
+ Resource(const char *filename) :
+ fname_(filename), ref_(0), luaRef_(false) { }
+ Resource(const Resource &r) : fname_(r.fname_), ref_(0), luaRef_(false) {}
+ virtual ~Resource() { }
+ void ref() { ref_++; }
+ void deref();
+ const char *filename() const { return fname_.c_str(); }
- void luaRef() { if (! luaRef_) { ref(); luaRef_ = true; } }
- void luaGc() { if (luaRef_) { luaRef_ = false; deref(); } }
+ void luaRef() { if (! luaRef_) { ref(); luaRef_ = true; } }
+ void luaGc() { if (luaRef_) { luaRef_ = false; deref(); } }
private:
- std::string fname_;
- int ref_;
- bool luaRef_;
+ std::string fname_;
+ int ref_;
+ bool luaRef_;
};
template <class T>
class ResPtr {
public:
- ResPtr() { ptr_ = NULL; }
- ResPtr(const ResPtr &p) { ptr_ = p.ptr_; if (ptr_ != NULL) ptr_->ref(); }
- ResPtr(T* ptr) { ptr_ = ptr; if (ptr_ != NULL) ptr_->ref(); }
- operator T*() { return ptr_; }
- T& operator *() { return *ptr_; }
- T* operator ->() { return ptr_; }
- ResPtr& operator =(T* ptr) {
- if (ptr_ == ptr) return *this;
- if (ptr_ != NULL) ptr_->deref();
- ptr_ = ptr;
- if (ptr_ != NULL) ptr_->ref();
- return *this;
- }
- ResPtr& operator =(const ResPtr& p) {
- if (this == &p || ptr_ == p.ptr_) return *this;
- if (ptr_ != NULL) ptr_->deref();
- ptr_ = p.ptr_;
- if (ptr_ != NULL) ptr_->ref();
- return *this;
- }
- ~ResPtr() { if (ptr_ != NULL) ptr_->deref(); }
+ ResPtr() { ptr_ = NULL; }
+ ResPtr(const ResPtr &p) { ptr_ = p.ptr_; if (ptr_ != NULL) ptr_->ref(); }
+ ResPtr(T* ptr) { ptr_ = ptr; if (ptr_ != NULL) ptr_->ref(); }
+ operator T*() { return ptr_; }
+ T& operator *() { return *ptr_; }
+ T* operator ->() { return ptr_; }
+ ResPtr& operator =(T* ptr) {
+ if (ptr_ == ptr) return *this;
+ if (ptr_ != NULL) ptr_->deref();
+ ptr_ = ptr;
+ if (ptr_ != NULL) ptr_->ref();
+ return *this;
+ }
+ ResPtr& operator =(const ResPtr& p) {
+ if (this == &p || ptr_ == p.ptr_) return *this;
+ if (ptr_ != NULL) ptr_->deref();
+ ptr_ = p.ptr_;
+ if (ptr_ != NULL) ptr_->ref();
+ return *this;
+ }
+ ~ResPtr() { if (ptr_ != NULL) ptr_->deref(); }
private:
- T* ptr_;
-};
+ T* ptr_;
+ };
class ResourceLoader {
public:
- bool fileExists(const char *filename) const;
- Block *getFileBlock(const char *filename) const;
- std::FILE *openNewStream(const char *filename) const;
- int fileLength(const char *filename) const;
+ bool fileExists(const char *filename) const;
+ Block *getFileBlock(const char *filename) const;
+ std::FILE *openNewStream(const char *filename) const;
+ int fileLength(const char *filename) const;
- static ResourceLoader *instance() {
- if (instance_ == NULL)
- instance_ = new ResourceLoader;
- return instance_;
- }
+ static ResourceLoader *instance() {
+ if (instance_ == NULL)
+ instance_ = new ResourceLoader;
+ return instance_;
+ }
- Bitmap *loadBitmap(const char *fname);
- CMap *loadColormap(const char *fname);
- Costume *loadCostume(const char *fname, Costume *prevCost);
- KeyframeAnim *loadKeyframe(const char *fname);
- Material *loadMaterial(const char *fname, const CMap &c);
- Model *loadModel(const char *fname, const CMap &c);
- Sound *loadSound(const char *fname);
- void uncache(const char *fname);
+ Bitmap *loadBitmap(const char *fname);
+ CMap *loadColormap(const char *fname);
+ Costume *loadCostume(const char *fname, Costume *prevCost);
+ KeyframeAnim *loadKeyframe(const char *fname);
+ Material *loadMaterial(const char *fname, const CMap &c);
+ Model *loadModel(const char *fname, const CMap &c);
+ Sound *loadSound(const char *fname);
+ void uncache(const char *fname);
private:
- ResourceLoader();
- ResourceLoader(const ResourceLoader &);
- ~ResourceLoader();
+ ResourceLoader();
+ ResourceLoader(const ResourceLoader &);
+ ~ResourceLoader();
- static ResourceLoader *instance_;
+ static ResourceLoader *instance_;
- typedef std::list<Lab *> LabList;
- LabList labs_;
+ typedef std::list<Lab *> LabList;
+ LabList labs_;
- const Lab *findFile(const char *filename) const;
+ const Lab *findFile(const char *filename) const;
- typedef std::map<std::string, Resource *> cache_type;
- cache_type cache_;
+ typedef std::map<std::string, Resource *> cache_type;
+ cache_type cache_;
- // Shut up pointless g++ warning
- friend class dummy;
+ // Shut up pointless g++ warning
+ friend class dummy;
};
inline void Resource::deref() {
- if (--ref_ == 0) {
- ResourceLoader::instance()->uncache(fname_.c_str());
- delete this;
- }
+ if (--ref_ == 0) {
+ ResourceLoader::instance()->uncache(fname_.c_str());
+ delete this;
+ }
}
#endif
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- scene.cpp 29 Jan 2004 13:03:07 -0000 1.18
+++ scene.cpp 24 Feb 2004 22:43:32 -0000 1.19
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -29,127 +29,126 @@
#include "driver_gl.h"
Scene::Scene(const char *name, const char *buf, int len) :
- name_(name) {
- TextSplitter ts(buf, len);
- char tempBuf[256];
+ name_(name) {
+ TextSplitter ts(buf, len);
+ char tempBuf[256];
- ts.expectString("section: colormaps");
- ts.scanString(" numcolormaps %d", 1, &numCmaps_);
- cmaps_ = new ResPtr<CMap>[numCmaps_];
- char cmap_name[256];
- for (int i = 0; i < numCmaps_; i++) {
- ts.scanString(" colormap %256s", 1, cmap_name);
- cmaps_[i] = ResourceLoader::instance()->loadColormap(cmap_name);
- }
+ ts.expectString("section: colormaps");
+ ts.scanString(" numcolormaps %d", 1, &numCmaps_);
+ cmaps_ = new ResPtr<CMap>[numCmaps_];
+ char cmap_name[256];
+ for (int i = 0; i < numCmaps_; i++) {
+ ts.scanString(" colormap %256s", 1, cmap_name);
+ cmaps_[i] = ResourceLoader::instance()->loadColormap(cmap_name);
+ }
- ts.expectString("section: setups");
- ts.scanString(" numsetups %d", 1, &numSetups_);
- setups_ = new Setup[numSetups_];
- for (int i = 0; i < numSetups_; i++)
- setups_[i].load(ts);
- currSetup_ = setups_;
+ ts.expectString("section: setups");
+ ts.scanString(" numsetups %d", 1, &numSetups_);
+ setups_ = new Setup[numSetups_];
+ for (int i = 0; i < numSetups_; i++)
+ setups_[i].load(ts);
+ currSetup_ = setups_;
- numSectors_ = -1;
- numLights_ = -1;
- lights_ = NULL;
- sectors_ = NULL;
- // Lights are optional
- if (ts.eof())
- return;
+ numSectors_ = -1;
+ numLights_ = -1;
+ lights_ = NULL;
+ sectors_ = NULL;
+ // Lights are optional
+ if (ts.eof())
+ return;
- ts.expectString("section: lights");
- ts.scanString(" numlights %d", 1, &numLights_);
- lights_ = new Light[numLights_];
- for (int i = 0; i < numLights_; i++)
- lights_[i].load(ts);
+ ts.expectString("section: lights");
+ ts.scanString(" numlights %d", 1, &numLights_);
+ lights_ = new Light[numLights_];
+ for (int i = 0; i < numLights_; i++)
+ lights_[i].load(ts);
- // Calculate the number of sectors
- ts.expectString("section: sectors");
- if (ts.eof()) // Sectors are optional, but section: doesn't seem to be
- return;
+ // Calculate the number of sectors
+ ts.expectString("section: sectors");
+ if (ts.eof()) // Sectors are optional, but section: doesn't seem to be
+ return;
- // Sector NAMES can be null, but ts doesn't seem flexible enough to allow this
- if (strlen(ts.currentLine()) > strlen(" sector"))
- ts.scanString(" sector %256s", 1, tempBuf);
- else {
- ts.nextLine();
- strcpy(tempBuf, "");
- }
+ // Sector NAMES can be null, but ts doesn't seem flexible enough to allow this
+ if (strlen(ts.currentLine()) > strlen(" sector"))
+ ts.scanString(" sector %256s", 1, tempBuf);
+ else {
+ ts.nextLine();
+ strcpy(tempBuf, "");
+ }
- ts.scanString(" id %d", 1, &numSectors_);
- sectors_ = new Sector[numSectors_];
- // FIXME: This would be nicer if we could rewind the textsplitter
- // stream...
- sectors_[0].load0(ts, tempBuf, numSectors_);
- for (int i = 1; i < numSectors_; i++)
- sectors_[i].load(ts);
+ ts.scanString(" id %d", 1, &numSectors_);
+ sectors_ = new Sector[numSectors_];
+ // FIXME: This would be nicer if we could rewind the textsplitter
+ // stream
+ sectors_[0].load0(ts, tempBuf, numSectors_);
+ for (int i = 1; i < numSectors_; i++)
+ sectors_[i].load(ts);
}
Scene::~Scene() {
- delete [] cmaps_;
- delete [] setups_;
- if (lights_)
- delete [] lights_;
- if (sectors_)
- delete [] sectors_;
+ delete [] cmaps_;
+ delete [] setups_;
+ if (lights_)
+ delete [] lights_;
+ if (sectors_)
+ delete [] sectors_;
}
void Scene::Setup::load(TextSplitter &ts) {
- char buf[256];
+ char buf[256];
- ts.scanString(" setup %256s", 1, buf);
- name_ = buf;
+ ts.scanString(" setup %256s", 1, buf);
+ name_ = buf;
- ts.scanString(" background %256s", 1, buf);
- bkgnd_bm_ = ResourceLoader::instance()->loadBitmap(buf);
+ ts.scanString(" background %256s", 1, buf);
+ bkgnd_bm_ = ResourceLoader::instance()->loadBitmap(buf);
- // ZBuffer is optional
- if (!ts.checkString("zbuffer")) {
- bkgnd_zbm_ = NULL;
- } else {
- ts.scanString(" zbuffer %256s", 1, buf);
- bkgnd_zbm_ = ResourceLoader::instance()->loadBitmap(buf);
- }
+ // ZBuffer is optional
+ if (!ts.checkString("zbuffer")) {
+ bkgnd_zbm_ = NULL;
+ } else {
+ ts.scanString(" zbuffer %256s", 1, buf);
+ bkgnd_zbm_ = ResourceLoader::instance()->loadBitmap(buf);
+ }
- ts.scanString(" position %f %f %f", 3, &pos_.x(), &pos_.y(), &pos_.z());
- ts.scanString(" interest %f %f %f", 3, &interest_.x(), &interest_.y(),
+ ts.scanString(" position %f %f %f", 3, &pos_.x(), &pos_.y(), &pos_.z());
+ ts.scanString(" interest %f %f %f", 3, &interest_.x(), &interest_.y(),
&interest_.z());
- ts.scanString(" roll %f", 1, &roll_);
- ts.scanString(" fov %f", 1, &fov_);
- ts.scanString(" nclip %f", 1, &nclip_);
- ts.scanString(" fclip %f", 1, &fclip_);
+ ts.scanString(" roll %f", 1, &roll_);
+ ts.scanString(" fov %f", 1, &fov_);
+ ts.scanString(" nclip %f", 1, &nclip_);
+ ts.scanString(" fclip %f", 1, &fclip_);
}
void Scene::Light::load(TextSplitter &ts) {
- char buf[256];
+ char buf[256];
- // Light names can be null, but ts doesn't seem flexible enough to allow this
- if (strlen(ts.currentLine()) > strlen(" light"))
- ts.scanString(" light %256s", 1, buf);
- else {
- ts.nextLine();
- strcpy(buf, "");
- }
- name_ = buf;
+ // Light names can be null, but ts doesn't seem flexible enough to allow this
+ if (strlen(ts.currentLine()) > strlen(" light"))
+ ts.scanString(" light %256s", 1, buf);
+ else {
+ ts.nextLine();
+ strcpy(buf, "");
+ }
+ name_ = buf;
- ts.scanString(" type %256s", 1, buf);
- type_ = buf;
+ ts.scanString(" type %256s", 1, buf);
+ type_ = buf;
- ts.scanString(" position %f %f %f", 3, &pos_.x(), &pos_.y(), &pos_.z());
- ts.scanString(" direction %f %f %f", 3, &dir_.x(), &dir_.y(), &dir_.z());
- ts.scanString(" intensity %f", 1, &intensity_);
- ts.scanString(" umbraangle %f", 1, &umbraangle_);
- ts.scanString(" penumbraangle %f", 1, &penumbraangle_);
- ts.scanString(" color %d %d %d", 3, &color_.red(), &color_.green(), &color_.blue());
+ ts.scanString(" position %f %f %f", 3, &pos_.x(), &pos_.y(), &pos_.z());
+ ts.scanString(" direction %f %f %f", 3, &dir_.x(), &dir_.y(), &dir_.z());
+ ts.scanString(" intensity %f", 1, &intensity_);
+ ts.scanString(" umbraangle %f", 1, &umbraangle_);
+ ts.scanString(" penumbraangle %f", 1, &penumbraangle_);
+ ts.scanString(" color %d %d %d", 3, &color_.red(), &color_.green(), &color_.blue());
}
void Scene::Setup::setupCamera() const {
- g_driver->setupCamera(fov_, nclip_, fclip_, roll_);
- g_driver->positionCamera(pos_, interest_);
+ g_driver->setupCamera(fov_, nclip_, fclip_, roll_);
+ g_driver->positionCamera(pos_, interest_);
}
-void Scene::setSetup(int num)
-{
+void Scene::setSetup(int num) {
currSetup_ = setups_ + num;
if (SCREENBLOCKS_GLOBAL == 0)
Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- scene.h 5 Oct 2003 17:45:46 -0000 1.11
+++ scene.h 24 Feb 2004 22:43:32 -0000 1.12
@@ -1,5 +1,5 @@
// Residual - Virtual machine to run LucasArts' 3D adventure games
-// Copyright (C) 2003 The ScummVM-Residual Team (www.scummvm.org)
+// Copyright (C) 2003-2004 The ScummVM-Residual Team (www.scummvm.org)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -34,64 +34,64 @@
class Scene {
public:
- Scene(const char *name, const char *buf, int len);
- ~Scene();
+ Scene(const char *name, const char *buf, int len);
+ ~Scene();
- void drawBackground() const {
- if (currSetup_->bkgnd_zbm_ != NULL) // Some screens have no zbuffer mask (eg, Alley)
- currSetup_->bkgnd_zbm_->draw();
+ void drawBackground() const {
+ if (currSetup_->bkgnd_zbm_ != NULL) // Some screens have no zbuffer mask (eg, Alley)
+ currSetup_->bkgnd_zbm_->draw();
- if (currSetup_->bkgnd_bm_ == NULL) {
- error("Null background for setup %s in %s", currSetup_->name_.c_str(), name_.c_str());
- return;
- }
- currSetup_->bkgnd_bm_->draw();
- }
- void setupCamera() {
- currSetup_->setupCamera();
- }
+ if (currSetup_->bkgnd_bm_ == NULL) {
+ error("Null background for setup %s in %s", currSetup_->name_.c_str(), name_.c_str());
+ return;
+ }
+ currSetup_->bkgnd_bm_->draw();
+ }
+ void setupCamera() {
+ currSetup_->setupCamera();
+ }
- const char *name() const { return name_.c_str(); }
+ const char *name() const { return name_.c_str(); }
- void setSetup(int num);
- int setup() const { return currSetup_ - setups_; }
+ void setSetup(int num);
+ int setup() const { return currSetup_ - setups_; }
- // Sector access functions
- int getSectorCount() { return numSectors_; }
- Sector *getSectorBase(int id) {
- if ((numSectors_ >= 0) && (id < numSectors_))
- return §ors_[id];
- else
- return NULL;
- }
+ // Sector access functions
+ int getSectorCount() { return numSectors_; }
+ Sector *getSectorBase(int id) {
+ if ((numSectors_ >= 0) && (id < numSectors_))
+ return §ors_[id];
+ else
+ return NULL;
+ }
private:
- struct Setup { // Camera setup data
- void load(TextSplitter &ts);
- void setupCamera() const;
- std::string name_;
- ResPtr<Bitmap> bkgnd_bm_, bkgnd_zbm_;
- Vector3d pos_, interest_;
- float roll_, fov_, nclip_, fclip_;
- };
+ struct Setup { // Camera setup data
+ void load(TextSplitter &ts);
+ void setupCamera() const;
+ std::string name_;
+ ResPtr<Bitmap> bkgnd_bm_, bkgnd_zbm_;
+ Vector3d pos_, interest_;
+ float roll_, fov_, nclip_, fclip_;
+ };
- struct Light { // Scene lighting data
- void load(TextSplitter &ts);
- std::string name_;
- std::string type_;
- Vector3d pos_, dir_;
- Color color_;
- float intensity_, umbraangle_, penumbraangle_;
- };
+ struct Light { // Scene lighting data
+ void load(TextSplitter &ts);
+ std::string name_;
+ std::string type_;
+ Vector3d pos_, dir_;
+ Color color_;
+ float intensity_, umbraangle_, penumbraangle_;
+ };
- std::string name_;
- int numCmaps_;
- ResPtr<CMap> *cmaps_;
- int numSetups_, numLights_, numSectors_;
- Sector *sectors_;
- Light *lights_;
- Setup *setups_;
- Setup *currSetup_;
+ std::string name_;
+ int numCmaps_;
+ ResPtr<CMap> *cmaps_;
+ int numSetups_, numLights_, numSectors_;
+ Sector *sectors_;
+ Light *lights_;
+ Setup *setups_;
+ Setup *currSetup_;
};
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.104,1.105 player_mod.cpp,2.14,2.15 player_v2.cpp,2.46,2.47 scummvm.cpp,2.587,2.588
- Next message: [Scummvm-cvs-logs] CVS: scummvm/backends/sdl build.rules,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list