Skip to content

Commit 2137ebd

Browse files
committed
lua crash-proof, zoom with scroll, alt highlight kind of works with zoom, packets broken
1 parent da8da64 commit 2137ebd

26 files changed

+385
-1155
lines changed

Infernity.zip

3.34 KB
Binary file not shown.

Source/automap.cpp

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,22 +348,49 @@ void AddItemToDrawQueue(int x, int y, int id) {
348348
int rarity = GetItemRarity(id);
349349
std::string name(plr[myplr]._pName);
350350
std::string itemName(textOnGround);
351-
352351
lootFilterData lfd = luaLootFilter(name, plr[myplr]._pClass, itemName, it->_itype, (int)it->_iLoc, rarity, GetItemColor(id));
353352
if (lfd.show == false) { return; }
354353
int centerXOffset = GetTextWidth((char*)lfd.name.c_str()) ;
355-
if (zoomflag) {
354+
355+
int targetHeight = GLOBAL_HEIGHT - GLOBAL_HEIGHT * globalScrollZoom / 200;
356+
int targetWidth = GLOBAL_WIDTH - GLOBAL_WIDTH * globalScrollZoom / 200;
357+
int widthDiff = GLOBAL_WIDTH - targetWidth;
358+
int heightDiff = GLOBAL_HEIGHT - targetHeight;
359+
360+
//x += widthDiff/4;
361+
//y += widthDiff/4;
362+
std::stringstream ss;
363+
364+
365+
366+
int distToCenterX = abs(ScreenWidth/2-x);
367+
int distToCenterY = abs(ScreenHeight / 2 - y);
368+
if (x <= ScreenWidth / 2) {
369+
x = ScreenWidth / 2 - distToCenterX - distToCenterX * (globalScrollZoom) / 100;
370+
}
371+
else {
372+
x = ScreenWidth / 2 + distToCenterX + distToCenterX * (globalScrollZoom) / 100;
373+
}
374+
375+
if (y <= ScreenHeight / 2) {
376+
y = ScreenHeight / 2 - distToCenterY - distToCenterY * (globalScrollZoom) / 100;
377+
}
378+
else {
379+
y = ScreenHeight / 2 + distToCenterY + distToCenterY * (globalScrollZoom) / 100;
380+
}
381+
356382
x -= centerXOffset / 2 + 20;
357383
y -= 193;
358-
}
359-
else {
384+
360385

361-
x -= centerXOffset + 20;
362-
y -= 0;
363386

364-
}
365-
drawQ.push_back(drawingQueue(x, y, GetTextWidth((char*)lfd.name.c_str()), 13, it->_ix, it->_iy, id, lfd.color2, lfd.name, 1, lfd.r, lfd.g,lfd.b));
366387

388+
//ss << x << " " << y << " ";
389+
390+
//NetSendCmdString(1 << myplr, ss.str().c_str());
391+
//x += x globalScrollZoom / 100;
392+
//y += y * globalScrollZoom / 100;
393+
drawQ.push_back(drawingQueue(x, y, GetTextWidth((char*)lfd.name.c_str()), 13, it->_ix, it->_iy, id, lfd.color2, lfd.name, 1, lfd.r, lfd.g,lfd.b));
367394
}
368395

369396
void HighlightItemsNameOnMap()

Source/control.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,12 +3265,14 @@ void __cdecl DrawSpellBook()
32653265
v5 = v4 >> 6;
32663266
v12 = v4 >> 6;
32673267
GetDamageAmt(v2, &sel, &v11);
3268-
sel = sel*CalculateSpellPower(myplr)/100;
3269-
v11 = v11*CalculateSpellPower(myplr) / 100;
3270-
if ( sel == -1 )
3268+
if (sel == -1) {
32713269
sprintf(tempstr, "Mana: %i Dam: n/a", v5);
3272-
else
3270+
}
3271+
else {
3272+
sel = sel * CalculateSpellPower(myplr, v2, v7) / 100;
3273+
v11 = v11 * CalculateSpellPower(myplr, v2, v7) / 100;
32733274
sprintf(tempstr, "Mana: %i Dam: %i - %i", v5, sel, v11);
3275+
}
32743276
if ( v2 == SPL_BONESPIRIT )
32753277
sprintf(tempstr, "Mana: %i Dam: 1/8 tgt hp", v12);
32763278
PrintSBookStr(10, v8, 0, tempstr, 0);

