Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added spherecustom.ini definition #1310

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3914,3 +3914,36 @@ Added: 'H' shortcut for variables to get the value as hexadecimal.

13-10-2024, Jhobean
- Added: @PetRelease trigger work like @petdesert and return 1 to prevent the pet from being released.

16-10-2024, xwerswoodx
- Added: spherecustom.ini definition has been added to Sphere.
This allows you to override Sphere settings without touching the Sphere.ini file.
For example, when you want to switch from an older Sphere version to 56x or when you haven't updated for a long time, instead of checking all the new data
added to Sphere.ini one by one, you can simply use your old sphere.ini as spherecustom.ini. This way, newly added data will take the default settings from
Sphere.ini, while your previous custom settings will override the defaults without requiring any further adjustments.
On the other hand, it helps you maintain a clean Sphere.ini. Instead of directly changing the Sphere.ini settings, you can create a spherecustom.ini file
and add only the settings you want to change there, allowing you to easily track the changes without modifying Sphere.ini.
Here's an example of a spherecustom.ini:
[SPHERE]
AGREE=1

// Server Data
ServName=MyCuteServer
ServIP=255.255.255.255
ServPort=2593

// Server Settings
AdvancedLos=2
GuardsInstatntKill=0
FeatureT2A = 01|02

[SERVERS]
MyCuteServer
255.255.255.255
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)
53 changes: 35 additions & 18 deletions src/game/CServerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4542,23 +4542,37 @@ void CServerConfig::PrintEFOFFlags(bool bEF, bool bOF, CTextConsole *pSrc)

bool CServerConfig::LoadIni( bool fTest )
{
ADDTOCALLSTACK("CServerConfig::LoadIni");
// Load my INI file first.
if ( ! OpenResourceFind( m_scpIni, SPHERE_FILE ".ini", !fTest )) // Open script file
{
if( !fTest )
{
g_Log.Event(LOGL_FATAL|LOGM_INIT|LOGF_CONSOLE_ONLY, SPHERE_FILE ".ini has not been found.\n");
g_Log.Event(LOGL_FATAL|LOGM_INIT|LOGF_CONSOLE_ONLY, "Download a sample sphere.ini from https://github.com/Sphereserver/Source-X/tree/master/src\n");
}
return false;
}

LoadResourcesOpen(&m_scpIni);
m_scpIni.Close();
m_scpIni.CloseForce();
ADDTOCALLSTACK("CServerConfig::LoadIni");
// Load my INI file first.
if (!OpenResourceFind(m_scpIni, SPHERE_FILE ".ini", !fTest)) // Open script file
{
if (!fTest)
{
g_Log.Event(LOGL_FATAL | LOGM_INIT | LOGF_CONSOLE_ONLY, SPHERE_FILE ".ini has not been found.\n");
g_Log.Event(
LOGL_FATAL | LOGM_INIT | LOGF_CONSOLE_ONLY, "Download a sample sphere.ini from https://github.com/Sphereserver/Source-X/tree/master/src\n");
}
return false;
}
LoadResourcesOpen(&m_scpIni);
m_scpIni.Close();
m_scpIni.CloseForce();
m_scpCustomIni.Close();
m_scpCustomIni.CloseForce();

// Load SphereCustom.ini after Sphere.ini to override values.
lpctstr sCustomIni = SPHERE_FILE "custom.ini";
if (CSFile::FileExists(sCustomIni))
{
if (OpenResourceFind(m_scpCustomIni, sCustomIni, !fTest))
{
LoadResourcesOpen(&m_scpCustomIni);
m_scpCustomIni.Close();
m_scpCustomIni.CloseForce();
}
}

return true;
return true;
}

bool CServerConfig::LoadCryptIni( void )
Expand Down Expand Up @@ -4596,8 +4610,9 @@ void CServerConfig::Unload( bool fResync )
break;
pResFile->CloseForce();
}
m_scpIni.CloseForce();
m_scpTables.CloseForce();
m_scpIni.CloseForce();
m_scpCustomIni.CloseForce();
m_scpTables.CloseForce();
return;
}

Expand Down Expand Up @@ -4680,6 +4695,8 @@ bool CServerConfig::Load( bool fResync )
{
m_scpIni.ReSync();
m_scpIni.CloseForce();
m_scpCustomIni.ReSync();
m_scpCustomIni.CloseForce();
}

// Now load the *TABLES.SCP file.
Expand Down
1 change: 1 addition & 0 deletions src/game/CServerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ extern class CServerConfig : public CResourceHolder
// End INI file options.

CResourceScript m_scpIni; // Keep this around so we can link to it.
CResourceScript m_scpCustomIni; // Custom optional spherecustom.ini
CResourceScript m_scpCryptIni; // Encryption keys are in here

CResourceScript m_scpTables; // Script's loaded.
Expand Down
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
2 changes: 1 addition & 1 deletion src/game/items/CItemBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ int CItemBase::GetMakeValue( int iQualityLevel )

CValueRangeDef values(m_values);

if ( m_values.m_iLo == INT64_MIN || m_values.m_iHi == INT64_MIN )
if ( m_values.m_iLo == INT32_MIN || m_values.m_iHi == INT32_MIN )
{
values.m_iLo = CalculateMakeValue(0); // low quality specimen
m_values.m_iLo = -values.m_iLo; // negative means they will float.
Expand Down
2 changes: 1 addition & 1 deletion src/network/receive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ bool PacketClientVersion::onReceive(CNetState* net)
/***************************************************************************
*
*
* Packet 0xBD : PacketAssistVersion assist version
* Packet 0xBE : PacketAssistVersion assist version
*
*
***************************************************************************/
Expand Down