DEADSOFTWARE

Fix access violation on x86_64
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 30 Jul 2017 17:53:14 +0000 (20:53 +0300)
committerKetmar Dark <ketmar@ketmar.no-ip.org>
Sun, 30 Jul 2017 22:36:52 +0000 (01:36 +0300)
src/engine/e_input.pas
src/shared/BinEditor.pas
src/shared/MAPREADER.pas
src/sheditor/WADEDITOR_full.pas

index d4081ee5615075eaa89c26fb80962c47e82e1dda..2a2f435de2c5d5c8ce606e87d9788292995dd766 100644 (file)
@@ -192,14 +192,14 @@ function PollKeyboard(): Boolean;
 var
   Keys: PByte;
   NKeys: Integer;
-  i: Cardinal;
+  i: NativeInt;
 begin
   Result := False;
   Keys := SDL_GetKeyboardState(@NKeys);
   if (Keys = nil) or (NKeys < 1) then
     Exit;
   for i := 0 to NKeys do
-    KeyBuffer[i] := ((PByte(Cardinal(Keys) + i)^) <> 0);
+    KeyBuffer[i] := ((PByte(NativeInt(Keys) + i)^) <> 0);
   for i := NKeys to High(KeyBuffer) do
     KeyBuffer[i] := False;
 end;
index 251f07573646492e99edf75eb1669e3cb581dbe9..cd0eb068ebdb7d0785b5d149b7aa02573b5e6621 100644 (file)
@@ -166,7 +166,7 @@ begin
   if (FPosition + varSize) > FSize then
     ExtendMemory(varSize);
 
