Prepare field access
This commit is contained in:
parent
d2e2bb711f
commit
206b81ee01
@ -70,12 +70,39 @@ namespace game
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) VariableValue get_entity_field_value_dedicated(unsigned int classnum, int entnum, int _offset)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push _offset
|
||||
push entnum
|
||||
mov ecx, classnum
|
||||
mov eax, 4F1400h
|
||||
call eax
|
||||
add esp, 8h
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
VariableValue GetEntityFieldValue(const unsigned int classnum, const int entnum, const int offset)
|
||||
{
|
||||
if (is_dedi())
|
||||
{
|
||||
return get_entity_field_value_dedicated(classnum, entnum, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
return reinterpret_cast<VariableValue(*)(unsigned int, int, int)> //
|
||||
(SELECT_VALUE(0x530E30, 0x56AF20, 0x0))(classnum, entnum, offset);
|
||||
}
|
||||
}
|
||||
|
||||
void* MT_Alloc(const int numBytes, const int type)
|
||||
{
|
||||
return scrMemTreeGlob + 12 * size_t(MT_AllocIndex(numBytes, type));
|
||||
}
|
||||
|
||||
const float* Scr_AllocVector(const float *v)
|
||||
const float* Scr_AllocVector(const float* v)
|
||||
{
|
||||
const auto mem = static_cast<DWORD*>(MT_Alloc(16, 2));
|
||||
*mem = 0;
|
||||
|
@ -65,6 +65,8 @@ namespace game
|
||||
|
||||
void AddRefToValue(VariableValue* value);
|
||||
|
||||
VariableValue GetEntityFieldValue(unsigned int classnum, int entnum, int offset);
|
||||
|
||||
void* MT_Alloc(int numBytes, int type);
|
||||
|
||||
const float* Scr_AllocVector(const float* v);
|
||||
|
@ -411,6 +411,22 @@ void scripting::stop_execution()
|
||||
}
|
||||
}
|
||||
|
||||
int scripting::get_field_id(const int classnum, const std::string& field) const
|
||||
{
|
||||
switch (classnum)
|
||||
{
|
||||
case 0: // Entity
|
||||
case 1: // HudElem
|
||||
case 2: // Pathnode
|
||||
case 3: // VehPathNode
|
||||
case 4: // VehTrackSegment
|
||||
case 6: // PIPElem
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::notify(const std::string& event, const unsigned int entity_id,
|
||||
std::vector<chaiscript::Boxed_Value> arguments)
|
||||
{
|
||||
|
@ -82,6 +82,8 @@ private:
|
||||
static void start_execution();
|
||||
static void stop_execution();
|
||||
|
||||
int get_field_id(int classnum, const std::string& field) const;
|
||||
|
||||
void notify(const std::string& event, unsigned int entity_id, std::vector<chaiscript::Boxed_Value> arguments);
|
||||
|
||||
void push_param(const chaiscript::Boxed_Value& value) const;
|
||||
|
Loading…
Reference in New Issue
Block a user