stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus doc/ChangeLog.html src/ui/mouse.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus doc/ChangeLog.html src/ui/mouse.c
Date: Thu, 13 Nov 2003 21:26:54 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/11/13 21:26:54

Modified files:
        doc            : ChangeLog.html 
        src/ui         : mouse.c 

Log message:
        Fixed bug #6522: Set Harvest/Mining button doesn't work
        Fixed redraw when shift clicking and unselecting all units
        Fixed acknowledgement sound when clicking on unexplored terrain

Patches:
Index: stratagus/doc/ChangeLog.html
diff -u stratagus/doc/ChangeLog.html:1.575 stratagus/doc/ChangeLog.html:1.576
--- stratagus/doc/ChangeLog.html:1.575  Thu Nov 13 15:26:39 2003
+++ stratagus/doc/ChangeLog.html        Thu Nov 13 21:26:53 2003
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-----   $Id: ChangeLog.html,v 1.575 2003/11/13 20:26:39 pludov Exp $
+----   $Id: ChangeLog.html,v 1.576 2003/11/14 02:26:53 jsalmon3 Exp $
 
 ----   (c) Copyright 1998-2003 by Lutz Sammer
 
@@ -36,11 +36,12 @@
 <li>Future 2.00 Release<p>
     <ul>
     <li>++
-    <li>Fixed Bug #5602 Replay's use incorrect player when playing single 
player from Multiplayer menu (from Pollet Ludovic).
-    <li>Fixed Bug #6444 Passive AI is not passive (from Pollet Ludovic).
-    <li>Fixed Bug #6392 Crash with guile support enabled (from Pollet Ludovic).
+    <li>Fixed Bug #6522: Set Harvest/Mining button doesn't work (from Jimmy 
Salmon).
+    <li>Fixed Bug #5602: Replay's use incorrect player when playing single 
player from Multiplayer menu (from Pollet Ludovic).
+    <li>Fixed Bug #6444: Passive AI is not passive (from Pollet Ludovic).
+    <li>Fixed Bug #6392: Crash with guile support enabled (from Pollet 
Ludovic).
     <li>Fixed Bug #6516: Cactus selection problem in Magnant (from Russell 
Smith).
-    <li>Fixed Bug #6427 and added a brand new seen mechanism (from Crestez 
Leonard).
+    <li>Fixed Bug #6427: and added a brand new seen mechanism (from Crestez 
Leonard).
     <li>Fixed Bug #6391: Infinite loop in UpdateMinimap() (from Russell Smith).
     <li>Major clean-up in checking goals that disappear and unit reference 
counting (from Crestez Leonard).
     <li>Fixed Bug #5992: Little undesirable effects with invisibility and 
flameShield spell (from Crestez Leonard).
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.162 stratagus/src/ui/mouse.c:1.163
--- stratagus/src/ui/mouse.c:1.162      Tue Nov  4 17:54:35 2003
+++ stratagus/src/ui/mouse.c    Thu Nov 13 21:26:54 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mouse.c,v 1.162 2003/11/04 22:54:35 n0body Exp $
+//     $Id: mouse.c,v 1.163 2003/11/14 02:26:54 jsalmon3 Exp $
 
 //@{
 
@@ -268,7 +268,7 @@
                    if (action == MouseActionSpellCast) {
                        // This is for demolition squads and such
                        DebugCheck(!unit->Type->CanCastSpell);
-                       for (spellnum=0; !unit->Type->CanCastSpell[spellnum] &&
+                       for (spellnum = 0; !unit->Type->CanCastSpell[spellnum] 
&&
                                spellnum < SpellTypeCount ; spellnum++) ;
                        DebugCheck(spellnum == SpellTypeCount);
                        SendCommandSpellCast(unit, x, y, dest, spellnum, flush);
@@ -343,12 +343,12 @@
            if (dest && dest->Type->GivesResource) {
                 dest->Blink = 4;
                DebugLevel3("Set rally point to a resource.\n");
-                SendCommandResource(Selected[i],dest, !(KeyModifiers & 
ModifierShift));
+                SendCommandResource(unit, dest, flush);
                continue;
            }
            if (IsMapFieldExplored(unit->Player, x, y) && ForestOnMap(x, y)) {
                DebugLevel3("Set rally point to a forest.\n");
-               SendCommandResourceLoc(Selected[i], x, y,!(KeyModifiers & 
ModifierShift));
+               SendCommandResourceLoc(unit, x, y, flush);
                 continue;
             }
            DebugLevel3("Set rally point to a location.\n");
@@ -823,14 +823,16 @@
 **     @param sx       X screen map position.
 **     @param sy       Y screen map position.
 */
-local void SendRepair(int sx, int sy)
+local int SendRepair(int sx, int sy)
 {
     int i;
     Unit* unit;
     Unit* dest;
     int x;
     int y;
+    int ret;
 
+    ret = 0;
     x = sx / TileSizeX;
     y = sy / TileSizeY;
 
@@ -842,11 +844,13 @@
            unit = Selected[i];
            if (unit->Type->RepairRange) {
                SendCommandRepair(unit, x, y, dest, !(KeyModifiers & 
ModifierShift));
+               ret = 1;
            } else {
                DebugLevel0Fn("Non-worker repairs\n");
            }
        }
     }
+    return ret;
 }
 
 /**
@@ -858,18 +862,21 @@
 **     @todo   To reduce the CPU load for pathfinder, we should check if
 **             the destination is reachable and handle nice group movements.
 */
