예제 #1
0
/**
**	Define a map.
**
**	@param width	Map width.
**	@param height	Map height.
*/
local SCM CclDefineMap(SCM width,SCM height)
{
    TheMap.Width=gh_scm2int(width);
    TheMap.Height=gh_scm2int(height);

    TheMap.Fields=calloc(TheMap.Width*TheMap.Height,sizeof(*TheMap.Fields));
    InitUnitCache();

    MapX=MapY=0;

    return SCM_UNSPECIFIED;
}
예제 #2
0
/**
**	Define health sprite.
**
**	@param file	Spell graphic file.
**	@param x	Spell X position.
**	@param y	Spell Y position.
**	@param w	Spell width.
**	@param h	Spell height.
*/
global SCM CclSpellSprite(SCM file,SCM x,SCM y,SCM w,SCM h)
{
    free(SpellSprite.File);

    SpellSprite.File=gh_scm2newstr(file,NULL);
    SpellSprite.HotX=gh_scm2int(x);
    SpellSprite.HotY=gh_scm2int(y);
    SpellSprite.Width=gh_scm2int(w);
    SpellSprite.Height=gh_scm2int(h);

    return SCM_UNSPECIFIED;
}
예제 #3
0
/**
**	Define the used fonts.
**
**	@param type	Type of the font (game,small,...)
**	@param file	File name of the graphic file
**	@param width	Font width in pixels
**	@param height	Font height in pixels
**
**	@todo	make the font name functions more general, support more fonts.
*/
local SCM CclDefineFont(SCM type, SCM file, SCM width, SCM height)
{
    int i;

    i = CclFontByIdentifier(type);
    free(Fonts[i].File);
    VideoSaveFree(Fonts[i].Graphic);
    Fonts[i].Graphic=NULL;
    Fonts[i].File = gh_scm2newstr(file, NULL);
    Fonts[i].Width = gh_scm2int(width);
    Fonts[i].Height = gh_scm2int(height);

    return SCM_UNSPECIFIED;
}
예제 #4
0
SCM
scm_cdf_neg_binomal(SCM sk, SCM sn, SCM sx)
{
  SCM_ASSERT(gh_exact_p(sk), sk, SCM_ARG1, "cdf-neg-binomial");
  SCM_ASSERT(gh_exact_p(sn), sn, SCM_ARG2, "cdf-neg-binomial");
  SCM_ASSERT(gh_number_p(sx), sx, SCM_ARG3, "cdf-neg-binomial");

  int k = gh_scm2int(sk);
  int n = gh_scm2int(sn);
  double x = gh_scm2double(sx);
  double p = neg_binomial_cdf(k,n,x);

  return gh_double2scm(p);
}
예제 #5
0
SCM
scm_cdf_F(SCM sdf1, SCM sdf2, SCM sx)
{
  SCM_ASSERT(gh_exact_p(sdf1), sdf1, SCM_ARG1, "cdf-F");
  SCM_ASSERT(gh_exact_p(sdf2), sdf2, SCM_ARG2, "cdf-F");
  SCM_ASSERT(gh_number_p(sx), sx, SCM_ARG3, "cdf-F");

  int df1 = gh_scm2int(sdf1);
  int df2 = gh_scm2int(sdf1);
  double x = gh_scm2double(sx);
  double p = F_cdf(df1,df2,x);

  return gh_double2scm(p);
}
예제 #6
0
SCM
scm_inv_cdf_F(SCM sdf1, SCM sdf2, SCM sp)
{
  SCM_ASSERT(gh_exact_p(sdf1), sdf1, SCM_ARG1, "inv-cdf-F");
  SCM_ASSERT(gh_exact_p(sdf2), sdf2, SCM_ARG2, "inv-cdf-F");
  SCM_ASSERT(gh_number_p(sp), sp, SCM_ARG3, "inv-cdf-F");

  int df1 = gh_scm2int(sdf1);
  int df2 = gh_scm2int(sdf1);
  double p = gh_scm2double(sp);
  double x = inv_F_cdf(df1,df2,p);

  return gh_double2scm(x);
}
예제 #7
0
/**
**	Parse missile-type.
**
**	@param list	List describing missile.
*/
local SCM CclMissileType(SCM list)
{
    SCM value;
    int type;

    //	Slot
    value=gh_car(list);
    type=gh_scm2int(value);
    if( type>=MissileTypeMax ) {
	fprintf(stderr,"Wrong type %d\n",type);
	return list;
    }
    list=gh_cdr(list);
    DebugLevel3("MissileType: %d\n",type);

    //	Name
    value=gh_car(list);
    MissileTypes[type].Name=gh_scm2newstr(value,NULL);
    list=gh_cdr(list);

    //	File
    value=gh_car(list);
    MissileTypes[type].File=gh_scm2newstr(value,NULL);
    list=gh_cdr(list);

    // Width,Height
    value=gh_car(list);
    MissileTypes[type].Width=gh_scm2int(value);
    list=gh_cdr(list);
    value=gh_car(list);
    MissileTypes[type].Height=gh_scm2int(value);
    list=gh_cdr(list);

    // Sound impact
    value=gh_car(list);
#ifdef WITH_SOUND
    if (ccl_sound_p(value)) {
	MissileTypes[type].ImpactSound.Sound=ccl_sound_id(value);
    } else
#endif
    if (!gh_boolean_p(value) ||  gh_scm2bool(value) ) {
	fprintf(stderr,"Wrong argument in MissileType\n");
    }
    list=gh_cdr(list);

    // FIXME: class, speed not written!!!

    return list;
}
예제 #8
0
/**
**	Change the shared vision from player to another player.
**
**	@param player	Player to change shared vision.
**	@param opponent	Player number to change.
**	@param state	To which state this should be changed.
**
**	@return		FIXME: should return old state.
**
**	@todo FIXME: should return old state.
*/
local SCM CclSetSharedVision(SCM player,SCM state,SCM opponent)
{
    int plynr;
    int base;
    int shared;

    base=gh_scm2int(player);
    shared=gh_scm2bool(state);
    plynr=gh_scm2int(opponent);

    SendCommandSharedVision(base,shared,plynr);

    // FIXME: we can return the old state
    return SCM_UNSPECIFIED;
}
InputAxis*
AxisFactory::create_joystick_axis(SCM lst)
{
  int device_num = gh_scm2int(gh_car(lst));
  int axis_num   = gh_scm2int(gh_cadr(lst));

  if (device_num >= 0 && device_num < CL_Joystick::get_device_count())
    return new InputAxisInputDevice(CL_Joystick::get_device(device_num), axis_num);
  else
    {
      throw FeuerkraftError("Error: AxisFactory::create_joystick_axis: " 
                            + Guile::scm2string(lst));
      return 0;
    }
}
예제 #10
0
/**
**	Parse unit-type.
**
**	@param list	List describing missile.
*/
local SCM CclUnitType(SCM list)
{
    SCM value;
    int type;

    return list;

    //	Slot
    value=gh_car(list);
    type=gh_scm2int(value);
    list=gh_cdr(list);
    DebugLevel3("UnitType: %d\n",type);

    //	Name
    value=gh_car(list);
    UnitTypes[type].Name=gh_scm2newstr(value,NULL);
    list=gh_cdr(list);

    //	Graphics
    value=gh_car(list);

    //	FIXME: more ...

    return list;
}
예제 #11
0
/**
**	Change the diplomacy from player to another player.
**
**	@param player	Player to change diplomacy.
**	@param opponent	Player number to change.
**	@param state	To which state this should be changed.
**
**	@return		FIXME: should return old state.
**
**	@todo FIXME: should return old state.
*/
local SCM CclSetDiplomacy(SCM player,SCM state,SCM opponent)
{
    int plynr;

#if 0
    Player* base;

    base=CclGetPlayer(player);
    plynr=gh_scm2int(opponent);

    if( gh_eq_p(state,gh_symbol2scm("allied")) ) {
	base->Enemy&=~(1<<plynr);
	base->Allied|=1<<plynr;
    } else if( gh_eq_p(state,gh_symbol2scm("neutral")) ) {
	base->Enemy&=~(1<<plynr);
	base->Allied&=~(1<<plynr);
    } else if( gh_eq_p(state,gh_symbol2scm("crazy")) ) {
	base->Enemy|=1<<plynr;
	base->Allied|=1<<plynr;
    } else if( gh_eq_p(state,gh_symbol2scm("enemy")) ) {
	base->Enemy|=1<<plynr;
	base->Allied&=~(1<<plynr);
    }

#else
    int base;

    base=gh_scm2int(player);
    plynr=gh_scm2int(opponent);

    // FIXME: must send over network!!

    if( gh_eq_p(state,gh_symbol2scm("allied")) ) {
	SendCommandDiplomacy(base,DiplomacyAllied,plynr);
    } else if( gh_eq_p(state,gh_symbol2scm("neutral")) ) {
	SendCommandDiplomacy(base,DiplomacyNeutral,plynr);
    } else if( gh_eq_p(state,gh_symbol2scm("crazy")) ) {
	SendCommandDiplomacy(base,DiplomacyCrazy,plynr);
    } else if( gh_eq_p(state,gh_symbol2scm("enemy")) ) {
	SendCommandDiplomacy(base,DiplomacyEnemy,plynr);
    }

#endif

    // FIXME: we can return the old state
    return SCM_UNSPECIFIED;
}
예제 #12
0
/**
**	Set player unit limit.
**
**	@param limit	Unit limit.
*/
local SCM CclSetAllPlayersBuildingLimit(SCM limit)
{
    int i;

    for( i=0; i<PlayerMax; ++i ) {
	Players[i].BuildingLimit=gh_scm2int(limit);
    }

    return limit;
}
예제 #13
0
/**
**	Set player unit limit.
**
**	@param limit	Unit limit.
*/
local SCM CclSetAllPlayersTotalUnitLimit(SCM limit)
{
    int i;

    for( i=0; i<PlayerMax; ++i ) {
	Players[i].TotalUnitLimit=gh_scm2int(limit);
    }

    return limit;
}
예제 #14
0
/**
**	Define a map.
**
**	@param width	Map width.
**	@param height	Map height.
*/
local SCM CclDefineMap(SCM width,SCM height)
{
    TheMap.Width=gh_scm2int(width);
    TheMap.Height=gh_scm2int(height);

    TheMap.Fields=calloc(TheMap.Width*TheMap.Height,sizeof(*TheMap.Fields));
#ifdef MOVE_MAP
    TheMap.MovementMap=calloc(TheMap.Width*TheMap.Height
	    ,sizeof(*TheMap.MovementMap));
#endif
#ifdef ACTION_MAP
    TheMap.ActionMap=calloc(TheMap.Width*TheMap.Height
	    ,sizeof(*TheMap.ActionMap));
#endif
    InitUnitCache();

    MapX=MapY=0;

    return SCM_UNSPECIFIED;
}
예제 #15
0
SCM
scm_inv_cdf_chi_square(SCM sdf, SCM sp)
{
  SCM_ASSERT(gh_exact_p(sdf), sdf, SCM_ARG1, "inv-cdf-chi-square");
  SCM_ASSERT(gh_number_p(sp), sp, SCM_ARG2, "inv-cdf-chi-square");

  int df = gh_scm2int(sdf);
  double p = gh_scm2double(sp);
  double x = inv_chi_square_cdf(df,p);

  return gh_double2scm(x);
}
예제 #16
0
/*
**	For debug increase all speeds.
*/
local SCM CclSpeeds(SCM speed)
{
    SpeedMine=SpeedGold=
	SpeedChop=SpeedWood=
	SpeedHaul=SpeedOil=
	SpeedBuild=
	SpeedTrain=
	SpeedUpgrade=
	SpeedResearch=gh_scm2int(speed);

    return speed;
}
예제 #17
0
SCM
scm_cdf_chi_square(SCM sdf, SCM sx)
{
  SCM_ASSERT(gh_exact_p(sdf), sdf, SCM_ARG1, "cdf-chi-square");
  SCM_ASSERT(gh_number_p(sx), sx, SCM_ARG2, "cdf-chi-square");

  int df = gh_scm2int(sdf);
  double x = gh_scm2double(sx);
  double p = chi_square_cdf(df,x);

  return gh_double2scm(p);
}
예제 #18
0
SCM
scm_cdf_t(SCM sdf, SCM sx)
{
  SCM_ASSERT(gh_exact_p(sdf), sdf, SCM_ARG1, "cdf-t");
  SCM_ASSERT(gh_number_p(sx), sx, SCM_ARG2, "cdf-t");

  int df = gh_scm2int(sdf);
  double x = gh_scm2double(sx);
  double p = t_cdf(df,x);

  return gh_double2scm(p);
}
예제 #19
0
/**
**	Set a* parameter (cost of MOVING unit tile crossing).
*/
local SCM CclAStarSetMovingUCC(SCM cost)
{
    int i;

    i=gh_scm2int(cost);
    if( i<=0) {
	PrintFunction();
	fprintf(stdout,"Moving unit crossing cost must be strictly positive\n");
	i=1;
    }
    AStarMovingUnitCrossingCost=i;

    return SCM_UNSPECIFIED;
}
예제 #20
0
/**
**	Set a* parameter (cost of FIXED unit tile crossing).
*/
local SCM CclAStarSetFixedUCC(SCM cost)
{
    int i;

    i=gh_scm2int(cost);
    if( i<=0) {
	PrintFunction();
	fprintf(stdout,"Fixed unit crossing cost must be strictly positive\n");
	i=TheMap.Width*TheMap.Height;
    }
    AStarFixedUnitCrossingCost=i;

    return SCM_UNSPECIFIED;
}
예제 #21
0
/**
**	Set player resources.
**
**	@param ptr	Player
**	@param vec	Resources vector
**	@return		Old resource vector
*/
local SCM CclSetPlayerResources(SCM ptr,SCM vec)
{
    int i;
    Player* player;
    SCM old;

    player=CclGetPlayer(ptr);
    old=cons_array(gh_int2scm(MaxCosts),NIL);
    for( i=0; i<MaxCosts; ++i ) {
	aset1(old,gh_int2scm(i),gh_int2scm(player->Resources[i]));
    }
    for( i=0; i<MaxCosts; ++i ) {
	player->Resources[i]=gh_scm2int(gh_vector_ref(vec,gh_int2scm(i)));
    }
    return old;
}
예제 #22
0
/**
**	Define the used font colors.
*/
local SCM CclDefineFontColors(SCM list)
{
    int i;
    int j;
    SCM value;
    SCM temp;

    for (i = 0; i < 16; ++i) {
	value = gh_car(list);
	list = gh_cdr(list);

	if (gh_vector_length(value) != 7) {
	    fprintf(stderr, "Wrong vector length\n");
	}
	for (j = 0; j < 7; ++j) {
	    temp = gh_vector_ref(value, gh_int2scm(j));
	    FontColors[i][j] = gh_scm2int(temp);
	}
    }

    return SCM_UNSPECIFIED;
}
int
building_create_type(const char* name, SCM lst)
{
  AList alist;
  
  while(!gh_null_p(lst))
    {
      SCM key   = gh_car(lst);

      if (gh_null_p(gh_cdr(lst)))
        {
          std::cout << "Missing argument to keyword!" << std::endl;
        }

      SCM value = gh_cadr(lst);

      if (gh_boolean_p(value))
        {
          alist.set_bool(Guile::keyword2string(key), gh_scm2bool(value));
        }
      else if (gh_number_p(value))
        {
          alist.set_int(Guile::keyword2string(key), gh_scm2int(value));
        }
      else if (gh_string_p(value))
        {
          alist.set_string(Guile::keyword2string(key), Guile::scm2string(value));
        }
      else
        {
          std::cout << "BuildingCommands: unknown argumnent type" << std::endl;
        }

      lst = gh_cddr(lst);
    }

  return BuildingTypeManager::current()->register_factory(new CustomBuildingFactory(name, alist));
}
예제 #24
0
/**
**	Parse the player configuration.
**
**	@param list	Tagged list of all informations.
*/
local SCM CclPlayer(SCM list)
{
    SCM value;
    SCM sublist;
    Player* player;
    int i;
    char* str;

    i=gh_scm2int(gh_car(list));
    player=&Players[i];
    if( NumPlayers<=i ) {
	NumPlayers=i+1;
    }
    player->Player = i;
    player->Color=PlayerColors[i];
    if( !(player->Units=(Unit**)calloc(UnitMax,sizeof(Unit*))) ) {
	DebugLevel0("Not enough memory to create player %d.\n" _C_ i);

	return SCM_UNSPECIFIED;
    }
    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(gh_car(list),NULL);
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("type")) ) {
	    value=gh_car(list);
	    list=gh_cdr(list);
	    if( gh_eq_p(value,gh_symbol2scm("neutral")) ) {
		player->Type=PlayerNeutral;
	    } else if( gh_eq_p(value,gh_symbol2scm("nobody")) ) {
		player->Type=PlayerNobody;
	    } else if( gh_eq_p(value,gh_symbol2scm("computer")) ) {
		player->Type=PlayerComputer;
	    } else if( gh_eq_p(value,gh_symbol2scm("person")) ) {
		player->Type=PlayerPerson;
	    } else if( gh_eq_p(value,gh_symbol2scm("rescue-passive")) ) {
		player->Type=PlayerRescuePassive;
	    } else if( gh_eq_p(value,gh_symbol2scm("rescue-active")) ) {
		player->Type=PlayerRescueActive;
	    } else {
	       // FIXME: this leaves a half initialized player
	       errl("Unsupported tag",value);
	    }
	} else if( gh_eq_p(value,gh_symbol2scm("race")) ) {
	    str=gh_scm2newstr(gh_car(list),NULL);
	    if( RaceWcNames ) {
		for( i=0; RaceWcNames[i]; ++i ) {
		    if( !strcmp(str,RaceWcNames[i]) ) {
			player->RaceName=RaceWcNames[i];
			player->Race=i;
			break;
		    }
		}
	    }
	    free(str);
	    if( !RaceWcNames || !RaceWcNames[i] ) {
	       // FIXME: this leaves a half initialized player
	       errl("Unsupported tag",gh_car(list));
	    }
#if 0
	    player->RaceName=str=gh_scm2newstr(gh_car(list),NULL);
	    if( !strcmp(str,"human") ) {
		player->Race=PlayerRaceHuman;
	    } else if( !strcmp(str,"orc") ) {
		player->Race=PlayerRaceOrc;
	    } else if( !strcmp(str,"neutral") ) {
		player->Race=PlayerRaceNeutral;
	    } else {
	       // FIXME: this leaves a half initialized player
	       errl("Unsupported tag",gh_car(list));
	    }
#endif
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("ai")) ) {
	    player->AiNum=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("team")) ) {
	    player->Team=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("enemy")) ) {
	    str=gh_scm2newstr(gh_car(list),NULL);
	    list=gh_cdr(list);
	    for( i=0; i<PlayerMax && *str; ++i,++str ) {
		if( *str=='-' || *str=='_' || *str==' ' ) {
		    player->Enemy&=~(1<<i);
		} else {
		    player->Enemy|=(1<<i);
		}
	    }
	} else if( gh_eq_p(value,gh_symbol2scm("allied")) ) {
	    str=gh_scm2newstr(gh_car(list),NULL);
	    list=gh_cdr(list);
	    for( i=0; i<PlayerMax && *str; ++i,++str ) {
		if( *str=='-' || *str=='_' || *str==' ' ) {
		    player->Allied&=~(1<<i);
		} else {
		    player->Allied|=(1<<i);
		}
	    }
	} else if( gh_eq_p(value,gh_symbol2scm("shared-vision")) ) {
	    str=gh_scm2newstr(gh_car(list),NULL);
	    list=gh_cdr(list);
	    for( i=0; i<PlayerMax && *str; ++i,++str ) {
		if( *str=='-' || *str=='_' || *str==' ' ) {
		    player->SharedVision&=~(1<<i);
		} else {
		    player->SharedVision|=(1<<i);
		}
	    }
	} else if( gh_eq_p(value,gh_symbol2scm("start")) ) {
	    value=gh_car(list);
	    list=gh_cdr(list);
	    player->StartX=gh_scm2int(gh_car(value));
	    player->StartY=gh_scm2int(gh_cadr(value));
	} else if( gh_eq_p(value,gh_symbol2scm("resources")) ) {
	    sublist=gh_car(list);
	    list=gh_cdr(list);
	    while( !gh_null_p(sublist) ) {

		value=gh_car(sublist);
		sublist=gh_cdr(sublist);

		for( i=0; i<MaxCosts; ++i ) {
		    if( gh_eq_p(value,gh_symbol2scm((char*)DefaultResourceNames[i])) ) {
			player->Resources[i]=gh_scm2int(gh_car(sublist));
			break;
		    }
		}
		if( i==MaxCosts ) {
		   // FIXME: this leaves a half initialized player
		   errl("Unsupported tag",value);
		}
		sublist=gh_cdr(sublist);
	    }
	} else if( gh_eq_p(value,gh_symbol2scm("incomes")) ) {
	    sublist=gh_car(list);
	    list=gh_cdr(list);
	    while( !gh_null_p(sublist) ) {

		value=gh_car(sublist);
		sublist=gh_cdr(sublist);

		for( i=0; i<MaxCosts; ++i ) {
		    if( gh_eq_p(value,gh_symbol2scm((char*)DefaultResourceNames[i])) ) {
			player->Incomes[i]=gh_scm2int(gh_car(sublist));
			break;
		    }
		}
		if( i==MaxCosts ) {
		   // FIXME: this leaves a half initialized player
		   errl("Unsupported tag",value);
		}
		sublist=gh_cdr(sublist);
	    }
	} else if( gh_eq_p(value,gh_symbol2scm("ai-enabled")) ) {
	    player->AiEnabled=1;
	} else if( gh_eq_p(value,gh_symbol2scm("ai-disabled")) ) {
	    player->AiEnabled=0;
	} else if( gh_eq_p(value,gh_symbol2scm("food")) ) {
	    player->Food=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("food-unit-limit")) ) {
	    player->FoodUnitLimit=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("building-limit")) ) {
	    player->BuildingLimit=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("total-unit-limit")) ) {
	    player->TotalUnitLimit=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("score")) ) {
	    player->Score=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("total-units")) ) {
	    player->TotalUnits=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("total-buildings")) ) {
	    player->TotalBuildings=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("total-razings")) ) {
	    player->TotalRazings=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("total-kills")) ) {
	    player->TotalKills=gh_scm2int(gh_car(list));
	    list=gh_cdr(list);
	} else if( gh_eq_p(value,gh_symbol2scm("total-resources")) ) {
	    sublist=gh_car(list);
	    list=gh_cdr(list);
	    i=gh_length(sublist);
	    if( i!=MaxCosts ) {
		fprintf(stderr,"Wrong number of total-resources %d\n",i);
	    }
	    i=0;
	    while( !gh_null_p(sublist) ) {
		if( i<MaxCosts ) {
		    player->TotalResources[i]=gh_scm2int(gh_car(sublist));
		}
		sublist=gh_cdr(sublist);
		++i;
	    }
	    player->TotalUnits=gh_scm2int(gh_car(list));
	} else if( gh_eq_p(value,gh_symbol2scm("timers")) ) {
	    sublist=gh_car(list);
	    list=gh_cdr(list);
	    i=gh_length(sublist);
	    if( i!=UpgradeMax ) {
		fprintf(stderr,"Wrong upgrade timer length %d\n",i);
	    }

	    i=0;
	    while( !gh_null_p(sublist) ) {
		if( i<UpgradeMax ) {
		    player->UpgradeTimers.Upgrades[i]=
			    gh_scm2int(gh_car(sublist));
		}
		sublist=gh_cdr(sublist);
		++i;
	    }
	} else {
	   // FIXME: this leaves a half initialized player
	   errl("Unsupported tag",value);
	}
    }

    return SCM_UNSPECIFIED;
}
예제 #25
0
/**
**	Get a player pointer
**
**	@param value	Player slot number.
**
**	@return		The player pointer
*/
local Player* CclGetPlayer(SCM value)
{
    return &Players[gh_scm2int(value)];
}
예제 #26
0
/*
**	For debug increase upgrading speed.
*/
local SCM CclSpeedUpgrade(SCM speed)
{
    SpeedUpgrade=gh_scm2int(speed);

    return speed;
}
예제 #27
0
/*
**	For debug increase researching speed.
*/
local SCM CclSpeedResearch(SCM speed)
{
    SpeedResearch=gh_scm2int(speed);

    return speed;
}
예제 #28
0
/**
**	Parse a clone map.
**
**	@param list	list of tuples keyword data
*/
local SCM CclCloneMap(SCM list)
{
    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,"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[TilesetSummer].Table[
				gh_scm2int(gh_vector_ref(value,gh_int2scm(i)))
			    ];
		}
	    } else {
		;
	    }
	} else {
	    fprintf(stderr,"list expected\n");
	    return list;
	}

	list=gh_cdr(list);
    }

    return list;
}
예제 #29
0
/**
**	Set ThisPlayer.
**
**	@param plynr	This player number.
*/
local SCM CclSetThisPlayer(SCM plynr)
{
    ThisPlayer=&Players[gh_scm2int(plynr)];

    return plynr;
}
예제 #30
0
/*
**	For debug increase training speed.
*/
local SCM CclSpeedTrain(SCM speed)
{
    SpeedTrain=gh_scm2int(speed);

    return speed;
}