SimSet and SimGroup support

Added SimSet and SimGroup recursive move test code.
This commit is contained in:
Calvin Balke 2015-01-20 17:31:51 -08:00
parent 8a9330cd87
commit 2b6995b7e3
11 changed files with 106 additions and 14 deletions

View file

@ -25,6 +25,7 @@
<ClCompile Include="source\DXAPI\SceneObject.cpp" />
<ClCompile Include="source\DXAPI\ScriptObject.cpp" />
<ClCompile Include="source\DXAPI\ShapeBase.cpp" />
<ClCompile Include="source\DXAPI\SimGroup.cpp" />
<ClCompile Include="source\DXAPI\SimObject.cpp" />
<ClCompile Include="source\DXAPI\StaticShape.cpp" />
<ClCompile Include="source\DXAPI\TCPObject.cpp" />
@ -48,6 +49,7 @@
<ClInclude Include="include\DXAPI\SceneObject.h" />
<ClInclude Include="include\DXAPI\ScriptObject.h" />
<ClInclude Include="include\DXAPI\ShapeBase.h" />
<ClInclude Include="include\DXAPI\SimGroup.h" />
<ClInclude Include="include\DXAPI\SimObject.h" />
<ClInclude Include="include\DXAPI\StaticShape.h" />
<ClInclude Include="include\DXAPI\TCPObject.h" />

View file

@ -87,6 +87,9 @@
<ClCompile Include="source\DXAPI\MatMath.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
<ClCompile Include="source\DXAPI\SimGroup.cpp">
<Filter>Source Files\DXAPI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\LinkerAPI.h">
@ -146,5 +149,8 @@
<ClInclude Include="include\DXAPI\MatMath.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
<ClInclude Include="include\DXAPI\SimGroup.h">
<Filter>Header Files\DXAPI</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -24,6 +24,7 @@
#include <DXAPI/SceneObject.h>
#include <DXAPI/ShapeBase.h>
#include <DXAPI/SimObject.h>
#include <DXAPI/SimGroup.h>
#include <DXAPI/StaticShape.h>
#include <DXAPI/GrenadeProjectile.h>
#include <DXAPI/FlyingVehicle.h>

View file

@ -0,0 +1,14 @@
#pragma once
#include <DXAPI/SimObject.h>
namespace DX
{
class SimGroup : public SimObject
{
public:
SimGroup(unsigned int obj);
unsigned int &count;
unsigned int *simobjptr;
unsigned int SimGroup::getObject(unsigned int idx);
unsigned int SimGroup::getCount(void);
};
};

View file

@ -8,8 +8,9 @@ namespace DX
SimObject(unsigned int obj);
void deleteObject(void);
const char *SimObject::getClassName();
const char *CallMethod(const char *name, unsigned int argc, ...);
const unsigned int &type;
const unsigned int &identifier;
const unsigned int base_pointer_value;
};

View file

@ -13,7 +13,7 @@
#pragma once
#include <LinkerAPI.h>
bool conSetMPS(Linker::SimObject *obj, S32 argc, const char *argv[]) ;
void serverProcessReplacement(unsigned int timeDelta) ;
const char* conGetPosition(Linker::SimObject * obj, S32 argc, const char *argv[]);
const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]);

View file

@ -0,0 +1,27 @@
#include <cstdarg>
#include <DXAPI/SimObject.h>
#include <DXAPI/SimGroup.h>
#include <LinkerAPI.h>
namespace DX
{
SimGroup::SimGroup(unsigned int obj) : count(*(unsigned int*)(obj+0x30)), simobjptr((unsigned int*)*(unsigned int*)(obj+0x38)),
SimObject(obj)
{
}
unsigned int SimGroup::getObject(unsigned int idx) {
if (idx<this->count) {
return simobjptr[idx];
} else {
return 0;
}
}
unsigned int SimGroup::getCount(void) {
return this->count;
}
};

View file

