[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src ai/ccl_ai.c clone/ccl.c clone/ccl...
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src ai/ccl_ai.c clone/ccl.c clone/ccl... |
Date: |
Thu, 20 Nov 2003 15:00:30 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/11/20 15:00:29
Modified files:
src/ai : ccl_ai.c
src/clone : ccl.c ccl_helpers.c ccl_player.c ccl_spell.c
construct.c selection.c unit_draw.c
Log message:
Converted to LuaTo* functions, cleaned up spaces
Patches:
Index: stratagus/src/ai/ccl_ai.c
diff -u stratagus/src/ai/ccl_ai.c:1.83 stratagus/src/ai/ccl_ai.c:1.84
--- stratagus/src/ai/ccl_ai.c:1.83 Thu Nov 20 11:48:12 2003
+++ stratagus/src/ai/ccl_ai.c Thu Nov 20 15:00:23 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_ai.c,v 1.83 2003/11/20 16:48:12 pludov Exp $
+// $Id: ccl_ai.c,v 1.84 2003/11/20 20:00:23 jsalmon3 Exp $
//@{
@@ -66,7 +66,7 @@
-- Constants
----------------------------------------------------------------------------*/
-/// Description of the AiActionEvaluation structure
+/// Description of the AiActionEvaluation structure
static IOStructDef AiActionEvaluationStructDef = {
"AiActionEvaluation",
sizeof (AiActionEvaluation),
@@ -88,7 +88,7 @@
sizeof (AiExplorationRequest),
-1,
{
- {"`next", NULL, &((AiExplorationRequest *)
0)->Next, NULL},
+ {"`next", NULL, &((AiExplorationRequest *)
0)->Next, NULL},
{"gamecycle", &IOInt, &((AiExplorationRequest *)
0)->Mask, NULL},
{"map-x", &IOInt, &((AiExplorationRequest *)
0)->X, NULL},
{"map-y", &IOInt, &((AiExplorationRequest *)
0)->Y, NULL},
@@ -579,7 +579,7 @@
UnitType *type;
Upgrade *upgrade;
int cost;
-
+
#ifdef DEBUG
type = NULL;
upgrade = NULL;
@@ -821,7 +821,7 @@
local void InsertUnitTypeRequests(UnitType * type, int count)
{
int n;
-
+
if (AiPlayer->UnitTypeRequests) {
n = AiPlayer->UnitTypeRequestsCount;
AiPlayer->UnitTypeRequests = realloc(AiPlayer->UnitTypeRequests,
@@ -951,7 +951,7 @@
/**
** Activate AI debugging for the given player(s)
** Player can be
-** a number for a specific player
+** a number for a specific player
** "self" for current human player (ai me)
** "none" to disable
**
@@ -1389,12 +1389,12 @@
int transporterplace;
UnitType * transporter;
AiUnit * aiunit;
-
+
if ((AiScript->HotSpot_X == -1) || (AiScript->HotSpot_Y == -1)
|| (AiScript->HotSpot_Ray <= 0)) {
return SCM_BOOL_T;
}
-
+
ZoneSetClear(&sources);
transporter = 0;
transporterplace = 0;
@@ -1426,10 +1426,10 @@
ZoneSetAddConnected(&transportable,&sources);
// Add water as well
ZoneSetAddSet(&transportable,&sources);
-
+
aiunit = AiPlayer->Force[AiScript->ownForce].Units;
-
+
while (aiunit) {
switch(aiunit->Unit->Type->UnitType) {
case UnitTypeFly:
@@ -1440,13 +1440,13 @@
}
break;
case UnitTypeLand:
-
+
ZoneSetClear(&sources);
ZoneSetAddUnitZones(&sources,aiunit->Unit);
-
+
ZoneSetClear(&targets);
ZoneSetAddGoalZones(&targets, aiunit->Unit, AiScript->HotSpot_X
- 4, AiScript->HotSpot_Y - 4, 9, 9,0,0);
-
+
if (!ZoneSetHasIntersect(&targets,&sources) &&
(!ZoneSetHasIntersect(&targets,&transportable) ||
!ZoneSetHasIntersect(&sources,&transportable))) {
@@ -1765,7 +1765,7 @@
CclGcProtectedAssign(&AiPlayer->Scripts[i].Script, NIL);
AiPlayer->Scripts[i].SleepCycles = 0;
AiEraseForce(AiPlayer->Scripts[i].ownForce);
- snprintf(AiPlayer->Scripts[i].ident, 10, "Empty");
+ snprintf(AiPlayer->Scripts[i].ident, 10, "Empty");
}
return SCM_BOOL_T;
}
@@ -1962,11 +1962,7 @@
}
for (j = 0; j < i; ++j) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- *cp++ = strdup(lua_tostring(l, j + 1));
+ *cp++ = strdup(LuaToString(l, j + 1));
}
*cp = NULL;
@@ -2007,7 +2003,7 @@
** ai-type => the name of the ai
** script => ???
** script-debug => ???
-**
+**
** @param list List of the AI Player.
*/
#if defined(USE_GUILE) || defined(USE_SIOD)
Index: stratagus/src/clone/ccl.c
diff -u stratagus/src/clone/ccl.c:1.140 stratagus/src/clone/ccl.c:1.141
--- stratagus/src/clone/ccl.c:1.140 Thu Nov 20 12:56:35 2003
+++ stratagus/src/clone/ccl.c Thu Nov 20 15:00:24 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl.c,v 1.140 2003/11/20 17:56:35 jsalmon3 Exp $
+// $Id: ccl.c,v 1.141 2003/11/20 20:00:24 jsalmon3 Exp $
//@{
@@ -197,11 +197,11 @@
{
char buf[1024];
- if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- LibraryFileName(lua_tostring(l, 1), buf);
+ LibraryFileName(LuaToString(l, 1), buf);
LuaLoadFile(buf);
return 0;
}
@@ -697,11 +697,11 @@
#elif defined(USE_LUA)
local int CclSetGameCycle(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- GameCycle = lua_tonumber(l, 1);
+ GameCycle = LuaToNumber(l, 1);
return 0;
}
#endif
@@ -747,11 +747,11 @@
#elif defined(USE_LUA)
local int CclSetVideoSyncSpeed(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- VideoSyncSpeed = lua_tonumber(l, 1);
+ VideoSyncSpeed = LuaToNumber(l, 1);
return 0;
}
#endif
@@ -775,11 +775,11 @@
{
const char* str;
- if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- str = lua_tostring(l, 1);
+ str = LuaToString(l, 1);
strncpy(LocalPlayerName, str, sizeof(LocalPlayerName) - 1);
LocalPlayerName[sizeof(LocalPlayerName) - 1] = '\0';
return 0;
@@ -807,12 +807,12 @@
{
int old;
- if (lua_gettop(l) != 1 || !lua_isboolean(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
old = ShowTips;
- ShowTips = lua_toboolean(l, 1);
+ ShowTips = LuaToBoolean(l, 1);
lua_pushboolean(l, old);
return 1;
@@ -843,12 +843,12 @@
{
lua_Number old;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
old = CurrentTip;
- CurrentTip = lua_tonumber(l, 1);
+ CurrentTip = LuaToNumber(l, 1);
if (CurrentTip >= MAX_TIPS || Tips[CurrentTip] == NULL) {
CurrentTip = 0;
}
@@ -889,11 +889,11 @@
int i;
const char* str;
- if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- str = lua_tostring(l, 1);
+ str = LuaToString(l, 1);
for (i = 0; i < MAX_TIPS; ++i) {
if (Tips[i] && !strcmp(str, Tips[i])) {
break;
@@ -935,14 +935,14 @@
int i;
const char* resource;
- if (lua_gettop(l) != 2 || !lua_isstring(l, 1) || !lua_isnumber(l, 2)) {
+ if (lua_gettop(l) != 2) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- resource = lua_tostring(l, 1);
+ resource = LuaToString(l, 1);
for (i = 0; i < MaxCosts; ++i) {
if (!strcmp(resource, DefaultResourceNames[i])) {
- SpeedResourcesHarvest[i] = lua_tonumber(l, 2);
+ SpeedResourcesHarvest[i] = LuaToNumber(l, 2);
return 0;
}
}
@@ -979,14 +979,14 @@
int i;
const char* resource;
- if (lua_gettop(l) != 2 || !lua_isstring(l, 1) || !lua_isnumber(l, 2)) {
+ if (lua_gettop(l) != 2) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- resource = lua_tostring(l, 1);
+ resource = LuaToString(l, 1);
for (i = 0; i < MaxCosts; ++i) {
if (!strcmp(resource, DefaultResourceNames[i])) {
- SpeedResourcesReturn[i] = lua_tonumber(l, 2);
+ SpeedResourcesReturn[i] = LuaToNumber(l, 2);
return 0;
}
}
@@ -1010,11 +1010,11 @@
#elif defined(USE_LUA)
local int CclSetSpeedBuild(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- SpeedBuild = lua_tonumber(l, 1);
+ SpeedBuild = LuaToNumber(l, 1);
lua_pushnumber(l, SpeedBuild);
return 1;
@@ -1034,11 +1034,11 @@
#elif defined(USE_LUA)
local int CclSetSpeedTrain(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- SpeedTrain = lua_tonumber(l, 1);
+ SpeedTrain = LuaToNumber(l, 1);
lua_pushnumber(l, SpeedTrain);
return 1;
@@ -1058,11 +1058,11 @@
#elif defined(USE_LUA)
local int CclSetSpeedUpgrade(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- SpeedUpgrade = lua_tonumber(l, 1);
+ SpeedUpgrade = LuaToNumber(l, 1);
lua_pushnumber(l, SpeedUpgrade);
return 1;
@@ -1082,11 +1082,11 @@
#elif defined(USE_LUA)
local int CclSetSpeedResearch(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- SpeedResearch = lua_tonumber(l, 1);
+ SpeedResearch = LuaToNumber(l, 1);
lua_pushnumber(l, SpeedResearch);
return 1;
@@ -1117,11 +1117,11 @@
int i;
lua_Number s;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- s = lua_tonumber(l, 1);
+ s = LuaToNumber(l, 1);
for (i = 0; i < MaxCosts; ++i) {
SpeedResourcesHarvest[i] = s;
SpeedResourcesReturn[i] = s;
@@ -1155,11 +1155,7 @@
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isnumber(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultResources[i] = lua_tonumber(l, i + 1);
+ DefaultResources[i] = LuaToNumber(l, i + 1);
}
return 0;
}
@@ -1187,11 +1183,7 @@
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isnumber(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultResourcesLow[i] = lua_tonumber(l, i + 1);
+ DefaultResourcesLow[i] = LuaToNumber(l, i + 1);
}
return 0;
}
@@ -1219,11 +1211,7 @@
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isnumber(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultResourcesMedium[i] = lua_tonumber(l, i + 1);
+ DefaultResourcesMedium[i] = LuaToNumber(l, i + 1);
}
return 0;
}
@@ -1251,11 +1239,7 @@
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isnumber(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultResourcesHigh[i] = lua_tonumber(l, i + 1);
+ DefaultResourcesHigh[i] = LuaToNumber(l, i + 1);
}
return 0;
}
@@ -1283,11 +1267,7 @@
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isnumber(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultIncomes[i] = lua_tonumber(l, i + 1);
+ DefaultIncomes[i] = LuaToNumber(l, i + 1);
}
return 0;
}
@@ -1323,11 +1303,7 @@
}
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isstring(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultActions[i] = strdup(lua_tostring(l, i + 1));
+ DefaultActions[i] = strdup(LuaToString(l, i + 1));
}
return 0;
}
@@ -1363,11 +1339,7 @@
}
args = lua_gettop(l);
for (i = 0; i < MaxCosts && i < args; ++i) {
- if (!lua_isstring(l, i + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultResourceNames[i] = strdup(lua_tostring(l, i + 1));
+ DefaultResourceNames[i] = strdup(LuaToString(l, i + 1));
}
return 0;
}
@@ -1414,19 +1386,11 @@
lua_error(l);
}
for (j = 0; j < args; ++j) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
for (i = 0; i < MaxCosts; ++i) {
if (!strcmp(value, DefaultResourceNames[i])) {
++j;
- if (!lua_isnumber(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- DefaultResourceAmounts[i] = lua_tonumber(l, j + 1);
+ DefaultResourceAmounts[i] = LuaToNumber(l, j + 1);
break;
}
}
@@ -1639,11 +1603,11 @@
const char* name;
char buffer[1024];
- if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- name = lua_tostring(l, 1);
+ name = LuaToString(l, 1);
LoadPud(LibraryFileName(name, buffer), &TheMap);
// FIXME: LoadPud should return an error
@@ -1679,11 +1643,11 @@
const char* name;
char buffer[1024];
- if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- name = lua_tostring(l, 1);
+ name = LuaToString(l, 1);
if (strcasestr(name, ".pud")) {
LoadPud(LibraryFileName(name, buffer), &TheMap);
}
@@ -2035,7 +1999,7 @@
FILE* fd;
char buf[1024];
int i;
-
+
//
// preferences1.ccl
// This file is loaded before stratagus.ccl
@@ -2056,7 +2020,7 @@
}
fprintf(fd, ";;; -----------------------------------------\n");
- fprintf(fd, ";;; $Id: ccl.c,v 1.140 2003/11/20 17:56:35 jsalmon3 Exp $\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.141 2003/11/20 20:00:24 jsalmon3 Exp $\n");
fprintf(fd, "(set-video-resolution! %d %d)\n", VideoWidth, VideoHeight);
fprintf(fd, "(set-group-keys \"");
@@ -2088,7 +2052,7 @@
}
fprintf(fd, "--[[\n");
- fprintf(fd, " $Id: ccl.c,v 1.140 2003/11/20 17:56:35 jsalmon3 Exp
$\n");
+ fprintf(fd, " $Id: ccl.c,v 1.141 2003/11/20 20:00:24 jsalmon3 Exp
$\n");
fprintf(fd, "]]\n");
fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
@@ -2115,7 +2079,7 @@
}
fprintf(fd, ";;; -----------------------------------------\n");
- fprintf(fd, ";;; $Id: ccl.c,v 1.140 2003/11/20 17:56:35 jsalmon3 Exp $\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.141 2003/11/20 20:00:24 jsalmon3 Exp $\n");
// Global options
if (OriginalFogOfWar) {
@@ -2196,7 +2160,7 @@
}
fprintf(fd, "--[[\n");
- fprintf(fd, " $Id: ccl.c,v 1.140 2003/11/20 17:56:35 jsalmon3 Exp
$\n");
+ fprintf(fd, " $Id: ccl.c,v 1.141 2003/11/20 20:00:24 jsalmon3 Exp
$\n");
fprintf(fd, "]]\n");
fprintf(fd, "SetVideoFullscreen(%s)\n", VideoFullScreen ? "true" :
"false");
@@ -2256,7 +2220,7 @@
extern SCM oblistvar;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.140 2003/11/20 17:56:35
jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.141 2003/11/20 20:00:24
jsalmon3 Exp $\n\n");
for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
SCM sym;
Index: stratagus/src/clone/ccl_helpers.c
diff -u stratagus/src/clone/ccl_helpers.c:1.9
stratagus/src/clone/ccl_helpers.c:1.10
--- stratagus/src/clone/ccl_helpers.c:1.9 Fri Nov 14 15:20:46 2003
+++ stratagus/src/clone/ccl_helpers.c Thu Nov 20 15:00:26 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_helpers.c,v 1.9 2003/11/14 20:20:46 jsalmon3 Exp $
+// $Id: ccl_helpers.c,v 1.10 2003/11/20 20:00:26 jsalmon3 Exp $
//@{
@@ -163,8 +163,8 @@
/**
** Handle saving/loading a reference to a structure.
-** The structure content is also saved/loaded.
-** On load, the structure is malloc'ed.
+** The structure content is also saved/loaded.
+** On load, the structure is malloc'ed.
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the structure'reference to load/save
( <structure-type> ** )
@@ -194,8 +194,8 @@
/**
** Handle saving/loading an array of structures.
-** The array size is found in the array_size field of the IOStructDef
structure.
-** The array is NOT malloc'ed.
+** The array size is found in the array_size field of the IOStructDef
structure.
+** The array is NOT malloc'ed.
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the structure'reference to load/save
( <structure-type> * )
@@ -235,7 +235,7 @@
** The binaryform is a pointer to the "first" field.
** The third parameter is a pointer to a IOStructDef, describing list
elements.
**
-** defs[0] must contain the reference to the next field on the loaded
structure.
+** defs[0] must contain the reference to the next field on the loaded
structure.
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the "first"'ref ( <any-structure>** )
@@ -254,7 +254,7 @@
item = gh_car(scmfrom);
scmfrom = gh_cdr(scmfrom);
- // Just to be safe...
+ // Just to be safe...
if (!gh_null_p(item)) {
IOStructPtr(item, current, itemDef);
current =
@@ -283,14 +283,14 @@
/**
** Handle saving/loading a table of structure.
-** The table is composed of two thing : a pointer to data and a counter.
+** The table is composed of two thing : a pointer to data and a counter.
** The third parameter is a pointer to a IOStructDef, describing the table
** fields of the IOStructDef are :
** size indicate the size of one element of the table.
-** defs[0]: describe the data field ( should be
<any-structure>** )
+** defs[0]: describe the data field ( should be
<any-structure>** )
** defs[1]: describe the counter field ( should be int )
** defs[2]: describe the type of each structure to load. (
func & para )
-**
+**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the "first"'ref ( <any-structure>** )
** @param para Pointer to the IOStructDef
@@ -371,9 +371,9 @@
char* str, *escape;
char buffer[1024];
int i;
-
+
str = (*((char **) binaryform));
-
+
// Escape '"' & '\n'
CLprintf(IOOutFile," \"");
do {
@@ -386,7 +386,7 @@
CLprintf(IOOutFile, "%s", str);
break;
}
-
+
while (str < escape) {
i = 0;
while (str < escape && i < 1023) {
@@ -475,7 +475,7 @@
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the scm value to load/save ( char* )
-** @param para Array of IOFlagDef, describing possible values
( IOFlagDef * )
+** @param para Array of IOFlagDef, describing possible values
( IOFlagDef * )
*/
global void IOCharFlag(SCM scmfrom, void *binaryform, void *para)
{
@@ -521,7 +521,7 @@
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the string buffer
-** @param para Max size of string ( int )
+** @param para Max size of string ( int )
*/
global void IOStrBuffer(SCM scmfrom, void *binaryform, void *para)
{
@@ -572,7 +572,7 @@
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the array'ref ( int ** )
-** @param para Size of array to allocate/save
+** @param para Size of array to allocate/save
*/
global void IOIntArrayPtr(SCM scmfrom, void *binaryform, void *para)
{
@@ -610,7 +610,7 @@
**
** @param scmform When loading, the scm data to load
** @param binaryform Pointer to the array ( int * )
-** @param para Size of array to load/save
+** @param para Size of array to load/save
*/
global void IOIntArray(SCM scmfrom, void *binaryform, void *para)
{
Index: stratagus/src/clone/ccl_player.c
diff -u stratagus/src/clone/ccl_player.c:1.47
stratagus/src/clone/ccl_player.c:1.48
--- stratagus/src/clone/ccl_player.c:1.47 Wed Nov 19 22:42:05 2003
+++ stratagus/src/clone/ccl_player.c Thu Nov 20 15:00:26 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_player.c,v 1.47 2003/11/20 03:42:05 jsalmon3 Exp $
+// $Id: ccl_player.c,v 1.48 2003/11/20 20:00:26 jsalmon3 Exp $
//@{
@@ -68,11 +68,7 @@
#elif defined(USE_LUA)
local Player* CclGetPlayer(lua_State* l)
{
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- return &Players[(int)lua_tonumber(l, -1)];
+ return &Players[(int)LuaToNumber(l, -1)];
}
#endif
@@ -322,13 +318,13 @@
int n;
int oldp;
int newp;
-
+
n = SelectUnits(gh_scm2int(gh_car(pos1)), gh_scm2int(gh_cadr(pos1)),
gh_scm2int(gh_car(pos2)), gh_scm2int(gh_cadr(pos2)), table);
oldp = gh_scm2int(oldplayer);
newp = gh_scm2int(newplayer);
while (n) {
- if (table[n - 1]->Player->Player == oldp) {
+ if (table[n - 1]->Player->Player == oldp) {
ChangeUnitOwner(table[n - 1], &Players[newp]);
}
--n;
@@ -347,8 +343,7 @@
int x2;
int y2;
- if (lua_gettop(l) != 4 || !lua_istable(l, 1) || !lua_istable(l, 2) ||
- !lua_isnumber(l, 3) || !lua_isnumber(l, 4)) {
+ if (lua_gettop(l) != 4 || !lua_istable(l, 1) || !lua_istable(l, 2)) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
@@ -357,18 +352,10 @@
lua_error(l);
}
lua_rawgeti(l, 1, 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- x1 = lua_tonumber(l, -1);
+ x1 = LuaToNumber(l, -1);
lua_pop(l, 1);
lua_rawgeti(l, 1, 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- y1 = lua_tonumber(l, -1);
+ y1 = LuaToNumber(l, -1);
lua_pop(l, 1);
if (luaL_getn(l, 2) != 2) {
@@ -376,25 +363,17 @@
lua_error(l);
}
lua_rawgeti(l, 2, 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- x2 = lua_tonumber(l, -1);
+ x2 = LuaToNumber(l, -1);
lua_pop(l, 1);
lua_rawgeti(l, 2, 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- y2 = lua_tonumber(l, -1);
+ y2 = LuaToNumber(l, -1);
lua_pop(l, 1);
n = SelectUnits(x1, y1, x2, y2, table);
- oldp = lua_tonumber(l, 3);
- newp = lua_tonumber(l, 4);
+ oldp = LuaToNumber(l, 3);
+ newp = LuaToNumber(l, 4);
while (n) {
- if (table[n - 1]->Player->Player == oldp) {
+ if (table[n - 1]->Player->Player == oldp) {
ChangeUnitOwner(table[n - 1], &Players[newp]);
}
--n;
@@ -443,11 +422,11 @@
{
int plynr;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- plynr = lua_tonumber(l, 1);
+ plynr = LuaToNumber(l, 1);
ThisPlayer = &Players[plynr];
lua_pushnumber(l, plynr);
@@ -469,11 +448,11 @@
#elif defined(USE_LUA)
local int CclSetMaxSelectable(lua_State* l)
{
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- MaxSelectable = lua_tonumber(l, 1);
+ MaxSelectable = LuaToNumber(l, 1);
lua_pushnumber(l, MaxSelectable);
return 1;
@@ -501,12 +480,12 @@
{
int i;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
for (i = 0; i < PlayerMax; ++i) {
- Players[i].UnitLimit = lua_tonumber(l, 1);
+ Players[i].UnitLimit = LuaToNumber(l, 1);
}
lua_pushnumber(l, lua_tonumber(l, 1));
@@ -535,12 +514,12 @@
{
int i;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
for (i = 0; i < PlayerMax; ++i) {
- Players[i].BuildingLimit = lua_tonumber(l, 1);
+ Players[i].BuildingLimit = LuaToNumber(l, 1);
}
lua_pushnumber(l, lua_tonumber(l, 1));
@@ -569,12 +548,12 @@
{
int i;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
for (i = 0; i < PlayerMax; ++i) {
- Players[i].TotalUnitLimit = lua_tonumber(l, 1);
+ Players[i].TotalUnitLimit = LuaToNumber(l, 1);
}
lua_pushnumber(l, lua_tonumber(l, 1));
@@ -622,14 +601,13 @@
int base;
const char* state;
- if (lua_gettop(l) != 3 || !lua_isnumber(l, 1) || !lua_isstring(l, 2) ||
- !lua_isnumber(l, 3)) {
+ if (lua_gettop(l) != 3) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- base = lua_tonumber(l, 1);
- plynr = lua_tonumber(l, 3);
- state = lua_tostring(l, 2);
+ base = LuaToNumber(l, 1);
+ plynr = LuaToNumber(l, 3);
+ state = LuaToString(l, 2);
if (!strcmp(state, "allied")) {
SendCommandDiplomacy(base, DiplomacyAllied, plynr);
@@ -699,15 +677,14 @@
int base;
int shared;
- if (lua_gettop(l) != 3 || !lua_isnumber(l, 1) || !lua_isboolean(l, 2) ||
- !lua_isnumber(l, 3)) {
+ if (lua_gettop(l) != 3) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
- base = lua_tonumber(l, 1);
- shared = lua_toboolean(l, 2);
- plynr = lua_tonumber(l, 3);
+ base = LuaToNumber(l, 1);
+ shared = LuaToBoolean(l, 2);
+ plynr = LuaToNumber(l, 3);
SendCommandSharedVision(base, shared, plynr);
@@ -798,11 +775,7 @@
PlayerRaces.Count = 0;
args = lua_gettop(l);
for (j = 0; j < args; ++j) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
if (!strcmp(value, "race")) {
++j;
if (!lua_istable(l, j + 1)) {
@@ -817,38 +790,22 @@
PlayerRaces.Visible[i] = 0;
for (k = 0; k < subargs; ++k) {
lua_rawgeti(l, j + 1, k + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, -1);
+ value = LuaToString(l, -1);
lua_pop(l, 1);
if (!strcmp(value, "race")) {
++k;
lua_rawgeti(l, j + 1, k + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- PlayerRaces.Race[i] = lua_tonumber(l, -1);
+ PlayerRaces.Race[i] = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "name")) {
++k;
lua_rawgeti(l, j + 1, k + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- PlayerRaces.Name[i] = strdup(lua_tostring(l, -1));
+ PlayerRaces.Name[i] = strdup(LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "display")) {
++k;
lua_rawgeti(l, j + 1, k + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- PlayerRaces.Display[i] = strdup(lua_tostring(l, -1));
+ PlayerRaces.Display[i] = strdup(LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "visible")) {
PlayerRaces.Visible[i] = 1;
@@ -917,8 +874,8 @@
}
}
if (i == MaxCosts) {
- // FIXME: this leaves a half initialized player
- errl("Invalid resource", resource);
+ // FIXME: this leaves a half initialized player
+ errl("Invalid resource", resource);
}
ret = gh_int2scm(plyr->Resources[i]);
free(res);
@@ -931,14 +888,14 @@
Player* plyr;
const char* res;
- if (lua_gettop(l) != 2 || !lua_isstring(l, 2)) {
+ if (lua_gettop(l) != 2) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
lua_pushvalue(l, 1);
plyr = CclGetPlayer(l);
lua_pop(l, 1);
- res = lua_tostring(l, 2);
+ res = LuaToString(l, 2);
for (i = 0; i < MaxCosts; ++i) {
if (!strcmp(res, DefaultResourceNames[i])) {
@@ -946,9 +903,9 @@
}
}
if (i == MaxCosts) {
- // FIXME: this leaves a half initialized player
- lua_pushfstring(l, "Invalid resource", res);
- lua_error(l);
+ // FIXME: this leaves a half initialized player
+ lua_pushfstring(l, "Invalid resource", res);
+ lua_error(l);
}
lua_pushnumber(l, plyr->Resources[i]);
return 1;
@@ -1001,11 +958,7 @@
player = CclGetPlayer(l);
lua_pop(l, 1);
for (j = 1; j < args; ++j) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
++j;
for (i = 0; i < MaxCosts; ++i) {
if (!strcmp(value, DefaultResourceNames[i])) {
Index: stratagus/src/clone/ccl_spell.c
diff -u stratagus/src/clone/ccl_spell.c:1.27
stratagus/src/clone/ccl_spell.c:1.28
--- stratagus/src/clone/ccl_spell.c:1.27 Wed Nov 19 20:01:00 2003
+++ stratagus/src/clone/ccl_spell.c Thu Nov 20 15:00:26 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_spell.c,v 1.27 2003/11/20 01:01:00 jsalmon3 Exp $
+// $Id: ccl_spell.c,v 1.28 2003/11/20 20:00:26 jsalmon3 Exp $
//@{
/*----------------------------------------------------------------------------
@@ -64,7 +64,7 @@
local void CclSpellMissileLocation(SCM list, SpellActionMissileLocation*
location)
{
SCM value;
-
+
DebugCheck(location == NULL);
memset(location, 0, sizeof(*location));
//list = gh_cdr(list);
@@ -112,7 +112,7 @@
{
char* str;
SCM value;
-
+
DebugCheck(spellaction == NULL);
value = gh_car(list);
@@ -527,7 +527,7 @@
/**
** Get a condition value from a scm object.
-**
+**
** @param value scm value to convert.
**
** @return CONDITION_TRUE, CONDITION_FALSE, CONDITION_ONLY or -1 on error.
@@ -567,7 +567,7 @@
/**
** Parse the Condition for spell.
-**
+**
** @param list SCM object to parse
** @param condition pointer to condition to fill with data.
**
@@ -645,9 +645,9 @@
for (i = 0; i < NumberBoolFlag; i++) { // User defined flags
if (gh_eq_p(value, gh_symbol2scm(BoolFlagName[i]))) {
condition->BoolFlag[i] = Scm2Condition(gh_car(list));
- list = gh_cdr(list);
+ list = gh_cdr(list);
break;
- }
+ }
}
if (i != NumberBoolFlag) {
continue;
@@ -691,129 +691,69 @@
args = luaL_getn(l, -1);
for (j = 0; j < args; ++j) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, -1);
+ value = LuaToString(l, -1);
lua_pop(l, 1);
++j;
if (!strcmp(value, "coward")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->Coward = Ccl2Condition(l, lua_tostring(l, -1));
+ condition->Coward = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "alliance")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->Alliance = Ccl2Condition(l, lua_tostring(l, -1));
+ condition->Alliance = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "building")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->Building = Ccl2Condition(l, lua_tostring(l, -1));
+ condition->Building = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "self")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->TargetSelf = Ccl2Condition(l, lua_tostring(l, -1));
+ condition->TargetSelf = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "min-hp-percent")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MinHpPercent = lua_tonumber(l, -1);
+ condition->MinHpPercent = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-hp-percent")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxHpPercent = lua_tonumber(l, -1);
+ condition->MaxHpPercent = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "min-mana-percent")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MinManaPercent = lua_tonumber(l, -1);
+ condition->MinManaPercent = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-mana-percent")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxManaPercent = lua_tonumber(l, -1);
+ condition->MaxManaPercent = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-slow-ticks")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxSlowTicks = lua_tonumber(l, -1);
+ condition->MaxSlowTicks = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-haste-ticks")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxHasteTicks = lua_tonumber(l, -1);
+ condition->MaxHasteTicks = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-bloodlust-ticks")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxBloodlustTicks = lua_tonumber(l, -1);
+ condition->MaxBloodlustTicks = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-invisibility-ticks")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxInvisibilityTicks = lua_tonumber(l, -1);
+ condition->MaxInvisibilityTicks = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "max-invincibility-ticks")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->MaxInvincibilityTicks = lua_tonumber(l, -1);
+ condition->MaxInvincibilityTicks = LuaToNumber(l, -1);
lua_pop(l, 1);
} else {
for (i = 0; i < NumberBoolFlag; i++) { // User defined flags
if (!strcmp(value, BoolFlagName[i])) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- condition->BoolFlag[i] = Ccl2Condition(l, lua_tostring(l,
-1));
+ condition->BoolFlag[i] = Ccl2Condition(l, LuaToString(l,
-1));
lua_pop(l, 1);
break;
- }
+ }
}
if (i != NumberBoolFlag) {
continue;
@@ -827,7 +767,7 @@
/*
** Parse the Condition for spell.
-**
+**
** @param list SCM object to parse
** @param autocast pointer to autocast to fill with data.
**
@@ -875,28 +815,16 @@
args = luaL_getn(l, -1);
for (j = 0; j < args; ++j) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, -1);
+ value = LuaToString(l, -1);
lua_pop(l, 1);
++j;
if (!strcmp(value, "range")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isnumber(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- autocast->Range = lua_tonumber(l, -1);
+ autocast->Range = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "combat")) {
lua_rawgeti(l, -1, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- autocast->Combat = Ccl2Condition(l, lua_tostring(l, -1));
+ autocast->Combat = Ccl2Condition(l, LuaToString(l, -1));
lua_pop(l, 1);
} else if (!strcmp(value, "condition")) {
if (!autocast->Condition) {
@@ -946,7 +874,7 @@
value = gh_car(list);
list = gh_cdr(list);
if (gh_eq_p(value, gh_symbol2scm("showname"))) {
- if (spell->Name) {
+ if (spell->Name) {
free(spell->Name);
}
spell->Name = gh_scm2newstr(gh_car(list), NULL);
@@ -1058,11 +986,7 @@
args = lua_gettop(l);
j = 0;
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- identname = strdup(lua_tostring(l, j + 1));
+ identname = strdup(LuaToString(l, j + 1));
++j;
spell = SpellTypeByIdent(identname);
if (spell != NULL) {
@@ -1077,27 +1001,15 @@
spell->DependencyId = -1;
}
for (; j < args; ++j) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
++j;
if (!strcmp(value, "showname")) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- if (spell->Name) {
+ if (spell->Name) {
free(spell->Name);
}
- spell->Name = strdup(lua_tostring(l, j + 1));
+ spell->Name = strdup(LuaToString(l, j + 1));
} else if (!strcmp(value, "manacost")) {
- if (!lua_isnumber(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- spell->ManaCost = lua_tonumber(l, j + 1);
+ spell->ManaCost = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "range")) {
if (!lua_isstring(l, j + 1) && !lua_isnumber(l, j + 1)) {
lua_pushstring(l, "incorrect argument");
@@ -1115,11 +1027,7 @@
spell->RepeatCast = 1;
--j;
} else if (!strcmp(value, "target")) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
if (!strcmp(value, "self")) {
spell->Target = TargetSelf;
} else if (!strcmp(value, "unit")) {
@@ -1171,15 +1079,11 @@
CclSpellAutocast(l, spell->AICast);
lua_pop(l, 1);
} else if (!strcmp(value, "sound-when-cast")) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
// Free the old name, get the new one
if (spell->SoundWhenCast.Name) {
free(spell->SoundWhenCast.Name);
}
- spell->SoundWhenCast.Name = strdup(lua_tostring(l, j + 1));
+ spell->SoundWhenCast.Name = strdup(LuaToString(l, j + 1));
spell->SoundWhenCast.Sound =
SoundIdForName(spell->SoundWhenCast.Name);
// Check for sound.
if (!spell->SoundWhenCast.Sound) {
@@ -1187,22 +1091,14 @@
spell->SoundWhenCast.Name = 0;
}
} else if (!strcmp(value, "missile-when-cast")) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
spell->Missile = MissileTypeByIdent(value);
if (spell->Missile == NULL) {
DebugLevel0Fn("in spell-type '%s' : missile %s does not
exist\n" _C_
spell->Name _C_ value);
}
} else if (!strcmp(value, "depend-upgrade")) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- value = lua_tostring(l, j + 1);
+ value = LuaToString(l, j + 1);
spell->DependencyId = UpgradeIdByIdent(value);
if (spell->DependencyId == -1) {
lua_pushfstring(l, "Bad upgrade name: %s", value);
@@ -1331,7 +1227,7 @@
} else if (action->CastFunction == CastSpawnPortal) {
CLprintf(file, "(spawn-portal portal-type %s)",
action->Data.SpawnPortal.PortalType->Ident);
- }
+ }
}
/*
@@ -1369,10 +1265,10 @@
CLprintf(file, "self %s ", condstrings[(int)condition->TargetSelf]);
}
for (i = 0; i < NumberBoolFlag; i++) { // User defined flags
- if (condition->BoolFlag[i] != CONDITION_TRUE) {
- CLprintf(file, "%s %s ",
- BoolFlagName[i], condstrings[(int)condition->BoolFlag[i]]);
- }
+ if (condition->BoolFlag[i] != CONDITION_TRUE) {
+ CLprintf(file, "%s %s ",
+ BoolFlagName[i], condstrings[(int)condition->BoolFlag[i]]);
+ }
}
//
// Min/Max vital percents
@@ -1396,7 +1292,7 @@
}
/*
-** Save autocast info to a CCL file
+** Save autocast info to a CCL file
**
** @param file The file to save to.
** @param autocast Auocastinfo to save.
@@ -1408,7 +1304,7 @@
"false", /// CONDITION_FALSE
"only" /// CONDITION_ONLY
};
-
+
CLprintf(file, "( range %d ", autocast->Range);
if (autocast->Combat != CONDITION_TRUE) {
CLprintf(file, "combat %s ", condstrings[(int)autocast->Combat]);
@@ -1422,7 +1318,7 @@
/*
** Save spells to a CCL file.
-**
+**
** @param file The file to save to.
*/
global void SaveSpells(CLFile* file)
@@ -1431,7 +1327,7 @@
SpellActionType* act;
DebugCheck(!file);
-
+
for (spell = SpellTypeTable; spell < SpellTypeTable + SpellTypeCount;
++spell) {
CLprintf(file, "(define-spell\n");
//
@@ -1445,7 +1341,7 @@
}
CLprintf(file, " 'manacost %d\n", spell->ManaCost);
CLprintf(file, " 'range %d\n", spell->Range);
- if (spell->SoundWhenCast.Name) {
+ if (spell->SoundWhenCast.Name) {
CLprintf(file, " 'sound-when-cast \"%s\"\n",
spell->SoundWhenCast.Name);
}
if (spell->Missile) {
Index: stratagus/src/clone/construct.c
diff -u stratagus/src/clone/construct.c:1.38
stratagus/src/clone/construct.c:1.39
--- stratagus/src/clone/construct.c:1.38 Wed Nov 12 15:40:24 2003
+++ stratagus/src/clone/construct.c Thu Nov 20 15:00:27 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: construct.c,v 1.38 2003/11/12 20:40:24 jsalmon3 Exp $
+// $Id: construct.c,v 1.39 2003/11/20 20:00:27 jsalmon3 Exp $
//@{
@@ -147,10 +147,10 @@
ConstructionFrame* cframe;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: constructions $Id: construct.c,v 1.38
2003/11/12 20:40:24 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: constructions $Id: construct.c,v 1.39
2003/11/20 20:00:27 jsalmon3 Exp $\n\n");
// FIXME: needed?
-
+
//
// Dump table wc2 construction numbers -> internal symbol.
//
@@ -364,11 +364,7 @@
}
for (j = 0; j < i; ++j) {
- if (!lua_isstring(l, j + 1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- *cp++ = strdup(lua_tostring(l, j + 1));
+ *cp++ = strdup(LuaToString(l, j + 1));
}
*cp = NULL;
Index: stratagus/src/clone/selection.c
diff -u stratagus/src/clone/selection.c:1.61
stratagus/src/clone/selection.c:1.62
--- stratagus/src/clone/selection.c:1.61 Wed Nov 19 22:31:19 2003
+++ stratagus/src/clone/selection.c Thu Nov 20 15:00:28 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: selection.c,v 1.61 2003/11/20 03:31:19 jsalmon3 Exp $
+// $Id: selection.c,v 1.62 2003/11/20 20:00:28 jsalmon3 Exp $
//@{
@@ -121,7 +121,7 @@
DebugCheck(count > MaxSelectable);
- if (count == 1 && units[0]->Type->ClicksToExplode &&
+ if (count == 1 && units[0]->Type->ClicksToExplode &&
units[0]->Type->Selectable) {
HandleSuicideClick(units[0]);
}
@@ -144,9 +144,9 @@
** Add a unit to the other selected units.
**
** @param unit Pointer to unit to add.
-** @return true if added to selection, false otherwise
+** @return true if added to selection, false otherwise
** (if NumSelected == MaxSelectable or
-** unit is already selected or unselectable)
+** unit is already selected or unselectable)
*/
global int SelectUnit(Unit* unit)
{
@@ -513,10 +513,10 @@
** of its upper left and lower right corner expressed in screen map
** coordinate system.
**
-** @param sx0 x-coord of upper left corner of the rectangle
-** @param sy0 y-coord of upper left corner of the rectangle
-** @param sx1 x-coord of lower right corner of the rectangle
-** @param sy1 y-coord of lower right corner of the rectangle
+** @param sx0 x-coord of upper left corner of the rectangle
+** @param sy0 y-coord of upper left corner of the rectangle
+** @param sx1 x-coord of lower right corner of the rectangle
+** @param sy1 y-coord of lower right corner of the rectangle
** @param table table of units
** @param num_units number of units in table
**
@@ -978,7 +978,7 @@
char* ref;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: selection $Id: selection.c,v 1.61 2003/11/20
03:31:19 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: selection $Id: selection.c,v 1.62 2003/11/20
20:00:28 jsalmon3 Exp $\n\n");
CLprintf(file, "(set-group-id! %d)\n", GroupId);
CLprintf(file, "(selection %d '(", NumSelected);
@@ -1025,12 +1025,12 @@
{
int old;
- if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+ if (lua_gettop(l) != 1) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
old = GroupId;
- GroupId = lua_tonumber(l, 1);
+ GroupId = LuaToNumber(l, 1);
lua_pushnumber(l, old);
return 1;
@@ -1069,23 +1069,19 @@
int args;
int j;
- if (lua_gettop(l) != 2 || !lua_isnumber(l, 1) || !lua_istable(l, 2)) {
+ if (lua_gettop(l) != 2 || !lua_istable(l, 2)) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
InitSelections();
- NumSelected = lua_tonumber(l, 1);
+ NumSelected = LuaToNumber(l, 1);
i = 0;
args = luaL_getn(l, 2);
for (j = 0; j < args; ++j) {
const char* str;
lua_rawgeti(l, 2, j + 1);
- if (!lua_isstring(l, -1)) {
- lua_pushstring(l, "incorrect argument");
- lua_error(l);
- }
- str = lua_tostring(l, -1);
+ str = LuaToString(l, -1);
lua_pop(l, 1);
Selected[i++] = UnitSlots[strtol(str + 1, NULL, 16)];
}
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.186
stratagus/src/clone/unit_draw.c:1.187
--- stratagus/src/clone/unit_draw.c:1.186 Thu Nov 20 02:59:43 2003
+++ stratagus/src/clone/unit_draw.c Thu Nov 20 15:00:28 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit_draw.c,v 1.186 2003/11/20 07:59:43 nehalmistry Exp $
+// $Id: unit_draw.c,v 1.187 2003/11/20 20:00:28 jsalmon3 Exp $
//@{
@@ -89,8 +89,8 @@
** Show that units are selected.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void (*DrawSelection)(SDL_Color color, int x1, int y1,
@@ -153,7 +153,7 @@
// If building mark all own buildings
if (CursorBuilding && unit->Type->Building &&
unit->Player == ThisPlayer) {
- *color = ColorGray;
+ *color = ColorGray;
return color;
}
return NULL;
@@ -183,7 +183,7 @@
// If building mark all own buildings
if (CursorBuilding && unit->Type->Building &&
unit->Player == ThisPlayer) {
- return &ColorGray;
+ return &ColorGray;
}
return NULL;
}
@@ -206,7 +206,7 @@
UnitType* type;
type = unit->Type;
-
+
color = SelectionColor(unit);
if (!color) {
return;
@@ -224,8 +224,8 @@
** Don't show selected units.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void DrawSelectionNone(SDL_Color color, int x1, int y1,
@@ -243,8 +243,8 @@
** Show selected units with circle.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void DrawSelectionCircle(SDL_Color color, int x1, int x2,
@@ -264,8 +264,8 @@
** Show selected units with circle.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void DrawSelectionCircleWithTrans(SDL_Color color, int x1, int y1,
@@ -290,8 +290,8 @@
** Draw selected rectangle around the unit.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void DrawSelectionRectangle(SDL_Color color, int x1, int y1,
@@ -308,8 +308,8 @@
** Draw selected rectangle around the unit.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void DrawSelectionRectangleWithTrans(SDL_Color color, int x1, int y1,
@@ -333,8 +333,8 @@
** Draw selected corners around the unit.
**
** @param color
-** @param x1,y1 Coordinates of the top left corner.
-** @param x2,y2 Coordinates of the bottom right corner.
+** @param x1,y1 Coordinates of the top left corner.
+** @param x2,y2 Coordinates of the bottom right corner.
*/
#ifdef USE_SDL_SURFACE
global void DrawSelectionCorners(SDL_Color color, int x1, int y1,
@@ -420,18 +420,17 @@
#elif defined(USE_LUA)
local int CclManaSprite(lua_State* l)
{
- if (lua_gettop(l) != 5 || !lua_isstring(l, 1) || !lua_isnumber(l, 2) ||
- !lua_isnumber(l, 3) || !lua_isnumber(l, 4) || !lua_isnumber(l, 5)) {
+ if (lua_gettop(l) != 5) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
free(ManaSprite.File);
- ManaSprite.File = strdup(lua_tostring(l, 1));
- ManaSprite.HotX = lua_tonumber(l, 2);
- ManaSprite.HotY = lua_tonumber(l, 3);
- ManaSprite.Width = lua_tonumber(l, 4);
- ManaSprite.Height = lua_tonumber(l, 5);
+ ManaSprite.File = strdup(LuaToString(l, 1));
+ ManaSprite.HotX = LuaToNumber(l, 2);
+ ManaSprite.HotY = LuaToNumber(l, 3);
+ ManaSprite.Width = LuaToNumber(l, 4);
+ ManaSprite.Height = LuaToNumber(l, 5);
return 0;
}
@@ -462,18 +461,17 @@
#elif defined(USE_LUA)
local int CclHealthSprite(lua_State* l)
{
- if (lua_gettop(l) != 5 || !lua_isstring(l, 1) || !lua_isnumber(l, 2) ||
- !lua_isnumber(l, 3) || !lua_isnumber(l, 4) || !lua_isnumber(l, 5)) {
+ if (lua_gettop(l) != 5) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
free(HealthSprite.File);
- HealthSprite.File = strdup(lua_tostring(l, 1));
- HealthSprite.HotX = lua_tonumber(l, 2);
- HealthSprite.HotY = lua_tonumber(l, 3);
- HealthSprite.Width = lua_tonumber(l, 4);
- HealthSprite.Height = lua_tonumber(l, 5);
+ HealthSprite.File = strdup(LuaToString(l, 1));
+ HealthSprite.HotX = LuaToNumber(l, 2);
+ HealthSprite.HotY = LuaToNumber(l, 3);
+ HealthSprite.Width = LuaToNumber(l, 4);
+ HealthSprite.Height = LuaToNumber(l, 5);
return 0;
}
@@ -504,18 +502,17 @@
#elif defined(USE_LUA)
local int CclShadowSprite(lua_State* l)
{
- if (lua_gettop(l) != 5 || !lua_isstring(l, 1) || !lua_isnumber(l, 2) ||
- !lua_isnumber(l, 3) || !lua_isnumber(l, 4) || !lua_isnumber(l, 5)) {
+ if (lua_gettop(l) != 5) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
free(ShadowSprite.File);
- ShadowSprite.File = strdup(lua_tostring(l, 1));
- ShadowSprite.HotX = lua_tonumber(l, 2);
- ShadowSprite.HotY = lua_tonumber(l, 3);
- ShadowSprite.Width = lua_tonumber(l, 4);
- ShadowSprite.Height = lua_tonumber(l, 5);
+ ShadowSprite.File = strdup(LuaToString(l, 1));
+ ShadowSprite.HotX = LuaToNumber(l, 2);
+ ShadowSprite.HotY = LuaToNumber(l, 3);
+ ShadowSprite.Width = LuaToNumber(l, 4);
+ ShadowSprite.Height = LuaToNumber(l, 5);
return 0;
}
@@ -546,18 +543,17 @@
#elif defined(USE_LUA)
local int CclSpellSprite(lua_State* l)
{
- if (lua_gettop(l) != 5 || !lua_isstring(l, 1) || !lua_isnumber(l, 2) ||
- !lua_isnumber(l, 3) || !lua_isnumber(l, 4) || !lua_isnumber(l, 5)) {
+ if (lua_gettop(l) != 5) {
lua_pushstring(l, "incorrect argument");
lua_error(l);
}
free(SpellSprite.File);
- SpellSprite.File = strdup(lua_tostring(l, 1));
- SpellSprite.HotX = lua_tonumber(l, 2);
- SpellSprite.HotY = lua_tonumber(l, 3);
- SpellSprite.Width = lua_tonumber(l, 4);
- SpellSprite.Height = lua_tonumber(l, 5);
+ SpellSprite.File = strdup(LuaToString(l, 1));
+ SpellSprite.HotX = LuaToNumber(l, 2);
+ SpellSprite.HotY = LuaToNumber(l, 3);
+ SpellSprite.Width = LuaToNumber(l, 4);
+ SpellSprite.Height = LuaToNumber(l, 5);
return 0;
}
@@ -947,7 +943,7 @@
global void SaveDecorations(CLFile* file)
{
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.186
2003/11/20 07:59:43 nehalmistry Exp $\n\n");
+ CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.187
2003/11/20 20:00:28 jsalmon3 Exp $\n\n");
CLprintf(file, "(mana-sprite \"%s\" %d %d %d %d)\n",
ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,
@@ -1120,8 +1116,8 @@
(f * type->BoxHeight) / 100, 4);
}
- w = (f * type->BoxHeight) / 100 - 1;
- if (w > 0) { // Prevents -1 turning into unsigned int
+ w = (f * type->BoxHeight) / 100 - 1;
+ if (w > 0) { // Prevents -1 turning into unsigned int
VideoFillRectangleClip(ColorBlue,
x + (type->TileWidth * TileSizeX - type->BoxWidth) / 2 + 1,
(y + (type->TileHeight * TileSizeY - type->BoxHeight) / 2) +
@@ -1221,8 +1217,8 @@
((f * type->BoxHeight) / 100) + 1, 5);
#endif
}
- w = (f * type->BoxHeight) / 100 - 1;
- if (w > 0) { // Prevents -1 turning into unsigned int
+ w = (f * type->BoxHeight) / 100 - 1;
+ if (w > 0) { // Prevents -1 turning into unsigned int
VideoFillRectangleClip(color,
x + ((type->TileWidth * TileSizeX - type->BoxWidth) /
2) + 1,
(y + (type->TileHeight * TileSizeY - type->BoxHeight) /
2) +
@@ -1393,7 +1389,7 @@
DrawManaSprite(x,y,type,unit->Orders[0].Type->Stats[
unit->Player->Player].Costs[TimeCost],
unit->Data.UpgradeTo.Ticks);
-
+
//
// Carry resource.
//
@@ -1545,7 +1541,7 @@
}
return;
}
-
+
// Use ShadowSprite if the unit flies
if (type->UnitType == UnitTypeFly) {
int i;
@@ -1698,7 +1694,7 @@
/**
** Get the location of an unit's order.
-**
+**
** @param unit Pointer to unit.
** @param order Pointer to order.
** @param x Resulting screen X cordinate.
@@ -1761,7 +1757,7 @@
int dest;
GetOrderPosition(unit, order, &x2, &y2);
-
+
dest = 0;
switch (order->Action) {
case UnitActionNone:
@@ -1892,7 +1888,7 @@
if (unit->Destroyed) {
return;
}
-
+
x1 = Map2ViewportX(CurrentViewport,
unit->X) + unit->IX + unit->Type->TileWidth * TileSizeX / 2;
y1 = Map2ViewportY(CurrentViewport,
@@ -2012,7 +2008,7 @@
SDL_LockSurface(sprite->Surface);
SDL_SetColors(sprite->Surface, unit->Colors->Colors, 208, 4);
if (sprite->SurfaceFlip) {
- SDL_SetColors(sprite->SurfaceFlip, unit->Colors->Colors, 208, 4);
+ SDL_SetColors(sprite->SurfaceFlip, unit->Colors->Colors, 208, 4);
}
SDL_UnlockSurface(sprite->Surface);
#else
@@ -2312,8 +2308,8 @@
drawlevel2 = c2->Type->DrawLevel;
}
if (drawlevel1 == drawlevel2) {
- return c1->Y * MaxMapWidth + c1->X - c2->Y * MaxMapWidth - c2->X ?
- c1->Y * MaxMapWidth + c1->X - c2->Y * MaxMapWidth - c2->X :
+ return c1->Y * MaxMapWidth + c1->X - c2->Y * MaxMapWidth - c2->X ?
+ c1->Y * MaxMapWidth + c1->X - c2->Y * MaxMapWidth - c2->X :
c1->Slot - c2->Slot;
} else {
return drawlevel1 <= drawlevel2 ? -1 : 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src ai/ccl_ai.c clone/ccl.c clone/ccl...,
Jimmy Salmon <=