- 1
- 2
- 3
- 4
- 5
- 6
- 7
function GetBit(numBit,Val: integer):boolean;
var
i: integer;
begin
i := round(power(2,numBit-1));
result := (i and Val) >0;
end;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+101
function GetBit(numBit,Val: integer):boolean;
var
i: integer;
begin
i := round(power(2,numBit-1));
result := (i and Val) >0;
end;
Суровые и беспощадные битовые операции в дельфи. Причем коллега, у которого я это нашел неплохие программы пишет, во всяком случае по части удобства интерфейса мне до него далеко. Но иногда такие перлы встречаются.
+17
// base class for objects that need to be initialized
//
struct Initializable
{
protected:
inline void OneTimeInit()
{
#if _DEBUG_BUILD
ASSERT(!m__hasBeenIsInitialized);
m__hasBeenIsInitialized = true;
#endif // _DEBUG_BUILD
}
inline void OneTimeDestroy()
{
#if _DEBUG_BUILD
ASSERT(m__hasBeenIsInitialized);
m__hasBeenIsInitialized = false;
#endif // _DEBUG_BUILD
}
inline void CheckInitialized()
{
#if _DEBUG_BUILD
mxBREAK_IF( !m__hasBeenIsInitialized );
#endif // _DEBUG_BUILD
}
inline Initializable()
{
#if _DEBUG_BUILD
m__hasBeenIsInitialized = false;
#endif // _DEBUG_BUILD
}
inline ~Initializable()
{
#if _DEBUG_BUILD
ASSERT(!m__hasBeenIsInitialized);
#endif // _DEBUG_BUILD
}
private:
#if _DEBUG_BUILD
bool m__hasBeenIsInitialized;
#endif // _DEBUG_BUILD
};
template< class KLASS > // where KLASS : TGlobal<KLASS>, Initializable
struct DependsOn
{
protected:
DependsOn()
{
ASSERT( KLASS::HasInstance() );
ASSERT( KLASS::Get().IsInitialized() );
}
};
template< class KLASS > // where KLASS : TGlobal<KLASS>
struct DependsOnGlobal
{
protected:
DependsOnGlobal()
{
ASSERT( KLASS::HasInstance() );
//ASSERT( KLASS::Get().IsInitialized() );
}
};
Базовый класс для дебажной проверки того, был ли инициализирован конкретный объект.
Этот бред находился в самой древней кодобазе, сейчас нигде не используется. Удаляю.
+166
window.__debugMode = true; // Don't turn it off
vk.com/js/al/common.js
+87
delim:=0;
result:='';
resulttemp:='';
otv1:=trunc(rez);
ott2:=rez-otv1;
while otv1>=s1 do
begin
delim:=delim+1;
r1:=otv1 div s1;
r2:=otv1 mod s1;
otv1:=r1;
if (r2>=0) and (r2<=9) then
str(r2,resulttemp);
if r2=10 then resulttemp:='a';
if r2=11 then resulttemp:='b';
if r2=12 then resulttemp:='c';
if r2=13 then resulttemp:='d';
if r2=14 then resulttemp:='e';
if r2=15 then resulttemp:='f';
result:=result+resulttemp;
end;
if (otv1>=0) and (otv1<=9) then
str(otv1,resulttemp);
if otv1=10 then resulttemp:='a';
if otv1=11 then resulttemp:='b';
if otv1=12 then resulttemp:='c';
if otv1=13 then resulttemp:='d';
if otv1=14 then resulttemp:='e';
if otv1=15 then resulttemp:='f';
result:=result+resulttemp;
delim:=length(result);
resulttemp:=result;
for otv1:=1 to delim do
result[otv1]:=resulttemp[delim+1-otv1];
Перевод числа из десятичной системы счисления в систему счисления с основанием s1
+133
if (other && other->client && other->s.number < MAX_CLIENTS)
{//player touched me
/*
char *text;
qboolean keyTaken;
//give him my key
...
*/
//rwwFIXMEFIXME: support for goodie/security keys?
/*
if ( keyTaken )
{//remove my key
NPC_SetSurfaceOnOff( self, "l_arm_key", 0x00000002 );
self->message = NULL;
//FIXME: temp pickup sound
G_Sound( player, G_SoundIndex( "sound/weapons/key_pkup.wav" ) );
//FIXME: need some event to pass to cgame for sound/graphic/message?
}
//FIXME: temp message
gi.SendServerCommand( NULL, text );
*/
}
FIXMEFIXMEFIXME... Да ну нахуй, лучше все закомментим.
+154
var SE = document.getElementsByTagName("a");
for (var i = 0; i < SE.length; i++)
{
if (SE[i].href.indexOf('http://www.govnokod.ru/ratings/comment/') == 0
&& SE[i].href.indexOf('on') != -1)
{
plusIT(SE[i].href);
console.log(SE[i].href);
}
}
function plusIT(ID)
{
$.get(
ID,
{},
function(x) {
});
}
+72
public boolean fastItemEquals(ItemStack st, ItemStack nd) {
if(nd == null) return false;
if(st.hashCode() != nd.hashCode()) return false;
if(st.getType() != nd.getType()) return false;
if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
final List<String>
lst = st.getItemMeta().getLore(),
lnd = nd.getItemMeta().getLore();
for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
if(!lst.get(i).equals(lnd.get(i))) return false;
//return st.isSimilar(nd);
return true;
}
public void fastItemRemove(Inventory inv, ItemStack st) {
for(int i = 0 ; i < inv.getContents().length ; i++)
if(fastItemEquals(st, inv.getContents()[i])) inv.clear(i);
}
+72
public boolean fastItemEquals(ItemStack st, ItemStack nd) {
if(st.hashCode() == nd.hashCode()) return true;
if(st.getType() != nd.getType()) return false;
if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
final List<String>
lst = st.getItemMeta().getLore(),
lnd = nd.getItemMeta().getLore();
for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
if(!lst.get(i).equals(lnd.get(i))) return false;
//return st.isSimilar(nd);
return true;
}
/* оригинал
@Override
public boolean isSimilar(ItemStack stack) {
if (stack == null) {
return false;
}
if (stack == this) {
return true;
}
if (!(stack instanceof CraftItemStack)) {
return stack.getClass() == ItemStack.class && stack.isSimilar(this);
}
CraftItemStack that = (CraftItemStack) stack;
if (handle == that.handle) {
return true;
}
if (handle == null || that.handle == null) {
return false;
}
if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
return false;
}
return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
}
*/
+68
public boolean fastItemEquals(ItemStack st, ItemStack nd) {
if(st.hashCode() == nd.hashCode()) return true;
if(st.getType() != nd.getType()) return false;
if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
if(st.getItemMeta().getLore().size() != nd.getItemMeta().getLore().size()) return false;
List<String>
lst = st.getItemMeta().getLore(),
lnd = nd.getItemMeta().getLore();
for(int i = 0 ; i < st.getItemMeta().getLore().size() ; i++)
if(!lst.get(i).equals(lst.get(i))) return false;
//return st.isSimilar(nd);
return true;
}
/* оригинал
@Override
public boolean isSimilar(ItemStack stack) {
if (stack == null) {
return false;
}
if (stack == this) {
return true;
}
if (!(stack instanceof CraftItemStack)) {
return stack.getClass() == ItemStack.class && stack.isSimilar(this);
}
CraftItemStack that = (CraftItemStack) stack;
if (handle == that.handle) {
return true;
}
if (handle == null || that.handle == null) {
return false;
}
if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
return false;
}
return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
}
*/
+70
public boolean fastItemEquals(ItemStack st, ItemStack nd) {
if(st.hashCode() != nd.hashCode()) return false;
if(st.getType() != nd.getType()) return false;
if(!st.getItemMeta().getDisplayName().equals(nd.getItemMeta().getDisplayName())) return false;
if(st.getEnchantments().size() != nd.getEnchantments().size()) return false;
//return st.isSimilar(nd);
return true;
}
/* оригинал
@Override
public boolean isSimilar(ItemStack stack) {
if (stack == null) {
return false;
}
if (stack == this) {
return true;
}
if (!(stack instanceof CraftItemStack)) {
return stack.getClass() == ItemStack.class && stack.isSimilar(this);
}
CraftItemStack that = (CraftItemStack) stack;
if (handle == that.handle) {
return true;
}
if (handle == null || that.handle == null) {
return false;
}
if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
return false;
}
return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
}
*/