From: DeaDDooMER Date: Sun, 30 Jul 2017 17:53:14 +0000 (+0300) Subject: Fix access violation on x86_64 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=a25182b0259235ece5d4a2cdceafd0b2cdfc582b;p=d2df-sdl.git Fix access violation on x86_64 --- diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas index d4081ee..2a2f435 100644 --- a/src/engine/e_input.pas +++ b/src/engine/e_input.pas @@ -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; diff --git a/src/shared/BinEditor.pas b/src/shared/BinEditor.pas index 251f075..cd0eb06 100644 --- a/src/shared/BinEditor.pas +++ b/src/shared/BinEditor.pas @@ -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 diff --git a/src/shared/MAPREADER.pas b/src/shared/MAPREADER.pas index 6c9e863..a122bee 100644 --- a/src/shared/MAPREADER.pas +++ b/src/shared/MAPREADER.pas @@ -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; diff --git a/src/sheditor/WADEDITOR_full.pas b/src/sheditor/WADEDITOR_full.pas index f58c485..4c61f45 100644 --- a/src/sheditor/WADEDITOR_full.pas +++ b/src/sheditor/WADEDITOR_full.pas @@ -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