stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src editor/ccl_editor.c game/intro.c ...


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src editor/ccl_editor.c game/intro.c ...
Date: Thu, 20 Nov 2003 15:04:56 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/11/20 15:04:56

Modified files:
        src/editor     : ccl_editor.c 
        src/game       : intro.c 
        src/map        : ccl_map.c ccl_tileset.c 
        src/missile    : ccl_missile.c 
        src/pathfinder : ccl_pathfinder.c 
        src/video      : font.c 

Log message:
        Converted to LuaTo* functions, removed spaces

Patches:
Index: stratagus/src/editor/ccl_editor.c
diff -u stratagus/src/editor/ccl_editor.c:1.12 
stratagus/src/editor/ccl_editor.c:1.13
--- stratagus/src/editor/ccl_editor.c:1.12      Thu Nov 20 00:03:34 2003
+++ stratagus/src/editor/ccl_editor.c   Thu Nov 20 15:04:51 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_editor.c,v 1.12 2003/11/20 05:03:34 jsalmon3 Exp $
+//     $Id: ccl_editor.c,v 1.13 2003/11/20 20:04:51 jsalmon3 Exp $
 
 //@{
 
@@ -109,11 +109,7 @@
     EditorUnitTypes = cp = malloc((args + 1) * sizeof(char*));
     MaxUnitIndex = args;
     for (j = 0; j < args; ++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;
 
@@ -134,12 +130,12 @@
 #elif defined(USE_LUA)
 local int CclSetEditorSelectIcon(lua_State* l)
 {
-    if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
     free(EditorSelectIcon);
-    EditorSelectIcon = strdup(lua_tostring(l, 1));
+    EditorSelectIcon = strdup(LuaToString(l, 1));
     return 0;
 }
 #endif
@@ -157,12 +153,12 @@
 #elif defined(USE_LUA)
 local int CclSetEditorUnitsIcon(lua_State* l)
 {
-    if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
     free(EditorUnitsIcon);
-    EditorUnitsIcon = strdup(lua_tostring(l, 1));
+    EditorUnitsIcon = strdup(LuaToString(l, 1));
     return 0;
 }
 #endif
Index: stratagus/src/game/intro.c
diff -u stratagus/src/game/intro.c:1.106 stratagus/src/game/intro.c:1.107
--- stratagus/src/game/intro.c:1.106    Mon Nov 17 18:09:15 2003
+++ stratagus/src/game/intro.c  Thu Nov 20 15:04:52 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: intro.c,v 1.106 2003/11/17 23:09:15 nehalmistry Exp $
+//     $Id: intro.c,v 1.107 2003/11/20 20:04:52 jsalmon3 Exp $
 
 //@{
 
@@ -73,7 +73,7 @@
 } PlayerRanks;
 
 /**
-**     Linked list of TextLines 
+**     Linked list of TextLines
 */
 typedef struct ChapterTextLines {
     struct TextLines* Text;            /// TextLines struct
@@ -476,8 +476,8 @@
     while (1) {
 #ifdef WITH_SOUND
        // FIXME: move sound specific code to the sound files
-       if (soundfree != -1 && (!Channels[soundfree].Command) && 
-               stage < MAX_BRIEFING_VOICES && soundout != NextSoundRequestOut 
&& 
+       if (soundfree != -1 && (!Channels[soundfree].Command) &&
+               stage < MAX_BRIEFING_VOICES && soundout != NextSoundRequestOut 
&&
                intro->VoiceFile[stage]) {
            // FIXME: is there a better way to do this?
            if (soundcount == 15) {
@@ -1133,7 +1133,7 @@
            if (p == ThisPlayer || p->Type == PlayerNobody) {
                continue;
            }
-            sprintf(buf, "%u", p->TotalResources[GoldCost]);
+           sprintf(buf, "%u", p->TotalResources[GoldCost]);
            percent = p->TotalResources[GoldCost] * 100 / max;
            DrawStatBox(x + 190, y + bottom_offset + description_offset + 
line_spacing * c,
                buf, p->Color, percent);
@@ -1166,7 +1166,7 @@
            if (p == ThisPlayer || p->Type == PlayerNobody) {
                continue;
            }
-            sprintf(buf, "%u", p->TotalResources[WoodCost]);
+           sprintf(buf, "%u", p->TotalResources[WoodCost]);
            percent = p->TotalResources[WoodCost] * 100 / max;
            DrawStatBox(x + 280, y + bottom_offset + description_offset + 
line_spacing * c,
                buf, p->Color,percent);
@@ -1463,26 +1463,14 @@
 
     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);
        ++j;
        if (!strcmp(value, "background")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           GameCredits.Background = strdup(lua_tostring(l, j + 1));
+           GameCredits.Background = strdup(LuaToString(l, j + 1));
        } else if (!strcmp(value, "name") ||
                !strcmp(value, "title") ||
                !strcmp(value, "comment")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           n = lua_tostring(l, j + 1);
+           n = LuaToString(l, j + 1);
            nlen = strlen(n);
            GameCredits.Names = (char*)realloc(GameCredits.Names, len + nlen + 
2);
            if (len != 0) {
@@ -1687,12 +1675,12 @@
     int len;
     int args;
 
-    if (lua_gettop(l) != 2 || !lua_isstring(l, 1) || !lua_istable(l, 2)) {
+    if (lua_gettop(l) != 2) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
     rank = NULL;
-    race = lua_tostring(l, 1);
+    race = LuaToString(l, 1);
     for (i = 0; i < PlayerRaces.Count; ++i) {
        if (!strcmp(PlayerRaces.Name[i], race)) {
            rank = &Ranks[i];
@@ -1722,19 +1710,11 @@
     i = 0;
     for (j = 0; j < args; ++j) {
        lua_rawgeti(l, 2, j + 1);
-       if (!lua_isnumber(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       rank->Scores[i] = lua_tonumber(l, -1);
+       rank->Scores[i] = LuaToNumber(l, -1);
        lua_pop(l, 1);
        ++j;
        lua_rawgeti(l, 2, j + 1);
-       if (!lua_isstring(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       rank->Ranks[i] = strdup(lua_tostring(l, -1));
+       rank->Ranks[i] = strdup(LuaToString(l, -1));
        lua_pop(l, 1);
        ++i;
     }
Index: stratagus/src/map/ccl_map.c
diff -u stratagus/src/map/ccl_map.c:1.43 stratagus/src/map/ccl_map.c:1.44
--- stratagus/src/map/ccl_map.c:1.43    Wed Nov 12 15:20:12 2003
+++ stratagus/src/map/ccl_map.c Thu Nov 20 15:04:54 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_map.c,v 1.43 2003/11/12 20:20:12 jsalmon3 Exp $
+//     $Id: ccl_map.c,v 1.44 2003/11/20 20:04:54 jsalmon3 Exp $
 
 //@{
 
@@ -122,7 +122,7 @@
                    TheMap.Terrain = i;
                    // Ignore: str=gh_scm2newstr(gh_cadr(value),NULL);
                    LoadTileset();
-                  
+
                } else if (gh_eq_p(value, gh_symbol2scm("size"))) {
                    value = gh_car(data);
                    data = gh_cdr(data);
@@ -292,12 +292,12 @@
 #elif defined(USE_LUA)
 local int CclCenterMap(lua_State* l)
 {
-    if (lua_gettop(l) != 2 || !lua_isnumber(l, 1) || !lua_isnumber(l, 2)) {
+    if (lua_gettop(l) != 2) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
     ViewportCenterViewpoint(TheUI.SelectedViewport,
-       lua_tonumber(l, 1), lua_tonumber(l, 2));
+       LuaToNumber(l, 1), LuaToNumber(l, 2));
 
     return 0;
 }
@@ -340,19 +340,18 @@
     // Put a unit on map, use it's properties, except for
     // what is listed below
 
-    if (lua_gettop(l) != 4 || !lua_isnumber(l, 1) || !lua_isnumber(l, 2) ||
-           !lua_isnumber(l, 3) || !lua_isnumber(l, 4) || !lua_isstring(l, 5)) {
+    if (lua_gettop(l) != 4) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    unitname = lua_tostring(l, 5);
+    unitname = LuaToString(l, 5);
     target = MakeUnit(UnitTypeByIdent(unitname), ThisPlayer);
     target->Orders[0].Action = UnitActionStill;
     target->HP = 0;
-    target->X = lua_tonumber(l, 1);
-    target->Y = lua_tonumber(l, 2);
-    target->TTL = GameCycle + lua_tonumber(l, 4);
-    target->CurrentSightRange = lua_tonumber(l, 3);
+    target->X = LuaToNumber(l, 1);
+    target->Y = LuaToNumber(l, 2);
+    target->TTL = GameCycle + LuaToNumber(l, 4);
+    target->CurrentSightRange = LuaToNumber(l, 3);
     MapMarkUnitSight(target);
     return 0;
 }
@@ -385,12 +384,12 @@
 {
     char* old;
 
-    if (lua_gettop(l) != 1 || !lua_isstring(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
     old = strdup(DefaultMap);
-    strcpy(DefaultMap, lua_tostring(l, 1));
+    strcpy(DefaultMap, LuaToString(l, 1));
 
     lua_pushstring(l, old);
     free(old);
@@ -420,12 +419,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 = !TheMap.NoFogOfWar;
-    TheMap.NoFogOfWar = !lua_toboolean(l, 1);
+    TheMap.NoFogOfWar = !LuaToBoolean(l, 1);
 
     lua_pushboolean(l, old);
     return 1;
@@ -454,12 +453,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 = MinimapWithTerrain;
-    MinimapWithTerrain = lua_toboolean(l, 1);
+    MinimapWithTerrain = LuaToBoolean(l, 1);
 
     lua_pushboolean(l, old);
     return 1;
@@ -558,11 +557,11 @@
     int i;
     int old;
 
-    if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    i = lua_tonumber(l, 1);
+    i = LuaToNumber(l, 1);
     if (i < 0 || i > 400) {
        PrintFunction();
        fprintf(stdout, "Contrast should be 0 - 400\n");
@@ -610,11 +609,11 @@
     int i;
     int old;
 
-    if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    i = lua_tonumber(l, 1);
+    i = LuaToNumber(l, 1);
     if (i < -100 || i > 100) {
        PrintFunction();
        fprintf(stdout, "Brightness should be -100 - 100\n");
@@ -662,11 +661,11 @@
     int i;
     int old;
 
-    if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    i = lua_tonumber(l, 1);
+    i = LuaToNumber(l, 1);
     if (i < -100 || i > 200) {
        PrintFunction();
        fprintf(stdout, "Saturation should be -100 - 200\n");
@@ -714,11 +713,11 @@
     int i;
     int old;
 
-    if (lua_gettop(l) != 1 || !lua_isnumber(l, 1)) {
+    if (lua_gettop(l) != 1) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    i = lua_tonumber(l, 1);
+    i = LuaToNumber(l, 1);
     if (i < 0 || i > 255) {
        PrintFunction();
        fprintf(stdout, "Regneration speed should be 0 - 255\n");
Index: stratagus/src/map/ccl_tileset.c
diff -u stratagus/src/map/ccl_tileset.c:1.32 
stratagus/src/map/ccl_tileset.c:1.33
--- stratagus/src/map/ccl_tileset.c:1.32        Wed Nov 12 15:20:12 2003
+++ stratagus/src/map/ccl_tileset.c     Thu Nov 20 15:04:54 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_tileset.c,v 1.32 2003/11/12 20:20:12 jsalmon3 Exp $
+//     $Id: ccl_tileset.c,v 1.33 2003/11/20 20:04:54 jsalmon3 Exp $
 
 //@{
 
@@ -107,11 +107,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;
 
@@ -179,11 +175,7 @@
     char* ident;
     int i;
 
-    if (!lua_isstring(l, -1)) {
-       lua_pushstring(l, "incorrect argument");
-       lua_error(l);
-    }
-    ident = strdup(lua_tostring(l, -1));
+    ident = strdup(LuaToString(l, -1));
     for (i = 0; i < tileset->NumTerrainTypes; ++i) {
        if (!strcmp(ident, tileset->SolidTerrainTypes[i].TerrainName)) {
            free(ident);
@@ -275,12 +267,8 @@
     flags = 0;
     while (1) {
        lua_rawgeti(l, -1, *j + 1);
-       if (!lua_isstring(l, -1)) {
-           lua_pop(l, 1);
-           break;
-       }
        ++(*j);
-       value = lua_tostring(l, -1);
+       value = LuaToString(l, -1);
        lua_pop(l, 1);
 
        //
@@ -407,11 +395,7 @@
     //
     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);
 
        //
@@ -420,29 +404,17 @@
        if (!strcmp(value, "top-one-tree")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->TopOneTree = lua_tonumber(l, -1);
+           tileset->TopOneTree = LuaToNumber(l, -1);
            lua_pop(l, 1);
        } else if (!strcmp(value, "mid-one-tree")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->MidOneTree = lua_tonumber(l, -1);
+           tileset->MidOneTree = LuaToNumber(l, -1);
            lua_pop(l, 1);
        } else if (!strcmp(value, "bot-one-tree")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->BotOneTree = lua_tonumber(l, -1);
+           tileset->BotOneTree = LuaToNumber(l, -1);
            lua_pop(l, 1);
        //
        //      removed-tree
@@ -450,11 +422,7 @@
        } else if (!strcmp(value, "removed-tree")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->RemovedTree = lua_tonumber(l, -1);
+           tileset->RemovedTree = LuaToNumber(l, -1);
            lua_pop(l, 1);
        //
        //      growing-tree
@@ -472,11 +440,7 @@
            }
            for (i = 0; i < 2; ++i) {
                lua_rawgeti(l, -1, i + 1);
-               if (!lua_isnumber(l, -1)) {
-                   lua_pushstring(l, "incorrect argument");
-                   lua_error(l);
-               }
-               tileset->GrowingTree[i] = lua_tonumber(l, -1);
+               tileset->GrowingTree[i] = LuaToNumber(l, -1);
                lua_pop(l, 1);
            }
            lua_pop(l, 1);
@@ -487,29 +451,17 @@
        } else if (!strcmp(value, "top-one-rock")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->TopOneRock = lua_tonumber(l, -1);
+           tileset->TopOneRock = LuaToNumber(l, -1);
            lua_pop(l, 1);
        } else if (!strcmp(value, "mid-one-rock")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->MidOneRock = lua_tonumber(l, -1);
+           tileset->MidOneRock = LuaToNumber(l, -1);
            lua_pop(l, 1);
        } else if (!strcmp(value, "bot-one-rock")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->BotOneRock = lua_tonumber(l, -1);
+           tileset->BotOneRock = LuaToNumber(l, -1);
            lua_pop(l, 1);
        //
        //      removed-rock
@@ -517,11 +469,7 @@
        } else if (!strcmp(value, "removed-rock")) {
            ++j;
            lua_rawgeti(l, -1, j + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->RemovedRock = lua_tonumber(l, -1);
+           tileset->RemovedRock = LuaToNumber(l, -1);
            lua_pop(l, 1);
        } else {
            lua_pushfstring(l, "special: unsupported tag: %s", value);
@@ -631,12 +579,8 @@
 
     for (i = 0; i < len; ++i) {
        lua_rawgeti(l, -1, i + 1);
-       if (!lua_isnumber(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       tileset->Table[index + i] = lua_tonumber(l, -1);
-//     tt->SolidTiles[i] = tileset->Table[index + i] = lua_tonumber(l, -1);
+       tileset->Table[index + i] = LuaToNumber(l, -1);
+//     tt->SolidTiles[i] = tileset->Table[index + i] = LuaToNumber(l, -1);
        lua_pop(l, 1);
        tileset->FlagsTable[index + i] = f;
        tileset->Tiles[index + i].BaseTerrain = basic_name;
@@ -769,11 +713,7 @@
        len = luaL_getn(l, -1);
        for (i = 0; i < len; ++i) {
            lua_rawgeti(l, -1, i + 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->Table[index + i] = lua_tonumber(l, -1);
+           tileset->Table[index + i] = LuaToNumber(l, -1);
            tileset->FlagsTable[index + i] = f;
            tileset->Tiles[index + i].BaseTerrain = basic_name;
            tileset->Tiles[index + i].MixTerrain = mixed_name;
@@ -909,11 +849,7 @@
     args = luaL_getn(l, t);
     for (j = 0; j < args; ++j) {
        lua_rawgeti(l, t, 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;
 
@@ -989,19 +925,11 @@
     args = luaL_getn(l, t);
     for (j = 0; j < args; ++j) {
        lua_rawgeti(l, -1, j + 1);
-       if (!lua_isnumber(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       num = lua_tonumber(l, -1);
+       num = LuaToNumber(l, -1);
        lua_pop(l, 1);
        ++j;
        lua_rawgeti(l, -1, j + 1);
-       if (!lua_isstring(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       unit = strdup(lua_tostring(l, -1));
+       unit = strdup(LuaToString(l, -1));
        lua_pop(l, 1);
        sprintf(buf, "%d", num);
        if ((h = (char**)hash_find(tileset->ItemsHash, buf)) != NULL) {
@@ -1123,11 +1051,7 @@
     int args;
     int j;
 
-    if (!lua_isstring(l, 1)) {
-       lua_pushstring(l, "incorrect argument");
-       lua_error(l);
-    }
-    ident = strdup(lua_tostring(l, 1));
+    ident = strdup(LuaToString(l, 1));
 
     //
     // Find the tile set.
@@ -1175,61 +1099,29 @@
     //
     args = lua_gettop(l);
     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;
 
        if (!strcmp(value, "file")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->File = strdup(lua_tostring(l, j + 1));
+           tileset->File = strdup(LuaToString(l, j + 1));
        } else if (!strcmp(value, "class")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->Class = strdup(lua_tostring(l, j + 1));
+           tileset->Class = strdup(LuaToString(l, j + 1));
        } else if (!strcmp(value, "name")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->Name = strdup(lua_tostring(l, j + 1));
+           tileset->Name = strdup(LuaToString(l, j + 1));
        } else if (!strcmp(value, "image")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->ImageFile = strdup(lua_tostring(l, j + 1));
+           tileset->ImageFile = strdup(LuaToString(l, j + 1));
        } else if (!strcmp(value, "palette")) {
-           if (!lua_isstring(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->PaletteFile = strdup(lua_tostring(l, j + 1));
+           tileset->PaletteFile = strdup(LuaToString(l, j + 1));
        } else if (!strcmp(value, "size")) {
            if (!lua_istable(l, j + 1)) {
                lua_pushstring(l, "incorrect argument");
                lua_error(l);
            }
            lua_rawgeti(l, j + 1, 1);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->TileSizeX = lua_tonumber(l, -1);
+           tileset->TileSizeX = LuaToNumber(l, -1);
            lua_pop(l, 1);
            lua_rawgeti(l, j + 1, 2);
-           if (!lua_isnumber(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           tileset->TileSizeY = lua_tonumber(l, -1);
+           tileset->TileSizeY = LuaToNumber(l, -1);
            lua_pop(l, 1);
        } else if (!strcmp(value, "slots")) {
            if (!lua_istable(l, j + 1)) {
Index: stratagus/src/missile/ccl_missile.c
diff -u stratagus/src/missile/ccl_missile.c:1.39 
stratagus/src/missile/ccl_missile.c:1.40
--- stratagus/src/missile/ccl_missile.c:1.39    Wed Nov 12 15:36:51 2003
+++ stratagus/src/missile/ccl_missile.c Thu Nov 20 15:04:54 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_missile.c,v 1.39 2003/11/12 20:36:51 jsalmon3 Exp $
+//     $Id: ccl_missile.c,v 1.40 2003/11/20 20:04:54 jsalmon3 Exp $
 
 //@{
 
@@ -216,11 +216,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;
 
@@ -364,7 +360,7 @@
            list = gh_cdr(list);
            missile->CurrentStep = gh_scm2int(gh_car(sublist));
            missile->TotalStep = gh_scm2int(gh_cadr(sublist));
-        }
+       }
     }
     return SCM_UNSPECIFIED;
 }
Index: stratagus/src/pathfinder/ccl_pathfinder.c
diff -u stratagus/src/pathfinder/ccl_pathfinder.c:1.24 
stratagus/src/pathfinder/ccl_pathfinder.c:1.25
--- stratagus/src/pathfinder/ccl_pathfinder.c:1.24      Wed Nov 19 21:22:30 2003
+++ stratagus/src/pathfinder/ccl_pathfinder.c   Thu Nov 20 15:04:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_pathfinder.c,v 1.24 2003/11/20 02:22:30 pludov Exp $
+//     $Id: ccl_pathfinder.c,v 1.25 2003/11/20 20:04:55 jsalmon3 Exp $
 
 //@{
 
@@ -62,13 +62,13 @@
 {
     SCM value;
     int i;
-    
+
     while( !gh_null_p(list) ) {
        value=gh_car(list);
        list=gh_cdr(list);
        if( gh_eq_p(value,gh_symbol2scm("fixed-unit-cost")) ) {
            i=gh_scm2int(gh_car(list));
-            list=gh_cdr(list);
+           list=gh_cdr(list);
            if( i <=3 ) {
                PrintFunction();
                fprintf(stdout,"Fixed unit crossing cost must be strictly > 
3\n");
@@ -101,7 +101,7 @@
            errl("Unsupported tag",value);
        }
     }
-                                         
+
     return SCM_UNSPECIFIED;
 }
 #elif defined(USE_LUA)
@@ -114,18 +114,10 @@
 
     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, "fixed-unit-cost")) {
            ++j;
-           if (!lua_isnumber(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           i = lua_tonumber(l, j + 1);
+           i = LuaToNumber(l, j + 1);
            if (i <= 3) {
                PrintFunction();
                fprintf(stdout, "Fixed unit crossing cost must be strictly > 
3\n");
@@ -134,11 +126,7 @@
            }
        } else if (!strcmp(value, "moving-unit-cost")) {
            ++j;
-           if (!lua_isnumber(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           i = lua_tonumber(l, j + 1);
+           i = LuaToNumber(l, j + 1);
            if (i <= 3) {
                PrintFunction();
                fprintf(stdout, "Moving unit crossing cost must be strictly > 
3\n");
@@ -151,11 +139,7 @@
            AStarKnowUnknown = 0;
        } else if (!strcmp(value, "unseen-terrain-cost")) {
            ++j;
-           if (!lua_isnumber(l, j + 1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           i = lua_tonumber(l, j + 1);
+           i = LuaToNumber(l, j + 1);
            if (i < 0) {
                PrintFunction();
                fprintf(stdout, "Unseen Terrain Cost must be non-negative\n");
Index: stratagus/src/video/font.c
diff -u stratagus/src/video/font.c:1.62 stratagus/src/video/font.c:1.63
--- stratagus/src/video/font.c:1.62     Mon Nov 17 18:02:30 2003
+++ stratagus/src/video/font.c  Thu Nov 20 15:04:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: font.c,v 1.62 2003/11/17 23:02:30 nehalmistry Exp $
+//     $Id: font.c,v 1.63 2003/11/20 20:04:55 jsalmon3 Exp $
 
 //@{
 
@@ -204,7 +204,7 @@
     dp = VideoMemory8 + x + y * VideoWidth - 1;
     da = VideoWidth - w;
     --w;
-    
+
 #define UNROLL \
     ++dp; \
     p = *++sp; \
@@ -621,7 +621,7 @@
                    rev = FontPixels;
                    FontPixels = ReverseTextColor;
 #endif
-                   
+
                    ++text;
                    break;
                case '<':
@@ -887,7 +887,7 @@
            sp += fp->Graphic->Width;
        }
 
-    }    
+    }
 }
 #else
 /**
@@ -1186,18 +1186,17 @@
 {
     int i;
 
-    if (lua_gettop(l) != 4 || !lua_isstring(l, 1) || !lua_isstring(l, 2) ||
-           !lua_isnumber(l, 3) || !lua_isnumber(l, 4)) {
+    if (lua_gettop(l) != 4) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    i = CclFontByIdentifier(lua_tostring(l, 1));
+    i = CclFontByIdentifier(LuaToString(l, 1));
     free(Fonts[i].File);
     VideoSaveFree(Fonts[i].Graphic);
     Fonts[i].Graphic = NULL;
-    Fonts[i].File = strdup(lua_tostring(l, 2));
-    Fonts[i].Width = lua_tonumber(l, 3);
-    Fonts[i].Height = lua_tonumber(l, 4);
+    Fonts[i].File = strdup(LuaToString(l, 2));
+    Fonts[i].Width = LuaToNumber(l, 3);
+    Fonts[i].Height = LuaToNumber(l, 4);
 
     return 0;
 }
@@ -1281,11 +1280,11 @@
     FontColorMapping* fcm;
     FontColorMapping** fcmp;
 
-    if (lua_gettop(l) != 2 || !lua_isstring(l, 1) || !lua_istable(l, 2)) {
+    if (lua_gettop(l) != 2) {
        lua_pushstring(l, "incorrect argument");
        lua_error(l);
     }
-    color = strdup(lua_tostring(l, 1));
+    color = strdup(LuaToString(l, 1));
 
     if (!FontColorMappings) {
        FontColorMappings = calloc(sizeof(*FontColorMappings), 1);
@@ -1312,25 +1311,13 @@
     }
     for (i = 0; i < NumFontColors; ++i) {
        lua_rawgeti(l, 2, i * 3 + 1);
-       if (!lua_isnumber(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       fcm->RGB[i].R = lua_tonumber(l, -1);
+       fcm->RGB[i].R = LuaToNumber(l, -1);
        lua_pop(l, 1);
        lua_rawgeti(l, 2, i * 3 + 2);
-       if (!lua_isnumber(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       fcm->RGB[i].G = lua_tonumber(l, -1);
+       fcm->RGB[i].G = LuaToNumber(l, -1);
        lua_pop(l, 1);
        lua_rawgeti(l, 2, i * 3 + 3);
-       if (!lua_isnumber(l, -1)) {
-           lua_pushstring(l, "incorrect argument");
-           lua_error(l);
-       }
-       fcm->RGB[i].B = lua_tonumber(l, -1);
+       fcm->RGB[i].B = LuaToNumber(l, -1);
        lua_pop(l, 1);
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]