-local void SendMove(int sx, int sy)
+local int SendMove(int sx, int sy)
 {
     int i;
     int flush;
     Unit* unit;
     Unit* transporter;
+    int ret;
 
+    ret = 0;
     //  Move to a transporter.
     if ((transporter = UnitUnderCursor) &&
            (transporter->Type->Transporter) &&
            (transporter->Player == ThisPlayer)){
        SendCommandStopUnit(transporter);
+       ret = 1;
     } else {
        transporter = NULL;
     }
@@ -883,10 +890,13 @@
            DebugLevel3Fn("Board transporter\n");
            SendCommandFollow(transporter, unit, 0);
            SendCommandBoard(unit, -1, -1, transporter, flush);
+           ret = 1;
        } else {
            SendCommandMove(unit, sx / TileSizeX, sy / TileSizeY, flush);
+           ret = 1;
        }
     }
+    return ret;
 }
 
 /**
@@ -903,16 +913,18 @@
 **
 **     @see Selected, @see NumSelected
 */
-local void SendAttack(int sx, int sy)
+local int SendAttack(int sx, int sy)
 {
     int i;
     Unit* unit;
     Unit* dest;
     int x;
     int y;
+    int ret;
 
-    x=sx / TileSizeX;
-    y=sy / TileSizeY;
+    ret = 0;
+    x = sx / TileSizeX;
+    y = sy / TileSizeY;
     for (i = 0; i < NumSelected; ++i) {
        unit = Selected[i];
        if (unit->Type->CanAttack || unit->Type->Building) {
@@ -924,11 +936,14 @@
            }
            if (dest != unit) { // don't let an unit self destruct
                SendCommandAttack(unit, x, y, dest, !(KeyModifiers & 
ModifierShift));
+               ret = 1;
            }
        } else {
            SendCommandMove(unit, x, y, !(KeyModifiers & ModifierShift));
+           ret = 1;
        }
     }
+    return ret;
 }
 
 /**
@@ -937,21 +952,26 @@
 **     @param sx       X screen map position.
 **     @param sy       Y screen map position.
 */
-local void SendAttackGround(int sx, int sy)
+local int SendAttackGround(int sx, int sy)
 {
     int i;
     Unit* unit;
+    int ret;
 
+    ret = 0;
     for (i = 0; i < NumSelected; ++i) {
        unit = Selected[i];
        if (unit->Type->CanAttack) {
            SendCommandAttackGround(unit, sx / TileSizeX, sy / TileSizeY,
                !(KeyModifiers & ModifierShift));
+           ret = 1;
        } else {
            SendCommandMove(unit, sx / TileSizeX, sy / TileSizeY,
                !(KeyModifiers & ModifierShift));
+           ret = 1;
        }
     }
+    return ret;
 }
 
 /**
@@ -959,16 +979,20 @@
 **     @param sx       X screen map position.
 **     @param sy       Y screen map position.
 */
-local void SendPatrol(int sx, int sy)
+local int SendPatrol(int sx, int sy)
 {
     int i;
     Unit* unit;
+    int ret;
 
+    ret = 0;
     for (i = 0; i < NumSelected; ++i) {
        unit = Selected[i];
        SendCommandPatrol(unit, sx / TileSizeX, sy / TileSizeY,
            !(KeyModifiers & ModifierShift));
+       ret = 1;
     }
+    return ret;
 }
 
 /**
@@ -979,36 +1003,78 @@
 **
 **     @see Selected
 */
