static void import_items(ICalImporterData *icidata) { ESource *source; g_return_if_fail (icidata != NULL); source = e_source_selector_peek_primary_selection ((ESourceSelector *)icidata->selector); g_return_if_fail ( source != NULL); icidata->client = auth_new_cal_from_source (source, icidata->source_type); e_cal_open (icidata->client, FALSE, NULL); switch (icidata->source_type) { case E_CAL_SOURCE_TYPE_EVENT: prepare_events (icidata->icalcomp, NULL); if (!update_objects (icidata->client, icidata->icalcomp)) /* FIXME: e_error ... */; break; case E_CAL_SOURCE_TYPE_TODO: prepare_tasks (icidata->icalcomp, NULL); if (!update_objects (icidata->client, icidata->icalcomp)) /* FIXME: e_error ... */; break; default: g_assert_not_reached (); } ical_import_done (icidata); }
static gboolean ivcal_import_items (gpointer d) { ICalImporter *ici = d; switch (ici->source_type) { case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: prepare_events (ici->icalcomp, NULL); update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici); break; case E_CAL_CLIENT_SOURCE_TYPE_TASKS: prepare_tasks (ici->icalcomp, NULL); update_objects (ici->cal_client, ici->icalcomp, ici->cancellable, ivcal_call_import_done, ici); break; default: g_warn_if_reached (); ici->idle_id = 0; ivcal_import_done (ici); return FALSE; } ici->idle_id = 0; return FALSE; }
void setfilename(char *fname) { char *t,*text; text = &windforms[WIND_CTRL].formtree[CTRL_FILENAME].ob_spec. tedinfo->te_ptext[6]; strncpy(text, fname, 8); text[8] = '\0'; if((t=strchr(text, '.')) != NULL) *t = '\0'; update_objects(&windforms[WIND_CTRL],CTRL_FNAME_BOX,0,0); update_objects(&windforms[WIND_CTRL],CTRL_FILENAME,0,0); }
int event_exitportal(EVENT_DATA *event) { CHAR_DATA *ch = event->owner.ch; OBJECT_DATA *obj = event->victim.obj; int args[3]; args[0] = event->args[0]; /* newx */ args[1] = event->args[1]; /* newy */ args[2] = event->args[2]; /* newplane */ destroy_all_events(ch, EVENT_EXITPORTAL); ch->x = args[0]; ch->y = args[1]; ch->plane = args[2]; update_objects(ch); act("\nYou jump out of $v and look around.\n", ch, obj, TO_ACTOR + TYPE_ACT_CHAR + TYPE_VIC_OBJ, SENSE_SIGHT); act("$a jumps out of $v.", ch, obj, TO_NOTACTVIC + TYPE_ACT_CHAR + TYPE_VIC_OBJ, SENSE_SIGHT); do_look(ch, ""); if (ch->level == LEVEL_MORTAL && (args[2] == PLANE_NEXUS || args[2] == PLANE_HNEXUS)) { send_to_char(ch, "#R+#r------------------------------------------------------------------------#R+\n"); send_to_char(ch, "#r| #RWARNING:#Y This plane is meant for characters of greater power than you. #r|\n"); send_to_char(ch, "#r| #YWe recommend that you return to the newbie plane by typing #CENTER BLUE#Y. #r|\n"); send_to_char(ch, "#R+#r------------------------------------------------------------------------#R+\n"); } return 1; }
static void gc_import_events (ECalClient *cal_client, const GError *error, ICalIntelligentImporter *ici) { g_return_if_fail (ici != NULL); if (error != NULL) { g_warning ( "%s: Failed to open events calendar: %s", G_STRFUNC, error->message); if (ici->tasks) open_default_source ( ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks); else e_import_complete (ici->ei, ici->target); return; } e_import_status (ici->ei, ici->target, _("Importing..."), 0); update_objects ( cal_client, ici->icalcomp, ici->cancellable, ici->tasks ? continue_tasks_cb : continue_done_cb, ici); }
void RemoteServerProxyUpdater::handle_objects(GameInitMessage *message) { if (!new_level_) { update_objects(message); } else { create_objects(message); new_level_ = false; } }
obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum) { int found = NOTHING; zone_rnum rznum = real_zone_by_thing(ovnum); /* * Write object to internal tables. */ if ((newobj->item_number = real_object(ovnum)) != NOTHING) { copy_object(&obj_proto[newobj->item_number], newobj); update_objects(&obj_proto[newobj->item_number]); add_to_save_list(zone_table[rznum].number, SL_OBJ); return newobj->item_number; } found = insert_object(newobj, ovnum); adjust_objects(found); add_to_save_list(zone_table[rznum].number, SL_OBJ); return (found); }
/* process_sync_request After the RPC thread recieves a sync response from the server we update the object information in the maze, the broken walls in the maze and the players in the game parameter: maze pointer to the client's local copy of the maze parameter: ch handle to a Proto_Client parameter: hdr pointer to hdr that contains unmarshalled data return: int return code */ int process_sync_request(Maze* maze, Proto_Client_Handle ch, Proto_Msg_Hdr* hdr) { // Variable Declaration int* broken_walls_compress; int* player_compress; int* object_compress; int offset; //Get number of elements for walls and players int num_walls = hdr->pstate.v2.raw; int num_players = hdr->pstate.v3.raw; //Malloc the variables broken_walls_compress = (int*) malloc(num_walls*sizeof(int)); player_compress = (int*) malloc(num_players*sizeof(int)); object_compress = (int*) malloc(4*sizeof(int)); //Get the data from the body of the message offset = 0; offset = get_compress_from_body(ch, offset, num_walls, broken_walls_compress); offset = get_compress_from_body(ch, offset, num_players, player_compress); offset = get_compress_from_body(ch, offset, 4, object_compress); PixelUpdate pu; //null pointer to get the below to work update_objects(4,object_compress,maze, &pu); update_walls(num_walls,broken_walls_compress,maze, &pu); update_players(num_players,player_compress,maze, &pu); //De-allocate the malloced variables free(broken_walls_compress); free(player_compress); free(object_compress); if(proto_debug()) { } return hdr->gstate.v0.raw; }
void toggle_object(WINDFORM *wind,int obj_id,int mode) { if((mode==SET_NORMAL) || ((mode==TOGGLE) && (wind->formtree[obj_id].ob_state & SELECTED))) { objc_change(wind->formtree,obj_id,0,wind->form.x, wind->form.y,wind->form.w,wind->form.h, NORMAL,0); wind->formtree[wind->formtree[obj_id].ob_head].ob_x--; wind->formtree[wind->formtree[obj_id].ob_head].ob_y--; } else if((mode==SET_SELECTED) || ((mode==TOGGLE) && !(wind->formtree[obj_id].ob_state & SELECTED))) { objc_change(wind->formtree,obj_id,0,wind->form.x, wind->form.y,wind->form.w,wind->form.h, SELECTED,0); wind->formtree[wind->formtree[obj_id].ob_head].ob_x++; wind->formtree[wind->formtree[obj_id].ob_head].ob_y++; } update_objects(wind,obj_id,1,0); }
static void gc_import_tasks (ECalClient *cal_client, const GError *error, ICalIntelligentImporter *ici) { g_return_if_fail (ici != NULL); if (error != NULL) { g_warning ( "%s: Failed to open tasks: %s", G_STRFUNC, error->message); e_import_complete (ici->ei, ici->target); return; } e_import_status (ici->ei, ici->target, _("Importing..."), 0); prepare_tasks (ici->icalcomp, ici->tasks); update_objects ( cal_client, ici->icalcomp, ici->cancellable, continue_done_cb, ici); }
int handle_message(int pipe[8]) { static int first_open=0; int wnr,error; /* ,avmsg[8]; */ char *vamsg,*o; #ifdef DEBUG char tmp[128]; #endif switch (pipe[0]) { case AC_OPEN: if (pipe[4] == acc_id) { if(first_open) { if(windforms[WIND_CTRL].wind_open) wind_set(windforms[WIND_CTRL].whandle,WF_TOP); else fgbg=FG; } else { fg_init(&windforms[WIND_CTRL]); fgbg=FG; first_open=1; } } #ifdef DEBUG form_alert(1,"[1][Got AC_OPEN][Ok]"); #endif break; case AC_CLOSE: /* if (pipe[4] == acc_id) */ { #ifdef DEBUG sprintf(tmp,"[1][Got AC_CLOSE|ACC id: %d|pipe4: %d][Ok]",acc_id,pipe[4]); form_alert(1,tmp); #endif if(windforms[WIND_CTRL].wind_open) { wind_close(windforms[WIND_CTRL].whandle); wind_delete(windforms[WIND_CTRL].whandle); windforms[WIND_CTRL].wind_open=0; } if(windforms[WIND_INFO].wind_open) { wind_close(windforms[WIND_INFO].whandle); wind_delete(windforms[WIND_INFO].whandle); windforms[WIND_INFO].wind_open=0; } #ifdef DEBUG sprintf(tmp,"[1][Filepos: %ld][Ok]",filepos); form_alert(1,tmp); #endif file_was_open=file_open; if(file_open) close_file(fd); closed_acc=1; return 1; } /* break; */ case AP_TERM: quit=1; return 1; /* switch(pipe[5]) { case AP_RESCHG: printf("Got AP_RESCHG!\n"); break; case AP_TERM: printf("Got AP_TERM!"); break; default: printf("Got unknown AP_TERM!"); } */ /* break; */ case RESCHG_COMPLETED: /* printf("Got RESCHG_COMPLETED!"); */ break; case WM_REDRAW: if((wnr=find_windform(pipe[3]))>=0) update_objects(&windforms[wnr],windforms[wnr].firstobj, windforms[wnr].objdepth,pipe); break; case WM_MOVED: if((wnr=find_windform(pipe[3]))>=0) { wind_set(windforms[wnr].whandle,WF_CURRXYWH,pipe[4],pipe[5],pipe[6],pipe[7]); windforms[wnr].wind.x=pipe[4]; windforms[wnr].wind.y=pipe[5]; windforms[wnr].wind.w=pipe[6]; windforms[wnr].wind.h=pipe[7]; wind_calc(WC_WORK,windforms[wnr].windkind, windforms[wnr].wind.x,windforms[wnr].wind.y, windforms[wnr].wind.w,windforms[wnr].wind.h, &windforms[wnr].form.x,&windforms[wnr].form.y, &windforms[wnr].form.w,&windforms[wnr].form.h); windforms[wnr].formtree[windforms[wnr].firstobj].ob_x=windforms[wnr].form.x; windforms[wnr].formtree[windforms[wnr].firstobj].ob_y=windforms[wnr].form.y; windforms[wnr].formtree[windforms[wnr].firstobj].ob_width=windforms[wnr].form.w; windforms[wnr].formtree[windforms[wnr].firstobj].ob_height=windforms[wnr].form.h; if(replay) update_time(); } break; case WM_CLOSED: if((wnr=find_windform(pipe[3]))>=0) { wind_close(windforms[wnr].whandle); windforms[wnr].wind_open=0; if(wnr==WIND_CTRL) { if(windforms[WIND_INFO].wind_open) { wind_close(windforms[WIND_INFO].whandle); windforms[WIND_INFO].wind_open=0; } return 1; } else wind_delete(windforms[wnr].whandle); } break; case WM_TOPPED: if((wnr=find_windform(pipe[3]))>=0) wind_set(pipe[3],WF_TOP); break; case AP_DRAGDROP: if(wind_find(pipe[4],pipe[5]) == windforms[WIND_CTRL].whandle) { if(do_dragdrop(pipe,DD_OK)) { exit_replay(); if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); replay_pause=0; filepos=0; fd=reopen_file(); filesize=Fseek(0L,fd,2); Fseek(0L,fd,0); if((error=getmp2info(fd))==MP2_NOERR) { update_time(); setfilename(filename); if(!(pipe[6] & K_ALT)) init_replay(); } else { exit_replay(); show_mp2_error(error); close_file(fd); strcpy(windforms[WIND_CTRL].wind_title,"MPEG"); wind_set(windforms[WIND_CTRL].whandle,WF_NAME, windforms[WIND_CTRL].wind_title); setfilename("MPEGFILE"); } } } else { do_dragdrop(pipe,DD_NAK); } break; case VA_START: vamsg=*((char **)&pipe[3]); strcpy(path,vamsg); /* This *should* be sent to the application which sent the VA_START msg, but it seems to hang Thing doing it. */ /* avmsg[0]=AV_STARTED; avmsg[1]=app_id; avmsg[2]=0; avmsg[3]=pipe[3]; avmsg[4]=pipe[4]; appl_write(pipe[1],5*2,avmsg); */ if((o=strchr(path,' '))!=NULL) o[0]='\0'; o=strrchr(path,'\\'); strcpy(filename,&o[1]); o=strrchr(path,'\\'); strncpy(o,"\\*.MP?",6); o[6] = '\0'; exit_replay(); if(windforms[WIND_CTRL].formtree[CTRL_FF].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_FF,SET_NORMAL); Dsp_Hf1(0); if(windforms[WIND_CTRL].formtree[CTRL_PAUSE].ob_state & SELECTED) toggle_object(&windforms[WIND_CTRL],CTRL_PAUSE,SET_NORMAL); replay_pause=0; filepos=0; fd=reopen_file(); filesize=Fseek(0L,fd,2); Fseek(0L,fd,0); if((error=getmp2info(fd))==MP2_NOERR) { update_time(); setfilename(filename); init_replay(); } else { exit_replay(); show_mp2_error(error); close_file(fd); strcpy(windforms[WIND_CTRL].wind_title,"MPEG"); wind_set(windforms[WIND_CTRL].whandle,WF_NAME, windforms[WIND_CTRL].wind_title); setfilename("MPEGFILE"); } break; default: #ifdef DEBUG sprintf(tmp,"[1][Unimplemented| message: %d][Ok]",pipe[0]); form_alert(1,tmp); #endif break; } return 0; }
int ev2_loop(WINDFORM *wind,int mx,int my) { int x,y,kstate,key,clicks,event,state,org_state; int obj_id,ev2exit,fgexit=0; int pipe[8]; CORDS t; if((obj_id=objc_find(wind->formtree,CTRL_FIRST,1,mx,my))>=0) { if(wind->formtree[obj_id].ob_flags & SELECTABLE) { org_state=wind->formtree[obj_id].ob_state & SELECTED; toggle_object(wind,obj_id,TOGGLE); objc_offset(wind->formtree,obj_id,&t.x,&t.y); t.w=wind->formtree[obj_id].ob_width; t.h=wind->formtree[obj_id].ob_height; ev2exit=0; do { event = evnt_multi( MU_MESAG | MU_TIMER | MU_BUTTON | MU_M1 | MU_M2, 1, 0x1, 0x0, 0, t.x, t.y, t.w, t.h, 1, t.x, t.y, t.w, t.h, pipe, time_slice, 0, &x, &y, &state, &kstate, &key, &clicks ); if (event & MU_TIMER) if (replay) { if(first_init) checkhang(); load(1); update_time(); } if (event & MU_MESAG) fgexit=handle_message(pipe); if (event & MU_M1) /* Enter area */ { if(org_state==(wind->formtree[obj_id].ob_state & SELECTED)) toggle_object(wind,obj_id,TOGGLE); } if (event & MU_M2) /* Leave area */ { if(org_state!=(wind->formtree[obj_id].ob_state & SELECTED)) toggle_object(wind,obj_id,TOGGLE); } if (event & MU_BUTTON) { if(obj_id==objc_find(wind->formtree,CTRL_FIRST,1,x,y)) { if(wind->formtree[obj_id].ob_flags & KEEPSELECT) { if(org_state && (wind->formtree[obj_id].ob_state & SELECTED)) toggle_object(wind,obj_id,SET_NORMAL); if(!org_state && !(wind->formtree[obj_id].ob_state & SELECTED)) toggle_object(wind,obj_id,SET_SELECTED); } else if(wind->formtree[obj_id].ob_state & SELECTED) toggle_object(wind,obj_id,SET_NORMAL); fgexit=do_formstuff(obj_id); } else { objc_change(wind->formtree,obj_id,0,wind->form.x, wind->form.y,wind->form.w,wind->form.h,org_state,0); update_objects(wind,obj_id,1,0); } ev2exit=1; } } while (((replay || fgbg==FG) && !fgexit) && !ev2exit); event=0; return 1; } } return 0; }
void test_update_objects_from_compress(TestContext* tc) { int assertion; int red_flag_compress,blue_flag_compress,red_shovel_compress,blue_shovel_compress; PixelUpdate pu; //Create maze Maze maze; maze_build_from_file(&maze,"test.map"); //Initialize a dummy object Object* red_flag = object_get(&maze,OBJECT_FLAG,TEAM_RED); Object* blue_flag = object_get(&maze,OBJECT_FLAG,TEAM_BLUE); Object* red_shovel = object_get(&maze,OBJECT_SHOVEL,TEAM_RED); Object* blue_shovel = object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE); //Position of each object somewhere on the map red_flag->cell = &maze.get[50][27]; blue_flag->cell = &maze.get[99][20]; red_shovel->cell = &maze.get[34][53]; blue_shovel->cell = &maze.get[79][22]; //Compress Object compress_object(red_flag,&red_flag_compress); compress_object(blue_flag,&blue_flag_compress); compress_object(red_shovel,&red_shovel_compress); compress_object(blue_shovel,&blue_shovel_compress); //Update Maze based on compressed object update_objects(1,&red_flag_compress,&maze,&pu); update_objects(1,&blue_flag_compress,&maze,&pu); update_objects(1,&red_shovel_compress,&maze,&pu); update_objects(1,&blue_shovel_compress,&maze,&pu); //Check if pointer to object from object list points to same object from the cell it occupies assertion = (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.x == 50) && (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.y == 27); should("correctly update (50,27): RED FLAG",assertion,tc); assertion = (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.x == 99) && (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.y == 20); should("correctly update (99,20): BLUE FLAG",assertion,tc); assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.x == 34) && (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.y == 53); should("correctly update (34,53): RED SHOVEL",assertion,tc); assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.x == 79) && (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.y == 22); should("correctly update (79,22): BLUE SHOVEL",assertion,tc); //Position of each object somewhere on the map red_flag->cell = &maze.get[11][22]; blue_flag->cell = &maze.get[52][61]; red_shovel->cell = &maze.get[20][16]; blue_shovel->cell = &maze.get[12][28]; //Compress Object compress_object(red_flag,&red_flag_compress); compress_object(blue_flag,&blue_flag_compress); compress_object(red_shovel,&red_shovel_compress); compress_object(blue_shovel,&blue_shovel_compress); //Update Maze based on compressed object update_objects(1,&red_flag_compress,&maze,&pu); update_objects(1,&blue_flag_compress,&maze,&pu); update_objects(1,&red_shovel_compress,&maze,&pu); update_objects(1,&blue_shovel_compress,&maze,&pu); //Check if pointer to object from object list points to same object from the cell it occupies assertion = (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.x == 11) && (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.y == 22); should("correctly update (11,22): RED FLAG",assertion,tc); assertion = (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.x == 52) && (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.y == 61); should("correctly update (52,61): BLUE FLAG",assertion,tc); assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.x == 20) && (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.y == 16); should("correctly update (20,16): RED SHOVEL",assertion,tc); assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.x == 12) && (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.y == 28); should("correctly update (12,28): BLUE SHOVEL",assertion,tc); }
int main ( int argc, char** argv ) { std::cout << "Starting\n"; initalize(); //TODO add resource load error handling add_surface("spaceb", load_surface("gray_space.png",1) ); add_surface("spacem", load_surface("gray_space.png",1) ); add_surface("spacef", load_surface("gray_space.png",1) ); for(int i=-2; i < 20+2; i++) meta::objects.push_back(new psrect_static(200*i, 200, 200, 200)); //meta::objects.push_back(new psrect_static(320, 20, 320, 20)); //meta::objects.push_back(new psrect_static(0, -400,1, 1000)); //meta::objects.push_back(new psrect_static(1000, -400, 1, 1000)); meta::objects.push_back(new rocket(2000,-100, 50,70)); //load_map("test.json"); float32 timeStep = 1.0f / 30.0f; int32 velocityIterations = 6; int32 positionIterations = 2; FPSmanager manager; SDL_initFramerate(&manager); SDL_setFramerate(&manager, 30); // program main loop bool done = false; while (!done) { SDL_framerateDelay(&manager); // message processing loop SDL_Event event; while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = true; break; // check for keypresses case SDL_KEYDOWN: // exit if ESCAPE is pressed if (event.key.keysym.sym == SDLK_ESCAPE) done = true; break; } // end switch } // end of message processing // DRAWING STARTS HERE // clear screen //SDL_FillRect(meta::screen, 0, SDL_MapRGB(meta::screen->format, 0, 0, 0 )); SDL_FillRect(meta::screen, 0, SDL_MapRGB(meta::screen->format, meta::background_red , meta::background_green, meta::background_blue )); draw_background(); // Instruct the world to perform a single step of simulation. // It is generally best to keep the time step and iterations fixed. meta::world.Step(timeStep, velocityIterations, positionIterations); update_objects(); meta::world.DrawDebugData(); // DRAWING ENDS HERE // finally, update the screen :) SDL_Flip(meta::screen); } // end main loop // all is well ;) printf("Exited cleanly\n"); return 0; }