id stringlengths 27 29 | content stringlengths 226 3.24k |
|---|---|
codereview_new_cpp_data_788 | int main(int argc, char** argv, char** envp)
exit(1);
}
- dserver_rpc_set_executable_path(filename, strlen(filename));
-
start_thread(&mldr_load_results);
__builtin_unreachable();
Error handling, just in case (which is just exiting since we can't actually do anything without the server):
```suggestion
... |
codereview_new_cpp_data_789 | static bool parse_smaps_firstline(
static long _proc_pidinfo_pathinfo(int32_t pid, void* buffer, int32_t bufsize)
{
struct vchroot_unexpand_args args;
- int rv = dserver_rpc_get_executable_path(pid, args.path, sizeof(args.path));
- if (rv < 0)
- return rv;
rv = vchroot_unexpand(&args);
if (rv != 0)
Lik... |
codereview_new_cpp_data_832 |
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.9.9 */
-
-#include "sessions.nanopb.h"
//#include "FirebaseSessions/SourcesObjC/Protogen/nanopb/sessions.nanopb.h"
This needs to be resolved - do we generate #ifs?
/* Automatically generated nanopb constant definitions *... |
codereview_new_cpp_data_871 |
/*
- * Copyright 2019 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
```suggestion
* Copyright 2022 Google LLC
```
/*
+ * Copyright 2022 Google
*
* Licensed under the Apache License, Version 2.0 (the "Licen... |
codereview_new_cpp_data_872 |
/*
- * Copyright 2019 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
```suggestion
* Copyright 2022 Google LLC
```
/*
+ * Copyright 2022 Google
*
* Licensed under the Apache License, Version 2.0 (the "Licen... |
codereview_new_cpp_data_957 | bool ksdl_dladdr(const uintptr_t address, Dl_info* const info)
for(uint32_t iSym = 0; iSym < symtabCmd->nsyms; iSym++)
{
- // When building with Xcode 14, symbol which n_type field equal
- // to N_ENSYM will put the actual address to n_value field, see
- ... |
codereview_new_cpp_data_958 | bool ksdl_dladdr(const uintptr_t address, Dl_info* const info)
for(uint32_t iSym = 0; iSym < symtabCmd->nsyms; iSym++)
{
// Skip all debug N_STAB symbols
- if ((symbolTable[iSym].n_type & N_STAB) > 0)
{
continue;
... |
codereview_new_cpp_data_959 | bool ksobjc_ivarValue(const void* const objectPtr, int ivarIndex, void* dst)
return false;
}
uintptr_t ivarPtr = (uintptr_t)&ivars->first;
- const struct ivar_t *ivar = (void *)(ivarPtr + (uintptr_t)ivars->entsizeAndFlags * (uintptr_t)ivarIndex);
uintptr_t valuePtr = (uintptr_t)objectP... |
codereview_new_cpp_data_1990 | Java_com_duckduckgo_sync_crypto_SyncNativeLib_encrypt(
);
// Release the input arrays
- (*env)->ReleaseByteArrayElements(env, encryptedBytes, encryptedBytesElements, JNI_ABORT);
- (*env)->ReleaseByteArrayElements(env, rawBytes, rawBytesElements, JNI_COMMIT);
(*env)->ReleaseByteArrayElements(env,... |
codereview_new_cpp_data_1991 | DDGSyncCryptoResult ddgSyncEncrypt(
return DDGSYNCCRYPTO_ENCRYPTION_FAILED;
}
- memcpy(&encryptedBytes[rawBytesLength + crypto_secretbox_MACBYTES], nonceBytes, crypto_secretbox_NONCEBYTES);
return DDGSYNCCRYPTO_OK;
}
We can discard this change
DDGSyncCryptoResult ddgSyncEncrypt(
... |
codereview_new_cpp_data_2209 | std::string py_fetch_error() {
// build error text
std::ostringstream oss;
for (Py_ssize_t i = 0, n = PyList_Size(formatted); i < n; i++)
oss << as_std_string(PyList_GetItem(formatted, i));
std::string error = oss.str();
- int max_msg_len(Rf_asInteger(Rf_GetOption1(Rf_install("warning.length"))... |
codereview_new_cpp_data_2210 | std::string py_fetch_error() {
// build error text
std::ostringstream oss;
for (Py_ssize_t i = 0, n = PyList_Size(formatted); i < n; i++)
oss << as_std_string(PyList_GetItem(formatted, i));
std::string error = oss.str();
- int max_msg_len(Rf_asInteger(Rf_GetOption1(Rf_install("warning.length"))... |
codereview_new_cpp_data_2264 | double integer_to_real(int x) {
}
void deprecate_to_char(const char* type_char) {
- SEXP env = PROTECT(caller_env());
SEXP type = PROTECT(Rf_mkString(type_char));
SEXP fun = PROTECT(Rf_lang3(Rf_install(":::"), Rf_install("purrr"), Rf_install("deprecate_to_char")));
SEXP call = PROTECT(Rf_lang3(fun, typ... |
codereview_new_cpp_data_2349 | SEXP pluck_impl(SEXP x, SEXP index, SEXP missing, SEXP strict_arg) {
end:
UNPROTECT(1);
- return Rf_isNull(x) ? missing : x;
}
We usually do:
```suggestion
return x == R_NilValue ? missing : x;
```
SEXP pluck_impl(SEXP x, SEXP index, SEXP missing, SEXP strict_arg) {
end:
UNPROTECT(1);
+ ... |
codereview_new_cpp_data_2840 | r_obj* expr_vec_zap_srcref(r_obj* x) {
attrib_zap_srcref(x);
r_ssize n = r_length(x);
for (r_ssize i = 0; i < n; ++i) {
- r_list_poke(x, i, zap_srcref(r_list_get(x, i)));
}
FREE(1);
Super minor, could use `v_x[i]` if you wanted, instead of `r_list_get()`
r_obj* expr_vec_zap_srcref(r_obj* x) {
... |
codereview_new_cpp_data_2841 | enum is_number dbl_standalone_check_number(r_obj* x,
}
}
- if (!r_as_bool(allow_decimal) && !r_dbl_is_decimal(value)) {
return IS_NUMBER_false;
}
I guess we rely on these not being missing values. Seems reasonable because that would be a programmer mistake
enum is_number dbl_standalone_check_nu... |
codereview_new_cpp_data_2842 |
#include <rlang.h>
-r_obj* ffi_standalone_check_is_bool(r_obj* x,
- r_obj* allow_na,
- r_obj* allow_null) {
if (x == r_null) {
return r_lgl(r_as_bool(allow_null));
}
It does make me wonder if we should version them to begin with?
L... |
codereview_new_cpp_data_2844 | r_obj* hash_value(XXH3_state_t* p_xx_state) {
XXH64_hash_t high = hash.high64;
XXH64_hash_t low = hash.low64;
- // 32 for hash, 1 for terminating null added by `sprintf()`
char out[32 + 1];
snprintf(out, sizeof(out), "%016" PRIx64 "%016" PRIx64, high, low);
```suggestion
// 32 for hash, 1 for term... |
codereview_new_cpp_data_2862 | r_ssize r_lgl_sum(r_obj* x, bool na_true) {
}
r_obj* r_lgl_which(r_obj* x, bool na_propagate) {
- if (r_typeof(x) != R_TYPE_logical) {
- r_stop_internal("Expected logical vector.");
}
const r_ssize n = r_length(x);
Could use `r_stop_unexpected_type()`.
r_ssize r_lgl_sum(r_obj* x, bool na_true) {
}
... |
codereview_new_cpp_data_2901 | Perl_thread_locale_init()
/* On Windows, make sure new thread has per-thread locales enabled */
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
-# else
/* This thread starts off in the C locale */
Perl_setlocale(LC_ALL, "C");
-# endif
#endif
}
This (also) alters the behavior on Windows... |
codereview_new_cpp_data_2902 | S_aassign_scan(pTHX_ OP* o, bool rhs, int *scalars_p)
if (o == effective_top_op)
effective_top_op = next_kid;
}
- else
- if (o == effective_top_op)
- effective_top_op = o->op_sibparent;
o = o->op_sibparent; /* try parent's next sibling */... |
codereview_new_cpp_data_3046 |
PG_MODULE_MAGIC;
-#define BUILD_VERSION "1.0.1"
#define PG_STAT_STATEMENTS_COLS 53 /* maximum of above */
#define PGSM_TEXT_FILE "/tmp/pg_stat_monitor_query"
Version issue
PG_MODULE_MAGIC;
+#define BUILD_VERSION "1.1.0-dev"
#define PG_STAT... |
codereview_new_cpp_data_3047 | pg_stat_monitor_internal(FunctionCallInfo fcinfo,
SpinLockRelease(&e->mutex);
}
- /* In case plan is enable, there is no need to show 0 planid query */
if (tmp.info.cmd_type == CMD_SELECT && PGSM_QUERY_PLAN && planid == 0)
continue;
Minor nit:
```suggestion
/* In case t... |
codereview_new_cpp_data_4001 | static int vine_manager_transfer_capacity_available(struct vine_manager *q, stru
/* Provide a substitute file object to describe the peer. */
if(m->file->type != VINE_MINI_TASK)
{
- vine_file_delete(m->substitute);
if((peer = vine_file_replica_table_find_worker(q, m->file->cached_name)))
{
cha... |
codereview_new_cpp_data_4006 | int main(int argc, char *argv[])
for(i=0;i<36;i++) {
char filename[256];
sprintf(filename,"%d.cat.jpg",i);
- vine_task_add_input(t,temp_file[i],filename,VINE_CACHE);
}
vine_task_add_input_file(t,"montage.sfx","montage.sfx",VINE_NOCACHE);
vine_task_add_output_file(t,"mosaic.jpg","mosaic.jpg",VINE_NOCACHE... |
codereview_new_cpp_data_4007 | struct vine_file * vine_file_substitute_url( struct vine_file *f, const char *so
return vine_file_create(source,0,f->cached_name,0,f->length,VINE_URL,0,0);
}
-struct vine_file * vine_file_temp()
{
- return vine_file_create("temp",0,0,0,0,VINE_TEMP,0,0);
}
struct vine_file * vine_file_buffer( const char *buff... |
codereview_new_cpp_data_4008 | Return true if this task can run with the resources currently available.
static int task_resources_fit_now( struct vine_task *t )
{
return
(cores_allocated + t->resources_requested->cores <= local_resources->cores.total) &&
(memory_allocated + t->resources_requested->memory <= local_resources->memory.tot... |
codereview_new_cpp_data_4009 | static void bucketing_cursor_w_pos_delete(bucketing_cursor_w_pos_t* cursor_pos)
list_cursor_destroy(cursor_pos->lc);
free(cursor_pos);
}
- else
- warn(D_BUCKETING, "ignoring command to delete null pointer to bucketing_cursor_w_pos\n");
}
/* Create a bucketing_bucket_range_t structu... |
codereview_new_cpp_data_4010 | void bucketing_state_delete(bucketing_state_t* s)
void bucketing_state_tune(bucketing_state_t* s, const char* field, void* val)
{
- if (!s){
fatal("No bucketing state to tune\n");
return;
}
- if (!field){
fatal("No field in bucketing state to tune\n");
return;
... |
codereview_new_cpp_data_4011 |
/*
-Copyright (C) 2022 The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file COPYING for details.
*/
We do want the hyphen. 2022-
/*
+Copyright (C) 2022- The University of Notre Dame
This software is distributed under the GNU General Public License.
See ... |
codereview_new_cpp_data_4548 | namespace fheroes2
Blit( _staticImage, 0, 0, output, offset.x, offset.y, _staticImage.width(), _staticImage.height() );
}
- const Sprite & animationImage = AGG::GetICN( _animationIcnId, ICN::AnimationFrame( _animationIcnId, _animationIndexOffset, _currentIndex++ ) );
Blit( anima... |
codereview_new_cpp_data_4549 | void Maps::Tiles::QuantityUpdate( bool isFirstLoad )
static_assert( std::is_same_v<decltype( quantity1 ), uint8_t> && std::is_same_v<decltype( quantity2 ), uint8_t>,
"Type of quantity1 or quantity2 has been changed, check the logic below" );
- int spell... |
codereview_new_cpp_data_4550 |
#include "serialize.h"
#include "system.h"
-namespace
-{
- constexpr uint8_t spriteBackground = 0;
-}
-
int main( int argc, char ** argv )
{
if ( argc < 3 ) {
:warning: **clang\-diagnostic\-unused\-const\-variable** :warning:
unused variable `` spriteBackground ``
#include "serialize.h"
#include "sy... |
codereview_new_cpp_data_4551 | int main( int argc, char ** argv )
std::string baseName = System::GetBasename( argv[0] );
std::cerr << baseName << " generates an image with colors based on a provided palette file." << std::endl
- << "Syntax: " << baseName << " palette_file.pal output.bmp" << std::endl;
r... |
codereview_new_cpp_data_4552 | int main( int argc, char ** argv )
std::string baseName = System::GetBasename( argv[0] );
std::cerr << baseName << " generates an image with colors based on a provided palette file." << std::endl
- << "Syntax: " << baseName << " palette_file.pal output.bmp" << std::endl;
r... |
codereview_new_cpp_data_4553 | namespace fheroes2
{
assert( data != nullptr && imageCount > 0 && width > 0 && height > 0 );
- output.clear();
output.resize( imageCount );
const size_t imageSize = static_cast<size_t>( width * height );
:warning: **bugprone\-misplaced\-widening\-cast** :warning:
either cast... |
codereview_new_cpp_data_4554 | namespace fheroes2
output.resize( imageCount );
- const size_t imageSize = static_cast<size_t>( width * height );
for ( size_t i = 0; i < imageCount; ++i ) {
Image & tilImage = output[i];
We can avoid this warning this way:
```suggestion
const size_t imageSize =... |
codereview_new_cpp_data_4555 | namespace
{
const int32_t borderSize{ BORDERWIDTH };
- // Offset from border edges (size of evil interface corners is 43 pixels) - this edges (corners) will not be copied to fill the border.
const int32_t borderEdgeOffset{ 43 };
// Size in pixels of dithered transition from one image to another.... |
codereview_new_cpp_data_4556 | namespace AI
double cellThreatLevel = 0.0;
for ( const Unit * enemy : enemies ) {
- // Archers and Flyers are always threating, skip
if ( enemy->isFlying() || ( enemy->isArchers() && !enemy->isHandFighting() ) ) {
continue;
... |
codereview_new_cpp_data_4557 | void ActionToArtifact( Heroes & hero, int32_t dst_index )
}
}
else
- // 4,5 - need have skill wizard or leadership,
if ( 3 < cond && cond < 6 ) {
const Skill::Secondary & skill = tile.QuantitySkill();
Also should this be "wisdom" and not "wizard"?
... |
codereview_new_cpp_data_4558 | void Maps::Tiles::QuantityUpdate( bool isFirstLoad )
else {
// 0: 70% none
// 1,2,3 - 2000g, 2500g+3res, 3000g+5res,
- // 4,5 - need have skill wizard or leadership,
// 6 - 50 rogues, 7 - 1 gin, 8,9,10,11,12,13 - 1 monster level4,
... |
codereview_new_cpp_data_4559 | void Interface::GameArea::Redraw( fheroes2::Image & dst, int flag, bool isPuzzle
--greenColorSteps;
}
- // Not all arrows and their shadows fit in 1 tile. We need to consider an area of 1 tile bigger area to properly render everything.
const fheroes2::Rect extendedVisibleRoi{ ti... |
codereview_new_cpp_data_4560 | int main( int argc, char ** argv )
const size_t inputStreamSize = inputStream.size();
const uint16_t itemsCount = inputStream.getLE16();
- StreamBuf itemsStream = inputStream.toStreamBuf( itemsCount * 4 * 3 /* hash, offset, size */ );
inputStream.seek( inputStreamSize - AGGItemNameLen * itemsCount ... |
codereview_new_cpp_data_4561 | namespace fheroes2
const CustomImageDialogElement lighthouseImageElement( combined );
- std::string lighthouseControlledString = _( "%{count}" );
- StringReplace( lighthouseControlledString, "%{count}", std::to_string( lighthouseCount ) );
- const Text lighthouseControlledText( lighth... |
codereview_new_cpp_data_4562 | void Kingdom::openOverviewDialog()
Dialog::Message( _( "Exit" ), _( "Exit this menu." ), Font::BIG );
}
else if ( le.MousePressRight( rectIncome ) ) {
- fheroes2::showKingdomIncome( *this, 0 );
}
else if ( le.MousePressRight( rectLighthouse ) ) {
- ... |
codereview_new_cpp_data_4563 | namespace AI
return target;
}
- Actions BattlePlanner::berserkTurn( Arena & arena, const Unit & currentUnit ) const
{
assert( currentUnit.Modes( SP_BERSERKER ) );
:warning: **readability\-convert\-member\-functions\-to\-static** :warning:
method `` berserkTurn `` can be made static
... |
codereview_new_cpp_data_4564 | namespace
if ( hero != nullptr ) {
hero->PickupArtifact( Artifact( awards[i]._subType ) );
- }
- // Some artifacts increase the Spell Power of the hero we have to set spell points to maximum.
- hero->SetSpellPoints( std::max( hero->... |
codereview_new_cpp_data_4565 | void ActionToMagellanMaps( Heroes & hero, const MP2::MapObjectType objectType, i
hero.setVisitedForAllies( dst_index );
Interface::Basic & I = Interface::Basic::Get();
- I.GetRadar().SetRenderWholeMap();
I.SetRedraw( Interface::REDRAW_GAMEAREA | Interface::REDRAW_RAD... |
codereview_new_cpp_data_4566 | void Heroes::MeetingDialog( Heroes & otherHero )
ScoutRadar();
}
if ( hero2ScoutAreaBonus < otherHero.GetBagArtifacts().getTotalArtifactEffectValue( fheroes2::ArtifactBonusType::AREA_REVEAL_DISTANCE ) ) {
- Scoute( otherHero.GetIndex() );
otherHero.ScoutRadar();
}
IMHO this l... |
codereview_new_cpp_data_4567 | fheroes2::Rect Heroes::GetScoutRoi( const bool ignoreDirection /* = false */ ) c
}
return { heroPosition.x - ( ( direction == Direction::RIGHT ) ? 1 : scoutRange ), heroPosition.y - ( ( direction == Direction::BOTTOM ) ? 1 : scoutRange ),
- ( ( direction == Direction::LEFT || direction == Direc... |
codereview_new_cpp_data_4568 | void Interface::Radar::SetZoom()
void Interface::Radar::SetRedraw( const uint32_t redrawMode ) const
{
// Only radar redraws are allowed here.
- assert( redrawMode & ( REDRAW_RADAR_CURSOR | REDRAW_RADAR ) );
_interface.SetRedraw( redrawMode );
}
Hi @Districh-ru
The whole point of this check is to... |
codereview_new_cpp_data_4569 | namespace fheroes2
basicInterface.Reset();
// We need to redraw radar first due to the nature of restorers. Only then we can redraw everything.
- basicInterface.Redraw( Interface::REDRAW_RADAR_CURSOR );
- basicInterface.Redraw( Interface::REDRAW_ALL );
... |
codereview_new_cpp_data_4570 | void Heroes::MeetingDialog( Heroes & otherHero )
// If the scout area bonus is increased with the new artifact we reveal the fog and update the radar.
if ( hero1ScoutAreaBonus < bag_artifacts.getTotalArtifactEffectValue( fheroes2::ArtifactBonusType::AREA_REVEAL_DISTANCE ) ) {
- Scoute( this->GetInde... |
codereview_new_cpp_data_4571 | bool World::LoadMapMP2( const std::string & filename, const bool isOriginalMp2Fi
case MP2::OBJ_EXPANSION_DWELLING:
case MP2::OBJ_EXPANSION_OBJECT:
case MP2::OBJ_JAIL:
- DEBUG_LOG( DBG_GAME, DBG_INFO, "Failed to load The Price of Loyalty '" << filename << "' map whi... |
codereview_new_cpp_data_4572 | namespace AI
// Then consider the stacks from the graveyard
for ( const int32_t idx : arena.GraveyardOccupiedCells() ) {
- const Unit * unit = arena.GraveyardLastTroop( idx );
- assert( unit != nullptr && !unit->isValid() );
-
if ( !arena.GraveyardAllowResurrect( ... |
codereview_new_cpp_data_4573 | void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const Unit
}
const int spellPoints = hero ? hero->GetPower() : DEFAULT_SPELL_DURATION;
- const uint32_t spellDamage = defender->CalculateDamage( spell, (uint32_t) spellPoints, hero, 0 /* targetInfo damage */, true /* ignore defending h... |
codereview_new_cpp_data_4574 | void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const Unit
}
const int spellPoints = hero ? hero->GetPower() : DEFAULT_SPELL_DURATION;
- const uint32_t spellDamage = defender->CalculateDamage( spell, (uint32_t) spellPoints, hero, 0 /* targetInfo damage */, true /* ignore defending h... |
codereview_new_cpp_data_4575 | void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const Unit
}
const int spellPoints = hero ? hero->GetPower() : DEFAULT_SPELL_DURATION;
- const uint32_t spellDamage = defender->CalculateDamage( spell, (uint32_t)spellPoints, hero, 0 /* targetInfo damage */, true /* ignore defending he... |
codereview_new_cpp_data_4576 | void Battle::PopupDamageInfo::SetAttackInfo( const Cell * cell, const Unit * att
void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const HeroBase * hero, const Unit * defender, const Spell spell )
{
- if ( hero == nullptr || !SetDamageInfoBase( cell, defender ) ) {
return;
}
-... |
codereview_new_cpp_data_4577 | void Battle::PopupDamageInfo::SetAttackInfo( const Cell * cell, const Unit * att
void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const HeroBase * hero, const Unit * defender, const Spell spell )
{
- if ( hero == nullptr || !SetDamageInfoBase( cell, defender ) ) {
return;
}
-... |
codereview_new_cpp_data_4578 | void Battle::PopupDamageInfo::SetAttackInfo( const Cell * cell, const Unit * att
void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const HeroBase * hero, const Unit * defender, const Spell spell )
{
- if ( hero == nullptr || !SetDamageInfoBase( cell, defender ) ) {
return;
}
-... |
codereview_new_cpp_data_4579 | void Battle::Interface::RedrawActionWincesKills( const TargetsInfo & targets, Un
// There sould not be more Lich cloud animation frames than in corresponding ICN.
assert( lichCloudFrame <= lichCloudMaxFrame );
- // Important: 'lichCloudFrame' can be more than 'lichCloudMaxFrame' when perform... |
codereview_new_cpp_data_4580 | Battle::Indexes Battle::Arena::GetPath( const Position & position ) const
return result;
}
-Battle::Indexes Battle::Arena::CalculateTwoMoveOverlap( int32_t /* indexTo */, uint32_t /* movementRange = 0 */ ) const
-{
- // TODO: Not implemented yet
- return {};
-}
-
uint32_t Battle::Arena::CalculateMoveDis... |
codereview_new_cpp_data_4581 | Battle::Position Battle::Position::GetReachable( const Unit & currentUnit, const
return {};
};
- Position result = tryHead();
- if ( result.GetHead() == nullptr || result.GetTail() == nullptr ) {
- result = tryTail();
}
- return result;
}
... |
codereview_new_cpp_data_4582 | void Battle::Interface::RedrawActionHolyShoutSpell( const uint8_t strength )
const uint8_t alphaStep = 25;
fheroes2::Display & display = fheroes2::Display::instance();
- const fheroes2::Rect renderArea( _interfacePosition.x + area.y, _interfacePosition.y + area.y, area.width, area.height );
// Im... |
codereview_new_cpp_data_4583 | Artifact Artifact::FromMP2IndexSprite( uint32_t index )
else if ( Settings::Get().isPriceOfLoyaltySupported() && 0xAB < index && 0xCE > index )
return Artifact( ( index - 1 ) / 2 );
else if ( 0xA3 == index )
- return Artifact( Rand( ART_LEVEL_ALL_NORMAL ) );
else if ( 0xA4 == index )
- ... |
codereview_new_cpp_data_4584 | Artifact Artifact::FromMP2IndexSprite( uint32_t index )
else if ( Settings::Get().isPriceOfLoyaltySupported() && 0xAB < index && 0xCE > index )
return Artifact( ( index - 1 ) / 2 );
else if ( 0xA3 == index )
- return Artifact( Rand( ART_LEVEL_ALL_NORMAL ) );
else if ( 0xA4 == index )
- ... |
codereview_new_cpp_data_4585 | Artifact Artifact::FromMP2IndexSprite( uint32_t index )
else if ( Settings::Get().isPriceOfLoyaltySupported() && 0xAB < index && 0xCE > index )
return Artifact( ( index - 1 ) / 2 );
else if ( 0xA3 == index )
- return Artifact( Rand( ART_LEVEL_ALL_NORMAL ) );
else if ( 0xA4 == index )
- ... |
codereview_new_cpp_data_4586 | Artifact Artifact::FromMP2IndexSprite( uint32_t index )
else if ( Settings::Get().isPriceOfLoyaltySupported() && 0xAB < index && 0xCE > index )
return Artifact( ( index - 1 ) / 2 );
else if ( 0xA3 == index )
- return Artifact( Rand( ART_LEVEL_ALL_NORMAL ) );
else if ( 0xA4 == index )
- ... |
codereview_new_cpp_data_4587 | Artifact Artifact::FromMP2IndexSprite( uint32_t index )
else if ( Settings::Get().isPriceOfLoyaltySupported() && 0xAB < index && 0xCE > index )
return Artifact( ( index - 1 ) / 2 );
else if ( 0xA3 == index )
- return Artifact( Rand( ART_LEVEL_ALL_NORMAL ) );
else if ( 0xA4 == index )
- ... |
codereview_new_cpp_data_4589 | namespace
int returnCode = SDL_SetRenderDrawColor( _renderer, 0, 0, 0, SDL_ALPHA_OPAQUE );
if ( returnCode < 0 ) {
- ERROR_LOG( "Failed to set default color for rendered. The error value: " << returnCode << ", description: " << SDL_GetError() )
}
r... |
codereview_new_cpp_data_4591 | void Battle::Interface::RedrawActionWincesKills( const TargetsInfo & targets, Un
}
const int animationState = info.defender->GetAnimationState();
- if ( animationState == ( Monster_Info::WNCE || Monster_Info::WNCE_UP || Monster_Info::WNCE_DOWN ) ) {
... |
codereview_new_cpp_data_4592 | void Battle::Interface::RedrawActionWincesKills( const TargetsInfo & targets, Un
}
const int animationState = info.defender->GetAnimationState();
- if ( animationState == ( Monster_Info::WNCE || Monster_Info::WNCE_UP || Monster_Info::WNCE_DOWN ) ) {
... |
codereview_new_cpp_data_4593 | namespace fheroes2
Image CreateDeathWaveEffect( const Image & in, const int32_t x, const std::vector<int32_t> & deathWaveCurve )
{
if ( in.empty() ) {
- return Image();
}
const int32_t inWidth = in.width();
const int32_t waveWidth = static_cast<int32_t>( death... |
codereview_new_cpp_data_4594 | bool LocalEvent::HandleEvents( const bool sleepAfterEventProcessing, const bool
case SDL_JOYDEVICEADDED:
case SDL_JOYDEVICEREMOVED:
case SDL_CONTROLLERDEVICEREMAPPED:
- // All these joystick and controller events aren't handled.
break;
case SDL_CONTROLLERAXIS... |
codereview_new_cpp_data_4595 | int32_t AnimationState::getCurrentFrameXOffset() const
if ( currentFrame < offset.size() ) {
return offset[currentFrame];
}
- else {
- // If there is no horizontal offset data, return 0 as offset.
- return 0;
- }
}
double AnimationState::movementProgress() const
:warning: **... |
codereview_new_cpp_data_4596 | namespace fheroes2
// 'MOVE_MAIN' has 7 frames and we copy only first 6.
const int32_t copyFramesNum = 6;
// 'MOVE_MAIN' frames starts from the 6th frame in Golem ICN sprites.
- const std::_Vector_iterator firstFrameToCopy = _icnVsSprite[id].begin() + 6... |
codereview_new_cpp_data_4597 | namespace
void AIToXanadu( Heroes & hero, int32_t dst_index )
{
const Maps::Tiles & tile = world.GetTiles( dst_index );
- const uint32_t level1 = hero.GetLevelSkill( Skill::Secondary::DIPLOMACY );
- const uint32_t level2 = hero.GetLevel();
if ( !hero.isVisited( tile ) && Gam... |
codereview_new_cpp_data_4598 | namespace
void AIToXanadu( Heroes & hero, int32_t dst_index )
{
const Maps::Tiles & tile = world.GetTiles( dst_index );
- const uint32_t level1 = hero.GetLevelSkill( Skill::Secondary::DIPLOMACY );
- const uint32_t level2 = hero.GetLevel();
if ( !hero.isVisited( tile ) && Gam... |
codereview_new_cpp_data_4599 | void Dialog::NonFixedFrameBox::redraw()
Dialog::NonFixedFrameBox::~NonFixedFrameBox()
{
- const fheroes2::Rect restoredArea{ _restorer->x(), _restorer->y(), _restorer->width(), _restorer->height() };
_restorer->restore();
- fheroes2::Display::instance().render( restoredArea );
}
Dialog::FrameBox::... |
codereview_new_cpp_data_4600 | bool Battle::Bridge::AllowUp() const
return isValid() && isDown() && !isOccupied();
}
-bool Battle::Bridge::isOccupied() const
{
const Battle::Graveyard * graveyard = Arena::GetGraveyard();
:warning: **readability\-convert\-member\-functions\-to\-static** :warning:
method `` isOccupied `` can be made ... |
codereview_new_cpp_data_4601 | bool Maps::FileInfo::ReadMP2( const std::string & filename )
void Maps::FileInfo::FillUnions( const int side1Colors, const int side2Colors )
{
- static_assert( std::is_same_v<decltype( unions ), uint8_t[KINGDOMMAX]>, "The type of the unions[] member has been changed, check the logic below" );
-
- assert( sid... |
codereview_new_cpp_data_4602 | Spell Maps::Tiles::QuantitySpell() const
{
switch ( GetObject( false ) ) {
case MP2::OBJ_ARTIFACT:
- return Spell( QuantityVariant() == 15 ? quantity1 : Spell::NONE );
case MP2::OBJ_SHRINE1:
case MP2::OBJ_SHRINE2:
case MP2::OBJ_SHRINE3:
case MP2::OBJ_PYRAMID:
- return Spe... |
codereview_new_cpp_data_4603 | void Battle::Bridge::Action( const Unit & b, int32_t dst )
ForceAction( NeedDown( b, dst ) );
}
-void Battle::Bridge::ForceAction( const bool action_down )
{
if ( Arena::GetInterface() )
- Arena::GetInterface()->RedrawBridgeAnimation( action_down );
- SetDown( action_down );
}
Since you are... |
codereview_new_cpp_data_4604 | namespace fheroes2
const std::vector<int32_t>::const_iterator endX = deathWaveCurve.end() - ( x > width ? x - width : 0 );
for ( ; pntX != endX; ++pntX, ++outImageX, ++inImageX ) {
- const uint8_t * outImageYEnd = outImageX + ( height + *pntX ) * width;
- const uint8_t * inIma... |
codereview_new_cpp_data_4605 | namespace fheroes2
const std::vector<int32_t>::const_iterator endX = deathWaveCurve.end() - ( x > width ? x - width : 0 );
for ( ; pntX != endX; ++pntX, ++outImageX, ++inImageX ) {
- const uint8_t * outImageYEnd = outImageX + ( height + *pntX ) * width;
- const uint8_t * inIma... |
codereview_new_cpp_data_4606 | namespace fheroes2
const std::vector<int32_t>::const_iterator endX = deathWaveCurve.end() - ( x > width ? x - width : 0 );
for ( ; pntX != endX; ++pntX, ++outImageX, ++inImageX ) {
- const uint8_t * outImageYEnd = outImageX + static_cast<int64_t>( height + *pntX ) * width;
- c... |
codereview_new_cpp_data_4607 | namespace fheroes2
const bool isEvilInterface = ( id == ICN::BUTTON_SMALL_OKAY_EVIL );
- if ( isPolishLanguageAndResources() ) {
_icnVsSprite[id][0] = GetICN( isEvilInterface ? ICN::SYSTEME : ICN::SYSTEM, 1 );
_icnVsSprite[id][1] = GetICN( i... |
codereview_new_cpp_data_4608 | Castle::CastleDialogReturnValue Castle::OpenDialog( const bool openConstructionW
fheroes2::drawCastleName( *this, display, cur_pt );
fheroes2::drawResourcePanel( GetKingdom().GetFunds(), display, cur_pt );
display.render();
}
Is this logic not needed anymore?
Cast... |
codereview_new_cpp_data_4609 | void Interface::StatusWindow::TimerEventProcessing()
void Interface::StatusWindow::RedrawStatusIfNeeded( const uint32_t progressValue )
{
turn_progress = progressValue;
interface.Redraw( REDRAW_STATUS );
if ( Game::validateAnimationDelay( Game::MAPS_DELAY ) ) {
- // Process events if any ... |
codereview_new_cpp_data_4610 | void Interface::StatusWindow::TimerEventProcessing()
void Interface::StatusWindow::RedrawStatusIfNeeded( const uint32_t progressValue )
{
turn_progress = progressValue;
interface.Redraw( REDRAW_STATUS );
if ( Game::validateAnimationDelay( Game::MAPS_DELAY ) ) {
- // Process events if any ... |
codereview_new_cpp_data_4611 | void Maps::Tiles::redrawBottomLayerObjects( fheroes2::Image & dst, bool isPuzzle
// Some addons must be rendered after the main object on the tile. This applies for flags.
// Since this method is called intensively during rendering we have to avoid memory allocation on heap.
const size_t maxPostRenderAd... |
codereview_new_cpp_data_4612 | void Battle::Arena::SetCastleTargetValue( int target, uint32_t value )
case CAT_BRIDGE:
if ( _bridge->isValid() ) {
- if ( !_bridge->isDown() ) {
- _bridge->SetDown( true );
- }
-
_bridge->SetDestroy();
}
break;
So the code after the ... |
codereview_new_cpp_data_4613 | std::string Army::SizeString( uint32_t size )
Troops::Troops( const Troops & troops )
: std::vector<Troop *>()
{
- *this = troops;
-}
-
-Troops & Troops::operator=( const Troops & rhs )
-{
- clear();
- reserve( rhs.size() );
- for ( const_iterator it = rhs.begin(); it != rhs.end(); ++it )
p... |
codereview_new_cpp_data_4614 | Troops::Troops( const Troops & troops )
: std::vector<Troop *>()
{
reserve( troops.size() );
- for ( const_iterator it = troops.begin(); it != troops.end(); ++it )
- push_back( new Troop( **it ) );
}
Troops::~Troops()
:warning: **modernize\-loop\-convert** :warning:
use range\-based for loop ... |
codereview_new_cpp_data_4615 | namespace fheroes2
case SupportedLanguage::Hungarian:
return _( "Hungarian" );
case SupportedLanguage::Danish:
- return _( "Hungarian" );
default:
// Did you add a new language? Please add the code to handle it.
assert( 0 );
:warning: **bugp... |
codereview_new_cpp_data_4616 | bool LocalEvent::HandleWindowEvent( const SDL_WindowEvent & event )
return true;
}
- if ( event.event == SDL_WINDOWEVENT_RESIZED ) {
- return true;
- }
-
- return false;
}
void LocalEvent::HandleRenderDeviceResetEvent()
:warning: **readability\-simplify\-boolean\-expr** :warning:
r... |
codereview_new_cpp_data_4617 | namespace
const fheroes2::Image & getDebugFogImage()
{
- static fheroes2::Image fog;
- if ( fog.empty() ) {
- fog.resize( 32, 32 );
- fheroes2::FillTransform( fog, 0, 0, fog.width(), fog.height(), 2 );
- }
return fog;
}
Hi @ihhub I propose to init... |
codereview_new_cpp_data_4618 | int Mixer::setVolume( const int channelId, const int volumePercentage )
const int logvol = volumePercentage / 10;
- const int arr[] = {0, 2, 3, 5, 8, 12, 20, 32, 50, 80, 128};
if ( !isInitialized ) {
return 0;
:warning: **cppcoreguidelines\-avoid\-c\-arrays** :warning:
do not declare C\-st... |
codereview_new_cpp_data_4619 | namespace
std::array<int, maxVolume + 1> result{ 0 };
result[maxVolume] = MIX_MAX_VOLUME;
for ( int i = 1; i < maxVolume; i++ )
- result[i] = round( a * std::pow( 10.0, i * b ) * MIX_MAX_VOLUME );
return result;
}
();
:warning: **bug... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3