[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src clone/clone.c clone/player.c clon...
From: |
Nehal Mistry |
Subject: |
[Stratagus-CVS] stratagus/src clone/clone.c clone/player.c clon... |
Date: |
Thu, 20 Nov 2003 02:59:46 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Nehal Mistry <address@hidden> 03/11/20 02:59:45
Modified files:
src/clone : clone.c player.c unit_draw.c
src/game : game.c loadgame.c
src/include : video.h
src/ui : ccl_ui.c menus.c
src/video : graphic.c sdl.c video.c
Log message:
fix unit colors
Patches:
Index: stratagus/src/clone/clone.c
diff -u stratagus/src/clone/clone.c:1.227 stratagus/src/clone/clone.c:1.228
--- stratagus/src/clone/clone.c:1.227 Mon Nov 17 18:45:20 2003
+++ stratagus/src/clone/clone.c Thu Nov 20 02:59:43 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: clone.c,v 1.227 2003/11/17 23:45:20 nehalmistry Exp $
+// $Id: clone.c,v 1.228 2003/11/20 07:59:43 nehalmistry Exp $
//@{
@@ -1046,11 +1046,10 @@
TheMap.TerrainName = Tilesets[0]->Ident;
LoadTileset();
#ifdef USE_SDL_SURFACE
- LoadRGB(&GlobalPalette, s = strdcat3(StratagusLibPath,
+ GlobalPalette = LoadRGB(s = strdcat3(StratagusLibPath,
"/graphics/", Tilesets[0]->PaletteFile));
TheMap.TerrainName = NULL;
free(s);
- VideoCreatePalette(&GlobalPalette);
#else
LoadRGB(GlobalPalette, s = strdcat3(StratagusLibPath,
"/graphics/", Tilesets[0]->PaletteFile));
Index: stratagus/src/clone/player.c
diff -u stratagus/src/clone/player.c:1.101 stratagus/src/clone/player.c:1.102
--- stratagus/src/clone/player.c:1.101 Tue Nov 18 12:56:21 2003
+++ stratagus/src/clone/player.c Thu Nov 20 02:59:43 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: player.c,v 1.101 2003/11/18 17:56:21 pludov Exp $
+// $Id: player.c,v 1.102 2003/11/20 07:59:43 nehalmistry Exp $
//@{
@@ -220,7 +220,7 @@
int j;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: players $Id: player.c,v 1.101 2003/11/18
17:56:21 pludov Exp $\n\n");
+ CLprintf(file, ";;; MODULE: players $Id: player.c,v 1.102 2003/11/20
07:59:43 nehalmistry Exp $\n\n");
//
// Dump table wc2 race numbers -> internal symbol.
@@ -880,8 +880,13 @@
global void GraphicPlayerPixels(const Player* player, const Graphic* sprite)
{
#ifdef USE_SDL_SURFACE
- memcpy(&sprite->Surface->format->palette->colors[208],
- player->UnitColors.Colors, sizeof(SDL_Color) * 4);
+ SDL_LockSurface(sprite->Surface);
+ SDL_SetColors(sprite->Surface, ((Player*)player)->UnitColors.Colors, 208,
4);
+ if (sprite->SurfaceFlip) {
+ SDL_SetColors(sprite->SurfaceFlip,
+ ((Player*)player)->UnitColors.Colors, 208, 4);
+ }
+ SDL_UnlockSurface(sprite->Surface);
#else
switch (VideoBpp) {
case 8:
@@ -913,8 +918,9 @@
global void PlayerPixels(const Player* player)
{
#ifdef USE_SDL_SURFACE
- memcpy(&GlobalPalette.colors[208], player->UnitColors.Colors,
- sizeof(Pixels) * 4);
+ // FIXME:
+ memcpy(&GlobalPalette->colors[208], player->UnitColors.Colors,
+ sizeof(SDL_Color) * 4);
#else
// FIXME: use function pointer
switch (VideoBpp) {
@@ -947,32 +953,22 @@
int i;
int o;
-// Pixels->colors = calloc(256, sizeof(SDL_Color));
-
//o = rand() & 0x7; // FIXME: random colors didn't
work
o = 0;
#ifdef USE_SDL_SURFACE
for (i = 0; i < 7; ++i) {
- Players[o].UnitColors.Colors[0] = GlobalPalette.colors[208];
- Players[o].UnitColors.Colors[1] = GlobalPalette.colors[209];
- Players[o].UnitColors.Colors[2] = GlobalPalette.colors[210];
- Players[o].UnitColors.Colors[3] = GlobalPalette.colors[211];
-
- Players[o + 8].UnitColors.Colors[0] = GlobalPalette.colors[208];
- Players[o + 8].UnitColors.Colors[1] = GlobalPalette.colors[209];
- Players[o + 8].UnitColors.Colors[2] = GlobalPalette.colors[210];
- Players[o + 8].UnitColors.Colors[3] = GlobalPalette.colors[211];
+ memcpy(Players[o].UnitColors.Colors, &GlobalPalette->colors[208 + i *
4],
+ sizeof(SDL_Color) * 4);
+ memcpy(Players[o + 8].UnitColors.Colors, &GlobalPalette->colors[208 + i
* 4],
+ sizeof(SDL_Color) * 4);
o = (o + 1) & 0x7;
}
- Players[o].UnitColors.Colors[0] = GlobalPalette.colors[12];
- Players[o].UnitColors.Colors[1] = GlobalPalette.colors[13];
- Players[o].UnitColors.Colors[2] = GlobalPalette.colors[14];
- Players[o].UnitColors.Colors[3] = GlobalPalette.colors[15];
- Players[o+8].UnitColors.Colors[0] = GlobalPalette.colors[12];
- Players[o+8].UnitColors.Colors[1] = GlobalPalette.colors[13];
- Players[o+8].UnitColors.Colors[2] = GlobalPalette.colors[14];
- Players[o+8].UnitColors.Colors[3] = GlobalPalette.colors[15];
+ memcpy(Players[o].UnitColors.Colors, &GlobalPalette->colors[12],
+ sizeof(SDL_Color) * 4);
+ memcpy(Players[o + 8].UnitColors.Colors, &GlobalPalette->colors[12],
+ sizeof(SDL_Color) * 4);
+
#else
switch (VideoBpp) {
case 8:
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.185
stratagus/src/clone/unit_draw.c:1.186
--- stratagus/src/clone/unit_draw.c:1.185 Tue Nov 18 12:56:23 2003
+++ stratagus/src/clone/unit_draw.c Thu Nov 20 02:59:43 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit_draw.c,v 1.185 2003/11/18 17:56:23 pludov Exp $
+// $Id: unit_draw.c,v 1.186 2003/11/20 07:59:43 nehalmistry Exp $
//@{
@@ -947,7 +947,7 @@
global void SaveDecorations(CLFile* file)
{
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: decorations $Id: unit_draw.c,v 1.185
2003/11/18 17:56:23 pludov Exp $\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, "(mana-sprite \"%s\" %d %d %d %d)\n",
ManaSprite.File, ManaSprite.HotX, ManaSprite.HotY,
@@ -2009,8 +2009,12 @@
local void GraphicUnitPixels(const Unit* unit, const Graphic* sprite)
{
#ifdef USE_SDL_SURFACE
- memcpy(&sprite->Surface->format->palette->colors[208],
- unit->Colors->Colors, sizeof(SDL_Color) * 4);
+ 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_UnlockSurface(sprite->Surface);
#else
switch (VideoBpp) {
case 8:
Index: stratagus/src/game/game.c
diff -u stratagus/src/game/game.c:1.114 stratagus/src/game/game.c:1.115
--- stratagus/src/game/game.c:1.114 Wed Nov 19 21:22:29 2003
+++ stratagus/src/game/game.c Thu Nov 20 02:59:44 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: game.c,v 1.114 2003/11/20 02:22:29 pludov Exp $
+// $Id: game.c,v 1.115 2003/11/20 07:59:44 nehalmistry Exp $
//@{
@@ -396,11 +396,10 @@
// Graphic part
//
#ifdef USE_SDL_SURFACE
- LoadRGB(&GlobalPalette,
- s = strdcat3(StratagusLibPath, "/graphics/",
+ GlobalPalette = LoadRGB(s = strdcat3(StratagusLibPath, "/graphics/",
TheMap.Tileset->PaletteFile));
free(s);
- VideoCreatePalette(&GlobalPalette);
+ SetPlayersPalette();
#else
LoadRGB(GlobalPalette,
s = strdcat3(StratagusLibPath, "/graphics/",
Index: stratagus/src/game/loadgame.c
diff -u stratagus/src/game/loadgame.c:1.71 stratagus/src/game/loadgame.c:1.72
--- stratagus/src/game/loadgame.c:1.71 Wed Nov 19 21:22:29 2003
+++ stratagus/src/game/loadgame.c Thu Nov 20 02:59:44 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: loadgame.c,v 1.71 2003/11/20 02:22:29 pludov Exp $
+// $Id: loadgame.c,v 1.72 2003/11/20 07:59:44 nehalmistry Exp $
//@{
@@ -204,11 +204,10 @@
#endif
#ifdef USE_SDL_SURFACE
- LoadRGB(&GlobalPalette,
- s = strdcat3(StratagusLibPath, "/graphics/",
+ GlobalPalette = LoadRGB(s = strdcat3(StratagusLibPath, "/graphics/",
TheMap.Tileset->PaletteFile));
free(s);
- VideoCreatePalette(&GlobalPalette);
+ SetPlayersPalette();
#else
LoadRGB(GlobalPalette,
s = strdcat3(StratagusLibPath, "/graphics/",
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.97 stratagus/src/include/video.h:1.98
--- stratagus/src/include/video.h:1.97 Thu Nov 20 01:43:41 2003
+++ stratagus/src/include/video.h Thu Nov 20 02:59:44 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.h,v 1.97 2003/11/20 06:43:41 nehalmistry Exp $
+// $Id: video.h,v 1.98 2003/11/20 07:59:44 nehalmistry Exp $
#ifndef __VIDEO_H__
#define __VIDEO_H__
@@ -228,7 +228,7 @@
/// Loaded system palette. 256-entries long, active system palette.
// FIXME: use SDL_Palette
-extern SDL_Palette GlobalPalette;
+extern SDL_Palette* GlobalPalette;
typedef unsigned char GraphicData; /// generic graphic data type
@@ -291,10 +291,7 @@
/// Load palette from resource. Just loads palette, to set it use
/// VideoCreatePalette, which sets system palette.
// FIXME: use SDL_Palette
-extern void LoadRGB(SDL_Palette* pal,const char* name);
-
- /// Set the system hardware palette from an independant Palette
struct.
-extern void VideoCreatePalette(const SDL_Palette* palette);
+extern SDL_Palette* LoadRGB(const char* name);
/// Load sprite
extern Graphic* LoadSprite(const char* file, int w, int h);
Index: stratagus/src/ui/ccl_ui.c
diff -u stratagus/src/ui/ccl_ui.c:1.154 stratagus/src/ui/ccl_ui.c:1.155
--- stratagus/src/ui/ccl_ui.c:1.154 Wed Nov 19 23:47:43 2003
+++ stratagus/src/ui/ccl_ui.c Thu Nov 20 02:59:44 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_ui.c,v 1.154 2003/11/20 04:47:43 jsalmon3 Exp $
+// $Id: ccl_ui.c,v 1.155 2003/11/20 07:59:44 nehalmistry Exp $
//@{
@@ -298,7 +298,7 @@
}
TheUI.Contrast = i;
#ifdef USE_SDL_SURFACE
- VideoCreatePalette(&GlobalPalette); // rebuild palette
+ // FIXME
#else
VideoCreatePalette(GlobalPalette); // rebuild palette
#endif
@@ -352,7 +352,7 @@
}
TheUI.Brightness = i;
#ifdef USE_SDL_SURFACE
- VideoCreatePalette(&GlobalPalette); // rebuild palette
+ // FIXME:
#else
VideoCreatePalette(GlobalPalette); // rebuild palette
#endif
@@ -406,7 +406,7 @@
}
TheUI.Saturation = i;
#ifdef USE_SDL_SURFACE
- VideoCreatePalette(&GlobalPalette); // rebuild palette
+ // FIXME
#else
VideoCreatePalette(GlobalPalette); // rebuild palette
#endif
Index: stratagus/src/ui/menus.c
diff -u stratagus/src/ui/menus.c:1.592 stratagus/src/ui/menus.c:1.593
--- stratagus/src/ui/menus.c:1.592 Mon Nov 17 19:48:16 2003
+++ stratagus/src/ui/menus.c Thu Nov 20 02:59:45 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: menus.c,v 1.592 2003/11/18 00:48:16 nehalmistry Exp $
+// $Id: menus.c,v 1.593 2003/11/20 07:59:45 nehalmistry Exp $
//@{
@@ -5784,11 +5784,11 @@
LoadTileset();
ChangeTilesetPud(old, &TheMap);
#ifdef USE_SDL_SURFACE
- LoadRGB(&GlobalPalette,
- s=strdcat3(StratagusLibPath,"/graphics/",
+ GlobalPalette = LoadRGB(s = strdcat3(StratagusLibPath,"/graphics/",
TheMap.Tileset->PaletteFile));
free(s);
- VideoCreatePalette(&GlobalPalette);
+ SetPlayersPalette();
+// VideoCreatePalette(GlobalPalette);
#else
LoadRGB(GlobalPalette,
s=strdcat3(StratagusLibPath,"/graphics/",
Index: stratagus/src/video/graphic.c
diff -u stratagus/src/video/graphic.c:1.51 stratagus/src/video/graphic.c:1.52
--- stratagus/src/video/graphic.c:1.51 Thu Nov 20 01:53:14 2003
+++ stratagus/src/video/graphic.c Thu Nov 20 02:59:45 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: graphic.c,v 1.51 2003/11/20 06:53:14 nehalmistry Exp $
+// $Id: graphic.c,v 1.52 2003/11/20 07:59:45 nehalmistry Exp $
//@{
@@ -585,11 +585,6 @@
((char*)s->pixels)[j + i * s->w] =
((char*)graphic->Surface->pixels)[s->w - j + i * s->w];
}
- }
-
- if (s->format->palette) {
- free(s->format->palette);
- s->format->palette = graphic->Surface->format->palette;
}
SDL_UnlockSurface(s);
Index: stratagus/src/video/sdl.c
diff -u stratagus/src/video/sdl.c:1.105 stratagus/src/video/sdl.c:1.106
--- stratagus/src/video/sdl.c:1.105 Wed Nov 19 22:05:48 2003
+++ stratagus/src/video/sdl.c Thu Nov 20 02:59:45 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sdl.c,v 1.105 2003/11/20 03:05:48 jsalmon3 Exp $
+// $Id: sdl.c,v 1.106 2003/11/20 07:59:45 nehalmistry Exp $
//@{
@@ -211,9 +211,9 @@
}
#ifdef USE_SDL_SURFACE
- if (VideoDepth == 8) {
- TheScreen->format->palette = &GlobalPalette;
- }
+// if (VideoDepth == 8) {
+// TheScreen->format->palette = &GlobalPalette;
+// }
#endif
#ifdef DEBUG
Index: stratagus/src/video/video.c
diff -u stratagus/src/video/video.c:1.71 stratagus/src/video/video.c:1.72
--- stratagus/src/video/video.c:1.71 Mon Nov 17 14:14:48 2003
+++ stratagus/src/video/video.c Thu Nov 20 02:59:45 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.c,v 1.71 2003/11/17 19:14:48 nehalmistry Exp $
+// $Id: video.c,v 1.72 2003/11/20 07:59:45 nehalmistry Exp $
//@{
@@ -213,7 +213,7 @@
/// Loaded system palette. 256-entries long, active system palette.
#ifdef USE_SDL_SURFACE
-global SDL_Palette GlobalPalette;
+global SDL_Palette* GlobalPalette;
#else
global Palette GlobalPalette[256];
#endif
@@ -620,21 +620,16 @@
}
/**
-** Load palette from resource. Just loads palette, to set it use
-** VideoCreatePalette, which sets system palette.
-**
-** @param pal buffer to store palette (256-entries long)
-** @param name resource file name
-**
-** @see VideoCreatePalette
+** FIXME
*/
#ifdef USE_SDL_SURFACE
-global void LoadRGB(SDL_Palette* pal, const char* name)
+global SDL_Palette* LoadRGB(const char* name)
{
CLFile* fp;
int i;
unsigned char* p;
unsigned char buffer[256 * 3];
+ SDL_Palette* pal;
if (!(fp = CLopen(name, CL_OPEN_READ)) || CLread(fp, buffer, 256 * 3) !=
256 * 3) {
fprintf(stderr, "Can't load palette %s\n", name);
@@ -655,8 +650,19 @@
}
CLclose(fp);
+
+ return pal;
}
#else
+/**
+** Load palette from resource. Just loads palette, to set it use
+** VideoCreatePalette, which sets system palette.
+**
+** @param pal buffer to store palette (256-entries long)
+** @param name resource file name
+**
+** @see VideoCreatePalette
+*/
global void LoadRGB(Palette* pal, const char* name)
{
CLFile* fp;
@@ -1394,17 +1400,7 @@
**
** @see SetPlayersPalette
*/
-#ifdef USE_SDL_SURFACE
-global void VideoSetPalette(const SDL_Palette* palette)
-{
- if (!GlobalPalette.colors) {
-// GlobalPalette = (SDL_Palette*)malloc(sizeof(SDL_Palette));
- GlobalPalette.colors = calloc(256, sizeof(SDL_Color));
- }
-// TheScreen->format->palette = (SDL_Palette*)palette;
- SetPlayersPalette();
-}
-#else
+#ifndef USE_SDL_SURFACE
global void VideoSetPalette(const VMemType* palette)
{
DebugLevel2Fn("Palette %x used\n" _C_ (unsigned)palette);
@@ -1426,15 +1422,7 @@
**
** @param palette System independ palette structure.
*/
-#ifdef USE_SDL_SURFACE
-global void VideoCreatePalette(const SDL_Palette* palette)
-{
-// SDL_SetPalette(
-// SDL_Palette* temp;
-// temp = VideoCreateNewPalette(palette);
- VideoSetPalette(palette);
-}
-#else
+#ifndef USE_SDL_SURFACE
global void VideoCreatePalette(const Palette* palette)
{
VMemType* temp;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src clone/clone.c clone/player.c clon...,
Nehal Mistry <=