Esempio n. 1
0
void JStringServer::ExtractStrings()
{
    FILE* fp = fopen( "strings.txt", "wt" );
    if (!fp)
    {
        return;
    }
    m_Dictionary.clear();

    //  extract text strings
    JObjectIterator it( JCore::s_pInstance );
    JString val, hash;
    while (it)
    {
        JObject* pObj = *it;
        if (pObj->HasName( "system" ))
        {
            it.breadth_next();
            continue;
        }
        ++it;
        bool bRes = pObj->GetProperty( "text", val );
        if (!bRes || val.size() == 0 || val[0] == '#')
        {
            continue;
        }
        if (!HasCyrillics( val.c_str() ))
        {
            continue;
        }
        HashString( val.c_str(), hash );
        JStringDictionary::iterator location = m_Dictionary.find( hash );

        JString taggedHash = "#";
        taggedHash += hash;
        pObj->SetProperty( "text", taggedHash.c_str() );

        if (location != m_Dictionary.end())
        {
            if (val == (*location).second)
            {
                continue;
            }
            assert( false );
        }
        fprintf( fp, "%s %s\n", hash.c_str(), val.c_str() );
        m_Dictionary[hash] = val;
    }
    fclose( fp );

    //  save scripts
    g_pPersistServer->SaveScripts();
}
Esempio n. 2
0
// Static function
uint CElement::GetTypeHashFromString ( const SString& strTypeName )
{
    // Standard types use unique index upto EElementType::UNKNOWN
    EElementType elementType;
    if ( StringToEnum ( strTypeName, elementType ) )
        return elementType;

    // Custom types use name hash.  TODO: Make it use a unique index instead
    uint uiTypeHash = HashString ( strTypeName );
    uiTypeHash = ( uiTypeHash % 0xFFFFFF00 ) + CElement::UNKNOWN + 1;
    return uiTypeHash;
}
Esempio n. 3
0
//*****************************************************************************
//
//*****************************************************************************
void Translate_Dump(const char *string, bool dump)
{
	if(dump)
	{
		FILE * fh = fopen( "hash.txt", "a" );
		if(fh)
		{
			fprintf( fh,  "%08x,%s\n", HashString(string), string );
			fclose(fh);
		}
	}
}
Esempio n. 4
0
BUrlContext::BUrlContext()
	: 
	fCookieJar(),
	fAuthenticationMap(NULL)
{
	fAuthenticationMap = new(std::nothrow) BHttpAuthenticationMap();

	// This is the default authentication, used when nothing else is found.
	// The empty string used as a key will match all the domain strings, once
	// we have removed all components.
	fAuthenticationMap->Put(HashString("", 0), new BHttpAuthentication());
}
Esempio n. 5
0
static void
RebuildLiteralTable(
    register LiteralTable *tablePtr)
				/* Local or global table to enlarge. */
{
    LiteralEntry **oldBuckets;
    register LiteralEntry **oldChainPtr, **newChainPtr;
    register LiteralEntry *entryPtr;
    LiteralEntry **bucketPtr;
    const char *bytes;
    int oldSize, count, index, length;

    oldSize = tablePtr->numBuckets;
    oldBuckets = tablePtr->buckets;

    /*
     * Allocate and initialize the new bucket array, and set up hashing
     * constants for new array size.
     */

    tablePtr->numBuckets *= 4;
    tablePtr->buckets = ckalloc(tablePtr->numBuckets * sizeof(LiteralEntry*));
    for (count=tablePtr->numBuckets, newChainPtr=tablePtr->buckets;
	    count>0 ; count--, newChainPtr++) {
	*newChainPtr = NULL;
    }
    tablePtr->rebuildSize *= 4;
    tablePtr->mask = (tablePtr->mask << 2) + 3;

    /*
     * Rehash all of the existing entries into the new bucket array.
     */

    for (oldChainPtr=oldBuckets ; oldSize>0 ; oldSize--,oldChainPtr++) {
	for (entryPtr=*oldChainPtr ; entryPtr!=NULL ; entryPtr=*oldChainPtr) {
	    bytes = TclGetStringFromObj(entryPtr->objPtr, &length);
	    index = (HashString(bytes, length) & tablePtr->mask);

	    *oldChainPtr = entryPtr->nextPtr;
	    bucketPtr = &tablePtr->buckets[index];
	    entryPtr->nextPtr = *bucketPtr;
	    *bucketPtr = entryPtr;
	}
    }

    /*
     * Free up the old bucket array, if it was dynamically allocated.
     */

    if (oldBuckets != tablePtr->staticBuckets) {
	ckfree(oldBuckets);
    }
}
Esempio n. 6
0
//---------------------------- PRIVATE          -----------------------------//
void *wxServerConnectionThread::Entry()
{
	bool valid = true;

	// It's ok to block this thread waiting for data.
	mSocket->SetFlags(wxSOCKET_WAITALL);

	try
	{
		// If we pass the check, but return false, it means we got hit by the
		// site requesting a host check.

		if(false == Cities3DCheck())
		{
            static const wxString stReceivedAHostCheck = _("Received a host check from the site.");
    
			wxRuleEvent event(shNetworkRuleSystemMessage, 
				DataObject(stReceivedAHostCheck, wxDateTime::Now()));
			mHandler->AddPendingEvent(event);

			valid = false;
			goto error;
		}
		VersionCheck();

		ReceiveSpectator();

		SendSpectators();
		SendGame();
		SendRNG();
	}
	catch(const std::exception &e)
	{
		valid = false;

		wxLogDebug(HashString(e.what()).wx_str());
	}

error:
	if(true == valid)
	{
		// This socket is complete and ready for data.
		mSocket->mIsComplete = true;
	}
	else
	{
		mSocket->Destroy();
		mSocket = NULL;
	}

	return NULL;
}
	const uint32 ConvertGameRulesToHash(const char* gameRules)
	{
		if (gameRules && (strlen(gameRules) < 32))
		{
			char lowerRulesName[32];
			NameCRCHelper::MakeLowercase(lowerRulesName, gameRules);
			return HashString(lowerRulesName);
		}
		else
		{
			return 0;
		}
	}
