- 1
 - 2
 - 3
 - 4
 - 5
 
#include "alloca.h"
//...
template<class o>
o*MakeOAtStack(){
return (o*)alloca(sizeof(o));};//;;;Оптимизировоной operator new nothrow
                                    Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+166
#include "alloca.h"
//...
template<class o>
o*MakeOAtStack(){
return (o*)alloca(sizeof(o));};//;;;Оптимизировоной operator new nothrow
                                    
+161
String str=String::Format("a=<^>, b=<^>, c=\"<^>\"")(a)(b, 4)(c);  //str будет равно: a=234, b=32422.1231, c="Текст"
str=String::Format(nullptr)(a)("+")(b, 4)("=")(a+b, 4);  //str будет равно: 234+32422.1231=32656.1231
str=String::Format("<^><^>")(5);  //Выбрасывает исключение, так как переданы не все аргументы
str=String::Format("<^>")(3252)(3.1415926);  //Выбрасывает исключение, так как передан лишний аргумент
                                    
            Форматирование строк с помощью смайликов.
http://www.gamedev.ru/code/forum/?id=148200&page=4#m55
        
        
        
        +158
DWORD WINAPI SexToClient(LPVOID client_socket) // Поток для клиента 
{ 
SOCKET my_sock; 
my_sock=((SOCKET *) client_socket)[0]; 
char buffer[1024] = {0}; 
int ral;
while(1){ 
ral =recv (my_sock,&buffer[0],sizeof(buffer), 0); 
if(ral == SOCKET_ERROR) 
{std::cout << "хуй" << "\n";} 
else{ 
std::cout << buffer << "\n"; 
} 
}
closesocket(my_sock); 
return 0; 
}
                                    
http://www.gamedev.ru/code/forum/?id=151671
        
        
        
        +166
int32 chance; 
	
if (SkillValue <= 115)
{
    chance = 100;
}
else if (SkillValue > 115 && SkillValue <= 150)
{
    chance = 50;
}
else if (SkillValue > 150 && SkillValue <= 170)
{
    chance = 33,33;
}
else if (SkillValue > 170 && SkillValue <= 190)
{
    chance = 25;
}
else if (SkillValue > 190 && SkillValue <= 215)
{
    chance = 20;
}
else if (SkillValue > 215 && SkillValue <= 235)
{
    chance = 16,67;
}
else if (SkillValue > 235 && SkillValue <= 260)
{
    chance = 14,29;
}
else if (SkillValue > 260 && SkillValue <= 280)
{
    chance = 12,5;
}
else if (SkillValue > 280 && SkillValue <= 325)
{
    chance = 11,11;
}
else if (SkillValue > 325 && SkillValue <= 365)
{
    chance = 10;
}
else if (SkillValue > 365 && SkillValue <= 450)
{
    chance = 9,09;
}
else if (SkillValue > 450 && SkillValue <= 500)
{
    chance = 11,11;
}
else if (SkillValue > 500)
{
    chance = 10;
}
                                    Формулы? Нет, не слышал.
+163
/* allocate memory for the extended format buffer */
  extFormat = new char [ strlen( format ) +
                         strlen( "\n" )   +
                         1 ];
  if ( (char*)0 != extFormat )
  {
    /* extend format info */
    sprintf ( extFormat, "%s", format );
    strcat  ( extFormat, "\n" );
  }
                                    из реализации логгера. просто нет слов.
