c++ - C++ - 未声明的标识符/'FUNCTION'的左侧必须有类/结构/联合
问题描述
我整天都在搜索这个问题,但似乎没有一个答案可以帮助我修复错误......
我目前正在用 C++ 做一个 DLL,它连接游戏的 EndScene,并获取viewmatrix
并转换到屏幕......所有代码都很好,但似乎有些变量正在搞砸一切......
我收到了这些错误
错误 1:“LocalPlayer”:未声明的标识符
错误 2:'.flMatrix' 的左侧必须有类/结构/联合
错误 3:'.WorldToScreenMatrix' 的左侧必须有类/结构/联合
这是WorldToScreen
功能:
bool WorldToScreen(float * from, float * to)
{
HWND atual = GetActiveWindow();
RECT m_Rect;
GetWindowRect(atual, &m_Rect);
float w = 0.0f;
to[0] = LocalPlayer.WorldToScreenMatrix.flMatrix[0][0] * from[0] + LocalPlayer.WorldToScreenMatrix.flMatrix[0][1] * from[1] + LocalPlayer.WorldToScreenMatrix.flMatrix[0][2] * from[2] + LocalPlayer.WorldToScreenMatrix.flMatrix[0][3];
to[1] = LocalPlayer.WorldToScreenMatrix.flMatrix[1][0] * from[0] + LocalPlayer.WorldToScreenMatrix.flMatrix[1][1] * from[1] + LocalPlayer.WorldToScreenMatrix.flMatrix[1][2] * from[2] + LocalPlayer.WorldToScreenMatrix.flMatrix[1][3];
w = LocalPlayer.WorldToScreenMatrix.flMatrix[3][0] * from[0] + LocalPlayer.WorldToScreenMatrix.flMatrix[3][1] * from[1] + LocalPlayer.WorldToScreenMatrix.flMatrix[3][2] * from[2] + LocalPlayer.WorldToScreenMatrix.flMatrix[3][3];
if (w < 0.01f)
return false;
float invw = 1.0f / w;
to[0] *= invw;
to[1] *= invw;
int width = (int)(m_Rect.right - m_Rect.left);
int height = (int)(m_Rect.bottom - m_Rect.top);
float x = width / 2;
float y = height / 2;
x += 0.5 * to[0] * width + 0.5;
y -= 0.5 * to[1] * height + 0.5;
to[0] = x + m_Rect.left;
to[1] = y + m_Rect.top;
return true;
}
错误在这一行:
to[0] = LocalPlayer.WorldToScreenMatrix.flMatrix[0][0] * from[0] + LocalPlayer.WorldToScreenMatrix.flMatrix[0][1] * from[1] + LocalPlayer.WorldToScreenMatrix.flMatrix[0][2] * from[2] + LocalPlayer.WorldToScreenMatrix.flMatrix[0][3];
to[1] = LocalPlayer.WorldToScreenMatrix.flMatrix[1][0] * from[0] + LocalPlayer.WorldToScreenMatrix.flMatrix[1][1] * from[1] + LocalPlayer.WorldToScreenMatrix.flMatrix[1][2] * from[2] + LocalPlayer.WorldToScreenMatrix.flMatrix[1][3];
w = LocalPlayer.WorldToScreenMatrix.flMatrix[3][0] * from[0] + LocalPlayer.WorldToScreenMatrix.flMatrix[3][1] * from[1] + LocalPlayer.WorldToScreenMatrix.flMatrix[3][2] * from[2] + LocalPlayer.WorldToScreenMatrix.flMatrix[3][3];
LocalPlayer 结构是:
struct LocalPlayer
{
DWORD Local;
int Team;
int Health;
WorldToScreenMatrix_t WorldToScreenMatrix;
float* Position;
int Flags;
int CrossHair;
void Read()
{
Local = *(DWORD*)(dwClient + dwLocalPlayer);
if (Local != NULL)
{
Team = *(int*)(Local + dwTeam);
Position = (float*)(Local + dwOrigin);
Health = *(int*)(Local + dwHealth);
CrossHair = *(int*)(Local + dwCrossHairID);
WorldToScreenMatrix = *(WorldToScreenMatrix_t*)(dwEngine + dw_vMatrix);
}
}
}LocalPlayer;
flmatrix 开启:
typedef struct
{
float flMatrix[4][4];
}WorldToScreenMatrix_t;
哪里导致错误?
解决方案
推荐阅读
- javascript - 如何在代码中实现依赖注入和单一职责原则
- javascript - Asp.net - 引导确认 - FullCalendar => 单例怪异行为
- elasticsearch - 有没有办法从 RAM 中获取弹性搜索索引数据?
- javascript - 无法保存从 .Net api 发送的 .pdf 文档
- android - 访问和添加项目到 Spinner
- sql - 基于从源表的一列向目标表插入多列的查询优化
- azure-devops - 即使构建没有发布工件,也会触发发布
- php - 如何在我的网络浏览器上获取注册消息
- ruby - 将变量的名称作为输入并输出其值 - Ruby
- svg - 如何在处理过程中为 svg 着色并保持亮度?