pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/games/devilutionx devilutionx: Backport some fixes for...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b6a028dd4ce6
branches:  trunk
changeset: 398698:b6a028dd4ce6
user:      nia <nia%pkgsrc.org@localhost>
date:      Sun Jul 28 10:26:43 2019 +0000

description:
devilutionx: Backport some fixes for 64-bit save files and UB.

diffstat:

 games/devilutionx/Makefile                          |     3 +-
 games/devilutionx/distinfo                          |     6 +-
 games/devilutionx/patches/patch-Source_inv.cpp      |   952 ++++++++++++++++
 games/devilutionx/patches/patch-Source_loadsave.cpp |  1092 +++++++++++++++++++
 games/devilutionx/patches/patch-Source_loadsave.h   |    19 +
 games/devilutionx/patches/patch-structs.h           |    53 +
 6 files changed, 2123 insertions(+), 2 deletions(-)

diffs (truncated from 2159 to 300 lines):

diff -r 4fbad6aae07c -r b6a028dd4ce6 games/devilutionx/Makefile
--- a/games/devilutionx/Makefile        Sun Jul 28 08:41:06 2019 +0000
+++ b/games/devilutionx/Makefile        Sun Jul 28 10:26:43 2019 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2019/07/11 12:56:04 nia Exp $
+# $NetBSD: Makefile,v 1.6 2019/07/28 10:26:43 nia Exp $
 
 DISTNAME=      devilutionx-0.4.0
+PKGREVISION=   1
 CATEGORIES=    games
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=diasurgical/}
 GITHUB_PROJECT=        devilutionX
diff -r 4fbad6aae07c -r b6a028dd4ce6 games/devilutionx/distinfo
--- a/games/devilutionx/distinfo        Sun Jul 28 08:41:06 2019 +0000
+++ b/games/devilutionx/distinfo        Sun Jul 28 10:26:43 2019 +0000
@@ -1,6 +1,10 @@
-$NetBSD: distinfo,v 1.2 2019/07/11 12:56:04 nia Exp $
+$NetBSD: distinfo,v 1.3 2019/07/28 10:26:43 nia Exp $
 
 SHA1 (devilutionx-0.4.0.tar.gz) = d5d71cf752dc0b5c89f9827b52f1567cb5cfb8f4
 RMD160 (devilutionx-0.4.0.tar.gz) = 0b647b8ee4641d9af000d4d54e1008a506a9fc66
 SHA512 (devilutionx-0.4.0.tar.gz) = ba8f650f8dd00e3b08f6ac082566351c8f3b6162d7bfa2fdf3464b38c201b08677d2f6151f2272e1d73eb972b8babc49b38364523d10763eb179f6b682641443
 Size (devilutionx-0.4.0.tar.gz) = 1351201 bytes
