reverting save/load simplifications

This commit is contained in:
martinxyz 2003-08-09 19:08:39 +00:00
parent d807780b05
commit a87376314c
21 changed files with 753 additions and 68 deletions

View file

@ -38,7 +38,6 @@
<li>++
<li>A lot of progress in resource configurability (from Crestez Dan Leonard).
<li>Minimap panel can have its own palette now (from Martin Renold).
<li>Simplified save/load, fewer things are now saved (from Martin Renold).
<li>NEW_UI: Dropped of displaying the current unit action with the buttons (from Martin Renold).
<li>NEW_UI: Dropped Alt-Buttons support (did anybody use this?) (from Martin Renold).
<li>NEW_UI: Button actions are now custom scheme scripts (from Martin Renold).

View file

@ -121,7 +121,7 @@ global void CleanModules(void)
/**
** Initialize all modules.
**
** Call each module to initialize (for LoadGame).
** Call each module to initialize.
*/
global void InitModules(void)
{
@ -217,57 +217,8 @@ global void LoadGame(char* filename)
int old_siod_verbose_level;
unsigned long game_cycle;
// protect from hooks
//LoadCcl(); // Reload the main config file
{ // maxy: added instead of CleanModules(); untested
// FIXME: those things should be somehow either in InitModules
// or be cleaned implicitely when things get overriden from
// the savegame
CleanModules();
EndReplayLog();
CleanMessages();
DestroyCursorBackground();
CursorBuilding=0;
GameCursor=0;
UnitUnderCursor=NoUnitP;
CleanAi();
{ //CleanPlayers(); //?
int p;
for( p=0; p<PlayerMax; ++p ) {
if( Players[p].Name ) {
free(Players[p].Name);
}
if( Players[p].Units ) {
free(Players[p].Units);
}
}
ThisPlayer=NULL;
memset(Players,0,sizeof(Players));
NumPlayers=0;
// ? NoRescueCheck=0;
}
CleanUnits();
CleanSelections();
CleanGroups();
// CleanUpgrades() ?
// CleanDependencies() ?
// should not be necessary: CleanButtons()
CleanMissiles();
CleanMap();
CleanReplayLog();
#ifdef HIERARCHIC_PATHFINDER
PfHierClean ();
#endif
if (AStarOn) {
FreeAStar();
}
}
// collect garbage, then eval the savegame
old_siod_verbose_level=siod_verbose_level;
siod_verbose_level=4;
user_gc(SCM_BOOL_F);
@ -285,8 +236,8 @@ global void LoadGame(char* filename)
GameCycle=game_cycle;
//GameCursor=TheUI.Point.Cursor; // FIXME: just a default.
GameCursor=CursorTypeByIdent("cursor-point"); // TheUI not cleaned
SelectionChanged();
MustRedraw=RedrawEverything;
UpdateButtonPanel();
MustRedraw=RedrawEverything; // redraw everything
}
/**

View file

@ -127,11 +127,17 @@ global void SaveGame(const char* filename)
fprintf(file,"(set-game-cycle! %lu)\n",GameCycle);
SaveCcl(file);
SaveIcons(file);
SaveCursors(file);
SaveUserInterface(file);
SaveTilesets(file);
SaveConstructions(file);
SaveDecorations(file);
SaveUnitTypes(file);
SaveUpgrades(file);
SaveDependencies(file);
SaveButtons(file);
SaveMissileTypes(file);
SavePlayers(file);
SaveMap(file);
SaveUnits(file);

View file

@ -137,6 +137,8 @@ extern void DependenciesCclRegister(void);
extern void InitDependencies(void);
/// Load the dependencies
extern void LoadDependencies(FILE* file);
/// Save the dependencies
extern void SaveDependencies(FILE* file);
/// Cleanup dependencies module
extern void CleanDependencies();

View file

@ -219,6 +219,7 @@ extern void DrawIcon(const Player*,Icon*,int,int);
/// Draw icon of an unit
extern void DrawUnitIcon(const Player*,Icon*,unsigned,int,int);
extern void SaveIcons(FILE*); /// Save icons
extern void IconCclRegister(void); /// Register CCL features
//@}

View file

@ -529,6 +529,8 @@ extern void MissileActions(void);
/// distance from view point to missile
extern int ViewPointDistanceToMissile(const Missile*);
/// Save missile-types
extern void SaveMissileTypes(FILE*);
/// Save missiles
extern void SaveMissiles(FILE*);

View file

@ -334,6 +334,7 @@ extern Tileset** Tilesets; /// Tileset information
----------------------------------------------------------------------------*/
extern void LoadTileset(void); /// Load tileset definition
extern void SaveTilesets(FILE*); /// Save the tileset configuration
extern void CleanTilesets(void); /// Cleanup the tileset module
extern void TilesetCclRegister(void); /// Register CCL features for tileset

