- 1
uint8_t value = arg & 1 ? arg ^ 1 : arg;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 27
+144
uint8_t value = arg & 1 ? arg ^ 1 : arg;
+142
void BloomPattern::process(GLuint rectangleVao, float blurRadius) const
{
sptrFrameBufferTwo->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sptrBrightPassShaderProgram->enable();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferThree->getColorTexture().getTexture());
sptrBrightPassShaderProgram->setUniform("colorTexture", 0);
glBindVertexArray(rectangleVao);
glViewport(0, 0, windowWidth >> 1, windowHeight >> 1);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
sptrFrameBufferOne->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sptrBlurShaderProgram->enable();
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferTwo->getColorTexture().getTexture());
sptrBlurShaderProgram->setUniform("defaultTexture", 0);
sptrBlurShaderProgram->setUniform("blurRadius", 1.0F / (windowWidth >> 1), 0.0F, blurRadius);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
sptrFrameBufferTwo->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferOne->getColorTexture().getTexture());
sptrBlurShaderProgram->setUniform("defaultTexture", 0);
sptrBlurShaderProgram->setUniform("blurRadius", 0.0F, 1.0F / (windowHeight >> 1), blurRadius);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
sptrFinalFrameBuffer->enable();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
sptrBloomShaderProgram->enable();
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferThree->getColorTexture().getTexture());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, sptrFrameBufferTwo->getColorTexture().getTexture());
sptrBloomShaderProgram->setUniform("defaultTexture", 0);
sptrBloomShaderProgram->setUniform("brightpassTexture", 1);
glViewport(0, 0, windowWidth, windowHeight);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
+54
void Game::initialize()
{
if (SDL_Init(SDL_INIT_VIDEO))
exit(1);
window = new Window("Game", 640, 480);
try
{
window->create();
}
catch (const Exception& exception)
{
std::cout << exception.getError() << '\n';
delete window;
exit(1);
}
canvas = new Canvas();
try
{
canvas->initialize(window->getWindow());
}
catch (const Exception& exception)
{
std::cout << exception.getError() << '\n';
delete canvas;
exit(1);
}
}
+131
std::string new_artifact()
{
if (one_in(2)) { // Generate a "tool" artifact
it_artifact_tool *art = new it_artifact_tool();
int form = rng(ARTTOOLFORM_NULL + 1, NUM_ARTTOOLFORMS - 1);
artifact_tool_form_datum *info = &(artifact_tool_form_data[form]);
art->create_name(info->name);
art->color = info->color;
art->sym = info->sym;
art->materials.push_back(info->material);
art->volume = rng(info->volume_min, info->volume_max);
art->weight = rng(info->weight_min, info->weight_max);
// Set up the basic weapon type
artifact_weapon_datum *weapon = &(artifact_weapon_data[info->base_weapon]);
art->melee_dam = rng(weapon->bash_min, weapon->bash_max);
art->melee_cut = rng(weapon->cut_min, weapon->cut_max);
art->m_to_hit = rng(weapon->to_hit_min, weapon->to_hit_max);
if( weapon->tag != "" ) {
art->item_tags.insert(weapon->tag);
}
// Add an extra weapon perhaps?
if (one_in(2)) {
int select = rng(0, 2);
if (info->extra_weapons[select] != ARTWEAP_NULL) {
weapon = &(artifact_weapon_data[ info->extra_weapons[select] ]);
art->volume += weapon->volume;
art->weight += weapon->weight;
art->melee_dam += rng(weapon->bash_min, weapon->bash_max);
art->melee_cut += rng(weapon->cut_min, weapon->cut_max);
art->m_to_hit += rng(weapon->to_hit_min, weapon->to_hit_max);
if( weapon->tag != "" ) {
art->item_tags.insert(weapon->tag);
}
std::stringstream newname;
newname << weapon->adjective << " " << info->name;
art->create_name(newname.str());
}
}
// CHOP is a sword, STAB is a dagger
if( art->item_tags.count( "CHOP" ) > 0 ) {
art->item_tags.insert( "SHEATH_SWORD" );
}
if( art->item_tags.count( "STAB" ) > 0 ) {
art->item_tags.insert( "SHEATH_KNIFE" );
}
art->description = string_format(
_("This is the %s.\nIt is the only one of its kind.\nIt may have unknown powers; try activating them."),
art->nname(1).c_str());
// Finally, pick some powers
art_effect_passive passive_tmp = AEP_NULL;
art_effect_active active_tmp = AEA_NULL;
int num_good = 0, num_bad = 0, value = 0;
std::vector<art_effect_passive> good_effects = fill_good_passive();
std::vector<art_effect_passive> bad_effects = fill_bad_passive();
// Wielded effects first
while (!good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
(num_good < 1 || num_bad < 1 || one_in(num_good + 1) ||
one_in(num_bad + 1) || value > 1)) {
if (value < 1 && one_in(2)) { // Good
int index = rng(0, good_effects.size() - 1);
passive_tmp = good_effects[index];
good_effects.erase(good_effects.begin() + index);
num_good++;
} else if (!bad_effects.empty()) { // Bad effect
int index = rng(0, bad_effects.size() - 1);
passive_tmp = bad_effects[index];
bad_effects.erase(bad_effects.begin() + index);
num_bad++;
}
value += passive_effect_cost[passive_tmp];
art->effects_wielded.push_back(passive_tmp);
}
// Next, carried effects; more likely to be just bad
num_good = 0;
num_bad = 0;
value = 0;
good_effects = fill_good_passive();
bad_effects = fill_bad_passive();
while (one_in(2) && !good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
((num_good > 2 && one_in(num_good + 1)) || num_bad < 1 ||
one_in(num_bad + 1) || value > 1)) {
if (value < 1 && one_in(3)) { // Good
int index = rng(0, good_effects.size() - 1);
passive_tmp = good_effects[index];
good_effects.erase(good_effects.begin() + index);
num_good++;
} else { // Bad effect
int index = rng(0, bad_effects.size() - 1);
passive_tmp = bad_effects[index];
bad_effects.erase(bad_effects.begin() + index);
num_bad++;
}
value += passive_effect_cost[passive_tmp];
art->effects_carried.push_back(passive_tmp);
+94
MenuGame extends GameMenu
+71
newMatrix.setElement(newMatrix.getElement(i, j) + getElement(i, k) * matrix.getElement(k, j), i, j);
Профессиональный говнокод.
+78
public static void create(String title, int width, int height) {
if (isWindowCreated())
throw new RuntimeException("Window created.");
if (title == null)
throw new NullPointerException("Window title == null.");
if (width <= 0 || height <= 0)
throw new IllegalArgumentException("Window size <= 0.");
if ((window = GLFW.glfwCreateWindow(width, height, title, MemoryUtil.NULL, MemoryUtil.NULL)) == MemoryUtil.NULL)
throw new RuntimeException("Failed to create the GLFW window.");
}