Ejemplo n.º 1
0
bool CSector::r_LoadVal( CScript &s )
{
	ADDTOCALLSTACK("CSector::r_LoadVal");
	EXC_TRY("LoadVal");
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, CountOf( sm_szLoadKeys )-1 ))
	{
		case SC_COLDCHANCE:
			SetWeatherChance( false, s.HasArgs() ? s.GetArgVal() : -1 );
			return true;
		case SC_FLAGS:
			m_dwFlags = s.GetArgVal();
			return true;
		case SC_LIGHT:
			if ( g_Cfg.m_bAllowLightOverride )
				SetLight( (s.HasArgs()) ? s.GetArgVal() : -1 );
			else
				g_Log.EventWarn("AllowLightOverride flag is disabled in sphere.ini, so sector's LIGHT property wasn't set\n");
			return true;
		case SC_RAINCHANCE:
			SetWeatherChance( true, s.HasArgs() ? s.GetArgVal() : -1 );
			return true;
		case SC_SEASON:
			SetSeason(s.HasArgs() ? static_cast<SEASON_TYPE>(s.GetArgVal()) : SEASON_Summer);
			return (true);
		case SC_WEATHER:
			SetWeather(s.HasArgs() ? static_cast<WEATHER_TYPE>(s.GetArgVal()) : WEATHER_DRY);
			return true;
	}
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 2
0
bool CWebPageDef::r_LoadVal( CScript & s ) // Load an item Script
{
	ADDTOCALLSTACK("CWebPageDef::r_LoadVal");
	EXC_TRY("LoadVal");
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case WC_PLEVEL:
			m_privlevel = static_cast<PLEVEL_TYPE>(s.GetArgVal());
			break;
		case WC_WEBPAGEFILE:
			m_sDstFilePath = s.GetArgStr();
			break;
		case WC_WEBPAGELOG:
			m_iUpdateLog = s.GetArgVal();
			break;
		case WC_WEBPAGESRC:
			return SetSourceFile( s.GetArgStr(), NULL );
		case WC_WEBPAGEUPDATE:	// (seconds)
			m_iUpdatePeriod = s.GetArgVal() * TICK_PER_SEC;
			if ( m_iUpdatePeriod && m_type == WEBPAGE_TEXT )
			{
				m_type = WEBPAGE_TEMPLATE;
			}
			break;
		default:
			return( CScriptObj::r_LoadVal( s ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 3
0
bool CSector::r_LoadVal( CScript &s )
{
	ADDTOCALLSTACK("CSector::r_LoadVal");
	EXC_TRY("LoadVal");
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case SC_COLDCHANCE:
			SetWeatherChance( false, s.HasArgs() ? s.GetArgVal() : -1 );
			return( true );
		case SC_FLAGS:
			m_dwFlags = s.GetArgVal();
			return true;
		case SC_LIGHT:
			if ( g_Cfg.m_bAllowLightOverride )
				m_Env.m_Light = static_cast<unsigned char>(s.GetArgVal() | LIGHT_OVERRIDE);
			return true;
		case SC_RAINCHANCE:
			SetWeatherChance( true, s.HasArgs() ? s.GetArgVal() : -1 );
			return( true );
		case SC_SEASON:
			SetSeason(s.HasArgs() ? static_cast<SEASON_TYPE>(s.GetArgVal()) : SEASON_Summer);
			return (true);
		case SC_WEATHER:
			SetWeather(s.HasArgs() ? static_cast<WEATHER_TYPE>(s.GetArgVal()) : WEATHER_DRY);
			return( true );
	}
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 4
0
bool CScriptTriggerArgs::r_Verb( CScript & s, CTextConsole * pSrc )
{
	int	index;
	LPCTSTR		pszKey = s.GetKey();
	LPCTSTR		pszArgs = s.GetArgStr();
	LOCKDATA;
	EXC_TRY(("r_Verb('%s %s',%x)", pszKey, pszArgs, pSrc));

	if ( !strnicmp( "LOCAL.", pszKey, 6 ) )
	{
		bool fQuoted = false;
		m_VarsLocal.SetStr( s.GetKey()+6, fQuoted, s.GetArgStr( &fQuoted ), false );
		return( true );
	}

	index = FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF(sm_szLoadKeys)-1 );
	switch (index)
	{
	case AGC_N:
	case AGC_N1:
		m_iN1	= s.GetArgVal();
		return true;
	case AGC_N2:
		m_iN2	= s.GetArgVal();
		return true;
	case AGC_N3:
		m_iN3	= s.GetArgVal();
		return true;
	case AGC_S:
		Init( s.GetArgStr() );
		return true;
	}
	EXC_CATCH("CScriptTriggerArgs");
	return false;
}
Ejemplo n.º 5
0
bool CItemSpawn::r_WriteVal(LPCTSTR pszKey, CGString & sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CitemSpawn:r_WriteVal");
	EXC_TRY("WriteVal");
	if (!strnicmp(pszKey, "amount", 6))
	{
		sVal.FormatVal(GetAmount());
		return true;
	}
	else if ( !strnicmp(pszKey, "at.", 3) )
	{
		pszKey += 3;
		int objIndex = Exp_GetVal(pszKey);
		if ( m_obj[objIndex].ItemFind() )
			return m_obj[objIndex].ItemFind()->r_WriteVal(pszKey, sVal, pSrc);
		else if ( m_obj[objIndex].CharFind() )
			return m_obj[objIndex].CharFind()->r_WriteVal(pszKey, sVal, pSrc);
		return true;
	}
	else if ( !strnicmp(pszKey, "count", 5) )
	{
		sVal.FormatVal(GetCount());
		return true;
	}
	EXC_CATCH;
	return CItem::r_WriteVal(pszKey, sVal, pSrc);
}
Ejemplo n.º 6
0
bool CItemMessage::r_LoadVal(CScript &s)
{
	ADDTOCALLSTACK("CItemMessage::r_LoadVal");
	EXC_TRY("LoadVal");
	// Load the message body for a book or a bboard message.
	if ( s.IsKeyHead("BODY", 4) )
	{
		AddPageText(s.GetArgStr());
		return true;
	}

	switch ( FindTableSorted(s.GetKey(), sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1) )
	{
		case CIC_AUTHOR:
			if ( s.GetArgStr()[0] != '0' )
				m_sAuthor = s.GetArgStr();
			return true;
		case CIC_BODY:		// handled above
			return false;
		case CIC_PAGES:		// not settable (used for resource stuff)
			return false;
		case CIC_TITLE:
			SetName(s.GetArgStr());
			return true;
	}
	return CItemVendable::r_LoadVal(s);
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 7
0
bool CItemMap::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CItemMap::r_WriteVal");
	EXC_TRY("WriteVal");
	if ( !strnicmp(pszKey, "PINS", 4) )
	{
		sVal.FormatVal(m_Pins.GetCount());
		return true;
	}
	if ( !strnicmp(pszKey, "PIN.", 4) )
	{
		pszKey += 4;
		size_t i = Exp_GetVal(pszKey) - 1;
		if ( m_Pins.IsValidIndex(i) )
		{
			sVal.Format("%i,%i", m_Pins[i].m_x, m_Pins[i].m_y);
			return true;
		}
	}
	return CItemVendable::r_WriteVal(pszKey, sVal, pSrc);
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 8
0
bool CItemMessage::r_Verb( CScript & s, CTextConsole * pSrc )
{
	LOCKDATA;
	EXC_TRY(("r_Verb('%s %s',%x)", s.GetKey(), s.GetArgStr(), pSrc));
	ASSERT(pSrc);
	if ( s.IsKey( sm_szVerbKeys[0] ))
	{
		// 1 based pages.
		int iPage = ( s.GetArgStr()[0] && toupper( s.GetArgStr()[0] ) != 'A' ) ? s.GetArgVal() : 0;
		if ( ! iPage )
		{
			m_sBodyLines.RemoveAll();
			return( true );
		}
		else if ( iPage <= m_sBodyLines.GetCount())
		{
			m_sBodyLines.RemoveAt( iPage-1 );
			return( true );
		}
	}
	if ( s.IsKeyHead( "PAGE", 4 ))
	{
		SetPageText( atoi( s.GetKey() + 4 )-1, s.GetArgStr());
		return( true );
	}
	return CItemVendable::r_Verb(s, pSrc);
	EXC_CATCH("CItemMessage");
	return false;
}
Ejemplo n.º 9
0
void CPathFinder::FillMap()
{
	ADDTOCALLSTACK("CPathFinder::FillMap");
	CRegionBase	*pArea;
	CPointMap	pt, ptChar;

	EXC_TRY("FillMap");
	pt = ptChar = m_pChar->GetTopPoint();

	for ( int x = 0 ; x != PATH_SIZE; ++x )
	{
		for ( int y = 0; y != PATH_SIZE; ++y )
		{
			if (x == m_Target.m_x && y == m_Target.m_y)
			{
				// always assume that our target position is walkable
				m_Points[x][y].m_Walkable = PATH_WALKABLE;
			}
			else
			{
				pt.m_x = static_cast<signed short>(x) + m_RealX;
				pt.m_y = static_cast<signed short>(y) + m_RealY;
					pArea = m_pChar->CanMoveWalkTo(pt, true, true, DIR_QTY, true);

				m_Points[x][y].m_Walkable = pArea ? PATH_WALKABLE : PATH_UNWALKABLE;
			}

			m_Points[x][y].Set(static_cast<WORD>(x), static_cast<WORD>(y), pt.m_z, pt.m_map);
		}
	}

	EXC_CATCH;
}
Ejemplo n.º 10
0
bool CItemMessage::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole * pSrc )
{
	EXC_TRY(("r_WriteVal('%s',,%x)", pszKey, pSrc));
	// Load the message body for a book or a bboard message.
	if ( ! strnicmp( pszKey, "BODY", 4 ))
	{
		pszKey += 4;
		int iPage = Exp_GetVal(pszKey);
		if ( iPage < 0 || iPage >= m_sBodyLines.GetCount())
			return( false );
		sVal = *m_sBodyLines[iPage];
		return( true );
	}
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case CIC_AUTHOR:
		sVal = m_sAuthor;
		return( true );
	case CIC_BODY:	// handled above.
		return( false );
	case CIC_PAGES:	// not settable. (used for resource stuff)
		sVal.FormatVal( m_sBodyLines.GetCount());
		return( true );
	case CIC_TITLE:
		sVal = GetName();
		return( true );
	}
	return CItemVendable::r_WriteVal(pszKey, sVal, pSrc);
	EXC_CATCH("CItemMessage");
	return false;
}
Ejemplo n.º 11
0
bool CItemMessage::r_LoadVal( CScript &s )
{
	LOCKDATA;
	EXC_TRY(("r_LoadVal('%s %s')", s.GetKey(), s.GetArgStr()));
	// Load the message body for a book or a bboard message.
	if ( s.IsKeyHead( "BODY", 4 ))
	{
		AddPageText( s.GetArgStr());
		return( true );
	}
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case CIC_AUTHOR:
		if ( s.GetArgStr()[0] != '0' )
		{
			m_sAuthor = s.GetArgStr();
		}
		return( true );
	case CIC_BODY:	// handled above.
		return( false );
	case CIC_PAGES:	// not settable. (used for resource stuff)
		return( false );
	case CIC_TITLE:
		SetName( s.GetArgStr());
		return( true );
	}
	return CItemVendable::r_LoadVal(s);
	EXC_CATCH("CItemMessage");
	return false;
}
Ejemplo n.º 12
0
bool CWebPageDef::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CWebPageDef::r_WriteVal");
	EXC_TRY("WriteVal");
	switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case WC_PLEVEL:
			sVal.FormatVal( m_privlevel );
			break;
		case WC_WEBPAGEFILE:
			sVal = m_sDstFilePath;
			break;
		case WC_WEBPAGELOG:
			sVal.FormatVal( m_iUpdateLog );
			break;
		case WC_WEBPAGESRC:
			sVal = m_sSrcFilePath;
			break;
		case WC_WEBPAGEUPDATE:	// (seconds)
			sVal.FormatVal( m_iUpdatePeriod / TICK_PER_SEC );
			break;
		default:
			return( g_Serv.r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 13
0
bool CRegionWorld::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command from script
{
	ADDTOCALLSTACK("CRegionWorld::r_Verb");
	EXC_TRY("Verb");
	/*LPCTSTR pszKey = s.GetKey();

	if ( !strnicmp(pszKey, "CLEARTAGS", 9) )
	{
		pszKey = s.GetArgStr();
		SKIP_SEPARATORS(pszKey);
		m_TagDefs.ClearKeys(pszKey);
		return true;
	}
	
	int index = FindTableSorted(pszKey, sm_szVerbKeys, COUNTOF(sm_szVerbKeys) - 1);
	if ( index < 0 )*/
		return CRegionBase::r_Verb(s, pSrc);

	/*switch( static_cast<RWV_TYPE>(index) )
	{
		case RWV_TAGLIST:
			m_TagDefs.DumpKeys(pSrc, "TAG.");
			return true;
		default:
			return false;
	}
	return true;*/
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("command '%s' args '%s' [%p]\n", s.GetKey(), s.GetArgRaw(), static_cast<void *>(pSrc));
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 14
0
bool CRegionResourceDef::r_LoadVal( CScript & s )
{
	ADDTOCALLSTACK("CRegionResourceDef::r_LoadVal");
	EXC_TRY("LoadVal");
	// RES_REGIONRESOURCE
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case RMC_AMOUNT: // AMOUNT
			m_Amount.Load( s.GetArgRaw() );
			break;
		case RMC_DEFNAME: // "DEFNAME",
			return SetResourceName( s.GetArgStr());
		case RMC_REAP: // "REAP",
			m_ReapItem = static_cast<ITEMID_TYPE>(g_Cfg.ResourceGetIndexType( RES_ITEMDEF, s.GetArgStr()));
			break;
		case RMC_REAPAMOUNT:
			m_ReapAmount.Load( s.GetArgRaw() );
			break;
		case RMC_REGEN:	// TICK_PER_SEC once found how long to regen this type.
			m_iRegenerateTime.Load( s.GetArgRaw() );
			break;
		case RMC_SKILL:
			m_Skill.Load( s.GetArgRaw() );
			break;
		default:
			return( CResourceDef::r_LoadVal( s ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 15
0
void CCharPlayer::r_WriteChar( CChar * pChar, CScript & s ) 
{
	ADDTOCALLSTACK("CCharPlayer::r_WriteChar");
	UNREFERENCED_PARAMETER(pChar);
	EXC_TRY("r_WriteChar");

	s.WriteKey("ACCOUNT", GetAccount()->GetName());

	if ( m_wDeaths )
		s.WriteKeyVal( "DEATHS", m_wDeaths );
	if ( m_wMurders )
		s.WriteKeyVal( "KILLS", m_wMurders );
	if ( GetSkillClass()->GetResourceID().GetResIndex() )
		s.WriteKey( "SKILLCLASS", GetSkillClass()->GetResourceName());
	if ( m_pflag )
		s.WriteKeyVal( "PFLAG", m_pflag );
	if ( m_speedMode )
		s.WriteKeyVal("SPEEDMODE", m_speedMode);
	if (( GetAccount()->GetResDisp() >= RDS_KR ) && m_bKrToolbarEnabled )
		s.WriteKeyVal("KRTOOLBARSTATUS", m_bKrToolbarEnabled);

	EXC_SET("saving dynamic speech");
	if ( m_Speech.GetCount() > 0 )
	{
		CGString sVal;
		m_Speech.WriteResourceRefList( sVal );
		s.WriteKey("DSPEECH", sVal);
	}

	EXC_SET("saving profile");
	if ( ! m_sProfile.IsEmpty())
	{
		TCHAR szLine[SCRIPT_MAX_LINE_LEN-16];
		Str_MakeUnFiltered( szLine, m_sProfile, sizeof(szLine));
		s.WriteKey( "PROFILE", szLine );
	}

	EXC_SET("saving stats locks");
	for ( int x = 0; x < STAT_BASE_QTY; x++)	// Don't write all lock states!
	{
		if ( ! m_StatLock[x] )
			continue;
		TCHAR szTemp[128];
		sprintf( szTemp, "StatLock[%d]", x );	// smaller storage space.
		s.WriteKeyVal( szTemp, m_StatLock[x] );
	}

	EXC_SET("saving skill locks");
	for ( size_t j = 0; j < g_Cfg.m_iMaxSkill; j++ )	// Don't write all lock states!
	{
		ASSERT(j < COUNTOF(m_SkillLock));
		if ( ! m_SkillLock[j] )
			continue;
		TCHAR szTemp[128];
		sprintf( szTemp, "SkillLock[%" FMTSIZE_T "]", j );	// smaller storage space.
		s.WriteKeyVal( szTemp, m_SkillLock[j] );
	}
	EXC_CATCH;
}
Ejemplo n.º 16
0
bool CContainer::r_WriteValContainer(LPCTSTR pszKey, CGString & sVal, CTextConsole *pSrc)
{
	ADDTOCALLSTACK("CContainer::r_WriteValContainer");
	EXC_TRY("WriteVal");

	static LPCTSTR const sm_szParams[] =
	{
		"count",
		"fcount",
		"rescount",
		"restest"
	};

	int i = FindTableHeadSorted(pszKey, sm_szParams, COUNTOF(sm_szParams));
	if ( i < 0 )
		return false;

	LPCTSTR	pKey = pszKey + strlen(sm_szParams[i]);
	SKIP_SEPARATORS(pKey);
	switch ( i )
	{
		case 0:			//	count
		{
			int iTotal = 0;

			for ( CItem* pItem = GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
				iTotal++;

			sVal.FormatVal(iTotal);
		} break;

		case 1:			//	fcount
			sVal.FormatVal(ContentCountAll());
			break;

		case 2:			//	rescount
			sVal.FormatVal(*pKey ? ContentCount(g_Cfg.ResourceGetID(RES_ITEMDEF, pKey)) : GetCount());
			break;

		case 3:			//	restest
		{
			CResourceQtyArray Resources;
			sVal.FormatVal(Resources.Load(pKey) ? ResourceConsume(&Resources, 1, true) : 0);
		} break;

		default:
			return false;
	}
	return true;

	EXC_CATCH;
	EXC_DEBUG_START;
	EXC_ADD_KEYRET(pSrc);
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 17
0
bool CScriptObj::r_LoadVal( CScript & s )
{
	LOCKDATA;
	LPCTSTR pszKey = s.GetKey();
	EXC_TRY(("r_LoadVal('%s %s')", pszKey, s.GetArgStr()));

	if ( !strnicmp(pszKey, "CLEARVARS", 9) )
	{
		pszKey = s.GetArgStr();
		SKIP_SEPERATORS(pszKey);
		g_Exp.m_VarGlobals.ClearKeys(pszKey);
		return true;
	}

	// ignore these.
	int index = FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 );
	if ( index < 0 )
	{
		DEBUG_ERR(( "Undefined keyword '%s'\n", s.GetKey()));
		return( false );
	}
	
	if ( index == SSC_VAR )
	{
		bool fQuoted = false;
		int	i	= g_Exp.m_VarGlobals.SetStr( pszKey+4, fQuoted, s.GetArgStr( &fQuoted ), false );
		return( true );
	}
	if ( index == SSC_VAR0 )
	{
		bool fQuoted = false;
		int	i	= g_Exp.m_VarGlobals.SetStr( pszKey+5, fQuoted, s.GetArgStr( &fQuoted ), true );
		return( true );
	}

	if ( index == SSC_DEFMSG )
	{
		long	l;
		pszKey += 7;
		for ( l = 0; l < DEFMSG_QTY; l++ )
		{
			if ( !strcmpi(pszKey, (const char *)g_Exp.sm_szMsgNames[0][l]) )
			{
				bool	fQuoted = false;
				TCHAR	*args = s.GetArgStr(&fQuoted);
				strcpy(g_Exp.sm_szMessages[l], args);
				return(true);
			}
		}
		g_Log.Event(LOGM_INIT|LOGL_ERROR, "Setting not used message override named '%s'" DEBUG_CR, pszKey);
		return(false);
	}
	return true;
	EXC_CATCH("CScriptObj");
	return false;
}
Ejemplo n.º 18
0
bool CRegionBase::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command from script
{
	ADDTOCALLSTACK("CRegionBase::r_Verb");
	EXC_TRY("Verb");
	LPCTSTR pszKey = s.GetKey();

	if ( !strnicmp(pszKey, "CLEARTAGS", 9) )
	{
		pszKey = s.GetArgStr();
		SKIP_SEPARATORS(pszKey);
		m_TagDefs.ClearKeys(pszKey);
		return true;
	}	

	int index = FindTableSorted(pszKey, sm_szVerbKeys, COUNTOF(sm_szVerbKeys) - 1);
	if ( index < 0 )
	{
		index = FindTableSorted(s.GetKey(), CSector::sm_szVerbKeys, SEV_QTY);
		if ( index >= 0 )
			return SendSectorsVerb(s.GetKey(), s.GetArgRaw(), pSrc);
	}

	switch ( static_cast<RV_TYPE>(index) )
	{
		case RV_ALLCLIENTS:
		{
			ClientIterator it;
			for (CClient* pClient = it.next(); pClient != NULL; pClient = it.next())
			{
				CChar * pChar = pClient->GetChar();
				if ( !pChar || (pChar->m_pArea != this) )
					continue;

				CScript script( s.GetArgStr() );
				pChar->r_Verb(script, pSrc);
			}
			return true;
		}
		case RV_TAGLIST:
		{
			m_TagDefs.DumpKeys( pSrc, "TAG." );
			return true;
		}

		default:
			break;
	}

	return CScriptObj::r_Verb(s, pSrc);
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("command '%s' args '%s' [%p]\n", s.GetKey(), s.GetArgRaw(), static_cast<void *>(pSrc));
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 19
0
bool CSector::r_Verb( CScript & s, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CSector::r_Verb");
	EXC_TRY("Verb");
	ASSERT(pSrc);
	int index = FindTableSorted( s.GetKey(), sm_szVerbKeys, COUNTOF(sm_szVerbKeys)-1 );
	switch (index)
	{
		case SEV_ALLCHARS:		// "ALLCHARS"
			v_AllChars( s, pSrc );
			break;
		case SEV_ALLCHARSIDLE:	// "ALLCHARSIDLE"
			v_AllCharsIdle( s, pSrc );
			break;
		case SEV_ALLCLIENTS:	// "ALLCLIENTS"
			v_AllClients( s, pSrc );
			break;
		case SEV_ALLITEMS:		// "ALLITEMS"
			v_AllItems( s, pSrc );
			break;
		case SEV_DRY:	// "DRY"
			SetWeather( WEATHER_DRY );
			break;
		case SEV_LIGHT:
			if ( g_Cfg.m_bAllowLightOverride )
				SetLight( (s.HasArgs()) ? s.GetArgVal() : -1 );
			break;
		case SEV_RAIN:
			SetWeather(s.HasArgs() ? static_cast<WEATHER_TYPE>(s.GetArgVal()) : WEATHER_RAIN);
			break;
		case SEV_RESPAWN:
			( toupper( s.GetArgRaw()[0] ) == 'A' ) ? g_World.RespawnDeadNPCs() : RespawnDeadNPCs();
			break;
		case SEV_RESTOCK:	// x
			// set restock time of all vendors in World, set the respawn time of all spawns in World.
			( toupper( s.GetArgRaw()[0] ) == 'A' ) ? g_World.Restock() : Restock();
			break;
		case SEV_SEASON:
			SetSeason(static_cast<SEASON_TYPE>(s.GetArgVal()));
			break;
		case SEV_SNOW:
			SetWeather( WEATHER_SNOW );
			break;
		default:
			return( CScriptObj::r_Verb( s, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPTSRC;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 20
0
bool CClient::addRelay( const CServerDef * pServ )
{
	ADDTOCALLSTACK("CClient::addRelay");
	EXC_TRY("addRelay");

	// Tell the client to play on this server.
	if ( !pServ )
		return false;

	CSocketAddressIP ipAddr = pServ->m_ip;

	if ( ipAddr.IsLocalAddr())	// local server address not yet filled in.
	{
		ipAddr = m_net->m_socket.GetSockName();
		DEBUG_MSG(( "%x:Login_Relay to %s\n", GetSocketID(), ipAddr.GetAddrStr() ));
	}

	if ( GetPeer().IsLocalAddr() || GetPeer().IsSameIP( ipAddr ))	// weird problem with client relaying back to self.
	{
		DEBUG_MSG(( "%x:Login_Relay loopback to server %s\n", GetSocketID(), ipAddr.GetAddrStr() ));
		ipAddr.SetAddrIP( SOCKET_LOCAL_ADDRESS );
	}

	EXC_SET("customer id");
	dword dwAddr = ipAddr.GetAddrIP();
	dword dwCustomerId = 0x7f000001;
	if ( g_Cfg.m_fUseAuthID )
	{
		CSString sCustomerID(pServ->GetName());
		sCustomerID.Add(GetAccount()->GetName());

		dwCustomerId = z_crc32(0L, Z_NULL, 0);
		dwCustomerId = z_crc32(dwCustomerId, reinterpret_cast<const z_Bytef *>(sCustomerID.GetPtr()), (z_uInt)sCustomerID.GetLength());

		GetAccount()->m_TagDefs.SetNum("customerid", dwCustomerId);
	}

	DEBUG_MSG(( "%x:Login_Relay to server %s with AuthId %u\n", GetSocketID(), ipAddr.GetAddrStr(), dwCustomerId ));

	EXC_SET("server relay packet");
	new PacketServerRelay(this, dwAddr, pServ->m_ip.GetPort(), dwCustomerId);
	
	m_Targ_Mode = CLIMODE_SETUP_RELAY;
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("account '%s'\n", GetAccount() ? GetAccount()->GetName() : "");
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 21
0
bool CScript::FindNextSection()
{
	ADDTOCALLSTACK("CScript::FindNextSection");
	EXC_TRY("FindNextSection");
	// RETURN: false = EOF.

	if ( m_fSectionHead )	// we have read a section already., (not at the start)
	{
		// Start from the previous line. It was the line that ended the last read.
		m_pszKey = GetKeyBuffer();
		ASSERT(m_pszKey);
		m_fSectionHead = false;
		if ( m_pszKey[0] == '[' )
			goto foundit;
	}

	for (;;)
	{
		if ( !ReadTextLine(true) )
		{
			m_lSectionData = GetPosition();
			return( false );
		}
		if ( m_pszKey[0] == '[' )
			break;
	}

foundit:
	// Parse up the section name.
	m_pszKey++;
	size_t len = strlen( m_pszKey );
	for ( size_t i = 0; i < len; i++ )
	{
		if ( m_pszKey[i] == ']' )
		{
			m_pszKey[i] = '\0';
			break;
		}
	}

	m_lSectionData = GetPosition();
	if ( IsSectionType( "EOF" ))
		return( false );

	Str_Parse( m_pszKey, &m_pszArg );
	return true;
	EXC_CATCH;
	return false;
}
Ejemplo n.º 22
0
bool CItemMap::r_LoadVal( CScript & s ) // Load an item Script
{
	LOCKDATA;
	EXC_TRY(("r_LoadVal('%s %s')", s.GetKey(), s.GetArgStr()));
	if ( s.IsKeyHead("PIN", 3 ))
	{
		CPointMap pntTemp;
		pntTemp.Read( s.GetArgStr());
		CMapPinRec pin( pntTemp.m_x, pntTemp.m_y );
		m_Pins.Add( pin );
		return( true );
	}
	return CItem::r_LoadVal(s);
	EXC_CATCH("CItemMap");
	return false;
}
Ejemplo n.º 23
0
static void Sphere_MainMonitorLoop()
{
	const char *m_sClassName = "Sphere";
	// Just make sure the main loop is alive every so often.
	// This should be the parent thread. try to restart it if it is not.
	while ( ! g_Serv.m_iExitFlag )
	{
		EXC_TRY("MainMonitorLoop");

		if ( g_Cfg.m_iFreezeRestartTime <= 0 )
		{
			DEBUG_ERR(("Freeze Restart Time cannot be cleared at run time\n"));
			g_Cfg.m_iFreezeRestartTime = 10;
		}

		EXC_SET("Sleep");
		// only sleep 1 second at a time, to avoid getting stuck here when closing
		// down with large m_iFreezeRestartTime values set
		for (int i = 0; i < g_Cfg.m_iFreezeRestartTime; ++i)
		{
			if ( g_Serv.m_iExitFlag )
				break;

#ifdef _WIN32
			NTWindow_OnTick(1000);
#else
			Sleep(1000);
#endif
		}

		EXC_SET("Checks");
		// Don't look for freezing when doing certain things.
		if ( g_Serv.IsLoading() || ! g_Cfg.m_fSecure || g_Serv.IsValidBusy() )
			continue;

		EXC_SET("Check Stuck");
#ifndef _DEBUG
		if (g_Main.checkStuck() == true)
			g_Log.Event(LOGL_CRIT, "'%s' thread hang, restarting...\n", g_Main.getName());
#endif
		EXC_CATCH;

		EXC_DEBUG_START;
		EXC_DEBUG_END;
	}

}
Ejemplo n.º 24
0
int Sphere_OnTick()
{
	// Give the world (CMainTask) a single tick. RETURN: 0 = everything is fine.
	const char *m_sClassName = "Sphere";
	EXC_TRY("Tick");
#ifdef _WIN32
	EXC_SET("service");
	g_Service.OnTick();
#endif
	EXC_SET("ships_tick");
	g_Serv.ShipTimers_Tick();

	EXC_SET("world");
	g_World.OnTick();

	// process incoming data
	EXC_SET("network-in");
#ifndef _MTNETWORK
	g_NetworkIn.tick();
#else
	g_NetworkManager.processAllInput();
#endif

	EXC_SET("server");
	g_Serv.OnTick();

	// push outgoing data
#ifndef _MTNETWORK
	if (g_NetworkOut.isActive() == false)
	{
		EXC_SET("network-out");
		g_NetworkOut.tick();
	}
#else
	EXC_SET("network-tick");
	g_NetworkManager.tick();

	EXC_SET("network-out");
	g_NetworkManager.processAllOutput();
#endif

	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_DEBUG_END;
	return g_Serv.m_iExitFlag;
}
Ejemplo n.º 25
0
bool CItemMap::r_WriteVal( LPCTSTR pszKey, CGString &sVal, CTextConsole * pSrc )
{
	EXC_TRY(("r_WriteVal('%s',,%x)", pszKey, pSrc));
	if ( ! strnicmp( pszKey, "PIN", 3 ))
	{
		pszKey += 3;
		int i = Exp_GetVal(pszKey) - 1;
		if ( i >= 0 && i < m_Pins.GetCount())
		{
			sVal.Format( "%i,%i", m_Pins[i].m_x, m_Pins[i].m_y );
			return( true );
		}
	}
	return CItemVendable::r_WriteVal(pszKey, sVal, pSrc);
	EXC_CATCH("CItemMap");
	return false;
}
Ejemplo n.º 26
0
bool CPartyDef::r_LoadVal( CScript & s )
{ 
	ADDTOCALLSTACK("CPartyDef::r_LoadVal");
	EXC_TRY("LoadVal");
	LPCTSTR pszKey = s.GetKey();

	int index = FindTableHeadSorted(pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys)-1);
	
	switch ( index )
	{
		case PDC_SPEECHFILTER:
		{
			if ( !s.HasArgs() )
				this->m_pSpeechFunction.Empty();
			else
			{
				LPCTSTR pszArg = s.GetArgStr();
				CResourceLink * m_pTestEvent = dynamic_cast<CResourceLink *>( g_Cfg.ResourceGetDefByName( RES_FUNCTION, pszArg ) );

				if ( m_pTestEvent == NULL )
					return( false );
		
				this->m_pSpeechFunction.Format("%s", pszArg);
			}
		
		} break;

		case PDC_TAG0:
		case PDC_TAG:
		{
			bool fQuoted = false;
			pszKey = pszKey + ((index == PDC_TAG0) ? 5 : 4);
			m_TagDefs.SetStr( pszKey, fQuoted, s.GetArgStr( &fQuoted ), (index == PDC_TAG0) );
		} break;
		
		default:
			return false;
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 27
0
bool CItemSpawn::r_LoadVal(CScript & s)
{
	ADDTOCALLSTACK("CitemSpawn:r_LoadVal");
	EXC_TRY("LoadVal");

	if (g_Serv.IsLoading())
	{
		if (!strnicmp(s.GetKey(), "more2", 5))	//More2 shouldn't be loaded as it's being set with ADDOBJ
			return true;
	}
	int iCmd = FindTableSorted(s.GetKey(), sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1);
	if (iCmd < 0)
		return CItem::r_LoadVal(s);

	switch (iCmd)
	{
		case ISPW_ADDOBJ:
		{
			CGrayUID uid = static_cast<CGrayUID>(s.GetArgVal());
			if ( uid.ObjFind() )
				AddObj(uid);
			return true;
		}
		case ISPW_DELOBJ:
		{
			CGrayUID uid = static_cast<CGrayUID>(s.GetArgVal());
			if (uid.ObjFind())
				DelObj(uid);
			return true;
		}
		case ISPW_RESET:
			KillChildren();
			return true;
		case ISPW_START:
			SetTimeout(0);
			return true;
		case ISPW_STOP:
			KillChildren();
			SetTimeout(-1);
			return true;
		default:
			break;
	}
	EXC_CATCH;
	return false;
}
Ejemplo n.º 28
0
bool CRegionWorld::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
	ADDTOCALLSTACK("CRegionWorld::r_WriteVal");
	EXC_TRY("WriteVal");
	//bool	fZero	= false;
	switch ( FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		case RWC_DEFNAME: // "DEFNAME" = for the speech system.
			sVal = GetResourceName();
			break;
		case RWC_RESOURCES:
			m_Events.WriteResourceRefList( sVal );
			break;
		case RWC_REGION:
			{
				// Check that the syntax is correct.
				if ( pszKey[6] && pszKey[6] != '.' )
					return false;

				CRegionWorld * pRegionTemp = dynamic_cast <CRegionWorld*>(m_pt.GetRegion( REGION_TYPE_AREA ));

				if ( !pszKey[6] )
				{
					// We're just checking if the reference is valid.
					sVal.FormatVal( pRegionTemp? 1:0 );
					return true;
				}

				// ELSE - We're trying to retrieve a property from the region.
				pszKey += 7;
				if ( pRegionTemp && m_pt.GetRegion( REGION_TYPE_MULTI ) )
					return pRegionTemp->r_WriteVal( pszKey, sVal, pSrc );

				return( this->r_WriteVal( pszKey, sVal, pSrc ));
			}
		default:
			return( CRegionBase::r_WriteVal( pszKey, sVal, pSrc ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("command '%s' ret '%s' [%p]\n", pszKey, static_cast<LPCTSTR>(sVal), static_cast<void *>(pSrc));
	EXC_DEBUG_END;
	return false;
}
Ejemplo n.º 29
0
bool CItemMulti::r_LoadVal( CScript & s  )
{
	LOCKDATA;
	EXC_TRY(("r_LoadVal('%s %s')", s.GetKey(), s.GetArgStr()));
	if ( s.IsKeyHead( "REGION.", 7 ))
	{
		if ( ! IsTopLevel())
		{
			MoveTo( GetTopPoint()); // Put item on the ground here.
		}
		ASSERT( m_pRegion );
		CScript script( s.GetKey()+7, s.GetArgStr());
		return( m_pRegion->r_LoadVal( script ) );
	}
	return CItem::r_LoadVal(s);
	EXC_CATCH("CItemMulti");
	return false;
}
Ejemplo n.º 30
0
bool CSkillClassDef::r_LoadVal( CScript &s )
{
	ADDTOCALLSTACK("CSkillClassDef::r_LoadVal");
	EXC_TRY("LoadVal");
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case SCC_DEFNAME:
		return SetResourceName( s.GetArgStr());
	case SCC_NAME:
		m_sName = s.GetArgStr();
		break;
	case SCC_SKILLSUM:
		m_SkillSumMax = s.GetArgVal();
		break;
	case SCC_STATSUM:
		m_StatSumMax = static_cast<WORD>(s.GetArgVal());
		break;
	default:
		{
			int i = g_Cfg.FindSkillKey( s.GetKey());
			if ( i != SKILL_NONE )
			{
				ASSERT( i >= 0 && static_cast<size_t>(i) < COUNTOF(m_SkillLevelMax));
				m_SkillLevelMax[i] = static_cast<WORD>(s.GetArgVal());
				break;
			}
			i = g_Cfg.FindStatKey( s.GetKey());
			if ( i >= 0 )
			{
				ASSERT( static_cast<size_t>(i) < COUNTOF(m_StatMax));
				m_StatMax[i] = static_cast<WORD>(s.GetArgVal());
				break;
			}
		}
		return( CResourceDef::r_LoadVal( s ));
	}
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}