MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / checkString

Method checkString

Engine/source/sim/connectionStringTable.cpp:123–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123U32 ConnectionStringTable::checkString(NetStringHandle &string, bool *isOnOtherSide)
124{
125 // see if the entry is in the hash table right now
126 U32 hashIndex = string.getIndex() % EntryCount;
127 for(Entry *walk = mHashTable[hashIndex]; walk; walk = walk->nextHash)
128 {
129 if(walk->string == string)
130 {
131 pushBack(walk);
132 if(isOnOtherSide)
133 *isOnOtherSide = walk->receiveConfirmed;
134 return walk->index;
135 }
136 }
137
138 // not in the hash table, means we have to add it
139 Entry *newEntry;
140
141 // pull the new entry from the LRU list.
142 newEntry = mLRUHead.nextLink;
143 pushBack(newEntry);
144
145 // remove the string from the hash table
146 Entry **hashWalk;
147 for (hashWalk = &mHashTable[newEntry->string.getIndex() % EntryCount]; *hashWalk; hashWalk = &((*hashWalk)->nextHash))
148 {
149 if(*hashWalk == newEntry)
150 {
151 *hashWalk = newEntry->nextHash;
152 break;
153 }
154 }
155
156 newEntry->string = string;
157 newEntry->receiveConfirmed = false;
158 newEntry->nextHash = mHashTable[hashIndex];
159 mHashTable[hashIndex] = newEntry;
160
161 mParent->postNetEvent(new NetStringEvent(newEntry->index, string));
162 if(isOnOtherSide)
163 *isOnOtherSide = false;
164 return newEntry->index;
165}
166
167void ConnectionStringTable::mapString(U32 netId, NetStringHandle &string)
168{

Callers

nothing calls this directly

Calls 3

postNetEventMethod · 0.80
pushBackFunction · 0.50
getIndexMethod · 0.45

Tested by

no test coverage detected