From a79d64ef2bee889a3a63ac0a7d96f5defc0e0459 Mon Sep 17 00:00:00 2001 From: Coruja Date: Mon, 27 Jun 2016 18:57:49 -0300 Subject: [PATCH] Fixed: Multi dynamic regions getting replaced by script static regions on server resync --- docs/REVISIONS-56-SERIES.TXT | 3 +- src/common/CResourceBase.cpp | 10 ++--- src/graysvr/CResource.cpp | 77 +++++++++++++++++------------------- 3 files changed, 44 insertions(+), 46 deletions(-) diff --git a/docs/REVISIONS-56-SERIES.TXT b/docs/REVISIONS-56-SERIES.TXT index 4a22e0ace..7f914e76e 100644 --- a/docs/REVISIONS-56-SERIES.TXT +++ b/docs/REVISIONS-56-SERIES.TXT @@ -94,4 +94,5 @@ Added: Support for colored multis on target functions (only compatible with HS c -Target will inherit the deed color when got triggered from an deed 27-06-2016, Coruja -Fixed: Function f_onchar_delete not being called if the player char get deleted in any other way different from client Character Selecion menu. \ No newline at end of file +Fixed: Function f_onchar_delete not being called if the player char get deleted in any other way different from client Character Selecion menu. +Fixed: Multi dynamic regions getting replaced by script static regions on server resync. \ No newline at end of file diff --git a/src/common/CResourceBase.cpp b/src/common/CResourceBase.cpp index d07a80102..eab72c77e 100644 --- a/src/common/CResourceBase.cpp +++ b/src/common/CResourceBase.cpp @@ -1107,22 +1107,22 @@ bool CResourceRefArray::r_LoadVal( CScript & s, RES_TYPE restype ) } if ( g_Cfg.m_pEventsPetLink.ContainsPtr(pResourceLink) ) { - DEBUG_ERR(("'%s' already defined in sphere.ini - skipping\n", pResourceLink->GetName())); + DEBUG_ERR(("'%s' already defined in " GRAY_FILE ".ini - skipping\n", pResourceLink->GetName())); continue; } else if ( g_Cfg.m_pEventsPlayerLink.ContainsPtr(pResourceLink) ) { - DEBUG_ERR(("'%s' already defined in sphere.ini - skipping\n", pResourceLink->GetName())); + DEBUG_ERR(("'%s' already defined in " GRAY_FILE ".ini - skipping\n", pResourceLink->GetName())); continue; } - else if ( restype == RES_REGIONTYPE && g_Cfg.m_pEventsRegionLink.ContainsPtr(pResourceLink) ) + else if ( (restype == RES_REGIONTYPE) && g_Cfg.m_pEventsRegionLink.ContainsPtr(pResourceLink) ) { - DEBUG_ERR(("'%s' already defined in sphere.ini - skipping\n", pResourceLink->GetName())); + DEBUG_ERR(("'%s' already defined in " GRAY_FILE ".ini - skipping\n", pResourceLink->GetName())); continue; } else if ( g_Cfg.m_iEventsItemLink.ContainsPtr(pResourceLink) ) { - DEBUG_ERR(("'%s' already defined in sphere.ini - skipping\n", pResourceLink->GetName())); + DEBUG_ERR(("'%s' already defined in " GRAY_FILE ".ini - skipping\n", pResourceLink->GetName())); continue; } diff --git a/src/graysvr/CResource.cpp b/src/graysvr/CResource.cpp index eeff0508d..5139556de 100644 --- a/src/graysvr/CResource.cpp +++ b/src/graysvr/CResource.cpp @@ -909,7 +909,7 @@ bool CResource::r_LoadVal( CScript &s ) } } - DEBUG_ERR(("Bad usage of MAPx. Check your sphere.ini or scripts (SERV.MAP is a read only property)\n")); + DEBUG_ERR(("Bad usage of MAPx. Check your " GRAY_FILE ".ini or scripts (SERV.MAP is a read only property)\n")); return false; } } @@ -3770,7 +3770,7 @@ bool CResource::LoadIni( bool fTest ) { if( !fTest ) { - g_Log.Event(LOGL_FATAL|LOGM_INIT, GRAY_FILE ".ini has not been found, server probably would be not usable.\n"); + g_Log.Event(LOGL_FATAL|LOGM_INIT, "File " GRAY_FILE ".ini is corrupt or missing, server probably would be not usable.\n"); g_Log.Event(LOGL_FATAL|LOGM_INIT, "Navigate to http://prerelease.sphereserver.net/ to download sample config.\n"); } return( false ); @@ -3788,8 +3788,7 @@ bool CResource::LoadCryptIni( void ) ADDTOCALLSTACK("CResource::LoadCryptIni"); if ( ! OpenResourceFind( m_scpCryptIni, GRAY_FILE "Crypt.ini", false )) { - g_Log.Event( LOGL_WARN|LOGM_INIT, "Could not open " GRAY_FILE "Crypt.ini, encryption might not be available\n"); - + g_Log.Event(LOGL_WARN|LOGM_INIT, "File " GRAY_FILE "Crypt.ini is corrupt or missing, client encryption list might not be available.\n"); return( false ); } @@ -3857,14 +3856,14 @@ bool CResource::Load( bool fResync ) // ARGS: // fResync = just look for changes. - if ( ! fResync ) + if ( fResync ) { - g_Install.FindInstall(); + m_scpIni.ReSync(); + m_scpIni.CloseForce(); } else { - m_scpIni.ReSync(); - m_scpIni.CloseForce(); + g_Install.FindInstall(); } // Open the MUL files I need. @@ -3879,8 +3878,8 @@ bool CResource::Load( bool fResync ) ); if ( i != VERFILE_QTY ) { - g_Log.Event( LOGL_FATAL|LOGM_INIT, "The " GRAY_FILE ".INI file is corrupt or missing\n" ); - g_Log.Event( LOGL_FATAL|LOGM_INIT, "MUL File '%s' not found...\n", static_cast(g_Install.GetBaseFileName(i))); + g_Log.Event(LOGL_FATAL|LOGM_INIT, "File " GRAY_FILE ".ini is corrupt or missing.\n"); + g_Log.Event(LOGL_FATAL|LOGM_INIT, "MUL File '%s' not found...\n", static_cast(g_Install.GetBaseFileName(i))); return( false ); } @@ -3891,40 +3890,41 @@ bool CResource::Load( bool fResync ) } catch ( const CGrayError& e ) { - g_Log.Event( LOGL_FATAL|LOGM_INIT, "The " GRAY_FILE ".INI file is corrupt or missing\n" ); + g_Log.Event(LOGL_FATAL|LOGM_INIT, "File " GRAY_FILE ".ini is corrupt or missing.\n"); g_Log.CatchEvent( &e, "g_VerData.Load" ); CurrentProfileData.Count(PROFILE_STAT_FAULTS, 1); return( false ); } catch(...) { - g_Log.Event( LOGL_FATAL|LOGM_INIT, "The " GRAY_FILE ".INI file is corrupt or missing\n" ); + g_Log.Event(LOGL_FATAL|LOGM_INIT, "File " GRAY_FILE ".ini is corrupt or missing.\n"); g_Log.CatchEvent( NULL, "g_VerData.Load" ); CurrentProfileData.Count(PROFILE_STAT_FAULTS, 1); return( false ); } // Now load the *TABLES.SCP file. - if ( ! fResync ) + if ( fResync ) { - if ( ! OpenResourceFind( m_scpTables, GRAY_FILE "tables" )) + m_scpTables.ReSync(); + } + else + { + if ( !OpenResourceFind(m_scpTables, GRAY_FILE "tables") ) { - g_Log.Event( LOGL_FATAL|LOGM_INIT, "The " GRAY_FILE ".INI file is corrupt or missing\n" ); - g_Log.Event( LOGL_FATAL|LOGM_INIT, "Error opening table definitions file...\n" ); - return false; + g_Log.Event(LOGL_FATAL|LOGM_INIT, "File " GRAY_FILE ".ini is corrupt or missing.\n"); + g_Log.Event(LOGL_FATAL|LOGM_INIT, "Error opening table definitions file...\n"); + return( false ); } LoadResourcesOpen(&m_scpTables); m_scpTables.Close(); } - else - { - m_scpTables.ReSync(); - } m_scpTables.CloseForce(); - // Initialize the world sectors - g_World.Init(); + // Initialize world sectors on server startup + if ( !fResync ) + g_World.Init(); // open and index all my script files i'm going to use. AddResourceDir( m_sSCPBaseDir ); // if we want to get *.SCP files from elsewhere. @@ -3938,10 +3938,10 @@ bool CResource::Load( bool fResync ) if ( !pResFile ) break; - if ( !fResync ) - LoadResources( pResFile ); - else + if ( fResync ) pResFile->ReSync(); + else + LoadResources(pResFile); #ifdef _WIN32 NTWindow_OnTick(0); @@ -3949,6 +3949,10 @@ bool CResource::Load( bool fResync ) g_Serv.PrintPercent(j + 1, count); } + // Reload world sectors after server resync to prevent dynamic multi regions get replaced by static regions loaded from scripts + if ( fResync ) + g_World.Init(); + // Make sure we have the basics. if ( g_Serv.GetName()[0] == '\0' ) // make sure we have a set name { @@ -3965,15 +3969,6 @@ bool CResource::Load( bool fResync ) m_ResHash.AddSortKey( RESOURCE_ID( RES_SKILLCLASS, 0 ), pSkillClass ); } - if ( !fResync ) - { - long total, used; - Triglist(total, used); - g_Serv.SysMessagef("Done loading scripts (%ld of %ld triggers used).\n", used, total); - } - else - g_Log.Event(LOGM_INIT, "Done loading scripts.\n"); - if ( m_StartDefs.GetCount() <= 0 ) { g_Log.Event(LOGM_INIT|LOGL_ERROR, "No START locations specified. Add them and try again.\n"); @@ -4025,18 +4020,20 @@ bool CResource::Load( bool fResync ) } LoadSortSpells(); - g_Serv.SysMessage("\n"); + long total, used; + Triglist(total, used); + g_Serv.SysMessagef("Done loading scripts (%ld of %ld triggers used)\n\n", used, total); // Load crypt keys from SphereCrypt.ini - if ( ! fResync ) + if ( fResync ) { - LoadCryptIni(); + m_scpCryptIni.ReSync(); + m_scpCryptIni.CloseForce(); } else { - m_scpCryptIni.ReSync(); - m_scpCryptIni.CloseForce(); + LoadCryptIni(); } // Yay for crypt version