Optional change to CharInfo routine...

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

NealThorpayt
Developer
Developer
Posts: 66
Joined: Thu Mar 13, 2003 2:14 pm
Location: Miskatonic University
Contact:

Post by NealThorpayt » Fri Apr 18, 2003 5:10 am

Greetings Constructs,

I believe my premise that the bank slot offset is not in the _CHARINFO struct is invalid.

DKAA, can you check your disassembly of EQGame.EXE line 0x0042A82D

Mine reads:

Code: Select all

:0042A82D 8D9C8140370000           lea ebx, dword ptr [exc+4*eax+00003740]
This is the bankslot offset from the start of the _CHARINFO struct.

If yours differs we have found the problem.

End of line...
By the pricking of my thumb, something wicked this way comes...

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Apr 18, 2003 12:33 pm

0042a82d 8d9c8140370000 lea ebx,[ecx+eax*4+0x3740]

Looks the same. And, in fact, 0x3740 is the correct offset in memory.

Did I screw up when I checked in the structs to cvs? My compiled code is generating 0x3744 as the offset. I thought I cut and pasted from your post....

As to the ZONELIST, either I found another struct that is similar to the ZONELIST, or I missed a byte somewhere. It was late when I look at this.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Apr 18, 2003 1:29 pm

Okay, you have a different CHARINFO struct than I have.

I dragged the struct from the CVS mq.h and compiled it with gcc. I get offset 0x3744 for the first Bank entry, just like the VC6.0 and VC7.0.

Here is the test:

Code: Select all

#include <stdio.h>

typedef char BYTE;
typedef short WORD;
typedef int DWORD;
typedef char CHAR;
typedef float FLOAT;

typedef struct _SPELLBUFF {
   BYTE      Unknown0000;
   BYTE      Level;
   WORD      Unknown0002;
   WORD      SpellID;
   WORD      Unknown0006;
   DWORD      Duration;
   DWORD      Unknown;
} SPELLBUFF, *PSPELLBUFF; 

#define      NUM_BANK_SLOTS         16

typedef void *PITEMINFO;  // generic pointer

typedef struct _CHARINFO {
   BYTE      Unknown0000;
   BYTE      Unknown0001;
   CHAR      Name[64];
   CHAR      Lastname[70];
   DWORD      Unknown0136;
   DWORD      Race;
   DWORD      Class;
   DWORD      Gender;
   DWORD      Level;
   DWORD      Exp;
   DWORD      Face;
   DWORD      Mana;
   DWORD      BaseHP;
   DWORD      Stunned;
   DWORD      BaseSTR;
   DWORD      BaseSTA;
   DWORD      BaseCHA;
   DWORD      BaseDEX;
   DWORD      BaseINT;
   DWORD      BaseAGI;
   DWORD      BaseWIS;
   BYTE Unknown0204[172];
   BYTE      Language[32];
   BYTE Unknown0408[496];
   SPELLBUFF   Buff[15];
   BYTE Unknown1144[1800];
   DWORD      SpellBook[256];
   BYTE Unknown3968[1024];
   DWORD      MemorizedSpells[8];
   BYTE Unknown5024[56];
   DWORD      Plat;
   DWORD      Gold;
   DWORD      Silver;
   DWORD      Copper;
   DWORD      BankPlat;
   DWORD      BankGold;
   DWORD      BankSilver;
   DWORD      BankCopper;
   BYTE Unknown5112[32];
   DWORD      Skill[125];
   BYTE Unknown5644[112];
   DWORD      AutoSplit;
   BYTE Unknown5760[96];
   struct _SPAWNINFO*   pSpawn;
   PITEMINFO   Inventory[30];
   PITEMINFO   Cursor;   
   BYTE Unknown5984[4];
   DWORD      STR;
   DWORD      STA;
   DWORD      CHA;
   DWORD      DEX;
   DWORD      INT;
   DWORD      AGI;
   DWORD      WIS;
   BYTE      Unknown6016[4];
   DWORD      SaveMagic;
   DWORD      SaveFire;
   DWORD      SaveCold;
   DWORD      SavePosion;
   DWORD      SaveDisease;
   DWORD      CurrWeight;
   BYTE      Uknown6044[12];
   SPELLBUFF   ShortBuff[6];
   BYTE Unknown6152[912];
   DWORD ZoneBoundId;
   DWORD ZoneBirthId;
   DWORD ZoneOtherId[3];
   FLOAT ZoneBoundX;
   FLOAT ZoneBirthX;
   FLOAT ZoneOtherX[3];
   FLOAT ZoneBoundY;
   FLOAT ZoneBirthY;
   FLOAT ZoneOtherY[3];
   FLOAT ZoneBoundZ;
   FLOAT ZoneBirthZ;
   FLOAT ZoneOtherZ[3];
   BYTE Unknown7144[3548];
   DWORD      GuildID;
   BYTE Unknown10696[15];
   BYTE      Anon;
   WORD GuildStatus;
   BYTE Unknown10714[452];
   DWORD AAExp;
   BYTE Unknown11170[428];
   DWORD AAPoints;
   BYTE Unknown11602[2542];
   PITEMINFO   Bank[NUM_BANK_SLOTS];
} CHARINFO, *PCHARINFO;