View file

@ -942,6 +942,8 @@ extern void DrawSelectionCorners(const Unit* unit,const UnitType* type
extern void DecorationCclRegister(void);
/// Load the decorations (health,mana) of units
extern void LoadDecorations(void);
/// Save the decorations (health,mana) of units
extern void SaveDecorations(FILE* file);
/// Clean the decorations (health,mana) of units
extern void CleanDecorations(void);

View file

@ -518,6 +518,233 @@ global void LoadTileset(void)
}
};
/**
** Save flag part of tileset.
**
** @param file File handle for the saved flags.
** @param flags Bit field of the flags.
*/
local void SaveTilesetFlags(FILE* file, unsigned flags)
{
if (flags & MapFieldWaterAllowed) {
fprintf(file, " 'water");
}
if (flags & MapFieldLandAllowed) {
fprintf(file, " 'land");
}
if (flags & MapFieldCoastAllowed) {
fprintf(file, " 'coast");
}
if (flags & MapFieldNoBuilding) {
fprintf(file, " 'no-building");
}
if (flags & MapFieldUnpassable) {
fprintf(file, " 'unpassable");
}
if (flags & MapFieldWall) {
fprintf(file, " 'wall");
}
if (flags & MapFieldRocks) {
fprintf(file, " 'rock");
}
if (flags & MapFieldForest) {
fprintf(file, " 'forest");
}
if (flags & MapFieldLandUnit) {
fprintf(file, " 'land-unit");
}
if (flags & MapFieldAirUnit) {
fprintf(file, " 'air-unit");
}
if (flags & MapFieldSeaUnit) {
fprintf(file, " 'sea-unit");
}
if (flags & MapFieldBuilding) {
fprintf(file, " 'building");
}
if (flags & MapFieldHuman) {
fprintf(file, " 'human");
}
}
/**
** Save solid part of tileset.
**
** @param file File handle to save the solid part.
** @param table Tile numbers.
** @param name Ascii name of solid tile
** @param flags Tile attributes.
** @param start Start index into table.
*/
local void SaveTilesetSolid(FILE* file, const unsigned short* table,
const char* name, unsigned flags, int start)
{
int i;
int j;
int n;
fprintf(file, " 'solid (list \"%s\"", name);
SaveTilesetFlags(file, flags);
// Remove empty tiles at end of block
for (n = 15; n >= 0 && !table[start + n]; n--) {
}
i = fprintf(file, "\n #(");
for (j = 0; j <= n; ++j) {
i += fprintf(file, " %3d", table[start + j]);
}
i += fprintf(file, "))");
while ((i += 8) < 80) {
fprintf(file, "\t");
}
fprintf(file, "; %03X\n", start);
}
/**
** Save mixed part of tileset.
**
** @param file File handle to save the mixed part.
** @param table Tile numbers.
** @param name1 First ascii name of mixed tiles.
** @param name2 Second Ascii name of mixed tiles.
** @param flags Tile attributes.
** @param start Start index into table.
** @param end End of tiles.
*/
local void SaveTilesetMixed(FILE* file, const unsigned short* table,
const char* name1, const char* name2, unsigned flags, int start, int end)
{
int x;
int i;
int j;
int n;
fprintf(file, " 'mixed (list \"%s\" \"%s\"", name1, name2);
SaveTilesetFlags(file, flags);
fprintf(file,"\n");
for (x = 0; x < 0x100; x += 0x10) {
if (start + x >= end) { // Check end must be 0x10 aligned
break;
}
fprintf(file, " #(");
// Remove empty slots at end of table
for (n = 15; n >= 0 && !table[start + x + n]; n--) {
}
i = 6;
for (j = 0; j <= n; ++j) {
i += fprintf(file, " %3d", table[start + x + j]);
}
if (x == 0xF0 ) {
i += fprintf(file, "))");
} else {
i += fprintf(file, ")");
}
while ((i += 8) < 80) {
fprintf(file, "\t");
}
fprintf(file, "; %03X\n", start + x);
}
}
/**
** Save the tileset.
**
** @param file Output file.
** @param tileset Save the content of this tileset.
*/
local void SaveTileset(FILE* file, const Tileset* tileset)
{
const unsigned short* table;
int i;
int n;
fprintf(file, "\n(define-tileset\n '%s 'class '%s", tileset->Ident,
tileset->Class);
fprintf(file, "\n 'name \"%s\"", tileset->Name);
fprintf(file, "\n 'image \"%s\"", tileset->ImageFile);
fprintf(file, "\n 'palette \"%s\"", tileset->PaletteFile);
fprintf(file, "\n ;; Slots descriptions");
fprintf(file,
"\n 'slots (list\n 'special (list\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]
, tileset->ExtraTrees[4], tileset->ExtraTrees[5]);
fprintf(file, " 'top-one-tree %d 'mid-one-tree %d 'bot-one-tree %d\n",
tileset->TopOneTree, tileset->MidOneTree, tileset->BotOneTree);
fprintf(file, " 'removed-tree %d\n", tileset->RemovedTree);
fprintf(file, " 'growing-tree #( %d %d )\n", tileset->GrowingTree[0],
tileset->GrowingTree[1]);
fprintf(file, " 'extra-rocks #( %d %d %d %d %d %d )\n",
tileset->ExtraRocks[0], tileset->ExtraRocks[1]
, tileset->ExtraRocks[2], tileset->ExtraRocks[3]
, tileset->ExtraRocks[4], tileset->ExtraRocks[5]);
fprintf(file, " 'top-one-rock %d 'mid-one-rock %d 'bot-one-rock %d\n",
tileset->TopOneRock, tileset->MidOneRock, tileset->BotOneRock);
fprintf(file, " 'removed-rock %d )\n", tileset->RemovedRock);
table = tileset->Table;
n = tileset->NumTiles;
for (i = 0; i < n;) {
//
// Mixeds
//
if (tileset->BasicNameTable[i] && tileset->MixedNameTable[i]) {
SaveTilesetMixed(file, table,
tileset->TileNames[tileset->BasicNameTable[i]],
tileset->TileNames[tileset->MixedNameTable[i]],
tileset->FlagsTable[i], i, n);
i += 256;
//
// Solids
//
} else {
SaveTilesetSolid(file, table,
tileset->TileNames[tileset->BasicNameTable[i]],
tileset->FlagsTable[i], i);
i += 16;
}
}
fprintf(file, " )\n");
fprintf(file, " ;; Animated tiles\n");
fprintf(file, " 'animations (list #( ) )\n");
fprintf(file, " 'objects (list #( ) ))\n");
}
/**
** Save the current tileset module.
**
** @param file Output file.
*/
global void SaveTilesets(FILE* file)
{
int i;
char** sp;
fprintf(file, "\n;;; -----------------------------------------\n");
fprintf(file,
";;; MODULE: tileset $Id$\n\n");
// Original number to internal tileset name
i = fprintf(file, "(define-tileset-wc-names");
for (sp = TilesetWcNames; *sp; ++sp) {
if (i + strlen(*sp) > 79) {
i = fprintf(file, "\n ");
}
i += fprintf(file, " '%s", *sp);
}
fprintf(file, ")\n");
// Save all loaded tilesets
for (i = 0; i < NumTilesets; ++i) {
SaveTileset(file, Tilesets[i]);
}
}
/**
** Cleanup the tileset module.
**

View file

@ -141,6 +141,8 @@ global void LoadConstructions(void)
global void SaveConstructions(FILE* file)
{
int j;
int i;
char** cp;
Construction** cop;
ConstructionFrame* cframe;
@ -149,6 +151,22 @@ global void SaveConstructions(FILE* file)
// FIXME: needed?
//
// Dump table wc2 construction numbers -> internal symbol.
//
if( (cp=ConstructionWcNames) ) {
fprintf(file,"(define-construction-wc-names");
i=90;
while( *cp ) {
if( i+strlen(*cp)>79 ) {
i=fprintf(file,"\n ");
}
i+=fprintf(file," '%s",*cp++);
}
fprintf(file,")\n\n");
}
//
// Dump table of all constructions
//

View file

@ -1510,6 +1510,75 @@ global int ViewPointDistanceToMissile(const Missile* missile)
return ViewPointDistance(x,y);
}
/**
** Save the missile-types to file.
**
** @param file Output file.
**
** @todo FIXME: CanHitOwner and FriendlyFire not supported!
*/
global void SaveMissileTypes(FILE* file)
{
MissileType* mtype;
char** sp;
int i;
fprintf(file,"\n;;; -----------------------------------------\n");
fprintf(file,";;; MODULE: missile-types $Id$\n\n");
//
// Original number to internal missile-type name.
//
i=fprintf(file,"(define-missiletype-wc-names");
for( sp=MissileTypeWcNames; *sp; ++sp ) {
if( i+strlen(*sp)>79 ) {
i=fprintf(file,"\n ");
}
i+=fprintf(file," '%s",*sp);
}
fprintf(file,")\n\n");
//
// Missile types
//
for( mtype=MissileTypes; mtype<&MissileTypes[NumMissileTypes]; ++mtype ) {
fprintf(file,"(define-missile-type '%s\n ",mtype->Ident);
if( mtype->File ) {
fprintf(file," 'file \"%s\"",mtype->File);
}
fprintf(file," 'size '(%d %d)",mtype->Width,mtype->Height);
if( mtype->Sprite ) {
fprintf(file," 'frames %d",mtype->SpriteFrames);
}
fprintf(file,"\n 'num-directions %d",mtype->NumDirections);
fprintf(file,"\n ");
if( mtype->FiredSound.Name ) {
fprintf(file," 'fired-sound \"%s\"",mtype->FiredSound.Name);
}
if( mtype->ImpactSound.Name ) {
fprintf(file," 'impact-sound \"%s\"",mtype->ImpactSound.Name);
}
if( mtype->FiredSound.Name || mtype->ImpactSound.Name ) {
fprintf(file,"\n ");
}
fprintf(file," 'class '%s",MissileClassNames[mtype->Class]);
fprintf(file," 'draw-level %d ",mtype->DrawLevel);
if( mtype->StartDelay ) {
fprintf(file," 'delay %d",mtype->StartDelay);
}
fprintf(file," 'sleep %d",mtype->Sleep);
fprintf(file," 'speed %d",mtype->Speed);
fprintf(file," 'range %d",mtype->Range);
if( mtype->ImpactMissile ) {
fprintf(file,"\n 'impact-missile '%s",mtype->ImpactMissile->Ident);
}
fprintf(file,"\n ");
fprintf(file," 'can-hit-owner #%c",mtype->CanHitOwner ? 't' : 'f');
fprintf(file," 'friendly-fire #%c",mtype->FriendlyFire ? 't' : 'f');
fprintf(file,")\n");
}
}
/**
** Save the state of a missile to file.
*/

