adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src event.cc,1.20,1.21 fileops.cc,1.


From: Kai Sterker <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src event.cc,1.20,1.21 fileops.cc,1.10,1.11 fileops.h,1.15,1.16 item_base.h,1.3,1.4 map_event_handler.cc,1.4,1.5 py_adonthell.i,1.34,1.35 time_event_handler.cc,1.5,1.6
Date: Sun, 19 Jan 2003 19:15:43 -0500

Update of /cvsroot/adonthell/adonthell/src
In directory subversions:/tmp/cvs-serv21778

Modified Files:
        event.cc fileops.cc fileops.h item_base.h map_event_handler.cc 
        py_adonthell.i time_event_handler.cc 
Log Message:
MADE fileops methods available to python
IMPROVED item stuff a little


Index: event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/event.cc,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** event.cc    16 Jan 2003 11:22:45 -0000      1.20
--- event.cc    20 Jan 2003 00:15:41 -0000      1.21
***************
*** 2,6 ****
     $Id$
  
!    Copyright (C) 2000/2001/2002 Kai Sterker <address@hidden>
     Part of the Adonthell Project http://adonthell.linuxgames.com
  
--- 2,6 ----
     $Id$
  
!    Copyright (C) 2000/2001/2002/2003 Kai Sterker <address@hidden>
     Part of the Adonthell Project http://adonthell.linuxgames.com
  
***************
*** 220,233 ****
  s_int32 event::do_repeat ()
  {
!     if (Repeat >= 0) 
!     {
!         Repeat--;
!         
!         if (Repeat <= 0) 
!         {
!             delete this;
!             return 0;
!         }
!     }
      
      return Repeat;
--- 220,224 ----
  s_int32 event::do_repeat ()
  {
!     if (Repeat > 0) Repeat--;
      
      return Repeat;

Index: fileops.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/fileops.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** fileops.cc  18 Jan 2003 23:22:59 -0000      1.10
--- fileops.cc  20 Jan 2003 00:15:41 -0000      1.11
***************
*** 23,27 ****
   */
  
! 
  #include <iostream>
  #include <SDL/SDL_endian.h>
--- 23,27 ----
   */
  
! #include <stdio.h>
  #include <iostream>
  #include <SDL/SDL_endian.h>
***************
*** 88,91 ****
--- 88,99 ----
  }
  
+ /// Reads a boolean.
+ bool igzstream::get_bool (igzstream& gfile)
+ {
+     u_int8 b;
+     gzread (gfile.file, &b, sizeof (b));
+     return b;
+ }
+ 
  /// Reads a char.
  char& operator << (char& n, igzstream& gfile)
***************
*** 107,110 ****
--- 115,126 ----
  }
  
+ /// Reads a u_int8.
+ u_int8 igzstream::get_uint8 (igzstream& gfile)
+ {
+     u_int8 n;
+     gzread (gfile.file, &n, sizeof (n));
+     return n;
+ }
+ 
  /// Reads a s_int8.
  s_int8& operator << (s_int8& n, igzstream& gfile)
***************
*** 114,117 ****
--- 130,141 ----
  }
  
+ /// Reads a s_int8.
+ s_int8 igzstream::get_sint8 (igzstream& gfile)
+ {
+     s_int8 n;
+     gzread (gfile.file, &n, sizeof (n));
+     return n;
+ }
+ 
  /// Reads a u_int16.
  u_int16& operator << (u_int16& n, igzstream& gfile)
***************
*** 122,125 ****
--- 146,157 ----
  }
  
+ /// Reads a u_int16.
+ u_int16 igzstream::get_uint16 (igzstream& gfile)
+ {
+     u_int16 n;
+     gzread (gfile.file, &n, sizeof (n));
+     return n;
+ }
+ 
  /// Reads a s_int16.
  s_int16& operator << (s_int16& n, igzstream& gfile)
***************
*** 130,133 ****
--- 162,173 ----
  }
  
