- 1
ReceiveManager* getReveiceManager() { return (receiveManager == 0 ? 0 : receiveManager); }
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+161
ReceiveManager* getReveiceManager() { return (receiveManager == 0 ? 0 : receiveManager); }
+159
#ifdef Status // we seem to pick up a macro Status --> int somewhere
#undef Status
#endif
...
enum Status {
Где-то мы макрос подхватили. qsettings.h
+161
void convert_bglfile(std::string infile, std::string source_charset, std::string target_charset)
{
std::string outfile;
const char *p = infile.c_str();
const char *p1 = strrchr(p, '.');
if (p1) {
outfile.assign(p, p1-p);
} else {
outfile = infile;
}
...
Из опенсорсного словаря StarDict. Товарисч на форуме написал, что не комилируется - не иклюдился cstring. А там такое :o
+146
else
{
if(cells[i][j-1].label == 1)
{
cells[i][0].label = 2;
cells[i][0].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i-1][j].label == 1)
{
cells[0][2].label = 2;
cells[0][2].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i-1][j-1].label == 1)
{
cells[0][0].label = 2;
cells[0][0].empty = false;
playerIsTurn = true;
numTurns++;
}
}
}
}
}
}
}
}
}
часть 4 полный код можно посмотреть на http://www.gamedev.ru/projects/forum/?id=160346&page=2
+142
else
{
if(i == 0)
{
if(j == 0)
{
if(cells[i][j+1].label == 1)
{
cells[i][2].label = 2;
cells[i][2].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j].label == 1)
{
cells[2][j].label = 2;
cells[2][j].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j+1].label == 1)
{
cells[2][2].label = 2;
cells[2][2].empty = false;
playerIsTurn = true;
numTurns++;
}
}else if(j == 1)
{
if(cells[i][j-1].label == 1)
{
cells[i][2].label = 2;
cells[i][2].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j].label == 1)
{
cells[2][j].label = 2;
cells[2][j].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i][j+1].label == 1)
{
cells[0][0].label = 2;
cells[0][0].empty = false;
playerIsTurn = true;
numTurns++;
}
}else
{
if(cells[i][j-1].label == 1)
{
cells[i][0].label = 2;
cells[i][0].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j].label == 1)
{
cells[2][2].label = 2;
cells[2][2].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j-1].label == 1)
{
cells[2][0].label = 2;
cells[2][0].empty = false;
playerIsTurn = true;
numTurns++;
}
}
}else if(cells[i-1][j].label == 1)
часть 3 полный код можно посмотреть на http://www.gamedev.ru/projects/forum/?id=160346&page=2
+141
else if(numTurns != 1)
{
{
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 3; j++)
{
if(cells[i][j].label == 1)
{
if(i == 1 && j == 1)
{
if(cells[i][j-1].label == 1)
{
cells[i][j+1].label = 2;
cells[i][j+1].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i][j+1].label == 1)
{
cells[i][j-1].label = 2;
cells[i][j-1].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i-1][j].label == 1)
{
cells[i+1][j].label = 2;
cells[i+1][j].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j].label == 1)
{
cells[i-1][j].label = 2;
cells[i-1][j].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i-1][j-1].label == 1)
{
cells[i+1][j+1].label = 2;
cells[i+1][j+1].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i-1][j+1].label == 1)
{
cells[i+1][j-1].label = 2;
cells[i+1][j-1].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j+1].label == 1)
{
cells[i-1][j-1].label = 2;
cells[i-1][j-1].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[i+1][j-1].label == 1)
{
cells[i-1][j+1].label = 2;
cells[i-1][j+1].empty = false;
playerIsTurn = true;
numTurns++;
}
}
часть 2
+150
if(numTurns == 1)
{
if(cells[1][1].label == 1)
{
cells[0][0].label = 2;
cells[0][0].empty = false;
playerIsTurn = true;
numTurns++;
}else
{
if(cells[0][0].label == 1 && cells[0][2].label == 1 &&
cells[2][0].label == 1 && cells[2][2].label == 1)
{
cells[1][1].label = 2;
cells[1][1].empty = false;
playerIsTurn = true;
numTurns++;
}else if(cells[0][1].label == 1 && cells[1][2].label == 1 &&
cells[1][0].label == 1 && cells[2][1].label == 1)
{
cells[1][1].label = 2;
cells[1][1].empty = false;
playerIsTurn = true;
numTurns++;
}
}
}
во аи для крестиков ноликов часть1
+162
...
q = new double[50];
c = new double[50];
d = new double[50];
b = new double[50];
s11 = new double[50];
a4 = new double[50];
s1 = new double[50];
int c2 = 0;
for ( int i = 1; i < n1; i++)
{
h1[i] = a3[i] - a3[i-1];
}
for ( int i = 0; i < n1; i++)
{
f1[i] = sin(exp(a3[i]));
}
for ( int i = 1; i < k; i++)
{
al[i] = h1[i];
bet[i] = 2*(h1[i+1] + h1[i]);
gam[i] = h1[i+1];
fi[i] = 6*(((f1[i+1] - f1[i])/h1[i+1]) - ((f1[i] - f1[i-1])/h1[i]));
}
p[1] = 0;
q[1] = 0;
for ( int i = 1; i < k; i++)
{
p[i+1] = -(gam[i])/(bet[i] + al[i]*p[i]);
q[i+1] = (fi[i] - al[i]*q[i])/(bet[i] + al[i]*p[i]);
}
c[0] = 0.0;
c[k] = 0.0;
for ( int i = k-1; i > 0; i--)
{
c[i] = p[i+1]*c[i+1] + q[i+1];
}
for ( int i = 0; i < k; i++)
{
d[i+1] = (c[i] - c[i+1])/h1[i+1];
b[i+1] = ((f1[i] - f1[i+1])/h1[i+1]) - ((c[i+1]*h1[i+1])/2) - (((c[i] - c[i+1])*h1[i+1])/6);
}
for ( double j = 0.0; j <= 0.5; j = j + 0.1)
{
c2 = c2 + 1;
for ( int i = 1; i < 2; i++)
{
spkub = f1[i] + b[i]*(a3[i] - j) + ((c[i]*pow((a3[i] - j), 2))/2) + ((d[i]*pow((a3[i] - j), 3))/6);
}
for (int i = c2 - 1; i < c2; i++)
{
a4[i] = j;
s1[i] = spkub;
}
}
for ( double j = 0.5; j <= 0.7; j = j + 0.1)
{
c2 = c2 + 1;
for ( int i = 2; i < 3; i++)
{
spkub = f1[i] + b[i]*(a3[i] - j) + ((c[i]*pow((a3[i] - j), 2))/2) + ((d[i]*pow((a3[i] - j), 3))/6);
}
for (int i = c2 - 1; i < c2; i++)
{
a4[i] = j;
s1[i] = spkub;
}
}
........
for ( double j = 1.4; j <= 1.6; j = j + 0.1)
{
c2 = c2 + 1;
for ( int i = 5; i < 6; i++)
{
spkub = f1[i] + b[i]*(a3[i] - j) + ((c[i]*pow((a3[i] - j), 2))/2) + ((d[i]*pow((a3[i] - j), 3))/6);
}
for (int i = c2 - 1; i < c2; i++)
{
a4[i] = j;
s1[i] = spkub;
}
}
for ( double j = 1.7; j <= 2.0; j = j + 0.1)
{
c2 = c2 + 1;
for ( int i = 6; i < 7; i++)
{
spkub = f1[i] + b[i]*(a3[i] - j) + ((c[i]*pow((a3[i] - j), 2))/2) + ((d[i]*pow((a3[i] - j), 3))/6);
}
for (int i = c2 - 1; i < c2; i++)
{
a4[i] = j;
s1[i] = spkub;
}
}
for ( int i = 0; i < c2; i++)
{
chart1 -> Series["Кубический сплайн S(x)"] -> Points -> AddXY( a4[i], s1[i]);
}
Построение кубического сплайна
+999
template<class TVisitedComponentList>
TUniqueIDOfVisitedComponentList getUniqueIDOfVisitedComponentTypeList(void)
{
static Type2Type<TVisitedComponentList> UniqueObjectForVisitedComponentTypeList;
return (size_t)(&UniqueObjectForVisitedComponentTypeList);
}
template<class TVisitedComponentList>
TCastWindowComponentTo* const castWindowComponentInternal(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
STATIC_CHECK(!(boost::mpl::empty<TVisitedComponentList>::value), TVisitedComponentList_must_be_not_empty_and_be__boost_mpl_list_c__type);
const TUniqueIDOfVisitedComponentList UniqueIDOfVisitedComponentList=this->getUniqueIDOfVisitedComponentTypeList<TVisitedComponentList>();
const TCasterRepositorys::const_iterator NotFound=_casterRepositorys.end();
TCasterRepositorys::const_iterator findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
if(findedCasterRepositoryForThisVisitedComponentList==NotFound)
{
this->registerVisitedComponentList<TVisitedComponentList>();
findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
}
ASSERT(findedCasterRepositoryForThisVisitedComponentList!=NotFound);
const TCasterRepository::const_iterator NotFoundCaster=findedCasterRepositoryForThisVisitedComponentList->second->end();
const unsigned int ComponentType=const_cast<PegThing* const>(Window)->Type();
const TCasterRepository::const_iterator findedCaster=findedCasterRepositoryForThisVisitedComponentList->second->find(ComponentType);
if(findedCaster==NotFoundCaster)
return NULL;
ASSERT(findedCaster!=NotFoundCaster);
return (*(findedCaster->second))(Window);
}
template<class TCurrentItem, class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TCurrentItem CurrentItem, TEnd End)
{
using namespace boost;
enum {WINDOW_COMPONENT_TYPE=mpl::deref<TCurrentItem>::type::value};
STATIC_CHECK((mpl::has_key<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::value!=0), WINDOW_COMPONENT_TYPE_must_be_at_TWindowComponentsTypeIdToTypeMap);
typedef mpl::at<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::type TRealTypeOfWindowComponent;
this->checkDuplicateComponentTypeID(WINDOW_COMPONENT_TYPE, casterRepository);
struct _
{
static TCastWindowComponentTo* const casterForEachWindowComponent(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
TRealTypeOfWindowComponent* const RealTypeComponent = static_cast<TRealTypeOfWindowComponent* const>(Window);
ASSERT(RealTypeComponent!=NULL);
TCastWindowComponentTo* const FinalCastedWindowComponent = static_cast<TCastWindowComponentTo* const >(RealTypeComponent);
ASSERT(FinalCastedWindowComponent!=NULL);
return FinalCastedWindowComponent;
}
};
TCasterForEachWindowComponent CasterForEachWindowComponentFunction=&(_::casterForEachWindowComponent);
this->checkDuplicateType(CasterForEachWindowComponentFunction, casterRepository);
casterRepository[WINDOW_COMPONENT_TYPE]=CasterForEachWindowComponentFunction;
registerVisitedComponentListItem(casterRepository, mpl::next<TCurrentItem>::type(), TEnd());
}
template<class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TEnd CurrentItem, TEnd End)
{}
Код из того же большого проекта.
Ассерты после static_cast и "шаблонная магия" особенно доставляют.
Мне конечно boost::mpl нравиться, но я считаю, что его негоже использовать в реальных проектах.
+163
THTTPServer::TDynamicResponse::~TDynamicResponse( void )
{
if(typeid(*this)==typeid(TDynamicResponse))//Борьба с pure virtual function call.
this->flush();
};
Проект поменьше.