id
stringlengths
27
29
content
stringlengths
226
3.24k
codereview_new_cpp_data_10004
static void workspace_delete() is inside the workspace. Abort if we really cannot clean up. */ -// unlink_recursive(workspace); free(workspace); } Don't check in dead code, just delete it. static void workspace_delete() is inside the workspace. Abort if we really cannot clean up. */ free(wo...
codereview_new_cpp_data_10005
void work_queue_accumulate_task(struct work_queue *q, struct work_queue_task *t) case WORK_QUEUE_RESULT_TASK_MAX_RUN_TIME: case WORK_QUEUE_RESULT_DISK_ALLOC_FULL: case WORK_QUEUE_RESULT_OUTPUT_TRANSFER_ERROR: - if (t->result == WORK_QUEUE_RESULT_SUCCESS) success = 1; - else if (t->result == WORK_QUEU...
codereview_new_cpp_data_10006
void * itable_pop( struct itable *t ) void *value; itable_firstkey(t); - if(itable_nextkey(t, &key, (void*)&value)) { return itable_remove(t,key); } else { return 0; (void **) ? I think compilers may complain otherwise. void * itable_pop( struct itable *t ) void *value; itable_firstkey(t); + if(...
codereview_new_cpp_data_10157
void Kingdom::openOverviewDialog() dst_pt.y = cur_pt.y + 360; fheroes2::Button buttonHeroes( dst_pt.x, dst_pt.y, ICN::OVERVIEW, 0, 1 ); - // We need to additionally render the background between HEROES and TOWSN/CASTLES buttons. dst_pt.y += 42; fheroes2::Copy( fheroes2::AGG::GetICN( ICN::OVERB...
codereview_new_cpp_data_10158
StreamBase & operator>>( StreamBase & msg, World & w ) static_assert( LAST_SUPPORTED_FORMAT_VERSION < FORMAT_VERSION_1002_RELEASE, "Remove the logic below." ); if ( Game::GetLoadVersion() < FORMAT_VERSION_1002_RELEASE ) { - uint32_t dummy; msg >> dummy; } msg >> w.map_objects ...
codereview_new_cpp_data_10159
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 by 1 tile bigger area to properly render everything. const fheroes2::Rect extendedVisibleRoi{ tileROI.x ...
codereview_new_cpp_data_10160
namespace fheroes2 Copy( in, 0, 0, out, 0, 0, in.width(), in.height() ); } - void Copy( const Image & in, Image & out, int32_t outX, int32_t outY ) - { - Copy( in, 0, 0, out, outX, outY, in.width(), in.height() ); - } - void Copy( const Image & in, int32_t inX, int32_t inY, Image &...
codereview_new_cpp_data_10161
namespace std::filesystem::path dir = argPath.parent_path(); if ( dir.empty() ) { - dir = { "." }; } std::error_code ec; :warning: **clang\-diagnostic\-error** :warning: use of overloaded operator `` = `` is ambiguous \(with operand types `` std::filesystem::path `` ...
codereview_new_cpp_data_10162
namespace Dialog display.render(); } - if ( selectedResolution.width > 0 && selectedResolution.height > 0 && selectedResolution.scale > 0 && ( selectedResolution != currentResolution ) ) { display.setResolution( selectedResolution ); #if !defined( MACOS_APP_BUNDLE ) The ...
codereview_new_cpp_data_10163
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_10164
bool Heroes::PickupArtifact( const Artifact & art ) } // If there were artifacts assembled we check them for scout area bonus. - if ( !assembledArtifacts.empty() ) { - for ( const ArtifactSetData & assembledArtifact : assembledArtifacts ) { - if ( scout( static_cast...
codereview_new_cpp_data_10165
bool Heroes::Recruit( const int col, const fheroes2::Point & pt ) // Update the set of recruits in the kingdom kingdom.GetRecruits(); - // After recruiting a hero we reveal map and radar image in hero scout area. Scoute( GetIndex() ); - ScoutRadar(); return true; } Hi @Districh-ru what ...
codereview_new_cpp_data_10166
int32_t Interface::Basic::GetDimensionDoorDestination( const int32_t from, const const bool isFadingEnabled = ( gameAreaROI.width > TILEWIDTH * distance ) || ( gameAreaROI.height > TILEWIDTH * distance ); const fheroes2::Rect spellROI = [this, from, distance, isHideInterface, &gameAreaROI]() -> fheroes2::R...
codereview_new_cpp_data_10167
void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const Unit return; } - const uint32_t spellPoints = hero ? hero->GetPower() : DEFAULT_SPELL_DURATION; - const uint32_t spellDamage = defender->CalculateDamage( spell, spellPoints, hero, 0 /* targetInfo damage */, true /* ignore ...
codereview_new_cpp_data_10168
void Battle::PopupDamageInfo::SetSpellAttackInfo( const Cell * cell, const Unit return; } - const uint32_t spellPoints = hero ? hero->GetPower() : DEFAULT_SPELL_DURATION; - const uint32_t spellDamage = defender->CalculateDamage( spell, spellPoints, hero, 0 /* targetInfo damage */, true /* ignore ...
codereview_new_cpp_data_10169
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_10170
void LocalEvent::HandleControllerButtonEvent( const SDL_ControllerButtonEvent & } #endif } - else { - if ( button.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ) { - _controllerPointerSpeed /= CONTROLLER_TRIGGER_CURSOR_SPEEDUP; - } } } Please combine these else and i...
codereview_new_cpp_data_10171
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_10172
void Battle::Interface::RedrawTargetsWithFrameAnimation( const TargetsInfo & tar // For certain spells reflect the spell sprite if the creature is reflected. const bool isReflectICN = ( icn == ICN::SHIELD || icn == ICN::REDDEATH || icn == ICN::MAGIC08 ); - _unitSpellEffectInfos.reserve( targets.size() )...
codereview_new_cpp_data_10173
void Battle::Interface::RedrawTargetsWithFrameAnimation( const TargetsInfo & tar } } -void Battle::Interface::RedrawTroopWithFrameAnimation( Unit & unit, int icn, int m82, CreatueSpellAnimation animation ) { LocalEvent & le = LocalEvent::Get(); Hi @Districh-ru I don't know when exactly this type was i...
codereview_new_cpp_data_10174
void Heroes::MeetingDialog( Heroes & otherHero ) std::set<ArtifactSetData> assembledArtifacts = bag_artifacts.assembleArtifactSetIfPossible(); std::set<ArtifactSetData> otherHeroAssembledArtifacts = otherHero.bag_artifacts.assembleArtifactSetIfPossible(); assembledArtifacts.mer...
codereview_new_cpp_data_10175
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_10176
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_10177
void StringReplaceWithLowercase( std::string & workString, const char * pattern, return; } - // This function converts all letters in 'patternReplacement' to lowercase before replacing the 'pattern' in 'workString', - // except for the first word in a sentence. for ( size_t position = workSt...
codereview_new_cpp_data_10178
std::vector<std::pair<fheroes2::Point, fheroes2::Sprite>> Heroes::getHeroSprites int flagFrameID = sprite_index; if ( !isMoveEnabled() ) { - flagFrameID = isShipMaster() ? 0 : Game::getAdventureMapAnimationIndex(); } fheroes2::Point offset; :warning: **bugprone\-narrowing\-conversions**...
codereview_new_cpp_data_10179
namespace AI if ( Game::validateAnimationDelay( Game::MAPS_DELAY ) ) { // Update Adventure Map objects' animation. Game::updateAdventureMapAnimationIndex(); - - gameArea.SetRedraw(); } ...
codereview_new_cpp_data_10180
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_10181
namespace } } DEBUG_LOG( DBG_GAME, DBG_WARN, "the hero to whom the bonus should be applied has not been found" << ", campaign id: " << scenarioInfoId.campaignId << ", scenario id: " << scenarioInfoId.scenarioId ) ...
codereview_new_cpp_data_10182
namespace } #endif - bool isPolishOrRussianLanguageAndResources() { - return ( fheroes2::getCurrentLanguage() == fheroes2::SupportedLanguage::Polish && fheroes2::getResourceLanguage() == fheroes2::SupportedLanguage::Polish ) - || ( fheroes2::getCurrentLanguage() == fheroes2::Suppor...
codereview_new_cpp_data_10183
namespace AI // The size of heroes can be increased if a new hero is released from Jail. const size_t maxHeroCount = std::max( heroes.size(), availableHeroes.size() ); - const size_t progressValue = ( endProgressValue - startProgressValue ) * ( maxHeroCount - availableHeroes.size...
codereview_new_cpp_data_10184
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_10185
void Battle::Arena::SetCastleTargetValue( int target, uint32_t value ) case CAT_BRIDGE: if ( _bridge->isValid() ) { - if ( !_bridge->isDown() ) { - _bridge->SetDown( true ); - } - _bridge->SetDestroy(); } break; We aren't showing brid...
codereview_new_cpp_data_10186
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_10187
namespace AI } } - // Call internally checks if it's valid (space/resources) to buy one. const Kingdom & kingdom = castle.GetKingdom(); if ( !kingdom.GetHeroes().empty() && kingdom.GetFunds() >= PaymentConditions::BuyBoat() * ( islandOrPeninsula ? 2 : 4 ) ) { ...
codereview_new_cpp_data_10188
namespace const uint8_t * dataEnd = data + size; while ( data != dataEnd ) { if ( *data == lineSeparator || isSpaceChar( *data ) ) { - // If it is the end of line ("\n") or a space (""), then the word has ended. if ( maxWidth < width ) { ...
codereview_new_cpp_data_10189
namespace ERROR_LOG( "Failed to set a linear scale hint for rendering." ) } - // Setting this hint prevents the window to regain focus after loosing it in fullscreen mode. // It also fixes issues when SDL_UpdateTexture() calls fail because of refocusing. ...
codereview_new_cpp_data_10190
Battle::Result Battle::Loader( Army & army1, Army & army2, int32_t mapsindex ) } } bool isBattleOver = false; while ( !isBattleOver ) { - const uint32_t battleSeed = computeBattleSeed( mapsindex, world.GetMapSeed(), army1, army2 ); Rand::DeterministicRandomGenerator randomGene...
codereview_new_cpp_data_10191
namespace int32_t offsetY = textInitialOffsetY; - TextBox title( _( "Support us at ), Font::BIG, textWidth ); TextBox name( _( "local-donation-platform|https://www.patreon.com/fheroes2" ), Font::YELLOW_BIG, textWidth ); title.Blit( ( textInitialOffsetX - title.w() ) / 2, offsetY, ...
codereview_new_cpp_data_10192
void Heroes::PortraitRedraw( const int32_t px, const int32_t py, const PortraitT } } - if ( ( GetControl() & CONTROL_AI ) != 0 ) { // AI heroes should not have any UI indicators for their statuses. return; } There should be also `isControlAI()`, which is a bit shorter, but is...
codereview_new_cpp_data_10193
namespace std::vector<fheroes2::SupportedLanguage> temp = languages; items.SetListContent( temp ); - const fheroes2::Size currentResolution( display.width(), display.height() ); - - fheroes2::Size selectedResolution; for ( size_t i = 0; i < languages.size(); ++i ) { ...
codereview_new_cpp_data_10194
namespace fheroes2 icnVsSprite[75].setPosition( icnVsSprite[75].x(), icnVsSprite[75].y() ); updateSmallFontLetterShadow( icnVsSprite[75] ); } - return; } } :warning: **readability\-redundant\-control\-flow** :warning: redundant return statement at the end of a function ...
codereview_new_cpp_data_10195
namespace #if defined( ANDROID ) // Same as ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE - SDL_SetHint( SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight" ); #endif uint32_t flags = SDL_WINDOW_SHOWN; This is a "good enough" place for this hint but we should add error ...
codereview_new_cpp_data_10264
static bool elektraCheckForInvalidMetaKey (Key * parentKey, KeySet * ks) const KeySet * metaKeys = keyMeta (cur); for (elektraCursor jt = 0; jt < ksGetSize (metaKeys); ++jt) { - // We reach her iff we try to set a metakey. Therefore we should t const Key * meta = ksAtCursor (metaKeys, jt); const cha...
codereview_new_cpp_data_10331
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { // New PyCFunction will own method reference PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); Py_DECREF(method); // __Pyx_PyObject_GetAttrStr - if (unlikely(!unboun...
codereview_new_cpp_data_10332
typedef struct { /////////////// UnpackUnboundCMethod /////////////// //@requires: PyObjectGetAttrStr -#define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) -#define __PYX_REINTERPRET_POINTER(pointer_type, pointer) ((pointer_type)(void *)(pointer)) -#define _...
codereview_new_cpp_data_10333
typedef struct { /////////////// UnpackUnboundCMethod /////////////// //@requires: PyObjectGetAttrStr -#define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) -#define __PYX_REINTERPRET_POINTER(pointer_type, pointer) ((pointer_type)(void *)(pointer)) -#define _...
codereview_new_cpp_data_10335
#undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC - #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07030900) #endif #elif defined(CYTHON_LIMITED_API) Did this creep in from #5074, or is it on purpose? #undef CYTHON_USE_EXC_INF...
codereview_new_cpp_data_10341
typedef struct { #ifdef __PYX_DEBUG_ATOMICS #warning "Using GNU atomics" #endif -#elif CYTHON_ATOMICS && defined(_MSC_VER) /* msvc */ #include <intrin.h> #undef __pyx_atomic_int_type If we wanted to make this less liable to break the rest of the world then we could only enable Window...
codereview_new_cpp_data_10344
class __Pyx_FakeReference { #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) -#ifndef CO_GENERATOR - #define CO_GENERATOR 0x20 -#endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif I checked, this was already added in Python 2.2, when generators were introduced. No need to...
codereview_new_cpp_data_10350
namespace machine_learning { /** * @namespace k_nearest_neighbors - * @brief K-nearest neighbors algorithm */ namespace k_nearest_neighbors { ```suggestion * @brief Functions for the [K-Nearest Neighbors algorithm] * (https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm) implementation ``` n...
codereview_new_cpp_data_10351
* Geeks For Geeks link [https://www.geeksforgeeks.org/maximum-contiguous-circular-sum/] */ -#include <cassert> -#include <iostream> using namespace std; int maxCircularSum(int a[], int n) Please add a one-line description of what the library/header is for (**see the example below**). ```c++ #include ...
codereview_new_cpp_data_10352
* @details * The idea is to modify Kadane’s algorithm to find a minimum contiguous subarray sum and the maximum contiguous subarray sum, * then check for the maximum value between the max_value and the value left after subtracting min_value from the total sum. -* [Geeks For Geeks](https://www.geeksforgeeks.org/maxi...
codereview_new_cpp_data_10353
* @author [KillerAV] (https://github.com/KillerAV) */ -#include <cassert> // for std::assert -#include <iostream> // for io operations -#include <vector> // for vector -#include <unordered_map> // for unordered map /** * @namespace dynamic_programming ```suggestion #include <cassert> /// f...
codereview_new_cpp_data_10354
* the array. For example, array = [1, -10, 2, 31, -6], targetSum = -14. * Output: true => We can pick subset [-10, 2, -6] with sum as * (-10) + 2 + (-6) = -14. - * @author [KillerAV] (https://github.com/KillerAV) */ #include <cassert> /// for std::assert ```suggestion * @author [KillerAV](https:...
codereview_new_cpp_data_10355
int main() std::cout << "Size can only be 1-30. Please choose another value: "; std::cin >> size; } - } int *array = new int[size]; int key = 0; This seems to be causing the CI to fail. ```suggestion ``` int main() std::cout << "Size can...
codereview_new_cpp_data_10356
struct ListNode { ListNode(int x, ListNode *next) : val(x), next(next) {} // Constructor with values provided for node->val and node->next }; - #include <iostream> // for IO operations - #include <cassert> // for assert in tests /** * @namespace search I suggest moving these before declaring any funct...
codereview_new_cpp_data_10357
* @file * @brief Given a linked list L[0,....,n] of n numbers, find the middle node. * - * @details The technique utilized in this implementation is the "Floyd's tortise and hare" approach. Wikipedia link to technique: https://en.wikipedia.org/wiki/Cycle_detection#Floyd's_tortoise_and_hare * This technique us...
codereview_new_cpp_data_10358
#include <iostream> #include <vector> #include <cassert> -#include <limits.h> /** * @namespace graph ```suggestion #include <climits> ``` __ [![sema-logo](https://app.semasoftware.com/img/sema-tray-logo.gif)](https://semasoftware.com/gh) &nbsp;**Summary:** :hammer_and_wrench: This code needs a fix&nbs...
codereview_new_cpp_data_10359
#include <iostream> #include <vector> #include <cassert> -#include <limits.h> /** * @namespace graph Please add a one-line description of what the library/header is for (**see the example below**). ```c++ #include <iostream> /// for IO operations #include <cassert> /// for assert ``` __ [![s...
codereview_new_cpp_data_10360
namespace list_array { /** * @brief Structure of List with supporting methods. */ - template <int N> struct list { std::array<uint64_t, N> data{}; // Array that implement list uint64_t top = 0; // Pointer to the last element I believe we should use `uint64_t` in here like th...
codereview_new_cpp_data_10361
std::size_t hashInt_2(int x) { y = y ^ (y >> 31); return y; } -} // namespace data_structures /** * @brief Test for bloom filter with string as generic type ```suggestion } // namespace data_structures ``` __ [![sema-logo](https://app.semasoftware.com/img/sema-tray-logo.gif)](https://semasoft...
codereview_new_cpp_data_10362
struct CheckWeightsFunctor : DefaultErrorReporter // Get weights matrix and gradient const auto& weights_matrix = dtw.get_values(); const auto& gradient = dtw.get_optimizer()->get_gradient(); - // std::cout << "*** CHECKING WEIGHTS: NAME=" << dtw.get_name() << ", SIZE=" - // << weights_matrix.Heig...
codereview_new_cpp_data_10365
TEST(get_or) { CHECK_EQUAL(foo, "bar"); auto bar = get_or(x, "bar", fallback); CHECK_EQUAL(bar, "fallback"); } Can you also add a test for get_or with a fallback string literal? I think there's a missing overload. TEST(get_or) { CHECK_EQUAL(foo, "bar"); auto bar = get_or(x, "bar", fallback); CHEC...
codereview_new_cpp_data_10366
expression expand_extractor(predicate::operand operand) { auto make_field_char_parser() { using parsers::chr; return parsers::alnum | chr{'_'} | chr{'-'} | chr{':'}; } I find it strange that this is out of sync with the `field_name` from the `legacy_type` parser: ``` auto field_name = parsers::identif...
codereview_new_cpp_data_10367
struct accountant_state_impl { /// Stores the names of known actors to fill into the actor_name column. std::unordered_map<caf::actor_id, std::string> actor_map; - /// Stores the builder instance. std::unordered_map<std::string, table_slice_builder_ptr> builders; /// Buffers table_slices, acting as a ...
codereview_new_cpp_data_10368
TEST(evaluation - pattern matching) { evaluate(unbox(to<pattern>("/f.*o/")), relational_operator::equal, "foo")); CHECK( evaluate("foo", relational_operator::equal, unbox(to<pattern>("/f.*o/")))); } TEST(serialization) { Can we also test case-insensitive evaluation? TEST(evaluation - pattern matchi...
codereview_new_cpp_data_10369
auto server_command(const vast::invocation& inv, caf::actor_system& system) setup_cors_preflight_handlers(router, *server_config->cors_allowed_origin); // Set up non-API routes. router->non_matched_request_handler([](auto req) { - VAST_VERBOSE("404 not found: {} {}", req->header().method(), ...
codereview_new_cpp_data_10370
parse_arguments(const std::vector<std::string>& args) { }; } const auto repr = detail::join(args.begin(), args.end(), " "); - using parsers::space, parsers::expr, parsers::eoi; auto f = repr.begin(); const auto l = repr.end(); auto parsed_expr = expression{}; - const auto optional_ws = ignore(*sp...
codereview_new_cpp_data_10371
caf::error ip_index::unpack_impl(const fbs::ValueIndex& from) { if (from_ip->byte_indexes()->size() != bytes_.size()) return caf::make_error(ec::format_error, fmt::format("unexpected number of byte indexes in " - "ip index: expected {}, got {}",...
codereview_new_cpp_data_10372
caf::behavior pivoter(caf::stateful_actor<pivoter_state>* self, node_actor node, auto normalized_expr = normalize_and_validate(std::move(expr)); if (!normalized_expr) { self->quit(caf::make_error(ec::format_error, - fmt::format("pivoter failed to normalize and " ...
codereview_new_cpp_data_10373
TEST(No dense indexes serialization when create dense index in config is false) last_written_chunks; auto filesystem = sys.spawn(dummy_filesystem, std::ref(last_written_chunks)); const auto partition_id = vast::uuid::random(); - // FIXME: We should implement a mock store and use that for this test. cons...
codereview_new_cpp_data_10374
class example_plugin final : public virtual analyzer_plugin, } /// Returns the unique name of the plugin. - std::string_view name() const override { return "example-analyzer"; } Shouldn't these simply return a `std::string`? class example_plugin final : public virtual analyzer_plugin, } ...
codereview_new_cpp_data_10375
class writer : public format::writer { auto&& layout = slice.layout(); // TODO: relax this check. We really only need the (1) flow, and (2) PCAP // payload. Everything else is optional. - if (!congruent(layout, make_packet_type())) { return caf::make_error( ec::format_error, fmt::form...
codereview_new_cpp_data_10376
namespace vast { namespace { inline uint32_t bitmask32(size_t bottom_bits) { return bottom_bits >= 32 ? 0xffffffff : ((uint32_t{1} << bottom_bits) - 1); } Please use snake_case in the code base for consistency. namespace vast { namespace { + inline uint32_t bitmask32(size_t bottom_bits) { return bo...
codereview_new_cpp_data_10377
export_helper(export_helper_actor::stateful_pointer<export_helper_state> self, }); return { // Index-facing API - [self](const vast::table_slice& slice) { if (self->state.limit_ <= self->state.events_) return; auto remaining = self->state.limit_ - self->state.events_; au...
codereview_new_cpp_data_10378
auto test_schema = record_type{ auto test_layout2 = record_type{ {"struct", record_type{ - {"foo", string_type{}, {"required"}}, {"bar", string_type{}} }}}; ```suggestion {"foo", type{string_type{}, {"required"}}}, ``` And then you no longer need the modification in type.hpp at all. auto...
codereview_new_cpp_data_10379
caf::expected<store_actor_plugin::builder_and_header> store_plugin::make_store_builder(system::accountant_actor accountant, system::filesystem_actor fs, const vast::uuid& id) const { - const auto& vast_config = caf::get<caf::settings>( - content(...
codereview_new_cpp_data_10380
int main(int argc, char** argv) { } if (compression_level < min_level.ValueUnsafe() || compression_level > max_level.ValueUnsafe()) { - VAST_ERROR("zstd compression level '{}' outside of valid range [{}, {}]", compression_level, min_level.ValueUnsafe(), max_l...
codereview_new_cpp_data_10381
make_pipelines(pipelines_location location, const caf::settings& settings) { auto events = detail::unpack_config_list_to_vector<std::string>( (*pipeline)["events"]); if (!events) { - VAST_ERROR("Unable to extract events from pipeline config"); return events.error(); } auto server...
codereview_new_cpp_data_10383
segment_builder::segment_builder(size_t initial_buffer_size, } caf::error segment_builder::add(table_slice x) { if (x.offset() == invalid_id) x.offset(num_events_); VAST_ASSERT(x.offset() == num_events_); This looks wrong. `num_events` should be equal `x.offset() + x.rows()`, but why do we even have to...
codereview_new_cpp_data_10384
class plugin final : public virtual transform_plugin { // transform plugin API [[nodiscard]] caf::expected<std::unique_ptr<transform_step>> make_transform_step(const record& options) const override { - if (!options.contains("fields") && !options.contains("schemas")) return caf::make_error(ec::invali...
codereview_new_cpp_data_10398
h2o_iovec_t h2o_url_normalize_path(h2o_mem_pool_t *pool, const char *path, size_ *query_at = SIZE_MAX; *norm_indexes = NULL; - if (len == 0 || (len == 1 && path[0] == '/')) { ret = h2o_iovec_init("/", 1); return ret; } Do we need this change? I think the code below would run f...
codereview_new_cpp_data_10520
UA_ServerConfig_clean(UA_ServerConfig *config) { #endif /* Logger */ if(config->logger.clear) config->logger.clear(config->logger.context); config->logger.log = NULL; Use `config->pLogger->clear` for the cleanup. Because some users will not set the normal config->logger at all. UA_Server...
codereview_new_cpp_data_10538
void Server_Card::resetState() setPT(QString()); setAnnotation(QString()); setDoesntUntap(false); - setFaceDown(false); } QString Server_Card::setAttribute(CardAttribute attribute, const QString &avalue, bool allCards) this causes a major bug: cards have their state reset when moved between the ...
codereview_new_cpp_data_10542
void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) { if (m_pp.exp != set_exp) { const auto xp_value = set_exp - m_pp.exp; - const auto export_string = fmt::format("{}",xp_value); - parse->EventPlayer(EVENT_XP_GAIN, this,export_string, xp_value); } if (m_pp.expA...
codereview_new_cpp_data_10543
void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons const auto has_npc_given_event = ( ( IsNPC() && - parse->HasQuestSub(CastToNPC()->GetNPCTypeID(), EVENT_DAMAGE_GIVEN, true) ) || ( attacker->IsNPC() && - parse->HasQuestSub(attacker->CastToNPC()->GetNPCTypeI...
codereview_new_cpp_data_10544
bool SharedDatabase::GetInventory(uint32 char_id, EQ::InventoryProfile *inv) inst->SetCharges(charges); if (item->RecastDelay) { - if (item->RecastType != -1 && timestamps.count(item->RecastType)) { inst->SetRecastTimestamp(timestamps.at(item->RecastType)); - } else if (item->RecastType == -1 && time...
codereview_new_cpp_data_10545
bool Mob::DoCastingChecksOnTarget(bool check_on_casting, int32 spell_id, Mob *sp } if (check_on_casting) { - if (spells[spell_id].target_type == ST_AEClientV1 || spells[spell_id].target_type == ST_AECaster || spells[spell_id].target_type == ST_Ring || Weird extra new line here. bool Mob::DoCastingC...
codereview_new_cpp_data_10546
bool Mob::CheckSpellLevelRestriction(Mob *caster, uint16 spell_id) bool can_cast = true; if (!caster) { - LogSpells("CheckSpellLevelRestriction: No caster"); return false; } Prefix log with `[CheckSpellLevelRestriction]` please vs `CheckSpellLevelRestriction:` bool Mob::CheckSpellLevelRestriction(Mob ...
codereview_new_cpp_data_10547
uint32 ZoneDatabase::GetDoorsCountPlusOne() int ZoneDatabase::GetDoorsDBCountPlusOne(std::string zone_short_name, int16 version) { const auto query = fmt::format( - "SELECT MAX(doorid) FROM doors " "WHERE zone = '{}' AND (version = {} OR version = -1)", zone_short_name, version Max can be null, shouldn'...
codereview_new_cpp_data_10548
uint64 Client::CalcEXP(uint8 conlevel) { uint64 Client::GetExperienceForKill(Mob *against) { #ifdef LUA_EQEMU - uint32 lua_ret = 0; bool ignoreDefault = false; lua_ret = LuaParser::Instance()->GetExperienceForKill(this, against, ignoreDefault); `lua_ret` will need to be adjusted as well for the associated me...
codereview_new_cpp_data_10549
const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_AA_BUY", "EVENT_AA_GAIN", "EVENT_PAYLOAD", - "EVENT_LEVEL_DOWN" - #ifdef BOTS - , "EVENT_SPELL_EFFECT_BOT", - "EVENT_SPELL_EFFECT_BUFF_TIC_BOT" #endif }; nit: I'd remove this floating comma and just put it at the end of `EVENT_LEVEL_DOWN` (and...
codereview_new_cpp_data_10550
bool RuleManager::SetRule(const std::string &rule_name, const std::string &rule_ LogRules("Set rule [{}] to value [{}]", rule_name, m_RuleIntValues[index]); break; case RealRule: - m_RuleRealValues[index] = std::stof(rule_value); LogRules("Set rule [{}] to value [{:.2f}]", rule_name, m_RuleRealValues[...
codereview_new_cpp_data_10551
bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) { // TODO: Add ST_TargetsTarget support for Buffing. if (!((spells[selectedBotSpell.SpellId].target_type == ST_Target || spells[selectedBotSpell.SpellId].target_type == ST_Pet || - (tar == this && !spells[selectedBotSpell.Spel...
codereview_new_cpp_data_10552
void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* } } - bool bots_ignore_race = RuleB(Bot, AllowBotEquipAnyRaceGear); - if (!trade_instance->IsClassEquipable(GetClass()) || (GetLevel() < trade_instance->GetItem()->ReqLevel) || (!trade_instance->IsRaceEquipable(GetRace()) && ...
codereview_new_cpp_data_10553
std::string Zone::GetAAName(int aa_id) int current_aa_id = 0; - for (const auto& r : aa_ranks) { - if (r.second.get()->id == aa_id && r.second.get()->base_ability) { - current_aa_id = r.second.get()->base_ability->id; - break; - } } if (current_aa_id) { - if (aa_abilities.find(current_aa_id) != aa_a...
codereview_new_cpp_data_10554
std::vector<int> Client::GetScribeableSpells(uint8 min_level, uint8 max_level) { if (spells[spell_id].spell_group) { uint32 highest_spell_id = GetHighestSpellinSpellGroup(spells[spell_id].spell_group); - if (spells[highest_spell_id].classes[m_pp.class_ - 1] <= max_level) { - if (spells[highest_spell_id]...
codereview_new_cpp_data_10555
uint32 Client::GetHighestSpellinSpellGroup(uint32 spell_group) int highest_rank = 0; //highest ranked found in spellgroup uint32 highest_spell_id = 0; //spell_id of the highest ranked spell - for (int i = 0; i < EQ::spells::SPELL_ID_MAX; i++) { - if (IsValidSpell(i)) { - if (spells[i].spell_group == spell_gr...
codereview_new_cpp_data_10556
NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi // lava dragon is a fixed size model and should always use its default // otherwise pathing issues if (race == RACE_LAVA_DRAGON_49) { - size = 6; } taunting = false; Should this be 5 since you said size is 5? NPC::NP...
codereview_new_cpp_data_10557
void Client::SetStartZone(uint32 zoneid, float x, float y, float z, float headin } if (x == 0 && y == 0 && z == 0) { - auto zd = GetZoneVersionWithFallback(m_pp.binds[4].zone_id); if (zd.id > 0) { m_pp.binds[4].x = zd.safe_x; m_pp.binds[4].y = zd.safe_y; GetZone() instead maybe since it's not using ...