Re: [Circle] event handler problem

From: John C. Dodds (zzan@dbeach.com)
Date: 08/14/96


zeke wrote:
> 
> At 02:56 AM 8/14/96 -0400, you wrote:
> >heya,
> >I just tried to install the event handler code from the ftp site but am
> >having a problem, and was wondering if anyone else had this problem
> >
> >I installed as per the instructions but when the compiler tries to
> >compile event.obj i get syntax errors in structs.h and comm.h, these
> >files compile fine for all other occurrences why don't they for
> >event.obj?
> >
> >i am running in win95 using MSVC++ v 4.0
> >
> >thanks for any help,
> >John
> You most likely have a parse error somewhere in events.c  I don't know if
> MSCV++ 4.0 outputs any errors to the screen while compiling like gcc does,
> but if so look at them and try to find out where the error is.  What
> probably happened is that you missed a (){};"" or something somewhere and
> MSVC++ is trying to redefine something already defined in structs.h or
> comm.h.  Well, hope you find the problem.
> 
> Zeke

well i figured out part of the problem i added sysdep.h and conf.h to
the includes and in the make file and it compiles but i get two errors
when compiling:

event.c(33) : warning C4047: 'function' : 'long ' differs in levels of
indirection from 'void *'
event.c(33) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 3

here are the lines of code:
-event.c-
#include <stdio.h>
#include <stdlib.h>

#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "event.h"
#include "utils.h"
#include "comm.h"
#include "handler.h"
#include "db.h"

int in_event_handler=0;
struct event_info *pending_events = NULL;
struct event_info *prev = NULL;

void run_events() 
{
  struct event_info *temp, *prox;

  in_event_handler=1;

  prev=NULL;
  for(temp=pending_events;temp;temp=prox) {
    prox=temp->next;
    temp->ticks_to_go--;
    if (temp->ticks_to_go==0) {
      
      /* run the event */
      if (!temp->func)
        log("SYSERR: Attempting to run a NULL event. Ignoring");
      else
>>this is line 33>>        (temp->func)(temp->causer,temp->victim,temp->info);

      /* remove the event from the list. */
      if (!prev)
        pending_events=prox;
      else
        prev->next=prox;
      free(temp);
    } else if (temp->ticks_to_go==-1) {
      if (!prev)
        pending_events=prox;
      else
        prev->next=prox;
      free(temp);
    } else  
      prev=temp;
  }; 

  in_event_handler=0;
};

void add_event(int delay,EVENT(*func),void *causer,void *victim,void
*info)
{
  struct event_info *new;

  CREATE(new,struct event_info,1);

  new->ticks_to_go=delay;
  new->func=func;
  new->causer=causer;
  new->victim=victim;
  new->info=info;

  new->next=pending_events;
  pending_events=new;
  if (in_event_handler && !prev)
    prev=pending_events;
};

void clean_events(void *pointer)
{
  struct event_info *temp,*prox;
  struct event_info *previous;

  if (in_event_handler)
    log("SYSERR: Trying to remove events inside the handler. Attempting
to continue.");
  previous=NULL;
  for(temp=pending_events;temp;temp=prox) {
    prox=temp->next;
    if (temp->causer==pointer || temp->victim==pointer ||
        (void *)(temp->func)==pointer)
      temp->ticks_to_go=0;
  };
};
-event.h-
/*  The macros provide the type casting useful when writing event
drivers. */
#define VICTIM_CH  ((struct char_data *)victim)
#define CAUSER_CH  ((struct char_data *)causer)
#define VICTIM_OBJ ((struct obj_data *)victim)
#define CAUSER_OBJ ((struct obj_data *)causer)

void add_event(int delay,EVENT(*func),void *causer,void *victim,void
*info);
void run_events();
void clean_events(void *pointer);

any help is appreciated,
John
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/07/00 PST