HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. HEMEN TIKLA!
flatik'den alıntıdır...
Windows ortamında kullanıyorsanız filesinizi, %100 düşme şansının fix'i
Öncesi:
Sonrası:
[CODE lang="cpp" title="../libthecore/src/utils.c(xx) İlk satırlarda uygun yere ekle"]#include <random>[/CODE]
[CODE lang="cpp" title="../libthecore/src/utils.c(xx) 'de bu fonksiyonu bul."]int number_ex(int from, int to, const char *file, int line)
{
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
int returnValue = 0;
if ((to - from + 1) != 0)
returnValue = ((thecore_random() % (to - from + 1)) + from);
else
sys_err("number(): devided by 0");
return returnValue;
}
[/CODE]
[CODE lang="cpp" title="Bununla değiştir:"]
int number_ex(int from, int to, const char* file, int line)
{
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
int returnValue = 0;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distrib(from, to);
if ((to - from + 1) != 0)
returnValue = distrib(gen);
else
sys_err("number(): devided by 0");
return returnValue;
}
[/CODE]
[CODE lang="cpp" title="Daha optimize Alternatif:"]int number_ex(int from, int to, const char *file, int line)
{
// We only need (and want) to initialize the mersenne twister generator once
static std::random_device rd;
static std::mt19937 mt(rd());
static std::uniform_int_distribution<int> dist; // not too expensive to create, though
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
// Set the range we'd like our distribution to be on, and generate the number
return dist(mt, std::uniform_int_distribution<int>:
aram_type(from, to));
}[/CODE]
Windows ortamında kullanıyorsanız filesinizi, %100 düşme şansının fix'i
Öncesi:
Sonrası:
[CODE lang="cpp" title="../libthecore/src/utils.c(xx) İlk satırlarda uygun yere ekle"]#include <random>[/CODE]
[CODE lang="cpp" title="../libthecore/src/utils.c(xx) 'de bu fonksiyonu bul."]int number_ex(int from, int to, const char *file, int line)
{
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
int returnValue = 0;
if ((to - from + 1) != 0)
returnValue = ((thecore_random() % (to - from + 1)) + from);
else
sys_err("number(): devided by 0");
return returnValue;
}
[/CODE]
[CODE lang="cpp" title="Bununla değiştir:"]
int number_ex(int from, int to, const char* file, int line)
{
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
int returnValue = 0;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distrib(from, to);
if ((to - from + 1) != 0)
returnValue = distrib(gen);
else
sys_err("number(): devided by 0");
return returnValue;
}
[/CODE]
[CODE lang="cpp" title="Daha optimize Alternatif:"]int number_ex(int from, int to, const char *file, int line)
{
// We only need (and want) to initialize the mersenne twister generator once
static std::random_device rd;
static std::mt19937 mt(rd());
static std::uniform_int_distribution<int> dist; // not too expensive to create, though
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
// Set the range we'd like our distribution to be on, and generate the number
return dist(mt, std::uniform_int_distribution<int>:
aram_type(from, to));}[/CODE]
Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)
Benzer konular
- Cevaplar
- 5
- Görüntüleme
- 674
- Cevaplar
- 8
- Görüntüleme
- 1K
