License changed to GPL.

This commit is contained in:
johns 2001-06-02 00:32:01 +00:00
parent 1bb269387a
commit 0b689237a4
40 changed files with 1002 additions and 209 deletions

View file

@ -650,6 +650,7 @@
<LI>Added new feature: automatic hit point regeneration of all units from
Jan Uerpmann.
<LI>License changed to GNU General Public License.
<LI>Fixed problems arround uncommon map sizes (32x64,64x32,128x1024...).
<LI>+++
</UL>
</UL>

View file

@ -199,7 +199,7 @@ freecraft [OPTIONS] [map.pud|map.pud.gz]
faster? Use 200 to play at double speed. (default is 100% which are
30 frames/second)
<LI>-F<BR>
Full-screen video-mode.
Full-screen video-mode. (Not supported on all platforms, just test)
<LI>-W<BR>
Windowed video-mode.
</UL>
@ -267,7 +267,7 @@ freecraft [OPTIONS] [map.pud|map.pud.gz]
<LI><KBD>ALT+G, CTRL+G</KBD><BR>
Toggle mouse grab mode.
<LI><KBD>ALT+F, CTRL+F</KBD><BR>
Toggle fullscreen mode. (only with SDL supported)
Toggle fullscreen mode. (only with SDL under X11 supported)
<LI><KBD>ALT+P, CTRL+P</KBD> or <KBD>pause</KBD><BR>
Toggle pause mode.
<LI><KBD>CTRL+S</KBD><BR>

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2000,2001 by Kenneth Sanislo
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer, Andreas Arens
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2001 by Lutz Sammer, Andreas Arens
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -28,6 +38,9 @@
#include "upgrade.h"
#include "depend.h"
#include "interface.h"
#include "missile.h"
#include "tileset.h"
#include "map.h"
#include "ccl.h"
/*----------------------------------------------------------------------------
@ -47,17 +60,16 @@ global void CleanModules(void)
{
CleanIcons();
// CleanUI();
CleanPlayers();
CleanUnitTypes();
CleanUnits();
CleanUpgrades();
CleanDependencies();
CleanButtons();
#if 0
CleanMissileTypes();
CleanMissiles();
CleanTileset();
CleanMap();
#endif
}
/**
@ -69,6 +81,7 @@ global void InitModules(void)
{
InitIcons();
// InitUI();
InitPlayers();
InitUnitTypes();
InitUnits();
InitUpgrades();
@ -86,8 +99,11 @@ global void LoadModules(void)
{
LoadIcons();
// LoadUI();
// LoadPlayers();
LoadUnitTypes();
LoadTileset();
// LoadButtons();
}

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2001 by Lutz Sammer, Andreas Arens
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -35,6 +45,7 @@
#include "missile.h"
#include "tileset.h"
#include "map.h"
#include "player.h"
#include "ccl.h"
@ -75,14 +86,15 @@ global void SaveGame(const char* filename)
SaveIcons(file);
// SaveUI(file);
SaveUnitTypes(file);
SaveUnits(file);
SaveUpgrades(file);
SaveDependencies(file);
SaveButtons(file);
SaveMissileTypes(file);
SaveMissiles(file);
SaveTileset(file);
SavePlayers(file);
SaveMap(file);
SaveUnits(file);
SaveMissiles(file);
// FIXME: find all state information which must be saved.

View file

@ -293,7 +293,7 @@ extern void InputMouseTimeout(const EventCallback*,unsigned);
// Chaos pur.
//
/// Called if right mouse button is pressed
extern void DoRightButton(int x,int y);
extern void DoRightButton(int tx,int ty);
/// Cancel the building input mode
extern void CancelBuildingMode(void);

View file

@ -75,7 +75,7 @@ struct _player_ {
char* Name; /// name of non computer
unsigned Type; /// type of player (human,computer,...)
char* RaceName; /// name of race.
char* RaceName; /// name of race
unsigned Race; /// race of player (orc,human,...)
unsigned AiNum; /// AI for computer
@ -88,7 +88,7 @@ struct _player_ {
unsigned Y; /// map tile start Y position
unsigned Resources[MaxCosts]; /// resources in store
int Incomes[MaxCosts]; /// income of the resources.
int Incomes[MaxCosts]; /// income of the resources
// FIXME: needed again? if not remove
// unsigned UnitFlags[
@ -101,7 +101,7 @@ struct _player_ {
void* Ai; /// Ai structure pointer
Unit** Units; /// units of this player
unsigned TotalNumUnits; /// total # units for units' list.
unsigned TotalNumUnits; /// total # units for units' list
unsigned NumFoodUnits; /// # units (need food)
unsigned NumBuildings; /// # buildings (don't need food)
@ -181,19 +181,27 @@ extern Player* ThisPlayer; /// Player on this computer
-- Functions
----------------------------------------------------------------------------*/
/// Init players
extern void InitPlayers(void);
/// Clean up players
extern void CleanPlayers(void);
/// Save players
extern void SavePlayers(FILE*);
/// Create a new player
extern void CreatePlayer(int type);
/// Change player side.
/// Change player side
extern void PlayerSetSide(Player* player,int side);
/// Change player name.
extern void PlayerSetName(Player* player,char* name);
/// Change player AI.
/// Change player name
extern void PlayerSetName(Player* player,const char* name);
/// Change player AI
extern void PlayerSetAiNum(Player* player,int ai);
/// Set a resource of the player.
/// Set a resource of the player
extern void PlayerSetResource(Player* player,int resource,int value);
/// Check if the unit-type didn't break any unit limits.
/// Check if the unit-type didn't break any unit limits
extern int PlayerCheckLimits(const Player* player,const UnitType* type);
/// Check if enough food is available for unit-type
@ -229,7 +237,7 @@ extern void PlayersEachFrame(void);
/// Called each second for player handlers (AI)
extern void PlayersEachSecond(void);
/// Change current color set to new player.
/// Change current color set to new player
extern void PlayerPixels(const Player* player);
/// Change current color set to new player of the sprite

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer and Vladi Shabanski
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -43,8 +53,8 @@ global WorldMap TheMap; /// The current map
global unsigned MapX; /// Map tile X start on display
global unsigned MapY; /// Map tile Y start on display
global unsigned MapWidth; /// Map width in tiles
global unsigned MapHeight; /// Map height in tiles
global unsigned MapWidth; /// Map width in tiles on display
global unsigned MapHeight; /// Map height in tiles on display
global int FlagRevealMap; /// Flag must reveal the map
@ -536,8 +546,25 @@ global void FreeMapInfo(MapInfo* info)
if (info->Description) {
free(info->Description);
}
if (info->MapTerrainName) {
free(info->MapTerrainName);
}
free(info);
}
}
/**
** Cleanup the map module.
*/
global void CleanMap(void)
{
free(TheMap.Fields);
free(TheMap.TerrainName);
// Tileset freeed by Tileset?
FreeMapInfo(TheMap.Info);
memset(&TheMap,0,sizeof(TheMap));
}
//@}

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Lutz Sammer and Vladi Shabanski
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Vladi Shabanski and Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -60,10 +70,12 @@ global void SaveMap(FILE* file)
fprintf(file," 'version \"" FreeCraftFormatString "\"\n",
FreeCraftFormatArgs(FreeCraftVersion));
fprintf(file," 'description \"%s\"\n",TheMap.Description);
fprintf(file," 'terrain '(%s \"%s\")\n"
,TheMap.TerrainName,Tilesets[TheMap.Terrain].Name);
fprintf(file," 'the-map '(\n");
fprintf(file," terrain (%s \"%s\")\n"
,TheMap.TerrainName,Tilesets[TheMap.Terrain].Name);
fprintf(file," size (%d %d)\n",TheMap.Width,TheMap.Height);
fprintf(file," %s\n",TheMap.NoFogOfWar ? "no-fog-of-war" : "fog-of-war");
@ -79,49 +91,49 @@ global void SaveMap(FILE* file)
fprintf(file," %d",mf->Value);
}
if( mf->Flags&MapFieldVisible ) {
fprintf(file," 'visible");
fprintf(file," visible");
}
if( mf->Flags&MapFieldExplored ) {
fprintf(file," 'explored");
fprintf(file," explored");
}
if( mf->Flags&MapFieldHuman ) {
fprintf(file," 'human");
fprintf(file," human");
}
if( mf->Flags&MapFieldLandAllowed ) {
fprintf(file," 'land");
fprintf(file," land");
}
if( mf->Flags&MapFieldCoastAllowed ) {
fprintf(file," 'coast");
fprintf(file," coast");
}
if( mf->Flags&MapFieldWaterAllowed ) {
fprintf(file," 'water");
fprintf(file," water");
}
if( mf->Flags&MapFieldNoBuilding ) {
fprintf(file," 'mud");
fprintf(file," mud");
}
if( mf->Flags&MapFieldUnpassable ) {
fprintf(file," 'block");
fprintf(file," block");
}
if( mf->Flags&MapFieldWall ) {
fprintf(file," 'wall");
fprintf(file," wall");
}
if( mf->Flags&MapFieldRocks ) {
fprintf(file," 'rock");
fprintf(file," rock");
}
if( mf->Flags&MapFieldForest ) {
fprintf(file," 'forest");
fprintf(file," wood");
}
if( mf->Flags&MapFieldLandUnit ) {
fprintf(file," 'ground");
fprintf(file," ground");
}
if( mf->Flags&MapFieldAirUnit ) {
fprintf(file," 'air");
fprintf(file," air");
}
if( mf->Flags&MapFieldSeaUnit ) {
fprintf(file," 'sea");
fprintf(file," sea");
}
if( mf->Flags&MapFieldBuilding ) {
fprintf(file," 'building");
fprintf(file," building");
}
if( w&1 ) {
fprintf(file,")\n");

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Vladi Shabanski
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Vladi Shabanski and Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -35,6 +45,190 @@
-- Functions
----------------------------------------------------------------------------*/
/**
** Parse a freecraft map.
**
** @param list list of tuples keyword data
*/
local SCM CclFreeCraftMap(SCM list)
{
SCM value;
SCM data;
char* str;
//
// Parse the list: (still everything could be changed!)
//
while( !gh_null_p(list) ) {
value=gh_car(list);
list=gh_cdr(list);
if( gh_eq_p(value,gh_symbol2scm("version")) ) {
char buf[32];
data=gh_car(list);
list=gh_cdr(list);
str=gh_scm2newstr(data,NULL);
sprintf(buf,FreeCraftFormatString,
FreeCraftFormatArgs(FreeCraftVersion));
if( strcmp(buf,str) ) {
fprintf(stderr,"Warning not saved with this version.\n");
}
free(str);
} else if( gh_eq_p(value,gh_symbol2scm("description")) ) {
data=gh_car(list);
list=gh_cdr(list);
str=gh_scm2newstr(data,NULL);
strncpy(TheMap.Description,str,sizeof(TheMap.Description));
free(str);
} else if( gh_eq_p(value,gh_symbol2scm("the-map")) ) {
data=gh_car(list);
list=gh_cdr(list);
while( !gh_null_p(data) ) {
value=gh_car(data);
data=gh_cdr(data);
if( gh_eq_p(value,gh_symbol2scm("terrain")) ) {
int i;
value=gh_car(data);
data=gh_cdr(data);
free(TheMap.TerrainName);
TheMap.TerrainName=str=gh_scm2newstr(gh_car(value),NULL);
//
// Lookup the index of this tileset.
//
for( i=0; TilesetWcNames[i]
&& strcmp(str,TilesetWcNames[i]); ++i ) {
}
TheMap.Terrain=i;
// Ignore: str=gh_scm2newstr(gh_cadr(value),NULL);
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
value=gh_car(data);
data=gh_cdr(data);
TheMap.Width=gh_scm2int(gh_car(value));
TheMap.Height=gh_scm2int(gh_cadr(value));
free(TheMap.Fields);
TheMap.Fields=calloc(TheMap.Width*TheMap.Height,
sizeof(*TheMap.Fields));
InitUnitCache();
} else if( gh_eq_p(value,gh_symbol2scm("fog-of-war")) ) {
TheMap.NoFogOfWar=0;
} else if( gh_eq_p(value,gh_symbol2scm("no-fog-of-war")) ) {
TheMap.NoFogOfWar=1;
} else if( gh_eq_p(value,gh_symbol2scm("map-fields")) ) {
int i;
value=gh_car(data);
data=gh_cdr(data);
i=gh_length(value);
if( i!=TheMap.Width*TheMap.Height ) {
fprintf(stderr,"Wrong tile table length %d\n",i);
}
i=0;
while( !gh_null_p(value) ) {
SCM field;
field=gh_car(value);
value=gh_cdr(value);
TheMap.Fields[i].Tile=gh_scm2int(gh_car(field));
field=gh_cdr(field);
TheMap.Fields[i].SeenTile=gh_scm2int(gh_car(field));
field=gh_cdr(field);
while( !gh_null_p(field) ) {
if( gh_exact_p(gh_car(field)) ) {
TheMap.Fields[i].Value=
gh_scm2int(gh_car(field));
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("visible")) ) {
TheMap.Fields[i].Flags|=MapFieldVisible;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("explored")) ) {
TheMap.Fields[i].Flags|=MapFieldExplored;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("human")) ) {
TheMap.Fields[i].Flags|=MapFieldHuman;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("land")) ) {
TheMap.Fields[i].Flags|=MapFieldLandAllowed;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("coast")) ) {
TheMap.Fields[i].Flags|=MapFieldCoastAllowed;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("water")) ) {
TheMap.Fields[i].Flags|=MapFieldWaterAllowed;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("mud")) ) {
TheMap.Fields[i].Flags|=MapFieldNoBuilding;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("block")) ) {
TheMap.Fields[i].Flags|=MapFieldUnpassable;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("wall")) ) {
TheMap.Fields[i].Flags|=MapFieldWall;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("rock")) ) {
TheMap.Fields[i].Flags|=MapFieldRocks;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("wood")) ) {
TheMap.Fields[i].Flags|=MapFieldForest;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("ground")) ) {
TheMap.Fields[i].Flags|=MapFieldLandUnit;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("air")) ) {
TheMap.Fields[i].Flags|=MapFieldAirUnit;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("sea")) ) {
TheMap.Fields[i].Flags|=MapFieldSeaUnit;
} else if( gh_eq_p(gh_car(field),
gh_symbol2scm("building")) ) {
TheMap.Fields[i].Flags|=MapFieldBuilding;
} else {
// FIXME: this leaves a half initialized map
errl("Unsupported tag",value);
}
field=gh_cdr(field);
}
++i;
}
} else {
// FIXME: this leaves a half initialized map
errl("Unsupported tag",value);
}
}
} else {
// FIXME: this leaves a half initialized map
errl("Unsupported tag",value);
}
}
return SCM_UNSPECIFIED;
}
/**
** Reveal the complete map.
** FIXME: only functional in init file!
@ -225,6 +419,7 @@ local SCM CclForestRegeneration(SCM speed)
*/
global void MapCclRegister(void)
{
gh_new_procedureN("freecraft-map",CclFreeCraftMap);
gh_new_procedure0_0("reveal-map",CclRevealMap);
gh_new_procedure1_0("set-fog-of-war!",CclSetFogOfWar);

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2000,2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -1471,13 +1481,12 @@ global void LoadTileset(void)
// Find the tileset.
//
for( i=0; i<TilesetsCount; ++i ) {
if( !strcmp(TilesetWcNames[TheMap.Terrain],Tilesets[i].Ident) ) {
if( !strcmp(TheMap.TerrainName,Tilesets[i].Ident) ) {
break;
}
}
if( i==TilesetsCount ) {
fprintf(stderr,"Tileset `%s' not available\n"
,TilesetWcNames[TheMap.Terrain]);
fprintf(stderr,"Tileset `%s' not available\n",TheMap.TerrainName);
exit(-1);
}
TheMap.Tileset=&Tilesets[i];
@ -1485,7 +1494,6 @@ global void LoadTileset(void)
//
// Load and prepare the tileset
//
TheMap.TileData=LoadGraphic(TheMap.Tileset->File);
//
@ -1872,7 +1880,7 @@ global void SaveTileset(FILE* file)
/**
** Cleanup the tileset module.
**
** NOTE: this didn't frees the configuration memory.
** @note this didn't frees the configuration memory.
*/
global void CleanTileset(void)
{
@ -1880,6 +1888,8 @@ global void CleanTileset(void)
IfDebug( TheMap.TileData=NULL; );
free(TheMap.Tiles);
IfDebug( TheMap.Tiles=NULL; );
DebugLevel0Fn("FIXME: not complete written\n");
}
//@}

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2000 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Patrice Fortier and Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2000,2001 by Andreas Arens
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998,2000,2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -70,6 +80,135 @@ local int PlayerColors[PlayerMax] = {
-- Functions
----------------------------------------------------------------------------*/
/**
** Init players.
*/
global void InitPlayers(void)
{
int p;
for( p=0; p<PlayerMax; ++p ) {
Players[p].Player=p;
}
}
/**
** Clean up players.
*/
global void CleanPlayers(void)
{
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;
}
/**
** Save state of players to file.
**
** @param file Output file.
*/
global void SavePlayers(FILE* file)
{
int i;
int j;
fprintf(file,"\n;;; -----------------------------------------\n");
fprintf(file,";;; MODULE: players $Id$\n\n");
for( i=0; i<NumPlayers; ++i ) {
fprintf(file,"(player %d\n",i);
fprintf(file," 'name \"%s\"\n",Players[i].Name);
fprintf(file," 'type ");
switch( Players[i].Type ) {
case 2: fprintf(file,"'neutral"); break;
case 3: fprintf(file,"'nobody"); break;
case 4: fprintf(file,"'computer"); break;
case 5: fprintf(file,"'human"); break;
case 6: fprintf(file,"'rescue-passive"); break;
case 7: fprintf(file,"'rescue-active"); break;
default:fprintf(file,"%d",Players[i].Type); break;
}
fprintf(file," 'race \"%s\"",Players[i].RaceName);
fprintf(file," 'ai %d\n",Players[i].AiNum);
fprintf(file," 'team %d",Players[i].Team);
fprintf(file," 'enemy \"");
for( j=0; j<PlayerMax; ++j ) {
fputc((Players[i].Enemy&(1<<j)) ? 'X' : '_',file);
}
fprintf(file,"\" 'allied \"");
for( j=0; j<PlayerMax; ++j ) {
fputc((Players[i].Allied&(1<<j)) ? 'X' : '_',file);
}
fprintf(file,"\"\n 'start '(%d %d)\n",Players[i].X,Players[i].Y);
// Resources
fprintf(file," 'resources '(");
for( j=0; j<MaxCosts; ++j ) {
if( j ) {
if( j==MaxCosts/2 ) {
fputs("\n ",file);
} else {
fputc(' ',file);
}
}
fprintf(file,"%s %d",DEFAULT_NAMES[j],Players[i].Resources[j]);
}
// Incomes
fprintf(file,")\n 'incomes '(");
for( j=0; j<MaxCosts; ++j ) {
if( j ) {
if( j==MaxCosts/2 ) {
fputs("\n ",file);
} else {
fputc(' ',file);
}
}
fprintf(file,"%s %d",DEFAULT_NAMES[j],Players[i].Incomes[j]);
}
// UnitTypesCount done by load units.
fprintf(file,")\n '%s\n",Players[i].AiEnabled ?
"ai-enabled" : "ai-disabled");
// Ai done by load ais.
fprintf(file," 'food-unit-limit %d",Players[i].FoodUnitLimit);
fprintf(file," 'building-limit %d",Players[i].BuildingLimit);
fprintf(file," 'total-unit-limit %d",Players[i].TotalUnitLimit);
fprintf(file," 'score %d",Players[i].Score);
// Colors done by init code.
// Allow saved by allow.
fprintf(file,"\n 'timers '(");
for( j=0; j<UpgradeMax; ++j ) {
if( j ) {
fputc(' ',file);
}
fprintf(file,"%d",Players[i].UpgradeTimers.Upgrades[j]);
}
fprintf(file,")");
fprintf(file,")\n\n");
}
fprintf(file,"(this-player %d)\n\n",ThisPlayer->Player);
}
/**
** Create a new player.
**
@ -142,7 +281,7 @@ global void CreatePlayer(int type)
return;
}
player->Name="Computer";
player->Name=strdup("Computer");
player->Type=type;
player->Race=PlayerRaceHuman;
player->RaceName="human";
@ -231,7 +370,6 @@ global void CreatePlayer(int type)
player->Score=0;
#ifndef USE_CCL
// FIXME: done by ccl
player->FoodUnitLimit=200;
player->BuildingLimit=200;
player->TotalUnitLimit=400;
@ -281,9 +419,12 @@ global void PlayerSetSide(Player* player,int side)
** @param player Pointer to player.
** @param name New name.
*/
global void PlayerSetName(Player* player,char *name)
global void PlayerSetName(Player* player,const char *name)
{
player->Name=name;
if( player->Name ) {
free(player->Name);
}
player->Name=strdup(name);
}
/**

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -414,27 +424,18 @@ global MapInfo* GetPudInfo(const char* pud)
if( !memcmp(header,"ERA ",4) || !memcmp(header,"ERAX",4) ) {
if( length==2 ) {
int t;
int i;
t=PudReadWord(input);
switch( t ) {
case TilesetSummer:
DebugLevel3("\tTerrain: SUMMER\n");
break;
case TilesetWinter:
DebugLevel3("\tTerrain: WINTER\n");
break;
case TilesetWasteland:
DebugLevel3("\tTerrain: WASTELAND\n");
break;
case TilesetSwamp:
DebugLevel3("\tTerrain: SWAMP\n");
break;
default:
DebugLevel1("Unknown terrain %d\n",t);
t=TilesetSummer;
break;
//
// Look if we have this as tileset.
//
for( i=0; i<t && TilesetWcNames[i]; ++i ) {
}
info->MapTerrainName=TilesetWcNames[t];
if( !TilesetWcNames[i] ) {
t=0;
}
info->MapTerrainName=strdup(TilesetWcNames[t]);
info->MapTerrain=t;
buf[0] = t & 0xFF;
info->MapUID += ChksumArea(buf, 1);
@ -864,31 +865,24 @@ global void LoadPud(const char* pud,WorldMap* map)
if( !memcmp(header,"ERA ",4) || !memcmp(header,"ERAX",4) ) {
if( length==2 ) {
int t;
int i;
t=PudReadWord(input);
if (GameSettings.Terrain == SettingsPresetMapDefault) {
switch( t ) {
case TilesetSummer:
DebugLevel3("\tTerrain: SUMMER\n");
break;
case TilesetWinter:
DebugLevel3("\tTerrain: WINTER\n");
break;
case TilesetWasteland:
DebugLevel3("\tTerrain: WASTELAND\n");
break;
case TilesetSwamp:
DebugLevel3("\tTerrain: SWAMP\n");
break;
default:
DebugLevel1("Unknown terrain %d\n",t);
t=TilesetSummer;
break;
}
} else {
if (GameSettings.Terrain != SettingsPresetMapDefault) {
t = GameSettings.Terrain;
}
map->TerrainName=TilesetWcNames[t];
if( map->TerrainName ) {
free(map->TerrainName);
}
//
// Look if we have this as tileset.
//
for( i=0; i<t && TilesetWcNames[i]; ++i ) {
}
if( !TilesetWcNames[i] ) {
t=0;
}
map->TerrainName=strdup(TilesetWcNames[t]);
map->Terrain=t;
continue;
} else {

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -302,13 +312,20 @@ local SCM CclShowAttackRange(void)
}
/**
** Enable display of orders.
** Set display of orders.
**
** @param flag True = turning display of orders on, false = off.
**
** @return The old state of display of orders.
*/
local SCM CclShowOrders(void)
local SCM CclSetShowOrders(SCM flag)
{
ShowOrders=1;
int old;
return SCM_UNSPECIFIED;
old=!ShowOrders;
ShowOrders=!gh_scm2bool(flag);
return gh_bool2scm(old);
}
/**
@ -563,108 +580,6 @@ local SCM CclDefineMap(SCM width,SCM height)
return SCM_UNSPECIFIED;
}
/**
** Parse a freecraft map.
**
** @param list list of tuples keyword data
*/
local SCM CclFreeCraftMap(SCM list)
{
#if 0
SCM value;
SCM name;
SCM data;
//
// Parse the list: (still everything could be changed!)
//
while( !gh_null_p(list) ) {
value=gh_car(list);
//gh_display(value);
//gh_newline();
if( gh_list_p(value) ) {
name=gh_car(value);
data=gh_cdr(value);
if( !gh_symbol_p(name) ) {
fprintf(stderr,__FUNCTION__": symbol expected\n");
return list;
}
if( gh_eq_p(name,gh_symbol2scm("version")) ) {
DebugLevel1("VERSION:\n");
gh_display(data);
gh_newline();
// FIXME:
} else if( gh_eq_p(name,gh_symbol2scm("description")) ) {
DebugLevel1("DESCRIPTION:\n");
gh_display(data);
gh_newline();
// FIXME:
} else if( gh_eq_p(name,gh_symbol2scm("terrain")) ) {
int terrain;
DebugLevel1("TERRAIN:\n");
gh_display(data);
gh_newline();
value=gh_car(data);
data=gh_cdr(data);
terrain=gh_scm2int(value);
TheMap.Terrain=terrain;
// FIXME:
} else if( gh_eq_p(name,gh_symbol2scm("dimension")) ) {
int width;
int height;
DebugLevel1("DIMENSION:\n");
gh_display(data);
gh_newline();
value=gh_car(data);
width=gh_scm2int(value);
data=gh_cdr(data);
value=gh_car(data);
height=gh_scm2int(value);
TheMap.Width=width;
TheMap.Height=height;
TheMap.Fields=calloc(width*height,sizeof(*TheMap.Fields));
InitUnitCache();
} else if( gh_eq_p(name,gh_symbol2scm("tiles")) ) {
int i;
int l;
DebugLevel1("TILES:\n");
value=gh_car(data);
if( !gh_vector_p(value) ) {
fprintf(stderr,"vector expected\n");
return SCM_UNSPECIFIED;
}
l=gh_vector_length(value);
if( l!=TheMap.Width*TheMap.Height ) {
fprintf(stderr,"Wrong tile table length %d\n",l);
}
for( i=0; i<l; ++i ) {
TheMap.Fields[i].Tile=
Tilesets[0].Table[
gh_scm2int(gh_vector_ref(value,gh_int2scm(i)))
];
}
} else {
;
}
} else {
fprintf(stderr,"list expected\n");
return list;
}
list=gh_cdr(list);
}
#endif
return list;
}
/*............................................................................
.. Commands
............................................................................*/
@ -740,7 +655,7 @@ global void CclInit(void)
init_subr_0("show-sight-range",CclShowSightRange);
init_subr_0("show-react-range",CclShowReactRange);
init_subr_0("show-attack-range",CclShowAttackRange);
init_subr_0("show-orders",CclShowOrders);
gh_new_procedure1_0("set-show-orders!",CclSetShowOrders);
gh_new_procedure1_0("speed-mine",CclSpeedMine);
gh_new_procedure1_0("speed-gold",CclSpeedGold);
@ -772,8 +687,6 @@ global void CclInit(void)
init_subr_1("load-pud",CclLoadPud);
init_subr_2("define-map",CclDefineMap);
init_lsubr("freecraft-map",CclFreeCraftMap);
gh_new_procedure0_0("mouse-scroll-off",CclMouseScrollOff);
gh_new_procedure0_0("units",CclUnits);

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -39,6 +49,99 @@
-- Functions
----------------------------------------------------------------------------*/
/**
** Parse the player configuration.
**
** @param list Tagged list of all informations.
*/
local SCM CclPlayer(SCM list)
{
SCM value;
SCM data;
Player* player;
//char* str;
player=&Players[gh_scm2int(gh_car(list))];
list=gh_cdr(list);
//
// Parse the list: (still everything could be changed!)
//
while( !gh_null_p(list) ) {
value=gh_car(list);
list=gh_cdr(list);
if( gh_eq_p(value,gh_symbol2scm("name")) ) {
player->Name=gh_scm2newstr(data=gh_car(list),NULL);
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("type")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("race")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("ai")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("team")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("enemy")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("allied")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("start")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("resources")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("incomes")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("ai-enabled")) ) {
DebugLevel0Fn("FIXME:\n");
} else if( gh_eq_p(value,gh_symbol2scm("ai-disabled")) ) {
DebugLevel0Fn("FIXME:\n");
} else if( gh_eq_p(value,gh_symbol2scm("food-unit-limit")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("building-limit")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("total-unit-limit")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("score")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else if( gh_eq_p(value,gh_symbol2scm("timers")) ) {
DebugLevel0Fn("FIXME:\n");
list=gh_cdr(list);
} else {
// FIXME: this leaves a half initialized player
errl("Unsupported tag",value);
}
}
return SCM_UNSPECIFIED;
}
/**
** Set ThisPlayer.
**
** @param plynr This player number.
*/
local SCM CclThisPlayer(SCM plynr)
{
ThisPlayer=&Players[gh_scm2int(plynr)];
return plynr;
}
/**
** Set player unit limit.
**
@ -94,11 +197,14 @@ local SCM CclSetAllPlayersTotalUnitLimit(SCM limit)
*/
global void PlayerCclRegister(void)
{
gh_new_procedure1_0("set-all-players-food-unit-limit",
gh_new_procedureN("player",CclPlayer);
gh_new_procedure1_0("this-player",CclThisPlayer);
gh_new_procedure1_0("set-all-players-food-unit-limit!",
CclSetAllPlayersFoodUnitLimit);
gh_new_procedure1_0("set-all-players-building-limit",
gh_new_procedure1_0("set-all-players-building-limit!",
CclSetAllPlayersBuildingLimit);
gh_new_procedure1_0("set-all-players-total-unit-limit",
gh_new_procedure1_0("set-all-players-total-unit-limit!",
CclSetAllPlayersTotalUnitLimit);
}

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Patrice Fortier
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Vladi Belperchinov-Shabanski and Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
/*

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -379,7 +389,7 @@ global int main1(int argc __attribute__ ((unused)),
#ifdef HAVE_EXPANSION
"EXPANSION "
#endif
"\n\nFreeCraft may be copied only under the terms of the Artistic License\
"\n\nFreeCraft may be copied only under the terms of the GNU General Public License\
\nwhich may be found in the FreeCraft source kit."
"\n\nDISCLAIMER:\n\
This software is provided as-is. The author(s) can not be held liable for any\

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2000,2001 by Vladi Belperchinov-Shabanski and Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -19,6 +19,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -843,7 +853,6 @@ global void DrawPath(const Unit* unit)
** Show the current order of an unit.
**
** @param unit Pointer to the unit.
**
*/
local void ShowOrder(const Unit* unit)
{
@ -880,7 +889,7 @@ local void ShowOrder(const Unit* unit)
break;
case UnitActionStandGround:
e_color=color=ColorGray;
e_color=color=ColorGreen;
break;
case UnitActionFollow:

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{
@ -859,11 +869,10 @@ local void SaveAnimation(const char* name,const Animation* anim,FILE* file)
local void SaveAnimations(const UnitType* type,FILE* file)
{
const UnitType* temp;
const Animations* anim;
const Animations* anims;
int i;
anim=type->Animations;
if( !anim ) {
if( !(anims=type->Animations) ) {
return;
}
@ -871,7 +880,7 @@ local void SaveAnimations(const UnitType* type,FILE* file)
// Look if this is the first use of it.
//
for( temp=UnitTypes; temp->OType && temp!=type ; ++temp ) {
if( temp->Animations==anim ) {
if( temp->Animations==anims ) {
return; // allready handled.
}
}
@ -882,7 +891,7 @@ local void SaveAnimations(const UnitType* type,FILE* file)
//
i=0;
for( temp=UnitTypes; temp->OType; ++temp ) {
if( temp->Animations==anim ) {
if( temp->Animations==anims ) {
if( i ) {
fprintf(file,", ");
}
@ -892,10 +901,10 @@ local void SaveAnimations(const UnitType* type,FILE* file)
}
fprintf(file,"\n(define-animations \"animations-%s\"",type->Ident+5);
SaveAnimation("still",anim->Still,file);
SaveAnimation("move",anim->Move,file);
SaveAnimation("attack",anim->Attack,file);
SaveAnimation("die",anim->Die,file);
SaveAnimation("still",anims->Still,file);
SaveAnimation("move",anims->Move,file);
SaveAnimation("attack",anims->Attack,file);
SaveAnimation("die",anims->Die,file);
fprintf(file,")\n");
}
@ -1430,6 +1439,8 @@ global void LoadUnitTypes(void)
if( type->CorpseName ) {
type->CorpseType=UnitTypeByIdent(type->CorpseName);
}
// FIXME: should i copy the animations of same graphics?
}
// FIXME: must copy unit data from peon/peasant to with gold/wood
@ -1441,6 +1452,7 @@ global void LoadUnitTypes(void)
*/
global void CleanUnitTypes(void)
{
UnitType* type;
void** ptr;
//
@ -1455,7 +1467,104 @@ global void CleanUnitTypes(void)
UnitTypeWcNames=NULL;
}
// FIXME: more!
// Clean all animations.
for( type=UnitTypes; type->OType; ++type ) {
Animations* anims;
UnitType* temp;
if( !(anims=type->Animations) ) { // Must be handled?
continue;
}
for( temp=type; temp->OType; ++temp ) { // remove all uses
if( anims==temp->Animations ) {
temp->Animations=NULL;
}
}
type->Animations=NULL;
if( anims->Still ) {
free(anims->Still);
}
if( anims->Move ) {
free(anims->Move);
}
if( anims->Attack ) {
free(anims->Attack);
}
if( anims->Die ) {
free(anims->Die);
}
free(anims);
}
// Clean all unit-types
if( UnitTypes ) {
for( type=UnitTypes; type->OType; ++type ) {
// FIXME: hash_del not supported
*(UnitType**)hash_add(UnitTypeHash,type->Ident)=NULL;
DebugCheck( !type->Ident );
free(type->Ident);
DebugCheck( !type->Name );
free(type->Name);
if( type->SameSprite ) {
free(type->SameSprite);
}
if( type->File[0] ) {
free(type->File[0]);
}
if( type->File[1] ) {
free(type->File[1]);
}
if( type->File[2] ) {
free(type->File[2]);
}
if( type->File[3] ) {
free(type->File[3]);
}
#if 0
if( type->Icon.Name ) {
free(type->Icon.Name);
}
if( type->Missile.Name ) {
free(type->Missile.Name);
}
if( type->CorpseName ) {
free(type->CorpseName);
}
#endif
if( type->Sound.Selected.Name ) {
free(type->Sound.Selected.Name);
}
if( type->Sound.Acknowledgement.Name ) {
free(type->Sound.Acknowledgement.Name);
}
if( type->Sound.Ready.Name ) {
free(type->Sound.Ready.Name);
}
if( type->Sound.Help.Name ) {
free(type->Sound.Help.Name);
}
if( type->Sound.Dead.Name ) {
free(type->Sound.Dead.Name);
}
if( type->Weapon.Attack.Name ) {
free(type->Weapon.Attack.Name);
}
if( !type->SameSprite ) {
VideoSaveFree(type->Sprite);
}
}
free(UnitTypes);
UnitTypes=NULL;
NumUnitTypes=0;
}
//
// Clean hardcoded unit types.

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1999-2001 by Vladi Belperchinov-Shabanski
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{

View file

@ -12,6 +12,16 @@
//
// (c) Copyright 1998-2001 by Lutz Sammer
//
// FreeCraft is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// FreeCraft is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// $Id$
//@{