Browse Source

Item Records & DrawDiabloMsg (#971)

pull/88/head
galaxyhaxz 7 years ago committed by GitHub
parent
commit
fe55ca18cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 103
      Source/error.cpp
  2. 185
      Source/items.cpp
  3. 6
      Source/items.h
  4. 2
      structs.h

103
Source/error.cpp

@ -84,40 +84,28 @@ void ClrDiabloMsg()
void DrawDiabloMsg()
{
int v0; // esi
signed int v1; // edi
int v8; // edi
signed int v9; // ebx
signed int v10; // eax
signed int v11; // ecx
int v12; // esi
signed int v13; // esi
unsigned char v14; // bl
BOOLEAN v15; // zf
signed int v16; // [esp+Ch] [ebp-8h]
signed int v17; // [esp+Ch] [ebp-8h]
signed int screen_x; // [esp+10h] [ebp-4h]
int i, len, off, width, sx, sy;
BYTE c;
CelDecodeOnly(165, 318, (BYTE *)pSTextSlidCels, 1, 12);
CelDecodeOnly(591, 318, (BYTE *)pSTextSlidCels, 4, 12);
CelDecodeOnly(165, 366, (BYTE *)pSTextSlidCels, 2, 12);
CelDecodeOnly(591, 366, (BYTE *)pSTextSlidCels, 3, 12);
screen_x = 173;
v16 = 35;
do {
CelDecodeOnly(screen_x, 318, (BYTE *)pSTextSlidCels, 5, 12);
CelDecodeOnly(screen_x, 366, (BYTE *)pSTextSlidCels, 7, 12);
screen_x += 12;
--v16;
} while (v16);
v0 = 330;
v1 = 3;
do {
CelDecodeOnly(165, v0, (BYTE *)pSTextSlidCels, 6, 12);
CelDecodeOnly(591, v0, (BYTE *)pSTextSlidCels, 8, 12);
v0 += 12;
--v1;
} while (v1);
sx = 173;
for(i = 0; i < 35; i++) {
CelDecodeOnly(sx, 318, (BYTE *)pSTextSlidCels, 5, 12);
CelDecodeOnly(sx, 366, (BYTE *)pSTextSlidCels, 7, 12);
sx += 12;
}
sy = 330;
for(i = 0; i < 3; i++) {
CelDecodeOnly(165, sy, (BYTE *)pSTextSlidCels, 6, 12);
CelDecodeOnly(591, sy, (BYTE *)pSTextSlidCels, 8, 12);
sy += 12;
}
/// ASSERT: assert(gpBuffer);
#define TRANS_RECT_X 104
#define TRANS_RECT_Y 150
@ -126,39 +114,36 @@ void DrawDiabloMsg()
#include "asm_trans_rect.inc"
strcpy(tempstr, MsgStrings[msgflag]);
v8 = screen_y_times_768[342] + 165;
v9 = strlen(tempstr);
v10 = 0;
v11 = 0;
v17 = v9;
if (v9 <= 0)
goto LABEL_27;
do {
v12 = (unsigned char)tempstr[v11++];
v10 += fontkern[fontframe[gbFontTransTbl[v12]]] + 1;
} while (v11 < v9);
if (v10 < 442)
LABEL_27:
v8 += (442 - v10) >> 1;
v13 = 0;
if (v9 > 0) {
do {
v14 = fontframe[gbFontTransTbl[(unsigned char)tempstr[v13]]];
if (v14)
CPrintString(v8, v14, 3);
++v13;
v8 += fontkern[v14] + 1;
} while (v13 < v17);
off = 165 + screen_y_times_768[342];
len = strlen(tempstr);
width = 0;
for(i = 0; i < len; i++) {
width += fontkern[fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]] + 1;
}
if(width < 442) {
off += (442 - width) >> 1;
}
for(i = 0; i < len; i++) {
c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]];
if(c != '\0') {
CPrintString(off, c, COL_GOLD);
}
off += fontkern[c] + 1;
}
if(msgdelay > 0) {
msgdelay--;
}
v15 = msgdelay == 0;
if (msgdelay > 0)
v15 = --msgdelay == 0;
if (v15) {
v15 = msgcnt-- == 1;
if(msgdelay == 0) {
msgcnt--;
msgdelay = 70;
if (v15)
if(msgcnt == 0) {
msgflag = 0;
else
} else {
msgflag = msgtable[msgcnt];
}
}
}

