pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.89,1.90 algo.cxx,1.2,1.


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.89,1.90 algo.cxx,1.2,1.3 console.cxx,1.6,1.7 entrance_data.cxx,1.4,1.5 exit_data.cxx,1.3,1.4 groundpiece_data.cxx,1.5,1.6 liquid.cxx,1.2,1.3 liquid_data.cxx,1.4,1.5 plt_xml.cxx,1.3,1.4 screen_manager.cxx,1.13,1.14 server.cxx,1.9,1.10 sound.cxx,1.4,1.5 sound.hxx,1.4,1.5 sound_real.cxx,1.4,1.5 surface_button.cxx,1.9,1.10 trap_data.cxx,1.4,1.5 world.cxx,1.14,1.15 xml_helper.cxx,1.12,1.13 xml_plf.cxx,1.7,1.8
Date: 22 Aug 2002 00:36:32 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv7629

Modified Files:
        Makefile.am algo.cxx console.cxx entrance_data.cxx 
        exit_data.cxx groundpiece_data.cxx liquid.cxx liquid_data.cxx 
        plt_xml.cxx screen_manager.cxx server.cxx sound.cxx sound.hxx 
        sound_real.cxx surface_button.cxx trap_data.cxx world.cxx 
        xml_helper.cxx xml_plf.cxx 
Log Message:
- replaced some incorrect free()'s with xmlFree()
- added some Free[tm] sounds
- some quirks in the sound code, no fix, but at least it no longer crashes


Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- Makefile.am 16 Aug 2002 17:15:31 -0000      1.89
+++ Makefile.am 22 Aug 2002 00:36:29 -0000      1.90
@@ -282,6 +282,7 @@
 smallmap_image.hxx \
 sound.cxx \
 sound.hxx \
+sounds.hxx \
 sound_dummy.cxx \
 sound_dummy.hxx \
 sound_real.cxx \

Index: algo.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/algo.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- algo.cxx    13 Jun 2002 14:25:12 -0000      1.2
+++ algo.cxx    22 Aug 2002 00:36:30 -0000      1.3
@@ -57,7 +57,7 @@
   }
 
   t_str = str;
-  free (str);
+  free (str); // from strdup
   return t_str;
 }
 
@@ -110,7 +110,7 @@
 #endif
   }
   if (verbose) std::cout << "find_file(): " << filename << ": File not found!" 