main()
{
 PCHARINFO p = NULL;
 printf("0x%x\n", &p->Bank);
}

NealThorpayt
Developer
Developer
Posts: 66
Joined: Thu Mar 13, 2003 2:14 pm
Location: Miskatonic University
Contact:

Post by NealThorpayt » Fri Apr 18, 2003 3:25 pm

Greetings Constructs,

As a first step in figuring out why you might have an offset of 0x3744, I disassembled my EQLib.dll and checked the offset in the UpdateItemInfo routine. Here is the pertinent line:

Code: Select all

:0300EDBE 83BC814037000000        cmp dword ptr [ecx+4*eax+00003740], 00000000
:?: Question: Are you using VC .NET or VC6?
:?: Question: How did you go about finding that the offset is 0x3744 instead of 0x3740?

I will check the code you posted next to see if there are any discrepencies with my code.

:idea: Theory: If all else checks out, perhaps a compiler setting is different and we are looking at a size of type difference that is causing the problem. Or, possibly a type alignment boundary issue.

End of line...
By the pricking of my thumb, something wicked this way comes...

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Apr 18, 2003 6:38 pm

1. I checked VC60, VC70, and gcc.
2. Besides the program above, I added the cod file target to the makefile

Code: Select all

; 3575 :    for (nInvIdx=0; nInvIdx < NUM_BANK_SLOTS; nInvIdx++) {

  001e3 8b 54 24 1c      mov     edx, DWORD PTR _pCharInfo$[esp+2080]
  001e7 c7 44 24 14 10
        00 00 00         mov     DWORD PTR -2060+[esp+2080], 16 ; 00000010H
  001ef 8d 9a 44 37 00
        00               lea     ebx, DWORD PTR [edx+14148]
I have building with the makefiles. I will test with VS.NET and the project files.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Fri Apr 18, 2003 7:55 pm

Bah, compilers suck.

/Zp1 is needed. This tells the compiler to bound structs to a single byte boundary.

Fixed in CVS.

NealThorpayt
Developer
Developer
Posts: 66
Joined: Thu Mar 13, 2003 2:14 pm
Location: Miskatonic University
Contact:

Good work!

Post by NealThorpayt » Fri Apr 18, 2003 9:37 pm

Greetings Constructs,

Just wanted to say "GOOD WORK" DKAA. You rock. You really contribute a lot to this project.

KUDOS.

End of line...
By the pricking of my thumb, something wicked this way comes...

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Fri Apr 18, 2003 10:26 pm

Salutations,
And another bug bites the dust! w00t! we be 1337 H4xx0r2 now! lol, anyway um... *sighs* Good work both of you, especially you NT for double posting :p