Palewolf's patch to allow controlling proportion of various objects in themes. Desert and Nature have non-default values
authornemo
Tue, 09 Feb 2010 18:58:44 +0000
changeset 2783 1532fde15179
parent 2782 c00a932f075f
child 2784 1a2e3c7c6a46
Palewolf's patch to allow controlling proportion of various objects in themes. Desert and Nature have non-default values
hedgewars/uLandObjects.pas
share/hedgewars/Data/Themes/Bamboo/theme.cfg
share/hedgewars/Data/Themes/Bath/theme.cfg
share/hedgewars/Data/Themes/Cake/theme.cfg
share/hedgewars/Data/Themes/Castle/theme.cfg
share/hedgewars/Data/Themes/City/theme.cfg
share/hedgewars/Data/Themes/Compost/theme.cfg
share/hedgewars/Data/Themes/Desert/theme.cfg
share/hedgewars/Data/Themes/EarthRise/theme.cfg
share/hedgewars/Data/Themes/Freeway/theme.cfg
share/hedgewars/Data/Themes/Halloween/theme.cfg
share/hedgewars/Data/Themes/Island/theme.cfg
share/hedgewars/Data/Themes/Olympics/theme.cfg
share/hedgewars/Data/Themes/Sheep/theme.cfg
share/hedgewars/Data/Themes/Snow/theme.cfg
share/hedgewars/Data/Themes/Underwater/theme.cfg
share/hedgewars/Data/Themes/cheese/theme.cfg
share/hedgewars/Data/Themes/hell/theme.cfg
share/hedgewars/Data/Themes/nature/theme.cfg
--- a/hedgewars/uLandObjects.pas	Tue Feb 09 18:34:49 2010 +0000
+++ b/hedgewars/uLandObjects.pas	Tue Feb 09 18:58:44 2010 +0000
@@ -260,7 +260,6 @@
     bRes: boolean;
 begin
 cnt:= 0;
-Obj.Maxcnt:= (Obj.Maxcnt * MaxHedgehogs) div 18;
 with Obj do
      begin
      if Maxcnt = 0 then
@@ -405,6 +404,8 @@
 			Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps);
 			Width:= Surf^.w;
 			Height:= Surf^.h;
+			Read(f, Maxcnt);
+			if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true);
 			with inland do
 				begin
 				Read(f, x, y, w, h);
@@ -417,7 +418,6 @@
 					Read(f, x, y, w, h);
 					CheckRect(Width, Height, x, y, w, h)
 					end;
-			Maxcnt:= 3;
 			ReadLn(f)
 			end;
 	end;
@@ -454,19 +454,23 @@
 var i, ii, t: LongInt;
     b: boolean;
 begin
-if ThemeObjects.Count = 0 then exit;
-WriteLnToConsole('Adding theme objects...');
-i:= 1;
-repeat
-    t:= getrandom(ThemeObjects.Count);
-    ii:= t;
-    repeat
-      inc(ii);
-      if ii = ThemeObjects.Count then ii:= 0;
-      b:= TryPut(ThemeObjects.objs[ii])
-    until b or (ii = t);
-    inc(i)
-until (i > MaxCount) or not b;
+	if ThemeObjects.Count = 0 then exit;
+	WriteLnToConsole('Adding theme objects...');
+
+	for i:=0 to ThemeObjects.Count do 
+		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
+	 
+	t := getrandom(1024);
+	repeat
+		b := false;
+		for i:=0 to ThemeObjects.Count do
+			begin
+			ii := (i+t) mod ThemeObjects.Count;
+			
+			if ThemeObjects.objs[ii].Maxcnt <> 0 then
+				b := b or TryPut(ThemeObjects.objs[ii])
+			end;
+	until not b;
 end;
 
 procedure AddSprayObjects(Surface: PSDL_Surface; var SprayObjects: TSprayObjects; MaxCount: Longword);
--- a/share/hedgewars/Data/Themes/Bamboo/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Bamboo/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,13 +6,13 @@
 9
 4
 Flower
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 Bamboo
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 Bamboo2
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 Bamboo3
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 0
 100
 1 1000 50 50
