【发布时间】:2011-10-14 13:32:11
【问题描述】:
我想在 Irrlicht 游戏中使用 Irrnet 网络库。
源代码使用 Linux 套接字,我正在尝试将其移植到 Windows 上,将其替换为使用 Windows 的 Winsock2 的代码。
库编译成功,但是当我尝试运行 Quake 示例时它崩溃了。我找到了程序停止的那一行,但我不知道如何解决这个问题。
程序在第二次调用函数getNextItem
时停止class NetworkType {
public :
NetworkType();
~NetworkType();
template<class T>
void getNextItem(irr::core::vector3d<T>& data);
private:
typedef std::queue<std::string> Container;
Container items;
};
template<class T>
void NetworkType::getNextItem(irr::core::vector3d<T>& data) {
T X, Y, Z;
std::istringstream item(items.front());
// the program does not get here the second time it calls this function
items.pop();
item >> X;
item >> Y;
item >> Z;
data = irr::core::vector3d<T>(X, Y, Z);
}
正好在这一行
std::istringstream item(items.front());
谁能告诉我为什么程序第二次到达这一行时会停止?
这里是完整源代码的link
【问题讨论】:
-
这似乎与游戏开发无关,可能更适合 StackOverflow;我已将问题标记为迁移考虑。
-
断言(!items.empty());你应该总是编码你的假设。
标签: networking libraries irrlicht