Source/cursor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,12 @@ void __cdecl CheckCursMove()
652652
LABEL_10:
653653
if ( MouseY >= (352 + GetHeightDiff()) && track_isscrolling() )
654654
v1 = (352+GetHeightDiff());
655-
if ( !zoomflag )
655+
if ( true) // !zoomflag
656656
{
657-
v0 >>= 1;
658-
v1 >>= 1;
657+
//v0 >>= 1;
658+
//v1 >>= 1;
659+
v0 -= v0 * globalScrollZoom / 200;
660+
v1 -= v1 * globalScrollZoom / 200;
659661
}
660662
v2 = v0 - ScrollInfo._sxoff;
661663
v3 = v1 - ScrollInfo._syoff;
@@ -675,7 +677,9 @@ void __cdecl CheckCursMove()
675677
v4 = v3 >> 5;
676678
v5 = v3 & 0x1F;
677679
v76 = v2 & 0x3F;
678-
v6 = (v2 >> 6) + (v3 >> 5) + ViewX - (zoomflag != 0 ? ScreenWidth/64 : ScreenWidth/128);
680+
//v6 = (v2 >> 6) + (v3 >> 5) + ViewX - (zoomflag != 0 ? ScreenWidth/64 : ScreenWidth/128);
681+
int zoomStuff = ScreenWidth / 64 - ScreenWidth * globalScrollZoom / 12800;
682+
v6 = (v2 >> 6) + (v3 >> 5) + ViewX - zoomStuff;
679683
v7 = v76 >> 1;
680684
v8 = v4 + ViewY - (v2 >> 6);
681685
if ( v5 < v76 >> 1 )
@@ -1293,7 +1297,6 @@ void __cdecl CheckCursMove()
12931297
// 4B8CC1: using guessed type char pcursobj;
12941298
// 4B8CC2: using guessed type char pcursplr;
12951299
// 4B8CCC: using guessed type int dword_4B8CCC;
1296-
// 52569C: using guessed type int zoomflag;
12971300
// 52575C: using guessed type int doomflag;
12981301
// 5BB1ED: using guessed type char leveltype;
12991302
// 69BD04: using guessed type int questlog;

Source/diablo.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ int glSeedTbl[NUMLEVELS];
1414
int gbRunGame; // weak
1515
int glMid3Seed[NUMLEVELS];
1616
int gbRunGameResult; // weak
17-
int zoomflag; // weak
1817
int gbProcessPlayers; // weak
1918
int glEndSeed[NUMLEVELS];
2019
int dword_5256E8; // weak
@@ -235,7 +234,6 @@ void __fastcall run_game_loop(int uMsg)
235234
void __fastcall start_game(int uMsg)
236235
{
237236
cineflag = 0;
238-
zoomflag = 1;
239237
InitCursor();
240238
InitLightTable();
241239
LoadDebugGFX();
@@ -247,7 +245,6 @@ void __fastcall start_game(int uMsg)
247245
sgbMouseDown = 0;
248246
track_repeat_walk(0);
249247
}
250-
// 52569C: using guessed type int zoomflag;
251248
// 525718: using guessed type char cineflag;
252249
// 525748: using guessed type char sgbMouseDown;
253250