Esempio n. 8
0
unsigned long StringHash::Hashed(string lpszString)
{ 
	//不同的字符串三次hash还会碰撞的几率无限接近于不可能
	unsigned long nHash = HashString(lpszString, HASH_OFFSET); 
	unsigned long nHashA = HashString(lpszString, HASH_A); 
	unsigned long nHashB = HashString(lpszString, HASH_B); 
	unsigned long nHashStart = nHash % m_tablelength, 
	nHashPos = nHashStart;

	while ( m_HashIndexTable[nHashPos].bExists) 
	{ 
	if (m_HashIndexTable[nHashPos].nHashA == nHashA && m_HashIndexTable[nHashPos].nHashB == nHashB)
		return nHashPos; 
	else 
		nHashPos = (nHashPos + 1) % m_tablelength;

	if (nHashPos == nHashStart) 
		break; 
	}

	return -1; //没有找到 
}
	const uint32 ConvertMapToHash(const char* mapName)
	{
		if (mapName && (strlen(mapName) < 128))
		{
			char lowerMapName[128];
			NameCRCHelper::MakeLowercase(lowerMapName, mapName);
			return HashString(lowerMapName);
		}
		else
		{
			return 0;
		}
	}
Esempio n. 10
0
DWORD FusionBind::Hash()
{
    DWORD hash = 0;

    // Normalize representation
    if (!m_fParsed)
        ParseName();


    // Hash fields.

    if (m_pAssemblyName)
        hash ^= HashStringA(m_pAssemblyName);
    hash = _rotl(hash, 4);

    hash ^= HashBytes(m_pbPublicKeyOrToken, m_cbPublicKeyOrToken);
    hash = _rotl(hash, 4);
        
    hash ^= m_dwFlags;
    hash = _rotl(hash, 4);

    if (m_CodeInfo.m_pszCodeBase)
        hash ^= HashString(m_CodeInfo.m_pszCodeBase);
    hash = _rotl(hash, 4);

    hash ^= m_context.usMajorVersion;
    hash = _rotl(hash, 8);

    if (m_context.usMajorVersion != (USHORT) -1) {
        hash ^= m_context.usMinorVersion;
        hash = _rotl(hash, 8);
        
        if (m_context.usMinorVersion != (USHORT) -1) {
            hash ^= m_context.usBuildNumber;
            hash = _rotl(hash, 8);
        
            if (m_context.usBuildNumber != (USHORT) -1) {
                hash ^= m_context.usRevisionNumber;
                hash = _rotl(hash, 8);
            }
        }
    }

    if (m_context.szLocale)
        hash ^= HashStringA(m_context.szLocale);
    hash = _rotl(hash, 4);

    hash ^= m_CodeInfo.m_fLoadFromParent;

    return hash;
}
Esempio n. 11
0
bool StringHash::Hash(string lpszString)
{  
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;  
	unsigned long nHash = HashString(lpszString, HASH_OFFSET);  
	unsigned long nHashA = HashString(lpszString, HASH_A);  
	unsigned long nHashB = HashString(lpszString, HASH_B);  
	unsigned long nHashStart = nHash % m_tablelength, 
		nHashPos = nHashStart;  

	while ( m_HashIndexTable[nHashPos].bExists)  
	{   
		nHashPos = (nHashPos + 1) % m_tablelength;  
		if (nHashPos == nHashStart)  
		{  
			return false;   
		}  
	}  
	m_HashIndexTable[nHashPos].bExists = true;  
	m_HashIndexTable[nHashPos].nHashA = nHashA;  
	m_HashIndexTable[nHashPos].nHashB = nHashB;  

	return true;  
}  
Esempio n. 12
0
uint32 Block::fileKey(const string &fileName, const BlockTableEntry &blockTableEntry)
{
	if (fileName.empty())
		throw std::logic_error(_("Never try to get file keys of empty filenames."));

	// Hash the name to get the base key
	uint32 nFileKey = HashString(Mpq::cryptTable(), fileName.c_str(), HashType::FileKey);

	// Offset-adjust the key if necessary
	if (blockTableEntry.flags & Flags::UsesEncryptionKey)
		nFileKey = (nFileKey + blockTableEntry.blockOffset) ^ blockTableEntry.fileSize;

	return nFileKey;
}
Esempio n. 13
0
HRESULT CeeSectionString::getEmittedStringRef(__in_z LPWSTR target, StringRef *ref)
{
    TESTANDRETURN(ref!=NULL, E_POINTER);
    ULONG hashId = HashString(target) % MaxVirtualEntries;
    ULONG bucketIndex = hashId / MaxRealEntries;

    StringTableEntry *entry;
    entry = findStringInsert(stringTable[bucketIndex], target, hashId);

    if (! entry)
        return E_OUTOFMEMORY;
    *ref = entry->m_offset;
    return S_OK;
}
Esempio n. 14
0
bool StringHash::Hash(string lpszString)
{ 
	unsigned long nHash = HashString(lpszString, HASH_OFFSET); 
	unsigned long nHashA = HashString(lpszString, HASH_A); 
	unsigned long nHashB = HashString(lpszString, HASH_B); 
	unsigned long nHashStart = nHash % m_tablelength, 
	nHashPos = nHashStart;

	while ( m_HashIndexTable[nHashPos].bExists) 
	{ 
		nHashPos = (nHashPos + 1) % m_tablelength; 
		if (nHashPos == nHashStart) //一个轮回 
		{ 
			//hash表中没有空余的位置了,无法完成hash
			return false; 
		} 
	} 
	m_HashIndexTable[nHashPos].bExists = true; 
	m_HashIndexTable[nHashPos].nHashA = nHashA; 
	m_HashIndexTable[nHashPos].nHashB = nHashB;

	return true; 
}
Esempio n. 15
0
static void resolveTypePrototypes( void ) {
/*****************************************/

/* adds required protoypes to the protoype section */

    statement   *finger;
    statement   *rc;
    long        len;
    char        *name;
    char        *libname;

    if( !SRU.type_sec ) {
        return;
    }

    finger = SRU.forward_prots;

    /* loop through the chain of prototypes and add them if necessary */
    while( finger ) {
        name = finger->data.sp.name;
        len = strlen( name );

        /* check in hash table for function name */
        if( !FindHashEntry(SRU.type_prots, HashString(name, len), name, len) ) {

            /* add to prototype section */
            rc = insertTypePrototype( finger, SRU.type_sec );
            rc->link = SRU.cpp_prots;
            SRU.cpp_prots = rc;
            rc->keep = TRUE;
            InsertHashValue( SRU.type_prots, rc->data.sp.name,
                             strlen( rc->data.sp.name ), rc );
        }
        finger = finger->link;
    }

    /* generate constructors and destructor prototypes if necessary */
    libname = GetLibName();
    len = max( sizeof( DES_DECL_TEMPLATE ) + strlen( SRU.des_name ),
               sizeof( CONS_DECL_TEMPLATE ) + strlen( SRU.con_name ) );
    name = alloca( len + strlen( libname ) + 1 );
    if( !( SRU.flags & DESTRUCTOR_DEFINED ) ) {
        sprintf( name, DES_DECL_TEMPLATE, SRU.des_name, libname );
        insertStatement( SRU.type_sec, name );
    }
    if( !( SRU.flags & CONSTRUCTOR_DEFINED ) ) {
        sprintf( name, CONS_DECL_TEMPLATE, SRU.con_name, libname );
        insertStatement( SRU.type_sec, name );
    }
}
Esempio n. 16
0
///////////////////////////////////////////////////////////
//function: 插入新的元素进入hash表
//parameter:
//author: wuxiaoqi
//time: 2016-3-23
///////////////////////////////////////////////////////////
int Ins3Hashmg(hashtable * HashMg, const char *pmkey, const char * pidkey, int fqv)
{
	int ln;
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;
	unsigned long nHash = HashString(pmkey, HASH_OFFSET);
	unsigned long nHashA = HashString(pmkey, HASH_A);
	unsigned long nHashB = HashString(pmkey, HASH_B);
	unsigned long nHashStart = nHash%DCHASH_SIZE, nHashPos = nHashStart;
	while(((*HashMg)+nHashPos)->bExists)
	{
		nHashPos = (nHashPos + 1)%DCHASH_SIZE;
		if (nHashPos == nHashStart)
			return 0;
	}

	((*HashMg)+nHashPos)->bExists = 1;
	((*HashMg)+nHashPos)->nHashA = nHashA;
	((*HashMg)+nHashPos)->nHashB = nHashB;

    if(pmkey != NULL && *pmkey != 0)
	{
		ln = strlen(pmkey);
		((*HashMg)+nHashPos)->pentityname = (char *)malloc(ln+1);
		strncpy(((*HashMg)+nHashPos)->pentityname, pmkey, ln);
		*(((*HashMg)+nHashPos)->pentityname + ln) = 0;	 
	}
	((*HashMg)+nHashPos)->fqval = fqv;
    ((*HashMg)+nHashPos)->score = 0.0001;
	if(pidkey != NULL && *pidkey != 0)
	{
		ln = strlen(pidkey);
		((*HashMg)+nHashPos)->pidcode = (char *)malloc(ln+1);
		strncpy(((*HashMg)+nHashPos)->pidcode, pidkey, ln);
		*(((*HashMg)+nHashPos)->pidcode + ln) = 0;	 
	}
	return 1;
}
Esempio n. 17
0
unsigned long StringHash::Hashed(string lpszString)  

