stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src clone/ccl.c clone/ccl_spell.c clo...


From: Russell Smith
Subject: [Stratagus-CVS] stratagus/src clone/ccl.c clone/ccl_spell.c clo...
Date: Fri, 14 Nov 2003 23:38:52 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Russell Smith <address@hidden>  03/11/14 23:38:52

Modified files:
        src/clone      : ccl.c ccl_spell.c player.c spells.c unit.c 
        src/map        : map.c tileset.c 
        src/ui         : ui.c 
        src/unit       : ccl_unit.c 

Log message:
        Memory Leak Fixes
        Allow 'this in create unit

Patches:
Index: stratagus/src/clone/ccl.c
diff -u stratagus/src/clone/ccl.c:1.131 stratagus/src/clone/ccl.c:1.132
--- stratagus/src/clone/ccl.c:1.131     Fri Nov 14 11:47:40 2003
+++ stratagus/src/clone/ccl.c   Fri Nov 14 23:38:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl.c,v 1.131 2003/11/14 16:47:40 pludov Exp $
+//     $Id: ccl.c,v 1.132 2003/11/15 04:38:51 mr-russ Exp $
 
 //@{
 
@@ -749,6 +749,7 @@
     str = gh_scm2newstr(name, 0);
     strncpy(LocalPlayerName, str, sizeof(LocalPlayerName) - 1);
     LocalPlayerName[sizeof(LocalPlayerName) - 1] = '\0';
+    free(str);
     return SCM_UNSPECIFIED;
 }
 #elif defined(USE_LUA)
@@ -1985,7 +1986,7 @@
     }
 
     fprintf(fd, ";;; -----------------------------------------\n");
-    fprintf(fd, ";;; $Id: ccl.c,v 1.131 2003/11/14 16:47:40 pludov Exp $\n");
+    fprintf(fd, ";;; $Id: ccl.c,v 1.132 2003/11/15 04:38:51 mr-russ Exp $\n");
 
     fprintf(fd, "(set-video-resolution! %d %d)\n", VideoWidth, VideoHeight);
     
@@ -2005,7 +2006,7 @@
     }
 
     fprintf(fd, "--[[\n");
-    fprintf(fd, "      $Id: ccl.c,v 1.131 2003/11/14 16:47:40 pludov Exp $\n");
+    fprintf(fd, "      $Id: ccl.c,v 1.132 2003/11/15 04:38:51 mr-russ Exp 
$\n");
     fprintf(fd, "]]\n");
 
     fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
@@ -2032,7 +2033,7 @@
     }
 
     fprintf(fd, ";;; -----------------------------------------\n");
-    fprintf(fd, ";;; $Id: ccl.c,v 1.131 2003/11/14 16:47:40 pludov Exp $\n");
+    fprintf(fd, ";;; $Id: ccl.c,v 1.132 2003/11/15 04:38:51 mr-russ Exp $\n");
 
     // Global options
     if (OriginalFogOfWar) {
@@ -2113,7 +2114,7 @@
     }
 
     fprintf(fd, "--[[\n");
