本文整理汇总了C++中CChar::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ CChar::GetNext方法的具体用法?C++ CChar::GetNext怎么用?C++ CChar::GetNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChar
的用法示例。
在下文中一共展示了CChar::GetNext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RespawnDeadNPCs
void CSector::RespawnDeadNPCs()
{
ADDTOCALLSTACK("CSector::RespawnDeadNPCs");
// skip sectors in unsupported maps
if ( !g_MapList.m_maps[m_map] )
return;
// Respawn dead NPC's
CChar * pCharNext;
CChar * pChar = static_cast <CChar *>( m_Chars_Disconnect.GetHead());
for ( ; pChar != nullptr; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
if ( ! pChar->m_pNPC )
continue;
if ( ! pChar->m_ptHome.IsValidPoint())
continue;
if ( ! pChar->IsStatFlag( STATF_DEAD ))
continue;
// Restock them with npc stuff.
pChar->NPC_LoadScript(true);
// Res them back to their "home".
ushort uiDist = pChar->m_pNPC->m_Home_Dist_Wander;
pChar->MoveNear( pChar->m_ptHome, uiDist );
pChar->NPC_CreateTrigger(); //Removed from NPC_LoadScript() and triggered after char placement
pChar->Spell_Resurrection();
}
}
示例2: Spawn_KillChildren
void CItem::Spawn_KillChildren()
{
// kill all creatures spawned from this !
DEBUG_CHECK( IsType(IT_SPAWN_CHAR));
int iCurrent = m_itSpawnChar.m_current;
for ( int j = 0; j < 256; j++ ) // loop through all maps
{
if ( !g_MapList.m_maps[j] ) continue; // skip unsupported maps
for ( int i = 0; i < g_MapList.GetSectorQty(j); i++ )
{
CSector * pSector = g_World.GetSector(j, i);
ASSERT(pSector);
CChar * pCharNext;
CChar * pChar = STATIC_CAST <CChar*>( pSector->m_Chars_Active.GetHead());
for ( ; pChar!=NULL; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
if ( pChar->NPC_IsSpawnedBy( this ))
{
pChar->Delete();
iCurrent --;
}
}
}
}
if (iCurrent && ! g_Serv.IsLoading())
{
DEBUG_CHECK(iCurrent==0);
}
m_itSpawnChar.m_current = 0; // Should not be necessary
Spawn_OnTick( false );
}
示例3: Restock
void CSector::Restock()
{
ADDTOCALLSTACK("CSector::Restock");
// ARGS: iTime = time in seconds
// set restock time of all vendors in Sector.
// set the respawn time of all spawns in Sector.
CChar * pCharNext;
CChar * pChar = dynamic_cast <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
pChar->NPC_Vendor_Restock(true);
}
CItem * pItemNext;
CItem * pItem = dynamic_cast <CItem*>( m_Items_Timer.GetHead());
for ( ; pItem; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
if (pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR))
{
static_cast<CItemSpawn*>(pItem)->OnTick(true);
}
}
}
示例4: SetLightNow
void CSector::SetLightNow( bool fFlash )
{
ADDTOCALLSTACK("CSector::SetLightNow");
// Set the light level for all the CClients here.
CChar * pChar = static_cast<CChar *>( m_Chars_Active.GetHead());
for ( ; pChar != NULL; pChar = pChar->GetNext())
{
if ( pChar->IsStatFlag( STATF_DEAD | STATF_NightSight ))
continue;
if ( pChar->m_pClient )
{
if ( fFlash ) // This does not seem to work predicably !
{
BYTE bPrvLight = m_Env.m_Light;
m_Env.m_Light = LIGHT_BRIGHT; // full bright.
pChar->m_pClient->addLight();
m_Env.m_Light = bPrvLight; // back to previous.
}
pChar->m_pClient->addLight();
}
// don't fire trigger when server is loading or light is flashing
if (( ! g_Serv.IsLoading() && fFlash == false ) && ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) ))
{
pChar->OnTrigger( CTRIG_EnvironChange, pChar );
}
}
}
示例5: SetSeason
void CSector::SetSeason( SEASON_TYPE season )
{
ADDTOCALLSTACK("CSector::SetSeason");
// Set the season type.
if ( season == m_Env.m_Season )
return;
m_Env.m_Season = season;
CChar * pChar = STATIC_CAST <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar != NULL; pChar = pChar->GetNext())
{
if ( pChar->IsClient() )
pChar->GetClient()->addSeason(season);
if ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) )
pChar->OnTrigger(CTRIG_EnvironChange, pChar);
}
}
示例6: SetWeather
void CSector::SetWeather( WEATHER_TYPE w )
{
ADDTOCALLSTACK("CSector::SetWeather");
// Set the immediate weather type.
// 0=dry, 1=rain or 2=snow.
if ( w == m_Env.m_Weather )
return;
m_Env.m_Weather = w;
CChar * pChar = STATIC_CAST <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar != NULL; pChar = pChar->GetNext())
{
if ( pChar->IsClient())
pChar->GetClient()->addWeather( w );
if ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) )
pChar->OnTrigger( CTRIG_EnvironChange, pChar );
}
}
示例7: OnTick
//.........这里部分代码省略.........
case WEATHER_RAIN:
{
int iVal = Calc_GetRandVal(30);
if ( iVal < 5 )
{
// Mess up the light levels for a sec..
LightFlash();
sound = sm_SfxThunder[ Calc_GetRandVal( COUNTOF( sm_SfxThunder )) ];
}
else if ( iVal < 10 )
sound = sm_SfxRain[ Calc_GetRandVal( COUNTOF( sm_SfxRain )) ];
else if ( iVal < 15 )
sound = sm_SfxWind[ Calc_GetRandVal( COUNTOF( sm_SfxWind )) ];
}
break;
default:
break;
}
}
}
// regen all creatures and do AI
ProfileTask charactersTask(PROFILE_CHARS);
//pChar = STATIC_CAST <CChar*>( m_Chars_Active.GetHead());
CChar * pCharNext = NULL;
CChar * pChar = dynamic_cast <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar != NULL; pChar = pCharNext )
{
EXC_TRYSUB("TickChar");
pCharNext = pChar->GetNext();
if (( fEnvironChange ) && ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) ))
pChar->OnTrigger(CTRIG_EnvironChange, pChar);
if ( pChar->IsClient())
{
CClient * pClient = pChar->GetClient();
ASSERT( pClient );
if ( sound )
pClient->addSound(sound, pChar);
if ( fLightChange && ! pChar->IsStatFlag( STATF_DEAD | STATF_NightSight ))
pClient->addLight();
if ( fWeatherChange )
pClient->addWeather(GetWeather());
if ( iRegionPeriodic && pChar->m_pArea )
{
if (( iRegionPeriodic == 2 )&&( IsTrigUsed(TRIGGER_REGPERIODIC) ))
{
pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_REGPERIODIC );
iRegionPeriodic--;
}
if ( IsTrigUsed(TRIGGER_CLIPERIODIC) )
pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_CLIPERIODIC );
}
}
// Can only die on your own tick.
if ( !pChar->OnTick() )
pChar->Delete();
EXC_CATCHSUB("Sector");
示例8: r_Write
void CSector::r_Write()
{
ADDTOCALLSTACK_INTENSIVE("CSector::r_Write");
if ( m_fSaveParity == g_World.m_fSaveParity )
return; // already saved.
CPointMap pt = GetBasePoint();
m_fSaveParity = g_World.m_fSaveParity;
bool bHeaderCreated = false;
if ( m_dwFlags > 0)
{
g_World.m_FileWorld.WriteSection("SECTOR %d,%d,0,%d", pt.m_x, pt.m_y, pt.m_map );
g_World.m_FileWorld.WriteKeyHex("FLAGS", m_dwFlags);
bHeaderCreated = true;
}
if (g_Cfg.m_bAllowLightOverride && IsLightOverriden())
{
if ( bHeaderCreated == false )
{
g_World.m_FileWorld.WriteSection("SECTOR %d,%d,0,%d", pt.m_x, pt.m_y, pt.m_map);
bHeaderCreated = true;
}
g_World.m_FileWorld.WriteKeyVal("LIGHT", GetLight());
}
if (!g_Cfg.m_fNoWeather && (IsRainOverriden() || IsColdOverriden()))
{
if ( bHeaderCreated == false )
{
g_World.m_FileWorld.WriteSection("SECTOR %d,%d,0,%d", pt.m_x, pt.m_y, pt.m_map);
bHeaderCreated = true;
}
if ( IsRainOverriden() )
g_World.m_FileWorld.WriteKeyVal("RAINCHANCE", GetRainChance());
if ( IsColdOverriden() )
g_World.m_FileWorld.WriteKeyVal("COLDCHANCE", GetColdChance());
}
if (GetSeason() != SEASON_Summer)
{
if ( bHeaderCreated == false )
g_World.m_FileWorld.WriteSection("SECTOR %d,%d,0,%d", pt.m_x, pt.m_y, pt.m_map);
g_World.m_FileWorld.WriteKeyVal("SEASON", GetSeason());
}
// Chars in the sector.
CChar *pCharNext = NULL;
for ( CChar *pChar = static_cast<CChar*>(m_Chars_Active.GetHead()); pChar != NULL; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
pChar->r_WriteParity(pChar->m_pPlayer ? g_World.m_FilePlayers : g_World.m_FileWorld);
}
// Inactive Client Chars, ridden horses and dead NPCs (NOTE: Push inactive player chars out to the account files here?)
for ( CChar *pChar = static_cast<CChar*>(m_Chars_Disconnect.GetHead()); pChar != NULL; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
pChar->r_WriteParity(pChar->m_pPlayer ? g_World.m_FilePlayers : g_World.m_FileWorld);
}
// Items on the ground.
CItem *pItemNext = NULL;
for ( CItem *pItem = static_cast<CItem*>(m_Items_Inert.GetHead()); pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
if ( pItem->IsType(IT_MULTI_CUSTOM) )
pItem->r_WriteSafe(g_World.m_FileMultis);
else if ( !pItem->IsAttr(ATTR_STATIC) )
pItem->r_WriteSafe(g_World.m_FileWorld);
}
for ( CItem *pItem = static_cast<CItem*>(m_Items_Timer.GetHead()); pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
if ( pItem->IsType(IT_MULTI_CUSTOM) )
pItem->r_WriteSafe(g_World.m_FileMultis);
else if ( !pItem->IsAttr(ATTR_STATIC) )
pItem->r_WriteSafe(g_World.m_FileWorld);
}
}
示例9: OnTick
//.........这里部分代码省略.........
// Lightning ? // wind, rain,
switch ( GetWeather() )
{
case WEATHER_CLOUDY:
break;
case WEATHER_SNOW:
if ( ! Calc_GetRandVal(5) )
sound = sm_SfxWind[ Calc_GetRandVal( CountOf( sm_SfxWind )) ];
break;
case WEATHER_RAIN:
{
int iVal = Calc_GetRandVal(30);
if ( iVal < 5 )
{
// Mess up the light levels for a sec..
LightFlash();
sound = sm_SfxThunder[ Calc_GetRandVal( CountOf( sm_SfxThunder )) ];
}
else if ( iVal < 10 )
sound = sm_SfxRain[ Calc_GetRandVal( CountOf( sm_SfxRain )) ];
else if ( iVal < 15 )
sound = sm_SfxWind[ Calc_GetRandVal( CountOf( sm_SfxWind )) ];
}
break;
default:
break;
}
}
// Check environ changes and inform clients of it.
ProfileTask charactersTask(PROFILE_CHARS);
CChar * pCharNext = nullptr;
CChar * pChar = static_cast <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar != nullptr; pChar = pCharNext )
{
EXC_TRYSUB("TickChar");
pCharNext = pChar->GetNext();
if (( fEnvironChange ) && ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) ))
pChar->OnTrigger(CTRIG_EnvironChange, pChar);
if ( pChar->IsClient())
{
CClient * pClient = pChar->GetClient();
ASSERT( pClient );
if ( sound )
pClient->addSound(sound, pChar);
if ( fLightChange && ! pChar->IsStatFlag( STATF_DEAD | STATF_NIGHTSIGHT ))
pClient->addLight();
if ( fWeatherChange )
pClient->addWeather(GetWeather());
if ( iRegionPeriodic && pChar->m_pArea )
{
if ( ( iRegionPeriodic == 2 ) && IsTrigUsed(TRIGGER_REGPERIODIC))
{
pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_REGPERIODIC );
--iRegionPeriodic;
}
if ( IsTrigUsed(TRIGGER_CLIPERIODIC) )
pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_CLIPERIODIC );
}
}
EXC_CATCHSUB("Sector");
EXC_DEBUGSUB_START;
CPointMap pt = GetBasePoint();
g_Log.EventDebug("#0 char 0%x '%s'\n", (dword)(pChar->GetUID()), pChar->GetName());
g_Log.EventDebug("#0 sector #%d [%d,%d,%d,%d]\n", GetIndex(), pt.m_x, pt.m_y, pt.m_z, pt.m_map);
EXC_DEBUGSUB_END;
}
ProfileTask overheadTask(PROFILE_OVERHEAD);
EXC_SET_BLOCK("check map cache");
if (fCanSleep && m_iMapBlockCacheTime < iCurTime) // Only if the sector can sleep.
{
// delete the static CServerMapBlock items that have not been used recently.
m_iMapBlockCacheTime = CServerTime::GetCurrentTime().GetTimeRaw() + g_Cfg.m_iMapCacheTime ;
CheckMapBlockCache();
}
EXC_CATCH;
SetTimeoutS(30); // Sector is Awake, make it tick after 30 seconds.
EXC_DEBUG_START;
CPointMap pt = GetBasePoint();
g_Log.EventError("#4 sector #%d [%hd,%hd,%hhd,%hhu]\n", GetIndex(), pt.m_x, pt.m_y, pt.m_z, pt.m_map);
EXC_DEBUG_END;
return true;
}