mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-03-09 23:40:28 +00:00
* Minor cleanups.
* Add preprocessor macros for resolving member field offsets in a standard, easy to read way.
This commit is contained in:
parent
fc39b03ffb
commit
0410000234
12 changed files with 88 additions and 69 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -6,6 +6,4 @@ namespace DX
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // End NameSpace DX
|
||||
|
|
@ -1,19 +1,23 @@
|
|||
#include <DXAPI/NetConnection.h>
|
||||
#include <DXAPI/NetObject.h>
|
||||
#include <LinkerAPI.h>
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,34 @@
|
|||
#include <DXAPI/SceneObject.h>
|
||||
#include <LinkerAPI.h>
|
||||
|
||||
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]);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue