Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/g_local.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ constexpr std::array<GameTypeInfo, static_cast<size_t>(GameType::Total)> GAME_MO
} };

extern cvar_t* g_gametype;
extern local_game_import_t gi;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Declare local_game_import_t before using in gi extern

extern local_game_import_t gi; is now placed before local_game_import_t is declared anywhere in the header, so any translation unit including this file fails to compile with an unknown-type error. The extern needs to come after the struct definition or be preceded by a forward declaration to keep the header buildable.

Useful? React with 👍 / 👎.


// This namespace encapsulates game state logic and provides safe, inline
// functions to replace the old macros.
namespace Game {
Expand Down Expand Up @@ -622,8 +624,6 @@ struct local_game_import_t : game_import_t {
}
};

extern local_game_import_t gi;

// =================================================================

// A template class to manage bitflags for any enum type.
Expand Down
51 changes: 20 additions & 31 deletions src/server/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,44 +131,33 @@ void Menu::Render(gentity_t* ent) const {
const int maxOffset = std::max(0, totalScrollable - MAX_VISIBLE_LINES);
const int offset = std::clamp(scrollOffset, 0, maxOffset);

const auto scrollableView = entries | std::views::filter([](const MenuEntry& entry) {
return entry.scrollable;
});
const bool hasAbove = (offset > 0 && totalScrollable > 0);
const bool hasBelow = ((offset + MAX_VISIBLE_LINES) < totalScrollable);

const bool hasAbove = (std::ranges::distance(scrollableView | std::views::take(offset)) > 0);
const bool hasBelow = (std::ranges::distance(scrollableView | std::views::drop(offset + MAX_VISIBLE_LINES)) > 0);
int remainingSkip = offset;
int visibleScrollable = 0;
std::vector<const MenuEntry*> visibleEntries;

const auto afterOffsetView = entries | std::views::drop_while([skipScrollable = offset](const MenuEntry& entry) mutable {
if (!entry.scrollable)
return skipScrollable > 0;
for (const MenuEntry& entry : entries) {
if (remainingSkip > 0) {
if (entry.scrollable)
--remainingSkip;

if (skipScrollable > 0) {
--skipScrollable;
return true;
continue;
}

return false;
});

int visibleScrollable = 0;
const auto visibleEntriesView = afterOffsetView
| std::views::filter([&](const MenuEntry& entry) mutable {
if (entry.scrollable) {
if (visibleScrollable < MAX_VISIBLE_LINES) {
++visibleScrollable;
return true;
}

return false;
}
if (entry.scrollable) {
if (visibleScrollable >= MAX_VISIBLE_LINES)
continue;

return visibleScrollable < MAX_VISIBLE_LINES || offset == maxOffset;
})
| std::views::transform([](const MenuEntry& entry) {
return &entry;
});
++visibleScrollable;
visibleEntries.push_back(&entry);
continue;
}

std::vector<const MenuEntry*> visibleEntries(std::ranges::begin(visibleEntriesView), std::ranges::end(visibleEntriesView));
if (visibleScrollable < MAX_VISIBLE_LINES || offset == maxOffset)
visibleEntries.push_back(&entry);
}
int y = 32;

if (hasAbove) {
Expand Down
9 changes: 8 additions & 1 deletion src/server/monsters/m_berserk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,15 @@ MONSTERINFO_RUN(berserk_run) (gentity_t* self) -> void {
M_SetAnimation(self, &berserk_move_run1);
}

/*
=============
berserk_attack_spike

Executes the berserk spike melee attack with a downward aim offset.
=============
*/
static void berserk_attack_spike(gentity_t* self) {
constexpr Vector3 aim = { MELEE_DISTANCE, 0, -24 };
static const Vector3 aim = { MELEE_DISTANCE, 0, -24 };

if (!fire_hit(self, aim, irandom(5, 11), 80)) // Faster attack -- upwards and backwards
self->monsterInfo.melee_debounce_time = level.time + 1.2_sec;
Expand Down