From f571f3dd28a4b82973d26ff724edec60ad6ea845 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 15 Jun 2016 13:40:15 +0600 Subject: CLOUD: Add comments for StorageWizardDialog methods --- gui/storagewizarddialog.cpp | 1 + gui/storagewizarddialog.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp index b419d1127a..46be812f6d 100644 --- a/gui/storagewizarddialog.cpp +++ b/gui/storagewizarddialog.cpp @@ -141,6 +141,7 @@ int StorageWizardDialog::decodeHashchar(char c) { } bool StorageWizardDialog::correctChecksum(Common::String s) { + if (s.size() == 0) return false; //no last char int providedChecksum = decodeHashchar(s.lastChar()); int calculatedChecksum = 0x2A; for (uint32 i = 0; i < s.size()-1; ++i) { diff --git a/gui/storagewizarddialog.h b/gui/storagewizarddialog.h index b75b952222..93e368463c 100644 --- a/gui/storagewizarddialog.h +++ b/gui/storagewizarddialog.h @@ -40,8 +40,28 @@ class StorageWizardDialog : public Dialog { StaticTextWidget *_messageWidget; ButtonWidget *_connectWidget; + /** + * Return the value corresponding to the given character. + * + * There is a value corresponding to each of 64 selected + * printable characters (0-9, A-Z, a-z, ? and !). + * + * When given another character, -1 is returned. + */ int decodeHashchar(char c); + + /** + * Return whether checksum is correct. + * + * The last character of the string is treated as + * the checksum of all the others (decoded with + * decodeHashchar()). + * + * Checksum = (c[0] ^ c[1] ^ ...) % 64 + */ bool correctChecksum(Common::String s); + + /** The "CRC16_CCITT_FALSE" CRC-16 algorithm. */ uint32 crc16(Common::String s); public: StorageWizardDialog(uint32 storageId); -- cgit v1.2.3