mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 15:16:46 +00:00
changed to proper convetion naming
This commit is contained in:
parent
39a4b54d30
commit
b00502ad31
12
bitmap.cpp
12
bitmap.cpp
@ -36,17 +36,17 @@ Bitmap::Bitmap(const char *filename, const char *data, int len) :
|
||||
error("Invalid magic loading bitmap\n");
|
||||
|
||||
int codec = READ_LE_UINT32(data + 8);
|
||||
_num_images = READ_LE_UINT32(data + 16);
|
||||
_numImages = READ_LE_UINT32(data + 16);
|
||||
_x = READ_LE_UINT32(data + 20);
|
||||
_y = READ_LE_UINT32(data + 24);
|
||||
_format = READ_LE_UINT32(data + 32);
|
||||
_width = READ_LE_UINT32(data + 128);
|
||||
_height = READ_LE_UINT32(data + 132);
|
||||
_curr_image = 1;
|
||||
_currImage = 1;
|
||||
|
||||
_data = new char *[_num_images];
|
||||
_data = new char *[_numImages];
|
||||
int pos = 0x88;
|
||||
for (int i = 0; i < _num_images; i++) {
|
||||
for (int i = 0; i < _numImages; i++) {
|
||||
_data[i] = new char[2 * _width * _height];
|
||||
if (codec == 0) {
|
||||
memcpy(_data[i], data + pos, 2 * _width * _height);
|
||||
@ -69,14 +69,14 @@ Bitmap::Bitmap(const char *filename, const char *data, int len) :
|
||||
}
|
||||
|
||||
void Bitmap::draw() const {
|
||||
if (_curr_image == 0)
|
||||
if (_currImage == 0)
|
||||
return;
|
||||
|
||||
g_driver->drawBitmap(this);
|
||||
}
|
||||
|
||||
Bitmap::~Bitmap() {
|
||||
for (int i = 0; i < _num_images; i++)
|
||||
for (int i = 0; i < _numImages; i++)
|
||||
delete[] _data[i];
|
||||
|
||||
delete[] _data;
|
||||
|
14
bitmap.h
14
bitmap.h
@ -30,27 +30,27 @@ public:
|
||||
void draw() const;
|
||||
|
||||
// Set which image in an animated bitmap to use
|
||||
void setNumber(int n) { _curr_image = n; }
|
||||
void setNumber(int n) { _currImage = n; }
|
||||
|
||||
int numImages() const { return _num_images; }
|
||||
int currentImage() const { return _curr_image; }
|
||||
int numImages() const { return _numImages; }
|
||||
int currentImage() const { return _currImage; }
|
||||
|
||||
int width() const { return _width; }
|
||||
int height() const { return _height; }
|
||||
int x() const { return _x; }
|
||||
int y() const { return _y; }
|
||||
|
||||
char *getData() { return _data[_curr_image]; }
|
||||
char *getData() { return _data[_currImage]; }
|
||||
|
||||
~Bitmap();
|
||||
|
||||
//private:
|
||||
char **_data;
|
||||
int _num_images, _curr_image;
|
||||
int _numImages, _currImage;
|
||||
int _width, _height, _x, _y;
|
||||
int _format;
|
||||
int _num_tex;
|
||||
GLuint *_tex_ids;
|
||||
int _numTex;
|
||||
GLuint *_texIds;
|
||||
bool _hasTransparency;
|
||||
};
|
||||
|
||||
|
32
costume.cpp
32
costume.cpp
@ -608,11 +608,11 @@ void Costume::Chore::load(Costume *owner, TextSplitter &ts) {
|
||||
for (int i = 0; i < _numTracks; i++) {
|
||||
int compID, numKeys;
|
||||
ts.scanString(" %d %d", 2, &compID, &numKeys);
|
||||
_tracks[i]._compID = compID;
|
||||
_tracks[i]._numKeys = numKeys;
|
||||
_tracks[i]._keys = new TrackKey[numKeys];
|
||||
_tracks[i].compID = compID;
|
||||
_tracks[i].numKeys = numKeys;
|
||||
_tracks[i].keys = new TrackKey[numKeys];
|
||||
for (int j = 0; j < numKeys; j++) {
|
||||
ts.scanString(" %d %d", 2, &_tracks[i]._keys[j]._time, &_tracks[i]._keys[j]._value);
|
||||
ts.scanString(" %d %d", 2, &_tracks[i].keys[j].time, &_tracks[i].keys[j].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -639,7 +639,7 @@ void Costume::Chore::stop() {
|
||||
_hasPlayed = false;
|
||||
|
||||
for (int i = 0; i < _numTracks; i++) {
|
||||
Component *comp = _owner->_components[_tracks[i]._compID];
|
||||
Component *comp = _owner->_components[_tracks[i].compID];
|
||||
if (comp != NULL)
|
||||
comp->reset();
|
||||
}
|
||||
@ -647,15 +647,15 @@ void Costume::Chore::stop() {
|
||||
|
||||
void Costume::Chore::setKeys(int startTime, int stopTime) {
|
||||
for (int i = 0; i < _numTracks; i++) {
|
||||
Component *comp = _owner->_components[_tracks[i]._compID];
|
||||
Component *comp = _owner->_components[_tracks[i].compID];
|
||||
if (comp == NULL)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < _tracks[i]._numKeys; j++) {
|
||||
if (_tracks[i]._keys[j]._time > stopTime)
|
||||
for (int j = 0; j < _tracks[i].numKeys; j++) {
|
||||
if (_tracks[i].keys[j].time > stopTime)
|
||||
break;
|
||||
if (_tracks[i]._keys[j]._time > startTime)
|
||||
comp->setKey(_tracks[i]._keys[j]._value);
|
||||
if (_tracks[i].keys[j].time > startTime)
|
||||
comp->setKey(_tracks[i].keys[j].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -754,12 +754,12 @@ void Costume::update() {
|
||||
}
|
||||
|
||||
void Costume::setHead(int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw) {
|
||||
_head._joint1 = joint1;
|
||||
_head._joint2 = joint2;
|
||||
_head._joint3 = joint3;
|
||||
_head._maxRoll = maxRoll;
|
||||
_head._maxPitch = maxPitch;
|
||||
_head._maxYaw = maxYaw;
|
||||
_head.joint1 = joint1;
|
||||
_head.joint2 = joint2;
|
||||
_head.joint3 = joint3;
|
||||
_head.maxRoll = maxRoll;
|
||||
_head.maxPitch = maxPitch;
|
||||
_head.maxYaw = maxYaw;
|
||||
}
|
||||
|
||||
void Costume::setPosRotate(Vector3d pos, float pitch, float yaw, float roll) {
|
||||
|
20
costume.h
20
costume.h
@ -78,22 +78,22 @@ private:
|
||||
Component **_components;
|
||||
|
||||
struct TrackKey {
|
||||
int _time, _value;
|
||||
int time, value;
|
||||
};
|
||||
|
||||
struct ChoreTrack {
|
||||
int _compID;
|
||||
int _numKeys;
|
||||
TrackKey *_keys;
|
||||
int compID;
|
||||
int numKeys;
|
||||
TrackKey *keys;
|
||||
};
|
||||
|
||||
struct Head {
|
||||
int _joint1;
|
||||
int _joint2;
|
||||
int _joint3;
|
||||
float _maxRoll;
|
||||
float _maxPitch;
|
||||
float _maxYaw;
|
||||
int joint1;
|
||||
int joint2;
|
||||
int joint3;
|
||||
float maxRoll;
|
||||
float maxPitch;
|
||||
float maxYaw;
|
||||
} _head;
|
||||
|
||||
class Chore {
|
||||
|
@ -413,14 +413,14 @@ void Driver::updateHierachyNode(const Model::HierNode *node) {
|
||||
void Driver::createBitmap(Bitmap *bitmap) {
|
||||
if (bitmap->_format == 1) {
|
||||
bitmap->_hasTransparency = false;
|
||||
bitmap->_num_tex = ((bitmap->_width + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
|
||||
bitmap->_numTex = ((bitmap->_width + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
|
||||
((bitmap->_height + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE);
|
||||
bitmap->_tex_ids = new GLuint[bitmap->_num_tex * bitmap->_num_images];
|
||||
glGenTextures(bitmap->_num_tex * bitmap->_num_images, bitmap->_tex_ids);
|
||||
bitmap->_texIds = new GLuint[bitmap->_numTex * bitmap->_numImages];
|
||||
glGenTextures(bitmap->_numTex * bitmap->_numImages, bitmap->_texIds);
|
||||
|
||||
byte *texData = new byte[4 * bitmap->_width * bitmap->_height];
|
||||
|
||||
for (int pic = 0; pic < bitmap->_num_images; pic++) {
|
||||
for (int pic = 0; pic < bitmap->_numImages; pic++) {
|
||||
// Convert data to 32-bit RGBA format
|
||||
byte *texDataPtr = texData;
|
||||
uint16 *bitmapData = reinterpret_cast<uint16 *>(bitmap->_data[pic]);
|
||||
@ -440,8 +440,8 @@ void Driver::createBitmap(Bitmap *bitmap) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < bitmap->_num_tex; i++) {
|
||||
glBindTexture(GL_TEXTURE_2D, bitmap->_tex_ids[bitmap->_num_tex * pic + i]);
|
||||
for (int i = 0; i < bitmap->_numTex; i++) {
|
||||
glBindTexture(GL_TEXTURE_2D, bitmap->_texIds[bitmap->_numTex * pic + i]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
@ -452,13 +452,13 @@ void Driver::createBitmap(Bitmap *bitmap) {
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap->_width);
|
||||
|
||||
int cur_tex_idx = bitmap->_num_tex * pic;
|
||||
int cur_tex_idx = bitmap->_numTex * pic;
|
||||
|
||||
for (int y = 0; y < bitmap->_height; y += BITMAP_TEXTURE_SIZE) {
|
||||
for (int x = 0; x < bitmap->_width; x += BITMAP_TEXTURE_SIZE) {
|
||||
int width = (x + BITMAP_TEXTURE_SIZE >= bitmap->_width) ? (bitmap->_width - x) : BITMAP_TEXTURE_SIZE;
|
||||
int height = (y + BITMAP_TEXTURE_SIZE >= bitmap->_height) ? (bitmap->_height - y) : BITMAP_TEXTURE_SIZE;
|
||||
glBindTexture(GL_TEXTURE_2D, bitmap->_tex_ids[cur_tex_idx]);
|
||||
glBindTexture(GL_TEXTURE_2D, bitmap->_texIds[cur_tex_idx]);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
texData + (y * 4 * bitmap->_width) + (4 * x));
|
||||
cur_tex_idx++;
|
||||
@ -470,7 +470,7 @@ void Driver::createBitmap(Bitmap *bitmap) {
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
delete [] texData;
|
||||
} else {
|
||||
for (int pic = 0; pic < bitmap->_num_images; pic++) {
|
||||
for (int pic = 0; pic < bitmap->_numImages; pic++) {
|
||||
uint16 *zbufPtr = reinterpret_cast<uint16 *>(bitmap->_data[pic]);
|
||||
for (int i = 0; i < (bitmap->_width * bitmap->_height); i++) {
|
||||
uint16 val = READ_LE_UINT16(bitmap->_data[pic] + 2 * i);
|
||||
@ -488,7 +488,7 @@ void Driver::createBitmap(Bitmap *bitmap) {
|
||||
}
|
||||
}
|
||||
}
|
||||
bitmap->_tex_ids = NULL;
|
||||
bitmap->_texIds = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,10 +514,10 @@ void Driver::drawBitmap(const Bitmap *bitmap) {
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(bitmap->_x, 480 - (bitmap->_y + bitmap->_height), bitmap->_width, bitmap->_height);
|
||||
int cur_tex_idx = bitmap->_num_tex * (bitmap->_curr_image - 1);
|
||||
int cur_tex_idx = bitmap->_numTex * (bitmap->_currImage - 1);
|
||||
for (int y = bitmap->_y; y < (bitmap->_y + bitmap->_height); y += BITMAP_TEXTURE_SIZE) {
|
||||
for (int x = bitmap->_x; x < (bitmap->_x + bitmap->_width); x += BITMAP_TEXTURE_SIZE) {
|
||||
glBindTexture(GL_TEXTURE_2D, bitmap->_tex_ids[cur_tex_idx]);
|
||||
glBindTexture(GL_TEXTURE_2D, bitmap->_texIds[cur_tex_idx]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex2i(x, y);
|
||||
@ -542,22 +542,22 @@ void Driver::drawBitmap(const Bitmap *bitmap) {
|
||||
if ((!ZBUFFER_GLOBAL) || SCREENBLOCKS_GLOBAL)
|
||||
return;
|
||||
|
||||
g_driver->drawDepthBitmap(bitmap->_x, bitmap->_y, bitmap->_width, bitmap->_height, bitmap->_data[bitmap->_curr_image - 1]);
|
||||
g_driver->drawDepthBitmap(bitmap->_x, bitmap->_y, bitmap->_width, bitmap->_height, bitmap->_data[bitmap->_currImage - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
void Driver::destroyBitmap(Bitmap *bitmap) {
|
||||
if (bitmap->_tex_ids) {
|
||||
glDeleteTextures(bitmap->_num_tex * bitmap->_num_images, bitmap->_tex_ids);
|
||||
delete[] bitmap->_tex_ids;
|
||||
if (bitmap->_texIds) {
|
||||
glDeleteTextures(bitmap->_numTex * bitmap->_numImages, bitmap->_texIds);
|
||||
delete[] bitmap->_texIds;
|
||||
}
|
||||
}
|
||||
|
||||
void Driver::createMaterial(Material *material, const char *data, const CMap *cmap) {
|
||||
material->_textures = new GLuint[material->_num_images];
|
||||
glGenTextures(material->_num_images, material->_textures);
|
||||
material->_textures = new GLuint[material->_numImages];
|
||||
glGenTextures(material->_numImages, material->_textures);
|
||||
char *texdata = new char[material->_width * material->_height * 4];
|
||||
for (int i = 0; i < material->_num_images; i++) {
|
||||
for (int i = 0; i < material->_numImages; i++) {
|
||||
char *texdatapos = texdata;
|
||||
for (int y = 0; y < material->_height; y++) {
|
||||
for (int x = 0; x < material->_width; x++) {
|
||||
@ -585,14 +585,14 @@ void Driver::createMaterial(Material *material, const char *data, const CMap *cm
|
||||
}
|
||||
|
||||
void Driver::selectMaterial(const Material *material) {
|
||||
glBindTexture(GL_TEXTURE_2D, material->_textures[material->_curr_image]);
|
||||
glBindTexture(GL_TEXTURE_2D, material->_textures[material->_currImage]);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glScalef(1.0f / material->_width, 1.0f / material->_height, 1);
|
||||
}
|
||||
|
||||
void Driver::destroyMaterial(Material *material) {
|
||||
glDeleteTextures(material->_num_images, material->_textures);
|
||||
glDeleteTextures(material->_numImages, material->_textures);
|
||||
delete[] material->_textures;
|
||||
}
|
||||
|
||||
|
10
engine.cpp
10
engine.cpp
@ -125,7 +125,7 @@ void Engine::mainLoop() {
|
||||
|
||||
if (_currScene != NULL) {
|
||||
// Update actor costumes
|
||||
for (actor_list_type::iterator i = _actors.begin(); i != _actors.end(); i++) {
|
||||
for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
|
||||
Actor *a = *i;
|
||||
if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
|
||||
a->update();
|
||||
@ -166,7 +166,7 @@ void Engine::mainLoop() {
|
||||
_currScene->setupCamera();
|
||||
|
||||
// Draw actors
|
||||
for (actor_list_type::iterator i = _actors.begin(); i != _actors.end(); i++) {
|
||||
for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
|
||||
Actor *a = *i;
|
||||
if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
|
||||
a->draw();
|
||||
@ -175,7 +175,7 @@ void Engine::mainLoop() {
|
||||
}
|
||||
|
||||
// Draw text
|
||||
for (text_list_type::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) {
|
||||
for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) {
|
||||
(*i)->draw();
|
||||
}
|
||||
|
||||
@ -198,11 +198,11 @@ void Engine::mainLoop() {
|
||||
}
|
||||
|
||||
lua_beginblock();
|
||||
set_frameTime(_frameTime);
|
||||
setFrameTime(_frameTime);
|
||||
lua_endblock();
|
||||
|
||||
lua_beginblock();
|
||||
set_movieTime(_movieTime);
|
||||
setMovieTime(_movieTime);
|
||||
lua_endblock();
|
||||
|
||||
if (SHOWFPS_GLOBAL) {
|
||||
|
16
engine.h
16
engine.h
@ -112,22 +112,22 @@ public:
|
||||
Scene *currScene() { return _currScene; }
|
||||
const char *sceneName() const { return _currScene->name(); }
|
||||
|
||||
typedef std::list<Actor *> actor_list_type;
|
||||
actor_list_type::const_iterator actorsBegin() const {
|
||||
typedef std::list<Actor *> ActorListType;
|
||||
ActorListType::const_iterator actorsBegin() const {
|
||||
return _actors.begin();
|
||||
}
|
||||
actor_list_type::const_iterator actorsEnd() const {
|
||||
ActorListType::const_iterator actorsEnd() const {
|
||||
return _actors.end();
|
||||
}
|
||||
|
||||
void setSelectedActor(Actor *a) { _selectedActor = a; }
|
||||
Actor *selectedActor() { return _selectedActor; }
|
||||
|
||||
typedef std::list<TextObject *> text_list_type;
|
||||
text_list_type::const_iterator textsBegin() const {
|
||||
typedef std::list<TextObject *> TextListType;
|
||||
TextListType::const_iterator textsBegin() const {
|
||||
return _textObjects.begin();
|
||||
}
|
||||
text_list_type::const_iterator textsEnd() const {
|
||||
TextListType::const_iterator textsEnd() const {
|
||||
return _textObjects.end();
|
||||
}
|
||||
void registerTextObject(TextObject *a) { _textObjects.push_back(a); }
|
||||
@ -166,9 +166,9 @@ private:
|
||||
|
||||
bool _controlsEnabled[SDLK_EXTRA_LAST];
|
||||
|
||||
actor_list_type _actors;
|
||||
ActorListType _actors;
|
||||
Actor *_selectedActor;
|
||||
text_list_type _textObjects;
|
||||
TextListType _textObjects;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -41,8 +41,8 @@ void KeyframeAnim::loadBinary(const char *data, int len) {
|
||||
_numMarkers = READ_LE_UINT32(data + 68);
|
||||
_markers = new Marker[_numMarkers];
|
||||
for (int i = 0; i < _numMarkers; i++) {
|
||||
_markers[i]._frame = get_float(data + 72 + 4 * i);
|
||||
_markers[i]._val = READ_LE_UINT32(data + 104 + 4 * i);
|
||||
_markers[i].frame = get_float(data + 72 + 4 * i);
|
||||
_markers[i].val = READ_LE_UINT32(data + 104 + 4 * i);
|
||||
}
|
||||
|
||||
_nodes = new KeyframeNode *[_numJoints];
|
||||
@ -70,7 +70,7 @@ void KeyframeAnim::loadText(TextSplitter &ts) {
|
||||
ts.scanString("markers %d", 1, &_numMarkers);
|
||||
_markers = new Marker[_numMarkers];
|
||||
for (int i = 0; i < _numMarkers; i++)
|
||||
ts.scanString("%f %d", 2, &_markers[i]._frame, &_markers[i]._val);
|
||||
ts.scanString("%f %d", 2, &_markers[i].frame, &_markers[i].val);
|
||||
} else {
|
||||
_numMarkers = 0;
|
||||
_markers = NULL;
|
||||
|
@ -41,8 +41,8 @@ private:
|
||||
int _numMarkers;
|
||||
|
||||
struct Marker {
|
||||
float _frame;
|
||||
int _val;
|
||||
float frame;
|
||||
int val;
|
||||
};
|
||||
Marker *_markers;
|
||||
|
||||
@ -61,6 +61,7 @@ private:
|
||||
~KeyframeNode();
|
||||
|
||||
void animate(Model::HierNode &node, float frame, int priority) const;
|
||||
|
||||
char _meshName[32];
|
||||
int _numEntries;
|
||||
KeyframeEntry *_entries;
|
||||
|
24
lab.cpp
24
lab.cpp
@ -56,8 +56,8 @@ bool Lab::open(const char *filename) {
|
||||
std::string fname = string_table + fname_offset;
|
||||
std::transform(fname.begin(), fname.end(), fname.begin(), tolower);
|
||||
|
||||
_file_map.insert(std::make_pair(fname, LabEntry(start, size)));
|
||||
_file_map.size();
|
||||
_fileMap.insert(std::make_pair(fname, LabEntry(start, size)));
|
||||
_fileMap.size();
|
||||
}
|
||||
|
||||
delete [] string_table;
|
||||
@ -65,12 +65,12 @@ bool Lab::open(const char *filename) {
|
||||
}
|
||||
|
||||
bool Lab::fileExists(const char *filename) const {
|
||||
return find_filename(filename) != _file_map.end();
|
||||
return findFilename(filename) != _fileMap.end();
|
||||
}
|
||||
|
||||
Block *Lab::getFileBlock(const char *filename) const {
|
||||
file_map_type::const_iterator i = find_filename(filename);
|
||||
if (i == _file_map.end())
|
||||
FileMapType::const_iterator i = findFilename(filename);
|
||||
if (i == _fileMap.end())
|
||||
return NULL;
|
||||
|
||||
std::fseek(_f, i->second.offset, SEEK_SET);
|
||||
@ -86,8 +86,8 @@ Block *Lab::getFileBlock(const char *filename) const {
|
||||
}
|
||||
|
||||
std::FILE *Lab::openNewStream(const char *filename) const {
|
||||
file_map_type::const_iterator i = find_filename(filename);
|
||||
if (i == _file_map.end())
|
||||
FileMapType::const_iterator i = findFilename(filename);
|
||||
if (i == _fileMap.end())
|
||||
return NULL;
|
||||
|
||||
std::fseek(_f, i->second.offset, SEEK_SET);
|
||||
@ -96,22 +96,22 @@ std::FILE *Lab::openNewStream(const char *filename) const {
|
||||
}
|
||||
|
||||
int Lab::fileLength(const char *filename) const {
|
||||
file_map_type::const_iterator i = find_filename(filename);
|
||||
if (i == _file_map.end())
|
||||
FileMapType::const_iterator i = findFilename(filename);
|
||||
if (i == _fileMap.end())
|
||||
return -1;
|
||||
|
||||
return i->second.len;
|
||||
}
|
||||
|
||||
Lab::file_map_type::const_iterator Lab::find_filename(const char *filename) const {
|
||||
Lab::FileMapType::const_iterator Lab::findFilename(const char *filename) const {
|
||||
std::string s = filename;
|
||||
std::transform(s.begin(), s.end(), s.begin(), tolower);
|
||||
return _file_map.find(s);
|
||||
return _fileMap.find(s);
|
||||
}
|
||||
|
||||
void Lab::close() {
|
||||
if (_f != NULL)
|
||||
std::fclose(_f);
|
||||
_f = NULL;
|
||||
_file_map.clear();
|
||||
_fileMap.clear();
|
||||
}
|
||||
|
6
lab.h
6
lab.h
@ -59,10 +59,10 @@ private:
|
||||
};
|
||||
|
||||
std::FILE *_f;
|
||||
typedef std::map<std::string, LabEntry> file_map_type;
|
||||
file_map_type _file_map;
|
||||
typedef std::map<std::string, LabEntry> FileMapType;
|
||||
FileMapType _fileMap;
|
||||
|
||||
file_map_type::const_iterator find_filename(const char *filename) const;
|
||||
FileMapType::const_iterator findFilename(const char *filename) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -94,7 +94,7 @@ std::string Localizer::localize(const char *str) const {
|
||||
return str;
|
||||
|
||||
std::string key(str + 1, slash2 - str - 1);
|
||||
string_map::const_iterator i = _entries.find(key);
|
||||
StringMap::const_iterator i = _entries.find(key);
|
||||
if (i == _entries.end())
|
||||
return str;
|
||||
|
||||
|
@ -33,8 +33,8 @@ private:
|
||||
|
||||
static Localizer *_instance;
|
||||
|
||||
typedef std::map<std::string, std::string> string_map;
|
||||
string_map _entries;
|
||||
typedef std::map<std::string, std::string> StringMap;
|
||||
StringMap _entries;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
10
lua.cpp
10
lua.cpp
@ -658,7 +658,7 @@ static void SetActorFollowBoxes() { // Constrain actor to walkplanes?
|
||||
static void GetVisibleThings() {
|
||||
lua_Object result = lua_createtable();
|
||||
Actor *sel = Engine::instance()->selectedActor();
|
||||
for (Engine::actor_list_type::const_iterator i = Engine::instance()->actorsBegin(); i != Engine::instance()->actorsEnd(); i++) {
|
||||
for (Engine::ActorListType::const_iterator i = Engine::instance()->actorsBegin(); i != Engine::instance()->actorsEnd(); i++) {
|
||||
if (!(*i)->inSet(Engine::instance()->sceneName()))
|
||||
continue;
|
||||
if (sel->angleTo(*(*i)) < 90) {
|
||||
@ -911,14 +911,14 @@ void ImSetSequence() {
|
||||
Mixer::instance()->setImuseSeq(seq);
|
||||
}
|
||||
|
||||
void set_frameTime(float frameTime) {
|
||||
void setFrameTime(float frameTime) {
|
||||
lua_pushobject(lua_getglobal("system"));
|
||||
lua_pushstring("frameTime");
|
||||
lua_pushnumber(frameTime);
|
||||
lua_settable();
|
||||
}
|
||||
|
||||
void set_movieTime(float movieTime) {
|
||||
void setMovieTime(float movieTime) {
|
||||
lua_pushobject(lua_getglobal("system"));
|
||||
lua_pushstring("movieTime");
|
||||
lua_pushnumber(movieTime);
|
||||
@ -1006,7 +1006,7 @@ static void KillTextObject() {
|
||||
|
||||
textID = lua_getstring(lua_getparam(1));
|
||||
|
||||
for (Engine::text_list_type::const_iterator i = Engine::instance()->textsBegin();
|
||||
for (Engine::TextListType::const_iterator i = Engine::instance()->textsBegin();
|
||||
i != Engine::instance()->textsEnd(); i++) {
|
||||
TextObject *textO = *i;
|
||||
|
||||
@ -1063,7 +1063,7 @@ static void ChangeTextObject() {
|
||||
lua_Object tableObj = lua_getparam(2);
|
||||
TextObject *modifyObject = NULL;
|
||||
|
||||
for (Engine::text_list_type::const_iterator i = Engine::instance()->textsBegin(); i != Engine::instance()->textsEnd(); i++) {
|
||||
for (Engine::TextListType::const_iterator i = Engine::instance()->textsBegin(); i != Engine::instance()->textsEnd(); i++) {
|
||||
TextObject *textO = *i;
|
||||
|
||||
if (strstr(textO->name(), textID)) {
|
||||
|
4
lua.h
4
lua.h
@ -30,10 +30,10 @@ void register_lua();
|
||||
int bundle_dofile(const char *filename);
|
||||
|
||||
// Set system.frameTime
|
||||
void set_frameTime(float frameTime);
|
||||
void setFrameTime(float frameTime);
|
||||
|
||||
// Set smush.movieTime
|
||||
void set_movieTime(float movieTime);
|
||||
void setMovieTime(float movieTime);
|
||||
|
||||
// Get the event handler function with the given name, pushing the handler
|
||||
// object if appropriate
|
||||
|
10
material.cpp
10
material.cpp
@ -27,16 +27,16 @@ Material::Material(const char *filename, const char *data, int len, const CMap &
|
||||
if (len < 4 || memcmp(data, "MAT ", 4) != 0)
|
||||
error("invalid magic loading texture\n");
|
||||
|
||||
_num_images = READ_LE_UINT32(data + 12);
|
||||
_curr_image = 0;
|
||||
_width = READ_LE_UINT32(data + 76 + _num_images * 40);
|
||||
_height = READ_LE_UINT32(data + 80 + _num_images * 40);
|
||||
_numImages = READ_LE_UINT32(data + 12);
|
||||
_currImage = 0;
|
||||
_width = READ_LE_UINT32(data + 76 + _numImages * 40);
|
||||
_height = READ_LE_UINT32(data + 80 + _numImages * 40);
|
||||
|
||||
if ((_width == 0) || (_height == 0)) {
|
||||
warning("bad texture size (%dx%d) for texture %s\n", _width, _height, filename);
|
||||
}
|
||||
|
||||
data += 100 + _num_images * 40;
|
||||
data += 100 + _numImages * 40;
|
||||
|
||||
g_driver->createMaterial(this, data, &cmap);
|
||||
}
|
||||
|
@ -34,15 +34,15 @@ public:
|
||||
void select() const;
|
||||
|
||||
// Set which image in an animated texture to use
|
||||
void setNumber(int n) { _curr_image = n; }
|
||||
void setNumber(int n) { _currImage = n; }
|
||||
|
||||
int numImages() const { return _num_images; }
|
||||
int currentImage() const { return _curr_image; }
|
||||
int numImages() const { return _numImages; }
|
||||
int currentImage() const { return _currImage; }
|
||||
|
||||
~Material();
|
||||
|
||||
//private:
|
||||
int _num_images, _curr_image;
|
||||
int _numImages, _currImage;
|
||||
int _width, _height;
|
||||
GLuint *_textures;
|
||||
};
|
||||
|
@ -54,7 +54,7 @@ Registry *Registry::instance() {
|
||||
}
|
||||
|
||||
const char *Registry::get(const char *key) const {
|
||||
group::const_iterator i = _settings.find(key);
|
||||
Group::const_iterator i = _settings.find(key);
|
||||
if (i == _settings.end())
|
||||
return NULL;
|
||||
else
|
||||
@ -88,7 +88,7 @@ void Registry::save() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (group::iterator i = _settings.begin(); i != _settings.end(); i++)
|
||||
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);
|
||||
|
@ -35,8 +35,8 @@ private:
|
||||
|
||||
static Registry *_instance;
|
||||
|
||||
typedef std::map<std::string, std::string> group;
|
||||
group _settings;
|
||||
typedef std::map<std::string, std::string> Group;
|
||||
Group _settings;
|
||||
bool _dirty;
|
||||
};
|
||||
|
||||
|
16
resource.cpp
16
resource.cpp
@ -142,7 +142,7 @@ int ResourceLoader::fileLength(const char *filename) const {
|
||||
Bitmap *ResourceLoader::loadBitmap(const char *filename) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<Bitmap *>(i->second);
|
||||
}
|
||||
@ -162,7 +162,7 @@ Bitmap *ResourceLoader::loadBitmap(const char *filename) {
|
||||
CMap *ResourceLoader::loadColormap(const char *filename) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<CMap *>(i->second);
|
||||
@ -191,7 +191,7 @@ Costume *ResourceLoader::loadCostume(const char *filename, Costume *prevCost) {
|
||||
KeyframeAnim *ResourceLoader::loadKeyframe(const char *filename) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<KeyframeAnim *>(i->second);
|
||||
}
|
||||
@ -210,7 +210,7 @@ LipSynch *ResourceLoader::loadLipSynch(const char *filename) {
|
||||
LipSynch *result;
|
||||
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<LipSynch *>(i->second);
|
||||
}
|
||||
@ -231,7 +231,7 @@ LipSynch *ResourceLoader::loadLipSynch(const char *filename) {
|
||||
Material *ResourceLoader::loadMaterial(const char *filename, const CMap &c) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<Material *>(i->second);
|
||||
}
|
||||
@ -248,7 +248,7 @@ Material *ResourceLoader::loadMaterial(const char *filename, const CMap &c) {
|
||||
Model *ResourceLoader::loadModel(const char *filename, const CMap &c) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<Model *>(i->second);
|
||||
}
|
||||
@ -265,7 +265,7 @@ Model *ResourceLoader::loadModel(const char *filename, const CMap &c) {
|
||||
Sound *ResourceLoader::loadSound(const char *filename) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end()) {
|
||||
return dynamic_cast<Sound *>(i->second);
|
||||
}
|
||||
@ -282,7 +282,7 @@ Sound *ResourceLoader::loadSound(const char *filename) {
|
||||
void ResourceLoader::uncache(const char *filename) {
|
||||
std::string fname = filename;
|
||||
makeLower(fname);
|
||||
cache_type::iterator i = _cache.find(fname);
|
||||
CacheType::iterator i = _cache.find(fname);
|
||||
if (i != _cache.end())
|
||||
_cache.erase(i);
|
||||
}
|
||||
|
@ -118,8 +118,8 @@ private:
|
||||
|
||||
const Lab *findFile(const char *filename) const;
|
||||
|
||||
typedef std::map<std::string, Resource *> cache_type;
|
||||
cache_type _cache;
|
||||
typedef std::map<std::string, Resource *> CacheType;
|
||||
CacheType _cache;
|
||||
|
||||
// Shut up pointless g++ warning
|
||||
friend class dummy;
|
||||
|
10
scene.cpp
10
scene.cpp
@ -104,14 +104,14 @@ void Scene::Setup::load(TextSplitter &ts) {
|
||||
_name = buf;
|
||||
|
||||
ts.scanString(" background %256s", 1, buf);
|
||||
_bkgnd_bm = ResourceLoader::instance()->loadBitmap(buf);
|
||||
_bkgndBm = ResourceLoader::instance()->loadBitmap(buf);
|
||||
|
||||
// ZBuffer is optional
|
||||
if (!ts.checkString("zbuffer")) {
|
||||
_bkgnd_zbm = NULL;
|
||||
_bkgndZBm = NULL;
|
||||
} else {
|
||||
ts.scanString(" zbuffer %256s", 1, buf);
|
||||
_bkgnd_zbm = ResourceLoader::instance()->loadBitmap(buf);
|
||||
_bkgndZBm = ResourceLoader::instance()->loadBitmap(buf);
|
||||
}
|
||||
|
||||
ts.scanString(" position %f %f %f", 3, &_pos.x(), &_pos.y(), &_pos.z());
|
||||
@ -164,8 +164,8 @@ void Scene::setSetup(int num) {
|
||||
if (!SCREENBLOCKS_GLOBAL)
|
||||
return;
|
||||
|
||||
if (_currSetup->_bkgnd_zbm)
|
||||
screenBlocksInit(_currSetup->_bkgnd_zbm->getData() );
|
||||
if (_currSetup->_bkgndZBm)
|
||||
screenBlocksInit(_currSetup->_bkgndZBm->getData() );
|
||||
else
|
||||
screenBlocksInitEmpty();
|
||||
}
|
||||
|
10
scene.h
10
scene.h
@ -39,14 +39,14 @@ public:
|
||||
~Scene();
|
||||
|
||||
void drawBackground() const {
|
||||
if (_currSetup->_bkgnd_zbm != NULL) // Some screens have no zbuffer mask (eg, Alley)
|
||||
_currSetup->_bkgnd_zbm->draw();
|
||||
if (_currSetup->_bkgndZBm != NULL) // Some screens have no zbuffer mask (eg, Alley)
|
||||
_currSetup->_bkgndZBm->draw();
|
||||
|
||||
if (_currSetup->_bkgnd_bm == NULL) {
|
||||
if (_currSetup->_bkgndBm == NULL) {
|
||||
error("Null background for setup %s in %s", _currSetup->_name.c_str(), _name.c_str());
|
||||
return;
|
||||
}
|
||||
_currSetup->_bkgnd_bm->draw();
|
||||
_currSetup->_bkgndBm->draw();
|
||||
}
|
||||
void drawBitmaps(ObjectState::Position stage);
|
||||
void setupCamera() {
|
||||
@ -79,7 +79,7 @@ private:
|
||||
void load(TextSplitter &ts);
|
||||
void setupCamera() const;
|
||||
std::string _name;
|
||||
ResPtr<Bitmap> _bkgnd_bm, _bkgnd_zbm;
|
||||
ResPtr<Bitmap> _bkgndBm, _bkgndZBm;
|
||||
Vector3d _pos, _interest;
|
||||
float _roll, _fov, _nclip, _fclip;
|
||||
};
|
||||
|
10
sound.cpp
10
sound.cpp
@ -285,7 +285,7 @@ void Mixer::playSfx(Sound *s) {
|
||||
}
|
||||
|
||||
void Mixer::stopSfx(Sound *s) {
|
||||
for (sound_list::iterator i = _sfxSounds.begin(); i != _sfxSounds.end(); ) {
|
||||
for (SoundList::iterator i = _sfxSounds.begin(); i != _sfxSounds.end(); ) {
|
||||
if (*i == s)
|
||||
i = _sfxSounds.erase(i);
|
||||
else
|
||||
@ -294,7 +294,7 @@ void Mixer::stopSfx(Sound *s) {
|
||||
}
|
||||
|
||||
void Mixer::stopVoice(Sound *s) {
|
||||
for (sound_list::iterator i = _voiceSounds.begin(); i != _voiceSounds.end(); ) {
|
||||
for (SoundList::iterator i = _voiceSounds.begin(); i != _voiceSounds.end(); ) {
|
||||
if (*i == s)
|
||||
i = _voiceSounds.erase(i);
|
||||
else
|
||||
@ -363,7 +363,7 @@ void Mixer::setImuseSeq(int state) {
|
||||
}
|
||||
|
||||
Sound *Mixer::findSfx(const char *filename) {
|
||||
for (sound_list::iterator i = _sfxSounds.begin(); i != _sfxSounds.end(); i++) {
|
||||
for (SoundList::iterator i = _sfxSounds.begin(); i != _sfxSounds.end(); i++) {
|
||||
if (std::strcmp((*i)->filename(), filename) == 0)
|
||||
return *i;
|
||||
}
|
||||
@ -376,14 +376,14 @@ bool Mixer::voicePlaying() const {
|
||||
|
||||
void Mixer::getAudio(int16 *data, int numSamples) {
|
||||
memset(data, 0, numSamples * 2);
|
||||
for (sound_list::iterator i = _voiceSounds.begin(); i != _voiceSounds.end(); ) {
|
||||
for (SoundList::iterator i = _voiceSounds.begin(); i != _voiceSounds.end(); ) {
|
||||
(*i)->mix(data, numSamples);
|
||||
if ((*i)->done())
|
||||
i = _voiceSounds.erase(i);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
for (sound_list::iterator i = _sfxSounds.begin(); i != _sfxSounds.end(); ) {
|
||||
for (SoundList::iterator i = _sfxSounds.begin(); i != _sfxSounds.end(); ) {
|
||||
(*i)->mix(data, numSamples);
|
||||
if ((*i)->done())
|
||||
i = _sfxSounds.erase(i);
|
||||
|
4
sound.h
4
sound.h
@ -66,8 +66,8 @@ private:
|
||||
~Mixer();
|
||||
|
||||
static Mixer *_instance;
|
||||
typedef std::list<ResPtr<Sound> > sound_list;
|
||||
sound_list _voiceSounds, _sfxSounds;
|
||||
typedef std::list<ResPtr<Sound> > SoundList;
|
||||
SoundList _voiceSounds, _sfxSounds;
|
||||
ResPtr<Sound> _musicSound, _seqSound;
|
||||
|
||||
friend void mixerCallback(void *userdata, uint8 *stream, int len);
|
||||
|
@ -47,7 +47,7 @@ TextSplitter::TextSplitter(const char *data, int len) {
|
||||
_data = new char[len + 1];
|
||||
std::memcpy(_data, data, len);
|
||||
_data[len] = '\0';
|
||||
_curr_line = _data;
|
||||
_currLine = _data;
|
||||
processLine();
|
||||
}
|
||||
|
||||
@ -89,29 +89,29 @@ void TextSplitter::processLine() {
|
||||
if (eof())
|
||||
return;
|
||||
|
||||
_next_line = std::strchr(_curr_line, '\n');
|
||||
if (_next_line != NULL) {
|
||||
*_next_line = '\0';
|
||||
_next_line++;
|
||||
_nextLine = std::strchr(_currLine, '\n');
|
||||
if (_nextLine != NULL) {
|
||||
*_nextLine = '\0';
|
||||
_nextLine++;
|
||||
}
|
||||
|
||||
// Cut off comments
|
||||
char *comment_start = std::strchr(_curr_line, '#');
|
||||
char *comment_start = std::strchr(_currLine, '#');
|
||||
if (comment_start != NULL)
|
||||
*comment_start = '\0';
|
||||
|
||||
// Cut off trailing whitespace (including '\r')
|
||||
char *strend = std::strchr(_curr_line, '\0');
|
||||
while (strend > _curr_line && std::isspace(strend[-1]))
|
||||
char *strend = std::strchr(_currLine, '\0');
|
||||
while (strend > _currLine && std::isspace(strend[-1]))
|
||||
strend--;
|
||||
*strend = '\0';
|
||||
|
||||
// Skip blank lines
|
||||
if (*_curr_line == '\0')
|
||||
if (*_currLine == '\0')
|
||||
nextLine();
|
||||
|
||||
// Convert to lower case
|
||||
if (!eof())
|
||||
for (char *s = _curr_line; *s != '\0'; s++)
|
||||
for (char *s = _currLine; *s != '\0'; s++)
|
||||
*s = std::tolower(*s);
|
||||
}
|
||||
|
12
textsplit.h
12
textsplit.h
@ -29,14 +29,14 @@ public:
|
||||
TextSplitter(const char *data, int len);
|
||||
|
||||
char *nextLine() {
|
||||
_curr_line = _next_line;
|
||||
_currLine = _nextLine;
|
||||
processLine();
|
||||
return _curr_line;
|
||||
return _currLine;
|
||||
}
|
||||
|
||||
char *currentLine() { return _curr_line; }
|
||||
const char *currentLine() const { return _curr_line; }
|
||||
bool eof() const { return _curr_line == NULL; }
|
||||
char *currentLine() { return _currLine; }
|
||||
const char *currentLine() const { return _currLine; }
|
||||
bool eof() const { return _currLine == NULL; }
|
||||
|
||||
// Check if the current line contains 'needle'
|
||||
bool TextSplitter::checkString(const char *needle);
|
||||
@ -57,7 +57,7 @@ public:
|
||||
~TextSplitter() { delete[] _data; }
|
||||
|
||||
private:
|
||||
char *_data, *_curr_line, *_next_line;
|
||||
char *_data, *_currLine, *_nextLine;
|
||||
|
||||
void processLine();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user