2020-08-21 17:38:45 +00:00
|
|
|
/*
|
2020-08-20 16:36:29 +00:00
|
|
|
CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
2020-08-18 20:42:30 +00:00
|
|
|
*/
|
|
|
|
|
2020-08-23 17:14:54 +00:00
|
|
|
#pragma once
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-08-20 21:47:38 +00:00
|
|
|
#ifdef _MSC_VER
|
2020-08-21 05:18:19 +00:00
|
|
|
// codecvt_* is deprecated in C++17 and MSVC will throw an annoying warning because of that.
|
|
|
|
// Defining this before anything else to silence it.
|
|
|
|
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
|
2020-08-20 21:47:38 +00:00
|
|
|
#endif
|
|
|
|
|
2020-08-18 20:42:30 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
2020-08-20 15:43:37 +00:00
|
|
|
#ifndef _MSC_VER
|
2020-08-21 05:18:19 +00:00
|
|
|
#include <sys/time.h>
|
2020-08-20 15:43:37 +00:00
|
|
|
#else
|
2020-08-20 21:47:38 +00:00
|
|
|
// Can't use this in MSVC.
|
2020-08-21 05:18:19 +00:00
|
|
|
#include <time.h>
|
2020-08-20 15:43:37 +00:00
|
|
|
#endif
|
2020-08-18 20:42:30 +00:00
|
|
|
#include <cstring>
|
2020-08-21 17:38:45 +00:00
|
|
|
#include <string>
|
|
|
|
#include <locale>
|
|
|
|
#include <codecvt>
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-09-14 13:53:48 +00:00
|
|
|
// yes this is ugly, but this is needed to zero out the memory so we don't have random stackdata in our structs.
|
2020-08-23 00:26:18 +00:00
|
|
|
#define INITSTRUCT(T, x) T x; \
|
|
|
|
memset(&x, 0, sizeof(T));
|
|
|
|
|
2020-08-18 20:42:30 +00:00
|
|
|
// TODO: rewrite U16toU8 & U8toU16 to not use codecvt
|
|
|
|
|
|
|
|
std::string U16toU8(char16_t* src);
|
2020-10-04 17:50:58 +00:00
|
|
|
size_t U8toU16(std::string src, char16_t* des, size_t max); // returns number of char16_t that was written at des
|
2020-09-16 18:14:00 +00:00
|
|
|
time_t getTime();
|
2020-09-22 19:15:47 +00:00
|
|
|
time_t getTimestamp();
|
2020-08-18 20:42:30 +00:00
|
|
|
|
2020-08-21 17:38:45 +00:00
|
|
|
// The PROTOCOL_VERSION definition is defined by the build system.
|
|
|
|
#if !defined(PROTOCOL_VERSION)
|
2020-08-21 19:29:09 +00:00
|
|
|
#include "structs/0104.hpp"
|
2020-08-21 17:38:45 +00:00
|
|
|
#elif PROTOCOL_VERSION == 728
|
2020-08-21 00:37:34 +00:00
|
|
|
#include "structs/0728.hpp"
|
2020-08-21 17:38:45 +00:00
|
|
|
#elif PROTOCOL_VERSION == 104
|
|
|
|
#include "structs/0104.hpp"
|
|
|
|
#else
|
|
|
|
#error Invalid PROTOCOL_VERSION
|
2020-08-19 20:00:39 +00:00
|
|
|
#endif
|