Commenting prepareStr a bit and renaming it to cleanupStr

svn-id: r42120
This commit is contained in:
Sven Hesse 2009-07-05 11:26:42 +00:00
parent d2c2386c6a
commit 704895b35f
7 changed files with 17 additions and 14 deletions

View File

@ -928,7 +928,7 @@ void Game_v1::collisionsBlock(void) {
strncpy0(_tempStr, GET_VARO_STR(_collisionAreas[i].key), 255);
if ((_collisionAreas[i].flags & 0x0F) < 7)
_vm->_util->prepareStr(_tempStr);
_vm->_util->cleanupStr(_tempStr);
int16 pos = 0;
do {
@ -938,7 +938,7 @@ void Game_v1::collisionsBlock(void) {
str += strlen(str) + 1;
if ((_collisionAreas[i].flags & 0x0F) < 7)
_vm->_util->prepareStr(_collStr);
_vm->_util->cleanupStr(_collStr);
if (strcmp(_tempStr, _collStr) == 0) {
WRITE_VAR(17, VAR(17) + 1);

View File

@ -935,7 +935,7 @@ void Game_v2::collisionsBlock(void) {
strncpy0(_tempStr, GET_VARO_STR(_collisionAreas[i].key), 255);
if ((_collisionAreas[i].flags & 0x0F) < 7)
_vm->_util->prepareStr(_tempStr);
_vm->_util->cleanupStr(_tempStr);
int16 pos = 0;
do {
@ -945,7 +945,7 @@ void Game_v2::collisionsBlock(void) {
str += strlen(str) + 1;
if ((_collisionAreas[i].flags & 0x0F) < 7)
_vm->_util->prepareStr(_collStr);
_vm->_util->cleanupStr(_collStr);
if (strcmp(_tempStr, _collStr) == 0) {
WRITE_VAR(17, VAR(17) + 1);

View File

@ -839,7 +839,7 @@ void Game_v6::collisionsBlock(void) {
strncpy0(_tempStr, GET_VARO_STR(_collisionAreas[i].key), 255);
if ((_collisionAreas[i].flags & 0x0F) < 7)
_vm->_util->prepareStr(_tempStr);
_vm->_util->cleanupStr(_tempStr);
int16 pos = 0;
do {
@ -849,7 +849,7 @@ void Game_v6::collisionsBlock(void) {
str += strlen(str) + 1;
if ((_collisionAreas[i].flags & 0x0F) < 7)
_vm->_util->prepareStr(_collStr);
_vm->_util->cleanupStr(_collStr);
if (strcmp(_tempStr, _collStr) == 0) {
WRITE_VAR(17, VAR(17) + 1);

View File

@ -238,7 +238,7 @@ protected:
bool o1_playComposition(OpFuncParams &params);
bool o1_getFreeMem(OpFuncParams &params);
bool o1_checkData(OpFuncParams &params);
bool o1_prepareStr(OpFuncParams &params);
bool o1_cleanupStr(OpFuncParams &params);
bool o1_insertStr(OpFuncParams &params);
bool o1_cutStr(OpFuncParams &params);
bool o1_strstr(OpFuncParams &params);

View File

@ -147,7 +147,7 @@ void Inter_v1::setupOpcodesFunc() {
OPCODEFUNC(0x3E, o1_getFreeMem);
OPCODEFUNC(0x3F, o1_checkData);
OPCODEFUNC(0x41, o1_prepareStr);
OPCODEFUNC(0x41, o1_cleanupStr);
OPCODEFUNC(0x42, o1_insertStr);
OPCODEFUNC(0x43, o1_cutStr);
@ -1601,11 +1601,11 @@ bool Inter_v1::o1_checkData(OpFuncParams &params) {
return false;
}
bool Inter_v1::o1_prepareStr(OpFuncParams &params) {
bool Inter_v1::o1_cleanupStr(OpFuncParams &params) {
int16 strVar;
strVar = _vm->_game->_script->readVarIndex();
_vm->_util->prepareStr(GET_VARO_FSTR(strVar));
_vm->_util->cleanupStr(GET_VARO_FSTR(strVar));
return false;
}

View File

@ -452,7 +452,7 @@ static const char trStr2[] =
" ";
static const char trStr3[] = " ";
void Util::prepareStr(char *str) {
void Util::cleanupStr(char *str) {
char *start, *end;
char buf[300];
@ -460,17 +460,20 @@ void Util::prepareStr(char *str) {
strcat(buf, trStr2);
strcat(buf, trStr3);
// Translating "wrong" characters
for (size_t i = 0; i < strlen(str); i++)
str[i] = buf[str[i] - 32];
str[i] = buf[MIN<int>(str[i] - 32, 32)];
// Trim spaces left
while (str[0] == ' ')
cutFromStr(str, 0, 1);
// Trim spaces right
while ((strlen(str) > 0) && (str[strlen(str) - 1] == ' '))
cutFromStr(str, strlen(str) - 1, 1);
// Merge double spaces
start = strchr(str, ' ');
while (start) {
if (start[1] == ' ') {
cutFromStr(str, start - str, 1);

View File

@ -92,7 +92,7 @@ public:
static void insertStr(const char *str1, char *str2, int16 pos);
static void cutFromStr(char *str, int16 from, int16 cutlen);
static void prepareStr(char *str);
static void cleanupStr(char *str);
static void replaceChar(char *str, char c1, char c2);
static void listInsertFront(List *list, void *data);