[Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_font.cpp,1.3,1.4 smush_font.h,1.3,1.4 smush_player.cpp,1.21,1.22
Max Horn
fingolfin at users.sourceforge.net
Wed Jun 4 08:18:03 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: web downloads.php,1.40,1.41
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sky logic.cpp,1.80,1.81 logic.h,1.24,1.25 mouse.cpp,1.5,1.6 mouse.h,1.5,1.6 sky.cpp,1.52,1.53
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1:/tmp/cvs-serv27606/smush
Modified Files:
smush_font.cpp smush_font.h smush_player.cpp
Log Message:
cleanup
Index: smush_font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_font.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smush_font.cpp 4 Jun 2003 14:37:43 -0000 1.3
+++ smush_font.cpp 4 Jun 2003 15:04:00 -0000 1.4
@@ -134,7 +134,7 @@
return _chars[v].height;
}
-int SmushFont::getStringWidth(char *str) {
+int SmushFont::getStringWidth(const char *str) {
int ret = 0;
while(*str) {
@@ -144,7 +144,7 @@
return ret;
}
-int SmushFont::getStringHeight(char *str) {
+int SmushFont::getStringHeight(const char *str) {
int ret = 0;
for(int i = 0; str[i] != 0; i++) {
@@ -155,35 +155,33 @@
return ret;
}
-void SmushFont::decodeCodec(byte *dst, byte *src, int length) {
+void SmushFont::decodeCodec(byte *dst, const byte *src, int length) {
int size_line, num;
- byte *src2 = src;
- byte *dst2 = dst;
byte val;
do {
- size_line = READ_LE_UINT16(src2);
- src2 += 2;
+ size_line = READ_LE_UINT16(src);
+ src += 2;
length -= 2;
while (size_line != 0) {
- num = *src2++;
- val = *src2++;
- memset(dst2, val, num);
- dst2 += num;
+ num = *src++;
+ val = *src++;
+ memset(dst, val, num);
+ dst += num;
length -= 2;
size_line -= 2;
if (size_line != 0) {
- num = READ_LE_UINT16(src2) + 1;
- src2 += 2;
- memcpy(dst2, src2, num);
- dst2 += num;
- src2 += num;
+ num = READ_LE_UINT16(src) + 1;
+ src += 2;
+ memcpy(dst, src, num);
+ dst += num;
+ src += num;
length -= num + 2;
size_line -= num + 2;
}
}
- dst2--;
+ dst--;
} while (length > 1);
}
@@ -270,7 +268,7 @@
return w + 1;
}
-static char **split(char *str, char sep) {
+static char **split(const char *str, char sep) {
char **ret = new char *[62];
int n = 0;
const char *i = str;
@@ -285,15 +283,16 @@
j = strchr(i, sep);
}
- ret[n] = new char[strlen(i) + 1];
- memcpy(ret[n], i, strlen(i));
- ret[n++][strlen(i)] = 0;
+ int len = strlen(i);
+ ret[n] = new char[len + 1];
+ memcpy(ret[n], i, len);
+ ret[n++][len] = 0;
ret[n] = 0;
return ret;
}
-void SmushFont::drawSubstring(char *str, byte *buffer, int dst_width, int x, int y) {
+void SmushFont::drawSubstring(const char *str, byte *buffer, int dst_width, int x, int y) {
for(int i = 0; str[i] != 0; i++) {
if((byte)str[i] >= 0x80 && g_scumm->_CJKMode) {
x += draw2byte(buffer, dst_width, x, y, (byte)str[i] + 256 * (byte)str[i+1]);
@@ -303,7 +302,7 @@
}
}
-void SmushFont::drawStringAbsolute(char *str, byte *buffer, int dst_width, int x, int y) {
+void SmushFont::drawStringAbsolute(const char *str, byte *buffer, int dst_width, int x, int y) {
debug(9, "SmushFont::drawStringAbsolute(%s, %d, %d)", str, x, y);
while(str) {
@@ -322,7 +321,7 @@
}
}
-void SmushFont::drawStringCentered(char *str, byte *buffer, int dst_width, int dst_height, int y, int xmin, int width, int offset) {
+void SmushFont::drawStringCentered(const char *str, byte *buffer, int dst_width, int dst_height, int y, int xmin, int width, int offset) {
debug(9, "SmushFont::drawStringCentered(%s, %d, %d)", str, xmin, y);
if ((strchr(str, '\n') != 0)) {
@@ -399,7 +398,7 @@
delete []substrings;
}
-void SmushFont::drawStringWrap(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
+void SmushFont::drawStringWrap(const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
debug(9, "SmushFont::drawStringWrap(%s, %d, %d)", str, x, y);
if ((strchr(str, '\n') != 0)) {
@@ -475,7 +474,7 @@
delete []substrings;
}
-void SmushFont::drawStringWrapCentered(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
+void SmushFont::drawStringWrapCentered(const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
debug(9, "SmushFont::drawStringWrapCentered(%s, %d, %d)", str, x, y);
int max_substr_width = 0;
Index: smush_font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_font.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smush_font.h 4 Jun 2003 14:37:43 -0000 1.3
+++ smush_font.h 4 Jun 2003 15:04:00 -0000 1.4
@@ -47,22 +47,22 @@
protected:
int getCharWidth(byte c);
- int getStringWidth(char *str);
+ int getStringWidth(const char *str);
int getCharHeight(byte c);
- int getStringHeight(char *str);
+ int getStringHeight(const char *str);
int draw2byte(byte *buffer, int dst_width, int x, int y, int idx);
int drawChar(byte *buffer, int dst_width, int x, int y, byte chr);
- void drawSubstring(char *str, byte *buffer, int dst_width, int x, int y);
- void decodeCodec(byte *dst, byte *src, int length);
+ void drawSubstring(const char *str, byte *buffer, int dst_width, int x, int y);
+ void decodeCodec(byte *dst, const byte *src, int length);
public:
bool loadFont(const char *filename, const char *directory);
void setColor(byte c) { _color = c; }
- void drawStringCentered(char *str, byte *buffer, int dst_width, int dst_height, int y, int xmin, int width, int offset);
- void drawStringWrap(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width);
- void drawStringWrapCentered(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width);
- void drawStringAbsolute(char *str, byte *buffer, int dst_width, int x, int y);
+ void drawStringCentered(const char *str, byte *buffer, int dst_width, int dst_height, int y, int xmin, int width, int offset);
+ void drawStringWrap(const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width);
+ void drawStringWrapCentered(const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width);
+ void drawStringAbsolute(const char *str, byte *buffer, int dst_width, int x, int y);
};
#endif
Index: smush_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- smush_player.cpp 30 May 2003 19:28:52 -0000 1.21
+++ smush_player.cpp 4 Jun 2003 15:04:00 -0000 1.22
@@ -43,12 +43,12 @@
struct {
int id;
- char *string;
+ const char *string;
} _strings[MAX_STRINGS];
int _nbStrings;
int _lastId;
- char *_lastString;
+ const char *_lastString;
public:
@@ -129,7 +129,7 @@
return true;
}
- char *get(int id) {
+ const char *get(int id) {
if(id == _lastId) {
return _lastString;
}
@@ -488,7 +488,8 @@
/*int32 height =*/ b.getShort();
/*int32 unk2 =*/ b.getWord();
- char *str, *string = NULL, *string2 = NULL;
+ const char *str;
+ char *string = NULL, *string2 = NULL;
if (b.getType() == TYPE_TEXT) {
string = (char *)malloc(b.getSize() - 16);
str = string;
@@ -511,8 +512,9 @@
}
if (_scumm->_gameId == GID_CMI) {
- _scumm->translateText((byte*)str - 1, _scumm->_transText);
- while(*str++ != '/');
+ _scumm->translateText((const byte *)str - 1, _scumm->_transText);
+ while(*str++ != '/')
+ ;
string2 = (char *)_scumm->_transText;
// If string2 contains formatting information there probably
@@ -545,44 +547,39 @@
assert(sf != NULL);
sf->setColor(color);
- if (_scumm->_gameId != GID_CMI) {
- string2 = str;
- }
- if (_scumm->_gameId == GID_CMI) {
- if (string2[0] == 0) {
- string2 = str;
- }
+ if (_scumm->_gameId == GID_CMI && string2[0] != 0) {
+ str = string2;
}
// flags:
- // bit 0 - center 1
- // bit 1 - not used 2
- // bit 2 - ??? 4
- // bit 3 - wrap around 8
+ // bit 0 - center 1
+ // bit 1 - not used 2
+ // bit 2 - ??? 4
+ // bit 3 - wrap around 8
switch (flags) {
case 0:
- sf->drawStringAbsolute(string2, _data, _width, pos_x, pos_y);
+ sf->drawStringAbsolute(str, _data, _width, pos_x, pos_y);
break;
case 1:
- sf->drawStringCentered(string2, _data, _width, _height, MAX(pos_y, top), left, width, pos_x);
+ sf->drawStringCentered(str, _data, _width, _height, MAX(pos_y, top), left, width, pos_x);
break;
case 4:
- sf->drawStringAbsolute(string2, _data, _width, pos_x, pos_y);
+ sf->drawStringAbsolute(str, _data, _width, pos_x, pos_y);
break;
case 5:
- sf->drawStringCentered(string2, _data, _width, _height, MAX(pos_y, top), left, width, pos_x);
+ sf->drawStringCentered(str, _data, _width, _height, MAX(pos_y, top), left, width, pos_x);
break;
case 8:
- sf->drawStringWrap(string2, _data, _width, _height, pos_x, MAX(pos_y, top), width);
+ sf->drawStringWrap(str, _data, _width, _height, pos_x, MAX(pos_y, top), width);
break;
case 9:
- sf->drawStringCentered(string2, _data, _width, _height, MAX(pos_y, top), left, width, pos_x);
+ sf->drawStringCentered(str, _data, _width, _height, MAX(pos_y, top), left, width, pos_x);
break;
case 12:
- sf->drawStringWrap(string2, _data, _width, _height, pos_x, MAX(pos_y, top), width);
+ sf->drawStringWrap(str, _data, _width, _height, pos_x, MAX(pos_y, top), width);
break;
case 13:
- sf->drawStringWrapCentered(string2, _data, _width, _height, pos_x, MAX(pos_y, top), width);
+ sf->drawStringWrapCentered(str, _data, _width, _height, pos_x, MAX(pos_y, top), width);
break;
default:
warning("SmushPlayer::handleTextResource. Not handled flags: %d", flags);
- Previous message: [Scummvm-cvs-logs] CVS: web downloads.php,1.40,1.41
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sky logic.cpp,1.80,1.81 logic.h,1.24,1.25 mouse.cpp,1.5,1.6 mouse.h,1.5,1.6 sky.cpp,1.52,1.53
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list