Merge remote-tracking branch 'upstream/master'

This commit is contained in:
FinnHornhoover 2020-08-22 17:04:00 +03:00
commit 324a606fff
8 changed files with 15 additions and 7 deletions

View File

@ -39,7 +39,8 @@ HDR=\
src/CNShardServer.hpp\ src/CNShardServer.hpp\
src/CNShared.hpp\ src/CNShared.hpp\
src/CNStructs.hpp\ src/CNStructs.hpp\
src/INIReader.hpp\ src/contrib/INIReader.hpp\
src/contrib/JSON.hpp\
src/NanoManager.hpp\ src/NanoManager.hpp\
src/ItemManager.hpp\ src/ItemManager.hpp\
src/NPCManager.hpp\ src/NPCManager.hpp\

View File

@ -10,7 +10,7 @@ randomcharacters=true
[shard] [shard]
port=8002 port=8002
# you'll want to change this one # you'll want to change this one
ip=192.168.1.183 ip=127.0.0.1
# distance at which other players and NPCs become visible # distance at which other players and NPCs become visible
view=20000 view=20000
# little message players see when they enter the game # little message players see when they enter the game

View File

@ -73,12 +73,15 @@ CNSocket::CNSocket(SOCKET s, PacketHandler ph): sock(s), pHandler(ph) {
bool CNSocket::sendData(uint8_t* data, int size) { bool CNSocket::sendData(uint8_t* data, int size) {
int sentBytes = 0; int sentBytes = 0;
int maxTries = 10;
while (sentBytes < size) { while (sentBytes < size) {
int sent = send(sock, (buffer_t*)(data + sentBytes), size - sentBytes, 0); // no flags defined int sent = send(sock, (buffer_t*)(data + sentBytes), size - sentBytes, 0); // no flags defined
if (SOCKETERROR(sent)) { if (SOCKETERROR(sent)) {
if (errno == 11) if (errno == 11 && maxTries > 0) {
maxTries--;
continue; // try again continue; // try again
}
std::cout << "[FATAL] SOCKET ERROR: " << errno << std::endl; std::cout << "[FATAL] SOCKET ERROR: " << errno << std::endl;
return false; // error occured while sending bytes return false; // error occured while sending bytes
} }

View File

@ -1,8 +1,12 @@
#include "CNStructs.hpp" #include "CNStructs.hpp"
std::string U16toU8(char16_t* src) { std::string U16toU8(char16_t* src) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert; try {
return convert.to_bytes(src); std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
return convert.to_bytes(src);
} catch(std::exception e) {
return "";
}
} }
// returns number of char16_t that was written at des // returns number of char16_t that was written at des

View File

@ -6,7 +6,7 @@
#include <list> #include <list>
#include <fstream> #include <fstream>
#include "JSON.hpp" #include "contrib/JSON.hpp"
std::map<int32_t, BaseNPC> NPCManager::NPCs; std::map<int32_t, BaseNPC> NPCManager::NPCs;

View File

@ -1,6 +1,6 @@
#include <iostream> #include <iostream>
#include "settings.hpp" #include "settings.hpp"
#include "INIReader.hpp" #include "contrib/INIReader.hpp"
// defaults :) // defaults :)
int settings::LOGINPORT = 8001; int settings::LOGINPORT = 8001;