mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-11 11:45:21 +00:00
SCI: Add SegManager::getSystemString() method
svn-id: r50550
This commit is contained in:
parent
3f429d64a2
commit
36799dc83f
@ -609,13 +609,15 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
|
||||
if (argv[1].segment == s->_segMan->getSysStringsSegment()) {
|
||||
// Resize if necessary
|
||||
const uint16 sysStringId = argv[1].toUint16();
|
||||
if ((uint32)s->_segMan->_sysStrings->_strings[sysStringId]._maxSize < index1 + count) {
|
||||
free(s->_segMan->_sysStrings->_strings[sysStringId]._value);
|
||||
s->_segMan->_sysStrings->_strings[sysStringId]._maxSize = index1 + count;
|
||||
s->_segMan->_sysStrings->_strings[sysStringId]._value = (char *)calloc(index1 + count, sizeof(char));
|
||||
SystemString *sysString = s->_segMan->getSystemString(sysStringId);
|
||||
assert(sysString);
|
||||
if ((uint32)sysString->_maxSize < index1 + count) {
|
||||
free(sysString->_value);
|
||||
sysString->_maxSize = index1 + count;
|
||||
sysString->_value = (char *)calloc(index1 + count, sizeof(char));
|
||||
}
|
||||
|
||||
strncpy(s->_segMan->_sysStrings->_strings[sysStringId]._value + index1, string2 + index2, count);
|
||||
strncpy(sysString->_value + index1, string2 + index2, count);
|
||||
} else {
|
||||
SciString *string1 = s->_segMan->lookupString(argv[1]);
|
||||
|
||||
|
@ -85,7 +85,7 @@ void SegManager::initSysStrings() {
|
||||
_sysStrings = (SystemStrings *)allocSegment(new SystemStrings(), &_sysStringsSegId);
|
||||
|
||||
// Allocate static buffer for savegame and CWD directories
|
||||
SystemString *strSaveDir = &_sysStrings->_strings[SYS_STRING_SAVEDIR];
|
||||
SystemString *strSaveDir = getSystemString(SYS_STRING_SAVEDIR);
|
||||
strSaveDir->_name = "savedir";
|
||||
strSaveDir->_maxSize = MAX_SAVE_DIR_SIZE;
|
||||
strSaveDir->_value = (char *)calloc(MAX_SAVE_DIR_SIZE, sizeof(char));
|
||||
@ -94,7 +94,7 @@ void SegManager::initSysStrings() {
|
||||
::strcpy(strSaveDir->_value, "");
|
||||
|
||||
// Allocate static buffer for the parser base
|
||||
SystemString *strParserBase = &_sysStrings->_strings[SYS_STRING_PARSER_BASE];
|
||||
SystemString *strParserBase = getSystemString(SYS_STRING_PARSER_BASE);
|
||||
strParserBase->_name = "parser-base";
|
||||
strParserBase->_maxSize = MAX_PARSER_BASE;
|
||||
strParserBase->_value = (char *)calloc(MAX_PARSER_BASE, sizeof(char));
|
||||
|
@ -448,6 +448,18 @@ public:
|
||||
*/
|
||||
SegmentId getSysStringsSegment() { return _sysStringsSegId; }
|
||||
|
||||
/**
|
||||
* Get a pointer to the system string with the specified index,
|
||||
* or NULL if that index is invalid.
|
||||
*
|
||||
* This method is currently only used by kString().
|
||||
*/
|
||||
SystemString *getSystemString(uint idx) const {
|
||||
if (idx >= SYS_STRINGS_MAX)
|
||||
return NULL;
|
||||
return &_sysStrings->_strings[idx];
|
||||
}
|
||||
|
||||
public: // TODO: make private
|
||||
Common::Array<SegmentObj *> _heap;
|
||||
// Only accessible from saveLoadWithSerializer()
|
||||
@ -476,11 +488,8 @@ private:
|
||||
|
||||
/* System strings */
|
||||
SegmentId _sysStringsSegId;
|
||||
public: // TODO: make private. Only kString() needs direct access
|
||||
SystemStrings *_sysStrings;
|
||||
|
||||
private:
|
||||
|
||||
#ifdef ENABLE_SCI32
|
||||
SegmentId _arraysSegId;
|
||||
SegmentId _stringSegId;
|
||||
|
Loading…
Reference in New Issue
Block a user