mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Merge branch 'main' into SDL3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -68,6 +68,10 @@ void showRecordingPermissionMissingDialog()
|
||||
#endif
|
||||
}
|
||||
|
||||
Audio::Audio(const char *name)
|
||||
: Module(M_AUDIO, name)
|
||||
{}
|
||||
|
||||
bool Audio::setMixWithSystem(bool mix)
|
||||
{
|
||||
#ifdef LOVE_IOS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -101,9 +101,6 @@ public:
|
||||
|
||||
virtual ~Audio() {}
|
||||
|
||||
// Implements Module.
|
||||
virtual ModuleType getModuleType() const { return M_AUDIO; }
|
||||
|
||||
virtual Source *newSource(love::sound::Decoder *decoder) = 0;
|
||||
virtual Source *newSource(love::sound::SoundData *soundData) = 0;
|
||||
virtual Source *newSource(int sampleRate, int bitDepth, int channels, int buffers) = 0;
|
||||
@@ -312,6 +309,10 @@ public:
|
||||
*/
|
||||
virtual void setPlaybackDevice(const char *name);
|
||||
|
||||
protected:
|
||||
|
||||
Audio(const char *name);
|
||||
|
||||
private:
|
||||
|
||||
static StringMap<DistanceModel, DISTANCE_MAX_ENUM>::Entry distanceModelEntries[];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -28,7 +28,8 @@ namespace null
|
||||
{
|
||||
|
||||
Audio::Audio()
|
||||
: distanceModel(DISTANCE_NONE)
|
||||
: love::audio::Audio("love.audio.null")
|
||||
, distanceModel(DISTANCE_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,11 +37,6 @@ Audio::~Audio()
|
||||
{
|
||||
}
|
||||
|
||||
const char *Audio::getName() const
|
||||
{
|
||||
return "love.audio.null";
|
||||
}
|
||||
|
||||
love::audio::Source *Audio::newSource(love::sound::Decoder *)
|
||||
{
|
||||
return new Source();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -41,9 +41,6 @@ public:
|
||||
Audio();
|
||||
virtual ~Audio();
|
||||
|
||||
// Implements Module.
|
||||
const char *getName() const;
|
||||
|
||||
// Implements Audio.
|
||||
love::audio::Source *newSource(love::sound::Decoder *decoder);
|
||||
love::audio::Source *newSource(love::sound::SoundData *soundData);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -106,7 +106,8 @@ static const char *getDeviceSpecifier(ALCdevice *device)
|
||||
}
|
||||
|
||||
Audio::Audio()
|
||||
: device(nullptr)
|
||||
: love::audio::Audio("love.audio.openal")
|
||||
, device(nullptr)
|
||||
, context(nullptr)
|
||||
, pool(nullptr)
|
||||
, poolThread(nullptr)
|
||||
@@ -256,11 +257,6 @@ Audio::~Audio()
|
||||
alcCloseDevice(device);
|
||||
}
|
||||
|
||||
const char *Audio::getName() const
|
||||
{
|
||||
return "love.audio.openal";
|
||||
}
|
||||
|
||||
love::audio::Source *Audio::newSource(love::sound::Decoder *decoder)
|
||||
{
|
||||
return new Source(pool, decoder);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -78,9 +78,6 @@ public:
|
||||
**/
|
||||
static ALenum getFormat(int bitDepth, int channels);
|
||||
|
||||
// Implements Module.
|
||||
const char *getName() const;
|
||||
|
||||
// Implements Audio.
|
||||
love::audio::Source *newSource(love::sound::Decoder *decoder);
|
||||
love::audio::Source *newSource(love::sound::SoundData *soundData);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -214,6 +214,7 @@ void hash(HashFunction::Function function, const char *input, uint64_t size, Has
|
||||
}
|
||||
|
||||
DataModule::DataModule()
|
||||
: Module(M_DATA, "love.data")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -117,10 +117,6 @@ public:
|
||||
DataModule();
|
||||
virtual ~DataModule();
|
||||
|
||||
// Implements Module.
|
||||
ModuleType getModuleType() const override { return M_DATA; }
|
||||
const char *getName() const override { return "love.data"; }
|
||||
|
||||
DataView *newDataView(Data *data, size_t offset, size_t size);
|
||||
ByteData *newByteData(size_t size);
|
||||
ByteData *newByteData(const void *d, size_t size);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -135,16 +135,6 @@ int w_ByteData_setUInt32(lua_State *L)
|
||||
return w_ByteData_setT<uint32>(L);
|
||||
}
|
||||
|
||||
int w_ByteData_setInt64(lua_State *L)
|
||||
{
|
||||
return w_ByteData_setT<int64>(L);
|
||||
}
|
||||
|
||||
int w_ByteData_setUInt64(lua_State *L)
|
||||
{
|
||||
return w_ByteData_setT<uint64>(L);
|
||||
}
|
||||
|
||||
static const luaL_Reg w_ByteData_functions[] =
|
||||
{
|
||||
{ "clone", w_ByteData_clone },
|
||||
@@ -157,8 +147,6 @@ static const luaL_Reg w_ByteData_functions[] =
|
||||
{ "setUInt16", w_ByteData_setUInt16 },
|
||||
{ "setInt32", w_ByteData_setInt32 },
|
||||
{ "setUInt32", w_ByteData_setUInt32 },
|
||||
{ "setInt64", w_ByteData_setInt64 },
|
||||
{ "setUInt64", w_ByteData_setUInt64 },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "wrap_Data.h"
|
||||
#include "common/int.h"
|
||||
#include "thread/threads.h"
|
||||
|
||||
// Put the Lua code directly into a raw string literal.
|
||||
static const char data_lua[] =
|
||||
@@ -78,6 +79,26 @@ int w_Data_getSize(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Data_performAtomic(lua_State *L)
|
||||
{
|
||||
Data *t = luax_checkdata(L, 1);
|
||||
int err = 0;
|
||||
|
||||
{
|
||||
love::thread::Lock lock(t->getMutex());
|
||||
// call the function, passing any user-specified arguments.
|
||||
err = lua_pcall(L, lua_gettop(L) - 2, LUA_MULTRET, 0);
|
||||
}
|
||||
|
||||
// Unfortunately, this eats the stack trace, too bad.
|
||||
if (err != 0)
|
||||
return lua_error(L);
|
||||
|
||||
// The function and everything after it in the stack are eaten by the pcall,
|
||||
// leaving only the Data object. Everything else is a return value.
|
||||
return lua_gettop(L) - 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int w_Data_getT(lua_State* L)
|
||||
{
|
||||
@@ -139,16 +160,6 @@ int w_Data_getUInt32(lua_State* L)
|
||||
return w_Data_getT<uint32>(L);
|
||||
}
|
||||
|
||||
int w_Data_getInt64(lua_State* L)
|
||||
{
|
||||
return w_Data_getT<int64>(L);
|
||||
}
|
||||
|
||||
int w_Data_getUInt64(lua_State* L)
|
||||
{
|
||||
return w_Data_getT<uint64>(L);
|
||||
}
|
||||
|
||||
// C functions in a struct, necessary for the FFI versions of Data methods.
|
||||
struct FFI_Data
|
||||
{
|
||||
@@ -170,6 +181,7 @@ const luaL_Reg w_Data_functions[] =
|
||||
{ "getPointer", w_Data_getPointer },
|
||||
{ "getFFIPointer", w_Data_getFFIPointer },
|
||||
{ "getSize", w_Data_getSize },
|
||||
{ "performAtomic", w_Data_performAtomic },
|
||||
{ "getFloat", w_Data_getFloat },
|
||||
{ "getDouble", w_Data_getDouble },
|
||||
{ "getInt8", w_Data_getInt8 },
|
||||
@@ -178,8 +190,6 @@ const luaL_Reg w_Data_functions[] =
|
||||
{ "getUInt16", w_Data_getUInt16 },
|
||||
{ "getInt32", w_Data_getInt32 },
|
||||
{ "getUInt32", w_Data_getUInt32 },
|
||||
{ "getInt64", w_Data_getInt64 },
|
||||
{ "getUInt64", w_Data_getUInt64 },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -3,7 +3,7 @@ R"luastring"--(
|
||||
-- There is a matching delimiter at the bottom of the file.
|
||||
|
||||
--[[
|
||||
Copyright (c) 2006-2023 LOVE Development Team
|
||||
Copyright (c) 2006-2024 LOVE Development Team
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -302,25 +302,52 @@ int w_decode(lua_State *L)
|
||||
|
||||
int w_hash(lua_State *L)
|
||||
{
|
||||
const char *fstr = luaL_checkstring(L, 1);
|
||||
int narg = 0; // used to change the arg position when using the deprecated function variant
|
||||
|
||||
ContainerType ctype = CONTAINER_STRING;
|
||||
HashFunction::Function function;
|
||||
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
if (!getConstant(str, ctype))
|
||||
{
|
||||
if (HashFunction::getConstant(str, function))
|
||||
{ // check if the argument at 1 is a hash function; deprecated function variant
|
||||
luax_markdeprecated(L, 1, "love.data.hash", API_FUNCTION_VARIANT, DEPRECATED_REPLACED, "variant with container return type parameter");
|
||||
narg = -1;
|
||||
}
|
||||
else
|
||||
luax_enumerror(L, "container type", getConstants(ctype), str);
|
||||
}
|
||||
|
||||
const char *fstr = luaL_checkstring(L, 2 + narg);
|
||||
if (!HashFunction::getConstant(fstr, function))
|
||||
return luax_enumerror(L, "hash function", HashFunction::getConstants(function), fstr);
|
||||
|
||||
HashFunction::Value hashvalue;
|
||||
if (lua_isstring(L, 2))
|
||||
if (lua_isstring(L, 3 + narg))
|
||||
{
|
||||
size_t rawsize = 0;
|
||||
const char *rawbytes = luaL_checklstring(L, 2, &rawsize);
|
||||
const char *rawbytes = luaL_checklstring(L, 3 + narg, &rawsize);
|
||||
luax_catchexcept(L, [&](){ love::data::hash(function, rawbytes, rawsize, hashvalue); });
|
||||
}
|
||||
else
|
||||
{
|
||||
Data *rawdata = luax_checktype<Data>(L, 2);
|
||||
Data *rawdata = luax_checktype<Data>(L, 3 + narg);
|
||||
luax_catchexcept(L, [&](){ love::data::hash(function, rawdata, hashvalue); });
|
||||
}
|
||||
|
||||
lua_pushlstring(L, hashvalue.data, hashvalue.size);
|
||||
if (ctype == CONTAINER_DATA)
|
||||
{
|
||||
Data* d = nullptr;
|
||||
luax_catchexcept(L, [&]() { d = instance()->newByteData(hashvalue.size); });
|
||||
memcpy(d->getData(), hashvalue.data, hashvalue.size);
|
||||
|
||||
luax_pushtype(L, Data::type, d);
|
||||
d->release();
|
||||
}
|
||||
else
|
||||
lua_pushlstring(L, hashvalue.data, hashvalue.size);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -38,6 +38,11 @@ Message::~Message()
|
||||
{
|
||||
}
|
||||
|
||||
Event::Event(const char *name)
|
||||
: Module(M_EVENT, name)
|
||||
{
|
||||
}
|
||||
|
||||
Event::~Event()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -54,10 +54,8 @@ public:
|
||||
class Event : public Module
|
||||
{
|
||||
public:
|
||||
virtual ~Event();
|
||||
|
||||
// Implements Module.
|
||||
virtual ModuleType getModuleType() const { return M_EVENT; }
|
||||
virtual ~Event();
|
||||
|
||||
void push(Message *msg);
|
||||
bool poll(Message *&msg);
|
||||
@@ -67,6 +65,9 @@ public:
|
||||
virtual Message *wait() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
Event(const char *name);
|
||||
|
||||
love::thread::MutexRef mutex;
|
||||
std::queue<Message *> queue;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -156,12 +156,8 @@ static int SDLCALL watchAppEvents(void * /*udata*/, SDL_Event *event)
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *Event::getName() const
|
||||
{
|
||||
return "love.event.sdl";
|
||||
}
|
||||
|
||||
Event::Event()
|
||||
: love::event::Event("love.event.sdl")
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0)
|
||||
throw love::Exception("Could not initialize SDL events subsystem (%s)", SDL_GetError());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -42,9 +42,6 @@ class Event : public love::event::Event
|
||||
{
|
||||
public:
|
||||
|
||||
// Implements Module.
|
||||
const char *getName() const;
|
||||
|
||||
Event();
|
||||
virtual ~Event();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -3,7 +3,7 @@ R"luastring"--(
|
||||
-- There is a matching delimiter at the bottom of the file.
|
||||
|
||||
--[[
|
||||
Copyright (c) 2006-2023 LOVE Development Team
|
||||
Copyright (c) 2006-2024 LOVE Development Team
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -45,7 +45,8 @@ namespace filesystem
|
||||
|
||||
love::Type Filesystem::type("filesystem", &Module::type);
|
||||
|
||||
Filesystem::Filesystem()
|
||||
Filesystem::Filesystem(const char *name)
|
||||
: Module(M_FILESYSTEM, name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -108,12 +108,8 @@ public:
|
||||
|
||||
static love::Type type;
|
||||
|
||||
Filesystem();
|
||||
virtual ~Filesystem();
|
||||
|
||||
// Implements Module.
|
||||
virtual ModuleType getModuleType() const { return M_FILESYSTEM; }
|
||||
|
||||
virtual void init(const char *arg0) = 0;
|
||||
|
||||
virtual void setFused(bool fused) = 0;
|
||||
@@ -317,6 +313,10 @@ public:
|
||||
STRINGMAP_CLASS_DECLARE(MountPermissions);
|
||||
STRINGMAP_CLASS_DECLARE(LoadMode);
|
||||
|
||||
protected:
|
||||
|
||||
Filesystem(const char *name);
|
||||
|
||||
private:
|
||||
|
||||
bool getRealPathType(const std::string &path, FileType &ftype) const;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -107,7 +107,8 @@ static bool isAppCommonPath(Filesystem::CommonPath path)
|
||||
}
|
||||
|
||||
Filesystem::Filesystem()
|
||||
: appendIdentityToPath(false)
|
||||
: love::filesystem::Filesystem("love.filesystem.physfs")
|
||||
, appendIdentityToPath(false)
|
||||
, fused(false)
|
||||
, fusedSet(false)
|
||||
, fullPaths()
|
||||
@@ -128,11 +129,6 @@ Filesystem::~Filesystem()
|
||||
PHYSFS_deinit();
|
||||
}
|
||||
|
||||
const char *Filesystem::getName() const
|
||||
{
|
||||
return "love.filesystem.physfs";
|
||||
}
|
||||
|
||||
void Filesystem::init(const char *arg0)
|
||||
{
|
||||
#ifdef LOVE_ANDROID
|
||||
@@ -249,8 +245,14 @@ bool Filesystem::setSource(const char *source)
|
||||
if (hasFusedGame)
|
||||
{
|
||||
if (gameLoveIO)
|
||||
// Actually we should just be able to mount gameLoveIO, but that's experimental.
|
||||
{
|
||||
if (PHYSFS_mountIo(gameLoveIO, ".zip", nullptr, 0)) {
|
||||
gameSource = new_search_path;
|
||||
return true;
|
||||
}
|
||||
|
||||
gameLoveIO->destroy(gameLoveIO);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!love::android::initializeVirtualArchive())
|
||||
@@ -278,6 +280,8 @@ bool Filesystem::setSource(const char *source)
|
||||
gameSource = new_search_path;
|
||||
return true;
|
||||
}
|
||||
|
||||
io->destroy(io);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
Filesystem();
|
||||
virtual ~Filesystem();
|
||||
|
||||
// Implements Module.
|
||||
const char *getName() const override;
|
||||
|
||||
void init(const char *arg0) override;
|
||||
|
||||
void setFused(bool fused) override;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -18,7 +18,6 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
#include "PhysfsIo.h"
|
||||
@@ -32,14 +31,15 @@ namespace physfs
|
||||
|
||||
bool StripSuffixIo::determineStrippedLength()
|
||||
{
|
||||
if (!file) {
|
||||
if (!file)
|
||||
return false;
|
||||
}
|
||||
const int64_t fullSize = fullLength();
|
||||
int64_t chunkSize = std::min(fullSize, (int64_t)8192);
|
||||
|
||||
const int64 fullSize = file->getSize();
|
||||
|
||||
int64 chunkSize = std::min(fullSize, (int64) 8192);
|
||||
std::string buffer;
|
||||
buffer.reserve(chunkSize);
|
||||
int64_t i = fullSize - chunkSize;
|
||||
int64 i = fullSize - chunkSize;
|
||||
// I don't think we really need to go through the whole file. The main known use
|
||||
// case for this functionality is to skip windows codesign signatures, which are
|
||||
// from what I have seen ~12KB or so, but trying is better than just failing.
|
||||
@@ -64,7 +64,7 @@ bool StripSuffixIo::determineStrippedLength()
|
||||
}
|
||||
if (i == 0)
|
||||
break;
|
||||
i = std::max((int64_t)0, i - chunkSize);
|
||||
i = std::max((int64)0, i - chunkSize);
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
@@ -75,7 +75,7 @@ bool StripSuffixIo::determineStrippedLength()
|
||||
// The comment length (u16) is located 20 bytes from the start of the EOCD record
|
||||
if (seek(i + 20) == 0)
|
||||
return false;
|
||||
uint8_t buffer[2];
|
||||
uint8 buffer[2];
|
||||
const auto n = read(buffer, 2);
|
||||
if (n <= 0)
|
||||
return false;
|
||||
@@ -96,17 +96,17 @@ bool StripSuffixIo::determineStrippedLength()
|
||||
return true;
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::read(void* buf, uint64_t len)
|
||||
int64 StripSuffixIo::read(void *buf, uint64 len)
|
||||
{
|
||||
if (!file)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
const auto ret = std::fread(buf, 1, len, file);
|
||||
if (ret == 0)
|
||||
int64 r = file->read(buf, (int64) len);
|
||||
if (r == 0)
|
||||
{
|
||||
if (std::feof(file))
|
||||
if (file->isEOF())
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OK);
|
||||
return 0;
|
||||
@@ -117,85 +117,59 @@ int64_t StripSuffixIo::read(void* buf, uint64_t len)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (ret < len && std::ferror(file))
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OK);
|
||||
return ret;
|
||||
return r;
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::write(const void* /*buf*/, uint64_t /*len*/)
|
||||
int64 StripSuffixIo::write(const void */*buf*/, uint64 /*len*/)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_READ_ONLY);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::seek(uint64_t offset)
|
||||
int64 StripSuffixIo::seek(uint64 offset)
|
||||
{
|
||||
if (!file)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return 0;
|
||||
}
|
||||
const auto ret = std::fseek(file, offset, SEEK_SET);
|
||||
PHYSFS_setErrorCode(ret != 0 ? PHYSFS_ERR_OS_ERROR : PHYSFS_ERR_OK);
|
||||
return ret == 0 ? 1 : 0;
|
||||
bool success = file->seek(offset, Stream::SEEKORIGIN_BEGIN);
|
||||
PHYSFS_setErrorCode(success ? PHYSFS_ERR_OK : PHYSFS_ERR_OS_ERROR);
|
||||
return success ? 1 : 0;
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::tell()
|
||||
int64 StripSuffixIo::tell()
|
||||
{
|
||||
if (!file)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
return std::ftell(file);
|
||||
return file->tell();
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::length()
|
||||
int64 StripSuffixIo::length()
|
||||
{
|
||||
return strippedLength_;
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::flush()
|
||||
int64 StripSuffixIo::flush()
|
||||
{
|
||||
if (!file)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return 0;
|
||||
}
|
||||
return std::fflush(file) == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
int64_t StripSuffixIo::fullLength()
|
||||
{
|
||||
assert(file);
|
||||
const auto cur = std::ftell(file);
|
||||
if (cur == -1)
|
||||
try
|
||||
{
|
||||
return file->flush() ? 1 : 0;
|
||||
}
|
||||
catch (love::Exception &)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
if (std::fseek(file, 0, SEEK_END) != 0)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
const auto len = std::ftell(file);
|
||||
if (len == -1)
|
||||
{
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
if (std::fseek(file, cur, SEEK_SET) != 0)
|
||||
{
|
||||
// We do have the length now, but something is wrong, so we return an error anyways
|
||||
PHYSFS_setErrorCode(PHYSFS_ERR_OS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
} // physfs
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -21,11 +21,11 @@
|
||||
#ifndef LOVE_FILESYSTEM_PHYSFS_PHYSFSIO_H
|
||||
#define LOVE_FILESYSTEM_PHYSFS_PHYSFSIO_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "libraries/physfs/physfs.h"
|
||||
#include "common/int.h"
|
||||
#include "filesystem/NativeFile.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -61,54 +61,54 @@ protected:
|
||||
private:
|
||||
|
||||
// Returns: number of bytes read, 0 on EOF, -1 on failure
|
||||
static PHYSFS_sint64 staticRead(struct PHYSFS_Io* io, void* buf, PHYSFS_uint64 len)
|
||||
static PHYSFS_sint64 staticRead(struct PHYSFS_Io *io, void *buf, PHYSFS_uint64 len)
|
||||
{
|
||||
return derived(io)->read(buf, len);
|
||||
}
|
||||
|
||||
// Returns: number of bytes written, -1 on failure
|
||||
static PHYSFS_sint64 staticWrite(struct PHYSFS_Io* io, const void* buf, PHYSFS_uint64 len)
|
||||
static PHYSFS_sint64 staticWrite(struct PHYSFS_Io *io, const void *buf, PHYSFS_uint64 len)
|
||||
{
|
||||
return derived(io)->write(buf, len);
|
||||
}
|
||||
|
||||
// Returns: non-zero on success, zero on error
|
||||
static int staticSeek(struct PHYSFS_Io* io, PHYSFS_uint64 offset)
|
||||
static int staticSeek(struct PHYSFS_Io *io, PHYSFS_uint64 offset)
|
||||
{
|
||||
return derived(io)->seek(offset);
|
||||
}
|
||||
|
||||
// Returns: current offset from start, -1 on error
|
||||
static PHYSFS_sint64 staticTell(struct PHYSFS_Io* io)
|
||||
static PHYSFS_sint64 staticTell(struct PHYSFS_Io *io)
|
||||
{
|
||||
return derived(io)->tell();
|
||||
}
|
||||
|
||||
// Returns: total size in bytes, -1 on error
|
||||
static PHYSFS_sint64 staticLength(struct PHYSFS_Io* io)
|
||||
static PHYSFS_sint64 staticLength(struct PHYSFS_Io *io)
|
||||
{
|
||||
return derived(io)->length();
|
||||
}
|
||||
|
||||
static struct PHYSFS_Io* staticDuplicate(struct PHYSFS_Io* io)
|
||||
static struct PHYSFS_Io *staticDuplicate(struct PHYSFS_Io *io)
|
||||
{
|
||||
// Just use copy constructor
|
||||
return new Derived(*derived(io));
|
||||
}
|
||||
|
||||
// Returns: non-zero on success, zero on error
|
||||
static int staticFlush(struct PHYSFS_Io* io)
|
||||
static int staticFlush(struct PHYSFS_Io *io)
|
||||
{
|
||||
return derived(io)->flush();
|
||||
}
|
||||
|
||||
static void staticDestroy(struct PHYSFS_Io* io)
|
||||
static void staticDestroy(struct PHYSFS_Io *io)
|
||||
{
|
||||
// Just use destructor
|
||||
delete derived(io);
|
||||
}
|
||||
|
||||
static Derived* derived(PHYSFS_Io* io)
|
||||
static Derived* derived(PHYSFS_Io *io)
|
||||
{
|
||||
return static_cast<Derived*>(reinterpret_cast<PhysfsIo*>(io->opaque));
|
||||
}
|
||||
@@ -116,47 +116,52 @@ private:
|
||||
|
||||
struct StripSuffixIo : public PhysfsIo<StripSuffixIo>
|
||||
{
|
||||
static const uint32_t version = 0;
|
||||
static const uint32 version = 0;
|
||||
|
||||
std::string filename;
|
||||
FILE* file = nullptr;
|
||||
NativeFile *file = nullptr;
|
||||
|
||||
// The constructor is private in favor of this function to prevent stack allocation
|
||||
// because Physfs will take ownership of this object and call destroy on it later.
|
||||
static StripSuffixIo* create(std::string f) { return new StripSuffixIo(f); }
|
||||
static StripSuffixIo *create(const std::string &f) { return new StripSuffixIo(f); }
|
||||
|
||||
virtual ~StripSuffixIo()
|
||||
{
|
||||
if (file)
|
||||
{
|
||||
std::fclose(file);
|
||||
file->release();
|
||||
}
|
||||
}
|
||||
|
||||
StripSuffixIo(const StripSuffixIo& other)
|
||||
StripSuffixIo(const StripSuffixIo &other)
|
||||
: StripSuffixIo(other.filename)
|
||||
{
|
||||
}
|
||||
|
||||
bool determineStrippedLength();
|
||||
|
||||
int64_t read(void* buf, uint64_t len);
|
||||
int64_t write(const void* buf, uint64_t len);
|
||||
int64_t seek(uint64_t offset);
|
||||
int64_t tell();
|
||||
int64_t length();
|
||||
int64_t flush();
|
||||
int64 read(void *buf, uint64 len);
|
||||
int64 write(const void *buf, uint64 len);
|
||||
int64 seek(uint64 offset);
|
||||
int64 tell();
|
||||
int64 length();
|
||||
int64 flush();
|
||||
|
||||
private:
|
||||
|
||||
StripSuffixIo(std::string f)
|
||||
: filename(std::move(f))
|
||||
, file(std::fopen(filename.c_str(), "rb"))
|
||||
StripSuffixIo(const std::string &f)
|
||||
: filename(f)
|
||||
, file(nullptr)
|
||||
{
|
||||
try
|
||||
{
|
||||
file = new NativeFile(f, File::MODE_READ);
|
||||
}
|
||||
catch (love::Exception &)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
int64_t fullLength();
|
||||
|
||||
int64_t strippedLength_ = -1;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -343,6 +343,7 @@ GlyphData *BMFontRasterizer::getGlyphDataForIndex(int index) const
|
||||
uint8 *pixels = (uint8 *) g->getData();
|
||||
const uint8 *ipixels = (const uint8 *) imagedata->getData();
|
||||
|
||||
// Always lock the mutex since the user can't know when to do it.
|
||||
love::thread::Lock lock(imagedata->getMutex());
|
||||
|
||||
// Copy the subsection of the texture from the ImageData to the GlyphData.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -34,7 +34,8 @@ namespace font
|
||||
// Default TrueType font, gzip-compressed.
|
||||
#include "NotoSans-Regular.ttf.gzip.h"
|
||||
|
||||
Font::Font()
|
||||
Font::Font(const char *name)
|
||||
: Module(M_FONT, name)
|
||||
{
|
||||
auto compressedbytes = (const char *) NotoSans_Regular_ttf_gzip;
|
||||
size_t compressedsize = NotoSans_Regular_ttf_gzip_len;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -43,7 +43,6 @@ class Font : public Module
|
||||
|
||||
public:
|
||||
|
||||
Font();
|
||||
virtual ~Font() {}
|
||||
|
||||
virtual Rasterizer *newRasterizer(love::filesystem::FileData *data) = 0;
|
||||
@@ -58,9 +57,9 @@ public:
|
||||
virtual GlyphData *newGlyphData(Rasterizer *r, const std::string &glyph);
|
||||
virtual GlyphData *newGlyphData(Rasterizer *r, uint32 glyph);
|
||||
|
||||
// Implement Module.
|
||||
virtual ModuleType getModuleType() const { return M_FONT; }
|
||||
virtual const char *getName() const = 0;
|
||||
protected:
|
||||
|
||||
Font(const char *name);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
@@ -90,7 +90,7 @@ GlyphData *ImageRasterizer::getGlyphDataForIndex(int index) const
|
||||
if (gm.width == 0)
|
||||
return g;
|
||||
|
||||
// We don't want another thread modifying our ImageData mid-copy.
|
||||
// Always lock the mutex since the user can't know when to do it.
|
||||
love::thread::Lock lock(imageData->getMutex());
|
||||
|
||||
Color32 *gdpixels = (Color32 *) g->getData();
|
||||
@@ -118,9 +118,6 @@ void ImageRasterizer::load(const uint32 *glyphs, int glyphcount)
|
||||
int imgw = imageData->getWidth();
|
||||
int imgh = imageData->getHeight();
|
||||
|
||||
// We don't want another thread modifying our ImageData mid-parse.
|
||||
love::thread::Lock lock(imageData->getMutex());
|
||||
|
||||
// Set the only metric that matters
|
||||
metrics.height = imgh;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2023 LOVE Development Team
|
||||
* Copyright (c) 2006-2024 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user