1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Rewrite horrible type casting pointer magic with shifts

Why would you generate that random number byte by byte, anyway ?
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-15 23:26:30 +01:00
parent 3de63c0061
commit 007a10346d
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -157,11 +157,11 @@ void PrivacyForm::generateRandomNospam()
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
uint8_t newNospam[4];
uint32_t newNospam;
for (int i = 0; i < 4; i++)
newNospam[i] = qrand() % 256;
newNospam = (newNospam<<8) + (qrand() % 256); // Generate byte by byte. For some reason.
Core::getInstance()->setNospam(*reinterpret_cast<uint32_t*>(newNospam));
Core::getInstance()->setNospam(newNospam);
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().noSpam);
}