if(CWeapon* Weapon = GetWeaponByIndex(pEntity.nWeaponID))//读取当前ID的武器名称
{
const char* EnemyWeaponName = Weapon->WName;
if(MyTeam == pInfo.iTeam)
{
Render.DrawString(ScreenX+5, ScreenY-25, D3DCOLOR_ARGB(255, 0, 255, 0), D3D.Font, EnemyWeaponName);
}
else
{
Render.DrawString(ScreenX+5, ScreenY-25, D3DCOLOR_ARGB(255, 255, 0, 0), D3D.Font, EnemyWeaponName);
}
下面的是子程序 读取index的武器名称并返回pweapon
CWeapon* GetWeaponByIndex( int Index )//武器名称
{
CWeapon* pWeapon = (CWeapon*)((DWORD)0x748658 + Index * WeaponSize);
return pWeapon;
}
下面的是类
class CWeapon
{
public:
char unknown0[4];
CWeaponInfo* WeaponInfo; //0004
char unknown2[48];
char* WName; //0038
};
时钟执行以上代码 一开启显示名称没一会就软件异常
改成char WName[1024];之后 直接显示乱码但不异常了 我郁闷 |