stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src clone/spells.c siod/slib.c


From: Martin Renold
Subject: [Stratagus-CVS] stratagus/src clone/spells.c siod/slib.c
Date: Tue, 23 Sep 2003 05:12:36 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Martin Renold <address@hidden>  03/09/23 05:12:35

Modified files:
        src/clone      : spells.c 
        src/siod       : slib.c 

Log message:
        fixed assertions before variable declaration

Patches:
Index: stratagus/src/clone/spells.c
diff -u stratagus/src/clone/spells.c:1.96 stratagus/src/clone/spells.c:1.97
--- stratagus/src/clone/spells.c:1.96   Mon Sep 22 15:13:08 2003
+++ stratagus/src/clone/spells.c        Tue Sep 23 05:12:35 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: spells.c,v 1.96 2003/09/22 19:13:08 n0body Exp $
+//     $Id: spells.c,v 1.97 2003/09/23 09:12:35 martinxyz Exp $
 
 /*
 **     And when we cast our final spell
@@ -490,11 +490,6 @@
 global int CastBlizzard(Unit* caster, const SpellType* spell,
     Unit* target __attribute__((unused)), int x, int y)
 {
-       assert(caster);
-       assert(spell);
-       assert(spell->SpellAction);
-//     assert(x in range, y in range);
-
     int fields;
     int shards;
     int damage;
@@ -505,6 +500,11 @@
     int dy;
     int i;
 
+    assert(caster);
+    assert(spell);
+    assert(spell->SpellAction);
+    //assert(x in range, y in range);
+
     fields = spell->SpellAction->Blizzard.Fields;
     shards = spell->SpellAction->Blizzard.Shards;
     damage = spell->SpellAction->Blizzard.Damage;
@@ -562,16 +562,16 @@
 global int CastCircleOfPower(Unit* caster, const SpellType* spell 
__attribute__((unused)),
     Unit* target __attribute__((unused)), int x, int y)
 {
+    // FIXME: vladi: cop should be placed only on explored land
+    Unit *cop = NULL;
+    UnitType *ucop = spell->SpellAction->SpawnPortal.PortalType;
+
     assert(caster);
     assert(spell);
     assert(spell->SpellAction);
     assert(spell->SpellAction->SpawnPortal.PortalType);
 //     assert(x in range, y in range);
 
-    // FIXME: vladi: cop should be placed only on explored land
-    Unit *cop = NULL;
-    UnitType *ucop = spell->SpellAction->SpawnPortal.PortalType;
-
     cop = caster->Goal;
     if (cop)
     {
@@ -609,11 +609,6 @@
 global int CastDeathAndDecay(Unit* caster, const SpellType* spell,
     Unit* target __attribute__((unused)), int x, int y)
 {
-       assert(caster);
-       assert(spell);
-       assert(spell->SpellAction);
-//     assert(x in range, y in range);
-
     int fields;                        // blizzard thing, yep :)
     int shards;
        int damage;
@@ -622,6 +617,11 @@
     int dy;
     int i;
 
+       assert(caster);
+       assert(spell);
+       assert(spell->SpellAction);
+//     assert(x in range, y in range);
+
     fields = spell->SpellAction->DeathAndDecay.Fields;
     shards = spell->SpellAction->DeathAndDecay.Shards;
     damage = spell->SpellAction->DeathAndDecay.Damage;
@@ -667,16 +667,16 @@
 global int CastDeathCoil(Unit* caster, const SpellType* spell, Unit* target,
     int x, int y)
 {
+    Missile *mis = NULL;
+    int sx = caster->X;
+    int sy = caster->Y;
+
     assert(caster);
     assert(spell);
     assert(spell->SpellAction);
 //     assert(target);
 //     assert(x in range, y in range);
 
-    Missile *mis = NULL;
-    int sx = caster->X;
-    int sy = caster->Y;
-
     caster->Mana -= spell->ManaCost;
 
     PlayGameSound(spell->SoundWhenCast.Sound, MaxSampleVolume);
@@ -710,6 +710,11 @@
 global int CastFireball(Unit* caster, const SpellType* spell,
     Unit* target __attribute__((unused)), int x, int y)
 {
+    Missile *missile = NULL;
+    int sx;
+    int sy;
+    int dist;
+
        assert(caster);
        assert(spell);
        assert(spell->SpellAction);
@@ -717,11 +722,6 @@
 //     assert(x in range, y in range);
        assert(spell->Missile);
 
-    Missile *missile = NULL;
-    int sx;
-    int sy;
-    int dist;
-
     // NOTE: fireball can be casted on spot
     sx = caster->X;
     sy = caster->Y;
@@ -759,6 +759,9 @@
 global int CastFlameShield(Unit* caster, const SpellType* spell, Unit* target,
     int x __attribute__((unused)), int y __attribute__((unused)))
 {
+       Missile* mis = NULL;
+       int     i;
+
        assert(caster);
        assert(spell);
        assert(spell->SpellAction);
@@ -766,9 +769,6 @@
 //     assert(x in range, y in range);
        assert(spell->Missile);
 
-       Missile* mis = NULL;
-       int     i;
-
        // get mana cost
        caster->Mana -= spell->ManaCost;
        target->FlameShield = spell->SpellAction->FlameShield.TTL;
@@ -799,12 +799,13 @@
 global int CastHaste(Unit* caster, const SpellType* spell, Unit* target,
     int x, int y)
 {
+       struct s_haste  *haste;
+
        assert(caster);
        assert(spell);
        assert(spell->SpellAction);
        assert(target);
 
-       struct s_haste  *haste;
        // get mana cost
        caster->Mana -= spell->ManaCost;
 
@@ -901,17 +902,17 @@
 global int CastHealing(Unit* caster, const SpellType* spell, Unit* target,
     int x, int y)
 {
-       assert(caster);
-       assert(spell);
-       assert(spell->SpellAction);
-       assert(target);
-
        int     i;
        int     diffHP;
        int diffMana = caster->Mana;
        int     HP = spell->SpellAction->healing.HP;
        int Mana = spell->ManaCost;
 
+       assert(caster);
+       assert(spell);
+       assert(spell->SpellAction);
+       assert(target);
+
        // Healing or exorcism
        diffHP = (HP > 0) ? target->Stats->HitPoints - target->HP : target->HP;
        i = min(diffHP / HP + (diffHP % HP ? 1 : 0),
@@ -1060,14 +1061,14 @@
 global int CastPolymorph(Unit* caster, const SpellType* spell, Unit* target,
     int x, int y)
 {
+       UnitType* type = spell->SpellAction->polymorph.unit;
+
        assert(caster);
        assert(spell);
        assert(spell->SpellAction);
        assert(target);
        assert(spell->SpellAction->polymorph.unit);
 
-       UnitType* type = spell->SpellAction->polymorph.unit;
-
        caster->Player->Score += target->Type->Points;
        if (target->Type->Building)
        {
@@ -1114,17 +1115,18 @@
 global int CastRaiseDead(Unit* caster, const SpellType* spell, Unit* target,
     int x, int y)
 {
+    Unit **corpses;
+    Unit *tempcorpse;
+    UnitType *skeleton;
+
        assert(caster);
        assert(spell);
        assert(spell->SpellAction);
        assert(spell->SpellAction->raisedead.skeleton != NULL);
 //     assert(x in range, y in range);
-
-       Unit **corpses;
-    Unit *tempcorpse;
+    skeleton = spell->SpellAction->raisedead.skeleton;
 
     corpses = &CorpseList;
-       UnitType *skeleton = spell->SpellAction->raisedead.skeleton;
 
     while (caster->Mana >= spell->ManaCost && *corpses)
     {
@@ -1172,11 +1174,6 @@
 global int CastRunes(Unit* caster, const SpellType* spell,
     Unit* target __attribute__((unused)), int x, int y)
 {
-       assert(caster);
-       assert(spell);
-       assert(spell->SpellAction);
-//     assert(x in range, y in range);
-
     Missile *mis = NULL;
        const int       xx[] = {-1, +1, 0, 0, 0};
        const int       yy[] = {0, 0, 0, -1, +1};
@@ -1185,6 +1182,11 @@
        int     oldy = y;
        int     i;
 
+       assert(caster);
+       assert(spell);
+       assert(spell->SpellAction);
+//     assert(x in range, y in range);
+
     PlayGameSound(spell->SoundWhenCast.Sound, MaxSampleVolume);
        for (i = 0; i < 5; i++)
        {
@@ -1258,13 +1260,13 @@
 global int CastWhirlwind(Unit* caster, const SpellType* spell,
     Unit* target __attribute__((unused)), int x, int y)
 {
+    Missile *mis = NULL;
+
        assert(caster);
        assert(spell);
        assert(spell->SpellAction);
 //     assert(x in range, y in range);
 
-    Missile *mis = NULL;
-
     caster->Mana -= spell->ManaCost;
     PlayGameSound(spell->SoundWhenCast.Sound, MaxSampleVolume);
     mis = MakeMissile(spell->Missile,
@@ -1354,11 +1356,12 @@
                                                                                
const Unit* caster,
                                                                                
const Unit* target, int x, int y)
 {
+       unsigned int    ttl;
        assert(condition);
+       ttl = condition->u.durationeffect.ttl;
 
        if (target == NULL)
                return !condition->expectvalue;
-       unsigned int    ttl = condition->u.durationeffect.ttl;
 
        switch (condition->u.durationeffect.flag)
        {
@@ -1418,9 +1421,6 @@
 global int     CheckEnemyPresence(const t_Conditions   *condition,
                                                        const Unit* caster)
 {
-       assert(condition != NULL);
-       assert(caster != NULL);
-       
        Unit* table[UnitMax];
     int i;
     int n;
@@ -1428,6 +1428,9 @@
        int     x = caster->X;
        int     y = caster->Y;
 
+       assert(condition != NULL);
+       assert(caster != NULL);
+       
 // +1 should be + Caster_tile_Size ?
     n = SelectUnits(x - range, y - range,
                                x + range + 1, y + range + 1,
@@ -1491,12 +1494,12 @@
 */
 local int PassGenericCondition(const Unit* caster,const SpellType* spell,const 
t_Conditions *condition)
 {
-       assert(caster != NULL);
-       assert(spell != NULL);
-
 //     const t_Conditions      *condition = NULL;
        int     ret;
 
+       assert(caster != NULL);
+       assert(spell != NULL);
+
        // FIXME : Move it in spell->Condition_generic ???
        // mana is a must!
     if (caster->Mana < spell->ManaCost)
@@ -1529,12 +1532,12 @@
                                                                            int 
y,
                                                                                
const t_Conditions *condition)
 {
-       assert(caster != NULL);
-       assert(spell != NULL);
-
 //     const t_Conditions      *condition = NULL;
        int     ret;
 
+       assert(caster != NULL);
+       assert(spell != NULL);
+
        for (/*condition = spell->Condition_specific*/; condition != NULL; 
condition = condition->next)
        {
                assert(condition->f.specific != NULL);
@@ -1685,8 +1688,8 @@
 */
 global int SpellIdByIdent(const char *IdentName)
 {
-    assert(IdentName != NULL);
     int id;
+    assert(IdentName != NULL);
 
     for (id = 0; id < SpellTypeCount; ++id) {
        if (strcmp(SpellTypeTable[id].IdentName, IdentName) == 0) {
@@ -1705,8 +1708,8 @@
 */
 global SpellType *SpellTypeByIdent(const char *IdentName)
 {
-    assert(IdentName != NULL);
     int id;
+    assert(IdentName != NULL);
 
     id = SpellIdByIdent(IdentName);
     return (id == -1 ? NULL : &SpellTypeTable[id]);
@@ -1796,13 +1799,13 @@
 global int     AutoCastSpell(Unit *caster,
                                                 const SpellType* spell)
 {
+    Target                             *target = NULL;
+
        assert(caster != NULL);
        assert(spell != NULL);
        assert(0 <= spell->Ident && spell->Ident < SpellTypeCount);
     assert(caster->Type->CanCastSpell);
     assert(caster->Type->CanCastSpell[spell->Ident]);
-
-    Target                             *target = NULL;
 
        if (!PassGenericCondition(caster, spell, spell->Condition_generic)
                || !PassGenericCondition(caster, spell, 
spell->AutoCast->Condition_generic))
Index: stratagus/src/siod/slib.c
diff -u stratagus/src/siod/slib.c:1.26 stratagus/src/siod/slib.c:1.27
--- stratagus/src/siod/slib.c:1.26      Mon Sep 22 06:40:53 2003
+++ stratagus/src/siod/slib.c   Tue Sep 23 05:12:35 2003
@@ -94,7 +94,7 @@
 
 static void init_slib_version(void)
 {setvar(cintern("*slib-version*"),
-       cintern("$Id: slib.c,v 1.26 2003/09/22 10:40:53 n0body Exp $"),
+       cintern("$Id: slib.c,v 1.27 2003/09/23 09:12:35 martinxyz Exp $"),
        NIL);}
 
 char * __stdcall siod_version(void)
@@ -585,10 +585,10 @@
      
 long repl(struct repl_hooks *h)
 {
-       assert(h != NULL);
 
        LISP x, cw = 0;
        double rt,ct;
+       assert(h != NULL);
        while(1)
        {
                if (gc_kind_copying == 1 &&




reply via email to

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