185
Source/items.cpp

@ -1368,11 +1368,15 @@ void CreatePlrItems(int p)
SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_RIGHT], IDI_WARRSHLD);
GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_RIGHT]);
// TODO: Add debug logic from 1.00 here
SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB);
GetPlrHandSeed(&plr[p].HoldItem);
AutoPlace(p, 0, 1, 3, 1);
#ifdef _DEBUG
if(!debug_mode_key_w) {
#endif
SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB);
GetPlrHandSeed(&plr[p].HoldItem);
AutoPlace(p, 0, 1, 3, TRUE);
#ifdef _DEBUG
}
#endif
SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL);
GetPlrHandSeed(&plr[p].SpdList[0]);
@ -1405,14 +1409,26 @@ void CreatePlrItems(int p)
SetPlrHandItem(&plr[p].HoldItem, IDI_GOLD);
GetPlrHandSeed(&plr[p].HoldItem);
// TODO: Add debug logic from 1.00 here
plr[p].HoldItem._iCurs = CURSOR_RECHARGE;
plr[p].HoldItem._ivalue = 100;
plr[p]._pGold = 100;
plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem;
plr[p].InvGrid[30] = plr[p]._pNumInv;
#ifdef _DEBUG
if(!debug_mode_key_w) {
#endif
plr[p].HoldItem._ivalue = 100;
plr[p].HoldItem._iCurs = ICURS_GOLD_SMALL;
plr[p]._pGold = plr[p].HoldItem._ivalue;
plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem;
plr[p].InvGrid[30] = plr[p]._pNumInv;
#ifdef _DEBUG
} else {
plr[p].HoldItem._ivalue = 5000;
plr[p].HoldItem._iCurs = ICURS_GOLD_LARGE;
plr[p]._pGold = plr[p].HoldItem._ivalue * 40;
for(i = 0; i < 40; i++) {
GetPlrHandSeed(&plr[p].HoldItem);
plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem;
plr[p].InvGrid[i] = plr[p]._pNumInv;
}
}
#endif
CalcPlrItemVals(p, FALSE);
}
@ -4712,113 +4728,70 @@ void CreateMagicWeapon(int x, int y, int imisc, int icurs, int sendmsg, int delt
}
}
BOOL GetItemRecord(int dwSeed, WORD CI, int indx)
BOOL GetItemRecord(int nSeed, WORD wCI, int nIndex)
{
int v3; // edi
int *v4; // ebx
int v6; // [esp+Ch] [ebp-18h]
DWORD v7; // [esp+10h] [ebp-14h]
int *v8; // [esp+14h] [ebp-10h]
unsigned short *v9; // [esp+18h] [ebp-Ch]
ItemGetRecordStruct *v10; // [esp+1Ch] [ebp-8h]
short v11; // [esp+20h] [ebp-4h]
v11 = CI;
v6 = dwSeed;
v3 = 0;
v7 = GetTickCount();
if (gnNumGetRecords <= 0)
return 1;
v8 = &itemrecord[0].nIndex;
v9 = &itemrecord[0].wCI;
v10 = itemrecord;
v4 = &itemrecord[0].dwTimestamp;
while (v7 - *v4 > 6000) {
NextItemRecord(v3);
--v10;
v9 -= 8;
--v3;
v4 -= 4;
v8 -= 4;
LABEL_8:
++v10;
v9 += 8;
v8 += 4;
++v3;
v4 += 4;
if (v3 >= gnNumGetRecords)
return 1;
}
if (v6 != v10->nSeed || v11 != *v9 || indx != *v8)
goto LABEL_8;
return 0;
int i;
DWORD dwTicks;
dwTicks = GetTickCount();
for(i = 0; i < gnNumGetRecords; i++) {
if(dwTicks - itemrecord[i].dwTimestamp > 6000) {
NextItemRecord(i);
i--;
} else if(nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
return FALSE;
}
}
return TRUE;
}
void NextItemRecord(int i)
{
int v1; // eax
gnNumGetRecords--;
v1 = gnNumGetRecords-- - 1;
if (gnNumGetRecords) {
itemrecord[i].nIndex = itemrecord[v1].nIndex;
itemrecord[i].nSeed = itemrecord[v1].nSeed;
itemrecord[i].wCI = itemrecord[v1].wCI;
itemrecord[i].dwTimestamp = itemrecord[v1].dwTimestamp;
if(gnNumGetRecords == 0) {
return;
}
itemrecord[i].dwTimestamp = itemrecord[gnNumGetRecords].dwTimestamp;
itemrecord[i].nSeed = itemrecord[gnNumGetRecords].nSeed;
itemrecord[i].wCI = itemrecord[gnNumGetRecords].wCI;
itemrecord[i].nIndex = itemrecord[gnNumGetRecords].nIndex;
}
void SetItemRecord(int dwSeed, WORD CI, int indx)
void SetItemRecord(int nSeed, WORD wCI, int nIndex)
{
int i; // ecx
DWORD dwTicks;
dwTicks = GetTickCount();
if (gnNumGetRecords != MAXITEMS) {
i = gnNumGetRecords++;
itemrecord[i].dwTimestamp = GetTickCount();
itemrecord[i].nSeed = dwSeed;
itemrecord[i].wCI = CI;
itemrecord[i].nIndex = indx;
if(gnNumGetRecords == MAXITEMS) {
return;
}
itemrecord[gnNumGetRecords].dwTimestamp = dwTicks;
itemrecord[gnNumGetRecords].nSeed = nSeed;
itemrecord[gnNumGetRecords].wCI = wCI;
itemrecord[gnNumGetRecords].nIndex = nIndex;
gnNumGetRecords++;
}
void PutItemRecord(int seed, WORD ci, int index)
void PutItemRecord(int nSeed, WORD wCI, int nIndex)
{
int v3; // edi
int *v4; // ebx
int v5; // [esp+Ch] [ebp-18h]
DWORD v6; // [esp+10h] [ebp-14h]
int *v7; // [esp+14h] [ebp-10h]
unsigned short *v8; // [esp+18h] [ebp-Ch]
ItemGetRecordStruct *v9; // [esp+1Ch] [ebp-8h]
short v10; // [esp+20h] [ebp-4h]
v10 = ci;
v5 = seed;
v3 = 0;
v6 = GetTickCount();
if (gnNumGetRecords > 0) {
v7 = &itemrecord[0].nIndex;
v8 = &itemrecord[0].wCI;
v9 = itemrecord;
v4 = &itemrecord[0].dwTimestamp;
do {
if (v6 - *v4 <= 6000) {
if (v5 == v9->nSeed && v10 == *v8 && index == *v7) {
NextItemRecord(v3);
return;
}
} else {
NextItemRecord(v3);
--v9;
v8 -= 8;
--v3;
v4 -= 4;
v7 -= 4;
}
++v9;
v8 += 8;
v7 += 4;
++v3;
v4 += 4;
} while (v3 < gnNumGetRecords);
int i;
DWORD dwTicks;
dwTicks = GetTickCount();
for(i = 0; i < gnNumGetRecords; i++) {
if(dwTicks - itemrecord[i].dwTimestamp > 6000) {
NextItemRecord(i);
i--;
} else if(nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
NextItemRecord(i);
break;
}
}
}

6
Source/items.h

@ -121,10 +121,10 @@ int ItemNoFlippy();
void CreateSpellBook(int x, int y, int ispell, BOOLEAN sendmsg, int delta);
void CreateMagicArmor(int x, int y, int imisc, int icurs, int sendmsg, int delta);
void CreateMagicWeapon(int x, int y, int imisc, int icurs, int sendmsg, int delta);
BOOL GetItemRecord(int dwSeed, WORD CI, int indx);
BOOL GetItemRecord(int nSeed, WORD wCI, int nIndex);
void NextItemRecord(int i);
void SetItemRecord(int dwSeed, WORD CI, int indx);
void PutItemRecord(int seed, WORD ci, int index);
void SetItemRecord(int nSeed, WORD wCI, int nIndex);
void PutItemRecord(int nSeed, WORD wCI, int nIndex);
/* rdata */

2
structs.h

@ -87,7 +87,7 @@ typedef struct ItemGetRecordStruct {
int nSeed;
unsigned short wCI;
int nIndex;
int dwTimestamp;
unsigned int dwTimestamp;
} ItemGetRecordStruct;
typedef struct ItemStruct {

Loading…
Cancel
Save