mirror of
https://github.com/bearstonem/openmohaa-vr.git
synced 2026-10-29 04:00:28 +01:00
Actor improvements p2
This commit is contained in:
1 parent
da28beeab4
commit
32fddb163f
37 files changed
+718
-710
No files matched your search
@@ -576,7 +576,7 @@ void ClassDef::BuildEventResponses( void )
|
||||
numclasses++;
|
||||
}
|
||||
|
||||
CLASS_DPrintf( "\n------------------\nEvent system initialized: "
|
||||
glbs.DPrintf( "\n------------------\nEvent system initialized: "
|
||||
"%d classes %d events %d total memory in response list\n\n", numclasses, Event::NumEventCommands(), amount );
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
enum
|
||||
{
|
||||
STRING_NULL = 0,
|
||||
STRING_EMPTY = 1,
|
||||
STRING_TOUCH, STRING_BLOCK, STRING_TRIGGER, STRING_USE,
|
||||
STRING_DAMAGE,STRING_LOCATION,
|
||||
|
||||
@@ -198,9 +198,9 @@ bool StateScript::AddLabel( const_str label, unsigned char *pos, bool private_se
|
||||
s.key = label;
|
||||
s.isprivate = private_section;
|
||||
|
||||
if( !label_list.findKeyValue( 0 ) )
|
||||
if( !label_list.findKeyValue(STRING_NULL) )
|
||||
{
|
||||
label_list.addKeyValue( 0 ) = s;
|
||||
label_list.addKeyValue(STRING_NULL) = s;
|
||||
}
|
||||
|
||||
reverse_label_list.AddObject( &s );
|
||||
@@ -258,7 +258,7 @@ const_str StateScript::NearestLabel( unsigned char *pos )
|
||||
{
|
||||
unsigned int offset = pos - m_Parent->m_ProgBuffer;
|
||||
unsigned int bestOfs = 0;
|
||||
const_str label = 0;
|
||||
const_str label = STRING_NULL;
|
||||
|
||||
for( int i = 1; i <= reverse_label_list.NumObjects(); i++ )
|
||||
{
|
||||
@@ -282,7 +282,7 @@ const_str StateScript::NearestLabel( unsigned char *pos )
|
||||
|
||||
GameScript::GameScript()
|
||||
{
|
||||
m_Filename = 0;
|
||||
m_Filename = STRING_NULL;
|
||||
successCompile = false;
|
||||
|
||||
m_ProgBuffer = NULL;
|
||||
@@ -367,7 +367,7 @@ void ArchiveOpcode( Archiver& arc, unsigned char *code )
|
||||
__exec:
|
||||
if( !arc.Loading() )
|
||||
{
|
||||
index = archivedEvents.AddUniqueObject( *reinterpret_cast< unsigned int * >( code + 2 ) );
|
||||
index = archivedEvents.AddUniqueObject( *reinterpret_cast< const_str * >( code + 2 ) );
|
||||
}
|
||||
|
||||
arc.ArchiveUnsigned( &index );
|
||||
@@ -411,7 +411,7 @@ __exec:
|
||||
case OP_STORE_STRING:
|
||||
if( !arc.Loading() )
|
||||
{
|
||||
index = archivedStrings.AddUniqueObject( *reinterpret_cast< unsigned int * >( code + 1 ) );
|
||||
index = archivedStrings.AddUniqueObject( *reinterpret_cast< const_str * >( code + 1 ) );
|
||||
}
|
||||
|
||||
arc.ArchiveUnsigned( &index );
|
||||
|
||||
+13
-13
@@ -423,6 +423,7 @@ void L_InitEvents( void )
|
||||
g_eventstats = gi.Cvar_Get( "g_eventstats", "0", 0 );
|
||||
#endif
|
||||
|
||||
gi.Printf("L_InitEvents\n");
|
||||
Event::LoadEvents();
|
||||
ClassDef::BuildEventResponses();
|
||||
|
||||
@@ -2222,7 +2223,7 @@ bool Event::GetBoolean( int pos )
|
||||
GetConstString
|
||||
=======================
|
||||
*/
|
||||
int Event::GetConstString( int pos )
|
||||
const_str Event::GetConstString( int pos )
|
||||
{
|
||||
ScriptVariable& variable = GetValue( pos );
|
||||
|
||||
@@ -3439,13 +3440,13 @@ void Listener::CancelWaiting( const_str name )
|
||||
}
|
||||
}
|
||||
|
||||
if( !DisableListenerNotify )
|
||||
for (int i = stoppedListeners.NumObjects(); i > 0; i--)
|
||||
{
|
||||
for( int i = stoppedListeners.NumObjects(); i > 0; i-- )
|
||||
{
|
||||
Listener *listener = stoppedListeners.ObjectAt( i );
|
||||
Listener *listener = stoppedListeners.ObjectAt(i);
|
||||
|
||||
if( listener )
|
||||
if (listener)
|
||||
{
|
||||
if (!DisableListenerNotify)
|
||||
{
|
||||
listener->StoppedNotify();
|
||||
}
|
||||
@@ -3480,17 +3481,16 @@ void Listener::CancelWaitingAll()
|
||||
m_WaitForList = NULL;
|
||||
|
||||
if( !DisableListenerNotify )
|
||||
StoppedWaitFor(STRING_NULL, false );
|
||||
|
||||
for (int i = stoppedListeners.NumObjects(); i > 0; i--)
|
||||
{
|
||||
StoppedWaitFor( 0, false );
|
||||
Listener *listener = stoppedListeners.ObjectAt(i);
|
||||
|
||||
for( int i = stoppedListeners.NumObjects(); i > 0; i-- )
|
||||
if (listener)
|
||||
{
|
||||
Listener *listener = stoppedListeners.ObjectAt( i );
|
||||
|
||||
if( listener )
|
||||
{
|
||||
if (!DisableListenerNotify)
|
||||
listener->StoppedNotify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
|
||||
bool GetBoolean( int pos );
|
||||
|
||||
int GetConstString( int pos );
|
||||
const_str GetConstString( int pos );
|
||||
|
||||
Entity *GetEntity( int pos );
|
||||
|
||||
|
||||
@@ -8996,6 +8996,16 @@ void ScriptThread::StoppedWaitFor( const_str name, bool bDeleting )
|
||||
}
|
||||
}
|
||||
|
||||
ScriptThread *ScriptThread::CreateThreadInternal(const ScriptVariable& label)
|
||||
{
|
||||
return m_ScriptVM->GetScriptClass()->CreateThreadInternal(label);
|
||||
}
|
||||
|
||||
ScriptThread * ScriptThread::CreateScriptInternal(const ScriptVariable & label)
|
||||
{
|
||||
return m_ScriptVM->GetScriptClass()->CreateScriptInternal(label);
|
||||
}
|
||||
|
||||
void ScriptThread::Pause()
|
||||
{
|
||||
Stop();
|
||||
@@ -9018,35 +9028,27 @@ void ScriptThread::Stop( void )
|
||||
|
||||
void ScriptThread::Wait( float time )
|
||||
{
|
||||
Stop();
|
||||
|
||||
m_ScriptVM->m_ThreadState = THREAD_WAITING;
|
||||
|
||||
Director.AddTiming( this, time );
|
||||
StartTiming(time);
|
||||
m_ScriptVM->Suspend();
|
||||
}
|
||||
|
||||
void ScriptThread::StartTiming(float time)
|
||||
{
|
||||
if (m_ScriptVM->ThreadState() == THREAD_WAITING)
|
||||
{
|
||||
m_ScriptVM->m_ThreadState = THREAD_RUNNING;
|
||||
Director.RemoveTiming(this);
|
||||
}
|
||||
else if (m_ScriptVM->ThreadState() == THREAD_SUSPENDED)
|
||||
{
|
||||
m_ScriptVM->m_ThreadState = THREAD_RUNNING;
|
||||
CancelWaitingAll();
|
||||
}
|
||||
Stop();
|
||||
|
||||
m_ScriptVM->m_ThreadState = THREAD_WAITING;
|
||||
|
||||
if (time < 0)
|
||||
{
|
||||
time = 0;
|
||||
}
|
||||
|
||||
Director.AddTiming(this, time);
|
||||
}
|
||||
|
||||
void ScriptThread::StartTiming(void)
|
||||
{
|
||||
StartTiming(level.inttime);
|
||||
StartTiming(0);//start timing now
|
||||
}
|
||||
|
||||
CLASS_DECLARATION( Listener, ScriptThread, NULL )
|
||||
|
||||
@@ -199,11 +199,13 @@ public:
|
||||
void operator delete( void *ptr );
|
||||
#endif
|
||||
|
||||
virtual void Archive( Archiver &arc );
|
||||
virtual void Archive( Archiver &arc ) override;
|
||||
void ArchiveInternal( Archiver& arc );
|
||||
virtual void StartedWaitFor( void );
|
||||
virtual void StoppedNotify( void );
|
||||
virtual void StoppedWaitFor( const_str name, bool bDeleting );
|
||||
virtual void StartedWaitFor( void ) override;
|
||||
virtual void StoppedNotify( void ) override;
|
||||
virtual void StoppedWaitFor( const_str name, bool bDeleting ) override;
|
||||
virtual ScriptThread *CreateThreadInternal(const ScriptVariable& label) override;
|
||||
virtual ScriptThread *CreateScriptInternal(const ScriptVariable& label) override;
|
||||
|
||||
ScriptThread();
|
||||
ScriptThread( ScriptClass *scriptClass, unsigned char *pCodePos );
|
||||
|
||||
@@ -1444,7 +1444,7 @@ void ScriptVariable::setConstArrayValue( ScriptVariable *pVar, unsigned int size
|
||||
|
||||
#ifndef NO_SCRIPTENGINE
|
||||
|
||||
int ScriptVariable::constStringValue( void ) const
|
||||
const_str ScriptVariable::constStringValue( void ) const
|
||||
{
|
||||
if( GetType() == VARIABLE_CONSTSTRING )
|
||||
{
|
||||
@@ -1663,9 +1663,7 @@ void ScriptVariable::operator*=( const ScriptVariable& value )
|
||||
break;
|
||||
|
||||
case VARIABLE_VECTOR + VARIABLE_VECTOR * VARIABLE_MAX: // ( vector ) * ( vector )
|
||||
m_data.vectorValue[ 0 ] = m_data.vectorValue[ 0 ] * value.m_data.vectorValue[ 0 ];
|
||||
m_data.vectorValue[ 1 ] = m_data.vectorValue[ 1 ] * value.m_data.vectorValue[ 1 ];
|
||||
m_data.vectorValue[ 2 ] = m_data.vectorValue[ 2 ] * value.m_data.vectorValue[ 2 ];
|
||||
setFloatValue(DotProduct(m_data.vectorValue, value.m_data.vectorValue));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
void setConstArrayValue( ScriptVariable *pVar, unsigned int size );
|
||||
|
||||
#ifndef NO_SCRIPTENGINE
|
||||
int constStringValue( void ) const;
|
||||
const_str constStringValue( void ) const;
|
||||
void setConstStringValue( const_str s );
|
||||
#endif
|
||||
|
||||
|
||||
+20
-3
@@ -120,7 +120,8 @@ public:
|
||||
float length( void ) const;
|
||||
float lengthfast( void ) const;
|
||||
float lengthSquared( void ) const;
|
||||
float lengthXY( bool squared = false ) const;
|
||||
float lengthXY() const;
|
||||
float lengthXYSquared() const;
|
||||
float normalize( void );
|
||||
void normalizefast( void );
|
||||
void EulerNormalize( void );
|
||||
@@ -548,9 +549,25 @@ inline float Vector::lengthfast( void ) const
|
||||
//
|
||||
// Returns: float - length of the vector in the xy plane
|
||||
//----------------------------------------------------------------
|
||||
inline float Vector::lengthXY( bool squared ) const
|
||||
inline float Vector::lengthXY() const
|
||||
{
|
||||
return squared ? (x * x) + (y * y) : sqrt(( x * x ) + ( y * y ));
|
||||
return sqrt(( x * x ) + ( y * y ));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Name: lengthXYSquared
|
||||
// Class: Vector
|
||||
//
|
||||
// Description: Returns length of the vector squared (using only the x
|
||||
// and y components
|
||||
//
|
||||
// Parameters: None
|
||||
//
|
||||
// Returns: float - squared length of the vector in the xy plane
|
||||
//----------------------------------------------------------------
|
||||
inline float Vector::lengthXYSquared() const
|
||||
{
|
||||
return ( x * x ) + ( y * y );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user