int restore_line(const char *filename,uint64_t lv,char *line) { char *ptr; uint32_t ts; int status; char* errormsgs[]={ ERROR_STRINGS }; status = ERROR_MISMATCH; ptr = line; EAT(ptr,filename,lv,':'); EAT(ptr,filename,lv,' '); GETU32(ts,ptr); EAT(ptr,filename,lv,'|'); switch (*ptr) { case 'A': if (strncmp(ptr,"ACCESS",6)==0) { status = do_access(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"ATTR",4)==0) { status = do_attr(filename,lv,ts,ptr+4); } else if (strncmp(ptr,"APPEND",6)==0) { status = do_append(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"ACQUIRE",7)==0) { status = do_acquire(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"AQUIRE",6)==0) { status = do_acquire(filename,lv,ts,ptr+6); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'C': if (strncmp(ptr,"CREATE",6)==0) { status = do_create(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"CUSTOMER",8)==0) { // deprecated status = do_session(filename,lv,ts,ptr+8); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'E': if (strncmp(ptr,"EMPTYTRASH",10)==0) { status = do_emptytrash(filename,lv,ts,ptr+10); } else if (strncmp(ptr,"EMPTYRESERVED",13)==0) { status = do_emptyreserved(filename,lv,ts,ptr+13); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'F': if (strncmp(ptr,"FREEINODES",10)==0) { status = do_freeinodes(filename,lv,ts,ptr+10); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'I': if (strncmp(ptr,"INCVERSION",10)==0) { status = do_incversion(filename,lv,ts,ptr+10); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'L': if (strncmp(ptr,"LENGTH",6)==0) { status = do_length(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"LINK",4)==0) { status = do_link(filename,lv,ts,ptr+4); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'M': if (strncmp(ptr,"MOVE",4)==0) { status = do_move(filename,lv,ts,ptr+4); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'P': if (strncmp(ptr,"PURGE",5)==0) { status = do_purge(filename,lv,ts,ptr+5); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'Q': if (strncmp(ptr,"QUOTA",5)==0) { status = do_quota(filename,lv,ts,ptr+5); } break; case 'R': if (strncmp(ptr,"RELEASE",7)==0) { status = do_release(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"REPAIR",6)==0) { status = do_repair(filename,lv,ts,ptr+6); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'S': if (strncmp(ptr,"SETEATTR",8)==0) { status = do_seteattr(filename,lv,ts,ptr+8); } else if (strncmp(ptr,"SETGOAL",7)==0) { status = do_setgoal(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"SETPATH",7)==0) { status = do_setpath(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"SETTRASHTIME",12)==0) { status = do_settrashtime(filename,lv,ts,ptr+12); } else if (strncmp(ptr,"SETXATTR",8)==0) { status = do_setxattr(filename,lv,ts,ptr+8); } else if (strncmp(ptr,"SNAPSHOT",8)==0) { status = do_snapshot(filename,lv,ts,ptr+8); } else if (strncmp(ptr,"SYMLINK",7)==0) { status = do_symlink(filename,lv,ts,ptr+7); } else if (strncmp(ptr,"SESSION",7)==0) { status = do_session(filename,lv,ts,ptr+7); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'T': if (strncmp(ptr,"TRUNC",5)==0) { status = do_trunc(filename,lv,ts,ptr+5); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'U': if (strncmp(ptr,"UNLINK",6)==0) { status = do_unlink(filename,lv,ts,ptr+6); } else if (strncmp(ptr,"UNDEL",5)==0) { status = do_undel(filename,lv,ts,ptr+5); } else if (strncmp(ptr,"UNLOCK",6)==0) { status = do_unlock(filename,lv,ts,ptr+6); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; case 'W': if (strncmp(ptr,"WRITE",5)==0) { status = do_write(filename,lv,ts,ptr+5); } else { printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } break; default: printf("%s:%"PRIu64": unknown entry '%s'\n",filename,lv,ptr); } if (status>STATUS_OK) { printf("%s:%"PRIu64": error: %d (%s)\n",filename,lv,status,errormsgs[status]); } return status; }
void veh_interact::exec (game *gm, vehicle *v, int x, int y) { g = gm; veh = v; ex = x; ey = y; // x1 x2 // y1 ----+------+-- // | | // y2 ----+------+ // | // | winw1 = 12; winw2 = 35; winh1 = 3; winh2 = 12; winw12 = winw1 + winw2 + 1; winw3 = 80 - winw1 - winw2 - 2; winh3 = 25 - winh1 - winh2 - 2; winh23 = winh2 + winh3 + 1; winx1 = winw1; winx2 = winw1 + winw2 + 1; winy1 = winh1; winy2 = winh1 + winh2 + 1; page_size = winh23; // h w y x w_grid = newwin(25, 80, 0, 0); w_mode = newwin(1, 80, 0, 0); w_msg = newwin(winh1 - 1, 80, 1, 0); w_disp = newwin(winh2, winw1, winy1 + 1, 0); w_parts = newwin(winh2, winw2, winy1 + 1, winx1 + 1); w_stats = newwin(winh3, winw12, winy2 + 1, 0); w_list = newwin(winh23, winw3, winy1 + 1, winx2 + 1); for (int i = 0; i < 25; i++) { mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2? LINE_XOXX : LINE_XOXO); if (i >= winy1 && i < winy2) mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO); } for (int i = 0; i < 80; i++) { mvwputch(w_grid, winy1, i, c_ltgray, i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX)); if (i < winx2) mvwputch(w_grid, winy2, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX); } wrefresh(w_grid); crafting_inv = gm->crafting_inventory(); int charges = ((it_tool *) g->itypes["welder"])->charges_per_use; has_wrench = crafting_inv.has_amount("wrench", 1) || crafting_inv.has_amount("toolset", 1); has_hacksaw = crafting_inv.has_amount("hacksaw", 1) || crafting_inv.has_amount("toolset", 1); has_welder = (crafting_inv.has_amount("welder", 1) && crafting_inv.has_charges("welder", charges)) || (crafting_inv.has_amount("toolset", 1) && crafting_inv.has_charges("toolset", charges/5)); display_stats (); display_veh (); move_cursor (0, 0); bool finish = false; while (!finish) { char ch = input(); // See keypress.h int dx, dy; get_direction (gm, dx, dy, ch); if (ch == KEY_ESCAPE) finish = true; else if (dx != -2 && (dx || dy) && cx + dx >= -6 && cx + dx < 6 && cy + dy >= -6 && cy + dy < 6) move_cursor(dx, dy); else { int mval = cant_do(ch); display_mode (ch); switch (ch) { case 'i': do_install(mval); break; case 'r': do_repair(mval); break; case 'f': do_refill(mval); break; case 'o': do_remove(mval); break; case 'e': do_rename(mval); break; default:; } if (sel_cmd != ' ') finish = true; display_mode (' '); } } werase(w_grid); werase(w_mode); werase(w_msg); werase(w_disp); werase(w_parts); werase(w_stats); werase(w_list); delwin(w_grid); delwin(w_mode); delwin(w_msg); delwin(w_disp); delwin(w_parts); delwin(w_stats); delwin(w_list); erase(); }
/** * Creates a veh_interact window based on the given parameters. * @param v The vehicle the player is interacting with. * @param x The x-coordinate of the square the player is 'e'xamining. * @param y The y-coordinate of the square the player is 'e'xamining. */ void veh_interact::exec (game *gm, vehicle *v, int x, int y) { g = gm; veh = v; // x1 x2 // y1 ----+------+-- // | | // y2 ----+------+ // | // | winw1 = 12; winw2 = 35; winh1 = 3; winh2 = 12; winw12 = winw1 + winw2 + 1; winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 2; winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2; winh23 = winh2 + winh3 + 1; winx1 = winw1; winx2 = winw1 + winw2 + 1; winy1 = winh1; winy2 = winh1 + winh2 + 1; // changed FALSE value to 1, to keep w_border from starting at a negative x,y const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 1; const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 1; page_size = winh23; // h w y x WINDOW *w_border= newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, -1 + iOffsetY, -1 + iOffsetX); w_grid = newwin(FULL_SCREEN_HEIGHT -2, FULL_SCREEN_WIDTH-2, iOffsetY, iOffsetX); w_mode = newwin(1, FULL_SCREEN_WIDTH-2, iOffsetY, iOffsetX); w_msg = newwin(winh1 - 1, FULL_SCREEN_WIDTH-2, 1 + iOffsetY, iOffsetX); w_disp = newwin(winh2-1, winw1, winy1 + 1 + iOffsetY, iOffsetX); w_parts = newwin(winh2-1, winw2, winy1 + 1 + iOffsetY, winx1 + 1 + iOffsetX); w_stats = newwin(winh3-1, winw12, winy2 + iOffsetY, iOffsetX); w_list = newwin(winh23, winw3, winy1 + 1 + iOffsetY, winx2 + 1 + iOffsetX); wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); mvwputch(w_border, 16, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, 4, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, 4, FULL_SCREEN_WIDTH-1, c_ltgray, LINE_XOXX); // -| mvwputch(w_border, 24, 49, c_ltgray, LINE_XXOX); wrefresh(w_border); for (int i = 0; i < FULL_SCREEN_HEIGHT; i++) { mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2-1? LINE_XOXX : LINE_XOXO); if (i >= winy1 && i < winy2) { mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO); } } for (int i = 0; i < FULL_SCREEN_WIDTH; i++) { mvwputch(w_grid, winy1, i, c_ltgray, i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX)); if (i < winx2) { mvwputch(w_grid, winy2-1, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX); } } wrefresh(w_grid); crafting_inv = gm->crafting_inventory(&gm->u); int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use; int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use; has_wrench = crafting_inv.has_amount("wrench", 1) || crafting_inv.has_amount("toolset", 1); has_hacksaw = crafting_inv.has_amount("hacksaw", 1) || crafting_inv.has_amount("toolset", 1); has_welder = (crafting_inv.has_amount("welder", 1) && crafting_inv.has_charges("welder", charges)) || (crafting_inv.has_amount("welder_crude", 1) && crafting_inv.has_charges("welder_crude", charges_crude)) || (crafting_inv.has_amount("toolset", 1) && crafting_inv.has_charges("toolset", charges/20)); has_jack = crafting_inv.has_amount("jack", 1); has_siphon = crafting_inv.has_amount("hose", 1); has_wheel = crafting_inv.has_amount( "wheel", 1 ) || crafting_inv.has_amount( "wheel_wide", 1 ) || crafting_inv.has_amount( "wheel_bicycle", 1 ) || crafting_inv.has_amount( "wheel_motorbike", 1 ) || crafting_inv.has_amount( "wheel_small", 1 ); display_stats (); display_veh (); move_cursor (0, 0); bool finish = false; while (!finish) { char ch = input(); // See keypress.h int dx, dy; get_direction (dx, dy, ch); if (ch == KEY_ESCAPE || ch == 'q' ) { finish = true; } else { if (dx != -2 && (dx || dy) && cursor_x + dx >= -6 && cursor_x + dx < 6 && cursor_y + dy >= -6 && cursor_y + dy < 6) { move_cursor(dx, dy); } else { int mval = cant_do(ch); display_mode (ch); switch (ch) { case 'i': do_install(mval); break; case 'r': do_repair(mval); break; case 'f': do_refill(mval); break; case 'o': do_remove(mval); break; case 'e': do_rename(mval); break; case 's': do_siphon(mval); break; case 'c': do_tirechange(mval); break; case 'd': do_drain(mval); break; } if (sel_cmd != ' ') { finish = true; } display_mode (' '); } } } werase(w_grid); werase(w_mode); werase(w_msg); werase(w_disp); werase(w_parts); werase(w_stats); werase(w_list); delwin(w_grid); delwin(w_mode); delwin(w_msg); delwin(w_disp); delwin(w_parts); delwin(w_stats); delwin(w_list); erase(); }
int replay(const char *log_data) { uint64_t fv,lv; //fv = filesystem's version lv = log's version uint32_t ts; uint8_t status; char buff[10000]; char *ptr; char* errormsgs[]={ ERROR_STRINGS }; char *test_ptr; sprintf(buff,"%s",log_data); ptr = buff; //for test test_ptr = buff; fv = shadow_fs_getversion(); GETU64(lv,ptr); if(lv < fv) { MFSLOG(LOG_ERR,"the changelog's verison %lu is smaller than filesystem's version %lu",lv,fv); //more complicated method to ensure consistency } else { status = ERROR_MISMATCH; EAT(ptr,lv,':'); EAT(ptr,lv,' '); GETU32(ts,ptr); EAT(ptr,lv,'|'); switch (*ptr) { case 'A': if (strncmp(ptr,"ACCESS",6)==0) { status = do_access(lv,ts,ptr+6); } else if (strncmp(ptr,"ATTR",4)==0) { status = do_attr(lv,ts,ptr+4); } else if (strncmp(ptr,"APPEND",6)==0) { status = do_append(lv,ts,ptr+6); } else if (strncmp(ptr,"AQUIRE",6)==0) { status = do_aquire(lv,ts,ptr+6); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'C': if (strncmp(ptr,"CREATE",6)==0) { status = do_create(lv,ts,ptr+6); } else if (strncmp(ptr,"CUSTOMER",8)==0) { // deprecated status = do_session(lv,ts,ptr+8); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'E': if (strncmp(ptr,"EMPTYTRASH",10)==0) { status = do_emptytrash(lv,ts,ptr+10); } else if (strncmp(ptr,"EMPTYRESERVED",13)==0) { status = do_emptyreserved(lv,ts,ptr+13); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'F': if (strncmp(ptr,"FREEINODES",10)==0) { status = do_freeinodes(lv,ts,ptr+10); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'I': if (strncmp(ptr,"INCVERSION",10)==0) { status = do_incversion(lv,ts,ptr+10); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'L': if (strncmp(ptr,"LENGTH",6)==0) { status = do_length(lv,ts,ptr+6); } else if (strncmp(ptr,"LINK",4)==0) { status = do_link(lv,ts,ptr+4); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'M': if (strncmp(ptr,"MOVE",4)==0) { status = do_move(lv,ts,ptr+4); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'P': if (strncmp(ptr,"PURGE",5)==0) { status = do_purge(lv,ts,ptr+5); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'R': if (strncmp(ptr,"RELEASE",7)==0) { status = do_release(lv,ts,ptr+7); } else if (strncmp(ptr,"REPAIR",6)==0) { status = do_repair(lv,ts,ptr+6); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'S': if (strncmp(ptr,"SETEATTR",8)==0) { status = do_seteattr(lv,ts,ptr+8); } else if (strncmp(ptr,"SETGOAL",7)==0) { status = do_setgoal(lv,ts,ptr+7); } else if (strncmp(ptr,"SETPATH",7)==0) { status = do_setpath(lv,ts,ptr+7); } else if (strncmp(ptr,"SETTRASHTIME",12)==0) { status = do_settrashtime(lv,ts,ptr+12); } else if (strncmp(ptr,"SNAPSHOT",8)==0) { status = do_snapshot(lv,ts,ptr+8); } else if (strncmp(ptr,"SYMLINK",7)==0) { status = do_symlink(lv,ts,ptr+7); } else if (strncmp(ptr,"SESSION",7)==0) { status = do_session(lv,ts,ptr+7); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'T': if (strncmp(ptr,"TRUNC",5)==0) { status = do_trunc(lv,ts,ptr+5); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'U': if (strncmp(ptr,"UNLINK",6)==0) { status = do_unlink(lv,ts,ptr+6); } else if (strncmp(ptr,"UNDEL",5)==0) { status = do_undel(lv,ts,ptr+5); } else if (strncmp(ptr,"UNLOCK",6)==0) { status = do_unlock(lv,ts,ptr+6); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'W': if (strncmp(ptr,"WRITE",5)==0) { status = do_write(lv,ts,ptr+5); } else { MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; default: MFSLOG(LOG_ERR,"%"PRIu64": unknown entry '%s'",lv,ptr); } /** * if master is down, slave switch, we may missed some metadata * return 0 to let the process continue, otherwise, we will reply the * log forever. * * Dongyang, Zhang */ if (status!=STATUS_OK) { MFSLOG(LOG_ERR,"%"PRIu64": error: %"PRIu8" (%s),the log is (%s)",lv,status,errormsgs[status],test_ptr); // syslog(LOG_ERR,"%"PRIu64": error: %"PRIu8" (%s)",lv,status,errormsgs[status]); return 1; } fv = shadow_fs_getversion(); if (lv+1!=fv) { MFSLOG(LOG_ERR,"%"PRIu64": version mismatch fsversion:%"PRIu64"",lv,fv); return 1; } } return 0; }
int restore(void) { FILE *fd; char buff[10000]; char *ptr; uint64_t v,lv; uint32_t ts; uint8_t status; uint32_t dplen; char *datapath = NULL; char *logpath = NULL; char* errormsgs[]={ ERROR_STRINGS }; v = shadow_fs_getversion(); lv = 0; MFSLOG(LOG_NOTICE,"meta data version: %"PRIu64"",v); datapath = strdup(DATA_PATH); dplen = strlen(datapath); logpath = malloc(dplen+sizeof("/changelog.0.mfs")); memcpy(logpath,datapath,dplen); memcpy(logpath+dplen,"/changelog.0.mfs",sizeof("/changelog.0.mfs")); fd = fopen(logpath,"r"); if (fd==NULL) { MFSLOG(LOG_NOTICE,"can't open changemeta file: %s",logpath); return 1; } while (fgets(buff,10000,fd)) { ptr = buff; GETU64(lv,ptr); if (lv<v) { // skip } else { status = ERROR_MISMATCH; EAT(ptr,lv,':'); EAT(ptr,lv,' '); GETU32(ts,ptr); EAT(ptr,lv,'|'); switch (*ptr) { case 'A': if (strncmp(ptr,"ACCESS",6)==0) { status = do_access(lv,ts,ptr+6); } else if (strncmp(ptr,"ATTR",4)==0) { status = do_attr(lv,ts,ptr+4); } else if (strncmp(ptr,"APPEND",6)==0) { status = do_append(lv,ts,ptr+6); } else if (strncmp(ptr,"AQUIRE",6)==0) { status = do_aquire(lv,ts,ptr+6); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'C': if (strncmp(ptr,"CREATE",6)==0) { status = do_create(lv,ts,ptr+6); } else if (strncmp(ptr,"CUSTOMER",8)==0) { // deprecated status = do_session(lv,ts,ptr+8); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'E': if (strncmp(ptr,"EMPTYTRASH",10)==0) { status = do_emptytrash(lv,ts,ptr+10); } else if (strncmp(ptr,"EMPTYRESERVED",13)==0) { status = do_emptyreserved(lv,ts,ptr+13); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'F': if (strncmp(ptr,"FREEINODES",10)==0) { status = do_freeinodes(lv,ts,ptr+10); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'I': if (strncmp(ptr,"INCVERSION",10)==0) { status = do_incversion(lv,ts,ptr+10); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'L': if (strncmp(ptr,"LENGTH",6)==0) { status = do_length(lv,ts,ptr+6); } else if (strncmp(ptr,"LINK",4)==0) { status = do_link(lv,ts,ptr+4); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'M': if (strncmp(ptr,"MOVE",4)==0) { status = do_move(lv,ts,ptr+4); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'P': if (strncmp(ptr,"PURGE",5)==0) { status = do_purge(lv,ts,ptr+5); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'R': if (strncmp(ptr,"RELEASE",7)==0) { status = do_release(lv,ts,ptr+7); } else if (strncmp(ptr,"REPAIR",6)==0) { status = do_repair(lv,ts,ptr+6); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'S': if (strncmp(ptr,"SETEATTR",8)==0) { status = do_seteattr(lv,ts,ptr+8); } else if (strncmp(ptr,"SETGOAL",7)==0) { status = do_setgoal(lv,ts,ptr+7); } else if (strncmp(ptr,"SETPATH",7)==0) { status = do_setpath(lv,ts,ptr+7); } else if (strncmp(ptr,"SETTRASHTIME",12)==0) { status = do_settrashtime(lv,ts,ptr+12); } else if (strncmp(ptr,"SNAPSHOT",8)==0) { status = do_snapshot(lv,ts,ptr+8); } else if (strncmp(ptr,"SYMLINK",7)==0) { status = do_symlink(lv,ts,ptr+7); } else if (strncmp(ptr,"SESSION",7)==0) { status = do_session(lv,ts,ptr+7); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'T': if (strncmp(ptr,"TRUNC",5)==0) { status = do_trunc(lv,ts,ptr+5); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'U': if (strncmp(ptr,"UNLINK",6)==0) { status = do_unlink(lv,ts,ptr+6); } else if (strncmp(ptr,"UNDEL",5)==0) { status = do_undel(lv,ts,ptr+5); } else if (strncmp(ptr,"UNLOCK",6)==0) { status = do_unlock(lv,ts,ptr+6); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; case 'W': if (strncmp(ptr,"WRITE",5)==0) { status = do_write(lv,ts,ptr+5); } else { MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } break; default: MFSLOG(LOG_NOTICE,"%"PRIu64": unknown entry '%s'",lv,ptr); } /** * let the restore continue if we missed some meta data, otherwise the * * Dongyang Zhang */ if (status!=STATUS_OK) { MFSLOG(LOG_ERR,"%"PRIu64": error: %"PRIu8" (%s)",lv,status,errormsgs[status]); return 1; } v = shadow_fs_getversion(); if (lv+1!=v) { MFSLOG(LOG_ERR,"%"PRIu64": version mismatch",lv); return 1; } } } fclose(fd); MFSLOG(LOG_NOTICE,"version after applying changelog: %"PRIu64"",v); return 0; }
/** * Creates a veh_interact window based on the given parameters. * @param v The vehicle the player is interacting with. * @param x The x-coordinate of the square the player is 'e'xamining. * @param y The y-coordinate of the square the player is 'e'xamining. */ void veh_interact::exec (game *gm, vehicle *v, int x, int y) { veh = v; // winw1 winw2 winw3 // winh1 | | // ------+-------+------ // winh2 | | // ------+-------+------ // winh3 | | // // +-------------------------+ // | w_mode | // | w_msg | // +-------+---------+-------+ // |w_disp | w_parts | w_list| // +-------+---------+-------+ // | w_stats | // +-------------------------+ int winw1 = 12; int winw2 = 35; int winh1 = 3; int winh2 = 13; int winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 4; int winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2; int winx1 = winw1; int winx2 = winw1 + winw2 + 1; int winy1 = winh1; int winy2 = winh1 + winh2 + 1; mode_h = 1; mode_w = FULL_SCREEN_WIDTH - 2; msg_h = winh1 - 1; msg_w = FULL_SCREEN_WIDTH - 2; disp_h = winh2 - 1; disp_w = winw1; parts_h = winh2 - 1; parts_w = winw2; stats_h = winh3 - 1; stats_w = FULL_SCREEN_WIDTH - 2; list_h = winh2 - 1; list_w = winw3; const int iOffsetX = 1 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0); const int iOffsetY = 1 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0); page_size = list_h; // h w y x WINDOW *w_border = newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, -1 + iOffsetY, -1 + iOffsetX ); w_grid = newwin( FULL_SCREEN_HEIGHT - 2, FULL_SCREEN_WIDTH - 2, iOffsetY, iOffsetX ); w_mode = newwin( mode_h, mode_w, iOffsetY, iOffsetX ); w_msg = newwin( msg_h, msg_w, mode_h + iOffsetY, iOffsetX ); w_disp = newwin( disp_h, disp_w, mode_h + msg_h + 1 + iOffsetY, iOffsetX ); w_parts = newwin( parts_h, parts_w, mode_h + msg_h + 1 + iOffsetY, disp_w + 1 + iOffsetX ); w_list = newwin( list_h, list_w, mode_h + msg_h + 1 + iOffsetY, disp_w + 1 + parts_w + 1 + iOffsetX ); w_stats = newwin( stats_h, stats_w, mode_h + msg_h + 1 + disp_h + 1 + iOffsetY, iOffsetX ); wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, mode_h + msg_h + 1, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX); mvwputch(w_border, mode_h + msg_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX); wrefresh(w_border); // Two lines dividing the three middle sections. for (int i = winy1; i < winy2; i++) { mvwputch(w_grid, i, winx2, c_ltgray, LINE_XOXO); mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO); } // Two lines dividing the vertical menu sections. for (int i = 0; i < FULL_SCREEN_WIDTH; i++) { mvwputch( w_grid, winy1, i, c_ltgray, LINE_OXOX ); mvwputch( w_grid, winy2-1, i, c_ltgray, LINE_OXOX ); } // Fix up the line intersections. mvwputch( w_grid, winy1, winx1, c_ltgray, LINE_OXXX ); mvwputch( w_grid, winy1, winx2, c_ltgray, LINE_OXXX ); mvwputch( w_grid, winy2 - 1, winx1, c_ltgray, LINE_XXOX ); mvwputch( w_grid, winy2 - 1, winx2, c_ltgray, LINE_XXOX ); wrefresh(w_grid); crafting_inv = g->crafting_inventory(&g->u); int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use; int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use; has_wrench = crafting_inv.has_amount("wrench", 1) || crafting_inv.has_amount("toolset", 1); has_hacksaw = crafting_inv.has_amount("hacksaw", 1) || crafting_inv.has_amount("toolset", 1); has_welder = (crafting_inv.has_amount("welder", 1) && crafting_inv.has_charges("welder", charges)) || (crafting_inv.has_amount("welder_crude", 1) && crafting_inv.has_charges("welder_crude", charges_crude)) || (crafting_inv.has_amount("toolset", 1) && crafting_inv.has_charges("toolset", charges/20)); has_jack = crafting_inv.has_amount("jack", 1); has_siphon = crafting_inv.has_amount("hose", 1); has_wheel = crafting_inv.has_amount( "wheel", 1 ) || crafting_inv.has_amount( "wheel_wide", 1 ) || crafting_inv.has_amount( "wheel_bicycle", 1 ) || crafting_inv.has_amount( "wheel_motorbike", 1 ) || crafting_inv.has_amount( "wheel_small", 1 ); display_stats (); display_veh (); move_cursor (0, 0); bool finish = false; while (!finish) { char ch = input(); // See keypress.h int dx, dy; get_direction (dx, dy, ch); if (ch == KEY_ESCAPE || ch == 'q' ) { finish = true; } else { if (dx != -2 && (dx || dy) && cursor_x + dx >= -6 && cursor_x + dx < 6 && cursor_y + dy >= -6 && cursor_y + dy < 6) { move_cursor(dx, dy); } else { int mval = cant_do(ch); display_mode (ch); switch (ch) { case 'i': do_install(mval); break; case 'r': do_repair(mval); break; case 'f': do_refill(mval); break; case 'o': do_remove(mval); break; case 'e': do_rename(mval); break; case 's': do_siphon(mval); break; case 'c': do_tirechange(mval); break; case 'd': do_drain(mval); break; } if (sel_cmd != ' ') { finish = true; } display_mode (' '); } } } werase(w_grid); werase(w_mode); werase(w_msg); werase(w_disp); werase(w_parts); werase(w_stats); werase(w_list); delwin(w_grid); delwin(w_mode); delwin(w_msg); delwin(w_disp); delwin(w_parts); delwin(w_stats); delwin(w_list); erase(); }
void rmove() { register struct player *j; register int i; register int burst; register int numHits, tDir; int avDir; extern struct Enemy *get_nearest(); struct Enemy *enemy_buf; struct player *enemy = NULL; static int roboclock = 0; static int avoid[2] = { -32, 32 }; int no_cloak; char towhom[MSG_LEN]; int timer; static int lastTorpped = 0; /* when we last fired a torp 4/13/92 TC */ roboclock++; /* keep ghostbuster away */ me->p_ghostbuster = 0; /* Check that I'm alive */ if (me->p_status == PEXPLODE) { if (debug) ERROR(1,("Robot: Augh! exploding.\n")); return; } else if (me->p_status == PDEAD) { if (me->p_ntorp > 0) return; if (debug) ERROR(1,("Robot: done exploding and torps are gone.\n")); exitRobot(); return; } timer=0; for (i = 0, j = &players[i]; i < (MAXPLAYER - TESTERS); i++, j++) { if ((j->p_status != PFREE) && !(j->p_flags & PFROBOT)) timer=1; } if (!timer && !sticky) { exitRobot(); return; } /* if I'm a Terminator, quit if he quits, and quit if he dies and */ /* I'm not "sticky" (-s) */ if (target >= 0) { if (players[target].p_status == PFREE) { /* he went away */ me->p_status = PEXPLODE; return; } if ((!sticky) && (players[target].p_status != PALIVE)) { /* he died */ me->p_status = PEXPLODE; return; } } /* If it's been BOREDOM_TIME updates since we fired a torp, become hostile to all races, if we aren't already, and if we're not a practice robot (intended for guardian bots). 4/13/92 TC */ if ((roboclock - lastTorpped > BOREDOM_TIME) && (!practice) && (!hostile) && (me->p_team != 0 && !quiet)) { messAll(me->p_no,roboname,"I'm bored."); hostile++; declare_war(ALLTEAM, 0); } /* Our first priority is to phaser plasma torps in nearby vicinity... */ /* If we fire, we aren't allowed to cloak... */ no_cloak = phaser_plasmas(); /* Find an enemy */ enemy_buf = get_nearest(); if ((enemy_buf != NULL) && (enemy_buf != NOENEMY)) { /* Someone to kill */ enemy = &players[enemy_buf->e_info]; if (((random() % messfuse) == 0) && (hypot((double) me->p_x-enemy->p_x, (double) me->p_y-enemy->p_y) < 20000.0)) { /* change 5/10/21 TC ...neut robots don't message */ messfuse = MESSFUSEVAL; if (me->p_team != 0 && !quiet) { sprintf(towhom, " %s->%s", players[me->p_no].p_mapchars, players[enemy->p_no].p_mapchars); pmessage2(enemy->p_no, MINDIV, towhom, me->p_no, "%s", robo_message(enemy)); } else if (target >= 0 && !quiet) { messAll(me->p_no,roboname,"%s",termie_message(enemy)); } } else if (--messfuse == 0) messfuse = 1; timer = 0; /* if (debug) ERROR(1,( "%d) noticed %d\n", me->p_no, enemy_buf->e_info));*/ } else if (enemy_buf == NOENEMY) { /* no more players. wait 1 minute. */ if (do_repair()) { return; } go_home(0); /* if (debug) ERROR(1,( "%d) No players in game.\n", me->p_no));*/ return; } else if (enemy_buf == 0) { /* no one hostile */ /* if (debug) ERROR(1,( "%d) No hostile players in game.\n", me->p_no));*/ if (do_repair()) { return; } go_home(0); timer = 0; return; } /* Note a bug in this algorithm: ** Once someone dies, he is forgotten. This makes robots particularly easy ** to kill on a suicide run, where you aim to where you think he will turn ** as you die. Once dead, the robot will ignore you and all of your ** active torpedoes! **/ /* Algorithm: ** We have an enemy. ** First priority: shoot at target in range. ** Second: Dodge torps and plasma torps. ** Third: Get away if we are damaged. ** Fourth: repair. ** Fifth: attack. */ /* ** If we are a practice robot, we will do all but the second. One ** will be modified to shoot poorly and not use phasers. **/ /* Fire weapons!!! */ /* ** get_nearest() has already determined if torpedoes and phasers ** will hit. It has also determined the courses which torps and ** phasers should be fired. If so we will go ahead and shoot here. ** We will lose repair and cloaking for the rest of this interrupt. ** if we fire here. */ if (practice) { no_cloak = 1; if (enemy_buf->e_flags & E_TSHOT) { /* if (debug) ERROR(1,( "%d) firing torps\n", me->p_no));*/ for (burst = 0; (burst < 3) && (me->p_ntorp < MAXTORP); burst++) { ntorp(enemy_buf->e_tcourse, TWOBBLE | TOWNERSAFE | TDETTEAMSAFE | TPRACTICE); } } } else { if (enemy_buf->e_flags & E_TSHOT) { /* if (debug) ERROR(1,( "%d) firing torps\n", me->p_no));*/ for (burst = 0; (burst < 2) && (me->p_ntorp < MAXTORP); burst++) { repair_off(); if (! cloaker) cloak_off(); ntorp(enemy_buf->e_tcourse, TWOBBLE | TOWNERSAFE | TDETTEAMSAFE); no_cloak++; lastTorpped = roboclock; /* record time of firing 4/13/92 TC */ } } if (enemy_buf->e_flags & E_PSHOT) { /* if (debug) ERROR(1,( "%d) phaser firing\n", me->p_no));*/ no_cloak++; repair_off(); if (! cloaker) cloak_off(); phaser(enemy_buf->e_course); } } /* auto pressor 7/27/91 TC */ /* tractor/pressor rewritten on 5/1/92... glitches galore :-| TC */ /* whoa, too close for comfort, or he's tractoring me, or headed in for me, or I'm hurt */ /* a little tuning -- 0.8 on phrange and +/- 90 degrees in for pressor */ /* pressor_player(-1); this didn't do anything before, so we'll let the pressors disengage by themselves 5/1/92 TC */ if (enemy_buf->e_flags & E_TRACT) { /* if pressorable */ if (((enemy_buf->e_dist < 0.8 * enemy_buf->e_phrange) && (angdist(enemy_buf->e_edir, enemy_buf->e_course) > 64)) || (isTractoringMe(enemy_buf)) || (me->p_damage > 0)) { if (!(enemy->p_flags & PFCLOAK)) { if (debug) ERROR(1,( "%d) pressoring %d\n", me->p_no, enemy_buf->e_info)); pressor_player(enemy->p_no); no_cloak++; repair_off(); if (!cloaker) cloak_off(); } } } /* auto tractor 7/31/91 TC */ /* tractor if not pressoring and... */ /* tractor if: in range, not too close, and not headed +/- 90 degrees */ /* of me, and I'm not hurt */ if ((!(me->p_flags & PFPRESS)) && (enemy_buf->e_flags & E_TRACT) && (angdist(enemy_buf->e_edir, enemy_buf->e_course) < 64) && (enemy_buf->e_dist > 0.7 * enemy_buf->e_phrange)) { if (!(me->p_flags & PFTRACT)) { if (debug) ERROR(1,( "%d) tractoring %d\n", me->p_no, enemy_buf->e_info)); tractor_player(enemy->p_no); no_cloak++; } } else tractor_player(-1); /* otherwise don't tractor */ /* Avoid torps */ /* ** This section of code allows robots to avoid torps. ** Within a specific range they will check to see if ** any of the 'closest' enemies torps will hit them. ** If so, they will evade for four updates. ** Evading is all they will do for this round, other than shooting. */ if (!practice) { if ((enemy->p_ntorp < 5)) { if ((enemy_buf->e_dist < 15000) || (avoidTime > 0)) { numHits = projectDamage(enemy->p_no, &avDir); if (debug) { ERROR(1,( "%d hits expected from %d from dir = %d\n", numHits, enemy->p_no, avDir)); } if (numHits == 0) { if (--avoidTime > 0) { /* we may still be avoiding */ if (angdist(me->p_desdir, me->p_dir) > 64) me->p_desspeed = dogslow; else me->p_desspeed = dogfast; return; } } else { /* * Actually avoid Torps */ avoidTime = AVOID_TIME; tDir = avDir - me->p_dir; /* put into 0->255 range */ tDir = NORMALIZE(tDir); if (debug) ERROR(1,( "mydir = %d avDir = %d tDir = %d q = %d\n", me->p_dir, avDir, tDir, tDir / 64)); switch (tDir / 64) { case 0: case 1: set_course(NORMALIZE(avDir + 64)); break; case 2: case 3: set_course(NORMALIZE(avDir - 64)); break; } if (!no_cloak) cloak_on(); if (angdist(me->p_desdir, me->p_dir) > 64) me->p_desspeed = dogslow; else me->p_desspeed = dogfast; shield_up(); detothers(); /* hmm */ if (debug) ERROR(1,( "evading to dir = %d\n", me->p_desdir)); return; } } } /* ** Trying another scheme. ** Robot will keep track of the number of torps a player has ** launched. If they are greater than say four, the robot will ** veer off immediately. Seems more humanlike to me. */ else if (enemy_buf->e_dist < 15000) { if (--avoidTime > 0) { /* we may still be avoiding */ if (angdist(me->p_desdir, me->p_dir) > 64) me->p_desspeed = dogslow; else me->p_desspeed = dogfast; return; } if (random() % 2) { me->p_desdir = NORMALIZE(enemy_buf->e_course - 64); avoidTime = AVOID_TIME; } else { me->p_desdir = NORMALIZE(enemy_buf->e_course + 64); avoidTime = AVOID_TIME; } if (angdist(me->p_desdir, me->p_dir) > 64) me->p_desspeed = dogslow; else me->p_desspeed = dogfast; shield_up(); return; } } /* Run away */ /* ** The robot has taken damage. He will now attempt to run away from ** the closest player. This obviously won't do him any good if there ** is another player in the direction he wants to go. ** Note that the robot will not run away if he dodged torps, above. ** The robot will lower his shields in hopes of repairing some damage. */ #define STARTDELTA 5000 /* ships appear +/- delta of home planet */ if (me->p_damage > 0 && enemy_buf->e_dist < 13000) { if (me->p_etemp > 900) /* 90% of 1000 */ me->p_desspeed = runslow; else me->p_desspeed = runfast; if (!no_cloak) cloak_on(); repair_off(); shield_down(); set_course(enemy_buf->e_course - 128); if (debug) ERROR(1,( "%d(%d)(%d/%d) running from %c%d %16s damage (%d/%d) dist %d\n", me->p_no, (int) me->p_kills, me->p_damage, me->p_shield, teamlet[enemy->p_team], enemy->p_no, enemy->p_login, enemy->p_damage, enemy->p_shield, enemy_buf->e_dist)); return; } /* Repair if necessary (we are safe) */ /* ** The robot is safely away from players. It can now repair in peace. ** It will try to do so now. */ if (do_repair()) { return; } /* Attack. */ /* ** The robot has nothing to do. It will check and see if the nearest ** enemy fits any of its criterion for attack. If it does, the robot ** will speed in and deliver a punishing blow. (Well, maybe) */ if ((enemy_buf->e_flags & E_INTRUDER) || (enemy_buf->e_dist < 15000) || (hostile)) { if ((!no_cloak) && (enemy_buf->e_dist < 10000)) cloak_on(); shield_up(); /* if (debug) ERROR(1,( "%d(%d)(%d/%d) attacking %c%d %16s damage (%d/%d) dist %d\n", me->p_no, (int) me->p_kills, me->p_damage, me->p_shield, teamlet[enemy->p_team], enemy->p_no, enemy->p_login, enemy->p_damage, enemy->p_shield, enemy_buf->e_dist));*/ if (enemy_buf->e_dist < 15000) { set_course(enemy_buf->e_course + avoid[(roboclock / AVOID_CLICKS) % SIZEOF(avoid)]); if (angdist(me->p_desdir, me->p_dir) > 64) set_speed(closeslow); else set_speed(closefast); } else { me->p_desdir = enemy_buf->e_course; if (angdist(me->p_desdir, me->p_dir) > 64) set_speed(closeslow); if (target >= 0) /* 7/27/91 TC */ set_speed(12); else if (me->p_etemp > 900) /* 90% of 1000 */ set_speed(runslow); else set_speed(runfast); } } else { go_home(enemy_buf); } }
void doship(shiptype *ship, int update) { racetype *Race; shiptype *ship2; /*ship is active */ ship->active = 1; if(!ship->owner) ship->alive = 0; if (ship->alive) { /* repair radiation */ if (ship->rad) { ship->active = 1; /* irradiated ships are immobile.. */ /* kill off some people */ /* check to see if ship is active */ if(success(ship->rad)) ship->active = 0; if(update) { ship->popn = round_rand(ship->popn * .80); ship->troops = round_rand(ship->troops * .80); if (ship->rad >= (int)REPAIR_RATE) ship->rad -= int_rand(0,(int)REPAIR_RATE); else ship->rad -= int_rand(0,(int)ship->rad); } } else ship->active = 1; if(!ship->popn && Max_crew(ship) && !ship->docked) ship->whatdest = LEVEL_UNIV; if (ship->whatorbits != LEVEL_UNIV && Stars[ship->storbits]->nova_stage>0) { /* damage ships from supernovae */ /* Maarten: modified to take into account MOVES_PER_UPDATE */ ship->damage += 5 * Stars[ship->storbits]->nova_stage / ((Armor(ship)+1) * segments); if (ship->damage >= 100) { kill_ship((int)(ship->owner), ship); return; } } if(ship->type==OTYPE_FACTORY && !ship->on) { Race = races[ship->owner-1]; ship->tech = Race->tech; } if(ship->active) Moveship(ship, update, 1, 0); ship->size = ship_size(ship); /* for debugging */ if(ship->whatorbits==LEVEL_SHIP) { (void)getship(&ship2, (int)ship->destshipno); if(ship2->owner != ship->owner) { ship2->owner = ship->owner; ship2->governor = ship->governor; putship(ship2); } free(ship2); /* just making sure */ } else if(ship->whatorbits != LEVEL_UNIV && (ship->popn || ship->type == OTYPE_PROBE)) { /* Though I have often used TWCs for exploring, I don't think it is right */ /* to be able to map out worlds with this type of junk. Either a manned ship, */ /* or a probe, which is designed for this kind of work. Maarten */ StarsInhab[ship->storbits] = 1; setbit(Stars[ship->storbits]->inhabited, ship->owner); setbit(Stars[ship->storbits]->explored, ship->owner); if(ship->whatorbits == LEVEL_PLAN) { planets[ship->storbits][ship->pnumorbits]->info[ship->owner-1].explored = 1; } } /* add ships, popn to total count to add AP's */ if(update) { Power[ship->owner-1].ships_owned++; Power[ship->owner-1].resource += ship->resource; Power[ship->owner-1].fuel += ship->fuel; Power[ship->owner-1].destruct += ship->destruct; Power[ship->owner-1].popn += ship->popn; Power[ship->owner-1].troops += ship->troops; } if (ship->whatorbits==LEVEL_UNIV) { Sdatanumships[ship->owner-1]++; Sdatapopns[ship->owner] += ship->popn; } else { starnumships[ship->storbits][ship->owner-1]++; /* add popn of ships to popn */ starpopns[ship->storbits][ship->owner-1] += ship->popn; /* set inhabited for ship */ /* only if manned or probe. Maarten */ if (ship->popn || ship->type==OTYPE_PROBE) { StarsInhab[ship->storbits] = 1; setbit(Stars[ship->storbits]->inhabited, ship->owner); setbit(Stars[ship->storbits]->explored, ship->owner); } } if (ship->active) { /* bombard the planet */ if (can_bombard(ship) && ship->bombard && ship->whatorbits==LEVEL_PLAN && ship->whatdest==LEVEL_PLAN && ship->deststar== ship->storbits && ship->destpnum== ship->pnumorbits) { /* ship bombards planet */ Stinfo[ship->storbits][ship->pnumorbits].inhab = 1; } /* repair ship by the amount of crew it has */ /* industrial complexes can repair (robot ships and offline factories can't repair) */ if(ship->damage && Repair(ship)) do_repair(ship); if(update) switch (ship->type) { /* do this stuff during updates only*/ case OTYPE_CANIST: do_canister(ship); break; case OTYPE_GREEN: do_greenhouse(ship); break; case STYPE_MIRROR: do_mirror(ship); break; case STYPE_GOD: do_god(ship); break; case OTYPE_AP: do_ap(ship); break; case OTYPE_VN: /* Von Neumann machine */ case OTYPE_BERS: if(!ship->special.mind.progenitor) ship->special.mind.progenitor = 1; do_VN(ship); break; case STYPE_OAP: do_oap(ship); break; case STYPE_HABITAT: do_habitat(ship); break; default: break; } if(ship->type==STYPE_POD) do_pod(ship); } } }