Fixed bug #635894: Altering Landscape Type in Editor
This commit is contained in:
parent
089c88268e
commit
2870fcd0fd
4 changed files with 70 additions and 12 deletions
|
@ -1012,6 +1012,8 @@
|
|||
<LI>Fixed bug #657533: User save directory not created (from Jimmy Salmon).
|
||||
<LI>Fixed bugs #647169 and #636552: Forest/Rock Display Errors (from
|
||||
Russell Smith).
|
||||
<LI>Fixed bug #635894: Altering Landscape Type in Editor (from
|
||||
Jimmy Salmon).
|
||||
<LI>+++
|
||||
</UL>
|
||||
</UL>
|
||||
|
|
|
@ -105,6 +105,8 @@ extern void LoadChk(const char* chk,WorldMap* map);
|
|||
|
||||
/// Save a pud file
|
||||
extern int SavePud(const char* pud,const WorldMap* map);
|
||||
/// Change a pud's tileset
|
||||
extern void ChangeTilesetPud(int old,WorldMap* map);
|
||||
|
||||
/// Clean the pud module
|
||||
extern void CleanPud(void);
|
||||
|
|
|
@ -1345,23 +1345,19 @@ local void PudWriteHeader(gzFile f,char* type,int length)
|
|||
}
|
||||
|
||||
/**
|
||||
** Save the MTXM section
|
||||
** Convert the map to MTXM format and save in a buffer.
|
||||
**
|
||||
** @param f File handle
|
||||
** @param map Map to save.
|
||||
** @param mtxm Buffer to save MTXM data
|
||||
** @param map Map to convert
|
||||
** @param tileset Tileset used to convert
|
||||
*/
|
||||
local void PudWriteMTXM(gzFile f,const WorldMap* map)
|
||||
local void PudConvertMTXM(unsigned char* mtxm,const WorldMap* map,
|
||||
Tileset* tileset)
|
||||
{
|
||||
int i;
|
||||
int n;
|
||||
unsigned char* mtxm;
|
||||
Tileset* tileset;
|
||||
|
||||
tileset=map->Tileset;
|
||||
n=map->Width*map->Height;
|
||||
PudWriteHeader(f,"MTXM",n*2);
|
||||
mtxm=alloca(n*2);
|
||||
|
||||
for( i=0; i<n; ++i ) {
|
||||
int tile;
|
||||
int j;
|
||||
|
@ -1376,10 +1372,46 @@ local void PudWriteMTXM(gzFile f,const WorldMap* map)
|
|||
mtxm[i*2+0]=j >> 0;
|
||||
mtxm[i*2+1]=j >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Save the MTXM section
|
||||
**
|
||||
** @param f File handle
|
||||
** @param map Map to save.
|
||||
*/
|
||||
local void PudWriteMTXM(gzFile f,const WorldMap* map)
|
||||
{
|
||||
int n;
|
||||
unsigned char* mtxm;
|
||||
Tileset* tileset;
|
||||
|
||||
tileset=map->Tileset;
|
||||
n=map->Width*map->Height;
|
||||
PudWriteHeader(f,"MTXM",n*2);
|
||||
mtxm=alloca(n*2);
|
||||
|
||||
PudConvertMTXM(mtxm,map,tileset);
|
||||
|
||||
gzwrite(f,mtxm,n*2);
|
||||
}
|
||||
|
||||
/**
|
||||
** Change a pud's tileset
|
||||
**
|
||||
** @param old Number of old tileset
|
||||
** @param map Map to change
|
||||
*/
|
||||
global void ChangeTilesetPud(int old,WorldMap* map)
|
||||
{
|
||||
unsigned char* mtxm;
|
||||
|
||||
MapOffsetX=MapOffsetY=0;
|
||||
mtxm=alloca(map->Width*map->Height*2);
|
||||
PudConvertMTXM(mtxm,map,Tilesets[old]);
|
||||
ConvertMTXM((const unsigned short*)mtxm,map->Width,map->Height,map);
|
||||
}
|
||||
|
||||
/**
|
||||
** Save the SQM section
|
||||
**
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "font.h"
|
||||
#include "tileset.h"
|
||||
#include "map.h"
|
||||
#include "minimap.h"
|
||||
#include "interface.h"
|
||||
#include "menus.h"
|
||||
#include "cursor.h"
|
||||
|
@ -5565,6 +5566,8 @@ local void EditorMapPropertiesOk(void)
|
|||
char *description;
|
||||
// FIXME: TilesetSummer, ... shouldn't be used, they will be removed.
|
||||
int v[] = { TilesetSummer, TilesetWinter, TilesetWasteland, TilesetSwamp };
|
||||
int old;
|
||||
char *s;
|
||||
|
||||
menu = CurrentMenu;
|
||||
|
||||
|
@ -5573,8 +5576,27 @@ local void EditorMapPropertiesOk(void)
|
|||
free(TheMap.Info->Description);
|
||||
TheMap.Info->Description = strdup(description);
|
||||
|
||||
// FIXME: Need to actually change the terrain
|
||||
TheMap.Info->MapTerrain = v[menu->items[6].d.pulldown.curopt];
|
||||
// Change the terrain
|
||||
old=TheMap.Info->MapTerrain;
|
||||
if (old != v[menu->items[6].d.pulldown.curopt]) {
|
||||
TheMap.Info->MapTerrain = v[menu->items[6].d.pulldown.curopt];
|
||||
free(TheMap.Info->MapTerrainName);
|
||||
TheMap.Info->MapTerrainName=strdup(TilesetWcNames[TheMap.Info->MapTerrain]);
|
||||
TheMap.Terrain = TheMap.Info->MapTerrain;
|
||||
free(TheMap.TerrainName);
|
||||
TheMap.TerrainName = strdup(TilesetWcNames[TheMap.Info->MapTerrain]);
|
||||
TheMap.Tileset = Tilesets[TheMap.Info->MapTerrain];
|
||||
|
||||
LoadTileset();
|
||||
ChangeTilesetPud(old,&TheMap);
|
||||
LoadRGB(GlobalPalette,
|
||||
s=strdcat3(FreeCraftLibPath,"/graphics/",
|
||||
TheMap.Tileset->PaletteFile));
|
||||
free(s);
|
||||
VideoCreatePalette(GlobalPalette);
|
||||
PreprocessMap();
|
||||
UpdateMinimap();
|
||||
}
|
||||
|
||||
// FIXME: Save the pud version somewhere
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue