[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/player.h stratagus/player...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/player.h stratagus/player... |
Date: |
17 Jan 2004 13:12:52 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/17 13:12:52
Modified files:
src/include : player.h
src/stratagus : player.c selection.c
src/ui : botpanel.c mainscr.c mouse.c
Log message:
Team Support, You can control Each Others Units
Patches:
Index: stratagus/src/include/player.h
diff -u stratagus/src/include/player.h:1.84 stratagus/src/include/player.h:1.85
--- stratagus/src/include/player.h:1.84 Thu Jan 15 13:05:38 2004
+++ stratagus/src/include/player.h Sat Jan 17 13:12:49 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: player.h,v 1.84 2004/01/15 02:05:38 jsalmon3 Exp $
+// $Id: player.h,v 1.85 2004/01/17 02:12:49 wizzard Exp $
#ifndef __PLAYER_H__
#define __PLAYER_H__
@@ -537,6 +537,10 @@
/// Two players share vision
#define PlayersShareVision(a, b) ((Players[a].SharedVision & (1 << (b))) &&
(Players[b].SharedVision & (1 << (a))) )
+ /// Players are on the same team (FIXME: use team)
+#define PlayersTeamed(a, b) ((Players[a].Allied & (1 << (b))) &&
(Players[b].Allied & (1 << (a))) )
+ /// Allowed to select multiple units, maybe not mine
+#define CanSelectMultipleUnits(player) ((player) == ThisPlayer ||
PlayersTeamed(ThisPlayer->Player, (player)->Player))
//@}
Index: stratagus/src/stratagus/player.c
diff -u stratagus/src/stratagus/player.c:1.112
stratagus/src/stratagus/player.c:1.113
--- stratagus/src/stratagus/player.c:1.112 Thu Jan 15 17:44:26 2004
+++ stratagus/src/stratagus/player.c Sat Jan 17 13:12:50 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: player.c,v 1.112 2004/01/15 06:44:26 jsalmon3 Exp $
+// $Id: player.c,v 1.113 2004/01/17 02:12:50 wizzard Exp $
//@{
@@ -207,7 +207,7 @@
int j;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: players $Id: player.c,v 1.112 2004/01/15
06:44:26 jsalmon3 Exp $\n\n");
+ CLprintf(file, "--- MODULE: players $Id: player.c,v 1.113 2004/01/17
02:12:50 wizzard Exp $\n\n");
#if 0
//
@@ -1001,7 +1001,8 @@
char temp[128];
va_list va;
- if (player != ThisPlayer) { // Currently
only notfiy me
+ // Notify me, and my TEAM members
+ if (player != ThisPlayer && !PlayersTeamed(ThisPlayer->Player,
player->Player)) {
return;
}
@@ -1012,7 +1013,12 @@
//
// FIXME: show minimap animation for the event.
//
- SetMessageEvent(x, y, "%s", temp);
+ if (player == ThisPlayer) {
+ SetMessageEvent(x, y, "%s", temp);
+ } else {
+ SetMessageEvent(x, y, "(%s): %s", player->Name, temp);
+ }
+
}
//@}
Index: stratagus/src/stratagus/selection.c
diff -u stratagus/src/stratagus/selection.c:1.67
stratagus/src/stratagus/selection.c:1.68
--- stratagus/src/stratagus/selection.c:1.67 Sat Jan 17 02:17:30 2004
+++ stratagus/src/stratagus/selection.c Sat Jan 17 13:12:50 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: selection.c,v 1.67 2004/01/16 15:17:30 wizzard Exp $
+// $Id: selection.c,v 1.68 2004/01/17 02:12:50 wizzard Exp $
//@{
@@ -298,9 +298,9 @@
NumSelected = 1;
CheckUnitToBeDrawn(base);
- // if unit isn't belonging to the player, or is a static unit
+ // if unit isn't belonging to the player or allied player, or is a
static unit
// (like a building), only 1 unit can be selected at the same time.
- if (base->Player != ThisPlayer || !type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(base->Player) ||
!type->SelectableByRectangle) {
return NumSelected;
}
@@ -311,7 +311,7 @@
// different type... idem for tankers
for (i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer || unit->Type != type) {
+ if (!CanSelectMultipleUnits(unit->Player) || unit->Type !=
type) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits doesn't check
this
@@ -378,7 +378,7 @@
}
// if unit isn't belonging to the player, or is a static unit
// (like a building), only 1 unit can be selected at the same time.
- if (base->Player != ThisPlayer || !type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(base->Player) ||
!type->SelectableByRectangle) {
return 0;
}
@@ -392,7 +392,7 @@
// different type... idem for tankers
for (i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer || unit->Type != type) {
+ if (!CanSelectMultipleUnits(unit->Player) || unit->Type !=
type) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits
doesn't check this
@@ -493,7 +493,7 @@
for (n = i = 0; i < num_units; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer ||
!unit->Type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(unit->Player) ||
!unit->Type->SelectableByRectangle) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits doesn't check
this
@@ -582,7 +582,7 @@
// and can be selectable by rectangle.
// In this case, do nothing.
if (NumSelected == 1 &&
- (Selected[0]->Player != ThisPlayer ||
+ (!CanSelectMultipleUnits(Selected[0]->Player) ||
!Selected[0]->Type->SelectableByRectangle)) {
return NumSelected;
}
@@ -661,7 +661,7 @@
//
for (i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer) {
+ if (!CanSelectMultipleUnits(unit->Player)) {
continue;
}
// FIXME: Can we get this?
@@ -745,7 +745,7 @@
for (n = i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer ||
!unit->Type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(unit->Player) ||
!unit->Type->SelectableByRectangle) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits doesn't check
this
@@ -797,7 +797,7 @@
for (n = i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer ||
!unit->Type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(unit->Player) ||
!unit->Type->SelectableByRectangle) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits doesn't check
this
@@ -848,7 +848,7 @@
// and can be selectable by rectangle.
// In this case, do nothing.
if (NumSelected == 1 &&
- (Selected[0]->Player != ThisPlayer ||
+ (!CanSelectMultipleUnits(Selected[0]->Player) ||
!Selected[0]->Type->SelectableByRectangle)) {
return NumSelected;
}
@@ -863,7 +863,8 @@
for (n = i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer ||
!unit->Type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(unit->Player) ||
+ !unit->Type->SelectableByRectangle) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits doesn't check
this
@@ -918,7 +919,7 @@
// and can be selectable by rectangle.
// In this case, do nothing.
if (NumSelected == 1 &&
- (Selected[0]->Player != ThisPlayer ||
+ (!CanSelectMultipleUnits(Selected[0]->Player) ||
!Selected[0]->Type->SelectableByRectangle)) {
return NumSelected;
}
@@ -933,7 +934,8 @@
for (n = i = 0; i < r; ++i) {
unit = table[i];
- if (unit->Player != ThisPlayer ||
!unit->Type->SelectableByRectangle) {
+ if (!CanSelectMultipleUnits(unit->Player) ||
+ !unit->Type->SelectableByRectangle) {
continue;
}
if (UnitUnusable(unit)) { // guess SelectUnits doesn't check
this
@@ -978,7 +980,7 @@
char* ref;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: selection $Id: selection.c,v 1.67
2004/01/16 15:17:30 wizzard Exp $\n\n");
+ CLprintf(file, "--- MODULE: selection $Id: selection.c,v 1.68
2004/01/17 02:12:50 wizzard Exp $\n\n");
CLprintf(file, "SetGroupId(%d)\n", GroupId);
CLprintf(file, "Selection(%d, {", NumSelected);
Index: stratagus/src/ui/botpanel.c
diff -u stratagus/src/ui/botpanel.c:1.101 stratagus/src/ui/botpanel.c:1.102
--- stratagus/src/ui/botpanel.c:1.101 Fri Jan 9 16:44:41 2004
+++ stratagus/src/ui/botpanel.c Sat Jan 17 13:12:51 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: botpanel.c,v 1.101 2004/01/09 05:44:41 jsalmon3 Exp $
+// $Id: botpanel.c,v 1.102 2004/01/17 02:12:51 wizzard Exp $
//@{
@@ -104,7 +104,7 @@
char* cp;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.101 2004/01/09
05:44:41 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.102 2004/01/17
02:12:51 wizzard Exp $\n\n");
for (i = 0; i < NumUnitButtons; ++i) {
CLprintf(file, "(define-button 'pos %d 'level %d 'icon '%s\n",
@@ -379,6 +379,7 @@
{
int i;
int v;
+ Player* player;
const UnitStats* stats;
const ButtonAction* buttons;
char buf[8];
@@ -396,6 +397,8 @@
return;
}
+ player = Selected[0]->Player;
+
for (i = 0; i < TheUI.NumButtonButtons; ++i) {
if (buttons[i].Pos != -1) {
int j;
@@ -499,7 +502,7 @@
}
}
- DrawUnitIcon(ThisPlayer, buttons[i].Icon.Icon,
+ DrawUnitIcon(player, buttons[i].Icon.Icon,
v, TheUI.ButtonButtons[i].X,
TheUI.ButtonButtons[i].Y);
//
@@ -515,7 +518,7 @@
case ButtonTrain:
case ButtonUpgradeTo:
// FIXME: store pointer in
button table!
- stats =
&UnitTypes[v]->Stats[ThisPlayer->Player];
+ stats =
&UnitTypes[v]->Stats[player->Player];
DebugLevel3("Upgrade to %s %d
%d %d %d %d\n" _C_
UnitTypes[v].Ident _C_
UnitTypes[v].Demand _C_
UnitTypes[v]._Costs[GoldCost] _C_
@@ -663,6 +666,7 @@
{
Unit* unit;
char unit_ident[128];
+ Player* player;
ButtonAction* buttonaction;
int z;
int allow;
@@ -696,9 +700,11 @@
}
unit = Selected[0];
+ player = unit->Player;
DebugCheck(unit == NoUnitP);
- if (unit->Player != ThisPlayer) { // foreign unit
+ if (unit->Player != ThisPlayer &&
+ !PlayersTeamed(ThisPlayer->Player, player->Player)) {
// foreign unit
return;
}
@@ -787,15 +793,15 @@
case ButtonUpgradeTo:
case ButtonResearch:
case ButtonBuild:
- allow = CheckDependByIdent(ThisPlayer,
buttonaction->ValueStr);
+ allow = CheckDependByIdent(player,
buttonaction->ValueStr);
if (allow &&
!strncmp(buttonaction->ValueStr, "upgrade-", 8)) {
- allow =
UpgradeIdentAllowed(ThisPlayer,
+ allow =
UpgradeIdentAllowed(player,
buttonaction->ValueStr)
== 'A';
}
break;
case ButtonSpellCast:
- allow =
CheckDependByIdent(ThisPlayer,buttonaction->ValueStr) &&
- UpgradeIdentAllowed(ThisPlayer,
buttonaction->ValueStr) == 'R';
+ allow =
CheckDependByIdent(player,buttonaction->ValueStr) &&
+ UpgradeIdentAllowed(player,
buttonaction->ValueStr) == 'R';
break;
case ButtonUnload:
allow = (Selected[0]->Type->Transporter
&& Selected[0]->InsideCount);
@@ -978,7 +984,7 @@
case ButtonBuild:
// FIXME: store pointer in button table!
type = UnitTypes[CurrentButtons[button].Value];
- if (!PlayerCheckUnitType(ThisPlayer, type)) {
+ if (!PlayerCheckUnitType(Selected[0]->Player, type)) {
SetStatusLine("Select Location");
ClearCosts();
CursorBuilding = type;
@@ -1001,9 +1007,9 @@
!EnableTrainingQueue)) {
NotifyPlayer(Selected[0]->Player, NotifyYellow,
Selected[0]->X,
Selected[0]->Y, "Unit training queue is
full");
- } else if (PlayerCheckLimits(ThisPlayer, type) >= 0 &&
- !PlayerCheckUnitType(ThisPlayer, type))
{
- //PlayerSubUnitType(ThisPlayer,type);
+ } else if (PlayerCheckLimits(Selected[0]->Player, type)
>= 0 &&
+
!PlayerCheckUnitType(Selected[0]->Player, type)) {
+ //PlayerSubUnitType(player,type);
SendCommandTrainUnit(Selected[0], type,
!(KeyModifiers & ModifierShift));
ClearStatusLine();
@@ -1014,10 +1020,10 @@
case ButtonUpgradeTo:
// FIXME: store pointer in button table!
type = UnitTypes[CurrentButtons[button].Value];
- if (!PlayerCheckUnitType(ThisPlayer, type)) {
+ if (!PlayerCheckUnitType(Selected[0]->Player, type)) {
DebugLevel3("Upgrade to %s %d %d\n" _C_
type->Ident _C_
type->_Costs[GoldCost] _C_
type->_Costs[WoodCost]);
- //PlayerSubUnitType(ThisPlayer,type);
+ //PlayerSubUnitType(player,type);
SendCommandUpgradeTo(Selected[0],type,
!(KeyModifiers & ModifierShift));
ClearStatusLine();
@@ -1026,8 +1032,8 @@
break;
case ButtonResearch:
i = CurrentButtons[button].Value;
- if (!PlayerCheckCosts(ThisPlayer, Upgrades[i]. Costs)) {
- //PlayerSubCosts(ThisPlayer,Upgrades[i].Costs);
+ if (!PlayerCheckCosts(Selected[0]->Player, Upgrades[i].
Costs)) {
+ //PlayerSubCosts(player,Upgrades[i].Costs);
SendCommandResearch(Selected[0],&Upgrades[i],
!(KeyModifiers & ModifierShift));
ClearStatusLine();
Index: stratagus/src/ui/mainscr.c
diff -u stratagus/src/ui/mainscr.c:1.153 stratagus/src/ui/mainscr.c:1.154
--- stratagus/src/ui/mainscr.c:1.153 Thu Jan 15 13:09:56 2004
+++ stratagus/src/ui/mainscr.c Sat Jan 17 13:12:51 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mainscr.c,v 1.153 2004/01/15 02:09:56 jsalmon3 Exp $
+// $Id: mainscr.c,v 1.154 2004/01/17 02:12:51 wizzard Exp $
//@{
@@ -213,7 +213,8 @@
x, y);
UiDrawLifeBar(unit, x, y);
- if (unit->Player == ThisPlayer) { // Only for own
units.
+ if (unit->Player == ThisPlayer ||
+ PlayersTeamed(ThisPlayer->Player,
unit->Player->Player)) { // Only for own units.
if (unit->HP && unit->HP < 10000) {
sprintf(buf, "%d/%d", unit->HP,
stats->HitPoints);
VideoDrawTextCentered(x +
(type->Icon.Icon->Width + 7) / 2,
@@ -254,7 +255,8 @@
//
// Show How much a resource has left for owner and neutral.
//
- if (unit->Player == ThisPlayer || unit->Player->Player ==
PlayerNumNeutral) {
+ if (unit->Player == ThisPlayer || unit->Player->Player ==
PlayerNumNeutral ||
+ PlayersTeamed(ThisPlayer->Player, unit->Player->Player)) {
if (type->GivesResource) {
sprintf(buf, "%s Left:",
DefaultResourceNames[type->GivesResource]);
VideoDrawText(x + 108 - VideoTextLength(GameFont, buf),
y + 8 + 78,
@@ -272,7 +274,7 @@
// Only for owning player.
//
#ifndef DEBUG
- if (unit->Player != ThisPlayer) {
+ if (unit->Player != ThisPlayer && !PlayersTeamed(ThisPlayer->Player,
unit->Player->Player)) {
return;
}
#endif
@@ -1139,7 +1141,8 @@
return;
} else {
// FIXME: not correct for enemies units
- if (Selected[0]->Player == ThisPlayer) {
+ if (Selected[0]->Player == ThisPlayer ||
+ PlayersTeamed(ThisPlayer->Player,
Selected[0]->Player->Player)) {
if (Selected[0]->Type->Building &&
(Selected[0]->Orders[0].Action
== UnitActionBuilded ||
Selected[0]->Orders[0].Action == UnitActionResearch ||
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.171 stratagus/src/ui/mouse.c:1.172
--- stratagus/src/ui/mouse.c:1.171 Sat Jan 17 00:39:31 2004
+++ stratagus/src/ui/mouse.c Sat Jan 17 13:12:51 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mouse.c,v 1.171 2004/01/16 13:39:31 wizzard Exp $
+// $Id: mouse.c,v 1.172 2004/01/17 02:12:51 wizzard Exp $
//@{
@@ -124,7 +124,7 @@
// Unit selected isn't owned by the player.
// You can't select your own units + foreign unit(s).
//
- if (Selected[0]->Player != ThisPlayer) {
+ if (!CanSelectMultipleUnits(Selected[0]->Player)) {
return;
}
@@ -139,7 +139,7 @@
dest = UnitUnderCursor;
// don't allow stopping enemy transporters!
- if (dest && dest->Type->Transporter && dest->Player == ThisPlayer) {
+ if (dest && dest->Type->Transporter &&
PlayersTeamed(ThisPlayer->Player, dest->Player->Player)) {
// n0b0dy: So we are clicking on a transporter. We have to:
// 1) Flush the transporters orders.
// 2) Tell the transporter to follow the units. We have to
queue all
@@ -768,8 +768,7 @@
if (CursorOn == CursorOnMap || CursorOn == CursorOnMinimap) {
GameCursor = TheUI.YellowHair.Cursor;
if (UnitUnderCursor) {
- // FIXME: should use IsEnemy here? yes (:
- if (UnitUnderCursor->Player == ThisPlayer) {
+ if (IsAllied(ThisPlayer, UnitUnderCursor)) {
GameCursor = TheUI.GreenHair.Cursor;
} else if (UnitUnderCursor->Player->Player !=
PlayerNumNeutral) {
GameCursor = TheUI.RedHair.Cursor;
@@ -877,7 +876,8 @@
// Move to a transporter.
if ((transporter = UnitUnderCursor) &&
(transporter->Type->Transporter) &&
- (transporter->Player == ThisPlayer)){
+ ((transporter->Player == ThisPlayer) ||
+
PlayersTeamed(ThisPlayer->Player,transporter->Player->Player))) {
SendCommandStopUnit(transporter);
ret = 1;
} else {
@@ -1709,6 +1709,7 @@
int num;
Unit* unit;
+ unit = NULL;
//
// Little threshold
//
@@ -1761,7 +1762,6 @@
//
// Select single unit
//
- unit = NULL;
// cade: cannot select unit on invisible space
// FIXME: johns: only complete invisibile units
if (IsMapFieldVisible(ThisPlayer,
@@ -1790,9 +1790,11 @@
// Don't allow to select own and enemy
units.
// Don't allow mixing buildings
} else if (KeyModifiers & ModifierShift &&
- unit->Player == ThisPlayer &&
!unit->Type->Building &&
+ (unit->Player == ThisPlayer ||
PlayersTeamed(ThisPlayer->Player, unit->Player->Player)) &&
+ !unit->Type->Building &&
(NumSelected != 1 ||
!Selected[0]->Type->Building) &&
- (NumSelected != 1 ||
Selected[0]->Player == ThisPlayer)) {
+ (NumSelected != 1 ||
Selected[0]->Player == ThisPlayer ||
+
PlayersTeamed(ThisPlayer->Player, Selected[0]->Player->Player))) {
num = ToggleSelectUnit(unit);
if (!num) {
SelectionChanged();
@@ -1824,7 +1826,7 @@
} else if (Selected[0]->Burning) {
// FIXME: use GameSounds.Burning
PlayGameSound(SoundIdForName("burning"), MaxSampleVolume);
- } else if (Selected[0]->Player == ThisPlayer ||
+ } else if (Selected[0]->Player == ThisPlayer ||
PlayersTeamed(ThisPlayer->Player, Selected[0]->Player->Player) ||
Selected[0]->Player->Race ==
PlayerRaceNeutral) {
PlayUnitSound(Selected[0],
VoiceSelected);
} else {
@@ -1832,9 +1834,15 @@
}
if (Selected[0]->Player == ThisPlayer) {
char buf[64];
- sprintf(buf, "You have ~<%d~> %s(s)",
-
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type],
- Selected[0]->Type->Name);
+ if
(Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type] > 1) {
+ sprintf(buf, "You have ~<%d~>
%ss",
+
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type],
+
Selected[0]->Type->Name);
+ } else {
+ sprintf(buf, "You have ~<%d~>
%s(s)",
+
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type],
+
Selected[0]->Type->Name);
+ }
SetStatusLine(buf);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/player.h stratagus/player...,
address@hidden <=