-local void SendResource(int sx, int sy)
+local int SendResource(int sx, int sy)
 {
     int i;
+    int x;
+    int y;
     int res;
+    Unit* unit;
     Unit* dest;
+    int ret;
+
+    ret = 0;
+    dest = UnitUnderCursor;
+    x = sx / TileSizeX;
+    y = sy / TileSizeY;
 
     for (i = 0; i < NumSelected; ++i) {
-       if ((dest = UnitUnderCursor) &&
-               (Selected[i]->Type->Harvester) &&
-               (res=dest->Type->GivesResource) &&
-               (Selected[i]->Type->ResInfo[res])) {
-           dest->Blink = 4;
-           DebugLevel3("RESOURCE\n");
-           SendCommandResource(Selected[i],dest, !(KeyModifiers & 
ModifierShift));
-           continue;
-       }
-       for (res = 0; res < MaxCosts; ++res) {
-           if (Selected[i]->Type->Harvester &&
-                   Selected[i]->Type->ResInfo[res] &&
-                   Selected[i]->Type->ResInfo[res]->TerrainHarvester &&
-                   //  Full harvesters don't act.
-                   Selected[i]->Value < 
Selected[i]->Type->ResInfo[res]->ResourceCapacity &&
-                   IsMapFieldExplored(Selected[i]->Player, sx / TileSizeX, sy 
/ TileSizeY) &&
-                   ForestOnMap(sx / TileSizeX, sy / TileSizeY)) {
+       unit = Selected[i];
+       if (unit->Type->Harvester) {
+           if (dest &&
+                   (res = dest->Type->GivesResource) &&
+                   unit->Type->ResInfo[res] &&
+                   unit->Value < unit->Type->ResInfo[res]->ResourceCapacity &&
+                   dest->Type->CanHarvest &&
+                   (dest->Player == unit->Player ||
+                       (dest->Player->Player == PlayerMax - 1))) {
                DebugLevel3("RESOURCE\n");
-               SendCommandResourceLoc(Selected[i], sx / TileSizeY, sy / 
TileSizeY,
-                   !(KeyModifiers & ModifierShift));
+               dest->Blink = 4;
+               SendCommandResource(Selected[i],dest, !(KeyModifiers & 
ModifierShift));
+               ret = 1;
+               continue;
+           } else {
+               for (res = 0; res < MaxCosts; ++res) {
+                   if (unit->Type->ResInfo[res] &&
+                           unit->Type->ResInfo[res]->TerrainHarvester &&
+                           IsMapFieldExplored(unit->Player, x, y) &&
+                           ForestOnMap(x, y) &&
+                           Selected[i]->Value < 
unit->Type->ResInfo[res]->ResourceCapacity &&
+                           ((unit->CurrentResource != res) ||
+                               (unit->Value < 
unit->Type->ResInfo[res]->ResourceCapacity))) {
+                       DebugLevel3("RESOURCE\n");
+                       SendCommandResourceLoc(unit, x, y,
+                           !(KeyModifiers & ModifierShift));
+                       ret = 1;
+                       break;
+                   }
+               }
+               if (res != MaxCosts) {
+                   continue;
+               }
            }
        }
+       if (unit->Type->Building) {
+           if (dest && dest->Type->GivesResource) {
+                dest->Blink = 4;
+               DebugLevel3("Set rally point to a resource.\n");
+                SendCommandResource(unit, dest, !(KeyModifiers & 
ModifierShift));
+               ret = 1;
+               continue;
+           }
+           if (IsMapFieldExplored(unit->Player, x, y) && ForestOnMap(x, y)) {
+               DebugLevel3("Set rally point to a forest.\n");
+               SendCommandResourceLoc(unit, x, y, !(KeyModifiers & 
ModifierShift));
+               ret = 1;
+                continue;
+            }
+           DebugLevel3("Set rally point to a location.\n");
+           SendCommandMove(unit, x, y, !(KeyModifiers & ModifierShift));
+           ret = 1;
+            continue;
+       }
     }
+    return ret;
 }
 
 /**
@@ -1017,15 +1083,19 @@
 **     @param sx       X screen map position.
 **     @param sy       Y screen map position.
 */
-local void SendUnload(int sx, int sy)
+local int SendUnload(int sx, int sy)
 {
     int i;
+    int ret;
 
+    ret = 0;
     for (i = 0; i < NumSelected; ++i) {
        // FIXME: not only transporter selected?
        SendCommandUnload(Selected[i], sx / TileSizeX, sy / TileSizeY, NoUnitP,
            !(KeyModifiers & ModifierShift));
+       ret = 1;
     }
+    return ret;
 }
 
 /**
@@ -1040,14 +1110,16 @@
 **
 **     @see Selected, @see NumSelected
 */
-local void SendSpellCast(int sx, int sy)
+local int SendSpellCast(int sx, int sy)
 {
     int i;
     Unit *unit;
     Unit *dest;
     int x;
     int y;
+    int ret;
 
+    ret = 0;
     x = sx / TileSizeX;
     y = sy / TileSizeY;
     
@@ -1073,7 +1145,9 @@
        // CursorValue here holds the spell type id
        SendCommandSpellCast(unit, x, y, dest, CursorValue,
            !(KeyModifiers & ModifierShift));
+       ret = 1;
     }
+    return ret;
 }
 
 /**
@@ -1087,47 +1161,52 @@
     int i;
     int x;
     int y;
+    int ret;
 
+    ret = 0;
     x = sx / TileSizeX;
     y = sy / TileSizeY;
     CurrentButtonLevel = 0; // reset unit buttons to normal
     UpdateButtonPanel();
     switch (CursorAction) {
        case ButtonMove:
-           SendMove(sx, sy);
+           ret = SendMove(sx, sy);
            break;
        case ButtonRepair:
-           SendRepair(sx, sy);
+           ret = SendRepair(sx, sy);
            break;
        case ButtonAttack:
-           SendAttack(sx, sy);
+           ret = SendAttack(sx, sy);
            break;
        case ButtonAttackGround:
-           SendAttackGround(sx, sy);
+           ret = SendAttackGround(sx, sy);
            break;
        case ButtonPatrol:
-           SendPatrol(sx, sy);
+           ret = SendPatrol(sx, sy);
            break;
        case ButtonHarvest:
-           SendResource(sx, sy);
+           ret = SendResource(sx, sy);
            break;
        case ButtonUnload:
-           SendUnload(sx, sy);
+           ret = SendUnload(sx, sy);
            break;
        case ButtonSpellCast:
-           SendSpellCast(sx, sy);
+           ret = SendSpellCast(sx, sy);
            break;
        default:
            DebugLevel1("Unsupported send action %d\n" _C_ CursorAction);
            break;
     }
 
-    //
-    // Acknowledge the command with first selected unit.
-    //
-    for (i = 0; i < NumSelected; ++i) {
-       PlayUnitSound(Selected[i], VoiceAcknowledging);
-       break;
+    if (ret) {
+       // Acknowledge the command with first selected unit.
+       for (i = 0; i < NumSelected; ++i) {
+           if (Selected[i]->Type->Sound.Acknowledgement.Sound) {
+               PlayUnitSound(Selected[i], VoiceAcknowledging);
+               break;
+           }
+       }
+       ShowOrdersCount = GameCycle + ShowOrders * CYCLES_PER_SECOND;
     }
 }
 
@@ -1327,7 +1406,7 @@
     if (CursorOn == CursorOnMap) {
        DebugCheck(!TheUI.MouseViewport);
 
-       if ((MouseButtons&LeftButton) &&
+       if ((MouseButtons & LeftButton) &&
                TheUI.SelectedViewport != TheUI.MouseViewport) {
            TheUI.SelectedViewport = TheUI.MouseViewport;
            MustRedraw = RedrawMinimapCursor | RedrawMap;
@@ -1339,7 +1418,7 @@
        if (CursorBuilding) {
            // Possible Selected[0] was removed from map
            // need to make sure there is an unit to build
-           if (Selected[0] && (MouseButtons&LeftButton)) {// enter select mode
+           if (Selected[0] && (MouseButtons & LeftButton)) {// enter select 
mode
                int x;
                int y;
                int i;
@@ -1359,7 +1438,7 @@
                        }
                    }
                }
-               if (CanBuildUnitType(Selected[0],CursorBuilding, x, y) &&
+               if (CanBuildUnitType(Selected[0], CursorBuilding, x, y) &&
                        (explored || ReplayRevealMap)) {
                    PlayGameSound(GameSounds.PlacementSuccess.Sound,
                        MaxSampleVolume);
@@ -1680,14 +1759,11 @@
            // Select single unit
            //
            unit = NULL;
-           if (NumSelected == 1) {
-               unit = Selected[0];
-           }
            // cade: cannot select unit on invisible space
            // FIXME: johns: only complete invisibile units
            if (IsMapFieldVisible(ThisPlayer,
-                   Viewport2MapX(TheUI.MouseViewport,CursorX),
-                   Viewport2MapY(TheUI.MouseViewport,CursorY)) || 
ReplayRevealMap) {
+                   Viewport2MapX(TheUI.MouseViewport, CursorX),
+                   Viewport2MapY(TheUI.MouseViewport, CursorY)) || 
ReplayRevealMap) {
                unit = UnitOnScreen(unit,
                    CursorX - TheUI.MouseViewport->X + 
TheUI.MouseViewport->MapX * TileSizeX,
                    CursorY - TheUI.MouseViewport->Y + 
TheUI.MouseViewport->MapY * TileSizeY);
@@ -1715,6 +1791,9 @@
                        (NumSelected != 1 || !Selected[0]->Type->Building) &&
                        (NumSelected != 1 || Selected[0]->Player == 
ThisPlayer)) {
                    num = ToggleSelectUnit(unit);
+                   if (!num) {
+                       SelectionChanged();
+                   }
                } else {
                    SelectSingleUnit(unit);
                    num = 1;




reply via email to

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