android fix
This commit is contained in:
parent
f4c5b1ad9a
commit
9a37e8b581
@ -4,6 +4,7 @@
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "sys.hpp"
|
||||
#include "DnaStore.hpp"
|
||||
@ -15,10 +16,12 @@
|
||||
#define ID_FILE_NAME "ID.bin"
|
||||
#define DATA_FILE_NAME "DATA.bin"
|
||||
#define VECTOR_FILE_NAME "VECTOR.bin"
|
||||
#define GEN_FILE_PATTRN "gen%04d.bin"
|
||||
#define GEN_FILE_PATTRN "gen/%04d.bin"
|
||||
|
||||
void DnaStore::load(DnaManagerData *data)
|
||||
{
|
||||
const char *dir = sys::transformFilePath("gen");
|
||||
std::filesystem::create_directory(dir);
|
||||
if (sys::fileExists(ID_FILE_NAME))
|
||||
{
|
||||
sys::loadDataFromFile(ID_FILE_NAME, &data->id, sizeof(int64_t));
|
||||
@ -160,8 +163,7 @@ void DnaStore::sync()
|
||||
|
||||
void client(std::string prefix)
|
||||
{
|
||||
|
||||
constexpr int extra_buff = 20; // len of 2**31 -> 2147483648 plus the pattern size
|
||||
constexpr int extra_buff = 22; // len of 2**31 -> 2147483648 plus the pattern size
|
||||
std::string buffer;
|
||||
buffer.resize(prefix.size() + extra_buff);
|
||||
|
||||
@ -173,7 +175,12 @@ void client(std::string prefix)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
int ret = sprintf(buffer.data(), "%s/" ID_FILE_NAME, prefix.c_str());
|
||||
#else
|
||||
int ret = sprintf(buffer.data(), ID_FILE_NAME);
|
||||
#endif
|
||||
|
||||
buffer.data()[ret] = 0;
|
||||
std::ifstream idf(buffer, std::ios_base::binary);
|
||||
|
||||
@ -203,7 +210,12 @@ void client(std::string prefix)
|
||||
|
||||
needed_gen = message.data;
|
||||
|
||||
#if defined(PLATFORM_ANDROID)
|
||||
int ret = sprintf(buffer.data(), "%s/" GEN_FILE_PATTRN, prefix.c_str(), needed_gen);
|
||||
#else
|
||||
int ret = sprintf(buffer.data(), GEN_FILE_PATTRN, needed_gen);
|
||||
#endif
|
||||
|
||||
buffer.data()[ret] = 0;
|
||||
|
||||
if (!std::filesystem::exists(buffer))
|
||||
|
@ -31,6 +31,7 @@ void call(int sock, sockaddr_in newSocketInfo)
|
||||
if (id == 0)
|
||||
{
|
||||
printf("ID ERROR\n");
|
||||
TcpSocket::closet(sock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -68,6 +69,7 @@ void call(int sock, sockaddr_in newSocketInfo)
|
||||
{
|
||||
message.mess = Mess::REQ_SEND_GEN;
|
||||
message.data = gen;
|
||||
printf("requesting gen %ld\n", gen);
|
||||
TcpSocket::sendt(sock, &message, sizeof(Message));
|
||||
TcpSocket::recvt(sock, &message, sizeof(Message));
|
||||
|
||||
|
@ -10,7 +10,7 @@ struct uint128
|
||||
|
||||
namespace mrand
|
||||
{
|
||||
uint128 getState(unsigned long seed);
|
||||
uint128 getState(uint64_t seed);
|
||||
float getFloat(uint128 *state);
|
||||
int getValue(int min, int max, uint128 *state);
|
||||
unsigned int computeCRC32(void *data, int dataSize);
|
||||
|
@ -34,7 +34,7 @@ uint64_t rprand_splitmix64(uint64_t &rprand_seed)
|
||||
|
||||
namespace mrand
|
||||
{
|
||||
uint128 getState(unsigned long rprand_seed)
|
||||
uint128 getState(uint64_t rprand_seed)
|
||||
{
|
||||
uint128 rprand_state;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user