我试图查找“找不到标识符”错误,只是为了找到必须将函数移出主循环或应该使用前向声明的帖子。但是,我的脚本用作游戏引擎的模块,因此没有真正的主循环,并且有问题的函数由失败行上方的不同函数调用,没有问题:
// Create a Steam ID
CSteamID Steam::createSteamID(uint32 steamID, int accountType){
CSteamID cSteamID;
if(accountType < 0 || accountType >= k_EAccountTypeMax){
accountType = 1;
}
cSteamID.Set(steamID, EUniverse(k_EUniversePublic), EAccountType(accountType));
return cSteamID;
}
// Set a Steam user as someone recently played with
void Steam::setPlayedWith(int steamID){
if(SteamFriends() == NULL){
return;
}
CSteamID friendID = createSteamID(steamID);
SteamFriends()->SetPlayedWith(friendID);
}
// Get friend's Steam username
String getFriendPersonaName(int steamID){
if(SteamFriends() == NULL || steamID == 0){
return "";
}
CSteamID friendID = createSteamID(steamID);
bool isDataLoading = SteamFriends()->RequestUserInformation(friendID, true);
if(!isDataLoading){
return SteamFriends()->GetFriendPersonaName(friendID);
}
}
ID 创建功能位于最顶部,这两个功能要晚得多。第一个(setPlayedWith)成功没有问题,但第二个(getFriendPersonaName)失败:'createSteamID':编译脚本时找不到标识符。
我有点茫然,希望有人能指出我正确的方向。