| 147 | if (!format) |
| 148 | { |
| 149 | RptF("Server: Bad message %d(%s) format", (int)type, (const char*)NetworkMessageTypeNames[type]); |
| 150 | return; |
| 151 | } |
| 152 | NetworkMessageContext ctx(msg, format, this, from, MSG_RECEIVE); |
| 153 | |
| 154 | #if _ENABLE_CHEATS |
| 155 | int level = GetDiagLevel(type, from != _parent->GetClient()->GetPlayer()); |
| 156 | if (level >= 2) |
| 157 | { |
| 158 | DiagLogF("Server: received message %s from %d", NetworkMessageTypeNames[type], from); |
| 159 | ctx.LogMessage(level, "\t"); |
| 160 | } |
| 161 | #endif |
| 162 | |
| 163 | // Table-driven dispatch (strangler-fig migration). Every message is first |
| 164 | // authorized centrally against its MsgDescriptor; types with a registered |
| 165 | // handler are then dispatched through the seam, everything else falls through |
| 166 | // to the switch below unchanged. |
| 167 | if (const MsgDescriptor* d = LookupMsgDescriptor(type)) |
| 168 | { |
| 169 | if (!Authorize(*d, from)) |
| 170 | { |
| 171 | LOG_WARN(Network, "Server: rejected {} from {} (server-origin message sent by a client)", |
| 172 | NetworkMessageTypeNames[type], from); |
| 173 | return; |
| 174 | } |
| 175 | if (d->handle) |
| 176 | { |
| 177 | ServerMsgCtx sctx{from, msg, type, *this, ctx}; |
| 178 | d->handle(sctx); |
| 179 | return; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | int index1 = -1, index2 = -1; |
| 184 | |
| 185 | switch (type) |
| 186 | { |
| 187 | case NMTIntegrityAnswer: |
| 188 | { |
| 189 | IntegrityAnswerMessage answer; |
| 190 | answer.TransferMsg(ctx); |
| 191 | NetworkPlayerInfo* info = GetPlayerInfo(from); |
| 192 | if (info) |
| 193 | { |
| 194 | int qId = answer.id; |
| 195 | IntegrityQuestionType qType = answer.type; |
| 196 | // it should be an answer to the first question of given type |
| 197 | |
| 198 | int qIndex = -1; |
| 199 | if (qId > 0) |
| 200 | { |
| 201 | qIndex = info->FindIntegrityQuestion(qId); |
| 202 | } |
| 203 | else |
| 204 | { |
| 205 | qIndex = info->FindIntegrityQuestion(qType); |
| 206 | } |
nothing calls this directly
no test coverage detected