[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/stratagus.h stratagus/scr...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/stratagus.h stratagus/scr... |
Date: |
17 Jan 2004 10:55:43 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/17 10:55:43
Modified files:
src/include : stratagus.h
src/stratagus : script.c stratagus.c
Log message:
Remove WithSound, add CompileOption()
Patches:
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.36
stratagus/src/include/stratagus.h:1.37
--- stratagus/src/include/stratagus.h:1.36 Sat Jan 17 05:40:02 2004
+++ stratagus/src/include/stratagus.h Sat Jan 17 10:55:42 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: stratagus.h,v 1.36 2004/01/16 18:40:02 nobody_ Exp $
+// $Id: stratagus.h,v 1.37 2004/01/16 23:55:42 nobody_ Exp $
#ifndef __STRATAGUS_H__
#define __STRATAGUS_H__
@@ -57,8 +57,8 @@
#define SPEED_OIL 1 /// Speed
factor for getting oil
#define SPEED_BUILD 1 /// Speed
factor for building
#define SPEED_TRAIN 1 /// Speed
factor for training
-#define SPEED_UPGRADE 1 /// Speed
factor for upgrading
-#define SPEED_RESEARCH 1 /// Speed
factor for researching
+#define SPEED_UPGRADE 1 /// Speed factor for
upgrading
+#define SPEED_RESEARCH 1 /// Speed factor for
researching
/*============================================================================
== Compiler repairs
@@ -519,6 +519,7 @@
/// How near could a depot be build to a resource
#define RESOURCE_DISTANCE 3
+extern char* CompileOptions;
//@}
#endif // !__STRATAGUS_H__
Index: stratagus/src/stratagus/script.c
diff -u stratagus/src/stratagus/script.c:1.156
stratagus/src/stratagus/script.c:1.157
--- stratagus/src/stratagus/script.c:1.156 Sat Jan 17 02:17:30 2004
+++ stratagus/src/stratagus/script.c Sat Jan 17 10:55:42 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script.c,v 1.156 2004/01/16 15:17:30 wizzard Exp $
+// $Id: script.c,v 1.157 2004/01/16 23:55:42 nobody_ Exp $
//@{
@@ -821,13 +821,24 @@
/**
** Compiled with sound.
*/
-local int CclWithSound(lua_State* l)
+local int CclGetCompileFeature(lua_State* l)
{
-#ifdef WITH_SOUND
- lua_pushboolean(l, 1);
-#else
- lua_pushboolean(l, 0);
-#endif
+ const char* str;
+
+ if (lua_gettop(l) != 1) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+
+ str = LuaToString(l, 1);
+ if (strstr(CompileOptions, str)) {
+ DebugLevel0Fn("I have %s\n" _C_ str);
+ lua_pushboolean(l, 1);
+ } else {
+ DebugLevel0Fn("I don't have %s\n" _C_ str);
+ lua_pushboolean(l, 0);
+ }
+
return 1;
}
@@ -937,6 +948,99 @@
.. Setup
............................................................................*/
+#ifdef META_LUA
+
+#define FAST_GET_STRING(keyval, v) \
+{ \
+ if (!strcmp(key, keyval)) { \
+ lua_pushstring(l, strdup(v)); \
+ return 1; \
+ } \
+}
+
+#define FAST_GET_INT(keyval, v) \
+{ \
+ if (!strcmp(key, keyval)) { \
+ lua_pushnumber(l, v); \
+ return 1; \
+ } \
+}
+
+#define FAST_GET_BOOL(keyval, v) \
+{ \
+ if (!strcmp(key, keyval)) { \
+ lua_pushboolean(l, v); \
+ return 1; \
+ } \
+}
+
+/**
+** Get a value from the big Stratagus struct.
+*/
+local int ScriptStratagusGetValue(lua_State* l)
+{
+ const char* key;
+
+ DebugCheck(lua_gettop(l) != 2);
+ key = LuaToString(l, -1);
+
+ // Here start the fields.
+ FAST_GET_STRING("LibraryPath", StratagusLibPath);
+ FAST_GET_INT("GameCycle", GameCycle);
+ FAST_GET_STRING("GameName", GameName);
+ FAST_GET_BOOL("GamePaused", GamePaused);
+
+ // Something went wrong.
+ lua_pushfstring(l, "Unknown field \"%s\". Going DOWN!!!\n", key);
+ lua_error(l);
+ return 0;
+}
+
+/**
+** Set a value from the big Stratagus struct.
+*/
+local int ScriptStratagusSetValue(lua_State* l)
+{
+ const char* key;
+
+ DebugCheck(lua_gettop(l) != 3);
+ key = LuaToString(l, -2);
+
+ // Here start the fields.
+ // Sorry, none yet.
+
+ // Something went wrong.
+ lua_pushfstring(l, "Unknown field \"%s\". Going DOWN!!!\n", key);
+ lua_error(l);
+ return 0;
+
+}
+
+/**
+** Initialize metatables and the main stratagus table.
+*/
+local void InitScript(void)
+{
+ lua_pushstring(Lua, "Stratagus");
+
+ /* First is the main table, and the metatable for Stratagus. */
+ lua_newtable(Lua);
+ lua_newtable(Lua);
+
+ lua_pushstring(Lua, "__index");
+ lua_pushcfunction(Lua, ScriptStratagusGetValue);
+ lua_settable(Lua, -3);
+ lua_pushstring(Lua, "__newindex");
+ lua_pushcfunction(Lua, ScriptStratagusSetValue);
+ lua_settable(Lua, -3);
+
+ lua_setmetatable(Lua, -2);
+
+ lua_settable(Lua, LUA_GLOBALSINDEX);
+}
+
+#endif
+
/**
** Initialize ccl and load the config file(s).
*/
@@ -950,6 +1054,11 @@
luaopen_debug(Lua);
lua_settop(Lua, 0); // discard any results
+#ifdef META_LUA
+ InitScript();
+#endif
+
+ lua_register(Lua, "CompileFeature", CclGetCompileFeature);
lua_register(Lua, "LibraryPath", CclStratagusLibraryPath);
lua_register(Lua, "GameCycle", CclGameCycle);
lua_register(Lua, "SetGameName", CclSetGameName);
@@ -1014,7 +1123,6 @@
lua_register(Lua, "Units", CclUnits);
- lua_register(Lua, "WithSound", CclWithSound);
lua_register(Lua, "GetStratagusHomePath", CclGetStratagusHomePath);
lua_register(Lua, "GetStratagusLibraryPath",
CclGetStratagusLibraryPath);
@@ -1091,7 +1199,7 @@
}
fprintf(fd, "--- -----------------------------------------\n");
- fprintf(fd, "--- $Id: script.c,v 1.156 2004/01/16 15:17:30 wizzard Exp
$\n");
+ fprintf(fd, "--- $Id: script.c,v 1.157 2004/01/16 23:55:42 nobody_ Exp
$\n");
fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
fprintf(fd, "SetGroupKeys(\"");
@@ -1127,7 +1235,7 @@
}
fprintf(fd, "--- -----------------------------------------\n");
- fprintf(fd, "--- $Id: script.c,v 1.156 2004/01/16 15:17:30 wizzard Exp
$\n");
+ fprintf(fd, "--- $Id: script.c,v 1.157 2004/01/16 23:55:42 nobody_ Exp
$\n");
// Global options
if (OriginalFogOfWar) {
@@ -1230,7 +1338,7 @@
extern SCM oblistvar;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: CCL $Id: script.c,v 1.156 2004/01/16
15:17:30 wizzard Exp $\n\n");
+ CLprintf(file, ";;; MODULE: CCL $Id: script.c,v 1.157 2004/01/16
23:55:42 nobody_ Exp $\n\n");
for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
SCM sym;
Index: stratagus/src/stratagus/stratagus.c
diff -u stratagus/src/stratagus/stratagus.c:1.248
stratagus/src/stratagus/stratagus.c:1.249
--- stratagus/src/stratagus/stratagus.c:1.248 Sat Jan 17 02:17:31 2004
+++ stratagus/src/stratagus/stratagus.c Sat Jan 17 10:55:43 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: stratagus.c,v 1.248 2004/01/16 15:17:31 wizzard Exp $
+// $Id: stratagus.c,v 1.249 2004/01/16 23:55:43 nobody_ Exp $
//@{
@@ -246,6 +246,7 @@
"Stratagus V" VERSION ", (c) 1998-2004 by The Stratagus Project.";
local char* MapName; /// Filename of the map to load
+global char* CompileOptions; /// Compile options.
/*----------------------------------------------------------------------------
-- Speedups FIXME: Move to some other more logic place
@@ -723,58 +724,7 @@
#ifdef USE_SDL
"\n SDL Copyright by Sam Lantinga."
#endif
- "\nCompile options "
-#ifdef USE_THREAD
- "THREAD "
-#endif
-#ifdef DEBUG
- "DEBUG "
-#endif
-#ifdef USE_ZLIB
- "ZLIB "
-#endif
-#ifdef USE_BZ2LIB
- "BZ2LIB "
-#endif
-#ifdef USE_SDL
- "SDL "
-#endif
-#ifdef USE_SDLA
- "SDL-AUDIO "
-#endif
-#ifdef USE_SDLCD
- "SDL-CD "
-#endif
-#ifdef WITH_SOUND
- "SOUND "
-#endif
-#ifdef USE_LIBCDA
- "LIBCDA "
-#endif
-#ifdef USE_FLAC
- "FLAC "
-#endif
-#ifdef USE_OGG
- "OGG "
-#endif
-#ifdef USE_MAD
- "MP3 "
-#endif
- // New features:
- "\nCompile feature "
-#ifdef UNIT_ON_MAP
- "UNIT-ON-MAP "
-#endif
-#ifdef NEW_MAPDRAW
- "NEW-MAPDRAW "
-#endif
-#ifdef HIERARCHIC_PATHFINDER
- "HIERARCHIC-PATHFINDER "
-#endif
-#ifdef MAP_REGIONS
- "MAP_REGIONS "
-#endif
- , NameLine);
+ "\nCompile options %s", NameLine, CompileOptions);
}
/**
@@ -947,6 +897,63 @@
*/
global int main(int argc, char** argv)
{
+ CompileOptions =
+#ifdef USE_THREAD
+ "THREAD "
+#endif
+#ifdef DEBUG
+ "DEBUG "
+#endif
+#ifdef USE_ZLIB
+ "ZLIB "
+#endif
+#ifdef USE_BZ2LIB
+ "BZ2LIB "
+#endif
+#ifdef USE_SDL
+ "SDL "
+#endif
+#ifdef USE_SDLA
+ "SDL-AUDIO "
+#endif
+#ifdef USE_SDLCD
+ "SDL-CD "
+#endif
+#ifdef WITH_SOUND
+ "SOUND "
+#endif
+#ifdef USE_LIBCDA
+ "LIBCDA "
+#endif
+#ifdef USE_FLAC
+ "FLAC "
+#endif
+#ifdef USE_OGG
+ "OGG "
+#endif
+#ifdef USE_MAD
+ "MP3 "
+#endif
+#ifdef UNIT_ON_MAP
+ "UNIT-ON-MAP "
+#endif
+#ifdef NEW_UNIT_CACHE
+ "NEW-UNIT-CACHE "
+#endif
+#ifdef NEW_MAPDRAW
+ "NEW-MAPDRAW "
+#endif
+#ifdef HIERARCHIC_PATHFINDER
+ "HIERARCHIC-PATHFINDER "
+#endif
+#ifdef MAP_REGIONS
+ "MAP-REGIONS "
+#endif
+#ifdef USE_OPENGL
+ "OPENGL "
+#endif
+ ;
+
#ifdef USE_BEOS
//
// Parse arguments for BeOS
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/stratagus.h stratagus/scr...,
address@hidden <=