@@ -764,6 +761,26 @@ LRESULT __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
764761
}
765762
return 0;
766763
}
764+
765+
766+
if (uMsg == WM_MOUSEWHEEL)
767+
{
768+
if ((short)HIWORD(wParam) < 0)
769+
{
770+
if (globalScrollZoom > 0) {
771+
globalScrollZoom -= 5;
772+
}
773+
}
774+
else
775+
{
776+
if (globalScrollZoom < 100) {
777+
globalScrollZoom += 5;
778+
}
779+
}
780+
return 0;
781+
}
782+
783+
767784
if ( uMsg != WM_RBUTTONUP )
768785
{
769786
if ( uMsg == WM_CAPTURECHANGED )
@@ -1863,7 +1880,6 @@ void __fastcall PressChar(int vkey)
18631880
}
18641881
case 'Z':
18651882
case 'z':
1866-
zoomflag = zoomflag == 0;
18671883
return;
18681884
#ifdef _DEBUG
18691885
case ')':
@@ -1971,14 +1987,6 @@ void __fastcall PressChar(int vkey)
19711987
}
19721988
}
19731989
}
1974-
// 4B84DC: using guessed type int dropGoldFlag;
1975-
// 4B8968: using guessed type int sbookflag;
1976-
// 4B8C98: using guessed type int spselflag;
1977-
// 52569C: using guessed type int zoomflag;
1978-
// 525740: using guessed type int PauseMode;
1979-
// 52575C: using guessed type int doomflag;
1980-
// 69BD04: using guessed type int questlog;
1981-
// 6AA705: using guessed type char stextflag;
19821990