\ No newline at end of file
--- a/share/hedgewars/Data/Themes/Bath/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Bath/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,17 +6,17 @@
 15
 6
 Toothbrush
-120 245 8 15 1 90 6 65 220
+3 120 245 8 15 1 90 6 65 220
 Toothbrush_g
-85 243 10 11 1 89 13 97 211
+3 85 243 10 11 1 89 13 97 211
 Toothbrush_b
-113 245 8 15 1 84 6 66 218
+3 113 245 8 15 1 84 6 66 218
 Duck
-102 253 20 4 1 48 142 150 107
+3 102 253 20 4 1 48 142 150 107
 Duck2
-50 94 16 4 1 5 15 101 72
+3 50 94 16 4 1 5 15 101 72
 Bubble
-37 78 3 2 1 0 0 77 44
+3 37 78 3 2 1 0 0 77 44
 0
 100
 1 0 0 10
--- a/share/hedgewars/Data/Themes/Cake/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Cake/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,13 +6,13 @@
 9
 4
 plant1
-83 215 92 35 1 0 0 250 190
+3 83 215 92 35 1 0 0 250 190
 plant2
-118 115 41 20 1 0 0 159 110
+3 118 115 41 20 1 0 0 159 110
 plant3
-0 115 70 40 1 8 0 60 100
+3 0 115 70 40 1 8 0 60 100
 plant4
-20 200 25 5 1 0 0 70 150
+3 20 200 25 5 1 0 0 70 150
 0
 20
 100 0 30 250
--- a/share/hedgewars/Data/Themes/Castle/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Castle/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,13 +6,13 @@
 5
 4
 Spear
-65 258 175 2 1 0 0 240 215
+3 65 258 175 2 1 0 0 240 215
 Shield
-0 165 163 2 1 0 0 163 140
+3 0 165 163 2 1 0 0 163 140
 Sword
-240 22 17 43 1 8 21 227 80
+3 240 22 17 43 1 8 21 227 80
 Axe
-25 195 90 65 1 40 5 195 175
+3 25 195 90 65 1 40 5 195 175
 0
 25
 3 99999999 0 750
\ No newline at end of file
--- a/share/hedgewars/Data/Themes/City/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/City/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -7,13 +7,13 @@
 45
 4
 plant1
-200 344 54 2 1 0 0 160 215
+3 200 344 54 2 1 0 0 160 215
 plant2
-32 165 65 2 1 0 0 163 140
+3 32 165 65 2 1 0 0 163 140
 plant3
-45 0 14 1 1 23 9 54 57
+3 45 0 14 1 1 23 9 54 57
 plant4
-99 8 1 38 1 42 7 42 103
+3 99 8 1 38 1 42 7 42 103
 0
 1500
 0 0 0 2000
--- a/share/hedgewars/Data/Themes/Compost/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Compost/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,21 +6,21 @@
 16
 8
 Eggshell1
-48 92 78 37 1 0 0 125 47
+3 48 92 78 37 1 0 0 125 47
 Eggshell2
-40 65 80 50 1 0 0 120 50
+3 40 65 80 50 1 0 0 120 50
 Onion1
-0 65 90 30 1 0 0 75 50
+3 0 65 90 30 1 0 0 75 50
 Onion2
-35 80 75 40 2 0 0 30 50 0 36 30 50
+3 35 80 75 40 2 0 0 30 50 0 36 30 50
 Cucumber1
-0 100 75 40 1 80 0 89 95
+3 0 100 75 40 1 80 0 89 95
 Cucumber2
-0 70 125 45 1 0 0 70 55
+3 0 70 125 45 1 0 0 70 55
 Carrot1
-65 0 40 30 1 0 100 100 100
+3 65 0 40 30 1 0 100 100 100
 Carrot2
-0 30 40 35 1 80 65 100 100
+3 0 30 40 35 1 80 65 100 100
 4
 Cucumber3
 1
--- a/share/hedgewars/Data/Themes/Desert/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Desert/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,17 +6,17 @@
 9
 6
 sand
-9 3 4 4 2 1 1 7 27 9 31 5 6
+3 9 3 4 4 2 1 1 7 27 9 31 5 6
 buzzard
