stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src game/game.c missile/script_missil...


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src game/game.c missile/script_missil...
Date: 30 Jan 2004 07:36:24 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/30 07:36:24

Modified files:
        src/game       : game.c 
        src/missile    : script_missile.c 
        src/stratagus  : mainloop.c 
        src/unit       : script_unit.c unit.c unit_draw.c 

Log message:
        More savegame fixes.

Patches:
Index: stratagus/src/game/game.c
diff -u stratagus/src/game/game.c:1.131 stratagus/src/game/game.c:1.132
--- stratagus/src/game/game.c:1.131     Tue Jan 27 22:03:26 2004
+++ stratagus/src/game/game.c   Fri Jan 30 07:36:20 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: game.c,v 1.131 2004/01/27 11:03:26 wizzard Exp $
+//      $Id: game.c,v 1.132 2004/01/29 20:36:20 nobody_ Exp $
 
 //@{
 
@@ -306,6 +306,7 @@
        char* s;
 
        if (SaveGameLoading) {
+               SaveGameLoading = 0;
                // Load game, already created game with Init/LoadModules
                return;
        }
Index: stratagus/src/missile/script_missile.c
diff -u stratagus/src/missile/script_missile.c:1.61 
stratagus/src/missile/script_missile.c:1.62
--- stratagus/src/missile/script_missile.c:1.61 Tue Jan 20 10:24:39 2004
+++ stratagus/src/missile/script_missile.c      Fri Jan 30 07:36:21 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script_missile.c,v 1.61 2004/01/19 23:24:39 nobody_ Exp $
+//      $Id: script_missile.c,v 1.62 2004/01/29 20:36:21 nobody_ Exp $
 
 //@{
 
