mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2026-08-01 12:50:33 +00:00
cleanup
This commit is contained in:
@@ -15,30 +15,30 @@ namespace scripting
|
||||
}
|
||||
|
||||
const auto value = game::scr_VarGlob->childVariableValue[this->id_ + 0xC800 * (this->parent_id_ & 1)];
|
||||
game::VariableValue variable;
|
||||
game::VariableValue variable{};
|
||||
variable.u = value.u.u;
|
||||
variable.type = (game::scriptType_e)value.type;
|
||||
|
||||
this->value_ = variable;
|
||||
}
|
||||
|
||||
void array_value::operator=(const script_value& _value)
|
||||
void array_value::operator=(const script_value& value)
|
||||
{
|
||||
if (!this->id_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto value = _value.get_raw();
|
||||
const auto& value_raw = value.get_raw();
|
||||
|
||||
const auto variable = &game::scr_VarGlob->childVariableValue[this->id_ + 0xC800 * (this->parent_id_ & 1)];
|
||||
game::AddRefToValue(value.type, value.u);
|
||||
game::AddRefToValue(value_raw.type, value_raw.u);
|
||||
game::RemoveRefToValue(variable->type, variable->u.u);
|
||||
|
||||
variable->type = value.type;
|
||||
variable->u.u = value.u;
|
||||
variable->type = value_raw.type;
|
||||
variable->u.u = value_raw.u;
|
||||
|
||||
this->value_ = value;
|
||||
this->value_ = value_raw;
|
||||
}
|
||||
|
||||
array::array(const unsigned int id)
|
||||
@@ -170,7 +170,7 @@ namespace scripting
|
||||
return game::Scr_GetSelf(this->id_);
|
||||
}
|
||||
|
||||
unsigned int array::push(script_value value) const
|
||||
unsigned int array::push(const script_value& value) const
|
||||
{
|
||||
this->set(this->size(), value);
|
||||
return this->size();
|
||||
@@ -225,7 +225,7 @@ namespace scripting
|
||||
}
|
||||
|
||||
const auto value = game::scr_VarGlob->childVariableValue[variable_id + 0xC800 * (this->id_ & 1)];
|
||||
game::VariableValue variable;
|
||||
game::VariableValue variable{};
|
||||
variable.u = value.u.u;
|
||||
variable.type = (game::scriptType_e)value.type;
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace scripting
|
||||
}
|
||||
|
||||
const auto value = game::scr_VarGlob->childVariableValue[variable_id + 0xC800 * (this->id_ & 1)];
|
||||
game::VariableValue variable;
|
||||
game::VariableValue variable{};
|
||||
variable.u = value.u.u;
|
||||
variable.type = (game::scriptType_e)value.type;
|
||||
|
||||
@@ -261,9 +261,9 @@ namespace scripting
|
||||
}
|
||||
}
|
||||
|
||||
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_raw = value.get_raw();
|
||||
const auto variable_id = this->get_value_id(key);
|
||||
|
||||
if (!variable_id)
|
||||
@@ -273,16 +273,16 @@ namespace scripting
|
||||
|
||||
const auto variable = &game::scr_VarGlob->childVariableValue[variable_id + 0xC800 * (this->id_ & 1)];
|
||||
|
||||
game::AddRefToValue(value.type, value.u);
|
||||
game::AddRefToValue(value_raw.type, value_raw.u);
|
||||
game::RemoveRefToValue(variable->type, variable->u.u);
|
||||
|
||||
variable->type = value.type;
|
||||
variable->u.u = value.u;
|
||||
variable->type = value_raw.type;
|
||||
variable->u.u = value_raw.u;
|
||||
}
|
||||
|
||||
void array::set(const unsigned int index, const script_value& value_) const
|
||||
void array::set(const unsigned int index, const script_value& value) const
|
||||
{
|
||||
const auto value = value_.get_raw();
|
||||
const auto& value_raw = value.get_raw();
|
||||
const auto variable_id = this->get_value_id(index);
|
||||
|
||||
if (!variable_id)
|
||||
@@ -292,11 +292,11 @@ namespace scripting
|
||||
|
||||
const auto variable = &game::scr_VarGlob->childVariableValue[variable_id + 0xC800 * (this->id_ & 1)];
|
||||
|
||||
game::AddRefToValue(value.type, value.u);
|
||||
game::AddRefToValue(value_raw.type, value_raw.u);
|
||||
game::RemoveRefToValue(variable->type, variable->u.u);
|
||||
|
||||
variable->type = value.type;
|
||||
variable->u.u = value.u;
|
||||
variable->type = value_raw.type;
|
||||
variable->u.u = value_raw.u;
|
||||
}
|
||||
|
||||
unsigned int array::get_entity_id() const
|
||||
@@ -320,6 +320,7 @@ namespace scripting
|
||||
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);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace scripting
|
||||
std::vector<script_value> get_keys() const;
|
||||
unsigned int size() const;
|
||||
|
||||
unsigned int push(script_value) const;
|
||||
unsigned int push(const script_value&) const;
|
||||
void erase(const unsigned int) const;
|
||||
void erase(const std::string&) const;
|
||||
script_value pop() const;
|
||||
@@ -69,12 +69,12 @@ namespace scripting
|
||||
{
|
||||
if (key.is<I>())
|
||||
{
|
||||
return { this->id_, this->get_value_id(key.as<I>()) };
|
||||
return {this->id_, this->get_value_id(key.as<I>())};
|
||||
}
|
||||
|
||||
if (key.is<S>())
|
||||
{
|
||||
return { this->id_, this->get_value_id(key.as<S>()) };
|
||||
return {this->id_, this->get_value_id(key.as<S>())};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,9 @@ namespace scripting
|
||||
|
||||
script_value function::get_raw() const
|
||||
{
|
||||
game::VariableValue value;
|
||||
game::VariableValue value{};
|
||||
value.type = game::SCRIPT_FUNCTION;
|
||||
value.u.codePosValue = this->pos_;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -23,7 +22,7 @@ namespace scripting
|
||||
return this->pos_;
|
||||
}
|
||||
|
||||
script_value function::call(const entity& self, std::vector<script_value> arguments) const
|
||||
script_value function::call(const entity& self, const std::vector<script_value>& arguments) const
|
||||
{
|
||||
return exec_ent_thread(self, this->pos_, arguments);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace scripting
|
||||
script_value get_raw() const;
|
||||
const char* get_pos() const;
|
||||
|
||||
script_value call(const entity& self, std::vector<script_value> arguments) const;
|
||||
script_value call(const entity& self, const std::vector<script_value>& arguments) const;
|
||||
|
||||
script_value operator()(const entity& self, std::vector<script_value> arguments) const
|
||||
script_value operator()(const entity& self, const std::vector<script_value>& arguments) const
|
||||
{
|
||||
return this->call(self, arguments);
|
||||
}
|
||||
|
||||
script_value operator()(std::vector<script_value> arguments) const
|
||||
script_value operator()(const std::vector<script_value>& arguments) const
|
||||
{
|
||||
return this->call(*game::levelEntityId, arguments);
|
||||
}
|
||||
@@ -28,7 +28,9 @@ namespace scripting
|
||||
{
|
||||
return this->call(*game::levelEntityId, {});
|
||||
}
|
||||
|
||||
private:
|
||||
const char* pos_;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <stdinc.hpp>
|
||||
#include "functions.hpp"
|
||||
|
||||
#include <utils/string.hpp>
|
||||
|
||||
namespace scripting
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
#include "game/game.hpp"
|
||||
|
||||
namespace scripting
|
||||
{
|
||||
using script_function = void(*)(game::scr_entref_t);
|
||||
}
|
||||
@@ -321,7 +321,7 @@ namespace scripting
|
||||
return this->value_.get();
|
||||
}
|
||||
|
||||
value_wrap::value_wrap(const scripting::script_value& value, int argument_index)
|
||||
value_wrap::value_wrap(const scripting::script_value& value, const std::uint32_t argument_index)
|
||||
: value_(value)
|
||||
, argument_index_(argument_index)
|
||||
{
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace scripting
|
||||
class value_wrap
|
||||
{
|
||||
public:
|
||||
value_wrap(const scripting::script_value& value, int argument_index);
|
||||
value_wrap(const scripting::script_value& value, const std::uint32_t);
|
||||
|
||||
template <typename T>
|
||||
T as() const
|
||||
@@ -179,7 +179,7 @@ namespace scripting
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename I = int>
|
||||
template <typename T>
|
||||
T* as_ptr()
|
||||
{
|
||||
try
|
||||
@@ -203,7 +203,7 @@ namespace scripting
|
||||
return this->value_.get_raw();
|
||||
}
|
||||
|
||||
int argument_index_{};
|
||||
std::uint32_t argument_index_{};
|
||||
scripting::script_value value_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ namespace scripting
|
||||
void set_z(float value);
|
||||
|
||||
private:
|
||||
game::vec3_t value_{ 0 };
|
||||
game::vec3_t value_{};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user