我试图弄清楚为什么以下代码不起作用,我假设使用char*作为键类型是一个问题,但是我不知道如何解决它或为什么它发生.我使用的所有其他功能(在HL2 SDK中)使用char*
这样std::string
会导致很多不必要的复杂化.
std::map<char*, int> g_PlayerNames;
int PlayerManager::CreateFakePlayer()
{
FakePlayer *player = new FakePlayer();
int index = g_FakePlayers.AddToTail(player);
bool foundName = false;
// Iterate through Player Names and find an Unused one
for(std::map<char*,int>::iterator it = g_PlayerNames.begin(); it != g_PlayerNames.end(); ++it)
{
if(it->second == NAME_AVAILABLE)
{
// We found an Available Name. Mark as Unavailable and move it to the end of the list
foundName = true;
g_FakePlayers.Element(index)->name = it->first;
g_PlayerNames.insert(std::pair<char*, int>(it->first, NAME_UNAVAILABLE));
g_PlayerNames.erase(it); // Remove name since …
Run Code Online (Sandbox Code Playgroud) 我今晚检查了很多SSL图书馆.OpenSSL看起来不错,但缺少文档,因为大多数都可以.当我找到NetSieben的SSL C++库(http://www.netsieben.com/products/ssh/index.phtml)时,我以为我中了大奖,但是几小时后,我无法进行编译.它说它需要Botan的lib,但绝对没有信息如何将它与Botan或任何东西联系起来.
所以我正在寻找一个相当容易使用的SSL库.我只是将它用于客户端应用程序以连接到现有的服务器.
我一直在谷歌搜索一段时间,但我遇到的问题是我不确定我需要搜索的是什么.(搜索PHP C++通信似乎不是我需要的)我基本上是为游戏服务器开发一个c ++插件,我想创建一个可以向/从C++插件传递数据的Web界面.游戏已经使用RCON端口进行远程管理访问,但我偶然发现了他们使用的网络接口的标题,所以我想我可以使用它.
我的问题是我对使用套接字不是很熟悉.我假设我基本上需要在C++中打开一个套接字并让它监听,然后在PHP中,连接到该套接字,传递数据并关闭它.
这是界面... http://www.ampaste.net/m2f6b6dbc
我大部分时间都会像当前连接的玩家名单,名字和分数那样提取信息.并传递命令以重启服务器,关闭服务器等.
任何帮助都会很棒,谢谢!
我一直在尝试使用SSL支持构建LibCurl 2天,我已经跟踪了互联网上的每个指南,并且谷歌的错误持续数小时.我终于把它编译好了,但是当我链接到它时,我收到下面列出的链接器错误.
我正在建设......
nmake -f Makefile.vc9 OPENSSL_PATH=c:\dev_mms\openSSL RTLIBCFG=static CFG=release-ssl
Run Code Online (Sandbox Code Playgroud)
以下错误,当我谷歌他们说了一些关于OpenSSL库没有正确链接,但我看了Makefile.vc9,它肯定包括适当的OpenSSL库.以下是链接器错误(我删除了大约50个只是为了缩短它),我该怎么做才能解决这些错误?
1>libcurl.lib(ssluse.obj) : error LNK2019: unresolved external symbol _RAND_status referenced in function _rand_enough
1>libcurl.lib(ssluse.obj) : error LNK2019: unresolved external symbol _RAND_file_name referenced in function _ossl_seed
1>libcurl.lib(ssluse.obj) : error LNK2019: unresolved external symbol _RAND_load_file referenced in function _ossl_seed
1>libcurl.lib(ssluse.obj) : error LNK2019: unresolved external symbol _SSL_CTX_check_private_key referenced in function _cert_stuff
1>libcurl.lib(ssluse.obj) : error LNK2019: unresolved external symbol _SSL_free referenced in function _cert_stuff
1>libcurl.lib(ssluse.obj) : error LNK2019: unresolved external symbol _BN_num_bits referenced in …
Run Code Online (Sandbox Code Playgroud) 在我为他们制作的游戏中,他们最近做了一些改变,打破了一个特定的实体.在与找到解决方法的人交谈之后,他们只有他们给我的信息是他们"修补它"并且不再共享.
我基本上试图记住如何在运行时转储类对象的内存内容.我依旧记得以前做过类似的事,但已经很久了.任何帮助记住如何去做这将是非常感激.
我自己也很困惑,但这就是我所拥有的.我最近才开始用指针来自己熟悉更多的一个点,我觉得更舒适的使用他们,但我得到关于strcpy_s缓冲器()太小错误.
请使用字符数组代替的std :: string,关于我的任何意见及其对围绕字符数组居中HL2SDK(不知道为什么),所以我只是坚持的模式.
void func_a()
{
char *szUserID = new char[64];
char *szInviterID = new char[64];
char *szGroupID = new char[64];
sprintf(szUserID, "%I64d", GetCommunityID(szUserSteamID));
sprintf(szInviterID, "%I64d", GetCommunityID(g_CvarSteamID.GetString()));
GetGroupCommunityID(1254745, &szGroupID); // Group Steam Community ID
}
void GetGroupCommunityID(int groupID, char **communityID)
{
int staticID = 1035827914;
int newGroupID = 29521408 + groupID;
char *buffer = new char[64];
snprintf(buffer, sizeof(buffer), "%d%d", staticID, newGroupID);
strcpy_s(*communityID, sizeof(*communityID), buffer);
delete buffer;
}
Run Code Online (Sandbox Code Playgroud)