@@ -324,12 +324,12 @@
                        DebugCheck(!missile);
                        value = LuaToString(l, j + 1);
                        missile->SourceUnit = UnitSlots[strtol(value + 1, 0, 
16)];
-                       missile->SourceUnit->Refs++;
+                       RefsIncrease(missile->SourceUnit);
                } else if (!strcmp(value, "target")) {
                        DebugCheck(!missile);
                        value = LuaToString(l, j + 1);
                        missile->TargetUnit = UnitSlots[strtol(value + 1, 0, 
16)];
-                       missile->TargetUnit->Refs++;
+                       RefsIncrease(missile->TargetUnit);
                } else if (!strcmp(value, "damage")) {
                        DebugCheck(!missile);
                        missile->Damage = LuaToNumber(l, j + 1);
Index: stratagus/src/stratagus/mainloop.c
diff -u stratagus/src/stratagus/mainloop.c:1.184 
stratagus/src/stratagus/mainloop.c:1.185
--- stratagus/src/stratagus/mainloop.c:1.184    Wed Jan 28 09:13:47 2004
+++ stratagus/src/stratagus/mainloop.c  Fri Jan 30 07:36:22 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: mainloop.c,v 1.184 2004/01/27 22:13:47 wizzard Exp $
+//      $Id: mainloop.c,v 1.185 2004/01/29 20:36:22 nobody_ Exp $
 
 //@{
 
@@ -774,7 +774,6 @@
        EnableDrawRefresh();
        GameCursor = TheUI.Point.Cursor;
        GameRunning = 1;
-       SaveGameLoading = 0;
 
        showtip = 0;
        RealVideoSyncSpeed = VideoSyncSpeed;
@@ -788,6 +787,9 @@
 
        while (GameRunning) {
 
+               // Can't find a better place.
+               // TODO: rewrite this mainloop junk. And menu system. MY BRAIN 
HURTS!!!
+               SaveGameLoading = 0;
 #if defined(DEBUG)
                if (setjmp(MainLoopJmpBuf)) {
                        GamePaused = 1;
Index: stratagus/src/unit/script_unit.c
diff -u stratagus/src/unit/script_unit.c:1.101 
stratagus/src/unit/script_unit.c:1.102
--- stratagus/src/unit/script_unit.c:1.101      Fri Jan 30 04:36:52 2004
+++ stratagus/src/unit/script_unit.c    Fri Jan 30 07:36:22 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script_unit.c,v 1.101 2004/01/29 17:36:52 nobody_ Exp $
+//      $Id: script_unit.c,v 1.102 2004/01/29 20:36:22 nobody_ Exp $
 
 //@{
 
@@ -637,11 +637,7 @@
        const char* s;
        int args;
        int j;
-       int savrefs;
 
-#ifdef DEBUG
-       savrefs = 0;
-#endif
        args = lua_gettop(l);
        j = 0;
 
@@ -693,7 +689,7 @@
                } else if (!strcmp(value, "current-sight-range")) {
                        unit->CurrentSightRange = LuaToNumber(l, j + 1);
                } else if (!strcmp(value, "refs")) {
-                       savrefs = LuaToNumber(l, j + 1);
+                       unit->Refs = LuaToNumber(l, j + 1);
                } else if (!strcmp(value, "host-info")) {
                        int x;
                        int y;
@@ -959,23 +955,22 @@
                MapMarkUnitSight(unit);
        }
 
-       // Units Dieing may have sight
-       if (unit->Removed && unit->Orders[0].Action == UnitActionDie) {
-               MapMarkUnitSight(unit);
-       }
-
        //              Place on map
        if (!unit->Removed && !unit->Destroyed && !unit->Type->Vanishes) {
                unit->Removed = 1;
                PlaceUnit(unit, unit->X, unit->Y);
        }
 
-       if (unit->UnitSlot) {
+       if (unit->UnitSlot && (unit->Destroyed || unit->Orders->Action == 
UnitActionDie)) {
                UnitCacheRemove(unit);
                UnitCacheInsert(unit);
        }
 
-       // FIXME: johns: works only for debug code.
+       // Units Dieing may have sight
+       if (unit->Removed && unit->Orders[0].Action == UnitActionDie) {
+               MapMarkUnitSight(unit);
+       }
+
        if (unit->Moving) {
                NewResetPath(unit);
        }
@@ -984,8 +979,6 @@
                unit->Colors = &unit->RescuedFrom->UnitColors;
        }
        
-       // Fix references. REFERENCES GET SAVED!.
-       unit->Refs = savrefs;
        DebugLevel3Fn("unit #%d parsed\n" _C_ slot);
 
        return 0;
Index: stratagus/src/unit/unit.c
diff -u stratagus/src/unit/unit.c:1.379 stratagus/src/unit/unit.c:1.380
--- stratagus/src/unit/unit.c:1.379     Fri Jan 30 04:36:52 2004
+++ stratagus/src/unit/unit.c   Fri Jan 30 07:36:22 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit.c,v 1.379 2004/01/29 17:36:52 nobody_ Exp $
+//      $Id: unit.c,v 1.380 2004/01/29 20:36:22 nobody_ Exp $
 
 //@{
 
@@ -141,7 +141,9 @@
 global void RefsIncrease(Unit* unit)
 {
        RefsDebugCheck(!unit->Refs || unit->Destroyed);
-       ++unit->Refs;
+       if (!SaveGameLoading) {
+               ++unit->Refs;
+       }
 }
 
 /**
@@ -152,13 +154,15 @@
 global void RefsDecrease(Unit* unit)
 {
        RefsDebugCheck(!unit->Refs);
-       if (unit->Destroyed) {
-               if (!--unit->Refs) {
-                       ReleaseUnit(unit);
+       if (!SaveGameLoading) {
+               if (unit->Destroyed) {
+                       if (!--unit->Refs) {
+                               ReleaseUnit(unit);
+                       }
+               } else {
+                       --unit->Refs;
+                       RefsDebugCheck(!unit->Refs);
                }
-       } else {
-               --unit->Refs;
-               RefsDebugCheck(!unit->Refs);
        }
 }
 
@@ -192,7 +196,7 @@
 
                if (--unit->Refs > 0) {
                        DebugLevel2Fn("%lu:More references of %d #%d\n" _C_ 
GameCycle _C_
-                       UnitNumber(unit) _C_ unit->Refs);
+                               UnitNumber(unit) _C_ unit->Refs);
                        return;
                }
        }
@@ -217,7 +221,7 @@
 
        unit->Next = 0;
        ReleasedTail = &unit->Next;
-       unit->Refs = GameCycle + NetworkMaxLag;         // could be reuse after 
this time
+       unit->Refs = GameCycle + (NetworkMaxLag << 1);  // could be reuse after 
this time
        DebugLevel2Fn("%lu:No more references, only wait for network lag, unit 
%d\n" _C_
                GameCycle _C_ UnitNumber(unit));
        unit->Type = 0;                                                 // for 
debugging.
@@ -285,13 +289,8 @@
 
        DebugCheck(!type);
 
-       // Refs need to be *increased* by 1, not *set* to 1, because if 
InitUnit()
-       // is called from game loading code, Refs can already have a nonzero
-       // value (thanks to forward references in the save file).  Incrementing
-       // should not matter during in-game unit creation because in that case
-       // Refs is 0 anyway.
-
-       ++unit->Refs;
+       //  Set refs to 1. This is the "I am alive ref", lost in ReleaseUnit.
+       unit->Refs = 1;
 
        //
        //  Build all unit table
@@ -3073,7 +3072,7 @@
                                0, 0);
                        missile->SourceUnit = target;
                        target->Burning = 1;
-                       target->Refs++;
+                       RefsIncrease(target);
                }
        }
 
@@ -3770,7 +3769,7 @@
        int j;
 
        CLprintf(file, "\n--- -----------------------------------------\n");
-       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.379 2004/01/29 
17:36:52 nobody_ Exp $\n\n");
+       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.380 2004/01/29 
20:36:22 nobody_ Exp $\n\n");
 
 #if 0
        //
Index: stratagus/src/unit/unit_draw.c
diff -u stratagus/src/unit/unit_draw.c:1.217 
stratagus/src/unit/unit_draw.c:1.218
--- stratagus/src/unit/unit_draw.c:1.217        Fri Jan 30 04:36:53 2004
+++ stratagus/src/unit/unit_draw.c      Fri Jan 30 07:36:23 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit_draw.c,v 1.217 2004/01/29 17:36:53 nobody_ Exp $
+//      $Id: unit_draw.c,v 1.218 2004/01/29 20:36:23 nobody_ Exp $
 
 //@{
 
@@ -644,7 +644,7 @@
 {
 #if 0
        CLprintf(file, "\n;;; -----------------------------------------\n");
-       CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.217 
2004/01/29 17:36:53 nobody_ Exp $\n\n");
+       CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.218 
2004/01/29 20:36:23 nobody_ Exp $\n\n");
 
        CLprintf(file, "(mana-sprite \"%s\"  %d %d  %d %d)\n",
                ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,
@@ -1635,7 +1635,7 @@
        const UnitStats* stats;
        int r;
 
-#if 1 // This is for showing vis counts and refs.
+#if 0 // This is for showing vis counts and refs.
        char buf[10];
        sprintf(buf, "%d%c%c%d", unit->VisCount[ThisPlayer->Player],
                unit->Seen.ByPlayer & (1 << ThisPlayer->Player) ? 'Y' : 'N',




reply via email to

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