stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] demogame/scripts garbagecollector.py overview.py


From: Martin Renold
Subject: [Stratagus-CVS] demogame/scripts garbagecollector.py overview.py
Date: Thu, 09 Oct 2003 12:09:42 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    demogame
Branch:         
Changes by:     Martin Renold <address@hidden>  03/10/09 12:09:42

Modified files:
        scripts        : garbagecollector.py overview.py 

Log message:
        removed alliance heros; removed mythical spells; merged engine changes

Patches:
Index: demogame/scripts/garbagecollector.py
diff -u demogame/scripts/garbagecollector.py:1.1 
demogame/scripts/garbagecollector.py:1.2
--- demogame/scripts/garbagecollector.py:1.1    Thu Oct  9 09:52:15 2003
+++ demogame/scripts/garbagecollector.py        Thu Oct  9 12:09:41 2003
@@ -30,9 +30,15 @@
 
 def removestatement(l):
     "wipes a statement list out of its ccl file"
-    pre, post = open(l.filename).read().split(l.string)
-    open(l.filename, 'w').write(pre + post)
-    overview.lists.remove(l)
+    try:
+        pre, post = open(l.filename).read().split(l.string)
+        open(l.filename, 'w').write(pre + post)
+        overview.lists.remove(l)
+    except ValueError:
+        print l.string
+        print 'Cannot remove statements containing comments. Remove the 
comment.'
+        print 'File', l.filename
+        sys.exit(1)
 
 # scan for icons defined but not used
 icons = {}
@@ -60,6 +66,42 @@
         usedfiles.append(l.iconfile)
 icons = None
 
+# scan for animations defined but not used
+animations = []
+for l in overview.lists:
+    if l.command == 'define-animations':
+        l.refcount = 0
+        l.name = l.list[1].lstrip("'")
+        animations.append(l)
+for l in overview.lists:
+    if l.command == 'define-animations': continue
+    for a in animations:
+        if a.name in l.string:
+            a.refcount += 1
+print len(animations), 'animation definitions'
+for a in animations:
+    if a.refcount == 0:
+        print 'removing unused animation', a.name
+        removestatement(a)
+
+# scan for spells defined but not used
+spells = []
+for l in overview.lists:
+    if l.command == 'define-spell':
+        l.refcount = 0
+        l.name = l.list[1].strip('"')
+        spells.append(l)
+for l in overview.lists:
+    if l.command == 'define-spell': continue
+    for s in spells:
+        if s.name in l.string:
+            s.refcount += 1
+print len(spells), 'spell definitions'
+for s in spells:
+    if s.refcount == 0:
+        print 'removing unused spell', s.name
+        removestatement(s)
+
 # scan for sounds defined but not used
 sounds = {}
 hardcoded_sounds = [
@@ -105,7 +147,6 @@
         l.soundfiles = None
         l.refcount = 0
         sounds[l.list[1]] = l
-
 for l in overview.lists:
     # have to find sounds in nested lists, too
     for s, sound in sounds.items():
Index: demogame/scripts/overview.py
diff -u demogame/scripts/overview.py:1.2 demogame/scripts/overview.py:1.3
--- demogame/scripts/overview.py:1.2    Thu Oct  9 09:52:15 2003
+++ demogame/scripts/overview.py        Thu Oct  9 12:09:42 2003
@@ -53,8 +53,8 @@
 os.path.walk(join(datadir, 'ccl'), visit, None)
 
 if __name__ == '__main__':
-    print 'Mythical units remaining:'
+    print 'Alliance units remaining:'
     for u in units:
-        if u.race == 'mythical':
+        if u.race == 'alliance':
             print u.type.ljust(30) + u.get("'name")
 




reply via email to

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