-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a spawned player count to the scoreboard #316
base: master
Are you sure you want to change the base?
Changes from all commits
1e0a84a
2fefeb4
d1deb74
a7bc671
be8a631
9119377
652651e
c351ba7
bca9508
b66b1a9
be0fab1
66e4b05
7a273cd
26b5927
0d7c2ac
4f804b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <patch_common/MemUtils.h> | ||
#include "localize.h" | ||
#include "player/player.h" | ||
#include "os/vtypes.h" | ||
#include "os/timestamp.h" | ||
#include "os/string.h" | ||
#include "os/array.h" | ||
#include <common/utils/list-utils.h> | ||
|
||
namespace rf | ||
{ | ||
|
@@ -88,6 +92,16 @@ namespace rf | |
NG_TYPE_TEAMDM = 2, | ||
}; | ||
|
||
inline std::string_view multi_game_type_name(const NetGameType game_type) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you put those functions ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (game_type == NG_TYPE_DM) { | ||
return std::string_view{strings::deathmatch}; | ||
} else if (game_type == NG_TYPE_CTF) { | ||
return std::string_view{strings::capture_the_flag}; | ||
} else { | ||
return std::string_view{strings::team_deathmatch}; | ||
} | ||
}; | ||
|
||
enum NetGameFlags | ||
{ | ||
NG_FLAG_DEBUG_SCOREBOARD = 0x1, | ||
|
@@ -151,6 +165,10 @@ namespace rf | |
static auto& multi_tdm_get_red_team_score = addr_as_ref<int()>(0x004828F0); // returns ubyte in vanilla game | ||
static auto& multi_tdm_get_blue_team_score = addr_as_ref<int()>(0x00482900); // returns ubyte in vanilla game | ||
static auto& multi_num_players = addr_as_ref<int()>(0x00484830); | ||
[[nodiscard]] inline int32_t multi_num_spawned_players() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer a name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True but no one speaks like that. It is not idiomatic. |
||
const auto f = [] (auto& p) { return !player_is_dead(&p) && !player_is_dying(&p); }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not want to split this line. It works better in a single line imo. |
||
return std::ranges::count_if(SinglyLinkedList{player_list}, f); | ||
} | ||
static auto& multi_kick_player = addr_as_ref<void(Player *player)>(0x0047BF00); | ||
static auto& multi_ban_ip = addr_as_ref<void(const NetAddr& addr)>(0x0046D0F0); | ||
static auto& multi_set_next_weapon = addr_as_ref<void(int weapon_type)>(0x0047FCA0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will it work if someone plays with resolution 1024x768 or less? Do we always use TTF font for that header? If not how separator will look like in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it will not render for the small hud I think. But does it really matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I sometimes use that resolution myself to test things in window. It can't crash, that's obvious. But it would be nice to also look good. If it looks okayish I guess we can leave it like this. Ultimately if we want to introduce more characters in the future (e.g. unicode?) we may want to fully stop using builtin fonts, then the problem will solve itself