MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / TabList_Set

Function TabList_Set

src/Entity.c:614–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614void TabList_Set(EntityID id, const cc_string* player_, const cc_string* list, const cc_string* group, cc_uint8 rank) {
615 cc_string oldPlayer, oldList, oldGroup;
616 cc_uint8 oldRank;
617 struct Event_Int* events;
618
619 /* Player name shouldn't have colour codes */
620 /* (intended for e.g. tab autocomplete) */
621 cc_string player; char playerBuffer[STRING_SIZE];
622 String_InitArray(player, playerBuffer);
623 String_AppendColorless(&player, player_);
624
625 if (TabList.NameOffsets[id]) {
626 oldPlayer = TabList_UNSAFE_GetPlayer(id);
627 oldList = TabList_UNSAFE_GetList(id);
628 oldGroup = TabList_UNSAFE_GetGroup(id);
629 oldRank = TabList.GroupRanks[id];
630
631 /* Don't redraw the tab list if nothing changed */
632 if (String_Equals(&player, &oldPlayer) && String_Equals(list, &oldList)
633 && String_Equals(group, &oldGroup) && rank == oldRank) return;
634
635 events = &TabListEvents.Changed;
636 } else {
637 events = &TabListEvents.Added;
638 }
639 TabList_Delete(id);
640
641 StringsBuffer_Add(&TabList._buffer, &player);
642 StringsBuffer_Add(&TabList._buffer, list);
643 StringsBuffer_Add(&TabList._buffer, group);
644
645 TabList.NameOffsets[id] = TabList._buffer.count;
646 TabList.GroupRanks[id] = rank;
647 Event_RaiseInt(events, id);
648}
649
650static void Tablist_Init(void) {
651 TabList_Set(ENTITIES_SELF_ID, &Game_Username, &Game_Username, &String_Empty, 0);

Callers 3

Tablist_InitFunction · 0.85
Classic_AddEntityFunction · 0.85
CPE_ExtAddPlayerNameFunction · 0.85

Calls 5

String_AppendColorlessFunction · 0.85
String_EqualsFunction · 0.85
TabList_DeleteFunction · 0.85
StringsBuffer_AddFunction · 0.85
Event_RaiseIntFunction · 0.85

Tested by

no test coverage detected