stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/stratagus player.c script_player.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src/stratagus player.c script_player.c
Date: 28 Jan 2004 08:12:05 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/28 08:12:04

Modified files:
        src/stratagus  : player.c script_player.c 

Log message:
        Load/Save player colors

Patches:
Index: stratagus/src/stratagus/player.c
diff -u stratagus/src/stratagus/player.c:1.115 
stratagus/src/stratagus/player.c:1.116
--- stratagus/src/stratagus/player.c:1.115      Mon Jan 26 09:34:32 2004
+++ stratagus/src/stratagus/player.c    Wed Jan 28 08:12:04 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: player.c,v 1.115 2004/01/25 22:34:32 wizzard Exp $
+//      $Id: player.c,v 1.116 2004/01/27 21:12:04 jsalmon3 Exp $
 
 //@{
 
@@ -205,9 +205,12 @@
 {
        int i;
        int j;
+       unsigned char r;
+       unsigned char g;
+       unsigned char b;
 
        CLprintf(file, "\n--- -----------------------------------------\n");
-       CLprintf(file, "--- MODULE: players $Id: player.c,v 1.115 2004/01/25 
22:34:32 wizzard Exp $\n\n");
+       CLprintf(file, "--- MODULE: players $Id: player.c,v 1.116 2004/01/27 
21:12:04 jsalmon3 Exp $\n\n");
 
 #if 0
        //
@@ -364,7 +367,9 @@
                CLprintf(file, "\n  \"total-razings\", %d,", 
Players[i].TotalRazings);
                CLprintf(file, "\n  \"total-kills\", %d,", 
Players[i].TotalKills);
 
-               // Color done by init code.
+               SDL_GetRGB(Players[i].Color, TheScreen->format, &r, &g, &b);
+               CLprintf(file, "\n  \"color\", { %d, %d, %d },", r, g, b);
+
                // UnitColors done by init code.
 
                // Allow saved by allow.
Index: stratagus/src/stratagus/script_player.c
diff -u stratagus/src/stratagus/script_player.c:1.57 
stratagus/src/stratagus/script_player.c:1.58
--- stratagus/src/stratagus/script_player.c:1.57        Wed Jan 21 04:40:07 2004
+++ stratagus/src/stratagus/script_player.c     Wed Jan 28 08:12:04 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script_player.c,v 1.57 2004/01/20 17:40:07 nobody_ Exp $
+//      $Id: script_player.c,v 1.58 2004/01/27 21:12:04 jsalmon3 Exp $
 
 //@{
 
@@ -90,7 +90,6 @@
                NumPlayers = i + 1;
        }
        player->Player = i;
-       player->Color = PlayerColors[i][0];
        if (!(player->Units = (Unit**)calloc(UnitMax, sizeof(Unit*)))) {
                DebugLevel0("Not enough memory to create player %d.\n" _C_ i);
                return 0;
@@ -321,6 +320,25 @@
                        }
                } else if (!strcmp(value, "total-units")) {
                        player->TotalUnits = LuaToNumber(l, j + 1);
+               } else if (!strcmp(value, "color")) {
+                       int r;
+                       int g;
+                       int b;
+
+                       if (!lua_istable(l, j + 1) || luaL_getn(l, j + 1) != 3) 
{
+                               lua_pushstring(l, "incorrect argument");
+                               lua_error(l);
+                       }
+                       lua_rawgeti(l, j + 1, 1);
+                       r = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                       lua_rawgeti(l, j + 1, 2);
+                       g = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                       lua_rawgeti(l, j + 1, 3);
+                       b = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                       player->Color = SDL_MapRGB(TheScreen->format, r, g, b);
                } else if (!strcmp(value, "timers")) {
                        if (!lua_istable(l, j + 1)) {
                                lua_pushstring(l, "incorrect argument");




reply via email to

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