GridMapData::GridMapData (SCM desc)
{
  grid_width  = -1;
  grid_height = -1;
  
  while (!gh_null_p (desc))
    {
      SCM symbol = gh_caar(desc);
      SCM data   = gh_cdar(desc);

      if (gh_equal_p (gh_symbol2scm ("file"), symbol))
        {
          parse_from_file (data);
        }
      else
        {
          std::cout << "GridMapData: Unknown data type: '" << std::flush;
          gh_display (symbol);
          std::cout << "' with data: " << std::flush;
          gh_display (data);
          std::cout << std::endl;
          return;
        }

      desc = gh_cdr (desc);
    }
}
예제 #2
0
/**
**  Dump some AI debug informations.
**
**  @param l  Lua state.
*/
static int CclAiDump(lua_State *l)
{
	LuaCheckArgs(l, 0);
	//
	// Script
	//
	printf("------\n");
	for (int i = 0; i < MaxCosts; ++i) {
		printf("%s(%4d) ", DefaultResourceNames[i].c_str(), AiPlayer->Player->Resources[i]);
	}
	printf("\n");
	printf("%d:", AiPlayer->Player->Index);
#if 0
	gh_display(gh_car(AiPlayer->Script));
#endif
	//
	// Requests
	//
	size_t n = AiPlayer->UnitTypeRequests.size();
	printf("UnitTypeRequests(%u):\n", static_cast<unsigned int>(n));
	for (size_t i = 0; i < n; ++i) {
		printf("%s ", AiPlayer->UnitTypeRequests[i].Type->Ident.c_str());
	}
	printf("\n");
	n = AiPlayer->UpgradeToRequests.size();
	printf("UpgradeToRequests(%u):\n", static_cast<unsigned int>(n));
	for (size_t i = 0; i < n; ++i) {
		printf("%s ", AiPlayer->UpgradeToRequests[i]->Ident.c_str());
	}
	printf("\n");
	n = AiPlayer->ResearchRequests.size();
	printf("ResearchRequests(%u):\n", static_cast<unsigned int>(n));
	for (size_t i = 0; i < n; ++i) {
		printf("%s ", AiPlayer->ResearchRequests[i]->Ident.c_str());
	}
	printf("\n");

	// Building queue
	printf("Building queue:\n");
	for (size_t i = 0; i < AiPlayer->UnitTypeBuilt.size(); ++i) {
		const AiBuildQueue &queue = AiPlayer->UnitTypeBuilt[i];
		printf("%s(%d/%d) ", queue.Type->Ident.c_str(), queue.Made, queue.Want);
	}
	printf("\n");

	// PrintForce
	for (size_t i = 0; i < AiPlayer->Force.Size(); ++i) {
		printf("Force(%u%s%s):\n", static_cast<unsigned int>(i),
			   AiPlayer->Force[i].Completed ? ",complete" : ",recruit",
			   AiPlayer->Force[i].Attacking ? ",attack" : "");
		for (size_t j = 0; j < AiPlayer->Force[i].UnitTypes.size(); ++j) {
			const AiUnitType &aut = AiPlayer->Force[i].UnitTypes[j];
			printf("%s(%d) ", aut.Type->Ident.c_str(), aut.Want);
		}
		printf("\n");
	}
	lua_pushboolean(l, 0);
	return 1;
}
GameObjData*
GameObjDataFactory::create (SCM symbol, SCM data)
{
  /*
  if (Guile::equal_p(scm_str2symbol("tree"), symbol))
    {
      return new TreeData (data);
    }
  else*/
    if (Guile::equal_p(scm_str2symbol("tank"), symbol))
    {
      std::cout << "GameObjDataFactory::create: not implemented" << std::endl;
    }
  else
    {
      std::cout << "GameObjDataFactory: Unknown symbol: " << std::flush;
      gh_display (symbol);
      gh_newline ();
    }
  return 0;
}
예제 #4
0
/**
**	Send command to ccl.
*/
global void CclCommand(char* command)
{
    gh_display(gh_eval_str_with_standard_handler(command));
    gh_newline();
}
예제 #5
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;
}