1
1
forked from 0ad/0ad

NMT_REMOVE_MESSAGE network message added so that an entity can be removed during a multiplayer game

This was SVN commit r6542.
This commit is contained in:
dax 2008-12-20 18:09:16 +00:00
parent 6116135c0e
commit fe645d8fc9
2 changed files with 24 additions and 1 deletions

View File

@ -212,7 +212,8 @@ void CNetMessage::ScriptingInit()
g_ScriptingHost.DefineConstant( "NMT_ADD_WAYPOINT", NMT_ADD_WAYPOINT );
g_ScriptingHost.DefineConstant( "NMT_CONTACT_ACTION", NMT_CONTACT_ACTION );
g_ScriptingHost.DefineConstant( "NMT_PRODUCE", NMT_PRODUCE );
g_ScriptingHost.DefineConstant( "NMT_PLACE_OBJECT", NMT_PLACE_OBJECT );
g_ScriptingHost.DefineConstant( "NMT_PLACE_OBJECTS", NMT_PLACE_OBJECTS );
g_ScriptingHost.DefineConstant( "NMT_REMOVE_OBJECT", NMT_REMOVE_OBJECT );
g_ScriptingHost.DefineConstant( "NMT_SET_RALLY_POINT", NMT_SET_RALLY_POINT );
g_ScriptingHost.DefineConstant( "NMT_SET_STANCE", NMT_SET_STANCE );
g_ScriptingHost.DefineConstant( "NMT_NOTIFY_REQUEST", NMT_NOTIFY_REQUEST );
@ -724,6 +725,17 @@ CNetMessage* CNetMessage::CommandFromJSArgs(
return pMessage;
}
case NMT_REMOVE_OBJECT:
{
CRemoveObjectMessage* pMessage = new CRemoveObjectMessage;
if ( !pMessage ) return NULL;
pMessage->m_IsQueued = isQueued;
pMessage->m_Entities = entities;
return pMessage;
}
default:
JS_ReportError( pContext, "Invalid order type" );
@ -908,6 +920,9 @@ CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
// Figure out message type
header.Deserialize( ( const u8* )pData, ( const u8* )pData + dataSize );
// This is what we want
pNewMessage = m_Pool.GetMessage( header.GetType() );
switch ( header.GetType() )
{
case NMT_GAME_SETUP:
@ -990,6 +1005,10 @@ CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
pNewMessage = new CPlaceObjectMessage;
break;
case NMT_REMOVE_OBJECT:
pNewMessage = new CRemoveObjectMessage;
break;
case NMT_RUN:
pNewMessage = new CRunMessage;
break;

View File

@ -55,6 +55,7 @@ enum NetMessageType
NMT_CONTACT_ACTION,
NMT_PRODUCE,
NMT_PLACE_OBJECT,
NMT_REMOVE_OBJECT,
NMT_RUN,
NMT_SET_RALLY_POINT,
NMT_SET_STANCE,
@ -228,6 +229,9 @@ DERIVE_NMT_CLASS_(Command, PlaceObject, NMT_PLACE_OBJECT)
NMT_FIELD_INT(m_Angle, u32, 4) // Orientation angle
END_NMT_CLASS()
DERIVE_NMT_CLASS_(Command, RemoveObject, NMT_REMOVE_OBJECT)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(Command, NotifyRequest, NMT_NOTIFY_REQUEST)
NMT_FIELD(HEntity, m_Target)
NMT_FIELD_INT(m_Action, u32, 4)