{   
	const unsigned long HASH_OFFSET = 0, HASH_A = 1, HASH_B = 2;  
	//
	unsigned long nHash = HashString(lpszString, HASH_OFFSET);  
	unsigned long nHashA = HashString(lpszString, HASH_A);  
	unsigned long nHashB = HashString(lpszString, HASH_B);  
	unsigned long nHashStart = nHash % m_tablelength,  
	nHashPos = nHashStart;  

	while ( m_HashIndexTable[nHashPos].bExists)  
	{   
		if (m_HashIndexTable[nHashPos].nHashA == nHashA && m_HashIndexTable[nHashPos].nHashB == nHashB)   
			return nHashPos;   
		else   
			nHashPos = (nHashPos + 1) % m_tablelength;  

		if (nHashPos == nHashStart)   
			break;   
	}  

	return -1; 
}  
Esempio n. 18
0
    uint64_t BSA::CalcHash(std::string path, std::string ext) {
        uint64_t hash1 = 0;
        uint32_t hash2 = 0;
        uint32_t hash3 = 0;
        const size_t len = path.length();

        if (!path.empty()) {
            hash1 = (uint64_t)(
                    ((uint8_t)path[len - 1])
                    + (len << 16)
                    + ((uint8_t)path[0] << 24)
                );

            if (len > 2) {
                hash1 += ((uint8_t)path[len - 2] << 8);
                if (len > 3)
                    hash2 = HashString(path.substr(1, len - 3));
            }
        }

        if (!ext.empty()) {
            if (ext == ".kf")
                hash1 += 0x80;
            else if (ext == ".nif")
                hash1 += 0x8000;
            else if (ext == ".dds")
                hash1 += 0x8080;
            else if (ext == ".wav")
                hash1 += 0x80000000;

            hash3 = HashString(ext);
        }

        hash2 = hash2 + hash3;
        return ((uint64_t)hash2 << 32) + hash1;
    }
