- 1
- 2
- 3
- 4
const QColor * c = & QColor.red;
const QColor * c = & QColor.rgb(12,12,12);
const QColor * c = & int QColor::red () const;
const int * c = & int QColor::red () const;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
const QColor * c = & QColor.red;
const QColor * c = & QColor.rgb(12,12,12);
const QColor * c = & int QColor::red () const;
const int * c = & int QColor::red () const;
Взято отсюда: http://www.prog.org.ru/topic_16855_0.html
Особенно радует фраза: "Пробовал так <....> И другими способами, на которые вылетало множество ошибок".
+170
void Draw_Pixel_Memset(UINT color, //color = _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))
UINT *buffer){ //buffer = (UINT*) ddsd.lpSurface
memset(buffer, color,8);
}
Рисование пикселя с помощью meset()
Подскажите, пожалуйста, почему при использование этой функции в 32 битном режиме точка получается какового то серого цвета.
С другой стороны если использовать 8 битный режим то пиксель будет нужного цвета.
Источник: http://www.gamedev.ru/code/forum/?id=145274
+168
#include <iostream>
using namespace std;
void main()
{
char U='#';
int K;
_asm
{
mov eax, 0
mov al, U
mov K,eax
}
cout<<K<<endl;
}
"Получение десятичного представления числа". C wasm.ru
+167
PopupWindow* GameLocations::getCurrentPopup()
{
if(m_curPopup != nullptr && m_curPopup->needsClose())
{
m_curPopup->onClose();
m_curPopup = nullptr;
m_walker->BeginWalk(m_graph->getClosestNode(m_currentLocationId));
}
return m_curPopup;
}
+154
__int64 timestamp;
// Get nanoseconds since 1601
timestamp = rand() + (((__int64)rand()) << 32);
timestamp /= 100;
очень вольная работа со временем...
+160
float alpha = float(m_startAlpha) + 255.0f * (getElapsed() / (m_duration * (1.0f - float(m_startAlpha) / 255.0f)));
m_target->setAlpha(static_cast<uint8_t>(alpha));
Выдержка из обновления объекта-действия, производящего линейный фейд-аут объекта...
Общение с чужим говнокодом не проходит бесследно... что же я курил, перед тем как ЭТО соорудить?
+167
float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating)
{
// returns the chance to win against a team with the given rating, used in the rating adjustment calculation
// ELO system
// return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f));
float a,b;
a = own_rating;
b = enemy_rating;
if(a<1800 && b<1800) return 16;
if(a>=1800 && a<2000 && b<2000 || b>=1800 && b<2000 && a<2000) return 15;
if(a>=2200 && b>=2200) return 15;
if(a>b){
if(a>=2000 && a<2100 && b>=2100 && b<2200) return 17;
if(a>=2000 && a<=2100 && b>=2200) return 18;
if(b>=2000 && b<2100 && a>=2200) return 9;
if(a>=2000 && a<2100 && b>=2000 && b<2100) return 15;
if(a>=2100 && a<2200 && b>=2100 && b<2200) return 15;
if(a>=2100 && a<2200 && b>=2200) return 16;
if(b>=2100 && b<2200 && a>=2200) return 11;
if (a>=2000 && a<2100 && b >=1850) return 10;
if (a>=2000 && a<2100 && b <=1850) return 5;
if (a>=2100 && a<=2200 && b >=1950 && b <2000) return 9;
if (a>=2100 && a<=2200 && b >=1900 && b <2000) return 7;
if (a>=2100 && a<=2200 && b >=2000 && b <2100) return 11;
if (a>=2100 && a<2200 && b <=1900 && b >=1750) return 4;
if (a>=2100 && a<2200 && b <1750) return 3;
if (a>=2200 && b >=1950 && b <=2000) return 4;
if (a>=2200 && b <=1950 && b>=1800) return 2;
if (a>=2200 && b <=1850) return 1;
if(a>=1500 && a<1600 && b >=2200) return 31;
if(a>=1500 && a<1600 && b>=2000 && b <2100) return 28;
if(a>=1500 && a<1600 && b>=2100 && b<2200) return 29;
if(a>=1500 && a<1600 && b>=2100 && b>2200) return 31;
if (a>=1900 && a<2000 && b>=2000 && b<= 2075) return 18;
if (a>=1900 && a<2000 && b>=2075 && b<= 2150) return 24;
if (a>=1900 && a<2000 && b>=2150 && b<= 2200) return 25;
if (a>=1900 && a<2000 && b>=2150 && b> 2200) return 27;
if (a>=1800 && a<1900 && b>=2000 && b<= 2075) return 22;
if (a>=1800 && a<1900 && b>=2075 && b<= 2150) return 27;
if (a>=1800 && a<1900 && b>=2150 && b<= 2200) return 29;
if (a>=1800 && a<1900 && b>=2150 && b> 2200) return 30;
if (a>=1600 && a<1800 && b>=2000 && b<= 2075) return 22;
if (a>=1600 && a<1800 && b>=2075 && b<= 2150) return 28;
if (a>=1600 && a<1800 && b>=2150 && b<= 2200) return 29;
if (a>=1600 && a<1800 && b>=2150 && b> 2200) return 30;
if(a<1500 & b>=2000) return 31;
}else{
// same just b instead of a and a instead of b
}
}
New developer for wow server ;) Best part is the cast to floats at start imo
+169
#include <iostream>
#include <cstdlib>
#include "filesdescrtable.h"
int ___cntr = 0;
#define _(X) if((X) == EXIT_SUCCESS) {___cntr++;} else {std::cerr << "error on operator: " << ___cntr << std::endl; return (EXIT_FAILURE);}
int main (int argc, char *argv[]) {
FilesDescrTable a;
int d1,d2,d3;
_(a.setAutoReport(true));
_(a.openFile(argv[1], O_RDWR | O_CREAT, 0600, d1));
_(a.openFile(argv[2], O_RDWR | O_CREAT, 0600, d2));
_(a.openFile(argv[3], O_RDWR | O_CREAT, 0600, d3));
_(a.clearFile(argv[3]));
_(a.cpy(d3,d2));
_(a.closeFile(d1));
_(a.closeFile(d2));
_(a.closeFile(d3));
return(EXIT_SUCCESS);
}
хитрый макрос для отлова ошибок. такой хитрый
+175
// "Dedicated to the near-memory of Nev. Let's start remembering people while they're still alive."
// Nev's great contribution to dc++
while(1) break;
Вот такое можно увидеть в исходниках ядра DC++
https://github.com/negativ/eiskaltdcpp/blob/master/dcpp/DCPlusPlus.cpp#L60
+154
if (request->status().is_success() &&
(request->GetResponseCode() / 100) == 2) {
/* блаблабла */
}
Было случайно откопано в исходниках хромиума (http://src.chromium.org/svn/trunk/src/webkit/appcache/appcache_update_job.cc). И первый вопрос который возникает это "Ну вот нахера???".