Port TabList to C.

This commit is contained in:
UnknownShadow200 2018-01-14 08:29:30 +11:00
parent 8c30aca49a
commit f1e697898e
2 changed files with 50 additions and 0 deletions

View File

@ -391,4 +391,43 @@ void Entities_DrawShadows(void) {
Gfx_SetDepthWrite(true);
Gfx_SetAlphaBlending(false);
Gfx_SetTexturing(false);
}
bool TabList_Remove(EntityID id) {
if (TabList_PlayerNames[id] == 0 && TabList_ListNames[id] == 0 && TabList_GroupNames[id] == 0) return false;
StringsBuffer_Remove(&TabList_Buffer, TabList_PlayerNames[id]); TabList_PlayerNames[id] = 0;
StringsBuffer_Remove(&TabList_Buffer, TabList_ListNames[id]); TabList_ListNames[id] = 0;
StringsBuffer_Remove(&TabList_Buffer, TabList_GroupNames[id]); TabList_GroupNames[id] = 0;
TabList_GroupRanks[id] = 0;
return true;
}
void TabList_Set(EntityID id, STRING_PURE String* player, STRING_PURE String* list, STRING_PURE String* group, UInt8 rank) {
UInt8 playerNameBuffer[String_BufferSize(STRING_SIZE)];
String playerName = String_InitAndClearArray(playerNameBuffer);
String_AppendColorless(&playerName, player);
TabList_PlayerNames[id] = TabList_Buffer.Count; StringsBuffer_Add(&TabList_Buffer, &playerName);
TabList_ListNames[id] = TabList_Buffer.Count; StringsBuffer_Add(&TabList_Buffer, list);
TabList_GroupNames[id] = TabList_Buffer.Count; StringsBuffer_Add(&TabList_Buffer, group);
TabList_GroupRanks[id] = rank;
}
void TabList_Init(void) { StringBuffers_Init(&TabList_Buffer); }
void TabList_Free(void) { StringsBuffer_Free(&TabList_Buffer); }
void TabList_Reset(void) {
Platform_MemSet(TabList_PlayerNames, 0, sizeof(TabList_PlayerNames));
Platform_MemSet(TabList_ListNames, 0, sizeof(TabList_ListNames));
Platform_MemSet(TabList_GroupNames, 0, sizeof(TabList_GroupNames));
Platform_MemSet(TabList_GroupRanks, 0, sizeof(TabList_GroupRanks));
TabList_Buffer.Count = 0; /* TODO: Should we be freeing the buffer here? */
}
IGameComponent TabList_MakeComponent(void) {
IGameComponent comp = IGameComponent_MakeEmpty();
comp.Init = TabList_Init;
comp.Free = TabList_Free;
comp.Reset = TabList_Reset;
return comp;
}

View File

@ -116,4 +116,15 @@ void Entities_Free(void);
void Entities_Remove(EntityID id);
EntityID Entities_GetCloset(Entity* src);
void Entities_DrawShadows(void);
#define TABLIST_MAX_NAMES 256
StringsBuffer TabList_Buffer;
UInt32 TabList_PlayerNames[TABLIST_MAX_NAMES];
UInt32 TabList_ListNames[TABLIST_MAX_NAMES];
UInt32 TabList_GroupNames[TABLIST_MAX_NAMES];
UInt8 TabList_GroupRanks[TABLIST_MAX_NAMES];
bool TabList_Remove(EntityID id);
void TabList_Set(EntityID id, STRING_PURE String* player, STRING_PURE String* list, STRING_PURE String* group, UInt8 rank);
IGameComponent TabList_MakeComponent(void);
#endif