static PyObject * python_orbresurrect( PyObject *self, PyObject *args ) { char *usage = "Usage: _orbresurrect(orb)\n"; int orbfd; Orb_relic *or; Relic relic; if( ! PyArg_ParseTuple( args, "i", &orbfd ) ) { if( ! PyErr_Occurred() ) { PyErr_SetString( PyExc_RuntimeError, usage ); } return NULL; } or = new_Orb_relic( orbfd ); relic.ip = &or->pktid; if( resurrect( or->pktid_relicname, relic, INT_RELIC ) == 0 ) { elog_notify( 0, "resurrected pktid %d\n", or->pktid ); } relic.dp = &or->pkttime; if( resurrect( or->pkttime_relicname, relic, DOUBLE_RELIC ) == 0 ) { elog_notify( 0, "resurrected pkttime %f\n", or->pkttime ); } return Py_BuildValue( "id", or->pktid, or->pkttime ); }
Player::Player(qreal p_x, qreal p_y, const QString& p_playerID, const PlayerSettings* p_playerSettings, Arena* p_arena) : Character(p_x, p_y, p_arena) , m_throwBomb(false) , m_kickBomb(false) { m_type = Granatier::Element::PLAYER; m_desktopFilePath = p_playerSettings->playerDesktopFilePath(p_playerID); m_graphicsFile = p_playerSettings->playerGraphicsFile(p_playerID); m_playerName = p_playerSettings->playerName(p_playerID); m_points = 0; m_direction = Granatier::Direction::EAST; m_badBonusCountdownTimer = new QTimer; m_badBonusCountdownTimer->setInterval(badBonusTimerTimeout); m_badBonusMillisecondsToElapse = 0; connect(m_badBonusCountdownTimer, &QTimer::timeout, this, &Player::slot_badBonusTimerTimeout); resurrect(); m_key.moveLeft = p_playerSettings->keyLeft(p_playerID); m_key.moveRight = p_playerSettings->keyRight(p_playerID); m_key.moveUp = p_playerSettings->keyUp(p_playerID); m_key.moveDown = p_playerSettings->keyDown(p_playerID); m_key.dropBomb = p_playerSettings->keyPutBomb(p_playerID); }
// figure out what the user wants to do! int body() { char c; while(1) { color = 0x01 + (running->pid % NPROC); // change the text color based on the process id! printf("\n******************************\n"); printf("Currently Running Process #%d", running->pid); printf("\nReady Queue: "); printQueue(readyQueue); printf("******************************\n"); printf("Input a command [s | q | f | r | ?]:"); c = getc(); printf("\n"); switch (c) { case 's': tswitch(); break; case 'q': zombify(); break; case 'f': kfork(); break; case 'r': resurrect(); break; case '?': help(); break; default: break; } } }
// ----------------------------------------------------------------------- // handle the resurrection spell // ----------------------------------------------------------------------- bool t_resurrection_spell::left_click( t_screen_point const& point ) { t_map_point_2d map_point; t_combat_creature_list creatures; bool defender = get_caster()->belongs_to_defender(); creatures = get_targets( point ); if (creatures.empty()) return false; eliminate_duplicates( creatures ); if (creatures.size() == 1) { resurrect( creatures.front().get() ); return true; } t_combat_creature_list::iterator index; t_combat_creature_ptr creature; t_handler handler; t_window* window = t_window::get_modal_window(); m_menu = new t_scroll_menu( window ); for (index = creatures.begin(); index != creatures.end(); index++) { creature = *index; handler = add_argument( bound_handler( *this, &t_resurrection_spell::resurrect ), creature ); m_menu->add_item( get_text( creature ), handler ); } m_menu->open( get_mouse_position( window ) ); m_battlefield.get_window()->set_help_balloon_text( "" ); return true; }
void Player::doDyingAnimation() { // explosion frame //m_currentFrame = 7 + int(((SDL_GetTicks() / (1000/ 10)) % m_numFrames)); m_currentFrame = int(((SDL_GetTicks() / (1000/ 10)) % m_numFrames)); if (m_dyingCounter == m_dyingTime) // dying finished { m_bDying = false; m_dyingCounter = 0; resurrect(); } m_dyingCounter++; }
int main(int argc, char **argv) { double modified_after =now() , last_lddate, last_mtime, mtime; char *orbname = NULL; char *dbname = NULL; int orb; int naptime = -1, check_lddate_interval = -1; Dbptr db, dbt, dbs; char *prefix = NULL; struct stat filestat; int i; Tbl *tablenames, *tables_containing_dfile, *check_tables = NULL, *ignore_tables = NULL; long table_present, recc, is_view; char *tablename, *schemaname; char *filename; int counter = 0, force_check = 0; char expr[512]; char *statefilename = NULL, *pfname = "dbnew2orb"; Pf *pf = NULL; void *priv_dfile = (void *) NULL; void *private = (void *) NULL; int pmsi; /* poor man's string index, replacment for * searchtbl... */ char *pmsp; double lastburytime; Relic relic; char *s; Expression *expr_lddate; double *mtimes; double *lddates; elog_init(argc, argv); if (argc < 2) { usage(); exit(1); } for (argc--, argv++; argc > 0; argc--, argv++) { if (!strcmp(*argv, "-modified_after")) { argc--; argv++; if (argc < 1) { complain(0, "Need -modified_after argument.\n"); usage(); exit(1); } modified_after = str2epoch(*argv); } else if (!strcmp(*argv, "-prefix")) { argc--; argv++; if (argc < 1) { complain(0, "Need -prefix argument.\n"); usage(); exit(1); } prefix = *argv; } else if (!strcmp(*argv, "-pf")) { argc--; argv++; if (argc < 1) { complain(0, "Need -pf argument.\n"); usage(); exit(1); } pfname = *argv; } else if (!strcmp(*argv, "-state")) { argc--; argv++; if (argc < 1) { complain(0, "Need -state argument.\n"); usage(); exit(1); } statefilename = *argv; } else if (!strcmp(*argv, "-sleep")) { argc--; argv++; if (argc < 1) { complain(0, "Need -sleep argument.\n"); usage(); exit(1); } naptime = atoi(*argv); } else if (!strcmp(*argv, "-check_lddate_interval")) { argc--; argv++; if (argc < 1) { complain(0, "Need -check_lddate_interval argument.\n"); usage(); exit(1); } check_lddate_interval = atoi(*argv); } else if (!strcmp(*argv, "-v")) { verbose++; } else if (**argv != '-') { break; } else { complain(0, "Unrecognized argument '%s'.\n", *argv); usage(); exit(1); } } if (pfread(pfname, &pf)) { elog_die(0, "parse_pf: pfread('%s') error.\n", pfname); } if (check_lddate_interval < 1) { if (parse_param(pf, "check_lddate_interval", P_LINT, 1, &check_lddate_interval) < 0) { elog_die(1, "parse_pf: sleep check_lddate_interval needed!\n"); } else { if (check_lddate_interval < 0) { check_lddate_interval = 1; } } } if (naptime < 1) { if (parse_param(pf, "sleep", P_LINT, 1, &naptime) < 0) { elog_die(1, "parse_pf: sleep value needed!\n"); } else { if (naptime < 0) { naptime = 1; } } } if (!prefix) { if (parse_param(pf, "prefix", P_STR, 0, &prefix) < 0) { printf("NO PREFIX!\n"); prefix = NULL; } } parse_param(pf, "check_tables", P_TBL, 0, &check_tables); if (check_tables) { if (maxtbl(check_tables) < 1) { freetbl(check_tables, 0); check_tables = NULL; } } parse_param(pf, "ignore_tables", P_TBL, 0, &ignore_tables); if (ignore_tables) { if (maxtbl(ignore_tables) < 1) { freetbl(ignore_tables, 0); ignore_tables = NULL; } } /* * no good here, would erase the table above pffree(pf); */ if (argc < 1) { complain(0, "Need db argument.\n"); usage(); exit(1); } dbname = *argv; argc--; argv++; if (argc < 1) { complain(0, "Need orb argument.\n"); usage(); exit(1); } orbname = *argv; argc--; argv++; if (argc > 0) { complain(0, "Unrecognized argument '%s'.\n", *argv); usage(); exit(1); } if (dbopen(dbname, "r", &db) < 0) { elog_complain(0, "Can't open database"); exit(1); } dbquery(db, dbSCHEMA_NAME, &schemaname); orb = orbopen(orbname, "w&"); if (orb < 0) { elog_die(0, "orbopen(%s) error\n", orbname); } /* * prepare for later call to dbquery(dbFIELD_TABLES) to find only * tables containing lddate */ /* * dbtables is much better, does not require the existence of table * origin dbf = dblookup(db, 0, "origin", "lddate", "dbNULL"); * dbquery(dbf, dbFIELD_TABLES, &tablenames); */ dbex_compile(db, "max(lddate)", &expr_lddate, dbTIME); tablenames = dbtables(db, "lddate"); tables_containing_dfile = dbtables(db, "dfile"); /* waste a few bytes... */ ntables = maxtbl(tablenames); mtimes = malloc(ntables * sizeof(double)); lddates = malloc(ntables * sizeof(double)); bury_times = malloc(ntables * sizeof(double)); static_flags = malloc(ntables * sizeof(long)); if (statefilename) { if (exhume(statefilename, &Stop, 10, mortician)) { elog_notify(0, "read old state file\n"); } else { elog_complain(0, "could not read old statefile\n"); } } for (i = 0; i < ntables; i++) { /* * mtimes[i] = modified_after; lddates[i] = modified_after; */ static_flags[i] = NEW_TABLE; } for (;;) { tablenames = dbtables(db, "lddate"); for (i = 0; i < ntables; i++) { tablename = gettbl(tablenames, i); if (!tablename) { continue; } dbt = dblookup(db, 0, tablename, 0, 0); dbquery(dbt, dbTABLE_PRESENT, &table_present); if (!table_present) { continue; } dbquery(dbt, dbTABLE_IS_VIEW, &is_view); if (is_view) { continue; } /* lastid is not a good idea (my personal choice)... */ if (strcmp(tablename, "lastid") == 0) { continue; } /* remove after Dan fixed the bug with remark */ if (strcmp(tablename, "remark") == 0) { continue; } if (findtbl(tablename, tables_containing_dfile)) { continue; } if (check_tables) { if (!findtbl(tablename,check_tables)) { if (verbose > 1 && static_flags[i]==NEW_TABLE) elog_notify(0,"ignoring table %s because it's NOT in 'check_tables'\n",tablename); continue; } } if (ignore_tables) { if (findtbl(tablename,ignore_tables)) { if (verbose > 1 && static_flags[i]==NEW_TABLE) elog_notify(0,"ignoring table %s because it's in 'ignore_tables'\n",tablename); continue; } } dbquery(dbt, dbRECORD_COUNT, &recc); if (recc < 1) { continue; } if (statefilename) { if (static_flags[i] == NEW_TABLE) { relic.dp = &bury_times[i]; if (resurrect(tablename, relic, TIME_RELIC) == 0) { mtimes[i] = bury_times[i]; lddates[i] = bury_times[i]; if (verbose > 1) { elog_notify(0, "resurrection successful: check %s after %s\n", tablename, s = strtime(bury_times[i])); free(s); } } else { bury_times[i] = modified_after; mtimes[i] = modified_after; lddates[i] = modified_after; if (verbose > 1) { elog_notify(0, "resurrection unsuccessful: check %s after %s\n", tablename, s = strtime(modified_after)); free(s); } } static_flags[i] = TABLE_SEEN; } } else { if (static_flags[i] == NEW_TABLE) { bury_times[i] = modified_after; mtimes[i] = modified_after; lddates[i] = modified_after; static_flags[i] = TABLE_SEEN; } } dbquery(dbt, dbTABLE_FILENAME, &filename); if (stat(filename, &filestat) < 0) { elog_die(1, "stat(%s) error.\n", filename); } last_mtime = mtimes[i]; last_lddate = lddates[i]; mtime = filestat.st_mtime; /* * the whole mtime stuff is not soo good: mtime is * typically > lddate, so setting modified_after to * mtime will certainly ignore the last value. To get * everything, I will have to keep 2 arrays: mtimes * to detect file modifications and lddates to get * the actual entries... */ if (force_check || mtime > last_mtime) { sprintf(expr, "lddate > %f", last_lddate); dbs = dbsubset(dbt, expr, 0); dbquery(dbs, dbRECORD_COUNT, &recc); if (recc > 0) { if (dbrows2orb(dbs, orb, prefix) == 0) { /* * dbex_evalstr(dbs, * "max(lddate)", dbTIME, * &lddates[i]); */ dbex_eval(dbs, expr_lddate, 0, &lddates[i]); mtimes[i] = mtime; bury_times[i] = lddates[i]; } } dbfree(dbs); } /* * a call to dbfree(dbt) would remove it from the * list of tablenames, all later calls to tablename * would return NIL... */ if (Stop) { bury(); return (0); } } sleep(naptime); if ((counter + 1) >= check_lddate_interval) { counter = 0; force_check = 1; } else { force_check = 0; counter++; } if (statefilename) { double nowtime; nowtime = now(); if (nowtime - lastburytime > 600.0) { lastburytime = nowtime; bury(); } } } }
void control(int b) { struct vector u; // Left button if (! map_mode) switch (selected_weapon) { case 0: if ((enable_mouse && button_read(SDL_BUTTON_LEFT)) || kread(gkeys[kc_fire].kc)) bot[b].but.canon=1; break; case 1: if ((enable_mouse && button_reset(SDL_BUTTON_LEFT)) || kreset(gkeys[kc_fire].kc)) bot[b].but.bomb=1; break; } else if ((enable_mouse && button_read(SDL_BUTTON_LEFT)) || kread(gkeys[kc_fire].kc)) { bot[b].u.x = ((xmouse-win_center_x)*(MAP_LEN/2)*TILE_LEN)/zoom+map_x*TILE_LEN; bot[b].u.y = ((win_center_y-ymouse)*(MAP_LEN/2)*TILE_LEN)/zoom+map_y*TILE_LEN; bot[b].u.z = z_ground(bot[b].u.x, bot[b].u.y, true); } // Right button if ((enable_mouse && button_reset(SDL_BUTTON_RIGHT)) || kreset(gkeys[kc_weapon].kc)) { if (abs(xmouse) < 2 && abs(ymouse) < 2) { if (! prompt_quit) prompt_quit = true; else quit_game = true; } selected_weapon ^= 1; } // Esc if (prompt_quit) { if (kreset(gkeys[kc_yes].kc)) quit_game = true; if (kreset(gkeys[kc_no].kc)) prompt_quit = false; } else if (kreset(gkeys[kc_esc].kc) && (bot[controlled_bot].camp!=-1 || !enable_resurrection || !resurrect())) { prompt_quit = true; } // Engine # define INCR .02 if (kread(gkeys[kc_motormore].kc) && bot[b].thrust <= 1.-INCR) bot[b].thrust += INCR; if (kread(gkeys[kc_motorless].kc) && bot[b].thrust >= INCR) bot[b].thrust -= INCR; # undef INCR // Views if (kreset(gkeys[kc_externview].kc)) { map_mode = false; view = next_external_view(view); snd_thrust=-1; } if (kreset(gkeys[kc_internview].kc)) { map_mode = false; if (view == VIEW_IN_PLANE) { view = VIEW_DOGFIGHT; } else { view = VIEW_IN_PLANE; snd_thrust=-1; } } if (kreset(gkeys[kc_travelview].kc)) { float zs; map_mode = false; view = VIEW_STANDING; copyv(&obj[0].pos,&obj[bot[viewed_bot].vion].rot.x); mulv(&obj[0].pos,300+drand48()*600+extcam_dist); copyv(&u,&obj[bot[viewed_bot].vion].rot.y); mulv(&u,(drand48()-.5)*600); addv(&obj[0].pos,&u); copyv(&u,&obj[bot[viewed_bot].vion].rot.z); mulv(&u,(drand48()-.5)*600); addv(&obj[0].pos,&u); addv(&obj[0].pos,&obj[bot[viewed_bot].vion].pos); if (obj[0].pos.z<(zs=z_ground(obj[0].pos.x,obj[0].pos.y, false)+100)) obj[0].pos.z=zs; snd_thrust=-1; } if (kreset(gkeys[kc_nextbot].kc)) { if (view == VIEW_ANYTHING_CHEAT) { if (++viewed_obj >= nb_obj) viewed_obj = 0; } else if (view == VIEW_DOGFIGHT) { next_dog_bot(); } else { do { if (++viewed_bot>=NBBOT) viewed_bot=0; } while (!enable_view_enemy && bot[viewed_bot].camp!=camp); // pas controlled_bot.camp car peut etre tue snd_thrust=-1; if (bot[viewed_bot].camp==-1) playsound(VOICE_MOTOR, SAMPLE_FEU, 1., &voices_in_my_head, true, true); } } if (kreset(gkeys[kc_prevbot].kc)) { if (view == VIEW_ANYTHING_CHEAT) { if (--viewed_obj<0) viewed_obj = nb_obj-1; } else if (view == VIEW_DOGFIGHT) { prev_dog_bot(); } else { do { if (--viewed_bot<0) viewed_bot=NBBOT-1; } while (!enable_view_enemy && bot[viewed_bot].camp!=camp); snd_thrust=-1; if (bot[viewed_bot].camp==-1) playsound(VOICE_MOTOR, SAMPLE_FEU, 1., &voices_in_my_head, true, true); } } if (kreset(gkeys[kc_mybot].kc)) { if (view != VIEW_DOGFIGHT) { viewed_bot = b; snd_thrust = -1; } else { float d; int DBi, DBm; next_dog_bot(); d=DogBotDist; DBi=DogBot; DBm=DogBot; do { next_dog_bot(); if (DogBotDist<d && bot[DogBot].camp!=bot[controlled_bot].camp) { d=DogBotDist; DBm=DogBot; } } while (DogBot!=DBi); DogBot=DBm; DogBotDist=d; } } if (!accelerated_mode || frame_count > 64) { if (kread(gkeys[kc_zoomout].kc)) { if (! map_mode) extcam_dist += 10.; else zoom += win_center_x/6; } if (kread(gkeys[kc_zoomin].kc)) { if (! map_mode && extcam_dist > 10.) extcam_dist -= 10.; else if ((zoom -= win_center_x/6) < win_center_x) zoom = win_center_x; } if (kread(gkeys[kc_riseview].kc)) { if (! map_mode) { if ((sight_teta -= .2) < -M_PI) sight_teta += 2*M_PI; } else if ((map_y += 1 + (3*win_width)/zoom) > MAP_LEN/2) { map_y = MAP_LEN/2; } } if (kread(gkeys[kc_lowerview].kc)) { if (! map_mode) { if ((sight_teta += .2) > M_PI) sight_teta -= 2*M_PI; } else if ((map_y -= 1 + (3*win_width)/zoom) < -MAP_LEN/2) { map_y = -MAP_LEN/2; } } if (kread(gkeys[kc_rightenview].kc)) { if (! map_mode) { if ((sight_phi -= .2) < -M_PI) sight_phi += 2*M_PI; } else if ((map_x += 1 + (3*win_width)/zoom) > MAP_LEN/2) { map_x = MAP_LEN/2; } } if (kread(gkeys[kc_leftenview].kc)) { if (! map_mode) { if ((sight_phi += .2) > M_PI) sight_phi -= 2*M_PI; } else if ((map_x -= 1 + (3*win_width)/zoom) < -MAP_LEN/2) { map_x = -MAP_LEN/2; } } } if (view != VIEW_DOGFIGHT) { if (kreset(gkeys[kc_towardview].kc)) { sight_teta = sight_phi = 0; } if (kreset(gkeys[kc_backview].kc)) { sight_teta = 0; sight_phi = M_PI; } if (kreset(gkeys[kc_leftview].kc)) { sight_teta = 0; sight_phi = M_PI*.5; } if (kreset(gkeys[kc_rightview].kc)) { sight_teta = 0; sight_phi = -M_PI*.5; } if (kreset(gkeys[kc_upview].kc)) { sight_teta = -M_PI/2; sight_phi = 0; } } else { view_predef = false; if (kread(gkeys[kc_towardview].kc)) { view_predef = true; sight_teta = sight_phi = 0; } if (kread(gkeys[kc_backview].kc)) { view_predef = true; sight_teta = 0; sight_phi = M_PI; } if (kread(gkeys[kc_leftview].kc)) { view_predef = true; sight_teta = 0; sight_phi = M_PI*.5; } if (kread(gkeys[kc_rightview].kc)) { view_predef = true; sight_teta = 0; sight_phi = -M_PI*.5; } if (kread(gkeys[kc_upview].kc)) { view_predef = true; sight_teta = -M_PI/2; sight_phi = 0; } if (! view_predef) sight_teta = sight_phi = 0; } view_instruments = kread(gkeys[kc_movetowardview].kc); // Commands if (kreset(gkeys[kc_gear].kc)) bot[b].but.gear^=1; if (kreset(gkeys[kc_flaps].kc)) { bot[b].but.flap^=1; playsound(VOICE_GEAR, SAMPLE_BIPBIP, 1., &obj[bot[b].vion].pos, false, false); } bot[b].but.brakes=kread(gkeys[kc_brakes].kc); if (kreset(gkeys[kc_business].kc)) bot[b].but.business = 1; if (kreset(gkeys[kc_autopilot].kc)) { autopilot = ! autopilot; playsound(VOICE_GEAR, SAMPLE_BIPBIP, 1., &obj[bot[b].vion].pos, false, false); if (autopilot) { bot[controlled_bot].target_speed = BEST_SPEED_FOR_CONTROL; bot[controlled_bot].target_rel_alt = 100. * ONE_METER; } } // Game control if (kreset(gkeys[kc_pause].kc)) { gtime_toggle(); game_paused = ! game_paused; } draw_high_scores = kread(gkeys[kc_highscores].kc); if (kreset(gkeys[kc_accelmode].kc)) { accelerated_mode = ! accelerated_mode; frame_count&=63; } if (kreset(gkeys[kc_basenav].kc)) { bot[b].u = obj[bot[b].babase].pos; } if (kreset(gkeys[kc_mapmode].kc)) { map_mode = ! map_mode; playsound(VOICE_GEAR, SAMPLE_BIPBIP3, 1., &voices_in_my_head, true, false); } if (kreset(gkeys[kc_suicide].kc) && bot[controlled_bot].camp!=-1) explode(bot[viewed_bot].vion, 0, "commited suicide"); if (kreset(gkeys[kc_markpos].kc)) bot[b].but.mark=1; // Cheats if (cheat_mode && kread(gkeys[kc_alti].kc)) { obj[bot[viewed_bot].vion].pos.z += 500; bot[viewed_bot].vionvit.z = 0; } if (cheat_mode && kreset(gkeys[kc_gunned].kc)) bot[viewed_bot].gunned=controlled_bot; if (!autopilot && !map_mode) { if (enable_mouse) { bot[b].xctl = ((xmouse-win_center_x)/(double)win_center_x); bot[b].yctl = ((ymouse-win_center_y)/(double)win_center_y); } else { int i=0; i=kread(gkeys[kc_left].kc); i+=kread(gkeys[kc_right].kc)<<1; i+=kread(gkeys[kc_down].kc)<<2; i+=kread(gkeys[kc_up].kc)<<3; if (i) { CtlSensActu += CtlSensitiv; if (i&1) bot[b].xctl-=CtlSensActu; if (i&2) bot[b].xctl+=CtlSensActu; if (i&4) bot[b].yctl-=CtlSensActu; if (i&8) bot[b].yctl+=CtlSensActu; } else CtlSensActu=0; if (bot[b].xctl<-1 || bot[b].xctl>1 || bot[b].yctl<-1 || bot[b].yctl>1) CtlSensActu=0; if (!(i&3)) bot[b].xctl*=CtlAmortis; if (!(i&12)) bot[b].yctl=CtlYequ+(bot[b].yctl-CtlYequ)*CtlAmortis; if (kread(gkeys[kc_center].kc)) { bot[b].xctl=0; bot[b].yctl=CtlYequ; if (kread(gkeys[kc_down].kc) && CtlYequ>-1) CtlYequ-=.02; if (kread(gkeys[kc_up].kc) && CtlYequ<1) CtlYequ+=.02; } } } else { // autopilot or map_mode if (autopilot) { robot_autopilot(b); } else { robot_safe(b, SAFE_LOW_ALT); } } CLAMP(bot[b].xctl, 1.); CLAMP(bot[b].yctl, 1.); }