diff --git a/CommonAPI/Common/include/DXAPI/Player.h b/CommonAPI/Common/include/DXAPI/Player.h index dfd644d..83edbb0 100644 --- a/CommonAPI/Common/include/DXAPI/Player.h +++ b/CommonAPI/Common/include/DXAPI/Player.h @@ -11,11 +11,6 @@ namespace DX public: 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) const bool &is_jetting; //! Player Object Jumping State (readonly, writing it doesn't do anything) diff --git a/CommonAPI/Common/include/DXAPI/SimObject.h b/CommonAPI/Common/include/DXAPI/SimObject.h index 8f6e11c..8dacf4b 100644 --- a/CommonAPI/Common/include/DXAPI/SimObject.h +++ b/CommonAPI/Common/include/DXAPI/SimObject.h @@ -1,5 +1,9 @@ #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 { class SimObject diff --git a/CommonAPI/Common/source/DXAPI/DXAPI.cpp b/CommonAPI/Common/source/DXAPI/DXAPI.cpp index 161c46d..6e9520f 100644 --- a/CommonAPI/Common/source/DXAPI/DXAPI.cpp +++ b/CommonAPI/Common/source/DXAPI/DXAPI.cpp @@ -180,7 +180,7 @@ namespace DX if (ret[iteration] == '.' || ret[iteration] == '\\' || ret[iteration] == '/' || ret[iteration] == '~') { 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++) ret[replace_iteration] = ret[replace_iteration + 1]; diff --git a/CommonAPI/Common/source/DXAPI/GameBase.cpp b/CommonAPI/Common/source/DXAPI/GameBase.cpp index a43a90c..078848a 100644 --- a/CommonAPI/Common/source/DXAPI/GameBase.cpp +++ b/CommonAPI/Common/source/DXAPI/GameBase.cpp @@ -6,6 +6,4 @@ namespace DX { } - - } // End NameSpace DX \ No newline at end of file diff --git a/CommonAPI/Common/source/DXAPI/NetConnection.cpp b/CommonAPI/Common/source/DXAPI/NetConnection.cpp index 50180eb..1c29b83 100644 --- a/CommonAPI/Common/source/DXAPI/NetConnection.cpp +++ b/CommonAPI/Common/source/DXAPI/NetConnection.cpp @@ -1,19 +1,23 @@ #include #include #include + namespace DX { - unsigned char NetConnection::getGhostFrom() { - return *(unsigned char *)((this->actualbaseptr)+0x8204); - } - unsigned char NetConnection::getGhostTo() { - return *(unsigned char *)((this->actualbaseptr)+0x8205); - } - S32 NetConnection::getGhostIndex(NetObject obj) { + unsigned char NetConnection::getGhostFrom() { + return *(unsigned char *)((this->actualbaseptr)+0x8204); + } + + unsigned char NetConnection::getGhostTo() { + return *(unsigned char *)((this->actualbaseptr)+0x8205); + } + + S32 NetConnection::getGhostIndex(NetObject obj) { unsigned int object_ptr = (unsigned int)obj.base_pointer_value; - unsigned int my_ptr = this->base_pointer_value-0xA0; - unsigned int ghostid=0; - unsigned int function=0x584FB0; + unsigned int my_ptr = this->base_pointer_value - 0xA0; + unsigned int ghostid = 0; + unsigned int function = 0x584FB0; + __asm { mov ecx,my_ptr @@ -24,38 +28,38 @@ namespace DX } 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 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))); - + 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 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))); + } } diff --git a/CommonAPI/Common/source/DXAPI/NetObject.cpp b/CommonAPI/Common/source/DXAPI/NetObject.cpp index 427fc16..986e08f 100644 --- a/CommonAPI/Common/source/DXAPI/NetObject.cpp +++ b/CommonAPI/Common/source/DXAPI/NetObject.cpp @@ -2,11 +2,12 @@ namespace DX { - NetObject::NetObject(unsigned int obj) : net_flags(*(unsigned int*)(obj + 64)), - SimObject(obj) + NetObject::NetObject(unsigned int obj) : SimObject(obj), + net_flags(MEMBER_FIELD(obj, unsigned int, 64)) { } + void NetObject::setMaskBits(unsigned int bits){ unsigned int localbits=bits; unsigned int bpv = this->base_pointer_value; @@ -18,6 +19,7 @@ namespace DX call eax }; } + void NetObject::clearMaskBits(unsigned int bits){ unsigned int localbits=bits; unsigned int bpv = this->base_pointer_value; diff --git a/CommonAPI/Common/source/DXAPI/Player.cpp b/CommonAPI/Common/source/DXAPI/Player.cpp index 8f575ca..9bea6df 100644 --- a/CommonAPI/Common/source/DXAPI/Player.cpp +++ b/CommonAPI/Common/source/DXAPI/Player.cpp @@ -3,13 +3,14 @@ namespace DX { Player::Player(unsigned int obj) : ShapeBase(obj), - name(0x00), id(*(unsigned int*)(obj + 32)), - is_jetting(*(bool*)(obj + 735)), - is_jumping(*(bool*)(obj + 734)), - headRotationZ(*(float*)(obj + 2376)), - mRotZ(*(float*)(obj + 2388)), - is_using_toggledpack(*(bool*)(obj + 1172)), - velocity(*(float*)(obj + 2392), *(float*)(obj + 2396), *(float*)(obj + 2400)) + is_jetting(MEMBER_FIELD(obj, bool, 735)), + is_jumping(MEMBER_FIELD(obj, bool, 734)), + + headRotationZ(MEMBER_FIELD(obj, float, 2376)), + mRotZ(MEMBER_FIELD(obj, float, 2388)), + + is_using_toggledpack(MEMBER_FIELD(obj, bool, 1172)), + velocity(MEMBER_POINT3F(obj, 2392, 4)) { } diff --git a/CommonAPI/Common/source/DXAPI/Projectile.cpp b/CommonAPI/Common/source/DXAPI/Projectile.cpp index e5cd57b..c1afb79 100644 --- a/CommonAPI/Common/source/DXAPI/Projectile.cpp +++ b/CommonAPI/Common/source/DXAPI/Projectile.cpp @@ -2,9 +2,9 @@ namespace DX { - Projectile::Projectile(unsigned int obj) : velocity(*(float*)(obj + 892), *(float*)(obj + 896), *(float*)(obj + 900)), - hidden(*(bool*)(obj + 796)), - GameBase(obj) + Projectile::Projectile(unsigned int obj) : GameBase(obj), + velocity(MEMBER_POINT3F(obj, 892, 4)), + hidden(MEMBER_FIELD(obj, bool, 796)) { } diff --git a/CommonAPI/Common/source/DXAPI/SceneObject.cpp b/CommonAPI/Common/source/DXAPI/SceneObject.cpp index 488b150..f26afaf 100644 --- a/CommonAPI/Common/source/DXAPI/SceneObject.cpp +++ b/CommonAPI/Common/source/DXAPI/SceneObject.cpp @@ -1,26 +1,34 @@ #include #include + namespace DX { //This is required to make these update properly over the network //memPatch("602D19","9090"); - SceneObject::SceneObject(unsigned int obj) : position(*(float*)(obj + 168), *(float*)(obj + 184), *(float*)(obj + 200)), - 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)), - NetObject(obj) + SceneObject::SceneObject(unsigned int obj) : NetObject(obj), + position(MEMBER_POINT3F(obj, 168, 16)), + 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) { const char * results = Con::getMatrixPosition(objtoworld,NULL,0); sscanf (results,"%f %f %f", &pos[0], &pos[1], &pos[2]); } } + void SceneObject::getRotation(float * rot){ if (this->base_pointer_value) { const char * results = Con::getMatrixRotation(objtoworld,NULL,0); sscanf (results,"%f %f %f %f", &rot[0], &rot[1], &rot[2], &rot[3]); } } + void SceneObject::setRotation(float rot []) { char arg0[128] = ""; sprintf (arg0,"%f %f %f %f", rot[0], rot[1], rot[2], rot[3]); diff --git a/CommonAPI/Common/source/DXAPI/ShapeBase.cpp b/CommonAPI/Common/source/DXAPI/ShapeBase.cpp index 05bfc33..0a2cc84 100644 --- a/CommonAPI/Common/source/DXAPI/ShapeBase.cpp +++ b/CommonAPI/Common/source/DXAPI/ShapeBase.cpp @@ -3,9 +3,12 @@ namespace DX { 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){ unsigned int addr=this->base_pointer_value; unsigned int bits=value; diff --git a/CommonAPI/Common/source/DXAPI/SimObject.cpp b/CommonAPI/Common/source/DXAPI/SimObject.cpp index fef31bc..33338a2 100644 --- a/CommonAPI/Common/source/DXAPI/SimObject.cpp +++ b/CommonAPI/Common/source/DXAPI/SimObject.cpp @@ -6,8 +6,12 @@ namespace DX { - SimObject::SimObject(unsigned int obj) : identifier(*(unsigned int*)(obj + 32)), fieldDictionary(*(unsigned int*)(obj + 0x2C)), dataBlock(*(unsigned int*)(obj + 0x248)), - base_pointer_value(obj), mName(*(char*)(obj + 4)) + SimObject::SimObject(unsigned int obj) : + 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)) { } diff --git a/CommonAPI/Common/source/DXAPI/TCPObject.cpp b/CommonAPI/Common/source/DXAPI/TCPObject.cpp index cdf6e06..97c6ec9 100644 --- a/CommonAPI/Common/source/DXAPI/TCPObject.cpp +++ b/CommonAPI/Common/source/DXAPI/TCPObject.cpp @@ -2,8 +2,8 @@ namespace DX { - TCPObject::TCPObject(unsigned int obj): state(*(unsigned int*)(obj + 56)), - SimObject(obj) + TCPObject::TCPObject(unsigned int obj) : SimObject(obj), + state(MEMBER_FIELD(obj, unsigned int, 56)) { } } \ No newline at end of file