-17 318 4 21 1 51 91 289 241
+3 17 318 4 21 1 51 91 289 241
 cobra
-65 230 57 4 1 28 0 206 202
+3 65 230 57 4 1 28 0 206 202
 cactus
-27 440 73 10 1 0 0 258 384
+3 27 440 73 10 1 0 0 258 384
 rock1
-101 116 10 1 1 0 0 173 99
+3 101 116 10 1 1 0 0 173 99
 rock2
-22 27 3 1 1 8 1 30 15
+3 22 27 3 1 1 8 1 30 15
 0
 0
 2 500 100 300
--- a/share/hedgewars/Data/Themes/EarthRise/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/EarthRise/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,9 +6,9 @@
 0
 2
 Rock
-65 258 175 2 1 0 0 240 215
+3 65 258 175 2 1 0 0 240 215
 RockShort
-0 165 163 2 1 0 0 163 140
+3 0 165 163 2 1 0 0 163 140
 0
 20
 1 0 20 0
\ No newline at end of file
--- a/share/hedgewars/Data/Themes/Freeway/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Freeway/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,9 +6,9 @@
 9
 2
 Tire
-83 215 92 35 1 0 0 250 190
+3 83 215 92 35 1 0 0 250 190
 AppleSmall
-40 0 25 1 1 0 35 100 65
+3 40 0 25 1 1 0 35 100 65
 4
 TireDirt
 2
--- a/share/hedgewars/Data/Themes/Halloween/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Halloween/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,9 +6,9 @@
 9
 2
 Rock
-65 258 175 2 1 0 0 240 215
+3 65 258 175 2 1 0 0 240 215
 RockShort
-0 165 163 2 1 0 0 163 140
+3 0 165 163 2 1 0 0 163 140
 0
 20
 7 130 0 5
--- a/share/hedgewars/Data/Themes/Island/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Island/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,15 +6,15 @@
 9
 5
 anchor
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 plant1
-10 192 60 2 1 33 0 149 152
+3 10 192 60 2 1 33 0 149 152
 plant2
-55 218 30 2 1 0 0 240 175
+3 55 218 30 2 1 0 0 240 175
 plant3
-20 0 60 1 1 0 15 100 44
+3 20 0 60 1 1 0 15 100 44
 plant4
-78 5 2 60 1 0 0 65 110
+3 78 5 2 60 1 0 0 65 110
 0
 100
 2 500 100 300
--- a/share/hedgewars/Data/Themes/Olympics/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Olympics/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -1,19 +1,19 @@
-177 190 216
-101 97 63
-$54 $5C $9D
-$34 $3C $7D
-$80
-Nature.ogg
-9
-4
-Statue
-42 258 115 2 1 0 0 165 240
-Column01
-21 258 80 2 1 0 0 110 240
-Column02
-12 258 76 2 1 0 0 110 240
-Column03
-3 173 84 2 1 0 0 90 155
-0
-50
+177 190 216
+101 97 63
+$54 $5C $9D
+$34 $3C $7D
+$80
+Nature.ogg
+9
+4
+Statue
+3 42 258 115 2 1 0 0 165 240
+Column01
+3 21 258 80 2 1 0 0 110 240
+Column02
+3 12 258 76 2 1 0 0 110 240
+Column03
+3 3 173 84 2 1 0 0 90 155
+0
+50
 1 1000 0 10
\ No newline at end of file
--- a/share/hedgewars/Data/Themes/Sheep/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Sheep/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,19 +6,19 @@
 4
 7
 fleur
-45 127 50 3 1 0 0 120 105
+3 45 127 50 3 1 0 0 120 105
 mouton1
-88 222 122 4 1 0 0 275 200
+3 88 222 122 4 1 0 0 275 200
 mouton2
-84 245 125 20 1 0 0 275 200
+3 84 245 125 20 1 0 0 275 200
 mouton3
-152 255 176 15 1 0 0 440 230
+3 152 255 176 15 1 0 0 440 230
 mouton4
-148 245 162 20 1 0 0 440 205
+3 148 245 162 20 1 0 0 440 205
 barriere
