Fix small things to help cross-platform compatibility.

Downgrade to C++11 in makefile.
Fixup make_unique.
Use old style chrono duration.
Switch to mutex from atomic to avoid linking to libatomic on some platforms.

Update info file to include pzp extension.
This commit is contained in:
Nathan Whitehead committed 2022-09-29 09:56:17 -06:00
1 parent aa11bf9a89
commit da2996e74a
5 files changed
+14 -10

No files matched your search

+2 -2
View File
@@ -727,8 +727,8 @@ OBJECTS := $(SOURCES_CXX:.cpp=.o) $(SOURCES_C:.c=.o)
ifeq ($(HAS_GCC), 1)
C_VER = -std=gnu99
# Requires at least C++ 17
CXXFLAGS += -std=c++17
# Requires at least C++ 11
CXXFLAGS += -std=c++11
CXXFLAGS += -fno-rtti
endif
+1 -1
View File
@@ -3,7 +3,7 @@ display_name = "PuzzleScript (pzretro)"
categories = "Game engine"
authors = "Nathan Whitehead"
corename = "puzzlescript"
supported_extensions = "pz"
supported_extensions = "pz|pzp"
license = "MIT"
permissions = ""
+5 -3
View File
@@ -112,7 +112,7 @@ public:
void GameLoop::thread_func()
{
js_context = std::make_unique<js::Context>();
js_context = std::unique_ptr<js::Context>(new js::Context());
if (should_use_puzzlescript_plus()) {
js_context->eval(std::string("use_puzzlescript_plus = true;"), "eval");
@@ -257,7 +257,7 @@ std::unique_ptr<GameLoop> gameLoop;
void reset_game()
{
update_variables();
gameLoop = std::make_unique<GameLoop>();
gameLoop = std::unique_ptr<GameLoop>(new GameLoop());
}
bool retro_load_game(const struct retro_game_info *info)
@@ -459,7 +459,9 @@ void retro_run()
// Get input for frame
input_poll_cb();
for (auto const & [key, val] : joypad_keys) {
for (auto const & binding : joypad_keys) {
auto const & key{binding.first};
auto const & val{binding.second};
if (!joypad_old_state[key] && input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, key)) {
if (key == RETRO_DEVICE_ID_JOYPAD_START) {
// Check for A+START cheatcode
+1 -2
View File
@@ -191,9 +191,8 @@ JSValue js_sprite_render(JSContext *ctx, JSValueConst /*this_val*/, int /*argc*/
JSValue js_sleep(JSContext *ctx, JSValueConst /*this_val*/, int /*argc*/, JSValueConst *argv)
{
using namespace std::chrono_literals;
double delay_s{js_getNumber(ctx, argv[0])};
std::this_thread::sleep_for(1s * delay_s);
std::this_thread::sleep_for(std::chrono::duration<double>(delay_s));
return JS_UNDEFINED;
}
+5 -2
View File
@@ -1,18 +1,21 @@
#include "time.h"
#include <atomic>
#include <mutex>
namespace pztime {
std::atomic<uint64_t> cumulative{0};
uint64_t cumulative{0};
std::mutex mutex;
uint64_t elapsed()
{
std::lock_guard<std::mutex> guard(mutex);
return cumulative;
}
void increment(uint64_t delta)
{
std::lock_guard<std::mutex> guard(mutex);
cumulative += delta;
}