[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src action/action_still.c action/comm...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src action/action_still.c action/comm... |
Date: |
23 Jan 2004 05:12:33 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/23 05:12:31
Modified files:
src/action : action_still.c command.c
src/include : actions.h script.h unit.h
src/network : commands.c
src/stratagus : script.c
src/ui : botpanel.c
src/unit : script_unit.c unit.c upgrade.c
Log message:
Apply multi-autocast patch.
Patches:
Index: stratagus/src/action/action_still.c
diff -u stratagus/src/action/action_still.c:1.80
stratagus/src/action/action_still.c:1.81
--- stratagus/src/action/action_still.c:1.80 Sat Jan 17 18:26:07 2004
+++ stratagus/src/action/action_still.c Fri Jan 23 05:12:21 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_still.c,v 1.80 2004/01/17 07:26:07 jsalmon3 Exp $
+// $Id: action_still.c,v 1.81 2004/01/22 18:12:21 nobody_ Exp $
//@{
@@ -61,6 +61,7 @@
const UnitType* type;
Unit* temp;
Unit* goal;
+ int i;
DebugLevel3Fn(" %d\n" _C_ UnitNumber(unit));
@@ -171,10 +172,13 @@
//
// Auto cast spells
//
- if (unit->AutoCastSpell && AutoCastSpell(unit, unit->AutoCastSpell)) {
- return;
+ if (unit->AutoCastSpell) {
+ for (i = 0; i < SpellTypeCount; i++) {
+ if (unit->AutoCastSpell[i] && AutoCastSpell(unit,
SpellTypeTable[i])) {
+ return;
+ }
+ }
}
-
//
// Cowards don't attack unless instructed.
//
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.128
stratagus/src/action/command.c:1.129
--- stratagus/src/action/command.c:1.128 Thu Jan 22 17:18:17 2004
+++ stratagus/src/action/command.c Fri Jan 23 05:12:21 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: command.c,v 1.128 2004/01/22 06:18:17 wizzard Exp $
+// $Id: command.c,v 1.129 2004/01/22 18:12:21 nobody_ Exp $
//@{
@@ -1229,7 +1229,7 @@
** @param unit pointer to unit.
** @param spell Spell type pointer.
*/
-global void CommandAutoSpellCast(Unit* unit, SpellType* spell)
+global void CommandAutoSpellCast(Unit* unit, int spellid)
{
DebugLevel3Fn(": %d auto-spell-casts %s\n" _C_
UnitNumber(unit) _C_ spell->Ident);
@@ -1238,7 +1238,7 @@
// Check if unit is still valid? (NETWORK!)
//
if (!unit->Removed && unit->Orders[0].Action != UnitActionDie) {
- unit->AutoCastSpell = spell;
+ unit->AutoCastSpell[spellid] ^= 1;
}
}
Index: stratagus/src/include/actions.h
diff -u stratagus/src/include/actions.h:1.63
stratagus/src/include/actions.h:1.64
--- stratagus/src/include/actions.h:1.63 Thu Jan 15 09:31:04 2004
+++ stratagus/src/include/actions.h Fri Jan 23 05:12:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: actions.h,v 1.63 2004/01/14 22:31:04 nobody_ Exp $
+// $Id: actions.h,v 1.64 2004/01/22 18:12:23 nobody_ Exp $
#ifndef __ACTIONS_H__
#define __ACTIONS_H__
@@ -124,7 +124,7 @@
extern void CommandSpellCast(Unit* unit,int x,int y,Unit* dest
,SpellType* spell,int flush);
/// Prepare command auto spellcast
-extern void CommandAutoSpellCast(Unit* unit,SpellType* spell);
+extern void CommandAutoSpellCast(Unit* unit, int spellid);
/// Prepare diplomacy command
extern void CommandDiplomacy(int player,int state,int opponent);
/// Prepare shared vision command
Index: stratagus/src/include/script.h
diff -u stratagus/src/include/script.h:1.56 stratagus/src/include/script.h:1.57
--- stratagus/src/include/script.h:1.56 Wed Jan 21 04:40:05 2004
+++ stratagus/src/include/script.h Fri Jan 23 05:12:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script.h,v 1.56 2004/01/20 17:40:05 nobody_ Exp $
+// $Id: script.h,v 1.57 2004/01/22 18:12:23 nobody_ Exp $
#ifndef __SCRIPT_H__
#define __SCRIPT_H__
@@ -126,14 +126,17 @@
----------------------------------------------------------------------------*/
/// Quick way to fail in a function. You can use _C_ like in DebugLevelx
-#ifdef DEBUG
#define LuaError(l, args) \
{ lua_pushfstring(l, args); lua_error(l); return 0; }
-#else
- /// Save on memory.
-#define LuaError(l, args) \
- { lua_pushstring(l, "Lua error"); lua_error(l); return 0; }
-#endif
+
+ /// Quick way to check the number of arguments
+#define LuaCheckArgCount(l, argcount) \
+{ \
+ if (lua_gettop(l) != (argcount)) { \
+ LuaError(l, "Wrong number of arguments, expected %d got %d" \
+ _C_ (argcount) _C_ lua_gettop(l)); \
+ } \
+}
//
// Pushing 0 as a string to lua is ok. strdup-ing 0 is not.
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.250 stratagus/src/include/unit.h:1.251
--- stratagus/src/include/unit.h:1.250 Thu Jan 22 17:18:20 2004
+++ stratagus/src/include/unit.h Fri Jan 23 05:12:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.h,v 1.250 2004/01/22 06:18:20 wizzard Exp $
+// $Id: unit.h,v 1.251 2004/01/22 18:12:23 nobody_ Exp $
#ifndef __UNIT_H__
#define __UNIT_H__
@@ -600,7 +600,7 @@
Order Orders[MAX_ORDERS]; ///
orders to process
Order SavedOrder;
/// order to continue after current
Order NewOrder;
/// order for new trained units
- struct _spell_type_* AutoCastSpell; /// spell to auto cast
+ char *AutoCastSpell; ///
spells to auto cast
union _order_data_ {
struct _order_move_ {
Index: stratagus/src/network/commands.c
diff -u stratagus/src/network/commands.c:1.92
stratagus/src/network/commands.c:1.93
--- stratagus/src/network/commands.c:1.92 Mon Jan 19 09:36:27 2004
+++ stratagus/src/network/commands.c Fri Jan 23 05:12:24 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: commands.c,v 1.92 2004/01/18 22:36:27 nobody_ Exp $
+// $Id: commands.c,v 1.93 2004/01/22 18:12:24 nobody_ Exp $
//@{
@@ -173,7 +173,7 @@
replay->Comment1 = strdup("Generated by Stratagus Version " VERSION "");
replay->Comment2 = strdup("Visit http://Stratagus.Org for more
information");
- replay->Comment3 = strdup("$Id: commands.c,v 1.92 2004/01/18 22:36:27
nobody_ Exp $");
+ replay->Comment3 = strdup("$Id: commands.c,v 1.93 2004/01/22 18:12:24
nobody_ Exp $");
if (GameSettings.NetGameType == SettingsSinglePlayerGame) {
replay->Type = ReplaySinglePlayer;
@@ -1386,7 +1386,7 @@
if (NetworkFildes == (Socket)-1) {
CommandLog("auto-spell-cast", unit, FlushCommands, on, -1,
NoUnitP,
NULL, spellid);
- CommandAutoSpellCast(unit, on ? SpellTypeTable[spellid] : NULL);
+ CommandAutoSpellCast(unit, spellid);
} else {
NetworkSendCommand(MessageCommandSpellCast + spellid,
unit, on, -1, NoUnitP, NULL, FlushCommands);
@@ -1658,7 +1658,7 @@
CommandSpellCast(unit, x, y, dest,
SpellTypeTable[id], status);
} else {
CommandLog("auto-spell-cast", unit, status, x,
-1, NoUnitP, NULL, id);
- CommandAutoSpellCast(unit, x ?
SpellTypeTable[id] : NULL);
+ CommandAutoSpellCast(unit, x);
}
break;
}
Index: stratagus/src/stratagus/script.c
diff -u stratagus/src/stratagus/script.c:1.166
stratagus/src/stratagus/script.c:1.167
--- stratagus/src/stratagus/script.c:1.166 Fri Jan 23 04:07:28 2004
+++ stratagus/src/stratagus/script.c Fri Jan 23 05:12:26 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script.c,v 1.166 2004/01/22 17:07:28 nobody_ Exp $
+// $Id: script.c,v 1.167 2004/01/22 18:12:26 nobody_ Exp $
//@{
@@ -1117,22 +1117,18 @@
*/
local int ScriptSyncRand(lua_State* l)
{
- if (lua_gettop(l) != 1) {
- LuaError(l, "Wrong argument count, %d got %d expected" _C_
lua_gettop(l) _C_ 1);
- }
+ LuaCheckArgCount(l, 1);
lua_pushnumber(l, SyncRand() % (int)LuaToNumber(l, -1));
return 1;
}
/**
-** Get a value from the Stratagus truly"" random number generator.
+** Get a value from the Stratagus "truly" random number generator.
*/
local int ScriptMyRand(lua_State* l)
{
- if (lua_gettop(l)){
- LuaError(l, "Wrong arguments");
- }
- lua_pushnumber(l, MyRand());
+ LuaCheckArgCount(l, 1);
+ lua_pushnumber(l, MyRand() % (int)LuaToNumber(l, -1));
return 1;
}
@@ -1367,7 +1363,7 @@
}
fprintf(fd, "--- -----------------------------------------\n");
- fprintf(fd, "--- $Id: script.c,v 1.166 2004/01/22 17:07:28 nobody_ Exp
$\n");
+ fprintf(fd, "--- $Id: script.c,v 1.167 2004/01/22 18:12:26 nobody_ Exp
$\n");
fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
@@ -1391,7 +1387,7 @@
}
fprintf(fd, "--- -----------------------------------------\n");
- fprintf(fd, "--- $Id: script.c,v 1.166 2004/01/22 17:07:28 nobody_ Exp
$\n");
+ fprintf(fd, "--- $Id: script.c,v 1.167 2004/01/22 18:12:26 nobody_ Exp
$\n");
// Global options
if (OriginalFogOfWar) {
Index: stratagus/src/ui/botpanel.c
diff -u stratagus/src/ui/botpanel.c:1.103 stratagus/src/ui/botpanel.c:1.104
--- stratagus/src/ui/botpanel.c:1.103 Mon Jan 19 09:36:30 2004
+++ stratagus/src/ui/botpanel.c Fri Jan 23 05:12:27 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: botpanel.c,v 1.103 2004/01/18 22:36:30 nobody_ Exp $
+// $Id: botpanel.c,v 1.104 2004/01/22 18:12:27 nobody_ Exp $
//@{
@@ -104,7 +104,7 @@
char* cp;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.103 2004/01/18
22:36:30 nobody_ Exp $\n\n");
+ CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.104 2004/01/22
18:12:27 nobody_ Exp $\n\n");
for (i = 0; i < NumUnitButtons; ++i) {
CLprintf(file, "(define-button 'pos %d 'level %d 'icon '%s\n",
@@ -485,8 +485,7 @@
break;
case ButtonSpellCast:
for (j = 0; j < NumSelected;
++j) {
- if
(Selected[j]->AutoCastSpell !=
-
SpellTypeTable[buttons[i].Value]) {
+ if
(Selected[j]->AutoCastSpell[buttons[i].Value] != 1) {
break;
}
}
@@ -888,10 +887,10 @@
if (CurrentButtons[button].Action == ButtonSpellCast &&
(KeyModifiers & ModifierControl)) {
int autocast;
- SpellType* spell;
+ int spellId;
- spell =
SpellTypeTable[CurrentButtons[button].Value];
- if (!CanAutoCastSpell(spell)) {
+ spellId = CurrentButtons[button].Value;
+ if (!CanAutoCastSpell(SpellTypeTable[spellId]))
{
PlayGameSound(GameSounds.PlacementError.Sound,
MaxSampleVolume);
break;
@@ -901,15 +900,15 @@
// If any selected unit doesn't have autocast
on turn it on
// for everyone
for (i = 0; i < NumSelected; ++i) {
- if (Selected[i]->AutoCastSpell !=
spell) {
+ if (Selected[i]->AutoCastSpell[spellId]
== 0) {
autocast = 1;
break;
}
}
for (i = 0; i < NumSelected; ++i) {
- if (!autocast ||
Selected[i]->AutoCastSpell != spell) {
-
SendCommandAutoSpellCast(Selected[i],
-
CurrentButtons[button].Value, autocast);
+ if (Selected[i]->AutoCastSpell[spellId]
!= autocast) {
+
SendCommandAutoSpellCast(Selected[i],
+ spellId, autocast);
}
}
} else {
Index: stratagus/src/unit/script_unit.c
diff -u stratagus/src/unit/script_unit.c:1.96
stratagus/src/unit/script_unit.c:1.97
--- stratagus/src/unit/script_unit.c:1.96 Wed Jan 21 11:49:19 2004
+++ stratagus/src/unit/script_unit.c Fri Jan 23 05:12:28 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_unit.c,v 1.96 2004/01/21 00:49:19 jsalmon3 Exp $
+// $Id: script_unit.c,v 1.97 2004/01/22 18:12:28 nobody_ Exp $
//@{
@@ -932,7 +932,8 @@
unit->Goal = UnitSlots[(int)LuaToNumber(l, j + 1)];
} else if (!strcmp(value, "auto-cast")) {
s = LuaToString(l, j + 1);
- unit->AutoCastSpell = SpellTypeByIdent(s);
+ DebugCheck(SpellTypeByIdent(s)->Slot == -1);
+ unit->AutoCastSpell[SpellTypeByIdent(s)->Slot] = 1;
} else {
// FIXME: this leaves a half initialized unit
lua_pushfstring(l, "Unsupported tag: %s", value);
Index: stratagus/src/unit/unit.c
diff -u stratagus/src/unit/unit.c:1.368 stratagus/src/unit/unit.c:1.369
--- stratagus/src/unit/unit.c:1.368 Thu Jan 22 17:18:24 2004
+++ stratagus/src/unit/unit.c Fri Jan 23 05:12:29 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.c,v 1.368 2004/01/22 06:18:24 wizzard Exp $
+// $Id: unit.c,v 1.369 2004/01/22 18:12:29 nobody_ Exp $
//@{
@@ -326,6 +326,8 @@
if (type->CanCastSpell) {
unit->Mana = (type->_MaxMana * MAGIC_FOR_NEW_UNITS) / 100;
+ unit->AutoCastSpell = malloc(SpellTypeCount);
+ memset(unit->AutoCastSpell, 0, SpellTypeCount);
}
unit->Active = 1;
@@ -3722,7 +3724,11 @@
CLprintf(file, ",\n \"goal\", %d", UnitNumber(unit->Goal));
}
if (unit->AutoCastSpell) {
- CLprintf(file, ",\n \"auto-cast\", \"%s\"",
unit->AutoCastSpell->Ident);
+ for (i = 0; i < SpellTypeCount; i++) {
+ if (unit->AutoCastSpell[i]) {
+ CLprintf(file, ",\n \"auto-cast\", \"%s\"",
SpellTypeTable[i]->Ident);
+ }
+ }
}
CLprintf(file, ")\n");
@@ -3743,7 +3749,7 @@
int j;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.368 2004/01/22
06:18:24 wizzard Exp $\n\n");
+ CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.369 2004/01/22
18:12:29 nobody_ Exp $\n\n");
#if 0
//
@@ -3829,6 +3835,7 @@
// Free memory for all units in unit table.
//
for (table = Units; table < &Units[NumUnits]; ++table) {
+ free((*table)->AutoCastSpell);
free(*table);
*table = NULL;
}
Index: stratagus/src/unit/upgrade.c
diff -u stratagus/src/unit/upgrade.c:1.74 stratagus/src/unit/upgrade.c:1.75
--- stratagus/src/unit/upgrade.c:1.74 Wed Jan 21 05:48:14 2004
+++ stratagus/src/unit/upgrade.c Fri Jan 23 05:12:30 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: upgrade.c,v 1.74 2004/01/20 18:48:14 jsalmon3 Exp $
+// $Id: upgrade.c,v 1.75 2004/01/22 18:12:30 nobody_ Exp $
//@{
@@ -45,6 +45,7 @@
#include "interface.h"
#include "map.h"
#include "script.h"
+#include "spells.h"
#include "myendian.h"
@@ -548,7 +549,7 @@
int j;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: upgrades $Id: upgrade.c,v 1.74 2004/01/20
18:48:14 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: upgrades $Id: upgrade.c,v 1.75 2004/01/22
18:12:30 nobody_ Exp $\n\n");
//
// Save all upgrades
@@ -1253,6 +1254,8 @@
UpdateForNewUnit(unit, 1);
if (dst->CanCastSpell) {
unit->Mana = MAGIC_FOR_NEW_UNITS;
+ unit->AutoCastSpell = malloc(SpellTypeCount);
+ memset(unit->AutoCastSpell, 0, SpellTypeCount);
}
if ((unit->CurrentSightRange !=
dst->Stats[player->Player].SightRange ||
src->TileWidth != dst->TileWidth ||
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src action/action_still.c action/comm...,
address@hidden <=