- 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
+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 строк.
+64
boolean i = true;
while (i){
out.println("\n");
}
Нашлось в недрах работающей программы
+147
var that = this;
просто и со вкусом
+133
if (ID_Pers == (decimal)r["Код_ФизЛица"])
query = new SqlCommand("UPDATE СписокФизическихЛиц SET ДатаРождения=CONVERT(DateTime,'" + Date + "',104) where ID='" + r["Код_ФизЛица"].ToString() + "'", conn);
else
query = new SqlCommand("UPDATE СписокФизическихЛиц SET ДатаРождения=CONVERT(DateTime,'" + Date + "',104) where ID='" + ID_Pers.ToString() + "'", conn);
Классический говнокод.
+178
#define float double
Так в последнем, полученном мною, для поддержки проекте произвели увеличение точности расчётов.
+139
char *reg = data;
char *temp = "blahblah is ";
strcat(temp,(const char*)"reg[4]");
Как оказывается на Си можно конкатенировать строки
−854
if rtrim(@parent_ID) = null
select '' as Parent_ID, '' as Parent_Name where 1 = 2
else
select isnull(@parent_ID, '') as Parent_ID, isnull(@parent_name, '') as Parent_Name
+72
package com.uva.concurrent;
import com.uva.log.Log;
import com.uva.log.Message;
public class ThreadExecutor implements Executor {
private final String name;
public ThreadExecutor(String name) {
this.name = name;
}
public void execute(Runnable target) {
new Thread(target, name).start();
}
/** Execute given runnable in separate thread. All exceptions will be caught.
* @param runnable - runnable to execute. */
public void executeSilent(final Runnable runnable) {
new Thread() {
public void run() {
try {
runnable.run();
}
catch (RuntimeException e) {
Log.exception(name, Message.CRITICAL_ERROR, e);
throw e;
}
}
}.start();
}
}
Junior пишет весьма ThreadPoolExecutor для BlackBerry.
+147
urldecode($_POST['name'])
Нашел у себя в коде.