/** ** Get player resources. ** ** @param ptr Player ** @return Player resource vector */ local SCM CclGetPlayerResources(SCM ptr) { int i; Player* player; SCM vec; player=CclGetPlayer(ptr); vec=cons_array(gh_int2scm(MaxCosts),NIL); for( i=0; i<MaxCosts; ++i ) { aset1(vec,gh_int2scm(i),gh_int2scm(player->Resources[i])); } return vec; }
/** ** 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; }
SCM gconf_value_to_scm(GConfValue* val) { SCM retval = SCM_EOL; if (val == NULL) return SCM_EOL; switch (val->type) { case GCONF_VALUE_INVALID: /* EOL */ break; case GCONF_VALUE_STRING: retval = gh_str02scm(gconf_value_get_string(val)); break; case GCONF_VALUE_INT: retval = gh_int2scm(gconf_value_get_int(val)); break; case GCONF_VALUE_FLOAT: retval = gh_double2scm(gconf_value_get_float(val)); break; case GCONF_VALUE_BOOL: retval = gh_bool2scm(gconf_value_get_bool(val)); break; case GCONF_VALUE_SCHEMA: /* FIXME this is more complicated, we need a smob or something */ break; case GCONF_VALUE_LIST: /* FIXME This is complicated too... */ break; case GCONF_VALUE_PAIR: retval = gh_cons(gconf_value_to_scm(gconf_value_get_car(val)), gconf_value_to_scm(gconf_value_get_cdr(val))); break; default: g_warning("Unhandled type in %s", G_STRFUNC); break; } return retval; }
/** ** 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; }
/** ** Change the shared vision from ThisPlayer to another player. ** ** @param state To which state this should be changed. ** @param player Player number to change. */ local SCM CclSharedVision(SCM state,SCM player) { return CclSetSharedVision(gh_int2scm(ThisPlayer->Player),state,player); }
/** ** Change the diplomacy from ThisPlayer to another player. ** ** @param state To which state this should be changed. ** @param player Player number to change. */ local SCM CclDiplomacy(SCM state,SCM player) { return CclSetDiplomacy(gh_int2scm(ThisPlayer->Player),state,player); }
/** ** Get ThisPlayer. ** ** @return This player number. */ local SCM CclGetThisPlayer(void) { return gh_int2scm(ThisPlayer-Players); }
/** ** 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; }