-    fprintf(fd, "      $Id: ccl.c,v 1.131 2003/11/14 16:47:40 pludov Exp $\n");
+    fprintf(fd, "      $Id: ccl.c,v 1.132 2003/11/15 04:38:51 mr-russ Exp 
$\n");
     fprintf(fd, "]]\n");
 
     fprintf(fd, "SetVideoFullscreen(%s)\n", VideoFullScreen ? "true" : 
"false");
@@ -2168,7 +2169,7 @@
     extern SCM oblistvar;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.131 2003/11/14 16:47:40 
pludov Exp $\n\n");
+    CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.132 2003/11/15 04:38:51 
mr-russ Exp $\n\n");
 
     for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
        SCM sym;
Index: stratagus/src/clone/ccl_spell.c
diff -u stratagus/src/clone/ccl_spell.c:1.25 
stratagus/src/clone/ccl_spell.c:1.26
--- stratagus/src/clone/ccl_spell.c:1.25        Wed Nov 12 15:40:23 2003
+++ stratagus/src/clone/ccl_spell.c     Fri Nov 14 23:38:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_spell.c,v 1.25 2003/11/12 20:40:23 jsalmon3 Exp $
+//     $Id: ccl_spell.c,v 1.26 2003/11/15 04:38:51 mr-russ Exp $
 //@{
 
 /*----------------------------------------------------------------------------
@@ -571,7 +571,9 @@
            list = gh_cdr(list);
        } else if (gh_eq_p(value, gh_symbol2scm("sound-when-cast"))) {
            //  Free the old name, get the new one
-           free(spell->SoundWhenCast.Name);
+           if (spell->SoundWhenCast.Name) {
+               free(spell->SoundWhenCast.Name);
+           }
            spell->SoundWhenCast.Name = gh_scm2newstr(gh_car(list), 0);
            spell->SoundWhenCast.Sound = 
SoundIdForName(spell->SoundWhenCast.Name);
            //  Check for sound.
Index: stratagus/src/clone/player.c
diff -u stratagus/src/clone/player.c:1.96 stratagus/src/clone/player.c:1.97
--- stratagus/src/clone/player.c:1.96   Thu Nov 13 00:53:34 2003
+++ stratagus/src/clone/player.c        Fri Nov 14 23:38:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: player.c,v 1.96 2003/11/13 05:53:34 nehalmistry Exp $
+//     $Id: player.c,v 1.97 2003/11/15 04:38:51 mr-russ Exp $
 
 //@{
 
@@ -202,7 +202,7 @@
     int j;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: players $Id: player.c,v 1.96 2003/11/13 
05:53:34 nehalmistry Exp $\n\n");
+    CLprintf(file, ";;; MODULE: players $Id: player.c,v 1.97 2003/11/15 
04:38:51 mr-russ Exp $\n\n");
 
     //
     // Dump table wc2 race numbers -> internal symbol.
@@ -412,20 +412,20 @@
        case PlayerNobody:
        default:
            team = 0;
-           player->Name = strdup("Neutral");
+           PlayerSetName(player, "Neutral");
            break;
        case PlayerComputer:
            team = 1;
-           player->Name = strdup("Computer");
+           PlayerSetName(player, "Computer");
            break;
        case PlayerPerson:
            team = 2 + NumPlayers;
-           player->Name = strdup("Person");
+           PlayerSetName(player, "Person");
            break;
        case PlayerRescuePassive:
        case PlayerRescueActive:
            // FIXME: correct for multiplayer games?
-           player->Name = strdup("Computer");
+           PlayerSetName(player, "Computer");
            team = 2 + NumPlayers;
            break;
     }
Index: stratagus/src/clone/spells.c
diff -u stratagus/src/clone/spells.c:1.127 stratagus/src/clone/spells.c:1.128
--- stratagus/src/clone/spells.c:1.127  Thu Nov 13 18:17:30 2003
+++ stratagus/src/clone/spells.c        Fri Nov 14 23:38:51 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: spells.c,v 1.127 2003/11/13 23:17:30 jsalmon3 Exp $
+//     $Id: spells.c,v 1.128 2003/11/15 04:38:51 mr-russ Exp $
 
 /*
 **     And when we cast our final spell
@@ -1270,6 +1270,9 @@
                free(spell->AICast->Condition);
            }
            free(spell->AICast);
+       }
+       if (spell->SoundWhenCast.Name) {
+           free(spell->SoundWhenCast.Name);
        }
        // FIXME: missile free somewhere else, right?
     }
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.336 stratagus/src/clone/unit.c:1.337
--- stratagus/src/clone/unit.c:1.336    Thu Nov 13 16:27:21 2003
+++ stratagus/src/clone/unit.c  Fri Nov 14 23:38:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.336 2003/11/13 21:27:21 mr-russ Exp $
+//     $Id: unit.c,v 1.337 2003/11/15 04:38:51 mr-russ Exp $
 
 //@{
 
@@ -2400,6 +2400,7 @@
                    *px = x;
                    *py = y;
                    DebugLevel3("Found it! %X %X\n" _C_ 
TheMap.Fields[x+y*TheMap.Width].Flags _C_ resmask);
+                   free(points);
                    return 1;
                }
                if (CanMoveToMask(x, y, movemask)) {    // reachable
@@ -3850,7 +3851,7 @@
     int RunStart;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.336 2003/11/13 21:27:21 
mr-russ Exp $\n\n");
+    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.337 2003/11/15 04:38:51 
mr-russ Exp $\n\n");
 
     //
     // Local variables
Index: stratagus/src/map/map.c
diff -u stratagus/src/map/map.c:1.63 stratagus/src/map/map.c:1.64
--- stratagus/src/map/map.c:1.63        Tue Nov 11 04:24:02 2003
+++ stratagus/src/map/map.c     Fri Nov 14 23:38:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: map.c,v 1.63 2003/11/11 09:24:02 n0body Exp $
+//     $Id: map.c,v 1.64 2003/11/15 04:38:51 mr-russ Exp $
 
 //@{
 
@@ -643,6 +643,8 @@
 {
     free(TheMap.Fields);
     free(TheMap.TerrainName);
+    free(TheMap.TileData);
+    free(TheMap.Tiles);
     free(TheMap.Visible[0]);
 
     // Tileset freeed by Tileset?
Index: stratagus/src/map/tileset.c
diff -u stratagus/src/map/tileset.c:1.55 stratagus/src/map/tileset.c:1.56
--- stratagus/src/map/tileset.c:1.55    Wed Nov 12 15:20:12 2003
+++ stratagus/src/map/tileset.c Fri Nov 14 23:38:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: tileset.c,v 1.55 2003/11/12 20:20:12 jsalmon3 Exp $
+//     $Id: tileset.c,v 1.56 2003/11/15 04:38:51 mr-russ Exp $
 
 //@{
 
@@ -726,7 +726,7 @@
     char** sp;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: tileset $Id: tileset.c,v 1.55 2003/11/12 
20:20:12 jsalmon3 Exp $\n\n");
+    CLprintf(file, ";;; MODULE: tileset $Id: tileset.c,v 1.56 2003/11/15 
04:38:51 mr-russ Exp $\n\n");
 
     //  Original number to internal tileset name
 
@@ -762,6 +762,7 @@
     //
     for (i = 0; i < NumTilesets; ++i) {
        free(Tilesets[i]->Ident);
+       free(Tilesets[i]->File);
        free(Tilesets[i]->Class);
        free(Tilesets[i]->Name);
        free(Tilesets[i]->ImageFile);
Index: stratagus/src/ui/ui.c
diff -u stratagus/src/ui/ui.c:1.87 stratagus/src/ui/ui.c:1.88
--- stratagus/src/ui/ui.c:1.87  Fri Oct 31 17:16:58 2003
+++ stratagus/src/ui/ui.c       Fri Nov 14 23:38:51 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ui.c,v 1.87 2003/10/31 22:16:58 jsalmon3 Exp $
+//     $Id: ui.c,v 1.88 2003/11/15 04:38:51 mr-russ Exp $
 
 //@{
 
@@ -644,7 +644,7 @@
     int i;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: ui $Id: ui.c,v 1.87 2003/10/31 22:16:58 
jsalmon3 Exp $\n\n");
+    CLprintf(file, ";;; MODULE: ui $Id: ui.c,v 1.88 2003/11/15 04:38:51 
mr-russ Exp $\n\n");
 
     // Contrast, Brightness, Saturation
     CLprintf(file, "(set-contrast! %d)\n", TheUI.Contrast);
@@ -689,10 +689,12 @@
 
     // Resource
     free(ui->Resource.File);
+    free(ui->Resource.Graphic);
 
     // Resource Icons
     for (i = 0; i < MaxCosts + 2; ++i) {
        free(ui->Resources[i].Icon.File);
+       free(ui->Resources[i].Icon.Graphic);
     }
 
     // Info Panel
Index: stratagus/src/unit/ccl_unit.c
diff -u stratagus/src/unit/ccl_unit.c:1.74 stratagus/src/unit/ccl_unit.c:1.75
--- stratagus/src/unit/ccl_unit.c:1.74  Wed Nov 12 15:31:16 2003
+++ stratagus/src/unit/ccl_unit.c       Fri Nov 14 23:38:52 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unit.c,v 1.74 2003/11/12 20:31:16 jsalmon3 Exp $
+//     $Id: ccl_unit.c,v 1.75 2003/11/15 04:38:52 mr-russ Exp $
 
 //@{
 
@@ -991,7 +991,7 @@
     iy = gh_scm2int(y);
 
     heading = SyncRand() % 256;
-    unit = MakeUnit(unittype, &Players[gh_scm2int(player)]);
+    unit = MakeUnit(unittype, &Players[TriggerGetPlayer(player)]);
     mask = UnitMovementMask(unit);
     if (CheckedCanMoveToMask(ix, iy, mask)) {
        unit->Wait = 1;




reply via email to

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