+void Mod_LoadLightList(void)
+{
+ int a, n, numlights;
+ char lightsfilename[1024], *s, *t, *lightsstring;
+ mlight_t *e;
+
+ strcpy(lightsfilename, loadmodel->name);
+ COM_StripExtension(lightsfilename, lightsfilename);
+ strcat(lightsfilename, ".lights");
+ s = lightsstring = (char *) COM_LoadFile (lightsfilename, false);
+ if (s)
+ {
+ numlights = 0;
+ while (*s)
+ {
+ while (*s && *s != '\n')
+ s++;
+ if (!*s)
+ {
+ Mem_Free(lightsstring);
+ Host_Error("lights file must end with a newline\n");
+ }
+ s++;
+ numlights++;
+ }
+ loadmodel->lights = Mem_Alloc(loadmodel->mempool, numlights * sizeof(mlight_t));
+ s = lightsstring;
+ n = 0;
+ while (*s && n < numlights)
+ {
+ t = s;
+ while (*s && *s != '\n')
+ s++;
+ if (!*s)
+ {
+ Mem_Free(lightsstring);
+ Host_Error("misparsed lights file!\n");
+ }
+ e = loadmodel->lights + n;
+ *s = 0;
+ a = sscanf(t, "%f %f %f %f %f %f %f %f %f %f %f %f %f %d", &e->origin[0], &e->origin[1], &e->origin[2], &e->falloff, &e->light[0], &e->light[1], &e->light[2], &e->subtract, &e->spotdir[0], &e->spotdir[1], &e->spotdir[2], &e->spotcone, &e->distbias, &e->style);
+ *s = '\n';
+ if (a != 14)
+ {
+ Mem_Free(lightsstring);
+ Host_Error("invalid lights file, found %d parameters on line %i, should be 14 parameters (origin[0] origin[1] origin[2] falloff light[0] light[1] light[2] subtract spotdir[0] spotdir[1] spotdir[2] spotcone distancebias style)\n", a, n + 1);
+ }
+ s++;
+ n++;
+ }
+ if (*s)
+ {
+ Mem_Free(lightsstring);
+ Host_Error("misparsed lights file!\n");
+ }
+ loadmodel->numlights = numlights;
+ Mem_Free(lightsstring);
+ }
+}
+