[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/ai ai.c ai_local.h ccl_ai.c
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src/ai ai.c ai_local.h ccl_ai.c |
Date: |
4 Jan 2004 09:33:26 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/04 09:33:26
Modified files:
src/ai : ai.c ai_local.h ccl_ai.c
Log message:
Load/Save exploration and transport requests
Patches:
Index: stratagus/src/ai/ai.c
diff -u stratagus/src/ai/ai.c:1.107 stratagus/src/ai/ai.c:1.108
--- stratagus/src/ai/ai.c:1.107 Sun Jan 4 08:37:08 2004
+++ stratagus/src/ai/ai.c Sun Jan 4 09:33:24 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai.c,v 1.107 2004/01/03 21:37:08 jsalmon3 Exp $
+// $Id: ai.c,v 1.108 2004/01/03 22:33:24 jsalmon3 Exp $
//@{
@@ -730,8 +730,33 @@
//
// Requests
//
- // FIXME: FirstExplorationRequest
- // FIXME: TransportRequests
+ if (ai->FirstExplorationRequest) {
+ AiExplorationRequest* ptr;
+
+ CLprintf(file, " \"exploration\", {");
+ ptr = ai->FirstExplorationRequest;
+ while (ptr) {
+ CLprintf(file, "{%d, %d, %d}, ",
+ ptr->X, ptr->Y, ptr->Mask);
+ ptr = ptr->Next;
+ }
+ CLprintf(file, "},\n");
+ }
+ CLprintf(file, " \"last-exploration-cycle\", %lu,\n",
ai->LastExplorationGameCycle);
+ if (ai->TransportRequests) {
+ AiTransportRequest* ptr;
+
+ CLprintf(file, " \"transport\", {");
+ ptr = ai->TransportRequests;
+ while (ptr) {
+ CLprintf(file, "{%d, ", UnitNumber(ptr->Unit));
+ SaveOrder(&ptr->Order, file);
+ CLprintf(file, "}, ");
+ ptr = ptr->Next;
+ }
+ CLprintf(file, "},\n");
+ }
+ CLprintf(file, " \"last-can-not-move-cycle\", %lu,\n",
ai->LastCanNotMoveGameCycle);
CLprintf(file, " \"unit-type\", {");
for (i = 0; i < ai->UnitTypeRequestsCount; ++i) {
CLprintf(file, "\"%s\", ",
ai->UnitTypeRequests[i].Table[0]->Ident);
@@ -796,7 +821,7 @@
{
CLprintf(file, "\n--- -----------------------------------------\n");
CLprintf(file,
- "--- MODULE: AI $Id: ai.c,v 1.107 2004/01/03 21:37:08 jsalmon3
Exp $\n\n");
+ "--- MODULE: AI $Id: ai.c,v 1.108 2004/01/03 22:33:24 jsalmon3
Exp $\n\n");
#if 0
SaveAiTypesWcName(file);
SaveAiHelper(file);
Index: stratagus/src/ai/ai_local.h
diff -u stratagus/src/ai/ai_local.h:1.53 stratagus/src/ai/ai_local.h:1.54
--- stratagus/src/ai/ai_local.h:1.53 Fri Jan 2 08:24:03 2004
+++ stratagus/src/ai/ai_local.h Sun Jan 4 09:33:25 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai_local.h,v 1.53 2004/01/01 21:24:03 jsalmon3 Exp $
+// $Id: ai_local.h,v 1.54 2004/01/03 22:33:25 jsalmon3 Exp $
#ifndef __AI_LOCAL_H__
#define __AI_LOCAL_H__
@@ -196,9 +196,9 @@
int NeedSupply; /// Flag need food
AiExplorationRequest* FirstExplorationRequest; /// Requests for
exploration
- unsigned int LastExplorationGameCycle; /// When did the last
explore occur ?
- AiTransportRequest* TransportRequests;
- unsigned int LastCanNotMoveGameCycle; /// number of elements
in UnitTypeRequests
+ unsigned long LastExplorationGameCycle; /// When did the last
explore occur?
+ AiTransportRequest* TransportRequests; /// Requests for
transport
+ unsigned long LastCanNotMoveGameCycle; /// Last can not move
cycle
int UnitTypeRequestsCount; /// unit-types to
build/train request,priority list
AiUnitTypeTable* UnitTypeRequests; /// number of elements
in UpgradeRequests
int UpgradeToRequestsCount; /// Upgrade to
unit-type requested and priority list
Index: stratagus/src/ai/ccl_ai.c
diff -u stratagus/src/ai/ccl_ai.c:1.96 stratagus/src/ai/ccl_ai.c:1.97
--- stratagus/src/ai/ccl_ai.c:1.96 Sun Jan 4 08:37:08 2004
+++ stratagus/src/ai/ccl_ai.c Sun Jan 4 09:33:25 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_ai.c,v 1.96 2004/01/03 21:37:08 jsalmon3 Exp $
+// $Id: ccl_ai.c,v 1.97 2004/01/03 22:33:25 jsalmon3 Exp $
//@{
@@ -1426,6 +1426,75 @@
} else if (!strcmp(value, "need-supply")) {
ai->NeedSupply = 1;
--j;
+ } else if (!strcmp(value, "exploration")) {
+ AiExplorationRequest** queue;
+
+ if (!lua_istable(l, j + 1)) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ subargs = luaL_getn(l, j + 1);
+ queue = &ai->FirstExplorationRequest;
+ for (k = 0; k < subargs; ++k) {
+ int x;
+ int y;
+ int mask;
+
+ lua_rawgeti(l, j + 1, k + 1);
+ if (!lua_istable(l, -1) || luaL_getn(l, -1) !=
3) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ lua_rawgeti(l, -1, 1);
+ x = LuaToNumber(l, -1);
+ lua_pop(l, 1);
+ lua_rawgeti(l, -1, 2);
+ y = LuaToNumber(l, -1);
+ lua_pop(l, 1);
+ lua_rawgeti(l, -1, 3);
+ mask = LuaToNumber(l, -1);
+ lua_pop(l, 1);
+ lua_pop(l, 1);
+ *queue = malloc(sizeof(AiExplorationRequest));
+ (*queue)->Next = NULL;
+ (*queue)->X = x;
+ (*queue)->Y = y;
+ (*queue)->Mask = mask;
+ queue = &(*queue)->Next;
+ }
+ } else if (!strcmp(value, "last-exploration-cycle")) {
+ ai->LastExplorationGameCycle = LuaToNumber(l, j + 1);
+ } else if (!strcmp(value, "transport")) {
+ AiTransportRequest** queue;
+
+ if (!lua_istable(l, j + 1)) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ subargs = luaL_getn(l, j + 1);
+ queue = &ai->TransportRequests;
+ for (k = 0; k < subargs; ++k) {
+ int unit;
+
+ lua_rawgeti(l, j + 1, k + 1);
+ if (!lua_istable(l, -1) || luaL_getn(l, -1) !=
2) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ lua_rawgeti(l, -1, 1);
+ unit = LuaToNumber(l, -1);
+ lua_pop(l, 1);
+ *queue = malloc(sizeof(AiTransportRequest));
+ (*queue)->Next = NULL;
+ (*queue)->Unit = UnitSlots[unit];
+ lua_rawgeti(l, -1, 2);
+ CclParseOrder(l, &(*queue)->Order);
+ lua_pop(l, 1);
+ queue = &(*queue)->Next;
+ lua_pop(l, 1);
+ }
+ } else if (!strcmp(value, "last-can-not-move-cycle")) {
+ ai->LastCanNotMoveGameCycle = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "unit-type")) {
if (!lua_istable(l, j + 1)) {
lua_pushstring(l, "incorrect argument");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/ai ai.c ai_local.h ccl_ai.c,
address@hidden <=