Skip to content

Commit

Permalink
refactor: simplified level functions
Browse files Browse the repository at this point in the history
  • Loading branch information
WillowSauceR authored and WillowSauceR committed Aug 29, 2023
1 parent f7d1085 commit a9840c2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/mediaplayer/mc/level.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

struct level;

struct player *get_player_by_xuid(struct level *level, const char *xuid);
struct player *get_player_by_xuid(const char *xuid);

extern struct level *g_level;
4 changes: 2 additions & 2 deletions src/mc/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

struct level *g_level = NULL;

struct player *get_player_by_xuid(struct level *level, const char *xuid)
struct player *get_player_by_xuid(const char *xuid)
{
struct string *xuid_cpp_str = std_string_string(xuid);
struct player *player =
TLCALL("?getPlayerByXuid@Level@@UEBAPEAVPlayer@@AEBV?$basic_string@"
"DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z",
struct player *(*)(struct level *level, struct string *xuid),
level, xuid_cpp_str);
g_level, xuid_cpp_str);
free(xuid_cpp_str);
return player;
}
4 changes: 2 additions & 2 deletions src/music_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void music_queue_delete_player(long long xuid)
free(curr_node);
char player_xuid[PLAYER_XUID_STR_LEN];
_i64toa(xuid, player_xuid, 10);
struct player *player = get_player_by_xuid(g_level, player_xuid);
struct player *player = get_player_by_xuid(player_xuid);
if (is_player(player))
send_boss_event_packet(player, "", 0, BOSS_BAR_HIDE);
video_queue_delete_player(xuid);
Expand All @@ -151,7 +151,7 @@ void send_music_sound_packet(void)
struct music_queue_node *music_queue_node_curr = music_queue_head;
while (music_queue_node_curr != NULL) {
sprintf_s(player_xuid, PLAYER_XUID_STR_LEN, "%lld", music_queue_node_curr->xuid);
player = get_player_by_xuid(g_level, player_xuid);
player = get_player_by_xuid(player_xuid);
if (!player) {
struct music_queue_node *to_delete = music_queue_node_curr;
music_queue_node_curr = music_queue_node_curr->next;
Expand Down
2 changes: 1 addition & 1 deletion src/video_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void play_video(struct video_queue *video_queue_node, struct map_item_saved_data
return;
char player_xuid[PLAYER_XUID_STR_LEN];
sprintf_s(player_xuid, PLAYER_XUID_STR_LEN, "%lld", video_queue_node->xuid);
struct player *player = get_player_by_xuid(g_level, player_xuid);
struct player *player = get_player_by_xuid(player_xuid);
char filepath[260];

if (((time_t)clock() - video_queue_node->start_time) <= 0)
Expand Down

0 comments on commit a9840c2

Please sign in to comment.