[String]: Add IString func (#877)
This commit is contained in:
parent
e539701d3d
commit
ae6d50dad8
@ -35,14 +35,14 @@ namespace Components::GSC
|
|||||||
|
|
||||||
void ScriptExtension::GScr_AddFieldsForEntityStub()
|
void ScriptExtension::GScr_AddFieldsForEntityStub()
|
||||||
{
|
{
|
||||||
for (const auto& [offset, field] : CustomEntityFields)
|
for (const auto& field : CustomEntityFields | std::views::values)
|
||||||
{
|
{
|
||||||
Game::Scr_AddClassField(Game::ClassNum::CLASS_NUM_ENTITY, field.name, field.ofs);
|
Game::Scr_AddClassField(Game::ClassNum::CLASS_NUM_ENTITY, field.name, field.ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Hook::Call<void()>(0x4A7CF0)(); // GScr_AddFieldsForClient
|
Utils::Hook::Call<void()>(0x4A7CF0)(); // GScr_AddFieldsForClient
|
||||||
|
|
||||||
for (const auto& [offset, field] : CustomClientFields)
|
for (const auto& field : CustomClientFields | std::views::values)
|
||||||
{
|
{
|
||||||
Game::Scr_AddClassField(Game::ClassNum::CLASS_NUM_ENTITY, field.name, field.ofs);
|
Game::Scr_AddClassField(Game::ClassNum::CLASS_NUM_ENTITY, field.name, field.ofs);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
namespace Components::GSC
|
namespace Components::GSC
|
||||||
{
|
{
|
||||||
|
using namespace Utils::String;
|
||||||
|
|
||||||
void String::AddScriptFunctions()
|
void String::AddScriptFunctions()
|
||||||
{
|
{
|
||||||
Script::AddFunction("ToUpper", [] // gsc: ToUpper(<string>)
|
Script::AddFunction("ToUpper", [] // gsc: ToUpper(<string>)
|
||||||
@ -122,7 +124,7 @@ namespace Components::GSC
|
|||||||
Game::Scr_AddFloat(static_cast<float>(Game::Scr_GetInt(0)));
|
Game::Scr_AddFloat(static_cast<float>(Game::Scr_GetInt(0)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Game::Scr_ParamError(0, Utils::String::VA("cannot cast %s to float", Game::Scr_GetTypeName(0)));
|
Game::Scr_ParamError(0, VA("cannot cast %s to float", Game::Scr_GetTypeName(0)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -141,6 +143,22 @@ namespace Components::GSC
|
|||||||
|
|
||||||
Game::Scr_AddInt(result);
|
Game::Scr_AddInt(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Script::AddFunction("IString", [] // gsc: IString(<string>)
|
||||||
|
{
|
||||||
|
if (Game::Scr_GetType(0) != Game::VAR_STRING)
|
||||||
|
{
|
||||||
|
Game::Scr_ParamError(0, VA("cannot cast %s to istring", Game::Scr_GetTypeName(0)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto value = Game::Scr_GetConstString(0);
|
||||||
|
|
||||||
|
Game::SL_AddRefToString(value);
|
||||||
|
Game::Scr_AddIString(Game::Scr_GetString(0));
|
||||||
|
|
||||||
|
Game::SL_RemoveRefToString(value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String::String()
|
String::String()
|
||||||
|
Loading…
Reference in New Issue
Block a user