Fix /client listmodels from MoreModels plugin

This commit is contained in:
UnknownShadow200 2019-02-09 16:27:44 +11:00
parent 9419d55de4
commit 778a49130c
5 changed files with 14 additions and 26 deletions

View File

@ -260,12 +260,7 @@ void Camera_CycleActive(void) {
static struct Camera* cams_head; static struct Camera* cams_head;
static struct Camera* cams_tail; static struct Camera* cams_tail;
void Camera_Register(struct Camera* cam) { void Camera_Register(struct Camera* cam) {
if (!cams_head) { LinkedList_Add(cam, cams_head, cams_tail);
cams_head = cam; /* want a circular linked list */
} else {
cams_tail->Next = cam;
}
cams_tail = cam;
cam->Next = cams_head; cam->Next = cams_head;
} }

View File

@ -216,14 +216,7 @@ static bool Commands_IsCommandPrefix(const String* str) {
} }
void Commands_Register(struct ChatCommand* cmd) { void Commands_Register(struct ChatCommand* cmd) {
if (!cmds_head) { LinkedList_Add(cmd, cmds_head, cmds_tail);
cmds_head = cmd;
} else {
cmds_tail->Next = cmd;
}
cmds_tail = cmd;
cmd->Next = NULL;
} }
static struct ChatCommand* Commands_GetMatch(const String* cmdName) { static struct ChatCommand* Commands_GetMatch(const String* cmdName) {

View File

@ -32,4 +32,10 @@ if (j - left <= right - i) {\
if (i < right) { quickSort(i, right); }\ if (i < right) { quickSort(i, right); }\
right = j;\ right = j;\
} }
#define LinkedList_Add(item, head, tail)\
if (!head) { head = item; } else { tail->Next = item; }\
tail = item;\
item->Next = NULL;
#endif #endif

View File

@ -67,13 +67,7 @@ String Game_IPAddress = String_FromArray(Game_IPAddressBuffer);
static struct IGameComponent* comps_head; static struct IGameComponent* comps_head;
static struct IGameComponent* comps_tail; static struct IGameComponent* comps_tail;
void Game_AddComponent(struct IGameComponent* comp) { void Game_AddComponent(struct IGameComponent* comp) {
if (!comps_head) { LinkedList_Add(comp, comps_head, comps_tail);
comps_head = comp;
} else {
comps_tail->Next = comp;
}
comps_tail = comp;
comp->Next = NULL;
} }
int ScheduledTask_Add(double interval, ScheduledTaskCallback callback) { int ScheduledTask_Add(double interval, ScheduledTaskCallback callback) {

View File

@ -364,7 +364,9 @@ void BoxDesc_ZQuad(struct Model* m, int texX, int texY, int texWidth, int texHei
*--------------------------------------------------------Models common----------------------------------------------------* *--------------------------------------------------------Models common----------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static struct Model* models_head; static struct Model* models_head;
static struct Model* models_tail;
static struct ModelTex* textures_head; static struct ModelTex* textures_head;
static struct ModelTex* textures_tail;
#define Model_RetSize(x,y,z) static Vector3 P = { (x)/16.0f,(y)/16.0f,(z)/16.0f }; e->Size = P; #define Model_RetSize(x,y,z) static Vector3 P = { (x)/16.0f,(y)/16.0f,(z)/16.0f }; e->Size = P;
#define Model_RetAABB(x1,y1,z1, x2,y2,z2) static struct AABB BB = { (x1)/16.0f,(y1)/16.0f,(z1)/16.0f, (x2)/16.0f,(y2)/16.0f,(z2)/16.0f }; e->ModelAABB = BB; #define Model_RetAABB(x1,y1,z1, x2,y2,z2) static struct AABB BB = { (x1)/16.0f,(y1)/16.0f,(z1)/16.0f, (x2)/16.0f,(y2)/16.0f,(z2)/16.0f }; e->ModelAABB = BB;
@ -409,13 +411,11 @@ struct ModelTex* Model_GetTexture(const String* name) {
} }
void Model_Register(struct Model* model) { void Model_Register(struct Model* model) {
model->Next = models_head; LinkedList_Add(model, models_head, models_tail);
models_head = model;
} }
void Model_RegisterTexture(struct ModelTex* tex) { void Model_RegisterTexture(struct ModelTex* tex) {
tex->Next = textures_head; LinkedList_Add(tex, textures_head, textures_tail);
textures_head = tex;
} }
static void Models_TextureChanged(void* obj, struct Stream* stream, const String* name) { static void Models_TextureChanged(void* obj, struct Stream* stream, const String* name) {