+ /// Reads a s_int16.
+ s_int16 igzstream::get_sint16 (igzstream& gfile)
+ {
+     s_int16 n;
+     gzread (gfile.file, &n, sizeof (n));
+     return n;
+ }
+ 
  /// Reads a u_int32.
  u_int32& operator << (u_int32& n, igzstream& gfile)
***************
*** 138,141 ****
--- 178,189 ----
  }
  
+ /// Reads a u_int32.
+ u_int32 igzstream::get_uint32 (igzstream& gfile)
+ {
+     u_int32 n;
+     gzread (gfile.file, &n, sizeof (n));
+     return n;
+ }
+ 
  /// Reads a s_int32.
  s_int32& operator << (s_int32& n, igzstream& gfile)
***************
*** 146,149 ****
--- 194,205 ----
  }
  
+ /// Reads a s_int32.
+ s_int32 igzstream::get_sint32 (igzstream& gfile)
+ {
+     s_int32 n;
+     gzread (gfile.file, &n, sizeof (n));
+     return n;
+ }
+ 
  /// Reads a string.
  string& operator << (string& s, igzstream& gfile)
***************
*** 162,165 ****
--- 218,250 ----
  }
  
+ /// Reads a string.
+ string igzstream::get_string (igzstream& gfile)
+ {
+     string s;
+     s << gfile;
+     return s;
+ }
+ 
+ /// Reads a float.
+ float& operator << (float& f, igzstream& gfile)
+ {
+     string sf;
+     sf << gfile;
+     
+     // floats saved as strings to remain independent of architecture
+     sscanf (sf.c_str (), "%f", &f);
+     
+     return f;
+ }
+ 
+ /// Reads a float.
+ float igzstream::get_float (igzstream& gfile)
+ {
+     float f;
+     f << gfile;
+     return f;
+ }
+ 
+ 
  ogzstream::ogzstream () : gz_file ()
  {
***************
*** 255,258 ****
--- 340,355 ----
          (*i) >>  gfile;
      return (string&) s;
+ }
+ 
+ /// Writes a float.
+ const float& operator >> (const float& f, ogzstream& gfile)
+ {
+     char sf[16];
+     
+     // floats saved as strings to remain independent of architecture
+     snprintf (sf, 16, "%f", f);
+     sf >> gfile;
+     
+     return f;
  }
  

Index: fileops.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/fileops.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** fileops.h   18 Jan 2003 23:22:59 -0000      1.15
--- fileops.h   20 Jan 2003 00:15:41 -0000      1.16
***************
*** 198,203 ****
      /// Reads a string.
      friend string& operator << (string& s, igzstream& gfile);
- #endif
      
  private:
      /// NEVER pass this by value.
--- 198,216 ----
      /// Reads a string.
      friend string& operator << (string& s, igzstream& gfile);
      
+     /// Reads a float.
+     friend float& operator << (float& s, igzstream& gfile);
+ #endif
+ 
+     bool get_bool (igzstream& gfile);
+     u_int8 get_uint8 (igzstream& gfile);
+     s_int8 get_sint8 (igzstream& gfile);
+     u_int16 get_uint16 (igzstream& gfile);
+     s_int16 get_sint16 (igzstream& gfile);
+     u_int32 get_uint32 (igzstream& gfile);
+     s_int32 get_sint32 (igzstream& gfile);
+     string get_string (igzstream& gfile);
+     float get_float (igzstream& gfile);
+ 
  private:
      /// NEVER pass this by value.
***************
*** 277,281 ****
--- 290,307 ----
      /// Writes a string.
      friend string& operator >> (const string& s, ogzstream& gfile);
+     
+     /// Writes a float.
+     friend const float& operator >> (const float& s, ogzstream& gfile);
  #endif
