Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [55a050f2d9]:

To Artifact [f7a8e77b3c]:


196
197
198
199
200
201
202

203
204
205
206
207
208
209

const char*load_level(int lvl) {
  // Load level by ID. Returns null pointer if successful, or an error message if it failed.
  long sz=0;
  unsigned char*buf=lvl>=0?read_lump(FIL_LEVEL,lvl,&sz,0):0;
  unsigned char*p=buf;
  unsigned char*end=buf+sz;

  int i,n,x,y,z;
  Uint16 lo=0;
  Uint32 o;
  Uint32 mru[2];
  if(lvl<0 && level_index && -lvl<=level_nindex) {
    lo=-lvl;
    lvl=level_index[~lvl];







>







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

const char*load_level(int lvl) {
  // Load level by ID. Returns null pointer if successful, or an error message if it failed.
  long sz=0;
  unsigned char*buf=lvl>=0?read_lump(FIL_LEVEL,lvl,&sz,0):0;
  unsigned char*p=buf;
  unsigned char*end=buf+sz;
  unsigned char*q;
  int i,n,x,y,z;
  Uint16 lo=0;
  Uint32 o;
  Uint32 mru[2];
  if(lvl<0 && level_index && -lvl<=level_nindex) {
    lo=-lvl;
    lvl=level_index[~lvl];
308
309
310
311
312
313
314
315













316
317
318
319
320
321
322
        objects[o]->x=x;
        objects[o]->y=y;
        pflink(o);
        n=0;
      }
    }
  }
  // skip level strings for now













  if(p>end) goto bad1;
  free(buf);
  level_id=lvl;
  level_ord=lo;
  if(level_index && !lo) {
    for(i=0;i<level_nindex;i++) if(level_index[i]==lvl) {
      level_ord=i+1;







|
>
>
>
>
>
>
>
>
>
>
>
>
>







309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
        objects[o]->x=x;
        objects[o]->y=y;
        pflink(o);
        n=0;
      }
    }
  }
  // Level strings
  i=0;
  while(p<end) {
    if(i>=max_objects) goto bad3;
    q=memchr(p,0,end-p);
    if(!q) goto bad1;
    levelstrings=realloc(levelstrings,(i+1)*sizeof(char*));
    if(!levelstrings) fatal("Allocation failed\n");
    levelstrings[i]=strdup(p);
    if(!levelstrings[i]) fatal("Allocation failed\n");
    p=q+1;
    i++;
  }
  nlevelstrings=i;
  if(p>end) goto bad1;
  free(buf);
  level_id=lvl;
  level_ord=lo;
  if(level_index && !lo) {
    for(i=0;i<level_nindex;i++) if(level_index[i]==lvl) {
      level_ord=i+1;