View file

@ -211,6 +211,24 @@ global void SavePlayers(FILE* file)
}
#endif
//
// Dump table wc2 race numbers -> internal symbol.
//
if( PlayerRaces.Count ) {
fprintf(file,"(define-race-names");
for( i=0; i<PlayerRaces.Count; ++i ) {
fprintf(file,"\n 'race '(");
fprintf(file,"\n race %d",PlayerRaces.Race[i]);
fprintf(file,"\n name %s",PlayerRaces.Name[i]);
fprintf(file,"\n display %s",PlayerRaces.Display[i]);
if( PlayerRaces.Visible[i] ) {
fprintf(file,"\n visible");
}
fprintf(file,")");
}
fprintf(file,")\n\n");
}
//
// Dump all players
//

View file

@ -418,6 +418,58 @@ global void DrawUnitIcon(const Player* player, Icon* icon, unsigned flags,
}
}
/**
** Save state of the icons to file.
**
** @param file Output file.
*/
global void SaveIcons(FILE* file)
{
char* const* cp;
int i;
fprintf(file, "\n;;; -----------------------------------------\n");
fprintf(file, ";;; MODULE: icons $Id$\n\n");
//
// Mapping the original icon numbers in puds to our internal strings
//
if ((cp = IconWcNames)) {
fprintf(file, "(define-icon-wc-names");
i = 90;
while (*cp) {
if (i + strlen(*cp) > 79) {
i = fprintf(file, "\n ");
}
i += fprintf(file, " '%s", *cp++);
}
fprintf(file, ")\n\n");
}
//
// Icons
//
for (i = 0; i < NumIcons; ++i) {
fprintf(file, "(define-icon '%s", Icons[i]->Ident);
if (Icons[i]->Tileset) {
fprintf(file, " 'tileset '%s", Icons[i]->Tileset);
}
fprintf(file, "\n 'size '(%d %d) 'normal '(%d \"%s\"))\n",
Icons[i]->Width, Icons[i]->Height,
Icons[i]->Index, Icons[i]->File->FileName);
}
fprintf(file, "\n");
//
// Icons aliases
//
for (i = 0; i < NumIconAliases; ++i) {
fprintf(file, "(define-icon-alias '%s '%s)\n",
IconAliases[i * 2 + 0], IconAliases[i * 2 + 1]);
}
}
/**
** @brief Parse icon definition.
**

View file

@ -294,6 +294,188 @@ global void LoadUserInterface(void)
}
}
/**
** Save the UI structure.
**
** @param file Save file handle
** @param ui User interface to save
*/
local void SaveUi(FILE* file,const UI* ui)
{
int i;
MenuPanel* menupanel;
fprintf(file,"(define-ui '%s %d %d\t; Selector",
ui->Name,ui->Width,ui->Height);
fprintf(file,"\n 'normal-font-color '%s"
"\n 'reverse-font-color '%s",
ui->NormalFontColor, ui->ReverseFontColor);
fprintf(file,"\n");
fprintf(file,"\n 'filler (list");
fprintf(file,"\n 'file \"%s\"",ui->Filler[0].File);
fprintf(file,"\n 'pos '(%3d %3d)",ui->FillerX[0],ui->FillerY[0]);
fprintf(file,")\n");
fprintf(file,"\n ; Resource line");
fprintf(file,"\n 'resource-line (list \"%s\" %d %d)",
ui->Resource.File,ui->ResourceX,ui->ResourceY);
fprintf(file,"\n 'resources (list");
for( i=1; i<MaxCosts+2; ++i ) {
if( !ui->Resources[i].Icon.File ) {
continue;
}
fprintf(file,"\n '%s",
i<MaxCosts ? DefaultResourceNames[i] :
i==FoodCost ? "food" : "score");
fprintf(file," (list 'file \"%s\" 'row %d\n"
" 'pos '(%d %d) 'size '(%d %d) 'text-pos '(%d %d))",
ui->Resources[i].Icon.File,ui->Resources[i].IconRow,
ui->Resources[i].IconX,ui->Resources[i].IconY,
ui->Resources[i].IconW,ui->Resources[i].IconH,
ui->Resources[i].TextX,ui->Resources[i].TextY);
}
fprintf(file,")\n");
fprintf(file," 'info-panel (list \"%s\" %d %d %d %d)\n",
ui->InfoPanel.File,
ui->InfoPanelX,ui->InfoPanelY,
ui->InfoPanelW,ui->InfoPanelH);
fprintf(file,"\n 'completed-bar '(");
fprintf(file,"\n color %d",ui->CompleteBarColor);
fprintf(file,"\n pos (%3d %3d)",ui->CompleteBarX,ui->CompleteBarY);
fprintf(file,"\n size (%d %d)",ui->CompleteBarW,ui->CompleteBarH);
fprintf(file,"\n text \"%s\"",ui->CompleteBarText);
fprintf(file,"\n font %s",FontNames[ui->CompleteBarFont]);
fprintf(file,"\n text-pos (%3d %3d)",
ui->CompleteTextX,ui->CompleteTextY);
fprintf(file,")\n\n");
fprintf(file," 'button-panel (list \"%s\" %d %d)\n",
ui->ButtonPanel.File,ui->ButtonPanelX,ui->ButtonPanelY);
fprintf(file,"\n 'map-area (list");
fprintf(file,"\n 'pos '(%3d %3d)",
ui->MapArea.X, ui->MapArea.Y);
fprintf(file,"\n 'size '(%d %d)",
ui->MapArea.EndX-ui->MapArea.X+1,
ui->MapArea.EndY-ui->MapArea.Y+1);
fprintf(file,")\n\n");
fprintf(file," ; Menu button background\n");
fprintf(file," 'menu-panel (list \"%s\" %d %d)\n",
ui->MenuButtonGraphic.File,ui->MenuButtonGraphicX,
ui->MenuButtonGraphicY);
fprintf(file," ; Minimap background\n");
fprintf(file," 'minimap-panel (list \"%s\" %d %d)\n",
ui->MinimapPanel.File,ui->MinimapPanelX,ui->MinimapPanelY);
fprintf(file," ; Minimap position\n");
fprintf(file," 'minimap-pos (list %d %d)\n",
ui->MinimapPosX,ui->MinimapPosY);
fprintf(file,"\n 'status-line '(");
fprintf(file,"\n file \"%s\"",ui->StatusLine.File);
fprintf(file,"\n pos (%d %d)",ui->StatusLineX,ui->StatusLineY);
fprintf(file,"\n text-pos (%d %d)",
ui->StatusLineTextX,ui->StatusLineTextY);
fprintf(file,"\n font %s",FontNames[ui->StatusLineFont]);
fprintf(file,")\n");
fprintf(file,"\n 'menu-button '(");
fprintf(file,"\n pos (%d %d)",
ui->MenuButton.X,ui->MenuButton.Y);
fprintf(file,"\n size (%d %d)",
ui->MenuButton.Width,ui->MenuButton.Height);
fprintf(file,"\n caption \"%s\"",
ui->MenuButton.Text);
fprintf(file,"\n style %s",
MenuButtonStyle(ui->MenuButton.Button));
fprintf(file,")");
fprintf(file,"\n 'network-menu-button '(");
fprintf(file,"\n pos (%d %d)",
ui->NetworkMenuButton.X,ui->NetworkMenuButton.Y);
fprintf(file,"\n size (%d %d)",
ui->NetworkMenuButton.Width,ui->NetworkMenuButton.Height);
fprintf(file,"\n caption \"%s\"",
ui->NetworkMenuButton.Text);
fprintf(file,"\n style %s",
MenuButtonStyle(ui->NetworkMenuButton.Button));
fprintf(file,")");
fprintf(file,"\n 'network-diplomacy-button '(");
fprintf(file,"\n pos (%d %d)",
ui->NetworkDiplomacyButton.X,ui->NetworkDiplomacyButton.Y);
fprintf(file,"\n size (%d %d)",
ui->NetworkDiplomacyButton.Width,ui->NetworkDiplomacyButton.Height);
fprintf(file,"\n caption \"%s\"",
ui->NetworkDiplomacyButton.Text);
fprintf(file,"\n style %s",
MenuButtonStyle(ui->NetworkDiplomacyButton.Button));
fprintf(file,")");
fprintf(file,"\n\n 'info-buttons '(");
for( i=0; i<ui->NumInfoButtons; ++i ) {
fprintf(file,"\n (pos (%3d %3d) size (%d %d))",
ui->InfoButtons[i].X,ui->InfoButtons[i].Y,
ui->InfoButtons[i].Width,ui->InfoButtons[i].Height);
}
fprintf(file,")");
fprintf(file,"\n 'training-buttons '(");
for( i=0; i<ui->NumTrainingButtons; ++i ) {
fprintf(file,"\n (pos (%3d %3d) size (%d %d))",
ui->TrainingButtons[i].X,ui->TrainingButtons[i].Y,
ui->TrainingButtons[i].Width,ui->TrainingButtons[i].Height);
}
fprintf(file,")");
fprintf(file,"\n 'button-buttons '(");
for( i=0; i<ui->NumButtonButtons; ++i ) {
fprintf(file,"\n (pos (%3d %3d) size (%d %d))",
ui->ButtonButtons[i].X,ui->ButtonButtons[i].Y,
ui->ButtonButtons[i].Width,ui->ButtonButtons[i].Height);
}
fprintf(file,")");
fprintf(file,"\n\n 'cursors '(");
fprintf(file,"\n point %s", ui->Point.Name);
fprintf(file,"\n glass %s", ui->Glass.Name);
fprintf(file,"\n cross %s", ui->Cross.Name);
fprintf(file,"\n yellow %s", ui->YellowHair.Name);
fprintf(file,"\n green %s", ui->GreenHair.Name);
fprintf(file,"\n red %s", ui->RedHair.Name);
fprintf(file,"\n scroll %s", ui->Scroll.Name);
fprintf(file,"\n arrow-e %s", ui->ArrowE.Name);
fprintf(file,"\n arrow-ne %s", ui->ArrowNE.Name);
fprintf(file,"\n arrow-n %s", ui->ArrowN.Name);
fprintf(file,"\n arrow-nw %s", ui->ArrowNW.Name);
fprintf(file,"\n arrow-w %s", ui->ArrowW.Name);
fprintf(file,"\n arrow-sw %s", ui->ArrowSW.Name);
fprintf(file,"\n arrow-s %s", ui->ArrowS.Name);
fprintf(file,"\n arrow-se %s", ui->ArrowSE.Name);
fprintf(file,")\n");
fprintf(file,"\n 'menu-panels '(");
menupanel=ui->MenuPanels;
while( menupanel ) {
fprintf(file,"\n %s \"%s\"",
menupanel->Ident,menupanel->Panel.File);
menupanel=menupanel->Next;
}
fprintf(file,")\n");
fprintf(file,"\n 'victory-background \"%s\"",
ui->VictoryBackground.File);
fprintf(file,"\n 'defeat-background \"%s\"",
ui->DefeatBackground.File);
fprintf(file," )\n\n");
}
/**
** Save the viewports.
**
@ -320,9 +502,34 @@ local void SaveViewports(FILE* file,const UI* ui)
*/
global void SaveUserInterface(FILE* file)
{
int i;
fprintf(file,"\n;;; -----------------------------------------\n");
fprintf(file,";;; MODULE: ui $Id$\n\n");
// Contrast, Brightness, Saturation
fprintf(file,"(set-contrast! %d)\n",TheUI.Contrast);
fprintf(file,"(set-brightness! %d)\n",TheUI.Brightness);
fprintf(file,"(set-saturation! %d)\n\n",TheUI.Saturation);
// Scrolling
fprintf(file,"(set-mouse-scroll! %s)\n",TheUI.MouseScroll ? "#t" : "#f");
fprintf(file,"(set-mouse-scroll-speed! %d)\n",SpeedMouseScroll);
fprintf(file,"(set-key-scroll! %s)\n",TheUI.KeyScroll ? "#t" : "#f");
fprintf(file,"(set-key-scroll-speed! %d)\n",SpeedKeyScroll);
fprintf(file,"(set-reverse-map-move! %s)\n\n",
TheUI.ReverseMouseMove ? "#t" : "#f");
fprintf(file,"(set-mouse-adjust! %d)\n",TheUI.MouseAdjust);
fprintf(file,"(set-mouse-scale! %d)\n\n",TheUI.MouseScale);
fprintf(file,"(set-original-resources! %s)\n\n",
TheUI.OriginalResources ? "#t" : "#f");
// Save the UIs for all resolutions
for( i=0; UI_Table[i]; ++i ) {
SaveUi(file,UI_Table[i]);
}
SaveViewports(file,&TheUI);
}

