- 1
- 2
- 3
- 4
- 5
float SGammaUIPanel::OnGetGamma() const
{
float DisplayGamma = GEngine->DisplayGamma;
return GEngine ? DisplayGamma : 2.2f;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
float SGammaUIPanel::OnGetGamma() const
{
float DisplayGamma = GEngine->DisplayGamma;
return GEngine ? DisplayGamma : 2.2f;
}
Этот и другие прелести из UE в статье https://www.unrealengine.com/blog/how-pvs-studio-team-improved-unreal-engines-code
+124
http://m.habrahabr.ru/post/249637/
−24
Оффтоп #2
Первая часть: http://govnokod.ru/18142
+67
public class Client extends Thread {
private final static Logger LOG = Logger.getLogger(Client.class);
@Override
public void run() {
System.out.println("Client " + name + " comes to restaurant " + restaurant.getName());
this.cashDesk = chooseCashDesk();
System.out.println("Client " + getClientName() + " choosed the cashDesk#"+ cashDesk.getNumber());
//...остальное говно
}
}
Что такое логгер ? ХЗ. Требуют - значит должно быть!
+145
#define pb push_back
#define ll long long#define forit(it, r) for (auto it = r.begin(); it != r.end(); it++)
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i < n; ++i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define ROF(i, m, n) for (int i = m; i >= n; --i)
#define fori(n) for (int i = 0; i < n; ++i)
#define forj(n) for (int j = 0; j < n; ++j)
// ...
string s;
int k;
while (i >= base)
k = i % base,
s.pb(k > 9 ? k + 'A' - 10 : k + 48),
i /= base;
k = i % base;
s.pb(k > 9 ? k + 'A' - 10 : k + 48);
// ...
fori(s.size())
if (i < s.size() - 1 && s[i] == '\\' && (s[i + 1] == 'n' || s[i + 1] == -47))
{
ret.append("%0A");
i += 1 + (s[i + 1] == -47);//-47 -- russian t, because has the same place with n (\n == \t_russian)
}
else
ret.append("%" + itoa((s[i] + 256) % 256, 16));
Олимпиадники... Олимпиадники повсюду...
+142
#define ADD_TYPE(type, tname, plname) \
int Get ## tname ## LocByName(string name) const\
{\
assert(MyInterface!=null);\
auto index=MyInterface.data->get_id_by_name(name);\
assert(index==-1 || MyInterface.data->Structure.Declarations[index].Type==ValueType::tname);\
return index;\
}\
ShaderParameters& Set ## tname (int loc, type val)\
{\
return Set ## plname (loc, &val, 0, 1);\
}\
ShaderParameters& Set ## tname (string name, type val)\
{\
return Set ## tname (Get ## tname ## LocByName(name), val);\
}\
ShaderParameters& Set ## plname (int loc, const type* vals, ushort first, ushort count)\
{\
if(loc==-1) return *this;\
assert(MyInterface!=null);\
update_id=++MyInterface.data->num_updates;\
values.Set(loc, vals, first, count);\
return *this;\
}\
ShaderParameters& Set ## plname (string name, const type* vals, ushort first, ushort count)\
{\
return Set ## plname (Get ## tname ## LocByName(name), vals, first, count);\
}\
type Get ## tname (int loc, ushort i=0) const\
{\
if(loc==-1) return type();\
return values.Get<type>(loc, i);\
}\
type Get ## tname (string name, ushort i=0) const\
{\
return Get ## tname (Get ## tname ## LocByName(name), i);\
}
ADD_TYPE(float, Float, Floats);
ADD_TYPE(Math::vec2, Vec2, Vecs2);
ADD_TYPE(Math::vec3, Vec3, Vecs3);
ADD_TYPE(Math::vec4, Vec4, Vecs4);
ADD_TYPE(int, Int, Ints);
ADD_TYPE(Math::ivec2, IVec2, IVecs2);
ADD_TYPE(Math::ivec3, IVec3, IVecs3);
ADD_TYPE(Math::ivec4, IVec4, IVecs4);
ADD_TYPE(Math::mat3, Mat3, Mats3);
ADD_TYPE(Math::mat4, Mat4, Mats4);
#undef ADD_TYPE
Вот так в моём движке идёт работа с параметрами шейдеров. Макросы делал, чтобы избежать копипаста. Выглядит ужасно, отлаживать неудобно, но зато использовать удобно. Буду думать, как красиво перевести это на шаблоны, чтобы не потерять удобство использования.
+144
var me = this;
if (me.profile.carveoutSettings) {
me.profile.carveoutSettings.truncationMethod = fields.truncationMethod;
me.profile.carveoutSettings.truncationMode = fields.truncationMode;
me.profile.carveoutSettings.applyTruncation = fields.applyTruncation;
me.profile.carveoutSettings.truncationValue = fields.truncationValue;
me.profile.carveoutSettings.applyExclusion = fields.applyExclusion;
me.profile.carveoutSettings.serviceTypes = me.getSelected(me.getServiceTypeSelector().getStore(), 'ServiceSubCategoryID');
me.profile.carveoutSettings.placeOfServices = me.getSelected(me.getPlaceOfServiceSelector().getStore(), 'code');
me.profile.carveoutSettings.chronicConditions = me.getSelected(me.getChronicConditionSelector().getStore(), 'column');
} else {
this.profile.carveoutSettings = {
truncationMethod: fields.truncationMethod,
truncationMode: fields.truncationMode,
applyTruncation: fields.applyTruncation,
truncationValue: fields.truncationValue,
applyExclusion: fields.applyExclusion,
serviceTypes: me.getSelected(me.getServiceTypeSelector().getStore(), 'ServiceSubCategoryID'),
placeOfServices: me.getSelected(me.getPlaceOfServiceSelector().getStore(), 'code'),
chronicConditions: me.getSelected(me.getChronicConditionSelector().getStore(), 'column')
}
}
Суслика видишь? а он есть ...
−54
* g o a t s e x * g o a t s e x * g o a t s e x *
g g
o / \ \ / \ o
a| | \ | | a
t| `. | | : t
s` | | \| | s
e \ | / / \\\ --__ \\ : e
x \ \/ _--~~ ~--__| \ | x
* \ \_-~ ~-_\ | *
g \_ \ _.--------.______\| | g
o \ \______// _ ___ _ (_(__> \ | o
a \ . C ___) ______ (_(____> | / a
t /\ | C ____)/ \ (_____> |_/ t
s / /\| C_____) | (___> / \ s
e | ( _C_____)\______/ // _/ / \ e
x | \ |__ \\_________// (__/ | x
* | \ \____) `---- --' | *
g | \_ ___\ /_ _/ | g
o | / | | \ | o
a | | / \ \ | a
t | / / | | \ |t
s | / / \__/\___/ | |s
e | / | | | |e
x | | | | | |x
* g o a t s e x * g o a t s e x * g o a t s e x *
https://searchcode.com/?q=goatse
https://code.openhub.net/search?s=goatse
+142
template<class T>
void KillGorynich()
{
T counter = 1;
while (true)
{
T newCount = counter + counter;
if (newCount > counter)
{
std::cout << "Отрубил Илья Муромец змею горынчу " << counter << " голов, а на их месте " << newCount << " выросло\n";
counter = newCount;
}
else
{
std::cout << "Отрубил Илья Муромец змею горынчу " << counter << " голов, и умер змей горыныч\n";
char * bits = "";
switch (sizeof(T) * 8)
{
case 8:
printf("Потому что восьмибитный был\n");
break;
case 16:
printf("Потому что шестнадцатибитный был\n");
break;
case 32:
printf("Потому что тридцатидвухбитный был\n");
break;
case 64:
printf("Потому что шестидесятичетырехбитный был\n");
break;
}
break;
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL, "russian");
//KillGorynich<unsigned short>();
KillGorynich<unsigned int>();
//KillGorynich<unsigned long long>();
//KillGorynich<long double>();
while (!_kbhit());
return 0;
}
Шаблонизм головного мозга.
+141
private function StrToFloat($str){
$str = trim($str);
$i=0;$k=1;
for($j=0;$j<=strlen($str);$j++){
if($str[$j]>='0' && $str[$j]<='9') {
$i = $i + $str[$j]*$k;
if($k>1) $k=$k*10;
else $k = $k*0.1;
} else {
if($str[$j]=='.' && $str[$j]==',') $k = 0.1;
else if($str[$j]<=' ') {}
}
}
return $i;
}