[Scummvm-cvs-logs] CVS: residual actor.cpp,1.52,1.53 actor.h,1.24,1.25 bitmap.cpp,1.33,1.34 costume.cpp,1.28,1.29 costume.h,1.14,1.15 debug.h,1.9,1.10 driver_gl.cpp,1.53,1.54 engine.cpp,1.77,1.78 engine.h,1.28,1.29 keyframe.cpp,1.10,1.11 localize.cpp,1.11,1.12 lua.cpp,1.140,1.141 main.cpp,1.48,1.49 material.cpp,1.14,1.15 material.h,1.9,1.10 model.cpp,1.26,1.27 model.h,1.9,1.10 registry.cpp,1.11,1.12 registry.h,1.6,1.7 resource.cpp,1.24,1.25 resource.h,1.15,1.16 scene.cpp,1.42,1.43 scene.h,1.27,1.28 smush.cpp,1.60,1.61 textobject.cpp,1.27,1.28 timer.cpp,1.12,1.13 walkplane.cpp,1.14,1.15
Erich Edgar Hoover
compholio at users.sourceforge.net
Sun Jul 10 11:58:03 CEST 2005
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20484
Modified Files:
actor.cpp actor.h bitmap.cpp costume.cpp costume.h debug.h
driver_gl.cpp engine.cpp engine.h keyframe.cpp localize.cpp
lua.cpp main.cpp material.cpp material.h model.cpp model.h
registry.cpp registry.h resource.cpp resource.h scene.cpp
scene.h smush.cpp textobject.cpp timer.cpp walkplane.cpp
Log Message:
Improved state object rendering - actor colormap support - preliminary debug message options - actor transparency support for hardware renderer
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- actor.cpp 5 May 2005 21:23:17 -0000 1.52
+++ actor.cpp 10 Jul 2005 18:57:27 -0000 1.53
@@ -46,6 +46,7 @@
_constrain = false;
_talkSoundName = "";
+ strcpy(_colormap, DEFAULT_COLORMAP);
for (int i = 0; i < 10; i++) {
_talkCostume[i] = NULL;
_talkChore[i] = -1;
@@ -358,6 +359,8 @@
void Actor::pushCostume(const char *name) {
Costume *newCost = g_resourceloader->loadCostume(name, currentCostume());
+
+ newCost->setColormap(_colormap);
_costumeStack.push_back(newCost);
}
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- actor.h 3 Apr 2005 11:33:28 -0000 1.24
+++ actor.h 10 Jul 2005 18:57:27 -0000 1.25
@@ -26,6 +26,8 @@
#include <string>
#include <list>
+#define DEFAULT_COLORMAP "item.cmp"
+
class Costume;
class LipSynch;
class TextObject;
@@ -71,6 +73,9 @@
void turn(int dir);
void sayLine(const char *msg, const char *msgId);
+ // When we clean all text objects we don't want the actors to clean their
+ // objects again since they're already freed
+ void lineCleanup() { _sayLineText = NULL; }
void shutUp();
bool talking();
@@ -80,6 +85,9 @@
void setTalkChore(int index, int choreNumber, Costume *cost);
void setMumbleChore(int choreNumber, Costume *cost);
+ void setColormap(const char *map) {
+ strcpy(_colormap, map);
+ }
void pushCostume(const char *name);
void setCostume(const char *name);
void popCostume();
@@ -125,6 +133,7 @@
Vector3d _pos;
float _pitch, _yaw, _roll;
float _walkRate, _turnRate;
+ char _colormap[256];
bool _constrain; // Constrain to walkboxes
float _reflectionAngle; // Maximum angle to turn by at walls
Index: bitmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/bitmap.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- bitmap.cpp 8 Apr 2005 14:35:13 -0000 1.33
+++ bitmap.cpp 10 Jul 2005 18:57:27 -0000 1.34
@@ -30,8 +30,10 @@
Bitmap::Bitmap(const char *filename, const char *data, int len) :
Resource(filename) {
- if (len < 8 || memcmp(data, "BM F\0\0\0", 8) != 0)
- error("Invalid magic loading bitmap\n");
+ if (len < 8 || memcmp(data, "BM F\0\0\0", 8) != 0) {
+ if (debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
+ error("Invalid magic loading bitmap\n");
+ }
strcpy(_filename, filename);
@@ -79,6 +81,8 @@
Bitmap::Bitmap(const char *data, int width, int height, const char *filename) :
Resource(filename) {
+ if (debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
+ printf("New bitmap loaded: %s\n", filename);
strcpy(_filename, filename);
_currImage = 1;
_numImages = 1;
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- costume.cpp 12 Jan 2005 23:26:04 -0000 1.28
+++ costume.cpp 10 Jul 2005 18:57:27 -0000 1.29
@@ -93,8 +93,8 @@
class BitmapComponent : public Costume::Component {
public:
- BitmapComponent(Costume::Component *parent, int parentID, const char *filename);
-
+ BitmapComponent(Costume::Component *parent, int parentID, const char *filename, char *tag);
+ void setMapName(char *map) { }
void setKey(int val);
private:
@@ -103,8 +103,19 @@
class ModelComponent : public Costume::Component {
public:
- ModelComponent(Costume::Component *parent, int parentID, const char *filename);
+ ModelComponent(Costume::Component *parent, int parentID, const char *filename, char *tag);
void init();
+ CMap *cmap() { return _cmap; }
+ char *colormap() { return _colormap; }
+ void setMapName(char *map) {
+ if (!strcmp(map, DEFAULT_COLORMAP) || !strcmp(map, _colormap))
+ return;
+ _colormap = map;
+ if (_obj != NULL) {
+ _cmap = g_resourceloader->loadColormap(_colormap);
+ _obj->reload(*_cmap);
+ }
+ }
void setKey(int val);
void update();
void reset();
@@ -116,6 +127,7 @@
void draw();
protected:
+ char *_colormap;
std::string _filename;
ResPtr<Model> _obj;
ResPtr<CMap> _cmap;
@@ -125,8 +137,8 @@
class MainModelComponent : public ModelComponent {
public:
- MainModelComponent(Costume::Component *parent, int parentID, const char *filename);
- MainModelComponent(const char *filename, Model *prevObj, Model::HierNode *prevHier);
+ MainModelComponent(Costume::Component *parent, int parentID, const char *filename, char *tag);
+ MainModelComponent(const char *filename, Model *prevObj, Model::HierNode *prevHier, char *tag);
void init();
void update();
void reset();
@@ -140,8 +152,10 @@
class MeshComponent : public Costume::Component {
public:
- MeshComponent(Costume::Component *parent, int parentID, const char *name);
+ MeshComponent(Costume::Component *parent, int parentID, const char *name, char *tag);
void init();
+ CMap *cmap() { return ((ModelComponent *) _parent)->cmap();}
+ void setMapName(char *) { }
void setKey(int val);
void update();
void reset();
@@ -152,36 +166,76 @@
Model::HierNode *node() { return _node; }
private:
+ std::string _name;
int _num;
Model::HierNode *_node;
Matrix4 _matrix;
};
-BitmapComponent::BitmapComponent(Costume::Component *parent, int parentID, const char *filename) :
- Costume::Component(parent, parentID), _filename(filename) {
+BitmapComponent::BitmapComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ Costume::Component(parent, parentID, tag), _filename(filename) {
}
void BitmapComponent::setKey(int val) {
- ObjectState *state = g_engine->currScene()->findState(_filename.c_str());
+ const char *bitmap = _filename.c_str();
+ ObjectState *state = g_engine->currScene()->findState(bitmap);
- if (state != NULL)
+ if (state != NULL) {
state->setNumber(val);
- else
- warning("Couldn't find bitmap %s in current scene\n", _filename.c_str());
+ return;
+ }
+ // Complain that we couldn't find the bitmap. This means we probably
+ // didn't handle something correctly. Example: Before the tube-switcher
+ // bitmaps were not loading with the scene. This was because they were requested
+ // as a different case then they were stored (tu_0_dorcu_door_open versus
+ // TU_0_DORCU_door_open), which was causing problems in the string comparison.
+ if(debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Missing scene bitmap: %s\n", bitmap);
+
+/* In case you feel like drawing the missing bitmap anyway...
+ // Assume that all objects the scene file forgot about are OBJSTATE_STATE class
+ state = new ObjectState(0, ObjectState::OBJSTATE_STATE, bitmap, NULL, true);
+ if (state == NULL) {
+ if (debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Couldn't find bitmap %s in current scene\n", _filename.c_str());
+ return;
+ }
+ g_engine->currScene()->addObjectState(state);
+ state->setNumber(val);
+*/
}
-ModelComponent::ModelComponent(Costume::Component *parent, int parentID, const char *filename) :
- Costume::Component(parent, parentID), _filename(filename), _obj(NULL), _cmap(NULL), _hier(NULL) {
+ModelComponent::ModelComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ Costume::Component(parent, parentID, tag), _filename(filename), _obj(NULL), _cmap(NULL),
+ _colormap(DEFAULT_COLORMAP), _hier(NULL) {
}
void ModelComponent::init() {
+ // Skip loading if it was initialized
+ // by the sharing MainModelComponent
+ // constructor before
if (_obj == NULL) {
- // Skip loading if it was initialized
- // by the sharing MainModelComponent
- // constructor before
+ // Special case for climbing the rope (it's screwed up)
+ // TODO: Find out a real fix for this
+ if(!strcmp(_filename.c_str(), "ma_climb_suit.3do"))
+ _colormap = "suit.cmp";
+
+ // If we don't have the necessary color data, check to see
+ // if the parent object does (for painting faces)
+ if (_cmap == NULL && _parent != NULL) {
+ MeshComponent *parent = dynamic_cast<MeshComponent *>(_parent);
+ CMap *cmap = parent->cmap();
+
+ if (cmap != NULL)
+ _cmap = cmap;
+ }
+
+ // Get the colormap
if (_cmap == NULL) {
- warning("No colormap specified for %s\n", _filename.c_str());
- _cmap = g_resourceloader->loadColormap("item.cmp");
+ if (_colormap == DEFAULT_COLORMAP && (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL))
+ warning("No colormap specified for %s, using %s\n", _filename.c_str(), _colormap);
+
+ _cmap = g_resourceloader->loadColormap(_colormap);
}
_obj = g_resourceloader->loadModel(_filename.c_str(), *_cmap);
_hier = _obj->copyHierarchy();
@@ -192,9 +246,10 @@
// parent object's tree.
if (_parent != NULL) {
MeshComponent *mc = dynamic_cast<MeshComponent *>(_parent);
+
if (mc != NULL)
mc->node()->addChild(_hier);
- else
+ else if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
warning("Parent of model %s wasn't a mesh\n", _filename.c_str());
}
}
@@ -222,6 +277,8 @@
void ModelComponent::setColormap(CMap *c) {
_cmap = c;
+ if (_obj != NULL && _cmap != NULL)
+ _obj->reload(*_cmap);
}
ModelComponent::~ModelComponent() {
@@ -238,13 +295,14 @@
_hier->draw();
}
-MainModelComponent::MainModelComponent(Costume::Component *parent, int parentID, const char *filename) :
- ModelComponent(parent, parentID, filename), _hierShared(false) {
+MainModelComponent::MainModelComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ ModelComponent(parent, parentID, filename, tag), _hierShared(false) {
}
// Constructor used if sharing the main model with the previous costume
-MainModelComponent::MainModelComponent(const char *filename, Model *prevObj, Model::HierNode *prevHier) :
- ModelComponent(NULL, -1, filename), _hierShared(true) {
+MainModelComponent::MainModelComponent(const char *filename, Model *prevObj, Model::HierNode *prevHier, char *tag) :
+ ModelComponent(NULL, -1, filename, tag), _hierShared(true) {
+
_obj = prevObj;
_hier = prevHier;
}
@@ -273,30 +331,32 @@
class ColormapComponent : public Costume::Component {
public:
- ColormapComponent(Costume::Component *parent, int parentID, const char *filename);
+ ColormapComponent(Costume::Component *parent, int parentID, const char *filename, char *tag);
ColormapComponent *copy(Costume::Component *newParent);
+ void setMapName(char *) { }
~ColormapComponent();
private:
ResPtr<CMap> _cmap;
};
-ColormapComponent::ColormapComponent(Costume::Component *parent, int parentID, const char *filename) :
- Costume::Component(parent, parentID) {
+ColormapComponent::ColormapComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ Costume::Component(parent, parentID, tag) {
_cmap = g_resourceloader->loadColormap(filename);
-
+
ModelComponent *mc = dynamic_cast<ModelComponent *>(parent);
if (mc != NULL)
mc->setColormap(_cmap);
- }
+}
ColormapComponent::~ColormapComponent() {
}
class KeyframeComponent : public Costume::Component {
public:
- KeyframeComponent(Costume::Component *parent, int parentID, const char *filename);
+ KeyframeComponent(Costume::Component *parent, int parentID, const char *filename, char *tag);
void init();
+ void setMapName(char *) { }
void setKey(int val);
void update();
void reset();
@@ -311,8 +371,8 @@
int _currTime;
};
-KeyframeComponent::KeyframeComponent(Costume::Component *parent, int parentID, const char *filename) :
- Costume::Component(parent, parentID), _priority1(1), _priority2(5), _hier(NULL), _active(false) {
+KeyframeComponent::KeyframeComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ Costume::Component(parent, parentID, tag), _priority1(1), _priority2(5), _hier(NULL), _active(false) {
const char *comma = std::strchr(filename, ',');
if (comma != NULL) {
std::string realName(filename, comma);
@@ -338,7 +398,8 @@
_active = false;
break;
default:
- warning("Unknown key %d for keyframe %s\n", val, _keyf->filename());
+ if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Unknown key %d for keyframe %s\n", val, _keyf->filename());
}
}
@@ -372,7 +433,8 @@
_currTime = animLength;
break;
default:
- warning("Unknown repeat mode %d for keyframe %s\n", _repeatMode, _keyf->filename());
+ if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Unknown repeat mode %d for keyframe %s\n", _repeatMode, _keyf->filename());
}
}
_keyf->animate(_hier, _currTime / 1000.0, _priority1, _priority2);
@@ -383,15 +445,17 @@
if (mc != NULL)
_hier = mc->hierarchy();
else {
- warning("Parent of %s was not a model\n", _keyf->filename());
+ if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Parent of %s was not a model\n", _keyf->filename());
_hier = NULL;
}
}
-MeshComponent::MeshComponent(Costume::Component *parent, int parentID, const char *name) :
- Costume::Component(parent, parentID), _node(NULL) {
+MeshComponent::MeshComponent(Costume::Component *parent, int parentID, const char *name, char *tag) :
+ Costume::Component(parent, parentID, tag), _name(name), _node(NULL) {
if (std::sscanf(name, "mesh %d", &_num) < 1)
error("Couldn't parse mesh name %s\n", name);
+
}
void MeshComponent::init() {
@@ -399,7 +463,8 @@
if (mc != NULL)
_node = mc->hierarchy() + _num;
else {
- warning("Parent of mesh %d was not a model\n", _num);
+ if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Parent of mesh %d was not a model\n", _num);
_node = NULL;
}
}
@@ -419,9 +484,10 @@
class MaterialComponent : public Costume::Component {
public:
- MaterialComponent(Costume::Component *parent, int parentID, const char *filename);
+ MaterialComponent(Costume::Component *parent, int parentID, const char *filename, char *tag);
void init();
void setKey(int val);
+ void setMapName(char *) { }
void setupTexture();
void reset();
~MaterialComponent() { }
@@ -429,20 +495,35 @@
private:
ResPtr<Material> _mat;
std::string _filename;
+ char *_colormap;
int _num;
};
-MaterialComponent::MaterialComponent(Costume::Component *parent, int parentID, const char *filename) :
- Costume::Component(parent, parentID), _filename(filename), _num(0) {
- warning("Constructing MaterialComponent %s\n", filename);
+MaterialComponent::MaterialComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ Costume::Component(parent, parentID, tag), _filename(filename), _colormap(DEFAULT_COLORMAP),
+ _num(0) {
+
+ if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Constructing MaterialComponent %s\n", filename);
}
void MaterialComponent::init() {
- warning("MaterialComponent::init on %s\n", _filename.c_str());
- // The parent model and thus all its textures should have been
- // loaded by now, so passing an arbitrary colormap here
- // shouldn't cause problems.
- ResPtr<CMap> cmap = g_resourceloader->loadColormap("item.cmp");
+ ModelComponent *mc = dynamic_cast<ModelComponent *>(_parent);
+ ResPtr<CMap> cmap;
+
+ // If the object doesn't have a colormap then get the parent's colormap
+ // this happens a lot with actor heads, the first head "object" will have
+ // a colormap but the other objects (different facial expressions) will not
+ if (_colormap == DEFAULT_COLORMAP && mc != NULL)
+ cmap = mc->cmap();
+
+ if (cmap == NULL) {
+ // Use the default colormap if we're still drawing a blank
+ if (_colormap == DEFAULT_COLORMAP && (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL))
+ warning("MaterialComponent::init on %s\n", _filename.c_str());
+
+ cmap = g_resourceloader->loadColormap(_colormap);
+ }
_mat = g_resourceloader->loadMaterial(_filename.c_str(), *cmap);
}
@@ -460,7 +541,8 @@
class LuaVarComponent : public Costume::Component {
public:
- LuaVarComponent(Costume::Component *parent, int parentID, const char *name);
+ LuaVarComponent(Costume::Component *parent, int parentID, const char *name, char *tag);
+ void setMapName(char *) { }
void setKey(int val);
~LuaVarComponent() { }
@@ -468,8 +550,8 @@
std::string _name;
};
-LuaVarComponent::LuaVarComponent(Costume::Component *parent, int parentID, const char *name) :
- Costume::Component(parent, parentID), _name(name) {
+LuaVarComponent::LuaVarComponent(Costume::Component *parent, int parentID, const char *name, char *tag) :
+ Costume::Component(parent, parentID, tag), _name(name) {
}
void LuaVarComponent::setKey(int val) {
@@ -479,7 +561,8 @@
class SoundComponent : public Costume::Component {
public:
- SoundComponent(Costume::Component *parent, int parentID, const char *name);
+ SoundComponent(Costume::Component *parent, int parentID, const char *name, char *tag);
+ void setMapName(char *) { }
void setKey(int val);
void reset();
~SoundComponent() { }
@@ -488,8 +571,8 @@
std::string _soundName;
};
-SoundComponent::SoundComponent(Costume::Component *parent, int parentID, const char *filename) :
- Costume::Component(parent, parentID) {
+SoundComponent::SoundComponent(Costume::Component *parent, int parentID, const char *filename, char *tag) :
+ Costume::Component(parent, parentID, tag) {
const char *comma = std::strchr(filename, ',');
if (comma != NULL) {
_soundName = std::string(filename, comma);
@@ -518,7 +601,8 @@
g_imuse->setHookId(_soundName.c_str(), 0x80);
break;
default:
- warning("Unknown key %d for sound %s\n", val, _soundName.c_str());
+ if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Unknown key %d for sound %s\n", val, _soundName.c_str());
}
}
@@ -527,8 +611,9 @@
}
Costume::Costume(const char *filename, const char *data, int len, Costume *prevCost) :
- _fname(filename) {
+ _fname(filename), _colormap(DEFAULT_COLORMAP) {
TextSplitter ts(data, len);
+
ts.expectString("costume v0.1");
ts.expectString("section tags");
int numTags;
@@ -557,7 +642,7 @@
if (id == 0 && prevCost != NULL && std::memcmp(tags[tagID], "mmdl", 4) == 0) {
MainModelComponent *mmc = dynamic_cast<MainModelComponent *>(prevCost->_components[0]);
if (mmc != NULL && mmc->_filename == std::string(line + namePos)) {
- _components[id] = new MainModelComponent(line + namePos, mmc->_obj, mmc->_hier);
+ _components[id] = new MainModelComponent(line + namePos, mmc->_obj, mmc->_hier, "mmdl");
continue;
}
}
@@ -565,6 +650,11 @@
_components[id] = loadComponent(tags[tagID], parentID == -1 ? NULL : _components[parentID], parentID, line + namePos);
}
+ for (int i = 0; i < _numComponents; i++) {
+ if (_components[i] != NULL)
+ _components[i]->setCostume(this);
+ }
+
delete[] tags;
for (int i = 0; i < _numComponents; i++)
@@ -581,7 +671,8 @@
_chores[id]._length = length;
_chores[id]._numTracks = tracks;
std::memcpy(_chores[id]._name, name, 32);
- printf("Loaded chore: %s\n", name);
+ if(debugLevel == DEBUG_ALL || debugLevel == DEBUG_CHORES)
+ printf("Loaded chore: %s\n", name);
}
ts.expectString("section keys");
@@ -599,9 +690,11 @@
delete[] _chores;
}
-Costume::Component::Component(Component *parent, int parentID) {
+Costume::Component::Component(Component *parent, int parentID, char *tag) {
_parentID = parentID;
+ _cost = NULL;
setParent(parent);
+ memcpy(_tag, tag, 4);
}
void Costume::Component::setParent(Component *newParent) {
@@ -675,6 +768,20 @@
}
}
+void Costume::Chore::setLastFrame() {
+ // If the chore has already played then don't set it to the end
+ // Example: This executing would result in Glottis being
+ // choppy when he hands Manny the work order
+ if (_hasPlayed)
+ return;
+ _currTime = _length;
+ _playing = false;
+ _hasPlayed = true;
+ _looping = false;
+ setKeys(-1, _currTime);
+ _currTime = -1;
+}
+
void Costume::Chore::update() {
if (!_playing)
return;
@@ -702,23 +809,23 @@
Costume::Component *Costume::loadComponent (char tag[4], Costume::Component *parent, int parentID, const char *name) {
if (std::memcmp(tag, "mmdl", 4) == 0)
- return new MainModelComponent(parent, parentID, name);
+ return new MainModelComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "modl", 4) == 0)
- return new ModelComponent(parent, parentID, name);
+ return new ModelComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "cmap", 4) == 0)
- return new ColormapComponent(parent, parentID, name);
+ return new ColormapComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "keyf", 4) == 0)
- return new KeyframeComponent(parent, parentID, name);
+ return new KeyframeComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "mesh", 4) == 0)
- return new MeshComponent(parent, parentID, name);
+ return new MeshComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "luav", 4) == 0)
- return new LuaVarComponent(parent, parentID, name);
+ return new LuaVarComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "imls", 4) == 0)
- return new SoundComponent(parent, parentID, name);
+ return new SoundComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "bknd", 4) == 0)
- return new BitmapComponent(parent, parentID, name);
+ return new BitmapComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "mat ", 4) == 0)
- return new MaterialComponent(parent, parentID, name);
+ return new MaterialComponent(parent, parentID, name, tag);
else if (std::memcmp(tag, "sprt", 4) == 0)
return NULL;// new SpriteComponent(parent, parentID, name);
Index: costume.h
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- costume.h 12 Jan 2005 23:26:04 -0000 1.14
+++ costume.h 10 Jul 2005 18:57:27 -0000 1.15
@@ -35,8 +35,25 @@
void playChore(int num) { _chores[num].play(); }
void playChoreLooping(int num) { _chores[num].playLooping(); }
+ void setChoreLastFrame(int num) { _chores[num].setLastFrame(); }
void setChoreLooping(int num, bool val) { _chores[num].setLooping(val); }
void stopChore(int num) { _chores[num].stop(); }
+ char *getColormap() { return _colormap; }
+ void setColormap(char *map) {
+ _colormap = map;
+ for(int i=0;i<_numComponents;i++) {
+ if (_components[i] == NULL)
+ continue;
+ // Needs to handle Main Models (pigeons) and normal Models
+ // (when Manny climbs the rope)
+ if (
+std::memcmp(_components[i]->tag(), "mmdl", 4) == 0
+ ||
+std::memcmp(_components[i]->tag(), "mat ", 4) == 0
+)
+ _components[i]->setMapName(_colormap);
+ }
+ }
void stopChores();
int isChoring(int num, bool excludeLooping);
int isChoring(bool excludeLooping);
@@ -50,11 +67,13 @@
class Component {
public:
- Component(Component *parent, int parentID);
+ Component(Component *parent, int parentID, char *tag);
+ char *tag() { return _tag; }
virtual void setMatrix(Matrix4) { };
virtual void init() { }
virtual void setKey(int) { }
+ virtual void setMapName(char *) { }
virtual void update() { }
virtual void setupTexture() { }
virtual void draw() { }
@@ -62,9 +81,12 @@
virtual ~Component() { }
protected:
+ char _tag[4];
int _parentID;
Component *_parent, *_child, *_sibling;
Matrix4 _matrix;
+ Costume *_cost;
+ void setCostume(Costume *cost) { _cost = cost; }
void setParent(Component *newParent);
friend class Costume;
@@ -72,9 +94,9 @@
private:
Component *loadComponent(char tag[4], Component *parent, int parentID, const char *name);
-
+ char *_colormap;
std::string _fname;
-
+
int _numComponents;
Component **_components;
@@ -105,6 +127,7 @@
void setLooping(bool val) { _looping = val; }
void stop();
void update();
+ void setLastFrame();
private:
Costume *_owner;
Index: debug.h
===================================================================
RCS file: /cvsroot/scummvm/residual/debug.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- debug.h 10 Jan 2005 09:07:46 -0000 1.9
+++ debug.h 10 Jul 2005 18:57:27 -0000 1.10
@@ -20,6 +20,46 @@
#ifndef DEBUG_H
#define DEBUG_H
+enum enDebugLevels {
+ DEBUG_NONE,
+ DEBUG_NORMAL,
+ DEBUG_WARN,
+ DEBUG_ERROR,
+ DEBUG_FUNC,
+ DEBUG_BITMAPS,
+ DEBUG_MODEL,
+ DEBUG_STUB,
+ DEBUG_SMUSH,
+ DEBUG_CHORES,
+ DEBUG_ALL
+};
+extern enDebugLevels debugLevel;
+static const char *debug_levels[] = {
+ "NONE",
+ "NORMAL",
+ "WARN",
+ "ERROR",
+ "FUNC",
+ "BITMAP",
+ "MODEL",
+ "STUB",
+ "SMUSH",
+ "CHORE",
+ "ALL"
+};
+static const char *debug_descriptions[] = {
+ "No debug messages will be printed (default)",
+ "\"Normal\" debug messages will be printed",
+ "Warning debug messages will be printed",
+ "Error debug messages will be printed",
+ "Function (normal and stub) debug messages will be printed",
+ "Bitmap debug messages will be printed",
+ "Model debug messages will be printed",
+ "Stub (missing function) debug messages will be printed",
+ "SMUSH debug messages will be printed",
+ "Chore debug messages will be printed",
+ "All debug messages will be printed",
+};
// Hacky toggles for experimental / debug code (defined/set in main.cpp)
extern bool ZBUFFER_GLOBAL, SHOWFPS_GLOBAL;
Index: driver_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- driver_gl.cpp 5 May 2005 21:23:17 -0000 1.53
+++ driver_gl.cpp 10 Jul 2005 18:57:27 -0000 1.54
@@ -117,9 +117,14 @@
void DriverGL::set3DMode() {
glMatrixMode(GL_MODELVIEW);
glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LESS);
}
void DriverGL::drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts) {
+ // Support transparency in actor objects, such as the message tube
+ // in Manny's Office
+ glAlphaFunc(GL_GREATER, 0.5);
+ glEnable(GL_ALPHA_TEST);
glNormal3fv(face->_normal._coords);
glBegin(GL_POLYGON);
for (int i = 0; i < face->_numVertices; i++) {
@@ -131,6 +136,8 @@
glVertex3fv(vertices + 3 * face->_vertices[i]);
}
glEnd();
+ // Done with transparency-capable objects
+ glDisable( GL_ALPHA_TEST );
}
void DriverGL::drawHierachyNode(const Model::HierNode *node) {
@@ -428,7 +435,6 @@
// if (num != 0) {
// warning("Animation not handled yet in GL texture path !\n");
// }
-
if (y + h == 480) {
glRasterPos2i(x, _screenHeight - 1);
glBitmap(0, 0, 0, 0, 0, -1, NULL);
Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- engine.cpp 8 Apr 2005 22:29:05 -0000 1.77
+++ engine.cpp 10 Jul 2005 18:57:27 -0000 1.78
@@ -152,6 +152,8 @@
lua_endblock();
}
if (event.type == SDL_KEYDOWN) {
+ if (event.key.keysym.sym == SDLK_z)
+ g_resourceloader->loadKeyframe("ma_card_hold.key");
if ((event.key.keysym.sym == SDLK_RETURN ||
event.key.keysym.sym == SDLK_KP_ENTER) &&
(event.key.keysym.mod & KMOD_ALT))
@@ -197,6 +199,20 @@
_currScene->drawBackground();
}
+ // Draw underlying scene components
+ if (_currScene != NULL) {
+ _currScene->drawBitmaps(ObjectState::OBJSTATE_UNDERLAY);
+ // State objects are drawn on top of other things, such as the flag
+ // on Manny's message tube
+ _currScene->drawBitmaps(ObjectState::OBJSTATE_STATE);
+ }
+
+ // Play SMUSH Animations
+ // This should occur on top of all underlying scene objects,
+ // a good example is the tube switcher room where some state objects
+ // need to render underneath the animation or you can't see what's going on
+ // This should not occur on top of everything though or Manny gets covered
+ // up when he's next to Glottis's service room
if (g_smush->isPlaying()) {
_movieTime = g_smush->getMovieTime();
if (g_smush->isUpdateNeeded()) {
@@ -207,12 +223,6 @@
g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
}
- if (_currScene != NULL) {
- _currScene->drawBitmaps(ObjectState::OBJSTATE_UNDERLAY);
- _currScene->drawBitmaps(ObjectState::OBJSTATE_STATE);
- _currScene->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
- }
-
if (SHOWFPS_GLOBAL)
g_driver->drawEmergString(550, 25, fps, Color(255, 255, 255));
@@ -234,6 +244,14 @@
if (_currScene != NULL)
a->undraw(a->inSet(_currScene->name()) && a->visible());
}
+
+ // Draw overlying scene components
+ if (_currScene != NULL) {
+ // The overlay objects should be drawn on top of everything else,
+ // including 3D objects such as Manny and the message tube
+ _currScene->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
+ }
+
}
// Draw Primitives
@@ -433,15 +451,57 @@
lua_endblock();
}
+Scene *Engine::findScene(const char *name) {
+ // Find scene object
+ for (SceneListType::const_iterator i = scenesBegin(); i != scenesEnd(); i++) {
+ if(!strcmp((char *) (*i)->name(), (char *) name))
+ return *i;
+ }
+ return NULL;
+}
+
+void Engine::setSceneLock(const char *name, bool lockStatus) {
+ Scene *scene = findScene(name);
+
+ if (scene == NULL) {
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Scene object '%s' not found in list!", name);
+ return;
+ }
+ // Change the locking status
+ scene->locked = lockStatus;
+}
+
void Engine::setScene(const char *name) {
+ Scene *scene = findScene(name);
+
+ // If the scene already exists then use the existing data
+ if (scene != NULL) {
+ setScene(scene);
+ return;
+ }
Block *b = g_resourceloader->getFileBlock(name);
if (b == NULL)
warning("Could not find scene file %s\n", name);
- delete _currScene;
+ if (_currScene != NULL && !_currScene->locked) {
+ removeScene(_currScene);
+ delete _currScene;
+ }
_currScene = new Scene(name, b->data(), b->len());
+ registerScene(_currScene);
_currScene->setSoundParameters(20, 127);
delete b;
}
+
+void Engine::setScene(Scene *scene) {
+ if (_currScene != NULL && !_currScene->locked) {
+ removeScene(_currScene);
+ delete _currScene;
+ }
+ _currScene = scene;
+ _currScene->setSoundParameters(20, 127);
+}
+
void Engine::setTextSpeed(int speed) {
if (speed < 1)
_textSpeed = 1;
Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- engine.h 8 Apr 2005 22:29:05 -0000 1.28
+++ engine.h 10 Jul 2005 18:57:27 -0000 1.29
@@ -111,12 +111,27 @@
void enableControl(int num) { _controlsEnabled[num] = true; }
void disableControl(int num) { _controlsEnabled[num] = false; }
- void registerActor(Actor *a) { _actors.push_back(a); }
-
+ Scene *findScene(const char *name);
+ void setSceneLock(const char *name, bool lockStatus);
void setScene(const char *name);
+ void setScene(Scene *scene);
Scene *currScene() { return _currScene; }
const char *sceneName() const { return _currScene->name(); }
+ // Scene registration
+ typedef std::list<Scene *> SceneListType;
+ SceneListType::const_iterator scenesBegin() const {
+ return _scenes.begin();
+ }
+ SceneListType::const_iterator scenesEnd() const {
+ return _scenes.end();
+ }
+ void registerScene(Scene *a) { _scenes.push_back(a); }
+ void removeScene(Scene *a) {
+ _scenes.remove(a);
+ }
+
+ // Actor registration
typedef std::list<Actor *> ActorListType;
ActorListType::const_iterator actorsBegin() const {
return _actors.begin();
@@ -124,7 +139,7 @@
ActorListType::const_iterator actorsEnd() const {
return _actors.end();
}
-
+ void registerActor(Actor *a) { _actors.push_back(a); }
void setSelectedActor(Actor *a) { _selectedActor = a; }
Actor *selectedActor() { return _selectedActor; }
@@ -194,6 +209,7 @@
bool _controlsEnabled[SDLK_EXTRA_LAST];
+ SceneListType _scenes;
ActorListType _actors;
Actor *_selectedActor;
TextListType _textObjects;
Index: keyframe.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/keyframe.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- keyframe.cpp 10 Jan 2005 09:07:46 -0000 1.10
+++ keyframe.cpp 10 Jul 2005 18:57:27 -0000 1.11
@@ -25,6 +25,7 @@
KeyframeAnim::KeyframeAnim(const char *filename, const char *data, int len) :
Resource(filename) {
+
if (len >= 4 && std::memcmp(data, "FYEK", 4) == 0)
loadBinary(data, len);
else {
@@ -52,7 +53,20 @@
const char *dataEnd = data + len;
data += 180;
while (data < dataEnd) {
+ // ma_card_hold.key crashes at this part without checking
+ // to make sure nodeNum is valid, unfortunately I believe
+ // whatever data we're losing from this file is what prevents
+ // the game from continuing after Manny reads the message
+ //
+ // TODO: Find out what really goes wrong when we read
+ // the data in ma_card_hold.key and fix it
int nodeNum = READ_LE_UINT32(data + 32);
+ if (nodeNum >= _numJoints) {
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL) {
+ warning("A node number was greater than the maximum number of nodes (%d/%d)", nodeNum, _numJoints);
+ }
+ return;
+ }
_nodes[nodeNum] = new KeyframeNode;
_nodes[nodeNum]->loadBinary(data);
}
Index: localize.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/localize.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- localize.cpp 3 Apr 2005 11:33:28 -0000 1.11
+++ localize.cpp 10 Jul 2005 18:57:27 -0000 1.12
@@ -30,7 +30,7 @@
const char *namesToTry[] = { "/GRIM.TAB", "/Grim.tab", "/grim.tab" };
for (unsigned i = 0; i < sizeof(namesToTry) / sizeof(namesToTry[0]); i++) {
- const char *datadir = g_registry->get("DataDir");
+ const char *datadir = g_registry->get("DataDir", NULL);
std::string fname = (datadir != NULL ? datadir : ".");
fname += namesToTry[i];
f = std::fopen(fname.c_str(), "rb");
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- lua.cpp 5 May 2005 21:23:17 -0000 1.140
+++ lua.cpp 10 Jul 2005 18:57:27 -0000 1.141
@@ -28,6 +28,7 @@
#include "smush.h"
#include "textobject.h"
#include "objectstate.h"
+#include "colormap.h"
#include "font.h"
#include "imuse/imuse.h"
@@ -41,7 +42,9 @@
extern Imuse *g_imuse;
#define strmatch(src, dst) (strlen(src) == strlen(dst) && strcmp(src, dst) == 0)
[...2209 lines suppressed...]
STUB_FUNC(SetCameraFOV)
@@ -3037,7 +3576,7 @@
delete b;
// Don't print warnings on Scripts\foo.lua,
// d:\grimFandango\Scripts\foo.lua
- if (std::strstr(filename, "Scripts\\") == NULL)
+ if (std::strstr(filename, "Scripts\\") == NULL && (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL))
warning("Cannot find script %s\n", filename);
return 2;
@@ -3066,7 +3605,8 @@
}
if (!lua_isfunction(handler)) {
- warning("Invalid event handler %s", name);
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Invalid event handler %s", name);
return LUA_NOOBJECT;
}
Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- main.cpp 28 Mar 2005 01:54:21 -0000 1.48
+++ main.cpp 10 Jul 2005 18:57:27 -0000 1.49
@@ -37,6 +37,7 @@
// Hacky global toggles for experimental/debug code
bool ZBUFFER_GLOBAL, SHOWFPS_GLOBAL, TINYGL_GLOBAL;
+enDebugLevels debugLevel = DEBUG_NONE;
#ifdef __MINGW32__
int PASCAL WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {
@@ -45,7 +46,6 @@
#endif
static bool g_lua_initialized = false;
-
Driver *g_driver = NULL;
static bool parseBoolStr(const char *val) {
@@ -86,10 +86,10 @@
g_registry = new Registry();
// Parse command line
- ZBUFFER_GLOBAL = parseBoolStr(g_registry->get("zbuffer"));
- SHOWFPS_GLOBAL = parseBoolStr(g_registry->get("fps"));
- TINYGL_GLOBAL = parseBoolStr(g_registry->get("soft"));
- bool fullscreen = parseBoolStr(g_registry->get("fullscreen"));
+ ZBUFFER_GLOBAL = parseBoolStr(g_registry->get("zbuffer", "TRUE"));
+ SHOWFPS_GLOBAL = parseBoolStr(g_registry->get("fps", "FALSE"));
+ TINYGL_GLOBAL = parseBoolStr(g_registry->get("soft", "FALSE"));
+ bool fullscreen = parseBoolStr(g_registry->get("fullscreen", "FALSE"));
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-zbuffer") == 0)
ZBUFFER_GLOBAL = true;
@@ -107,14 +107,48 @@
TINYGL_GLOBAL = true;
else if (strcmp(argv[i], "-nosoft") == 0)
TINYGL_GLOBAL = false;
- else {
+ else if (strncmp(argv[i], "-debug=", 7) == 0) {
+ bool numeric = true;
+ char debugtxt[20];
+ unsigned int j;
+ int level;
+
+ sscanf(argv[i], "%*[^=]%*1s%s", debugtxt);
+ for(j=0;j<strlen(debugtxt);j++) {
+ if(!isdigit(debugtxt[j]))
+ numeric = false;
+ }
+ if(numeric) {
+ sscanf(debugtxt, "%d", &level);
+ if(level < 0 || level > DEBUG_ALL)
+ goto needshelp;
+ } else {
+ level = -1;
+ for(j=0;j<=DEBUG_ALL;j++)
+ {
+ if(!strcasecmp(debugtxt, debug_levels[j])) {
+ level = j;
+ break;
+ }
+ }
+ if(level == -1)
+ goto needshelp;
+ }
+ debugLevel = (enDebugLevels) level;
+ printf("Debug level set to: %s\n", debug_levels[debugLevel]);
+ } else {
+ int j;
+needshelp:
printf("Residual CVS Version\n");
printf("--------------------\n");
printf("Recognised options:\n");
printf("\t-[no]zbuffer\t\tEnable/disable ZBuffers (Very slow on older cards)\n");
printf("\t-[no]fps\t\tEnable/disable fps display in upper right corner\n");
- printf("\t-[no]fullscreen\tEnable/disable fullscreen mode at startup\n");
+ printf("\t-[no]fullscreen\t\tEnable/disable fullscreen mode at startup\n");
printf("\t-[no]soft\t\tEnable/disable software renderer\n");
+ printf("\t-debug=[level]\t\tSet debug to [level], valid levels:\n");
+ for(j=0;j<=DEBUG_ALL;j++)
+ printf("\t\t%-8s (%d): %s.\n", debug_levels[j], j, debug_descriptions[j]);
exit(-1);
}
}
Index: material.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/material.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- material.cpp 13 Jan 2005 20:21:11 -0000 1.14
+++ material.cpp 10 Jul 2005 18:57:27 -0000 1.15
@@ -23,7 +23,7 @@
#include "driver.h"
Material::Material(const char *filename, const char *data, int len, const CMap &cmap) :
- Resource(filename) {
+ Resource(filename), _cmap((CMap *) &cmap) {
if (len < 4 || memcmp(data, "MAT ", 4) != 0)
error("invalid magic loading texture\n");
@@ -33,7 +33,8 @@
_height = READ_LE_UINT32(data + 80 + _numImages * 40);
if ((_width == 0) || (_height == 0)) {
- warning("skip load texture: bad texture size (%dx%d) for texture %s\n", _width, _height, filename);
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("skip load texture: bad texture size (%dx%d) for texture %s\n", _width, _height, filename);
return;
}
Index: material.h
===================================================================
RCS file: /cvsroot/scummvm/residual/material.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- material.h 12 Jan 2005 18:06:43 -0000 1.9
+++ material.h 10 Jul 2005 18:57:27 -0000 1.10
@@ -43,6 +43,7 @@
~Material();
//private:
+ CMap *_cmap;
int _numImages, _currImage;
int _width, _height;
void *_textures;
Index: model.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/model.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- model.cpp 12 Jan 2005 23:26:04 -0000 1.26
+++ model.cpp 10 Jul 2005 18:57:27 -0000 1.27
@@ -27,7 +27,9 @@
#include <cstring>
#include <SDL.h>
-Model::Model(const char *filename, const char *data, int len, const CMap &cmap) : Resource(filename) {
+Model::Model(const char *filename, const char *data, int len, const CMap &cmap) :
+ Resource(filename), _numMaterials(0), _numGeosets(0) {
+
if (len >= 4 && std::memcmp(data, "LDOM", 4) == 0)
loadBinary(data, cmap);
else {
@@ -36,12 +38,22 @@
}
}
+void Model::reload(const CMap &cmap) {
+ // Load the new colormap
+ for (int i = 0; i < _numMaterials; i++)
+ _materials[i] = g_resourceloader->loadMaterial(_materialNames[i], cmap);
+ for (int i = 0; i < _numGeosets; i++)
+ _geosets[i].changeMaterials(_materials);
+}
+
void Model::loadBinary(const char *data, const CMap &cmap) {
_numMaterials = READ_LE_UINT32(data + 4);
data += 8;
_materials = new ResPtr<Material>[_numMaterials];
+ _materialNames = new char[_numMaterials][32];
for (int i = 0; i < _numMaterials; i++) {
- _materials[i] = g_resourceloader->loadMaterial(data, cmap);
+ strcpy(_materialNames[i], data);
+ _materials[i] = g_resourceloader->loadMaterial(_materialNames[i], cmap);
data += 32;
}
data += 32; // skip name
@@ -61,6 +73,7 @@
Model::~Model() {
delete[] _materials;
+ delete[] _materialNames;
delete[] _geosets;
delete[] _rootHierNode;
}
@@ -104,8 +117,9 @@
}
data += _numVertices * 4;
_faces = new Face[_numFaces];
+ _materialid = new int[_numFaces];
for (int i = 0; i < _numFaces; i++)
- _faces[i].loadBinary(data, materials);
+ _materialid[i] = _faces[i].loadBinary(data, materials);
_vertNormals = new float[3 * _numVertices];
for (int i = 0; i < 3 * _numVertices; i++) {
_vertNormals[i] = get_float(data);
@@ -127,7 +141,11 @@
void Model::Mesh::update() {
}
-void Model::Face::loadBinary(const char *&data, ResPtr<Material> *materials) {
+void Model::Face::changeMaterial(ResPtr<Material> material) {
+ _material = material;
+}
+
+int Model::Face::loadBinary(const char *&data, ResPtr<Material> *materials) {
_type = READ_LE_UINT32(data + 4);
_geo = READ_LE_UINT32(data + 8);
_light = READ_LE_UINT32(data + 12);
@@ -157,8 +175,10 @@
_material = 0;
else {
_material = materials[READ_LE_UINT32(data)];
+ materialPtr = READ_LE_UINT32(data);
data += 4;
}
+ return materialPtr;
}
Model::Face::~Face() {
@@ -241,11 +261,12 @@
ts.expectString("section: modelresource");
ts.scanString("materials %d", 1, &_numMaterials);
_materials = new ResPtr<Material>[_numMaterials];
+ _materialNames = new char[_numMaterials][32];
for (int i = 0; i < _numMaterials; i++) {
int num;
- char name[32];
- ts.scanString("%d: %32s", 2, &num, name);
- _materials[num] = g_resourceloader->loadMaterial(name, cmap);
+
+ ts.scanString("%d: %32s", 2, &num, _materialNames[num]);
+ _materials[num] = g_resourceloader->loadMaterial(_materialNames[num], cmap);
}
ts.expectString("section: geometrydef");
@@ -302,10 +323,15 @@
_rootHierNode[num]._totalWeight = 1;
}
- if (!ts.eof())
+ if (!ts.eof() && (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL))
warning("Unexpected junk at end of model text\n");
}
+void Model::Geoset::changeMaterials(ResPtr<Material> *materials) {
+ for (int i = 0; i < _numMeshes; i++)
+ _meshes[i].changeMaterials(materials);
+}
+
void Model::Geoset::loadText(TextSplitter &ts, ResPtr<Material> *materials) {
ts.scanString("meshes %d", 1, &_numMeshes);
_meshes = new Mesh[_numMeshes];
@@ -316,6 +342,11 @@
}
}
+void Model::Mesh::changeMaterials(ResPtr<Material> *materials) {
+ for (int i = 0; i < _numFaces; i++)
+ _faces[i].changeMaterial(materials[_materialid[i]]);
+}
+
void Model::Mesh::loadText(TextSplitter &ts, ResPtr<Material> *materials) {
ts.scanString("name %32s", 1, _name);
ts.scanString("radius %f", 1, &_radius);
@@ -323,7 +354,8 @@
// In data001/rope_scale.3do, the shadow line is missing
if (std::sscanf(ts.currentLine(), "shadow %d", &_shadow) < 1) {
_shadow = 0;
- warning("Missing shadow directive in model\n");
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Missing shadow directive in model\n");
} else
ts.nextLine();
ts.scanString("geometrymode %d", 1, &_geometryMode);
@@ -367,18 +399,19 @@
ts.scanString("faces %d", 1, &_numFaces);
_faces = new Face[_numFaces];
+ _materialid = new int[_numFaces];
for (int i = 0; i < _numFaces; i++) {
- int num, material, type, geo, light, tex, verts;
+ int num, type, geo, light, tex, verts;
float extralight;
int readlen;
if (ts.eof())
error("Expected face data, got EOF\n");
- if (std::sscanf(ts.currentLine(), " %d: %d %i %d %d %d %f %d%n", &num, &material, &type, &geo, &light, &tex, &extralight, &verts, &readlen) < 8)
+ if (std::sscanf(ts.currentLine(), " %d: %d %i %d %d %d %f %d%n", &num, &_materialid[num], &type, &geo, &light, &tex, &extralight, &verts, &readlen) < 8)
error("Expected face data, got `%s'\n", ts.currentLine());
- _faces[num]._material = materials[material];
+ _faces[num]._material = materials[_materialid[num]];
_faces[num]._type = type;
_faces[num]._geo = geo;
_faces[num]._light = light;
Index: model.h
===================================================================
RCS file: /cvsroot/scummvm/residual/model.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- model.h 1 Jan 2005 12:27:56 -0000 1.9
+++ model.h 10 Jul 2005 18:57:27 -0000 1.10
@@ -34,7 +34,7 @@
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 reload(const CMap &cmap);
void draw() const;
~Model();
@@ -70,8 +70,9 @@
//private:
struct Face {
- void loadBinary(const char *&data, ResPtr<Material> *materials);
+ int loadBinary(const char *&data, ResPtr<Material> *materials);
void draw(float *vertices, float *vertNormals, float *textureVerts) const;
+ void changeMaterial(ResPtr<Material> materials);
~Face();
Material *_material;
@@ -85,8 +86,10 @@
struct Mesh {
void loadBinary(const char *&data, ResPtr<Material> *materials);
void loadText(TextSplitter &ts, ResPtr<Material> *materials);
+ void changeMaterials(ResPtr<Material> *materials);
void draw() const;
void update();
+ Mesh() : _numFaces(0) { }
~Mesh();
char _name[32];
@@ -94,6 +97,7 @@
int _shadow, _geometryMode, _lightingMode, _textureMode;
int _numVertices;
+ int *_materialid;
float *_vertices; // sets of 3
float *_verticesI;
float *_vertNormals; // sets of 3
@@ -109,6 +113,8 @@
struct Geoset {
void loadBinary(const char *&data, ResPtr<Material> *materials);
void loadText(TextSplitter &ts, ResPtr<Material> *materials);
+ void changeMaterials(ResPtr<Material> *materials);
+ Geoset() : _numMeshes(0) { }
~Geoset();
int _numMeshes;
@@ -116,6 +122,7 @@
};
int _numMaterials;
+ char (*_materialNames)[32];
ResPtr<Material> *_materials;
Vector3d _insertOffset;
int _numGeosets;
Index: registry.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/registry.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- registry.cpp 1 Jan 2005 12:27:56 -0000 1.11
+++ registry.cpp 10 Jul 2005 18:57:27 -0000 1.12
@@ -48,10 +48,10 @@
}
}
-const char *Registry::get(const char *key) const {
+const char *Registry::get(const char *key, const char *defval) const {
Group::const_iterator i = _settings.find(key);
if (i == _settings.end())
- return NULL;
+ return defval;
else
return i->second.c_str();
}
Index: registry.h
===================================================================
RCS file: /cvsroot/scummvm/residual/registry.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- registry.h 1 Jan 2005 10:23:16 -0000 1.6
+++ registry.h 10 Jul 2005 18:57:27 -0000 1.7
@@ -23,7 +23,7 @@
class Registry {
public:
- const char *get(const char *key) const;
+ const char *get(const char *key, const char *defval) const;
void set(const char *key, const char *val);
void save();
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- resource.cpp 8 Apr 2005 22:29:06 -0000 1.24
+++ resource.cpp 10 Jul 2005 18:57:27 -0000 1.25
@@ -40,7 +40,7 @@
ResourceLoader *g_resourceloader = NULL;
ResourceLoader::ResourceLoader() {
- const char *directory = g_registry->get("DataDir");
+ const char *directory = g_registry->get("DataDir", NULL);
std::string dir_str = (directory != NULL ? directory : ".");
dir_str += '/';
int lab_counter = 0;
@@ -148,7 +148,8 @@
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);
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Could not find bitmap %s\n", filename);
return NULL;
}
@@ -233,7 +234,8 @@
Block *b = getFileBlock(filename);
if (b == NULL) {
- warning("Could not find lipsynch file %s\n", filename);
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Could not find lipsynch file %s\n", filename);
result = NULL;
} else {
result = new LipSynch(filename, b->data(), b->len());
@@ -249,7 +251,12 @@
makeLower(fname);
CacheType::iterator i = _cache.find(fname);
if (i != _cache.end()) {
- return dynamic_cast<Material *>(i->second);
+ Material *material = dynamic_cast<Material *>(i->second);
+
+ // if the colormap has changed then we need to reload the material!
+ if (material->_cmap == &c)
+ return material;
+ _cache.erase(i, i);
}
Block *b = getFileBlock(filename);
Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- resource.h 18 Mar 2005 19:54:40 -0000 1.15
+++ resource.h 10 Jul 2005 18:57:27 -0000 1.16
@@ -104,13 +104,13 @@
ResourceLoader();
ResourceLoader(const ResourceLoader &);
~ResourceLoader() { }
-
+ const Lab *findFile(const char *filename) const;
private:
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 *> CacheType;
CacheType _cache;
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- scene.cpp 8 Apr 2005 12:41:19 -0000 1.42
+++ scene.cpp 10 Jul 2005 18:57:27 -0000 1.43
@@ -31,7 +31,7 @@
#include <cmath>
Scene::Scene(const char *name, const char *buf, int len) :
- _name(name) {
+ _name(name), locked(false) {
TextSplitter ts(buf, len);
char tempBuf[256];
@@ -48,7 +48,7 @@
ts.scanString(" numsetups %d", 1, &_numSetups);
_setups = new Setup[_numSetups];
for (int i = 0; i < _numSetups; i++)
- _setups[i].load(ts);
+ _setups[i].load(ts);
_currSetup = _setups;
_numSectors = -1;
@@ -111,6 +111,8 @@
ts.scanString(" background %256s", 1, buf);
_bkgndBm = g_resourceloader->loadBitmap(buf);
+ if(debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
+ printf("Loading scene bitmap: %s\n", buf);
// ZBuffer is optional
if (!ts.checkString("zbuffer")) {
@@ -118,6 +120,8 @@
} else {
ts.scanString(" zbuffer %256s", 1, buf);
_bkgndZBm = g_resourceloader->loadBitmap(buf);
+ if(debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
+ printf("Loading scene z-buffer bitmap: %s\n", buf);
}
ts.scanString(" position %f %f %f", 3, &_pos.x(), &_pos.y(), &_pos.z());
@@ -228,9 +232,17 @@
}
ObjectState *Scene::findState(const char *filename) {
+ // Check the different state objects for the bitmap
for (StateList::iterator i = _states.begin(); i != _states.end(); i++) {
- if (strcmp((*i)->bitmapFilename(), filename) == 0)
+ const char *file = (*i)->bitmapFilename();
+
+ if (strcmp(file, filename) == 0)
return *i;
+ if (strcasecmp(file, filename) == 0) {
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("State object request '%s' matches object '%s' but is the wrong case!", filename, file);
+ return *i;
+ }
}
return NULL;
}
Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- scene.h 8 Apr 2005 12:41:19 -0000 1.27
+++ scene.h 10 Jul 2005 18:57:27 -0000 1.28
@@ -73,7 +73,12 @@
int setup() const { return _currSetup - _setups; }
// Sector access functions
- int getSectorCount() { return _numSectors; }
+ int getSectorCount() {
+ // TODO: Find where this is called before we're initialized
+ if (this == NULL)
+ return 0;
+ return _numSectors;
+ }
Sector *getSectorBase(int id) {
if ((_numSectors >= 0) && (id < _numSectors))
return &_sectors[id];
@@ -114,6 +119,8 @@
float _intensity, _umbraangle, _penumbraangle;
};
+ bool locked;
+
private:
std::string _name;
Index: smush.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- smush.cpp 12 Jan 2005 23:26:04 -0000 1.60
+++ smush.cpp 10 Jul 2005 18:57:27 -0000 1.61
@@ -129,6 +129,7 @@
tag = _file.readUint32BE();
if (tag == MKID_BE('ANNO')) {
+printf("Announcement!\n");
size = _file.readUint32BE();
for (int l = 0; l < size; l++)
_file.readByte();
@@ -146,12 +147,14 @@
pos += READ_BE_UINT32(frame + pos + 4) + 8;
} else if (READ_BE_UINT32(frame + pos) == MKID_BE('Wave')) {
int decompressed_size = READ_BE_UINT32(frame + pos + 8);
+
if (decompressed_size < 0)
handleWave(frame + pos + 8 + 4 + 8, READ_BE_UINT32(frame + pos + 8 + 8));
else
+
handleWave(frame + pos + 8 + 4, decompressed_size);
pos += READ_BE_UINT32(frame + pos + 4) + 8;
- } else {
+ } else if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL) {
error("Smush::handleFrame() unknown tag");
}
} while (pos < size);
@@ -187,7 +190,7 @@
_freq = READ_LE_UINT32(f_header + pos + 8);
_channels = READ_LE_UINT32(f_header + pos + 12);
pos += 20;
- } else {
+ } else if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL){
error("Smush::handleFramesHeader() unknown tag");
}
} while (pos < size);
@@ -262,7 +265,8 @@
_inBuf = (char *)calloc(1, 16385);
if (_handle) {
- warning("zlibFile::open() File %s already opened", filename);
+ if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("zlibFile::open() File %s already opened", filename);
return false;
}
@@ -271,7 +275,8 @@
_handle = g_resourceloader->openNewStream(filename);
if (!_handle) {
- warning("zlibFile::open() zlibFile %s not found", filename);
+ if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("zlibFile::open() zlibFile %s not found", filename);
return false;
}
@@ -281,7 +286,8 @@
fread(_inBuf, 1, sizeof(char), _handle); flags = _inBuf[0]; // Flags
fread(_inBuf, 6, sizeof(char), _handle); // XFlags
- if (((flags & 0x04) != 0) || ((flags & 0x10) != 0)) // Xtra & Comment
+ // Xtra & Comment
+ if (((((flags & 0x04) != 0) || ((flags & 0x10) != 0))) && (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL))
error("zlibFile::open() Unsupported header flag");
if ((flags & 0x08) != 0) { // Orig. Name
@@ -298,7 +304,7 @@
_stream.zfree = NULL;
_stream.opaque = Z_NULL;
- if (inflateInit2(&_stream, -15) != Z_OK)
+ if (inflateInit2(&_stream, -15) != Z_OK && (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL))
error("zlibFile::open() inflateInit2 failed");
_stream.next_in = NULL;
@@ -330,7 +336,8 @@
bool fileEOF = false;
if (_handle == NULL) {
- error("zlibFile::read() File is not open!");
+ if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
+ error("zlibFile::read() File is not open!");
return 0;
}
@@ -353,17 +360,20 @@
result = inflate(&_stream, Z_NO_FLUSH);
if (result == Z_STREAM_END) { // EOF
- warning("zlibFile::read() Stream ended");
+ if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("zlibFile::read() Stream ended");
_fileDone = true;
break;
}
if (result == Z_DATA_ERROR) {
- warning("zlibFile::read() Decompression error");
+ if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("zlibFile::read() Decompression error");
_fileDone = true;
break;
}
if (result != Z_OK || fileEOF) {
- warning("zlibFile::read() Unknown decomp result: %d/%d\n", result, fileEOF);
+ if (debugLevel == DEBUG_SMUSH || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("zlibFile::read() Unknown decomp result: %d/%d\n", result, fileEOF);
_fileDone = true;
break;
}
Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- textobject.cpp 5 May 2005 21:23:17 -0000 1.27
+++ textobject.cpp 10 Jul 2005 18:57:27 -0000 1.28
@@ -228,7 +228,7 @@
x = 0;
g_driver->drawTextBitmap(x, height + _y, _textObjectHandle[i]);
- } else
+ } else if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
warning("TextObject::draw: Unknown justification code (%d)!", _justify);
height += _bitmapHeightPtr[i];
Index: timer.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/timer.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- timer.cpp 1 Jan 2005 12:27:56 -0000 1.12
+++ timer.cpp 10 Jul 2005 18:57:27 -0000 1.13
@@ -104,7 +104,8 @@
}
}
- warning("Couldn't find free timer slot!");
+ if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
+ warning("Couldn't find free timer slot!");
return false;
}
Index: walkplane.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/walkplane.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- walkplane.cpp 28 Mar 2005 01:56:40 -0000 1.14
+++ walkplane.cpp 10 Jul 2005 18:57:27 -0000 1.15
@@ -58,7 +58,7 @@
_type = 0x4000;
else if (strstr(buf, "chernobyl"))
_type = 0x8000;
- else
+ else if (debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
error("Unknown sector type '%s' in room setup", buf);
ts.scanString(" default visibility %256s", 1, buf);
More information about the Scummvm-git-logs
mailing list