1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

vcmi: modernize lua

This commit is contained in:
Konstantin
2023-02-05 19:24:34 +03:00
parent fb38050f9b
commit 976c5e7bd4
11 changed files with 43 additions and 35 deletions

View File

@@ -159,7 +159,7 @@ static void publishMap(lua_State * L, const T & map)
for(auto & p : map)
{
const std::string & name = p.first;
int32_t id = static_cast<int32_t>(p.second);
auto id = static_cast<int32_t>(p.second);
lua_pushstring(L, name.c_str());
lua_pushinteger(L, id);

View File

@@ -28,12 +28,12 @@ Registry * Registry::get()
void Registry::add(const std::string & name, std::shared_ptr<Registar> item)
{
data[name] = item;
data[name] = std::move(item);
}
void Registry::addCore(const std::string & name, std::shared_ptr<Registar> item)
{
coreData[name] = item;
coreData[name] = std::move(item);
}
const Registar * Registry::find(const std::string & name) const

View File

@@ -72,7 +72,7 @@ int ServerCbProxy::commitPackage(lua_State * L)
return S.retVoid();
CPackForClient * pack = static_cast<CPackForClient *>(lua_touserdata(L, 1));
auto * pack = static_cast<CPackForClient *>(lua_touserdata(L, 1));
object->apply(pack);

View File

@@ -53,7 +53,7 @@ int InfoWindowProxy::addReplacement(lua_State * L)
if(lua_isstring(L, 2))
{
size_t len = 0;
auto raw = lua_tolstring(L, 2, &len);
const auto *raw = lua_tolstring(L, 2, &len);
std::string text(raw, len);
object->text.addReplacement(text);
@@ -87,7 +87,7 @@ int InfoWindowProxy::addText(lua_State * L)
if(lua_isstring(L, 2))
{
size_t len = 0;
auto raw = lua_tolstring(L, 2, &len);
const auto *raw = lua_tolstring(L, 2, &len);
std::string text(raw, len);
object->text << text;