mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-22 03:50:04 +00:00
Rearranged the codebase a little.
* Deleted empty Player.cpp * Moved the helper functions from the obsolete CNStructs.cpp into main.cpp and deleted it * Renamed CombatManager to MobManager, as that will likely become it's main focus soon
This commit is contained in:
36
src/main.cpp
36
src/main.cpp
@@ -2,7 +2,7 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "ChatManager.hpp"
|
||||
#include "CombatManager.hpp"
|
||||
#include "MobManager.hpp"
|
||||
#include "ItemManager.hpp"
|
||||
#include "MissionManager.hpp"
|
||||
#include "NanoManager.hpp"
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <thread>
|
||||
#endif
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <signal.h>
|
||||
|
||||
// HACK
|
||||
@@ -92,7 +93,7 @@ int main() {
|
||||
TableData::init();
|
||||
PlayerManager::init();
|
||||
ChatManager::init();
|
||||
CombatManager::init();
|
||||
MobManager::init();
|
||||
ItemManager::init();
|
||||
MissionManager::init();
|
||||
NanoManager::init();
|
||||
@@ -117,3 +118,34 @@ int main() {
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// helper functions
|
||||
|
||||
std::string U16toU8(char16_t* src) {
|
||||
try {
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
|
||||
return convert.to_bytes(src);
|
||||
} catch(const std::exception& e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// returns number of char16_t that was written at des
|
||||
size_t U8toU16(std::string src, char16_t* des) {
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
|
||||
std::u16string tmp = convert.from_bytes(src);
|
||||
|
||||
// copy utf16 string to buffer
|
||||
memcpy(des, tmp.c_str(), sizeof(char16_t) * tmp.length());
|
||||
des[tmp.length()] = '\0';
|
||||
|
||||
return tmp.length();
|
||||
}
|
||||
|
||||
time_t getTime() {
|
||||
using namespace std::chrono;
|
||||
|
||||
milliseconds value = duration_cast<milliseconds>((time_point_cast<milliseconds>(high_resolution_clock::now())).time_since_epoch());
|
||||
|
||||
return (time_t)value.count();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user