本文整理汇总了C++中read_groups函数的典型用法代码示例。如果您正苦于以下问题:C++ read_groups函数的具体用法?C++ read_groups怎么用?C++ read_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_groups函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: read_item_definition
ItemDefinition read_item_definition(lua_State *L, int index,
ItemDefinition default_def)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
// Read the item definition
ItemDefinition def = default_def;
def.type = (ItemType)getenumfield(L, index, "type",
es_ItemType, ITEM_NONE);
getstringfield(L, index, "name", def.name);
getstringfield(L, index, "description", def.description);
getstringfield(L, index, "inventory_image", def.inventory_image);
getstringfield(L, index, "wield_image", def.wield_image);
lua_getfield(L, index, "wield_scale");
if(lua_istable(L, -1)){
def.wield_scale = check_v3f(L, -1);
}
lua_pop(L, 1);
def.stack_max = getintfield_default(L, index, "stack_max", def.stack_max);
if(def.stack_max == 0)
def.stack_max = 1;
lua_getfield(L, index, "on_use");
def.usable = lua_isfunction(L, -1);
lua_pop(L, 1);
getboolfield(L, index, "liquids_pointable", def.liquids_pointable);
warn_if_field_exists(L, index, "tool_digging_properties",
"deprecated: use tool_capabilities");
lua_getfield(L, index, "tool_capabilities");
if(lua_istable(L, -1)){
def.tool_capabilities = new ToolCapabilities(
read_tool_capabilities(L, -1));
}
// If name is "" (hand), ensure there are ToolCapabilities
// because it will be looked up there whenever any other item has
// no ToolCapabilities
if(def.name == "" && def.tool_capabilities == NULL){
def.tool_capabilities = new ToolCapabilities();
}
lua_getfield(L, index, "groups");
read_groups(L, -1, def.groups);
lua_pop(L, 1);
// Client shall immediately place this node when player places the item.
// Server will update the precise end result a moment later.
// "" = no prediction
getstringfield(L, index, "node_placement_prediction",
def.node_placement_prediction);
return def;
}
开发者ID:hexafraction,项目名称:minetest-debug-testing,代码行数:60,代码来源:scriptapi_item.cpp
示例2: print_counts
static void
print_counts(perf_event_desc_t *fds, int num)
{
int i;
unsigned long int values[10];
read_groups(fds, num);
for(i=0; i < num; i++) {
double ratio;
unsigned long int val;
val = fds[i].value - fds[i].prev_value;
ratio = 0.0;
if (fds[i].enabled)
ratio = 1.0 * fds[i].running / fds[i].enabled;
/* separate groups */
/*if (perf_is_group_leader(fds, i))
putchar('\n');*/
// if (fds[i].value < fds[i].prev_value) {
// fprintf(output_file, "inconsistent scaling %s (cur=%'"PRIu64" : prev=%'"PRIu64")\n", fds[i].name, fds[i].value, fds[i].prev_value);
// continue;
// }
values[i] = val;
/*printf("%'20"PRIu64" %s (%.2f%% scaling, ena=%'"PRIu64", run=%'"PRIu64")\n",
val,
fds[i].name,
(1.0-ratio)*100.0,
fds[i].enabled,
fds[i].running);*/
}
/*if (acc_cycles == 0) {
acc_cycles = values[0];
} else {
acc_cycles += values[0];
}*/
//for(i=0; i < num; i++) {
// printf("%lu \t %lu \t %lu \t %.2f\n",
output_file = fopen(file_name, "w");
//fprintf(output_file, "%lu\t%lu\t%lu\n",
fprintf(output_file, "%lu\t%lu\n",
values[0],
//values[1],
// values[2],
values[1]);
// fflush(output_file);
//}
fclose(output_file);
}
开发者ID:chavli,项目名称:HetCMP-Codebase,代码行数:56,代码来源:task2.c
示例3: l_get_hit_params
// get_hit_params(groups, tool_capabilities[, time_from_last_punch])
static int l_get_hit_params(lua_State *L)
{
std::map<std::string, int> groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
push_hit_params(L, getHitParams(groups, &tp));
else
push_hit_params(L, getHitParams(groups, &tp,
luaL_checknumber(L, 3)));
return 1;
}
开发者ID:AngelCry,项目名称:minetest,代码行数:13,代码来源:scriptapi.cpp
示例4: checkobject
// set_armor_groups(self, groups)
int ObjectRef::l_set_armor_groups(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
if (co == NULL) return 0;
// Do it
ItemGroupList groups;
read_groups(L, 2, groups);
co->setArmorGroups(groups);
return 0;
}
开发者ID:rubenwardy,项目名称:minetest,代码行数:13,代码来源:l_object.cpp
示例5: read_groups
// get_dig_params(groups, tool_capabilities[, time_from_last_punch])
int ModApiUtil::l_get_dig_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ItemGroupList groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
push_dig_params(L, getDigParams(groups, &tp));
else
push_dig_params(L, getDigParams(groups, &tp,
luaL_checknumber(L, 3)));
return 1;
}
开发者ID:CasimirKaPazi,项目名称:minetest,代码行数:14,代码来源:l_util.cpp
示例6: read_groups
// get_hit_params(groups, tool_capabilities[, time_from_last_punch])
int ModApiUtil::l_get_hit_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
std::map<std::string, int> groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
push_hit_params(L, getHitParams(groups, &tp));
else
push_hit_params(L, getHitParams(groups, &tp,
luaL_checknumber(L, 3)));
return 1;
}
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:14,代码来源:l_util.cpp
示例7: weston_launch_allowed
static bool
weston_launch_allowed(struct weston_launch *wl)
{
struct group *gr;
gid_t *groups;
int i;
#ifdef HAVE_SYSTEMD_LOGIN
char *session, *seat;
int err;
#endif
if (getuid() == 0)
return true;
gr = getgrnam("weston-launch");
if (gr) {
groups = read_groups();
if (groups) {
for (i = 0; groups[i]; ++i) {
if (groups[i] == gr->gr_gid) {
free(groups);
return true;
}
}
free(groups);
}
}
#ifdef HAVE_SYSTEMD_LOGIN
err = sd_pid_get_session(getpid(), &session);
if (err == 0 && session) {
if (sd_session_is_active(session) &&
sd_session_get_seat(session, &seat) == 0) {
free(seat);
free(session);
return true;
}
free(session);
}
#endif
return false;
}
开发者ID:kendling,项目名称:weston,代码行数:43,代码来源:weston-launch.c
示例8: print_counts
static void
print_counts(perf_event_desc_t *fds, int num)
{
double ratio;
uint64_t val, delta;
int i;
read_groups(fds, num);
for(i=0; i < num; i++) {
val = perf_scale(fds[i].values);
delta = perf_scale_delta(fds[i].values, fds[i].prev_values);
ratio = perf_scale_ratio(fds[i].values);
/* separate groups */
if (perf_is_group_leader(fds, i))
putchar('\n');
if (options.print)
printf("%'20"PRIu64" %'20"PRIu64" %s (%.2f%% scaling, ena=%'"PRIu64", run=%'"PRIu64")\n",
val,
delta,
fds[i].name,
(1.0-ratio)*100.0,
fds[i].values[1],
fds[i].values[2]);
else
printf("%'20"PRIu64" %s (%.2f%% scaling, ena=%'"PRIu64", run=%'"PRIu64")\n",
val,
fds[i].name,
(1.0-ratio)*100.0,
fds[i].values[1],
fds[i].values[2]);
fds[i].prev_values[0] = fds[i].values[0];
fds[i].prev_values[1] = fds[i].values[1];
fds[i].prev_values[2] = fds[i].values[2];
}
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:40,代码来源:task.c
示例9: test_group_readwrite
static void test_group_readwrite(CuTest * tc)
{
faction * f;
group *g;
ally *al;
storage store;
FILE *F;
stream strm;
F = fopen("test.dat", "wb");
fstream_init(&strm, F);
binstore_init(&store, &strm);
test_cleanup();
test_create_world();
f = test_create_faction(0);
g = new_group(f, "test", 42);
al = ally_add(&g->allies, f);
al->status = HELP_GIVE;
write_groups(&store, f);
binstore_done(&store);
fstream_done(&strm);
F = fopen("test.dat", "rb");
fstream_init(&strm, F);
binstore_init(&store, &strm);
f->groups = 0;
free_group(g);
read_groups(&store, f);
binstore_done(&store);
fstream_done(&strm);
CuAssertPtrNotNull(tc, f->groups);
CuAssertPtrNotNull(tc, f->groups->allies);
CuAssertPtrEquals(tc, 0, f->groups->allies->next);
CuAssertPtrEquals(tc, f, f->groups->allies->faction);
CuAssertIntEquals(tc, HELP_GIVE, f->groups->allies->status);
remove("test.dat");
test_cleanup();
}
开发者ID:Xolgrim,项目名称:server,代码行数:39,代码来源:group.test.c
示例10: serve
serve()
{
char line[NNTP_STRLEN];
char host[MAXHOSTNAMELEN];
char gdbuf[MAXBUFLEN];
char **argp;
char *timeptr, *cp;
int argnum, i;
double Tstart, Tfinish;
double user, sys;
#ifdef USG
time_t start, finish;
#else not USG
struct timeval start, finish;
#endif not USG
extern char *ctime();
#ifdef POSTER
struct passwd *pp;
#endif
#ifdef LOG
# ifdef USG
struct tms cpu;
# else not USG
struct rusage me, kids;
# endif not USG
# ifdef TIMEOUT
void timeout();
# endif
grps_acsd = arts_acsd = 0;
#endif
/* Not all systems pass fd's 1 and 2 from inetd */
(void) close(1);
(void) close(2);
(void) dup(0);
(void) dup(0);
/* If we're ALONE, then we've already opened syslog */
#ifndef ALONE
# ifdef SYSLOG
# ifdef BSD_42
openlog("nntpd", LOG_PID);
# else
openlog("nntpd", LOG_PID, SYSLOG);
# endif
# endif
#endif
#ifdef ALONE
#ifndef USG
(void) signal(SIGCHLD, SIG_IGN);
#endif not USG
#endif
/* Ignore SIGPIPE, since we'll see closed connections with read */
(void) signal(SIGPIPE, SIG_IGN);
/* Get permissions and see if we can talk to this client */
host_access(&canread, &canpost, &canxfer, gdbuf);
if (gethostname(host, sizeof(host)) < 0)
(void) strcpy(host, "Amnesiac");
if (!canread && !canxfer) {
printf("%d %s NNTP server can't talk to you. Goodbye.\r\n",
ERR_ACCESS, host);
(void) fflush(stdout);
#ifdef LOG
syslog(LOG_INFO, "%s refused connection", hostname);
#endif
exit(1);
}
/* If we can talk, proceed with initialization */
ngpermcount = get_nglist(&ngpermlist, gdbuf);
#ifdef POSTER
pp = getpwnam(POSTER);
if (pp != NULL) {
uid_poster = pp->pw_uid;
gid_poster = pp->pw_gid;
} else
#endif
uid_poster = gid_poster = 0;
#ifndef FASTFORK
num_groups = 0;
num_groups = read_groups(); /* Read in the active file */
#else
signal(SIGALRM, SIG_IGN); /* Children don't deal with */
/* these things */
#endif
art_fp = NULL;
//.........这里部分代码省略.........
开发者ID:sergev,项目名称:2.11BSD,代码行数:101,代码来源:serve.c
示例11: main
main()
{
#ifdef ALONE /* If no inetd */
int sockt, client, length;
struct sockaddr_in from;
extern int reaper();
disassoc();
/* fd 0-2 should be open and point to / now. */
#ifdef SYSLOG
#ifdef BSD_42
openlog("nntpd", LOG_PID); /* fd 3 */
#else
openlog("nntpd", LOG_PID, SYSLOG); /* fd 3 */
#endif
#endif
#ifdef FASTFORK
num_groups = read_groups(); /* Read active file now (fd 4) */
/* and then do it every */
set_timer(); /* so often later */
#endif
#ifndef EXCELAN
sockt = get_socket(); /* should be fd 4 or 5 */
#endif
#ifndef USG
(void) signal(SIGCHLD, reaper);
#endif
#ifndef EXCELAN
if (listen(sockt, SOMAXCONN) < 0) {
#ifdef SYSLOG
syslog(LOG_ERR, "main: listen: %m");
#endif
exit(1);
}
#endif
for (;;) {
#ifdef EXCELAN
int status;
sockt = get_socket();
if (sockt < 0)
continue;
client = accept(sockt, &from);
#else
length = sizeof (from);
client = accept(sockt, &from, &length);
#endif EXCELAN
if (client < 0) {
#ifdef SYSLOG
if (errno != EINTR)
syslog(LOG_ERR, "accept: %m\n");
#endif
#ifdef EXCELAN
close(sockt);
sleep(1);
#endif
continue;
}
switch (fork()) {
case -1:
#ifdef SYSLOG
syslog(LOG_ERR, "fork: %m\n");
#endif
#ifdef EXCELAN
(void) close(sockt);
#endif
(void) close(client);
break;
case 0:
#ifdef EXCELAN
if (fork())
exit(0);
bcopy(&from,¤t_peer,sizeof(from));
make_stdio(sockt);
#else
(void) close(sockt);
make_stdio(client);
#endif
serve();
break;
default:
#ifdef EXCELAN
(void) close(sockt);
(void) wait(&status);
#else
(void) close(client);
#endif
break;
}
//.........这里部分代码省略.........
开发者ID:sergev,项目名称:2.11BSD,代码行数:101,代码来源:main.c
示例12: main
//.........这里部分代码省略.........
/* LE UNITA' NATURALI GADGET LAVORANO IN 10^10 MSOL. SE SONO STATE
CAMBIATE, OCCORRE MODIFICARE QUI */
if (MassMin != -1 && MassMax != -1)
{
fprintf(stderr, "Mass range: [%2.2e,%2.2e]\n", MassMin, MassMax);
MassMin /= UdM; MassMax /= UdM;
}
else
{
fprintf(stderr, "Mass range: Unbounded\n");
MassMin = 0;
MassMax = 1e33;
}
switch (mode)
{
case MAKE_FOF:
fprintf(stderr, "Making FOFs.\n");
fof_(fEpsf,fPeriodf1,fPeriodf2,fPeriodf3,NumPart,P,pmap);
write_pmap(fof_fname, fEpsf,fPeriodf1,fPeriodf2,fPeriodf3,NumPart,pmap);
break;
case MAKE_GROUPS:
fprintf(stderr, "Making Groups.\n");
if (read_pmap(fof_fname, fEpsf,fPeriodf1,fPeriodf2,fPeriodf3,NumPart,pmap))
exit(1);
EvalGroups0(pmap,snapshot_fname);
break;
case MAKE_TREE:
fprintf(stderr, "Making Progenitor Trees.\n");
if (read_groups(groups_fname, &groups, &nGroups)) exit(1);
if (read_gmap(gmap_fname, &gmap, &nMapGroups)) exit(1);
/*=======================================================================
* Sanity check that the group files match up.
*=====================================================================*/
#if 0
if (nGroups != nMapGroups)
{
fprintf(stderr,
"Mismatched number of groups between group and map files (%i != %i).\n",
nGroups, nMapGroups);
exit(1);
}
#endif
#if 0
int nPartInGroups=0, nPartInMap=0;
for (i=0; i < nGroups; i++)
{
nPartInGroups += groups[i].npart;
nPartInMap += gmap[i].npart;
}
fprintf(stderr, "HERE 4\n");
if (nGroups != nMapGroups)
{
fprintf(stderr, "Mismatched number of particles between group and map files.\n");
exit(1);
}
#endif
开发者ID:jpcoles,项目名称:tip2gad,代码行数:66,代码来源:mergtree.c
示例13: read_content_features
ContentFeatures read_content_features(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
ContentFeatures f;
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_destruct");
if(!lua_isnil(L, -1)) f.has_on_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "after_destruct");
if(!lua_isnil(L, -1)) f.has_after_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_rightclick");
f.rightclickable = lua_isfunction(L, -1);
lua_pop(L, 1);
/* Name */
getstringfield(L, index, "name", f.name);
/* Groups */
lua_getfield(L, index, "groups");
read_groups(L, -1, f.groups);
lua_pop(L, 1);
/* Visual definition */
f.drawtype = (NodeDrawType)getenumfield(L, index, "drawtype",
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "tile_images",
"Deprecated; new name is \"tiles\".");
lua_getfield(L, index, "tile_images");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
// Copy last value to all remaining textures
if(i >= 1){
TileDef lasttile = f.tiledef[i-1];
while(i < 6){
f.tiledef[i] = lasttile;
i++;
}
}
}
lua_pop(L, 1);
// special_tiles = {}
lua_getfield(L, index, "special_tiles");
// If nil, try the deprecated name "special_materials" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "special_materials",
"Deprecated; new name is \"special_tiles\".");
lua_getfield(L, index, "special_materials");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef_special[i] = read_tiledef(L, -1);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
}
lua_pop(L, 1);
f.alpha = getintfield_default(L, index, "alpha", 255);
//.........这里部分代码省略.........
开发者ID:BobMikfillin,项目名称:minetest,代码行数:101,代码来源:c_content.cpp
示例14: read_content_features
ContentFeatures read_content_features(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
ContentFeatures f;
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_destruct");
if(!lua_isnil(L, -1)) f.has_on_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "after_destruct");
if(!lua_isnil(L, -1)) f.has_after_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_activate");
if(!lua_isnil(L, -1))
{
f.has_on_activate = true;
f.is_circuit_element = true;
}
lua_pop(L, 1);
lua_getfield(L, index, "on_deactivate");
if(!lua_isnil(L, -1))
{
f.has_on_deactivate = true;
f.is_circuit_element = true;
}
lua_pop(L, 1);
lua_getfield(L, index, "on_rightclick");
f.rightclickable = lua_isfunction(L, -1);
lua_pop(L, 1);
/* Name */
getstringfield(L, index, "name", f.name);
/* Groups */
lua_getfield(L, index, "groups");
read_groups(L, -1, f.groups);
lua_pop(L, 1);
/* Visual definition */
f.drawtype = (NodeDrawType)getenumfield(L, index, "drawtype",
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
/* Meshnode model filename */
getstringfield(L, index, "mesh", f.mesh);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "tile_images",
"Deprecated; new name is \"tiles\".");
lua_getfield(L, index, "tile_images");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
// Copy last value to all remaining textures
if(i >= 1){
TileDef lasttile = f.tiledef[i-1];
while(i < 6){
f.tiledef[i] = lasttile;
i++;
}
}
}
lua_pop(L, 1);
/* Circuit options */
lua_getfield(L, index, "is_wire");
if(!lua_isnil(L, -1)) {
f.is_wire = true;
}
lua_pop(L, 1);
lua_getfield(L, index, "is_wire_connector");
if(!lua_isnil(L, -1)) {
f.is_wire_connector = true;
}
lua_pop(L, 1);
//.........这里部分代码省略.........
开发者ID:Falcon-peregrinus,项目名称:freeminer,代码行数:101,代码来源:c_content.cpp
示例15: read_content_features
ContentFeatures read_content_features(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
ContentFeatures f;
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_destruct");
if(!lua_isnil(L, -1)) f.has_on_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "after_destruct");
if(!lua_isnil(L, -1)) f.has_after_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_rightclick");
f.rightclickable = lua_isfunction(L, -1);
lua_pop(L, 1);
/* Name */
getstringfield(L, index, "name", f.name);
/* Groups */
lua_getfield(L, index, "groups");
read_groups(L, -1, f.groups);
lua_pop(L, 1);
/* Visual definition */
f.drawtype = (NodeDrawType)getenumfield(L, index, "drawtype",
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
/* Meshnode model filename */
getstringfield(L, index, "mesh", f.mesh);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "tile_images",
"Deprecated; new name is \"tiles\".");
lua_getfield(L, index, "tile_images");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1, f.drawtype);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
// Copy last value to all remaining textures
if(i >= 1){
TileDef lasttile = f.tiledef[i-1];
while(i < 6){
f.tiledef[i] = lasttile;
i++;
}
}
}
lua_pop(L, 1);
// special_tiles = {}
lua_getfield(L, index, "special_tiles");
// If nil, try the deprecated name "special_materials" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "special_materials",
"Deprecated; new name is \"special_tiles\".");
lua_getfield(L, index, "special_materials");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef_special[i] = read_tiledef(L, -1, f.drawtype);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==CF_SPECIAL_COUNT){
lua_pop(L, 1);
break;
}
}
}
lua_pop(L, 1);
//.........这里部分代码省略.........
开发者ID:kaeza,项目名称:minetest,代码行数:101,代码来源:c_content.cpp
示例16: main
int main(int argc, char *argv[]) {
SID_Init(&argc, &argv, NULL);
// Fetch user inputs
char filename_halos_root[256];
char filename_catalog_root[256];
char filename_PHKs_root[256];
double box_size;
double dx;
int i_file_lo_in;
int i_file_hi_in;
int i_file_skip;
strcpy(filename_halos_root, argv[1]);
strcpy(filename_catalog_root, argv[2]);
strcpy(filename_PHKs_root, argv[3]);
box_size = atof(argv[4]);
dx = atof(argv[5]);
i_file_lo_in = atoi(argv[6]);
i_file_hi_in = atoi(argv[7]);
i_file_skip = atoi(argv[8]);
int i_file_lo;
int i_file_hi;
if(i_file_lo_in < i_file_hi_in) {
i_file_lo = i_file_lo_in;
i_file_hi = i_file_hi_in;
} else {
i_file_lo = i_file_hi_in;
i_file_hi = i_file_lo_in;
}
SID_log("Generating group PH keys for files #%d->#%d...", SID_LOG_OPEN | SID_LOG_TIMER, i_file_lo, i_file_hi);
for(int i_file = i_file_lo; i_file <= i_file_hi; i_file += i_file_skip) {
SID_log("Processing file #%03d...", SID_LOG_OPEN | SID_LOG_TIMER, i_file);
SID_set_verbosity(SID_SET_VERBOSITY_RELATIVE, 0);
// Read group info from the halo catalogs
plist_info plist;
int * PHK_group = NULL;
size_t * PHK_group_index = NULL;
char * filename_number = (char *)SID_malloc(sizeof(char) * 10);
init_plist(&plist, NULL, GADGET_LENGTH, GADGET_MASS, GADGET_VELOCITY);
sprintf(filename_number, "%03d", i_file);
ADaPS_store(&(plist.data), (void *)filename_number, "read_catalog", ADaPS_DEFAULT);
read_groups(filename_halos_root, i_file, READ_GROUPS_ALL | READ_GROUPS_MBP_IDS_ONLY, &plist, filename_number);
int n_groups_all = ((int *)ADaPS_fetch(plist.data, "n_groups_all_%s", filename_number))[0];
int n_groups = ((int *)ADaPS_fetch(plist.data, "n_groups_%s", filename_number))[0];
// If there's any groups to analyze ...
int * n_particles_groups = NULL;
size_t n_particles_cumulative = 0;
int n_bits = 0; // Default value if there are no groups
if(n_groups > 0) {
// Fetch the halo sizes
n_particles_groups = (int *)ADaPS_fetch(plist.data, "n_particles_group_%s", filename_number);
// Read MBP data from halo catalogs
SID_log("Reading most-bound-particle positions...", SID_LOG_OPEN);
halo_properties_info group_properties;
fp_catalog_info fp_group_properties;
double * x_array = (double *)SID_malloc(sizeof(double) * n_groups);
double * y_array = (double *)SID_malloc(sizeof(double) * n_groups);
double * z_array = (double *)SID_malloc(sizeof(double) * n_groups);
fopen_catalog(filename_catalog_root, i_file, READ_CATALOG_GROUPS | READ_CATALOG_PROPERTIES, &fp_group_properties);
if(fp_group_properties.n_halos_total != n_groups)
SID_exit_error("Halo counts in group files and catalogs don't match (ie. %d!=%d)", SID_ERROR_LOGIC,
fp_group_properties.n_halos_total, n_groups);
for(int i_group = 0; i_group < n_groups; i_group++) {
fread_catalog_file(&fp_group_properties, NULL, NULL, &group_properties, NULL, i_group);
x_array[i_group] = group_properties.position_MBP[0];
y_array[i_group] = group_properties.position_MBP[1];
z_array[i_group] = group_properties.position_MBP[2];
// Enforce periodic BCs
if(x_array[i_group] < 0.)
x_array[i_group] += box_size;
if(x_array[i_group] >= box_size)
x_array[i_group] -= box_size;
if(y_array[i_group] < 0.)
y_array[i_group] += box_size;
if(y_array[i_group] >= box_size)
y_array[i_group] -= box_size;
if(z_array[i_group] < 0.)
z_array[i_group] += box_size;
if(z_array[i_group] >= box_size)
z_array[i_group] -= box_size;
}
fclose_catalog(&fp_group_properties);
SID_log("Done.", SID_LOG_CLOSE);
// Determine the number of bits to use for the PHKs
for(n_bits = N_BITS_MIN; (box_size / pow(2., (double)(n_bits + 1))) > dx && n_bits <= 20;)
n_bits++;
// Compute PHKs
SID_log("Computing PHKs (using %d bits per dimension)...", SID_LOG_OPEN, n_bits);
PHK_group = (int *)SID_malloc(sizeof(int) * n_groups);
for(int i_group = 0; i_group < n_groups; i_group++) {
// Compute the key for this group
PHK_group[i_group] = compute_PHK_from_Cartesian(
n_bits, 3, (double)x_array[i_group] / box_size, (double)y_array[i_group] / box_size, (double)z_array[i_group] / box_size);
//.........这里部分代码省略.........
开发者ID:gbpoole,项目名称:gbpCode,代码行数:101,代码来源:make_group_PHKs.c
注:本文中的read_groups函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论