<< std::endl;
-  free(path);
+  free(path); // from strdup
   return filename;
 }
 /*

Index: console.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/console.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- console.cxx 17 Aug 2002 17:21:25 -0000      1.6
+++ console.cxx 22 Aug 2002 00:36:30 -0000      1.7
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <config.h>
 #include <assert.h>
 #include <ClanLib/Display/Display/display.h>
 #include <ClanLib/Display/Font/font.h>
@@ -120,6 +121,13 @@
   is_visible = false;
   current_pos = 0;
   number_of_lines = 12;
+
+  *this << "================================" << std::endl;
+  *this << "Welcome to Pingus " << VERSION << std::endl;
+  *this << "================================" << std::endl;
+  newline ();
+  *this << "This is the output and debug console, you can toggle it with ^" << 
std::endl;
+  newline ();
 }
 
 Console::~Console()

Index: entrance_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/entrance_data.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- entrance_data.cxx   16 Aug 2002 15:13:59 -0000      1.4
+++ entrance_data.cxx   22 Aug 2002 00:36:30 -0000      1.5
@@ -43,7 +43,7 @@
        {
          char* name = (char*)xmlNodeListGetString(doc, cur->children, 1); 
          type = name;
-         free(name);
+         xmlFree(name);
        }
       else if (strcmp((char*)cur->name, "owner-id") == 0)
        {
@@ -57,7 +57,7 @@
        {
          char* release_rate_str = (char*)xmlNodeListGetString(doc, 
cur->children, 1);
          release_rate = StringConverter::to_int(release_rate_str);
-         free(release_rate_str);
+         xmlFree(release_rate_str);
        }
       else if (strcmp((char*)cur->name, "direction") == 0)
        {
@@ -70,7 +70,7 @@
          else if (strcmp(direction_str, "misc") == 0)
            direction = EntranceData::MISC;
          
-         free(direction_str);
+         xmlFree(direction_str);
        }
       else
        {

Index: exit_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/exit_data.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- exit_data.cxx       2 Jul 2002 10:42:38 -0000       1.3
+++ exit_data.cxx       22 Aug 2002 00:36:30 -0000      1.4
@@ -33,7 +33,7 @@
     {
       std::cout << "XMLPLF: Use Old Pos Handling: " << pos_handling << 
std::endl;
       use_old_pos_handling = static_cast<bool>(StringConverter::to_int 
(pos_handling));
-      free (pos_handling);
+      xmlFree (pos_handling);
     }
   else
     {

Index: groundpiece_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/groundpiece_data.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- groundpiece_data.cxx        2 Jul 2002 10:42:38 -0000       1.5
+++ groundpiece_data.cxx        22 Aug 2002 00:36:30 -0000      1.6
@@ -36,7 +36,7 @@
   if (gptype_c_str)
     {
       gptype = GroundpieceData::string_to_type (gptype_c_str);
-      free(gptype_c_str);
+      xmlFree(gptype_c_str);
     }
   else
     std::cout << "XMLPLF: groundtype empty" << std::endl;

Index: liquid.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/liquid.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- liquid.cxx  17 Aug 2002 17:56:23 -0000      1.2
+++ liquid.cxx  22 Aug 2002 00:36:30 -0000      1.3
@@ -84,6 +84,7 @@
   }
 
   if (s == 1.0) {
+    // FIXME: I don't need we need clip_rects here any longer
     CL_Display::push_clip_rect();
     CL_Display::set_clip_rect(CL_ClipRect(x1, y1, x2, y2));
     

Index: liquid_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/liquid_data.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- liquid_data.cxx     2 Jul 2002 10:42:38 -0000       1.4
+++ liquid_data.cxx     22 Aug 2002 00:36:30 -0000      1.5
@@ -46,7 +46,7 @@
       std::cout << "XMLPLF: Use Old Width Handling: " << width_handling << 
std::endl;
       old_width_handling 
        = static_cast<bool>(StringConverter::to_int (width_handling));
-      free (width_handling);
+      xmlFree(width_handling);
     }
   else
     {

Index: plt_xml.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/plt_xml.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- plt_xml.cxx 16 Aug 2002 15:13:59 -0000      1.3
+++ plt_xml.cxx 22 Aug 2002 00:36:30 -0000      1.4
@@ -107,8 +107,8 @@
       description[default_language] = desc;
   }
 
-  if (desc) free(desc);          
-  if (lang) free(lang);
+  if (desc) xmlFree(desc);       
+  if (lang) xmlFree(lang);
 }
 
 void 
@@ -125,8 +125,8 @@
        world_name[default_language] = name;
     }
 
-  if (name) free(name);
-  if (lang) free(lang);
+  if (name) xmlFree(name);
+  if (lang) xmlFree(lang);
 }
 
 void
@@ -142,7 +142,7 @@
          if (name)
            {
              level_list.push_back(name);
-             free(name);
+             xmlFree(name);
            }
        }
       else

Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- screen_manager.cxx  17 Aug 2002 12:32:23 -0000      1.13
+++ screen_manager.cxx  22 Aug 2002 00:36:30 -0000      1.14
@@ -106,7 +106,7 @@
        }
       else
        {
-         fade_over (last_screen, current_screen);
+         //fade_over (last_screen, current_screen);
        }
 
       // Stupid hack to make this thing take less CPU

Index: server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- server.cxx  16 Aug 2002 15:13:59 -0000      1.9
+++ server.cxx  22 Aug 2002 00:36:30 -0000      1.10
@@ -183,7 +183,7 @@
       std::cout << "Server: Unknown Event: " << event << std::endl;
     }
   
-  free(event_str);
+  free(event_str); // from a strdup
 }
 
 bool

Index: sound.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/sound.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.cxx   21 Jun 2002 07:45:35 -0000      1.4
+++ sound.cxx   22 Aug 2002 00:36:30 -0000      1.5
@@ -18,6 +18,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <assert.h>
+#include "path_manager.hxx"
 #include "sound_dummy.hxx"
 
 PingusSound* PingusSound::sound;
@@ -33,14 +34,39 @@
 /** Load a sound file and play it immediately.
     
     @param filename The complete filename */
-    
+   
 void 
 PingusSound::play_sound(const std::string & filename, float volume, float 
panning)
 {
   assert (sound);
-  sound->real_play_sound (filename, volume, panning);
+  sound->real_play_sound (path_manager.complete (filename), volume, panning);
 }
 
