GOB: Fix the save list width

The length of the slot 0 string determines the list's width

svn-id: r55426
This commit is contained in:
Sven Hesse 2011-01-22 14:23:03 +00:00
parent 185a0b9070
commit 40a4b09246
3 changed files with 15 additions and 3 deletions

View File

@ -77,10 +77,13 @@ int32 SlotFileIndexed::tallyUpFiles(uint32 slotSize, uint32 indexSize) const {
}
void SlotFileIndexed::buildIndex(byte *buffer, SavePartInfo &info,
SaveConverter *converter) const {
SaveConverter *converter, bool setLongest) const {
uint32 descLength = info.getDescMaxLength();
uint32 longest = 0;
byte *bufferStart = buffer;
// Iterate over all files
for (uint32 i = 0; i < _slotCount; i++, buffer += descLength) {
Common::String slotFile = build(i);
@ -100,10 +103,19 @@ void SlotFileIndexed::buildIndex(byte *buffer, SavePartInfo &info,
delete[] desc;
longest = MAX<uint32>(longest, strlen((const char *) buffer));
} else
// No valid slot, fill with 0
memset(buffer, 0, descLength);
}
if (setLongest) {
uint32 slot0Len;
for (slot0Len = strlen((const char *) bufferStart); slot0Len < longest; slot0Len++)
buffer[slot0Len] = ' ';
buffer[slot0Len] = '\0';
}
}
bool SlotFileIndexed::exists(int slot) const {

View File

@ -78,7 +78,7 @@ public:
/** Creates an index in buffer. */
virtual void buildIndex(byte *buffer, SavePartInfo &info,
SaveConverter *converter = 0) const;
SaveConverter *converter = 0, bool setLongest = false) const;
virtual bool exists(int slot) const;
virtual Common::InSaveFile *openRead(int slot) const;

View File

@ -547,7 +547,7 @@ void SaveLoad_v6::GameHandler::buildIndex(byte *buffer) const {
SavePartInfo info(kSlotNameLength, (uint32) _vm->getGameType(),
0, _vm->getEndianness(), varSize);
_slotFile->buildIndex(buffer, info);
_slotFile->buildIndex(buffer, info, 0, true);
}
void SaveLoad_v6::GameHandler::refreshProps() {