mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-04-21 05:15:44 +00:00
Add some array methods
This commit is contained in:
parent
517cad33f4
commit
833271b7a1
@ -110,14 +110,41 @@ namespace scripting
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int array::size() const
|
unsigned int array::size() const
|
||||||
{
|
{
|
||||||
return game::Scr_GetSelf(this->id_);
|
return game::Scr_GetSelf(this->id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void array::push(script_value value) const
|
unsigned int array::push(script_value value) const
|
||||||
{
|
{
|
||||||
this->set(this->size(), value);
|
this->set(this->size(), value);
|
||||||
|
return this->size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void array::erase(const unsigned int index) const
|
||||||
|
{
|
||||||
|
const auto variable_id = game::FindVariable(this->id_, (index - 0x800000) & 0xFFFFFF);
|
||||||
|
if (variable_id)
|
||||||
|
{
|
||||||
|
game::RemoveVariableValue(this->id_, variable_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void array::erase(const std::string& key) const
|
||||||
|
{
|
||||||
|
const auto string_value = game::SL_GetString(key.data(), 0);
|
||||||
|
const auto variable_id = game::FindVariable(this->id_, string_value);
|
||||||
|
if (variable_id)
|
||||||
|
{
|
||||||
|
game::RemoveVariableValue(this->id_, variable_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
script_value array::pop() const
|
||||||
|
{
|
||||||
|
const auto value = this->get(this->size() - 1);
|
||||||
|
this->erase(this->size() - 1);
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
script_value array::get(const std::string& key) const
|
script_value array::get(const std::string& key) const
|
||||||
@ -155,35 +182,6 @@ namespace scripting
|
|||||||
return variable;
|
return variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int array::get_entity_id() const
|
|
||||||
{
|
|
||||||
return this->id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int array::get_value_id(const std::string& key) const
|
|
||||||
{
|
|
||||||
const auto string_value = game::SL_GetString(key.data(), 0);
|
|
||||||
const auto variable_id = game::FindVariable(this->id_, string_value);
|
|
||||||
|
|
||||||
if (!variable_id)
|
|
||||||
{
|
|
||||||
return game::GetNewVariable(this->id_, string_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return variable_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int array::get_value_id(const unsigned int index) const
|
|
||||||
{
|
|
||||||
const auto variable_id = game::FindVariable(this->id_, (index - 0x800000) & 0xFFFFFF);
|
|
||||||
if (!variable_id)
|
|
||||||
{
|
|
||||||
return game::GetNewArrayVariable(this->id_, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return variable_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void array::set(const std::string& key, const script_value& _value) const
|
void array::set(const std::string& key, const script_value& _value) const
|
||||||
{
|
{
|
||||||
const auto value = _value.get_raw();
|
const auto value = _value.get_raw();
|
||||||
@ -224,6 +222,35 @@ namespace scripting
|
|||||||
variable->u.u = value.u;
|
variable->u.u = value.u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int array::get_entity_id() const
|
||||||
|
{
|
||||||
|
return this->id_;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int array::get_value_id(const std::string& key) const
|
||||||
|
{
|
||||||
|
const auto string_value = game::SL_GetString(key.data(), 0);
|
||||||
|
const auto variable_id = game::FindVariable(this->id_, string_value);
|
||||||
|
|
||||||
|
if (!variable_id)
|
||||||
|
{
|
||||||
|
return game::GetNewVariable(this->id_, string_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return variable_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int array::get_value_id(const unsigned int index) const
|
||||||
|
{
|
||||||
|
const auto variable_id = game::FindVariable(this->id_, (index - 0x800000) & 0xFFFFFF);
|
||||||
|
if (!variable_id)
|
||||||
|
{
|
||||||
|
return game::GetNewArrayVariable(this->id_, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return variable_id;
|
||||||
|
}
|
||||||
|
|
||||||
entity array::get_raw() const
|
entity array::get_raw() const
|
||||||
{
|
{
|
||||||
return entity(this->id_);
|
return entity(this->id_);
|
||||||
|
@ -30,21 +30,24 @@ namespace scripting
|
|||||||
array(std::unordered_map<std::string, script_value>);
|
array(std::unordered_map<std::string, script_value>);
|
||||||
|
|
||||||
std::vector<array_key> get_keys() const;
|
std::vector<array_key> get_keys() const;
|
||||||
|
unsigned int size() const;
|
||||||
|
|
||||||
int size() const;
|
unsigned int push(script_value) const;
|
||||||
void push(script_value) const;
|
void erase(const unsigned int index) const;
|
||||||
|
void erase(const std::string& key) const;
|
||||||
|
script_value pop() const;
|
||||||
|
|
||||||
script_value get(const std::string&) const;
|
script_value get(const std::string&) const;
|
||||||
script_value get(const unsigned int) const;
|
script_value get(const unsigned int) const;
|
||||||
|
|
||||||
|
void set(const std::string&, const script_value&) const;
|
||||||
|
void set(const unsigned int, const script_value&) const;
|
||||||
|
|
||||||
unsigned int get_entity_id() const;
|
unsigned int get_entity_id() const;
|
||||||
|
|
||||||
unsigned int get_value_id(const std::string&) const;
|
unsigned int get_value_id(const std::string&) const;
|
||||||
unsigned int get_value_id(const unsigned int) const;
|
unsigned int get_value_id(const unsigned int) const;
|
||||||
|
|
||||||
void set(const std::string&, const script_value&) const;
|
|
||||||
void set(const unsigned int, const script_value&) const;
|
|
||||||
|
|
||||||
entity get_raw() const;
|
entity get_raw() const;
|
||||||
|
|
||||||
array_value array::operator[](const int index) const
|
array_value array::operator[](const int index) const
|
||||||
|
@ -33,6 +33,7 @@ namespace game
|
|||||||
WEAK symbol<unsigned int(unsigned int parentId, unsigned int name)> GetNewVariable{0x566390};
|
WEAK symbol<unsigned int(unsigned int parentId, unsigned int name)> GetNewVariable{0x566390};
|
||||||
WEAK symbol<unsigned int(unsigned int parentId, unsigned int unsignedValue)> GetNewArrayVariable{0x5668C0};
|
WEAK symbol<unsigned int(unsigned int parentId, unsigned int unsignedValue)> GetNewArrayVariable{0x5668C0};
|
||||||
WEAK symbol<void(unsigned int parentId, unsigned int id, VariableValue* value)> SetNewVariableValue{0x5658D0};
|
WEAK symbol<void(unsigned int parentId, unsigned int id, VariableValue* value)> SetNewVariableValue{0x5658D0};
|
||||||
|
WEAK symbol<void(unsigned int parentId, unsigned int index)> RemoveVariableValue{0x566500};
|
||||||
|
|
||||||
WEAK symbol<const float* (const float* v)> Scr_AllocVector{0x565680};
|
WEAK symbol<const float* (const float* v)> Scr_AllocVector{0x565680};
|
||||||
WEAK symbol<void()> Scr_ClearOutParams{0x569010};
|
WEAK symbol<void()> Scr_ClearOutParams{0x569010};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user