+void
+PingusSound::play_sound(Sound::Name name, float volume, float panning)
+{
+  // FIXME: We need to return a handle to the sound
+
+  // This should be configurable via a .xml file
+  switch (name)
+    {
+    case Sound::DIGGER:
+      play_sound (path_manager.complete ("sounds/digger.wav"));
+      break;
+    case Sound::PLOP:
+      play_sound (path_manager.complete ("sounds/plop.wav"));
+      break;
+    case Sound::GOODIDEA:
+      play_sound (path_manager.complete ("sounds/goodidea.wav"));
+      break;
+    case Sound::OHNO:
+      play_sound (path_manager.complete ("sounds/ohno.wav"));
+      break;
+    case Sound::TICK:
+      play_sound (path_manager.complete ("sounds/tick.wav"));
+      break;
+    }
+}
 
 /** Load a sound file and play it immediately.
     
@@ -51,7 +77,7 @@
 PingusSound::play_music(const std::string & filename, float volume)
 {
   assert (sound);
-  sound->real_play_music(filename, volume);
+  sound->real_play_music(path_manager.complete (filename), volume);
 }
 
 

Index: sound.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/sound.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.hxx   16 Aug 2002 13:03:35 -0000      1.4
+++ sound.hxx   22 Aug 2002 00:36:30 -0000      1.5
@@ -22,6 +22,7 @@
 
 #include <string>
 #include "pingus.hxx"
+#include "sounds.hxx"
 
 class PingusSound
 {
@@ -43,6 +44,7 @@
   
   static void play_music(const std::string & filename, float volume = 0.5f);
 
+  static void play_sound(Sound::Name name, float volume = 0.5f, float panning 
= 0.0f);
 };
 
 #endif

Index: sound_real.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/sound_real.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound_real.cxx      17 Aug 2002 17:56:23 -0000      1.4
+++ sound_real.cxx      22 Aug 2002 00:36:30 -0000      1.5
@@ -92,17 +92,17 @@
   if (!sound_enabled)
     return;
 
-  
-
   std::vector<CL_SoundBuffer_Session *>::iterator it;
 
+  std::cout << "FIXME: this is broken PingusSoundReal::real_play_sound(const 
std::string & filename, float volume, float panning)" << std::endl;
   // search for unused SoundBuffer_Sessions - clean them up
+  /* FIXME: This causes segfaults, newing SoundBuffer_Session is IIRC incorrect
   for (it = sound_holder.begin(); it != sound_holder.end(); it++) {
     if (!(*it) -> is_playing()) {
       delete *it;
       sound_holder.erase(it);
     }
-  }
+    }*/
 
   CL_SoundBuffer         * buffer;
   CL_SoundBuffer_Session * sess;
@@ -111,7 +111,8 @@
     buffer = new CL_SoundBuffer (new CL_Sample(filename.c_str(), NULL), true);
     sess   = new CL_SoundBuffer_Session(buffer -> prepare());
   } catch (const CL_Error & e) {
-    pout(PINGUS_DEBUG_SOUND) << "Can't open file " << filename << " -- 
skipping\n";
+    perr(PINGUS_DEBUG_SOUND) << "Can't open file " << filename << " -- 
skipping\n"
+                            << "  CL_Error: " << e.message << std::endl;    
     return;
   }
   

Index: surface_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/surface_button.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- surface_button.cxx  16 Aug 2002 17:15:31 -0000      1.9
+++ surface_button.cxx  22 Aug 2002 00:36:30 -0000      1.10
@@ -121,7 +121,7 @@
 SurfaceButton::on_pointer_enter ()
 {
   mouse_over = true;
-  PingusSound::play_sound ("sounds/chain.wav", 0.1f);
+  PingusSound::play_sound ("sounds/tick.wav");
   //std::cout << "X: " << this << "enter" << std::endl;
 }
 
@@ -261,6 +261,7 @@
 QuitButton::on_click()
 {
   std::cout << "QuitButton: do exit" << std::endl;
+  PingusSound::play_sound ("sounds/goodidea.wav");
   menu->get_manager ()->show_exit_menu ();
 }
 

Index: trap_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/trap_data.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- trap_data.cxx       16 Aug 2002 15:13:59 -0000      1.4
+++ trap_data.cxx       22 Aug 2002 00:36:30 -0000      1.5
@@ -49,7 +49,7 @@
            {
              // std::cout << "parse_trap: name = " << name << std::endl;
              type = name;
-             free(name);
+             xmlFree(name);
            }
        } 
       else if (strcmp((char*)cur->name, "position") == 0) 

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- world.cxx   17 Aug 2002 17:56:23 -0000      1.14
+++ world.cxx   22 Aug 2002 00:36:30 -0000      1.15
@@ -281,7 +281,9 @@
 void 
 World::armageddon(void)
 {
+  PingusSound::play_sound ("sounds/goodidea.wav");
   do_armageddon = true;
+  // FIXME: Ugly to use iterator, since it can get invalid
   armageddon_count = pingus->begin();
 }
 

