mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
Fix printing, make CI into unique_ptr (more)
This commit is contained in:
parent
b663563f01
commit
7fce274915
@ -82,4 +82,4 @@ struct ClientInterface{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ClientInterface* CI;
|
extern std::unique_ptr<ClientInterface> CI;
|
||||||
|
@ -132,6 +132,7 @@ static bool CompositeInputExpected { false };
|
|||||||
static void ProcessCompositeInput() {
|
static void ProcessCompositeInput() {
|
||||||
if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array<char, 2> { 91, 65 }.data(), 2) == 0) {
|
if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array<char, 2> { 91, 65 }.data(), 2) == 0) {
|
||||||
// UP ARROW
|
// UP ARROW
|
||||||
|
info(std::to_string(ConsoleHistoryReadIndex));
|
||||||
if (!ConsoleHistory.empty()) {
|
if (!ConsoleHistory.empty()) {
|
||||||
if (ConsoleHistoryReadIndex != 0) {
|
if (ConsoleHistoryReadIndex != 0) {
|
||||||
ConsoleHistoryReadIndex -= 1;
|
ConsoleHistoryReadIndex -= 1;
|
||||||
@ -140,6 +141,7 @@ static void ProcessCompositeInput() {
|
|||||||
}
|
}
|
||||||
} else if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array<char, 2> { 91, 66 }.data(), 2) == 0) {
|
} else if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array<char, 2> { 91, 66 }.data(), 2) == 0) {
|
||||||
// DOWN ARROW
|
// DOWN ARROW
|
||||||
|
info(std::to_string(ConsoleHistoryReadIndex));
|
||||||
if (!ConsoleHistory.empty()) {
|
if (!ConsoleHistory.empty()) {
|
||||||
if (ConsoleHistoryReadIndex != ConsoleHistory.size() - 1) {
|
if (ConsoleHistoryReadIndex != ConsoleHistory.size() - 1) {
|
||||||
ConsoleHistoryReadIndex += 1;
|
ConsoleHistoryReadIndex += 1;
|
||||||
|
@ -31,5 +31,5 @@ void Args(int argc, char* argv[]){
|
|||||||
void InitServer(int argc, char* argv[]){
|
void InitServer(int argc, char* argv[]){
|
||||||
InitLog();
|
InitLog();
|
||||||
Args(argc,argv);
|
Args(argc,argv);
|
||||||
CI = new ClientInterface;
|
CI = std::make_unique<ClientInterface>();
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){
|
|||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DebugPrintTIDInternal(std::string("Client(") + Name + ")");
|
// DebugPrintTIDInternal(std::string("Client(") + Name + ")");
|
||||||
debug(Sec("Name -> ") + Name + Sec(", Role -> ") + Role + Sec(", ID -> ") + DID);
|
debug(Sec("Name -> ") + Name + Sec(", Role -> ") + Role + Sec(", ID -> ") + DID);
|
||||||
for(auto& c : CI->Clients){
|
for(auto& c : CI->Clients){
|
||||||
if(c != nullptr){
|
if(c != nullptr){
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
ClientInterface* CI;
|
#include <memory>
|
||||||
|
std::unique_ptr<ClientInterface> CI;
|
||||||
void NetMain(){
|
void NetMain(){
|
||||||
std::thread TCP(TCPServerMain);
|
std::thread TCP(TCPServerMain);
|
||||||
TCP.detach();
|
TCP.detach();
|
||||||
|
@ -113,7 +113,7 @@ void TCPRcv(Client*c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TCPClient(Client*c){
|
void TCPClient(Client*c){
|
||||||
DebugPrintTID();
|
DebugPrintTIDInternal(c->GetName(), true);
|
||||||
Assert(c);
|
Assert(c);
|
||||||
if(c->GetTCPSock() == -1){
|
if(c->GetTCPSock() == -1){
|
||||||
CI->RemoveClient(c);
|
CI->RemoveClient(c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user