Difference for plugins/cfpython/cfpython.c from version 1.16 to 1.17


version 1.16 version 1.17
Line 658
 
Line 658
         return NULL;          return NULL;
 }  }
   
   static int do_script(CFPContext* context)
   {
       FILE*   scriptfile;
       PyObject* dict;
   
       scriptfile = fopen(context->script,"r");
       if (scriptfile == NULL)
       {
           printf( "cfpython - The Script file %s can't be opened\n",context->script);
           return 0;
       }
       pushContext(context);
       dict = PyDict_New();
       PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins());
       PyRun_File(scriptfile, context->script, Py_file_input, dict, dict);
       if (PyErr_Occurred())
       {
           PyErr_Print();
       }
       Py_DECREF(dict);
       fclose(scriptfile);
       return 1;
   }
   
 CF_PLUGIN int initPlugin(const char* iversion, f_plug_api gethooksptr)  CF_PLUGIN int initPlugin(const char* iversion, f_plug_api gethooksptr)
 {  {
     PyObject *m, *d;      PyObject *m, *d;
Line 751
 
Line 775
   
 CF_PLUGIN int runPluginCommand(object* op, char* params)  CF_PLUGIN int runPluginCommand(object* op, char* params)
 {  {
     FILE*        scriptfile;  
     char         buf[1024];      char         buf[1024];
     CFPContext*  context;      CFPContext*  context;
     static int rv = 0;      static int rv = 0;
   
    rv = 0;
   
     if (current_command < -999)      if (current_command < -999)
     {      {
         printf("Illegal call of runPluginCommand, call find_plugin_command first.\n");          printf("Illegal call of runPluginCommand, call find_plugin_command first.\n");
Line 774
 
Line 799
   
     Py_XINCREF(context->who);      Py_XINCREF(context->who);
   
     scriptfile = fopen(context->script,"r");      if (!do_script(context))
     if (scriptfile == NULL)  
     {      {
         printf( "cfpython - The Script file %s can't be opened\n",context->script);          free(context);
         return rv;          return rv;
     }      }
     pushContext(context);  
     PyRun_SimpleFile(scriptfile, context->script);  
     fclose(scriptfile);  
     context = popContext();      context = popContext();
     rv = context->returnvalue;      rv = context->returnvalue;
     Py_XDECREF(context->who);      Py_XDECREF(context->who);
Line 836
 
Line 858
 {  {
     va_list args;      va_list args;
     static int rv=0;      static int rv=0;
     FILE*   scriptfile;  
     CFPContext* context;      CFPContext* context;
     Crossfire_Player* cfpl;      Crossfire_Player* cfpl;
     Crossfire_Object* cfob;      Crossfire_Object* cfob;
Line 845
 
Line 866
     object* op;      object* op;
     context = malloc(sizeof(CFPContext));      context = malloc(sizeof(CFPContext));
   
    rv = 0;
   
     va_start(args, type);      va_start(args, type);
     context->event_code = va_arg(args, int);      context->event_code = va_arg(args, int);
   
Line 957
 
Line 980
     va_end(args);      va_end(args);
     context->returnvalue = 0;      context->returnvalue = 0;
   
     scriptfile = fopen(context->script,"r");      if (!do_script(context))
     if (scriptfile == NULL)  
     {      {
         printf( "cfpython - The Script file %s can't be opened\n",context->script);          free(context);
         return &rv;          return &rv;
     }      }
     pushContext(context);  
     PyRun_SimpleFile(scriptfile, context->script);  
     fclose(scriptfile);  
     context = popContext();      context = popContext();
     rv = context->returnvalue;      rv = context->returnvalue;
     Py_XDECREF(context->who);      Py_XDECREF(context->who);
Line 981
 
Line 1001
     static int rv=0;      static int rv=0;
     va_list args;      va_list args;
     char* buf;      char* buf;
     FILE*   scriptfile;  
     CFPContext* context;      CFPContext* context;
   
    rv = 0;
   
     context = malloc(sizeof(CFPContext));      context = malloc(sizeof(CFPContext));
   
     context->message[0]=0;      context->message[0]=0;
Line 1003
 
Line 1024
     context->returnvalue = 0;      context->returnvalue = 0;
   
     va_end(args);      va_end(args);
     scriptfile = fopen(context->script,"r");  
     if (scriptfile == NULL)      if (!do_script(context))
     {      {
         printf( "cfpython - The Script file %s can't be opened\n",context->script);          free(context);
         return &rv;          return &rv;
     }      }
     pushContext(context);  
     PyRun_SimpleFile(scriptfile, context->script);  
     fclose(scriptfile);  
     context = popContext();      context = popContext();
     rv = context->returnvalue;      rv = context->returnvalue;
     Py_XDECREF(context->who);      Py_XDECREF(context->who);


Legend:
line(s) removed in v.1.16 
line(s) changed
 line(s) added in v.1.17

File made using version 1.98 of cvs2html by leaf at 2011-07-21 16:59