Skip to content

Commit

Permalink
- Changed: Now CHARDEFs can read custom Item Resources as an ICON, th…
Browse files Browse the repository at this point in the history
…e restriction of being TILEDATA value is removed. (Issue: Sphereserver#1301)
  • Loading branch information
xwerswoodx committed Oct 16, 2024
1 parent 8053f36 commit f295506
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3943,6 +3943,7 @@ Added: 'H' shortcut for variables to get the value as hexadecimal.
2593

[EOF]
- Changed: Now CHARDEFs can read custom Item Resources as an ICON, the restriction of being TILEDATA value is removed. (Issue: #1301)

16-10-2024, canerksk
Fixed: The mismatched default value check was causing the price of items without a set price to return as -2,147,483,648. (Issue: #1233)
38 changes: 27 additions & 11 deletions src/game/chars/CCharBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ bool CCharBase::r_WriteVal( lpctstr ptcKey, CSString & sVal, CTextConsole * pSrc
case CBC_HIREDAYWAGE:
sVal.FormatVal( m_iHireDayWage );
break;
case CBC_ICON:
sVal.FormatHex( m_trackID );
break;
case CBC_ICON:
sVal.FormatHex(m_trackID);
break;
case CBC_INT:
sVal.FormatVal( m_Int );
break;
Expand Down Expand Up @@ -390,14 +390,30 @@ bool CCharBase::r_LoadVal( CScript & s )
case CBC_HIREDAYWAGE:
m_iHireDayWage = s.GetArgVal();
break;
case CBC_ICON:
{
ITEMID_TYPE id = (ITEMID_TYPE)(g_Cfg.ResourceGetIndexType( RES_ITEMDEF, s.GetArgStr()));
if ( (id < 0) || (id >= ITEMID_MULTI) )
return false;
m_trackID = id;
}
break;
case CBC_ICON:
{
ITEMID_TYPE id = (ITEMID_TYPE)s.GetArgDWVal();
if (id > ITEMID_NOTHING) //Is ICON valid item?
{
m_trackID = id;
}
else //If ICON is invalid, check the base Character ICON.
{
CREID_TYPE baseID = (CREID_TYPE)GetResourceID().GetResIndex();
CCharBase *pBase = FindCharBase(baseID);
if (pBase && pBase->m_trackID > ITEMID_NOTHING)
{
m_trackID = pBase->m_trackID;
}
else
{
// This should only happen if the char and the base char has no icon defined.
// If all checks invalid, return i_pet_wisp as default icon.
m_trackID = ITEMID_TRACK_WISP;
}
}
break;
}
case CBC_ID:
return SetDispID((CREID_TYPE)(g_Cfg.ResourceGetIndexType( RES_CHARDEF, s.GetArgStr())));
case CBC_INT:
Expand Down

0 comments on commit f295506

Please sign in to comment.