-  CopyMemory(Pointer(Cardinal(FData) + FPosition),
+  CopyMemory(Pointer(NativeInt(FData) + FPosition),
              @x, varSize);
   FPosition := FPosition + varSize;
 end;
@@ -256,13 +256,13 @@ begin
     ExtendMemory(SizeOf(Byte) + len);
 
 // Äëèíà ñòðîêè:
-  CopyMemory(Pointer(Cardinal(FData) + FPosition),
+  CopyMemory(Pointer(NativeInt(FData) + FPosition),
              @len, SizeOf(Byte));
   FPosition := FPosition + SizeOf(Byte);
 // Ñòðîêà:
   if len > 0 then
   begin
-    CopyMemory(Pointer(Cardinal(FData) + FPosition),
+    CopyMemory(Pointer(NativeInt(FData) + FPosition),
                @x[1], len);
     FPosition := FPosition + len;
   end;
@@ -274,13 +274,13 @@ begin
     ExtendMemory(SizeOf(Cardinal) + memSize);
 
 // Äëèíà áëîêà ïàìÿòè:
-  CopyMemory(Pointer(Cardinal(FData) + FPosition),
+  CopyMemory(Pointer(NativeInt(FData) + FPosition),
              @memSize, SizeOf(Cardinal));
   FPosition := FPosition + SizeOf(Cardinal);
 // Áëîê ïàìÿòè:
   if memSize > 0 then
   begin
-    CopyMemory(Pointer(Cardinal(FData) + FPosition),
+    CopyMemory(Pointer(NativeInt(FData) + FPosition),
                x, memSize);
     FPosition := FPosition + memSize;
   end;
@@ -293,7 +293,7 @@ begin
 
   if aLen > 0 then
   begin
-    FillMemory(Pointer(Cardinal(FData) + FPosition),
+    FillMemory(Pointer(NativeInt(FData) + FPosition),
                aLen, aFillSym);
     FPosition := FPosition + aLen;
   end;
@@ -354,7 +354,7 @@ begin
   if (FPosition + varSize) <= FSize then
     begin
       CopyMemory(@x,
-                 Pointer(Cardinal(FData) + FPosition),
+                 Pointer(NativeInt(FData) + FPosition),
                  varSize);
       FPosition := FPosition + varSize;
     end
@@ -419,7 +419,7 @@ begin
     begin
     // Äëèíà ñòðîêè:
       CopyMemory(@len,
-                 Pointer(Cardinal(FData) + FPosition),
+                 Pointer(NativeInt(FData) + FPosition),
                  SizeOf(Byte));
 
       if (FPosition + SizeOf(Byte) + len) <= FSize then
@@ -430,7 +430,7 @@ begin
           if len > 0 then
             begin
               CopyMemory(@x[1],
-                         Pointer(Cardinal(FData) + FPosition),
+                         Pointer(NativeInt(FData) + FPosition),
                          len);
               FPosition := FPosition + len;
             end
@@ -450,7 +450,7 @@ begin
     begin
     // Äëèíà áëîêà ïàìÿòè:
       CopyMemory(@memSize,
-                 Pointer(Cardinal(FData) + FPosition),
+                 Pointer((FData) + FPosition),
                  SizeOf(Cardinal));
 
       if (FPosition + SizeOf(Cardinal) + memSize) <= FSize then
@@ -461,7 +461,7 @@ begin
             begin
               GetMem(x, memSize);
               CopyMemory(x,
-                         Pointer(Cardinal(FData) + FPosition),
+                         Pointer(NativeInt(FData) + FPosition),
                          memSize);
               FPosition := FPosition + memSize;
             end
index 6c9e86326551d7b0d24ba7e8151aed028e565c01..a122bee5cb0b13d6f47ba5679edf30d3cdc0c31f 100644 (file)
@@ -152,7 +152,7 @@ function TMapReader_1.GetAreas(): TAreasRec1Array;
 var
   TempDataBlocks: TDataBlocksArray;
   a: Integer;
-  b, Size: LongWord;
+  b, Size: NativeInt;
 begin
  Result := nil;
 
@@ -167,7 +167,7 @@ begin
   begin
    SetLength(Result, Length(Result)+1);
    //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
-   mb_Read_TAreaRec_1(Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size)^, size);
+   mb_Read_TAreaRec_1(Result[High(Result)], Pointer(NativeInt(TempDataBlocks[a].Data)+b*size)^, size);
   end;
 
  TempDataBlocks := nil;
@@ -177,7 +177,7 @@ function TMapReader_1.GetItems(): TItemsRec1Array;
 var
   TempDataBlocks: TDataBlocksArray;
   a: Integer;
-  b, Size: LongWord;
+  b, Size: NativeInt;
 begin
  Result := nil;
 
@@ -192,7 +192,7 @@ begin
   begin
    SetLength(Result, Length(Result)+1);
    //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
-   mb_Read_TItemRec_1(Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size)^, size);
+   mb_Read_TItemRec_1(Result[High(Result)], Pointer(NativeInt(TempDataBlocks[a].Data)+b*size)^, size);
   end;
 
  TempDataBlocks := nil;
@@ -218,7 +218,7 @@ function TMapReader_1.GetMonsters(): TMonsterRec1Array;
 var
   TempDataBlocks: TDataBlocksArray;
   a: Integer;
-  b, Size: LongWord;
+  b, Size: NativeInt;
 begin
  Result := nil;
 
@@ -233,7 +233,7 @@ begin
   begin
    SetLength(Result, Length(Result)+1);
    //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
-   mb_Read_TMonsterRec_1(Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size)^, size);
+   mb_Read_TMonsterRec_1(Result[High(Result)], Pointer(NativeInt(TempDataBlocks[a].Data)+b*size)^, size);
   end;
 
  TempDataBlocks := nil;
@@ -243,7 +243,7 @@ function TMapReader_1.GetPanels(): TPanelsRec1Array;
 var
   TempDataBlocks: TDataBlocksArray;
   a: Integer;
-  b, Size: LongWord;
+  b, Size: NativeInt;
 begin
  Result := nil;
 
@@ -258,7 +258,7 @@ begin
   begin
    SetLength(Result, Length(Result)+1);
    //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
-   mb_Read_TPanelRec_1(Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size)^, size);
+   mb_Read_TPanelRec_1(Result[High(Result)], Pointer(NativeInt(TempDataBlocks[a].Data)+b*size)^, size);
   end;
 
  TempDataBlocks := nil;
@@ -268,7 +268,7 @@ function TMapReader_1.GetTextures(): TTexturesRec1Array;
 var
   TempDataBlocks: TDataBlocksArray;
   a: Integer;
-  b, Size: LongWord;
+  b, Size: NativeInt;
 begin
  Result := nil;
 
@@ -282,8 +282,8 @@ begin
   for b := 0 to (TempDataBlocks[a].Block.BlockSize div size)-1 do
   begin
    SetLength(Result, Length(Result)+1);
-   //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
-   mb_Read_TTextureRec_1(Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size)^, size);
+    //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
+    mb_Read_TTextureRec_1(Result[High(Result)], Pointer(NativeInt(TempDataBlocks[a].Data)+b*size)^, size);
   end;
 
  TempDataBlocks := nil;
@@ -293,7 +293,8 @@ function TMapReader_1.GetTriggers(): TTriggersRec1Array;
 var
   TempDataBlocks: TDataBlocksArray;
   a: Integer;
-  b, Size: LongWord;
+  b: NativeInt;
+  Size: LongWord;
   trdata: TTriggerData;
 begin
  Result := nil;
@@ -309,7 +310,7 @@ begin
   begin
    SetLength(Result, Length(Result)+1);
    //CopyMemory(@Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size), size);
-   mb_Read_TTriggerRec_1(Result[High(Result)], Pointer(LongWord(TempDataBlocks[a].Data)+b*size)^, size);
+   mb_Read_TTriggerRec_1(Result[High(Result)], Pointer(NativeInt(TempDataBlocks[a].Data)+b*size)^, size);
    if (Result[High(Result)].TriggerType <> 0) then
    begin
      // preprocess trigger data
@@ -368,7 +369,7 @@ begin
   if FDataBlocks[a].Block.BlockType = BlocksType then
   begin
    SetLength(Result, Length(Result)+1);
-   Result[High(Result)] := FDataBlocks[a];
+    Result[High(Result)] := FDataBlocks[a];
   end;
 end;
 
@@ -379,7 +380,7 @@ end;
 
 function TMapReader.LoadMap(Data: Pointer): Boolean;
 var
-  adr: LongWord;
+  adr: NativeInt;
   _id: Integer;
   Sign: array[0..2] of Char;
   Ver: Byte;
@@ -394,7 +395,7 @@ begin
  end;
  adr := 3;
 
- CopyMemory(@Ver, Pointer(LongWord(Data)+adr), 1);
+ CopyMemory(@Ver, Pointer(NativeInt(Data)+adr), 1);
  FVersion := Ver;
  if Ver > HandledVersion() then
  begin
@@ -407,12 +408,12 @@ begin
   SetLength(FDataBlocks, Length(FDataBlocks)+1);
   _id := High(FDataBlocks);
 
-  CopyMemory(@FDataBlocks[_id].Block, Pointer(LongWord(Data)+adr), SizeOf(TBlock));
+  CopyMemory(@FDataBlocks[_id].Block, Pointer(NativeInt(Data)+adr), SizeOf(TBlock));
   adr := adr+SizeOf(TBlock);
 
   FDataBlocks[_id].Data := GetMemory(FDataBlocks[_id].Block.BlockSize);
 
-  CopyMemory(FDataBlocks[_id].Data, Pointer(LongWord(Data)+adr), FDataBlocks[_id].Block.BlockSize);
+  CopyMemory(FDataBlocks[_id].Data, Pointer(NativeInt(Data)+adr), FDataBlocks[_id].Block.BlockSize);
 
   adr := adr+FDataBlocks[_id].Block.BlockSize;
  until FDataBlocks[_id].Block.BlockType = BLOCK_NONE;
index f58c4850b0fd3b14ab7401c585a7f6228ddc56e6..4c61f454d8c1c021d51f7a147959cbc666b22c70 100644 (file)
@@ -648,7 +648,7 @@ begin
   else
  begin
   TempData := GetMemory(FResTable[i].Length);
-  CopyMemory(TempData, Pointer(LongWord(FResData)+FResTable[i].Address+6+
+  CopyMemory(TempData, Pointer(NativeUInt(FResData)+FResTable[i].Address+6+
              LongWord(SizeOf(TWADHeaderRec_1)+SizeOf(TResourceTableRec_1)*Length(FResTable))),
              FResTable[i].Length);
   DecompressBuf(TempData, FResTable[i].Length, 0, pData, OutBytes);
@@ -810,19 +810,19 @@ begin
   Exit;
  end;
 
- CopyMemory(@FVersion, Pointer(LongWord(Data)+5), 1);
+ CopyMemory(@FVersion, Pointer(NativeUInt(Data)+5), 1);
  if FVersion <> DFWAD_VERSION then
  begin
    FLastError := DFWAD_ERROR_WRONGVERSION;
    Exit;
  end;
 
- CopyMemory(@FHeader, Pointer(LongWord(Data)+6), SizeOf(TWADHeaderRec_1));
+ CopyMemory(@FHeader, Pointer(NativeUInt(Data)+6), SizeOf(TWADHeaderRec_1));
 
  SetLength(FResTable, FHeader.RecordsCount);
  if FResTable <> nil then
  begin
-  CopyMemory(@FResTable[0], Pointer(LongWord(Data)+6+SizeOf(TWADHeaderRec_1)),
+  CopyMemory(@FResTable[0], Pointer(NativeUInt(Data)+6+SizeOf(TWADHeaderRec_1)),
              SizeOf(TResourceTableRec_1)*FHeader.RecordsCount);
 
   for a := 0 to High(FResTable) do