Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Read server configuration from single file

Initiate Mage
Joined
Oct 30, 2007
Messages
4
Reaction score
6
Hey guys,

Tired of having all those wacky ini files for each server spamming your precious Program directory? :glare:

I've done some modification to the read-routine which allows you to store your whole configuration in a single file -> config.ini
.. though i'm not sure if this was already released within some other source, but anyways here are the required snippets:

_Common/scanner.h:
replace
Code:
BOOL Read( CFileIO* pFile, BOOL );
with
Code:
BOOL Read( CFileIO* pFile, BOOL bMultiByte = TRUE, LPCTSTR lpszSection = NULL );

replace
Code:
BOOL Load( LPCTSTR lpszFileName, BOOL bMultiByte = TRUE );
with
Code:
BOOL Load( LPCTSTR lpszFileName, BOOL bMultiByte = TRUE, LPCTSTR lpszSection = NULL );

_Common/scanner.cpp:
replace
Code:
BOOL CScanner::Read( CFileIO* pFile, BOOL )
{
    m_bMemFlag = 0;
    m_nProgSize = pFile->GetLength();
with
Code:
BOOL CScanner::Read( CFileIO* pFile, BOOL bMultiByte, LPCTSTR lpszSection )
{
    char *pTmp = NULL;
    int nSect[] = { 0, 0 };

    m_bMemFlag = 0;
    m_nProgSize = pFile->GetLength();

below
Code:
    m_pProg = m_pBuf = pProg;
    pFile->Read( m_pBuf, m_nProgSize );
insert
Code:
    if(m_pBuf != NULL && lpszSection != NULL && (pTmp = strstr(m_pBuf, lpszSection)) != NULL &&
      (pTmp == m_pBuf || (iswhite(pTmp[-1]) && iswhite(pTmp[strlen(lpszSection)]))))
    {
      for(int i = (pTmp - m_pBuf) + strlen(lpszSection); i < nSize; i++)
      {
        if(!nSect[0] && m_pBuf[i] == '{')
        {
          nSect[0] = (i + 1);
        } else if(!nSect[0] && !iswhite(m_pBuf[i]))
        {
          pTmp = NULL;
          break;
        } else if(nSect[0] && m_pBuf[i] == '}')
        {
          nSect[1] = (i - 1);
          break;
        }
      }

      if(nSect[0] > 0 && nSect[1] > nSect[0])
      {
        m_nProgSize = (nSect[1] - nSect[0]);
        nSize = (m_nProgSize + 2);

        pTmp = new char[nSize];
        memcpy(pTmp, m_pBuf + nSect[0], nSect[1] - nSect[0]);

        safe_delete_array(pProg);
        pProg = pTmp;
        m_pProg = m_pBuf = pProg;
      } else
      {
        safe_delete_array(pProg);
        return 0;
      }
    } else if(lpszSection != NULL)
    {
      safe_delete_array(pProg);
      return 0;
    }

replace
Code:
BOOL CScanner::Load( LPCTSTR lpszFileName, BOOL bMultiByte )
with
Code:
BOOL CScanner::Load( LPCTSTR lpszFileName, BOOL bMultiByte, LPCTSTR lpszSection )

replace
Code:
    return Read( &file, bMultiByte );
with
Code:
    return Read( &file, bMultiByte, lpszSection );

AccountServer/AccountServer.cpp:
replace
Code:
BOOL Script( LPCTSTR lpszFileName );
with
Code:
BOOL Script(LPCTSTR lpszFileName, LPCTSTR lpszSection = NULL);

replace
Code:
if( Script( "AccountServer.ini" ) == FALSE )
with
Code:
if( Script( "config.ini", "AccountServer" ) == FALSE )

replace
Code:
BOOL Script( LPCTSTR lpszFileName )
with
Code:
BOOL Script( LPCTSTR lpszFileName, LPCTSTR lpszSection )

replace
Code:
if( s.Load( lpszFileName ) )
with
Code:
if( s.Load( lpszFileName, TRUE, lpszSection ) )

CACHESERVER/CacheServer.cpp:
replace
Code:
BOOL Script( LPCSTR lpszFileName );
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCTSTR lpszSection );

replace
Code:
if( !Script( "CacheServer.ini" ) )
with
Code:
if( !Script( "config.ini", "CacheServer" ) )

replace
Code:
BOOL Script( LPCSTR lpszFileName )
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCTSTR lpszSection )