Esempio n. 19
0
int GetHashTablePos_easy( har *lpszString, SOMESTRUCTURE *lpTable ) 
//lpszString要在Hash表中查找的字符串,lpTable为存储字符串Hash值的Hash表。
{ 
    int nHash = HashString(lpszString);  //调用上述函数二,返回要查找字符串lpszString的Hash值。
    int nHashPos = nHash % nTableSize; 
    if ( lpTable[nHashPos].bExists  &&  !strcmp( lpTable[nHashPos].pString, lpszString ) ) 
		//如果找到的Hash值在表中存在,且要查找的字符串与表中对应位置的字符串相同
    {  
        return nHashPos;    //则返回上述调用函数二后,找到的Hash值
    } 
    else
    {
        return -1;  
    } 
}
Esempio n. 20
0
void AddSymbol(char *Name, int Value)
{
	Symbol sym;

	int hash = HashString(Name);

	if (InSymbolList(hash))
		Error("Symbol '%s' already exists", Name);

	sym.Hash = hash;
	sym.Name = Name;
	sym.Value = Value;

	Symbols.push_back(sym);
}
Esempio n. 21
0
/// ***************************************************************************
/// ***************************************************************************
Bool ContainerProtect(BaseObject* op, String const& pass, String hash, Bool packup)
{
  if (!op || op->GetType() != Ocontainer) return false;
  ContainerObject* data = GetNodeData<ContainerObject>(op);
  if (!data) return false;
  if (data->m_protected)
    return false;
  if (!hash.Content())
    hash = HashString(pass);
  data->m_protected = true;
  data->m_protectionHash = hash;
  if (packup)
    data->HideNodes(op, nullptr, packup);
  return true;
}
	virtual void Execute(const DataObject &object)
	{
		// The current player is now in a blocking action.
        RULE.Execute(shRuleBeginBlockingAction, DataObject(current()));

		wxASSERT(1 <= object.numItems());

		//retrieve the text to put in the MessageUI
		DataObject input(0), output;
		
		const HashString& state = gameData<HashString>(shState);
		if(false == DecideHash(state, input, output))
		{
			wxLogError(
				wxString::Format(wxT("Programmer Error: No State %s in ")
				wxT("RuleRequestInitialRoadSeafarers"), state.cwx_str()));

			return;
		}

		wxASSERT(3 == output.numItems());

		wxString text1 = output.read<wxString>();
		wxString text2 = output.read<wxString>(1);
		HashString logic = HashString::Format(shLogicStringFormat.c_str(),
			output.read<HashString>(2).c_str());
		HashString rule = HashString::Format(shRuleStringFormat.c_str(),
			output.read<HashString>(2).c_str());

		//if this involves ships, do some crazy mojo
		if(TRUE == gameData<wxInt32>(shInitialShip))
		{
			text1 = stPlaceAShip;
			text2 = stWaitingPlaceAShip;

			wxInt32 index = logic.find(shRoad);
			wxASSERT(-1 != index);

			logic.replace(index, 4, shShip);
            logic = HashString(logic.c_str());
		}

		RULE.Execute(shRuleUpdateMessageUI, 
			DataObject(text1, text2));		
		
		RULE.Execute(shRuleLocateInitialRoad, DataObject(
			object.read<wxInt32>(), logic, rule));
	}