View file

@ -271,6 +271,69 @@ try_or:
*/
global void InitDependencies(void){}
/**
** Save state of the dependencies to file.
**
** @param file Output file.
*/
global void SaveDependencies(FILE* file)
{
unsigned u;
const DependRule* node;
const DependRule* rule;
const DependRule* temp;
fprintf(file,"\n;;; -----------------------------------------\n");
fprintf(file,";;; MODULE: dependencies $Id$\n\n");
// Save all dependencies
for( u=0; u<sizeof(DependHash)/sizeof(*DependHash); ++u ) {
node=DependHash[u];
while( node ) { // all hash links
fprintf(file,"(define-dependency '");
switch( node->Type ) {
case DependRuleUnitType:
fprintf(file,"%s",node->Kind.UnitType->Ident);
break;
case DependRuleUpgrade:
fprintf(file,"%s",node->Kind.Upgrade->Ident);
break;
}
// All or cases
fprintf(file,"\n '(");
rule=node->Rule;
for( ;; ) {
temp=rule;
while( temp ) {
switch( temp->Type ) {
case DependRuleUnitType:
fprintf(file,"%s",temp->Kind.UnitType->Ident);
break;
case DependRuleUpgrade:
fprintf(file,"%s",temp->Kind.Upgrade->Ident);
break;
}
temp=temp->Rule;
if( temp ) {
fprintf(file," ");
}
}
fprintf(file,")");
if( !(rule=rule->Next) ) {
break;
}
fprintf(file,"\n 'or '( ");
}
fprintf(file,")\n");
node=node->Next;
}
}
}
/**
** Clean up unit and upgrade dependencies.
*/