replace
Code:
if( s.Load( lpszFileName ) )
with
Code:
if( s.Load( lpszFileName, TRUE, lpszSection ) )

CERTIFIER/certifier.cpp:
replace
Code:
BOOL Script( LPCTSTR lpszFileName );
with
Code:
BOOL Script( LPCTSTR lpszFileName, LPCTSTR lpszSection );

replace
Code:
if( Script( "Certifier.ini" ) == FALSE )
with
Code:
if( Script( "config.ini", "Certifier" ) == FALSE )

replace
Code:
BOOL Script( LPCTSTR lpszFileName )
with
Code:
BOOL Script( LPCTSTR lpszFileName, LPCTSTR lpszSection )

replace
Code:
if( s.Load( lpszFileName ) )
with
Code:
if( s.Load( lpszFileName, TRUE, lpszSection ) )

CORESERVER/CoreServer.cpp:
replace
Code:
BOOL Script( LPCSTR lpszFileName );
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCTSTR lpszSection );

replace
Code:
if( !Script( "CoreServer.ini" ) )
with
Code:
if( !Script( "config.ini", "CoreServer" ) )

replace
Code:
BOOL Script( LPCSTR lpszFileName )
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCTSTR lpszSection )

replace
Code:
 if( s.Load( lpszFileName ) )
with
Code:
 if( s.Load( lpszFileName, TRUE, lpszSection ) )

LOGINSERVER/LoginServer.cpp:
replace
Code:
BOOL Script( LPCSTR lpszFileName );
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCSTR lpszSection );

replace
Code:
if( !Script( "LoginServer.ini" ) )
with
Code:
if( !Script( "config.ini", "LoginServer" ) )

replace
Code:
BOOL Script( LPCSTR lpszFileName )
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCSTR lpszSection )

replace
Code:
if( s.Load( lpszFileName ) )
with
Code:
if( s.Load( lpszFileName, TRUE, lpszSection) )

databaseserver/DatabaseServer.cpp:
replace
Code:
BOOL Script( LPCSTR lpszFileName );
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCTSTR lpszSection );

replace
Code:
static char g_szINI[] = "databaseserver.ini";
with
Code:
static char g_szINI[] = "config.ini";

replace
Code:
if( Script( g_szINI ) == FALSE )
with
Code:
if( Script( g_szINI, "DatabaseServer" ) == FALSE )

replace
Code:
BOOL Script( LPCSTR lpszFileName )
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCTSTR lpszSection )

replace
Code:
if( s.Load( lpszFileName ) )
with
Code:
if( s.Load( lpszFileName, TRUE, lpszSection ) )

WORLDSERVER/WorldServer.cpp:
replace
Code:
BOOL Script( LPCSTR lpszFileName );
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCSTR lpszSection );

replace
Code:
static char g_szINI[] = "WorldServer.ini";
with
Code:
static char g_szINI[] = "config.ini";

replace
Code:
if( Script( g_szINI ) == TRUE )
with
Code:
if( Script( g_szINI, "WorldServer" ) == TRUE )

replace
Code:
BOOL Script( LPCSTR lpszFileName )
with
Code:
BOOL Script( LPCSTR lpszFileName, LPCSTR lpszSection )

replace
Code:
if( s.Load( lpszFileName ) == FALSE)
with
Code:
if( s.Load( lpszFileName, TRUE, lpszSection ) == FALSE)

And finally your shiny new and delicious config.ini will look like this:
AccountServer
{
TEST
AddTail( -1, 1, "FlyFF", "127.0.0.1", 0, 1, 0, 1 );
AddTail( 1, 1, "Channel 1", "127.0.0.1", 1, 1, 500, 1 );
DSN_NAME_LOGIN "login"
DB_ADMIN_ID_LOGIN "sa"

DSN_NAME_LOG "log01"
DB_ADMIN_ID_LOG "sa"

MSG_VER "20100412"

SKIP_TRACKING

DB_PWD_LOGIN "1234"
DB_PWD_LOG "1234"
}

