mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-23 08:27:06 +00:00
Fix useless strlen & substr
This commit is contained in:
@@ -195,12 +195,11 @@ void HandleEvent(Client* c, const std::string& Data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalParser(Client* c, const std::string& Pack) {
|
void GlobalParser(Client* c, const std::string& Packet) {
|
||||||
Assert(c);
|
Assert(c);
|
||||||
if (Pack.empty() || c == nullptr)
|
if (Packet.empty() || c == nullptr)
|
||||||
return;
|
return;
|
||||||
std::any Res;
|
std::any Res;
|
||||||
std::string Packet = Pack.substr(0, strlen(Pack.c_str()));
|
|
||||||
char Code = Packet.at(0);
|
char Code = Packet.at(0);
|
||||||
|
|
||||||
//V to Z
|
//V to Z
|
||||||
@@ -212,7 +211,7 @@ void GlobalParser(Client* c, const std::string& Pack) {
|
|||||||
switch (Code) {
|
switch (Code) {
|
||||||
case 'H': // initial connection
|
case 'H': // initial connection
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug(std::string("got 'H' packet: '") + Pack + "' (" + std::to_string(Packet.size()) + ")");
|
debug(std::string("got 'H' packet: '") + Packet + "' (" + std::to_string(Packet.size()) + ")");
|
||||||
#endif
|
#endif
|
||||||
SyncClient(c);
|
SyncClient(c);
|
||||||
return;
|
return;
|
||||||
@@ -228,13 +227,13 @@ void GlobalParser(Client* c, const std::string& Pack) {
|
|||||||
return;
|
return;
|
||||||
case 'J':
|
case 'J':
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug(std::string(("got 'J' packet: '")) + Pack + ("' (") + std::to_string(Packet.size()) + (")"));
|
debug(std::string(("got 'J' packet: '")) + Packet + ("' (") + std::to_string(Packet.size()) + (")"));
|
||||||
#endif
|
#endif
|
||||||
SendToAll(c, Packet, false, true);
|
SendToAll(c, Packet, false, true);
|
||||||
return;
|
return;
|
||||||
case 'C':
|
case 'C':
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug(std::string(("got 'C' packet: '")) + Pack + ("' (") + std::to_string(Packet.size()) + (")"));
|
debug(std::string(("got 'C' packet: '")) + Packet + ("' (") + std::to_string(Packet.size()) + (")"));
|
||||||
#endif
|
#endif
|
||||||
if (Packet.length() < 4 || Packet.find(':', 3) == std::string::npos)
|
if (Packet.length() < 4 || Packet.find(':', 3) == std::string::npos)
|
||||||
break;
|
break;
|
||||||
@@ -245,7 +244,7 @@ void GlobalParser(Client* c, const std::string& Pack) {
|
|||||||
return;
|
return;
|
||||||
case 'E':
|
case 'E':
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug(std::string(("got 'E' packet: '")) + Pack + ("' (") + std::to_string(Packet.size()) + (")"));
|
debug(std::string(("got 'E' packet: '")) + Packet + ("' (") + std::to_string(Packet.size()) + (")"));
|
||||||
#endif
|
#endif
|
||||||
HandleEvent(c, Packet);
|
HandleEvent(c, Packet);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user