@ -6,11 +6,27 @@
namespace DX
{
SimObject::SimObject(unsigned int obj) : identifier(*(unsigned int*)(obj + 32)),
SimObject::SimObject(unsigned int obj) : identifier(*(unsigned int*)(obj + 32)), type(*(unsigned int*)(obj+0x28)),
base_pointer_value(obj)
{
}
const char *SimObject::getClassName(){
unsigned int bpv=this->base_pointer_value;
unsigned int cnptr=0;
unsigned int bpv2=(*(unsigned int*)bpv);
__asm {
mov ecx,bpv2
mov eax,[ecx]
call eax
mov eax,[eax+0x1C]
mov cnptr,eax
};
if (cnptr) {
return (char *) cnptr;
} else {
return "";
}
}
void SimObject::deleteObject(void)
{
void *pointer = (void*)this->base_pointer_value;

View file

@ -6,22 +6,42 @@
#include <DXAPI/DXAPI.h>
#include <DXAPI/MatMath.h>
static float counter=0;
static float mps=0.0;
void moveRecursive(unsigned int simgroup,float xoff){
unsigned int mainsim=(unsigned int)simgroup;
if (mainsim) {
DX::SimObject sim1=DX::SimObject(mainsim);
if (strcmp((sim1.getClassName()),"SimGroup")==0) {
DX::SimGroup sim2 = DX::SimGroup(mainsim);
for (unsigned int x=0; x<sim2.getCount(); x++) {
DX::SimObject obj2=DX::SimObject(sim2.getObject(x));
if ((strcmp((obj2.getClassName()),"SimGroup")!=0)&&(strcmp((obj2.getClassName()),"SimSet")!=0)) {
if (obj2.type&0x8){
DX::SceneObject sobj = DX::SceneObject(sim2.getObject(x));
DX::MatrixF mat1=DX::MatrixF(sobj.objtoworld);
DX::Point3F test;
mat1.getColumn(3,&test);
test.x+=xoff;
mat1.setColumn(3,&test);
}
} else {
moveRecursive(sim2.getObject(x),xoff);
}
}
}
}
}
void serverProcessReplacement(unsigned int timeDelta) {
unsigned int servertickaddr=0x602350;
unsigned int serverthisptr=0x9E5EC0;
float basex=348.08;
float basey=-178.761;
float basez=113.037;
if (Sim::findObjectc("Team1TurretBaseLarge1")) {
basex+=counter/180.0;
DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("Team1TurretBaseLarge1"));
DX::MatrixF mat1=DX::MatrixF(sobj.objtoworld);
mat1.setColumn(3,&DX::Point3F(basex,basey,basez));
sobj.setTransform(mat1.m);
if (counter>=(30*180)){
counter=0;
}
counter+=1.0;
if (Sim::findObjectc("Team1")) {
basex+=counter;
DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("Team1"));
moveRecursive((unsigned int)Sim::findObjectc("Team1"),(mps*((float)((timeDelta)*0.001))));
}
__asm
{
@ -62,6 +82,10 @@ const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]
test2[8]=0;
return test2;
}
bool conSetMPS(Linker::SimObject *obj, S32 argc, const char *argv[]) {
mps=atof(argv[1]);
return false;
}
const char *conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[])
{
// Hmm...

View file

@ -43,6 +43,7 @@ extern "C"
Con::addMethodS("GrenadeProjectile", "getvelocity", &conGrenadeProjectileGetVelocity,"Gets the velocity of the GrenadeProjectile", 2, 2);
Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2);
Con::addMethodS("SceneObject", "getPositionTest", &conGetPosition,"Gets the Rotation by alternate means as a test", 2, 2);
Con::addMethodB(NULL,"setMPS",&conSetMPS,"sets meters per second for turret", 2, 2);
// TCPObject
#ifdef ENABLE_TCPOBJECT
Con::addMethodS("TCPObject", "connect", &conTCPObjectConnect, "Connects to a remote server", 3, 3);