+SHA1 (patch-Source_inv.cpp) = 788414c9141da13391cd4f540e364a034fd87b41
+SHA1 (patch-Source_loadsave.cpp) = 22d8d6e4ca44358dfbc55741b8aebeac6af8e468
+SHA1 (patch-Source_loadsave.h) = 6d7e7cc9e188e5a406c10caceb0aa80139c6e301
+SHA1 (patch-structs.h) = d9cba47b2ca876529aef33d4190f082d134cdcb6
diff -r 4fbad6aae07c -r b6a028dd4ce6 games/devilutionx/patches/patch-Source_inv.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/games/devilutionx/patches/patch-Source_inv.cpp    Sun Jul 28 10:26:43 2019 +0000
@@ -0,0 +1,952 @@
+$NetBSD: patch-Source_inv.cpp,v 1.1 2019/07/28 10:26:43 nia Exp $
+
+[PATCH] Clean up CheckInvPaste (bin exact) (#1205)
+Fixes some item duplication.
+https://github.com/diasurgical/devilutionX/commit/a549d5ebc461e757065c4536cb351969dcf60fe9.patch
+
+--- Source/inv.cpp.orig        2019-05-19 17:06:45.000000000 +0000
++++ Source/inv.cpp
+@@ -686,562 +686,408 @@ int SwapItem(ItemStruct *a, ItemStruct *
+ 
+ void CheckInvPaste(int pnum, int mx, int my)
+ {
+-      int v3;              // ebx
+-      int v4;              // edi
+-      int v5;              // eax
+-      int v6;              // esi
+-      signed int v7;       // edi
+-      int v8;              // edx
+-      int v9;              // edx
+-      signed int v10;      // edi
+-      char v11;            // al
+-      signed int v12;      // ecx
+-      int v13;             // eax
+-      int v14;             // eax
+-      char *v15;           // edi
+-      int v16;             // esi
+-      int v17;             // ecx
+-      int v18;             // edx
+-      int v21;             // esi
+-      ItemStruct *v22;     // edi
+-      ItemStruct *v23;     // ecx
+-      int v24;             // eax
+-      int v25;             // eax
+-      int v26;             // edx
+-      ItemStruct *v27;     // esi
+-      int v28;             // eax
+-      int v29;             // ecx
+-      int v30;             // esi
+-      int v31;             // eax
+-      int v32;             // eax
+-      int v33;             // ecx
+-      int v34;             // eax
+-      int v35;             // ecx
+-      char *v36;           // eax
+-      int v37;             // edx
+-      int v38;             // ecx
+-      int v39;             // edi
+-      int v40;             // esi
+-      int v41;             // ebx
+-      int v42;             // edx
+-      int v43;             // eax
+-      int v44;             // eax
+-      signed int v45;      // ecx
+-      int v46;             // edx
+-      char *v47;           // eax
+-      int v48;             // edi
+-      int v49;             // eax
+-      int v50;             // ecx
+-      char *v51;           // esi
+-      char v52;            // cl
+-      int v53;             // ecx
+-      int v54;             // eax
+-      int v55;             // edi
+-      int v56;             // edx
+-      int v57;             // esi
+-      int v58;             // ebx
+-      int v59;             // eax
+-      int v60;             // esi
+-      ItemStruct tempitem; // [esp+Ch] [ebp-190h]
+-      int v62;             // [esp+17Ch] [ebp-20h]
+-      int p;               // [esp+180h] [ebp-1Ch]
+-      int v64;             // [esp+184h] [ebp-18h]
+-      int v65;             // [esp+188h] [ebp-14h]
+-      int v66;             // [esp+18Ch] [ebp-10h]
+-      int v67;             // [esp+190h] [ebp-Ch]
+-      int v68;             // [esp+194h] [ebp-8h]
+-      int v69;             // [esp+198h] [ebp-4h]
+-      int cursor_id;       // [esp+1A4h] [ebp+8h]
+-      int cursor_ida;      // [esp+1A4h] [ebp+8h]
+-
+-      p = pnum;
+-      v3 = pnum;
+-      v4 = mx;
++      int r, sx, sy;
++      int i, j, xx, yy, ii;
++      BOOL done, done2h;
++      int il, cn, it, iv, ig, gt;
++      ItemStruct tempitem;
++
+       SetICursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM);
+-      v5 = my + (icursH >> 1);
+-      v6 = v4 + (icursW >> 1);
+-      v64 = icursW28;
+-      v7 = 0;
+-      v67 = icursH28;
+-      v68 = 0;
+-      do {
+-              if (v7)
+-                      goto LABEL_18;
+-              v8 = InvRect[v68].X;
+-              if (v6 >= v8 && v6 < v8 + 28) {
+-                      v9 = InvRect[v68].Y;
+-                      if (v5 >= v9 - 29 && v5 < v9) {
+-                              v7 = 1;
+-                              --v68;
+-                      }
+-              }
+-              if (v68 != 24)
+-                      goto LABEL_13;
+-              if (!(v64 & 1))
+-                      v6 -= 14;
+-              if (!(v67 & 1)) {
+-                      v5 -= 14;
+-              LABEL_13:
+-                      if (v68 == 64 && !(v67 & 1))
+-                              v5 += 14;
+-              }
+-              ++v68;
+-      } while ((unsigned int)v68 < 0x49);
+-      if (!v7)
++      i = mx + (icursW >> 1);
++      j = my + (icursH >> 1);
++      sx = icursW28;
++      sy = icursH28;
++      done = FALSE;
++      for (r = 0; r < sizeof(InvRect) / sizeof(InvRect[0]) && !done; r++) {
++              if (i >= InvRect[r].X && i < InvRect[r].X + INV_SLOT_SIZE_PX) {
++                      if (j >= InvRect[r].Y - INV_SLOT_SIZE_PX - 1 && j < InvRect[r].Y) {
++                              done = TRUE;
++                              r--;
++                      }
++              }
++              if (r == 24) {
++                      if ((sx & 1) == 0)
++                              i -= 14;
++                      if ((sy & 1) == 0) {
++                              j -= 14;
++                      }
++              }
++              if (r == 64 && (sy & 1) == 0)
++                      j += 14;
++      }
++      if (!done)
+               return;
+-LABEL_18:
+-      v10 = v68;
+-      v69 = ILOC_UNEQUIPABLE;
+-      if (v68 >= 0 && v68 <= ILOC_ARMOR)
+-              v69 = ILOC_HELM;
+-      if (v68 >= ILOC_HELM && v68 <= ILOC_RING)
+-              v69 = ILOC_RING;
+-      if (v68 == ILOC_AMULET)
+-              v69 = ILOC_AMULET;
+-      if (v68 >= ILOC_UNEQUIPABLE && v68 <= 18)
+-              v69 = ILOC_ONEHAND;
+-      if (v68 >= 19 && v68 <= 24)
+-              v69 = ILOC_ARMOR;
+-      if (v68 >= 65 && v68 <= 72)
+-              v69 = ILOC_BELT;
+-      v11 = plr[v3].HoldItem._iLoc;
+-      v12 = 0;
+-      if ((char)v11 == v69)
+-              v12 = 1;
+-      if (v69 == 1 && v11 == ILOC_TWOHAND) {
+-              v69 = ILOC_TWOHAND;
+-              v12 = 1;
+-      }
+-      if (v11 != 7 || v69 != ILOC_BELT) {
+-      LABEL_50:
+-              if (v69 != ILOC_UNEQUIPABLE)
+-                      goto LABEL_81;
+-              v66 = 0;
+-              cursor_id = 1;
+-              v13 = (v68 - 25) / 10;
+-              if (plr[v3].HoldItem._itype == ITYPE_GOLD) {
+-                      _LOBYTE(v13) = plr[0].InvGrid[10 * v13 + v3 * 21720 + (v68 - 25) % 10];
+-                      if (!(_BYTE)v13)
+-                              goto LABEL_93;
+-                      v13 = (char)v13;
+-                      if ((char)v13 <= 0) {
+-                              v13 = -v13;
+-                      } else if (*(int *)((char *)&plr[0].InvBody[v13 + 6]._itype + v3 * 21720) == ITYPE_GOLD) {
+-                              goto LABEL_93;
+-                      }
+-                      v66 = v13;
+-              LABEL_93:
+-                      v21 = p;
+-                      if (p == myplr) {
+-                              PlaySFX(ItemInvSnds[ItemCAnimTbl[plr[v3].HoldItem._iCurs]]);
+-                              v10 = v68;
+-                      }
+-                      cursor_ida = 1;
+-                      switch (v69) {
+-                      case ILOC_ONEHAND:
+-                              if (v10 > 12) {
+-                                      if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE) {
+-                                              v25 = plr[v3].InvBody[INVLOC_HAND_LEFT]._itype;
+-                                              if (v25 == ITYPE_NONE)
+-                                                      goto LABEL_232;
+-                                              if (plr[v3].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) {
+-                                                      NetSendCmdDelItem(FALSE, 4u);
+-                                                      NetSendCmdChItem(FALSE, 5u);
+-                                                      SwapItem(&plr[v3].InvBody[INVLOC_HAND_RIGHT], &plr[v3].InvBody[INVLOC_HAND_LEFT]);
+-                                                      v23 = &plr[v3].InvBody[INVLOC_HAND_RIGHT];
+-                                              LABEL_99:
+-                                                      v24 = SwapItem(v23, &plr[v3].HoldItem);
+-                                              LABEL_172:
+-                                                      cursor_ida = v24;
+-                                                      goto LABEL_226;
+-                                              }
+-                                              if (v25 == ITYPE_NONE || plr[v3].InvBody[INVLOC_HAND_LEFT]._iClass != plr[v3].HoldItem._iClass) {
+-                                              LABEL_232:
+-                                                      NetSendCmdChItem(FALSE, 5u);
+-                                                      v22 = &plr[v3].InvBody[INVLOC_HAND_RIGHT];
+-                                              LABEL_158:
+-                                                      qmemcpy(v22, &plr[v3].HoldItem, sizeof(ItemStruct));
+-                                                      goto LABEL_226;
+-                                              }
+-                                      } else if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE
+-                                          || plr[v3].InvBody[INVLOC_HAND_LEFT]._iClass != plr[v3].HoldItem._iClass) {
+-                                              goto LABEL_114;
++      il = ILOC_UNEQUIPABLE;
++      if (r >= 0 && r <= 3)
++              il = ILOC_HELM;
++      if (r >= 4 && r <= 5)
++              il = ILOC_RING;
++      if (r == 6)
++              il = ILOC_AMULET;
++      if (r >= 7 && r <= 18)
++              il = ILOC_ONEHAND;
++      if (r >= 19 && r <= 24)
++              il = ILOC_ARMOR;
++      if (r >= 65 && r <= 72)
++              il = ILOC_BELT;
++      done = FALSE;
++      if (plr[pnum].HoldItem._iLoc == il)
++              done = TRUE;
++      if (il == ILOC_ONEHAND && plr[pnum].HoldItem._iLoc == ILOC_TWOHAND) {
++              il = ILOC_TWOHAND;
++              done = TRUE;
++      }
++      if (plr[pnum].HoldItem._iLoc == ILOC_UNEQUIPABLE && il == ILOC_BELT) {
++              if (sx == 1 && sy == 1) {
++                      done = TRUE;
++                      if (!AllItemsList[plr[pnum].HoldItem.IDidx].iUsable)
++                              done = FALSE;
++                      if (!plr[pnum].HoldItem._iStatFlag)
++                              done = FALSE;
++                      if (plr[pnum].HoldItem._itype == ITYPE_GOLD)
++                              done = FALSE;
++              }
++      }
++
++      if (il == ILOC_UNEQUIPABLE) {
++              done = TRUE;
++              it = 0;
++              ii = r - 25;
++              if (plr[pnum].HoldItem._itype == ITYPE_GOLD) {
++                      yy = 10 * (ii / 10);
++                      xx = ii % 10;
++                      if (plr[pnum].InvGrid[xx + yy] != 0) {
++                              iv = plr[pnum].InvGrid[xx + yy];
++                              if (iv > 0) {
++                                      if (plr[pnum].InvList[iv - 1]._itype != ITYPE_GOLD) {
++                                              it = iv;
+                                       }
+                               } else {
+-                                      if (plr[v3].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE) {
+-                                              if (plr[v3].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE



Home | Main Index | Thread Index | Old Index