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

Method checkString

engine/source/network/connectionStringTable.cc:114–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

postNetEventMethod · 0.80
getIndexMethod · 0.45

Tested by

no test coverage detected