~ubuntu-branches/ubuntu/trusty/hedgewars/trusty-proposed

« back to all changes in this revision

Viewing changes to hedgewars/uLand.pas

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-11-20 18:31:17 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20111120183117-pjhz1n2pvnmxa246
Tags: 0.9.17-1
* [Paul Wise]
 * Mention the homing bee in the package description (Closes: #577092)
 * Also install the hwengine desktop file (LP: #811770)
 * Depend on ttf-dejavu-core since it is smaller
 * Depend on ttf-wqy-zenhei instead of embedding a copy of it
* [Dmitry E. Oboukhov]
 * New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
implementation
38
38
uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
39
 
     uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted;
 
39
     uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted, uTextures;
40
40
 
41
41
operator=(const a, b: direction) c: Boolean;
42
42
begin
302
302
    // freed in freeModule() below
303
303
    LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
304
304
    if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
 
305
    if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface);
305
306
 
306
307
    tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Border', ifIgnoreCaps or ifTransparent);
307
308
    if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
855
856
end;
856
857
 
857
858
begin
858
 
case cMazeSize of
 
859
case cTemplateFilter of
859
860
    0: begin
860
861
        cellsize := small_cell_size;
861
862
        maze_inverted := false;
1142
1143
    if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
1143
1144
    end;
1144
1145
 
1145
 
    if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
1146
 
    begin
1147
 
        cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
1148
 
        cpY:= LAND_HEIGHT - tmpsurf^.h;
1149
 
        if SDL_MustLock(tmpsurf) then
1150
 
            SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
1151
 
 
1152
 
            p:= tmpsurf^.pixels;
1153
 
            for y:= 0 to Pred(tmpsurf^.h) do
 
1146
 
 
1147
if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
 
1148
begin
 
1149
    disableLandBack:= true;
 
1150
 
 
1151
    cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
 
1152
    cpY:= LAND_HEIGHT - tmpsurf^.h;
 
1153
    if SDL_MustLock(tmpsurf) then
 
1154
        SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
 
1155
 
 
1156
        p:= tmpsurf^.pixels;
 
1157
        for y:= 0 to Pred(tmpsurf^.h) do
 
1158
        begin
 
1159
            for x:= 0 to Pred(tmpsurf^.w) do
1154
1160
            begin
1155
 
                for x:= 0 to Pred(tmpsurf^.w) do
1156
 
                begin
1157
 
                    if ((AMask and p^[x]) = 0) then  // Tiy was having trouble generating transparent black
1158
 
                        Land[cpY + y, cpX + x]:= 0
1159
 
                    else if p^[x] = (AMask or RMask) then
1160
 
                        Land[cpY + y, cpX + x]:= lfIndestructible
1161
 
                    else if p^[x] = $FFFFFFFF then
1162
 
                        Land[cpY + y, cpX + x]:= lfBasic;
1163
 
                end;
1164
 
                p:= @(p^[tmpsurf^.pitch div 4]);
 
1161
                if ((AMask and p^[x]) = 0) then
 
1162
                    Land[cpY + y, cpX + x]:= 0
 
1163
                else if p^[x] = $FFFFFFFF then
 
1164
                    Land[cpY + y, cpX + x]:= lfObject
 
1165
                else if p^[x] = (AMask or RMask) then
 
1166
                    Land[cpY + y, cpX + x]:= lfIndestructible
 
1167
                else if p^[x] = AMask then
 
1168
                    begin
 
1169
                    Land[cpY + y, cpX + x]:= lfBasic;
 
1170
                    disableLandBack:= false
 
1171
                    end
 
1172
                else if p^[x] = (AMask or BMask) then
 
1173
                    Land[cpY + y, cpX + x]:= lfObject or lfIce
1165
1174
            end;
 
1175
            p:= @(p^[tmpsurf^.pitch div 4]);
 
1176
        end;
1166
1177
 
1167
 
        if SDL_MustLock(tmpsurf) then
1168
 
            SDL_UnlockSurface(tmpsurf);
1169
 
    end;
1170
 
    if (tmpsurf <> nil) then
1171
 
        SDL_FreeSurface(tmpsurf);
1172
 
    tmpsurf:= nil;
 
1178
    if SDL_MustLock(tmpsurf) then
 
1179
        SDL_UnlockSurface(tmpsurf);
 
1180
    if not disableLandBack then
 
1181
        begin
 
1182
        // freed in freeModule() below
 
1183
        LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
 
1184
        if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent);
 
1185
        if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface)
 
1186
        end;
 
1187
end;
 
1188
if (tmpsurf <> nil) then
 
1189
    SDL_FreeSurface(tmpsurf);
 
1190
tmpsurf:= nil;
1173
1191
end;
1174
1192
 
1175
1193
procedure LoadMap;
1234
1252
for w:= 0 to 23 do
1235
1253
    for x:= leftX to rightX do
1236
1254
        begin
1237
 
        Land[cWaterLine-1 - w, x]:= lfIndestructible;
 
1255
        Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible;
1238
1256
        if (x + w) mod 32 < 16 then
1239
1257
            c:= AMask
1240
1258
        else
1241
1259
            c:= AMask or RMask or GMask; // FF00FFFF
1242
1260
 
1243
1261
        if (cReducedQuality and rqBlurryLand) = 0 then
1244
 
            LandPixels[cWaterLine-1 - w, x]:= c
 
1262
            LandPixels[Longword(cWaterLine) - 1 - w, x]:= c
1245
1263
        else
1246
 
            LandPixels[(cWaterLine-1 - w) div 2, x div 2]:= c
 
1264
            LandPixels[(Longword(cWaterLine) - 1 - w) div 2, x div 2]:= c
1247
1265
        end
1248
1266
end;
1249
1267
 
1423
1441
    adler:= 1;
1424
1442
    for i:= 0 to LAND_HEIGHT-1 do
1425
1443
        Adler32Update(adler, @Land[i,0], LAND_WIDTH);
1426
 
    s:= 'M' + IntToStr(adler);
 
1444
    s:= 'M' + IntToStr(adler) + cScriptName;
1427
1445
 
1428
1446
    chLandCheck(s);
1429
1447
    SendIPCRaw(@s[0], Length(s) + 1)