- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我完全厌倦了这个,但为什么我得到:
client.cpp: In member function 'void Client::netRead(int, int)':
client.cpp:158:57: error: no matching function for call to 'Client::nextGameUpdate(sf::Vector2i [0], int [0], sf::IpAddress [0], int&)'
client.cpp:158:57: note: candidate is:
client.cpp:85:6: note: void Client::nextGameUpdate(sf::Vector2i, int, sf::IpAddress, int)
client.cpp:85:6: note: no known conversion for argument 1 from 'sf::Vector2i [0] {aka sf::Vector2<int> [0]}' to 'sf::Vector2i {aka sf::Vector2<int>}'
[Finished in 4.7s]
void Client::nextGameUpdate(sf::Vector2i qq, int ww, sf::IpAddress cc, int dataSize)
{
pListIP[dataSize] = cc;
pListVec[dataSize] = qq;
pListRot[dataSize] = ww;
int num_pListIP = sizeof(pListIP)/sizeof(sf::IpAddress);
if (num_pListIP == lastPlayerCount)
{
return;
}
else if (num_pListIP > lastPlayerCount)
{
int new_players = num_pListIP - lastPlayerCount;
for (new_players; new_players>0; new_players--)
{
addPlayer();
}
}
else if (num_pListIP < lastPlayerCount)
{
int dc_players = lastPlayerCount - num_pListIP;
for (dc_players; dc_players>0; dc_players--)
{
removePlayer();
}
}
lastPlayerCount = num_pListIP;
}
void Client::netRead(int net_step, int dataSize)
{
sf::Packet player_vectors;
sf::Packet player_rotations;
sf::Packet player_ips;
switch (net_step)
{
case 1:
if (socket.receive(player_vectors, sender, senderPort) != sf::Socket::Done)
return;
while (dataSize>0)
{
sf::Vector2i tmp_vec;
player_vectors >> tmp_vec.x >> tmp_vec.y;
pListVec[dataSize] = tmp_vec;
dataSize--;
}
break;
case 2:
if (socket.receive(player_rotations, sender, senderPort) != sf::Socket::Done)
return;
while (dataSize>0)
{
int tmp_rot;
player_rotations >> tmp_rot;
pListRot[dataSize] = tmp_rot;
dataSize--;
}
break;
case 3:
if (socket.receive(player_ips, sender, senderPort) != sf::Socket::Done)
return;
while (dataSize>0)
{
std::string tmp_str;
player_ips >> tmp_str;
sf::IpAddress tmp_ips = tmp_str;
pListIP[dataSize] = tmp_ips;
dataSize--;
}
break;
}
nextGameUpdate(pListVec, pListRot, pListIP, dataSize);
}
标题
private:
sf::Vector2i pListVec[];
sf::IpAddress pListIP[];
int pListRot[];
我觉得这与我试图用 sf::Vector2i 填充的数组有关.../我茫然地盯着屏幕
非常简单。 netRead 从另一个非常基本的函数获取信息。然后交换机经过net_step int...
在游戏收到继续运行所需的所有数据包后,我们触发 nextGameUpdate() 并向其发送 3 个数组和一个 dataSize int 变量。
如果您解决了这个问题,请提前致谢。 ^^
最佳答案
您正在尝试将 pListVec
传递给 qq
,其中前者是 Vector2i
的数组,后者是单个 Vector2i
。
但是你的逻辑也有问题。将 pListVec
替换为更新函数中的 qq
,第二条语句为:
pListVec[dataSize] = pListVec;
那不可能是你想要做的。
此外,由于 pListVec
是您类的私有(private)字段,因此无需将其作为成员函数之间的参数传递(至少在您的情况下,两个方法在同一个对象上调用实例)。
关于c++ - 没有已知的 SFML Vector2i 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14440353/
将此矩阵视为一个内存。 p00 p01 p02 p03 p04 p05 p06.... p0n
一般,您如何确定如何根据已知模式迭代数组? 具体,这是我想要迭代的模式,返回一个数组数组:(每个数字都是原始数组的索引值:[0, 1, 2, 3] ) 0 0,1 0,1,2 0,1,2,3 1 1,
问题: 我正在编写一个 C++ 程序,我想在其中从 TCP/IP 套接字读取数据流。数据由几个不同长度和数据类型的数据包组成,但是,它们都是以十六进制格式接收的。在此图中可以看到数据包的长度及其数据类
使用 VC12(在 Visual Studio 2013 RTM 中)[1] 编译此程序会导致崩溃(在所有构建配置中),而实际上它不应该: #include void foo(std::string
我有一个 Snakemake 规则,适用于数据存档并本质上解压其中的数据。文件包含我在规则开始之前知道的不同数量的文件,因此我想利用它并执行类似的操作 rule unpack: input:
有这样的 list 吗? 我对 iOS 开发比较陌生,我认为研究最知名的编译器错误或陷阱列表会很棒。 编辑: 今天我花了太多时间来理解这样的代码发生了什么: 在 *.h @interface I :
如何选择已知 div 中的最后一个子元素,其中该子元素是未知元素。即:元素可以是段落或无序列表。 大多数情况下结构是: Text 但在其他情况下,结构将是: Text More Text
我想绘制以下内容: x = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] y = [10, 20, 1, 8, 7, 2, 3, 7, 11] 作为条形图
关于未知列表的排序问题,人们已经知道很多了。但是,在堆栈机器中找到已知列表的最佳排序问题呢?也就是说,假设您有以下堆栈计算机: [4,1,3,2] [] [] 也就是说,有3个堆栈的空间,其中1个堆栈
正如主题中所写,我必须使用 mechanize 更改某些输入字段的值,但我没有它的名称只有 id:/让我们坚持这一点。 表单是这样的:
我只是回想起我的大学类(class),想知道这里是否有人在专业环境中使用过“Z 符号”。老实说,这是我一生中参加过的最无聊的类(class)。也许是因为老师,但当时我们真的都认为这是浪费时间。我可能错
我正在尝试编写一个函数来获取 Windows 等效的 HOME。我的 C 技能生疏了,所以请不要介意我的示例代码无法编译。我试图在 Windows Vista 和更新版本上使用 SHGetKnownF
我想找到一个正整数矩阵B,使得AB = BC,其中A和C是具有共同特征值的正整数矩阵。对于这种情况,存在解,但不唯一;我只需要一种解决方案。 有人知道 python 或 matlab 中可以执行此操作
如果您有两个二进制 blob,x 和 y。然后将它们散列在一起,假设使用 SHA-512。入侵者知道 y,这会使反转哈希变得容易多少? 是否有关于 y 有多大并且可以与 x 比较才成为问题的指南?这有
我正在使用Angular-Stripe-Checkout library创建像这样的 stripeToken example 。一些亮点如下所示。 与许多 Angular-stripe 库和示例一样,
我有一个带有 (e,n) 加密数据的公钥,必须通过 RSA 获取纯文本,并且所有这些都在 C 中! 首先我想知道如何找出我的 p 和 q 是什么?我知道它们必须是质数和 p<>q! 最佳答案 首先,因
表1(客户表) Id, CustomerId, IsKnownCustomer,phonemacaddress 1, 空 0 00:9a:34:cf:a4 2, 004024 1 00:6f:64:c
问题是找到第 n-th Catalan 数 mod m,其中 m 是 NOT prime , m = (10^14 + 7)。以下是我尝试过的方法列表:(max N = 10,000) 查表的动态编程
每当我打开我的应用程序时,我都想将我的应用程序连接到一个已知的 wifi 网络/ssid。即使手机当前通过 3G 或任何其他 wifi 网络连接。 仅使用 phonegap/html5 是否可行? 最
我正在做一个项目,我想为特定的用户组(具有管理员角色)实现实时通知,经过一些研究,我明白我需要 session 才能知道哪些用户已登录(默认情况下他们是匿名的)。 另外,我只需要向特定用户发送通知。
我是一名优秀的程序员,十分优秀!