* Minor cleanups.

* Add preprocessor macros for resolving member field offsets in a standard, easy to read way.
This commit is contained in:
Robert MacGregor 2019-07-14 17:00:46 -07:00
parent fc39b03ffb
commit 0410000234
12 changed files with 88 additions and 69 deletions

View file

@ -11,11 +11,6 @@ namespace DX
public: public:
Player(unsigned int obj); Player(unsigned int obj);
//! Object Name
const char *name;
//! Object ID
const unsigned int &id;
//! Player Object Jetting State (readonly, writing it doesn't do anything) //! Player Object Jetting State (readonly, writing it doesn't do anything)
const bool &is_jetting; const bool &is_jetting;
//! Player Object Jumping State (readonly, writing it doesn't do anything) //! Player Object Jumping State (readonly, writing it doesn't do anything)

View file

@ -1,5 +1,9 @@
#pragma once #pragma once
#define MEMBER_POINTER(obj, type, offset) (type*)(obj + offset)
#define MEMBER_FIELD(obj, type, offset) *(type*)(obj + offset)
#define MEMBER_POINT3F(obj, offset, spacing) MEMBER_FIELD(obj, float, offset), MEMBER_FIELD(obj, float, offset + spacing), MEMBER_FIELD(obj, float, offset + (spacing * 2))
namespace DX namespace DX
{ {
class SimObject class SimObject

View file

@ -180,7 +180,7 @@ namespace DX
if (ret[iteration] == '.' || ret[iteration] == '\\' || ret[iteration] == '/' || ret[iteration] == '~') if (ret[iteration] == '.' || ret[iteration] == '\\' || ret[iteration] == '/' || ret[iteration] == '~')
{ {
was_dirty = true; was_dirty = true;
ret[iteration] == 0x20; // In the event the occurence is at the very end ret[iteration] = 0x20; // In the event the occurence is at the very end
for (unsigned int replace_iteration = iteration; replace_iteration < strlen(ret); replace_iteration++) for (unsigned int replace_iteration = iteration; replace_iteration < strlen(ret); replace_iteration++)
ret[replace_iteration] = ret[replace_iteration + 1]; ret[replace_iteration] = ret[replace_iteration + 1];

View file

@ -6,6 +6,4 @@ namespace DX
{ {
} }
} // End NameSpace DX } // End NameSpace DX

View file

@ -1,19 +1,23 @@
#include <DXAPI/NetConnection.h> #include <DXAPI/NetConnection.h>
#include <DXAPI/NetObject.h> #include <DXAPI/NetObject.h>
#include <LinkerAPI.h> #include <LinkerAPI.h>
namespace DX namespace DX
{ {
unsigned char NetConnection::getGhostFrom() { unsigned char NetConnection::getGhostFrom() {
return *(unsigned char *)((this->actualbaseptr)+0x8204); return *(unsigned char *)((this->actualbaseptr)+0x8204);
} }
unsigned char NetConnection::getGhostTo() {
return *(unsigned char *)((this->actualbaseptr)+0x8205); unsigned char NetConnection::getGhostTo() {
} return *(unsigned char *)((this->actualbaseptr)+0x8205);
S32 NetConnection::getGhostIndex(NetObject obj) { }
S32 NetConnection::getGhostIndex(NetObject obj) {
unsigned int object_ptr = (unsigned int)obj.base_pointer_value; unsigned int object_ptr = (unsigned int)obj.base_pointer_value;
unsigned int my_ptr = this->base_pointer_value-0xA0; unsigned int my_ptr = this->base_pointer_value - 0xA0;
unsigned int ghostid=0; unsigned int ghostid = 0;
unsigned int function=0x584FB0; unsigned int function = 0x584FB0;
__asm __asm
{ {
mov ecx,my_ptr mov ecx,my_ptr
@ -24,38 +28,38 @@ namespace DX
} }
return ghostid; return ghostid;
} }
unsigned int NetConnection::resolveGhostParent(S32 id) {
if (this->getGhostFrom()) {
if (this->mGhostRefs[id].obj)
{
return (unsigned int)(this->mGhostRefs[id].obj);
}
}
return NULL;
}
unsigned int NetConnection::resolveGhost(S32 id) {
if (id == NULL) {
return NULL;
}
if (this->getGhostTo()) {
if ((unsigned int)this->mLocalGhosts[id] == NULL) {
return NULL;
}
return (unsigned int)this->mLocalGhosts[id];
}
return NULL;
}
NetConnection::NetConnection(unsigned int obj) : SimObject(obj)
{ unsigned int NetConnection::resolveGhostParent(S32 id) {
unsigned int ptr=((this->base_pointer_value)-(0xA0)); if (this->getGhostFrom()) {
this->actualbaseptr=ptr; if (this->mGhostRefs[id].obj)
unsigned int * ginfoptrptr=0; {
ginfoptrptr=(unsigned int *) (this->actualbaseptr+(0x8210)); return (unsigned int)(this->mGhostRefs[id].obj);
this->mGhostRefs = (GhostInfo *) *ginfoptrptr; }
this->mLocalGhosts = (NetObject **) *(unsigned int *) ((this->actualbaseptr+(0x820C))); }
return NULL;
} }
unsigned int NetConnection::resolveGhost(S32 id) {
if (id == NULL) {
return NULL;
}
if (this->getGhostTo()) {
if ((unsigned int)this->mLocalGhosts[id] == NULL) {
return NULL;
}
return (unsigned int)this->mLocalGhosts[id];
}
return NULL;
}
NetConnection::NetConnection(unsigned int obj) : SimObject(obj)
{
unsigned int ptr=((this->base_pointer_value)-(0xA0));
this->actualbaseptr=ptr;
unsigned int * ginfoptrptr=0;
ginfoptrptr=(unsigned int *) (this->actualbaseptr+(0x8210));
this->mGhostRefs = (GhostInfo *) *ginfoptrptr;
this->mLocalGhosts = (NetObject **) *(unsigned int *)((this->actualbaseptr+(0x820C)));
}
} }

View file

@ -2,11 +2,12 @@
namespace DX namespace DX
{ {
NetObject::NetObject(unsigned int obj) : net_flags(*(unsigned int*)(obj + 64)), NetObject::NetObject(unsigned int obj) : SimObject(obj),
SimObject(obj) net_flags(MEMBER_FIELD(obj, unsigned int, 64))
{ {
} }
void NetObject::setMaskBits(unsigned int bits){ void NetObject::setMaskBits(unsigned int bits){
unsigned int localbits=bits; unsigned int localbits=bits;
unsigned int bpv = this->base_pointer_value; unsigned int bpv = this->base_pointer_value;
@ -18,6 +19,7 @@ namespace DX
call eax call eax
}; };
} }
void NetObject::clearMaskBits(unsigned int bits){ void NetObject::clearMaskBits(unsigned int bits){
unsigned int localbits=bits; unsigned int localbits=bits;
unsigned int bpv = this->base_pointer_value; unsigned int bpv = this->base_pointer_value;

View file

@ -3,13 +3,14 @@
namespace DX namespace DX
{ {
Player::Player(unsigned int obj) : ShapeBase(obj), Player::Player(unsigned int obj) : ShapeBase(obj),
name(0x00), id(*(unsigned int*)(obj + 32)), is_jetting(MEMBER_FIELD(obj, bool, 735)),
is_jetting(*(bool*)(obj + 735)), is_jumping(MEMBER_FIELD(obj, bool, 734)),
is_jumping(*(bool*)(obj + 734)),
headRotationZ(*(float*)(obj + 2376)), headRotationZ(MEMBER_FIELD(obj, float, 2376)),
mRotZ(*(float*)(obj + 2388)), mRotZ(MEMBER_FIELD(obj, float, 2388)),
is_using_toggledpack(*(bool*)(obj + 1172)),
velocity(*(float*)(obj + 2392), *(float*)(obj + 2396), *(float*)(obj + 2400)) is_using_toggledpack(MEMBER_FIELD(obj, bool, 1172)),
velocity(MEMBER_POINT3F(obj, 2392, 4))
{ {
} }

View file

@ -2,9 +2,9 @@
namespace DX namespace DX
{ {
Projectile::Projectile(unsigned int obj) : velocity(*(float*)(obj + 892), *(float*)(obj + 896), *(float*)(obj + 900)), Projectile::Projectile(unsigned int obj) : GameBase(obj),
hidden(*(bool*)(obj + 796)), velocity(MEMBER_POINT3F(obj, 892, 4)),
GameBase(obj) hidden(MEMBER_FIELD(obj, bool, 796))
{ {
} }

View file

@ -1,26 +1,34 @@
#include <DXAPI/SceneObject.h> #include <DXAPI/SceneObject.h>
#include <LinkerAPI.h> #include <LinkerAPI.h>
namespace DX namespace DX
{ {
//This is required to make these update properly over the network //This is required to make these update properly over the network
//memPatch("602D19","9090"); //memPatch("602D19","9090");
SceneObject::SceneObject(unsigned int obj) : position(*(float*)(obj + 168), *(float*)(obj + 184), *(float*)(obj + 200)), SceneObject::SceneObject(unsigned int obj) : NetObject(obj),
scale(*(float*)(obj + 284), *(float*)(obj + 288), *(float*)(obj + 292)), worldtoobj((void*)(obj+0xdc)),objtoworld((void*)(obj+0x9c)),renderobjtoworld((void*)(obj+360)),renderworldtoobj((void*)(obj+424)), position(MEMBER_POINT3F(obj, 168, 16)),
NetObject(obj) scale(MEMBER_POINT3F(obj, 284, 4)),
worldtoobj(MEMBER_POINTER(obj, void, 0xdc)),
objtoworld(MEMBER_POINTER(obj, void, 0x9c)),
renderobjtoworld(MEMBER_POINTER(obj, void, 360)),
renderworldtoobj(MEMBER_POINTER(obj, void, 424))
{ {
} }
void SceneObject::getPosition(float * pos){
void SceneObject::getPosition(float *pos){
if (this->base_pointer_value) { if (this->base_pointer_value) {
const char * results = Con::getMatrixPosition(objtoworld,NULL,0); const char * results = Con::getMatrixPosition(objtoworld,NULL,0);
sscanf (results,"%f %f %f", &pos[0], &pos[1], &pos[2]); sscanf (results,"%f %f %f", &pos[0], &pos[1], &pos[2]);
} }
} }
void SceneObject::getRotation(float * rot){ void SceneObject::getRotation(float * rot){
if (this->base_pointer_value) { if (this->base_pointer_value) {
const char * results = Con::getMatrixRotation(objtoworld,NULL,0); const char * results = Con::getMatrixRotation(objtoworld,NULL,0);
sscanf (results,"%f %f %f %f", &rot[0], &rot[1], &rot[2], &rot[3]); sscanf (results,"%f %f %f %f", &rot[0], &rot[1], &rot[2], &rot[3]);
} }
} }
void SceneObject::setRotation(float rot []) { void SceneObject::setRotation(float rot []) {
char arg0[128] = ""; char arg0[128] = "";
sprintf (arg0,"%f %f %f %f", rot[0], rot[1], rot[2], rot[3]); sprintf (arg0,"%f %f %f %f", rot[0], rot[1], rot[2], rot[3]);

View file

@ -3,9 +3,12 @@
namespace DX namespace DX
{ {
ShapeBase::ShapeBase(unsigned int obj) : GameBase(obj), ShapeBase::ShapeBase(unsigned int obj) : GameBase(obj),
heat_level(*(float*)(obj + 1972)), cloak_level(*(float*)(obj+0x810)), cloaked(*(bool*)(obj+0x80D)) heat_level(MEMBER_FIELD(obj, float, 1972)),
cloak_level(MEMBER_FIELD(obj, float, 0x810)),
cloaked(MEMBER_FIELD(obj, bool, 0x80D))
{ {
} }
void ShapeBase::setMaskBits(int value){ void ShapeBase::setMaskBits(int value){
unsigned int addr=this->base_pointer_value; unsigned int addr=this->base_pointer_value;
unsigned int bits=value; unsigned int bits=value;

View file

@ -6,8 +6,12 @@
namespace DX namespace DX
{ {
SimObject::SimObject(unsigned int obj) : identifier(*(unsigned int*)(obj + 32)), fieldDictionary(*(unsigned int*)(obj + 0x2C)), dataBlock(*(unsigned int*)(obj + 0x248)), SimObject::SimObject(unsigned int obj) :
base_pointer_value(obj), mName(*(char*)(obj + 4)) identifier(MEMBER_FIELD(obj, unsigned int, 32)),
fieldDictionary(MEMBER_FIELD(obj, unsigned int, 0x2C)),
dataBlock(MEMBER_FIELD(obj, unsigned int, 0x248)),
base_pointer_value(MEMBER_FIELD(obj, unsigned int, 0)),
mName(MEMBER_FIELD(obj, char, 4))
{ {
} }

View file

@ -2,8 +2,8 @@
namespace DX namespace DX
{ {
TCPObject::TCPObject(unsigned int obj): state(*(unsigned int*)(obj + 56)), TCPObject::TCPObject(unsigned int obj) : SimObject(obj),
SimObject(obj) state(MEMBER_FIELD(obj, unsigned int, 56))
{ {
} }
} }