Edit: Solved please close
Hi guys, I'm trying to convert DaCoder's C# object manager to c++ and having some issues. Right now calling:
Code:
ListWoWObjects * tempList = new ListWoWObjects();
WoWObject tempObj;
tempObj = *tempList->get(0);
cout << tempObj.Name;
Is giving me a blank char (All wow objects are being initialised as "null object").
Edit: Should have mentioned this is a dll.
Code:
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwAttached, LPVOID lpvReserved)
{
if (dwAttached == DLL_PROCESS_ATTACH) {
CreateThread(NULL, 0, &Main_Thread, NULL, 0, NULL);
RedirectIOToConsole();
}
return 1;
}
WoWObject.h
Code:
#ifndef __WOWOBJECT_H__
#define __WOWOBJECT_H__
#include <windows.h>
#include <string>
typedef unsigned long ulong;
typedef unsigned int uint;
enum ObjType : uint
{
OT_NONE = 0,
OT_ITEM = 1,
OT_CONTAINER = 2,
OT_UNIT = 3,
OT_PLAYER = 4,
OT_GAMEOBJ = 5,
OT_DYNOBJ = 6,
OT_CORPSE = 7,
OT_FORCEDWORD = 0xFFFFFFFF
};
enum GameObjectType : uint
{
Door = 0,
Button = 1,
QuestGiver = 2,
Chest = 3,
Binder = 4,
Generic = 5,
Trap = 6,
Chair = 7,
SpellFocus = 8,
Text = 9,
Goober = 0xa,
Transport = 0xb,
AreaDamage = 0xc,
Camera = 0xd,
WorldObj = 0xe,
MapObjTransport = 0xf,
DuelArbiter = 0x10,
FishingNode = 0x11,
Ritual = 0x12,
Mailbox = 0x13,
AuctionHouse = 0x14,
SpellCaster = 0x16,
MeetingStone = 0x17,
Unkown18 = 0x18,
FishingPool = 0x19,
FORCEDWORD = 0xFFFFFFFF,
};
class WoWObject{
public:
WoWObject();
~WoWObject();
ulong Guid;
ulong SummonedBy;
float XPos;
float YPos;
float ZPos;
float Rotation;
byte ComboPoints;
int Energy;
int Mana;
uint BaseAddress;
uint UnitFieldsAddress;
short Type;
std::string Name;
uint id;
uint CurrentHealth;
uint MaxHealth;
uint CurrentEnergy;
uint MaxEnergy;
uint Level;
int CurrentForm;
uint GameObjectType;
};
#endif
WoWObject.cpp
Code:
#include "WoWObject.h"
WoWObject::WoWObject(){
ulong Guid = 0;
ulong SummonedBy = 0;
float XPos = 0;
float YPos = 0;
float ZPos = 0;
float Rotation = 0;
byte ComboPoints = 0;
int Energy = 0;
int Mana = 0;
uint BaseAddress = 0;
uint UnitFieldsAddress = 0;
short Type = 0;
std::string Name = "null object";
uint id = 0;
uint CurrentHealth = 0;
uint MaxHealth = 0;
uint CurrentEnergy = 0;
uint MaxEnergy = 0;
uint Level = 30;
int CurrentForm = 0;
uint GameObjectType = 0;
}
WoWObject::~WoWObject(){
}
ListWoWObjects.h
Code:
#ifndef __LISTWOWOBJECTS_H__
#define __LISTWOWOBJECTS_H__
#include "WoWObject.h"
class ListWoWObjects{
public:
ListWoWObjects();
~ListWoWObjects();
WoWObject Head;
void add(WoWObject *);
WoWObject * get(int);
int count();
WoWObject * pointerArray(int);
WoWObject * objects;
private:
int size;
};
#endif
ListWoWObjects.cpp
Code:
#include "ListWoWObjects.h"
WoWObject * objects();
ListWoWObjects::ListWoWObjects(){
objects = pointerArray(10000); //Yes I know this is stupid, will be using a function
size = 0; //to have the function grow dynamically later
}
ListWoWObjects::~ListWoWObjects(){
}
void ListWoWObjects::add(WoWObject *obj){
objects[size] = *obj;
size++; //Again this function is stupid, it will be changed
}
WoWObject * ListWoWObjects::get(int pos){
return &objects[pos];
}
int ListWoWObjects::count(){
return size;
}
//Trying to create an array of pointers in the heap to keep track of all objects
WoWObject * ListWoWObjects::pointerArray(int n){
WoWObject *returnValue = new WoWObject[n];
for (int i = 0; i < n; i++){
returnValue[i] = * new WoWObject();
}
return returnValue;
}