mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Enable dynamic_add_media to take the file data instead of a path
This commit is contained in:
parent
c90ebad46b
commit
d4b107e2e8
8 changed files with 167 additions and 67 deletions
|
@ -483,6 +483,17 @@ bool check_field_or_nil(lua_State *L, int index, int type, const char *fieldname
|
|||
|
||||
bool getstringfield(lua_State *L, int table,
|
||||
const char *fieldname, std::string &result)
|
||||
{
|
||||
std::string_view sv;
|
||||
if (getstringfield(L, table, fieldname, sv)) {
|
||||
result = sv;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getstringfield(lua_State *L, int table,
|
||||
const char *fieldname, std::string_view &result)
|
||||
{
|
||||
lua_getfield(L, table, fieldname);
|
||||
bool got = false;
|
||||
|
@ -491,7 +502,7 @@ bool getstringfield(lua_State *L, int table,
|
|||
size_t len = 0;
|
||||
const char *ptr = lua_tolstring(L, -1, &len);
|
||||
if (ptr) {
|
||||
result.assign(ptr, len);
|
||||
result = std::string_view(ptr, len);
|
||||
got = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <string_view>
|
||||
|
||||
#include "irrlichttypes_bloated.h"
|
||||
#include "common/c_types.h"
|
||||
|
@ -67,11 +67,11 @@ v3s16 getv3s16field_default(lua_State *L, int table,
|
|||
|
||||
bool getstringfield(lua_State *L, int table,
|
||||
const char *fieldname, std::string &result);
|
||||
bool getstringfield(lua_State *L, int table,
|
||||
const char *fieldname, std::string_view &result);
|
||||
size_t getstringlistfield(lua_State *L, int table,
|
||||
const char *fieldname,
|
||||
std::vector<std::string> *result);
|
||||
void read_groups(lua_State *L, int index,
|
||||
std::unordered_map<std::string, int> &result);
|
||||
bool getboolfield(lua_State *L, int table,
|
||||
const char *fieldname, bool &result);
|
||||
bool getfloatfield(lua_State *L, int table,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue