equal
deleted
inserted
replaced
258 ar: array[0..MaxPointsIndex] of TPoint; |
258 ar: array[0..MaxPointsIndex] of TPoint; |
259 cnt, i: Longword; |
259 cnt, i: Longword; |
260 bRes: boolean; |
260 bRes: boolean; |
261 begin |
261 begin |
262 cnt:= 0; |
262 cnt:= 0; |
263 Obj.Maxcnt:= (Obj.Maxcnt * MaxHedgehogs) div 18; |
|
264 with Obj do |
263 with Obj do |
265 begin |
264 begin |
266 if Maxcnt = 0 then |
265 if Maxcnt = 0 then |
267 exit(false); |
266 exit(false); |
268 x:= 0; |
267 x:= 0; |
403 with ThemeObjects.objs[i] do |
402 with ThemeObjects.objs[i] do |
404 begin |
403 begin |
405 Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps); |
404 Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps); |
406 Width:= Surf^.w; |
405 Width:= Surf^.w; |
407 Height:= Surf^.h; |
406 Height:= Surf^.h; |
|
407 Read(f, Maxcnt); |
|
408 if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); |
408 with inland do |
409 with inland do |
409 begin |
410 begin |
410 Read(f, x, y, w, h); |
411 Read(f, x, y, w, h); |
411 CheckRect(Width, Height, x, y, w, h) |
412 CheckRect(Width, Height, x, y, w, h) |
412 end; |
413 end; |
415 with outland[ii] do |
416 with outland[ii] do |
416 begin |
417 begin |
417 Read(f, x, y, w, h); |
418 Read(f, x, y, w, h); |
418 CheckRect(Width, Height, x, y, w, h) |
419 CheckRect(Width, Height, x, y, w, h) |
419 end; |
420 end; |
420 Maxcnt:= 3; |
|
421 ReadLn(f) |
421 ReadLn(f) |
422 end; |
422 end; |
423 end; |
423 end; |
424 |
424 |
425 // sprays |
425 // sprays |
452 |
452 |
453 procedure AddThemeObjects(var ThemeObjects: TThemeObjects; MaxCount: LongInt); |
453 procedure AddThemeObjects(var ThemeObjects: TThemeObjects; MaxCount: LongInt); |
454 var i, ii, t: LongInt; |
454 var i, ii, t: LongInt; |
455 b: boolean; |
455 b: boolean; |
456 begin |
456 begin |
457 if ThemeObjects.Count = 0 then exit; |
457 if ThemeObjects.Count = 0 then exit; |
458 WriteLnToConsole('Adding theme objects...'); |
458 WriteLnToConsole('Adding theme objects...'); |
459 i:= 1; |
459 |
460 repeat |
460 for i:=0 to ThemeObjects.Count do |
461 t:= getrandom(ThemeObjects.Count); |
461 ThemeObjects.objs[i].Maxcnt := max(1, (ThemeObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map |
462 ii:= t; |
462 |
463 repeat |
463 t := getrandom(1024); |
464 inc(ii); |
464 repeat |
465 if ii = ThemeObjects.Count then ii:= 0; |
465 b := false; |
466 b:= TryPut(ThemeObjects.objs[ii]) |
466 for i:=0 to ThemeObjects.Count do |
467 until b or (ii = t); |
467 begin |
468 inc(i) |
468 ii := (i+t) mod ThemeObjects.Count; |
469 until (i > MaxCount) or not b; |
469 |
|
470 if ThemeObjects.objs[ii].Maxcnt <> 0 then |
|
471 b := b or TryPut(ThemeObjects.objs[ii]) |
|
472 end; |
|
473 until not b; |
470 end; |
474 end; |
471 |
475 |
472 procedure AddSprayObjects(Surface: PSDL_Surface; var SprayObjects: TSprayObjects; MaxCount: Longword); |
476 procedure AddSprayObjects(Surface: PSDL_Surface; var SprayObjects: TSprayObjects; MaxCount: Longword); |
473 var i: Longword; |
477 var i: Longword; |
474 ii, t: LongInt; |
478 ii, t: LongInt; |