Made palette file part of the tileset structure.
This commit is contained in:
parent
ebff2d3075
commit
07824aa35c
6 changed files with 108 additions and 105 deletions
|
@ -21,6 +21,7 @@
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "freecraft.h"
|
||||
|
@ -171,19 +172,23 @@ global void SaveMap(FILE* file)
|
|||
*/
|
||||
global void CreateGame(char* filename, WorldMap* map)
|
||||
{
|
||||
char* PalettePath;
|
||||
int i, j;
|
||||
char* s;
|
||||
|
||||
if (filename == NULL) {
|
||||
ProcessMenu(MENU_PRG_START, 1);
|
||||
} else {
|
||||
s=NULL;
|
||||
if (filename[0] != '/' && filename[0] != '.') {
|
||||
filename = strdcat3(FreeCraftLibPath, "/", filename);
|
||||
s= filename = strdcat3(FreeCraftLibPath, "/", filename);
|
||||
}
|
||||
//
|
||||
// Load the map.
|
||||
//
|
||||
LoadMap(filename, map);
|
||||
if( s ) {
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
|
||||
if( FlagRevealMap ) {
|
||||
|
@ -224,35 +229,14 @@ global void CreateGame(char* filename, WorldMap* map)
|
|||
NetworkInSync=1;
|
||||
}
|
||||
|
||||
DebugLevel3("Terrain %d\n",TheMap.Terrain);
|
||||
|
||||
// FIXME: must use palette from tileset!!
|
||||
// FIXME: this must be extendable!!
|
||||
|
||||
switch( TheMap.Terrain ) {
|
||||
case TilesetSummer:
|
||||
PalettePath = strdcat(FreeCraftLibPath, "/summer.rgb");
|
||||
break;
|
||||
case TilesetWinter:
|
||||
PalettePath = strdcat(FreeCraftLibPath, "/winter.rgb");
|
||||
break;
|
||||
case TilesetWasteland:
|
||||
PalettePath = strdcat(FreeCraftLibPath, "/wasteland.rgb");
|
||||
break;
|
||||
case TilesetSwamp:
|
||||
PalettePath = strdcat(FreeCraftLibPath, "/swamp.rgb");
|
||||
break;
|
||||
default:
|
||||
DebugLevel2("Unknown Terrain %d\n",TheMap.Terrain);
|
||||
PalettePath = strdcat(FreeCraftLibPath, "/summer.rgb");
|
||||
break;
|
||||
}
|
||||
LoadRGB(GlobalPalette, PalettePath);
|
||||
VideoCreatePalette(GlobalPalette);
|
||||
|
||||
//
|
||||
// Graphic part
|
||||
//
|
||||
LoadTileset();
|
||||
LoadRGB(GlobalPalette,
|
||||
s=strdcat3(FreeCraftLibPath,"/",TheMap.Tileset->PaletteFile));
|
||||
free(s);
|
||||
VideoCreatePalette(GlobalPalette);
|
||||
LoadIcons();
|
||||
|
||||
// FIXME: Race only known in single player game:
|
||||
|
@ -260,7 +244,6 @@ global void CreateGame(char* filename, WorldMap* map)
|
|||
LoadImages(ThisPlayer->Race);
|
||||
LoadCursors(ThisPlayer->Race);
|
||||
|
||||
LoadTileset();
|
||||
InitUnitButtons();
|
||||
LoadMissileSprites();
|
||||
InitSpells();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
/**@name tileset.h - The tileset headerfile. */
|
||||
//
|
||||
// (c) Copyright 1998-2000 by Lutz Sammer
|
||||
// (c) Copyright 1998-2001 by Lutz Sammer
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
@ -29,15 +29,6 @@
|
|||
//#define MaxTilesInTileset 1024 /// Current limit of tiles in tileset
|
||||
#define MaxTilesInTileset 3072 /// Current limit of tiles in tileset
|
||||
|
||||
#if 0
|
||||
|
||||
#define TILE_PER_ROW 16 /// tiles stored in an image row
|
||||
#define TILE_ROWS 24 /// tiles rows in the image
|
||||
#define TILE_COUNT (TILE_PER_ROW*TILE_ROWS)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
** These are used for lookup tiles types
|
||||
** mainly used for the FOW implementation of the seen woods/rocks
|
||||
|
@ -63,6 +54,7 @@ typedef struct _tileset_ {
|
|||
char* Ident; /// tileset identifier
|
||||
char* Name; /// name for future extensions
|
||||
char* File; /// file containing image data
|
||||
char* PaletteFile; /// file containing the global palette
|
||||
|
||||
const unsigned short* Table; /// pud to internal conversion table
|
||||
unsigned char* TileTypeTable; /// for fast lookup of tile type
|
||||
|
|
|
@ -86,54 +86,59 @@ global int MapWallChk(int x,int y,int walltype) // used by FixWall, walltype==-1
|
|||
return t == walltype;
|
||||
}
|
||||
|
||||
global int FixWall(int x,int y) // used by MapRemoveWall and PreprocessMap
|
||||
global int FixWall(int x, int y) // used by MapRemoveWall and PreprocessMap
|
||||
{
|
||||
int tile;
|
||||
int walltype;
|
||||
MapField* mf;
|
||||
int tile;
|
||||
int walltype;
|
||||
MapField *mf;
|
||||
|
||||
//
|
||||
// Outside the map
|
||||
//
|
||||
if( x<0 || y<0 || x>=TheMap.Width || y>=TheMap.Height ) {
|
||||
return 0;
|
||||
}
|
||||
mf=TheMap.Fields+(x)+(y)*TheMap.Width;
|
||||
walltype = TheMap.Tileset->TileTypeTable[mf->SeenTile];
|
||||
if ( walltype != TileTypeHumanWall && walltype != TileTypeOrcWall ) {
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Outside the map
|
||||
//
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
return 0;
|
||||
}
|
||||
mf = TheMap.Fields + (x) + (y) * TheMap.Width;
|
||||
walltype = TheMap.Tileset->TileTypeTable[mf->SeenTile];
|
||||
if (walltype != TileTypeHumanWall && walltype != TileTypeOrcWall) {
|
||||
return 0;
|
||||
}
|
||||
#define WALL(xx,yy) (MapWallChk(xx,yy,walltype) != 0)
|
||||
tile = 0;
|
||||
if (WALL(x, y - 1)) {
|
||||
tile |= 1 << 0;
|
||||
}
|
||||
if (WALL(x + 1, y)) {
|
||||
tile |= 1 << 1;
|
||||
}
|
||||
if (WALL(x, y + 1)) {
|
||||
tile |= 1 << 2;
|
||||
}
|
||||
if (WALL(x - 1, y)) {
|
||||
tile |= 1 << 3;
|
||||
}
|
||||
|
||||
#define WALL(xx,yy) (MapWallChk(xx,yy,walltype) != 0)
|
||||
tile = 0;
|
||||
if (WALL(x ,y-1)) tile |= 1<<0;
|
||||
if (WALL(x+1,y )) tile |= 1<<1;
|
||||
if (WALL(x ,y+1)) tile |= 1<<2;
|
||||
if (WALL(x-1,y )) tile |= 1<<3;
|
||||
tile = WallTable[tile];
|
||||
|
||||
tile = WallTable[tile];
|
||||
|
||||
if (walltype == TileTypeHumanWall)
|
||||
{
|
||||
if (mf->Value < WALL_50HP)
|
||||
tile += TheMap.Tileset->HumanWall50Tile;
|
||||
else
|
||||
tile += TheMap.Tileset->HumanWall100Tile;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mf->Value < WALL_50HP)
|
||||
tile += TheMap.Tileset->OrcWall50Tile;
|
||||
else
|
||||
tile += TheMap.Tileset->OrcWall100Tile;
|
||||
}
|
||||
if (walltype == TileTypeHumanWall) {
|
||||
if (mf->Value < WALL_50HP)
|
||||
tile += TheMap.Tileset->HumanWall50Tile;
|
||||
else
|
||||
tile += TheMap.Tileset->HumanWall100Tile;
|
||||
} else {
|
||||
if (mf->Value < WALL_50HP)
|
||||
tile += TheMap.Tileset->OrcWall50Tile;
|
||||
else
|
||||
tile += TheMap.Tileset->OrcWall100Tile;
|
||||
}
|
||||
|
||||
// FIXME: Johns, Is this correct? Could this function be called under fog of war
|
||||
if (mf->SeenTile == tile)
|
||||
if (mf->SeenTile == tile) {
|
||||
return 0;
|
||||
}
|
||||
mf->SeenTile = tile;
|
||||
|
||||
UpdateMinimapXY(x,y);
|
||||
UpdateMinimapXY(x, y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,10 @@
|
|||
** @param slot Slot name
|
||||
** @param name Reference name
|
||||
** @param file Graphic file
|
||||
** @param palette Palette file
|
||||
** @param table Conversion table
|
||||
*/
|
||||
local SCM CclTileset(SCM slot,SCM name,SCM file,SCM table)
|
||||
local SCM CclTileset(SCM slot,SCM name,SCM file,SCM palette,SCM table)
|
||||
{
|
||||
int type;
|
||||
int i;
|
||||
|
@ -66,6 +67,7 @@ local SCM CclTileset(SCM slot,SCM name,SCM file,SCM table)
|
|||
}
|
||||
Tilesets[type].Name=gh_scm2newstr(name,NULL);
|
||||
Tilesets[type].File=gh_scm2newstr(file,NULL);
|
||||
Tilesets[type].PaletteFile=gh_scm2newstr(palette,NULL);
|
||||
|
||||
// CONVERT TABLE!!
|
||||
if( gh_vector_length(table)!=2528 ) { // 0x9E0
|
||||
|
@ -128,7 +130,7 @@ local SCM CclDefineTileset(SCM list)
|
|||
global void TilesetCclRegister(void)
|
||||
{
|
||||
// FIXME: will be removed
|
||||
gh_new_procedure4_0("tileset",CclTileset);
|
||||
gh_new_procedure5_0("tileset",CclTileset);
|
||||
|
||||
gh_new_procedureN("define-tileset-wc-names",CclDefineTilesetWcNames);
|
||||
gh_new_procedureN("define-tileset",CclDefineTileset);
|
||||
|
|
|
@ -1349,6 +1349,8 @@ local const unsigned short TileTableWasteland[0x9E0] = {
|
|||
0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Count of available Tilesets.
|
||||
*/
|
||||
|
@ -1365,8 +1367,10 @@ global Tileset Tilesets[TilesetMax] = {
|
|||
,"summer"
|
||||
#ifdef NEW_NAMES
|
||||
,"graphic/tilesets/summer/terrain/summer.png"
|
||||
,"graphic/tilesets/summer/summer.rgb"
|
||||
#else
|
||||
,"graphic/tileset/summer.png"
|
||||
,"summer.rgb"
|
||||
#endif
|
||||
,TileTableSummer
|
||||
,NULL
|
||||
|
@ -1384,8 +1388,15 @@ global Tileset Tilesets[TilesetMax] = {
|
|||
,166
|
||||
},
|
||||
{
|
||||
"tileset-winter",
|
||||
"winter", "graphic/tileset/winter.png"
|
||||
"tileset-winter"
|
||||
,"winter"
|
||||
#ifdef NEW_NAMES
|
||||
,"graphic/tilesets/summer/terrain/winter.png"
|
||||
,"graphic/tilesets/summer/winter.rgb"
|
||||
#else
|
||||
,"graphic/tileset/winter.png"
|
||||
,"winter.rgb"
|
||||
#endif
|
||||
,TileTableWinter
|
||||
,NULL
|
||||
,NULL
|
||||
|
@ -1402,8 +1413,15 @@ global Tileset Tilesets[TilesetMax] = {
|
|||
,161
|
||||
},
|
||||
{
|
||||
"tileset-wasteland",
|
||||
"wasteland", "graphic/tileset/wasteland.png"
|
||||
"tileset-wasteland"
|
||||
,"wasteland"
|
||||
#ifdef NEW_NAMES
|
||||
,"graphic/tilesets/summer/terrain/wasteland.png"
|
||||
,"graphic/tilesets/summer/wasteland.rgb"
|
||||
#else
|
||||
,"graphic/tileset/wasteland.png"
|
||||
,"wasteland.rgb"
|
||||
#endif
|
||||
,TileTableWasteland
|
||||
,NULL
|
||||
,NULL
|
||||
|
@ -1420,8 +1438,15 @@ global Tileset Tilesets[TilesetMax] = {
|
|||
,163
|
||||
},
|
||||
{
|
||||
"tileset-swamp",
|
||||
"swamp", "graphic/tileset/swamp.png"
|
||||
"tileset-swamp"
|
||||
,"swamp"
|
||||
#ifdef NEW_NAMES
|
||||
,"graphic/tilesets/summer/terrain/swamp.png"
|
||||
,"graphic/tilesets/summer/swamp.rgb"
|
||||
#else
|
||||
,"graphic/tileset/swamp.png"
|
||||
,"swamp.rgb"
|
||||
#endif
|
||||
,TileTableSwamp
|
||||
,NULL
|
||||
,NULL
|
||||
|
@ -1439,8 +1464,6 @@ global Tileset Tilesets[TilesetMax] = {
|
|||
},
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -1796,27 +1819,17 @@ global void SaveTileset(FILE* file)
|
|||
{
|
||||
const unsigned short* table;
|
||||
const Tileset* tileset;
|
||||
int i;
|
||||
|
||||
tileset=TheMap.Tileset;
|
||||
fprintf(file,"\n;;; -----------------------------------------\n");
|
||||
fprintf(file,";;; MODULE: tileset $Id$\n");
|
||||
|
||||
fprintf(file,"(define-tileset\n '%s",tileset->Ident);
|
||||
i=strlen(tileset->Ident);
|
||||
if( i<5 ) {
|
||||
fputc('\t',file);
|
||||
}
|
||||
if( i<13 ) {
|
||||
fputc('\t',file);
|
||||
}
|
||||
fprintf(file,"\t\"%s\"",tileset->Name);
|
||||
i=strlen(tileset->Name);
|
||||
if( i<7 ) {
|
||||
fputc('\t',file);
|
||||
}
|
||||
fprintf(file,"\t\"%s\"\n",tileset->File);
|
||||
fprintf(file," ;; Slots\n '(( 'special\t\t;; Can't be in pud\n");
|
||||
fprintf(file," 'class \"%s\"",tileset->Name);
|
||||
fprintf(file,"\n 'image \"%s\"",tileset->File);
|
||||
fprintf(file,"\n 'palette \"%s\"",tileset->PaletteFile);
|
||||
fprintf(file,"\n ;; Slots descriptions");
|
||||
fprintf(file,"\n 'slots '(( 'special\t\t;; Can't be in pud\n");
|
||||
fprintf(file," 'extra-trees #( %d %d %d %d %d %d )\n"
|
||||
,tileset->ExtraTrees[0] ,tileset->ExtraTrees[1]
|
||||
,tileset->ExtraTrees[2] ,tileset->ExtraTrees[3]
|
||||
|
@ -1869,7 +1882,7 @@ global void SaveTileset(FILE* file)
|
|||
SaveTilesetMixed(file,table,"orc-wall","dark-ground","'wall", 0x900);
|
||||
fprintf(file," )\n");
|
||||
fprintf(file," ;; Animated tiles\n");
|
||||
fprintf(file," '( #( ) ))\n");
|
||||
fprintf(file," 'animations '( #( ) ))\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -236,6 +236,8 @@ global char* strdcat3(const char* l, const char* m, const char* r) {
|
|||
global int main1(int argc __attribute__ ((unused)),
|
||||
char** argv __attribute__ ((unused)))
|
||||
{
|
||||
char* s;
|
||||
|
||||
printf("%s\n written by Lutz Sammer, Fabrice Rossi, Vladi Shabanski, Patrice Fortier,\n Jon Gabrielson, Andreas Arens and others. (http://FreeCraft.Org)"
|
||||
#ifdef USE_CCL
|
||||
"\n SIOD Copyright by George J. Carrette."
|
||||
|
@ -338,7 +340,13 @@ Use it at your own risk.\n"
|
|||
//
|
||||
// Inital menues require some gfx..
|
||||
//
|
||||
LoadRGB(GlobalPalette, strdcat(FreeCraftLibPath, "/summer.rgb"));
|
||||
#ifdef NEW_NAMES
|
||||
LoadRGB(GlobalPalette, s=strdcat(FreeCraftLibPath,
|
||||
"/graphics/tilesets/summer/summer.rgb"));
|
||||
#else
|
||||
LoadRGB(GlobalPalette, s=strdcat(FreeCraftLibPath, "/summer.rgb"));
|
||||
#endif
|
||||
free(s);
|
||||
VideoCreatePalette(GlobalPalette);
|
||||
LoadFonts();
|
||||
|
||||
|
|
Loading…
Reference in a new issue