Skip to content

Commit

Permalink
fix for signed stats
Browse files Browse the repository at this point in the history
  • Loading branch information
bobode committed Nov 2, 2011
1 parent fd40929 commit 272c616
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion D2Ptrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ FUNCPTR(D2COMMON, GetLevel, Level * __fastcall, (ActMisc *pMisc, DWORD dwLevelNo

FUNCPTR(D2COMMON, GetStatList, StatList* __stdcall, (UnitAny* pUnit, DWORD dwUnk, DWORD dwMaxEntries ), 0x57830)
FUNCPTR(D2COMMON, CopyStatList, DWORD __stdcall, (StatList* pStatList, Stat* pStatArray, DWORD dwMaxEntries), 0x57D30)
FUNCPTR(D2COMMON, GetUnitStat, DWORD __stdcall, (UnitAny* pUnit, DWORD dwStat, DWORD dwStat2), 0x584E0)
FUNCPTR(D2COMMON, GetUnitStat, long __stdcall, (UnitAny* pUnit, DWORD dwStat, DWORD dwStat2), 0x584E0)
FUNCPTR(D2COMMON, GetUnitState, int __stdcall, (UnitAny *pUnit, DWORD dwStateNo), 0x2F310)

FUNCPTR(D2COMMON, CheckUnitCollision, DWORD __stdcall, (UnitAny* pUnitA, UnitAny* pUnitB, DWORD dwBitMask), 0x17CF0)
Expand Down
8 changes: 4 additions & 4 deletions Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ void SendGold(int nGold, int nMode)
D2CLIENT_PerformGoldDialogAction();
}

void __fastcall UseStatPoint(WORD stat, unsigned int count)
void __fastcall UseStatPoint(WORD stat, int count)
{
if(D2COMMON_GetUnitStat(D2CLIENT_GetPlayerUnit(), STAT_STATPOINTSLEFT, 0) < count)
return;

BYTE packet[3] = {0x3A};
*(WORD*)&packet[1] = stat;

for(unsigned int i = 0; i < count; i++)
for( int i = 0; i < count; i++)
{
D2CLIENT_SendGamePacket(3, packet);
if(i != count-1) Sleep(500);
}
}

void __fastcall UseSkillPoint(WORD skill, unsigned int count)
void __fastcall UseSkillPoint(WORD skill, int count)
{
if(D2COMMON_GetUnitStat(D2CLIENT_GetPlayerUnit(), STAT_SKILLPOINTSLEFT, 0) < count)
return;

BYTE packet[3] = {0x3B};
*(WORD*)&packet[1] = skill;

for(unsigned int i = 0; i < count; i++)
for( int i = 0; i < count; i++)
{
D2CLIENT_SendGamePacket(3, packet);
if(i != count-1) Sleep(500);
Expand Down
4 changes: 2 additions & 2 deletions Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#include "D2Ptrs.h"

void SendGold(int nGold, int nMode);
void __fastcall UseStatPoint(WORD stat, unsigned int count = 1);
void __fastcall UseSkillPoint(WORD skill, unsigned int count = 1);
void __fastcall UseStatPoint(WORD stat, int count = 1);
void __fastcall UseSkillPoint(WORD skill, int count = 1);
2 changes: 2 additions & 0 deletions JSUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,8 @@ JSAPI_FUNC(unit_getStat)
*rval = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, nStat, nSubIndex)>>8);
else if(nStat == 13 || nStat == 29 || nStat == 30)
JS_NewNumberValue(cx, (unsigned int)D2COMMON_GetUnitStat(pUnit, nStat, nSubIndex), rval);
//else if (nStat == 36 || nStat == 37 || nStat == 39|| nStat == 41 || nStat == 43|| nStat == 45) // negitive resistance
// *rval = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, nStat, nSubIndex));
else if(nStat == 92)
*rval = INT_TO_JSVAL(D2COMMON_GetItemLevelRequirement(pUnit, D2CLIENT_GetPlayerUnit()));
else if(nStat == -1)
Expand Down

0 comments on commit 272c616

Please sign in to comment.