+ 
+     void put_bool (const bool &n, ogzstream& gfile)         { n >> gfile; }
+     void put_uint8 (const u_int8 &n, ogzstream& gfile)      { n >> gfile; }
+     void put_sint8 (const s_int8 &n, ogzstream& gfile)      { n >> gfile; }
+     void put_uint16 (const u_int16 &n, ogzstream& gfile)    { n >> gfile; }
+     void put_sint16 (const s_int16 &n, ogzstream& gfile)    { n >> gfile; }
+     void put_uint32 (const u_int32 &n, ogzstream& gfile)    { n >> gfile; }
+     void put_sint32 (const s_int32 &n, ogzstream& gfile)    { n >> gfile; }
+     void put_string (const string& s, ogzstream& gfile)     { s >> gfile; }
+     void put_float (const float &n, ogzstream& gfile)       { n >> gfile; }
      
  private:

Index: item_base.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/item_base.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** item_base.h 18 Jan 2003 23:22:59 -0000      1.3
--- item_base.h 20 Jan 2003 00:15:41 -0000      1.4
***************
*** 51,55 ****
       */
      item_base () : py_object () {};
!     
      /**
       * Create a new item from the given item data. 
--- 51,55 ----
       */
      item_base () : py_object () {};
! #ifndef SWIG    
      /**
       * Create a new item from the given item data. 
***************
*** 57,61 ****
       */
      item_base (const string & item);
!     
      /**
       * Destructor.
--- 57,61 ----
       */
      item_base (const string & item);
! #endif    
      /**
       * Destructor.
***************
*** 175,178 ****
--- 175,179 ----
       */
      //@{
+ #ifndef SWIG
      /**
       * Load item from named file. This will first load the item template
***************
*** 195,199 ****
--- 196,205 ----
       */
      bool put_state (const string & file) const;
+ #endif
      
+     // wrappers needed for SWIG
+     bool load (const string & file) { return get_state (file); }
+     bool save (const string & file) { return put_state (file); }
+         
      /**
       * Load item from stream. This will first load the item template

Index: map_event_handler.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/map_event_handler.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** map_event_handler.cc        18 Aug 2002 22:34:35 -0000      1.4
--- map_event_handler.cc        20 Jan 2003 00:15:41 -0000      1.5
***************
*** 2,6 ****
     $Id$
  
!    Copyright (C) 2002 Kai Sterker <address@hidden>
     Part of the Adonthell Project http://adonthell.linuxgames.com
  
--- 2,6 ----
     $Id$
  
!    Copyright (C) 2002/2003 Kai Sterker <address@hidden>
     Part of the Adonthell Project http://adonthell.linuxgames.com
  
***************
*** 37,42 ****
          
          // if the events match, execute them. Note that events that use up
!         // their repeat count are automatically deleted and unregistered.
!         if ((*i)->equals (e)) (*i)->execute (e);
      }
      
--- 37,44 ----
          
          // if the events match, execute them. Note that events that use up
!         // their repeat count are deleted (and automatically unregistered).
!         if ((*i)->equals (e)) 
!             if (!(*i)->execute (e))
!                 delete *i;
      }
      

Index: py_adonthell.i
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/py_adonthell.i,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** py_adonthell.i      12 Jan 2003 23:24:29 -0000      1.34
--- py_adonthell.i      20 Jan 2003 00:15:41 -0000      1.35
***************
*** 146,149 ****
--- 146,150 ----
  %include "audio.h"
  %include "character_base.h"
+ %include "py_object.h"
  %include "item_base.h"
  %include "drawing_area.h"

Index: time_event_handler.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/time_event_handler.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** time_event_handler.cc       21 Aug 2002 15:25:45 -0000      1.5
--- time_event_handler.cc       20 Jan 2003 00:15:41 -0000      1.6
***************
*** 2,6 ****
     $Id$
  
!    Copyright (C) 2002 Kai Sterker <address@hidden>
     Part of the Adonthell Project http://adonthell.linuxgames.com
  
--- 2,6 ----
     $Id$
  
!    Copyright (C) 2002/2003 Kai Sterker <address@hidden>
     Part of the Adonthell Project http://adonthell.linuxgames.com
  
***************
*** 48,51 ****
--- 48,52 ----
          // re-register event if it needs be repeated
          if (repeat) register_event (evt);
+         else delete evt;
      }
      





reply via email to

[Prev in Thread] Current Thread [Next in Thread]