- k = -1;
- for (i = 0;i < SHOWLMP_MAXLABELS;i++)
- if (showlmp[i].isactive)
- {
- if (strcmp(showlmp[i].label, lmplabel) == 0)
- {
- k = i;
- break; // drop out to replace it
- }
- }
- else if (k < 0) // find first empty one to replace
- k = i;
- if (k < 0)
- return; // none found to replace
- // change existing one
- showlmp[k].isactive = true;
- strlcpy (showlmp[k].label, lmplabel, sizeof (showlmp[k].label));
- strlcpy (showlmp[k].pic, picname, sizeof (showlmp[k].pic));
- showlmp[k].x = x;
- showlmp[k].y = y;
+ if (!cl.showlmps || cl.num_showlmps >= cl.max_showlmps)
+ {
+ showlmp_t *oldshowlmps = cl.showlmps;
+ cl.max_showlmps += 16;
+ cl.showlmps = Mem_Alloc(cls.levelmempool, cl.max_showlmps * sizeof(showlmp_t));
+ if (cl.num_showlmps)
+ memcpy(cl.showlmps, oldshowlmps, cl.num_showlmps * sizeof(showlmp_t));
+ if (oldshowlmps)
+ Mem_Free(oldshowlmps);
+ }
+ for (k = 0;k < cl.max_showlmps;k++)
+ if (cl.showlmps[k].isactive && !strcmp(cl.showlmps[k].label, lmplabel))
+ break;
+ if (k == cl.max_showlmps)
+ for (k = 0;k < cl.max_showlmps;k++)
+ if (!cl.showlmps[k].isactive)
+ break;
+ cl.showlmps[k].isactive = true;
+ strlcpy (cl.showlmps[k].label, lmplabel, sizeof (cl.showlmps[k].label));
+ strlcpy (cl.showlmps[k].pic, picname, sizeof (cl.showlmps[k].pic));
+ cl.showlmps[k].x = x;
+ cl.showlmps[k].y = y;
+ cl.num_showlmps = max(cl.num_showlmps, k + 1);