Index: xml_helper.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_helper.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- xml_helper.cxx      16 Aug 2002 17:15:31 -0000      1.12
+++ xml_helper.cxx      22 Aug 2002 00:36:30 -0000      1.13
@@ -89,7 +89,7 @@
          } else {
            std::cout << "Unhandled position ident: " << ident << std::endl;
          }
-         free(ident);
+         xmlFree(ident);
        }
       cur = cur->next;
     }
@@ -105,7 +105,7 @@
   char* number_str = (char*)xmlNodeListGetString(doc, cur, 1);
   if (number_str) {
     number = StringConverter::to_int(number_str);
-    free(number_str);
+    xmlFree(number_str);
   } else {
     std::cout << "Error: XMLhelper: parse_int: Field empty" << std::endl;
   }
@@ -121,7 +121,7 @@
   char* number_str = (char*)xmlNodeListGetString(doc, cur, 1);
   if (number_str) {
     number = StringConverter::to_float(number_str);
-    free(number_str);
+    xmlFree(number_str);
   } else {
     std::cout << "XMLhelper: parse_int: Field empty" << std::endl;
   }
@@ -204,7 +204,7 @@
                        {
                          desc.res_name = filename;
                          desc.type = ResDescriptor::RD_FILE;
-                         free(filename);
+                         xmlFree(filename);
                        }       
                    }
                  else if (strcmp((char*) ccur->name, "modifier") == 0)
@@ -215,7 +215,7 @@
                          //std::cout << "Seen: modifier: " << ident << 
std::endl;
 
                          desc.modifier = rs_from_string(ident);
-                         free(ident);
+                         xmlFree(ident);
                        }
                    }
                  else
@@ -244,7 +244,7 @@
                      if (datafile) 
                        {
                          desc.datafile = datafile;
-                         free(datafile);
+                         xmlFree(datafile);
                        }
                      else
                        {
@@ -257,7 +257,7 @@
                      if (ident) 
                        {
                          desc.res_name = ident;
-                         free(ident);            
+                         xmlFree(ident);                 
                        }
                    }
                  else if (strcmp((char*)ccur->name, "modifier") == 0)
@@ -269,7 +269,7 @@
                          //std::cout << "Seen: modifier: " << ident << 
std::endl;
                      
                          desc.modifier = rs_from_string(ident);
-                         free(ident);
+                         xmlFree(ident);
                        }
                    }
                  else
@@ -283,7 +283,7 @@
            {
              std::cout << "XMLhelper: Unhandled resource type: " << type << 
std::endl;   
            }
-         free(type);
+         xmlFree(type);
        }
       cur = cur->next;
     }
@@ -303,7 +303,7 @@
   if (str) 
     {
       ret_str = str;
-      free(str);
+      xmlFree(str);
       return ret_str;
     }
   else

Index: xml_plf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_plf.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- xml_plf.cxx 16 Aug 2002 15:13:59 -0000      1.7
+++ xml_plf.cxx 22 Aug 2002 00:36:30 -0000      1.8
@@ -290,7 +290,7 @@
                               ->create ("surface-background", doc, cur));
     }
 
-  free (type_cstr);
+  xmlFree(type_cstr);
 }
 
 void 
@@ -313,7 +313,7 @@
       if (count)
        {
          from_string(count, button.number_of);
-         free (count);
+         xmlFree(count);
        }
       else
        {
@@ -325,7 +325,7 @@
          } else {
            std::cout << "XMLPLF:parse_actions: no action number given" << 
std::endl;
          }
-         free(number);
+         xmlFree(number);
        }
 
       actions.push_back(button);
@@ -358,8 +358,8 @@
              levelname[default_language] = name;
          }
 
-         if (name) free(name);
-         if (lang) free(lang);
+         if (name) xmlFree(name);
+         if (lang) xmlFree(lang);
        }
       else if (strcmp((char*)cur->name, "description") == 0)
        {
@@ -373,15 +373,15 @@
              description[default_language] = desc;
          }
 
-         if (desc) free(desc);   
-         if (lang) free(lang);
+         if (desc) xmlFree(desc);        
+         if (lang) xmlFree(lang);
        }
       else if (strcmp((char*)cur->name, "author") == 0)
        {
          char* tmp_author = (char*)xmlNodeListGetString(doc, cur->children, 1);
          if (tmp_author) {
            author = tmp_author;
-           free(tmp_author);
+           xmlFree(tmp_author);
          }
          //std::cout << "Author: " << author << " -----------------------" << 
std::endl;
        }





reply via email to

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