View file

@ -4276,9 +4276,6 @@ global void SaveUnits(FILE* file)
//
// Local variables
//
// FIXME: is this map specifig or global for the game?
// if it is global, don't save it
fprintf(file,"(set-hitpoint-regeneration! #%s)\n",
HitPointRegeneration ? "t" : "f");
fprintf(file,"(set-xp-damage! #%s)\n",
@ -4339,7 +4336,6 @@ global void SaveUnits(FILE* file)
*/
global void InitUnits(void)
{
// probably call CleanUnits() here?
}
/**

View file

@ -643,6 +643,69 @@ global void LoadDecorations(void)
}
}
/**
** Save decorations.
*/
global void SaveDecorations(FILE* file)
{
fprintf(file,"\n;;; -----------------------------------------\n");
fprintf(file,";;; MODULE: decorations $Id$\n\n");
fprintf(file,"(mana-sprite \"%s\" %d %d %d %d)\n",
ManaSprite.File,ManaSprite.HotX,ManaSprite.HotY,
ManaSprite.Width,ManaSprite.Height);
fprintf(file,"(health-sprite \"%s\" %d %d %d %d)\n",
HealthSprite.File,HealthSprite.HotX,HealthSprite.HotY,
HealthSprite.Width,HealthSprite.Height);
fprintf(file,"(shadow-sprite \"%s\" %d %d %d %d)\n",
ShadowSprite.File,ShadowSprite.HotX,ShadowSprite.HotY,
ShadowSprite.Width,ShadowSprite.Height);
fprintf(file,"(spell-sprite \"%s\" %d %d %d %d)\n",
SpellSprite.File,SpellSprite.HotX,SpellSprite.HotY,
SpellSprite.Width,SpellSprite.Height);
// This belongs to the config and not save file
if( ShowHealthBar ) {
fprintf(file,";(show-health-bar)\n");
}
if( ShowHealthDot ) {
fprintf(file,";(show-health-dot)\n");
}
if( ShowHealthHorizontal ) {
fprintf(file,";(show-health-horizontal)\n");
} else {
fprintf(file,";(show-health-vertical)\n");
}
if( ShowHealthBackgroundLong ) {
fprintf(file,";(show-health-blackground-long)\n");
}
if( ShowManaBar ) {
fprintf(file,";(show-mana-bar)\n");
}
if( ShowManaDot ) {
fprintf(file,";(show-mana-dot)\n");
}
if( ShowManaHorizontal ) {
fprintf(file,";(show-mana-horizontal)\n");
} else {
fprintf(file,";(show-mana-vertical)\n");
}
if( ShowManaBackgroundLong ) {
fprintf(file,";(show-mana-blackground-long)\n");
}
if( ShowEnergySelectedOnly ) {
fprintf(file,";(show-energy-selected-only)\n");
}
if( ShowNoFull ) {
fprintf(file,";(show-no-full)\n");
} else {
fprintf(file,";(show-full)\n");
}
if( DecorationOnTop ) {
fprintf(file,";(decoration-on-top)\n");
}
}
/**
** Clean decorations.
*/

View file

@ -588,7 +588,6 @@ local void SaveAnimation(const char* name,const Animation* anim,FILE* file)
}
/**
<<<<<<< unittype.c
** Save state of the animitions set to file.
**
** We save only the first occurance of an animation.
@ -980,8 +979,6 @@ local void SaveUnitType(FILE* file,const UnitType* type,int all)
}
/**
=======
>>>>>>> 1.80
** Save state of an unit-stats to file.
**
** @param stats Unit-stats to save.

View file

@ -568,7 +568,20 @@ global void SaveUpgrades(FILE* file)
fprintf(file,"\n");
*/
// FIXME: can at least partially be removed
//
// Save all upgrades
//
for( i=0; i<NumUpgrades; ++i ) {
fprintf(file,"(define-upgrade '%s 'icon '%s\n"
,Upgrades[i].Ident,Upgrades[i].Icon.Name);
fprintf(file," 'costs #(");
for( j=0; j<MaxCosts; ++j ) {
fprintf(file," %5d",Upgrades[i].Costs[j]);
}
fprintf(file,"))\n");
}
fprintf(file,"\n");
//
// Save all upgrade modifiers.

