MESSAGE.CPP
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:2k
源码类别:

游戏

开发平台:

Visual C++

  1. #include "ray.h"
  2. #include "globals.h"
  3. #include "rayspr.h"
  4. #include "message.h"
  5. void Request_Object_Messages(pobject send_obj, pobject receive_obj) {
  6.    if ((send_obj==NULL)||(receive_obj==NULL))
  7.       return;
  8.    pobject_node new_send_node, new_receive_node;
  9.    new_send_node=(pobject_node)NewPtr(sizeof(object_node));
  10.    new_receive_node=(pobject_node)NewPtr(sizeof(object_node));
  11.    new_send_node->data=receive_obj;
  12.    new_receive_node->data=send_obj;
  13.    OL_Push_Node(new_send_node, send_obj->send_objects);
  14.    OL_Push_Node(new_receive_node, send_obj->receive_objects);
  15. }
  16. void Release_Object_Messages(pobject send_obj, pobject receive_obj) {
  17.    if ((send_obj==NULL)||(receive_obj==NULL))
  18.       return;
  19.    pobject_node cur_node;
  20.    cur_node=send_obj->send_objects;
  21.    while (!OL_Empty_Node(cur_node)) {
  22.       if (cur_node->data==receive_obj) {
  23.          break;
  24.       }
  25.       cur_node=OL_Next_Node(cur_node);
  26.    } /* endwhile */
  27.    if (!OL_Empty_Node(cur_node)) {
  28.       OL_Delete_Node(cur_node, send_obj->send_objects);
  29.    }
  30.    cur_node=receive_obj->receive_objects;
  31.    while (!OL_Empty_Node(cur_node)) {
  32.       if (cur_node->data==send_obj) {
  33.          break;
  34.       }
  35.       cur_node=OL_Next_Node(cur_node);
  36.    } /* endwhile */
  37.    if (!OL_Empty_Node(cur_node)) {
  38.       OL_Delete_Node(cur_node, receive_obj->receive_objects);
  39.    }
  40. }
  41. void Send_Auto_Message(pobject send_obj, ULONG message, pdata extra_data) {
  42.   if (send_obj==NULL)
  43.       return;
  44.   
  45.   pobject_node cur_node;
  46.   cur_node=send_obj->send_objects;
  47.   while (!OL_Empty_Node(cur_node)) {
  48.      // send the message to the object (structure derefrencing & function pointer 'o rama)
  49.      (*cur_node->data->type->Message_Func)(send_obj, cur_node->data, message, extra_data);
  50.      cur_node=OL_Next_Node(cur_node);
  51.   } /* endwhile */
  52. }
  53. ULONG Send_Specific_Message(pobject send_obj, pobject receive_obj, ULONG message,
  54.    pdata extra_data) {
  55.    if (receive_obj==NULL)
  56.       return ERROR_MESSAGE;
  57.    return (*receive_obj->type->Message_Func)(send_obj, receive_obj, message, extra_data);
  58. }