Skip to content

Commit

Permalink
Backport cleanups from Hellfire branch
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Dec 15, 2019
1 parent da74a3c commit 5fa0c57
Show file tree
Hide file tree
Showing 39 changed files with 474 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: cpp
os:
- linux
- osx

osx_image: xcode10.3

notifications:
Expand Down
10 changes: 6 additions & 4 deletions Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,12 @@ WORD GetAutomapType(int x, int y, BOOL view)
}

rv = automaptype[(BYTE)dungeon[x][y]];
if (rv == 7
&& GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8)
&& GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) {
rv = 1;
if (rv == 7) {
if ((GetAutomapType(x - 1, y, FALSE) >> 8) & MAPFLAG_HORZARCH) {
if ((GetAutomapType(x, y - 1, FALSE) >> 8) & MAPFLAG_VERTARCH) {
rv = 1;
}
}
}
return rv;
}
Expand Down
9 changes: 4 additions & 5 deletions Source/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ static BOOL CapturePix(HANDLE hFile, WORD width, WORD height, WORD stride, BYTE
BYTE *pBuffer, *pBufferEnd;

pBuffer = (BYTE *)DiabloAllocPtr(2 * width);
while (height != 0) {
height--;
while (height--) {
pBufferEnd = CaptureEnc(pixels, pBuffer, width);
pixels += stride;
writeSize = pBufferEnd - pBuffer;
Expand Down Expand Up @@ -158,9 +157,9 @@ void CaptureScreen()
success = CaptureHdr(hObject, SCREEN_WIDTH, SCREEN_HEIGHT);
if (success) {
success = CapturePix(hObject, SCREEN_WIDTH, SCREEN_HEIGHT, BUFFER_WIDTH, &gpBuffer[SCREENXY(0, 0)]);
if (success) {
success = CapturePal(hObject, palette);
}
}
if (success) {
success = CapturePal(hObject, palette);
}
unlock_buf(2);
CloseHandle(hObject);
Expand Down
41 changes: 37 additions & 4 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,43 @@ const BYTE gbFontTransTbl[256] = {
/* data */

char SpellITbl[MAX_SPELLS] = {
1, 1, 2, 3, 4, 5, 6, 7, 8, 9,
28, 13, 12, 18, 16, 14, 18, 19, 11, 20,
15, 21, 23, 24, 25, 22, 26, 29, 37, 38,
39, 42, 41, 40, 10, 36, 30
1,
1,
2,
3,
4,
5,
6,
7,
8,
9,
28,
13,
12,
18,
16,
14,
18,
19,
11,
20,
15,
21,
23,
24,
25,
22,
26,
29,
37,
38,
39,
42,
41,
40,
10,
36,
30,
};
int PanBtnPos[8][5] = {
{ PANEL_LEFT + 9, PANEL_TOP + 9, 71, 19, 1 }, // char button
Expand Down
11 changes: 8 additions & 3 deletions Source/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void CheckRportal()

void CheckCursMove()
{
int i, sx, sy, mx, my, tx, ty, px, py, xx, yy, mi;
int i, sx, sy, fx, fy, mx, my, tx, ty, px, py, xx, yy, mi;
char bv;
BOOL flipflag, flipx, flipy;

Expand Down Expand Up @@ -201,9 +201,14 @@ void CheckCursMove()
sx -= ScrollInfo._sxoff;
sy -= ScrollInfo._syoff;

fx = plr[myplr]._pVar6 >> 8;
fy = plr[myplr]._pVar7 >> 8;
fx -= (plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8;
fy -= (plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8;

if (ScrollInfo._sdir != 0) {
sx += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8);
sy += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8);
sx -= fx;
sy -= fy;
}

if (sx < 0) {
Expand Down
2 changes: 1 addition & 1 deletion Source/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void StoresCheat()

numpremium = 0;

for (i = 0; i < 6; i++)
for (i = 0; i < SMITH_PREMIUM_ITEMS; i++)
premiumitem[i]._itype = -1;

SpawnPremium(30);
Expand Down
2 changes: 1 addition & 1 deletion Source/doom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int doom_get_frame_from_time()

void doom_alloc_cel()
{
pDoomCel = DiabloAllocPtr(229376);
pDoomCel = DiabloAllocPtr(0x38000);
}

void doom_cleanup()
Expand Down
21 changes: 10 additions & 11 deletions Source/drlg_l1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,11 @@ static void DRLG_L1Shadows()

static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int noquad, int ldir)
{
int xx, yy, sx, sy;
int ii, i, t, found;
int numt;
int sx, sy, sw, sh, xx, yy, i, ii, numt, found, t;
BOOL abort;

int sw = miniset[0];
int sh = miniset[1];
sw = miniset[0];
sh = miniset[1];

if (tmax - tmin == 0)
numt = 1;
Expand Down Expand Up @@ -900,7 +898,7 @@ static void L5makeDungeon()

static void L5makeDmt()
{
int i, j, dmtx, dmty;
int i, j, idx, val, dmtx, dmty;

for (j = 0; j < DMAXY; j++) {
for (i = 0; i < DMAXX; i++) {
Expand All @@ -910,11 +908,12 @@ static void L5makeDmt()

for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) {
for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) {
int val = L5dungeon[dmtx + 1][dmty + 1];
val = 2 * val + L5dungeon[dmtx][dmty + 1];
val = 2 * val + L5dungeon[dmtx + 1][dmty];
val = 2 * val + L5dungeon[dmtx][dmty];
dungeon[i][j] = L5ConvTbl[val];
val = 8 * L5dungeon[dmtx + 1][dmty + 1]
+ 4 * L5dungeon[dmtx][dmty + 1]
+ 2 * L5dungeon[dmtx + 1][dmty]
+ L5dungeon[dmtx][dmty];
idx = L5ConvTbl[val];
dungeon[i][j] = idx;
}
}
}
Expand Down
36 changes: 19 additions & 17 deletions Source/drlg_l4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,16 @@ void DRLG_L4SetSPRoom(int rx1, int ry1)

static void L4makeDmt()
{
int i, j, val, dmtx, dmty;
int i, j, idx, val, dmtx, dmty;

for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) {
for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) {
val = L4dungeon[dmtx + 1][dmty + 1];
val = 2 * val + L4dungeon[dmtx][dmty + 1];
val = 2 * val + L4dungeon[dmtx + 1][dmty];
val = 2 * val + L4dungeon[dmtx][dmty];
dungeon[i][j] = L4ConvTbl[val];
val = 8 * L4dungeon[dmtx + 1][dmty + 1]
+ 4 * L4dungeon[dmtx][dmty + 1]
+ 2 * L4dungeon[dmtx + 1][dmty]
+ L4dungeon[dmtx][dmty];
idx = L4ConvTbl[val];
dungeon[i][j] = idx;
}
}
}
Expand Down Expand Up @@ -1314,7 +1315,7 @@ static void L4roomGen(int x, int y, int w, int h, int dir)

static void L4firstRoom()
{
int x, y, w, h, rndx, rndy, xmin, xmax, ymin, ymax;
int x, y, w, h, rndx, rndy, xmin, xmax, ymin, ymax, tx, ty;

if (currlevel != 16) {
if (currlevel == quests[QTYPE_WARLRD]._qlevel && quests[QTYPE_WARLRD]._qactive) {
Expand All @@ -1337,15 +1338,17 @@ static void L4firstRoom()
xmax = 19 - w;
rndx = random_(0, xmax - xmin + 1) + xmin;
if (rndx + w > 19) {
x = 19 - w + 1;
tx = w + rndx - 19;
x = rndx - tx + 1;
} else {
x = rndx;
}
ymin = (20 - h) >> 1;
ymax = 19 - h;
rndy = random_(0, ymax - ymin + 1) + ymin;
if (rndy + h > 19) {
y = 19 - h + 1;
ty = h + rndy - 19;
y = rndy - ty + 1;
} else {
y = rndy;
}
Expand Down Expand Up @@ -1374,17 +1377,16 @@ void L4SaveQuads()
{
int i, j, x, y;

y = 0;
x = l4holdx;
y = l4holdy;

for (j = 0; j < 14; j++) {
x = 0;
for (i = 0; i < 14; i++) {
dflags[i + l4holdx][j + l4holdy] = 1;
dflags[DMAXX - 1 - x - l4holdx][j + l4holdy] = 1;
dflags[i + l4holdx][DMAXY - 1 - y - l4holdy] = 1;
dflags[DMAXX - 1 - x - l4holdx][DMAXY - 1 - y - l4holdy] = 1;
x++;
dflags[i + x][j + y] = 1;
dflags[DMAXX - 1 - i - x][j + y] = 1;
dflags[i + x][DMAXY - 1 - j - y] = 1;
dflags[DMAXX - 1 - i - x][DMAXY - 1 - j - y] = 1;
}
y++;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/gmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void gmenu_draw()

void gmenu_draw_menu_item(TMenuItem *pItem, int y)
{
DWORD x, w, nSteps, step, pos, t;
DWORD w, x, nSteps, step, pos, t;
t = y - 2;
w = gmenu_get_lfont(pItem);
if (pItem->dwFlags & GMENU_SLIDER) {
Expand Down
4 changes: 2 additions & 2 deletions Source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void init_create_window(int nCmdShow)
wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1));
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = "DIABLO";
wcex.lpszMenuName = GAME_NAME;
wcex.lpszClassName = "DIABLO";
wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
if (!RegisterClassEx(&wcex))
Expand All @@ -168,7 +168,7 @@ void init_create_window(int nCmdShow)
nHeight = SCREEN_HEIGHT;
else
nHeight = GetSystemMetrics(SM_CYSCREEN);
hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL);
hWnd = CreateWindowEx(0, "DIABLO", GAME_NAME, WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL);
if (!hWnd)
app_fatal("Unable to create main window");
ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow)
Expand Down
Loading

0 comments on commit 5fa0c57

Please sign in to comment.