WorldServer
{
ResourceFolder "..\Resource"
Key 101
Core "127.0.0.1"
DB "127.0.0.1"

LANG 1
Heartbeat 10101

Proc 2

GUILDWAR
18
//PK
//PKCOST
//STEAL

DROPITEM_REMOVE
//WORMON
GUILDBANK
GUILDCOMBAT
GUILDCOMBAT1TO1
ARENA
SECRETROOM
//RAINBOWRACE

//SCHOOL

RECOMMEND
}

Certifier
{
Account "127.0.0.1"
DB_PWD_LOGIN "1234" // String
DB_ADMIN_ID_LOGIN "sa"
DSN_NAME_LOGIN "login" // DSN Server fix
HEARTBEAT
}

CacheServer
{
Core "127.0.0.1"
Port "5400"
}

LoginServer
{
DB "127.0.0.1"
Core "127.0.0.1"
// CACHE
AddCache( "127.0.0.1" );
MSG_VER "20100412"

//NPROTECT
}

DatabaseServer
{
ResourceFolder "..\Resource"
Sys 1
Account "127.0.0.1"

DSN_NAME_CHARACTER "character01"
DB_ADMIN_ID_CHARACTER "sa"

DSN_NAME_LOG "log01"
DB_ADMIN_ID_LOG "sa"

//ITEMUPDATE

//DSN_NAME_ITEMUPDATE "item"
//DB_ADMIN_ID_ITEMUPDATE "sa"

//DSN_NAME_BACKSYSTEM "backsystem"
//DB_ADMIN_ID_BACKSYSTEM "sa"
//BACKENDSYSTEM

//BankToItemSendTbl
//InventoryToItemSendTbl

//ConvStartItem
//REMOVEITEM
//REMOVEITEM 2
//PIERCING_CONFIRM
//SAVE_TEXT
//__ITEM_REMOVE0203

//Conv
DB_PWD_LOG "1234"
DB_PWD_CHARACTER "1234"
DB_PWD_BACKEND ""
DB_PWD_ITEMUPDATE ""

//REMOVE_QUEST
//ITEM_ID

//RESTORE_PET
}

CoreServer
{
Sys 1 // number, dwSys
//dwId n // number g_dwId
Database "127.0.0.1" // Sting, database-address
Certifier "127.0.0.1" // certifier-address
PartyExpRate 1 // Floating number, s_fPartyExpRate

0101
{
1 0 0 30 30 00 00
2 0 0 5 5 00 00
3 0 0 5 5 00 00
21 0 0 1 1 00 00
22 0 0 1 1 00 00
23 0 0 1 1 00 00
24 0 0 1 1 00 00
25 0 0 1 1 00 00
151 0 0 2 2 00 00
152 0 0 2 2 00 00
153 0 0 2 2 00 00
154 0 0 2 2 00 00
155 0 0 2 2 00 00
156 0 0 2 2 00 00
157 0 0 2 2 00 00
158 0 0 2 2 00 00
159 0 0 2 2 00 00
160 0 0 2 2 00 00
161 0 0 2 2 00 00
162 0 0 2 2 00 00
163 0 0 2 2 00 00
164 0 0 2 2 00 00
165 0 0 2 2 00 00
166 0 0 2 2 00 00
167 0 0 2 2 00 00
200 0 0 5 5 00 00
201 0 0 5 5 00 00
202 0 0 5 5 00 00
203 0 0 3 3 00 00
204 0 0 5 5 00 00
205 0 0 2 2 00 00
206 0 0 2 2 00 00
207 0 0 2 2 00 00
208 0 0 2 2 00 00
209 0 0 1 1 00 00
210 0 0 1 1 00 00
220 0 0 1 1 00 00
230 0 0 1 1 00 00
241 0 0 1 1 00 00
242 0 0 1 1 00 00
243 0 0 1 1 00 00
244 0 0 1 1 00 00
// 14
121 0 0 5 5 00 00
122 0 0 5 5 00 00
// 14.5
211 0 0 5 5 00 00
// 15
123 0 0 10 10 00 00
212 0 0 1 1 00 00
213 0 0 1 1 00 00
214 0 0 1 1 00 00
124 0 0 5 5 00 00
125 0 0 5 5 00 00
}
}

The additional configuration files IPCut.ini and pmttd.ini are loaded the usual way from their respective files. (they ain't necessary anyways)


cheers :D
 

Attachments

You must be registered for see attachments list
Back
Top