+147
void  Character::getWalkScreenDirection(SPVector& dst) {
	float stick_y = 0.0f, stick_x = 0.0f;
	/*if(isPadMove())*/	{
		stick_y = getOffsetLY();
		stick_x = getOffsetLX();
	}/*else*/{
		//stick_y =  angleAC_DIRECTION[animator.animation.getDirection()][0];
		//stick_x =  angleAC_DIRECTION[animator.animation.getDirection()][1];
		/*
		if(stick_y == 0 && stick_x == 0){
			animator.animation.set(AC_DIRECTION_NONE);   // stop walking
			animator.animation.set(AC_MOVEMENT_IDLE);
			animator.animation.update();
		}*/	}
  dst.asg(0,0,0);
  /* if(animator.animation.getDirection() == AC_DIRECTION_NONE){  
    //CameraCore* camera = game.get_camera();
    camera = game.get_camera();
    cam_up = camera->up();
    SPVector up_tmp = camera->up();
    SPVector look = camera->look();
    SPVector look_tmp = camera->look();
    cam_right = up_tmp.cross(look_tmp);    
    return;
  } */
  SPPosition current; 
  model.getRootPose(current);
  bool isRun = this->isRun();
  if(animator.getTarget()){
    if(animator.getTarget()->get_run(current, isRun)){ // run stance can overwrite depend from target
    state(CharacterFlags_MODE_SWAPRUN, true);
    state(CharacterFlags_MODE_RUN,isRun);
    }
  }  
  CameraCore* camera_compare = game.get_camera(); 
  SPVector cam_compare_pos = camera_compare->pos();
  if(cam_compare_pos != cam_pos) {
    if(first_time) {
      cam_time = game.time.system.current_value(1); 
      cam_time /= 1000;
      first_time = false;      
      first_stick_x = stick_x;  //premiere fois : on rйcup la position du stick en x et y
      first_stick_y = stick_y;
    }
    double move_time = game.time.system.current_value(1);
    move_time /= 1000;
    if(move_time - cam_time < delta_time) {
      //stick_y = first_stick_y; 
      //stick_x = first_stick_x;  
      /*if(dst.len() != 0)
      {
      //animator.animation.set(AC_DIRECTION_FORWARD);  // for the animation
      animator.animation.enable(true);
      animator.animation.set(isRun?AC_MOVEMENT_RUN:AC_MOVEMENT_WALK);
      dst.norm();
      model.setDirection(dst);                     // facing the direction
      }  
      return;*/
    }
  }
  if(stick_y==0 && stick_x==0) initializeCameraAxis();
  SPVector new_direction;
  new_direction.asg(stick_x, 0, stick_y);
  if(new_direction.len() != 0)  new_direction.norm();
  if(direction_reference.len() != 0)  direction_reference.norm();
  float scalar_product = new_direction.dot(direction_reference);
  if(fabs(scalar_product) <= delta) {
    direction_reference.asg(new_direction);
    initializeCameraAxis();
  }  
  if(cam_compare_pos == cam_pos || (cam_compare_pos != cam_pos && fabs(scalar_product) <= delta)) {
    first_time = true;
    SPVector up = cam_up;
    SPVector right = cam_right;
    up.y = 0;
    right.y = 0;    
//     CameraCore* camera_2 = game.get_camera();    //rйtablissement d'une camйra inversйe
//     SPPosition pos_test = camera_2->sview();
//     SPVector vec_test = pos_test.c;    
    SPVector vec_test = cam_pos;
    SPVector vec_stock;
    vec_stock.asg(69.8761444,2.45131993,117.599548);
    if(vec_test.equal(vec_stock,0.0000001f)) {
      up.x = - up.x;
      up.z = - up.z;
    }
    ////////////////
    if(up.len() != 0)  up.norm();
    if(right.len() != 0) right.norm();
    up *= stick_y;
    right *= stick_x;
    dst = up;                                              // update destination vector
    dst += right;  // i.e. dst = up + right 
   if(dst.len() != 0)  {
     //animator.animation.set(AC_DIRECTION_FORWARD);  // for the animation
     animator.animation.enable(true);
     animator.animation.set(isRun?AC_MOVEMENT_RUN:AC_MOVEMENT_WALK);
     dst.norm();
     model.setDirection(dst);                     // facing the direction
   }
                                    
            Такой код в нашем движке.
ЗЫ. Код немного ужат, так как не помещался в 100 строк.
        
+159
Obj = 0;
  while (dsmodel1.tellg () < LEN)
  {
    dsmodel1.read ( (char*)&ID, 2);
    dsmodel1.read ( (char*)&length, 4);
    switch (ID)
    {
    case 0x4d4d: break;
    case 0xb000: break;
    case 0xb002: break;
    case 0xb010: 
      char ch;
            do
            {
                dsmodel1.read ( (char*)&ch, 1);
            }while (ch != '\0' && !dsmodel1.eof ());
      dsmodel1.ignore (4);
      dsmodel1.read ( (char*)&father_id [Obj], 2); // айди родительского объекта в иерархии
      break;
    case 0xb013:
      dsmodel1.read ( (char*)&(pivot [Obj].x), 4);   //координаты точки, вокруг которой будет вращаться объект
      dsmodel1.read ( (char*)&(pivot [Obj].y), 4);
      dsmodel1.read ( (char*)&(pivot [Obj].z), 4);
      break;
    case 0xb020:                                                                             // это поле описывает перенос объекта
      dsmodel1.ignore (10);
      number_of_keys [Obj] = new DWORD;
      dsmodel1.read ( (char*)&(number_of_keys [Obj][0]), 4);  //сколько кадров анимации будет у объекта
      key_number [Obj] = new DWORD [number_of_keys [Obj][0]];
      frameTran [Obj] = new D3DXVECTOR3 [number_of_keys [Obj][0]];
      how_much_to_ignore = 0;
      accel_flags = 0;
      for (i = 0; i < number_of_keys [Obj][0]; i++)
      {
        dsmodel1.read ( (char*)&(key_number [Obj][i]), 4);  
        dsmodel1.read ( (char*)&(accel_flags), 2);              //это флаги сплайнов, в этом примере всегда = 0
        if (accel_flags && (1 << 15)) how_much_to_ignore++;
        if (accel_flags && (1 << 14)) how_much_to_ignore++;
        if (accel_flags && (1 << 13)) how_much_to_ignore++;
//...
 dsmodel1.read ( (char*)&(frameRot [Obj][i].y), 4);    // как я понял он должен быть помещен в точку pivot (она считывалась выше в поле 0хb013)
//...
case 0xb030:
      dsmodel1.read ( (char*)&(hierarchy_id [Obj]), 2);            // номер объекта в иерархии, в нашем примере = номеру объекта по порядку считывания
                                    
            Полный код:
http://www.gamedev.ru/code/forum/?id=151570
        
        
        
        +164
FrmCabinetFound *frm = new FrmCabinetFound(index.data(Qt::UserRole).toInt());
    ((QMdiArea*)this->parent()->parent()->parent())->addSubWindow(frm);
    frm->show();
                                    
+167
char *sLoop = new char[4];
_itoa(i, sLoop, 10);
string strField = fp1 + sLoop + fp2;
char *str = new char[255];
for (int i=0; i<=sizeof(strField); i++)
    str[i] = strField[i];
_bstr_t impFieldName(str);
// думаю, очевдно, что delete нигде не было. ;)
                                    
+144
class GameDevTroll:public Troll{};
GameDevTroll TarasB;
TarasB.throwIn( Url("Какие проблемы в данных отрывках кода? (5 стр)") );
                                    
http://www.gamedev.ru/flame/forum/?id=150336&page=5#m65