mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
Some SCI32 (minor) String bug fixes and cleanup.
svn-id: r46492
This commit is contained in:
parent
bac7961b3f
commit
4be2788ffd
@ -455,6 +455,11 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
|
||||
SciString *string = s->_segMan->allocateString(&stringHandle);
|
||||
string->setType(3);
|
||||
string->setSize(argv[1].toUint16());
|
||||
|
||||
// Make sure the first character is a null character
|
||||
if (string->getSize() > 0)
|
||||
string->setValue(0, 0);
|
||||
|
||||
return stringHandle;
|
||||
}
|
||||
case 1: // Size
|
||||
@ -512,23 +517,16 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
|
||||
if (string1->getSize() < index1 + count)
|
||||
string1->setSize(index1 + count);
|
||||
|
||||
// Note: We're accessing from c_str() here because the string's size ignores
|
||||
// the trailing 0 and therefore triggers an assert when doing string2[i + index2].
|
||||
for (uint16 i = 0; i < count; i++)
|
||||
string1->setValue(i + index1, string2[i + index2]);
|
||||
string1->setValue(i + index1, string2.c_str()[i + index2]);
|
||||
|
||||
return argv[1];
|
||||
}
|
||||
case 7: { // Cmp
|
||||
Common::String string1, string2;
|
||||
|
||||
if (argv[1].isNull())
|
||||
string1 = "";
|
||||
else
|
||||
string1 = s->_segMan->lookupString(argv[1])->toString();
|
||||
|
||||
if (argv[2].isNull())
|
||||
string2 = "";
|
||||
else
|
||||
string2 = s->_segMan->lookupString(argv[2])->toString();
|
||||
Common::String string1 = argv[1].isNull() ? "" : s->_segMan->getString(argv[1]);
|
||||
Common::String string2 = argv[2].isNull() ? "" : s->_segMan->getString(argv[2]);
|
||||
|
||||
if (argc == 4) // Strncmp
|
||||
return make_reg(0, strncmp(string1.c_str(), string2.c_str(), argv[3].toUint16()));
|
||||
@ -547,11 +545,8 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
|
||||
return argv[1];
|
||||
|
||||
return GET_SEL32(s->_segMan, argv[1], data);
|
||||
case 10: { // Stringlen
|
||||
SciString *sciString = s->_segMan->lookupString(argv[1]);
|
||||
Common::String string = sciString->toString();
|
||||
return make_reg(0, string.size());
|
||||
}
|
||||
case 10: // Stringlen
|
||||
return make_reg(0, s->_segMan->strlen(argv[1]));
|
||||
case 11: // Printf
|
||||
// TODO: Return a new formatting string
|
||||
warning("kString(Printf)");
|
||||
|
@ -153,14 +153,11 @@ bool MessageState::getRecord(CursorStack &stack, bool recurse, MessageRecord &re
|
||||
reader = new MessageReaderV3(res->data, res->size);
|
||||
break;
|
||||
case 4:
|
||||
#ifdef ENABLE_SCI32
|
||||
case 5: // v5 seems to be compatible with v4
|
||||
#endif
|
||||
reader = new MessageReaderV4(res->data, res->size);
|
||||
break;
|
||||
#ifdef ENABLE_SCI32
|
||||
case 5:
|
||||
// TODO: Decode this version's format... It's at least used in Torin.
|
||||
warning("The SCI 2.1 message format is not supported");
|
||||
return false;
|
||||
#endif
|
||||
default:
|
||||
warning("Message: unsupported resource version %d", version);
|
||||
return false;
|
||||
|
@ -512,7 +512,7 @@ void SciString::fromString(Common::String string) {
|
||||
|
||||
SegmentRef StringTable::dereference(reg_t pointer) {
|
||||
SegmentRef ret;
|
||||
ret.isRaw = false;
|
||||
ret.isRaw = true;
|
||||
ret.maxSize = _table[pointer.offset].getSize();
|
||||
ret.raw = (byte*)_table[pointer.offset].getRawData();
|
||||
return ret;
|
||||
|
@ -706,6 +706,7 @@ public:
|
||||
|
||||
// Check if we never created an array before
|
||||
if (!_data) {
|
||||
_size = _actualSize = size;
|
||||
_data = newArray;
|
||||
return;
|
||||
}
|
||||
@ -736,9 +737,6 @@ public:
|
||||
byte getType() { return _type; }
|
||||
uint32 getSize() { return _size; }
|
||||
T *getRawData() { return _data; }
|
||||
|
||||
//Common::String toString();
|
||||
//void fromString(Common::String string);
|
||||
|
||||
protected:
|
||||
int8 _type;
|
||||
|
Loading…
Reference in New Issue
Block a user