19831991
void __cdecl LoadLvlGFX()
19841992
{

Source/diablo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ extern int glSeedTbl[NUMLEVELS];
1414
extern int gbRunGame; // weak
1515
extern int glMid3Seed[NUMLEVELS];
1616
extern int gbRunGameResult; // weak
17-
extern int zoomflag; // weak
1817
extern int gbProcessPlayers; // weak
1918
extern int glEndSeed[NUMLEVELS];
2019
extern int dword_5256E8; // weak

Source/dx.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ char gbBackBuf; // weak
1515
char gbEmulate; // weak
1616
HMODULE ghDiabMod; // idb
1717
int currentGameState=0;
18+
int globalScrollZoom = 0;
1819
void setGameState(int state) {
1920
currentGameState = state;
2021
lpDDSPrimary->UpdateOverlayDisplay(state);

Source/engine.cpp

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ void PrintDebugInfo() {
19011901
std::stringstream ss;
19021902
int isActivated = -1;
19031903
if (pcursmonst != -1) { isActivated = monster[pcursmonst].isActivated; }
1904-
ss << "debuginfo: " << MouseX << " " << MouseY << " " << (int)plr[myplr]._pSplLvl[plr[myplr]._pRSpell] << " " << (int)plr[myplr]._pISplLvlAdd;
1904+
ss << "debuginfo: " << MouseX << " " << MouseY << " " << globalScrollZoom;
19051905
if (played == false) {
19061906
PlaySFX(num++);
19071907
played = true;
@@ -2016,6 +2016,46 @@ void DrawXpBar()
20162016
}
20172017
}
20182018
}
2019+
bool AreAffixesGoodForItem(int i, char affix) {
2020+
std::set<char> uselessAffixes;
2021+
uselessAffixes.insert(IPL_DUR);
2022+
uselessAffixes.insert(IPL_INDESTRUCTIBLE);
2023+
2024+
switch (item[i]._itype) {
2025+
case ITYPE_SWORD:
2026+
case ITYPE_AXE:
2027+
case ITYPE_STAFF:
2028+
case ITYPE_MACE:
2029+
uselessAffixes.insert(IPL_ACP);
2030+
uselessAffixes.insert(IPL_LIGHT_ARROWS);
2031+
uselessAffixes.insert(IPL_FIRE_ARROWS);
2032+
break;
2033+
case ITYPE_BOW:
2034+
uselessAffixes.insert(IPL_ACP);
2035+
uselessAffixes.insert(IPL_LIGHTDAM);
2036+
uselessAffixes.insert(IPL_FIREDAM);
2037+
2038+
break;
2039+
case ITYPE_SHIELD:
2040+
uselessAffixes.insert(IPL_LIGHT_ARROWS);
2041+
uselessAffixes.insert(IPL_FIRE_ARROWS);
2042+
break;
2043+
case ITYPE_LARMOR:
2044+
case ITYPE_HELM:
2045+
case ITYPE_MARMOR:
2046+
case ITYPE_HARMOR:
2047+
break;
2048+
case ITYPE_RING:
2049+
case ITYPE_AMULET:
2050+
uselessAffixes.insert(IPL_ACP);
2051+
break;
2052+
default:
2053+
break;
2054+
}
2055+
return uselessAffixes.find(affix) == uselessAffixes.end();
2056+
}
2057+
2058+
20192059
bool AreAffixesGood(char p1, char p2) {
20202060
if (p1 == p2) { return false; }
20212061
map<int, set<int> > sadAffix;
@@ -2038,6 +2078,7 @@ bool AreAffixesGood(char p1, char p2) {
20382078

20392079
sadAffix[IPL_GETHIT] = { IPL_GETHIT_CURSE };
20402080
sadAffix[IPL_LIFE] = { IPL_LIFE_CURSE };
2081+
sadAffix[IPL_ACP] = { IPL_ACP_CURSE};
20412082
sadAffix[IPL_MANA] = { IPL_MANA_CURSE };
20422083
sadAffix[IPL_DUR_CURSE] = { IPL_DUR,IPL_INDESTRUCTIBLE };
20432084
sadAffix[IPL_TOHIT_DAMP_CURSE] = { IPL_TOHIT_CURSE,IPL_TOHIT,IPL_TOHIT_DAMP,IPL_DAMP };
@@ -2068,7 +2109,8 @@ void GenerateRareUniqueAffix(int i, int x, int y, int minlvl, int maxlvl, std::s
20682109
for (auto f : powers) {
20692110
if (!AreAffixesGood(f, PL_UPrefix[prefIter].PLPower)) { allGood = false; break; }
20702111
}
2071-
if (PL_UPrefix[prefIter].PLMinLvl >= minlvl && PL_UPrefix[prefIter].PLMinLvl <= maxlvl && PL_UPrefix[prefIter].PLOk && allGood==true)
2112+
bool affixGood = AreAffixesGoodForItem(i, PL_UPrefix[prefIter].PLPower);
2113+
if (PL_UPrefix[prefIter].PLMinLvl >= minlvl && PL_UPrefix[prefIter].PLMinLvl <= maxlvl && PL_UPrefix[prefIter].PLOk && allGood==true && affixGood==true)
20722114
{
20732115
pref[local_pref_iter++] = prefIter;
20742116
if (PL_Prefix[prefIter].PLDouble) {
@@ -2103,7 +2145,8 @@ void GenerateRareUniqueAffix(int i, int x, int y, int minlvl, int maxlvl, std::s
21032145
for (auto f : powers) {
21042146
if (!AreAffixesGood(f, PL_USuffix[sufIter].PLPower)) { allGood = false; break; }
21052147
}
2106-
if (PL_USuffix[sufIter].PLMinLvl >= minlvl && PL_USuffix[sufIter].PLMinLvl <= maxlvl && PL_Suffix[sufIter].PLOk && allGood==true)
2148+
bool affixGood = AreAffixesGoodForItem(i, PL_USuffix[sufIter].PLPower);
2149+
if (PL_USuffix[sufIter].PLMinLvl >= minlvl && PL_USuffix[sufIter].PLMinLvl <= maxlvl && PL_Suffix[sufIter].PLOk && allGood==true && affixGood==true)
21072150
{
21082151
suf[local_suf_iter++] = sufIter;
21092152
if (PL_USuffix[sufIter].PLDouble) {
@@ -2147,7 +2190,8 @@ void GenerateRareAffix(int i,int x, int y, int minlvl, int maxlvl, char prefPowe
21472190
do {
21482191
bool prefGood = AreAffixesGood(prefPower, PL_UPrefix[prefIter].PLPower);
21492192
bool sufGood = AreAffixesGood(sufPower, PL_UPrefix[prefIter].PLPower);
2150-
if (PL_UPrefix[prefIter].PLMinLvl >= minlvl && PL_UPrefix[prefIter].PLMinLvl <= maxlvl && PL_UPrefix[prefIter].PLOk && prefGood && sufGood)
2193+
bool affixGood = AreAffixesGoodForItem(i, PL_UPrefix[prefIter].PLPower);
2194+
if (PL_UPrefix[prefIter].PLMinLvl >= minlvl && PL_UPrefix[prefIter].PLMinLvl <= maxlvl && PL_UPrefix[prefIter].PLOk && prefGood && sufGood && affixGood)
21512195
{
21522196
pref[local_pref_iter++] = prefIter;
21532197
if (PL_Prefix[prefIter].PLDouble) {
@@ -2180,7 +2224,8 @@ void GenerateRareAffix(int i,int x, int y, int minlvl, int maxlvl, char prefPowe
21802224
do {
21812225
bool prefGood = AreAffixesGood(prefPower, PL_USuffix[sufIter].PLPower);
21822226
bool sufGood = AreAffixesGood(sufPower, PL_USuffix[sufIter].PLPower);
2183-
if (PL_USuffix[sufIter].PLMinLvl >= minlvl && PL_USuffix[sufIter].PLMinLvl <= maxlvl && PL_Suffix[sufIter].PLOk && prefGood && sufGood)
2227+
bool affixGood = AreAffixesGoodForItem(i, PL_USuffix[sufIter].PLPower);
2228+
if (PL_USuffix[sufIter].PLMinLvl >= minlvl && PL_USuffix[sufIter].PLMinLvl <= maxlvl && PL_Suffix[sufIter].PLOk && prefGood && sufGood && affixGood)
21842229
{
21852230
suf[local_suf_iter++] = sufIter;
21862231
if (PL_USuffix[sufIter].PLDouble) {

Source/engine.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void ReloadConfig();
7878
bool CanPutToBelt(int miscId);
7979
int FreeSlotOnBelt();
8080
bool CanRun(int pnum);
81-
int CalculateSpellPower(int pnum);
81+
int CalculateSpellPower(int pnum, int spell, int spellType);
8282
int MonstersInCombat(int pnum);
8383
int GetTextWidth(char* s);
8484
void PrintDebugInfo();
@@ -111,7 +111,7 @@ extern int currentGameState;
111111
void setGameState(int state);
112112
void fatalLua(const char* message);
113113
void LuaInit();
114-
114+
void DrawGame(int StartX, int StartY, bool isTown);
115115

116116
extern std::map<std::string, bool> BoolConfig;
117117
extern std::map<std::string, int> IntConfig;
@@ -128,6 +128,7 @@ extern int HighlightedItemCol;
128128
extern bool ShouldHighlightItems;
129129
extern lua_State* L;
130130
extern bool lootFilterBroken;
131+
extern int globalScrollZoom;
131132

132133
// try versioning struct size
133134
#define countof( a ) __crt_countof( a )

Source/gendung.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -650,27 +650,7 @@ void __cdecl SetDungeonMicros()
650650
while ( (signed int)v8 < (signed int)dpiece_defs_map_2[0][16] ); /* check */
651651
gendung_418D91();
652652
gendung_4192C2();
653-
if ( zoomflag )
654-
{
655-
scr_pix_width = 640;
656-
scr_pix_height = 352;
657-
dword_5C2FF8 = 10;
658-
dword_5C2FFC = 11;
659-
}
660-
else
661-
{
662-
scr_pix_width = 384;
663-
scr_pix_height = 224;
664-
dword_5C2FF8 = 6;
665-
dword_5C2FFC = 7;
666-
}
667653
}
668-
// 52569C: using guessed type int zoomflag;
669-
// 5BB1ED: using guessed type char leveltype;
670-
// 5C2FF8: using guessed type int dword_5C2FF8;
671-
// 5C2FFC: using guessed type int dword_5C2FFC;
672-
// 5C3000: using guessed type int scr_pix_width;
673-
// 5C3004: using guessed type int scr_pix_height;
674654

675655
void __cdecl DRLG_InitTrans()
676656
{

0 commit comments

Comments
 (0)