diff --git a/Makefile b/Makefile index be6ed7a..d8eef65 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,8 @@ HDR=\ src/CNShardServer.hpp\ src/CNShared.hpp\ src/CNStructs.hpp\ - src/INIReader.hpp\ + src/contrib/INIReader.hpp\ + src/contrib/JSON.hpp\ src/NanoManager.hpp\ src/ItemManager.hpp\ src/NPCManager.hpp\ diff --git a/config.ini b/config.ini index b73ff3b..c479216 100644 --- a/config.ini +++ b/config.ini @@ -10,7 +10,7 @@ randomcharacters=true [shard] port=8002 # 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 view=20000 # little message players see when they enter the game diff --git a/src/CNProtocol.cpp b/src/CNProtocol.cpp index ad724d6..f7df999 100644 --- a/src/CNProtocol.cpp +++ b/src/CNProtocol.cpp @@ -73,12 +73,15 @@ CNSocket::CNSocket(SOCKET s, PacketHandler ph): sock(s), pHandler(ph) { bool CNSocket::sendData(uint8_t* data, int size) { int sentBytes = 0; + int maxTries = 10; while (sentBytes < size) { int sent = send(sock, (buffer_t*)(data + sentBytes), size - sentBytes, 0); // no flags defined if (SOCKETERROR(sent)) { - if (errno == 11) + if (errno == 11 && maxTries > 0) { + maxTries--; continue; // try again + } std::cout << "[FATAL] SOCKET ERROR: " << errno << std::endl; return false; // error occured while sending bytes } diff --git a/src/CNStructs.cpp b/src/CNStructs.cpp index 2885f36..b580cc3 100644 --- a/src/CNStructs.cpp +++ b/src/CNStructs.cpp @@ -1,8 +1,12 @@ #include "CNStructs.hpp" std::string U16toU8(char16_t* src) { - std::wstring_convert,char16_t> convert; - return convert.to_bytes(src); + try { + std::wstring_convert,char16_t> convert; + return convert.to_bytes(src); + } catch(std::exception e) { + return ""; + } } // returns number of char16_t that was written at des diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index 0a2cff8..52cc07e 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -6,7 +6,7 @@ #include #include -#include "JSON.hpp" +#include "contrib/JSON.hpp" std::map NPCManager::NPCs; diff --git a/src/INIReader.hpp b/src/contrib/INIReader.hpp similarity index 100% rename from src/INIReader.hpp rename to src/contrib/INIReader.hpp diff --git a/src/JSON.hpp b/src/contrib/JSON.hpp similarity index 100% rename from src/JSON.hpp rename to src/contrib/JSON.hpp diff --git a/src/settings.cpp b/src/settings.cpp index a4fcb47..59dff6d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,6 +1,6 @@ #include #include "settings.hpp" -#include "INIReader.hpp" +#include "contrib/INIReader.hpp" // defaults :) int settings::LOGINPORT = 8001;