diff options
author | Littleboy | 2012-07-15 19:25:16 -0400 |
---|---|---|
committer | Littleboy | 2012-07-16 23:51:27 -0400 |
commit | 132dd5b4bc236f805babe0187797ef03bbb16310 (patch) | |
tree | 927651fd035f328cdcd0f94a4a7893d7864a2019 /engines | |
parent | d4f7c0232380b94b42d280c3680e473cd0c2d9b5 (diff) | |
download | scummvm-rg350-132dd5b4bc236f805babe0187797ef03bbb16310.tar.gz scummvm-rg350-132dd5b4bc236f805babe0187797ef03bbb16310.tar.bz2 scummvm-rg350-132dd5b4bc236f805babe0187797ef03bbb16310.zip |
LASTEXPRESS: Replace SYNC_STRING macro by function
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lastexpress/entities/entity.cpp | 29 | ||||
-rw-r--r-- | engines/lastexpress/entities/entity.h | 9 |
2 files changed, 24 insertions, 14 deletions
diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 776b9f6c40..120c1f2d85 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -51,6 +51,17 @@ EntityData::EntityCallData::~EntityCallData() { SAFE_DELETE(sequence3); } +void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::String &string, int length) { + char seqName[13]; + memset(&seqName, 0, length); + + if (s.isSaving()) strcpy((char *)&seqName, string.c_str()); + s.syncBytes((byte *)&seqName, length); + + if (s.isLoading()) + string = seqName; +} + void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) { for (uint i = 0; i < ARRAYSIZE(callbacks); i++) s.syncAsByte(callbacks[i]); @@ -77,20 +88,10 @@ void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsByte(directionSwitch); // Sync strings -#define SYNC_STRING(varName, count) { \ - char seqName[13]; \ - memset(&seqName, 0, count); \ - if (s.isSaving()) strcpy((char *)&seqName, varName.c_str()); \ - s.syncBytes((byte *)&seqName, count); \ - if (s.isLoading()) varName = seqName; \ -} - - SYNC_STRING(sequenceName, 13); - SYNC_STRING(sequenceName2, 13); - SYNC_STRING(sequenceNamePrefix, 7); - SYNC_STRING(sequenceNameCopy, 13); - -#undef SYNC_STRING + syncString(s, sequenceName, 13); + syncString(s, sequenceName2, 13); + syncString(s, sequenceNamePrefix, 7); + syncString(s, sequenceNameCopy, 13); // Skip pointers to frame & sequences s.skip(5 * 4); diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index bb2b96618e..4dca5424b1 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -596,6 +596,15 @@ public: return str; } + /** + * Synchronizes a string. + * + * @param s The Common::Serializer to use. + * @param string The string. + * @param length Length of the string. + */ + void syncString(Common::Serializer &s, Common::String &string, int length); + // Serializable void saveLoadWithSerializer(Common::Serializer &s); }; |