[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src action/action_build.c action/acti...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src action/action_build.c action/acti... |
Date: |
19 Jan 2004 09:36:36 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/19 09:36:32
Modified files:
src/action : action_build.c action_upgradeto.c command.c
src/ai : ai.c ai_force.c ai_magic.c ai_resource.c
script_ai.c
src/game : trigger.c
src/include : missile.h spells.h stratagus.h unittype.h
src/missile : missile.c script_missile.c
src/network : commands.c network.c
src/stratagus : player.c script_spell.c spells.c
src/ui : botpanel.c mouse.c
src/unit : depend.c script_unit.c script_unittype.c unit.c
unit_find.c unittype.c upgrade.c
Log message:
Cleanup.
Patches:
Index: stratagus/src/action/action_build.c
diff -u stratagus/src/action/action_build.c:1.108
stratagus/src/action/action_build.c:1.109
--- stratagus/src/action/action_build.c:1.108 Sat Jan 17 18:26:07 2004
+++ stratagus/src/action/action_build.c Mon Jan 19 09:36:22 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_build.c,v 1.108 2004/01/17 07:26:07 jsalmon3 Exp $
+// $Id: action_build.c,v 1.109 2004/01/18 22:36:22 nobody_ Exp $
//@{
@@ -250,7 +250,7 @@
*/
// HACK: the building is not ready yet
- build->Player->UnitTypesCount[type->Type]--;
+ build->Player->UnitTypesCount[type->Slot]--;
stats = build->Stats;
@@ -356,7 +356,7 @@
}
unit->Orders[0].Action = UnitActionStill;
// HACK: the building is ready now
- unit->Player->UnitTypesCount[type->Type]++;
+ unit->Player->UnitTypesCount[type->Slot]++;
unit->Constructed = 0;
if (unit->Frame < 0) {
unit->Frame = -1;
Index: stratagus/src/action/action_upgradeto.c
diff -u stratagus/src/action/action_upgradeto.c:1.45
stratagus/src/action/action_upgradeto.c:1.46
--- stratagus/src/action/action_upgradeto.c:1.45 Fri Jan 16 02:15:07 2004
+++ stratagus/src/action/action_upgradeto.c Mon Jan 19 09:36:22 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_upgradeto.c,v 1.45 2004/01/15 15:15:07 nobody_ Exp $
+// $Id: action_upgradeto.c,v 1.46 2004/01/18 22:36:22 nobody_ Exp $
//@{
@@ -76,14 +76,14 @@
unit->HP += stats->HitPoints -
unit->Type->Stats[player->Player].HitPoints;
// don't have such unit now
- player->UnitTypesCount[unit->Type->Type]--;
+ player->UnitTypesCount[unit->Type->Slot]--;
DebugCheck(unit->Type->TileWidth != type->TileWidth ||
unit->Type->TileHeight != type->TileHeight);
unit->Type = type;
unit->Stats = (UnitStats*)stats;
// and we have new one...
- player->UnitTypesCount[unit->Type->Type]++;
+ player->UnitTypesCount[unit->Type->Slot]++;
UpdateForNewUnit(unit, 1);
NotifyPlayer(player, NotifyGreen, unit->X, unit->Y,
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.125
stratagus/src/action/command.c:1.126
--- stratagus/src/action/command.c:1.125 Thu Jan 15 09:31:02 2004
+++ stratagus/src/action/command.c Mon Jan 19 09:36:22 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: command.c,v 1.125 2004/01/14 22:31:02 nobody_ Exp $
+// $Id: command.c,v 1.126 2004/01/18 22:36:22 nobody_ Exp $
//@{
@@ -1193,8 +1193,8 @@
#endif
DebugLevel0Fn(": %d casts %s at %d %d on %d\n" _C_
- UnitNumber(unit) _C_ spell->IdentName _C_ x _C_ y _C_ dest ?
UnitNumber(dest) : 0);
- DebugCheck(!unit->Type->CanCastSpell[spell->Ident]);
+ UnitNumber(unit) _C_ spell->Ident _C_ x _C_ y _C_ dest ?
UnitNumber(dest) : 0);
+ DebugCheck(!unit->Type->CanCastSpell[spell->Slot]);
//
// Check if unit is still valid? (NETWORK!)
Index: stratagus/src/ai/ai.c
diff -u stratagus/src/ai/ai.c:1.111 stratagus/src/ai/ai.c:1.112
--- stratagus/src/ai/ai.c:1.111 Sat Jan 17 05:06:22 2004
+++ stratagus/src/ai/ai.c Mon Jan 19 09:36:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai.c,v 1.111 2004/01/16 18:06:22 jsalmon3 Exp $
+// $Id: ai.c,v 1.112 2004/01/18 22:36:23 nobody_ Exp $
//@{
@@ -221,7 +221,7 @@
// Count the already made build requests.
//
for (queue = AiPlayer->UnitTypeBuilded; queue; queue = queue->Next) {
- counter[queue->Type->Type] += queue->Want;
+ counter[queue->Type->Slot] += queue->Want;
DebugLevel3Fn("Already in build queue: %s %d/%d\n" _C_
queue->Type->Ident _C_ queue->Made _C_ queue->Want);
}
@@ -232,7 +232,7 @@
n = AiPlayer->Player->TotalNumUnits;
for (i = 0; i < n; ++i) {
if (!AiPlayer->Player->Units[i]->Active) {
- counter[AiPlayer->Player->Units[i]->Type->Type]--;
+ counter[AiPlayer->Player->Units[i]->Type->Slot]--;
DebugLevel3Fn("Removing non active unit: %s\n" _C_
AiPlayer->Player->Units[i]->Type->Ident);
}
@@ -244,7 +244,7 @@
//
n = AiPlayer->UnitTypeRequestsCount;
for (i = 0; i < n; ++i) {
- t = AiPlayer->UnitTypeRequests[i].Table[0]->Type;
+ t = AiPlayer->UnitTypeRequests[i].Table[0]->Slot;
x = AiPlayer->UnitTypeRequests[i].Count;
//
@@ -255,7 +255,7 @@
DebugLevel3Fn("Equivalence for %s\n" _C_
AiPlayer->UnitTypeRequests[i].Table[0]->Ident);
for (j = 0; j < AiHelpers.Equiv[t]->Count; ++j) {
- e +=
unit_types_count[AiHelpers.Equiv[t]->Table[j]->Type];
+ e +=
unit_types_count[AiHelpers.Equiv[t]->Table[j]->Slot];
}
}
@@ -276,7 +276,7 @@
const AiUnit* unit;
for (unit = AiPlayer->Force[i].Units; unit; unit = unit->Next) {
- attacking[unit->Unit->Type->Type]++;
+ attacking[unit->Unit->Type->Slot]++;
}
}
@@ -293,7 +293,7 @@
}
for (aiut = AiPlayer->Force[i].UnitTypes; aiut; aiut =
aiut->Next) {
- t = aiut->Type->Type;
+ t = aiut->Type->Slot;
x = aiut->Want;
if (x > unit_types_count[t] + counter[t] -
attacking[t]) { // Request it.
DebugLevel2Fn("Force %d need %s * %d\n" _C_ i
_C_ aiut->Type->
@@ -312,7 +312,7 @@
//
n = AiPlayer->UpgradeToRequestsCount;
for (i = 0; i < n; ++i) {
- t = AiPlayer->UpgradeToRequests[i]->Type;
+ t = AiPlayer->UpgradeToRequests[i]->Slot;
x = 1;
//
@@ -323,7 +323,7 @@
DebugLevel3Fn("Equivalence for %s\n" _C_
AiPlayer->UpgradeToRequests[i]->
Ident);
for (j = 0; j < AiHelpers.Equiv[t]->Count; ++j) {
- e +=
unit_types_count[AiHelpers.Equiv[t]->Table[j]->Type];
+ e +=
unit_types_count[AiHelpers.Equiv[t]->Table[j]->Slot];
}
}
@@ -403,7 +403,7 @@
for (f = i = 0; i < n; ++i) {
if (table[i]) {
for (j = 0; j < table[i]->Count; ++j) {
- if (table[i]->Table[j]->Type == t) {
+ if (table[i]->Table[j]->Slot == t) {
if (!f) {
CLprintf(file, "\n
(list '%s '%s\n ", name,
UnitTypes[t]->Ident);
@@ -481,7 +481,7 @@
for (f = i = 0; i < n; ++i) {
if (table[i]) {
for (j = 0; j < table[i]->Count; ++j) {
- if (table[i]->Table[j]->Type == t) {
+ if (table[i]->Table[j]->Slot == t) {
if (!f) {
CLprintf(file, "\n
(list '%s '%s\n ", name,
UnitTypes[t]->Ident);
@@ -522,7 +522,7 @@
for (f = i = 0; i < n; ++i) {
if (table[i]) {
for (j = 0; j < table[i]->Count; ++j) {
- if (table[i]->Table[j]->Type == t) {
+ if (table[i]->Table[j]->Slot == t) {
if (!f) {
CLprintf(file, "\n
(list '%s '%s\n ", name,
UnitTypes[t]->Ident);
@@ -820,7 +820,7 @@
{
CLprintf(file, "\n--- -----------------------------------------\n");
CLprintf(file,
- "--- MODULE: AI $Id: ai.c,v 1.111 2004/01/16 18:06:22 jsalmon3
Exp $\n\n");
+ "--- MODULE: AI $Id: ai.c,v 1.112 2004/01/18 22:36:23 nobody_
Exp $\n\n");
#if 0
SaveAiTypesWcName(file);
SaveAiHelper(file);
@@ -1168,7 +1168,7 @@
//
equivnb = AiFindUnitTypeEquiv(type, equivs);
- for (i = 0; i < AiHelpers.Equiv[type->Type]->Count; ++i) {
+ for (i = 0; i < AiHelpers.Equiv[type->Slot]->Count; ++i) {
if (AiReduceMadeInBuilded2(pai, UnitTypes[equivs[i]])) {
return;
}
Index: stratagus/src/ai/ai_force.c
diff -u stratagus/src/ai/ai_force.c:1.47 stratagus/src/ai/ai_force.c:1.48
--- stratagus/src/ai/ai_force.c:1.47 Fri Jan 2 08:24:03 2004
+++ stratagus/src/ai/ai_force.c Mon Jan 19 09:36:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai_force.c,v 1.47 2004/01/01 21:24:03 jsalmon3 Exp $
+// $Id: ai_force.c,v 1.48 2004/01/18 22:36:23 nobody_ Exp $
//@{
@@ -82,8 +82,8 @@
int replace;
int i;
- find = UnitTypeEquivs[a->Type];
- replace = UnitTypeEquivs[b->Type];
+ find = UnitTypeEquivs[a->Slot];
+ replace = UnitTypeEquivs[b->Slot];
// Always record equivalences with the lowest unittype.
if (find < replace) {
@@ -115,7 +115,7 @@
int search;
int count;
- search = UnitTypeEquivs[unittype->Type];
+ search = UnitTypeEquivs[unittype->Slot];
count = 0;
for (i = 0; i < UnitTypeMax + 1; ++i) {
@@ -229,7 +229,7 @@
aiunit = AiPlayer->Force[force].Units;
while (aiunit) {
// FIXME: Should I use equivalent unit types?
- counter[aiunit->Unit->Type->Type]++;
+ counter[aiunit->Unit->Type->Slot]++;
aiunit = aiunit->Next;
}
@@ -239,11 +239,11 @@
AiPlayer->Force[force].Completed = 1;
aitype = AiPlayer->Force[force].UnitTypes;
while (aitype) {
- if (aitype->Want > counter[aitype->Type->Type]) {
+ if (aitype->Want > counter[aitype->Type->Slot]) {
DebugLevel3Fn("%d: missing %s.\n" _C_ force _C_
aitype->Type->Ident);
AiPlayer->Force[force].Completed = 0;
}
- counter[aitype->Type->Type] -= aitype->Want;
+ counter[aitype->Type->Slot] -= aitype->Want;
aitype = aitype->Next;
}
@@ -253,9 +253,9 @@
if (!AiPlayer->Force[force].Attacking) {
prev = &AiPlayer->Force[force].Units;
while ((aiunit = *prev)) {
- if (counter[aiunit->Unit->Type->Type] > 0) {
+ if (counter[aiunit->Unit->Type->Slot] > 0) {
DebugLevel3Fn("Release unit %s\n" _C_
aiunit->Unit->Type->Ident);
- counter[aiunit->Unit->Type->Type]--;
+ counter[aiunit->Unit->Type->Slot]--;
RefsDecrease(aiunit->Unit);
*prev = aiunit->Next;
free(aiunit);
@@ -305,7 +305,7 @@
aiunit = AiPlayer->Force[force].Units;
while (aiunit) {
// FIXME: Should I use equivalent unit types?
- counter[aiunit->Unit->Type->Type]++;
+ counter[aiunit->Unit->Type->Slot]++;
aiunit = aiunit->Next;
}
@@ -316,9 +316,9 @@
AiPlayer->Force[force].Completed = 1;
aitype = AiPlayer->Force[force].UnitTypes;
while (aitype) {
- if (aitype->Want > counter[aitype->Type->Type]) {
+ if (aitype->Want > counter[aitype->Type->Slot]) {
if (type == aitype->Type) {
- if (aitype->Want - 1 >
counter[aitype->Type->Type]) {
+ if (aitype->Want - 1 >
counter[aitype->Type->Slot]) {
AiPlayer->Force[force].Completed = 0;
}
flag = 1;
Index: stratagus/src/ai/ai_magic.c
diff -u stratagus/src/ai/ai_magic.c:1.23 stratagus/src/ai/ai_magic.c:1.24
--- stratagus/src/ai/ai_magic.c:1.23 Sun Dec 14 21:15:00 2003
+++ stratagus/src/ai/ai_magic.c Mon Jan 19 09:36:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai_magic.c,v 1.23 2003/12/14 10:15:00 wizzard Exp $
+// $Id: ai_magic.c,v 1.24 2004/01/18 22:36:23 nobody_ Exp $
//@{
@@ -75,14 +75,14 @@
for (j = 0; j < SpellTypeCount; ++j) {
// Check if we can cast this spell.
SpellIsAvailable checks for upgrades.
if (unit->Type->CanCastSpell[j] &&
SpellIsAvailable(player, j) &&
- (SpellTypeById(j)->AutoCast ||
SpellTypeById(j)->AICast)) {
+ (SpellTypeTable[j]->AutoCast ||
SpellTypeTable[j]->AICast)) {
#ifdef DEBUG
success = // Follow on next line
(AutoCastSpell).
#endif
- AutoCastSpell(unit,
SpellTypeById(j));
+ AutoCastSpell(unit,
SpellTypeTable[j]);
DebugLevel3Fn("Mage '%s' cast '%s' :
%s\n" _C_
unit->Type->Ident _C_
- SpellTypeById(j)->Ident _C_
success ? "success" : "fail");
+ SpellTypeTable[j]->Ident _C_
success ? "success" : "fail");
}
}
}
Index: stratagus/src/ai/ai_resource.c
diff -u stratagus/src/ai/ai_resource.c:1.88 stratagus/src/ai/ai_resource.c:1.89
--- stratagus/src/ai/ai_resource.c:1.88 Thu Jan 15 09:31:03 2004
+++ stratagus/src/ai/ai_resource.c Mon Jan 19 09:36:23 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai_resource.c,v 1.88 2004/01/14 22:31:03 nobody_ Exp $
+// $Id: ai_resource.c,v 1.89 2004/01/18 22:36:23 nobody_ Exp $
//@{
@@ -319,7 +319,7 @@
//
memset(counter, 0, sizeof(counter));
for (queue = AiPlayer->UnitTypeBuilded; queue; queue = queue->Next) {
- counter[queue->Type->Type] += queue->Want;
+ counter[queue->Type->Slot] += queue->Want;
}
//
@@ -328,7 +328,7 @@
n = AiHelpers.UnitLimit[0]->Count;
for (i = 0; i < n; ++i) {
type = AiHelpers.UnitLimit[0]->Table[i];
- if (counter[type->Type]) { // Already ordered.
+ if (counter[type->Slot]) { // Already ordered.
return;
}
@@ -416,7 +416,7 @@
AiUnitTypeTable* const* tablep;
const AiUnitTypeTable* table;
- if (UnitIdAllowed(AiPlayer->Player, type->Type) == 0) {
+ if (UnitIdAllowed(AiPlayer->Player, type->Slot) == 0) {
DebugLevel0Fn("Can't build `%s' now\n" _C_ type->Ident);
return 0;
}
@@ -430,11 +430,11 @@
n = AiHelpers.TrainCount;
tablep = AiHelpers.Train;
}
- if (type->Type > n) { // Oops not known.
+ if (type->Slot > n) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
return 0;
}
- table = tablep[type->Type];
+ table = tablep[type->Slot];
if (!table) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
return 0;
@@ -447,7 +447,7 @@
//
// The type for builder/trainer is available
//
- result += unit_count[table->Table[i]->Type];
+ result += unit_count[table->Table[i]->Slot];
}
return result;
}
@@ -493,11 +493,11 @@
n = AiHelpers.TrainCount;
tablep = AiHelpers.Train;
}
- if (type->Type > n) { // Oops not known.
+ if (type->Slot > n) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_
type->Ident);
continue;
}
- table = tablep[type->Type];
+ table = tablep[type->Slot];
if (!table) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_
type->Ident);
continue;
@@ -509,7 +509,7 @@
//
// The type for builder/trainer is available
//
- if (unit_count[table->Table[i]->Type]) {
+ if (unit_count[table->Table[i]->Slot]) {
DebugLevel3("Found a builder for a %s.\n" _C_
type->ident);
if (type->Building) {
if (AiBuildBuilding(table->Table[i],
type)) {
@@ -614,7 +614,7 @@
//
// The type is available
//
- if (unit_count[table->Table[i]->Type]) {
+ if (unit_count[table->Table[i]->Slot]) {
if (AiResearchUpgrade(table->Table[i], upgrade)) {
return;
}
@@ -696,11 +696,11 @@
n = AiHelpers.UpgradeCount;
tablep = AiHelpers.Upgrade;
- if (type->Type > n) { // Oops not known.
+ if (type->Slot > n) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
return;
}
- table = tablep[type->Type];
+ table = tablep[type->Slot];
if (!table) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
return;
@@ -712,7 +712,7 @@
//
// The type is available
//
- if (unit_count[table->Table[i]->Type]) {
+ if (unit_count[table->Table[i]->Slot]) {
if (AiUpgradeTo(table->Table[i], type)) {
return;
}
@@ -1240,11 +1240,11 @@
n = AiHelpers.RepairCount;
tablep = AiHelpers.Repair;
type = unit->Type;
- if (type->Type > n) { // Oops not known.
+ if (type->Slot > n) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
return 0;
}
- table = tablep[type->Type];
+ table = tablep[type->Slot];
if (!table) { // Oops not known.
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
return 0;
@@ -1256,7 +1256,7 @@
//
// The type is available
//
- if (unit_count[table->Table[i]->Type]) {
+ if (unit_count[table->Table[i]->Slot]) {
if (AiRepairBuilding(table->Table[i], unit)) {
return 1;
}
Index: stratagus/src/ai/script_ai.c
diff -u stratagus/src/ai/script_ai.c:1.99 stratagus/src/ai/script_ai.c:1.100
--- stratagus/src/ai/script_ai.c:1.99 Sat Jan 17 05:06:23 2004
+++ stratagus/src/ai/script_ai.c Mon Jan 19 09:36:24 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_ai.c,v 1.99 2004/01/16 18:06:23 jsalmon3 Exp $
+// $Id: script_ai.c,v 1.100 2004/01/18 22:36:24 nobody_ Exp $
//@{
@@ -239,18 +239,18 @@
switch (what) {
case 0: // build
AiHelperSetupTable(&AiHelpers.BuildCount, &AiHelpers.Build,
- type->Type);
- AiHelperInsert(AiHelpers.Build +
type->Type, base);
+ type->Slot);
+ AiHelperInsert(AiHelpers.Build +
type->Slot, base);
break;
case 1: // train
AiHelperSetupTable(&AiHelpers.TrainCount, &AiHelpers.Train,
- type->Type);
- AiHelperInsert(AiHelpers.Train +
type->Type, base);
+ type->Slot);
+ AiHelperInsert(AiHelpers.Train +
type->Slot, base);
break;
case 2: // upgrade
AiHelperSetupTable(&AiHelpers.UpgradeCount, &AiHelpers.Upgrade,
- type->Type);
- AiHelperInsert(AiHelpers.Upgrade +
type->Type, base);
+ type->Slot);
+ AiHelperInsert(AiHelpers.Upgrade +
type->Slot, base);
break;
case 3: // research
AiHelperSetupTable(&AiHelpers.ResearchCount, &AiHelpers.Research,
@@ -264,15 +264,15 @@
break;
case 5: // equivalence
AiHelperSetupTable(&AiHelpers.EquivCount, &AiHelpers.Equiv,
- base->Type);
- AiHelperInsert(AiHelpers.Equiv +
base->Type, type);
+ base->Slot);
+ AiHelperInsert(AiHelpers.Equiv +
base->Slot, type);
AiNewUnitTypeEquiv(base, type);
break;
case 6: // repair
AiHelperSetupTable(&AiHelpers.RepairCount, &AiHelpers.Repair,
- type->Type);
- AiHelperInsert(AiHelpers.Repair +
type->Type, base);
+ type->Slot);
+ AiHelperInsert(AiHelpers.Repair +
type->Slot, base);
break;
}
}
@@ -656,7 +656,7 @@
//
// Look if we have this unit-type.
//
- if (unit_types_count[type->Type]) {
+ if (unit_types_count[type->Slot]) {
lua_pushboolean(l, 0);
return 1;
}
@@ -664,10 +664,10 @@
//
// Look if we have equivalent unit-types.
//
- if (type->Type < AiHelpers.EquivCount &&
AiHelpers.Equiv[type->Type]) {
+ if (type->Slot < AiHelpers.EquivCount &&
AiHelpers.Equiv[type->Slot]) {
DebugLevel3Fn("Equivalence for %s\n" _C_ type->Ident);
- for (j = 0; j < AiHelpers.Equiv[type->Type]->Count;
++j) {
- if
(unit_types_count[AiHelpers.Equiv[type->Type]->Table[j]->Type]) {
+ for (j = 0; j < AiHelpers.Equiv[type->Slot]->Count;
++j) {
+ if
(unit_types_count[AiHelpers.Equiv[type->Slot]->Table[j]->Slot]) {
lua_pushboolean(l, 0);
return 1;
}
@@ -687,10 +687,10 @@
//
// Add equivalent units
//
- n = unit_types_count[type->Type];
- if (type->Type < AiHelpers.EquivCount && AiHelpers.Equiv[type->Type]) {
- for (j = 0; j < AiHelpers.Equiv[type->Type]->Count; ++j) {
- n +=
unit_types_count[AiHelpers.Equiv[type->Type]->Table[j]->Type];
+ n = unit_types_count[type->Slot];
+ if (type->Slot < AiHelpers.EquivCount && AiHelpers.Equiv[type->Slot]) {
+ for (j = 0; j < AiHelpers.Equiv[type->Slot]->Count; ++j) {
+ n +=
unit_types_count[AiHelpers.Equiv[type->Slot]->Table[j]->Slot];
}
}
// units available?
@@ -745,14 +745,14 @@
}
// Use the equivalent unittype.
- type = UnitTypes[UnitTypeEquivs[type->Type]];
+ type = UnitTypes[UnitTypeEquivs[type->Slot]];
//
// Look if already in force.
//
for (prev = &AiPlayer->Force[force].UnitTypes; (aiut = *prev);
prev = &aiut->Next) {
- if (UnitTypeEquivs[aiut->Type->Type] == type->Type) {
// found
+ if (UnitTypeEquivs[aiut->Type->Slot] == type->Slot) {
// found
if (count) {
aiut->Want = count;
} else {
Index: stratagus/src/game/trigger.c
diff -u stratagus/src/game/trigger.c:1.58 stratagus/src/game/trigger.c:1.59
--- stratagus/src/game/trigger.c:1.58 Sat Jan 17 02:17:23 2004
+++ stratagus/src/game/trigger.c Mon Jan 19 09:36:25 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: trigger.c,v 1.58 2004/01/16 15:17:23 wizzard Exp $
+// $Id: trigger.c,v 1.59 2004/01/18 22:36:25 nobody_ Exp $
//@{
@@ -261,7 +261,7 @@
} else {
for (; plynr < pn; ++plynr) {
DebugLevel3Fn("Player%d, %d == %s\n" _C_ plynr _C_ q
_C_ unittype->Ident);
- if
(compare(Players[plynr].UnitTypesCount[unittype->Type], q)) {
+ if
(compare(Players[plynr].UnitTypesCount[unittype->Slot], q)) {
lua_pushboolean(l, 1);
return 1;
}
@@ -1305,7 +1305,7 @@
int trigger;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.58 2004/01/16
15:17:23 wizzard Exp $\n\n");
+ CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.59 2004/01/18
22:36:25 nobody_ Exp $\n\n");
i = 0;
trigger = -1;
Index: stratagus/src/include/missile.h
diff -u stratagus/src/include/missile.h:1.82
stratagus/src/include/missile.h:1.83
--- stratagus/src/include/missile.h:1.82 Mon Jan 19 06:40:58 2004
+++ stratagus/src/include/missile.h Mon Jan 19 09:36:25 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: missile.h,v 1.82 2004/01/18 19:40:58 nobody_ Exp $
+// $Id: missile.h,v 1.83 2004/01/18 22:36:25 nobody_ Exp $
#ifndef __MISSILE_H__
#define __MISSILE_H__
@@ -398,7 +398,7 @@
struct _missile_type_ {
char* Ident; /// missile name
char* File; /// missile sprite file
- int Transparency; /// Missile transparency possible value is 50
(later 25 and 75)
+ int Transparency; /// missile transparency possible value is 50
(later 25 and 75)
int Width; /// missile width in pixels
int Height; /// missile height in pixels
int DrawLevel; /// Level to draw missile at
Index: stratagus/src/include/spells.h
diff -u stratagus/src/include/spells.h:1.47 stratagus/src/include/spells.h:1.48
--- stratagus/src/include/spells.h:1.47 Mon Jan 19 06:40:58 2004
+++ stratagus/src/include/spells.h Mon Jan 19 09:36:25 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: spells.h,v 1.47 2004/01/18 19:40:58 nobody_ Exp $
+// $Id: spells.h,v 1.48 2004/01/18 22:36:25 nobody_ Exp $
#ifndef __SPELLS_H__
#define __SPELLS_H__
@@ -241,20 +241,19 @@
** Base structure of a spell type.
*/
typedef struct _spell_type_ {
- // Identification stuff
- void* ScriptData; /// Script Data
for this object.
- int Ident;
/// Spell numeric identifier
- char *IdentName; ///
Spell unique identifier (spell-holy-vision)
+ // Identification stuff
+ char *Ident; /// Spell
unique identifier (spell-holy-vision)
char *Name;
/// Spell name shown by the engine
+ int Slot;
/// Spell numeric identifier
- // Spell Specifications
- TargetType Target;
/// Targetting information. See TargetType.
+ // Spell Specifications
+ TargetType Target; ///
Targetting information. See TargetType.
SpellActionType *Action; /// More
arguments for spell (damage, delay, additional sounds...).
int Range;
/// Max range of the target.
#define INFINITE_RANGE 0xFFFFFFF
- int ManaCost; /// Required
mana for each cast.
- int RepeatCast; /// If the
spell will be cast again until out of targets.
+ int ManaCost; ///
Required mana for each cast.
+ int RepeatCast; /// If the
spell will be cast again until out of targets.
int DependencyId; /// Id
of upgrade, -1 if no upgrade needed for cast the spell.
ConditionInfo *Condition; /// Conditions
to cast the spell. (generic (no test for each target))
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.39
stratagus/src/include/stratagus.h:1.40
--- stratagus/src/include/stratagus.h:1.39 Mon Jan 19 06:40:58 2004
+++ stratagus/src/include/stratagus.h Mon Jan 19 09:36:26 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: stratagus.h,v 1.39 2004/01/18 19:40:58 nobody_ Exp $
+// $Id: stratagus.h,v 1.40 2004/01/18 22:36:26 nobody_ Exp $
#ifndef __STRATAGUS_H__
#define __STRATAGUS_H__
@@ -44,7 +44,7 @@
#define NEW_UNIT_CACHE
// New Lua scripting.
-//#define META_LUA
+#define META_LUA
//
// Default speed for many things, set it higher for faster
actions.
Index: stratagus/src/include/unittype.h
diff -u stratagus/src/include/unittype.h:1.140
stratagus/src/include/unittype.h:1.141
--- stratagus/src/include/unittype.h:1.140 Sat Jan 17 01:40:14 2004
+++ stratagus/src/include/unittype.h Mon Jan 19 09:36:26 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unittype.h,v 1.140 2004/01/16 14:40:14 wizzard Exp $
+// $Id: unittype.h,v 1.141 2004/01/18 22:36:26 nobody_ Exp $
#ifndef __UNITTYPE_H__
#define __UNITTYPE_H__
@@ -632,6 +632,7 @@
struct _unit_type_ {
char* Ident; /// Identifier
char* Name; /// Pretty name shown from the engine
+ int Slot; /// Type as number
char* SameSprite; /// Unit-type shared sprites
char* File[TilesetMax]; /// Sprite files
char* ShadowFile; /// Shadow file
@@ -761,9 +762,6 @@
// FIXME: This stats should? be moved into the player struct
UnitStats Stats[PlayerMax]; /// Unit status for each player
-
- // FIXME: Should use a general name f.e. Slot here?
- int Type; /// Type as number
Graphic* Sprite; /// Sprite images
Graphic* ShadowSprite; /// Shadow sprite image
Index: stratagus/src/missile/missile.c
diff -u stratagus/src/missile/missile.c:1.129
stratagus/src/missile/missile.c:1.130
--- stratagus/src/missile/missile.c:1.129 Mon Jan 19 06:40:59 2004
+++ stratagus/src/missile/missile.c Mon Jan 19 09:36:26 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: missile.c,v 1.129 2004/01/18 19:40:59 nobody_ Exp $
+// $Id: missile.c,v 1.130 2004/01/18 22:36:26 nobody_ Exp $
//@{
@@ -203,9 +203,6 @@
/**
** Allocate an empty missile-type slot.
**
-** @todo Don't allocate an array of missile-types, allocate an array
-** of pointers.
-**
** @param ident Identifier to identify the slot.
**
** @return New allocated (zeroed) missile-type pointer.
@@ -218,11 +215,7 @@
MissileTypes = realloc(MissileTypes, (NumMissileTypes + 1) *
sizeof(MissileType *));
mtype = MissileTypes[NumMissileTypes++] = (MissileType
*)malloc(sizeof(MissileType));
memset(mtype, 0, sizeof(MissileType));
-
- // Defaults.
mtype->Ident = ident;
- mtype->CanHitOwner = 0;
- mtype->FriendlyFire = 0;
// Rehash.
for (i = 0; i < NumMissileTypes; ++i) {
@@ -1305,7 +1298,7 @@
DebugCheck(file == NULL);
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: missile-types $Id: missile.c,v 1.129
2004/01/18 19:40:59 nobody_ Exp $\n\n");
+ CLprintf(file, ";;; MODULE: missile-types $Id: missile.c,v 1.130
2004/01/18 22:36:26 nobody_ Exp $\n\n");
//
// Original number to internal missile-type name.
@@ -1427,7 +1420,7 @@
Missile* const* missiles;
CLprintf(file,"\n--- -----------------------------------------\n");
- CLprintf(file,"--- MODULE: missiles $Id: missile.c,v 1.129 2004/01/18
19:40:59 nobody_ Exp $\n\n");
+ CLprintf(file,"--- MODULE: missiles $Id: missile.c,v 1.130 2004/01/18
22:36:26 nobody_ Exp $\n\n");
for (missiles = GlobalMissiles; *missiles; ++missiles) {
SaveMissile(*missiles, file);
Index: stratagus/src/missile/script_missile.c
diff -u stratagus/src/missile/script_missile.c:1.58
stratagus/src/missile/script_missile.c:1.59
--- stratagus/src/missile/script_missile.c:1.58 Mon Jan 19 06:40:59 2004
+++ stratagus/src/missile/script_missile.c Mon Jan 19 09:36:27 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_missile.c,v 1.58 2004/01/18 19:40:59 nobody_ Exp $
+// $Id: script_missile.c,v 1.59 2004/01/18 22:36:27 nobody_ Exp $
//@{
@@ -439,7 +439,22 @@
*/
local int ScriptMissileTypesCreate(lua_State* l)
{
- LuaError(l, "Function not implemented.\n");
+ const char* name;
+ MissileType* mtype;
+
+ if (lua_gettop(l) != 1) {
+ LuaError(l, "Incorrect number of arguments");
+ }
+ name = LuaToString(l, 1);
+
+ mtype = MissileTypeByIdent(name);
+ if (mtype != NULL) {
+ LuaError(l, "Spell allready exists");
+ } else {
+ ScriptCreateUserdata(l, NewMissileTypeSlot(strdup(name)),
+ ScriptMissileTypeGet, ScriptMissileTypeSet);
+ return 1;
+ }
}
/**
@@ -478,7 +493,7 @@
i = LuaToNumber(l, 2);
DebugLevel3Fn("(%d)\n" _C_ i);
if (i < 0 || i >= NumMissileTypes) {
- LuaError(l, "Missile index out of range");
+ LuaError(l, "Missile type index out of range");
}
ScriptCreateUserdata(l, MissileTypes[i], ScriptMissileTypeGet,
ScriptMissileTypeSet);
return 1;
@@ -494,7 +509,7 @@
return 1;
}
- LuaError(l, "Spell \"%s\" doesn't exist.\n" _C_ key);
+ LuaError(l, "Missile type \"%s\" doesn't exist.\n" _C_ key);
}
/**
Index: stratagus/src/network/commands.c
diff -u stratagus/src/network/commands.c:1.91
stratagus/src/network/commands.c:1.92
--- stratagus/src/network/commands.c:1.91 Sat Jan 17 05:06:25 2004
+++ stratagus/src/network/commands.c Mon Jan 19 09:36:27 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: commands.c,v 1.91 2004/01/16 18:06:25 jsalmon3 Exp $
+// $Id: commands.c,v 1.92 2004/01/18 22:36:27 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.91 2004/01/16 18:06:25
jsalmon3 Exp $");
+ replay->Comment3 = strdup("$Id: commands.c,v 1.92 2004/01/18 22:36:27
nobody_ Exp $");
if (GameSettings.NetGameType == SettingsSinglePlayerGame) {
replay->Type = ReplaySinglePlayer;
@@ -1367,7 +1367,7 @@
{
if (NetworkFildes == (Socket)-1) {
CommandLog("spell-cast", unit, flush, x, y, dest, NULL,
spellid);
- CommandSpellCast(unit, x, y, dest, SpellTypeById(spellid),
flush);
+ CommandSpellCast(unit, x, y, dest, SpellTypeTable[spellid],
flush);
} else {
NetworkSendCommand(MessageCommandSpellCast + spellid,
unit, x, y, dest, NULL, flush);
@@ -1386,7 +1386,7 @@
if (NetworkFildes == (Socket)-1) {
CommandLog("auto-spell-cast", unit, FlushCommands, on, -1,
NoUnitP,
NULL, spellid);
- CommandAutoSpellCast(unit, on ? SpellTypeById(spellid) : NULL);
+ CommandAutoSpellCast(unit, on ? SpellTypeTable[spellid] : NULL);
} else {
NetworkSendCommand(MessageCommandSpellCast + spellid,
unit, on, -1, NoUnitP, NULL, FlushCommands);
@@ -1655,10 +1655,10 @@
DebugCheck(!dest || !dest->Type);
}
CommandLog("spell-cast", unit, status, x, y,
dest, NULL, id);
- CommandSpellCast(unit, x, y, dest,
SpellTypeById(id), status);
+ CommandSpellCast(unit, x, y, dest,
SpellTypeTable[id], status);
} else {
CommandLog("auto-spell-cast", unit, status, x,
-1, NoUnitP, NULL, id);
- CommandAutoSpellCast(unit, x ?
SpellTypeById(id) : NULL);
+ CommandAutoSpellCast(unit, x ?
SpellTypeTable[id] : NULL);
}
break;
}
Index: stratagus/src/network/network.c
diff -u stratagus/src/network/network.c:1.126
stratagus/src/network/network.c:1.127
--- stratagus/src/network/network.c:1.126 Thu Jan 15 09:31:07 2004
+++ stratagus/src/network/network.c Mon Jan 19 09:36:28 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: network.c,v 1.126 2004/01/14 22:31:07 nobody_ Exp $
+// $Id: network.c,v 1.127 2004/01/18 22:36:28 nobody_ Exp $
//@{
@@ -552,7 +552,7 @@
if (dest && check->Data.Dest == htons(dest->Slot)) {
DebugLevel3Fn("Removed Repeat Command\n");
return;
- } else if (type && check->Data.Dest ==
htons(type->Type)) {
+ } else if (type && check->Data.Dest ==
htons(type->Slot)) {
DebugLevel3Fn("Removed Repeat Command\n");
return;
} else if (check->Data.Dest == 0xFFFF) {
@@ -578,7 +578,7 @@
if (dest) {
ncq->Data.Dest = htons(dest->Slot);
} else if (type) {
- ncq->Data.Dest = htons(type->Type);
+ ncq->Data.Dest = htons(type->Slot);
} else {
ncq->Data.Dest = htons(-1);
}
Index: stratagus/src/stratagus/player.c
diff -u stratagus/src/stratagus/player.c:1.113
stratagus/src/stratagus/player.c:1.114
--- stratagus/src/stratagus/player.c:1.113 Sat Jan 17 13:12:50 2004
+++ stratagus/src/stratagus/player.c Mon Jan 19 09:36:28 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: player.c,v 1.113 2004/01/17 02:12:50 wizzard Exp $
+// $Id: player.c,v 1.114 2004/01/18 22:36:28 nobody_ Exp $
//@{
@@ -207,7 +207,7 @@
int j;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: players $Id: player.c,v 1.113 2004/01/17
02:12:50 wizzard Exp $\n\n");
+ CLprintf(file, "--- MODULE: players $Id: player.c,v 1.114 2004/01/18
22:36:28 nobody_ Exp $\n\n");
#if 0
//
@@ -660,8 +660,9 @@
NotifyPlayer(player, NotifyYellow, 0, 0, "Total Unit
Limit Reached");
return -4;
}
- if (player->UnitTypesCount[type->Type] >=
player->Allow.Units[type->Type]) {
- NotifyPlayer(player, NotifyYellow, 0, 0, "Limit of %d
Reached for this unit type", player->Allow.Units[type->Type]);
+ if (player->UnitTypesCount[type->Slot] >=
player->Allow.Units[type->Slot]) {
+ NotifyPlayer(player, NotifyYellow, 0, 0, "Limit of %d
Reached for this unit type",
+ player->Allow.Units[type->Slot]);
return -6;
}
return 1;
@@ -824,7 +825,7 @@
*/
global int HaveUnitTypeByType(const Player* player, const UnitType* type)
{
- return player->UnitTypesCount[type->Type];
+ return player->UnitTypesCount[type->Slot];
}
/**
@@ -838,7 +839,7 @@
*/
global int HaveUnitTypeByIdent(const Player* player, const char* ident)
{
- return player->UnitTypesCount[UnitTypeByIdent(ident)->Type];
+ return player->UnitTypesCount[UnitTypeByIdent(ident)->Slot];
}
/**
Index: stratagus/src/stratagus/script_spell.c
diff -u stratagus/src/stratagus/script_spell.c:1.38
stratagus/src/stratagus/script_spell.c:1.39
--- stratagus/src/stratagus/script_spell.c:1.38 Mon Jan 19 06:41:00 2004
+++ stratagus/src/stratagus/script_spell.c Mon Jan 19 09:36:29 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_spell.c,v 1.38 2004/01/18 19:41:00 nobody_ Exp $
+// $Id: script_spell.c,v 1.39 2004/01/18 22:36:29 nobody_ Exp $
//@{
/*----------------------------------------------------------------------------
@@ -596,8 +596,8 @@
SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) *
sizeof(SpellType*));
spell = SpellTypeTable[SpellTypeCount++] =
malloc(sizeof(SpellType));
memset(spell, 0, sizeof(SpellType));
- spell->Ident = SpellTypeCount - 1;
- spell->IdentName = identname;
+ spell->Slot = SpellTypeCount - 1;
+ spell->Ident = identname;
spell->DependencyId = -1;
}
for (; j < args; ++j) {
@@ -1042,8 +1042,8 @@
SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) *
sizeof(SpellType*));
spell = SpellTypeTable[SpellTypeCount++] =
malloc(sizeof(SpellType));
memset(spell, 0, sizeof(SpellType));
- spell->Ident = SpellTypeCount - 1;
- spell->IdentName = strdup(name);
+ spell->Slot = SpellTypeCount - 1;
+ spell->Ident = strdup(name);
spell->DependencyId = -1;
ScriptCreateUserdata(l, spell, ScriptSpellGet, ScriptSpellSet);
return 1;
@@ -1058,8 +1058,9 @@
*/
local int ScriptSpellGet(SpellType* spell, const char* key, lua_State* l)
{
- META_GET_STRING("DisplayName", spell->Name);
- META_GET_STRING("Ident", spell->IdentName);
+ META_GET_STRING("Name", spell->Name);
+ META_GET_STRING("Ident", spell->Ident);
+ META_GET_INT("Slot", spell->Slot);
META_GET_INT("ManaCost", spell->ManaCost);
META_GET_INT("Range", spell->Range);
META_GET_BOOL("RepeatCast", spell->RepeatCast);
@@ -1094,7 +1095,7 @@
{
const char* val;
- META_SET_STRING("DisplayName", spell->Name);
+ META_SET_STRING("Name", spell->Name);
META_SET_INT("ManaCost", spell->ManaCost);
META_SET_INT("Range", spell->Range);
META_SET_BOOL("RepeatCast", spell->RepeatCast);
Index: stratagus/src/stratagus/spells.c
diff -u stratagus/src/stratagus/spells.c:1.139
stratagus/src/stratagus/spells.c:1.140
--- stratagus/src/stratagus/spells.c:1.139 Mon Jan 19 06:41:00 2004
+++ stratagus/src/stratagus/spells.c Mon Jan 19 09:36:29 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: spells.c,v 1.139 2004/01/18 19:41:00 nobody_ Exp $
+// $Id: spells.c,v 1.140 2004/01/18 22:36:29 nobody_ Exp $
/*
** And when we cast our final spell
@@ -985,30 +985,6 @@
{
}
-// ****************************************************************************
-// Get Spell.
-// ****************************************************************************
-
-/**
-** Get the numeric spell id by string identifer.
-**
-** @param IdentName Spell identifier
-**
-** @return Spell id (index in spell-type
table)
-*/
-global int SpellIdByIdent(const char* ident)
-{
- int id;
-
- DebugCheck(!ident);
- for (id = 0; id < SpellTypeCount; ++id) {
- if (strcmp(SpellTypeTable[id]->IdentName, ident) == 0) {
- return id;
- }
- }
- return -1;
-}
-
/**
** Get spell-type struct pointer by string identifier.
**
@@ -1018,41 +994,15 @@
*/
global SpellType* SpellTypeByIdent(const char* ident)
{
- int id;
-
- DebugCheck(!ident);
- id = SpellIdByIdent(ident);
- return (id == -1 ? NULL : SpellTypeTable[id]);
-}
-
-/**
-** FIXME: docu
-*/
-global unsigned CclGetSpellByIdent(lua_State* l)
-{
int i;
- const char* value;
- value = LuaToString(l, -1);
+ DebugCheck(!ident);
for (i = 0; i < SpellTypeCount; ++i) {
- if (!strcmp(value, SpellTypeTable[i]->IdentName)) {
- return i;
+ if (strcmp(SpellTypeTable[i]->Ident, ident) == 0) {
+ return SpellTypeTable[i];
}
}
- return -1;
-}
-
-/**
-** Get spell-type struct ptr by id
-**
-** @param id Spell id (index in the spell-type table)
-**
-** @return spell-type struct ptr
-*/
-global SpellType* SpellTypeById(int id)
-{
- DebugCheck(!(0 <= id && id < SpellTypeCount));
- return SpellTypeTable[id];
+ return 0;
}
// ****************************************************************************
@@ -1111,10 +1061,10 @@
// And caster must know the spell
// FIXME: spell->Ident < MaxSpell
- DebugCheck(!(caster->Type->CanCastSpell &&
caster->Type->CanCastSpell[spell->Ident]));
+ DebugCheck(!(caster->Type->CanCastSpell &&
caster->Type->CanCastSpell[spell->Slot]));
if (!caster->Type->CanCastSpell ||
- !caster->Type->CanCastSpell[spell->Ident] ||
+ !caster->Type->CanCastSpell[spell->Slot] ||
(spell->Target == TargetUnit && target == NULL)) {
return 0;
}
@@ -1136,9 +1086,9 @@
DebugCheck(!caster);
DebugCheck(!spell);
- DebugCheck(!(0 <= spell->Ident && spell->Ident < SpellTypeCount));
+ DebugCheck(!(0 <= spell->Slot && spell->Slot < SpellTypeCount));
DebugCheck(!(caster->Type->CanCastSpell));
- DebugCheck(!(caster->Type->CanCastSpell[spell->Ident]));
+ DebugCheck(!(caster->Type->CanCastSpell[spell->Slot]));
target = NULL;
@@ -1179,7 +1129,7 @@
DebugCheck(!spell);
DebugCheck(!spell->Action->CastFunction);
DebugCheck(!caster);
- DebugCheck(!SpellIsAvailable(caster->Player, spell->Ident));
+ DebugCheck(!SpellIsAvailable(caster->Player, spell->Slot));
caster->Invisible = 0;// unit is invisible until attacks // FIXME: Must
be configurable
if (target) {
@@ -1194,7 +1144,7 @@
y=caster->Y;
target=caster;
}
- DebugLevel0Fn("Spell cast: (%s), %s -> %s (%d,%d)\n" _C_
spell->IdentName _C_
+ DebugLevel0Fn("Spell cast: (%s), %s -> %s (%d,%d)\n" _C_ spell->Ident
_C_
caster->Type->Name _C_ target ? target->Type->Name : "none" _C_
x _C_ y);
if (CanCastSpell(caster, spell, target, x, y)) {
act=spell->Action;
@@ -1245,7 +1195,7 @@
DebugLevel0("Cleaning spells.\n");
for (i = 0; i < SpellTypeCount; ++i) {
spell = SpellTypeTable[i];
- free(spell->IdentName);
+ free(spell->Ident);
free(spell->Name);
act = spell->Action;
Index: stratagus/src/ui/botpanel.c
diff -u stratagus/src/ui/botpanel.c:1.102 stratagus/src/ui/botpanel.c:1.103
--- stratagus/src/ui/botpanel.c:1.102 Sat Jan 17 13:12:51 2004
+++ stratagus/src/ui/botpanel.c Mon Jan 19 09:36:30 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: botpanel.c,v 1.102 2004/01/17 02:12:51 wizzard Exp $
+// $Id: botpanel.c,v 1.103 2004/01/18 22:36:30 nobody_ Exp $
//@{
@@ -104,7 +104,7 @@
char* cp;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.102 2004/01/17
02:12:51 wizzard Exp $\n\n");
+ CLprintf(file, ";;; MODULE: buttons $Id: botpanel.c,v 1.103 2004/01/18
22:36:30 nobody_ Exp $\n\n");
for (i = 0; i < NumUnitButtons; ++i) {
CLprintf(file, "(define-button 'pos %d 'level %d 'icon '%s\n",
@@ -285,7 +285,7 @@
ba->ValueStr = strdup(value);
switch (action) {
case ButtonSpellCast:
- ba->Value = SpellIdByIdent(value);
+ ba->Value = SpellTypeByIdent(value)->Slot;
#ifdef DEBUG
if (ba->Value < 0) {
DebugLevel0("Spell %s does not
exist?\n" _C_ value);
@@ -486,7 +486,7 @@
case ButtonSpellCast:
for (j = 0; j < NumSelected;
++j) {
if
(Selected[j]->AutoCastSpell !=
-
SpellTypeById(buttons[i].Value)) {
+
SpellTypeTable[buttons[i].Value]) {
break;
}
}
@@ -532,7 +532,7 @@
SetCosts(0, 0,
Upgrades[v].Costs);
break;
case ButtonSpellCast:
-
SetCosts(SpellTypeById(v)->ManaCost, 0, NULL);
+
SetCosts(SpellTypeTable[v]->ManaCost, 0, NULL);
break;
default:
@@ -890,7 +890,7 @@
int autocast;
SpellType* spell;
- spell =
SpellTypeById(CurrentButtons[button].Value);
+ spell =
SpellTypeTable[CurrentButtons[button].Value];
if (!CanAutoCastSpell(spell)) {
PlayGameSound(GameSounds.PlacementError.Sound,
MaxSampleVolume);
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.172 stratagus/src/ui/mouse.c:1.173
--- stratagus/src/ui/mouse.c:1.172 Sat Jan 17 13:12:51 2004
+++ stratagus/src/ui/mouse.c Mon Jan 19 09:36:30 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mouse.c,v 1.172 2004/01/17 02:12:51 wizzard Exp $
+// $Id: mouse.c,v 1.173 2004/01/18 22:36:30 nobody_ Exp $
//@{
@@ -1834,13 +1834,13 @@
}
if (Selected[0]->Player == ThisPlayer) {
char buf[64];
- if
(Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type] > 1) {
+ if
(Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Slot] > 1) {
sprintf(buf, "You have ~<%d~>
%ss",
-
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type],
+
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Slot],
Selected[0]->Type->Name);
} else {
sprintf(buf, "You have ~<%d~>
%s(s)",
-
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Type],
+
Selected[0]->Player->UnitTypesCount[Selected[0]->Type->Slot],
Selected[0]->Type->Name);
}
SetStatusLine(buf);
Index: stratagus/src/unit/depend.c
diff -u stratagus/src/unit/depend.c:1.38 stratagus/src/unit/depend.c:1.39
--- stratagus/src/unit/depend.c:1.38 Sat Jan 17 02:17:35 2004
+++ stratagus/src/unit/depend.c Mon Jan 19 09:36:31 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: depend.c,v 1.38 2004/01/16 15:17:35 wizzard Exp $
+// $Id: depend.c,v 1.39 2004/01/18 22:36:31 nobody_ Exp $
//@{
@@ -201,7 +201,7 @@
if (!strncmp(target, "unit-", 5)) {
// target string refers to unit-XXX
rule.Kind.UnitType = UnitTypeByIdent(target);
- if (UnitIdAllowed(player, rule.Kind.UnitType->Type) == 0) {
+ if (UnitIdAllowed(player, rule.Kind.UnitType->Slot) == 0) {
return 0;
}
rule.Type = DependRuleUnitType;
@@ -288,7 +288,7 @@
const DependRule* temp;
CLprintf(file,"\n;;; -----------------------------------------\n");
- CLprintf(file,";;; MODULE: dependencies $Id: depend.c,v 1.38 2004/01/16
15:17:35 wizzard Exp $\n\n");
+ CLprintf(file,";;; MODULE: dependencies $Id: depend.c,v 1.39 2004/01/18
22:36:31 nobody_ Exp $\n\n");
// Save all dependencies
Index: stratagus/src/unit/script_unit.c
diff -u stratagus/src/unit/script_unit.c:1.93
stratagus/src/unit/script_unit.c:1.94
--- stratagus/src/unit/script_unit.c:1.93 Sat Jan 17 02:17:35 2004
+++ stratagus/src/unit/script_unit.c Mon Jan 19 09:36:31 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_unit.c,v 1.93 2004/01/16 15:17:35 wizzard Exp $
+// $Id: script_unit.c,v 1.94 2004/01/18 22:36:31 nobody_ Exp $
//@{
@@ -893,7 +893,7 @@
unit->HP = hp;
if (unit->Orders[0].Action == UnitActionBuilded) {
// HACK: the building is not ready yet
- unit->Player->UnitTypesCount[type->Type]--;
+ unit->Player->UnitTypesCount[type->Slot]--;
}
} else if (!strcmp(value, "saved-order")) {
lua_pushvalue(l, j + 1);
Index: stratagus/src/unit/script_unittype.c
diff -u stratagus/src/unit/script_unittype.c:1.132
stratagus/src/unit/script_unittype.c:1.133
--- stratagus/src/unit/script_unittype.c:1.132 Sat Jan 17 02:17:36 2004
+++ stratagus/src/unit/script_unittype.c Mon Jan 19 09:36:31 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_unittype.c,v 1.132 2004/01/16 15:17:36 wizzard Exp $
+// $Id: script_unittype.c,v 1.133 2004/01/18 22:36:31 nobody_ Exp $
//@{
@@ -645,7 +645,7 @@
lua_rawgeti(l, -1, k + 1);
value = LuaToString(l, -1);
- id = CclGetSpellByIdent(l);
+ id = SpellTypeByIdent(value)->Slot;
lua_pop(l, 1);
DebugLevel3Fn("%d \n" _C_ id);
if (id == -1) {
Index: stratagus/src/unit/unit.c
diff -u stratagus/src/unit/unit.c:1.365 stratagus/src/unit/unit.c:1.366
--- stratagus/src/unit/unit.c:1.365 Mon Jan 19 06:41:01 2004
+++ stratagus/src/unit/unit.c Mon Jan 19 09:36:31 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.c,v 1.365 2004/01/18 19:41:01 nobody_ Exp $
+// $Id: unit.c,v 1.366 2004/01/18 22:36:31 nobody_ Exp $
//@{
@@ -374,7 +374,7 @@
}
*unit->PlayerSlot = unit;
- player->UnitTypesCount[type->Type]++;
+ player->UnitTypesCount[type->Slot]++;
}
if (type->Demand) {
@@ -731,7 +731,7 @@
}
if (unit->Orders[0].Action != UnitActionBuilded) {
- player->UnitTypesCount[type->Type]--;
+ player->UnitTypesCount[type->Slot]--;
}
}
@@ -799,7 +799,7 @@
}
DebugCheck(player->NumBuildings > UnitMax);
DebugCheck(player->TotalNumUnits > UnitMax);
- DebugCheck(player->UnitTypesCount[type->Type] > UnitMax);
+ DebugCheck(player->UnitTypesCount[type->Slot] > UnitMax);
}
/**
@@ -1572,7 +1572,7 @@
if (unit->Type->Building) {
newplayer->NumBuildings++;
}
- newplayer->UnitTypesCount[unit->Type->Type]++;
+ newplayer->UnitTypesCount[unit->Type->Slot]++;
UpdateForNewUnit(unit, 0);
}
@@ -3508,7 +3508,7 @@
(int)order->Arg1 >> 16,
(int)order->Arg1 & 0xFFFF);
break;
case UnitActionSpellCast:
- CLprintf(file, " \"spell\", \"%s\",",
((SpellType*)order->Arg1)->IdentName);
+ CLprintf(file, " \"spell\", \"%s\",",
((SpellType*)order->Arg1)->Ident);
break;
case UnitActionResearch:
CLprintf(file, " \"upgrade\", \"%s\",",
((Upgrade*)order->Arg1)->Ident);
@@ -3790,7 +3790,7 @@
int j;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.365 2004/01/18
19:41:01 nobody_ Exp $\n\n");
+ CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.366 2004/01/18
22:36:31 nobody_ Exp $\n\n");
#if 0
//
Index: stratagus/src/unit/unit_find.c
diff -u stratagus/src/unit/unit_find.c:1.69 stratagus/src/unit/unit_find.c:1.70
--- stratagus/src/unit/unit_find.c:1.69 Sat Jan 17 01:40:15 2004
+++ stratagus/src/unit/unit_find.c Mon Jan 19 09:36:31 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit_find.c,v 1.69 2004/01/16 14:40:15 wizzard Exp $
+// $Id: unit_find.c,v 1.70 2004/01/18 22:36:31 nobody_ Exp $
//@{
@@ -153,7 +153,7 @@
nunits = player->TotalNumUnits;
units = player->Units;
- typecount = player->UnitTypesCount[type->Type];
+ typecount = player->UnitTypesCount[type->Slot];
for (num = 0, i = 0; i < nunits && typecount; ++i) {
unit = units[i];
if (unit->Type == type) {
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.146 stratagus/src/unit/unittype.c:1.147
--- stratagus/src/unit/unittype.c:1.146 Sun Jan 18 09:23:28 2004
+++ stratagus/src/unit/unittype.c Mon Jan 19 09:36:32 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unittype.c,v 1.146 2004/01/17 22:23:28 nobody_ Exp $
+// $Id: unittype.c,v 1.147 2004/01/18 22:36:32 nobody_ Exp $
//@{
@@ -1039,7 +1039,7 @@
CLprintf(file, " 'can-cast-spell '( ");
for (i = 0; i < SpellTypeCount; ++i) {
if (type->CanCastSpell[i]) {
- CLprintf(file, "%s ",
SpellTypeTable[i]->IdentName);
+ CLprintf(file, "%s ", SpellTypeTable[i]->Ident);
}
}
CLprintf(file, ")\n");
@@ -1187,7 +1187,7 @@
// char** sp;
CLprintf(file, "\n--- -----------------------------------------\n");
- CLprintf(file, "--- MODULE: unittypes $Id: unittype.c,v 1.146
2004/01/17 22:23:28 nobody_ Exp $\n\n");
+ CLprintf(file, "--- MODULE: unittypes $Id: unittype.c,v 1.147
2004/01/18 22:36:32 nobody_ Exp $\n\n");
#if 0
// Original number to internal unit-type name.
@@ -1276,7 +1276,7 @@
ExitFatal(-1);
}
memset(type, 0, sizeof(UnitType));
- type->Type = NumUnitTypes;
+ type->Slot = NumUnitTypes;
DebugLevel3Fn("Making a new unit, called %s, branded %d\n"
_C_ ident _C_ type->Type);
type->Ident = ident;
@@ -1335,7 +1335,7 @@
//
// Initialize:
//
- DebugCheck(UnitTypes[type]->Type != type);
+ DebugCheck(UnitTypes[type]->Slot != type);
//
// Add idents to hash.
//
Index: stratagus/src/unit/upgrade.c
diff -u stratagus/src/unit/upgrade.c:1.72 stratagus/src/unit/upgrade.c:1.73
--- stratagus/src/unit/upgrade.c:1.72 Sat Jan 17 02:17:37 2004
+++ stratagus/src/unit/upgrade.c Mon Jan 19 09:36:32 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: upgrade.c,v 1.72 2004/01/16 15:17:37 wizzard Exp $
+// $Id: upgrade.c,v 1.73 2004/01/18 22:36:32 nobody_ Exp $
//@{
@@ -360,17 +360,17 @@
if (unit_for_bit[i * 16 + 0 + b * 2] >= 0) {
if (v & (1 << b)) {
AllowUnitId(player,
-
UnitTypeByWcNum(unit_for_bit[i * 16 + 0 + b * 2])->Type,
+
UnitTypeByWcNum(unit_for_bit[i * 16 + 0 + b * 2])->Slot,
UnitMax);
AllowUnitId(player,
-
UnitTypeByWcNum(unit_for_bit[i * 16 + 1 + b * 2])->Type,
+
UnitTypeByWcNum(unit_for_bit[i * 16 + 1 + b * 2])->Slot,
UnitMax);
} else {
AllowUnitId(player,
-
UnitTypeByWcNum(unit_for_bit[i * 16 + 0 + b * 2])->Type,
+
UnitTypeByWcNum(unit_for_bit[i * 16 + 0 + b * 2])->Slot,
0);
AllowUnitId(player,
-
UnitTypeByWcNum(unit_for_bit[i * 16 + 1 + b * 2])->Type,
+
UnitTypeByWcNum(unit_for_bit[i * 16 + 1 + b * 2])->Slot,
0);
}
}
@@ -545,7 +545,7 @@
int j;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: upgrades $Id: upgrade.c,v 1.72 2004/01/16
15:17:37 wizzard Exp $\n\n");
+ CLprintf(file, ";;; MODULE: upgrades $Id: upgrade.c,v 1.73 2004/01/18
22:36:32 nobody_ Exp $\n\n");
//
// Save all upgrades
@@ -1217,7 +1217,7 @@
UnitType* type;
if ((type = UnitTypeByIdent(ident))) {
- return type->Type;
+ return type->Slot;
}
DebugLevel0Fn(" fix this %s\n" _C_ ident);
return -1;
@@ -1287,7 +1287,7 @@
unit->HP += dst->Stats[player->Player].HitPoints -
unit->Stats->HitPoints;
// don't have such unit now
- player->UnitTypesCount[src->Type]--;
+ player->UnitTypesCount[src->Slot]--;
// UnMark the Unit sight for conversion if on map
if ((unit->CurrentSightRange !=
dst->Stats[player->Player].SightRange ||
src->TileWidth != dst->TileWidth ||