import ADV settings, platform files

This commit is contained in:
Ondřej Novák 2025-01-30 20:43:42 +01:00
parent 9b86bed2d8
commit ccebc91f0d
17 changed files with 244 additions and 14 deletions

View file

@ -1,2 +0,0 @@
add_library(skeldal_linux map_file.cpp timer.cpp)

View file

@ -0,0 +1,25 @@
#include "../save_folder.h"
#include "../error.h"
#include <filesystem>
static std::string get_default_savegame_dir() {
// Linux
char* home = std::getenv("HOME");
if (home) {
return std::filesystem::path(home) / ".local/share/" SAVEGAME_FOLDERNAME;
} else {
display_error("$HOME has no value (user with no home)");
abort();
}
}
const char *get_default_savegame_directory() {
static std::string dir = get_default_savegame_dir();
return dir.c_str();
}

View file

@ -1,18 +0,0 @@
#include "timer.h"
#include <chrono>
#include "../platform.h"
#include <thread>
int get_timer_value() {
auto n = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(n.time_since_epoch()).count()/TIMERSPEED;
}
uint32_t get_game_tick_count() {
auto n = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(n.time_since_epoch()).count();
}
void sleep_ms(uint32_t x) {
std::this_thread::sleep_for(std::chrono::milliseconds(x));
}

View file

@ -1,28 +0,0 @@
/*
* timer.h
*
* Created on: 26. 1. 2025
* Author: ondra
*/
#ifndef PLATFORM_LINUX_TIMER_H_
#define PLATFORM_LINUX_TIMER_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
int get_timer_value();
uint32_t get_game_tick_count();
void sleep_ms(uint32_t);
#ifdef __cplusplus
}
#endif
#endif /* PLATFORM_LINUX_TIMER_H_ */