50 function GenPreview: TPreview; |
50 function GenPreview: TPreview; |
51 procedure CheckLandDigest(s: shortstring); |
51 procedure CheckLandDigest(s: shortstring); |
52 function LandBackPixel(x, y: LongInt): LongWord; |
52 function LandBackPixel(x, y: LongInt): LongWord; |
53 |
53 |
54 implementation |
54 implementation |
55 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, Adler32, uIO, uLandTexture; |
55 uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, Adler32, uIO, uLandTexture, sysutils; |
56 |
56 |
57 operator=(const a, b: direction) c: Boolean; |
57 operator=(const a, b: direction) c: Boolean; |
58 begin |
58 begin |
59 c := (a.x = b.x) and (a.y = b.y); |
59 c := (a.x = b.x) and (a.y = b.y); |
60 end; |
60 end; |
1163 |
1163 |
1164 procedure LoadMap; |
1164 procedure LoadMap; |
1165 var tmpsurf: PSDL_Surface; |
1165 var tmpsurf: PSDL_Surface; |
1166 s: shortstring; |
1166 s: shortstring; |
1167 f: textfile; |
1167 f: textfile; |
|
1168 mapName: shortstring; |
1168 begin |
1169 begin |
1169 isMap:= true; |
1170 isMap:= true; |
1170 WriteLnToConsole('Loading land from file...'); |
1171 WriteLnToConsole('Loading land from file...'); |
1171 AddProgress; |
1172 AddProgress; |
1172 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1173 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
|
1174 if tmpsurf = nil then |
|
1175 begin |
|
1176 mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
|
1177 tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
|
1178 end; |
1173 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); |
1179 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); |
1174 |
1180 |
1175 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what |
1181 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what |
1176 s:= Pathz[ptMapCurrent] + '/map.cfg'; |
1182 s:= Pathz[ptMapCurrent] + '/map.cfg'; |
1177 WriteLnToConsole('Fetching map HH limit'); |
1183 WriteLnToConsole('Fetching map HH limit'); |
|
1184 {$I-} |
1178 Assign(f, s); |
1185 Assign(f, s); |
1179 filemode:= 0; // readonly |
1186 filemode:= 0; // readonly |
1180 Reset(f); |
1187 Reset(f); |
|
1188 if IOResult <> 0 then |
|
1189 begin |
|
1190 s:= Pathz[ptMissionMaps] + '/' + mapName + '/map.cfg'; |
|
1191 Assign(f, s); |
|
1192 Reset(f); |
|
1193 end; |
1181 Readln(f); |
1194 Readln(f); |
1182 if not eof(f) then Readln(f, MaxHedgehogs); |
1195 if not eof(f) then Readln(f, MaxHedgehogs); |
1183 |
1196 {$I+} |
1184 if (MaxHedgehogs = 0) then MaxHedgehogs:= 18; |
1197 if (MaxHedgehogs = 0) then MaxHedgehogs:= 18; |
1185 |
1198 |
1186 playHeight:= tmpsurf^.h; |
1199 playHeight:= tmpsurf^.h; |
1187 playWidth:= tmpsurf^.w; |
1200 playWidth:= tmpsurf^.w; |
1188 leftX:= (LAND_WIDTH - playWidth) div 2; |
1201 leftX:= (LAND_WIDTH - playWidth) div 2; |