Make IGameConfig::GetMemSig return value clearer (bug 6081, r=asherkin).
authorNicholas Hastings <skamonkey@gmail.com>
Sat Mar 29 14:22:53 2014 -0400 (2014-03-29)
changeset 4303915476a973a5
parent 4302 9f455f812556
child 4304 bff9916aa9b2
Make IGameConfig::GetMemSig return value clearer (bug 6081, r=asherkin).
core/logic/GameConfigs.cpp
public/IGameConfigs.h
     1.1 --- a/core/logic/GameConfigs.cpp	Sat Mar 29 14:14:00 2014 -0400
     1.2 +++ b/core/logic/GameConfigs.cpp	Sat Mar 29 14:22:53 2014 -0400
     1.3 @@ -559,7 +559,9 @@
     1.4  				smcore.LogError("[SM] Unrecognized library \"%s\" (gameconf \"%s\")", 
     1.5  					s_TempSig.library, 
     1.6  					m_CurFile);
     1.7 -			} else {
     1.8 +			}
     1.9 +			else if (s_TempSig.sig[0])
    1.10 +			{
    1.11  				if (s_TempSig.sig[0] == '@')
    1.12  				{
    1.13  #if defined PLATFORM_WINDOWS
    1.14 @@ -594,28 +596,28 @@
    1.15  					}
    1.16  #endif
    1.17  				}
    1.18 -				if (final_addr)
    1.19 +
    1.20 +				if (!final_addr)
    1.21  				{
    1.22 -					goto skip_find;
    1.23 -				}
    1.24 -				/* First, preprocess the signature */
    1.25 -				unsigned char real_sig[511];
    1.26 -				size_t real_bytes;
    1.27 -				size_t length;
    1.28 +					/* First, preprocess the signature */
    1.29 +					unsigned char real_sig[511];
    1.30 +					size_t real_bytes;
    1.31 +					size_t length;
    1.32  
    1.33 -				real_bytes = 0;
    1.34 -				length = strlen(s_TempSig.sig);
    1.35 +					real_bytes = 0;
    1.36 +					length = strlen(s_TempSig.sig);
    1.37  
    1.38 -				real_bytes = UTIL_DecodeHexString(real_sig, sizeof(real_sig), s_TempSig.sig);
    1.39 +					real_bytes = UTIL_DecodeHexString(real_sig, sizeof(real_sig), s_TempSig.sig);
    1.40  
    1.41 -				if (real_bytes >= 1)
    1.42 -				{
    1.43 -					final_addr = g_MemUtils.FindPattern(addrInBase, (char*)real_sig, real_bytes);
    1.44 +					if (real_bytes >= 1)
    1.45 +					{
    1.46 +						final_addr = g_MemUtils.FindPattern(addrInBase, (char*) real_sig, real_bytes);
    1.47 +					}
    1.48  				}
    1.49 +
    1.50 +				m_Sigs.replace(m_offset, final_addr);
    1.51  			}
    1.52  
    1.53 -skip_find:
    1.54 -			m_Sigs.replace(m_offset, final_addr);
    1.55  			m_ParseState = PSTATE_GAMEDEFS_SIGNATURES;
    1.56  
    1.57  			break;
     2.1 --- a/public/IGameConfigs.h	Sat Mar 29 14:14:00 2014 -0400
     2.2 +++ b/public/IGameConfigs.h	Sat Mar 29 14:22:53 2014 -0400
     2.3 @@ -84,9 +84,9 @@
     2.4  		 *
     2.5  		 * @param key			Name of the signature.
     2.6  		 * @param addr			Pointer to store the memory address in.
     2.7 -		 * @return				True if the key was found, false otherwise.
     2.8 -		 *						Note that true is a valid return even if the
     2.9 -		 *						address is NULL.
    2.10 +		 *						(NULL is copied if signature is not found in binary).
    2.11 +		 * @return				True if the section exists and key for current
    2.12 +		 *						platform was found, false otherwise.
    2.13  		 */
    2.14  		virtual bool GetMemSig(const char *key, void **addr) =0;
    2.15