-34 190 300 10 1 0 0 381 140
+3 34 190 300 10 1 0 0 381 140
 rocher
-16 90 69 3 1 0 0 110 65
+3 16 90 69 3 1 0 0 110 65
 8
 grass
 7
--- a/share/hedgewars/Data/Themes/Snow/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Snow/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,13 +6,13 @@
 9
 4
 plant1
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 plant2
-0 85 25 25 2 0 0 170 70 50 70 120 40
+3 0 85 25 25 2 0 0 170 70 50 70 120 40
 plant3
-26 0 48 1 1 25 15 50 60
+3 26 0 48 1 1 25 15 50 60
 plant4
-45 4 1 45 1 20 45 20 60
+3 45 4 1 45 1 20 45 20 60
 0
 100
 3 99999999 100 300
--- a/share/hedgewars/Data/Themes/Underwater/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/Underwater/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,15 +6,15 @@
 9
 5
 anchor
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 clam
-60 131 16 2 1 0 0 150 117
+3 60 131 16 2 1 0 0 150 117
 crab
-78 256 96 2 1 3 60 237 155
+3 78 256 96 2 1 3 60 237 155
 coral
-10 193 38 32 2 128 66 66 94 39 0 88 167
+3 10 193 38 32 2 128 66 66 94 39 0 88 167
 coral2
-119 146 23 22 1 5 0 123 130
+3 119 146 23 22 1 5 0 123 130
 0
 20
 20 150 0 5
--- a/share/hedgewars/Data/Themes/cheese/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/cheese/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,14 +6,14 @@
 9
 5
 cheese
-60 80 55 30 1 0 0 140 70
+3 60 80 55 30 1 0 0 140 70
 mouseright
-85 162 60 20 1 6 6 200 140
+3 85 162 60 20 1 6 6 200 140
 mouseleft
-60 162 63 20 1 6 6 200 140
+3 60 162 63 20 1 6 6 200 140
 knife
-90 130 50 20 1 140 0 160 110
+3 90 130 50 20 1 140 0 160 110
 fork
-240 130 10 30 1 0 0 170 120
+3 240 130 10 30 1 0 0 170 120
 0
 0
--- a/share/hedgewars/Data/Themes/hell/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/hell/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -6,13 +6,13 @@
 9
 4
 plant1
-83 215 92 35 1 0 0 250 190
+3 83 215 92 35 1 0 0 250 190
 plant2
-118 115 41 20 1 0 0 159 110
+3 118 115 41 20 1 0 0 159 110
 plant3
-0 115 70 40 1 8 0 60 100
+3 0 115 70 40 1 8 0 60 100
 plant4
-20 200 25 5 1 0 0 70 150
+3 20 200 25 5 1 0 0 70 150
 0
 20
 30 0 0 250
--- a/share/hedgewars/Data/Themes/nature/theme.cfg	Tue Feb 09 18:34:49 2010 +0000
+++ b/share/hedgewars/Data/Themes/nature/theme.cfg	Tue Feb 09 18:58:44 2010 +0000
@@ -7,23 +7,23 @@
 9
 9
 plant1
-65 258 80 2 1 0 0 240 215
+3 65 258 80 2 1 0 0 240 215
 plant2
-21 163 33 15 1 60 62 87 95
+3 21 163 33 15 1 60 62 87 95
 plant3
-40 0 25 1 1 0 35 100 65
+3 40 0 25 1 1 0 35 100 65
 plant4
-98 10 2 25 1 0 0 70 110
+3 98 10 2 25 1 0 0 70 110
 mole
-0 129 161 14 1 13 0 142 99
+1 0 129 161 14 1 13 0 142 99
 mole2
-0 129 161 14 1 13 0 142 99
+1 0 129 161 14 1 13 0 142 99
 mole3
-0 129 161 14 1 13 0 142 99
+1 0 129 161 14 1 13 0 142 99
 butterfly
-43 176 56 6 1 21 14 91 46
+1 43 176 56 6 1 21 14 91 46
 snail
-51 94 52 3 1 0 0 135 87
+3 51 94 52 3 1 0 0 135 87
 0
 55
-40 99999999 30 200
\ No newline at end of file
+40 99999999 30 200