Browse Source

*** empty log message ***

Roger Hughston 21 years ago
parent
commit
e395f7712e
3 changed files with 45 additions and 0 deletions
  1. 39 0
      direct/src/dcparser/dcClass.cxx
  2. 4 0
      direct/src/dcparser/dcClass.h
  3. 2 0
      direct/src/dcparser/dcmsgtypes.h

+ 39 - 0
direct/src/dcparser/dcClass.cxx

@@ -877,6 +877,45 @@ ai_format_generate(PyObject *distobj, int do_id,
   return Datagram(packer.get_data(), packer.get_length());
 }
 #endif  // HAVE_PYTHON
+#ifdef HAVE_PYTHON
+////////////////////////////////////////////////////////////////////
+//     Function: DCClass::ai_database_generate
+//       Access: Published
+//  Description: Generates a datagram containing the message necessary
+//               to create a new database distributed object from the AI.
+//
+// First Pass is to only incldue required values(with Defaults).                   
+////////////////////////////////////////////////////////////////////
+Datagram DCClass::
+ai_database_generate_context(int context_id, 
+                   int parent_id, int zone_id,
+                   CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const 
+{
+  DCPacker packer;
+  packer.RAW_PACK_CHANNEL(database_server_id);
+  packer.RAW_PACK_CHANNEL(from_channel_id);
+  packer.raw_pack_uint8('A');
+  packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT);
+  packer.raw_pack_uint32(parent_id);  
+  packer.raw_pack_uint32(zone_id);
+  packer.raw_pack_uint16(_number); // DCD class ID
+  packer.raw_pack_uint32(context_id);
+
+  // Specify all of the required fields.
+  int num_fields = get_num_inherited_fields();
+  for (int i = 0; i < num_fields; ++i) {
+    DCField *field = get_inherited_field(i);
+    if (field->is_required() && field->as_molecular_field() == NULL) 
+    {
+      packer.begin_pack(field);
+      packer.pack_default_value();
+      packer.end_pack();
+    }
+  }
+
+  return Datagram(packer.get_data(), packer.get_length());
+}
+#endif  // HAVE_PYTHON
 
 ////////////////////////////////////////////////////////////////////
 //     Function : DCClass::output

+ 4 - 0
direct/src/dcparser/dcClass.h

@@ -99,6 +99,10 @@ PUBLISHED:
                               PyObject *optional_fields) const;
   Datagram client_format_generate(PyObject *distobj, int do_id, int zone_id,                              
                                   PyObject *optional_fields) const;
+
+  Datagram ai_database_generate_context(int context_id, int parent_id, int zone_id,
+                                CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
+  
 #endif 
 
 public:

+ 2 - 0
direct/src/dcparser/dcmsgtypes.h

@@ -30,6 +30,8 @@
 #define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED         2001
 #define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER   2003
 #define STATESERVER_OBJECT_UPDATE_FIELD                   2004
+#define STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT    2050
+#define STATESERVER_OBJECT_CREATE_WITH_REQUIR_OTHER_CONTEXT  2051
 
 
 #endif