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

Method checkString

Engine/source/sim/connectionStringTable.cpp:125–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

postNetEventMethod · 0.80
pushBackFunction · 0.50
getIndexMethod · 0.45

Tested by

no test coverage detected