@@ -434,7 +434,7 @@ void CSector::r_Write()
434434 if ( m_fSaveParity == g_World.m_fSaveParity )
435435 return ; // already saved.
436436
437- CPointMap const & pt = m_BasePoint ;
437+ CPointMap const & pt = m_BasePointSectUnits ;
438438
439439 m_fSaveParity = g_World.m_fSaveParity ;
440440 bool fHeaderCreated = false ;
@@ -615,23 +615,23 @@ int CSector::GetLocalTime() const
615615{
616616 ADDTOCALLSTACK (" CSector::GetLocalTime" );
617617 // Get local time of the day (in minutes)
618+ const CPointMap& pt = m_BasePointSectUnits;
618619 const CSectorList& pSectors = CSectorList::Get ();
619- const CPointMap& pt = m_BasePoint ;
620- int64 iLocalTime = CWorldGameTime::GetCurrentTimeInGameMinutes ();
620+ const MapSectorsData& sd = pSectors. GetMapSectorDataUnchecked (pt. m_map ) ;
621+ int64 iLocalTime = CWorldGameTime::GetCurrentTimeInGameMinutes ();
621622
622623 if ( !g_Cfg.m_fAllowLightOverride )
623624 {
624- iLocalTime += ( pt.m_x * 24 *60 ) / g_MapList. GetMapSizeX (pt. m_map ) ;
625+ iLocalTime += ( pt.m_x * 24 *60 ) / sd. iSectorColumns ;
625626 }
626627 else
627628 {
628- const MapSectorsData& sd = pSectors.GetMapSectorDataUnchecked (pt.m_map );
629-
630629 // Time difference between adjacent sectors in minutes
631630 const int iSectorTimeDiff = (24 *60 ) / sd.iSectorColumns ;
632631
633632 // Calculate the # of columns between here and Castle Britannia ( x = 1400 )
634- const int iSectorOffset = ( pt.m_x / sd.iSectorSize );
633+ // TODO: This code doesn't actually do that...
634+ const int iSectorOffset = pt.m_x ;
635635
636636 // Calculate the time offset from global time
637637 const int iTimeOffset = iSectorOffset * iSectorTimeDiff;
@@ -835,8 +835,9 @@ void CSector::SetLight( int light )
835835void CSector::SetDefaultWeatherChance ()
836836{
837837 ADDTOCALLSTACK (" CSector::SetDefaultWeatherChance" );
838- CPointMap const & pt = m_BasePoint;
839- byte iPercent = (byte)(IMulDiv ( pt.m_y , 100 , g_MapList.GetMapSizeY (pt.m_map ) )); // 100 = south
838+ const CSectorList& pSectors = CSectorList::Get ();
839+ const MapSectorsData& sd = pSectors.GetMapSectorDataUnchecked (m_BasePointSectUnits.m_map );
840+ byte iPercent = (byte)(IMulDiv ( m_BasePointSectUnits.m_y , 100 , sd.iSectorRows )); // 100 = south
840841 if ( iPercent < 50 )
841842 {
842843 // Anywhere north of the Britain Moongate is a good candidate for snow
@@ -949,7 +950,7 @@ bool CSector::IsInDungeon() const
949950 ADDTOCALLSTACK (" CSector::IsInDungeon" );
950951 // What part of the maps are filled with dungeons.
951952 // Used for light / weather calcs.
952- CRegion *pRegion = GetRegion (m_BasePoint , REGION_TYPE_AREA);
953+ CRegion *pRegion = GetRegion (GetBasePointMapUnits () , REGION_TYPE_AREA);
953954
954955 return ( pRegion && pRegion->IsFlag (REGION_FLAG_UNDERGROUND) );
955956}
@@ -1122,7 +1123,7 @@ void CSector::RespawnDeadNPCs()
11221123{
11231124 ADDTOCALLSTACK (" CSector::RespawnDeadNPCs" );
11241125 // skip sectors in unsupported maps
1125- if ( !g_MapList.IsMapSupported (m_BasePoint .m_map ) )
1126+ if ( !g_MapList.IsMapSupported (m_BasePointSectUnits .m_map ) )
11261127 return ;
11271128
11281129 // Respawn dead NPCs
@@ -1201,7 +1202,7 @@ bool CSector::_OnTick()
12011202 */
12021203
12031204 // do not tick sectors on maps not supported by server
1204- if ( !g_MapList.IsMapSupported (m_BasePoint .m_map ) )
1205+ if ( !g_MapList.IsMapSupported (m_BasePointSectUnits .m_map ) )
12051206 return true ;
12061207
12071208 EXC_TRY (" _OnTick" );
@@ -1337,9 +1338,10 @@ bool CSector::_OnTick()
13371338 EXC_CATCHSUB (" Sector" );
13381339
13391340 EXC_DEBUGSUB_START;
1340- CPointMap const & pt = m_BasePoint ;
1341+ CPointMap const & pt = m_BasePointSectUnits ;
13411342 g_Log.EventDebug (" #0 char 0%x '%s'\n " , (dword)(pChar->GetUID ()), pChar->GetName ());
13421343 g_Log.EventDebug (" #0 sector #%d [%d,%d,%d,%d]\n " , GetIndex (), pt.m_x , pt.m_y , pt.m_z , pt.m_map );
1344+ // TODO: add rect cords?
13431345 EXC_DEBUGSUB_END;
13441346 }
13451347
@@ -1348,8 +1350,9 @@ bool CSector::_OnTick()
13481350 _SetTimeout (SECTOR_TICKING_PERIOD); // Sector is Awake, make it tick after 30 seconds.
13491351
13501352 EXC_DEBUG_START;
1351- CPointMap const & pt = m_BasePoint ;
1353+ CPointMap const & pt = m_BasePointSectUnits ;
13521354 g_Log.EventError (" #4 sector #%d [%hd,%hd,%hhd,%hhu]\n " , GetIndex (), pt.m_x , pt.m_y , pt.m_z , pt.m_map );
1355+ // TODO: add rect coords?
13531356 EXC_DEBUG_END;
13541357 return true ;
13551358}
@@ -1422,7 +1425,7 @@ bool CSector::CheckItemComplexity() const noexcept
14221425 const size_t uiCount = GetItemComplexity ();
14231426 if (uiCount > g_Cfg.m_iMaxSectorComplexity )
14241427 {
1425- g_Log.Event (LOGL_WARN, " %" PRIuSIZE_T " items at %s. Sector too complex!\n " , uiCount, m_BasePoint .WriteUsed ());
1428+ g_Log.Event (LOGL_WARN, " %" PRIuSIZE_T " items at %s. Sector too complex!\n " , uiCount, GetBasePointMapUnits () .WriteUsed ());
14261429 return true ;
14271430 }
14281431 return false ;
@@ -1473,7 +1476,7 @@ bool CSector::CheckCharComplexity() const noexcept
14731476 const size_t uiCount = GetCharComplexity ();
14741477 if (uiCount > g_Cfg.m_iMaxCharComplexity )
14751478 {
1476- g_Log.Event (LOGL_WARN, " %" PRIuSIZE_T " chars at %s. Sector too complex!\n " , uiCount, m_BasePoint .WriteUsed ());
1479+ g_Log.Event (LOGL_WARN, " %" PRIuSIZE_T " chars at %s. Sector too complex!\n " , uiCount, GetBasePointMapUnits () .WriteUsed ());
14771480 return true ;
14781481 }
14791482 return false ;
0 commit comments