Esempio n. 23
0
/*****************************************************************************
 * Lookup: find an existing variable given its name
 *****************************************************************************
 * We use a recursive inner function indexed on the hash. Care is taken of
 * possible hash collisions.
 * XXX: does this really need to be written recursively?
 *****************************************************************************/
static int Lookup( variable_t *p_vars, int i_count, const char *psz_name )
{
    uint32_t i_hash;
    int i, i_pos;

    if( i_count == 0 )
    {
        return -1;
    }

    i_hash = HashString( psz_name );

    i_pos = LookupInner( p_vars, i_count, i_hash );

    /* Hash not found */
    if( i_hash != p_vars[i_pos].i_hash )
    {
        return -1;
    }

    /* Hash found, entry found */
    if( !strcmp( psz_name, p_vars[i_pos].psz_name ) )
    {
        return i_pos;
    }

    /* Hash collision! This should be very rare, but we cannot guarantee
     * it will never happen. Just do an exhaustive search amongst all
     * entries with the same hash. */
    for( i = i_pos - 1 ; i > 0 && i_hash == p_vars[i].i_hash ; i-- )
    {
        if( !strcmp( psz_name, p_vars[i].psz_name ) )
        {
            return i;
        }
    }

    for( i = i_pos + 1 ; i < i_count && i_hash == p_vars[i].i_hash ; i++ )
    {
        if( !strcmp( psz_name, p_vars[i].psz_name ) )
        {
            return i;
        }
    }

    /* Hash found, but entry not found */
    return -1;
}
Esempio n. 24
0
bool PacaReader::GetResource( const std::string& resourcePath, void* outBuffer, uint32_t outBufferSize )
{
    bool result = false;
    uint32_t pathHash = HashString( resourcePath );
    if ( m_HeaderInfo.find( pathHash ) != m_HeaderInfo.end() )
    {
        const ResoureMetaData& resourceMetaData = m_HeaderInfo.at( pathHash );
        if ( resourceMetaData.ByteSize <= outBufferSize )
        {
            m_InStream.seekg( resourceMetaData.StartIndex );
            m_InStream.read( static_cast<char*>( outBuffer ), resourceMetaData.ByteSize );
            result = true;
        }
    }

    return result;
}
Esempio n. 25
0
CElement::CElement ( CElement* pParent, CXMLNode* pNode )
{
    // Allocate us an unique ID
    m_ID = CElementIDs::PopUniqueID ( this );

    // Init
    m_pParent = pParent;
    m_pXMLNode = pNode;
    m_pElementGroup = NULL;

    m_iType = CElement::UNKNOWN;
    m_strName = "";
    m_strTypeName = "unknown";
    m_bIsBeingDeleted = false;
    m_usDimension = 0;
    m_ucSyncTimeContext = 1;
    m_ucInterior = 0;
    m_bMapCreated = false;

    // Store the line
    if ( m_pXMLNode )
    {
        m_uiLine = m_pXMLNode->GetLine ();
    }
    else
    {
        m_uiLine = 0;
    }

    // Add us to our parent's list
    if ( pParent )
    {
        pParent->m_Children.push_back ( this );
    }

    m_uiTypeHash = HashString ( m_strTypeName.c_str () );
    if ( m_pParent )
        CElement::AddEntityFromRoot ( m_uiTypeHash, this );

    // Make an event manager for us
    m_pEventManager = new CMapEventManager;
    m_pCustomData = new CCustomData;

    m_pAttachedTo = NULL;
    m_szAttachToID [ 0 ] = 0;
}
Esempio n. 26
0
const char* resGetNamefromData(const char* type, const void *data)
{
	RES_TYPE	*psT;
	RES_DATA	*psRes;
	UDWORD   HashedType;

	if (type == NULL || data == NULL)
	{
		return "";
	}

	// Find the correct type
	HashedType = HashString(type);

	// Find the resource table for the given type
	for (psT = psResTypes; psT != NULL; psT = psT->psNext)
	{
		if (psT->HashedType == HashedType)
		{
			break;
		}
	}

	if (psT == NULL)
	{
		ASSERT( false, "resGetHashfromData: Unknown type: %x", HashedType );
		return "";
	}

	// Find the resource in the resource table
	for(psRes = psT->psRes; psRes; psRes = psRes->psNext)
	{
		if (psRes->pData == data)
		{
			break;
		}
	}

	if (psRes == NULL)
	{
		ASSERT( false, "resGetHashfromData:: couldn't find data for type %x\n", HashedType );
		return "";
	}

	return psRes->aID;
}
Esempio n. 27
0
/*
-----------------------------------------------------------------------------
 Function: Cvar_FindVar -Return cvar;
 
 Parameters: var_name -[in] Name of cvar to lookup.
 
 Returns: NULL if cvar not found, otherwise returns the cvar.
 
 Notes: 

-----------------------------------------------------------------------------
*/
cvar_t *Cvar_FindVar( const char *var_name )
{
	cvar_t	*var;
	int hashid;

	hashid = HashString( var_name );
	
	for( var = cvar_vars ; var ; var = var->next )
	{
		if( hashid == var->hashid && !strcasecmp( var_name, var->name ) )
		{
			return var;
		}
	}

	return NULL;
}
Esempio n. 28
0
void CWedDoc::SaveRedo()
{
	CString droot; int hhh = HashString(GetPathName());
	droot.Format("%sdata\\%x.rdo", dataroot, hhh);

	//P2N("Save Redo To: %s\r\n", droot);

 	CFile cf;
	if( cf.Open(droot, CFile::modeCreate | CFile::modeWrite ))
		{
		CArchive ar( &cf, CArchive::store);
		redo.Serialize(ar);
		}
	else
		{
		//P2N("Cannot create redo file: %s\r\n", droot);
		}
}
Esempio n. 29
0
BHttpAuthentication&
BUrlContext::GetAuthentication(const BUrl& url)
{
	BString domain = url.Host();
	domain += url.Path();

	BHttpAuthentication* authentication = NULL;

	do {
		authentication = fAuthenticationMap->Get( HashString(domain.String(),
			domain.Length()));

		domain.Truncate(domain.FindLast('/'));

	} while(authentication == NULL);

	return *authentication;
}
Esempio n. 30
0
void CElement::FindAllChildrenByType ( const char* szType, lua_State* pLua )
{
    assert ( szType );
    assert ( pLua );

    // Add all children of the given type to the table
    unsigned int uiIndex = 0;
    unsigned int uiTypeHash = HashString ( szType );

    if ( this == g_pGame->GetMapManager ()->GetRootElement () )
    {
        GetEntitiesFromRoot ( uiTypeHash, pLua );
    }
    else
    {
        FindAllChildrenByTypeIndex ( uiTypeHash, pLua, uiIndex );
    }
}