我想在 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());
谁能告诉我为什么程序第二次到达这条线时会停止?
这是完整源代码的链接