View file

@ -74,11 +74,7 @@ global CursorType* Cursors;
global CursorStates CursorState;/// current cursor state (point,...)
global int CursorAction; /// action for selection
#ifndef NEW_UI
global int CursorValue; /// value for CursorAction (spell type f.e.)
#else
global int CursorSpell; /// spell type while selecting target
#endif
//Event changed mouse position, can alter at any moment
global int CursorX; /// cursor position on screen X
@ -1107,7 +1103,6 @@ global void InitVideoCursors(void)
/**
** Save cursor state.
*/
/* should not be necessary
global void SaveCursors(FILE* file)
{
int i;
@ -1147,7 +1142,6 @@ global void SaveCursors(FILE* file)
fprintf(file,";;(unit-under-cursor %s\n",
UnitUnderCursor ? UnitReference(UnitUnderCursor) : "()");
}
*/
/**
** Cleanup cursor module

View file

@ -717,8 +717,12 @@ global Graphic* LoadGraphic(const char *name)
char buf[1024];
if (!(graphic = LoadGraphicPNG(LibraryFileName(name, buf)))) {
/*
fprintf(stderr, "Can't load the graphic `%s'\n", name);
ExitFatal(-1);
*/
name = NULL; // force crash
fprintf(stderr, "Can't load the graphic `%s'\n", name);
}
graphic->Pixels = VideoCreateSharedPalette(graphic->Palette);