mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-01-19 18:14:44 +00:00
Implemented reIterBegin, reIterEnd, reIterNext, reMatch and reSearch; Fixed a ton of compiler warnings regarding unsafe methods such as sprintf; Fixed a ton of compiler warnings regarding returning stack-based variables
This commit is contained in:
parent
0a1e4da05d
commit
e6ecfb8a91
|
|
@ -60,11 +60,18 @@ bool conBinaryObjectSetBufferPointer(Linker::SimObject *obj, S32 argc, const cha
|
|||
const char *conBinaryObjectGetBufferPointer(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
bool conBinaryObjectClose(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
bool conBinaryObjectSave(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
const char *conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
const char* conResolveGhost(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
S32 conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
S32 conResolveGhost(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
// Network Commands ---------------------------------
|
||||
const char *conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
S32 conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
bool conForceUpdate(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
// General Commands ---------------------------------
|
||||
const char* conSprintf(Linker::SimObject *obj, S32 argc, const char* argv[]);
|
||||
bool conTSExtensionUpdate(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
bool conTSExtensionUpdate(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
// Regex Commands ----------------------------------
|
||||
const char* reIterNext(Linker::SimObject* obj, S32 argc, const char* argv[]);
|
||||
bool reIterEnd(Linker::SimObject* obj, S32 argc, const char* argv[]);
|
||||
bool reIterBegin(Linker::SimObject* obj, S32 argc, const char* argv[]);
|
||||
const char* reReplace(Linker::SimObject* obj, S32 argc, const char* argv[]);
|
||||
bool reSearch(Linker::SimObject* obj, S32 argc, const char* argv[]);
|
||||
bool reMatch(Linker::SimObject* obj, S32 argc, const char* argv[]);
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
#include <LinkerAPI.h>
|
||||
#include <DXAPI/DXAPI.h>
|
||||
|
||||
const char *conDumpHex(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
// Hmm...
|
||||
|
|
@ -35,37 +37,46 @@ const char *conDumpFloat(Linker::SimObject *obj, S32 argc, const char *argv[])
|
|||
}
|
||||
const char *conFloatToHex(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
char result[256];
|
||||
char formatResult[256];
|
||||
float input=atof(argv[1]);
|
||||
float * inputptr=&input;
|
||||
void * inputptr2 = (void *)inputptr;
|
||||
unsigned int * inputptr3=(unsigned int*)inputptr2;
|
||||
sprintf (result,"%08X",*inputptr3);
|
||||
sprintf (formatResult,"%08X",*inputptr3);
|
||||
|
||||
char* result = new char[256];
|
||||
memcpy(result, formatResult, 256);
|
||||
|
||||
return result;
|
||||
}
|
||||
const char *conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
// Hmm...
|
||||
char result[256];
|
||||
sprintf(result, "%x", obj);
|
||||
char formatResult[256];
|
||||
sprintf(formatResult, "%x", obj);
|
||||
|
||||
char* result = new char[256];
|
||||
memcpy(result, formatResult, 256);
|
||||
|
||||
return result;
|
||||
}
|
||||
const char *conGetAddressDec(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
// Hmm...
|
||||
char result[256];
|
||||
sprintf(result, "%d", obj);
|
||||
char formatResult[256];
|
||||
sprintf(formatResult, "%d", obj);
|
||||
|
||||
char* result = new char[256];
|
||||
memcpy(result, formatResult, 256);
|
||||
|
||||
return result;
|
||||
}
|
||||
bool conShapeBaseSetCloakValue(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
DX::ShapeBase operand = DX::ShapeBase((unsigned int)obj);
|
||||
operand.cloaked=dAtob(argv[2]);
|
||||
if (operand.cloaked==true) {
|
||||
operand.cloak_level=atof(argv[3]);
|
||||
} else {
|
||||
operand.cloak_level=atof(argv[3]);
|
||||
}
|
||||
|
||||
operand.cloak_level = std::stof(argv[3]);
|
||||
operand.setMaskBits(0x40);
|
||||
|
||||
return true;
|
||||
|
|
@ -88,7 +99,8 @@ bool conPlayerGetJettingState(Linker::SimObject *obj, S32 argc, const char* argv
|
|||
bool conGameConnectionSetHeatLevel(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
DX::GameConnection operand = DX::GameConnection((unsigned int)obj);
|
||||
operand.getControlObject().heat_level = atof(argv[1]);
|
||||
operand.getControlObject().heat_level = std::stof(argv[1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -113,92 +125,88 @@ bool conProjectileMakeNerf(Linker::SimObject *obj, S32 argc, const char* argv[])
|
|||
|
||||
return true;
|
||||
}
|
||||
bool conForceUpdate(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
if (obj == NULL || (unsigned int)Sim::findObjectc(argv[2]) == NULL) {
|
||||
|
||||
bool conForceUpdate(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
if (obj == NULL || (unsigned int)Sim::findObjectc(argv[2]) == NULL)
|
||||
return 0;
|
||||
}
|
||||
|
||||
DX::NetConnection conn = DX::NetConnection((unsigned int)obj);
|
||||
DX::NetObject netobj = DX::NetObject((unsigned int)Sim::findObjectc(argv[2]));
|
||||
GhostInfo * mGhostRefs=conn.mGhostRefs;
|
||||
if (netobj.base_pointer_value!=0) {
|
||||
S32 index = conn.getGhostIndex(netobj);
|
||||
if (index > 0) {
|
||||
if (netobj.base_pointer_value!=0)
|
||||
{
|
||||
S32 index = conn.getGhostIndex(netobj);
|
||||
|
||||
if (index > 0)
|
||||
mGhostRefs[index].updateMask=mGhostRefs[index].updateMask | GameBaseMasks::InitialUpdateMask;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
const char* conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
char outint[20]="4231";
|
||||
char returnvar[255]="";
|
||||
Con::printf("%s\n",argv[2]);
|
||||
|
||||
S32 conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
unsigned int objptr2=(unsigned int)Sim::findObjectc(argv[2]);
|
||||
if ((unsigned int)obj == NULL || objptr2==NULL) {
|
||||
strcpy(returnvar,"-1");
|
||||
return returnvar;
|
||||
}
|
||||
|
||||
if ((unsigned int)obj == NULL || objptr2==NULL)
|
||||
return -1;
|
||||
|
||||
DX::NetConnection conn = DX::NetConnection((unsigned int)obj);
|
||||
|
||||
char aicommand[255]="";
|
||||
sprintf (aicommand,"return (%d.isAIControlled());",conn.identifier);
|
||||
if (dAtob(Con::evaluate(aicommand,false,NULL,false))==true) {
|
||||
strcpy(returnvar,"-1");
|
||||
return returnvar;
|
||||
}
|
||||
sprintf (aicommand,"return (%d.isAIControlled());", conn.identifier);
|
||||
if (dAtob(Con::evaluate(aicommand, false, NULL, false)) == true)
|
||||
return -1;
|
||||
|
||||
char command[255]="";
|
||||
sprintf (command,"return (%d.getAddress());",conn.identifier);
|
||||
if (strcmp(Con::evaluate(command,false,NULL,false),"local")==0) {
|
||||
strncpy(returnvar,argv[2],255);
|
||||
returnvar[255]=0x0;
|
||||
return returnvar;
|
||||
}
|
||||
|
||||
if (strcmp(Con::evaluate(command, false, NULL, false), "local") == 0)
|
||||
return atoi(argv[2]);
|
||||
|
||||
DX::NetObject netobj = DX::NetObject(objptr2);
|
||||
if (netobj.base_pointer_value!=0) {
|
||||
S32 index = conn.getGhostIndex(netobj);
|
||||
Con::printf("%d",index);
|
||||
itoa(index,outint,10);
|
||||
return outint;
|
||||
}
|
||||
if (netobj.base_pointer_value!=0)
|
||||
return conn.getGhostIndex(netobj);
|
||||
|
||||
return -1;
|
||||
}
|
||||
const char* conResolveGhost(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
char outint[20]="";
|
||||
if (obj==NULL) {
|
||||
return "";
|
||||
}
|
||||
|
||||
S32 conResolveGhost(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
if (obj==NULL)
|
||||
return -1;
|
||||
|
||||
DX::NetConnection conn = DX::NetConnection((unsigned int)obj);
|
||||
|
||||
S32 id = atoi(argv[2]);
|
||||
if (id==-1) {
|
||||
return "";
|
||||
}
|
||||
if (conn.resolveGhost(id)!=NULL) {
|
||||
itoa(DX::NetObject(conn.resolveGhost(id)).identifier,outint,10);
|
||||
return outint;
|
||||
}
|
||||
return "";
|
||||
if (id == -1)
|
||||
return -1;
|
||||
|
||||
if (conn.resolveGhost(id) != NULL)
|
||||
return conn.resolveGhost(id);
|
||||
|
||||
return -1;
|
||||
}
|
||||
const char* conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
char outint[20]="";
|
||||
if (((unsigned int)obj)==NULL) {
|
||||
return "";
|
||||
}
|
||||
|
||||
S32 conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
if (((unsigned int)obj) == NULL)
|
||||
return -1;
|
||||
|
||||
DX::NetConnection conn = DX::NetConnection((unsigned int)obj);
|
||||
S32 ghostindex = atoi(argv[2]);
|
||||
if (conn.base_pointer_value!=0) {
|
||||
if (conn.base_pointer_value!=0)
|
||||
if (conn.resolveGhostParent(ghostindex))
|
||||
{
|
||||
S32 objid = DX::NetObject(conn.resolveGhostParent(ghostindex)).identifier;
|
||||
if (objid != 0) {
|
||||
itoa(objid,outint,10);
|
||||
return outint;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
{
|
||||
S32 objid = DX::NetObject(conn.resolveGhostParent(ghostindex)).identifier;
|
||||
if (objid != 0)
|
||||
return objid;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool conclientCmdSetGhostTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
unsigned int result_ptr = 0;
|
||||
unsigned int my_ptr = 0;
|
||||
|
|
@ -235,43 +243,18 @@ bool conclientCmdSetGhostTicks(Linker::SimObject *obj, S32 argc, const char* arg
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool conclientCmdSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
unsigned int result_ptr = 0;
|
||||
unsigned int my_ptr = 0;
|
||||
DX::NetObject objptr=(unsigned int)Sim::findObjectc(argv[1]);
|
||||
if (objptr.base_pointer_value)
|
||||
{
|
||||
my_ptr=objptr.base_pointer_value;
|
||||
if (atoi(argv[2])==1) {
|
||||
__asm
|
||||
{
|
||||
mov eax, my_ptr;
|
||||
add eax, 0x264;
|
||||
mov ebx,eax
|
||||
mov al, 1
|
||||
mov [ebx],al
|
||||
|
||||
}
|
||||
} else {
|
||||
__asm
|
||||
{
|
||||
mov eax, my_ptr;
|
||||
add eax, 0x264;
|
||||
mov ebx,eax
|
||||
mov al, 0
|
||||
mov [ebx],al
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
bool conclientCmdSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
unsigned int result_ptr = 0;
|
||||
unsigned int my_ptr = 0;
|
||||
DX::NetObject objptr = (unsigned int)Sim::findObjectc(argv[1]);
|
||||
|
||||
bool conSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
||||
if (objptr.base_pointer_value)
|
||||
{
|
||||
my_ptr=objptr.base_pointer_value;
|
||||
|
||||
unsigned int result_ptr = 0;
|
||||
unsigned int my_ptr = (unsigned int) obj;
|
||||
if (atoi(argv[2])==1) {
|
||||
if (atoi(argv[2]) == 1)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, my_ptr;
|
||||
|
|
@ -279,9 +262,11 @@ bool conSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
|||
mov ebx,eax
|
||||
mov al, 1
|
||||
mov [ebx],al
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, my_ptr;
|
||||
|
|
@ -289,26 +274,68 @@ bool conSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) {
|
|||
mov ebx,eax
|
||||
mov al, 0
|
||||
mov [ebx],al
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool conSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
unsigned int result_ptr = 0;
|
||||
unsigned int my_ptr = (unsigned int) obj;
|
||||
|
||||
if (atoi(argv[2])==1)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, my_ptr;
|
||||
add eax, 0x264;
|
||||
mov ebx,eax
|
||||
mov al, 1
|
||||
mov [ebx],al
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, my_ptr;
|
||||
add eax, 0x264;
|
||||
mov ebx,eax
|
||||
mov al, 0
|
||||
mov [ebx],al
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* conGrenadeProjectileGetPosition(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
char result[256];
|
||||
char formatResult[256];
|
||||
|
||||
DX::GrenadeProjectile grenade = DX::GrenadeProjectile((unsigned int)obj);
|
||||
sprintf_s<256>(result, "%f %f %f", grenade.position.x, grenade.position.y, grenade.position.z);
|
||||
sprintf_s<256>(formatResult, "%f %f %f", grenade.position.x, grenade.position.y, grenade.position.z);
|
||||
|
||||
char* result = new char[256];
|
||||
memcpy(result, formatResult, 256);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* conGrenadeProjectileGetVelocity(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
char result[256];
|
||||
|
||||
char formatResult[256];
|
||||
DX::GrenadeProjectile grenade((unsigned int)obj);
|
||||
sprintf_s<256>(result, "%f %f %f", grenade.velocity.x, grenade.velocity.y, grenade.velocity.z);
|
||||
sprintf_s<256>(formatResult, "%f %f %f", grenade.velocity.x, grenade.velocity.y, grenade.velocity.z);
|
||||
|
||||
char* result = new char[256];
|
||||
memcpy(result, formatResult, 256);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -321,13 +348,118 @@ const char* conGrenadeProjectileGetVelocity(Linker::SimObject *obj, S32 argc, co
|
|||
const char* conSprintf(Linker::SimObject *obj, S32 argc, const char* argv[])
|
||||
{
|
||||
std::vector<const char*> input;
|
||||
for (unsigned int i = 2; i < argc; i++)
|
||||
for (int i = 2; i < argc; i++)
|
||||
input.push_back(argv[i]);
|
||||
|
||||
char result[256];
|
||||
char formatResult[256];
|
||||
|
||||
va_list variable_args = reinterpret_cast<va_list>(input.data());
|
||||
vsprintf(result, argv[1], variable_args);
|
||||
vsprintf(formatResult, argv[1], variable_args);
|
||||
|
||||
char* result = new char[256];
|
||||
memcpy(result, formatResult, 256);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// RE Commands -----------------------------------
|
||||
|
||||
#include <regex>
|
||||
|
||||
bool reMatch(Linker::SimObject* obj, S32 argc, const char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
std::smatch match;
|
||||
|
||||
std::regex sequence(argv[1], std::regex::extended);
|
||||
std::regex_match(std::string(argv[2]), match, sequence);
|
||||
|
||||
return !match.empty() && match.size() != 0;
|
||||
}
|
||||
catch (std::regex_error)
|
||||
{
|
||||
Con::errorf(0, "RE: Invalid regex sequence: %s", argv[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool reSearch(Linker::SimObject* obj, S32 argc, const char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
std::smatch match;
|
||||
|
||||
std::regex sequence(argv[1], std::regex::extended);
|
||||
std::regex_search(std::string(argv[2]), match, sequence);
|
||||
|
||||
return !match.empty() && match.size() != 0;
|
||||
}
|
||||
catch (std::regex_error)
|
||||
{
|
||||
Con::errorf(0, "RE: Invalid regex sequence: %s", argv[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* reReplace(Linker::SimObject* obj, S32 argc, const char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string result = std::regex_replace(std::string(argv[2]),
|
||||
std::regex(argv[1], std::regex::extended),
|
||||
std::string(argv[3]));
|
||||
return result.c_str();
|
||||
}
|
||||
catch (std::regex_error)
|
||||
{
|
||||
Con::errorf(0, "RE: Invalid regex sequence: %s", argv[1]);
|
||||
return "-1";
|
||||
}
|
||||
|
||||
return "-1";
|
||||
}
|
||||
|
||||
static std::string currentString = "";
|
||||
static std::regex currentRegex = std::regex("", std::regex::extended);
|
||||
static auto matchBegin = std::sregex_iterator(currentString.begin(), currentString.end(), currentRegex);
|
||||
static auto matchEnd = std::sregex_iterator();
|
||||
static std::sregex_iterator currentMatchIter = matchEnd;
|
||||
|
||||
bool reIterBegin(Linker::SimObject* obj, S32 argc, const char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
currentRegex = std::regex(argv[1], std::regex::extended);
|
||||
currentString = std::string(argv[2]);
|
||||
matchBegin = std::sregex_iterator(currentString.begin(), currentString.end(), currentRegex);
|
||||
matchEnd = std::sregex_iterator();
|
||||
currentMatchIter = matchBegin;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (std::regex_error)
|
||||
{
|
||||
Con::errorf(0, "RE: Invalid regex sequence: %s", argv[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool reIterEnd(Linker::SimObject* obj, S32 argc, const char* argv[])
|
||||
{
|
||||
return currentMatchIter == matchEnd;
|
||||
}
|
||||
|
||||
const char* reIterNext(Linker::SimObject* obj, S32 argc, const char* argv[])
|
||||
{
|
||||
std::string currentResult = (*currentMatchIter).str();
|
||||
++currentMatchIter;
|
||||
|
||||
return currentResult.c_str();
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
#include <LinkerAPI.h>
|
||||
#include <DXAPI/Move.h>
|
||||
#include <DXConCmds.h>
|
||||
|
||||
static DX::Move curmove;
|
||||
static unsigned int tmpobjptr=0;
|
||||
static char test[100];
|
||||
|
|
@ -31,11 +32,12 @@ static DX::Move *mechchangedmove;
|
|||
static char test2[100];
|
||||
static void * moveptrmech;
|
||||
unsigned int updatemoveretptr=0x5d2d7c;
|
||||
float maxrot=2.9;
|
||||
float minrot=-2.9;
|
||||
float maxrot=2.9f;
|
||||
float minrot=-2.9f;
|
||||
static unsigned int playerptr=0x0;
|
||||
static float newTurn = 0.1;
|
||||
static float turnStrength = 1.0;
|
||||
static float newTurn = 0.1f;
|
||||
static float turnStrength = 1.0f;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
static DX::AIMove aimoves[1024];
|
||||
|
|
@ -45,11 +47,13 @@ extern "C"
|
|||
//#define MECH_TURNING_SPEED 0.4
|
||||
|
||||
// Maximum radians per 32ms tick
|
||||
void * readIntptr=(void *)0x43BF10;
|
||||
void * writeIntptr=(void *)0x43BF60;
|
||||
void * writeStringptr=(void *)0x43C6D0;
|
||||
void * readStringptr=(void *)0x43C630;
|
||||
int streamReadInt(void * stream,int bitcount) {
|
||||
void *readIntptr=(void *)0x43BF10;
|
||||
void *writeIntptr=(void *)0x43BF60;
|
||||
void *writeStringptr=(void *)0x43C6D0;
|
||||
void *readStringptr=(void *)0x43C630;
|
||||
|
||||
int streamReadInt(void * stream,int bitcount)
|
||||
{
|
||||
int retvalue=0x0;
|
||||
__asm {
|
||||
mov ecx,stream
|
||||
|
|
@ -59,6 +63,7 @@ int streamReadInt(void * stream,int bitcount) {
|
|||
}
|
||||
return retvalue;
|
||||
}
|
||||
|
||||
void streamWriteInt(void * stream,int value,int bitcount) {
|
||||
__asm {
|
||||
mov ecx,stream
|
||||
|
|
@ -68,6 +73,7 @@ void streamWriteInt(void * stream,int value,int bitcount) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void streamWriteString(void * stream,const char * stringvar,int maxlen) {
|
||||
__asm {
|
||||
mov ecx,stream
|
||||
|
|
@ -77,6 +83,7 @@ void streamWriteString(void * stream,const char * stringvar,int maxlen) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void streamReadString(void * stream,char *stringvar) {
|
||||
__asm {
|
||||
mov ecx,stream
|
||||
|
|
@ -85,6 +92,7 @@ void streamReadString(void * stream,char *stringvar) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static char fieldnames[127][256];
|
||||
static char fieldvalues[127][256];
|
||||
static DX::Player *playervar;
|
||||
|
|
@ -141,21 +149,24 @@ void DBpackData(void *stream) {
|
|||
mov thisptr,ecx
|
||||
};
|
||||
DX::SimObject dbobj = DX::SimObject((unsigned int)thisptr);
|
||||
char readcommand[255]="";
|
||||
sprintf (readcommand,"return getWordCount(%d.extraNetFields);",dbobj.identifier);
|
||||
char str[255]="";
|
||||
strncpy(str,Con::evaluate(readcommand,false,NULL,true),254);
|
||||
char readcommand[256]="";
|
||||
sprintf_s<256>(readcommand,"return getWordCount(%d.extraNetFields);", dbobj.identifier);
|
||||
|
||||
char str[256]="";
|
||||
strncpy_s<256>(str,Con::evaluate(readcommand,false,NULL,true), 256);
|
||||
|
||||
Con::printf ("GWC returned %s\n",str);
|
||||
int realcount=atoi(str);
|
||||
int i=0;
|
||||
int counter=0;
|
||||
for (i; (i<126 && i<realcount); i++) {
|
||||
sprintf (readcommand,"return getWord(%d.extraNetFields,%d);",dbobj.identifier,i);
|
||||
strncpy(fieldnames[i],Con::evaluate(readcommand,false,NULL,true),254);
|
||||
sprintf_s<256>(readcommand,"return getWord(%d.extraNetFields,%d);",dbobj.identifier,i);
|
||||
strncpy_s<256>(fieldnames[i],Con::evaluate(readcommand,false,NULL,true), 256);
|
||||
|
||||
Con::printf (fieldnames[i]);
|
||||
_snprintf (readcommand,255,"return(%d.%s);",dbobj.identifier,fieldnames[i]);
|
||||
strncpy(fieldvalues[i],Con::evaluate(readcommand,false,NULL,true),254);
|
||||
strcpy(buf,dbobj.getFieldValue(DX::StringTableInsert(fieldnames[i],false)));
|
||||
_snprintf_s<256>(readcommand,256,"return(%d.%s);",dbobj.identifier,fieldnames[i]);
|
||||
strncpy_s<256>(fieldvalues[i],Con::evaluate(readcommand,false,NULL,true), 256);
|
||||
strcpy_s<256>(buf,dbobj.getFieldValue(DX::StringTableInsert(fieldnames[i],false)));
|
||||
Con::printf ("fieldvalues[i]:%s GDF: %s\n",fieldvalues[i],buf);
|
||||
|
||||
}
|
||||
|
|
@ -174,16 +185,16 @@ void DBunpackData(void *stream) {
|
|||
mov thisptr,ecx
|
||||
};
|
||||
|
||||
char setcommand[255]="";
|
||||
char setcommand[256]="";
|
||||
DX::SimObject dbobj = DX::SimObject((unsigned int)thisptr);
|
||||
int counter=streamReadInt(stream,7);
|
||||
char buf[256]="";
|
||||
Con::printf ("Receiving %d extra fields",counter);
|
||||
for (int i=0; i < counter; i++) {
|
||||
streamReadString(stream,buf);
|
||||
strcpy(fieldnames[i],buf);
|
||||
strcpy_s<256>(fieldnames[i],buf);
|
||||
streamReadString(stream,buf);
|
||||
strcpy(fieldvalues[i],buf);
|
||||
strcpy_s<256>(fieldvalues[i],buf);
|
||||
}
|
||||
for (int i=0; i < counter; i++ ){
|
||||
Con::printf (fieldnames[i]);
|
||||
|
|
@ -195,8 +206,9 @@ void DBunpackData(void *stream) {
|
|||
}
|
||||
|
||||
|
||||
float MECH_TURNING_SPEED=0.4;
|
||||
float MECH_TURNING_SPEED=0.4f;
|
||||
static unsigned int playerptr2;
|
||||
|
||||
__declspec(naked) void updateMoveHook()
|
||||
{
|
||||
// this gets run from 0x5D2D6E
|
||||
|
|
@ -207,9 +219,9 @@ __declspec(naked) void updateMoveHook()
|
|||
mov moveptrmech,eax
|
||||
pusha
|
||||
};
|
||||
MECH_TURNING_SPEED=0.4;
|
||||
//=NULL;
|
||||
unsigned int dbptr;
|
||||
|
||||
MECH_TURNING_SPEED=0.4f;
|
||||
|
||||
if (playerptr!=0) {
|
||||
playervar=&DX::Player(playerptr);
|
||||
mechchangedmove=(DX::Move*) moveptrmech;
|
||||
|
|
@ -219,16 +231,18 @@ __declspec(naked) void updateMoveHook()
|
|||
|
||||
playerdatavar = &DX::SimObject(playervar->dataBlock);
|
||||
//Con::printf("Datablock is %s\n",buf);
|
||||
if (playerdatavar->base_pointer_value!=0) {
|
||||
strcpy(buf,playerdatavar->getFieldValue(DX::StringTableInsert("mechControlEnabled",false)));
|
||||
if (playerdatavar->base_pointer_value!=0)
|
||||
{
|
||||
strcpy_s<256>(buf,playerdatavar->getFieldValue(DX::StringTableInsert("mechControlEnabled",false)));
|
||||
Con::printf("mechControlEnabled: %s",buf);
|
||||
|
||||
if ((mechchangedmove)->freelook && ((mechchangedmove)->y>0.0) && dAtob(buf))
|
||||
{
|
||||
//sprintf (command,"return (%d.getDataBlock().mechTurnSpeed);",playervar->identifier);
|
||||
strcpy(buf,playerdatavar->getFieldValue(DX::StringTableInsert("mechTurnSpeed",false)));
|
||||
strcpy_s<256>(buf,playerdatavar->getFieldValue(DX::StringTableInsert("mechTurnSpeed",false)));
|
||||
Con::printf("mechTurnSpeed: %s",buf);
|
||||
MECH_TURNING_SPEED=atof(buf);
|
||||
// FIXME: The 3 here should reference the datablock's maximum turning angle -- we're essentially normalizing our rotation here.
|
||||
|
||||
// FIXME: The 3 here should reference the datablock's maximum turning angle -- we're essentially normalizing our rotation here.
|
||||
float turnStrength = playervar->headRotationZ / 3;
|
||||
// Use whatever is leftover in our forward movement
|
||||
|
|
@ -239,6 +253,7 @@ __declspec(naked) void updateMoveHook()
|
|||
|
||||
(mechchangedmove)->y = forwardStrength;
|
||||
(mechchangedmove)->x += turnStrength;
|
||||
|
||||
// FIXME: Is the yaw value definitely in radians?
|
||||
playervar->mRotZ += newTurn + (mechchangedmove)->yaw;
|
||||
|
||||
|
|
@ -254,7 +269,8 @@ __declspec(naked) void updateMoveHook()
|
|||
}
|
||||
}
|
||||
}
|
||||
__asm {
|
||||
__asm
|
||||
{
|
||||
popa
|
||||
mov ebx,playerptr
|
||||
mov eax,[ebp+8]
|
||||
|
|
@ -311,7 +327,7 @@ __declspec(naked) void updateMoveHook()
|
|||
aiconn = &DX::GameConnection((unsigned int)origobjptr+0xA0);
|
||||
aimove = getAIMovePtr(aiconn->identifier);
|
||||
char movecallback[120]="";
|
||||
sprintf (movecallback,"AIMoveCallback(%d);",aiconn->identifier);
|
||||
sprintf_s<120>(movecallback,"AIMoveCallback(%d);",aiconn->identifier);
|
||||
Con::evaluate(movecallback,false,NULL,NULL);
|
||||
//Con::printf ("BasePointer: %08X", aiconn.base_pointer_value);
|
||||
//Con::printf ("Ecx Value: %08X", origobjptr);
|
||||
|
|
@ -329,9 +345,8 @@ __declspec(naked) void updateMoveHook()
|
|||
*moves = &(aimove->move);
|
||||
*moveCount=1;
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool consetTrigger(Linker::SimObject *obj, S32 argc, const char *argv[]) {
|
||||
unsigned int aiconid = atoi(argv[1]);
|
||||
unsigned int index = atoi(argv[2]);
|
||||
|
|
@ -343,16 +358,17 @@ __declspec(naked) void updateMoveHook()
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool consetMove(Linker::SimObject *obj, S32 argc, const char *argv[]) {
|
||||
// setMove(%aicon, x, y, z, yaw, pitch, roll);
|
||||
unsigned int aiconid = atoi(argv[1]);
|
||||
DX::AIMove * aimove = getAIMovePtr(aiconid);
|
||||
aimove->move.x=DX::clampFloat(atof(argv[2]));
|
||||
aimove->move.y=DX::clampFloat(atof(argv[3]));
|
||||
aimove->move.z=DX::clampFloat(atof(argv[4]));
|
||||
aimove->move.yaw=DX::clampMove(atof(argv[5]));
|
||||
aimove->move.pitch=DX::clampMove(atof(argv[6]));
|
||||
aimove->move.roll=DX::clampMove(atof(argv[7]));
|
||||
aimove->move.x=DX::clampFloat(std::stof(argv[2]));
|
||||
aimove->move.y=DX::clampFloat(std::stof(argv[3]));
|
||||
aimove->move.z=DX::clampFloat(std::stof(argv[4]));
|
||||
aimove->move.yaw=DX::clampMove(std::stof(argv[5]));
|
||||
aimove->move.pitch=DX::clampMove(std::stof(argv[6]));
|
||||
aimove->move.roll=DX::clampMove(std::stof(argv[7]));
|
||||
//Con::printf ("Set move variables for %d to x:%f y:%f z:%f yaw:%f pitch:%f roll:%f\n",aimove->id,aimove->move.x,aimove->move.y,aimove->move.z,aimove->move.yaw,aimove->move.pitch,aimove->move.roll);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -360,7 +376,6 @@ __declspec(naked) void updateMoveHook()
|
|||
|
||||
bool conEnableNewAI(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
|
||||
(*((unsigned int *)0x75e360))=(unsigned int)newAIMoveListGenerator;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -433,17 +448,23 @@ __declspec(naked) void updateMoveHook()
|
|||
Con::addMethodS("BinaryObject", "getbufferlength", &conBinaryObjectGetBufferLength, "Returns the length of the buffer", 2, 2);
|
||||
Con::addMethodS("BinaryObject", "getbufferpointer", &conBinaryObjectGetBufferPointer, "Returns the buffer pointer", 2, 2);
|
||||
Con::addMethodB("BinaryObject", "close", &conBinaryObjectClose, "Closes the binary object", 2, 2);
|
||||
Con::addMethodS("NetConnection","getGhostIndex", &conGetGhostIndex, "Gets a ghost index for an object id", 3, 3);
|
||||
Con::addMethodI("NetConnection","getGhostIndex", &conGetGhostIndex, "Gets a ghost index for an object id", 3, 3);
|
||||
Con::addMethodB("NetConnection","forceUpdate", &conForceUpdate,"Forces an initial update for an object id", 3, 3);
|
||||
Con::addMethodS("NetConnection","resolveGhostParent",&conResolveGhostParent,"Resolves a ghost index parent", 3, 3);
|
||||
Con::addMethodI("NetConnection","resolveGhostParent",&conResolveGhostParent,"Resolves a ghost index parent", 3, 3);
|
||||
Con::addMethodS(NULL,"floatToHex",&conFloatToHex,"converts float to hex",2,3);
|
||||
Con::addMethodS("NetConnection","resolveGhost",&conResolveGhost,"Resolves an object from a ghost ID for ServerConnection", 3, 3);
|
||||
Con::addMethodI("NetConnection","resolveGhost",&conResolveGhost,"Resolves an object from a ghost ID for ServerConnection", 3, 3);
|
||||
Con::addMethodB(NULL,"clientCmdSetGhostTicks",&conclientCmdSetGhostTicks,"Client Command for disabling tick processing on ghost index",2,10);
|
||||
Con::addMethodB(NULL,"clientCmdsetProcessTicks",&conclientCmdSetProcessTicks,"Client Command for disabling tick processing on ghost object",2,10);
|
||||
// General
|
||||
Con::addMethodS(NULL, "sprintf", &conSprintf,"Formats a string. See the C sprintf.", 2, 20);
|
||||
Con::addMethodB(NULL, "tsExtensionUpdate", &conTSExtensionUpdate,"Updates the TSExtension.", 1, 1);
|
||||
|
||||
// Regex
|
||||
Con::addMethodB(NULL, "reSearch", &reSearch,"reSearch(pattern, target): Searches for a pattern within the target string.", 3, 3);
|
||||
Con::addMethodB(NULL, "reMatch", &reMatch,"reMatch(pattern, pattern): Attempts to match the entire target string to a pattern.", 3, 3);
|
||||
Con::addMethodB(NULL, "reIterBegin", &reIterBegin,"reIterBegin(pattern, target): Begins an iterator search for patterns in the target string.", 3, 3);
|
||||
Con::addMethodB(NULL, "reIterEnd", &reIterEnd,"reIterEnd(): Returns true when the iterator search ends.", 1, 1);
|
||||
Con::addMethodS(NULL,"reIterNext",&reIterNext,"reIterNext(): Returns the next matched pattern in the string.", 1, 1);
|
||||
Con::addMethodS(NULL,"reReplace",&reReplace,"reReplace(pattern, target, replace): Replaces the pattern within the target string with another string.", 4, 4);
|
||||
|
||||
// Add this Gvar to signify that TSExtension is active
|
||||
static bool is_active = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue